Skip to content

Commit ec228a8

Browse files
committed
Merge pull request #3 from vishal22/master
First cut - JTicketing plugins needed for app
2 parents 8d4e856 + c962346 commit ec228a8

File tree

9 files changed

+883
-0
lines changed

9 files changed

+883
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
COM_JTICKETING_SELECT_GET_METHOD="Please use GET method."
2+
COM_JTICKETING_WRONG_METHOD_PUT="Put method not supported to this plugin."
3+
COM_JTICKETING_WRONG_METHOD_DEL="Delete method not supported to this plugin."
4+
COM_JTICKETING_INVALID_TICKET="Invalid ticket."
5+
COM_JTICKETING_INVALID_EVENT="Event not found."

jticketing/jticket.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* @package API plugins
4+
* @copyright Copyright (C) 2009 2014 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved.
5+
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
6+
* @link http://www.techjoomla.com
7+
*/
8+
9+
defined('_JEXEC') or die( 'Restricted access' );
10+
11+
jimport('joomla.plugin.plugin');
12+
13+
class plgAPIJticket extends ApiPlugin
14+
{
15+
public function __construct()
16+
{
17+
parent::__construct();
18+
// Load all required helpers.
19+
$component_path=JPATH_ROOT.DS.'components'.DS.'com_jticketing';
20+
if(!file_exists($component_path))
21+
{
22+
return;
23+
}
24+
25+
$jticketingmainhelperPath = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'main.php';
26+
27+
if (!class_exists('jticketingmainhelper'))
28+
{
29+
JLoader::register('jticketingmainhelper', $jticketingmainhelperPath );
30+
JLoader::load('jticketingmainhelper');
31+
}
32+
33+
$jticketingfrontendhelper = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'frontendhelper.php';
34+
35+
if (!class_exists('jticketingfrontendhelper'))
36+
{
37+
JLoader::register('jticketingfrontendhelper', $jticketingfrontendhelper );
38+
JLoader::load('jticketingfrontendhelper');
39+
}
40+
41+
$jteventHelperPath = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'event.php';
42+
43+
if (!class_exists('jteventHelper'))
44+
{
45+
JLoader::register('jteventHelper', $jteventHelperPath );
46+
JLoader::load('jteventHelper');
47+
}
48+
49+
ApiResource::addIncludePath(dirname(__FILE__).'/jticket');
50+
}
51+
}

jticketing/jticket.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<extension version="2.5.0" type="plugin" group="api" method="upgrade">
3+
<name>Api - Jticketing</name>
4+
<version>1.6</version>
5+
<creationDate>10/11/2014</creationDate>
6+
<author>Techjoomla</author>
7+
<authorEmail>extensions@techjoomla.com</authorEmail>
8+
<authorUrl>www.techjoomla.com</authorUrl>
9+
<copyright>Techjoomla. All rights reserved.</copyright>
10+
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
11+
<description>API plugins of Jticketing components of the Joomla! </description>
12+
13+
<files>
14+
<filename plugin="jticket">jticket.php</filename>
15+
<filename >jticket/checkin.php</filename>
16+
<folder>jticket</folder>
17+
</files>
18+
<languages>
19+
<language tag="en-GB">en-GB/en-GB.plg_api_jticket.ini</language>
20+
</languages>
21+
</extension>

