/app/controllers/creativezones_controller_bakup.php
PHP | 3851 lines | 2536 code | 783 blank | 532 comment | 396 complexity | 4a890db0242573c7d2df323b93eae2e4 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
- <?
- class CreativezonesController extends AppController {
- var $name='Creativezones';
- var $helpers = array('Html','javascript','error','Ajax','Friendsurl','Common');
- var $uses=array('Creativezone','User','Creative_favorites','Creative_favorite_tags','Creative_tickets','Transaction_creatives');
- var $components = array('Newdir','Thumbnail','Thumbnailc','Zipfile','Download','Cartmail','Creative','Sendmail');
-
-
- //ok
- function index() {
- //$this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ Home';
- //$this->layout = 'creativehome';
- $this->layout = 'creativedetail';
- $this->homepageslideInfo('ScrapFOTO');
-
- //Initializing all the bradcamp back again so that it all starts all over again
- unset($_SESSION['bradcamp_creative']);
- $this->set("filename","index"); //filename should contain the name of the file that should be selected
-
- //_________________________________________________________________________________________________
-
- unset($_SESSION['buyTemplate']);
- //check creative_carts
- if(isset($_SESSION['UserId'])) {
- $sql = "SELECT Cart.id FROM creative_carts as Cart
- LEFT JOIN creative_cart_details CartDetail ON Cart.id = CartDetail.creative_cart_id
- LEFT JOIN creative_favorites Favorite ON Favorite.id = CartDetail.creative_favorite_id
- WHERE Cart.user_id ='".$_SESSION['UserId']."' AND Cart.pay_status='0' AND Favorite.is_republished ='0' AND Favorite.is_temp='1' ";
-
- $result = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($result)>0) {
- //delete cart
- while($row=mysql_fetch_array($result)) {
- mysql_query("DELETE FROM creative_carts WHERE id='".$row['id']."' ") or die(mysql_error());
- }
- }
-
- //check delete favorite
- //mysql_query("DELETE FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_republished ='0' AND is_temp='1' ") or die(mysql_error());
- }
-
- $this->creativeType();
- $this->countFavCart();
- $this->getRankScrap();
- $this->getFeaturedScrap();
- $this->getPublicScrap();
-
- $this->render('index');
- }
-
- //ok ajax call get scrap in tab "Featured","Hight Rated","Recent"
- function featuredscrap($catlisttype=null) {
- $this->layout = 'profile_blank';
- ///////////////////////////////////////////////////// SQL FOR FEATURED SCRAP
- /* Pagination and PHOTO listing */
- $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.price,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
-
- LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0' ";
-
-
- if($catlisttype=='featured') {
- $where.=" AND X.is_featured='1' ";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=featured';
- }
-
- $others=" group by X.id ";
-
- if($catlisttype=='mostvoted') {
- $others .=" order by photorat desc ";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=mostvoted';
-
- }
-
- if(!$catlisttype) {
- $others.=" order by X.id desc";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=recent';
-
- }
-
- $tabsql = $select.$from.$where. $others . ' LIMIT 12';
- $tabsql_res = mysql_query($tabsql);
- $this->set('query',$tabsql_res) ;
- $this->set('tabsql',$tabsql) ;
- $this->set('morelink',$morelink);
- /////////////////////////////////////////////////////////////////
- }
-
- //ok scrap listing
- function scrapxonglisting() {
- $this->layout = 'creativeinner';
-
- $catlisttype = '';
- if(isset($_REQUEST['listtype']) && $_REQUEST['listtype']!='')
- $catlisttype = $_REQUEST['listtype'];
-
- //this section is used to check whether to show the list based on the category given in the header section
- $scrapType=0;
- if(isset($this->params['url']['cat'])) {
- $scrapType=base64_decode($this->params['url']['cat']);
- $this->set("selTab",$scrapType);
- }
-
- ############################### Page Title & Head ############################
-
- $pageheadArr = array();
- $pageheadArr['featured'] = 'Featured';
- $pageheadArr['recent'] = 'Recent';
- $pageheadArr['mostvoted'] = 'Most Voted';
- $pageheadArr['mostcomment'] = 'Most Discussed';
- $pageheadArr['random'] = 'Random';
- $pageheadArr['favorite'] = 'Most Favorited ';
- $pageheadArr['tag'] = 'Tagged ';
- $pageheadArr['search'] = 'Search Result';
- $pageheadArr['mostviewed'] = 'Most Viewed';
- $pageheadArr['albumview'] = 'Album';
- $pageheadArr['seller'] = 'Seller';
- $pageheadArr['popular'] = 'Popular';
- if (array_key_exists($catlisttype, $pageheadArr)) {
- if($catlisttype=='albumview') {
- /* Album Name*/
- $albumNameSql = "Select IFNULL(creative_name,'') as albumName from creative_type where id='".base64_decode($_REQUEST['albumid'])."'";
- $albumNameSql_res = mysql_fetch_array(mysql_query($albumNameSql));
- $albumName = stripslashes($albumNameSql_res['albumName']) ;
- /**/
- $this->pageTitle = $pageheadArr[$catlisttype]. $albumName.' ScrapFOTO™';
- $this->set('pagehead',$pageheadArr[$catlisttype].' : '. $albumName. ' ScrapFOTO™');
-
- }
- else {
- if($catlisttype=='tag') {
- $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO™ : '. $_REQUEST['sortby'];
- $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO™ : '.$_REQUEST['sortby']);
- }
- else {
- if($catlisttype=='seller') {
- /* SELLER INFO */
- $sellinfo = " SELECT username from users where id='".base64_decode($_REQUEST['resaleby'])."'";
- $sellinfo_res = mysql_query($sellinfo);
- $sellinfo_arr = mysql_fetch_array($sellinfo_res);
-
- $this->pageTitle = 'ScrapFOTO™ '.$pageheadArr[$catlisttype] .' : '.$sellinfo_arr['username'];
- $this->set('pagehead','ScrapFOTO™ '.$pageheadArr[$catlisttype].' : '.$sellinfo_arr['username']);
-
- }
- else {
- $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO™';
- $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO™');
- }
- }
- }
- }
- else {
- if($catlisttype=='category') {
- $scrapDetail=$this->getCreativeType($scrapType);
- $this->pageTitle = $scrapDetail['creative_name'];
- $this->set('pagehead',$scrapDetail['creative_name']);
- }
- else {
- $this->pageTitle = 'ScrapFOTO™';
- $this->set('pagehead','ScrapFOTO™');
- }
- }
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0'";
-
-
- if($catlisttype=='featured')
- $where.=" AND X.is_featured='1' ";
- if( $catlisttype=='albumview' && isset($_REQUEST['albumid']) && base64_decode($_REQUEST['albumid'])>0)
- $where.=" AND XCreativetype.id='".base64_decode($_REQUEST['albumid'])."' ";
- if($catlisttype=='tag')
- $where.=" AND X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['sortby']."%')";
- if($catlisttype=='search')
- $where.=" AND X.title LIKE '%".$_REQUEST['srchtxt']."%' OR X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['srchtxt']."%') ";
- if($catlisttype=='seller')
- $where.=" AND X.user_id='".base64_decode($_REQUEST['resaleby'])."' ";
-
- if($catlisttype=='category')
- $where.=" AND XCreativetype.id='".$scrapType."' ";
-
-
- $others=" group by X.id ";
-
- if($catlisttype=='mostvoted')
- $others .=" order by photorat desc ";
-
- if($catlisttype=='mostcomment')
- $others .=" order by photoreview desc ";
-
- if($catlisttype=='mostviewed')
- $others .=" order by X.viewed desc ";
- if($catlisttype=='random')
- $others .=" order by X.id desc , rand()";
-
- if($catlisttype=='favorite')
- $others .=" order by photofavored desc ";
-
- if($catlisttype=='')
- $others.=" order by X.id desc";
-
-
- if(isset($_REQUEST['sortby']) && $_REQUEST['sortby']!='')
- $PassParameter="listtype=".$catlisttype."&sortby=".$_REQUEST['sortby'];
- else {
- if(isset($catlisttype) && $catlisttype=='albumview')
- $PassParameter="listtype=".$catlisttype."&albumid=".$_REQUEST['albumid'];
- else {
- if(isset($_REQUEST['srchtxt']) && $_REQUEST['srchtxt']!='')
- $PassParameter="listtype=".$catlisttype."&srchtxt=".$_REQUEST['srchtxt'];
- else {
- if(isset($_REQUEST['resaleby']) && base64_decode($_REQUEST['resaleby'])>0)
- $PassParameter="listtype=".$catlisttype."&resaleby=".$_REQUEST['resaleby'];
- else {
- if($catlisttype=='category')
- $PassParameter="listtype=".$catlisttype.'&cat='.base64_encode($scrapType) ;
- else
- $PassParameter="listtype=".$catlisttype;
- }
- }
- }
- }
-
-
-
- $fltr='';
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","scrapxonglisting");
- $this->set("parameter",$PassParameter);
- $this->set("fltr",$fltr);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") ) {
- $this->set('pagehead','Most Recent');
- $this->render("scrapxonglisting2","ajax");
- }
-
- /**/
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- //ok scrap detail
- function scrapxong() {
- //$this->verifyserverUrl($_SERVER['REQUEST_URI']);
- $this->pageTitle = 'ScrapFOTO™';
- $this->layout = 'creativedetail';
-
- ############################################ SCRAP XONG DETAILS
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
-
- $this->set('photoid',$_REQUEST['sxid']);
-
- //update viewed
- $select = "UPDATE creative_favorites SET viewed=viewed+1 WHERE id='".base64_decode($_REQUEST['sxid'])."' ";
- mysql_query($select);
-
- $select = " Select X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.user_id,X.title,X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.id='".base64_decode($_REQUEST['sxid'])."' AND X.type='0' AND X.is_stop_sell='0' group by X.id";
-
- $photo_sql = $select . $from .$where;
- $photo_res = mysql_query($photo_sql);
- $photores_arr = mysql_fetch_array($photo_res);
- $photoUrl = FULL_BASE_URL.$this->webroot."creativezones/scrapxong?sxid=".$_REQUEST['sxid'];//DOMAIN
- $this->set('photoUrl',$photoUrl);
-
- $this->set('photoArr', $photores_arr);
- $this->set('photoTitle', $photores_arr['title']);
- $this->set('photoDesc', $photores_arr['description']);
- $this->set('photoImage', $photores_arr['template_img']);
- $this->set('photoImageId', $photores_arr['id']);
- $this->set('photoUsername', $photores_arr['username']);
- $this->set('photototalRating', $photores_arr['photorat']);
- $this->set('photototalReview', $photores_arr['photoreview']);
- $this->set('photoPrice', number_format($photores_arr['price'],2,'.',','));
-
- $checklover = "Select * from creative_favorite_lovers where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."'" ;
- $checklover_res = mysql_query($checklover);
- $checklover_res_num = mysql_num_rows($checklover_res);
- $this->set('nooflover', $checklover_res_num);
-
- ##### Check for the review already posted or not
- $numberpreview=0;
- if(isset($_SESSION['UserId'])) {
- $checkbackdropreview = "SELECT * FROM creative_favorite_comments where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."' and user_id='".$_SESSION['UserId']."'";
- $checkbackdropreview_res = mysql_query($checkbackdropreview);
- $numberpreview = mysql_num_rows($checkbackdropreview_res);
- }
- $this->set('reviewposted', $numberpreview);
- #####
-
- ################################################### FOR NEXT AND PREVIOUS #######################
-
- $Imgselect="
- SELECT CF.id,title,template_img
- FROM creative_favorites CF,creative_favorites_details CFDTL
- WHERE CF.id=CFDTL.creative_favorite_id AND CF.type='0'
- GROUP BY CF.id ORDER BY CF.id DESC
- " ;
-
-
- $Imgselect_res = mysql_query($Imgselect);
- $Imgarray = array();
-
- while($Imgselect_arr = mysql_fetch_array($Imgselect_res)) {
- //$Imgarray['image'.$Imgselect_arr['id']] = $Imgselect_arr['id'] ;
- $Imgarray[] = $Imgselect_arr['id'] ;
- }
- //pr($Imgarray);
- //echo base64_decode($_REQUEST['pid']) ;
- $searchKey = array_search(base64_decode($_REQUEST['sxid']),$Imgarray) ;
- // Next
- $searchKeyNext = ($searchKey + 1);
- $searchKeyPrev = ($searchKey - 1);
-
- if (array_key_exists($searchKeyNext, $Imgarray)) {
- $this->set('nxtImage',$Imgarray[$searchKeyNext]);
- }
- // Prev
- if (array_key_exists($searchKeyPrev, $Imgarray)) {
- $this->set('prevImage',$Imgarray[$searchKeyPrev]);
- }
-
- ################################################### FOR NEXT AND PREVIOUS #######################
-
- ########
- }
-
- //checking
- function creativetemplate() {
-
- //$this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Create Template';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- //This variable contains the category Id
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['pg']))
- $tmpImg=base64_decode($this->params['url']['pg']);
-
- $themeId=0;
- if(isset($this->params['url']['tmplate']))
- $themeId=base64_decode($this->params['url']['tmplate']);
-
- //this variable is used to show the selected section in the accordian tag
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
- $this->set("themeId",$themeId);
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creativetemplate"); //filename should contain the name of the file that should be selected
- $_SESSION['bradcamp_creative'][20]=$this->params['action']; //we are passing the name of the file to keep track which step is visited
- $this->set("nextpage","creativezone");
-
- //_________________________________________________________________________________________________
-
- $this->countFavCart();
- /*
- // getting out the template name under the type
- if(isset($id)) {
-
- $templateName = array();
- $tempname="
- SELECT CP.*
- FROM creative_type CT,creative_template_pages CP
- WHERE CT.id=CP.creative_type_id AND CT.id='".$id."' AND block='0'
- ORDER BY CP.template_type ASC,CP.title ASC
- ";
- $tempname_res = mysql_query($tempname) or die('Line number '.__LINE__. mysql_error());
- $tempNum = mysql_num_rows($tempname_res);
- if($tempNum > 0) {
- $i=0;
- while($rwTmp = mysql_fetch_assoc($tempname_res)) {
- if($i==0) {
- $defaultTmpId=$rwTmp['id'];
- $this->set("defaultTemplateId",$defaultTmpId);
- }
-
- $i++;
- $templateName[$rwTmp['id']]=array($rwTmp['title'],$rwTmp['template_img'],$rwTmp['price'],$rwTmp['template_type']);
- }
-
- }
-
- }
-
- $this->set('templateImg',$templateName);
-
- //Getting the large thimbnail image
- if(isset($tmpImg) && $tmpImg!=0) {
- $this->templateDetail($tmpImg);
- $this->render("template","ajax");
- }
-
-
- if(isset($this->params['url']['tpage'])) {
- //print "test";
- $tPage=base64_decode($this->params['url']['tpage']);
- $this->templateDetail($tPage);
- //exit;
- $this->render("template","ajax");
- }
- */
- }
- //checking
- function creativetemplatezone() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Creative Zone';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creativetemplatezone"); //filename should contain the name of the file that should be selected
- $this->set("nextpage","creative_favorite");
-
- //_________________________________________________________________________________________________
-
-
-
- if(isset($this->params['url']['tmp'])) {
- $tmpImg=base64_decode($this->params['url']['tmp']);
- $tmpImg = $this->templateDetail($tmpImg);
-
- if($tmpImg==0) {
- $this->redirect('/creativezones/index');
- }else {
- //emty cart current
- $sql ="SELECT id FROM creative_carts WHERE pay_status='0' ";
- $result = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($result)>0) {
- while($row=mysql_fetch_array($result)) {
- $sql ="DELETE FROM creative_cart_details WHERE creative_cart_id='".$row['id']."' ";
- mysql_query($sql) or die(mysql_error());
- }
- }
- //add favorite
- if(!isset($_SESSION['buyTemplate']['tmpId'])) {
- $_SESSION['buyTemplate']['tmpId'] = $tmpImg;
- //add to favorite
- $fav = $this->Creative_favorites->findById($tmpImg);
-
- $fav['Creative_favorites']['id'] = null;
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['is_temp'] = 1;
- $fav['Creative_favorites']['type'] = 1;
- $fav['Creative_favorites']['is_featured'] = 0;
- $fav['Creative_favorites']['is_republished'] = 0;
-
- $this->Creative_favorites->create();
- $this->Creative_favorites->save($fav);
-
- $idNew = $this->Creative_favorites->id;
- $_SESSION['buyTemplate']['idNew'] = $idNew;
- }
- }
- }
-
- $this->countFavCart();
-
- //case create form header
- if(isset($_POST['widthScrap'])) {
- $this->set('widthScrap',$_POST['widthScrap']);
- $this->set('heightScrap',$_POST['heightScrap']);
- $this->set('titleScrap',$_POST['titleScrap']);
- }
-
- }
- //checking
- function creative_favorite() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - My Favorite';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
-
- $tmpImg=0;
- if(isset($this->params['url']['tmp'])) {
- $tmpImg=base64_decode($this->params['url']['tmp']);
- $tmpImg = $this->templateDetail($tmpImg);
- }else if(isset($_SESSION['buyTemplate']['tmpId'])) {
- $tmpImg = $_SESSION['buyTemplate']['tmpId'];
- $tmpImg = $this->templateDetail($tmpImg);
- }
-
-
- if(isset($_POST['ssn_id'])) {
- $ssn_id = $_POST['ssn_id'];
- $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
-
- if(!$fav) {//create
- $this->Creative_favorites->create();
- }
- else {//update
- $this->Creative_favorites->id = $fav['Creative_favorites']['id'];
- }
- $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
- $fav['Creative_favorites']['description'] = $_POST['description'];
- $fav['Creative_favorites']['price'] = $_POST['price'];
- $fav['Creative_favorites']['width'] = $_POST['width'];
- $fav['Creative_favorites']['height'] = $_POST['height'];
- $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
- $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
- $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
- $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
- $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
- $fav['Creative_favorites']['is_temp'] = 0;
-
- $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
- $fav['Creative_favorites']['type'] = $_POST['type'];
- $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
-
- $fav['Creative_favorites']['is_temp'] = $fav['Creative_favorites']['is_featured'];
-
- if($fav['Creative_favorites']['type']==0) {//public
- $featuredAmount=$this->getConfigAmount('creative artist price');
- $fav['Creative_favorites']['price'] = $featuredAmount['config_value'];
- }
-
- $resultSave = $this->Creative_favorites->save($fav);//return 1/null
-
-
- //insert tag
- if($resultSave && $_POST['tag']!='') {
- $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
- $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
- $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
- $this->Creative_favorite_tags->create();
- $this->Creative_favorite_tags->save($tag);
- }
-
- if($fav['Creative_favorites']['type']==0) {
- if($resultSave && $fav['Creative_favorites']['is_featured']==1) {
- $this->redirect("creativezones/creative_featured?lid=".base64_encode($this->Creative_favorites->id));
- exit();
- }else {
- $this->redirect("creativezones/featuredsuccess?lid=".base64_encode($this->Creative_favorites->id));
- }
- }
-
- }
-
- if(isset($_POST['actionCall']) && $_POST['actionCall']=='exit') {
- $this->redirect('/creativezones/index');
- }
-
- if($tmpImg==0) {
- unset($_SESSION['buyTemplate']);
- $favs = null;
- $result = mysql_query("SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_temp='0' AND is_republished='1' ") or die("Error on line :".__LINE__.mysql_error());
- if(mysql_num_rows($result)>0) {
- $favs = $result;
- }
- $this->set("favs",$favs);
- }else if(isset($_SESSION['buyTemplate']['idNew'])) {
- $favs = null;
- $result = mysql_query("SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND id='".$_SESSION['buyTemplate']['idNew']."' ") or die("Error on line :".__LINE__.mysql_error());
- if(mysql_num_rows($result)>0) {
- $favs = $result;
- }
- $this->set("favs",$favs);
- }
-
- $this->countFavCart();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creative_favorite");
- $this->set("nextpage","mycart");
-
- //_________________________________________________________________________________________________
-
- $this->set("recenttype","creative_favorite");
- $this->getCartDetails();
- }
- //ok
- function creative_favorite_ajax() {
- if(isset($_POST['ssn_id'])) {
- $ssn_id = $_POST['ssn_id'];
- $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
-
- if(!$fav) {
- $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
- $fav['Creative_favorites']['description'] = $_POST['description'];
- $fav['Creative_favorites']['price'] = $_POST['price'];
- $fav['Creative_favorites']['width'] = $_POST['width'];
- $fav['Creative_favorites']['height'] = $_POST['height'];
- $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
- $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
- $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
- $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
- $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
- $fav['Creative_favorites']['is_temp'] = 0;
-
- $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
- $fav['Creative_favorites']['type'] = $_POST['type'];
- $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
-
- $this->Creative_favorites->create();
- $resultSave = $this->Creative_favorites->save($fav);//return 1/null
-
-
- //insert tag
- if($resultSave && $_POST['tag']!='') {
- $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
- $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
- $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
- $this->Creative_favorite_tags->create();
- $this->Creative_favorite_tags->save($tag);
- }
- }
- }
-
- $this->countFavCart();
- $this->render("creative_favorite_ajax","ajax");
-
- }
-
- function creativeType() {
- $q1=mysql_query("SELECT * FROM creative_type WHERE is_delete='0' ORDER BY sequence 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);
-
- $type = 0;
- foreach($defaultCat as $key=>$value) {
- $type = $key;
- break;
- }
-
- if(isset($this->params['url']['cat'])) {
- $scrapType=base64_decode($this->params['url']['cat']);
- $detail = $this->getCreativeType($scrapType);
- if($detail) {
- $type = $detail['id'];
- }
- }
-
- $this->set('defaultCate',$type);
- }
- //checking
-
- function templateDetail($tmpImg) {
- $q1=mysql_query("SELECT * FROM creative_favorites WHERE id='".$tmpImg."' AND is_blocked='0' AND is_temp='0' AND is_approved='1' AND type='0' ") or die(mysql_error());
- if(mysql_num_rows($q1)>0) {
- $rwTmpImg=mysql_fetch_assoc($q1);
- $this->set("tmpid",base64_encode($rwTmpImg['ssn_id']));
- $this->set("tmp",base64_encode($tmpImg));
- return $tmpImg;
- }
- return 0;
- }
- //ok
- function getPublicScrap() {
-
- $select = " Select X.price,X.fileThumb2 as imagename,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0'";
- $others=" group by X.id ";
- $others .=" order by photorat desc ";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
-
-
-
-
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicScrap",$queryCreativeFavorites);
- $this->set("publicScrapSql",$queryCreative);
-
- }
- //ok
- function getRankScrap() {
- /*$select = " Select X.fileThumb2 as template_img,X.price,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' ";
- $others=" group by X.id ";
- $others .=" order by photorat desc LIMIT 21";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicRank",$queryCreativeFavorites);
- $this->set("publicRankSql",$queryCreative);
- */
- }
- //ok
- function getFeaturedScrap() {
- /*$select = " Select X.width, X.height, X.price, X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,XCreativetypeDetail.template_img,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,Xalbum.price";
-
- $from=" FROM creative_favorites X
-
- LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
- LEFT JOIN creative_template_pages Xalbum ON X.creative_template_page_id = Xalbum.id
- LEFT JOIN creative_type XCreativetype ON Xalbum.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_featured='1' AND X.is_approved='1' ";
- $others=" group by X.id ";
- $others .=" order by photorat desc LIMIT 21";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicFeatured",$queryCreativeFavorites);
- $this->set("publicFeaturedSql",$queryCreative);
- */
- }
- //ok
- function viewalltag() {
- $this->pageTitle = 'ScrapFOTO™ - View Tag';
- $this->layout = 'creativedetail';
- $this->creativeType();
- $this->getPublicScrap();
-
- }
- //ok
- function searchtag($alphasearch=null) {
-
- if($alphasearch)
- $searchtxt = "'".strtolower($alphasearch)."%'" ;
- else {
- if(isset($_REQUEST['txttagsearch']) && $_REQUEST['txttagsearch']!='')
- $searchtxt = "'%". strip_html_tags($_REQUEST['txttagsearch'])."%'";
- else
- $searchtxt='a%';
- }
-
- $tagarray = array();
- $tagsearchsql = "SELECT DISTINCT(tagname) FROM creative_favorite_tags where tagname!='' and tagname like ". $searchtxt ."";
- $tagsearchsql_res = mysql_query($tagsearchsql);
- while($tagsearchsql_arr = mysql_fetch_array($tagsearchsql_res)) {
- $tagarray[] = $tagsearchsql_arr['tagname'];
- }
- $this->set('tagsql',$tagsearchsql);
- $this->set('tagarray',$tagarray);
- $this->set('Numtagarray',mysql_num_rows($tagsearchsql_res));
- $this->set('searchtxt',$alphasearch);
- $this->render('searchtaglist', 'ajax');
-
- }
- //ok
- function scrapaddtocart($scrapxongid=null) {
-
- $queryCreativeFavorites=mysql_query("
- SELECT CF.title,CTP.price
- FROM creative_favorites CF,creative_template_pages CTP
- WHERE CF.id='".base64_decode($scrapxongid)."' AND CF.creative_template_page_id=CTP.id AND CF.type='0'");
- $fetchCreativeFavorites=mysql_fetch_assoc($queryCreativeFavorites);
- $productName=$fetchCreativeFavorites['title'];
- $price=$fetchCreativeFavorites['price'];
-
- if(isset($_SESSION['UserId'])) {
- $creativecartsql = "SELECT * from creative_carts WHERE user_id='".$_SESSION['UserId']."' and product_name='".$productName."' and ssn_id='".session_id()."' and pay_status='0'";
- $creativecartsql_res = mysql_query($creativecartsql);
- if(mysql_num_rows($creativecartsql_res)==0) {
- mysql_query("INSERT INTO
- creative_carts(user_id,product_name,price,qty,transaction_creative_id,pay_status,ssn_id)
- VALUES('".$_SESSION['UserId']."','".$productName."','".$price."','1','0','0','".session_id()."')") or die("Error on line : ".__LINE__.mysql_error());
-
- $lastId=mysql_insert_id();
-
- $queryCreativeFavoritesDetails=mysql_query("SELECT template_img FROM creative_favorites_details WHERE creative_favorite_id='".base64_decode($scrapxongid)."'");
- while($fetchCreativeFavoritesDetails=mysql_fetch_assoc($queryCreativeFavoritesDetails)) {
- mysql_query("INSERT INTO creative_cart_details(creative_cart_id,imagename) VALUES('".$lastId."','".$fetchCreativeFavoritesDetails['template_img']."')");
- }
- }
- }
-
-
- $this->countFavCart();
- $this->set('photoImageId',$scrapxongid);
- $this->render('cartitem', 'ajax');
- }
-
- function creative_login() {
- $uName=base64_decode($this->params['url']['u']);
- $password=$this->params['url']['p'];
-
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
-
- //This is the last iserted id in the favorite table
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
- $someone=$this->userLogin($uName,$password);
- if(!empty($someone))
- $this->redirect("creativezones/creative_favorite?ct=".base64_encode($id)."&tmp=".base64_encode($tmpImg)."&lid=".base64_encode($lastId));
-
- }
-
- function featuredpayment() {
- /*
- $this->checkSession();
- $this->layout = 'previewpaymemnt';
- $this->render("paymentback");
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
- //This is the last iserted id in the favorite table
- //If lid means user comes to this page after saving the scrapbook
- //We are checking whether the user features the scrapblog or not if yes then ask for the payment
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
- $this->set("lastId",$lastId);
-
- if(!empty($this->data)) {
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $featuredAmount=$this->getConfigAmount('creative featured');
-
- $amountCharge=$this->data['creative']['amount'];
- if(isset($this->data['Event']['radiobutton'])) {
- if($this->data['Event']['radiobutton']=="paypal") {
- $this->itemName="ScrapFOTO™ fetaured";
- $this->amountPay=$amountCharge;
- $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
- $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->merchantEmail=$fetchAdminPaymentSetup['paypal_email'];
- $this->custom=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId;
- $this->paypal();
- }
-
- if($this->data['Event']['radiobutton']=="google") {
- $adminPayment=$fetchAdminPaymentSetup['gcheckout_email'];
- $adminPaymentDetails=explode("break",$adminPayment);
- $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
- $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
- $this->Gcheckout->gItemName="ScrapFOTO™ Featured";
- $this->Gcheckout->gItemDesc="ScrapFOTO™ Featured";
- $this->Gcheckout->gQuantity=1;
- $this->Gcheckout->gPrice=$amountCharge;
- $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
- $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->Gcheckout->customData=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId."^".$amountCharge;
- $this->Gcheckout->google();
-
- }
- }
-
- }*/
-
- }
-
- function creative_featured() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Featured ScrapFOTO™';
- $this->layout = 'creativehome';
- $this->creativeType();
- $this->getPublicScrap();
- $cartCount=$this->countFavCart();
-
- $tmpImg =0;
- $id =0;
-
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
- $this->set("lastId",$lastId);
-
- $this->set("filename","creative_cart");
- $this->set("recenttype","creative_favorite");
-
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set("featuredAmount",$featuredAmount);
-
- //getCartDetails;
- $sql = "SELECT *,CF.fileThumb2 as imagename FROM creative_favorites as CF WHERE CF.id='".$lastId."' LIMIT 1";
- $queryCreativeCarts=mysql_query($sql);
- $this->set("queryCreativeCarts",$queryCreativeCarts);
-
- $this->getUserDetails();
-
-
-
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
- }
- //checking
- function featured_payment_notify() {
- /*
- $this->Paypal->paypal_class();
- $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
-
- //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
- $paypal=0;
- if ($this->Paypal->validate_ipn()) {
- $paypal=1;
- if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="") {
- $totalPay=$this->Paypal->ipn_data['payment_gross'];
- $custom=explode("^",$this->Paypal->ipn_data['custom']);
- $userId=$custom['0'];
- $lastId=$custom['1'];
- $invoice=$_POST['invoice'];
- $ticket=$custom['3'];
-
- }
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
- $userId=$ipnData['0'];
- $lastId=$ipnData['1'];
- $invoice=$ipnData['2'];
- $ticket=$ipnData['3'];
- $totalPay=$ipnData['4'];
- }
-
- }
- */
- }
- //checking
- function featuredsuccess() {
-
- $is_featured = 1;
- $productId=0;
- if(isset($this->params['url']['lid']))
- $productId=base64_decode($this->params['url']['lid']);
-
- if($productId==0) {
- //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
- $paypal=0;
- if (isset($_POST['payment_gross']) && ($_POST['payment_gross'])!="") {
- $paypal=1;
-
- $totalPay=$_POST['payment_gross'];
- $custom=explode("^",$_POST['custom']);
-
- $userId=$custom['0'];
- $sellerId=$custom['1'];
- $isAdmin=$custom['2'];
- $rdPage=$custom['3'];
- $invoice=$custom['4'];
- $transactionId=$custom['5'];
- $ticket=$custom['6'];
- $productId=$custom['7'];
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
-
- $userId=$ipnData['0'];
- $sellerId=$ipnData['1'];
- $isAdmin=$ipnData['2'];
- $rdPage=$ipnData['3'];
- $invoice=$ipnData['4'];
- $transactionId=$ipnData['5'];
- $totalPay=$ipnData['6'];
- $ticket=$ipnData['7'];
- $productId=$ipnData['8'];
- }
- }
- }else {
- $userId = $_SESSION['UserId'];
- $totalPay = 0;
- $ticket = $this->createTransactionNumber('SPTT');
- $is_featured = 0;
- }
-
- //________________________________________________XOIMAGE DATABASE UPDATION SECTION
-
- //update featured_time
- $featured_time = NULL;
- if($is_featured==1){
- $result = $this->getConfigAmount('creative featured days');
- $featureddays = $result['config_value'];
- $featured_time = date('Y-m-d G:i:s', strtotime("+".$featureddays." day"));
- }
-
- $queryCreativeFavorites=mysql_query("
- UPDATE creative_favorites
- SET is_featured='$is_featured',is_temp='0', featured_time='".$featured_time."'
- WHERE user_id='".$userId."' AND id='".$productId."'") or die("Error on line : ".__LINE__.mysql_error());
-
-
- if(isset($transactionId)) {
- //UPDATE date on TRANSACTION_CREATIVE TABLE
- $queryUpdateTransactionCreative="
- UPDATE transaction_creatives
- SET pay_status='1',invoice='".$invoice."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'";
- mysql_query($queryUpdateTransactionCreative) or die("Error on line : ".__LINE__.mysql_error());
-
- //UPDATE data to the CREATIVE_CARTS TABLE after successful transaction
- $queryUpdateCreativeCart="
- UPDATE creative_carts
- SET pay_status='1', total_price='".$totalPay."'
- WHERE user_id='".$userId."' AND pay_status='0' AND transaction_creative_id='".$transactionId."' ";
- mysql_query($queryUpdateCreativeCart) or die("Error on line : ".__LINE__.mysql_error());
- }
-
- //____________________________________________________TRANSACTION LOG MANAGEMENT_____________________________________
-
- $userDetails=$this->getUserDetails($userId);
- $scrapDetails=$this->scrapDetails($productId);
-
- if(isset($invoice))
- $this->set('invoice',$invoice);
-
- $this->set('ticket',$ticket);
- $this->set('totalPay',$totalPay);
-
- //ticket
- $ticketData = $this->Creative_tickets->findByCreative_favorites_id($productId);
-
- if(!$ticketData) {
- $ticketData['Creative_tickets']['user_id'] = $userId;
- $ticketData['Creative_tickets']['creative_favorites_id'] = $productId;
- $ticketData['Creative_tickets']['ticket_number'] = $ticket;
- $ticketData['Creative_tickets']['status'] = 'awaiting';
-
- $this->Creative_tickets->create();
- $this->Creative_tickets->save($ticketData);
-
-
-
-
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
- //mail sent to the user personal account
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
-
- if(isset($userDetails['email'])) {
- $this->Sendmail->To($userDetails['email']);
-
- //$this->Sendmail->Cc("sujoy@navsoft.in");
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - Scrapfoto Ticket ".$ticket;
- $this->Sendmail->Subject($subject);
-
- $this->set("ticket_number",$ticket);
- if(isset($invoice)) {
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set('featurefee', $featuredAmount['config_value']);
- }
-
- $this->Sendmail->layout='email';
- $this->Sendmail->view='mail_ticket';
- $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=$userId;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- }
-
- }else {
- $ticket = $ticketData['Creative_tickets']['ticket_number'];
- }
-
- //invoice
- if(isset($invoice)) {
- $downloadimg=$this->getCartImages($userId,$transactionId);
- $zipfilename = 'scrapblogimg'.$transactionId.$userId.'.zip';
-
- //UPDATE transaction_creatives with the scrapfoto filename$zipfilename
- mysql_query("
- UPDATE transaction_creatives
- SET scrapfoto_file='".$zipfilename."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'") or die("Error on line - ".__LINE__.mysql_error());
- ;
- $downloadimgs = array();
- $Imgdestination='';
- foreach($downloadimg as $img) {
- $arr = explode('/', $img);
- $downloadimgs[] = $arr[count($arr)-1];
- $Imgdestination = '../'.substr($img, 0, - strlen($arr[count($arr)-1]));
- }
-
- $Imgdestination = realpath($Imgdestination).'/';
- $zipdestination = realpath('../app/webroot/creativezone/downloadscraps/').'/';
- $this->Zipfile->addFiles($downloadimgs,$Imgdestination); //array of files
- $this->Zipfile->output($zipfilename,$zipdestination);
-
- $queryXouserTransactions=mysql_query("SELECT * FROM xouser_transactions WHERE transaction_head='scrapfoto' AND transaction_title='feature' AND invoice_id='".$transactionId."'");
- if(mysql_num_rows($queryXouserTransactions)<=0) {
- $transactionDesc="ScrapFOTO - scraps featured";
- $transactionHead="scrapfoto";
- $transactionTitle="feature";
- $invoiceId=$transactionId;
-
- $statusoffee = "nontransactionfee";
-
- $lastInsertId=$this->transactionMaster($transactionDesc,$transactionHead,$transactionTitle,$invoice,$invoiceId);
-
- $this->transactionDetail($userId,$totalPay,'-1',$lastInsertId,1,$statusoffee,0,'finished'); //charged//this code is changed on 7th January 2010(statusfee added as well as paymentstatus value 'finished' added---finished is not in used now.)
- //$this->transactionDetail($userId,$totalPay,'+1',$lastInsertId,1); //paid//this code is blocked on 7th January 2010
-
-
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
- //mail sent to the user personal account
- if(isset($userDetails['email'])) {
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($userDetails['email']);
-
- //$this->Sendmail->Cc("sujoy@navsoft.in");
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - ScrapFoto Invoice ".$invoice;
- $this->Sendmail->Subject($subject);
-
- $this->set('tranId', $invoiceId);
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set('featurefee', $featuredAmount['config_value']);
-
- $this->Sendmail->layout='email';
- $this->Sendmail->view='mail_scrapfeature';
- $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=$userId;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- }
- }
- }
-
-
- $this->layout = 'creativedetail';
- $this->creativeType();
- $this->countFavCart();
- $this->getRankScrap();
- $this->getFeaturedScrap();
- $this->getPublicScrap();
- $this->render('featuredsuccess','creativedetail');
-
- }
- //test
- function mail_ticket($ticket) {
- $this->layout = 'email';
- $this->set("ticket_number",$ticket);
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set('featurefee', $featuredAmount['config_value']);
- }
- //test
- function mail_scrapfeature($tranId) {
- $this->layout = 'email';
- $this->set("tranId",$tranId);
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set('featurefee', $featuredAmount['config_value']);
- }
-
- function scrapDetails($id) {
- $queryCreativeFavorites=mysql_query("SELECT * FROM creative_favorites WHERE id='".$id."'");
- return $fetchCreativeFavorites=mysql_fetch_assoc($queryCreativeFavorites);
- }
-
- function getUserCreativeSalesTax($stateId) {
- $queryCreativeSaletax=mysql_query("
- SELECT tax
- FROM creative_saletax CS WHERE CS.state_id='".$stateId."'") or die("Error on line ".__LINE__.mysql_error());
- $fetchCreativeSaletax=mysql_fetch_assoc($queryCreativeSaletax);
-
- return $fetchCreativeSaletax['tax'];
-
- }
- //checking
- function chargecouponcode() {
- //cart deatils
- $this->getCartDetails();
-
- //sale tax
- $stateId=0;
- $saleTax=0;
- if(isset($this->params['url']['orderBy']))
- $stateId=$this->params['url']['orderBy'];
-
- if(isset($this->params['pass']['0']))
- $stateId=$this->params['pass']['0'];
-
- $saleTax=$this->getUserCreativeSalesTax($stateId);
- $this->set("saleTax",$saleTax);
- $this->set("stateId",$stateId);
- //Coupon code
- $couponCode=$this->params['pass']['1'];
- $this->set("coupon",$couponCode);
-
- $curDate=date("Y-m-d");
- $couponValue=0;
- $qry="SELECT coupon_value FROM creative_coupon
- WHERE coupon_code='".$couponCode."' AND '$curDate' BETWEEN coupon_from AND coupon_to AND blocked='0'";
- $q1=mysql_query($qry);
- if(mysql_num_rows($q1)>0) {
- $rw=mysql_fetch_assoc($q1);
- $couponValue=$rw['coupon_value'];
- }
-
- //payment details
- //check if buy template then get payment of user create artist
- $tmpImg=0;
- if(isset($_SESSION['buyTemplate']['tmpId']))
- $tmpImg= $this->templateDetail($_SESSION['buyTemplate']['tmpId']);
- if($tmpImg>0) {
- $fav = $this->Creative_favorites->findById($tmpImg);
- $fetchAdminPaymentSetup=$this->getPaymentMethodsUsers($fav['Creative_favorites']['user_id']); // that means payment will go to the user paymenbt id
- $this->set('sellerId',$fav['Creative_favorites']['user_id']);
- }else {
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set('sellerId',1);
- }
-
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- $this->set("couponValue",$couponValue);
- $this->set("saleTax",$saleTax);
-
-
- $this->render("couponcharge","ajax");
- }
-
- function feature_chargecouponcode() {
-
- $featuredAmount=$this->getConfigAmount('creative featured');
- $totalAmount = $featuredAmount['config_value'];
-
- //sale tax
- $stateId=0;
- $saleTax=0;
- if(isset($this->params['url']['orderBy']))
- $stateId=$this->params['url']['orderBy'];
-
- if(isset($this->params['pass']['0']))
- $stateId=$this->params['pass']['0'];
-
- $saleTax=$this->getUserCreativeSalesTax($stateId);
- $this->set("saleTax",$saleTax);
- $this->set("stateId",$stateId);
- //Coupon code
- $couponCode=$this->params['pass']['1'];
- $this->set("coupon",$couponCode);
-
- $curDate=date("Y-m-d");
- $couponValue=0;
- $qry="SELECT coupon_value FROM creative_coupon
- WHERE coupon_code='".$couponCode."' AND '$curDate' BETWEEN coupon_from AND coupon_to AND blocked='0'";
- $q1=mysql_query($qry);
- if(mysql_num_rows($q1)>0) {
- $rw=mysql_fetch_assoc($q1);
- $couponValue=$rw['coupon_value'];
- }
-
- //payment details
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- $this->set("couponValue",$couponValue);
- $this->set("saleTax",$saleTax);
-
- $this->set("totalAmount",$totalAmount);
- $this->render("feature_chargecouponcode","ajax");
- }
-
- function getcheckoutcity() {
- $this->checkSession();
- $usrDetail=$this->getUserDetails($_SESSION['UserId']);
- $this->set("UserDtl",$usrDetail);
-
- //$this->set("arg",$this->params['url']);
- $city=$this->getCityList($this->params['url']['orderBy']);
- $this->set("billingCity",$city);
- $this->set("divType",$this->params['url']['s']);
-
- $this->getCartDetails();
-
- //sale tax
- $stateId=0;
- $saleTax=0;
- if(isset($this->params['url']['orderBy']))
- $stateId=$this->params['url']['orderBy'];
-
- if(isset($this->params['pass']['0']))
- $stateId=$this->params['pass']['0'];
-
- $saleTax=$this->getUserCreativeSalesTax($stateId);
- $this->set("saleTax",$saleTax);
- $this->set("stateId",$stateId);
- //Coupon code
- $couponCode=$this->params['pass']['1'];
- $this->set("coupon",$couponCode);
-
- $curDate=date("Y-m-d");
- $couponValue=0;
- $qry="SELECT coupon_value FROM creative_coupon
- WHERE coupon_code='".$couponCode."' AND '$curDate' BETWEEN coupon_from AND coupon_to AND blocked='0'";
- $q1=mysql_query($qry);
- if(mysql_num_rows($q1)>0) {
- $rw=mysql_fetch_assoc($q1);
- $couponValue=$rw['coupon_value'];
- }
-
-
- //payment details
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- $this->set("couponValue",$couponValue);
- $this->set("saleTax",$saleTax);
-
- $this->render("checkoutcitylist","ajax");
-
- }
-
- function getcheckoutstate() {
- $this->checkSession();
- $usrDetail=$this->getUserDetails($_SESSION['UserId']);
- $this->set("UserDtl",$usrDetail);
-
- //$this->set("arg",$this->params['url']);
- $state=$this->getStateList($this->params['url']['orderBy']);
- $this->set("stateBList",$state);
- $this->set("divType",$this->params['url']['c']);
-
- $this->render("checkoutstatelist","ajax");
-
- }
-
- function getUserDetails($user_id=null) {
- if($user_id==null)
- $user_id = $_SESSION['UserId'];
- $coutryList=array();
- $countryList['0']="Select a country";
- $qry = mysql_query("SELECT * FROM countries");
- while($country = mysql_fetch_array($qry)) {
- $countryList[$country['id']]=$country['country_name'];
- }
-
- $qry2=mysql_query("SELECT * FROM user_details WHERE user_id=".$user_id);
- $rowQry=mysql_fetch_assoc($qry2);
- $this->set("UserDtl",$rowQry);
-
- $saleTax=$this->getUserCreativeSalesTax($rowQry['state']);
- $this->set("saleTax",$saleTax);
-
- $countryList=$this->getCountryList();
- $bList=$this->getStateList($rowQry['c_id']);
- $SList=$this->getStateList($rowQry['shipc_id']);
- $billingCity=$this->getCityList($rowQry['state']);
-
- $this->set("billingCity",$billingCity);
- $this->set("stateBList",$bList);
- $this->set("stateSList",$SList);
- $this->set("countryList",$countryList);
-
- return $rowQry;
- }
-
- function getCreativeState($conId) {
- $stateSList=array("0"=>"Select State");
- $qry3 = mysql_query("SELECT * FROM state WHERE c_id='".$conId."'");
- while($state = mysql_fetch_array($qry3)) {
- $stateSList[$state['id']]=$state['Name'];
- }
-
- $this->set("stateBList",$stateSList);
- }
-
- function getstate() {
- $this->getCreativeState($this->params['url']['orderBy']);
- $this->render("creativestate","ajax");
- }
-
- function creative_cart() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - My Cart';
- $this->layout = 'creativehome';
- $this->creativeType();
- $this->getPublicScrap();
- $cartCount=$this->countFavCart();
- if($cartCount<=0) {
- $this->redirect("/creativezones/creative_favorite");
- die();
- }
-
- $tmpImg=0;
- if(isset($_SESSION['buyTemplate']['tmpId']))
- $tmpImg= $this->templateDetail($_SESSION['buyTemplate']['tmpId']);
-
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creative_cart"); //filename should contain the name of the file that should be selected
- $this->set("nextpage","checkout");
-
- //_________________________________________________________________________________________________
-
- $this->set("recenttype","creative_favorite");
-
- $this->getCartDetails();
- $this->getUserDetails();
-
-
- //$this->getUserCreativeSalesTax($_SESSION['UserId']);
-
- ############################################## CART CODE #################################
-
- if(isset($this->params['url']['act']) && $this->params['url']['act']=="update") {
- $cartsql2 ="
- SELECT SUM(CM.price*CM.qty) as totValue
- FROM creative_carts CM,creative_cart_details CD
- WHERE CM.id=CD.creative_cart_id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'";
-
- $rec=mysql_query($cartsql2);
- $resultSet=mysql_fetch_assoc($rec);
- $this->set("totalValue",$resultSet['totValue']);
-
-
- $this->set("arg",$this->params['url']);
- $this->render("mycart2","ajax");
- }
-
- if(isset($this->params['url']['act']) && $this->params['url']['act']=="saveupdate") {
- $cartId=$this->params['url']['cid'];
- $i=$this->params['url']['i'];
- //mysql_query("UPDATE backdrop_cart SET quantity='".$this->data['Backdrop']['qty'.$i]."' WHERE id='".$cartId."'");
- $cartsql2 ="
- SELECT SUM(CM.price*CM.qty) as totValue
- FROM creative_carts CM,creative_cart_details CD
- WHERE CM.id=CD.creative_cart_id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'";
-
- $rec=mysql_query($cartsql2);
- $resultSet=mysql_fetch_assoc($rec);
- $this->set("totalValue",$resultSet['totValue']);
-
- $this->set("qty",$this->data['Creativezone']['qty'.$i]);
- $this->set("arg",$this->params['url']);
- $this->set("argForm",$this->params['form']);
- $this->render("mycart2","ajax");
- }
-
- if(isset($this->params['url']['action']) && $this->params['url']['action']=="deleteCartitem") {
-
- if(isset($this->params['url']['cartid'])) {
- $cartId=base64_decode($this->params['url']['cartid']);
- $delCartItem = "DELETE from creative_carts where id='".$cartId."' AND ssn_id='".session_id()."' AND pay_status='0' AND user_id='".$_SESSION['UserId']."'";
- mysql_query($delCartItem);
- }
- else {
- if(isset($this->params['url']['cartuserid'])) {
- $cartBlockuser=base64_decode($this->params['url']['cartuserid']);
- $delCartItem = "DELETE FROM creative_carts WHERE ssn_id='".session_id()."' AND pay_status='0' AND user_id='".$_SESSION['UserId']."' AND product_name IN (SELECT title FROM creative_favorites WHERE user_id='".$cartBlockuser."' AND is_temp='0' AND is_blocked='0')";
- mysql_query($delCartItem) or die("Error on line - ".__LINE__.mysql_error());
- }
- }
-
- }
-
- if(isset($this->params['url']['action']) && $this->params['url']['action']=="deleteCartitem") {
- $this->render("myupdatedcart","ajax");
- }
-
- ###########################################
- //check if buy template then get payment of user create artist
- if($tmpImg>0) {
- $fav = $this->Creative_favorites->findById($tmpImg);
- $fetchAdminPaymentSetup=$this->getPaymentMethodsUsers($fav['Creative_favorites']['user_id']); // that means payment will go to the user paymenbt id
- $this->set('sellerId',$fav['Creative_favorites']['user_id']);
- }else {
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set('sellerId',1);
- }
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- }
-
- function pcreative_cart() {
- $this->checkSession();
- $this->pageTitle = 'Creative - My Cart';
- $this->layout = 'creativedetail';
- $this->creativeType();
- $this->getPublicScrap();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
-
- $this->countFavCart();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creative_cart"); //filename should contain the name of the file that should be selected
- $_SESSION['bradcamp_creative'][80]=$this->params['action']; //we are passing the name of the file to keep track which step is visited
- $this->set("nextpage","checkout");
-
- //_________________________________________________________________________________________________
-
- $this->set("recenttype","creative_favorite");
-
- $this->getCartDetails();
-
-
- ############################################## CART CODE #################################
- $queryCreativeCarts=mysql_query("
- SELECT CM.id,CM.product_name,CM.price,CM.qty,CD.imagename,(CM.price*CM.qty) as subTotal
- FROM creative_carts CM,creative_cart_details CD
- WHERE CM.id=CD.creative_cart_id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'
- GROUP BY CM.id");
-
-
- if(isset($this->params['url']['act']) && $this->params['url']['act']=="update") {
- $cartsql2 ="
- SELECT SUM(CM.price*CM.qty) as totValue
- FROM creative_carts CM,creative_cart_details CD
- WHERE CM.id=CD.creative_cart_id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'";
-
- $rec=mysql_query($cartsql2);
- $resultSet=mysql_fetch_assoc($rec);
- $this->set("totalValue",$resultSet['totValue']);
-
-
- $this->set("arg",$this->params['url']);
- $this->render("mycart2","ajax");
- }
-
- if(isset($this->params['url']['act']) && $this->params['url']['act']=="saveupdate") {
- $cartId=$this->params['url']['cid'];
- $i=$this->params['url']['i'];
- //mysql_query("UPDATE backdrop_cart SET quantity='".$this->data['Backdrop']['qty'.$i]."' WHERE id='".$cartId."'");
- $cartsql2 ="
- SELECT SUM(CM.price*CM.qty) as totValue
- FROM creative_carts CM,creative_cart_details CD
- WHERE CM.id=CD.creative_cart_id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'";
-
- $rec=mysql_query($cartsql2);
- $resultSet=mysql_fetch_assoc($rec);
- $this->set("totalValue",$resultSet['totValue']);
-
- $this->set("qty",$this->data['Creativezone']['qty'.$i]);
- $this->set("arg",$this->params['url']);
- $this->set("argForm",$this->params['form']);
- $this->render("mycart2","ajax");
- }
-
- if(isset($this->params['url']['action']) && $this->params['url']['action']=="deleteCartitem") {
-
- if(isset($this->params['url']['cartid'])) {
- $cartId=base64_decode($this->params['url']['cartid']);
- $delCartItem = "DELETE from creative_carts where id='".$cartId."' AND ssn_id='".session_id()."' AND pay_status='0' AND user_id='".$_SESSION['UserId']."'";
- mysql_query($delCartItem);
- }
- else {
- if(isset($this->params['url']['cartuserid'])) {
- $cartBlockuser=base64_decode($this->params['url']['cartuserid']);
- $delCartItem = "DELETE FROM creative_carts WHERE ssn_id='".session_id()."' AND pay_status='0' AND user_id='".$_SESSION['UserId']."' AND product_name IN (SELECT title FROM creative_favorites WHERE user_id='".$cartBlockuser."' AND is_temp='0' AND is_blocked='0')";
- mysql_query($delCartItem) or die("Error on line - ".__LINE__.mysql_error());
- }
- }
-
- }
-
- if(isset($_SESSION['UserId'])) {
-
- $cartsql = "
- SELECT CM.id,Cfav.id as favid,CM.product_name,Creativedetail.imagename,
- CM.qty,CM.price ,(CM.price*CM.qty) as subtotal
- from creative_carts CM
- LEFT JOIN creative_cart_details Creativedetail ON CM.id =Creativedetail.creative_cart_id
- LEFT JOIN creative_favorites Cfav ON CM.product_name = Cfav.title
- LEFT JOIN creative_template_pages ctemppage ON Cfav.id=ctemppage.id
- where
- CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'and CM.pay_status='0' ";
-
-
-
- $this->set('mycartsql',$cartsql);
-
-
- $newcartsql ="
- SELECT ifnull( Buser.username, 'NA') AS username,
- Cfav.id , Cfav.user_id,
- COUNT( Cfav.title) as creative_count
- FROM creative_carts Creativecart
- LEFT JOIN creative_favorites Cfav ON Creativecart.product_name = Cfav.title
-
- LEFT JOIN users Buser ON ( Cfav.user_id = Buser.id )
-
- WHERE Creativecart.user_id = '".$_SESSION['UserId']."'
- AND Creativecart.ssn_id = '".session_id()."'
- AND Creativecart.pay_status = '0'
- GROUP BY Cfav.user_id
- ";
-
-
- $this->set('newmycartsql',$newcartsql);
-
- }
-
- if(isset($this->params['url']['action']) && $this->params['url']['action']=="deleteCartitem") {
- $this->render("myupdatedcart","ajax");
- }
-
-
-
- ###########################################
-
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- }
- //checking
- function getCartImages($userId,$tranId,$isThumb=false) {
-
- $downloadimg=array();
- $getYearBookImg=mysql_query("
- SELECT CF.fileZip, CF.fileThumb2
- FROM creative_carts C,creative_cart_details CD, creative_favorites as CF
- WHERE C.id=CD.creative_cart_id AND CF.id=CD.creative_favorite_id AND C.user_id='".$userId."' AND C.pay_status='1' AND transaction_creative_id='".$tranId."'
- ") or die(mysql_error());
-
- while($rwYearbookImg=mysql_fetch_assoc($getYearBookImg)) {
- if($isThumb)
- array_push($downloadimg,$rwYearbookImg['fileThumb2']);
- else
- array_push($downloadimg,$rwYearbookImg['fileZip']);
- }
-
- return $downloadimg;
-
- }
- //checking
- function checkout() {
- $this->checkSession();
- $this->countFavCart();
- $this->layout = 'previewpaymemnt';
- $this->render("paymentback");
- $totalAmount=$this->data['creative']['totalAmount'];
- $sellerId=$this->data['creative']['sellerId'];
- //$rdPage refers to function success
- $rdPage=$this->data['creative']['rdpage'];
-
- $isAdmin=1;
- //If user purchases his own scraps then the payment will go to admin
- //If the user purchases scraps of other users then the payment will go to that other users
- if($sellerId==1) {
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- }
- else {
- $isAdmin=0;
- $fetchAdminPaymentSetup=$this->getPaymentMethodsUsers($sellerId);
- }
-
- //UPDATE USERS ADDRESS
- if(!empty($this->data)) {
- if(isset($this->data['creativezones']['B']) && ($this->data['creativezones']['B'])!="") {
-
- $updateUser="
- UPDATE user_details
- SET
- address='".$this->data['creativezones']['Baddress']."',city='".$this->data['creativezones']['Bcity']."',
- zip='".$this->data['creativezones']['Bzip']."',c_id='".$this->params['form']['creativezonesBcountry']."'
- ,state='".$this->params['form']['creativezonesBstate']."'
- WHERE user_id=".$_SESSION['UserId'];
- mysql_query($updateUser);
- }
- }
-
- $feature = isset($this->data['creativezones']['feature']);
-
- if($feature) {
- //create creative_carts
- mysql_query("DELETE FROM creative_carts WHERE pay_status='0' AND user_id='".$_SESSION['UserId']."'");
- mysql_query("INSERT INTO
- creative_carts(user_id,cart_name,transaction_creative_id,pay_status)
- VALUES('".$_SESSION['UserId']."','Feature fee','0','0')") or die("Error on line : ".__LINE__.mysql_error());
-
- $cart_id=mysql_insert_id();
- $productId = $this->data['creativezones']['lastId'];
-
- $featuredAmount=$this->getConfigAmount('creative featured');
- $price = $featuredAmount['config_value'];
-
- mysql_query("INSERT INTO creative_cart_details SET creative_cart_id='$cart_id' ,creative_favorite_id='$productId', product_name='Feature fee',price='$price',qty='1'");
- }
-
- $transactionfee = isset($this->data['creativezones']['transactionfee']);
- if(!$transactionfee) {
- //insert data to the TRANSACTION_CREATIVES TABLE after successful transaction
- mysql_query("INSERT INTO
- transaction_creatives(user_id,seller_id,total_amount,is_admin)
- VALUES('".$_SESSION['UserId']."','".$sellerId."','".$totalAmount."','".$isAdmin."')") or die("Error on line : ".__LINE__.mysql_error());
-
- $lastTransactionId=mysql_insert_id();
-
- //UPDATE CART
- mysql_query("
- UPDATE creative_carts
- SET
- coupon='".$this->data['creativezones']['couponprice']."',
- saletax='".$this->data['creativezones']['saletax']."',
- transaction_creative_id='".$lastTransactionId."'
- WHERE pay_status='0' AND user_id='".$_SESSION['UserId']."'");
-
- $invoice = $this->createTransactionNumber('SP');
- $ticket = $this->createTransactionNumber('SPTT');
- }else {
- $invoice = $this->data['creativezones']['lastId'];
- }
-
- $zero =str_repeat('0',(5-strlen($_SESSION['UserId'])));
- $userId=$zero.$_SESSION['UserId'];
-
-
-
- if(isset($this->data['Event']['radiobutton'])) {
- if($this->data['Event']['radiobutton']=="paypal") {
- $this->invoice=$invoice;
- $this->amountPay=$totalAmount;
- $this->merchantEmail=$fetchAdminPaymentSetup['paypal_email'];
-
- if($transactionfee) {
- $this->invoice='TF'.$invoice;
- $this->itemName="ScrapFOTO™ Transaction Fee";
- $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/transactionfee_success";
- $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/transactionfee_payment_notify";
- $this->custom=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice;
- }else if($feature) {
- $this->itemName="ScrapFOTO™ Featured";
- $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featured_payment_notify";
- $this->custom=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice."^".$lastTransactionId."^".$ticket."^".$productId;
- }else {
- $this->itemName="ScrapFOTO™ Image download";
- $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/".$rdPage."?tr=".base64_encode($lastTransactionId);//DOMAIN
- $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/checkout_notify";
- $this->custom=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice."^".$lastTransactionId;
- }
-
- $this->paypal();
- }
-
- if($this->data['Event']['radiobutton']=="google") {
-
- $adminPayment=$fetchAdminPaymentSetup['gcheckout_email'];
- $adminPaymentDetails=explode("break",$adminPayment);
- $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
- $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
- $this->Gcheckout->gQuantity=1;
- $this->Gcheckout->gPrice=$totalAmount;
- if($feature) {
- $this->Gcheckout->gItemName="ScrapFOTO™ Featured";
- $this->Gcheckout->gItemDesc="ScrapFOTO™ Featured";
- $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featured_payment_notify";
- $this->Gcheckout->customData=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice."^".$lastTransactionId."^".$totalAmount."^".$ticket."^".$productId;
- }else if($transactionfee) {
- $this->Gcheckout->gItemName="ScrapFOTO™ Transaction Fee";
- $this->Gcheckout->gItemDesc="ScrapFOTO™ Transaction Fee";
- $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/transactionfee_success";
- $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/transactionfee_payment_notify";
- $this->Gcheckout->customData=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice."^".$totalAmount;
- }
- else {
- $this->Gcheckout->gItemName="ScrapFOTO™ Image download";
- $this->Gcheckout->gItemDesc="ScrapFOTO™ Image download";
- $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/".$rdPage."?tr=".base64_encode($lastTransactionId);
- $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/checkout_notify";
- $this->Gcheckout->customData=$_SESSION['UserId']."^".$sellerId."^".$isAdmin."^".$rdPage."^".$invoice."^".$lastTransactionId."^".$totalAmount;
- }
-
- $this->Gcheckout->google();
- }
- }
-
- }
- //checking
- function checkout_notify() {
-
- /*
- $this->Paypal->paypal_class();
- $this->Paypal->paypal_url = $this->paypalUrl;
- $paypal=0;
- //____________________________________________________IPN DATA SECTION______________________________________________
-
- //This section is used to catch from PAYPAL IPN data
- if ($this->Paypal->validate_ipn()) {
- $paypal=1;
- if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="") {
- $totalPay=$this->Paypal->ipn_data['payment_gross'];
- $custom=explode("^",$this->Paypal->ipn_data['custom']);
- $userId=$custom['0'];
- $sellerId=$custom['1'];
- $isAdmin=$custom['2'];
- $rdPage=$custom['3'];
- $ssnId=$custom['4'];
- $transactionId=$custom['5'];
- $invoice=$this->Paypal->ipn_data['invoice'];
-
- }
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
-
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
-
- $userId=$ipnData['0'];
- $sellerId=$ipnData['1'];
- $isAdmin=$ipnData['2'];
- $rdPage=$ipnData['3'];
- $ssnId=$ipnData['4'];
- $transactionId=$ipnData['5'];
- $invoice=$ipnData['6'];
- $totalPay=$ipnData['7'];
- }
- }
-
-
- *
- */
-
- }
- //checking
- function success() {
- $this->checkSession();
- //
- $paypal=0;
- //____________________________________________________IPN DATA SECTION______________________________________________
-
- //This section is used to catch from PAYPAL IPN data
- if (isset($_POST['payment_gross']) && ($_POST['payment_gross'])!="") {
- $paypal=1;
-
- $totalPay=$_POST['payment_gross'];
- $custom=explode("^",$_POST['custom']);
-
- $userId=$custom['0'];
- $sellerId=$custom['1'];
- $isAdmin=$custom['2'];
- $rdPage=$custom['3'];
- $invoice=$custom['4'];
- $transactionId=$custom['5'];
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
-
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
-
- $userId=$ipnData['0'];
- $sellerId=$ipnData['1'];
- $isAdmin=$ipnData['2'];
- $rdPage=$ipnData['3'];
- $invoice=$ipnData['4'];
- $transactionId=$ipnData['5'];
- $totalPay=$ipnData['6'];
- }
- }
-
- //____________________________________________________XOIMAGE DATABASE UPDATION_____________________________________
-
- //UPDATE date on TRANSACTION_CREATIVE TABLE
- $queryUpdateTransactionCreative="
- UPDATE transaction_creatives
- SET pay_status='1',invoice='".$invoice."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'";
- mysql_query($queryUpdateTransactionCreative) or die("Error on line : ".__LINE__.mysql_error());
-
- //UPDATE data to the CREATIVE_CARTS TABLE after successful transaction
- $queryUpdateCreativeCart="
- UPDATE creative_carts
- SET pay_status='1', total_price='".$totalPay."'
- WHERE user_id='".$userId."' AND pay_status='0' AND transaction_creative_id='".$transactionId."' ";
- mysql_query($queryUpdateCreativeCart) or die("Error on line : ".__LINE__.mysql_error());
-
-
-
- //generating the downloadable file
- //Get the list of the downloaded images
- $downloadimg=$this->getCartImages($userId,$transactionId);
- $zipfilename = 'scrapblogimg'.$transactionId.$userId.'.zip';
-
- //UPDATE transaction_creatives with the scrapfoto filename$zipfilename
- mysql_query("
- UPDATE transaction_creatives
- SET scrapfoto_file='".$zipfilename."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'") or die("Error on line - ".__LINE__.mysql_error());
- ;
- $downloadimgs = array();
- $Imgdestination='';
- foreach($downloadimg as $img) {
- $arr = explode('/', $img);
- $downloadimgs[] = $arr[count($arr)-1];
- $Imgdestination = '../'.substr($img, 0, - strlen($arr[count($arr)-1]));
- }
-
- $Imgdestination = realpath($Imgdestination).'/';
- $zipdestination = realpath('../app/webroot/creativezone/downloadscraps/').'/';
- $this->Zipfile->addFiles($downloadimgs,$Imgdestination); //array of files
- $this->Zipfile->output($zipfilename,$zipdestination);
-
- //____________________________________________________TRANSACTION LOG MANAGEMENT_____________________________________
-
- $userDetails=$this->getUserDetails($userId);
- $queryXouserTransactions=mysql_query("SELECT * FROM xouser_transactions WHERE transaction_head='scrapfoto' AND transaction_title='download' AND invoice_id='".$transactionId."'");
- if(mysql_num_rows($queryXouserTransactions)<=0) {
- $transactionDesc="ScrapFOTO - scraps purchase and download";
- $transactionHead="scrapfoto";
- $transactionTitle="download";
- $invoice=$invoice;
- $invoiceId=$transactionId;
-
- $statusoffee="nontransactionfee";
- $lastInsetID=$this->transactionMaster($transactionDesc,$transactionHead,$transactionTitle,$invoice,$invoiceId);
- if(!isset($_SESSION['buyTemplate']))
- $this->transactionDetail($userId,$totalPay,'-1',$lastInsetID,1,$statusoffee,0,'finished'); //charged//this code is changed on 7th January 2010(statusfee added as well as paymentstatus value 'finished' added---finished is not in used now.)
-
-
-
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
-
- //check buy template
- if(isset($_SESSION['buyTemplate'])) {
- //update transaction_fee for transaction_creatives
- $tranfee = $this->getConfigAmount('creative commission');
- $tranfee = $tranfee['config_value']/100*$totalPay;
- mysql_query("
- UPDATE transaction_creatives
- SET transaction_fee='".$tranfee."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'") or die("Error on line - ".__LINE__.mysql_error());
- ;
-
- // “notification of sale” (E7) will be send to User Artist
- $fav = $this->Creative_favorites->findById($_SESSION['buyTemplate']['tmpId']);
-
- $fav['Creative_favorites']['num_sell']++;
- $this->Creative_favorites->save($fav);
-
- //save transaction of seller
- $transactionDesc="ScrapFOTO - scraps template purchase and download";
- $this->transactionDetail($userId,$totalPay,'-1',$lastInsetID,$fav['Creative_favorites']['user_id'],$statusoffee,0,'finished1'); //charged//this code is changed on 7th January 2010(statusfee added as well as paymentstatus value 'finished' added---finished is not in used now.)
- //$this->transactionDetail($fav['Creative_favorites']['user_id'],$totalPay,'+1',$lastInsetID,$userId); //paid
- //send mail seller
- $sellDetails=$this->getUserDetails($fav['Creative_favorites']['user_id']);
- if(isset($sellDetails['email'])) {
-
- $receiver=$fav['Creative_favorites']['user_id'];
-
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($sellDetails['email']);
-
- //$this->Sendmail->Cc($sellDetails['email']);
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - Notification of sales";
- $this->Sendmail->Subject($subject);
-
- $this->set("tranId",$transactionId);
- $this->set("sellerId",$receiver);
- $this->Sendmail->layout='email';
- $this->Sendmail->view= 'mail_notification_sales';
- $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;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- $this->Sendmail->__destruct();
-
- //check creative quantity sold
- $quantitysold = $this->getConfigAmount('creative quantity sold');
- if($quantitysold['config_value']==$fav['Creative_favorites']['num_sell']){
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($sellDetails['email']);
-
- //$this->Sendmail->Cc($sellDetails['email']);
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - Notification of user set price";
- $this->Sendmail->Subject($subject);
-
- $this->set("tranId",$transactionId);
- $this->set("sellerId",$receiver);
- $this->set('num_sell',$fav['Creative_favorites']['num_sell']);
- $this->Sendmail->layout='email';
- $this->Sendmail->view= 'mail_notification_set_price';
- $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;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- $this->Sendmail->__destruct();
- //$this->redirect('creativezones/mail_notification_set_price/'.$transactionId.'/'.$receiver);
- }
-
- }
- }
-
- //mail sent to the user personal account
- if(isset($userDetails['email'])) {
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($userDetails['email']);
-
- //$this->Sendmail->Cc($userDetails['email']);
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - Scrapfoto Invoice ".$invoice;
- $this->Sendmail->Subject($subject);
-
- $this->set("tranId",$transactionId);
- $this->set('amountPaid', $totalPay);
- $this->Sendmail->layout='email';
- $this->Sendmail->view= 'mail_scrapdownload';
- $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->Attach($zipdestination.$zipfilename, "image/jpeg" ) ; // attach a file of type image/gif
- $this->Sendmail->Send(); // send the mail
-
- //mail sent to the user mail account in the system
-
- $sender=1;
- $receiver=$userId;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- $this->Sendmail->__destruct();
- }
- }
-
-
-
- $sql = "SELECT Favorite.id FROM creative_carts as Cart
- LEFT JOIN creative_cart_details CartDetail ON Cart.id = CartDetail.creative_cart_id
- LEFT JOIN creative_favorites Favorite ON Favorite.id = CartDetail.creative_favorite_id
- WHERE Cart.transaction_creative_id='".$transactionId."' ";
-
- $result = mysql_query($sql);
- if(mysql_num_rows($result)>0) {
- while($row=mysql_fetch_array($result)) {
- mysql_query("UPDATE creative_favorites SET is_temp='0' WHERE id='".$row['id']."' ");
- }
- }
-
- if(isset($_SESSION['buyTemplate'])) {
- $_SESSION['buyTemplate']['pay'] = 1;
- }
-
- //
-
- $this->pageTitle = 'ScrapFOTO™ - success';
- $this->layout = 'creativehome';
- $this->creativeType();
- $this->getPublicScrap();
-
-
- $this->countFavCart();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","success");//filename should contain the name of the file that should be selected
- $this->set("nextpage","success");
-
- //_________________________________________________________________________________________________
-
- $userId=$_SESSION['UserId'];
-
-
- $transactionId=base64_decode($this->params['url']['tr']);
- $queryTransactionCreatives=mysql_query("SELECT invoice,scrapfoto_file FROM transaction_creatives WHERE id='".$transactionId."'");
- $fetchTransactionCreatives=mysql_fetch_assoc($queryTransactionCreatives);
-
- $this->set("transactionInv",$fetchTransactionCreatives['invoice']);
- $this->set('scrapbookfilename',$fetchTransactionCreatives['scrapfoto_file']);
-
- $downloadimg=$this->getCartImages($_SESSION['UserId'],$transactionId,true);
- $this->set("downloadImage",$downloadimg);
-
- $this->render('success','creativehome');
- }
-
- function transactionfee_payment_notify() {
-
- }
-
- function transactionfee_success() {
- $this->checkSession();
- //
- $paypal=0;
- //____________________________________________________IPN DATA SECTION______________________________________________
-
- //This section is used to catch from PAYPAL IPN data
- if (isset($_POST['payment_gross']) && ($_POST['payment_gross'])!="") {
- $paypal=1;
-
- $totalPay=$_POST['payment_gross'];
- $custom=explode("^",$_POST['custom']);
-
- $userId=$custom['0'];
- $sellerId=$custom['1'];
- $isAdmin=$custom['2'];
- $rdPage=$custom['3'];
- $invoice=$custom['4'];
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
-
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
-
- $userId=$ipnData['0'];
- $sellerId=$ipnData['1'];
- $isAdmin=$ipnData['2'];
- $rdPage=$ipnData['3'];
- $invoice=$ipnData['4'];
- $totalPay=$ipnData['5'];
- }
- }
- //____________________________________________________XOIMAGE DATABASE UPDATION_____________________________________
-
- $tf = $this->Transaction_creatives->findByInvoice($invoice);
- if($tf) {
- $tf['Transaction_creatives']['is_pay_transaction_fee'] = '1';
- $this->Transaction_creatives->save($tf);
-
- $sql = "SELECT FX .id
- FROM transaction_creatives TC
- RIGHT JOIN creative_carts C ON ( C.transaction_creative_id = TC.id )
- RIGHT JOIN creative_cart_details CDT ON ( CDT.creative_cart_id = C.id )
- RIGHT JOIN creative_favorites F ON ( F.id = CDT.creative_favorite_id )
- RIGHT JOIN creative_favorites FX ON ( FX.ssn_id = F.ssn_id AND FX.is_republished = '1' )
- WHERE TC.invoice = '".$invoice."'
- LIMIT 1 ";
- $result = mysql_query($sql);
- if(mysql_num_rows($result)>0){
- $row = mysql_fetch_assoc($result);
- $sql = "UPDATE creative_favorites SET is_blocked='0' WHERE id='".$row['id']."'";
- mysql_query($sql);
- }
- $this->set('sql',$sql);
-
- //check unblock user
-
- $result = mysql_query("SELECT * FROM creative_favorites WHERE user_id ='".$userId."' and is_blocked='1' LIMIT 1");
- if(mysql_num_rows($result)<=0){
- mysql_query("UPDATE user_payment_setup SET is_blocked='0' WHERE user_id ='".$userId."' ");
- }
-
- }
-
- $userDetails=$this->getUserDetails($userId);
- $queryXouserTransactions=mysql_query("SELECT * FROM xouser_transactions WHERE transaction_head='scrapfoto' AND transaction_title='comission paid' AND invoice='".$invoice."'");
- if(mysql_num_rows($queryXouserTransactions)<=0) {
- $transactionDesc="ScrapFOTO - scraps transaction fee";
- $transactionHead="scrapfoto";
- $transactionTitle="comission paid";
- $invoice=$invoice;
- $invoiceId=0;
-
- $statusoffee="projectfee";
- $lastInsetID=$this->transactionMaster($transactionDesc,$transactionHead,$transactionTitle,$invoice,$invoiceId);
-
- $this->transactionDetail($userId,$totalPay,'+1',$lastInsetID,1,$statusoffee,0,'finished'); //charged//this code is changed on 7th January 2010(statusfee added as well as paymentstatus value 'finished' added---finished is not in used now.)
- //$this->transactionDetail($userId,$totalPay,'+1',$lastInsertId,1); //paid//this code is blocked on 7th January 2010
-
-
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
-
- /*if(isset($userDetails['email'])) {
-
-
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($userDetails['email']);
-
- //$this->Sendmail->Cc($sellDetails['email']);
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages Notification of sales";
- $this->Sendmail->Subject($subject);
-
- $this->set("tranId",$transactionId);
-
- $this->Sendmail->layout='email';
- $this->Sendmail->view= 'mail_notification_sales';
- $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=$userId;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- $this->Sendmail->__destruct();
- }*/
-
- }
-
- $this->pageTitle = 'ScrapFOTO™ - transaction fee success';
- $this->layout = 'creativemysales';
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
-
- $this->set('transactionInv',$invoice);
-
- }
- //test
- function mail_scrapdownload($tranId) {
- $this->layout = 'email';
- $this->set("tranId",$tranId);
- }
- function mail_notification_set_price($tranId,$receiver) {
- $this->layout = 'email';
- $this->set('num_sell',2);
- $this->set("tranId",$tranId);
- $this->set("sellerId",$receiver);
- }
-
- function setpriceproduct($ssn_id){
- $this->checkSession();
- $this->layout = 'creativedetail';
- $this->creativeType();
- $this->countFavCart();
- $this->getRankScrap();
- $this->getFeaturedScrap();
- $this->getPublicScrap();
-
- $this->set('id',$ssn_id);
-
- if($ssn_id!=null) {
- $query = "SELECT * FROM creative_favorites WHERE ssn_id='".$ssn_id."' AND user_id='".$_SESSION['UserId']."' and is_republished='1' LIMIT 1 ";
- $favs = mysql_query($query);
- if($favs && mysql_num_rows($favs)>0){
- $fav = mysql_fetch_array($favs);
- $fav = $this->Creative_favorites->findById($fav['id']);
- if($this->data) {
- $fav['Creative_favorites']['price'] = $this->data['creativezones']['price'];
- $this->Creative_favorites->save($fav);
- }
- $this->set('price',$fav['Creative_favorites']['price']);
- }
- }
- }
-
-
- function downloadscraps() {
- $fileName=$this->params['url']['f'];
- $basePath='../app/webroot/creativezone/downloadscraps/';
- $this->Download->downloadFile($basePath,$fileName);
- }
-
- function getUserLastTransaction($userId) {
- $queryTransactionCreatives=mysql_query("SELECT id FROM transaction_creatives WHERE user_id='".$userId."' ORDER BY id DESC") or die("Error on line - ".__LINE__.mysql_error());
- if(mysql_num_rows($queryTransactionCreatives)>0) {
- $fetchTransactionCreatives=mysql_fetch_assoc($queryTransactionCreatives);
- return $fetchTransactionCreatives;
- }
-
- }
-
- function psuccess() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - success';
- $this->layout = 'creativedetail';
- $this->getPublicScrap();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
-
- $this->countFavCart();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","success"); //filename should contain the name of the file that should be selected
- $_SESSION['bradcamp_creative'][100]=$this->params['action']; //we are passing the name of the file to keep track which step is visited
- $this->set("nextpage","success");
-
- //_________________________________________________________________________________________________
-
-
- $transactionId=0;
- if(isset($this->params['url']['tid']))
- $transactionId= base64_decode($this->params['url']['tid']);
-
- $queryTransactionCreatives=mysql_query("SELECT invoice FROM transaction_creatives WHERE id='".$transactionId."'");
- $fetchTransactionCreatives=mysql_fetch_assoc($queryTransactionCreatives);
-
- $this->set("transactionInv",$fetchTransactionCreatives['invoice']);
-
- $zipfilename = 'scrapblogimg'.$transactionId.$_SESSION['UserId'].'.zip';
- $this->set('scrapbookfilename',$zipfilename);
-
- $downloadimg=$this->getCartImages($_SESSION['UserId'],$transactionId);
- $this->set("downloadImage",$downloadimg);
-
- }
-
- function scrapsbuynow() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Payment';
- $this->layout = 'creativedetail';
- $this->getPublicScrap();
-
- if(isset($this->params['url']['seller'])) {
- $sellerId=base64_decode($this->params['url']['seller']);
-
-
- $cartsql = "
- SELECT CM.id,Cfav.id as favid,CM.product_name,Creativedetail.imagename,
- CM.qty,CM.price ,(CM.price*CM.qty) as subtotal
- from creative_carts CM
- LEFT JOIN creative_cart_details Creativedetail ON CM.id =Creativedetail.creative_cart_id
- LEFT JOIN creative_favorites Cfav ON CM.product_name = Cfav.title
- LEFT JOIN creative_template_pages ctemppage ON Cfav.id=ctemppage.id
- where
- CM.user_id='".$_SESSION['UserId']."' AND CM.ssn_id='".session_id()."'and CM.pay_status='0' ";
-
-
-
- $this->set('mycartsql',$cartsql);
-
- $newcartsql ="
- SELECT ifnull( Buser.username, 'NA') AS username,
- Cfav.id , Cfav.user_id,
- COUNT( Cfav.title) as creative_count
- FROM creative_carts Creativecart
- LEFT JOIN creative_favorites Cfav ON Creativecart.product_name = Cfav.title
-
- LEFT JOIN users Buser ON ( Cfav.user_id = Buser.id )
-
- WHERE Creativecart.user_id = '".$_SESSION['UserId']."'
- AND Creativecart.ssn_id = '".session_id()."'
- AND Creativecart.pay_status = '0' AND Cfav.user_id='".$sellerId."'
- GROUP BY Cfav.user_id
- ";
-
-
- $this->set('newmycartsql',$newcartsql);
- if($sellerId==$_SESSION['UserId']) {
- $this->set("sellerId",1);
- $paymentMethods=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- }
- else {
- $this->set("sellerId",$sellerId);
- $paymentMethods=$this->getPaymentMethodsUsers($sellerId);
- }
-
- $this->set("paymentMethods",$paymentMethods);
- }
-
- }
-
- //checking
- function countFavCart() {
- //get creativeFavCount
- $creativeFavCount=0;
- if(isset($_SESSION['UserId'])) {
- if(isset($_SESSION['buyTemplate']['idNew'])) {
- $favQry = mysql_query("SELECT * FROM creative_favorites WHERE user_id ='".$_SESSION['UserId']."' AND id='".$_SESSION['buyTemplate']['idNew']."'") or die("Error on line :".__LINE__.mysql_error());
- }else {
- $favQry = mysql_query("SELECT * FROM creative_favorites WHERE user_id ='".$_SESSION['UserId']."' AND is_temp='0' AND is_republished='1' ") or die("Error on line :".__LINE__.mysql_error());
- }
- $creativeFavCount = mysql_num_rows($favQry);
- }
- $this->set("creativeFavCount",$creativeFavCount);
-
- //get creativeCart Count
- $creativeCart=0;
- if(isset($_SESSION['UserId'])) {
- $creativeCart = @mysql_num_rows(mysql_query("SELECT * FROM creative_carts as CC, creative_cart_details as CD, creative_favorites as CF WHERE CC.user_id=".$_SESSION['UserId']." AND CC.pay_status='0' AND CC.id=CD.creative_cart_id AND CD.creative_favorite_id=CF.id AND CD.creative_favorite_id>0"));
- }
-
- $this->set("creativeCart",$creativeCart);
- //get config payment
- $result = $this->getConfigAmount('creative price');
- $this->set("creative_price",number_format($result['config_value'],2));
-
- return $creativeCart;
- }
- //ok
- function getCartDetails() {
- $queryCreativeCarts=mysql_query("
- SELECT CM.id,CM.cart_name,(CD.price*CD.qty) as subTotal,CD.product_name,CD.qty,CD.id as cart_detail_id,CF.fileThumb2 as imagename
- FROM creative_carts CM,creative_cart_details CD, creative_favorites as CF
- WHERE CM.id=CD.creative_cart_id AND CD.creative_favorite_id=CF.id AND CM.pay_status='0' AND CM.user_id='".$_SESSION['UserId']."'
- ") or die("Error on line : ".__LINE__.mysql_error());
-
- $this->set("queryCreativeCarts",$queryCreativeCarts);
-
- }
- //ok
- function removefromcart() {
- $cartId =0;
-
- if(isset($this->params['url']['cartid']) && isset($this->params['url']['cartdtid']) && isset($this->params['url']['act']) && $this->params['url']['act']=='del' ) {
- $cartId=base64_decode($this->params['url']['cartid']);
- $cartdtId=base64_decode($this->params['url']['cartdtid']);
- mysql_query("DELETE FROM creative_cart_details WHERE creative_cart_id='".$cartId."' AND id ='".$cartdtId."'");
- $this->set("action",strtoupper($this->params['url']['act']));
- }
-
- $this->set("cartId",$cartId);
-
- if(isset($this->params['url']['act']) && $this->params['url']['act']=='edit') {
- $this->set("action",strtoupper($this->params['url']['act']));
- }
-
- //this is to check whther the delete method is called from CREATIVE_FAVORITE function or CREATIVE_CART
- if(isset($this->params['url']['f']))
- $this->set("f",$this->params['url']['f']);
-
- $this->getCartDetails();
- $this->getUserDetails();
- $this->countFavCart();
-
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
-
- $this->render("cartlist","ajax");
- }
- //checking
- function delfavorite() {
- $this->checkSession();
- if(isset($this->params['url']['fid'])) {
- $favId=base64_decode($this->params['url']['fid']);
-
- $sql = "SELECT * FROM creative_favorites WHERE id='".$favId."' AND user_id='".$_SESSION['UserId']."'";
- $result = mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
- if(mysql_num_rows($result)>0) {
- $sql="UPDATE creative_favorites SET is_temp='1' WHERE id='".$favId."' AND user_id='".$_SESSION['UserId']."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
-
- /*$sql="DELETE FROM creative_favorites_details WHERE creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
-
- $sql="DELETE FROM creative_favorite_comments WHERE creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
-
- $sql="DELETE FROM creative_favorite_lovers WHERE creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
-
- $sql="DELETE FROM creative_favorite_tags WHERE creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
-
- $sql="DELETE FROM creative_favorite_voting WHERE creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
- */
- //note check delete item in cart
- //get cart not pay
- $sql = "SELECT * FROM creative_carts WHERE pay_status='0'";
- $result = mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
- while ($row = mysql_fetch_array($result)) {
- $sql="DELETE FROM creative_cart_details WHERE creative_cart_id='".$row['id']."' AND creative_favorite_id='".$favId."'";
- mysql_query($sql) or die("Error on line : ".__LINE__.mysql_error());
- }
- }
-
- }
- if(isset($_SESSION['buyTemplate']['idNew'])) {
- unset($_SESSION['buyTemplate']);
- $this->redirect("/creativezones/index");
- }else {
- $this->redirect("/creativezones/creative_favorite");
- }
-
- }
- //checking
- function addtocart() {
- $favId=base64_decode($this->data['xoevent']['favoriteId']);
-
- $result=mysql_query(" SELECT *
- FROM creative_favorites
- WHERE id='".$favId."' AND user_id='".$_SESSION['UserId']."'");
- if(mysql_num_rows($result)>0) {
- $fav=mysql_fetch_assoc($result);
- $productId=$fav['id'];
- $cart_name="Scrap";
- $price=$fav['price'];
- $productName=$fav['title'];
-
- if(!isset($_SESSION['buyTemplate']) || !isset($_SESSION['buyTemplate']['tmpId'])){
- $creative_price=$this->getConfigAmount('creative price');
- $price = $creative_price['config_value'];
- }
-
- $result = mysql_query("SELECT * FROM creative_carts WHERE user_id='".$_SESSION['UserId']."' AND pay_status='0' LIMIT 1");
- if(mysql_num_rows($result)>0) {
- $cart = mysql_fetch_assoc($result);
- $cart_id = $cart['id'];
- }else {
- mysql_query("INSERT INTO
- creative_carts(user_id,cart_name,transaction_creative_id,pay_status)
- VALUES('".$_SESSION['UserId']."','".$cart_name."','0','0')") or die("Error on line : ".__LINE__.mysql_error());
-
- $cart_id=mysql_insert_id();
- }
-
-
- $result = mysql_query("SELECT * FROM creative_cart_details WHERE creative_cart_id='".$cart_id."' AND creative_favorite_id='$productId' LIMIT 1");
- if(mysql_num_rows($result)>0) {
- $cartdetail = mysql_fetch_assoc($result);
- mysql_query("UPDATE FROM creative_cart_details SET product_name='".$productName."' price='$price',qty='1' WHERE id='".$cartdetail['id']."' ");
- }else {
- mysql_query("INSERT INTO creative_cart_details SET creative_cart_id='$cart_id' ,creative_favorite_id='$productId', product_name='".$productName."',price='$price',qty='1'");
- }
- }
- $this->getCartDetails();
- $this->countFavCart();
- $this->render("addtocart","ajax");
- }
-
- function photolover($id=null) {
- if(isset($_SESSION['UserId'])&& $id) {
- $checklover = "Select * from creative_favorite_lovers where user_id='".$_SESSION['UserId']."' and creative_favorite_id='".$id."'" ;
- $checklover_res = mysql_query($checklover);
- $checklover_res_num = mysql_num_rows($checklover_res);
- if($checklover_res_num==0) {
- $insertlover = "INSERT INTO creative_favorite_lovers SET user_id='".$_SESSION['UserId']."', creative_favorite_id='".$id."' ";
- $insertlover=mysql_query($insertlover);
- }
-
-
- }
- $checklover = "Select * from creative_favorite_lovers where creative_favorite_id='".$id."'" ;
- $checklover_res = mysql_query($checklover);
- $checklover_res_num = mysql_num_rows($checklover_res);
- $this->set('nooflover', $checklover_res_num);
- $this->set('photoId', $id);
-
- $this->render('photolover', 'ajax');
-
- }
-
- function addtag($photoId=null) {
- /* */
- $this->set('photoImageId',$_REQUEST['hfphotopid']);
- if(isset($_REQUEST['hfphotopid']) && $_REQUEST['hfphotopid']>0 && isset($_SESSION['UserId']) && addslashes($_REQUEST['phototag'])!='Enter Tag') {
- /* INSERT INTO TAGE TABLE */
- $insersql = "INSERT INTO creative_favorite_tags SET user_id='".$_SESSION['UserId']."',creative_favorite_id='".$_REQUEST['hfphotopid']."',tagname='".addslashes($_REQUEST['phototag'])."' ";
- $insersql_res = mysql_query($insersql);
- }
- $this->set('photoImageId', $_REQUEST['hfphotopid']);
- $this->render('taglist', 'ajax');
- }
-
- function Postreview() {
- if(isset($_REQUEST['hfphotoid']) && $_REQUEST['hfphotoid']>0 && isset($_SESSION['UserId'])) {
- /* Getting out the review*/
- $selectRec= "Select * from creative_favorite_comments where user_id='".$_SESSION['UserId']."' and creative_favorite_id='".$_REQUEST['hfphotoid']."'" ;
- $selectRec_res = mysql_query($selectRec);
- if(mysql_num_rows($selectRec_res)==0) {
- $insertIntoreview = "Insert into creative_favorite_comments SET user_id='".$_SESSION['UserId']."',creative_favorite_id='".$_REQUEST['hfphotoid']."',comment_desc='".addslashes($_REQUEST['reviewdesc'])."' ";
- mysql_query($insertIntoreview);
-
- }
- }
- $this->set('photoId', $_REQUEST['hfphotoid']);
- $this->render('reviewlist', 'ajax');
- }
-
- function getCreativeType($scrapId) {
- $queryCreativeType=mysql_query("SELECT * FROM creative_type WHERE id='".$scrapId."'");
- $fetchCreativeType=mysql_fetch_assoc($queryCreativeType);
- return $fetchCreativeType;
- }
-
- function myscrapxing($idDelete=null) {
- $this->checksession();
- $this->layout = 'creativeinner';
- ############################### Page Title & Head ############################
- $this->pageTitle = 'My ScrapFOTO - My Favorite';
- $this->set('pagehead','My Favorite');
-
- if($idDelete!=null) {
- $delquery ="UPDATE creative_favorites SET is_temp='1' where user_id='".$_SESSION['UserId']."' AND id='".base64_decode($idDelete)."' ";
- mysql_query($delquery);
- }
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $select = " Select X.fileThumb2 as template_img,X.price,X.id,X1.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
-
- $from=" FROM creative_favorites X
- RIGHT JOIN creative_favorites X1 ON ( X1.ssn_id = X.ssn_id AND X1.is_republished ='1' )
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X1.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X1.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' ";
- $where.=" AND X.user_id='".$_SESSION['UserId']."' ";
-
- $others=" group by X.id ";
- $others.=" order by X.id desc";
- $PassParameter='';
- $fltr='';
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","myscrapxing");
- $this->set("parameter",$PassParameter);
- $this->set("fltr",$fltr);
-
- $this->set('sql',$select.$from.$where.$others);
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") || $idDelete!=null) {
- $this->render("myscrapxing2","ajax");
- }
-
- /**/
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- //echo $select;echo $from;echo $where;echo $others; echo $CountField;
-
- }
-
- function approve() {
- $this->checkSession();
- $this->layout = 'creativeinner';
-
- $viewSearchType = '';
-
- if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
- $viewSearchType=$_REQUEST['hfsearch'];
-
-
-
- ############################### Page Title & Head ############################
- $this->pageTitle = 'ScrapFOTO™ '.'Approve';
- $this->set('pagehead','Approve');
-
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat
- , X.creation, X.is_stop_sell,Ticket.msg_to_user,X.num_sell,X.is_approved";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_tickets Ticket ON X.id = Ticket.creative_favorites_id
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.user_id='".$_SESSION['UserId']."' AND X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' ";
-
-
- $searchpass='';
- if($viewSearchType=='title' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='') {
- $where.=" AND X.title like '%".$_REQUEST['txtsrch']."%' ";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='prodid') {
- $where.=" AND X.ssn_id like '%".$_REQUEST['txtsrch']."%'";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='daterange') {
- if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
-
- if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
- $urltodate = $_REQUEST['inpdateto'];
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['inpdateto'];
-
- }
-
- $where.=" AND X.creation between '".$eventFromDate."' and '".$eventToDate."' ";
- $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
- }
-
- $this->set('searchpass',$where);
-
-
-
- $others=" group by X.id ";
-
- if($viewSearchType=='title')
- $others .=" order by X.title desc ";
-
- if($viewSearchType=='prodid')
- $others .=" order by X.ssn_id desc ";
-
- if($viewSearchType=='daterange')
- $others .=" order by X.creation desc ";
-
- $PassParameter ='';
- if($viewSearchType!='') {
- $PassParameter="hfsearch=".$viewSearchType.$searchpass;
- }
-
-
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","approve");
- $this->set("parameter",$PassParameter);
-
- $quantityAllowSell = $this->getConfigAmount('creative quantity sold');
- $this->set('quantityAllowSell',$quantityAllowSell['config_value']);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || $viewSearchType!='') {
- $this->render("approve_search","ajax");
- }
-
- /**/
-
-
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- function reject() {
- $this->checkSession();
- $this->layout = 'creativeinner';
-
- $viewSearchType = '';
-
- if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
- $viewSearchType=$_REQUEST['hfsearch'];
-
-
-
- ############################### Page Title & Head ############################
- $this->pageTitle = 'ScrapFOTO™ '.'Reject';
- $this->set('pagehead','Reject');
-
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat
- , X.creation, X.is_stop_sell,Ticket.msg_to_user,X.num_sell,X.is_approved,Ticket.ticket_number";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_tickets Ticket ON X.id = Ticket.creative_favorites_id
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.user_id='".$_SESSION['UserId']."' AND X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='-1' ";
-
-
- $searchpass='';
- if($viewSearchType=='title' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='') {
- $where.=" AND X.title like '%".$_REQUEST['txtsrch']."%' ";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='prodid') {
- $where.=" AND X.ssn_id like '%".$_REQUEST['txtsrch']."%'";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='ticket') {
- $where.=" AND Ticket.ticket_number like '%".$_REQUEST['txtsrch']."%'";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='daterange') {
- if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
-
- if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
- $urltodate = $_REQUEST['inpdateto'];
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['inpdateto'];
-
- }
-
- $where.=" AND X.creation between '".$eventFromDate."' and '".$eventToDate."' ";
- $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
- }
-
- $this->set('searchpass',$where);
-
-
-
- $others=" group by X.id ";
-
- if($viewSearchType=='title')
- $others .=" order by X.title desc ";
-
- if($viewSearchType=='prodid')
- $others .=" order by X.ssn_id desc ";
-
- if($viewSearchType=='daterange')
- $others .=" order by X.creation desc ";
-
- if($viewSearchType=='ticket')
- $others .=" order by Ticket.ticket_number desc ";
-
- $PassParameter ='';
- if($viewSearchType!='') {
- $PassParameter="hfsearch=".$viewSearchType.$searchpass;
- }
-
-
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","reject");
- $this->set("parameter",$PassParameter);
-
- $quantityAllowSell = $this->getConfigAmount('creative quantity sold');
- $this->set('quantityAllowSell',$quantityAllowSell['config_value']);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || $viewSearchType!='') {
- $this->render("approve_search","ajax");
- }
-
- /**/
-
-
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- function submission() {
- $this->checkSession();
- $this->layout = 'creativeinner';
-
- $viewSearchType = '';
-
- if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
- $viewSearchType=$_REQUEST['hfsearch'];
-
-
-
- ############################### Page Title & Head ############################
- $this->pageTitle = 'ScrapFOTO™ '.'Submisson';
- $this->set('pagehead','Submisson');
-
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat
- , X.creation, X.is_stop_sell,Ticket.msg_to_user,X.num_sell,X.is_approved,Ticket.ticket_number";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_tickets Ticket ON X.id = Ticket.creative_favorites_id
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.user_id='".$_SESSION['UserId']."' AND X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='0' ";
-
-
- $searchpass='';
- if($viewSearchType=='title' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='') {
- $where.=" AND X.title like '%".$_REQUEST['txtsrch']."%' ";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='prodid') {
- $where.=" AND X.ssn_id like '%".$_REQUEST['txtsrch']."%'";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='ticket') {
- $where.=" AND Ticket.ticket_number like '%".$_REQUEST['txtsrch']."%'";
- $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
- }
-
- if($viewSearchType=='daterange') {
- if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['inpdatefrom'];
- }
-
- if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
- $urltodate = $_REQUEST['inpdateto'];
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['inpdateto'];
-
- }
-
- $where.=" AND X.creation between '".$eventFromDate."' and '".$eventToDate."' ";
- $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
- }
-
- $this->set('searchpass',$where);
-
-
-
- $others=" group by X.id ";
-
- if($viewSearchType=='title')
- $others .=" order by X.title desc ";
-
- if($viewSearchType=='prodid')
- $others .=" order by X.ssn_id desc ";
-
- if($viewSearchType=='daterange')
- $others .=" order by X.creation desc ";
-
- if($viewSearchType=='ticket')
- $others .=" order by Ticket.ticket_number desc ";
-
- $PassParameter ='';
- if($viewSearchType!='') {
- $PassParameter="hfsearch=".$viewSearchType.$searchpass;
- }
-
-
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","submission");
- $this->set("parameter",$PassParameter);
-
- $quantityAllowSell = $this->getConfigAmount('creative quantity sold');
- $this->set('quantityAllowSell',$quantityAllowSell['config_value']);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || $viewSearchType!='') {
- $this->render("approve_search","ajax");
- }
-
- /**/
-
-
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- function approve_msg($id,$is_cancel=null) {
- $this->set('id',$id);
- $this->set('is_cancel',$is_cancel);
- if($is_cancel==null) {
- $tt = $this->Creative_tickets->findByCreative_favorites_id($id);
- $this->set('msg',$tt['Creative_tickets']['msg_to_user']);
- }
-
- }
- function approve_stop_sell($id,$is_stop_sell) {
- $fav = $this->Creative_favorites->findById($id);
- if($fav) {
- $fav['is_stop_sell'] = $is_stop_sell;
- $this->Creative_favorites->save();
- }
-
- $this->set('id',$id);
- $this->set('is_stop_sell',$is_stop_sell);
-
- $this->render("approve_stop_sell","ajax");
- }
- function approve_feature($id,$is_cancel=null) {
- $this->set('id',$id);
- $this->set('is_cancel',$is_cancel);
- if($is_cancel==null) {
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set('totalAmount',$featuredAmount['config_value']);
-
- $featuredDay=$this->getConfigAmount('creative featured days');
- $this->set('featuredDay',$featuredDay['config_value']);
-
- //payment details
- $sellerId = 1;// that means payment will go to the admin paymenbt id
- $fetchAdminPaymentSetup=$this->getPaymentMethods($sellerId);
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
- $this->set("sellerId",$sellerId);
- }
- }
-
- function approve_set_price($id,$is_cancel=null) {
- $this->set('id',$id);
- $this->set('is_cancel',$is_cancel);
- if($is_cancel==null) {
- if($this->data) {
- $fav = $this->Creative_favorites->findById($id);
- $fav['Creative_favorites']['price'] = $this->data['creativezones']['price'];
- $this->Creative_favorites->save($fav);
- }else {
- $fav = $this->Creative_favorites->findById($id);
- }
- $this->set('price',$fav['Creative_favorites']['price']);
-
- }
- }
-
- function mysales() {
- $this->checkSession();
- $this->layout = 'creativemysales';
-
- $viewSearchType = '';
-
- if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
- $viewSearchType=$_REQUEST['hfsearch'];
-
-
-
- ############################### Page Title & Head ############################
- $this->pageTitle = 'ScrapFOTO™ '.'My Sales';
- $this->set('pagehead','My Sales');
-
-
-
- /* Pagination and PHOTO listing */
- $select = "SELECT X.id, X.ssn_id, X.title, X.creative_type_id, X.width, X.height, X.fileThumb2, X.viewed,X1.user_id AS buyer_id, X1.id AS creative_favorite_buyer, DT.creative_cart_id, TC.total_amount, TC.invoice, TC.trandate,
- TC.transaction_fee,TC.is_pay_transaction_fee
- ";
-
- $from=" FROM creative_favorites X
- RIGHT JOIN creative_favorites X1 ON ( X.ssn_id = X1.ssn_id AND X1.is_republished = '0')
- RIGHT JOIN creative_cart_details DT ON ( X1.id = DT.creative_favorite_id )
- RIGHT JOIN creative_carts C ON ( C.id = DT.creative_cart_id AND C.pay_status = '1' )
- RIGHT JOIN transaction_creatives TC ON ( C.transaction_creative_id = TC.id AND TC.pay_status='1' )
- ";
-
- $where=" WHERE X.user_id='".$_SESSION['UserId']."' AND X.is_temp='0' AND X.type='0' AND X.is_republished = '1' ";
-
-
-
- $searchpass='';
- if($viewSearchType=='within' && (isset($_REQUEST['within']) && $_REQUEST['within']!='' ) ) {
- $withinType=$_REQUEST['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($withinType=="past") {
- $curDate=$date;
- }
-
- if($withinType=="week") {
- $past=$week;
- $curDate=$date;
- }
-
- if($withinType=="month") {
- $past=$month;
- $curDate=$date;
- }
-
- if($withinType=="year") {
- $past=$year;
- $curDate=$date;
- }
-
- if($withinType=="past")
- $where.=" AND TC.trandate<'".$curDate."'";
- else
- $where.=" AND TC.trandate BETWEEN '".$past."' AND '".$curDate."'";
-
- $searchpass = "&within=".$withinType ;
- }
-
- if($viewSearchType=='daterange') {
- if(isset($_REQUEST['sdatefrom']) && $_REQUEST['sdatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['sdatefrom']));
- $urlfromdate = $_REQUEST['sdatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['sdatefrom'];
- }
-
- if(isset($_REQUEST['sdateto']) && $_REQUEST['sdateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['sdateto']));
- $urltodate = $_REQUEST['sdateto'].' 23:59:59';
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['sdateto'].' 23:59:59';
- }
-
- $where.=" AND TC.trandate BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass = "&sdatefrom=".$urlfromdate."&sdateto=".$urltodate ;
- }
-
- if($viewSearchType=='advance') {
- if(isset($_REQUEST['prodid']) && $_REQUEST['prodid']!='') {
- $where.=" AND X.ssn_id like '%".$_REQUEST['prodid']."%' ";
- $searchpass .= "&prodid=".$_REQUEST['prodid'] ;
- }
- if(isset($_REQUEST['invoice']) && $_REQUEST['invoice']!='') {
- $where.=" AND TC.invoice like '%".$_REQUEST['invoice']."%' ";
- $searchpass .= "&invoice=".$_REQUEST['invoice'] ;
- }
-
- if(isset($_REQUEST['adatefrom']) && $_REQUEST['adatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['adatefrom']));
- $urlfromdate = $_REQUEST['adatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['adatefrom'];
- }
-
- if(isset($_REQUEST['adateto']) && $_REQUEST['adateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['adateto']));
- $urltodate = $_REQUEST['adateto'].' 23:59:59';
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['adateto'].' 23:59:59';
- }
-
- if(isset($_REQUEST['adatefrom']) && isset($_REQUEST['adateto']) && $_REQUEST['adatefrom']!='mm/dd/YY' && $_REQUEST['adateto']!='mm/dd/YY'){
- $where.=" AND TC.trandate BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass .= "&adatefrom=".$urlfromdate."&adateto=".$urltodate ;
- }
-
-
- }
-
- $this->set('searchpass',$where);
-
- //calculator total sell
- $sqltotal= 'SELECT SUM(TC.total_amount) as total_sell '.$from.$where.'';
- $result = mysql_query($sqltotal);
- $row = mysql_fetch_array($result);
- $this->set('total_sell',$row['total_sell']);
-
- $others=" order by TC.trandate desc ";
-
- $PassParameter ='';
- if($viewSearchType!='') {
- $PassParameter="hfsearch=".$viewSearchType.$searchpass;
- }
-
-
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","mysales");
- $this->set("parameter",$PassParameter);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || $viewSearchType!='') {
- $this->render("mysales_search","ajax");
- }
-
- /**/
-
-
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- function mysales_transaction_fee($invoice,$is_cancel=null) {
- $this->set('id',$invoice);
- $this->set('is_cancel',$is_cancel);
- if($is_cancel==null) {
- $tc = $this->Transaction_creatives->findByInvoice($invoice);
- $this->set('totalAmount',$tc['Transaction_creatives']['transaction_fee']);
-
- //payment details
- $sellerId = 1;// that means payment will go to the admin paymenbt id
- $fetchAdminPaymentSetup=$this->getPaymentMethods($sellerId);
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
- $this->set("sellerId",$sellerId);
- }
- }
-
- function mysales_product_detail($invoice,$ssn_id,$is_cancel=null) {
- $this->set('id',$invoice);
- $this->set('is_cancel',$is_cancel);
- $this->set('ssn_id',$ssn_id);
- if($is_cancel==null) {
- $fav = $this->Creative_favorites->findBySsn_id($ssn_id);
- $this->set('fav',$fav['Creative_favorites']);
- }
- }
-
- 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=4; /* 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 $others");
-
- $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
- $this->set("query",$SelectRecord);
-
- }
-
- function sales() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ '.'Order History';
- $this->layout = 'creativemysales';
- $this->set('pagehead','Order History');
-
- $this->creativeType();
- $this->getRankScrap();
- $this->getFeaturedScrap();
- $this->getPublicScrap();
- $this->countFavCart();
-
- $viewSearchType = '';
-
- if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
- $viewSearchType=$_REQUEST['hfsearch'];
-
- $select="SELECT TC. * ,TC.id tranId, C. * , GROUP_CONCAT( DISTINCT CONCAT_WS( '-', C.cart_name) ) AS scrapName";
- $from=" FROM transaction_creatives TC
- LEFT JOIN creative_carts C ON ( C.transaction_creative_id = TC.id )";
-
- $where=" WHERE TC.user_id = '".$_SESSION['UserId']."' AND TC.pay_status='1' ";
-
- $searchpass='';
- if($viewSearchType=='within' && (isset($_REQUEST['within']) && $_REQUEST['within']!='' ) ) {
- $withinType=$_REQUEST['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($withinType=="past") {
- $curDate=$date;
- }
-
- if($withinType=="week") {
- $past=$week;
- $curDate=$date;
- }
-
- if($withinType=="month") {
- $past=$month;
- $curDate=$date;
- }
-
- if($withinType=="year") {
- $past=$year;
- $curDate=$date;
- }
-
- if($withinType=="past")
- $where.=" AND TC.trandate<'".$curDate."'";
- else
- $where.=" AND TC.trandate BETWEEN '".$past."' AND '".$curDate."'";
-
- $searchpass = "&within=".$withinType ;
- }
-
- if($viewSearchType=='daterange') {
- if(isset($_REQUEST['sdatefrom']) && $_REQUEST['sdatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['sdatefrom']));
- $urlfromdate = $_REQUEST['sdatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['sdatefrom'];
- }
-
- if(isset($_REQUEST['sdateto']) && $_REQUEST['sdateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['sdateto']));
- $urltodate = $_REQUEST['sdateto'].' 23:59:59';
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['sdateto'].' 23:59:59';
- }
-
- $where.=" AND TC.trandate BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass = "&sdatefrom=".$urlfromdate."&sdateto=".$urltodate ;
- }
-
- if($viewSearchType=='advance') {
- if(isset($_REQUEST['cartname']) && $_REQUEST['cartname']!='') {
- $where.=" AND C.cart_name like '%".$_REQUEST['cartname']."%' ";
- $searchpass .= "&cartname=".$_REQUEST['cartname'] ;
- }
- if(isset($_REQUEST['invoice']) && $_REQUEST['invoice']!='') {
- $where.=" AND TC.invoice like '%".$_REQUEST['invoice']."%' ";
- $searchpass .= "&invoice=".$_REQUEST['invoice'] ;
- }
-
- if(isset($_REQUEST['adatefrom']) && $_REQUEST['adatefrom']!='mm/dd/YY') {
- $eventFromDate=date("Y-m-d",strtotime($_REQUEST['adatefrom']));
- $urlfromdate = $_REQUEST['adatefrom'];
- }
- else {
- $eventFromDate=date("Y-m-d");
- $urlfromdate = $_REQUEST['adatefrom'];
- }
-
- if(isset($_REQUEST['adateto']) && $_REQUEST['adateto']!='mm/dd/YY') {
- $eventToDate=date("Y-m-d",strtotime($_REQUEST['adateto']));
- $urltodate = $_REQUEST['adateto'].' 23:59:59';
- }
- else {
- $eventToDate=date("Y-m-d");
- $urltodate = $_REQUEST['adateto'].' 23:59:59';
- }
-
- if(isset($_REQUEST['adatefrom']) && isset($_REQUEST['adateto']) && $_REQUEST['adatefrom']!='mm/dd/YY' && $_REQUEST['adateto']!='mm/dd/YY'){
- $where.=" AND TC.trandate BETWEEN '".$eventFromDate."' AND '".$eventToDate."' ";
- $searchpass .= "&adatefrom=".$urlfromdate."&adateto=".$urltodate ;
- }
- }
-
- $this->set('searchpass',$where);
- //calculator total sell
- $sqltotal= 'SELECT SUM(TC.total_amount) as total_sell '.$from.$where.'';
- $result = mysql_query($sqltotal);
- $row = mysql_fetch_array($result);
- $this->set('total_sell',$row['total_sell']);
-
- $others=" GROUP BY TC.id ORDER BY TC.id DESC";
-
- $PassParameter ='';
- if($viewSearchType!='') {
- $PassParameter="hfsearch=".$viewSearchType.$searchpass;
- }
-
-
- $CountField="tranId";
- $this->set("controller","creativezones");
- $this->set("action","sales");
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
-
- if(isset($this->params['url']['Page']) || $viewSearchType!='') {
- $this->render("sales2","ajax");
- }
-
- }
-
- function getTransactionDetails($transactionId=null) /// Invoice detail
- {
- ##################################################### INVOICE DETAILAS ######################
-
- $ticketqry = "
- SELECT tranTic.id, tranTic.invoice , tranTic.total_amount , DATE(tranTic.cudate) as saledate , CONCAT(BUYusrdetail.first_name ,' ',BUYusrdetail.last_name) as Buyername ,
- BUYusrdetail.address as Buyeraddress ,IFNULL(BUYCITYName.city_name,'--') as Buyercity , IFNULL(BUYstate.Name,'--') as Buyerstatename , BUYcountry.country_name as BUYercountryname , BUYusrdetail.zip as Buyerzip ,
-
- POSTBYusrdetail.comp_name as PostCompanyname , CONCAT(POSTBYusrdetail.first_name ,' ',POSTBYusrdetail.last_name) as Postname ,POSTBYusrdetail.email as Postemail,IF(POSTBYusrdetail.land_phone <>'',POSTBYusrdetail.land_phone,'--') as Postphonenumber,
- POSTBYusrdetail.address as Postaddress ,IFNULL(POSTCITYMaster.city_name,'--') as Postcity , IFNULL(POSTstate.Name,'--') as Poststatename , POSTcountry.country_name as Postcountryname , POSTBYusrdetail.zip as Postzip ,
-
- Tic.plan_name as Eventname , tranTic.total_amount as Totalamount , MEMPLAN.picture as logoimage , SUM(MEMPLANCART.plan_price*MEMPLANCART.quantity) as TicketTotal
-
-
- FROM transaction_memberships tranTic
-
- LEFT JOIN membership_plantype_cart MEMPLANCART ON MEMPLANCART.transaction_membership_id = tranTic.id
-
- LEFT JOIN membership_plantype MEMPLAN ON (MEMPLANCART.plantype_id = MEMPLAN.plantype_id AND MEMPLANCART.membership_id = MEMPLAN.membership_id)
-
- LEFT JOIN user_details BUYusrdetail ON MEMPLANCART.user_id = BUYusrdetail.user_id
-
- LEFT JOIN state BUYstate ON BUYstate.id = BUYusrdetail.state
- LEFT JOIN city_master BUYCITYName ON BUYCITYName.city_id = BUYusrdetail.city
- LEFT JOIN countries BUYcountry ON BUYcountry.id=BUYusrdetail.c_id
-
- LEFT JOIN memberships Tic On MEMPLANCART.membership_id=Tic.id
-
- LEFT JOIN user_details POSTBYusrdetail ON tranTic.org_id = POSTBYusrdetail.user_id
- LEFT JOIN state POSTstate ON POSTstate.id = POSTBYusrdetail.state
- LEFT JOIN city_master POSTCITYMaster ON POSTCITYMaster.city_id = POSTBYusrdetail.city
- LEFT JOIN countries POSTcountry ON POSTcountry.id=POSTBYusrdetail.c_id
-
- WHERE tranTic.id='".$tranId."' and MEMPLANCART.pay_status='1' AND MEMPLANCART.user_id='".$_SESSION['UserId']."'
- AND MEMPLANCART.ssn_id='".session_id()."'
-
- GROUP BY MEMPLANCART.transaction_membership_id
- ORDER BY MEMPLANCART.id ASC
- ";
-
- //echo $ticketqry ;
- $qry=mysql_query($ticketqry) or die("Error on line :".__LINE__.mysql_error());
- $this->set("q1",$qry);
-
-
-
-
- ##################################################### INVOICE DETAILAS ######################
-
- }
-
- function creative_invoice_detail(){
- $this->layout = "blank";
- $this->set("tranId",base64_decode($this->params['url']['inv']));
- }
-
- function printscrap(){
- $this->layout = "blank";
- }
-
- function sendinvoice() {
- $this->set("urlVars",$this->params['url']);
-
- $userDetails=$this->getUserDetails($_SESSION['UserId']);
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
- //mail sent to the user personal account
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
-
- if(isset($userDetails['email'])){
- $this->Sendmail->To($userDetails['email']);
-
- //$this->Sendmail->Cc("sujoy@navsoft.in");
- //$this->Sendmail->Cc("amarjit@navsoft.in");
- //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
-
- $subject="XOimages - Scrapfoto invoice request";
- $this->Sendmail->Subject($subject);
-
- $this->set("tranId",base64_decode($this->params['url']['inv']));
- $this->Sendmail->layout='email';
- $this->Sendmail->view='mail_invoicerequest';
- $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=$_SESSION['UserId'];
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
- }
- $this->render("invoicesent","ajax");
- }
-
-
-
- function createTransactionNumber($pre) {
- global $db;
- $id = $pre;
- $id .= $this->genRandomStringNumbers(10);
-
- // check id if exist in db, if not, add
- if($pre=='SPTT') {
- $query ="SELECT id FROM creative_tickets WHERE ticket_number ='".$id."' LIMIT 1";
- }else {
- $query ="SELECT id FROM xouser_transactions WHERE invoice ='".$id."' LIMIT 1";
- }
-
- $result = mysql_query($query);
-
- if(mysql_numrows($result) < 1) {
- return $id;
- } else {
- return $this->createTransactionNumber($pre);
- }
- return $this->createTransactionNumber($pre);
- }
- function genRandomStringNumbers($length) {
- $characters = 'ABCEFGHIJKLMNOPQRTUVWXYZ1234567890';
- $string = '';
- for ($c = 0; $c < $length; $c++) {
- $string .= substr($characters, mt_rand(0, strlen($characters)-1), 1);
- }
- return $string;
- }
- function run_cron_job(){
- if (!defined('CRON_DISPATCHER')) {
- exit();
- }else{
- //check Feature
- $query = "UPDATE creative_favorites SET is_featured='0' WHERE is_featured='1' AND featured_time<'".date('Y-m-d G:i:s')."'";
- mysql_query($query);
-
- //check transaction fee
-
- $day1 = $this->getConfigAmount('creative settlement time1');
- $day1 = $day1['config_value'];
-
- $day2 = $this->getConfigAmount('creative settlement time2');
- $day2 = $day2['config_value'];
-
- if($day1>$day2){
- $tmp = $day1;
- $day1 = $day2;
- $day2 = $tmp;
- }
-
- $cur_day = date('Y-m-d G:i:s');
- $today = getdate();
- $day_c = $today['mday'];
-
- $emailtime = $this->getConfigAmount('creative reactivation time');
- $emailtime = $emailtime['config_value'];
- $numday_month = date('t')+0;
-
- $is_send_mail = ($today['mday']%((int)$numday_month/$emailtime)) == 0 ;
-
- $this->set('is_send_mail',$is_send_mail);
-
-
-
- $time1 = $today['year'].'-'.$today['mon'].'-'.$day1.' '.$today['hours'].':'.$today['minutes'].':'.$today['seconds'];
- $time2 = $today['year'].'-'.$today['mon'].'-'.$day2.' '.$today['hours'].':'.$today['minutes'].':'.$today['seconds'];
- $compare_date = ($day_c<$day2) ? $time1 : $time2;
-
- $sql = "SELECT TC.*,FX.ssn_id, FX.is_blocked FROM transaction_creatives TC
- 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)
- RIGHT JOIN creative_favorites FX ON (F.ssn_id = FX.ssn_id and FX.is_republished='1')
-
- WHERE TC.transaction_fee>0 AND TC.is_pay_transaction_fee='0'";
- $result = mysql_query($sql);
-
- $arr = array();
-
- while($row=mysql_fetch_assoc($result)){
- $trandate = $row['trandate'];
- $tmpdate = new DateTime($trandate);
- if($tmpdate->format('d')>$day2){
- $tmpdate->modify('+1 month');
- $pay_date = $tmpdate->format('Y').'-'.$tmpdate->format('m').'-'.$day1.' '.$tmpdate->format('G').':'.$tmpdate->format('i').':'.$tmpdate->format('s');
- }else{
- $pay_date = $tmpdate->format('Y').'-'.$tmpdate->format('m').'-'.$day2.' '.$tmpdate->format('G').':'.$tmpdate->format('i').':'.$tmpdate->format('s');
- }
-
- $due_day = (strtotime($trandate)<strtotime($compare_date)) ? (int)((strtotime($cur_day)-strtotime($pay_date))/(24*60*60)) : 0;
- if($due_day>0){
- if(isset($arr[$row['seller_id']]))
- $arr[$row['seller_id']]['due_amount'] += $row['transaction_fee'];
- else{
- $arr[$row['seller_id']]['due_amount'] = $row['transaction_fee'];
- $arr[$row['seller_id']]['due_day'] = $due_day;
- $arr[$row['seller_id']]['ids'] = array();
- }
- $arr[$row['seller_id']]['ids'][$row['ssn_id']]=$row['ssn_id'];
-
- if($due_day>$arr[$row['seller_id']]['due_day'])
- $arr[$row['seller_id']]['due_day'] = $due_day;
- }
- }
-
- $blockId = array();
- foreach($arr as $key=>$value){
- $blockId = array_merge($blockId, $value['ids']);
- //check sendmail
- if($is_send_mail)
- $this->mail_reactivation($key,$value['due_amount'],$value['due_day']);
-
- $sql = "UPDATE user_payment_setup SET is_blocked='1' WHERE user_id='$key' ";
- mysql_query($sql);
- }
-
- if(count($blockId)>0){
- $sql = "UPDATE creative_favorites SET is_blocked='1' WHERE ssn_id IN ('".join("', '", $blockId)."') AND is_republished='1' ";
- mysql_query($sql);
- }
- }
- }
-
- function mail_reactivation($user_id,$due_amount,$due_day){
- $userDetails=$this->getUserDetails($user_id);
- //____________________________________________________MAIL MANAGEMENT________________________________________________
- //this mailing code is here so that it fires just once.
-
- //mail sent to the user personal account
- if(isset($userDetails['email'])){
- $this->Sendmail->Mail();
- $this->Sendmail->From(FROMMAIL);
- $this->Sendmail->To($userDetails['email']);
-
- $subject="XOimages Reactivation Notification";
- $this->Sendmail->Subject($subject);
-
- $this->set('user_id',$user_id);
- $this->set('due_amount',$due_amount);
- $this->set('due_day',$due_day);
-
- $this->Sendmail->layout='email';
- $this->Sendmail->view='mail_reactivation';
- $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=$user_id;
- $this->senderMail($sender,$receiver,$subject,$messageBody);
- $this->receiverMail($receiver,$sender,$subject,$messageBody);
-
- $this->Sendmail->__destruct();
- }
- }
-
- }
- ?>