PageRenderTime 66ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/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

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

  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'])!="")

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