jticketing/jticket/checkin.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
/**
3+
* @package API plugins
4+
* @copyright Copyright (C) 2009 2014 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved.
5+
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
6+
* @link http://www.techjoomla.com
7+
*/
8+
9+
defined('_JEXEC') or die;
10+
11+
jimport('joomla.plugin.plugin');
12+
13+
14+
class JticketApiResourceCheckin extends ApiResource
15+
{
16+
public function get()
17+
{
18+
jimport( 'joomla.application.component.helper' );
19+
$send_email_after_checkin=0;
20+
$com_params=JComponentHelper::getParams('com_jticketing');
21+
$send_email_after_checkin = $com_params->get('send_email_after_checkin');
22+
$jticketingmainhelper = new jticketingmainhelper();
23+
$lang =JFactory::getLanguage();
24+
$extension = 'com_jticketing';
25+
$base_dir = JPATH_SITE;
26+
$lang->load($extension, $base_dir);
27+
$ticketidstr = JRequest::getVar('ticketid',0);
28+
$eventid = JRequest::getVar('eventid',0);
29+
$eventintegrationid=$jticketingmainhelper->getEventrefid($eventid);
30+
31+
if(empty($ticketidstr))
32+
{
33+
$obj->success = 0;
34+
$obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
35+
$this->plugin->setResponse($obj);
36+
return;
37+
38+
39+
}
40+
41+
$ticketidarr=explode('-',$ticketidstr);
42+
$oid=$ticketidarr[0];
43+
$orderitemsid=$ticketidarr[1];
44+
$obj = new stdClass();
45+
46+
$result=$jticketingmainhelper->GetActualTicketidAPI($oid,$orderitemsid,'');
47+
$originalticketid=JText::_("TICKET_PREFIX").$ticketidstr;
48+
49+
if($result[0]->attendee_id)
50+
{
51+
$field_array=array('first_name','last_name');
52+
//Get Attendee Details
53+
$attendee_details=$jticketingmainhelper->getAttendees_details($result[0]->attendee_id,$field_array);
54+
}
55+
56+
if(!empty($attendee_details['first_name']))
57+
{
58+
$attendernm=implode(" ",$attendee_details);
59+
}
60+
else
61+
{
62+
$attendernm=$result[0]->name;
63+
}
64+
65+
if(empty($result))
66+
{
67+
$obj->success = 0;
68+
$obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
69+
70+
}
71+
else if($result[0]->eventid!=$eventintegrationid)
72+
{
73+
$obj->success = 0;
74+
$obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
75+
}
76+
else
77+
{
78+
$checkindone=$jticketingmainhelper->GetCheckinStatusAPI($orderitemsid);
79+
if($checkindone)
80+
{
81+
$obj->success = 0;
82+
if($attendernm)
83+
$obj->message =sprintf(JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE'),$attendernm);
84+
else
85+
$obj->message =JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE');
86+
87+
}
88+
else
89+
{
90+
91+
92+
$obj->success = $jticketingmainhelper->DoCheckinAPI($orderitemsid,$result);
93+
94+
if($obj->success)
95+
{
96+
$obj->success = 1;
97+
$ticketTypeData=$jticketingmainhelper->GetTicketTypes('',$result[0]->type_id);
98+
$app =JFactory::getApplication();
99+
$mailfrom = $app->getCfg('mailfrom');
100+
$fromname = $app->getCfg('fromname');
101+
$sitename = $app->getCfg('sitename');
102+
$message=JText::_("CHECKIN_MESSAGE");
103+
$message_subject=JText::_("CHECKIN_SUBJECT");
104+
$eventnm=$jticketingmainhelper->getEventTitle($oid);
105+
$message_subject= stripslashes($message_subject);
106+
$message_subject = str_replace("[EVENTNAME]", $eventnm,$message_subject);
107+
108+
$message_body = stripslashes($message);
109+
$message_body = str_replace("[EVENTNAME]", $eventnm,$message_body);
110+
$message_body = str_replace("[NAME]", $attendernm,$message_body);
111+
$message_body = str_replace("[TICKETID]", $originalticketid,$message_body);
112+
$message_body = str_replace("[TICKET_TYPE_TITLE]", $ticketTypeData[0]->title,$message_body);
113+
114+
115+
if($send_email_after_checkin)
116+
{
117+
$result=JFactory::getMailer()->sendMail($fromname,$mailfrom,$result[0]->email,$message_subject,$message_body,$html=1,null,null,'');
118+
}
119+
}
120+
121+
if($attendernm and $ticketTypeData[0]->title and $originalticketid)
122+
{
123+
$obj->message =sprintf(JText::_('COM_JTICKETING_CHECKIN_SUCCESS'),$attendernm,$ticketTypeData[0]->title,$originalticketid);
124+
}
125+
else
126+
{
127+
$obj->message =JText::_('COM_JTICKETING_CHECKIN_SUCCESS');
128+
129+
}
130+
}
131+
}
132+
133+
$this->plugin->setResponse($obj);
134+
}
135+
136+
/**
137+
* This is not the best example to follow
138+
* Please see the category plugin for a better example
139+
*/
140+
public function post()
141+
{
142+
143+
144+
}
145+
146+
public function put()
147+
{
148+
149+
}
150+
151+
152+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
/**
3+
* @package API_plugins
4+
* @copyright Copyright (C) 2009 2014 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved.
5+
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
6+
* @link http://www.techjoomla.com
7+
*/
8+
9+
defined('_JEXEC') or die;
10+
11+
jimport('joomla.plugin.plugin');
12+
13+
class JticketApiResourcegetAttendeelist extends ApiResource
14+
{
15+
public function get()
16+
{
17+
$this->plugin->setResponse($this->getattendee());
18+
}
19+
20+
public function post()
21+
{
22+
$this->plugin->setResponse($this->getattendee());
23+
}
24+
25+
public function getattendee()
26+
{
27+
$lang =JFactory::getLanguage();
28+
$extension = 'com_jticketing';
29+
$base_dir = JPATH_SITE;
30+
$jinput = JFactory::getApplication()->input;
31+
32+
$lang->load($extension, $base_dir);
33+
34+
$eventid = $jinput->get('eventid',0,'INT');
35+
$var['attendtype'] = $jinput->get('attendtype','all','CMD');
36+
$var['tickettypeid'] = $jinput->get('tickettypeid','0','INT');
37+
38+
$jticketingmainhelper = new jticketingmainhelper();
39+
if(empty($eventid) OR empty($var))
40+
{
41+
$obj->success = 0;
42+
$obj->message =JText::_("COM_JTICKETING_INVALID_EVENT");
43+
return $obj;
44+
}
45+
$results=$jticketingmainhelper->GetOrderitemsAPI($eventid,$var);
46+
if(empty($results))
47+
{
48+
$obj->success = "0";
49+
$obj->data = JText::_("COM_JTICKETING_INVALID_TICKET");;
50+
return $obj;
51+
}
52+
53+
if($eventid)
54+
{
55+
$data = array();
56+
foreach($results as &$orderitem)
57+
{
58+
$obj = new stdClass();
59+
if($orderitem->attendee_id)
60+
{
61+
$field_array=array('first_name','last_name');
62+
//Get Attendee Details
63+
$attendee_details=$jticketingmainhelper->getAttendees_details($orderitem->attendee_id,$field_array);
64+
}
65+
if(!empty($attendee_details['first_name']))
66+
{
67+
$buyername=implode(" ",$attendee_details);
68+
}
69+
else
70+
{
71+
$buyername=$orderitem->name;
72+
}
73+
74+
$obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id);
75+
$obj->ticketid = $orderitem->oid.'-'.$orderitem->order_items_id;
76+
77+
$obj->attendee_nm =strtolower($buyername);
78+
$obj->tickettypeid=$orderitem->tickettypeid;
79+
$obj->ticket_type_title =$orderitem->ticket_type_title;
80+
$obj->event_title = $orderitem->event_title;
81+
$obj->ticket_prefix=JText::_("TICKET_PREFIX");
82+
83+
/*if($var['attendtype']=="all")
84+
{
85+
$data[] = $obj;
86+
}
87+
else if($var['attendtype']=="attended" && $obj->checkin==1)
88+
{
89+
$data[] = $obj;
90+
}
91+
else if($var['attendtype']=="notattended" && $obj->checkin==0)
92+
{
93+
$data[] = $obj;
94+
}*/
95+
$data[] = $obj;
96+
}
97+
98+
$fobj = new stdClass();
99+
$fobj->success = "1";
100+
$fobj->total = count($data);
101+
$fobj->data = $data;
102+
}
103+
else
104+
{
105+
$fobj->success = "0";
106+
$fobj->data = JText::_("COM_JTICKETING_INVALID_TICKET");
107+
}
108+
109+
return $fobj;
110+
}
111+
112+
public function put()
113+
{
114+
$obj = new stdClass();
115+
$obj->success = 0;
116+
$obj->code = 403;
117+
$obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
118+
$this->plugin->setResponse($obj);
119+
}
120+
public function delete()
121+
{
122+
$obj = new stdClass();
123+
$obj->success = 0;
124+
$obj->code = 403;
125+
$obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
126+
$this->plugin->setResponse($obj);
127+
}
128+
129+
}

0 commit comments

Comments
 (0)