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

/app/controllers/creativezones_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 3440 lines | 2286 code | 611 blank | 543 comment | 357 complexity | 7bc5db9c1b1ac3373b45675c96c20fc1 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0

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

  1. <?
  2. class CreativezonesController extends AppController {
  3. var $name='Creativezones';
  4. var $helpers = array('Html','javascript','error','Ajax','Friendsurl','Common');
  5. var $uses=array('Creativezone','User','Creative_favorites','Creative_favorite_tags','Creative_tickets','Transaction_creatives');
  6. var $components = array('Newdir','Thumbnail','Thumbnailc','Zipfile','Download','Cartmail','Creative','Sendmail');
  7. //ok
  8. function index() {
  9. //$this->checkSession();
  10. $this->pageTitle = 'ScrapFOTO&trade; Home';
  11. //$this->layout = 'creativehome';
  12. $this->layout = 'creativedetail';
  13. $this->homepageslideInfo('ScrapFOTO');
  14. //Initializing all the bradcamp back again so that it all starts all over again
  15. unset($_SESSION['bradcamp_creative']);
  16. $this->set("filename","index"); //filename should contain the name of the file that should be selected
  17. //_________________________________________________________________________________________________
  18. unset($_SESSION['buyTemplate']);
  19. //check creative_carts
  20. if(isset($_SESSION['UserId'])) {
  21. $sql = "SELECT Cart.id FROM creative_carts as Cart
  22. LEFT JOIN creative_cart_details CartDetail ON Cart.id = CartDetail.creative_cart_id
  23. LEFT JOIN creative_favorites Favorite ON Favorite.id = CartDetail.creative_favorite_id
  24. WHERE Cart.user_id ='".$_SESSION['UserId']."' AND Cart.pay_status='0' AND Favorite.is_republished ='0' AND Favorite.is_temp='1' ";
  25. $result = mysql_query($sql) or die(mysql_error());
  26. if(mysql_num_rows($result)>0) {
  27. //delete cart
  28. while($row=mysql_fetch_array($result)) {
  29. mysql_query("DELETE FROM creative_carts WHERE id='".$row['id']."' ") or die(mysql_error());
  30. }
  31. }
  32. //check delete favorite
  33. //mysql_query("DELETE FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_republished ='0' AND is_temp='1' ") or die(mysql_error());
  34. }
  35. $this->creativeType();
  36. $this->countFavCart();
  37. $this->getRankScrap();
  38. $this->getFeaturedScrap();
  39. $this->getPublicScrap();
  40. $this->render('index');
  41. }
  42. //ok ajax call get scrap in tab "Featured","Hight Rated","Recent"
  43. function featuredscrap($catlisttype=null) {
  44. $this->layout = 'profile_blank';
  45. ///////////////////////////////////////////////////// SQL FOR FEATURED SCRAP
  46. /* Pagination and PHOTO listing */
  47. $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";
  48. $from=" FROM creative_favorites X
  49. LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
  50. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  51. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  52. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  53. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  54. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  55. $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' ";
  56. if($catlisttype=='featured') {
  57. $where.=" AND X.is_featured='1' ";
  58. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=featured';
  59. }
  60. $others=" group by X.id ";
  61. if($catlisttype=='mostvoted') {
  62. $others .=" order by photorat desc ";
  63. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=mostvoted';
  64. }
  65. if(!$catlisttype) {
  66. $others.=" order by X.id desc";
  67. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=recent';
  68. }
  69. $tabsql = $select.$from.$where. $others . ' LIMIT 12';
  70. $tabsql_res = mysql_query($tabsql);
  71. $this->set('query',$tabsql_res) ;
  72. $this->set('tabsql',$tabsql) ;
  73. $this->set('morelink',$morelink);
  74. }
  75. //ok scrap listing
  76. function scrapxonglisting() {
  77. $this->layout = 'creativeinner';
  78. $catlisttype = '';
  79. if(isset($_REQUEST['listtype']) && $_REQUEST['listtype']!='')
  80. $catlisttype = $_REQUEST['listtype'];
  81. //this section is used to check whether to show the list based on the category given in the header section
  82. $scrapType=0;
  83. if(isset($this->params['url']['cat'])) {
  84. $scrapType=base64_decode($this->params['url']['cat']);
  85. $this->set("selTab",$scrapType);
  86. }
  87. ############################### Page Title & Head ############################
  88. $pageheadArr = array();
  89. $pageheadArr['featured'] = 'Featured';
  90. $pageheadArr['recent'] = 'Recent';
  91. $pageheadArr['mostvoted'] = 'Most Voted';
  92. $pageheadArr['mostcomment'] = 'Most Discussed';
  93. $pageheadArr['random'] = 'Random';
  94. $pageheadArr['favorite'] = 'Most Favorited ';
  95. $pageheadArr['tag'] = 'Tagged ';
  96. $pageheadArr['search'] = 'Search Result';
  97. $pageheadArr['mostviewed'] = 'Most Viewed';
  98. $pageheadArr['albumview'] = 'Album';
  99. $pageheadArr['seller'] = 'Seller';
  100. $pageheadArr['popular'] = 'Popular';
  101. if (array_key_exists($catlisttype, $pageheadArr)) {
  102. if($catlisttype=='albumview') {
  103. /* Album Name*/
  104. $albumNameSql = "Select IFNULL(creative_name,'') as albumName from creative_type where id='".base64_decode($_REQUEST['albumid'])."'";
  105. $albumNameSql_res = mysql_fetch_array(mysql_query($albumNameSql));
  106. $albumName = stripslashes($albumNameSql_res['albumName']) ;
  107. /**/
  108. $this->pageTitle = $pageheadArr[$catlisttype]. $albumName.' ScrapFOTO&trade;';
  109. $this->set('pagehead',$pageheadArr[$catlisttype].' : '. $albumName. ' ScrapFOTO&trade;');
  110. }
  111. else {
  112. if($catlisttype=='tag') {
  113. $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO&trade; : '. $_REQUEST['sortby'];
  114. $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO&trade; : '.$_REQUEST['sortby']);
  115. }
  116. else {
  117. if($catlisttype=='seller') {
  118. /* SELLER INFO */
  119. $sellinfo = " SELECT username from users where id='".base64_decode($_REQUEST['resaleby'])."'";
  120. $sellinfo_res = mysql_query($sellinfo);
  121. $sellinfo_arr = mysql_fetch_array($sellinfo_res);
  122. $this->pageTitle = 'ScrapFOTO&trade; '.$pageheadArr[$catlisttype] .' : '.$sellinfo_arr['username'];
  123. $this->set('pagehead','ScrapFOTO&trade; '.$pageheadArr[$catlisttype].' : '.$sellinfo_arr['username']);
  124. }
  125. else {
  126. $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO&trade;';
  127. $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO&trade;');
  128. }
  129. }
  130. }
  131. }
  132. else {
  133. if($catlisttype=='category') {
  134. $scrapDetail=$this->getCreativeType($scrapType);
  135. $this->pageTitle = $scrapDetail['creative_name'];
  136. $this->set('pagehead',$scrapDetail['creative_name']);
  137. }
  138. else {
  139. $this->pageTitle = 'ScrapFOTO&trade;';
  140. $this->set('pagehead','ScrapFOTO&trade;');
  141. }
  142. }
  143. ############################### Page Title & Head ############################
  144. /* Pagination and PHOTO listing */
  145. $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";
  146. $from=" FROM creative_favorites X
  147. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  148. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  149. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  150. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  151. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  152. $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'";
  153. if($catlisttype=='featured')
  154. $where.=" AND X.is_featured='1' ";
  155. if( $catlisttype=='albumview' && isset($_REQUEST['albumid']) && base64_decode($_REQUEST['albumid'])>0)
  156. $where.=" AND XCreativetype.id='".base64_decode($_REQUEST['albumid'])."' ";
  157. if($catlisttype=='tag')
  158. $where.=" AND X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['sortby']."%')";
  159. if($catlisttype=='search')
  160. $where.=" AND X.title LIKE '%".$_REQUEST['srchtxt']."%' OR X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['srchtxt']."%') ";
  161. if($catlisttype=='seller')
  162. $where.=" AND X.user_id='".base64_decode($_REQUEST['resaleby'])."' ";
  163. if($catlisttype=='category')
  164. $where.=" AND XCreativetype.id='".$scrapType."' ";
  165. $others=" group by X.id ";
  166. if($catlisttype=='mostvoted')
  167. $others .=" order by photorat desc ";
  168. if($catlisttype=='mostcomment')
  169. $others .=" order by photoreview desc ";
  170. if($catlisttype=='mostviewed')
  171. $others .=" order by X.viewed desc ";
  172. if($catlisttype=='random')
  173. $others .=" order by X.id desc , rand()";
  174. if($catlisttype=='favorite')
  175. $others .=" order by photofavored desc ";
  176. if($catlisttype=='')
  177. $others.=" order by X.id desc";
  178. if(isset($_REQUEST['sortby']) && $_REQUEST['sortby']!='')
  179. $PassParameter="listtype=".$catlisttype."&sortby=".$_REQUEST['sortby'];
  180. else {
  181. if(isset($catlisttype) && $catlisttype=='albumview')
  182. $PassParameter="listtype=".$catlisttype."&albumid=".$_REQUEST['albumid'];
  183. else {
  184. if(isset($_REQUEST['srchtxt']) && $_REQUEST['srchtxt']!='')
  185. $PassParameter="listtype=".$catlisttype."&srchtxt=".$_REQUEST['srchtxt'];
  186. else {
  187. if(isset($_REQUEST['resaleby']) && base64_decode($_REQUEST['resaleby'])>0)
  188. $PassParameter="listtype=".$catlisttype."&resaleby=".$_REQUEST['resaleby'];
  189. else {
  190. if($catlisttype=='category')
  191. $PassParameter="listtype=".$catlisttype.'&cat='.base64_encode($scrapType) ;
  192. else
  193. $PassParameter="listtype=".$catlisttype;
  194. }
  195. }
  196. }
  197. }
  198. $fltr='';
  199. $CountField="X.id";
  200. $this->set("controller","creativezones");
  201. $this->set("action","scrapxonglisting");
  202. $this->set("parameter",$PassParameter);
  203. $this->set("fltr",$fltr);
  204. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  205. if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") ) {
  206. $this->set('pagehead','Most Recent');
  207. $this->render("scrapxonglisting2","ajax");
  208. }
  209. /**/
  210. $this->creativeType();
  211. $this->countFavCart();
  212. $this->getPublicScrap();
  213. }
  214. //ok scrap detail
  215. function scrapxong() {
  216. //$this->verifyserverUrl($_SERVER['REQUEST_URI']);
  217. $this->pageTitle = 'ScrapFOTO&trade;';
  218. $this->layout = 'creativedetail';
  219. ############################################ SCRAP XONG DETAILS
  220. $this->creativeType();
  221. $this->countFavCart();
  222. $this->getPublicScrap();
  223. $this->set('photoid',$_REQUEST['sxid']);
  224. //update viewed
  225. $select = "UPDATE creative_favorites SET viewed=viewed+1 WHERE id='".base64_decode($_REQUEST['sxid'])."' ";
  226. mysql_query($select);
  227. $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,
  228. Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,
  229. X.type";
  230. $from=" FROM creative_favorites X
  231. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  232. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  233. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  234. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  235. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  236. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.id='".base64_decode($_REQUEST['sxid'])."' AND X.is_stop_sell='0' group by X.id";
  237. $photo_sql = $select . $from .$where;
  238. $photo_res = mysql_query($photo_sql);
  239. $photores_arr = mysql_fetch_array($photo_res);
  240. $photoUrl = FULL_BASE_URL.$this->webroot."creativezones/scrapxong?sxid=".$_REQUEST['sxid'];//DOMAIN
  241. $this->set('photoUrl',$photoUrl);
  242. $this->set('photoArr', $photores_arr);
  243. $this->set('photoTitle', $photores_arr['title']);
  244. $this->set('photoDesc', $photores_arr['description']);
  245. $this->set('photoImage', $photores_arr['template_img']);
  246. $this->set('photoImageId', $photores_arr['id']);
  247. $this->set('photoUsername', $photores_arr['username']);
  248. $this->set('photototalRating', $photores_arr['photorat']);
  249. $this->set('photototalReview', $photores_arr['photoreview']);
  250. $this->set('photoPrice', number_format($photores_arr['price'],2,'.',','));
  251. $checklover = "Select * from creative_favorite_lovers where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."'" ;
  252. $checklover_res = mysql_query($checklover);
  253. $checklover_res_num = mysql_num_rows($checklover_res);
  254. $this->set('nooflover', $checklover_res_num);
  255. ##### Check for the review already posted or not
  256. $numberpreview=0;
  257. if(isset($_SESSION['UserId'])) {
  258. $checkbackdropreview = "SELECT * FROM creative_favorite_comments where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."' and user_id='".$_SESSION['UserId']."'";
  259. $checkbackdropreview_res = mysql_query($checkbackdropreview);
  260. $numberpreview = mysql_num_rows($checkbackdropreview_res);
  261. }
  262. $this->set('reviewposted', $numberpreview);
  263. ################################################### FOR NEXT AND PREVIOUS #######################
  264. $Imgselect="
  265. SELECT CF.id,title,template_img
  266. FROM creative_favorites CF,creative_favorites_details CFDTL
  267. WHERE CF.id=CFDTL.creative_favorite_id AND CF.type='0'
  268. GROUP BY CF.id ORDER BY CF.id DESC
  269. " ;
  270. $Imgselect_res = mysql_query($Imgselect);
  271. $Imgarray = array();
  272. while($Imgselect_arr = mysql_fetch_array($Imgselect_res)) {
  273. //$Imgarray['image'.$Imgselect_arr['id']] = $Imgselect_arr['id'] ;
  274. $Imgarray[] = $Imgselect_arr['id'] ;
  275. }
  276. //pr($Imgarray);
  277. //echo base64_decode($_REQUEST['pid']) ;
  278. $searchKey = array_search(base64_decode($_REQUEST['sxid']),$Imgarray) ;
  279. // Next
  280. $searchKeyNext = ($searchKey + 1);
  281. $searchKeyPrev = ($searchKey - 1);
  282. if (array_key_exists($searchKeyNext, $Imgarray)) {
  283. $this->set('nxtImage',$Imgarray[$searchKeyNext]);
  284. }
  285. // Prev
  286. if (array_key_exists($searchKeyPrev, $Imgarray)) {
  287. $this->set('prevImage',$Imgarray[$searchKeyPrev]);
  288. }
  289. ################################################### FOR NEXT AND PREVIOUS #######################
  290. }
  291. function creativetemplatezone() {
  292. $this->checkSession();
  293. $this->pageTitle = 'ScrapFOTO&trade; - Creative Zone';
  294. $this->layout = 'creativehome';
  295. $this->creativeType();
  296. //Initializing all the bradcamp back again so that it all starts all over again
  297. $this->set("filename","creativetemplatezone"); //filename should contain the name of the file that should be selected
  298. $this->set("nextpage","creative_favorite");
  299. //_________________________________________________________________________________________________
  300. if(isset($this->params['url']['tmp'])) {
  301. $tmpImg=base64_decode($this->params['url']['tmp']);
  302. $tmpImg = $this->templateDetail($tmpImg);
  303. if($tmpImg==0) {
  304. $this->redirect('/creativezones/index');
  305. }else {
  306. //empty cart current
  307. $sql ="SELECT id FROM creative_carts WHERE pay_status='0' ";
  308. $result = mysql_query($sql) or die(mysql_error());
  309. if(mysql_num_rows($result)>0) {
  310. while($row=mysql_fetch_array($result)) {
  311. $sql ="DELETE FROM creative_cart_details WHERE creative_cart_id='".$row['id']."' ";
  312. mysql_query($sql) or die(mysql_error());
  313. }
  314. }
  315. //add favorite
  316. $_SESSION['buyTemplate']['tmpId'] = $tmpImg;
  317. if(!isset($_SESSION['buyTemplate']['tmpId'])) {
  318. //add to favorite
  319. /*$fav = $this->Creative_favorites->findById($tmpImg);
  320. $fav['Creative_favorites']['id'] = null;
  321. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  322. $fav['Creative_favorites']['is_temp'] = 1;
  323. $fav['Creative_favorites']['type'] = 1;
  324. $fav['Creative_favorites']['is_featured'] = 0;
  325. $fav['Creative_favorites']['is_republished'] = 0;
  326. $this->Creative_favorites->create();
  327. $this->Creative_favorites->save($fav);
  328. $idNew = $this->Creative_favorites->id;
  329. $_SESSION['buyTemplate']['idNew'] = $idNew;
  330. */
  331. }
  332. }
  333. }
  334. $this->countFavCart();
  335. //case create form header
  336. if(isset($_POST['widthScrap'])) {
  337. $this->set('widthScrap',$_POST['widthScrap']);
  338. $this->set('heightScrap',$_POST['heightScrap']);
  339. $this->set('titleScrap',$_POST['titleScrap']);
  340. }
  341. }
  342. //checking
  343. function creative_favorite() {
  344. $this->checkSession();
  345. $this->pageTitle = 'ScrapFOTO&trade; - My Favorite';
  346. $this->layout = 'creativehome';
  347. $this->creativeType();
  348. //This ct variable comes from INDEX page and CREATIVETEMPLATE page
  349. $tmpImg=0;
  350. if(isset($this->params['url']['tmp'])) {
  351. $tmpImg=base64_decode($this->params['url']['tmp']);
  352. $tmpImg = $this->templateDetail($tmpImg);
  353. }else if(isset($_SESSION['buyTemplate']['tmpId'])) {
  354. $tmpImg = $_SESSION['buyTemplate']['tmpId'];
  355. $tmpImg = $this->templateDetail($tmpImg);
  356. }
  357. if($tmpImg==0) {
  358. unset($_SESSION['buyTemplate']);
  359. }
  360. if(isset($_POST['ssn_id'])) {
  361. $ssn_id = $_POST['ssn_id'];
  362. $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
  363. if(!$fav) {//create
  364. $this->Creative_favorites->create();
  365. }
  366. else {//update
  367. $this->Creative_favorites->id = $fav['Creative_favorites']['id'];
  368. if($fav['Creative_favorites']['template_id']>0)
  369. $_SESSION['buyTemplate']['tmpId'] = $fav['Creative_favorites']['template_id'];
  370. }
  371. $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
  372. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  373. $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
  374. $fav['Creative_favorites']['description'] = $_POST['description'];
  375. $fav['Creative_favorites']['price'] = $_POST['price'];
  376. $fav['Creative_favorites']['width'] = $_POST['width'];
  377. $fav['Creative_favorites']['height'] = $_POST['height'];
  378. $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
  379. $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
  380. $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
  381. $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
  382. $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
  383. $fav['Creative_favorites']['is_temp'] = 0;
  384. $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
  385. $fav['Creative_favorites']['type'] = $_POST['type'];
  386. $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
  387. $fav['Creative_favorites']['is_temp'] = $fav['Creative_favorites']['is_featured'];
  388. if($fav['Creative_favorites']['type']==0) {//public
  389. $featuredAmount=$this->getConfigAmount('creative artist price');
  390. $fav['Creative_favorites']['price'] = $featuredAmount['config_value'];
  391. }
  392. if(isset($_SESSION['buyTemplate']) && isset($_SESSION['buyTemplate']['tmpId'])) {
  393. $fav['Creative_favorites']['template_id'] = $_SESSION['buyTemplate']['tmpId'];
  394. //get price
  395. $template = $this->Creative_favorites->findById($_SESSION['buyTemplate']['tmpId']);
  396. if($template)
  397. $fav['Creative_favorites']['price'] = $template['Creative_favorites']['price'];
  398. }
  399. $resultSave = $this->Creative_favorites->save($fav);//return 1/null
  400. //insert tag
  401. if($resultSave && $_POST['tag']!='') {
  402. $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
  403. $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
  404. $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
  405. $this->Creative_favorite_tags->create();
  406. $this->Creative_favorite_tags->save($tag);
  407. }
  408. if($fav['Creative_favorites']['type']==0) {
  409. if($resultSave && $fav['Creative_favorites']['is_featured']==1) {
  410. $this->redirect("creativezones/creative_featured?lid=".base64_encode($this->Creative_favorites->id));
  411. exit();
  412. }else {
  413. $this->redirect("creativezones/featuredsuccess?lid=".base64_encode($this->Creative_favorites->id));
  414. }
  415. }
  416. }
  417. if(isset($_POST['actionCall']) && $_POST['actionCall']=='exit') {
  418. $this->redirect('/creativezones/index');
  419. }
  420. $sql = "";
  421. if($tmpImg==0) {
  422. $sql = "SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND template_id<=0 AND is_temp='0' AND is_republished='1' ";
  423. }else {
  424. $sql = "SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND template_id>0 AND is_temp='0' ";
  425. }
  426. if($sql!="") {
  427. $favs = null;
  428. $result = mysql_query($sql) or die("Error on line :".__LINE__.mysql_error());
  429. if(mysql_num_rows($result)>0) {
  430. $favs = $result;
  431. }
  432. $this->set("favs",$favs);
  433. }
  434. $this->countFavCart();
  435. //Initializing all the bradcamp back again so that it all starts all over again
  436. $this->set("filename","creative_favorite");
  437. $this->set("nextpage","mycart");
  438. //_________________________________________________________________________________________________
  439. $this->set("recenttype","creative_favorite");
  440. $this->getCartDetails();
  441. }
  442. //ok
  443. function creative_favorite_ajax() {
  444. if(isset($_POST['ssn_id'])) {
  445. $ssn_id = $_POST['ssn_id'];
  446. $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
  447. if(!$fav) {
  448. $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
  449. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  450. $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
  451. $fav['Creative_favorites']['description'] = $_POST['description'];
  452. $fav['Creative_favorites']['price'] = $_POST['price'];
  453. $fav['Creative_favorites']['width'] = $_POST['width'];
  454. $fav['Creative_favorites']['height'] = $_POST['height'];
  455. $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
  456. $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
  457. $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
  458. $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
  459. $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
  460. $fav['Creative_favorites']['is_temp'] = 0;
  461. $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
  462. $fav['Creative_favorites']['type'] = $_POST['type'];
  463. $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
  464. if(isset($_SESSION['buyTemplate']) && isset($_SESSION['buyTemplate']['tmpId'])) {
  465. $fav['Creative_favorites']['template_id'] = $_SESSION['buyTemplate']['tmpId'];
  466. //get price
  467. $template = $this->Creative_favorites->findById($_SESSION['buyTemplate']['tmpId']);
  468. if($template)
  469. $fav['Creative_favorites']['price'] = $template['Creative_favorites']['price'];
  470. }
  471. $this->Creative_favorites->create();
  472. $resultSave = $this->Creative_favorites->save($fav);//return 1/null
  473. //insert tag
  474. if($resultSave && $_POST['tag']!='') {
  475. $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
  476. $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
  477. $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
  478. $this->Creative_favorite_tags->create();
  479. $this->Creative_favorite_tags->save($tag);
  480. }
  481. }
  482. if($fav['Creative_favorites']['template_id']>0) {
  483. $_SESSION['buyTemplate']['tmpId'] = $fav['Creative_favorites']['template_id'];
  484. }
  485. }
  486. $this->countFavCart();
  487. $this->render("creative_favorite_ajax","ajax");
  488. }
  489. function creativeType() {
  490. $q1=mysql_query("SELECT * FROM creative_type WHERE is_delete='0' ORDER BY sequence ASC");
  491. $i=0;
  492. while($rwCr=mysql_fetch_array($q1)) {
  493. if($i==0)
  494. $defaultCat[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
  495. $i++;
  496. $creativeType[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
  497. }
  498. $this->set("defaultType",$defaultCat);
  499. $this->set("creativeType",$creativeType);
  500. $type = 0;
  501. foreach($defaultCat as $key=>$value) {
  502. $type = $key;
  503. break;
  504. }
  505. if(isset($this->params['url']['cat'])) {
  506. $scrapType=base64_decode($this->params['url']['cat']);
  507. $detail = $this->getCreativeType($scrapType);
  508. if($detail) {
  509. $type = $detail['id'];
  510. }
  511. }
  512. $this->set('defaultCate',$type);
  513. }
  514. //checking
  515. function templateDetail($tmpImg) {
  516. $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());
  517. if(mysql_num_rows($q1)>0) {
  518. $rwTmpImg=mysql_fetch_assoc($q1);
  519. $this->set("tmpid",base64_encode($rwTmpImg['ssn_id']));
  520. $this->set("tmp",base64_encode($tmpImg));
  521. return $tmpImg;
  522. }
  523. return 0;
  524. }
  525. //ok
  526. function getPublicScrap() {
  527. $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";
  528. $from=" FROM creative_favorites X
  529. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  530. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  531. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  532. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  533. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  534. $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'";
  535. $others=" group by X.id ";
  536. $others .=" order by photorat desc ";
  537. $queryCreative = $select . $from . $where .$others ;
  538. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  539. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  540. $this->set("publicScrap",$queryCreativeFavorites);
  541. $this->set("publicScrapSql",$queryCreative);
  542. }
  543. //ok
  544. function getRankScrap() {
  545. /*$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";
  546. $from=" FROM creative_favorites X
  547. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  548. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  549. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  550. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  551. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  552. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' ";
  553. $others=" group by X.id ";
  554. $others .=" order by photorat desc LIMIT 21";
  555. $queryCreative = $select . $from . $where .$others ;
  556. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  557. $this->set("publicRank",$queryCreativeFavorites);
  558. $this->set("publicRankSql",$queryCreative);
  559. */
  560. }
  561. //ok
  562. function getFeaturedScrap() {
  563. /*$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";
  564. $from=" FROM creative_favorites X
  565. LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
  566. LEFT JOIN creative_template_pages Xalbum ON X.creative_template_page_id = Xalbum.id
  567. LEFT JOIN creative_type XCreativetype ON Xalbum.creative_type_id = XCreativetype.id
  568. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  569. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  570. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  571. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  572. $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' ";
  573. $others=" group by X.id ";
  574. $others .=" order by photorat desc LIMIT 21";
  575. $queryCreative = $select . $from . $where .$others ;
  576. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  577. $this->set("publicFeatured",$queryCreativeFavorites);
  578. $this->set("publicFeaturedSql",$queryCreative);
  579. */
  580. }
  581. //ok
  582. function viewalltag() {
  583. $this->pageTitle = 'ScrapFOTO&trade; - View Tag';
  584. $this->layout = 'creativedetail';
  585. $this->creativeType();
  586. $this->getPublicScrap();
  587. }
  588. //ok
  589. function searchtag($alphasearch=null) {
  590. if($alphasearch)
  591. $searchtxt = "'".strtolower($alphasearch)."%'" ;
  592. else {
  593. if(isset($_REQUEST['txttagsearch']) && $_REQUEST['txttagsearch']!='')
  594. $searchtxt = "'%". strip_html_tags($_REQUEST['txttagsearch'])."%'";
  595. else
  596. $searchtxt='a%';
  597. }
  598. $tagarray = array();
  599. $tagsearchsql = "SELECT DISTINCT(tagname) FROM creative_favorite_tags where tagname!='' and tagname like ". $searchtxt ."";
  600. $tagsearchsql_res = mysql_query($tagsearchsql);
  601. while($tagsearchsql_arr = mysql_fetch_array($tagsearchsql_res)) {
  602. $tagarray[] = $tagsearchsql_arr['tagname'];
  603. }
  604. $this->set('tagsql',$tagsearchsql);
  605. $this->set('tagarray',$tagarray);
  606. $this->set('Numtagarray',mysql_num_rows($tagsearchsql_res));
  607. $this->set('searchtxt',$alphasearch);
  608. $this->render('searchtaglist', 'ajax');
  609. }
  610. //ok
  611. function scrapaddtocart($scrapxongid=null) {
  612. $queryCreativeFavorites=mysql_query("
  613. SELECT CF.title,CTP.price
  614. FROM creative_favorites CF,creative_template_pages CTP
  615. WHERE CF.id='".base64_decode($scrapxongid)."' AND CF.creative_template_page_id=CTP.id AND CF.type='0'");
  616. $fetchCreativeFavorites=mysql_fetch_assoc($queryCreativeFavorites);
  617. $productName=$fetchCreativeFavorites['title'];
  618. $price=$fetchCreativeFavorites['price'];
  619. if(isset($_SESSION['UserId'])) {
  620. $creativecartsql = "SELECT * from creative_carts WHERE user_id='".$_SESSION['UserId']."' and product_name='".$productName."' and ssn_id='".session_id()."' and pay_status='0'";
  621. $creativecartsql_res = mysql_query($creativecartsql);
  622. if(mysql_num_rows($creativecartsql_res)==0) {
  623. mysql_query("INSERT INTO
  624. creative_carts(user_id,product_name,price,qty,transaction_creative_id,pay_status,ssn_id)
  625. VALUES('".$_SESSION['UserId']."','".$productName."','".$price."','1','0','0','".session_id()."')") or die("Error on line : ".__LINE__.mysql_error());
  626. $lastId=mysql_insert_id();
  627. $queryCreativeFavoritesDetails=mysql_query("SELECT template_img FROM creative_favorites_details WHERE creative_favorite_id='".base64_decode($scrapxongid)."'");
  628. while($fetchCreativeFavoritesDetails=mysql_fetch_assoc($queryCreativeFavoritesDetails)) {
  629. mysql_query("INSERT INTO creative_cart_details(creative_cart_id,imagename) VALUES('".$lastId."','".$fetchCreativeFavoritesDetails['template_img']."')");
  630. }
  631. }
  632. }
  633. $this->countFavCart();
  634. $this->set('photoImageId',$scrapxongid);
  635. $this->render('cartitem', 'ajax');
  636. }
  637. function creative_login() {
  638. $uName=base64_decode($this->params['url']['u']);
  639. $password=$this->params['url']['p'];
  640. $id=0;
  641. if(isset($this->params['url']['ct']))
  642. $id=base64_decode($this->params['url']['ct']);
  643. //This ct variable comes from CREATIVETEMPLATE page
  644. $tmpImg=0;
  645. if(isset($this->params['url']['tmp']))
  646. $tmpImg=base64_decode($this->params['url']['tmp']);
  647. //This is the last iserted id in the favorite table
  648. $lastId=0;
  649. if(isset($this->params['url']['lid']))
  650. $lastId=base64_decode($this->params['url']['lid']);
  651. $someone=$this->userLogin($uName,$password);
  652. if(!empty($someone))
  653. $this->redirect("creativezones/creative_favorite?ct=".base64_encode($id)."&tmp=".base64_encode($tmpImg)."&lid=".base64_encode($lastId));
  654. }
  655. function featuredpayment() {
  656. /*
  657. $this->checkSession();
  658. $this->layout = 'previewpaymemnt';
  659. $this->render("paymentback");
  660. //This ct variable comes from INDEX page and CREATIVETEMPLATE page
  661. $id=0;
  662. if(isset($this->params['url']['ct']))
  663. $id=base64_decode($this->params['url']['ct']);
  664. //This ct variable comes from CREATIVETEMPLATE page
  665. $tmpImg=0;
  666. if(isset($this->params['url']['tmp']))
  667. $tmpImg=base64_decode($this->params['url']['tmp']);
  668. //This is the last iserted id in the favorite table
  669. //If lid means user comes to this page after saving the scrapbook
  670. //We are checking whether the user features the scrapblog or not if yes then ask for the payment
  671. $lastId=0;
  672. if(isset($this->params['url']['lid']))
  673. $lastId=base64_decode($this->params['url']['lid']);
  674. $this->set("cType",$id);
  675. $this->set("cTemplate",$tmpImg);
  676. $this->set("lastId",$lastId);
  677. if(!empty($this->data)) {
  678. $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
  679. $featuredAmount=$this->getConfigAmount('creative featured');
  680. $amountCharge=$this->data['creative']['amount'];
  681. if(isset($this->data['Event']['radiobutton'])) {
  682. if($this->data['Event']['radiobutton']=="paypal") {
  683. $this->itemName="ScrapFOTO&trade; fetaured";
  684. $this->amountPay=$amountCharge;
  685. $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
  686. $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
  687. $this->merchantEmail=$fetchAdminPaymentSetup['paypal_email'];
  688. $this->custom=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId;
  689. $this->paypal();
  690. }
  691. if($this->data['Event']['radiobutton']=="google") {
  692. $adminPayment=$fetchAdminPaymentSetup['gcheckout_email'];
  693. $adminPaymentDetails=explode("break",$adminPayment);
  694. $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
  695. $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
  696. $this->Gcheckout->gItemName="ScrapFOTO&trade; Featured";
  697. $this->Gcheckout->gItemDesc="ScrapFOTO&trade; Featured";
  698. $this->Gcheckout->gQuantity=1;
  699. $this->Gcheckout->gPrice=$amountCharge;
  700. $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
  701. $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
  702. $this->Gcheckout->customData=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId."^".$amountCharge;
  703. $this->Gcheckout->google();
  704. }
  705. }
  706. }*/
  707. }
  708. function creative_featured() {
  709. $this->checkSession();
  710. $this->pageTitle = 'ScrapFOTO&trade; - Featured ScrapFOTO&trade;';
  711. $this->layout = 'creativehome';
  712. $this->creativeType();
  713. $this->getPublicScrap();
  714. $cartCount=$this->countFavCart();
  715. $tmpImg =0;
  716. $id =0;
  717. $lastId=0;
  718. if(isset($this->params['url']['lid']))
  719. $lastId=base64_decode($this->params['url']['lid']);
  720. $this->set("lastId",$lastId);
  721. $this->set("filename","creative_cart");
  722. $this->set("recenttype","creative_favorite");
  723. $featuredAmount=$this->getConfigAmount('creative featured');
  724. $this->set("featuredAmount",$featuredAmount);
  725. //getCartDetails;
  726. $sql = "SELECT *,CF.fileThumb2 as imagename FROM creative_favorites as CF WHERE CF.id='".$lastId."' LIMIT 1";
  727. $queryCreativeCarts=mysql_query($sql);
  728. $this->set("queryCreativeCarts",$queryCreativeCarts);
  729. $this->getUserDetails();
  730. $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
  731. $this->set('sellerId',1);
  732. $this->set('receiverId',1);
  733. $this->set("paymentMethods",$fetchAdminPaymentSetup);
  734. }
  735. //checking
  736. function featured_payment_notify() {
  737. /*
  738. $this->Paypal->paypal_class();
  739. $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
  740. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  741. $paypal=0;
  742. if ($this->Paypal->validate_ipn()) {
  743. $paypal=1;
  744. if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="") {
  745. $totalPay=$this->Paypal->ipn_data['payment_gross'];
  746. $custom=explode("^",$this->Paypal->ipn_data['custom']);
  747. $userId=$custom['0'];
  748. $lastId=$custom['1'];
  749. $invoice=$_POST['invoice'];
  750. $ticket=$custom['3'];
  751. }
  752. }
  753. //This section is used to catch from GOOGLE IPN data
  754. if(!$paypal) {
  755. //this section is used to update from google IPN data
  756. $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
  757. if($xml_response) {
  758. $gCustom=$this->parseXmlArray($xml_response);
  759. $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
  760. $ipnData=explode("^",$cData);
  761. $userId=$ipnData['0'];
  762. $lastId=$ipnData['1'];
  763. $invoice=$ipnData['2'];
  764. $ticket=$ipnData['3'];
  765. $totalPay=$ipnData['4'];
  766. }
  767. }
  768. */
  769. }
  770. //checking
  771. function featuredsuccess() {
  772. $is_featured = 1;
  773. $productId=0;
  774. if(isset($this->params['url']['lid']))
  775. $productId=base64_decode($this->params['url']['lid']);
  776. if(isset($_POST['custom'])) {
  777. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  778. $paypal=1;
  779. $totalPay=$_POST['total_amount'];
  780. $custom=explode("^",$_POST['custom']);
  781. $userId=$custom['0'];
  782. $sellerId=$custom['1'];
  783. $isAdmin=$custom['2'];
  784. $rdPage=$custom['3'];
  785. $invoice=$custom['4'];
  786. $transactionId=$custom['5'];
  787. $ticket=$custom['6'];
  788. $productId=$custom['7'];
  789. }else {
  790. $userId = $_SESSION['UserId'];
  791. $totalPay = 0;
  792. $ticket = $this->createTransactionNumber('SPTT');
  793. $is_featured = 0;
  794. }
  795. //________________________________________________XOIMAGE DATABASE UPDATION SECTION
  796. //update featured_time
  797. $featured_time = NULL;
  798. if($is_featured==1) {
  799. $result = $this->getConfigAmount('creative featured days');
  800. $featureddays = $result['config_value'];
  801. $featured_time = date('Y-m-d G:i:s', strtotime("+".$featureddays." day"));
  802. }
  803. $queryCreativeFavorites=mysql_query("
  804. UPDATE creative_favorites
  805. SET is_featured='$is_featured',is_temp='0', featured_time='".$featured_time."'
  806. WHERE user_id='".$userId."' AND id='".$productId."'") or die("Error on line : ".__LINE__.mysql_error());
  807. if(isset($transactionId)) {
  808. //UPDATE date on TRANSACTION_CREATIVE TABLE
  809. $queryUpdateTransactionCreative="
  810. UPDATE transaction_creatives
  811. SET pay_status='1',invoice='".$invoice."', payment_ts_id='".$_POST['payment_ts_id']."'
  812. WHERE id='".$transactionId."' ";
  813. mysql_query($queryUpdateTransactionCreative) or die("Error on line : ".__LINE__.mysql_error());
  814. //UPDATE data to the CREATIVE_CARTS TABLE after successful transaction
  815. $queryUpdateCreativeCart="
  816. UPDATE creative_carts
  817. SET pay_status='1', total_price='".$totalPay."'
  818. WHERE user_id='".$userId."' AND pay_status='0' AND transaction_creative_id='".$transactionId."' ";
  819. mysql_query($queryUpdateCreativeCart) or die("Error on line : ".__LINE__.mysql_error());
  820. }
  821. //____________________________________________________TRANSACTION LOG MANAGEMENT_____________________________________
  822. $userDetails=$this->getUserDetails($userId);
  823. $scrapDetails=$this->scrapDetails($productId);
  824. if(isset($invoice))
  825. $this->set('invoice',$invoice);
  826. $this->set('ticket',$ticket);
  827. $this->set('totalPay',$totalPay);
  828. //ticket
  829. $ticketData = $this->Creative_tickets->findByCreative_favorites_id($productId);
  830. if(!$ticketData) {
  831. $ticketData['Creative_tickets']['user_id'] = $userId;
  832. $ticketData['Creative_tickets']['creative_favorites_id'] = $productId;
  833. $ticketData['Creative_tickets']['ticket_number'] = $ticket;
  834. $ticketData['Creative_tickets']['status'] = 'awaiting';
  835. $this->Creative_tickets->create();
  836. $this->Creative_tickets->save($ticketData);
  837. //____________________________________________________MAIL MANAGEMENT________________________________________________
  838. //this mailing code is here so that it fires just once.
  839. //mail sent to the user personal account
  840. $this->Sendmail->Mail();
  841. $this->Sendmail->From(FROMMAIL);
  842. if(isset($userDetails['email'])) {
  843. $this->Sendmail->To($userDetails['email']);
  844. $subject="XOimages - Scrapfoto Ticket ".$ticket;
  845. $this->Sendmail->Subject($subject);
  846. $this->set("ticket_number",$ticket);
  847. if(isset($invoice)) {
  848. $featuredAmount=$this->getConfigAmount('creative featured');
  849. $this->set('featurefee', $featuredAmount['config_value']);
  850. }
  851. $this->Sendmail->layout='email';
  852. $this->Sendmail->view='mail_ticket';
  853. $this->Sendmail->startup($this);
  854. $messageBody=$this->Sendmail->bodyText();
  855. $this->Sendmail->Body($messageBody); // set the body
  856. $this->Sendmail->Priority(1) ; // set the priority to Low
  857. $this->Sendmail->Send(); // send the mail
  858. //mail sent to the user mail account in the system
  859. $sender=1;
  860. $receiver=$userId;
  861. $this->senderMail($sender,$receiver,$subject,$messageBody);
  862. $this->receiverMail($receiver,$sender,$subject,$messageBody);
  863. }
  864. }else {
  865. $ticket = $ticketData['Creative_tickets']['ticket_number'];
  866. $this->set('ticket_exists',1);
  867. }
  868. //invoice
  869. if(isset($invoice)) {
  870. $downloadimg=$

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