/admin/app/controllers/creativezones_controller.php
PHP | 1050 lines | 812 code | 207 blank | 31 comment | 124 complexity | e4866a7d3f3e4f7e2da8a492ea1adfdc MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
- <?
- class CreativezonesController extends AppController {
- var $name='Creativezones';
- var $helpers = array('Html','javascript','Ajax');
- var $uses=array('Creativezone');
- var $components = array('Sendmail','Upload');
- function uploadCategory() {
- $upldCategory=array();
- $upldCategory['photos']="Photo";
- $upldCategory['backdrops']="Background";
- $upldCategory['corners']="Superimpose";
- $upldCategory['texts']="Frames & Borders";
- $upldCategory['borders']="Texts & Symbols";
- $upldCategory['lines']="Corners & Shapes";
- $upldCategory['stickers']="Sports & Calendars";
- $upldCategory['sports']="Real & Graphic";
- $this->set("uploadCategory",$upldCategory);
- }
- 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*/
- $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=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");
- //echo "$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage";
- $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
- $this->set("query",$SelectRecord);
- }
- function tagimages() {
- $this->checkSession();
- $this->layout = 'tagimages';
- $this->set("uploadTitle","Tag Images");
- $this->creativetype();
- $this->uploadCategory();
- $upldCat=0;
- $upldType=0;
- if(isset($this->params['url']['uploadCategory'])) {
- $upldCat=$this->params['url']['uploadCategory'];
- $upldType=$this->params['url']['uploadType'];
- }
- if(isset($this->params['form']['uploadCategory'])) {
- $upldCat=$this->params['form']['uploadCategory'];
- $upldType=$this->params['form']['uploadType'];
- }
- if(isset($this->params['url']['upldcat'])) {
- $upldCat=$this->params['url']['upldcat'];
- $upldType=$this->params['url']['upldtype'];
- }
- $this->set("upldCat",$upldCat);
- $this->set("upldType",$upldType);
- //Get the images uploaded by ADMIN
- //if(isset($upldCat) && $upldCat!='0' && isset($upldType) && $upldType!='0')
- // {
- $select=" SELECT * ";
- $from=" FROM creative_template_images ";
- $where="WHERE creative_type_id='".$upldCat."' AND imgtype='".$upldType."' AND uploader='1' and is_delete='0'";
- $others=NULL;
- $PassParameter="upldcat=".$upldCat."&upldtype=".$upldType;
- $CountField="B.id";
- $this->set("controller","creativezones");
- $this->set("action","tagimages");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page'])) {
- $this->render("tagimages2","ajax");
- }
- // }
- }
- function deletestatik() {
- //pr($this->params);
- mysql_query("update creative_template_pages set is_delete='1' where id='".$this->params['url']['id']."'");
- $this->redirect("/creativezones/statikimages?uploadCategory=".$this->params['url']['uploadCategory']);
- }
- function deletetagimg() {
- //pr($this->params);
- mysql_query("update creative_template_images set is_delete='1' where id='".$this->params['url']['id']."'");
- $this->redirect("/creativezones/tagimages?uploadCategory=".$this->params['url']['uploadCategory']."&uploadType=".$this->params['url']['uploadType']);
- }
- function statikimages() {
- $this->checkSession();
- $this->layout = 'tagimages';
- $this->set("uploadTitle","Statik Images");
- $this->creativetype();
- $this->uploadCategory();
- $upldCat=0;
- $upldType=0;
- if(isset($this->params['url']['uploadCategory'])) {
- $upldCat=$this->params['url']['uploadCategory'];
- //$upldType=$this->params['form']['uploadType'];
- }
- if(isset($this->params['form']['uploadCategory'])) {
- $upldCat=$this->params['form']['uploadCategory'];
- //$upldType=$this->params['form']['uploadType'];
- }
- if(isset($this->params['url']['upldcat'])) {
- $upldCat=$this->params['url']['upldcat'];
- //$upldType=$this->params['url']['upldtype'];
- }
- $this->set("upldCat",$upldCat);
- $this->set("upldType",$upldType);
- //Get the images uploaded by ADMIN
- //if(isset($upldCat) && $upldCat!='0' && isset($upldType) && $upldType!='0')
- // {
- $select=" SELECT * ";
- $from=" FROM creative_template_pages ";
- $where="WHERE creative_type_id='".$upldCat."' AND block='0' and is_delete='0' and template_type='1'";
- $others=NULL;
- $PassParameter=" ";
- $CountField="B.id";
- $this->set("controller","creativezones");
- $this->set("action","tagimages");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page'])) {
- $this->render("tagimages2","ajax");
- }
- // }
- }
- function savetag() {
- $this->set("params",$this->params);
- if(isset($this->params['url']['id']) && $this->params['url']['id']!="") {
- $this->set("imgId",$this->params['url']['id']);
- $sql=mysql_query("SELECT imgdescription FROM creative_template_images WHERE id='".$this->params['url']['id']."'");
- $fetchDesc=mysql_fetch_assoc($sql);
- $this->set("imgDesc",$fetchDesc['imgdescription']);
- $this->render("savetag","ajax");
- }
- if(isset($this->data['creativexones'])) {
- $imgId=$this->data['creativexones']['imgId'];
- $imageTag=$this->data['creativexones']['imgTag'];
- //setting image description
- mysql_query("UPDATE creative_template_images SET imgdescription='".$imageTag."' WHERE id='".$imgId."'");
- $this->set("imgId",$imgId);
- $this->render("tagsaved","ajax");
- }
- }
- function creativeType() {
- $q1=mysql_query("SELECT * FROM creative_type WHERE is_delete='0' ORDER BY id ASC");
- $i=0;
- while($rwCr=mysql_fetch_array($q1)) {
- if($i==0)
- $defaultCat[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
- $i++;
- $creativeType[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
- }
- $this->set("defaultType",$defaultCat);
- $this->set("creativeType",$creativeType);
- }
- function creativeupload() {
- $this->checkSession();
- if(!empty($this->data)) {
- if(strtoupper($this->data['Creativezones']['uploadcat'])=='IMAGES')
- $this->redirect("/creativezones/uploadimg?t=".base64_encode($this->data['Creativezones']['templatetype']));
- if(strtoupper($this->data['Creativezones']['uploadcat'])=='STATIK')
- $this->redirect("/creativezones/uploadstatiktemplate?t=".base64_encode($this->data['Creativezones']['templatetype']));
- }
- }
- function uploadimg() {
- $this->checkSession();
- $this->layout = 'default_after_login';
- $this->set("themeId",$this->params['url']['t']);
- }
- function uploadstatiktemplate() {
- $this->checkSession();
- $this->layout = 'default_after_login';
- $this->set("themeId",$this->params['url']['t']);
- }
- function uploadimage1() {
- $this->checkSession();
- $this->layout = 'default_after_login';
- $this->set("uploadTitle","Upload Images");
- $this->set("upldType","images");
- $this->creativeType();
- }
- function uploadstatik() {
- $this->checkSession();
- $this->layout = 'default_after_login';
- $this->set("uploadTitle","Upload Statik Templates");
- $this->set("upldType","statik");
- $this->creativeType();
- $this->render("uploadimage");
- }
- function managetax() {
- $this->checkSession();
- $this->layout = 'default_user';
- if(isset($this->data['Sale']['tax'])) {
- mysql_query("UPDATE creative_saletax SET tax='".$this->data['Sale']['tax']."' WHERE user_id='1' AND state_id='".$this->data['Sale']['sid']."'") or die(mysql_error());
- }
- $saletaxarr = array();
- $sqlsatetax = "select countries.id , countries.country_name , creative_saletax.user_id from creative_saletax , state , countries where user_id = '1' and state_id=state.id and state.c_id=countries.id Group by countries.id";
- $sqlsatetax_res = mysql_query($sqlsatetax);
- $sqlsatetax_num = mysql_num_rows($sqlsatetax_res);
- if($sqlsatetax_num > 0) {
- while($sqlsatetax_res_arr = mysql_fetch_array($sqlsatetax_res)) {
- $saletaxarr[$sqlsatetax_res_arr['id']] = $sqlsatetax_res_arr['country_name'] ;
- }
- }
- $this->set('saltaxnum', $sqlsatetax_num);
- $this->set('saltaxinfo', $saletaxarr);
- }
- function savesaletax() {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->pageTitle = 'Sale Tax';
- $stateTax = $_REQUEST['saletax'] ;
- foreach($stateTax as $stateTax_index=> $stateTax_value ) {
- if(isset($_REQUEST['saletax'][$stateTax_index]) && $_REQUEST['saletax'][$stateTax_index]!="") {
- $mynumber = $_REQUEST['saletax'][$stateTax_index] ;
- if($mynumber>0) {
- if (preg_match ("/^([0-9.,-]+)$/", $mynumber)) {
- /* Saving in the sale tax */
- $selectrec = "select * from creative_saletax where user_id = '1' and state_id = ".$stateTax_index."" ;
- $selectrec_res = mysql_query($selectrec);
- if(mysql_num_rows($selectrec_res)>0) {
- $saletaxsql = "Update creative_saletax SET tax = ".$mynumber." where user_id = '1' and state_id = ".$stateTax_index."" ;
- }
- else {
- $saletaxsql = "INSERT INTO creative_saletax SET tax = ".$mynumber." , user_id = '1' , state_id = ".$stateTax_index."" ;
- }
- mysql_query($saletaxsql)or die(mysql_error());
- /* */
- }
- }
- }
- }
- $redirectURL = "creativezones/managetax";
- $this->redirect($redirectURL);
- }
- function managecoupon() {
- $this->checkSession();
- $this->layout = 'default_user';
- if(isset($_REQUEST['chkAll']) && $_REQUEST['chkAll']=='checkbox' && isset($_REQUEST['box'])) {
- foreach($_REQUEST['box'] as $boxind=>$boxvalue) {
- $chkCoupon="DELETE FROM creative_coupon WHERE user_id='1' AND id='".$boxvalue."'";
- $chkCoupon_res = mysql_query($chkCoupon);
- }
- }
- }
- function addcoupon() {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function savecoupon($couponid=null) {
- $this->checkSession();
- $this->layout = 'default_user';
- //pr($_REQUEST);
- $copFrm = $_REQUEST['fromyear'] .'-'.$_REQUEST['frommonth'] .'-'.$_REQUEST['fromdate'] ;
- $copTo = $_REQUEST['toyear'] .'-'.$_REQUEST['tomonth'] .'-'.$_REQUEST['todate'] ;
- if($couponid) {
- $coupQry = "update creative_coupon set coupon_code = '".$this->data['creativezone']['coupon_code']."', coupon_value = ".$this->data['creativezone']['coupon_value'].", coupon_from = '".$copFrm."', coupon_to = '".$copTo."' where id=".$couponid."";
- mysql_query($coupQry);
- }
- else {
- $chkCoupon="SELECT * FROM creative_coupon WHERE user_id='1' AND coupon_code='".$this->data['creativezone']['coupon_code']."'";
- if(mysql_num_rows(mysql_query($chkCoupon))==0) {
- $coupQry = "insert into creative_coupon values('', '1', '".$this->data['creativezone']['coupon_code']."', ".$this->data['creativezone']['coupon_value'].", '".$copFrm."', '".$copTo."', NOW(), '0')";
- mysql_query($coupQry);
- }
- }
- $this->redirect('creativezones/managecoupon');
- }
- function editcreativecoupon($couponid=null) {
- $this->checkSession();
- $this->layout = 'default_user';
- $chkCoupon="SELECT * FROM creative_coupon WHERE user_id='1' AND id='".base64_decode($couponid)."'";
- $chkCoupon_res = mysql_query($chkCoupon);
- $chkCoupon_arr = mysql_fetch_array($chkCoupon_res);
- $this->set('couponarr',$chkCoupon_arr);
- }
- function delcreativecoupon($couponid=null) {
- $this->checkSession();
- $this->layout = 'default_user';
- $chkCoupon="DELETE FROM creative_coupon WHERE user_id='1' AND id='".base64_decode($couponid)."'";
- $chkCoupon_res = mysql_query($chkCoupon);
- $this->redirect('creativezones/managecoupon');
- }
- function blockunblock($couponid=null,$changestatus=null) {
- if($changestatus=='Blocked') {
- $blockedstatus = '1';
- }
- else
- $blockedstatus = '0';
- $chkCoupon="UPDATE creative_coupon SET blocked = '".$blockedstatus."' WHERE user_id='1' AND id='".base64_decode($couponid)."'";
- $chkCoupon_res = mysql_query($chkCoupon);
- $this->redirect('creativezones/managecoupon');
- }
- function salesdata() {
- $this->checkSession();
- $this->layout = 'default_user';
- $select = "SELECT PM.*,TC.* ,USR.first_name,USR.last_name,USR.email, COUNTRY.country_name, F.ssn_id,COUNT(CDT.id) as num_item,FX.is_blocked";
- $from = " FROM transaction_creatives as TC
- LEFT JOIN payment_transactions PM ON ( PM.id = TC.payment_ts_id )
- LEFT JOIN creative_carts C ON ( C.transaction_creative_id = TC.id )
- LEFT JOIN creative_cart_details CDT ON ( CDT.creative_cart_id = C.id )
- LEFT JOIN creative_favorites F ON ( F.id = CDT.creative_favorite_id)
- LEFT JOIN creative_favorites FX ON (F.template_id>0 AND F.template_id=FX.id)
- LEFT JOIN user_details USR ON ( PM.user_id = USR.user_id )
- LEFT JOIN countries COUNTRY ON ( USR.c_id = COUNTRY.id )";
- $where = " WHERE TC.pay_status = '1' ";
- $others=" GROUP BY TC.id DESC
- ORDER BY TC.trandate DESC ";
- $searchpass = '';
- if(isset($_REQUEST['invoice']) && $_REQUEST['invoice']!='') {
- $where.=" AND TC.invoice like '%".$_REQUEST['invoice']."%' ";
- $searchpass .= "&invoice=".$_REQUEST['invoice'] ;
- $others .=", TC.invoice ";
- }
- if(isset($_REQUEST['email']) && $_REQUEST['email']!='') {
- $where.=" AND USR.email like '%".$_REQUEST['email']."%' ";
- $searchpass .= "&email=".$_REQUEST['email'] ;
- $others .=", USR.email ";
- }
- if(isset($_REQUEST['prodid']) && $_REQUEST['prodid']!='') {
- $where.=" AND F.ssn_id like '%".$_REQUEST['prodid']."%' ";
- $searchpass .= "&prodid=".$_REQUEST['prodid'] ;
- $others .=", F.ssn_id ";
- }
- if(isset($_REQUEST['country']) && $_REQUEST['country']!='') {
- $where.=" AND COUNTRY.country_name like '%".$_REQUEST['country']."%' ";
- $searchpass .= "&country=".$_REQUEST['country'] ;
- $others .=", COUNTRY.country_name ";
- }
- if(isset($_REQUEST['first_name']) && $_REQUEST['first_name']!='') {
- $where.=" AND USR.first_name like '%".$_REQUEST['first_name']."%' ";
- $searchpass .= "&first_name=".$_REQUEST['first_name'] ;
- $others .=", USR.first_name ";
- }
- if(isset($_REQUEST['last_name']) && $_REQUEST['last_name']!='') {
- $where.=" AND USR.last_name like '%".$_REQUEST['last_name']."%' ";
- $searchpass .= "&last_name=".$_REQUEST['last_name'] ;
- $others .=", USR.last_name ";
- }
- if(isset($_REQUEST['datefrom']) && $_REQUEST['datefrom']!='mm/dd/YY' && isset($_REQUEST['dateto']) && $_REQUEST['dateto']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['datefrom']));
- $urlfromdate = $_REQUEST['datefrom'];
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['dateto'])).' 23:59:59';
- $urltodate = $_REQUEST['dateto'];
- $where.=" AND TC.trandate BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass = "&datefrom=".$urlfromdate."&dateto=".$urltodate ;
- }
- //get number user
- $query = "SELECT COUNT(DISTINCT USR.id) as num_user, SUM(TC.total_amount) as total_sale ".$from.$where;
- $this->set('sqlnum',$query);
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- $this->set('num_user',$row['num_user']);
- $this->set('total_sale',$row['total_sale']);
- $PassParameter =$searchpass;
- $CountField="TC.id";
- $this->set("controller","creativezones");
- $this->set("action","salesdata");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || isset($_REQUEST['search'])) {
- $this->render("salesdata2","ajax");
- }
- }
- function creative_invoice_detail() {
- $this->layout = "blank";
- $this->set("tranId",base64_decode($this->params['url']['inv']));
- }
- function printscrap() {
- $this->layout = "blank";
- }
- function submission() {
- $this->checkSession();
- $this->layout = 'default_user';
- $select = "SELECT TK.ticket_number,TK.creation,TK.status ,USR.first_name,USR.last_name,USR.email, COUNTRY.country_name, F.ssn_id,F.id";
- $from = " FROM creative_favorites as F
- RIGHT JOIN creative_tickets TK ON (TK.creative_favorites_id = F.id)
- LEFT JOIN user_details USR ON ( F.user_id = USR.user_id )
- LEFT JOIN countries COUNTRY ON ( USR.c_id = COUNTRY.id )";
- $where = " WHERE F.is_temp = '0' ";
- $others=" GROUP BY F.id
- ORDER BY TK.creation DESC ";
- $searchpass = '';
- if(isset($_REQUEST['ticket']) && $_REQUEST['ticket']!='') {
- $where.=" AND TK.ticket_number like '%".$_REQUEST['ticket']."%' ";
- $searchpass .= "&ticket=".$_REQUEST['ticket'] ;
- $others .=", TK.ticket_number ";
- }
- if(isset($_REQUEST['email']) && $_REQUEST['email']!='') {
- $where.=" AND USR.email like '%".$_REQUEST['email']."%' ";
- $searchpass .= "&email=".$_REQUEST['email'] ;
- $others .=", USR.email ";
- }
- if(isset($_REQUEST['prodid']) && $_REQUEST['prodid']!='') {
- $where.=" AND F.ssn_id like '%".$_REQUEST['prodid']."%' ";
- $searchpass .= "&prodid=".$_REQUEST['prodid'] ;
- $others .=", F.ssn_id ";
- }
- if(isset($_REQUEST['country']) && $_REQUEST['country']!='') {
- $where.=" AND COUNTRY.country_name like '%".$_REQUEST['country']."%' ";
- $searchpass .= "&country=".$_REQUEST['country'] ;
- $others .=", COUNTRY.country_name ";
- }
- if(isset($_REQUEST['first_name']) && $_REQUEST['first_name']!='') {
- $where.=" AND USR.first_name like '%".$_REQUEST['first_name']."%' ";
- $searchpass .= "&first_name=".$_REQUEST['first_name'] ;
- $others .=", USR.first_name ";
- }
- if(isset($_REQUEST['last_name']) && $_REQUEST['last_name']!='') {
- $where.=" AND USR.last_name like '%".$_REQUEST['last_name']."%' ";
- $searchpass .= "&last_name=".$_REQUEST['last_name'] ;
- $others .=", USR.last_name ";
- }
- if(isset($_REQUEST['datefrom']) && $_REQUEST['datefrom']!='mm/dd/YY' && isset($_REQUEST['dateto']) && $_REQUEST['dateto']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['datefrom']));
- $urlfromdate = $_REQUEST['datefrom'];
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['dateto'])).' 23:59:59';
- $urltodate = $_REQUEST['dateto'];
- $where.=" AND TK.creation BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass = "&datefrom=".$urlfromdate."&dateto=".$urltodate ;
- }
- //get number user
- $query = "SELECT COUNT(DISTINCT USR.id) as num_user ".$from.$where;
- $this->set('sqlnum',$query);
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- $this->set('num_user',$row['num_user']);
- $PassParameter =$searchpass;
- $CountField="F.id";
- $this->set("controller","creativezones");
- $this->set("action","submission");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || isset($_REQUEST['search'])) {
- $this->render("submission2","ajax");
- }
- }
- function charges() {
- $this->checkSession();
- $this->layout = 'default_user';
- if(isset($_POST['submit'])) {
- if($_POST['creative_price']!='')
- $this->savePaymentConfig('creative price',$_POST['creative_price'],'price');
- if($_POST['creative_artist_price']!='')
- $this->savePaymentConfig('creative artist price',$_POST['creative_artist_price'],'price');
- if($_POST['creative_commission']!='')
- $this->savePaymentConfig('creative commission',$_POST['creative_commission'],'%');
-
- if($_POST['creative_featured']!='')
- $this->savePaymentConfig('creative featured',$_POST['creative_featured'],'price');
- if($_POST['creative_featured_days']!='')
- $this->savePaymentConfig('creative featured days',$_POST['creative_featured_days'],'days');
- if($_POST['creative_quantity_sold']!='')
- $this->savePaymentConfig('creative quantity sold',$_POST['creative_quantity_sold'],'times');
- //save 168 Washington sale_tax
- if($_POST['sale_tax']!='')
- $this->save_Saletax(1,168,$_POST['sale_tax']);
- if($_POST['creative_commission_minimum']!='')
- $this->savePaymentConfig('creative commission minimum',$_POST['creative_commission_minimum'],'days');
- if($_POST['password_payout']!='')
- $this->savePaymentConfig('password payout',$_POST['password_payout'],'days');
- //check uppdate price product
- if($_POST['creative_artist_price']!='' || $_POST['creative_quantity_sold']!='') {
- $artist_price = $this->getPaymentConfig('creative artist price');
- $artist_price = $artist_price['config_value'];
- $quantity_sold = $this->getPaymentConfig('creative quantity sold');
- $quantity_sold = $quantity_sold['config_value'];
- $query = "UPDATE creative_favorites SET price='".$artist_price."' WHERE type='0' AND is_republished='1' AND num_sell<".$quantity_sold;
- mysql_query($query);
- }
- }
- $this->getPaymentConfig('creative price',true);
- $this->getPaymentConfig('creative artist price',true);
- $this->getPaymentConfig('creative commission',true);
- $this->getPaymentConfig('creative featured',true);
- $this->getPaymentConfig('creative featured days',true);
- $this->getPaymentConfig('creative quantity sold',true);
- $this->getPaymentConfig('creative commission minimum',true);
- $this->getPaymentConfig('password payout',true);
- $this->get_Saletax(168,true);
- }
- function save_Saletax($user_id,$state_id,$tax) {
- $query = "SELECT id FROM creative_saletax WHERE state_id='".$state_id."' LIMIT 1";
- $result = mysql_query($query);
- if(mysql_num_rows($result)>0) {
- $query = "UPDATE creative_saletax SET tax='".$tax."' WHERE state_id='".$state_id."' LIMIT 1";
- }else {
- $query = "INSERT INTO creative_saletax SET user_id='".$user_id."', state_id='".$state_id."', tax='".$tax."' ";
- }
- $this->set('sale_tax',$tax);
- mysql_query($query);
- }
- function get_Saletax($state_id,$is_set=false) {
- $query = "SELECT * FROM creative_saletax WHERE state_id='".$state_id."' LIMIT 1";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- if($is_set) {
- $this->set('sale_tax',$row['tax']);
- }
- return $row;
- }
- function savePaymentConfig($config_name,$config_value,$value_type) {
- $query = "SELECT id FROM admin_payment_config WHERE config_name='".$config_name."' LIMIT 1";
- $result = mysql_query($query);
- if(mysql_num_rows($result)>0) {
- $query = "UPDATE admin_payment_config SET config_value='".$config_value."', value_type='".$value_type."' WHERE config_name='".$config_name."' LIMIT 1";
- }else {
- $query = "INSERT INTO admin_payment_config SET config_name='".$config_name."', config_value='".$config_value."', value_type='".$value_type."'";
- }
- $this->set(str_replace(' ', '_', $config_name),$config_value);
- mysql_query($query);
- }
- function getPaymentConfig($config_name,$is_set=false) {
- $query = "SELECT * FROM admin_payment_config WHERE config_name='".$config_name."' LIMIT 1";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- if($is_set) {
- $this->set(str_replace(' ', '_', $config_name),$row['config_value']);
- }
- return $row;
- }
- function ticket_approve() {
- $this->layout = "blank";
- $this->set("ticket_number",base64_decode($this->params['url']['tk']));
- }
- function save_ticket_approval() {
- //save data
- if(isset($_POST['ticket_number'])) {
- $status = $_POST['approve']==1 ? 'Approve' : 'Reject';
- //
- $query = "SELECT TK.ticket_number,TK.creation,TK.status ,USR.first_name,USR.last_name,USR.email, COUNTRY.country_name, F.ssn_id,F.id,F.user_id,USR.email
- FROM creative_tickets TK
- RIGHT JOIN creative_favorites F ON (TK.creative_favorites_id=F.id)
- LEFT JOIN user_details USR ON ( F.user_id = USR.user_id )
- LEFT JOIN countries COUNTRY ON ( USR.c_id = COUNTRY.id )
- WHERE TK.ticket_number='".$_POST['ticket_number']."'
- LIMIT 1 ";
- $result = mysql_query($query);
- if(mysql_num_rows($result)>0) {
- $row = mysql_fetch_assoc($result);
- //update ticket
- $sql = "UPDATE creative_tickets SET status ='".$status."', msg_to_user='".$_POST['msg_to_user']."' WHERE ticket_number='".$_POST['ticket_number']."' LIMIT 1 ";
- mysql_query($sql);
- //update favorites
- $sql = "UPDATE creative_favorites SET is_approved ='".$_POST['approve']."' WHERE id='".$row['id']."' LIMIT 1 ";
- mysql_query($sql);
- $row['status'] = $status;
- $this->set('row',$row);
- //check send mail
- $userDetails=$this->getUserDetails($row['user_id']);
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- if(isset($row['email'])) {
- $this->Sendmail->To($row['email']);
- $subject="XOimages - Submission Ticket ".$row['ticket_number'];
- $this->Sendmail->Subject($subject);
- $this->set("ticket_number",$row['ticket_number']);
- $this->Sendmail->layout='email';
- $this->Sendmail->view='mail_ticket_'.($_POST['approve']==1 ? 'approve' : 'reject') ;
- $this->Sendmail->startup($this);
- $messageBody=$this->Sendmail->bodyText();
- $this->Sendmail->Body($messageBody); // set the body
- $this->Sendmail->Priority(1) ; // set the priority to Low
- $this->Sendmail->Send(); // send the mail
- //mail sent to the user mail account in the system
- $sender=1;
- $receiver=$row['user_id'];
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- }
- }
- }
- $this->render('save_ticket_approval');
- }
- function product_detail() {
- $this->layout = "blank";
- $this->set("prodid",base64_decode($this->params['url']['prodid']));
- }
- function categories_image() {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('pageHeader','Categories Image');
- $types= $this->getTypeImage();
- $this->set('types',$types);
- $this->getCategory($types[0]['id']);
- }
- function save_categories_image() {
- if(isset($_POST['id_type'])) {
- if($_POST['name_category']!='') {
- if($_POST['id_cate']!='') {
- $query = "UPDATE sp_categories SET id_type='".$_POST['id_type']."', name='".$_POST['name_category']."', sequence='".$_POST['sequence']."'
- WHERE id='".$_POST['id_cate']."' ";
- }else
- $query = "INSERT INTO sp_categories SET id_type='".$_POST['id_type']."', name='".$_POST['name_category']."', sequence='".$_POST['sequence']."' ";
- mysql_query($query);
- }
- $this->getCategory($_POST['id_type'],true);
- }
- }
- function removeCategory($id) {
- $query = "SELECT id_type FROM sp_categories WHERE id='".$id."' ";
- $result = mysql_query($query);
- ;
- $row= mysql_fetch_assoc($result);
- $query = "DELETE FROM sp_categories WHERE id='".$id."' ";
- mysql_query($query);
- $this->getCategory($row['id_type'],true);
- }
- function editCategory($id) {
- $query = "SELECT * FROM sp_categories WHERE id='".$id."'";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- $this->set('cate',$row);
- $this->set('id',$id);
- $this->render('categories_image_edit','ajax');
- }
- function getTypeImage() {
- $query = "SELECT * FROM sp_type";
- $result = mysql_query($query);
- $arr = array();
- while($row=mysql_fetch_assoc($result)) {
- $arr[] = $row;
- }
- return $arr;
- }
- function getCategory($id_type,$is_ajax=false) {
- $query = "SELECT * FROM sp_categories WHERE id_type='".$id_type."'";
- $result = mysql_query($query);
- $arr = array();
- while($row=mysql_fetch_assoc($result)) {
- $arr[] = $row;
- }
- $this->set('categories',$arr);
- if($is_ajax) {
- $this->render('categories_image_change_type','ajax');
- }
- return $arr;
- }
- function uploadimage() {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('pageHeader','Upload Image');
- $types= $this->getTypeImage();
- $this->set('types',$types);
- $id_type = $types[0]['id'];
- if(isset($_POST['id_type'])) {
- $id_type = $_POST['id_type'];
- if($_POST['name']!='' && $_POST['id_categori']!='') {
- $is_upload = false;
- if($_FILES['src']['tmp_name']!='') {
- $folder = '';
- switch ($_POST['id_type']) {
- case 1: $folder ='photos';
- break;
- case 2: $folder ='background';
- break;
- case 3: $folder ='superimpose';
- break;
- case 4: $folder ='frame';
- break;
- case 5: $folder ='text_symbol';
- break;
- case 6: $folder ='calendars';
- break;
- case 7: $folder ='graphics';
- break;
- }
- $des = '../../flash/library/'.$folder.'/';
- if(!file_exists($des)) {
- mkdir($des,0777);
- }
- if(!file_exists($des.'thumb')) {
- mkdir($des.'thumb',0777);
- }
- $this->Upload->upload($_FILES['src'],$des);
- if($this->Upload->errors!=null) {
- $this->set('error',join('<br/>',$this->Upload->errors));
- $is_upload = false;
- }
- else {
- $is_upload = true;
- $filesrc = str_replace('../../flash/', '', $this->Upload->_name);
- $file['tmp_name'] = $this->Upload->_name;
- $this->Upload->_name = $des.'thumb/'.str_replace($des, '', $this->Upload->_name);
- $this->Upload->image($file,'resizemin',array(110,80));
- $filethumb = str_replace('../../flash/', '', $this->Upload->_name);
- }
- }
- if($_POST['id_photo']=='' && $is_upload) {
- $sql = "INSERT INTO sp_photos SET id_categori='".$_POST['id_categori']."', name='".$_POST['name']."', thumb='".$filethumb."',src='".$filesrc."'";
- mysql_query($sql);
- }elseif ($_POST['id_photo']!='') {
- $sql = "UPDATE sp_photos SET id_categori='".$_POST['id_categori']."', name='".$_POST['name']."' ";
- if($is_upload)
- $sql .=", thumb='".$filethumb."',src='".$filesrc."'";
- $sql .=" WHERE id='".$_POST['id_photo']."' ";
- mysql_query($sql);
- }
- }
- }
- $cates = $this->getCategory($id_type);
- $id_cate = (count($cates)==0) ? 0 : $cates[0]['id'];
- if(isset($_POST['id_categori']) && $_POST['id_categori']!='') {
- $id_cate = $_POST['id_categori'];
- }
- $this->set('id_type',$id_type);
- $this->set('id_cate',$id_cate);
- $this->getImage($id_cate);
- }
- function editImage($id) {
- $query = "SELECT * FROM sp_photos WHERE id='".$id."'";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- $this->set('photo',$row);
- $this->set('id',$id);
- $this->render('uploadimage_edit','ajax');
- }
- function removeImage($id) {
- $query = "SELECT * FROM sp_photos WHERE id='".$id."'";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- $id_cate = $row['id_categori'];
- $query = "DELETE FROM sp_photos WHERE id='".$id."'";
- mysql_query($query);
- $this->getImage($id_cate,true);
- }
- function uploadimage_changetype($id_type) {
- $cates = $this->getCategory($id_type);
- $id_cate = (count($cates)==0) ? 0 : $cates[0]['id'];
- $this->getImage($id_cate,true);
- }
- function getImage($id_categori=null,$is_ajax=false) {
- $select = "SELECT * ";
- $from = "FROM sp_photos ";
- $where = "WHERE id_categori='".$id_categori."'";
- if(isset($_REQUEST['id_categori']) && $_REQUEST['id_categori']!='') {
- $id_categori = $_REQUEST['id_categori'];
- }
- $where = "WHERE id_categori='".$id_categori."'";
- $searchpass = "id_categori=".$id_categori ;
- $others = " ORDER BY name";
- $PassParameter =$searchpass;
- $CountField="id";
- $this->set("controller","creativezones");
- $this->set("action","getImage");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || $is_ajax) {
- $this->render("uploadimage2","ajax");
- }
- }
- function fonts() {
- $this->checkSession();
- $this->layout = 'default_user';
- $this->set('pageHeader','Fonts');
- if(isset($_POST['name'])) {
- $is_upload = false;
- if($_FILES['src']['tmp_name']!='') {
- $folder = '';
- $des = '../../flash/FlashDesignFont/';
- if(!file_exists($des)) {
- mkdir($des,0777);
- }
- $this->Upload->upload($_FILES['src'],$des,NULL,NULL,array('swf'));
- if($this->Upload->errors!=null) {
- $this->set('error',join('<br/>',$this->Upload->errors));
- $is_upload = false;
- }
- else {
- $is_upload = true;
- $filesrc = str_replace($des, '', $this->Upload->_name);
- $file['tmp_name'] = $this->Upload->_name;
- }
- }
- if($_POST['id_font']=='' && $is_upload) {
- $sql = "INSERT INTO sp_fonts SET name='".$_POST['name']."', class_name='".$_POST['class_name']."', active='".(isset($_POST['active']) ? 1:0)."',src='".$filesrc."'";
- mysql_query($sql);
- }elseif ($_POST['id_font']!='') {
- $sql = "UPDATE sp_fonts SET name='".$_POST['name']."', class_name='".$_POST['class_name']."', active='".(isset($_POST['active']) ? 1:0)."' ";
- if($is_upload)
- $sql .=", src='".$filesrc."'";
- $sql .=" WHERE id='".$_POST['id_font']."' ";
- mysql_query($sql);
- }
- }
- }
- function fonts_list() {
- $query = "SELECT * FROM sp_fonts ";
- $result = mysql_query($query);
- $arr = array();
- while($row=mysql_fetch_assoc($result)) {
- $arr[] = $row;
- }
- $this->set('fonts',$arr);
- $this->render('fonts_list','ajax');
- }
- function fonts_edit($id){
- $query = "SELECT * FROM sp_fonts WHERE id='".$id."' LIMIT 1";
- $result = mysql_query($query);
- $this->set('item',mysql_fetch_array($result));
- }
- function fonts_remove($id){
- $query = "SELECT * FROM sp_fonts WHERE id='".$id."' LIMIT 1";
- $result = mysql_query($query);
- if(($row=mysql_fetch_array($result))){
- $des = '../../flash/FlashDesignFont/';
- if(file_exists($des.$row['src'])){
- @unlink($des.$row['src']);
- }
- mysql_query("DELETE FROM sp_fonts WHERE id='".$id."' ");
- }
- $this->fonts_list();
- }
- function payment_transactions(){
- $this->checkSession();
- $this->redirect(PAYMENT_ADMIN_URL);
- }
- }
- ?>