public function getTickettype()
 {
     $lang =& JFactory::getLanguage();
     $extension = 'com_jticketing';
     $base_dir = JPATH_SITE;
     $jinput = JFactory::getApplication()->input;
     $lang->load($extension, $base_dir);
     $eventid = $jinput->get('eventid', 0, 'INT');
     if (empty($eventid)) {
         $obj->success = 0;
         $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
         return $obj;
     }
     $jticketingmainhelper = new jticketingmainhelper();
     $tickettypes = $jticketingmainhelper->GetTicketTypes($eventid, '');
     if ($tickettypes) {
         foreach ($tickettypes as &$tickettype) {
             $tickettype->available = (int) $tickettype->available;
             $tickettype->count = (int) $tickettype->count;
             $tickettype->soldticket = $tickettype->available - $tickettype->count;
             if (empty($tickettype->soldticket) or $tickettype->soldticket < 0) {
                 $tickettype->soldticket = 0;
             }
             $tickettype->checkins = (int) $jticketingmainhelper->GetTicketTypescheckin($tickettype->id);
             if (empty($tickettype->checkins) or $tickettype->checkins < 0) {
                 $tickettype->checkins = 0;
             }
         }
     }
     if ($tickettypes) {
         $obj->success = "1";
         $obj->data = $tickettypes;
     } else {
         $obj->success = "0";
         $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
     }
     $this->plugin->setResponse($obj);
 }
Example #2
0
 public function getTicket()
 {
     $lang = JFactory::getLanguage();
     $extension = 'com_jticketing';
     $base_dir = JPATH_SITE;
     $jinput = JFactory::getApplication()->input;
     $lang->load($extension, $base_dir);
     $eventid = $jinput->get('eventid', 0, 'INT');
     $var['attendtype'] = $jinput->get('attendtype', 'all', 'CMD');
     $var['tickettypeid'] = $jinput->get('tickettypeid', '0', 'INT');
     $jticketingmainhelper = new jticketingmainhelper();
     $results = $jticketingmainhelper->GetOrderitemsAPI($eventid, $var);
     if (empty($results)) {
         $obj->success = "0";
         $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
         return $obj;
     }
     if ($eventid) {
         $data = array();
         foreach ($results as &$orderitem) {
             $obj = new stdClass();
             $obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id);
             if ($orderitem->attendee_id) {
                 $field_array = array('first_name', 'last_name');
                 //Get Attendee Details
                 $attendee_details = $jticketingmainhelper->getAttendees_details($orderitem->attendee_id, $field_array);
             }
             if (!empty($attendee_details['first_name'])) {
                 $attendee_nm = implode(" ", $attendee_details);
             } else {
                 $attendee_nm = $orderitem->name;
             }
             $obj->ticketid = $orderitem->oid . '-' . $orderitem->order_items_id;
             $obj->attendee_nm = $attendee_nm;
             $obj->tickettypeid = $orderitem->tickettypeid;
             $obj->ticket_type_title = $orderitem->ticket_type_title;
             $obj->event_title = $orderitem->event_title;
             $obj->ticket_prefix = JText::_("TICKET_PREFIX");
             /*if($var['attendtype']=="all")
             				{
             					$data[] = $obj;
             				}
             
             				else if($var['attendtype']=="attended" && $obj->checkin==1)
             				{
             					$data[] = $obj;
             				}
             				else if($var['attendtype']=="notattended" && $obj->checkin==0)
             				{
             					$data[] = $obj;
             				}*/
             $data[] = $obj;
         }
         $fobj = new stdClass();
         $fobj->success = "1";
         $fobj->total = count($data);
         $fobj->data = $data;
     } else {
         $fobj->success = "0";
         $fobj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
     }
     return $fobj;
 }
