PageRenderTime 73ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 1ms

/app/controllers/tickets_controller.php

https://bitbucket.org/fxrialab/tickets
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

  1. <?
  2. class TicketsController extends AppController {
  3. var $name='Tickets';
  4. var $helpers = array('Html','javascript','error','Ajax','common','Phoogle', 'Form','Friendsurl','Newexcel');
  5. var $components = array('Thumbnail','Thumbnailc','Upload','Sendmail','Mysqllocker','Download');
  6. var $uses=array('Ticket','User','Ticket_carts','PaymentTransaction');
  7. function index($uid=null,$keyuserId=null) {
  8. $this->pageTitle = 'Tickets Home';
  9. $this->layout = 'tickethome';
  10. if(!isset($_SESSION['UserId']) && $keyuserId && $uid ) {
  11. $uid = base64_decode($uid);
  12. if(md5('checklogin'.$uid)==$keyuserId) {
  13. $this->login_again($uid);
  14. }
  15. }
  16. $this->homepageslideInfo('Tickets');
  17. $this->ticketCategory();
  18. ################################## Event Location ##########################
  19. /* Turn oN the session for the project state and country*/
  20. if(isset($_SESSION['UserId'])) {
  21. $sql = "SELECT * FROM ticket_carts WHERE user_id='".$_SESSION['UserId']."' AND pay_status='0'";
  22. $result = mysql_query($sql);
  23. while($row = mysql_fetch_array($result)) {
  24. //delete cart
  25. mysql_query("DELETE FROM ticket_cart_details WHERE cart_id='".$row['id']."'") or die(mysql_error());
  26. mysql_query("DELETE FROM ticket_seat_booked WHERE cart_id='".$row['id']."'") or die(mysql_error());
  27. mysql_query("DELETE FROM ticket_carts WHERE id='".$row['id']."'") or die(mysql_error());
  28. }
  29. $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']." ";
  30. $userCountry_res = mysql_query($userCountry);
  31. if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
  32. if(!isset($_SESSION['PrjUserCityName'])) {
  33. $this->Session->write('PrjUserCityName', $userCountry_arr['city']);
  34. $this->Session->write('PrjUserCityId', $userCountry_arr['city']);
  35. }
  36. if(!isset($_SESSION['PrjUserStateId'])) {
  37. $this->Session->write('PrjUserStateId', $userCountry_arr['state']);
  38. $this->Session->write('PrjUserStateName', $userCountry_arr['Name']);
  39. }
  40. if(!isset($_SESSION['PrjUserCountryId'])) {
  41. $this->Session->write('PrjUserCountryId', $userCountry_arr['c_id']);
  42. $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
  43. }
  44. if(!isset($_SESSION['PrjUserLocation'])) {
  45. $locstr=$userCountry_arr['CurrentLocation'];
  46. // $locstr='';
  47. // if($_SESSION['PrjUserStateName']!="")
  48. // $locstr.=$_SESSION['PrjUserStateName'].',' ;
  49. //
  50. // if($_SESSION['PrjUserCountryName']!="")
  51. // $locstr.= $_SESSION['PrjUserCountryName'].',' ;
  52. $this->Session->write('PrjUserLocation',substr($locstr,0,(strlen($locstr)-1)));
  53. }
  54. }
  55. }
  56. else {
  57. $check = false;
  58. if(!isset($_SESSION['PrjUserCountryId'])) {
  59. $this->Session->write('PrjUserCityId', 14967);
  60. $this->Session->write('PrjUserStateId', 168);
  61. $this->Session->write('PrjUserCountryId', 254);
  62. }
  63. if(isset($_SESSION['PrjUserCityId']) && isset($_SESSION['PrjUserStateId']) && isset($_SESSION['PrjUserCountryId'])) {
  64. $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
  65. FROM countries
  66. LEFT JOIN state ON (state.id='".$_SESSION['PrjUserStateId']."' AND state.c_id=countries.id)
  67. LEFT JOIN city_master ON (city_master.city_id='".$_SESSION['PrjUserCityId']."' AND city_master.CountryID=countries.id AND city_master.state_id=state.id)
  68. WHERE countries.id='".$_SESSION['PrjUserCountryId']."' ";
  69. $userCountry_res = mysql_query($sql);
  70. if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
  71. $this->Session->write('PrjUserCityName', $userCountry_arr['CityName']);
  72. $this->Session->write('PrjUserStateName', $userCountry_arr['StateName']);
  73. $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
  74. $this->Session->write('PrjUserLocation',$userCountry_arr['CurrentLocation']);
  75. $check = true;
  76. }
  77. }
  78. if(!$check) {
  79. $userCountry = "select countries.id , countries.country_name from countries Where countries.id = '6'";
  80. $userCountry_res = mysql_query($userCountry);
  81. if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
  82. if(!isset($_SESSION['PrjUserCityName'])) {
  83. $this->Session->write('PrjUserCityName', '');
  84. $this->Session->write('PrjUserCityId', 0);
  85. }
  86. if(!isset($_SESSION['PrjUserStateId'])) {
  87. $this->Session->write('PrjUserStateId', 0);
  88. $this->Session->write('PrjUserStateName', '');
  89. }
  90. if(!isset($_SESSION['PrjUserCountryId'])) {
  91. $this->Session->write('PrjUserCountryId', $userCountry_arr['id']);
  92. $this->Session->write('PrjUserCountryName', $userCountry_arr['country_name']);
  93. }
  94. $locstr='';
  95. if(isset($_SESSION['PrjUserCityName']) && $_SESSION['PrjUserCityName']!="")
  96. $locstr.=$_SESSION['PrjUserCityName'] ;
  97. if(isset($_SESSION['PrjUserStateName']) && $_SESSION['PrjUserStateName']!="")
  98. $locstr.=', '.$_SESSION['PrjUserStateName'] ;
  99. if(isset($_SESSION['PrjUserCountryName']) && $_SESSION['PrjUserCountryName']!="")
  100. $locstr.= $_SESSION['PrjUserCountryName'] ;
  101. $this->Session->write('PrjUserLocation',$locstr);
  102. }
  103. }
  104. }
  105. ###########################################################################
  106. }
  107. function changelocation() {
  108. /* Turn oN the session for the project state and country*/
  109. $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']."";
  110. $userCountry_res = mysql_query($userCountry)or die(mysql_error());
  111. if(($userCountry_arr = mysql_fetch_array($userCountry_res))) {
  112. $this->Session->write('PrjUserCityName', $userCountry_arr['CityName']);
  113. $this->Session->write('PrjUserCityId', $userCountry_arr['CityId']);
  114. $this->Session->write('PrjUserStateId', $userCountry_arr['StateId']);
  115. $this->Session->write('PrjUserStateName', $userCountry_arr['StateName']);
  116. $this->Session->write('PrjUserCountryId', $userCountry_arr['countryId']);
  117. $this->Session->write('PrjUserCountryName', $userCountry_arr['countryName']);
  118. $strloc = '';
  119. if($userCountry_arr['CityName']!='') {
  120. $strloc .= $userCountry_arr['CityName'].', ' ;
  121. }
  122. if($userCountry_arr['StateName']!='') {
  123. $strloc .= $userCountry_arr['StateName'].', ' ;
  124. }
  125. if($userCountry_arr['countryName']!='') {
  126. $strloc .= $userCountry_arr['countryName'] ;
  127. }
  128. $this->Session->write('PrjUserLocation',$strloc);
  129. }
  130. $this->redirect('tickets');
  131. }
  132. function ticketCategory() {
  133. $evtcat = array();
  134. $evtcat['0']="Select Category";
  135. $select_ticket_cat = mysql_query("Select * from ticket_event_category");
  136. while($select_ticket_cat_arr = mysql_fetch_array($select_ticket_cat)) {
  137. $evtcat[$select_ticket_cat_arr['id']] = $select_ticket_cat_arr['cat_name'];
  138. }
  139. $this->set('ticketcat',$evtcat);
  140. }
  141. function recentticket() {
  142. $this->layout = 'profile_blank';
  143. $this->ticketCategory();
  144. $curDate=date("Y-m-d");
  145. if(isset($_SESSION['PrjUserCityId']))
  146. $city=$_SESSION['PrjUserCityId'];
  147. if(isset($_SESSION['PrjUserStateId']))
  148. $state=$_SESSION['PrjUserStateId'];
  149. if(isset($_SESSION['PrjUserCountryId']))
  150. $country=$_SESSION['PrjUserCountryId'];
  151. $pageFlag=null;
  152. $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";
  153. $from=" FROM tickets T
  154. LEFT JOIN ticket_event_venue TV ON (T.ticket_venue_section_id=TV.id)
  155. LEFT JOIN ticket_event_category TCAT ON (T.ticket_category_id=TCAT.id)
  156. LEFT JOIN users USR ON (T.user_id=USR.id)
  157. ";
  158. $where="WHERE T.is_temp='0' AND (NOW() < ticevent_enddate) AND parent_id=0";
  159. if(isset($city) && $city!=0)
  160. $where.=" AND TV.venue_city_id='".$city."'";
  161. if(isset($state) && $state!=0)
  162. $where.=" AND TV.venue_state_id='".$state."'";
  163. if(isset($country) && $country!=0)
  164. $where.=" AND TV.venue_country_id='".$country."'";
  165. $where.=" ORDER BY T.ticevent_startdate ";
  166. $CountField='T.id';
  167. $SelectRecord = mysql_query("$select $from $where LIMIT 12") or die('Line no '.__LINE__ . mysql_error());
  168. $this->set("ticketQry",$SelectRecord);
  169. $this->render('hotticket','ajax');
  170. }
  171. function category() {
  172. $catid=0;
  173. $searchpass ='';
  174. $this->layout = 'ticketdetail';
  175. $this->ticketCategory();
  176. $curDate=date("Y-m-d");
  177. $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";
  178. $from=" FROM tickets T
  179. LEFT JOIN ticket_event_venue TV ON (T.ticket_venue_section_id=TV.id)
  180. LEFT JOIN ticket_event_category TCAT ON (T.ticket_category_id=TCAT.id)
  181. LEFT JOIN users USR ON (T.user_id=USR.id)
  182. ";
  183. $where="WHERE T.is_temp='0' AND (NOW() < ticevent_enddate) AND parent_id>0";
  184. if(isset($this->params['pass']['0'])) {
  185. $catid=base64_decode($this->params['pass']['0']);
  186. }
  187. if(isset($this->data['Ticket']['ticketcat']) && $this->data['Ticket']['ticketcat']>0) {
  188. $catid = $this->data['Ticket']['ticketcat'];
  189. }
  190. if(isset($_REQUEST['catid']) && $_REQUEST['catid']!='') {
  191. $catid = $_REQUEST['catid'];
  192. }
  193. if(isset($this->data['Ticket']['srchtect']) && $this->data['Ticket']['srchtect']!="" && $this->data['Ticket']['srchtect']!="Event name or zip") {
  194. $srchtect = addslashes($this->data['Ticket']['srchtect']);
  195. }
  196. if(isset($_REQUEST['srchtect']) && $_REQUEST['srchtect']!='') {
  197. $srchtect = addslashes($_REQUEST['srchtect']);
  198. }
  199. if(isset($this->data['Ticket']['srchdate']) && $this->data['Ticket']['srchdate']!=0) {
  200. $ticDate = $this->data['Ticket']['srchdate'];
  201. }
  202. if(isset($_REQUEST['ticDate']) && $_REQUEST['ticDate']!='') {
  203. $ticDate = $_REQUEST['ticDate'];
  204. }
  205. if(isset($_SESSION['PrjUserCityId']))
  206. $city=$_SESSION['PrjUserCityId'];
  207. if(isset($_SESSION['PrjUserStateId']))
  208. $state=$_SESSION['PrjUserStateId'];
  209. if(isset($_SESSION['PrjUserCountryId']))
  210. $country=$_SESSION['PrjUserCountryId'];
  211. if(isset($catid) && $catid>0) {
  212. $where.= " AND T.ticket_category_id='".$catid."' ";
  213. }
  214. if(isset($city) && $city!=0)
  215. $where.=" AND TV.venue_city_id='".$city."'";
  216. if(isset($state) && $state!=0)
  217. $where.=" AND TV.venue_state_id='".$state."'";
  218. if(isset($country) && $country!=0)
  219. $where.=" AND TV.venue_country_id='".$country."'";
  220. if(isset($srchtect) && $srchtect!='') {
  221. $where.= " AND ( T.ticevent_name LIKE '%".$srchtect."%' OR (TV.venue_zip!=0 AND TV.venue_zip='".$srchtect."')) ";
  222. $searchpass .= '&srchtect='.$srchtect;
  223. }
  224. if(isset($ticDate) && $ticDate!='') {
  225. $where.=" AND T.ticevent_startdate<='".$ticDate."'";
  226. $searchpass .= '&ticDate='.$ticDate;
  227. }
  228. $others = 'ORDER BY T.ticevent_startdate';
  229. $this->set('catid',$catid);
  230. $PassParameter='catid='.$catid.$searchpass;
  231. $CountField="T.id";
  232. $this->set("controller","tickets");
  233. $this->set("action","category");
  234. $this->set("parameter",$PassParameter);
  235. $this->set('elementsUpdate',array('backdroplist','relatedevent'));
  236. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  237. if(isset($this->params['url']['Page']) || isset($_REQUEST['form_ajax']) ) {
  238. $this->render("category2","ajax");
  239. }
  240. }
  241. function saveperformer() {
  242. $inserintoperfomer_id =0;
  243. if(isset($_POST['add']) && $_POST['add']==1) {
  244. $sql = "INSERT INTO ticket_event_performer SET user_id='".$_SESSION['UserId']."'";
  245. mysql_query($sql);
  246. $inserintoperfomer_id = mysql_insert_id();
  247. }else if(isset($_POST['deleteorg']) && isset($_POST['oid']) && $_POST['deleteorg']==1) {
  248. $sql = "DELETE FROM ticket_event_performer WHERE id='".$_POST['oid']."'";
  249. mysql_query($sql);
  250. $inserintoperfomer_id = $_POST['oid'];
  251. }
  252. else if(isset($_POST['editorg']) && isset($_POST['oid']) && $_POST['editorg']==1 && $_POST['oid']!=0) {
  253. $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'])."'
  254. , performer_address = '".addslashes($_POST['address'])."', performer_zip = '".addslashes($_POST['zip'])."', performer_country='".$_POST['country']."', performer_state='".$_POST['state']."', performer_city='".$_POST['city']."'
  255. WHERE id='".addslashes($_POST['oid'])."' AND user_id='".$_SESSION['UserId']."'";
  256. mysql_query($sql) or die($sql);
  257. $inserintoperfomer_id = $_POST['oid'];
  258. }
  259. $this->set('id',$inserintoperfomer_id);
  260. }
  261. function create($tidCopy=null) {
  262. //$this->checkSession();
  263. $this->layout = 'ticket_create';
  264. if(!isset($_SESSION['UserId'])) {
  265. //$this->Session->write('actContinue','tickets/create');
  266. }else {
  267. $this->set('countrylist',$this->getCountryList());
  268. $sql = "SELECT * FROM ticket_event_performer WHERE user_id='".$_SESSION['UserId']."' AND blocked='0'";
  269. $this->set('performerlist',mysql_query($sql));
  270. $this->ticketCategory();
  271. $this->set('stateList',array('0'=>'Select State'));
  272. $this->set('cityList',array('0'=>'Select City'));
  273. $ticketsql_id=0;
  274. if(isset($_POST['t']) && md5(md5('save'))==$_POST['t']) {
  275. if(isset($_POST['tid']) && $_POST['tid']!='') {
  276. $ticketsql_id = base64_decode($_POST['tid']);
  277. $sql = 'SELECT * FROM tickets WHERE id="'.$ticketsql_id.'" AND user_id="'.$_SESSION['UserId'].'"';
  278. $result = mysql_query($sql);
  279. if(($row=mysql_fetch_array($result))) {
  280. //update ticket_event_venue
  281. $ticket_venue_section_id = $row['ticket_venue_section_id'];
  282. $sql = "UPDATE ticket_event_venue SET venue_name='".addslashes($_REQUEST['venue_name'])."' , venue_desc = '',venue_address='".addslashes($_REQUEST['address_1'])."',
  283. venue_city_id='".$_REQUEST['city']."',venue_state_id='".$_REQUEST['province']."',venue_country_id='".$_REQUEST['country']."',venue_zip='".$_REQUEST['postal_code']."', venue_phone='".$_REQUEST['phone']."'
  284. WHERE id='".$ticket_venue_section_id."'";
  285. mysql_query($sql) or die(mysql_error());
  286. }
  287. }
  288. if(!isset($ticket_venue_section_id) || $ticket_venue_section_id==0) {
  289. //save venue
  290. $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'])."',
  291. venue_city_id='".$_REQUEST['city']."',venue_state_id='".$_REQUEST['province']."',venue_country_id='".$_REQUEST['country']."',venue_zip='".$_REQUEST['postal_code']."', venue_phone='".$_REQUEST['phone']."' ";
  292. mysql_query($sql) or die(mysql_error());
  293. $ticket_venue_section_id = mysql_insert_id();
  294. }
  295. if($ticketsql_id!='' && $ticketsql_id!=0) {
  296. $ticketsql = "UPDATE tickets SET
  297. ticevent_name = '".addslashes($_POST['evname'])."', paypal_email = '".addslashes($_POST['paypal_email'])."',
  298. ticket_category_id='".$_POST['channels']."',
  299. ticevent_desc='".addslashes($_POST['description'])."', ticevent_terms='".addslashes($_POST['terms'])."',
  300. ticket_event_performer_id='".$_POST['savedOrganizers']."', ticket_venue_section_id='".$ticket_venue_section_id."',
  301. ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
  302. ticevent_image='".addslashes($_POST['image'])."', ticevent_logoimage='".addslashes($_POST['logo'])."',
  303. is_featured='0', is_hotlisted='0',
  304. timezone_id='".addslashes($_POST['timezone'])."',
  305. ticket_tags='".addslashes($_POST['tags'])."', is_show_remaining='".(isset($_POST['show_remaining'])?1:0)."',
  306. is_temp='".$_POST['is_temp']."', seating_type='".$_POST['seating_type']."', is_public='".(isset($_POST['show_public'])?1:0)."'
  307. ".(!isset($_POST['show_public']) ? ", password_private='".$_POST['password_private']."'" : '')."
  308. WHERE id='".$ticketsql_id."' ";
  309. //ticevent_startdate='".$start_date."', ticevent_enddate='".$end_date."', ticket_dooropen='".$dooropen."',
  310. mysql_query($ticketsql) or die($ticketsql);
  311. }else {
  312. $ticketsql = "INSERT INTO tickets SET
  313. ticevent_name = '".addslashes($_POST['evname'])."', paypal_email = '".addslashes($_POST['paypal_email'])."',
  314. ticket_category_id='".$_POST['channels']."',
  315. ticevent_desc='".addslashes($_POST['description'])."', ticevent_terms='".addslashes($_POST['terms'])."',
  316. ticket_event_performer_id='".$_POST['savedOrganizers']."', ticket_venue_section_id='".$ticket_venue_section_id."',
  317. ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
  318. ticevent_image='".addslashes($_POST['image'])."', ticevent_logoimage='".addslashes($_POST['logo'])."',
  319. is_featured='0', is_hotlisted='0',
  320. timezone_id='".addslashes($_POST['timezone'])."',
  321. ticket_tags='".addslashes($_POST['tags'])."', is_show_remaining='".(isset($_POST['show_remaining'])?1:0)."',
  322. is_temp='".$_POST['is_temp']."', seating_type='".$_POST['seating_type']."', is_public='".(isset($_POST['show_public'])?1:0)."'
  323. ".(!isset($_POST['show_public']) ? ", password_private='".$_POST['password_private']."'" : '');
  324. mysql_query($ticketsql) or die($ticketsql);
  325. $ticketsql_id = mysql_insert_id();
  326. }
  327. //update datetime
  328. foreach($_REQUEST['customDates'] as $key=>$value){
  329. $customDates = split('startDate', $value);
  330. $start_date = $customDates[0];
  331. $customDates = $customDates[1];
  332. $customDates = split('startTime', $customDates);
  333. $start_time = $customDates[0];
  334. $customDates = $customDates[1];
  335. $customDates = split('endDate', $customDates);
  336. $end_date = $customDates[0];
  337. $customDates = $customDates[1];
  338. $customDates = split('endTime', $customDates);
  339. $end_time = $customDates[0];
  340. $dooropen = $customDates[1];
  341. $start_date = split('/', $start_date);
  342. $start_date = $start_date[2].'-'.$start_date[0].'-'.$start_date[1].' '.$start_time;
  343. $end_date = split('/', $end_date);
  344. $end_date = $end_date[2].'-'.$end_date[0].'-'.$end_date[1].' '.$end_time;
  345. $sql = "UPDATE tickets SET ticevent_startdate='".$start_date."', ticevent_enddate='".$end_date."', ticket_dooropen='".$dooropen."'
  346. WHERE id='".$key."'";
  347. mysql_query($sql) or die($sql);
  348. }
  349. //update for children
  350. //get list id children
  351. $sql = "SELECT id FROM tickets WHERE parent_id='".$ticketsql_id."'";
  352. $result = mysql_query($sql);
  353. $listid = array();
  354. while($row=mysql_fetch_array($result)){
  355. $listid[] = $row['id'];
  356. }
  357. if(count($listid)>0){
  358. //info ticket parent
  359. $sql = "SELECT * FROM tickets WHERE id='".$ticketsql_id."'";
  360. $result = mysql_query($sql);
  361. $parent = mysql_fetch_array($result);
  362. //update information public
  363. $ticketsql = "UPDATE tickets SET
  364. ticevent_name = '".$parent['ticevent_name']."', paypal_email = '".$parent['paypal_email']."',
  365. ticket_category_id='".$parent['ticket_category_id']."',
  366. ticevent_desc='".$parent['ticevent_desc']."', ticevent_terms='".$parent['ticevent_terms']."',
  367. ticket_event_performer_id='".$parent['ticket_event_performer_id']."', ticket_venue_section_id='".$parent['ticket_venue_section_id']."',
  368. ticket_ship_master_id='1', user_id='".$parent['user_id']."',
  369. ticevent_image='".$parent['ticevent_image']."', ticevent_logoimage='".$parent['ticevent_logoimage']."',
  370. is_featured='0', is_hotlisted='0',
  371. timezone_id='".$parent['timezone_id']."',
  372. ticket_tags='".$parent['ticket_tags']."', is_show_remaining='".$parent['is_show_remaining']."',
  373. is_temp='".$parent['is_temp']."', seating_type='".$parent['seating_type']."', is_public='".$parent['is_public']."',
  374. password_private='".$parent['password_private']."'
  375. WHERE id IN (".join(',',$listid).") ";
  376. mysql_query($ticketsql) or die($ticketsql);
  377. //update product
  378. if($parent['seating_type']==0){
  379. $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$parent['id']."'";
  380. $result = mysql_query($sql) or die($sql);
  381. while($p = mysql_fetch_array($result)){
  382. foreach($listid as $ticket_child){
  383. $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$ticket_child."' AND seat_name='".$p['seat_name']."' ";
  384. $result_p = mysql_query($sql) or die($sql);
  385. if(!($row=mysql_fetch_array($result_p))){
  386. $sql = "INSERT tickets_product SET tickets_id='".$ticket_child."', seat_name='".$p['seat_name']."',
  387. seat_qty='".$p['seat_qty']."', seat_price='".$p['seat_price']."',color='".$p['color']."',
  388. enabled='".$p['enabled']."', handicap='".$p['handicap']."' ";
  389. mysql_query($sql) or die($sql);
  390. }
  391. }
  392. }
  393. }
  394. }
  395. if(isset($_POST['is_temp'])) {
  396. $this->redirect('tickets/index');
  397. }
  398. $this->set('updated',1);
  399. }
  400. if(isset($_REQUEST['tid']) && $_REQUEST['tid']!='') {
  401. $ticketsql_id = base64_decode($_REQUEST['tid']);
  402. }
  403. if(isset($_POST['is_preview']) && $_POST['is_preview']==1) {
  404. $this->redirect('tickets/previewevent/'.base64_encode($ticketsql_id));
  405. }
  406. if($tidCopy!=null) {
  407. $tidCopy = base64_decode($tidCopy);
  408. $sql = "SELECT * FROM tickets
  409. WHERE id='".addslashes($tidCopy)."' AND user_id='".$_SESSION['UserId']."' ";
  410. $result = mysql_query($sql);
  411. if(($row=mysql_fetch_array($result))) {
  412. //Insert ticket_event_venue
  413. $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`)
  414. SELECT `venue_name`,`venue_address`,`venue_phone`,`venue_city_id`,`venue_state_id`,`venue_country_id`,`user_id`,`venue_desc`,`venue_zip`
  415. FROM ticket_event_venue WHERE id=".$row['ticket_venue_section_id'];
  416. mysql_query($sql)or die(mysql_errno());
  417. $ticket_venue_section_id = mysql_insert_id();
  418. $ticketsql = "INSERT INTO tickets SET
  419. ticevent_name = '".$row['ticevent_name']." copy', paypal_email='".$row['paypal_email']."',
  420. ticevent_startdate='".$row['ticevent_startdate']."', ticevent_enddate='".$row['ticevent_enddate']."', ticket_dooropen='".$row['ticket_dooropen']."',
  421. ticket_category_id='".$row['ticket_category_id']."',
  422. ticevent_desc='".$row['ticevent_desc']."', ticevent_terms='".$row['ticevent_terms']."',
  423. ticket_event_performer_id='".$row['ticket_event_performer_id']."', ticket_venue_section_id='".$ticket_venue_section_id."',
  424. ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
  425. ticevent_image='".$row['ticevent_image']."', ticevent_logoimage='".$row['ticevent_logoimage']."',
  426. is_featured='0', is_hotlisted='0',
  427. timezone_id='".$row['timezone_id']."',
  428. ticket_tags='".$row['ticket_tags']."', is_show_remaining='".$row['is_show_remaining']."',
  429. is_temp='1', seating_type='".$row['seating_type']."',
  430. is_public='".$row['is_public']."',password_private='".$row['password_private']."'";
  431. mysql_query($ticketsql) or die(mysql_errno());
  432. $ticketsql_id = mysql_insert_id();
  433. $seatsxml = $row['seatsxml'];
  434. $seatsxml_new = $seatsxml;
  435. //insert tickets_product
  436. $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$row['id']."' ";
  437. $result = mysql_query($sql)or die($sql);
  438. $listp = array();
  439. while($row = mysql_fetch_array($result)) {
  440. $listp[] = $row;
  441. $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']."',
  442. color='".$row['color']."', enabled='".$row['enabled']."',handicap='".$row['handicap']."' ";
  443. mysql_query($sql)or die(mysql_errno());
  444. if($seatsxml_new!=''){
  445. $product_id_new = mysql_insert_id();
  446. //update id for product
  447. $old = '/id="'.$row['id'].'"/';
  448. $new = 'id="'.$product_id_new.'"';
  449. $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
  450. //update group_id for seat, shape
  451. $old = '/group_id="'.$row['id'].'"/';
  452. $new = 'group_id="'.$product_id_new.'"';
  453. $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
  454. }
  455. }
  456. $sql= "UPDATE tickets SET seatsxml='".$seatsxml_new."' WHERE id='".$ticketsql_id."'";
  457. mysql_query($sql)or die(mysql_errno());
  458. //check add children
  459. $sql = "SELECT * FROM tickets WHERE parent_id='".addslashes($tidCopy)."' AND user_id='".$_SESSION['UserId']."' ";
  460. $result = mysql_query($sql);
  461. while($child=mysql_fetch_array($result)){
  462. //insert ticket
  463. $ticketsql = "INSERT INTO tickets SET
  464. parent_id='".$ticketsql_id."',
  465. ticevent_name = '".$child['ticevent_name']." copy', paypal_email='".$child['paypal_email']."',
  466. ticevent_startdate='".$child['ticevent_startdate']."', ticevent_enddate='".$child['ticevent_enddate']."', ticket_dooropen='".$child['ticket_dooropen']."',
  467. ticket_category_id='".$child['ticket_category_id']."',
  468. ticevent_desc='".$child['ticevent_desc']."', ticevent_terms='".$child['ticevent_terms']."',
  469. ticket_event_performer_id='".$child['ticket_event_performer_id']."', ticket_venue_section_id='".$ticket_venue_section_id."',
  470. ticket_ship_master_id='1', user_id='".$_SESSION['UserId']."',
  471. ticevent_image='".$child['ticevent_image']."', ticevent_logoimage='".$child['ticevent_logoimage']."',
  472. is_featured='0', is_hotlisted='0',
  473. timezone_id='".$child['timezone_id']."',
  474. ticket_tags='".$child['ticket_tags']."', is_show_remaining='".$child['is_show_remaining']."',
  475. is_temp='1', seating_type='".$child['seating_type']."',
  476. is_public='".$child['is_public']."', password_private='".$child['password_private']."'";
  477. mysql_query($ticketsql) or die(mysql_errno());
  478. $child_new_id = mysql_insert_id();
  479. //insert product
  480. $seatsxml_new = $seatsxml;
  481. foreach($listp as $p){
  482. $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']."',
  483. color='".$p['color']."', enabled='".$p['enabled']."',handicap='".$p['handicap']."' ";
  484. mysql_query($sql)or die(mysql_errno());
  485. if($seatsxml_new!=''){
  486. $product_id_new = mysql_insert_id();
  487. //update id for product
  488. $old = '/id="'.$p['id'].'"/';
  489. $new = 'id="'.$product_id_new.'"';
  490. $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
  491. //update group_id for seat, shape
  492. $old = '/group_id="'.$p['id'].'"/';
  493. $new = 'group_id="'.$product_id_new.'"';
  494. $seatsxml_new = preg_replace($old,$new , $seatsxml_new);
  495. }
  496. }
  497. $sql= "UPDATE tickets SET seatsxml='".$seatsxml_new."' WHERE id='".$child_new_id."'";
  498. mysql_query($sql)or die(mysql_errno());
  499. }
  500. }
  501. }
  502. if($ticketsql_id>0) {
  503. $sql = "SELECT tickets.*,tickets.id as tid,Venue.* FROM tickets
  504. LEFT JOIN ticket_event_venue Venue ON (Venue.id=tickets.ticket_venue_section_id)
  505. WHERE tickets.id='".addslashes($ticketsql_id)."' AND tickets.user_id='".$_SESSION['UserId']."' ";
  506. $result = mysql_query($sql);
  507. if(($row=mysql_fetch_array($result))) {
  508. $this->set('data',$row);
  509. if($row['seating_type']=='0') {
  510. //get ticket product
  511. $sql = "SELECT * FROM tickets_product WHERE tickets_id='".$row['tid']."'";
  512. $this->set('tickets_seat', mysql_query($sql));
  513. }
  514. if($row['venue_country_id']>=0) {
  515. $this->set('stateList',$this->getStateList($row['venue_country_id']));
  516. }
  517. if($row['venue_state_id']>=0) {
  518. $this->set('cityList',$this->getCityList($row['venue_state_id']));
  519. }
  520. $this->set('tid',$ticketsql_id);
  521. //get datetime children
  522. $sql = "SELECT id,ticevent_startdate,ticevent_enddate,ticket_dooropen FROM tickets WHERE parent_id='".$ticketsql_id."'";
  523. $result = mysql_query($sql);
  524. $datetimes = array();
  525. while($row=mysql_fetch_array($result)){
  526. $datetimes[] = $row;
  527. }
  528. if(count($datetimes)>0)
  529. $this->set('datetimes',$datetimes);
  530. }
  531. }else {//new
  532. //delete all tickets is_temp='1' and title=''
  533. $sql = "SELECT id FROM tickets WHERE is_temp='1' AND ticevent_name='' AND user_id='".$_SESSION['UserId']."'";
  534. $result = mysql_query($sql);
  535. while($row=mysql_fetch_array($result)){
  536. mysql_query("DELETE FROM tickets WHERE id='".$row['id']."'");
  537. mysql_query("DELETE FROM tickets_product WHERE tickets_id='".$row['id']."'");
  538. }
  539. //insert tickets empty
  540. $query = "INSERT tickets SET is_temp='1', user_id='".$_SESSION['UserId']."'";
  541. mysql_query($query);
  542. $ticketsql_id = mysql_insert_id();
  543. $this->set('tid',$ticketsql_id);
  544. }
  545. }
  546. }
  547. function ajax_saveticketseat() {
  548. $this->layout = 'blank';
  549. if(isset($_POST['tic_action']) && $_POST['tic_action']!='') {
  550. if(isset($_POST['tic_id']) && $_POST['tic_id']>0) {
  551. if(isset($_POST['tic_action'])) {
  552. if($_POST['tic_action']=='delete') {
  553. $sql = "SELECT * FROM tickets_product WHERE id='".$_POST['tic_id']."'";
  554. $result = mysql_query($sql);
  555. if(($row=mysql_fetch_array($result))){
  556. $seat_name = $row['seat_name'];
  557. $sql = "SELECT P.id FROM tickets_product as P
  558. RIGHT JOIN tickets as T ON P.tickets_id=T.id
  559. WHERE T.parent_id='".$_POST['tictickets_id']."'";
  560. $result = mysql_query($sql);
  561. $listid = array();
  562. while($row=mysql_fetch_array($result)){
  563. $listid[] = $row['id'];
  564. }
  565. if(count($listid)>0){
  566. $sql = "DELETE FROM tickets_product WHERE id='".$_POST['tic_id']."' OR (id IN (".join(',',$listid).") AND seat_name='".$seat_name."')";
  567. }else{
  568. $sql = "DELETE FROM tickets_product WHERE id='".$_POST['tic_id']."'";
  569. }
  570. mysql_query($sql) or die(mysql_error());
  571. }
  572. $id = $_POST['tic_id'];
  573. $out ='{"action":"delete","id" : "'.$id.'"}';
  574. }
  575. else {
  576. $sql = "SELECT * FROM tickets_product WHERE id='".$_POST['tic_id']."'";
  577. $result = mysql_query($sql);
  578. if(($row=mysql_fetch_array($result))){
  579. $seat_name = $row['seat_name'];
  580. //check
  581. $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']."'";
  582. $result = mysql_query($query);
  583. $row= mysql_fetch_array($result);
  584. if($row['_count']>0){
  585. $out ='{"error":"Ticket Name Unavailable"}';
  586. }else if($_POST['ticprice']<5){
  587. $out ='{"error":"Minimum price is $5"}';
  588. }else{
  589. $sql = "SELECT P.id FROM tickets_product as P
  590. RIGHT JOIN tickets as T ON P.tickets_id=T.id
  591. WHERE T.parent_id='".$_POST['tictickets_id']."'";
  592. $result = mysql_query($sql);
  593. $listid = array();
  594. while($row=mysql_fetch_array($result)){
  595. $listid[] = $row['id'];
  596. }
  597. if(count($listid)>0){
  598. $sql = "UPDATE tickets_product SET seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."'
  599. WHERE id='".$_POST['tic_id']."' OR (id IN (".join(',',$listid).") AND seat_name='".$seat_name."')";
  600. }else{
  601. $sql = "UPDATE tickets_product SET seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."'
  602. WHERE id='".$_POST['tic_id']."'";
  603. }
  604. mysql_query($sql);
  605. $id = $_POST['tic_id'];
  606. $out ='{"action":"update","id" : "'.$id.'","ticcat": "'.$_POST['ticcat'].'", "ticquantity": "'.$_POST['ticquantity'].'", "ticprice": "'.$_POST['ticprice'].'"}';
  607. }
  608. }
  609. }
  610. }
  611. }else {
  612. //check seat_name
  613. $query = "SELECT count(id) as _count FROM tickets_product WHERE tickets_id='".$_POST['tictickets_id']."' AND seat_name='".$_POST['ticcat']."'";
  614. $result = mysql_query($query);
  615. $row= mysql_fetch_array($result);
  616. if($row['_count']>0){
  617. $out ='{"error":"Ticket Name Unavailable"}';
  618. }else if($_POST['ticprice']<5){
  619. $out ='{"error":"Minimum price is $5"}';
  620. }else{
  621. $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 ";
  622. mysql_query($sql);
  623. $id = mysql_insert_id();
  624. $out ='{"action":"insert","id" : "'.$id.'","ticcat": "'.$_POST['ticcat'].'", "ticquantity": "'.$_POST['ticquantity'].'", "ticprice": "'.$_POST['ticprice'].'"}';
  625. $query = "SELECT id FROM tickets WHERE parent_id='".$_POST['tictickets_id']."' ";
  626. $result = mysql_query($query);
  627. while($row = mysql_fetch_array($result)){
  628. $sql = "INSERT INTO tickets_product SET tickets_id='".$row['id']."', seat_name='".$_POST['ticcat']."', seat_qty='".$_POST['ticquantity']."', seat_price='".$_POST['ticprice']."',enabled=1 ";
  629. mysql_query($sql);
  630. }
  631. }
  632. }
  633. }
  634. if(!isset($out))
  635. $out = '{"action":""}';
  636. $this->set('out',$out);
  637. }
  638. function ajax_showticketproduct() {
  639. $out = '';
  640. if(isset($_POST['tickets_id'])) {
  641. $query = "SELECT * FROM tickets_product WHERE tickets_id='".$_POST['tickets_id']."' ";
  642. $result = mysql_query($query);
  643. while($row=mysql_fetch_array($result)) {
  644. if($out!='') $out .=",";
  645. $out .= '{ "id":"'.$row['id'].'", "ticcat":"'.$row['seat_name'].'", "ticquantity":"'.$row['seat_qty'].'", "ticprice":"'.$row['seat_price'].'" }';
  646. }
  647. }
  648. $out = '{"data":['.$out.']}';
  649. $this->set('out',$out);
  650. }
  651. function ajax_resetSeatProduct() {
  652. $this->layout='blank';
  653. if(isset($_POST['id'])) {
  654. $sql = "SELECT id FROM tickets WHERE id='".$_POST['id']."' or parent_id='".$_POST['id']."'";
  655. $result = mysql_query($sql);
  656. $listid = array();
  657. while($row=mysql_fetch_array($result)){
  658. $listid[] = $row['id'];
  659. }
  660. if(count($listid)>0){
  661. $sql= "DELETE FROM tickets_product WHERE tickets_id IN (".join(',',$listid).")";
  662. mysql_query($sql) or die(mysql_error());
  663. $sql = "UPDATE tickets SET seatsxml='', chart_id=0 WHERE id IN (".join(',',$listid).")";
  664. mysql_query($sql) or die(mysql_error());
  665. }
  666. }
  667. $this->render('blank_page');
  668. }
  669. function ajax_adddatetime() {
  670. $this->layout='blank';
  671. $out = '';
  672. if(isset($_POST['action'])){
  673. if( isset($_POST['parent_id']) && $_POST['action']=='insert'){
  674. $parent_ticketid = $_POST['parent_id'];
  675. if($_POST['action']=='insert'){
  676. $ticket['Ticket']['parent_id'] = $parent_ticketid;
  677. $ticket['Ticket']['user_id'] = $_SESSION['UserId'];
  678. $ticket['Ticket']['is_temp'] = 1;
  679. $this->Ticket->create();
  680. $this->Ticket->save($ticket);
  681. $id = $this->Ticket->id;
  682. }
  683. $out = '"action":"insert","id":"'.$id.'"';
  684. }else if(isset($_POST['id']) && $_POST['action']=='delete'){
  685. $sql = "DELETE FROM tickets WHERE id='".$_POST['id']."'";
  686. mysql_query($sql);
  687. $out = '"action":"delete","id":"'.$_POST['id'].'"';
  688. }
  689. }
  690. $out = '{'.$out.'}';
  691. $this->set('out',$out);
  692. }
  693. function ajax_checkeventname(){
  694. $this->layout='blank';
  695. $out = '"check":"error"';
  696. if(isset($_POST['id']) && isset($_POST['evname'])){
  697. $id = base64_decode($_POST['id']);
  698. $sql = 'SELECT count(id) as _count FROM tickets WHERE id<>"'.$id.'" AND ticevent_name="'.addslashes($_POST['evname']).'" AND parent_id=0 ';
  699. $result = mysql_query($sql);
  700. $row = mysql_fetch_array($result) or die(mysql_error());
  701. if($row['_count']==0){
  702. $out = '"check":"ok"';
  703. }
  704. }
  705. $out = '{'.$out.'}';
  706. $this->set('out',$out);
  707. }
  708. function eventlogoupload() {
  709. $this->layout='blank';
  710. $uploadstatus = 0;
  711. $imagefilename= 0;
  712. if(!isset($_REQUEST['type'])) $_REQUEST['type']='image';
  713. $type= $_REQUEST['type'];
  714. if (isset($_FILES['filedata'])) {
  715. $this->cleanUpFields();
  716. // grab the file
  717. $file = $_FILES['filedata'];
  718. // upload the image using the upload component
  719. // pr($_FILES);
  720. $file_info = getimagesize($file['tmp_name']);
  721. if(!empty($file_info)) {
  722. $des = "webroot/ticket_images/";
  723. if(!file_exists($des))
  724. mkdir($des);
  725. $this->Upload->upload($file,$des);
  726. if($this->Upload->errors!=null) {
  727. $this->set('errors',join('<br/>',$this->Upload->errors));
  728. }
  729. else {
  730. $uploadstatus = 1;
  731. $filesrc = str_replace($des, '', $this->Upload->_name);
  732. $file['tmp_name'] = $this->Upload->_name;
  733. if($type=="image") {
  734. $des = "webroot/ticket_images/medium/";
  735. if(!file_exists($des))
  736. mkdir($des);
  737. $this->Upload->_name = $des.$filesrc;
  738. $this->Upload->image($file,'resizemin',array(200,200),'jpg');
  739. $des = "webroot/ticket_images/thumb/";
  740. if(!file_exists($des))
  741. mkdir($des);
  742. $this->Upload->_name = $des.$filesrc;
  743. $this->Upload->image($file,'resizemin',array(45,45),'jpg');
  744. }else if($type=="logo") {
  745. $des = "webroot/ticket_images/logo/";
  746. if(!file_exists($des))
  747. mkdir($des);
  748. $this->Upload->_name = $des.$filesrc;
  749. $this->Upload->image($file,'resizemin',array(100,100),'jpg');
  750. }
  751. $filethumb = str_replace($des, '', $this->Upload->_name);
  752. //$this->set('filesrc' , $filesrc);
  753. $this->set('filethumb' , $filethumb);
  754. }
  755. }else {
  756. $this->set('errors','Required file image.');
  757. }
  758. }
  759. if(isset($_REQUEST['filesrc']) && $_REQUEST['filesrc']!='') {
  760. $this->set('filethumb' , $_REQUEST['filesrc']);
  761. }
  762. $maxwidth = $type=='logo'?100:200;
  763. $this->set('maxwidth',$maxwidth);
  764. $this->set('maxdimension',"$maxwidth x $maxwidth");
  765. $this->set('uploadstatus',$uploadstatus);
  766. }
  767. function venueinfo($venueid=null) {
  768. $this->checkSession();
  769. $this->layout = 'ticketcategoryinner';
  770. $this->ticketCategory();
  771. $this->pageTitle = 'View venue';
  772. $this->set('venueid',$venueid);
  773. }
  774. function perfomerinfo($perfomerid = null) {
  775. $this->checkSession();
  776. $this->layout = 'ticketcategoryinner';
  777. $this->ticketCategory();
  778. $this->pageTitle = 'View Perfomer';
  779. $

Large files files are truncated, but you can click here to view the full file