/admin/app/controllers/passport_controller.php
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
- <?php
- class PassportController extends AppController
- {
- var $name='Passport';
- var $components = array('Pagination','Upload','Image');
- var $helpers = array('Pagination', 'error','Ajax');
-
- function managephotolab()
- {
- $this->checkSession();
- $this->layout = 'default_user_cat';
- $arrPhotolab = array();
- $photosql = "SELECT passport_photolab.* from passport_photolab
- LEFT JOIN countries ON passport_photolab.lab_country = countries.id
- LEFT JOIN state On passport_photolab.lab_state = state.id
- LEFT JOIN city_master ON passport_photolab.lab_city =city_master.city_id
- ";
- $photosql .=" ORDER BY passport_photolab.id desc ";
-
- if(isset($limit) && $limit>0)
- $photosql .=" LIMIT ".$limit;
- $photosql_res = mysql_query($photosql);
- $photosql_num = mysql_num_rows($photosql_res);
- while($photosql_arr = mysql_query($photosql_res))
- {
- $arrPhotolab[] = array('id'=>$photosql_arr['id'],'lab_name'=>$photosql_arr['lab_name'],'lab_address'=>$photosql_arr['lab_address']);
- }
-
- $this->set('arrphotolab',$arrPhotolab) ;
- $this->set('Numofphotolab',$photosql_num) ;
-
- $select="SELECT passport_photolab.* , CONCAT_WS(',',passport_photolab.lab_address,city_master.city_name,state.Name,countries.country_name) as photlablocation";
- $from="from passport_photolab
- LEFT JOIN countries ON passport_photolab.lab_country = countries.id
- LEFT JOIN state On passport_photolab.lab_state = state.id
- LEFT JOIN city_master ON passport_photolab.lab_city =city_master.city_id";
- $where="";
- $others="ORDER BY passport_photolab.id DESC";
- $PassParameter="";
- $CountField="passport_photolab.id";
- $this->set("controller","passport");
- $this->set("action","managephotolab");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']))
- {
- $this->render("managephotolab2","ajax");
- }
- }
- function delphotolab($Slideid=null)
- {
- $this->checkSession();
- if($_SESSION['Admin_role']==1)
- {
- if($Slideid)
- {
- $delquery = "Delete from passport_photolab where id='".$Slideid."'";
- $delquery_res = @mysql_query($delquery);
- }
- }
- $this->redirect('passport/managephotolab');
-
- }
- function addphotolab($category=null)
- {
- $this->checkSession();
- $this->layout = 'default_user_cat';
-
- }
- function photoformatprice()
- {
- $this->checkSession();
- $this->layout = 'default_user_cat';
- ##### QUERY FOR PHOTOFROMAT
- $arrphotoformat=array();
- $photoformat = "SELECT * from admin_payment_config where config_name In ('Passport - Other format','Passport - USA format','Passport - Canada format')";
- $photoformat_res = mysql_query($photoformat);
- while($photoformat_arr = mysql_fetch_array($photoformat_res))
- {
- $arrphotoformat[] = array('id'=>$photoformat_arr['id'],'config_name'=>$photoformat_arr['config_name'],'config_value'=>$photoformat_arr['config_value']);
- }
-
- $this->set('photoformat',$arrphotoformat);
- }
-
- function saveformatprice($configId=null)
- {
- if($configId)
- {
- $valindex = 'formatprice'.$configId;
- $updateformatprice = "UPDATE admin_payment_config SET config_value='".$_REQUEST[$valindex]."' where id='".$configId."' ";
- @mysql_query($updateformatprice);
- }
- $this->redirect('passport/photoformatprice?menu=83');
- }
- function photosales()
- {
- $this->checkSession();
- $this->layout = 'default_user_cat';
- //IF DATE IS POSTED FROM THE PAGE THIS SECTION IS USED
- $this->set("display","none");
- $this->set("custOpen","Open");
- $this->set("textMonth","month");
- $this->set("textDay","day");
- $this->set("textYear","year");
- $this->set("textMonth2","month");
- $this->set("textDay2","day");
- $this->set("textYear2","year");
-
- $this->set("textMonth_2","month");
- $this->set("textDay_2","day");
- $this->set("textYear_2","year");
- $this->set("textMonth2_2","month");
- $this->set("textDay2_2","day");
- $this->set("textYear2_2","year");
-
- $this->set("past",0);
- $this->set("eventName",0);
- $this->set("invoice",0);
- $this->set("userId",0);
- $this->set("fDate",0);
- $this->set("tDate",0);
- $this->set("dateErr");
-
-
-
- #################################################################################
-
- if(isset($this->data['Passport']['eventname']) && ($this->data['Passport']['eventname'])!="")
- {
- $this->set("display","block");
- $scrapixName=$this->data['Passport']['eventname'];
- $this->set("eventName",$scrapixName);
- $this->data['Creative']['within']="";
-
- }
-
- if(isset($this->data['Passport']['invoice']) && ($this->data['Passport']['invoice'])!="")
- {
- $this->set("display","block");
- $invoice=$this->data['Passport']['invoice'];
- $this->set("invoice",$this->data['Passport']['invoice']);
- $this->data['Passport']['within']="";
- }
- if(isset($this->data['Passport']['fyear']) && isset($this->data['Passport']['fmonth']) && isset($this->data['Passport']['fday']))
- {
- $fromDate=$this->data['Passport']['fyear']."-".$this->data['Passport']['fmonth']."-".$this->data['Passport']['fday'];
- $len=strlen($fromDate);
- if($len==10)
- {
- $this->set("textMonth",$this->data['Passport']['fmonth']);
- $this->set("textDay",$this->data['Passport']['fday']);
- $this->set("textYear",$this->data['Passport']['fyear']);
-
- $this->set("display","block");
- $this->data['Passport']['within']="";
- $dateF=date("Y-m-d",strtotime($this->data['Passport']['fyear']."-".$this->data['Passport']['fmonth']."-".$this->data['Passport']['fday']));
- $fDate=$dateF;
- $this->set("fDate",$fDate);
- }
- else
- if(($this->data['Passport']['fyear'])!="year" && ($this->data['Passport']['fmonth'])!="month" && ($this->data['Passport']['fday'])!="day")
- {
- $this->set("dateErr","Date format should be : mm/dd/yyyy");
- }
- }
- if(isset($this->data['Passport']['tyear']) && isset($this->data['Passport']['tmonth']) && isset($this->data['Passport']['tday']))
- {
- $toDate=$this->data['Passport']['tyear']."-".$this->data['Passport']['tmonth']."-".$this->data['Passport']['tday'];
- $len=strlen($toDate);
- if($len==10)
- {
- $this->set("textMonth2",$this->data['Passport']['tmonth']);
- $this->set("textDay2",$this->data['Passport']['tday']);
- $this->set("textYear2",$this->data['Passport']['tyear']);
- $this->set("display","block");
- $this->data['Passport']['within']="";
- $dateT=date("Y-m-d",strtotime($this->data['Passport']['tyear']."-".$this->data['Passport']['tmonth']."-".$this->data['Passport']['tday']));
- $tDate=$dateT;
- $this->set("tDate",$tDate);
- }
- else
- if(($this->data['Passport']['tyear'])!="year" && ($this->data['Passport']['tmonth'])!="month" && ($this->data['Passport']['tday'])!="day")
- {
- $this->set("dateErr","Date format should be : mm/dd/yyyy");
- }
- }
- if(isset($this->data['Passport']['radio']))
- {
- $radio=$this->data['Passport']['radio'];
- if(isset($this->data['Passport']['radio']) && $this->data['Passport']['radio']==1)
- {
- if(isset($this->data['Passport']['within']))
- {
- $withinType=$this->data['Passport']['within'];
- $week=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),(date("d")-7),date("Y")));
- $month=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),(date("m")-1),date("d"),date("Y")));
- $year=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),date("d"),(date("Y")-1)));
- $date=date("Y-m-d G:i:s");
-
- if($this->data['Passport']['within']=="past")
- { $curDate=$date; $this->set("curDate",$curDate); }
-
- if($this->data['Passport']['within']=="week")
- { $past=$week; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
-
- if($this->data['Passport']['within']=="month")
- { $past=$month; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
-
- if($this->data['Passport']['within']=="year")
- { $past=$year; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
-
- }
- }
-
- if(isset($this->data['Passport']['radio']) && $this->data['Passport']['radio']==2)
- {
- $this->set("past");
- $past=0;
- $curDate=0;
- $this->set("curDate");
- $fromDate=$this->data['Passport']['fyear_2']."-".$this->data['Passport']['fmonth_2']."-".$this->data['Passport']['fday_2'];
- $len=strlen($fromDate);
- if($len==10)
- {
- $this->set("textMonth_2",$this->data['Passport']['fmonth_2']);
- $this->set("textDay_2",$this->data['Passport']['fday_2']);
- $this->set("textYear_2",$this->data['Passport']['fyear_2']);
-
- //$this->set("display","block");
- $this->data['Passport']['within']="";
- $dateF=date("Y-m-d",strtotime($this->data['Passport']['fyear_2']."-".$this->data['Passport']['fmonth_2']."-".$this->data['Passport']['fday_2']));
- $past=$dateF;
- $this->set("past",$past);
-
- }
- else
- {
- $this->set("dateErr","Date format should be : mm/dd/yyyy");
- }
-
- $toDate=$this->data['Passport']['tyear_2']."-".$this->data['Passport']['tmonth_2']."-".$this->data['Passport']['tday_2'];
- $len=strlen($toDate);
- if($len==10)
- {
- $this->set("textMonth2_2",$this->data['Passport']['tmonth_2']);
- $this->set("textDay2_2",$this->data['Passport']['tday_2']);
- $this->set("textYear2_2",$this->data['Passport']['tyear_2']);
- //$this->set("display","block");
- $this->data['Creative']['within']="";
- $dateT=date("Y-m-d",strtotime($this->data['Passport']['tyear_2']."-".$this->data['Passport']['tmonth_2']."-".$this->data['Passport']['tday_2']));
- $curDate=$dateT;
- $this->set("curDate",$curDate);
- }
- else
- {
- $this->set("dateErr","Date format should be : mm/dd/yyyy");
- }
- }
- }
-
- if(isset($this->params['url']['cdate']))
- $curDate=$this->params['url']['cdate'];
-
- if(isset($this->params['url']['past']))
- $past=$this->params['url']['past'];
-
- if(isset($this->params['url']['sname']))
- $scrapixName=$this->params['url']['sname'];
-
- $select="SELECT CT. * ,CT.id tranId, C_CART. * , C_CART.temp_userformat AS scrapName";
- $from=" FROM transaction_passport CT
- LEFT JOIN passport_user_image_temp C_CART ON ( C_CART.id = CT.passport_user_image_temp_id )";
-
- $where=" WHERE 1 ";
- if(isset($radio))
- {
- if(isset($withinType) && $withinType=="past")
- $where.=" AND CT.cudate<'".$curDate."'";
- else
- $where.=" AND CT.cudate BETWEEN '".$past."' AND '".$curDate."'";
- }
- else
- $radio=0;
- if(isset($scrapixName))
- $where.=" AND C_CART.temp_userformat LIKE '%".$scrapixName."%'";
- if(isset($invoice))
- $where.=" AND CT.invoice='".$invoice."'";
- if(isset($fDate) && $fDate!=0 && isset($tDate) && $tDate!=0)
- $where.=" AND CT.cudate BETWEEN '".$fDate."' AND '".$tDate."'";
- $others=" GROUP BY CT.id ORDER BY CT.id DESC";
-
-
- //echo $select.$from.$where.$others;
- $PassParameter="";
- if(isset($curDate))
- $PassParameter.="cdate=".$curDate."&";
- if(isset($past))
- $PassParameter.="past=".$past."&";
- if(isset($scrapixName))
- $PassParameter.="sname=".$scrapixName."&";
- if(isset($fDate))
- $PassParameter.="fd=".$fDate."&";
- if(isset($tDate))
- $PassParameter.="td=".$tDate."&";
- if(isset($invoice))
- $PassParameter.="inv=".$invoice;
-
-
- $CountField="CT.id";
- $this->set("controller","passport");
- $this->set("action","photosales");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']))
- {
- $this->render("photosales2","ajax");
- }
-
-
- ###################################################################################3
-
- }
-
-
- function saveaddphotolab($slideid=null)
- {
- if($slideid)
- {
- $destination = realpath('../../../app/webroot/photolabimg/') . '/';
- $file = $this->data['passport']['screenshot'];
- $Uploadfile = '';
- $result = $this->Image->photolab_upload_image_and_thumbnail($this->data,'screenshot',200,200,"sets",false);
- if($result!='')
- $Uploadfile = basename($result);
-
- //$this->Upload_video->eventheader_upload($destination,'1');
-
-
- $insertssql = "UPDATE passport_photolab SET lab_name = '".$this->data['passport']['labname']."' , lab_address = '".$this->data['passport']['labaddress']."' ,
- lab_city='".$_REQUEST['city']."' ,lab_state='".$_REQUEST['province']."' , lab_country='".$_REQUEST['country']."'" ;
- if($Uploadfile!='')
- $insertssql .= " , lab_logo ='".$Uploadfile."' " ;
-
-
- $insertssql .= " where id='".$slideid."' " ;
- $insertssql_sql = mysql_query($insertssql);
- }
- else
- {
- ################# UPLOADING FILE <br />
- $destination = realpath('../../../app/webroot/photolabimg/') . '/';
- $file = $this->data['passport']['screenshot'];
- $Uploadfile = '';
- $result = $this->Image->photolab_upload_image_and_thumbnail($this->data,'screenshot',200,200,"sets",false);
- if($result!='')
- $Uploadfile = basename($result);
- //exit();
-
- /* INSERTINO in the sitehelp_group_topic_qa Table */
- $insertssql = "INSERT INTO passport_photolab SET lab_name = '".$this->data['passport']['labname']."' , lab_address = '".$this->data['passport']['labaddress']."' ,
- lab_city='".$_REQUEST['city']."' ,lab_state='".$_REQUEST['province']."' , lab_country='".$_REQUEST['country']."' , lab_logo ='".$Uploadfile."'" ;
- $insertssql_sql = mysql_query($insertssql);
- ############
-
- }
- $this->redirect('passport/managephotolab');
- }
- function editphotolab($slideId=null)
- {
- $this->checkSession();
- $this->layout = 'default_user_cat';
- $selectTextimg = " SELECT * FROM passport_photolab where id='".$slideId."' ";
- $categorysql_res = mysql_query($selectTextimg);
- $categorysql_num = mysql_num_rows($categorysql_res);
- if($categorysql_num>0)
- {
- $categorysql_array = mysql_fetch_array($categorysql_res);
- }
- $this->set('slidearr',$categorysql_array);
- $this->set('slideNumber',$categorysql_num);
- }
-
- function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
- {
- if(isset($arg['Page']))
- $pageFlag=$arg['Page'];
- $this->set("PassParameter",$PassParameter);
- //$SetUserNumberOfVpsPerPage=SHOW_REC; /* Defined in config->paths.php*/
- $SetUserNumberOfVpsPerPage=2; /* Defined in config->paths.php*/
-
- $this->set("BackgroundClass",'pagination');
- $this->set("SelectedPage",'pagination_over');
- $this->set("Linkpage",'pagination_over');
- $this->set("FirstImage",'fdd.gif');
- $this->set("PreviousImage",'previous.gif');
- $this->set("NextImage",'next.gif');
- $this->set("LastImage",'rewd.gif');
-
- $UserNumberOfVpsPerPage=2; /*SHOW_REC Defined in config->paths.php*/
- if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
- $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
-
- if(!isset($arg['Page'])) $arg['Page']=1;
- if(!isset($arg['Offset'])) $arg['Offset']=0;
- $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
- //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
-
- //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
- $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
-
- $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
- $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
- if($arg['Offset']==$NoOfVps)
- {
- if(isset($Offset))
- {
- $Offset=$Offset-$NumberOfVpsPerPage;
- $Page--;
- if($Offset<0)
- {
- $Offset=0;$Page=1;
- }
- }else{
- $Offset=0;$Page=1;
- }
- }
-
- $this->set("Page",$arg['Page']);
- $this->set("Offset",$arg['Offset']);
- $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
- $this->set("NoOfPages",$NoOfPages);
- $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
-
- //print "$select $from $where $others";
- $this->set("qryOthr","$select $from $where)");
-
- $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
- $this->set("query",$SelectRecord);
-
- }
-
-
- }
- ?>