PageRenderTime 30ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/app/controllers/passport_controller.php

https://bitbucket.org/fxrialab/tickets
PHP | 460 lines | 368 code | 76 blank | 16 comment | 68 complexity | 45adf78d3adc581882f8b61e68502571 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
  1. <?php
  2. class PassportController extends AppController
  3. {
  4. var $name='Passport';
  5. var $components = array('Pagination','Upload','Image');
  6. var $helpers = array('Pagination', 'error','Ajax');
  7. function managephotolab()
  8. {
  9. $this->checkSession();
  10. $this->layout = 'default_user_cat';
  11. $arrPhotolab = array();
  12. $photosql = "SELECT passport_photolab.* from passport_photolab
  13. LEFT JOIN countries ON passport_photolab.lab_country = countries.id
  14. LEFT JOIN state On passport_photolab.lab_state = state.id
  15. LEFT JOIN city_master ON passport_photolab.lab_city =city_master.city_id
  16. ";
  17. $photosql .=" ORDER BY passport_photolab.id desc ";
  18. if(isset($limit) && $limit>0)
  19. $photosql .=" LIMIT ".$limit;
  20. $photosql_res = mysql_query($photosql);
  21. $photosql_num = mysql_num_rows($photosql_res);
  22. while($photosql_arr = mysql_query($photosql_res))
  23. {
  24. $arrPhotolab[] = array('id'=>$photosql_arr['id'],'lab_name'=>$photosql_arr['lab_name'],'lab_address'=>$photosql_arr['lab_address']);
  25. }
  26. $this->set('arrphotolab',$arrPhotolab) ;
  27. $this->set('Numofphotolab',$photosql_num) ;
  28. $select="SELECT passport_photolab.* , CONCAT_WS(',',passport_photolab.lab_address,city_master.city_name,state.Name,countries.country_name) as photlablocation";
  29. $from="from passport_photolab
  30. LEFT JOIN countries ON passport_photolab.lab_country = countries.id
  31. LEFT JOIN state On passport_photolab.lab_state = state.id
  32. LEFT JOIN city_master ON passport_photolab.lab_city =city_master.city_id";
  33. $where="";
  34. $others="ORDER BY passport_photolab.id DESC";
  35. $PassParameter="";
  36. $CountField="passport_photolab.id";
  37. $this->set("controller","passport");
  38. $this->set("action","managephotolab");
  39. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  40. if(isset($this->params['url']['Page']))
  41. {
  42. $this->render("managephotolab2","ajax");
  43. }
  44. }
  45. function delphotolab($Slideid=null)
  46. {
  47. $this->checkSession();
  48. if($_SESSION['Admin_role']==1)
  49. {
  50. if($Slideid)
  51. {
  52. $delquery = "Delete from passport_photolab where id='".$Slideid."'";
  53. $delquery_res = @mysql_query($delquery);
  54. }
  55. }
  56. $this->redirect('passport/managephotolab');
  57. }
  58. function addphotolab($category=null)
  59. {
  60. $this->checkSession();
  61. $this->layout = 'default_user_cat';
  62. }
  63. function photoformatprice()
  64. {
  65. $this->checkSession();
  66. $this->layout = 'default_user_cat';
  67. ##### QUERY FOR PHOTOFROMAT
  68. $arrphotoformat=array();
  69. $photoformat = "SELECT * from admin_payment_config where config_name In ('Passport - Other format','Passport - USA format','Passport - Canada format')";
  70. $photoformat_res = mysql_query($photoformat);
  71. while($photoformat_arr = mysql_fetch_array($photoformat_res))
  72. {
  73. $arrphotoformat[] = array('id'=>$photoformat_arr['id'],'config_name'=>$photoformat_arr['config_name'],'config_value'=>$photoformat_arr['config_value']);
  74. }
  75. $this->set('photoformat',$arrphotoformat);
  76. }
  77. function saveformatprice($configId=null)
  78. {
  79. if($configId)
  80. {
  81. $valindex = 'formatprice'.$configId;
  82. $updateformatprice = "UPDATE admin_payment_config SET config_value='".$_REQUEST[$valindex]."' where id='".$configId."' ";
  83. @mysql_query($updateformatprice);
  84. }
  85. $this->redirect('passport/photoformatprice?menu=83');
  86. }
  87. function photosales()
  88. {
  89. $this->checkSession();
  90. $this->layout = 'default_user_cat';
  91. //IF DATE IS POSTED FROM THE PAGE THIS SECTION IS USED
  92. $this->set("display","none");
  93. $this->set("custOpen","Open");
  94. $this->set("textMonth","month");
  95. $this->set("textDay","day");
  96. $this->set("textYear","year");
  97. $this->set("textMonth2","month");
  98. $this->set("textDay2","day");
  99. $this->set("textYear2","year");
  100. $this->set("textMonth_2","month");
  101. $this->set("textDay_2","day");
  102. $this->set("textYear_2","year");
  103. $this->set("textMonth2_2","month");
  104. $this->set("textDay2_2","day");
  105. $this->set("textYear2_2","year");
  106. $this->set("past",0);
  107. $this->set("eventName",0);
  108. $this->set("invoice",0);
  109. $this->set("userId",0);
  110. $this->set("fDate",0);
  111. $this->set("tDate",0);
  112. $this->set("dateErr");
  113. #################################################################################
  114. if(isset($this->data['Passport']['eventname']) && ($this->data['Passport']['eventname'])!="")
  115. {
  116. $this->set("display","block");
  117. $scrapixName=$this->data['Passport']['eventname'];
  118. $this->set("eventName",$scrapixName);
  119. $this->data['Creative']['within']="";
  120. }
  121. if(isset($this->data['Passport']['invoice']) && ($this->data['Passport']['invoice'])!="")
  122. {
  123. $this->set("display","block");
  124. $invoice=$this->data['Passport']['invoice'];
  125. $this->set("invoice",$this->data['Passport']['invoice']);
  126. $this->data['Passport']['within']="";
  127. }
  128. if(isset($this->data['Passport']['fyear']) && isset($this->data['Passport']['fmonth']) && isset($this->data['Passport']['fday']))
  129. {
  130. $fromDate=$this->data['Passport']['fyear']."-".$this->data['Passport']['fmonth']."-".$this->data['Passport']['fday'];
  131. $len=strlen($fromDate);
  132. if($len==10)
  133. {
  134. $this->set("textMonth",$this->data['Passport']['fmonth']);
  135. $this->set("textDay",$this->data['Passport']['fday']);
  136. $this->set("textYear",$this->data['Passport']['fyear']);
  137. $this->set("display","block");
  138. $this->data['Passport']['within']="";
  139. $dateF=date("Y-m-d",strtotime($this->data['Passport']['fyear']."-".$this->data['Passport']['fmonth']."-".$this->data['Passport']['fday']));
  140. $fDate=$dateF;
  141. $this->set("fDate",$fDate);
  142. }
  143. else
  144. if(($this->data['Passport']['fyear'])!="year" && ($this->data['Passport']['fmonth'])!="month" && ($this->data['Passport']['fday'])!="day")
  145. {
  146. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  147. }
  148. }
  149. if(isset($this->data['Passport']['tyear']) && isset($this->data['Passport']['tmonth']) && isset($this->data['Passport']['tday']))
  150. {
  151. $toDate=$this->data['Passport']['tyear']."-".$this->data['Passport']['tmonth']."-".$this->data['Passport']['tday'];
  152. $len=strlen($toDate);
  153. if($len==10)
  154. {
  155. $this->set("textMonth2",$this->data['Passport']['tmonth']);
  156. $this->set("textDay2",$this->data['Passport']['tday']);
  157. $this->set("textYear2",$this->data['Passport']['tyear']);
  158. $this->set("display","block");
  159. $this->data['Passport']['within']="";
  160. $dateT=date("Y-m-d",strtotime($this->data['Passport']['tyear']."-".$this->data['Passport']['tmonth']."-".$this->data['Passport']['tday']));
  161. $tDate=$dateT;
  162. $this->set("tDate",$tDate);
  163. }
  164. else
  165. if(($this->data['Passport']['tyear'])!="year" && ($this->data['Passport']['tmonth'])!="month" && ($this->data['Passport']['tday'])!="day")
  166. {
  167. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  168. }
  169. }
  170. if(isset($this->data['Passport']['radio']))
  171. {
  172. $radio=$this->data['Passport']['radio'];
  173. if(isset($this->data['Passport']['radio']) && $this->data['Passport']['radio']==1)
  174. {
  175. if(isset($this->data['Passport']['within']))
  176. {
  177. $withinType=$this->data['Passport']['within'];
  178. $week=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),(date("d")-7),date("Y")));
  179. $month=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),(date("m")-1),date("d"),date("Y")));
  180. $year=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),date("d"),(date("Y")-1)));
  181. $date=date("Y-m-d G:i:s");
  182. if($this->data['Passport']['within']=="past")
  183. { $curDate=$date; $this->set("curDate",$curDate); }
  184. if($this->data['Passport']['within']=="week")
  185. { $past=$week; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  186. if($this->data['Passport']['within']=="month")
  187. { $past=$month; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  188. if($this->data['Passport']['within']=="year")
  189. { $past=$year; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  190. }
  191. }
  192. if(isset($this->data['Passport']['radio']) && $this->data['Passport']['radio']==2)
  193. {
  194. $this->set("past");
  195. $past=0;
  196. $curDate=0;
  197. $this->set("curDate");
  198. $fromDate=$this->data['Passport']['fyear_2']."-".$this->data['Passport']['fmonth_2']."-".$this->data['Passport']['fday_2'];
  199. $len=strlen($fromDate);
  200. if($len==10)
  201. {
  202. $this->set("textMonth_2",$this->data['Passport']['fmonth_2']);
  203. $this->set("textDay_2",$this->data['Passport']['fday_2']);
  204. $this->set("textYear_2",$this->data['Passport']['fyear_2']);
  205. //$this->set("display","block");
  206. $this->data['Passport']['within']="";
  207. $dateF=date("Y-m-d",strtotime($this->data['Passport']['fyear_2']."-".$this->data['Passport']['fmonth_2']."-".$this->data['Passport']['fday_2']));
  208. $past=$dateF;
  209. $this->set("past",$past);
  210. }
  211. else
  212. {
  213. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  214. }
  215. $toDate=$this->data['Passport']['tyear_2']."-".$this->data['Passport']['tmonth_2']."-".$this->data['Passport']['tday_2'];
  216. $len=strlen($toDate);
  217. if($len==10)
  218. {
  219. $this->set("textMonth2_2",$this->data['Passport']['tmonth_2']);
  220. $this->set("textDay2_2",$this->data['Passport']['tday_2']);
  221. $this->set("textYear2_2",$this->data['Passport']['tyear_2']);
  222. //$this->set("display","block");
  223. $this->data['Creative']['within']="";
  224. $dateT=date("Y-m-d",strtotime($this->data['Passport']['tyear_2']."-".$this->data['Passport']['tmonth_2']."-".$this->data['Passport']['tday_2']));
  225. $curDate=$dateT;
  226. $this->set("curDate",$curDate);
  227. }
  228. else
  229. {
  230. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  231. }
  232. }
  233. }
  234. if(isset($this->params['url']['cdate']))
  235. $curDate=$this->params['url']['cdate'];
  236. if(isset($this->params['url']['past']))
  237. $past=$this->params['url']['past'];
  238. if(isset($this->params['url']['sname']))
  239. $scrapixName=$this->params['url']['sname'];
  240. $select="SELECT CT. * ,CT.id tranId, C_CART. * , C_CART.temp_userformat AS scrapName";
  241. $from=" FROM transaction_passport CT
  242. LEFT JOIN passport_user_image_temp C_CART ON ( C_CART.id = CT.passport_user_image_temp_id )";
  243. $where=" WHERE 1 ";
  244. if(isset($radio))
  245. {
  246. if(isset($withinType) && $withinType=="past")
  247. $where.=" AND CT.cudate<'".$curDate."'";
  248. else
  249. $where.=" AND CT.cudate BETWEEN '".$past."' AND '".$curDate."'";
  250. }
  251. else
  252. $radio=0;
  253. if(isset($scrapixName))
  254. $where.=" AND C_CART.temp_userformat LIKE '%".$scrapixName."%'";
  255. if(isset($invoice))
  256. $where.=" AND CT.invoice='".$invoice."'";
  257. if(isset($fDate) && $fDate!=0 && isset($tDate) && $tDate!=0)
  258. $where.=" AND CT.cudate BETWEEN '".$fDate."' AND '".$tDate."'";
  259. $others=" GROUP BY CT.id ORDER BY CT.id DESC";
  260. //echo $select.$from.$where.$others;
  261. $PassParameter="";
  262. if(isset($curDate))
  263. $PassParameter.="cdate=".$curDate."&";
  264. if(isset($past))
  265. $PassParameter.="past=".$past."&";
  266. if(isset($scrapixName))
  267. $PassParameter.="sname=".$scrapixName."&";
  268. if(isset($fDate))
  269. $PassParameter.="fd=".$fDate."&";
  270. if(isset($tDate))
  271. $PassParameter.="td=".$tDate."&";
  272. if(isset($invoice))
  273. $PassParameter.="inv=".$invoice;
  274. $CountField="CT.id";
  275. $this->set("controller","passport");
  276. $this->set("action","photosales");
  277. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  278. if(isset($this->params['url']['Page']))
  279. {
  280. $this->render("photosales2","ajax");
  281. }
  282. ###################################################################################3
  283. }
  284. function saveaddphotolab($slideid=null)
  285. {
  286. if($slideid)
  287. {
  288. $destination = realpath('../../../app/webroot/photolabimg/') . '/';
  289. $file = $this->data['passport']['screenshot'];
  290. $Uploadfile = '';
  291. $result = $this->Image->photolab_upload_image_and_thumbnail($this->data,'screenshot',200,200,"sets",false);
  292. if($result!='')
  293. $Uploadfile = basename($result);
  294. //$this->Upload_video->eventheader_upload($destination,'1');
  295. $insertssql = "UPDATE passport_photolab SET lab_name = '".$this->data['passport']['labname']."' , lab_address = '".$this->data['passport']['labaddress']."' ,
  296. lab_city='".$_REQUEST['city']."' ,lab_state='".$_REQUEST['province']."' , lab_country='".$_REQUEST['country']."'" ;
  297. if($Uploadfile!='')
  298. $insertssql .= " , lab_logo ='".$Uploadfile."' " ;
  299. $insertssql .= " where id='".$slideid."' " ;
  300. $insertssql_sql = mysql_query($insertssql);
  301. }
  302. else
  303. {
  304. ################# UPLOADING FILE <br />
  305. $destination = realpath('../../../app/webroot/photolabimg/') . '/';
  306. $file = $this->data['passport']['screenshot'];
  307. $Uploadfile = '';
  308. $result = $this->Image->photolab_upload_image_and_thumbnail($this->data,'screenshot',200,200,"sets",false);
  309. if($result!='')
  310. $Uploadfile = basename($result);
  311. //exit();
  312. /* INSERTINO in the sitehelp_group_topic_qa Table */
  313. $insertssql = "INSERT INTO passport_photolab SET lab_name = '".$this->data['passport']['labname']."' , lab_address = '".$this->data['passport']['labaddress']."' ,
  314. lab_city='".$_REQUEST['city']."' ,lab_state='".$_REQUEST['province']."' , lab_country='".$_REQUEST['country']."' , lab_logo ='".$Uploadfile."'" ;
  315. $insertssql_sql = mysql_query($insertssql);
  316. ############
  317. }
  318. $this->redirect('passport/managephotolab');
  319. }
  320. function editphotolab($slideId=null)
  321. {
  322. $this->checkSession();
  323. $this->layout = 'default_user_cat';
  324. $selectTextimg = " SELECT * FROM passport_photolab where id='".$slideId."' ";
  325. $categorysql_res = mysql_query($selectTextimg);
  326. $categorysql_num = mysql_num_rows($categorysql_res);
  327. if($categorysql_num>0)
  328. {
  329. $categorysql_array = mysql_fetch_array($categorysql_res);
  330. }
  331. $this->set('slidearr',$categorysql_array);
  332. $this->set('slideNumber',$categorysql_num);
  333. }
  334. function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
  335. {
  336. if(isset($arg['Page']))
  337. $pageFlag=$arg['Page'];
  338. $this->set("PassParameter",$PassParameter);
  339. //$SetUserNumberOfVpsPerPage=SHOW_REC; /* Defined in config->paths.php*/
  340. $SetUserNumberOfVpsPerPage=2; /* Defined in config->paths.php*/
  341. $this->set("BackgroundClass",'pagination');
  342. $this->set("SelectedPage",'pagination_over');
  343. $this->set("Linkpage",'pagination_over');
  344. $this->set("FirstImage",'fdd.gif');
  345. $this->set("PreviousImage",'previous.gif');
  346. $this->set("NextImage",'next.gif');
  347. $this->set("LastImage",'rewd.gif');
  348. $UserNumberOfVpsPerPage=2; /*SHOW_REC Defined in config->paths.php*/
  349. if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
  350. $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
  351. if(!isset($arg['Page'])) $arg['Page']=1;
  352. if(!isset($arg['Offset'])) $arg['Offset']=0;
  353. $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
  354. //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
  355. //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
  356. $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
  357. $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
  358. $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
  359. if($arg['Offset']==$NoOfVps)
  360. {
  361. if(isset($Offset))
  362. {
  363. $Offset=$Offset-$NumberOfVpsPerPage;
  364. $Page--;
  365. if($Offset<0)
  366. {
  367. $Offset=0;$Page=1;
  368. }
  369. }else{
  370. $Offset=0;$Page=1;
  371. }
  372. }
  373. $this->set("Page",$arg['Page']);
  374. $this->set("Offset",$arg['Offset']);
  375. $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
  376. $this->set("NoOfPages",$NoOfPages);
  377. $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
  378. //print "$select $from $where $others";
  379. $this->set("qryOthr","$select $from $where)");
  380. $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
  381. $this->set("query",$SelectRecord);
  382. }
  383. }
  384. ?>