Example #3
0
 public function get()
 {
     jimport('joomla.application.component.helper');
     $send_email_after_checkin = 0;
     $com_params = JComponentHelper::getParams('com_jticketing');
     $send_email_after_checkin = $com_params->get('send_email_after_checkin');
     $jticketingmainhelper = new jticketingmainhelper();
     $lang = JFactory::getLanguage();
     $extension = 'com_jticketing';
     $base_dir = JPATH_SITE;
     $lang->load($extension, $base_dir);
     $ticketidstr = JRequest::getVar('ticketid', 0);
     $eventid = JRequest::getVar('eventid', 0);
     $eventintegrationid = $jticketingmainhelper->getEventrefid($eventid);
     if (empty($ticketidstr)) {
         $obj->success = 0;
         $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET");
         $this->plugin->setResponse($obj);
         return;
     }
     $ticketidarr = explode('-', $ticketidstr);
     $oid = $ticketidarr[0];
     $orderitemsid = $ticketidarr[1];
     $obj = new stdClass();
     $result = $jticketingmainhelper->GetActualTicketidAPI($oid, $orderitemsid, '');
     $originalticketid = JText::_("TICKET_PREFIX") . $ticketidstr;
     if ($result[0]->attendee_id) {
         $field_array = array('first_name', 'last_name');
         //Get Attendee Details
         $attendee_details = $jticketingmainhelper->getAttendees_details($result[0]->attendee_id, $field_array);
     }
     if (!empty($attendee_details['first_name'])) {
         $attendernm = implode(" ", $attendee_details);
     } else {
         $attendernm = $result[0]->name;
     }
     if (empty($result)) {
         $obj->success = 0;
         $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET");
     } else {
         if ($result[0]->eventid != $eventintegrationid) {
             $obj->success = 0;
             $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET");
         } else {
             $checkindone = $jticketingmainhelper->GetCheckinStatusAPI($orderitemsid);
             if ($checkindone) {
                 $obj->success = 0;
                 if ($attendernm) {
                     $obj->message = sprintf(JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE'), $attendernm);
                 } else {
                     $obj->message = JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE');
                 }
             } else {
                 $obj->success = $jticketingmainhelper->DoCheckinAPI($orderitemsid, $result);
                 if ($obj->success) {
                     $obj->success = 1;
                     $ticketTypeData = $jticketingmainhelper->GetTicketTypes('', $result[0]->type_id);
                     $app = JFactory::getApplication();
                     $mailfrom = $app->getCfg('mailfrom');
                     $fromname = $app->getCfg('fromname');
                     $sitename = $app->getCfg('sitename');
                     $message = JText::_("CHECKIN_MESSAGE");
                     $message_subject = JText::_("CHECKIN_SUBJECT");
                     $eventnm = $jticketingmainhelper->getEventTitle($oid);
                     $message_subject = stripslashes($message_subject);
                     $message_subject = str_replace("[EVENTNAME]", $eventnm, $message_subject);
                     $message_body = stripslashes($message);
                     $message_body = str_replace("[EVENTNAME]", $eventnm, $message_body);
                     $message_body = str_replace("[NAME]", $attendernm, $message_body);
                     $message_body = str_replace("[TICKETID]", $originalticketid, $message_body);
                     $message_body = str_replace("[TICKET_TYPE_TITLE]", $ticketTypeData[0]->title, $message_body);
                     if ($send_email_after_checkin) {
                         $result = JFactory::getMailer()->sendMail($fromname, $mailfrom, $result[0]->email, $message_subject, $message_body, $html = 1, null, null, '');
                     }
                 }
                 if ($attendernm and $ticketTypeData[0]->title and $originalticketid) {
                     $obj->message = sprintf(JText::_('COM_JTICKETING_CHECKIN_SUCCESS'), $attendernm, $ticketTypeData[0]->title, $originalticketid);
                 } else {
                     $obj->message = JText::_('COM_JTICKETING_CHECKIN_SUCCESS');
                 }
             }
         }
     }
     $this->plugin->setResponse($obj);
 }
 public function getEvents()
 {
     $jinput = JFactory::getApplication()->input;
     $com_params = JComponentHelper::getParams('com_jticketing');
     //0 Jomsocial 1/Native 3 JEvents
     $integration = $com_params->get('integration');
     $extension = 'com_jticketing';
     $base_dir = JPATH_SITE;
     $jticketingmainhelper = new jticketingmainhelper();
     $lang = JFactory::getLanguage();
     $lang->load($extension, $base_dir);
     $eventid = $jinput->get('eventid', 0, 'INT');
     if (empty($eventid)) {
         $obj->success = 0;
         $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
         return $obj;
     }
     $eventdatapaid = $jticketingmainhelper->GetUserEventsAPI('', $eventid);
     $eveidarr = array();
     if ($eventdatapaid) {
         foreach ($eventdatapaid as &$eventdata) {
             $eveidarr[] = $eventdata->id;
             $eventdata->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata->id);
         }
     }
     $eventdataunpaid = $jticketingmainhelper->GetUser_unpaidEventsAPI($userid, $eveidarr, $eventid);
     if ($eventdataunpaid) {
         foreach ($eventdataunpaid as &$eventdata3) {
             $eventdata3->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata3->id);
             $eventdata3->soldtickets = 0;
             $eventdata3->checkin = 0;
         }
     }
     if ($eventdatapaid and $eventdataunpaid) {
         $obj_merged = array_merge((array) $eventdatapaid, (array) $eventdataunpaid);
     } else {
         if ($eventdatapaid and empty($eventdataunpaid)) {
             $obj_merged = (array) $eventdatapaid;
         } else {
             if ($eventdataunpaid and empty($eventdatapaid)) {
                 $obj_merged = (array) $eventdataunpaid;
             }
         }
     }
     $obj = new stdClass();
     if ($obj_merged) {
         $config = JFactory::getConfig();
         $return = $jticketingmainhelper->getTimezoneString($eventdata->id);
         $obj_merged[0]->startdate = $return['startdate'];
         $obj_merged[0]->enddate = $return['enddate'];
         $datetoshow = $return['startdate'] . '-' . $return['enddate'];
         if (!empty($return['eventshowtimezone'])) {
             $datetoshow .= '<br/>' . $return['eventshowtimezone'];
         }
         if ($obj_merged[0]->avatar) {
             if ($integration == 2) {
                 $obj_merged[0]->avatar = JURI::base() . 'media/com_jticketing/images/' . $obj_merged[0]->avatar;
             } else {
                 $obj_merged[0]->avatar = JURI::base() . $obj_merged[0]->avatar;
             }
         } else {
             $obj_merged[0]->avatar = '';
         }
         if (empty($obj_merged[0]->soldtickets)) {
             $obj_merged[0]->soldtickets = 0;
         }
         if (empty($obj_merged[0]->totaltickets)) {
             $obj_merged[0]->totaltickets = 0;
         }
         if (empty($obj_merged[0]->checkin)) {
             $obj_merged[0]->checkin = 0;
         }
         $obj->success = "1";
         $obj->data = $obj_merged;
     } else {
         $obj->success = "0";
         $obj->data = JText::_("COM_JTICKETING_NO_EVENT_DATA");
     }
     return $obj;
 }