PageRenderTime 70ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/app/controllers/backdrop_controller.php

https://bitbucket.org/fxrialab/tickets
PHP | 2288 lines | 1765 code | 418 blank | 105 comment | 231 complexity | 8cebc18cc553a03b7820d334278c8e4f MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
  1. <?php
  2. class BackdropController extends AppController
  3. {
  4. var $name='Backdrop';
  5. var $helpers = array('Pagination', 'error','Ajax');
  6. var $components = array('Pagination','Download','Sendmail');
  7. function backdropsizelist()
  8. {
  9. $categorylist = array('0'=>'Select Size',"6'X8'"=>"6'X8'","10'X10'"=>"10'X10'","20'X20'"=>"20'X20'");
  10. $this->set('sizelist',$categorylist);
  11. }
  12. function viewbackdrops($userType=null , $userId=null)
  13. {
  14. $this->checkSession();
  15. $this->layout = 'default_user';
  16. if($userType=='admin')
  17. $Qry = mysql_fetch_array(mysql_query("select * from backdrops where is_admin='Yes' and user_id=".base64_decode($userId)));
  18. else
  19. {
  20. if($userType=='admin')
  21. $Qry = mysql_fetch_array(mysql_query("select * from backdrops where is_admin='No' and user_id=".base64_decode($userId)));
  22. else
  23. $Qry = mysql_fetch_array(mysql_query("select * from backdrops where user_id=".base64_decode($userId).""));
  24. }
  25. $this->set('album', $Qry);
  26. $this->set('userType', $userType);
  27. $this->set('userId', $userId);
  28. }
  29. function backdropdetails($backdropUserType=null,$backdropUserId=null,$backdropid=null)
  30. {
  31. $this->checkSession();
  32. $this->layout = 'default_user';
  33. $this->set('BackdropUserType', $backdropUserType);
  34. $this->set('BackdropUserId', $backdropUserId);
  35. $this->set('Backdropid', $backdropid);
  36. $this->set('userType', $backdropUserType);
  37. $this->set('userId', $backdropUserId);
  38. $this->backdropcategory();
  39. $this->getbackdropdetails($backdropid);
  40. }
  41. function getbackdropdetails($backdropid=null)
  42. {
  43. /*getting out the backdrop details*/
  44. $selectbackdrop = "Select * from backdrops where id=".$backdropid."";
  45. $selectbackdrop_res = mysql_query($selectbackdrop);
  46. $selectbackdrop_arr = mysql_fetch_array($selectbackdrop_res);
  47. $this->set('BackdropTitle', stripslashes($selectbackdrop_arr['Name']));
  48. $this->set('BackdropDesc', stripslashes($selectbackdrop_arr['description']));
  49. $this->set('OriginalPrice', stripslashes($selectbackdrop_arr['original_price']));
  50. $this->set('ListingPrice', stripslashes($selectbackdrop_arr['listing_price']));
  51. $this->set('BackdropSize', stripslashes($selectbackdrop_arr['backdrop_size']));
  52. $this->set('Backdropcat', stripslashes($selectbackdrop_arr['backdrop_categories_id']));
  53. $this->set('Backdropfeatured', $selectbackdrop_arr['is_featured']);
  54. $this->set('Backdropresale', $selectbackdrop_arr['is_resale']);
  55. /// User belongs to query
  56. if($selectbackdrop_arr['belongstouser']>1)
  57. {
  58. $usernameQry = "Select username from users where id='".$selectbackdrop_arr['belongstouser']."'";
  59. $usernameQry_res = mysql_query($usernameQry);
  60. $usernameQry_arr = mysql_fetch_array($usernameQry_res);
  61. $backdropuser = $usernameQry_arr['username'];
  62. }
  63. else
  64. $backdropuser = 'admin';
  65. $this->set('Backdropbelongsto', $backdropuser);
  66. $this->set('Backdropapproved', $selectbackdrop_arr['is_approved']);
  67. if($selectbackdrop_arr['is_approved']==0)$apptxt = 'Awaiting';
  68. if($selectbackdrop_arr['is_approved']==1)$apptxt = 'Approved';
  69. if($selectbackdrop_arr['is_approved']==2)$apptxt = 'Disapproved' ;
  70. $this->set('Backdropapprovedtxt',$apptxt);
  71. }
  72. function savebackdropdetails($backdroptranId=null)
  73. {
  74. /* Save the updated records */
  75. $approvaltxt='awaiting';
  76. $rejecttxtmsg='';
  77. $updatebackdrop=0;
  78. if(isset($_REQUEST['backdropstatus']) && $_REQUEST['backdropstatus']!='')
  79. {
  80. $approvaltxt=$_REQUEST['backdropstatus'] ;
  81. }
  82. if(isset($_REQUEST['txtmsg'.$backdroptranId]) && $_REQUEST['txtmsg'.$backdroptranId]!='')
  83. {
  84. $rejecttxtmsg=$_REQUEST['txtmsg'.$backdroptranId] ;
  85. }
  86. @mysql_query("Update backdrop_tickets SET status='".$approvaltxt."' , admin_reject_msg='".$rejecttxtmsg."' where id='".$backdroptranId."' ");
  87. if($approvaltxt=='reject')
  88. $updatebackdrop = '2';
  89. if($approvaltxt=='approve')
  90. $updatebackdrop = '1';
  91. /* Select */
  92. $sectbackid = "SELECT backdrop_id from backdrop_tickets where id='".$backdroptranId."'" ;
  93. $sectbackid_res = mysql_query($sectbackid);
  94. $sectbackid_array = mysql_fetch_array($sectbackid_res);
  95. @mysql_query("Update backdrops SET is_approved='".$updatebackdrop."' where id='".$sectbackid_array['backdrop_id']."' ");
  96. $this->set('rejecttxtmsg',$rejecttxtmsg);
  97. if(isset($_REQUEST['hfresale']) && $_REQUEST['hfresale']==0)
  98. {
  99. $updatesql = "UPDATE backdrops SET original_price='".$_REQUEST['backdroporgprice']."' ,listing_price='".$_REQUEST['backdroplistprice']."',backdrop_size='".addslashes($_REQUEST['backdropsize'])."',backdrop_categories_id='".$_REQUEST['category']."',user_id='".$_SESSION['Admin_id']."',is_admin='Yes',is_approved='".$_REQUEST['backdropstatus']."' where id='".$sectbackid_array['backdrop_id']."' ";
  100. }else{
  101. $updatesql = "UPDATE backdrops SET original_price='".$_REQUEST['backdroporgprice']."' ,listing_price='".$_REQUEST['backdroplistprice']."',backdrop_size='".addslashes($_REQUEST['backdropsize'])."',backdrop_categories_id='".$_REQUEST['category']."' where id='".$sectbackid_array['backdrop_id']."' ";
  102. }
  103. //echo $updatesql ;
  104. //pr($_REQUEST);
  105. //exit();
  106. $updatesql_res = mysql_query($updatesql);
  107. $this->backdropcategory();
  108. $this->getbackdropdetails($sectbackid_array['backdrop_id']);
  109. $this->set('Backdropid',base64_encode($sectbackid_array['backdrop_id']));
  110. ##### USER EMAIL ADDRESS
  111. $selectBackdropuser = "Select user_details.email , user_details.first_name ,user_details.last_name from user_details Left JOIN backdrops On backdrops.belongstouser=user_details.user_id where backdrops.id='".$sectbackid_array['backdrop_id']."'" ;
  112. $selectBackdropuser_res = mysql_query($selectBackdropuser);
  113. $selectBackdropuser_arr = mysql_fetch_array($selectBackdropuser_res);
  114. $this->set('BackdropUserFirst',$selectBackdropuser_arr['first_name']);
  115. $this->set('BackdropUserLast',$selectBackdropuser_arr['last_name']);
  116. //////
  117. //pr($_REQUEST);
  118. /// echo $selectBackdropuser_arr['email'] ;
  119. $this->Sendmail->Mail();
  120. $this->Sendmail->From('xoadmin@gmail.com');
  121. $this->Sendmail->To($selectBackdropuser_arr['email']);
  122. $this->Sendmail->Cc("sanjib@navsoft.in");
  123. $this->Sendmail->Cc("sujoy@navsoft.in");
  124. $subject="Backdrop approval status";
  125. $this->Sendmail->Subject($subject);
  126. $this->Sendmail->layout='email';
  127. $this->Sendmail->view='mail_backdroppost';
  128. $this->Sendmail->startup($this);
  129. $messageBody=$this->Sendmail->bodyText();
  130. $this->Sendmail->Body($messageBody); // set the body
  131. $this->Sendmail->Priority(1) ; // set the priority to Low
  132. $this->Sendmail->Send(); /**/
  133. $this->redirect($_SERVER['HTTP_REFERER']);
  134. }
  135. function savetransactioncomment()
  136. {
  137. $statusDate=date("Y-m-d",strtotime($this->params['form']['statusDate']));
  138. mysql_query("
  139. UPDATE
  140. transaction_backdrop
  141. SET
  142. status='".$this->params['form']['status']."',status_date='".$statusDate."'
  143. WHERE id='".$this->params['form']['tranId']."'");
  144. $returnPage=$this->params['form']['returnurl'];
  145. $this->redirect("backdrop/".$returnPage);
  146. }
  147. function download_backdrop()
  148. {
  149. $fileName=$this->params['url']['f'];
  150. $basePath=realpath('../../app/webroot/user_backdrop_img').'/';
  151. //$basePath = str_replace("/",DS,$basePath);
  152. //if(file_exists($basePath.DS.$fileName)){
  153. // echo "Exists";
  154. //}
  155. //else{
  156. // echo "Not Exists";
  157. //}
  158. //
  159. //$basePath = MAINDOMAIN.'user_backdrop_img/';
  160. //$basePath = explode('/var/www/vhosts/xoimages.com',$basePath);
  161. //echo $basePath[1];
  162. //exit;
  163. $this->Download->downloadFile($basePath,$fileName);
  164. //$this->redirect($_SERVER['HTTP_REFERER']);
  165. }
  166. function managebackdropcategory()
  167. {
  168. $this->checkSession();
  169. $this->layout = 'default_user';
  170. }
  171. function managebackdrop()
  172. {
  173. $this->checkSession();
  174. $this->layout = 'default_user';
  175. }
  176. function createbackdrop($usertype=null,$userId=null)
  177. {
  178. $this->redirect('backdrop/newcreatebackdrop');
  179. $this->checkSession();
  180. $this->layout = 'default_user';
  181. $this->backdropcategory();
  182. $this->backdropsizelist();
  183. if($usertype)
  184. $this->set('Backdropusertype',$usertype);
  185. if($userId)
  186. $this->set('BackdropuserId',$userId);
  187. }
  188. function backdropcategory()
  189. {
  190. $evtcat = array();
  191. $evtcat['0']="Select Category";
  192. $select_ticket_cat = mysql_query("Select * from backdrop_categories");
  193. while($select_ticket_cat_arr = mysql_fetch_array($select_ticket_cat))
  194. {
  195. $evtcat[$select_ticket_cat_arr['id']] = $select_ticket_cat_arr['backdrop_cat_name'];
  196. }
  197. $this->set('backdropcat',$evtcat);
  198. $this->backdropsizelist();
  199. }
  200. function delbackdropcategory($catid=null)
  201. {
  202. $this->checkSession();
  203. if(isset($_REQUEST['box']))
  204. {
  205. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  206. $arr = $_REQUEST['box'];
  207. foreach($arr as $key => $value)
  208. {
  209. $sql_det = "delete from `backdrop_categories` where `id` = '".$value."'";
  210. $res_det = mysql_query($sql_det);
  211. }
  212. }
  213. ////IF DELETE IS FOR A SPECIFIC USER////
  214. else
  215. {
  216. $sql_det = "delete from `backdrop_categories` where `id` = '".$catid."'";
  217. $res_det = mysql_query($sql_det);
  218. }
  219. //$user_id=$_REQUEST['id'];
  220. $this->redirect($_SERVER['HTTP_REFERER']);
  221. }
  222. function createbackdrop2($backdrop=null)
  223. {
  224. $this->checkSession();
  225. $this->layout = 'default_user';
  226. if($backdrop)
  227. $this->set('Backdropid', $backdrop);
  228. if($backdrop)
  229. {
  230. $this->backdropcategory();
  231. $this->getbackdropdetails($backdrop);
  232. //$this->set('Backdropid', $backdrop);
  233. }
  234. if (!empty($this->data))
  235. {
  236. //pr($_REQUEST);
  237. if(isset($_REQUEST['backdropId']) && $_REQUEST['backdropId']!='')
  238. $this->data['Backdrop']['user_id'] = $_REQUEST['backdropId'];
  239. else
  240. $this->data['Backdrop']['user_id'] = $_SESSION['Admin_id'];
  241. $this->data['Backdrop']['belongstouser'] = $_SESSION['Admin_id'];
  242. $this->data['Backdrop']['is_featured'] = $_REQUEST['backdropfeatured'];
  243. $this->data['Backdrop']['is_approved'] = $_REQUEST['backdropstatus'];
  244. //echo $this->data['Backdrop']['user_id'] ;
  245. //
  246. //exit();
  247. if($_REQUEST['category']==0)
  248. $this->data['Backdrop']['backdrop_categories_id'] = 1;
  249. else
  250. $this->data['Backdrop']['backdrop_categories_id'] = $_REQUEST['category'];
  251. if(isset($_REQUEST['backdropIdUser']) && $_REQUEST['backdropIdUser']=='admin')
  252. $this->data['Backdrop']['is_admin'] = 'Yes';
  253. else
  254. {
  255. if(isset($_REQUEST['backdropuser']) && $_REQUEST['backdropuser']=='user')
  256. $this->data['Backdrop']['is_admin'] = 'No';
  257. else
  258. $this->data['Backdrop']['is_admin'] = 'Yes';
  259. }
  260. $this->data['Backdrop']['backdrop_size'] = $_REQUEST['backdropsize'];
  261. //pr($this->data);
  262. if ($this->Backdrop->save($this->data))
  263. {
  264. $backdrop_id = $this->Backdrop->getLastInsertId();
  265. /* UPDATE THE BACKDROP TABLE WITH UNIQUE NUMBER*/
  266. $this->data['Backdrop']['id'] = $backdrop_id;
  267. $this->data['Backdrop']['backdrop_id'] = $backdrop_id.date('mdY');
  268. $this->Backdrop->save($this->data);
  269. $this->redirect('/backdrop/createbackdrop2/'.$backdrop_id);
  270. }
  271. }
  272. }
  273. function Delbackdrop($backdropid=null)
  274. {
  275. if($backdropid)
  276. {
  277. $delbackquery = "DELETE FROM backdrops where id='".base64_decode($backdropid)."'";
  278. $delbackquery_res = mysql_query($delbackquery);
  279. }
  280. $this->redirect($this->webroot.'backdrop/managebackdrop');
  281. }
  282. function Blocked($blocktype=null,$backdropid=null)
  283. {
  284. if($blocktype=='block')
  285. {
  286. $delbackquery = "UPdate backdrops SET is_blocked='1' where id='".base64_decode($backdropid)."'";
  287. $delbackquery_res = mysql_query($delbackquery);
  288. }
  289. else{
  290. if($blocktype=='unblock')
  291. {
  292. $delbackquery = "UPdate backdrops SET is_blocked='0' where id='".base64_decode($backdropid)."'";
  293. $delbackquery_res = mysql_query($delbackquery);
  294. }
  295. }
  296. $this->redirect($_SERVER['HTTP_REFERER']);
  297. }
  298. function deletebackdrop($usertype=null,$userId=null)
  299. {
  300. if($usertype)
  301. {
  302. if($usertype=='admin' && $userId>0)
  303. {
  304. $delbackquery = "DELETE FROM backdrops where is_admin='Yes' and user_id='".$userId."'";
  305. $delbackquery_res = mysql_query($delbackquery);
  306. }
  307. else
  308. {
  309. if($usertype=='user' && $userId>0)
  310. {
  311. $delbackquery = "DELETE FROM backdrops where is_admin='No' and user_id='".$userId."'";
  312. $delbackquery_res = mysql_query($delbackquery);
  313. }
  314. }
  315. }
  316. $this->redirect($_SERVER['HTTP_REFERER']);
  317. }
  318. function add_musicstep2()
  319. {
  320. $this->checkSession();
  321. $this->layout = 'default_user';
  322. }
  323. function delete_musicgroup($id=null)
  324. {
  325. $this->checkSession();
  326. if(isset($_REQUEST['box']))
  327. {
  328. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  329. $arr = $_REQUEST['box'];
  330. foreach($arr as $key => $value)
  331. {
  332. $sql_det = "delete from `backdrops` where `user_id` = '".$value."'";
  333. $res_det = mysql_query($sql_det);
  334. }
  335. }
  336. ////IF DELETE IS FOR A SPECIFIC USER////
  337. else
  338. {
  339. $user_id=$_REQUEST['id'];
  340. $this->data['Music']['menu'] = $_REQUEST['menu'];
  341. $sql_det = "delete from `backdrops` where `user_id` = '".$user_id."'";
  342. $res_det = mysql_query($sql_det);
  343. }
  344. //$user_id=$_REQUEST['id'];
  345. $this->data['Music']['menu'] = $_REQUEST['menu'];
  346. if(isset($_REQUEST['page']))
  347. {
  348. $page = $_REQUEST['page'];
  349. }
  350. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  351. $this->redirect('/backdrop/managebackdrop');
  352. }
  353. function managehotmusic()
  354. {
  355. $this->checkSession();
  356. $this->layout = 'default_user';
  357. }
  358. function edithotmusic()
  359. {
  360. $this->checkSession();
  361. $this->layout = 'default_user';
  362. $music_cat = array();
  363. $music_cat[0] = "Select Category";
  364. $select_music_category = mysql_query("Select * from music_categories");
  365. while($select_music_category_res = mysql_fetch_array($select_music_category))
  366. {
  367. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  368. }
  369. $this->set('music_category',$music_cat);
  370. }
  371. function saveedithotmusic()
  372. {
  373. $update_sql = "Update music_hot set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
  374. mysql_query($update_sql);
  375. $this->redirect('/musics/edithotmusicphoto?id='.$_REQUEST['hid']);
  376. }
  377. function edithotmusicphoto()
  378. {
  379. $this->checkSession();
  380. $this->layout = 'default_user';
  381. }
  382. function listenhotmusic()
  383. {
  384. $this->checkSession();
  385. $this->layout = 'default_user';
  386. }
  387. function delhotmusic()
  388. {
  389. $this->checkSession();
  390. $this->layout = 'default_user';
  391. /* delete hot music */
  392. $delhot = mysql_query("Delete From music_hot where id=".$_REQUEST['id']."");
  393. $this->redirect('/musics/managehotmusic?menu='.$_REQUEST['menu']);
  394. }
  395. function delete_hotmusicgroup()
  396. {
  397. $this->checkSession();
  398. if(isset($_REQUEST['box']))
  399. {
  400. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  401. $arr = $_REQUEST['box'];
  402. foreach($arr as $key => $value)
  403. {
  404. $sql_det = "delete from `music_hot` where `id` = '".$value."'";
  405. $res_det = mysql_query($sql_det);
  406. }
  407. }
  408. ////IF DELETE IS FOR A SPECIFIC USER////
  409. else
  410. {
  411. $user_id=$_REQUEST['id'];
  412. $this->data['Music']['menu'] = $_REQUEST['menu'];
  413. $sql_det = "delete from `music_hot` where `id` = '".$user_id."'";
  414. $res_det = mysql_query($sql_det);
  415. }
  416. //$user_id=$_REQUEST['id'];
  417. $this->data['Music']['menu'] = $_REQUEST['menu'];
  418. if(isset($_REQUEST['page']))
  419. {
  420. $page = $_REQUEST['page'];
  421. }
  422. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  423. $this->redirect('/musics/managehotmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
  424. }
  425. function add_hotmusic()
  426. {
  427. $this->checkSession();
  428. $this->layout = 'default_user';
  429. /* Grtting the Music caltegory*/
  430. $music_cat = array();
  431. $music_cat[0] = "Select Category";
  432. $select_music_category = mysql_query("Select * from music_categories");
  433. while($select_music_category_res = mysql_fetch_array($select_music_category))
  434. {
  435. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  436. }
  437. $this->set('music_category',$music_cat);
  438. }
  439. function addhotmusicstep2()
  440. {
  441. $this->checkSession();
  442. $this->layout = 'default_user';
  443. //pr($_REQUEST);
  444. /* Insert into table name */
  445. $inserhot = "INSERT INTO `music_hot` ( `id` , `title` , `music_desc` , `file_name` , `url` , `music_id` )
  446. VALUES ('', '".$_REQUEST['hottitle']."', '', '', '', '".$_REQUEST['musicinfo']."')" ;
  447. $inserhot_res = mysql_query($inserhot);
  448. $inserhot_res_id = mysql_insert_id();
  449. $this->redirect('/musics/edithotmusicphoto?id='.$inserhot_res_id);
  450. }
  451. function managefeaturedmusic()
  452. {
  453. $this->checkSession();
  454. $this->layout = 'default_user';
  455. }
  456. function delete_featuredmusicgroup()
  457. {
  458. $this->checkSession();
  459. if(isset($_REQUEST['box']))
  460. {
  461. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  462. $arr = $_REQUEST['box'];
  463. foreach($arr as $key => $value)
  464. {
  465. $sql_det = "delete from `music_featured` where `id` = '".$value."'";
  466. $res_det = mysql_query($sql_det);
  467. }
  468. }
  469. ////IF DELETE IS FOR A SPECIFIC USER////
  470. else
  471. {
  472. $user_id=$_REQUEST['id'];
  473. $this->data['Music']['menu'] = $_REQUEST['menu'];
  474. $sql_det = "delete from `music_featured` where `id` = '".$user_id."'";
  475. $res_det = mysql_query($sql_det);
  476. }
  477. //$user_id=$_REQUEST['id'];
  478. $this->data['Music']['menu'] = $_REQUEST['menu'];
  479. if(isset($_REQUEST['page']))
  480. {
  481. $page = $_REQUEST['page'];
  482. }
  483. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  484. $this->redirect('/musics/managefeaturedmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
  485. }
  486. function delfeaturedmusic()
  487. {
  488. $this->checkSession();
  489. $this->layout = 'default_user';
  490. /* delete hot music */
  491. $delhot = mysql_query("Delete From music_featured where id=".$_REQUEST['id']."");
  492. $this->redirect('/musics/managefeaturedmusic?menu='.$_REQUEST['menu']);
  493. }
  494. function listenfeaturedmusic()
  495. {
  496. $this->checkSession();
  497. $this->layout = 'default_user';
  498. }
  499. function editfeaturedmusic()
  500. {
  501. $this->checkSession();
  502. $this->layout = 'default_user';
  503. $music_cat = array();
  504. $music_cat[0] = "Select Category";
  505. $select_music_category = mysql_query("Select * from music_categories");
  506. while($select_music_category_res = mysql_fetch_array($select_music_category))
  507. {
  508. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  509. }
  510. $this->set('music_category',$music_cat);
  511. }
  512. function saveeditfeaturedmusic()
  513. {
  514. $update_sql = "Update music_featured set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
  515. mysql_query($update_sql);
  516. $this->redirect('/musics/editfeaturedmusicphoto?id='.$_REQUEST['hid']);
  517. }
  518. function editfeaturedmusicphoto()
  519. {
  520. $this->checkSession();
  521. $this->layout = 'default_user';
  522. }
  523. function managemusiccategory()
  524. {
  525. $this->checkSession();
  526. $this->layout = 'default_user';
  527. }
  528. function editbackdropcategory()
  529. {
  530. $this->checkSession();
  531. $this->layout = 'default_user';
  532. /* Get the category name*/
  533. $category_sql = "select * from backdrop_categories where id=".$_REQUEST['id']."";
  534. $category_res = mysql_fetch_array(mysql_query($category_sql));
  535. $this->set('catname', $category_res['backdrop_cat_name']);
  536. $this->set('catid', $category_res['id']);
  537. /**/
  538. }
  539. function saveeditcategory()
  540. {
  541. $this->checkSession();
  542. $this->layout = 'default_user';
  543. /* Updation Table name */
  544. if($_REQUEST['cattitle']!="")
  545. {
  546. $update_sql = "Update backdrop_categories set backdrop_cat_name='".addslashes($_REQUEST['cattitle'])."' where id = ".$_REQUEST['cid']."";
  547. mysql_query($update_sql);
  548. }
  549. $this->redirect('/backdrop/managebackdropcategory');
  550. /**/
  551. }
  552. function add_backdrop_category()
  553. {
  554. $this->checkSession();
  555. $this->layout = 'default_user';
  556. }
  557. function savenewcategory()
  558. {
  559. $this->checkSession();
  560. $this->layout = 'default_user';
  561. /* Updation Table name */
  562. if($_REQUEST['cattitle']!="")
  563. {
  564. $update_sql = "insert into backdrop_categories set backdrop_cat_name='".addslashes($_REQUEST['cattitle'])."'";
  565. mysql_query($update_sql);
  566. $catid = mysql_insert_id();
  567. }
  568. $this->redirect('/backdrop/managebackdropcategory');
  569. /**/
  570. }
  571. function managebackdropshipping()
  572. {
  573. $this->checkSession();
  574. $this->layout = 'default_user';
  575. if(isset($_REQUEST['pageaction']) && $_REQUEST['pageaction']!='')
  576. {
  577. if($_REQUEST['pageaction']=='block')
  578. {
  579. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  580. {
  581. $updatesql = "UPDATE backdrop_shipping_master set blocked='1' where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  582. $updatesql_res = mysql_query($updatesql);
  583. }
  584. }
  585. if($_REQUEST['pageaction']=='unblock')
  586. {
  587. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  588. {
  589. $updatesql = "UPDATE backdrop_shipping_master set blocked='0' where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  590. $updatesql_res = mysql_query($updatesql);
  591. }
  592. }
  593. if($_REQUEST['pageaction']=='delete')
  594. {
  595. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  596. {
  597. $updatesql = "DELETE from backdrop_shipping_list where backdrop_shipping_master_id='".$boxvalue."' and user_id='".$_SESSION['Admin_id']."'";
  598. $updatesql_res = mysql_query($updatesql);
  599. $updatesql = "DELETE from backdrop_shipping_master where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  600. $updatesql_res = mysql_query($updatesql);
  601. }
  602. }
  603. }
  604. }
  605. function editshippingcategory($shipid=null)
  606. {
  607. $this->checkSession();
  608. $this->layout = 'default_user';
  609. /* Shipping information */
  610. $shipcatsql = " SELECT * from backdrop_shipping_master where id='".base64_decode($shipid)."'";
  611. $shipcatsql_res = mysql_query($shipcatsql);
  612. $shipcatsql_arr = mysql_fetch_array($shipcatsql_res);
  613. $this->set('categoryName',$shipcatsql_arr['order_name']);
  614. $this->set('categoryDesc',$shipcatsql_arr['order_desc']);
  615. $this->set('categoryId',$shipcatsql_arr['id']);
  616. }
  617. function copyshippingcategory($shipid=null)
  618. {
  619. $this->checkSession();
  620. $this->layout = 'default_user';
  621. /* Shipping information */
  622. $shipcatsql = " SELECT * from backdrop_shipping_master where id='".base64_decode($shipid)."'";
  623. $shipcatsql_res = mysql_query($shipcatsql);
  624. $shipcatsql_arr = mysql_fetch_array($shipcatsql_res);
  625. $this->set('categoryName','Copy of '.$shipcatsql_arr['order_name']);
  626. $this->set('categoryDesc',$shipcatsql_arr['order_desc']);
  627. $this->set('categoryId',$shipcatsql_arr['id']);
  628. }
  629. function savecreatebackdropshipping()
  630. {
  631. $this->checkSession();
  632. $this->layout = 'default_user';
  633. if(isset($_REQUEST['shipcat']) && strlen($_REQUEST['shipcat'])>0)
  634. {
  635. $updatesql = "INSERT INTO backdrop_shipping_master set order_name='".addslashes($_REQUEST['shipcat'])."' ,order_desc='".addslashes($_REQUEST['shipcatdesc'])."', is_admin='1' , user_id='".$_SESSION['Admin_id']."'";
  636. $updatesql_res = mysql_query($updatesql);
  637. }
  638. $this->redirect('/backdrop/managebackdropshipping');
  639. }
  640. function savebackdropshipping()
  641. {
  642. $this->checkSession();
  643. $this->layout = 'default_user';
  644. if(isset($_REQUEST['shipcat']) && strlen($_REQUEST['shipcat'])>0)
  645. {
  646. if(isset($_REQUEST['catid']) && $_REQUEST['catid']>0)
  647. {
  648. $updatesql = "UPDATE backdrop_shipping_master set order_name='".addslashes($_REQUEST['shipcat'])."' ,order_desc='".addslashes($_REQUEST['shipcatdesc'])."' where id='".$_REQUEST['catid']."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  649. $updatesql_res = mysql_query($updatesql);
  650. }
  651. }
  652. $this->redirect('/backdrop/managebackdropshipping');
  653. }
  654. function savecopybackdropshipping()
  655. {
  656. $this->checkSession();
  657. $this->layout = 'default_user';
  658. $catauth = "select * from backdrop_shipping_master where user_id = ".$_SESSION['Admin_id']." and order_name='".addslashes($_REQUEST['shipcat'])."'";
  659. $cataut_res = mysql_query($catauth);
  660. if(mysql_num_rows($cataut_res)==0)
  661. {
  662. if($_REQUEST['shipcat']!="")
  663. {
  664. $insert_sql = "Insert Into backdrop_shipping_master set is_admin='1',user_id= ".$_SESSION['Admin_id'].",order_name='".addslashes($_REQUEST['shipcat'])."', order_desc='".addslashes($_REQUEST['shipcatdesc'])."'";
  665. mysql_query($insert_sql);
  666. $newship = mysql_insert_id();
  667. if(isset($_REQUEST['catid']) && $_REQUEST['catid']!="")
  668. {
  669. $copyProduct = "INSERT INTO backdrop_shipping_list(backdrop_shipping_master_id,user_id,ship_name,ship_product_name,ship_price_from,ship_price_to,ship_postage)
  670. SELECT '$newship',user_id,ship_name,ship_product_name,ship_price_from,ship_price_to,ship_postage
  671. FROM backdrop_shipping_list where backdrop_shipping_master_id=".$_REQUEST['catid']."";
  672. mysql_query($copyProduct) ;
  673. }
  674. }
  675. }
  676. $this->redirect('/backdrop/managebackdropshipping');
  677. }
  678. function blockshippingcategory($backdrpid=null,$backdropstatus=null)
  679. {
  680. $this->checkSession();
  681. $this->layout = 'default_user';
  682. if($backdropstatus=='block')
  683. {
  684. $updatesql = "UPDATE backdrop_shipping_master set blocked='1' where id='".base64_decode($backdrpid)."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  685. $updatesql_res = mysql_query($updatesql);
  686. }
  687. else
  688. {
  689. $updatesql = "UPDATE backdrop_shipping_master set blocked='0' where id='".base64_decode($backdrpid)."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  690. $updatesql_res = mysql_query($updatesql);
  691. }
  692. $this->redirect('/backdrop/managebackdropshipping');
  693. }
  694. function delshippingcategory($backdrpid=null)
  695. {
  696. $this->checkSession();
  697. $this->layout = 'default_user';
  698. $updatesql = "DELETE from backdrop_shipping_list where backdrop_shipping_master_id='".base64_decode($backdrpid)."' and user_id='".$_SESSION['Admin_id']."'";
  699. $updatesql_res = mysql_query($updatesql);
  700. $updatesql = "DELETE from backdrop_shipping_master where id='".base64_decode($backdrpid)."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  701. $updatesql_res = mysql_query($updatesql);
  702. $this->redirect('/backdrop/managebackdropshipping');
  703. }
  704. function createshipping()
  705. {
  706. $this->checkSession();
  707. $this->layout = 'default_user';
  708. }
  709. function shippinglist($baccatid=null)
  710. {
  711. $this->checkSession();
  712. $this->layout = 'default_user';
  713. $this->set('catid', $baccatid );
  714. if(isset($_REQUEST['pageaction']) && $_REQUEST['pageaction']=='delete')
  715. {
  716. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  717. {
  718. $updatesql = "DELETE from backdrop_shipping_list where id='".$boxvalue."' and user_id='".$_SESSION['Admin_id']."'";
  719. $updatesql_res = mysql_query($updatesql);
  720. }
  721. }
  722. }
  723. function createshippinglist($catid=null)
  724. {
  725. $this->checkSession();
  726. $this->layout = 'default_user';
  727. $this->set('shipcatid', $catid);
  728. }
  729. function savecreatebackdropshippinglist()
  730. {
  731. $this->checkSession();
  732. $this->layout = 'default_user';
  733. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_from']." between ship_price_from and ship_price_to";
  734. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  735. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  736. if($_POST['price_to']!="")
  737. {
  738. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_to']." between ship_price_from and ship_price_to";
  739. $ResCheckDiscTo = mysql_query($selectShipping) or die('Line No 360');
  740. $NumResCheckDiscTo = mysql_num_rows($ResCheckDiscTo);
  741. }
  742. else
  743. $NumResCheckDiscTo = 0;
  744. if($_POST['price_to']=="")
  745. $_POST['price_to'] = 0;
  746. if($NumResCheckDiscFrom==0 && $NumResCheckDiscTo==0)
  747. {
  748. $sql_insert_discount = "INSERT into backdrop_shipping_list SET backdrop_shipping_master_id = ".$_REQUEST['editshipcat'].",ship_product_name = '".$_REQUEST['shipproduct']."' , ship_price_from=".$_POST['price_from'].",ship_price_to=".$_POST['price_to'].",ship_postage=".$_POST['shipping_postage'].",user_id=".$_SESSION['Admin_id']."";
  749. $res_insert_discount = mysql_query($sql_insert_discount) or die(mysql_error().'Line No 40') ;
  750. $mid=mysql_insert_id();
  751. }
  752. $backUrl = "backdrop/shippinglist/".base64_encode($_REQUEST['editshipcat']) ;
  753. $this->redirect($backUrl);
  754. }
  755. function editshippingcategorylist($bacshipid=null)
  756. {
  757. $this->checkSession();
  758. $this->layout = 'default_user';
  759. $catauth = "select * from backdrop_shipping_list where id=".base64_decode($bacshipid)."";
  760. $cataut_res = mysql_query($catauth);
  761. $catauth_arr = mysql_fetch_array($cataut_res);
  762. $shipname = $catauth_arr['ship_name'];
  763. $shipprodname = $catauth_arr['ship_product_name'];
  764. $shippricefrom = $catauth_arr['ship_price_from'];
  765. $shippriceto = $catauth_arr['ship_price_to'];
  766. $shippostage = $catauth_arr['ship_postage'];
  767. $shipcatid = $catauth_arr['backdrop_shipping_master_id'];
  768. $this->set('shipName',$shipname);
  769. $this->set('shipprodname',$shipprodname);
  770. $this->set('shipprfrm',$shippricefrom);
  771. $this->set('shipprto',$shippriceto);
  772. $this->set('shippost',$shippostage);
  773. $this->set('shipcatid',$shipcatid);
  774. $this->set('shiprecid',base64_decode($bacshipid));
  775. }
  776. function saveeditbackdropshippinglist()
  777. {
  778. $this->checkSession();
  779. $this->layout = 'default_user';
  780. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_from']." between ship_price_from and ship_price_to and id!=".$_REQUEST['recordid']."";
  781. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  782. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  783. if($_POST['price_to']!="")
  784. {
  785. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_to']." between ship_price_from and ship_price_to and id!=".$_REQUEST['recordid']."";
  786. $ResCheckDiscTo = mysql_query($selectShipping) or die('Line No 360');
  787. $NumResCheckDiscTo = mysql_num_rows($ResCheckDiscTo);
  788. }
  789. else
  790. $NumResCheckDiscTo = 0;
  791. if($_POST['price_to']=="")
  792. $_POST['price_to'] = 0;
  793. if($NumResCheckDiscFrom==0 && $NumResCheckDiscTo==0)
  794. {
  795. $order_sql = mysql_query("Select order_name from backdrop_shipping_master where id=".$_REQUEST['editshipcat']."") or die(mysql_error());
  796. $arr_order = mysql_fetch_array($order_sql);
  797. $sql_insert_discount = "Update backdrop_shipping_list SET backdrop_shipping_master_id = ".$_REQUEST['editshipcat'].", ship_product_name = '".$_REQUEST['shipproduct']."' , ship_price_from=".$_POST['price_from'].",ship_price_to=".$_POST['price_to'].",ship_postage=".$_POST['shipping_postage']." where id=".$_REQUEST['recordid']." and user_id=".$_SESSION['Admin_id']."";
  798. $res_insert_discount = mysql_query($sql_insert_discount) or die('Line No 40') ;
  799. }
  800. $backUrl = "backdrop/shippinglist/".base64_encode($_REQUEST['editshipcat'] );
  801. $this->redirect($backUrl);
  802. }
  803. function copyshippingcategorylist($bacshipid=null)
  804. {
  805. $this->checkSession();
  806. $this->layout = 'default_user';
  807. $catauth = "select * from backdrop_shipping_list where id=".base64_decode($bacshipid)."";
  808. $cataut_res = mysql_query($catauth);
  809. $catauth_arr = mysql_fetch_array($cataut_res);
  810. $shipname = $catauth_arr['ship_name'];
  811. $shipprodname = $catauth_arr['ship_product_name'];
  812. $shippricefrom = $catauth_arr['ship_price_from'];
  813. $shippriceto = $catauth_arr['ship_price_to'];
  814. $shippostage = $catauth_arr['ship_postage'];
  815. $shipcatid = $catauth_arr['backdrop_shipping_master_id'];
  816. $this->set('shipName',$shipname);
  817. $this->set('shipprodName',$shipprodname);
  818. $this->set('shipprfrm',$shippricefrom);
  819. $this->set('shipprto',$shippriceto);
  820. $this->set('shippost',$shippostage);
  821. $this->set('shipcatid',$shipcatid);
  822. $this->set('shiprecid',base64_decode($bacshipid));
  823. }
  824. function savecopybackdropshippinglist()
  825. {
  826. $this->checkSession();
  827. $this->layout = 'default_user';
  828. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_from']." between ship_price_from and ship_price_to and id!=".$_REQUEST['recordid']."";
  829. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  830. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  831. if($_POST['price_to']!="")
  832. {
  833. $selectShipping = "Select * from backdrop_shipping_list where user_id=".$_SESSION['Admin_id']." and backdrop_shipping_master_id = ".$_REQUEST['editshipcat']." and ship_product_name = '".$_REQUEST['shipproduct']."' and ".$_POST['price_to']." between ship_price_from and ship_price_to and id!=".$_REQUEST['recordid']."";
  834. $ResCheckDiscTo = mysql_query($selectShipping) or die('Line No 360');
  835. $NumResCheckDiscTo = mysql_num_rows($ResCheckDiscTo);
  836. }
  837. else
  838. $NumResCheckDiscTo = 0;
  839. if($_POST['price_to']=="")
  840. $_POST['price_to'] = 0;
  841. if($NumResCheckDiscFrom==0 && $NumResCheckDiscTo==0)
  842. {
  843. $sql_insert_discount = "INSERT into backdrop_shipping_list SET backdrop_shipping_master_id = ".$_REQUEST['editshipcat'].",ship_product_name = '".$_REQUEST['shipproduct']."',ship_price_from=".$_POST['price_from'].",ship_price_to=".$_POST['price_to'].",ship_postage=".$_POST['shipping_postage'].",user_id=".$_SESSION['Admin_id']."";
  844. $res_insert_discount = mysql_query($sql_insert_discount) or die('Line No 40') ;
  845. $mid=mysql_insert_id();
  846. }
  847. $backUrl = "backdrop/shippinglist/".base64_encode($_REQUEST['editshipcat']) ;
  848. $this->redirect($backUrl);
  849. }
  850. function delshippingcategorylist($shipid = null)
  851. {
  852. $this->checkSession();
  853. $this->layout = 'default_user';
  854. if($shipid)
  855. {
  856. $delqury = "DELETE from backdrop_shipping_list where id='".base64_decode($shipid)."' and user_id='".$_SESSION['Admin_id']."'";
  857. mysql_query($delqury);
  858. }
  859. $this->redirect($_SERVER['HTTP_REFERER']);
  860. }
  861. function managebackdropsaletax()
  862. {
  863. $this->checkSession();
  864. $this->layout = 'default_user';
  865. if(isset($this->data['Sale']['tax']))
  866. {
  867. mysql_query("UPDATE backdrop_saletax SET tax='".$this->data['Sale']['tax']."' WHERE user_id='".$this->data['Sale']['uid']."' AND is_admin='1' AND state_id='".$this->data['Sale']['sid']."'") or die(mysql_error());
  868. }
  869. $saletaxarr = array();
  870. $sqlsatetax = "select countries.id , countries.country_name , backdrop_saletax.user_id from backdrop_saletax , state , countries where user_id = ".$_SESSION['Admin_id']." and is_admin='1' and state_id=state.id and state.c_id=countries.id Group by countries.id";
  871. $sqlsatetax_res = mysql_query($sqlsatetax);
  872. $sqlsatetax_num = mysql_num_rows($sqlsatetax_res);
  873. if($sqlsatetax_num > 0)
  874. {
  875. while($sqlsatetax_res_arr = mysql_fetch_array($sqlsatetax_res))
  876. {
  877. $saletaxarr[$sqlsatetax_res_arr['id']] = $sqlsatetax_res_arr['country_name'] ;
  878. }
  879. }
  880. $this->set('saltaxnum', $sqlsatetax_num);
  881. $this->set('saltaxinfo', $saletaxarr);
  882. }
  883. function savesaletax()
  884. {
  885. $this->checkSession();
  886. $this->layout = 'default_user';
  887. $this->pageTitle = 'Sale Tax';
  888. $stateTax = $_REQUEST['saletax'] ;
  889. foreach($stateTax as $stateTax_index=> $stateTax_value )
  890. {
  891. if(isset($_REQUEST['saletax'][$stateTax_index]) && $_REQUEST['saletax'][$stateTax_index]!="")
  892. {
  893. $mynumber = $_REQUEST['saletax'][$stateTax_index] ;
  894. if($mynumber>0)
  895. {
  896. if (preg_match ("/^([0-9.,-]+)$/", $mynumber)) {
  897. /* Saving in the sale tax */
  898. $selectrec = "select * from backdrop_saletax where user_id = ".$_SESSION['Admin_id']." and state_id = ".$stateTax_index." and is_admin='1'" ;
  899. $selectrec_res = mysql_query($selectrec);
  900. if(mysql_num_rows($selectrec_res)>0)
  901. {
  902. $saletaxsql = "Update backdrop_saletax SET tax = ".$mynumber." where user_id = ".$_SESSION['Admin_id']." and state_id = ".$stateTax_index." and is_admin='1'" ;
  903. }
  904. else
  905. {
  906. $saletaxsql = "INSERT INTO backdrop_saletax SET tax = ".$mynumber." , user_id = ".$_SESSION['Admin_id']." , state_id = ".$stateTax_index.",is_admin='1'" ;
  907. }
  908. mysql_query($saletaxsql)or die(mysql_error());
  909. /* */
  910. }
  911. }
  912. }
  913. }
  914. $redirectURL = "backdrop/managebackdropsaletax";
  915. $this->redirect($redirectURL);
  916. }
  917. function activeshippingcategory($backdropid)
  918. {
  919. if(base64_decode($backdropid)>0)
  920. {
  921. $updateqry = "UPDATE backdrop_shipping_master SET is_active='1' Where user_id='".$_SESSION['Admin_id']."' and is_admin='1' and id='".base64_decode($backdropid)."'";
  922. $updateqry_res = mysql_query($updateqry);
  923. }
  924. else
  925. {
  926. $updateqry = "UPDATE backdrop_shipping_master SET is_active='0' Where user_id='".$_SESSION['Admin_id']."' and is_admin='1' and id!='".base64_decode($backdropid)."'";
  927. $updateqry_res = mysql_query($updateqry);
  928. }
  929. $redirectURL = "backdrop/managebackdropshipping";
  930. $this->redirect($redirectURL);
  931. }
  932. function managebackdropproduct()
  933. {
  934. $this->checkSession();
  935. $this->layout = 'default_user';
  936. if(isset($_REQUEST['pageaction']) && $_REQUEST['pageaction']!='')
  937. {
  938. if($_REQUEST['pageaction']=='block')
  939. {
  940. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  941. {
  942. $updatesql = "UPDATE backdrop_product_master set blocked='1' where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  943. $updatesql_res = mysql_query($updatesql);
  944. }
  945. }
  946. if($_REQUEST['pageaction']=='unblock')
  947. {
  948. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  949. {
  950. $updatesql = "UPDATE backdrop_product_master set blocked='0' where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  951. $updatesql_res = mysql_query($updatesql);
  952. }
  953. }
  954. if($_REQUEST['pageaction']=='delete')
  955. {
  956. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  957. {
  958. $updatesql = "DELETE from backdrop_product_list where backdrop_shipping_master_id='".$boxvalue."' and user_id='".$_SESSION['Admin_id']."'";
  959. $updatesql_res = mysql_query($updatesql);
  960. $updatesql = "DELETE from backdrop_product_master where id='".$boxvalue."' and is_admin='1' and user_id='".$_SESSION['Admin_id']."'";
  961. $updatesql_res = mysql_query($updatesql);
  962. }
  963. }
  964. }
  965. }
  966. function editproductcategory($shipid=null)
  967. {
  968. $this->checkSession();
  969. $this->layout = 'default_user';
  970. /* Shipping information */
  971. $shipcatsql = " SELECT * from backdrop_product_master where id='".base64_decode($shipid)."'";
  972. $shipcatsql_res = mysql_query($shipcatsql);
  973. $shipcatsql_arr = mysql_fetch_array($shipcatsql_res);
  974. $this->set('categoryName',$shipcatsql_arr['order_name']);
  975. $this->set('categoryDesc',$shipcatsql_arr['order_desc']);
  976. $this->set('categoryId',$shipcatsql_arr['id']);
  977. }
  978. function saveeditproductcategory()
  979. {
  980. $this->checkSession();
  981. $this->layout = 'default_user';
  982. /* Updation Table name */
  983. if($_REQUEST['cattitle']!="")
  984. {
  985. echo $update_sql = "Update backdrop_product_master set order_name='".addslashes($_REQUEST['cattitle'])."',order_desc='".addslashes($_REQUEST['prodcatdesc'])."' where id = ".$_REQUEST['cid']."";
  986. mysql_query($update_sql);
  987. }
  988. $this->redirect('/backdrop/managebackdropproduct');
  989. /**/
  990. }
  991. function copyproductcategory($shipid=null)
  992. {
  993. $this->checkSession();
  994. $this->layout = 'default_user';
  995. /* Shipping information */
  996. $shipcatsql = " SELECT * from backdrop_product_master where id='".base64_decode($shipid)."'";
  997. $shipcatsql_res = mysql_query($shipcatsql);
  998. $shipcatsql_arr = mysql_fetch_array($shipcatsql_res);
  999. $this->set('categoryName','Copy of '.$shipcatsql_arr['order_name']);
  1000. $this->set('categoryDesc',$shipcatsql_arr['order_desc']);
  1001. $this->set('categoryId',$shipcatsql_arr['id']);
  1002. }
  1003. function savecopybackdropproduct()
  1004. {
  1005. $this->checkSession();
  1006. $this->layout = 'default_user';
  1007. $catauth = "select * from backdrop_product_master where order_name='".addslashes($_REQUEST['shipcat'])."'";
  1008. $cataut_res = mysql_query($catauth);
  1009. if(mysql_num_rows($cataut_res)==0)
  1010. {
  1011. if($_REQUEST['shipcat']!="")
  1012. {
  1013. $insert_sql = "Insert Into backdrop_product_master SET order_name='".addslashes($_REQUEST['shipcat'])."', order_desc='".addslashes($_REQUEST['shipcatdesc'])."'";
  1014. mysql_query($insert_sql);
  1015. $newship = mysql_insert_id();
  1016. if(isset($_REQUEST['catid']) && $_REQUEST['catid']!="")
  1017. {
  1018. $copyProduct = "INSERT INTO backdrop_product_list(backdrop_product_master_id,product_name,product_desc,price)
  1019. SELECT '$newship',product_name,product_desc,price
  1020. FROM backdrop_product_list where backdrop_product_master_id=".$_REQUEST['catid']."";
  1021. mysql_query($copyProduct) ;
  1022. }
  1023. }
  1024. }
  1025. $this->redirect('/backdrop/managebackdropproduct');
  1026. }
  1027. function blockproductcategory($backdrpid=null,$backdropstatus=null)
  1028. {
  1029. $this->checkSession();
  1030. $this->layout = 'default_user';
  1031. if($backdropstatus=='block')
  1032. {
  1033. $updatesql = "UPDATE backdrop_product_master set blocked='1' where id='".base64_decode($backdrpid)."'";
  1034. $updatesql_res = mysql_query($updatesql);
  1035. }
  1036. else
  1037. {
  1038. $updatesql = "UPDATE backdrop_product_master set blocked='0' where id='".base64_decode($backdrpid)."'";
  1039. $updatesql_res = mysql_query($updatesql);
  1040. }
  1041. $this->redirect('/backdrop/managebackdropproduct');
  1042. }
  1043. function delproductcategory($backdrpid=null)
  1044. {
  1045. $this->checkSession();
  1046. $this->layout = 'default_user';
  1047. $updatesql = "DELETE from backdrop_product_list where backdrop_shipping_master_id='".base64_decode($backdrpid)."'";
  1048. $updatesql_res = mysql_query($updatesql);
  1049. $updatesql = "DELETE from backdrop_product_master where id='".base64_decode($backdrpid)."'";
  1050. $updatesql_res = mysql_query($updatesql);
  1051. $this->redirect('/backdrop/managebackdropproduct');
  1052. }
  1053. function createproductcategory()
  1054. {
  1055. $this->checkSession();
  1056. $this->layout = 'default_user';
  1057. }
  1058. function savecreatebackdropproduct()
  1059. {
  1060. $this->checkSession();
  1061. $this->layout = 'default_user';
  1062. if(isset($_REQUEST['shipcat']) && strlen($_REQUEST['shipcat'])>0)
  1063. {
  1064. $updatesql = "INSERT INTO backdrop_product_master set order_name='".addslashes($_REQUEST['shipcat'])."' ,order_desc='".addslashes($_REQUEST['shipcatdesc'])."'";
  1065. $updatesql_res = mysql_query($updatesql);
  1066. }
  1067. $this->redirect('/backdrop/managebackdropproduct');
  1068. }
  1069. function productlist($baccatid=null)
  1070. {
  1071. $this->checkSession();
  1072. $this->layout = 'default_user';
  1073. $this->set('catid', $baccatid );
  1074. if(isset($_REQUEST['pageaction']) && $_REQUEST['pageaction']=='delete')
  1075. {
  1076. foreach($_REQUEST['box'] as $boxindex=>$boxvalue)
  1077. {
  1078. $updatesql = "DELETE from backdrop_product_list where id='".$boxvalue."'";
  1079. $updatesql_res = mysql_query($updatesql);
  1080. }
  1081. }
  1082. }
  1083. function savecreatebackdropproductlist()
  1084. {
  1085. $this->checkSession();
  1086. $this->layout = 'default_user';
  1087. $selectShipping = "Select * from backdrop_product_list where backdrop_product_master_id = ".$_REQUEST['editshipcat']." and product_name = '".$_REQUEST['shipproduct']."'";
  1088. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  1089. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  1090. if($NumResCheckDiscFrom==0 )
  1091. {
  1092. $sql_insert_discount = "INSERT into backdrop_product_list SET backdrop_product_master_id = ".$_REQUEST['editshipcat'].",product_name = '".$_REQUEST['shipproduct']."'";
  1093. $res_insert_discount = mysql_query($sql_insert_discount) or die(mysql_error().'Line No 40') ;
  1094. $mid=mysql_insert_id();
  1095. }
  1096. $backUrl = "backdrop/productlist/".base64_encode($_REQUEST['editshipcat']) ;
  1097. $this->redirect($backUrl);
  1098. }
  1099. function createproductlist($catid=null)
  1100. {
  1101. $this->checkSession();
  1102. $this->layout = 'default_user';
  1103. $this->set('shipcatid', $catid);
  1104. }
  1105. function editshippingproductlist($bacshipid=null)
  1106. {
  1107. $this->checkSession();
  1108. $this->layout = 'default_user';
  1109. $catauth = "select * from backdrop_product_list where id=".base64_decode($bacshipid)."";
  1110. $cataut_res = mysql_query($catauth);
  1111. $catauth_arr = mysql_fetch_array($cataut_res);
  1112. $shipprodname = $catauth_arr['product_name'];
  1113. $shippricefrom = $catauth_arr['price'];
  1114. $shipcatid = $catauth_arr['backdrop_product_master_id'];
  1115. $this->set('prodName',$shipprodname);
  1116. $this->set('prodPrice',$shippricefrom);
  1117. $this->set('prodcatid',$shipcatid);
  1118. $this->set('prodrecid',base64_decode($bacshipid));
  1119. }
  1120. function saveeditbackdropproductlist()
  1121. {
  1122. $this->checkSession();
  1123. $this->layout = 'default_user';
  1124. $selectShipping = "Select * from backdrop_product_list where backdrop_product_master_id = ".$_REQUEST['editshipcat']." and product_name = '".$_REQUEST['shipproduct']."' and id!=".$_REQUEST['recordid']."";
  1125. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  1126. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  1127. if($NumResCheckDiscFrom==0)
  1128. {
  1129. $sql_insert_discount = "Update backdrop_product_list SET backdrop_product_master_id = ".$_REQUEST['editshipcat'].", product_name = '".$_REQUEST['shipproduct']."' where id=".$_REQUEST['recordid']."";
  1130. $res_insert_discount = mysql_query($sql_insert_discount) or die('Line No 40') ;
  1131. }
  1132. $backUrl = "backdrop/productlist/".base64_encode($_REQUEST['editshipcat'] );
  1133. $this->redirect($backUrl);
  1134. }
  1135. function copyshippingproductlist($bacshipid=null)
  1136. {
  1137. $this->checkSession();
  1138. $this->layout = 'default_user';
  1139. $catauth = "select * from backdrop_product_list where id=".base64_decode($bacshipid)."";
  1140. $cataut_res = mysql_query($catauth);
  1141. $catauth_arr = mysql_fetch_array($cataut_res);
  1142. $shipprodname = $catauth_arr['product_name'];
  1143. $shippricefrom = $catauth_arr['price'];
  1144. $shipcatid = $catauth_arr['backdrop_product_master_id'];
  1145. $this->set('prodName',$shipprodname);
  1146. $this->set('prodPrice',$shippricefrom);
  1147. $this->set('prodcatid',$shipcatid);
  1148. $this->set('prodrecid',base64_decode($bacshipid));
  1149. }
  1150. function savecopybackdropproductlist()
  1151. {
  1152. $this->checkSession();
  1153. $this->layout = 'default_user';
  1154. $selectShipping = "Select * from backdrop_product_list where backdrop_product_master_id = ".$_REQUEST['editshipcat']." and product_name = '".$_REQUEST['shipproduct']."' and id!=".$_REQUEST['recordid']."";
  1155. $ResCheckDiscFrom = mysql_query($selectShipping) or die('Line No 353');
  1156. $NumResCheckDiscFrom = mysql_num_rows($ResCheckDiscFrom);
  1157. if($NumResCheckDiscFrom==0)
  1158. {
  1159. $sql_insert_discount = "INSERT into backdrop_product_list SET backdrop_product_master_id = ".$_REQUEST['editshipcat'].",product_name = '".$_REQUEST['shipproduct']."'";
  1160. $res_insert_discount = mysql_query($sql_insert_discount) or die('Line No 40') ;
  1161. $mid=mysql_insert_id();
  1162. }
  1163. $backUrl = "backdrop/productlist/".base64_encode($_REQUEST['editshipcat']) ;
  1164. $this->redirect($backUrl);
  1165. }
  1166. function delshippingproductlist($shipid = null)
  1167. {
  1168. $this->checkSession();
  1169. $this->layout = 'default_user';
  1170. if($shipid)
  1171. {
  1172. $delqury = "DELETE from backdrop_product_list where id='".base64_decode($shipid)."'";
  1173. mysql_query($delqury);
  1174. }
  1175. $this->redirect($_SERVER['HTTP_REFERER']);
  1176. }
  1177. function backdropsales($backdropuserid=null)
  1178. {
  1179. //pr($this->data);
  1180. $this->checkSession();
  1181. $this->set('backdropuser',$backdropuserid);
  1182. $this->layout = 'default_user';
  1183. $this->pageTitle = 'Backdrop Sales';
  1184. //$this->backdropcategory();
  1185. $this->set("display","none");
  1186. $this->set("custOpen","Open");
  1187. $this->set("textMonth","month");
  1188. $this->set("textDay","day");
  1189. $this->set("textYear","year");
  1190. $this->set("textMonth2","month");
  1191. $this->set("textDay2","day");
  1192. $this->set("textYear2","year");
  1193. $this->set("textMonth_2","month");
  1194. $this->set("textDay_2","day");
  1195. $this->set("textYear_2","year");
  1196. $this->set("textMonth2_2","month");
  1197. $this->set("textDay2_2","day");
  1198. $this->set("textYear2_2","year");
  1199. $this->set("past");
  1200. $this->set("eventName");
  1201. $this->set("invoice");
  1202. $this->set("userId");
  1203. $this->set("fDate");
  1204. $this->set("tDate");
  1205. $this->set("dateErr");
  1206. if(isset($this->data['Backdrop']['eventname']) && ($this->data['Backdrop']['eventname'])!="")
  1207. { $this->set("display","block"); $this->set("eventName",$this->data['Backdrop']['eventname']); $this->data['Backdrop']['within']=""; }
  1208. if(isset($this->data['Backdrop']['invoice']) && ($this->data['Backdrop']['invoice'])!="")
  1209. { $this->set("display","block"); $this->set("invoice",$this->data['Backdrop']['invoice']); $this->data['Ticket']['within']=""; }
  1210. if(isset($this->data['Backdrop']['userid']) && ($this->data['Backdrop']['userid'])!="")
  1211. { $this->set("display","block"); $this->set("userId",$this->data['Backdrop']['userid']); $this->data['Backdrop']['within']=""; }
  1212. if(isset($this->data['Backdrop']['fyear']) && isset($this->data['Backdrop']['fmonth']) && isset($this->data['Backdrop']['fday']))
  1213. {
  1214. $fromDate=$this->data['Backdrop']['fyear']."-".$this->data['Backdrop']['fmonth']."-".$this->data['Backdrop']['fday'];
  1215. $len=strlen($fromDate);
  1216. if($len==10)
  1217. {
  1218. $this->set("textMonth",$this->data['Backdrop']['fmonth']);
  1219. $this->set("textDay",$this->data['Backdrop']['fday']);
  1220. $this->set("textYear",$this->data['Backdrop']['fyear']);
  1221. $this->set("display","block");
  1222. $this->data['Ticket']['within']="";
  1223. $dateF=date("Y-m-d",strtotime($this->data['Backdrop']['fyear']."-".$this->data['Backdrop']['fmonth']."-".$this->data['Backdrop']['fday']));
  1224. $this->set("fDate",$dateF);
  1225. }
  1226. else
  1227. if(($this->data['Backdrop']['fyear'])!="year" && ($this->data['Backdrop']['fmonth'])!="month" && ($this->data['Backdrop']['fday'])!="day")
  1228. {
  1229. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1230. }
  1231. }
  1232. if(isset($this->data['Backdrop']['tyear']) && isset($this->data['Backdrop']['tmonth']) && isset($this->data['Backdrop']['tday']))
  1233. {
  1234. $toDate=$this->data['Backdrop']['tyear']."-".$this->data['Backdrop']['tmonth']."-".$this->data['Backdrop']['tday'];
  1235. $len=strlen($toDate);
  1236. if($len==10)
  1237. {
  1238. $this->set("textMonth2",$this->data['Backdrop']['tmonth']);
  1239. $this->set("textDay2",$this->data['Backdrop']['tday']);
  1240. $this->set("textYear2",$this->data['Backdrop']['tyear']);
  1241. $this->set("display","block");
  1242. $this->data['Ticket']['within']="";
  1243. $dateT=date("Y-m-d",strtotime($this->data['Backdrop']['tyear']."-".$this->data['Backdrop']['tmonth']."-".$this->data['Backdrop']['tday']));
  1244. $this->set("tDate",$dateT);
  1245. }
  1246. else
  1247. if(($this->data['Backdrop']['tyear'])!="year" && ($this->data['Backdrop']['tmonth'])!="month" && ($this->data['Backdrop']['tday'])!="day")
  1248. {
  1249. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1250. }
  1251. }
  1252. if(isset($this->data['Backdrop']['radio']))
  1253. {
  1254. $this->set("radio",$this->data['Backdrop']['radio']);
  1255. if(isset($this->data['Backdrop']['radio']) && $this->data['Backdrop']['radio']==1)
  1256. {
  1257. if(isset($this->data['Backdrop']['within']))
  1258. {
  1259. $this->set("withinType",$this->data['Backdrop']['within']);
  1260. $week=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),(date("d")-7),date("Y")));
  1261. $month=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),(date("m")-1),date("d"),date("Y")));
  1262. $year=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),date("d"),(date("Y")-1)));
  1263. $date=date("Y-m-d");
  1264. if($this->data['Backdrop']['within']=="past")
  1265. { $this->set("curDate",$date); }
  1266. if($this->data['Backdrop']['within']=="week")
  1267. { $this->set("past",$week); $this->set("curDate",$date); }
  1268. if($this->data['Backdrop']['within']=="month")
  1269. { $this->set("past",$month); $this->set("curDate",$date); }
  1270. if($this->data['Backdrop']['within']=="year")
  1271. { $this->set("past",$year); $this->set("curDate",$date); }
  1272. }
  1273. }
  1274. if(isset($this->data['Backdrop']['radio']) && $this->data['Backdrop']['radio']==2)
  1275. {
  1276. $this->set("past");
  1277. $this->set("curDate");
  1278. $fromDate=$this->data['Backdrop']['fyear_2']."-".$this->data['Backdrop']['fmonth_2']."-".$this->data['Backdrop']['fday_2'];
  1279. $len=strlen($fromDate);
  1280. if($len==10)
  1281. {
  1282. $this->set("textMonth_2",$this->data['Backdrop']['fmonth_2']);
  1283. $this->set("textDay_2",$this->data['Backdrop']['fday_2']);
  1284. $this->set("textYear_2",$this->data['Backdrop']['fyear_2']);
  1285. //$this->set("display","block");
  1286. $this->data['Backdrop']['within']="";
  1287. $dateF=date("Y-m-d",strtotime($this->data['Backdrop']['fyear_2']."-".$this->data['Backdrop']['fmonth_2']."-".$this->data['Backdrop']['fday_2']));
  1288. $this->set("past",$dateF);
  1289. }
  1290. else
  1291. {
  1292. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1293. }
  1294. $toDate=$this->data['Backdrop']['tyear_2']."-".$this->data['Backdrop']['tmonth_2']."-".$this->data['Backdrop']['tday_2'];
  1295. $len=strlen($toDate);
  1296. if($len==10)
  1297. {
  1298. $this->set("textMonth2_2",$this->data['Backdrop']['tmonth_2']);
  1299. $this->set("textDay2_2",$this->data['Backdrop']['tday_2']);
  1300. $this->set("textYear2_2",$this->data['Backdrop']['tyear_2']);
  1301. //$this->set("display","block");
  1302. $this->data['Backdrop']['within']="";
  1303. $dateT=date("Y-m-d",strtotime($this->data['Backdrop']['tyear_2']."-".$this->data['Backdrop']['tmonth_2']."-".$this->data['Backdrop']['tday_2']));
  1304. $this->set("curDate",$dateT);
  1305. }
  1306. else
  1307. {
  1308. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1309. }
  1310. }
  1311. }
  1312. if(isset($this->params['url']['Page']))
  1313. {
  1314. $this->data['Backdrop']['page']=$this->params['url']['Page'];
  1315. $this->set("arg",$this->params['url']);
  1316. $this->render("backdrop_ajax","ajax");
  1317. }
  1318. }
  1319. function userbackdropsubmission()
  1320. {
  1321. $this->checkSession();
  1322. $this->layout = 'default_user';
  1323. $this->pageTitle = 'Backdrop Submission';
  1324. if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
  1325. $viewSearchType=$_REQUEST['hfsearch'];
  1326. /* FOR BACKDROP USER SUmission */
  1327. $select="SELECT backdrop_tickets.* , backdrops.backdrop_id as backdropcode ,backdrops.backdrop_image,backdrops.viewed,COUNT(backdrop_cart.id) as noofdownload";
  1328. $from=" FROM backdrop_tickets
  1329. LEFT JOIN backdrops On (backdrop_tickets.backdrop_id = backdrops.id)
  1330. LEFT JOIN backdrop_cart On (backdrop_cart.backdrop_id = backdrops.id and backdrop_cart.payflag='1')
  1331. LEFT JOIN users On ( backdrop_tickets.user_id = users.id)
  1332. ";
  1333. $where="WHERE 1 ";
  1334. $searchpass='';
  1335. if(isset($viewSearchType) && $viewSearchType=='code' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='')
  1336. {
  1337. $where.=" AND backdrops.backdrop_id like '%".$_REQUEST['txtsrch']."%' ";
  1338. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  1339. }
  1340. if(isset($viewSearchType) && $viewSearchType=='username')
  1341. {
  1342. $where.=" AND users.username like '%".$_REQUEST['txtsrch']."%'";
  1343. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  1344. }
  1345. if(isset($viewSearchType) && $viewSearchType=='daterange')
  1346. {
  1347. if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY')
  1348. {
  1349. $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
  1350. $urlfromdate = $_REQUEST['inpdatefrom'];
  1351. }
  1352. else
  1353. {
  1354. $eventFromDate=date("Y-m-d");
  1355. $urlfromdate = $_REQUEST['inpdatefrom'];
  1356. }
  1357. if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY')
  1358. {
  1359. $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
  1360. $urltodate = $_REQUEST['inpdateto'];
  1361. }
  1362. else
  1363. {
  1364. $eventToDate=date("Y-m-d");
  1365. $urltodate = $_REQUEST['inpdateto'];
  1366. }
  1367. $where.=" AND backdrop_tickets.creation between '".$eventFromDate."' and '".$eventToDate."' ";
  1368. $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
  1369. }
  1370. $others=" GROUP BY backdrops.id ORDER by backdrop_tickets.id desc,backdrop_tickets.status IN ('awaiting','approve','reject')";
  1371. // $PassParameter="";
  1372. $CountField="backdrop_tickets.id";
  1373. if(isset($viewSearchType) && $viewSearchType!='')
  1374. {
  1375. $PassParameter="&hfsearch=".$viewSearchType.$searchpass;
  1376. }
  1377. else
  1378. $PassParameter="";
  1379. $this->set("controller","backdrop");
  1380. $this->set("action","userbackdropsubmission");
  1381. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1382. if(isset($this->params['url']['Page']) || isset($viewSearchType))
  1383. {
  1384. $this->render("userbackdropsubmission2","ajax");
  1385. }
  1386. /**/
  1387. }
  1388. function userbackdroporder()
  1389. {
  1390. $this->checkSession();
  1391. $this->layout = 'default_user';
  1392. $this->pageTitle = 'Backdrop Order';
  1393. if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
  1394. $viewSearchType=$_REQUEST['hfsearch'];
  1395. /* FOR BACKDROP USER SUmission */
  1396. $select="SELECT transaction_backdrop.* , backdrops.backdrop_id as backdropcode ,backdrops.backdrop_image,backdrops.viewed,COUNT(backdrop_cart.id) as noofdownload , backdrop_cart.cart_time ";
  1397. $from=" FROM transaction_backdrop
  1398. LEFT JOIN backdrop_cart On (backdrop_cart.transaction_backdrop_id = transaction_backdrop.id and backdrop_cart.payflag='1')
  1399. LEFT JOIN backdrops On (backdrop_cart.backdrop_id = backdrops.id)
  1400. LEFT JOIN users On (transaction_backdrop.user_id = users.id)
  1401. ";
  1402. $where="WHERE 1 and transaction_backdrop.pflag='1' and backdrop_cart.payflag='1' ";
  1403. $searchpass='';
  1404. if((isset($viewSearchType) && $viewSearchType=='code' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='') || (isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='') )
  1405. {
  1406. $where.=" AND backdrops.backdrop_id like '%".$_REQUEST['txtsrch']."%' ";
  1407. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  1408. }
  1409. if(isset($viewSearchType) && $viewSearchType=='username')
  1410. {
  1411. $where.=" AND users.username like '%".$_REQUEST['txtsrch']."%'";
  1412. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  1413. }
  1414. if(isset($viewSearchType) && $viewSearchType=='invoice')
  1415. {
  1416. $where.=" AND transaction_backdrop.invoice like '%".$_REQUEST['txtsrch']."%'";
  1417. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  1418. }
  1419. if(isset($viewSearchType) && $viewSearchType=='daterange')
  1420. {
  1421. if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY')
  1422. {
  1423. $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
  1424. $urlfromdate = $_REQUEST['inpdatefrom'];
  1425. }
  1426. else
  1427. {
  1428. $eventFromDate=date("Y-m-d");
  1429. $urlfromdate = $_REQUEST['inpdatefrom'];
  1430. }
  1431. if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY')
  1432. {
  1433. $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
  1434. $urltodate = $_REQUEST['inpdateto'];
  1435. }
  1436. else
  1437. {
  1438. $eventToDate=date("Y-m-d");
  1439. $urltodate = $_REQUEST['inpdateto'];
  1440. }
  1441. $where.=" AND backdrop_cart.cart_time between '".$eventFromDate."' and '".$eventToDate."' ";
  1442. $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
  1443. }
  1444. $others=" GROUP BY transaction_backdrop.id ORDER by transaction_backdrop.id desc";
  1445. //$PassParameter="";
  1446. $CountField="backdrop_tickets.id";
  1447. if(isset($viewSearchType) && $viewSearchType!='')
  1448. {
  1449. $PassParameter="hfsearch=".$viewSearchType.$searchpass;
  1450. }
  1451. else
  1452. $PassParameter="";
  1453. $this->set("controller","backdrop");
  1454. $this->set("action","userbackdropsubmission");
  1455. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1456. if(isset($this->params['url']['Page']) || isset($viewSearchType))
  1457. {
  1458. $this->render("userbackdroporder2","ajax");
  1459. }
  1460. /**/
  1461. }
  1462. function updatestatusonresaletracking($tranbackdropId=NULL)
  1463. {
  1464. $backropsql = "SELECT status,tracking from transaction_backdrop where id='".base64_decode($tranbackdropId)."'";
  1465. $backropsql_res = mysql_query($backropsql);
  1466. $backropsql_num = mysql_num_rows($backropsql_res);
  1467. $this->set('comId',base64_decode($tranbackdropId));
  1468. $this->set('NumbercomId',$backropsql_num);
  1469. if($backropsql_num>0)
  1470. {
  1471. $backropsql_arr = mysql_fetch_array($backropsql_res);
  1472. $this->set('comstatus',$backropsql_arr['status']);
  1473. $this->set('comTracking',$backropsql_arr['tracking']);
  1474. }
  1475. else
  1476. {
  1477. $this->set('comstatus','');
  1478. $this->set('comTracking','Tracking number');
  1479. }
  1480. $this->render("updatestatusonresale","ajax");
  1481. }
  1482. function saveorderstatus($transactionid=null)
  1483. {
  1484. $orderstatus='Order In';
  1485. $trackingstatus='';
  1486. //pr($_REQUEST);
  1487. if(isset($_REQUEST['orderstatus'.$transactionid]) && $_REQUEST['orderstatus'.$transactionid]!='')
  1488. {
  1489. $orderstatus = $_REQUEST['orderstatus'.$transactionid] ;
  1490. }
  1491. if(isset($_REQUEST['txttracking'.$transactionid]) && $_REQUEST['txttracking'.$transactionid]!='')
  1492. {
  1493. $trackingstatus = $_REQUEST['txttracking'.$transactionid] ;
  1494. }
  1495. $updatetrack = "UPDATE transaction_backdrop SET status='".$orderstatus."' , status_date=CURDATE(),tracking='".$trackingstatus."' where id='".$transactionid."'";
  1496. @mysql_query($updatetrack);
  1497. $backropsql = "SELECT status,tracking from transaction_backdrop where id='".$transactionid."'";
  1498. $backropsql_res = mysql_query($backropsql);
  1499. $backropsql_num = mysql_num_rows($backropsql_res);
  1500. $this->set('comId',$transactionid);
  1501. $this->set('NumbercomId',$backropsql_num);
  1502. if($backropsql_num>0)
  1503. {
  1504. $backropsql_arr = mysql_fetch_array($backropsql_res);
  1505. $this->set('comstatus',$backropsql_arr['status']);
  1506. $this->set('comTracking',$backropsql_arr['tracking']);
  1507. }
  1508. else
  1509. {
  1510. $this->set('comstatus','');
  1511. $this->set('comTracking','');
  1512. }
  1513. $this->render("saveorderstatusdiv","ajax");
  1514. }
  1515. function statuscloseme($transactionid=null)
  1516. {
  1517. $this->set('comId',$transactionid);
  1518. $this->render("saveorderstatusdiv","ajax");
  1519. }
  1520. function payusercomfee($tranbackdropId=NULL)
  1521. {
  1522. /* Payment number */
  1523. if(!$tranbackdropId)
  1524. $tranbackdropId=base64_encode($_REQUEST['id']);
  1525. $backropsql = "SELECT user_comission,invoice,user_id from transaction_backdrop where id='".base64_decode($tranbackdropId)."' and admin_comission_paid !='0' ";
  1526. $backropsql_res = mysql_query($backropsql);
  1527. $backropsql_num = mysql_num_rows($backropsql_res);
  1528. $this->set('comId',base64_decode($tranbackdropId));
  1529. $this->set('NumbercomId',$backropsql_num);
  1530. if($backropsql_num >0)
  1531. {
  1532. $backropsql_arr = mysql_fetch_array($backropsql_res);
  1533. #####################################################################
  1534. $get_invoiceid = "SELECT backdrops.belongstouser from transaction_backdrop
  1535. Left Join backdrop_cart On backdrop_cart.transaction_backdrop_id = transaction_backdrop.id
  1536. left join backdrops on backdrops.id =backdrop_cart.backdrop_id
  1537. where transaction_backdrop.id='".base64_decode($tranbackdropId)."'";
  1538. $get_invoiceid_sql = mysql_query($get_invoiceid);
  1539. $get_invoiceid_sql_arr = mysql_fetch_array($get_invoiceid_sql);
  1540. $UserId = $get_invoiceid_sql_arr['belongstouser'];
  1541. $userDetails=$this->getUserDetails($get_invoiceid_sql_arr['belongstouser']);
  1542. $this->set('UserInfo',$userDetails);
  1543. #######################################################################
  1544. ########### USER PAYMENT CONFIG ########
  1545. $paymentMethods=$this->getPaymentMethods($UserId);
  1546. $this->set("paymentMethods",$paymentMethods);
  1547. ############
  1548. $this->set('payamount',$backropsql_arr['user_comission']);
  1549. $this->set('backdropinvoice',$backropsql_arr['invoice']);
  1550. $this->set('comId',base64_decode($tranbackdropId));
  1551. /**/
  1552. if(isset($this->data['Event']['radiobutton']))
  1553. {
  1554. $this->layout="previewpaymemnt";
  1555. $this->render("blank_page");
  1556. $amountPay=$this->data['Backdrop']['totalamount'];
  1557. if($this->data['Event']['radiobutton']=="paypal")
  1558. {
  1559. $this->itemName="Backdrop Commission for invoice: - ".$backropsql_arr['invoice'];
  1560. $this->amountPay=$amountPay;
  1561. $this->invoice="";
  1562. $this->returnUrl=DOMAIN."backdrop/backdropxofeethanks?id=".$tranbackdropId."&uid=".base64_encode($backropsql_arr['user_id']);
  1563. $this->notifyUrl=DOMAIN."backdrop/notify_backdropxofeepaid";
  1564. $this->custom=$tranbackdropId."^".$backropsql_arr['user_id'];
  1565. $this->merchantEmail=$paymentMethods['paypal_email'];
  1566. $this->paypal();
  1567. }
  1568. if($this->data['Event']['radiobutton']=="google")
  1569. {
  1570. $adminPayment=$paymentMethods['gcheckout_email'];
  1571. $adminPaymentDetails=explode("break",$adminPayment);
  1572. $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
  1573. $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
  1574. $this->Gcheckout->gItemName="Backdrop Commission for invoice: - ".$backropsql_arr['invoice'];
  1575. $this->Gcheckout->gItemDesc='';
  1576. $this->Gcheckout->gQuantity=1;
  1577. $this->Gcheckout->gPrice=$amountPay;
  1578. $this->Gcheckout->gReturnUrl=DOMAIN."backdrop/backdropxofeethanks?id=".$tranbackdropId."&uid=".base64_encode($backropsql_arr['user_id']);
  1579. $this->Gcheckout->gNotifyUrl=DOMAIN."backdrop/notify_backdropxofeepaid";
  1580. $this->Gcheckout->customData=$tranbackdropId."^".$backropsql_arr['user_id']."^".$amountPay;
  1581. $this->Gcheckout->google();
  1582. }
  1583. }
  1584. else
  1585. $this->render("payusercomfee","ajax");
  1586. }
  1587. }
  1588. function notify_backdropxofeepaid()
  1589. {
  1590. $this->Paypal->paypal_class();
  1591. $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
  1592. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  1593. $paypal=0;
  1594. if ($this->Paypal->validate_ipn())
  1595. {
  1596. $paypal=1;
  1597. if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="")
  1598. {
  1599. $totalPay=$this->Paypal->ipn_data['payment_gross'];
  1600. $custom=explode("^",$this->Paypal->ipn_data['custom']);
  1601. $backdroptranId=$custom['0'];
  1602. $UserId=$custom['1'];
  1603. }
  1604. }
  1605. //This section is used to catch from GOOGLE IPN data
  1606. if(!$paypal)
  1607. {
  1608. //this section is used to update from google IPN data
  1609. $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
  1610. if($xml_response)
  1611. {
  1612. $gCustom=$this->parseXmlArray($xml_response);
  1613. $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
  1614. $ipnData=explode("^",$cData);
  1615. $backdroptranId=$ipnData['0'];
  1616. $UserId=$ipnData['1'];
  1617. $totalPay=$ipnData['2'];
  1618. }
  1619. }
  1620. @mysql_query("UPDATE transaction_backdrop SET user_comission_paid='1' where id='".base64_decode($backdroptranId)."'");
  1621. #####################################################################
  1622. $get_invoiceid = "SELECT backdrops.belongstouser from transaction_backdrop
  1623. Left Join backdrop_cart On backdrop_cart.transaction_backdrop_id = transaction_backdrop.id
  1624. left join backdrops on backdrops.id =backdrop_cart.backdrop_id
  1625. where transaction_backdrop.id='".base64_decode($backdroptranId)."'";
  1626. $get_invoiceid_sql = mysql_query($get_invoiceid);
  1627. $get_invoiceid_sql_arr = mysql_fetch_array($get_invoiceid_sql);
  1628. $UserId = $get_invoiceid_sql_arr['belongstouser'];
  1629. $userDetails=$this->getUserDetails($get_invoiceid_sql_arr['belongstouser']);
  1630. $this->set('UserInfo',$userDetails);
  1631. #######################################################################
  1632. $queryXouserTransactions=mysql_query("SELECT * FROM xouser_transactions WHERE transaction_head='backdrop' AND transaction_title='comission paid' AND invoice_id='".base64_decode($backdroptranId)."'");
  1633. if(mysql_num_rows($queryXouserTransactions)<=0)
  1634. {
  1635. #####################Backdrop reposting ii
  1636. $transactionDesc="Backdrop resale comission payment";
  1637. $transactionHead="backdrop";
  1638. $transactionTitle="comission paid";
  1639. $invoice="BPPAYUSRCOMM".(35000+base64_decode($backdroptranId));
  1640. $invoiceId=base64_decode($backdroptranId);
  1641. $lastInsertId=$this->transactionMaster($transactionDesc,$transactionHead,$transactionTitle,$invoice,$invoiceId);
  1642. //$this->transactionDetail($UserId,$totalPay,'-1',$lastInsertId,1); //charged
  1643. $statusoffee="transactionfee";
  1644. //$this->transactionDetail($UserId,$totalPay,'+1',$lastInsertId,1); //paid//changed on 5th January 2010
  1645. $this->transactionDetail(1,$totalPay,'-1',$lastInsertId,$UserId);
  1646. //________________________________________________Mailing Section______________________________________________
  1647. /* Backdrop resale data entry */
  1648. $this->set('userpayInvoice',$invoice);
  1649. $backdropinfoQuery = "SELECT backdrops.backdrop_image , backdrops.backdrop_id from
  1650. transaction_backdrop
  1651. LEFT JOIN backdrop_cart ON (transaction_backdrop.id=backdrop_cart.transaction_backdrop_id)
  1652. LEFT JOIN backdrops ON (backdrop_cart.backdrop_id=backdrops.id)
  1653. where transaction_backdrop.id='".base64_decode($backdroptranId)."' ";
  1654. $backdropinfoQuery_res = mysql_query($backdropinfoQuery);
  1655. $backdropinfoQuery_arr = mysql_fetch_array($backdropinfoQuery_res);
  1656. $this->set('backdropImage',$backdropinfoQuery_arr['backdrop_image']);
  1657. $this->set('backdropCode',$backdropinfoQuery_arr['backdrop_id']);
  1658. /**/
  1659. //mail sent to the user personal account
  1660. $this->Sendmail->Mail();
  1661. $this->Sendmail->From(FROMMAIL);
  1662. if(isset($userDetails['email']))
  1663. $this->Sendmail->To($userDetails['email']);
  1664. $this->Sendmail->Cc("sujoy@navsoft.in");
  1665. $this->Sendmail->Cc("sanjib@navsoft.in");
  1666. //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
  1667. $subject="XOIMAGES Backdrop Commission payment- ".$invoice;
  1668. $this->Sendmail->Subject($subject);
  1669. $this->set('amount', $totalPay);
  1670. $this->Sendmail->layout='email';
  1671. $this->Sendmail->view='mail_payxofeepost';
  1672. $this->Sendmail->startup($this);
  1673. $messageBody=$this->Sendmail->bodyText();
  1674. $this->Sendmail->Body($messageBody); // set the body
  1675. $this->Sendmail->Priority(1) ; // set the priority to Low
  1676. $this->Sendmail->Send(); // send the mail
  1677. //mail sent to the user mail account in the system
  1678. $sender=1;
  1679. $receiver=$UserId;
  1680. $this->senderMail($sender,$receiver,$subject,$messageBody);
  1681. $this->receiverMail($receiver,$sender,$subject,$messageBody);
  1682. $this->render("blank_page");
  1683. }
  1684. }
  1685. function backdropxofeethanks()
  1686. {
  1687. $this->checkSession();
  1688. $this->layout = 'default_user';
  1689. }
  1690. function showinvoicestatus($backdroptranId=null)
  1691. {
  1692. $this->layout="loginblank";
  1693. if($backdroptranId)
  1694. {
  1695. $backdropQuery = "SELECT transaction_backdrop.invoice_qty,backdrops.backdrop_image, backdrops.Name , backdrops.backdrop_id as backdropcode , if(users.username<>'',users.username,'xoimage staff') as owner , user_details.email as purchaseemail
  1696. FROM transaction_backdrop
  1697. LEFT JOIN backdrop_cart ON (backdrop_cart.transaction_backdrop_id =transaction_backdrop.id)
  1698. LEFT JOIN backdrops On (backdrop_cart.backdrop_id = backdrops.id)
  1699. LEFT JOIN user_details On (transaction_backdrop.user_id=user_details.user_id)
  1700. LEFT JOIN users On (backdrops.belongstouser=users.id)
  1701. where transaction_backdrop.id='".$backdroptranId."'";
  1702. $backdropQuery_query = mysql_query($backdropQuery);
  1703. $newarray = array();
  1704. while($backdropQuery_arr = mysql_fetch_assoc($backdropQuery_query))
  1705. {
  1706. $newarray[] = $backdropQuery_arr;
  1707. }
  1708. $this->set('InvInfo',$newarray);
  1709. $this->set('backdropTitle',$backdropQuery_arr['Name']) ;
  1710. $this->set('backdropImage',$backdropQuery_arr['backdrop_image']) ;
  1711. $this->set('backdropCode',$backdropQuery_arr['backdropcode']) ;
  1712. $this->set('backdropInvemail',$backdropQuery_arr['purchaseemail']) ;
  1713. $this->set('backdropInvqty',$backdropQuery_arr['invoice_qty']) ;
  1714. $this->set('backdropOwner',$backdropQuery_arr['owner']) ;
  1715. }
  1716. }
  1717. function showticketstatus($ticketId=null)
  1718. {
  1719. $this->layout="loginblank";
  1720. if($ticketId)
  1721. {
  1722. $backdropQuery = "SELECT backdrop_tickets.*,backdrops.backdrop_image, backdrops.Name
  1723. FROM backdrop_tickets
  1724. LEFT JOIN backdrops On (backdrop_tickets.backdrop_id = backdrops.id)
  1725. where backdrop_tickets.id='".base64_decode($ticketId)."'";
  1726. $backdropQuery_query = mysql_query($backdropQuery);
  1727. $backdropQuery_arr = mysql_fetch_array($backdropQuery_query);
  1728. $this->set('backdropTitle',$backdropQuery_arr['Name']) ;
  1729. $this->set('backdropImage',$backdropQuery_arr['backdrop_image']) ;
  1730. $this->set('backdropStatus',$backdropQuery_arr['status']) ;
  1731. $this->set('backdropRejmsg',$backdropQuery_arr['admin_reject_msg']) ;
  1732. $this->set('backdropTicId',base64_decode($ticketId)) ;
  1733. $this->backdropcategory();
  1734. $this->getbackdropdetails($backdropQuery_arr['backdrop_id']);
  1735. }
  1736. }
  1737. function savebackdropapproval($backdroptranId=null)
  1738. {
  1739. $approvaltxt='awaiting';
  1740. $rejecttxtmsg='';
  1741. $updatebackdrop=0;
  1742. if(isset($_REQUEST['txtticket'.$backdroptranId]) && $_REQUEST['txtticket'.$backdroptranId]!='')
  1743. {
  1744. $approvaltxt=$_REQUEST['txtticket'.$backdroptranId] ;
  1745. }
  1746. if(isset($_REQUEST['txtmsg'.$backdroptranId]) && $_REQUEST['txtmsg'.$backdroptranId]!='')
  1747. {
  1748. $rejecttxtmsg=$_REQUEST['txtmsg'.$backdroptranId] ;
  1749. }
  1750. @mysql_query("Update backdrop_tickets SET status='".$approvaltxt."' , admin_reject_msg='".$rejecttxtmsg."' where id='".$backdroptranId."' ");
  1751. if($approvaltxt=='reject')
  1752. $updatebackdrop = '2';
  1753. if($approvaltxt=='approve')
  1754. $updatebackdrop = '1';
  1755. /* Select */
  1756. $sectbackid = "SELECT backdrop_id from backdrop_tickets where id='".$backdroptranId."'" ;
  1757. $sectbackid_res = mysql_query($sectbackid);
  1758. $sectbackid_array = mysql_fetch_array($sectbackid_res);
  1759. @mysql_query("Update backdrops SET is_approved='".$updatebackdrop."' where id='".$sectbackid_array['backdrop_id']."' ");
  1760. }
  1761. function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
  1762. {
  1763. if(isset($arg['Page']))
  1764. $pageFlag=$arg['Page'];
  1765. $this->set("PassParameter",$PassParameter);
  1766. $SetUserNumberOfVpsPerPage=100; /* Defined in config->paths.php*/
  1767. $this->set("BackgroundClass",'pagination');
  1768. $this->set("SelectedPage",'pagination_over');
  1769. $this->set("Linkpage",'pagination_over');
  1770. $this->set("FirstImage",'fdd.gif');
  1771. $this->set("PreviousImage",'previous.gif');
  1772. $this->set("NextImage",'next.gif');
  1773. $this->set("LastImage",'rewd.gif');
  1774. $UserNumberOfVpsPerPage=100; /* Defined in config->paths.php*/
  1775. if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
  1776. $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
  1777. if(!isset($arg['Page'])) $arg['Page']=1;
  1778. if(!isset($arg['Offset'])) $arg['Offset']=0;
  1779. $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
  1780. //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
  1781. //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
  1782. $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
  1783. $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
  1784. $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
  1785. if($arg['Offset']==$NoOfVps)
  1786. {
  1787. if(isset($Offset))
  1788. {
  1789. $Offset=$Offset-$NumberOfVpsPerPage;
  1790. $Page--;
  1791. if($Offset<0)
  1792. {
  1793. $Offset=0;$Page=1;
  1794. }
  1795. }else{
  1796. $Offset=0;$Page=1;
  1797. }
  1798. }
  1799. $this->set("Page",$arg['Page']);
  1800. $this->set("Offset",$arg['Offset']);
  1801. $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
  1802. $this->set("NoOfPages",$NoOfPages);
  1803. $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
  1804. //print "$select $from $where $others";
  1805. $this->set("qryOthr","$select $from $where)");
  1806. $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
  1807. $this->set("query",$SelectRecord);
  1808. }
  1809. function newcreatebackdrop()
  1810. {
  1811. $this->checkSession();
  1812. $this->layout = 'default_user';
  1813. $this->backdropcategory();
  1814. $this->backdropsizelist();
  1815. }
  1816. function newcreatebackdrop2($backdrop=null)
  1817. {
  1818. $this->checkSession();
  1819. $this->layout = 'default_user';
  1820. if($backdrop)
  1821. $this->set('Backdropid', $backdrop);
  1822. if($backdrop)
  1823. {
  1824. $this->backdropcategory();
  1825. $this->getbackdropdetails($backdrop);
  1826. //$this->set('Backdropid', $backdrop);
  1827. }
  1828. if (!empty($this->data))
  1829. {
  1830. //pr($_REQUEST);
  1831. if(isset($_REQUEST['backdropId']) && $_REQUEST['backdropId']!='')
  1832. $this->data['Backdrop']['user_id'] = $_REQUEST['backdropId'];
  1833. else
  1834. $this->data['Backdrop']['user_id'] = $_SESSION['Admin_id'];
  1835. $this->data['Backdrop']['belongstouser'] = $_SESSION['Admin_id'];
  1836. $this->data['Backdrop']['is_featured'] = $_REQUEST['backdropfeatured'];
  1837. $this->data['Backdrop']['is_approved'] = $_REQUEST['backdropstatus'];
  1838. //echo $this->data['Backdrop']['user_id'] ;
  1839. //
  1840. //exit();
  1841. if($_REQUEST['category']==0)
  1842. $this->data['Backdrop']['backdrop_categories_id'] = 1;
  1843. else
  1844. $this->data['Backdrop']['backdrop_categories_id'] = $_REQUEST['category'];
  1845. if(isset($_REQUEST['backdropIdUser']) && $_REQUEST['backdropIdUser']=='admin')
  1846. $this->data['Backdrop']['is_admin'] = 'Yes';
  1847. else
  1848. {
  1849. if(isset($_REQUEST['backdropuser']) && $_REQUEST['backdropuser']=='user')
  1850. $this->data['Backdrop']['is_admin'] = 'No';
  1851. else
  1852. $this->data['Backdrop']['is_admin'] = 'Yes';
  1853. }
  1854. $this->data['Backdrop']['backdrop_size'] = $_REQUEST['backdropsize'];
  1855. $this->data['Backdrop']['backdrop_image'] = $_REQUEST['hidimage'];
  1856. //pr($this->data);
  1857. //exit();
  1858. if ($this->Backdrop->save($this->data))
  1859. {
  1860. $backdrop_id = $this->Backdrop->getLastInsertId();
  1861. /* UPDATE THE BACKDROP TABLE WITH UNIQUE NUMBER*/
  1862. $this->data['Backdrop']['id'] = $backdrop_id;
  1863. $this->data['Backdrop']['backdrop_id'] = 'BKD'.mktime().$backdrop_id;
  1864. $this->Backdrop->save($this->data);
  1865. $this->redirect('/backdrop/createbackdrop2/'.$backdrop_id);
  1866. }
  1867. }
  1868. }
  1869. }
  1870. ?>