/app/controllers/tickets_controller.php
PHP | 2446 lines | 1956 code | 386 blank | 104 comment | 390 complexity | f9da7d3a0251fbe1f880afa9337551a7 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
Large files files are truncated, but you can click here to view the full file
- <?
- class TicketsController extends AppController {
- var $name='Tickets';
- var $helpers = array('Html','javascript','error','Ajax','common','Phoogle', 'Form','Friendsurl','Newexcel');
- var $components = array('Thumbnail','Thumbnailc','Upload','Sendmail','Mysqllocker','Download');
- var $uses=array('Ticket','User','Ticket_carts','PaymentTransaction');
-
- function index($uid=null,$keyuserId=null) {
- $this->pageTitle = 'Tickets Home';
- $this->layout = 'tickethome';
- if(!isset($_SESSION['UserId']) && $keyuserId && $uid ) {
- $uid = base64_decode($uid);
- if(md5('checklogin'.$uid)==$keyuserId) {
- $this->login_again($uid);
- }
- }
-
- $this->homepageslideInfo('Tickets');
- $this->ticketCategory();
-
- ################################## Event Location ##########################
- /* Turn oN the session for the project state and country*/
- if(isset($_SESSION['UserId'])) {
-
- $sql = "SELECT * FROM ticket_carts WHERE user_id='".$_SESSION['UserId']."' AND pay_status='0'";
-
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result)) {
- //delete cart
- mysql_query("DELETE FROM ticket_cart_details WHERE cart_id='".$row['id']."'") or die(mysql_error());
- mysql_query("DELETE FROM ticket_seat_booked WHERE cart_id='".$row['id']."'") or die(mysql_error());
- mysql_query("DELETE FROM ticket_carts WHERE id='".$row['id']."'") or die(mysql_error());
- }
-
- $userCountry = "select user_details.c_id , countries.country_name ,state.Name, user_details.state, user_details.city , CONCAT_WS(',',city_master.city_name,state.Name,countries.country_name) as CurrentLocation from user_details LEFT JOIN countries On countries.id = user_details.c_id LEFT JOIN state ON state.id = user_details.state LEFT JOIN city_master ON user_details.city = city_master.city_id where user_details.user_id= ".$_SESSION['UserId']." ";
- $userCountry_res = mysql_query($userCountry);
- if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
- if(!isset($_SESSION['PrjUserCityName'])) {
- $this->Session->write('PrjUserCityName', $userCountry_arr['city']);
- $this->Session->write('PrjUserCityId', $userCountry_arr['city']);
- }
-
- if(!isset($_SESSION['PrjUserStateId'])) {
- $this->Session->write('PrjUserStateId', $userCountry_arr['state']);
- $this->Session->write('PrjUserStateName', $userCountry_arr['Name']);
- }
-
- if(!isset($_SESSION['PrjUserCountryId'])) {
- $this->Session->write('PrjUserCountryId', $userCountry_arr['c_id']);
- $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
- }
-
- if(!isset($_SESSION['PrjUserLocation'])) {
- $locstr=$userCountry_arr['CurrentLocation'];
- // $locstr='';
- // if($_SESSION['PrjUserStateName']!="")
- // $locstr.=$_SESSION['PrjUserStateName'].',' ;
- //
- // if($_SESSION['PrjUserCountryName']!="")
- // $locstr.= $_SESSION['PrjUserCountryName'].',' ;
- $this->Session->write('PrjUserLocation',substr($locstr,0,(strlen($locstr)-1)));
- }
- }
- }
- else {
- $check = false;
- if(!isset($_SESSION['PrjUserCountryId'])) {
- $this->Session->write('PrjUserCityId', 14967);
- $this->Session->write('PrjUserStateId', 168);
- $this->Session->write('PrjUserCountryId', 254);
- }
-
- if(isset($_SESSION['PrjUserCityId']) && isset($_SESSION['PrjUserStateId']) && isset($_SESSION['PrjUserCountryId'])) {
- $sql = "SELECT CONCAT_WS(', ',city_master.city_name,state.Name,countries.country_name) as CurrentLocation, city_master.city_name as CityName, state.Name as StateName,countries.country_name
- FROM countries
- LEFT JOIN state ON (state.id='".$_SESSION['PrjUserStateId']."' AND state.c_id=countries.id)
- LEFT JOIN city_master ON (city_master.city_id='".$_SESSION['PrjUserCityId']."' AND city_master.CountryID=countries.id AND city_master.state_id=state.id)
- WHERE countries.id='".$_SESSION['PrjUserCountryId']."' ";
- $userCountry_res = mysql_query($sql);
- if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
- $this->Session->write('PrjUserCityName', $userCountry_arr['CityName']);
- $this->Session->write('PrjUserStateName', $userCountry_arr['StateName']);
- $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
- $this->Session->write('PrjUserLocation',$userCountry_arr['CurrentLocation']);
- $check = true;
- }
- }
-
- if(!$check) {
- $userCountry = "select countries.id , countries.country_name from countries Where countries.id = '6'";
- $userCountry_res = mysql_query($userCountry);
- if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
- if(!isset($_SESSION['PrjUserCityName'])) {
- $this->Session->write('PrjUserCityName', '');
- $this->Session->write('PrjUserCityId', 0);
- }
-
- if(!isset($_SESSION['PrjUserStateId'])) {
- $this->Session->write('PrjUserStateId', 0);
- $this->Session->write('PrjUserStateName', '');
- }
- if(!isset($_SESSION['PrjUserCountryId'])) {
- $this->Session->write('PrjUserCountryId', $userCountry_arr['id']);
- $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
- }
-
-
- $locstr='';
-
- if(isset($_SESSION['PrjUserCityName']) && $_SESSION['PrjUserCityName']!="")
- $locstr.=$_SESSION['PrjUserCityName'] ;
-
- if(isset($_SESSION['PrjUserStateName']) && $_SESSION['PrjUserStateName']!="")
- $locstr.=', '.$_SESSION['PrjUserStateName'] ;
-
- if(isset($_SESSION['PrjUserCountryName']) && $_SESSION['PrjUserCountryName']!="")
- $locstr.= $_SESSION['PrjUserCountryName'] ;
-
-
- $this->Session->write('PrjUserLocation',$locstr);
- }
- }
-
-
- }
- ###########################################################################
- }
-
- function changelocation() {
- /* Turn oN the session for the project state and country*/
- $userCountry = "select IFNULL(countries.id,0) as countryId , IFNULL(countries.country_name,'') as countryName ,IFNULL(state.Name,'')as StateName, IFNULL(state.id,0) as StateId, IFNULL(city_master.city_id,0) as CityId , IFNULL(city_master.city_name,'')as CityName from countries LEFT JOIN state ON state.c_id = countries.id and state.id = ".$_REQUEST['province']." LEFT JOIN city_master ON state_id = state.id and city_id = ".$_REQUEST['city']." where countries.id = ".$_REQUEST['country']."";
- $userCountry_res = mysql_query($userCountry)or die(mysql_error());
- if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
- $this->Session->write('PrjUserCityName', $userCountry_arr['CityName']);
- $this->Session->write('PrjUserCityId', $userCountry_arr['CityId']);
-
- $this->Session->write('PrjUserStateId', $userCountry_arr['StateId']);
- $this->Session->write('PrjUserStateName', $userCountry_arr['StateName']);
-
- $this->Session->write('PrjUserCountryId', $userCountry_arr['countryId']);
- $this->Session->write('PrjUserCountryName', $userCountry_arr['countryName']);
-
- $strloc = '';
- if($userCountry_arr['CityName']!='') {
- $strloc .= $userCountry_arr['CityName'].', ' ;
- }
- if($userCountry_arr['StateName']!='') {
- $strloc .= $userCountry_arr['StateName'].', ' ;
- }
- if($userCountry_arr['countryName']!='') {
- $strloc .= $userCountry_arr['countryName'] ;
- }
-
- $this->Session->write('PrjUserLocation',$strloc);
- }
- $this->redirect('tickets');
- }
-
- function ticketCategory() {
- $evtcat = array();
- $evtcat['0']="Select Category";
- $select_ticket_cat = mysql_query("Select * from ticket_event_category");
- while($select_ticket_cat_arr = mysql_fetch_array($select_ticket_cat)) {
- $evtcat[$select_ticket_cat_arr['id']] = $select_ticket_cat_arr['cat_name'];
- }
- $this->set('ticketcat',$evtcat);
- }
-
- function recentticket() {
- $this->layout = 'profile_blank';
- $this->ticketCategory();
- $curDate=date("Y-m-d");
-
- if(isset($_SESSION['PrjUserCityId']))
- $city=$_SESSION['PrjUserCityId'];
-
- if(isset($_SESSION['PrjUserStateId']))
- $state=$_SESSION['PrjUserStateId'];
-
- if(isset($_SESSION['PrjUserCountryId']))
- $country=$_SESSION['PrjUserCountryId'];
-
-
- $pageFlag=null;
- $select="SELECT T.* ,TV.id tvId,TV.venue_name venueName,USR.username,USR.id as postedbyuser,TCAT.id as ticketcategoryId ,TCAT.cat_name as ticketcategory";
- $from=" FROM tickets T
- LEFT JOIN ticket_event_venue TV ON (T.ticket_venue_section_id=TV.id)
- LEFT JOIN ticket_event_category TCAT ON (T.ticket_category_id=TCAT.id)
- LEFT JOIN users USR ON (T.user_id=USR.id)
- ";
- $where="WHERE T.is_temp='0' AND (NOW() < ticevent_enddate) AND parent_id=0";
-
- if(isset($city) && $city!=0)
- $where.=" AND TV.venue_city_id='".$city."'";
-
- if(isset($state) && $state!=0)
- $where.=" AND TV.venue_state_id='".$state."'";
-
- if(isset($country) && $country!=0)
- $where.=" AND TV.venue_country_id='".$country."'";
-
- $where.=" ORDER BY T.ticevent_startdate ";
-
- $CountField='T.id';
-
-
- $SelectRecord = mysql_query("$select $from $where LIMIT 12") or die('Line no '.__LINE__ . mysql_error());
- $this->set("ticketQry",$SelectRecord);
-
- $this->render('hotticket','ajax');
-
- }
-
- function category() {
- $catid=0;
- $searchpass ='';
- $this->layout = 'ticketdetail';
- $this->ticketCategory();
- $curDate=date("Y-m-d");
-
- $select="SELECT T.* ,TV.id tvId,TV.venue_name venueName,USR.username,USR.id as postedbyuser,TCAT.id as ticketcategoryId ,TCAT.cat_name as ticketcategory";
- $from=" FROM tickets T
- LEFT JOIN ticket_event_venue TV ON (T.ticket_venue_section_id=TV.id)
- LEFT JOIN ticket_event_category TCAT ON (T.ticket_category_id=TCAT.id)
- LEFT JOIN users USR ON (T.user_id=USR.id)
- ";
- $where="WHERE T.is_temp='0' AND (NOW() < ticevent_enddate) AND parent_id>0";
-
- if(isset($this->params['pass']['0'])) {
- $catid=base64_decode($this->params['pass']['0']);
- }
- if(isset($this->data['Ticket']['ticketcat']) && $this->data['Ticket']['ticketcat']>0) {
- $catid = $this->data['Ticket']['ticketcat'];
- }
- if(isset($_REQUEST['catid']) && $_REQUEST['catid']!='') {
- $catid = $_REQUEST['catid'];
- }
-
- if(isset($this->data['Ticket']['srchtect']) && $this->data['Ticket']['srchtect']!="" && $this->data['Ticket']['srchtect']!="Event name or zip") {
- $srchtect = addslashes($this->data['Ticket']['srchtect']);
- }
- if(isset($_REQUEST['srchtect']) && $_REQUEST['srchtect']!='') {
- $srchtect = addslashes($_REQUEST['srchtect']);
- }
-
- if(isset($this->data['Ticket']['srchdate']) && $this->data['Ticket']['srchdate']!=0) {
- $ticDate = $this->data['Ticket']['srchdate'];
- }
- if(isset($_REQUEST['ticDate']) && $_REQUEST['ticDate']!='') {
- $ticDate = $_REQUEST['ticDate'];
- }
-
- if(isset($_SESSION['PrjUserCityId']))
- $city=$_SESSION['PrjUserCityId'];
-
- if(isset($_SESSION['PrjUserStateId']))
- $state=$_SESSION['PrjUserStateId'];
-
- if(isset($_SESSION['PrjUserCountryId']))
- $country=$_SESSION['PrjUserCountryId'];
-
-
- if(isset($catid) && $catid>0) {
- $where.= " AND T.ticket_category_id='".$catid."' ";
- }
-
- if(isset($city) && $city!=0)
- $where.=" AND TV.venue_city_id='".$city."'";
-
- if(isset($state) && $state!=0)
- $where.=" AND TV.venue_state_id='".$state."'";
-
- if(isset($country) && $country!=0)
- $where.=" AND TV.venue_country_id='".$country."'";
-
- if(isset($srchtect) && $srchtect!='') {
- $where.= " AND ( T.ticevent_name LIKE '%".$srchtect."%' OR (TV.venue_zip!=0 AND TV.venue_zip='".$srchtect."')) ";
- $searchpass .= '&srchtect='.$srchtect;
- }
-
- if(isset($ticDate) && $ticDate!='') {
- $where.=" AND T.ticevent_startdate<='".$ticDate."'";
- $searchpass .= '&ticDate='.$ticDate;
- }
-
- $others = 'ORDER BY T.ticevent_startdate';
-
- $this->set('catid',$catid);
-
- $PassParameter='catid='.$catid.$searchpass;
-
- $CountField="T.id";
- $this->set("controller","tickets");
- $this->set("action","category");
- $this->set("parameter",$PassParameter);
-
- $this->set('elementsUpdate',array('backdroplist','relatedevent'));
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || isset($_REQUEST['form_ajax']) ) {
- $this->render("category2","ajax");
- }
-
- }
-
- function saveperformer() {
- $inserintoperfomer_id =0;
- if(isset($_POST['add']) && $_POST['add']==1) {
- $sql = "INSERT INTO ticket_event_performer SET user_id='".$_SESSION['UserId']."'";
- mysql_query($sql);
- $inserintoperfomer_id = mysql_insert_id();
- }else if(isset($_POST['deleteorg']) && isset($_POST['oid']) && $_POST['deleteorg']==1) {
- $sql = "DELETE FROM ticket_event_performer WHERE id='".$_POST['oid']."'";
- mysql_query($sql);
- $inserintoperfomer_id = $_POST['oid'];
- }
- else if(isset($_POST['editorg']) && isset($_POST['oid']) && $_POST['editorg']==1 && $_POST['oid']!=0) {
- $sql = "UPDATE ticket_event_performer SET performer_name='".addslashes($_POST['name'])."' , perfomer_desc = '".addslashes($_POST['description'])."', performer_phone = '".addslashes($_POST['phone'])."', performer_email = '".addslashes($_POST['email'])."'
- , performer_address = '".addslashes($_POST['address'])."', performer_zip = '".addslashes($_POST['zip'])."', performer_country='".$_POST['country']."', performer_state='".$_POST['state']."', performer_city='".$_POST['city']."'
- WHERE id='".addslashes($_POST['oid'])."' AND user_id='".$_SESSION['UserId']."'";
- mysql_query($sql) or die($sql);
- $inserintoperfomer_id = $_POST['oid'];
- }
-
- $this->set('id',$inserintoperfomer_id);
- }
-
- function create($tidCopy=null) {
- //$this->checkSession();
- $this->layout = 'ticket_create';
- if(!isset($_SESSION['UserId'])) {
- //$this->Session->write('actContinue','tickets/create');
- }else {
-
- $this->set('countrylist',$this->getCountryList());
- $sql = "SELECT * FROM ticket_event_performer WHERE user_id='".$_SESSION['UserId']."' AND blocked='0'";
- $this->set('performerlist',mysql_query($sql));
- $this->ticketCategory();
- $this->set('stateList',array('0'=>'Select State'));
- $this->set('cityList',array('0'=>'Select City'));
-
- $ticketsql_id=0;
-
-
- if(isset($_POST['t']) && md5(md5('save'))==$_POST['t']) {
-
- if(isset($_POST['tid']) && $_POST['tid']!='') {
- $ticketsql_id = base64_decode($_POST['tid']);
- $sql = 'SELECT * FROM tickets WHERE id="'.$ticketsql_id.'" AND user_id="'.$_SESSION['UserId'].'"';
- $result = mysql_query($sql);
- if(($row=mysql_fetch_array($result))) {
- //update ticket_event_venue
- $ticket_venue_section_id = $row['ticket_venue_section_id'];
- $sql = "UPDATE ticket_event_venue SET venue_name='".addslashes($_REQUEST['venue_name'])."' , venue_desc = '',venue_address='".addslashes($_REQUEST['address_1'])."',
- venue_city_id='".$_REQUEST['city']."',venue_state_id='".$_REQUEST['province']."',venue_country_id='".$_REQUEST['country']."',venue_zip='".$_REQUEST['postal_code']."', venue_phone='".$_REQUEST['phone']."'
- WHERE id='".$ticket_venue_section_id."'";
- mysql_query($sql) or die(mysql_error());
- }
- }
- if(!isset($ticket_venue_section_id) || $ticket_venue_section_id==0) {
- //save venue
- $sql = "Insert Into ticket_event_venue SET user_id='".$_SESSION['UserId']."' , venue_name='".addslashes($_REQUEST['venue_name'])."' , venue_desc = '',venue_address='".addslashes($_REQUEST['address_1'])."',
- venue_city_id='".$_REQUEST['city']."',venue_state_id='".$_REQUEST['province']."',venue_country_id='".$_REQUEST['country']."',venue_zip='".$_REQUEST['postal_code']."', venue_phone='".$_REQUEST['phone']."' ";
- mysql_query($sql) or die(mysql_error());
-
- $ticket_venue_section_id = mysql_insert_id();
- }
-
- if($ticketsql_id!='' && $ticketsql_id!=0) {
- $ticketsql = "UPDATE tickets SET
- ticevent_name = '".addslashes($_POST['evname'])."', paypal_email = '".addslashes($_POST['paypal_email'])."',
- ticket_category_id='".$_POST['channels']."',
- ticevent_desc='".addslashes($_POST['description'])."', ticevent_terms='".addslashes($_POST['terms'])."',
- ticket_event_performer_id='".$_POST['savedOrganizers']."', ticket_venue_section_id='".$ticket_venue_section_id."',
- ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
- ticevent_image='".addslashes($_POST['image'])."', ticevent_logoimage='".addslashes($_POST['logo'])."',
- is_featured='0', is_hotlisted='0',
- timezone_id='".addslashes($_POST['timezone'])."',
- ticket_tags='".addslashes($_POST['tags'])."', is_show_remaining='".(isset($_POST['show_remaining'])?1:0)."',
- is_temp='".$_POST['is_temp']."', seating_type='".$_POST['seating_type']."', is_public='".(isset($_POST['show_public'])?1:0)."'
- ".(!isset($_POST['show_public']) ? ", password_private='".$_POST['password_private']."'" : '')."
- WHERE id='".$ticketsql_id."' ";
- //ticevent_startdate='".$start_date."', ticevent_enddate='".$end_date."', ticket_dooropen='".$dooropen."',
- mysql_query($ticketsql) or die($ticketsql);
- }else {
- $ticketsql = "INSERT INTO tickets SET
- ticevent_name = '".addslashes($_POST['evname'])."', paypal_email = '".addslashes($_POST['paypal_email'])."',
- ticket_category_id='".$_POST['channels']."',
- ticevent_desc='".addslashes($_POST['description'])."', ticevent_terms='".addslashes($_POST['terms'])."',
- ticket_event_performer_id='".$_POST['savedOrganizers']."', ticket_venue_section_id='".$ticket_venue_section_id."',
- ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
- ticevent_image='".addslashes($_POST['image'])."', ticevent_logoimage='".addslashes($_POST['logo'])."',
- is_featured='0', is_hotlisted='0',
- timezone_id='".addslashes($_POST['timezone'])."',
- ticket_tags='".addslashes($_POST['tags'])."', is_show_remaining='".(isset($_POST['show_remaining'])?1:0)."',
- is_temp='".$_POST['is_temp']."', seating_type='".$_POST['seating_type']."', is_public='".(isset($_POST['show_public'])?1:0)."'
- ".(!isset($_POST['show_public']) ? ", password_private='".$_POST['password_private']."'" : '');
-
- mysql_query($ticketsql) or die($ticketsql);
- $ticketsql_id = mysql_insert_id();
- }
-
- //update datetime
- foreach($_REQUEST['customDates'] as $key=>$value){
- $customDates = split('startDate', $value);
- $start_date = $customDates[0];
-
- $customDates = $customDates[1];
- $customDates = split('startTime', $customDates);
- $start_time = $customDates[0];
-
- $customDates = $customDates[1];
- $customDates = split('endDate', $customDates);
- $end_date = $customDates[0];
-
- $customDates = $customDates[1];
- $customDates = split('endTime', $customDates);
- $end_time = $customDates[0];
-
- $dooropen = $customDates[1];
-
- $start_date = split('/', $start_date);
- $start_date = $start_date[2].'-'.$start_date[0].'-'.$start_date[1].' '.$start_time;
-
- $end_date = split('/', $end_date);
- $end_date = $end_date[2].'-'.$end_date[0].'-'.$end_date[1].' '.$end_time;
- $sql = "UPDATE tickets SET ticevent_startdate='".$start_date."', ticevent_enddate='".$end_date."', ticket_dooropen='".$dooropen."'
- WHERE id='".$key."'";
- mysql_query($sql) or die($sql);
- }
-
- //update for children
- //get list id children
- $sql = "SELECT id FROM tickets WHERE parent_id='".$ticketsql_id."'";
- $result = mysql_query($sql);
- $listid = array();
- while($row=mysql_fetch_array($result)){
- $listid[] = $row['id'];
- }
- if(count($listid)>0){
- //info ticket parent
- $sql = "SELECT * FROM tickets WHERE id='".$ticketsql_id."'";
- $result = mysql_query($sql);
- $parent = mysql_fetch_array($result);
- //update information public
- $ticketsql = "UPDATE tickets SET
- ticevent_name = '".$parent['ticevent_name']."', paypal_email = '".$parent['paypal_email']."',
- ticket_category_id='".$parent['ticket_category_id']."',
- ticevent_desc='".$parent['ticevent_desc']."', ticevent_terms='".$parent['ticevent_terms']."',
- ticket_event_performer_id='".$parent['ticket_event_performer_id']."', ticket_venue_section_id='".$parent['ticket_venue_section_id']."',
- ticket_ship_master_id='1', user_id='".$parent['user_id']."',
- ticevent_image='".$parent['ticevent_image']."', ticevent_logoimage='".$parent['ticevent_logoimage']."',
- is_featured='0', is_hotlisted='0',
- timezone_id='".$parent['timezone_id']."',
- ticket_tags='".$parent['ticket_tags']."', is_show_remaining='".$parent['is_show_remaining']."',
- is_temp='".$parent['is_temp']."', seating_type='".$parent['seating_type']."', is_public='".$parent['is_public']."',
- password_private='".$parent['password_private']."'
- WHERE id IN (".join(',',$listid).") ";
- mysql_query($ticketsql) or die($ticketsql);
- //update product
- if($parent['seating_type']==0){
- $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$parent['id']."'";
- $result = mysql_query($sql) or die($sql);
- while($p = mysql_fetch_array($result)){
- foreach($listid as $ticket_child){
- $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$ticket_child."' AND seat_name='".$p['seat_name']."' ";
- $result_p = mysql_query($sql) or die($sql);
- if(!($row=mysql_fetch_array($result_p))){
- $sql = "INSERT tickets_product SET tickets_id='".$ticket_child."', seat_name='".$p['seat_name']."',
- seat_qty='".$p['seat_qty']."', seat_price='".$p['seat_price']."',color='".$p['color']."',
- enabled='".$p['enabled']."', handicap='".$p['handicap']."' ";
- mysql_query($sql) or die($sql);
- }
- }
- }
-
- }
- }
- if(isset($_POST['is_temp'])) {
- $this->redirect('tickets/index');
- }
-
- $this->set('updated',1);
- }
-
- if(isset($_REQUEST['tid']) && $_REQUEST['tid']!='') {
- $ticketsql_id = base64_decode($_REQUEST['tid']);
- }
-
- if(isset($_POST['is_preview']) && $_POST['is_preview']==1) {
- $this->redirect('tickets/previewevent/'.base64_encode($ticketsql_id));
- }
-
- if($tidCopy!=null) {
- $tidCopy = base64_decode($tidCopy);
- $sql = "SELECT * FROM tickets
- WHERE id='".addslashes($tidCopy)."' AND user_id='".$_SESSION['UserId']."' ";
- $result = mysql_query($sql);
- if(($row=mysql_fetch_array($result))) {
- //Insert ticket_event_venue
- $sql = "INSERT INTO ticket_event_venue(`venue_name`,`venue_address`,`venue_phone`,`venue_city_id`,`venue_state_id`,`venue_country_id`,`user_id`,`venue_desc`,`venue_zip`)
- SELECT `venue_name`,`venue_address`,`venue_phone`,`venue_city_id`,`venue_state_id`,`venue_country_id`,`user_id`,`venue_desc`,`venue_zip`
- FROM ticket_event_venue WHERE id=".$row['ticket_venue_section_id'];
-
- mysql_query($sql)or die(mysql_errno());
- $ticket_venue_section_id = mysql_insert_id();
-
- $ticketsql = "INSERT INTO tickets SET
- ticevent_name = '".$row['ticevent_name']." copy', paypal_email='".$row['paypal_email']."',
- ticevent_startdate='".$row['ticevent_startdate']."', ticevent_enddate='".$row['ticevent_enddate']."', ticket_dooropen='".$row['ticket_dooropen']."',
- ticket_category_id='".$row['ticket_category_id']."',
- ticevent_desc='".$row['ticevent_desc']."', ticevent_terms='".$row['ticevent_terms']."',
- ticket_event_performer_id='".$row['ticket_event_performer_id']."', ticket_venue_section_id='".$ticket_venue_section_id."',
- ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
- ticevent_image='".$row['ticevent_image']."', ticevent_logoimage='".$row['ticevent_logoimage']."',
- is_featured='0', is_hotlisted='0',
- timezone_id='".$row['timezone_id']."',
- ticket_tags='".$row['ticket_tags']."', is_show_remaining='".$row['is_show_remaining']."',
- is_temp='1', seating_type='".$row['seating_type']."',
- is_public='".$row['is_public']."',password_private='".$row['password_private']."'";
-
- mysql_query($ticketsql) or die(mysql_errno());
- $ticketsql_id = mysql_insert_id();
-
- $seatsxml = $row['seatsxml'];
- $seatsxml_new = $seatsxml;
-
- //insert tickets_product
- $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$row['id']."' ";
- $result = mysql_query($sql)or die($sql);
- $listp = array();
- while($row = mysql_fetch_array($result)) {
- $listp[] = $row;
- $sql = "INSERT INTO tickets_product SET tickets_id='".$ticketsql_id."', seat_name='".$row['seat_name']."', seat_qty='".$row['seat_qty']."', seat_price='".$row['seat_price']."',
- color='".$row['color']."', enabled='".$row['enabled']."',handicap='".$row['handicap']."' ";
- mysql_query($sql)or die(mysql_errno());
- if($seatsxml_new!=''){
- $product_id_new = mysql_insert_id();
- //update id for product
- $old = '/id="'.$row['id'].'"/';
- $new = 'id="'.$product_id_new.'"';
- $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
-
- //update group_id for seat, shape
- $old = '/group_id="'.$row['id'].'"/';
- $new = 'group_id="'.$product_id_new.'"';
-
- $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
- }
- }
-
- $sql= "UPDATE tickets SET seatsxml='".$seatsxml_new."' WHERE id='".$ticketsql_id."'";
- mysql_query($sql)or die(mysql_errno());
-
- //check add children
- $sql = "SELECT * FROM tickets WHERE parent_id='".addslashes($tidCopy)."' AND user_id='".$_SESSION['UserId']."' ";
- $result = mysql_query($sql);
- while($child=mysql_fetch_array($result)){
- //insert ticket
- $ticketsql = "INSERT INTO tickets SET
- parent_id='".$ticketsql_id."',
- ticevent_name = '".$child['ticevent_name']." copy', paypal_email='".$child['paypal_email']."',
- ticevent_startdate='".$child['ticevent_startdate']."', ticevent_enddate='".$child['ticevent_enddate']."', ticket_dooropen='".$child['ticket_dooropen']."',
- ticket_category_id='".$child['ticket_category_id']."',
- ticevent_desc='".$child['ticevent_desc']."', ticevent_terms='".$child['ticevent_terms']."',
- ticket_event_performer_id='".$child['ticket_event_performer_id']."', ticket_venue_section_id='".$ticket_venue_section_id."',
- ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
- ticevent_image='".$child['ticevent_image']."', ticevent_logoimage='".$child['ticevent_logoimage']."',
- is_featured='0', is_hotlisted='0',
- timezone_id='".$child['timezone_id']."',
- ticket_tags='".$child['ticket_tags']."', is_show_remaining='".$child['is_show_remaining']."',
- is_temp='1', seating_type='".$child['seating_type']."',
- is_public='".$child['is_public']."', password_private='".$child['password_private']."'";
-
- mysql_query($ticketsql) or die(mysql_errno());
- $child_new_id = mysql_insert_id();
- //insert product
- $seatsxml_new = $seatsxml;
- foreach($listp as $p){
- $sql = "INSERT INTO tickets_product SET tickets_id='".$child_new_id."', seat_name='".$p['seat_name']."', seat_qty='".$p['seat_qty']."', seat_price='".$p['seat_price']."',
- color='".$p['color']."', enabled='".$p['enabled']."',handicap='".$p['handicap']."' ";
- mysql_query($sql)or die(mysql_errno());
- if($seatsxml_new!=''){
- $product_id_new = mysql_insert_id();
- //update id for product
- $old = '/id="'.$p['id'].'"/';
- $new = 'id="'.$product_id_new.'"';
- $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
-
- //update group_id for seat, shape
- $old = '/group_id="'.$p['id'].'"/';
- $new = 'group_id="'.$product_id_new.'"';
-
- $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
- }
- }
- $sql= "UPDATE tickets SET seatsxml='".$seatsxml_new."' WHERE id='".$child_new_id."'";
- mysql_query($sql)or die(mysql_errno());
- }
- }
- }
-
- if($ticketsql_id>0) {
- $sql = "SELECT tickets.*,tickets.id as tid,Venue.* FROM tickets
- LEFT JOIN ticket_event_venue Venue ON (Venue.id=tickets.ticket_venue_section_id)
- WHERE tickets.id='".addslashes($ticketsql_id)."' AND tickets.user_id='".$_SESSION['UserId']."' ";
- $result = mysql_query($sql);
- if(($row=mysql_fetch_array($result))) {
- $this->set('data',$row);
- if($row['seating_type']=='0') {
- //get ticket product
- $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$row['tid']."'";
- $this->set('tickets_seat', mysql_query($sql));
- }
-
- if($row['venue_country_id']>=0) {
- $this->set('stateList',$this->getStateList($row['venue_country_id']));
- }
- if($row['venue_state_id']>=0) {
- $this->set('cityList',$this->getCityList($row['venue_state_id']));
- }
-
- $this->set('tid',$ticketsql_id);
-
- //get datetime children
- $sql = "SELECT id,ticevent_startdate,ticevent_enddate,ticket_dooropen FROM tickets WHERE parent_id='".$ticketsql_id."'";
- $result = mysql_query($sql);
- $datetimes = array();
- while($row=mysql_fetch_array($result)){
- $datetimes[] = $row;
- }
- if(count($datetimes)>0)
- $this->set('datetimes',$datetimes);
- }
- }else {//new
- //delete all tickets is_temp='1' and title=''
- $sql = "SELECT id FROM tickets WHERE is_temp='1' AND ticevent_name='' AND user_id='".$_SESSION['UserId']."'";
- $result = mysql_query($sql);
- while($row=mysql_fetch_array($result)){
- mysql_query("DELETE FROM tickets WHERE id='".$row['id']."'");
- mysql_query("DELETE FROM tickets_product WHERE tickets_id='".$row['id']."'");
- }
- //insert tickets empty
- $query = "INSERT tickets SET is_temp='1', user_id='".$_SESSION['UserId']."'";
- mysql_query($query);
- $ticketsql_id = mysql_insert_id();
- $this->set('tid',$ticketsql_id);
- }
- }
- }
-
- function ajax_saveticketseat() {
- $this->layout = 'blank';
- if(isset($_POST['tic_action']) && $_POST['tic_action']!='') {
- if(isset($_POST['tic_id']) && $_POST['tic_id']>0) {
- if(isset($_POST['tic_action'])) {
- if($_POST['tic_action']=='delete') {
- $sql = "SELECT * FROM tickets_product WHERE id='".$_POST['tic_id']."'";
- $result = mysql_query($sql);
- if(($row=mysql_fetch_array($result))){
- $seat_name = $row['seat_name'];
- $sql = "SELECT P.id FROM tickets_product as P
- RIGHT JOIN tickets as T ON P.tickets_id=T.id
- WHERE T.parent_id='".$_POST['tictickets_id']."'";
- $result = mysql_query($sql);
- $listid = array();
- while($row=mysql_fetch_array($result)){
- $listid[] = $row['id'];
- }
- if(count($listid)>0){
- $sql = "DELETE FROM tickets_product WHERE id='".$_POST['tic_id']."' OR (id IN (".join(',',$listid).") AND seat_name='".$seat_name."')";
- }else{
- $sql = "DELETE FROM tickets_product WHERE id='".$_POST['tic_id']."'";
- }
- mysql_query($sql) or die(mysql_error());
- }
-
- $id = $_POST['tic_id'];
- $out ='{"action":"delete","id" : "'.$id.'"}';
- }
- else {
- $sql = "SELECT * FROM tickets_product WHERE id='".$_POST['tic_id']."'";
- $result = mysql_query($sql);
- if(($row=mysql_fetch_array($result))){
- $seat_name = $row['seat_name'];
- //check
- $query = "SELECT count(id) as _count FROM tickets_product WHERE tickets_id='".$_POST['tictickets_id']."' AND id<>'".$_POST['tic_id']."' AND seat_name='".$_POST['ticcat']."'";
- $result = mysql_query($query);
- $row= mysql_fetch_array($result);
- if($row['_count']>0){
- $out ='{"error":"Ticket Name Unavailable"}';
- }else if($_POST['ticprice']<5){
- $out ='{"error":"Minimum price is $5"}';
- }else{
- $sql = "SELECT P.id FROM tickets_product as P
- RIGHT JOIN tickets as T ON P.tickets_id=T.id
- WHERE T.parent_id='".$_POST['tictickets_id']."'";
- $result = mysql_query($sql);
- $listid = array();
- while($row=mysql_fetch_array($result)){
- $listid[] = $row['id'];
- }
- if(count($listid)>0){
- $sql = "UPDATE tickets_product SET seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."'
- WHERE id='".$_POST['tic_id']."' OR (id IN (".join(',',$listid).") AND seat_name='".$seat_name."')";
- }else{
- $sql = "UPDATE tickets_product SET seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."'
- WHERE id='".$_POST['tic_id']."'";
- }
- mysql_query($sql);
- $id = $_POST['tic_id'];
- $out ='{"action":"update","id" : "'.$id.'","ticcat": "'.$_POST['ticcat'].'", "ticquantity": "'.$_POST['ticquantity'].'", "ticprice": "'.$_POST['ticprice'].'"}';
- }
- }
- }
- }
- }else {
- //check seat_name
- $query = "SELECT count(id) as _count FROM tickets_product WHERE tickets_id='".$_POST['tictickets_id']."' AND seat_name='".$_POST['ticcat']."'";
- $result = mysql_query($query);
- $row= mysql_fetch_array($result);
- if($row['_count']>0){
- $out ='{"error":"Ticket Name Unavailable"}';
- }else if($_POST['ticprice']<5){
- $out ='{"error":"Minimum price is $5"}';
- }else{
- $sql = "INSERT INTO tickets_product SET tickets_id='".$_POST['tictickets_id']."', seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."',enabled=1 ";
- mysql_query($sql);
- $id = mysql_insert_id();
- $out ='{"action":"insert","id" : "'.$id.'","ticcat": "'.$_POST['ticcat'].'", "ticquantity": "'.$_POST['ticquantity'].'", "ticprice": "'.$_POST['ticprice'].'"}';
-
- $query = "SELECT id FROM tickets WHERE parent_id='".$_POST['tictickets_id']."' ";
- $result = mysql_query($query);
- while($row = mysql_fetch_array($result)){
- $sql = "INSERT INTO tickets_product SET tickets_id='".$row['id']."', seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."',enabled=1 ";
- mysql_query($sql);
- }
- }
- }
- }
-
- if(!isset($out))
- $out = '{"action":""}';
-
- $this->set('out',$out);
- }
-
- function ajax_showticketproduct() {
- $out = '';
- if(isset($_POST['tickets_id'])) {
- $query = "SELECT * FROM tickets_product WHERE tickets_id='".$_POST['tickets_id']."' ";
- $result = mysql_query($query);
-
- while($row=mysql_fetch_array($result)) {
- if($out!='') $out .=",";
- $out .= '{ "id":"'.$row['id'].'", "ticcat":"'.$row['seat_name'].'", "ticquantity":"'.$row['seat_qty'].'", "ticprice":"'.$row['seat_price'].'" }';
- }
- }
- $out = '{"data":['.$out.']}';
-
- $this->set('out',$out);
- }
-
- function ajax_resetSeatProduct() {
- $this->layout='blank';
- if(isset($_POST['id'])) {
- $sql = "SELECT id FROM tickets WHERE id='".$_POST['id']."' or parent_id='".$_POST['id']."'";
- $result = mysql_query($sql);
- $listid = array();
- while($row=mysql_fetch_array($result)){
- $listid[] = $row['id'];
- }
-
- if(count($listid)>0){
- $sql= "DELETE FROM tickets_product WHERE tickets_id IN (".join(',',$listid).")";
- mysql_query($sql) or die(mysql_error());
- $sql = "UPDATE tickets SET seatsxml='', chart_id=0 WHERE id IN (".join(',',$listid).")";
- mysql_query($sql) or die(mysql_error());
- }
- }
- $this->render('blank_page');
- }
-
- function ajax_adddatetime() {
- $this->layout='blank';
- $out = '';
- if(isset($_POST['action'])){
- if( isset($_POST['parent_id']) && $_POST['action']=='insert'){
- $parent_ticketid = $_POST['parent_id'];
- if($_POST['action']=='insert'){
- $ticket['Ticket']['parent_id'] = $parent_ticketid;
- $ticket['Ticket']['user_id'] = $_SESSION['UserId'];
- $ticket['Ticket']['is_temp'] = 1;
- $this->Ticket->create();
- $this->Ticket->save($ticket);
- $id = $this->Ticket->id;
- }
- $out = '"action":"insert","id":"'.$id.'"';
- }else if(isset($_POST['id']) && $_POST['action']=='delete'){
- $sql = "DELETE FROM tickets WHERE id='".$_POST['id']."'";
- mysql_query($sql);
- $out = '"action":"delete","id":"'.$_POST['id'].'"';
- }
- }
-
- $out = '{'.$out.'}';
- $this->set('out',$out);
- }
-
- function ajax_checkeventname(){
- $this->layout='blank';
- $out = '"check":"error"';
- if(isset($_POST['id']) && isset($_POST['evname'])){
- $id = base64_decode($_POST['id']);
- $sql = 'SELECT count(id) as _count FROM tickets WHERE id<>"'.$id.'" AND ticevent_name="'.addslashes($_POST['evname']).'" AND parent_id=0 ';
- $result = mysql_query($sql);
- $row = mysql_fetch_array($result) or die(mysql_error());
- if($row['_count']==0){
- $out = '"check":"ok"';
- }
- }
- $out = '{'.$out.'}';
- $this->set('out',$out);
- }
-
- function eventlogoupload() {
- $this->layout='blank';
-
- $uploadstatus = 0;
- $imagefilename= 0;
- if(!isset($_REQUEST['type'])) $_REQUEST['type']='image';
- $type= $_REQUEST['type'];
-
- if (isset($_FILES['filedata'])) {
- $this->cleanUpFields();
-
- // grab the file
- $file = $_FILES['filedata'];
- // upload the image using the upload component
- // pr($_FILES);
- $file_info = getimagesize($file['tmp_name']);
- if(!empty($file_info)) {
-
- $des = "webroot/ticket_images/";
- if(!file_exists($des))
- mkdir($des);
-
- $this->Upload->upload($file,$des);
- if($this->Upload->errors!=null) {
- $this->set('errors',join('<br/>',$this->Upload->errors));
- }
- else {
- $uploadstatus = 1;
- $filesrc = str_replace($des, '', $this->Upload->_name);
- $file['tmp_name'] = $this->Upload->_name;
- if($type=="image") {
- $des = "webroot/ticket_images/medium/";
- if(!file_exists($des))
- mkdir($des);
-
- $this->Upload->_name = $des.$filesrc;
- $this->Upload->image($file,'resizemin',array(200,200),'jpg');
-
- $des = "webroot/ticket_images/thumb/";
- if(!file_exists($des))
- mkdir($des);
-
- $this->Upload->_name = $des.$filesrc;
- $this->Upload->image($file,'resizemin',array(45,45),'jpg');
- }else if($type=="logo") {
- $des = "webroot/ticket_images/logo/";
- if(!file_exists($des))
- mkdir($des);
-
- $this->Upload->_name = $des.$filesrc;
- $this->Upload->image($file,'resizemin',array(100,100),'jpg');
- }
-
- $filethumb = str_replace($des, '', $this->Upload->_name);
-
- //$this->set('filesrc' , $filesrc);
- $this->set('filethumb' , $filethumb);
- }
- }else {
- $this->set('errors','Required file image.');
- }
- }
-
- if(isset($_REQUEST['filesrc']) && $_REQUEST['filesrc']!='') {
- $this->set('filethumb' , $_REQUEST['filesrc']);
- }
- $maxwidth = $type=='logo'?100:200;
- $this->set('maxwidth',$maxwidth);
- $this->set('maxdimension',"$maxwidth x $maxwidth");
- $this->set('uploadstatus',$uploadstatus);
- }
-
- function venueinfo($venueid=null) {
- $this->checkSession();
- $this->layout = 'ticketcategoryinner';
- $this->ticketCategory();
-
- $this->pageTitle = 'View venue';
- $this->set('venueid',$venueid);
- }
-
- function perfomerinfo($perfomerid = null) {
- $this->checkSession();
- $this->layout = 'ticketcategoryinner';
- $this->ticketCategory();
- $this->pageTitle = 'View Perfomer';
- $…
Large files files are truncated, but you can click here to view the full file