PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/app/controllers/admins_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 1326 lines | 1004 code | 211 blank | 111 comment | 152 complexity | 11b88a6107e1685c2da90bee5e93ad37 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. class AdminsController extends AppController
  3. {
  4. var $name='Admins';
  5. var $helpers = array('Html','Javascript','Ajax','Pagination','error');
  6. var $components = array('Pagination','Sendmail');
  7. function index()
  8. {
  9. $this->checkSession();
  10. }
  11. ######################################### My payment Page of the admin ####################
  12. function mypayment()
  13. {
  14. $this->checkSession();
  15. $this->pageTitle = 'My Payment';
  16. $this->layout = 'default_after_login';
  17. }
  18. function userpayment($userType=null,$userId=null)
  19. {
  20. $this->checkSession();
  21. $this->pageTitle = 'My Payment';
  22. $this->layout = 'default_after_login';
  23. $this->set('UserType',$userType);
  24. $this->set('viewUser',$userId);
  25. }
  26. function paymenttouser($userType=null,$userId=null)
  27. {
  28. $this->checkSession();
  29. $this->pageTitle = 'Payment to User';
  30. $this->layout = 'default_after_login';
  31. $this->set("paymentMethods",$this->getPaymentMethods(base64_decode($userId)));
  32. /* GET THE TOTAL BALANCE */
  33. $getTotalPayment=" SELECT amount , DrCr
  34. FROM xouser_transaction_details
  35. WHERE xouser_transaction_id
  36. AND user_id = '".base64_decode($userId)."'";
  37. $getTotalPayment_res = mysql_query($getTotalPayment);
  38. $temppayment = 0;
  39. while($getTotalPayment_arr =mysql_fetch_array($getTotalPayment_res))
  40. {
  41. $temppayment += ($getTotalPayment_arr['amount'] * $getTotalPayment_arr['DrCr']);
  42. }
  43. $queryGetTotalPayment=mysql_fetch_assoc(mysql_query($getTotalPayment));
  44. $this->set("totalPaymentAmount",$temppayment);
  45. $this->set("payableUser",$userId);
  46. /**/
  47. }
  48. function makepayment($userId=null)
  49. {
  50. $this->checkSession();
  51. $this->layout = 'commissionpaymemnt';
  52. $this->render("blank_page");
  53. /* GET THE TOTAL BALANCE */
  54. $getTotalPayment=" SELECT amount , DrCr
  55. FROM xouser_transaction_details
  56. WHERE xouser_transaction_id
  57. AND user_id = '".base64_decode($userId)."'";
  58. $getTotalPayment_res = mysql_query($getTotalPayment);
  59. $temppayment = 0;
  60. while($getTotalPayment_arr =mysql_fetch_array($getTotalPayment_res))
  61. {
  62. $temppayment += ($getTotalPayment_arr['amount'] * $getTotalPayment_arr['DrCr']);
  63. }
  64. //$temppayment=14;
  65. $amountPay=$temppayment;
  66. $paymentMethods=$this->getPaymentMethods(base64_decode($userId));
  67. if($this->data['Event']['radiobutton']=="paypal")
  68. {
  69. $this->itemName="Commission Payable";
  70. $this->amountPay=$amountPay;
  71. $this->returnUrl=DOMAIN."admins/userpaymentreq?menu=82";
  72. $this->notifyUrl=DOMAIN."admins/notify_commissionpayment";
  73. $this->custom=$userId."^".$amountPay;
  74. $this->merchantEmail=$paymentMethods['paypal_email'];
  75. $this->paypal();
  76. }
  77. if($this->data['Event']['radiobutton']=="google")
  78. {
  79. $adminPayment=$paymentMethods['gcheckout_email'];
  80. $adminPaymentDetails=explode("break",$adminPayment);
  81. $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
  82. $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
  83. $this->Gcheckout->gItemName="Commission Payable";
  84. $this->Gcheckout->gItemDesc="Commission Payable";
  85. $this->Gcheckout->gQuantity=1;
  86. $this->Gcheckout->gPrice=$amountPay;
  87. $this->Gcheckout->gReturnUrl=DOMAIN."admins/userpaymentreq?menu=82";
  88. $this->Gcheckout->gNotifyUrl=DOMAIN."admins/notify_commissionpayment";
  89. $this->Gcheckout->customData=$userId."^".$amountPay;
  90. $this->Gcheckout->google();
  91. }
  92. }
  93. function notify_commissionpayment()
  94. {
  95. $this->Paypal->paypal_class();
  96. $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
  97. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  98. $paypal=0;
  99. if ($this->Paypal->validate_ipn())
  100. {
  101. $paypal=1;
  102. if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="")
  103. {
  104. $custom=explode("^",$this->Paypal->ipn_data['custom']);
  105. $UserId=$custom['0'];
  106. $totalPay=$custom['1'];
  107. }
  108. }
  109. //This section is used to catch from GOOGLE IPN data
  110. if(!$paypal)
  111. {
  112. //this section is used to update from google IPN data
  113. $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
  114. if($xml_response)
  115. {
  116. $gCustom=$this->parseXmlArray($xml_response);
  117. $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
  118. $ipnData=explode("^",$cData);
  119. $UserId=$ipnData['0'];
  120. $totalPay=$ipnData['1'];
  121. }
  122. }
  123. //________________________________________________XOIMAGE DATABASE UPDATION SECTION
  124. $userDetails=$this->getUserDetails(base64_decode($UserId));
  125. $testmail = "INSERT INTO `abusive_words` ( `id` , `words` )VALUES ('', 'ddd')";
  126. @mysql_query($testmail);
  127. $getTotalPayment=" SELECT amount , DrCr
  128. FROM xouser_transaction_details
  129. WHERE xouser_transaction_id
  130. AND user_id = '".base64_decode($userId)."'";
  131. $getTotalPayment_res = mysql_query($getTotalPayment);
  132. $temppayment = 0;
  133. while($getTotalPayment_arr =mysql_fetch_array($getTotalPayment_res))
  134. {
  135. $temppayment += ($getTotalPayment_arr['amount'] * $getTotalPayment_arr['DrCr']);
  136. }
  137. if($temppayment>0)
  138. {
  139. $transactionDesc="Xoimages - Commission paid by administartor";
  140. $transactionHead="backdrop";
  141. $transactionTitle="Commission Payable";
  142. $invoice='XOCOMMUser'.base64_decode($userId).date("Ymd");
  143. $invoiceId='';
  144. $totalPay=$temppayment;
  145. //$transactionId=$fetchTransactionTable['xouser_transaction_id'];
  146. $transactionId='1';
  147. $lastInsertId=$this->transactionMaster($transactionDesc,$transactionHead,$transactionTitle,$invoice,$invoiceId);
  148. $this->transactionDetail(base64_decode($UserId),$totalPay,'+1',$lastInsertId,'1'); //USER RECEIVE
  149. $this->transactionDetail(base64_decode($UserId),$totalPay,'-1',$lastInsertId,'1'); //ADMIN PAID
  150. }
  151. //____________________________________________________TRANSACTION LOG MANAGEMENT_____________________________________
  152. //This section does not require
  153. //____________________________________________________MAIL MANAGEMENT________________________________________________
  154. //this mailing code is here so that it fires just once.
  155. //mail sent to the user personal account
  156. $this->Sendmail->Mail();
  157. $this->Sendmail->From(FROMMAIL);
  158. if(isset($userDetails['email']))
  159. $this->Sendmail->To($userDetails['email']);
  160. // $this->Sendmail->Cc("sujoy@navsoft.in");
  161. $this->Sendmail->Cc("sanjib@navsoft.in");
  162. //$this->Sendmail->Bcc( "someoneelse@somewhere.fr");
  163. $subject="Commission payment";
  164. $this->Sendmail->Subject($subject);
  165. $this->set('amount', $totalPay);
  166. $this->Sendmail->layout='email';
  167. $this->Sendmail->view='mail_duepayment';
  168. $this->Sendmail->startup($this);
  169. $messageBody=$this->Sendmail->bodyText();
  170. $this->Sendmail->Body($messageBody); // set the body
  171. $this->Sendmail->Priority(1) ; // set the priority to Low
  172. $this->Sendmail->Send(); // send the mail
  173. $sender=1;
  174. $receiver=$UserId;
  175. $this->senderMail($sender,$receiver,$subject,$messageBody);
  176. $this->receiverMail($receiver,$sender,$subject,$messageBody);
  177. $this->render("blank_page");
  178. }
  179. function userpaymentreq()
  180. {
  181. $this->checkSession();
  182. $this->pageTitle = 'User Payment Request';
  183. $this->layout = 'default_after_login';
  184. }
  185. function managecountry()
  186. {
  187. $this->checkSession();
  188. $this->layout = 'default_user_cat';
  189. if($_SESSION['Admin_role']!=1)
  190. $this->redirect('/user_group_masters/noaccess');
  191. }
  192. function addcountry()
  193. {
  194. $this->checkSession();
  195. $this->layout = 'default_user_cat';
  196. if($_SESSION['Admin_role']!=1)
  197. $this->redirect('/user_group_masters/noaccess');
  198. }
  199. function editcountry($coutryid=null)
  200. {
  201. $this->checkSession();
  202. $this->layout = 'default_user_cat';
  203. if($_SESSION['Admin_role']!=1)
  204. $this->redirect('/user_group_masters/noaccess');
  205. ///// Country Name ////
  206. $countrysql = "Select country_name from countries where id='".base64_decode($coutryid)."'";
  207. $countrysql_res = mysql_query($countrysql);
  208. $countrysql_arr = mysql_fetch_array($countrysql_res);
  209. $this->set('countryId',$coutryid );
  210. $this->set('countryName',$countrysql_arr['country_name']);
  211. }
  212. function delcountry($coutryid=null)
  213. {
  214. $countrysql = "DELETE FROM countries where id='".base64_decode($coutryid)."'";
  215. $countrysql_res = mysql_query($countrysql);
  216. ##### DELETING THE City list under that country and associated state ########
  217. $selectstate = "Select * FROM state where c_id='".base64_decode($coutryid)."'";
  218. $selectstate_res = mysql_query($selectstate);
  219. while($selectstate_arr = mysql_fetch_array($selectstate_res))
  220. {
  221. $delcitysql = "DELETE FROM city_master where state_id='".$selectstate_arr['id']."'";
  222. $delcitysql_res = mysql_query($delcitysql);
  223. }
  224. ##### DELETING THE City list under that country and associated state ########
  225. ##### DELETING THE State under that country ########
  226. $delstatesql = "DELETE FROM state where c_id='".base64_decode($coutryid)."'";
  227. $countrysql_res = mysql_query($countrysql);
  228. ##### DELETING THE State under that country ########
  229. $this->redirect('admins/managecountry');
  230. }
  231. function saveeditcountry()
  232. {
  233. $this->checkSession();
  234. $this->layout = 'default_user_cat';
  235. if($_SESSION['Admin_role']!=1)
  236. $this->redirect('/user_group_masters/noaccess');
  237. if(isset($_REQUEST['txtcountry']) && trim($_REQUEST['txtcountry'])!='')
  238. {
  239. $updatecountry = "UPDATE countries set country_name='".addslashes($_REQUEST['txtcountry'])."' where id='".base64_decode($_REQUEST['hfcountry'])."' ";
  240. mysql_query($updatecountry);
  241. }
  242. $this->redirect('admins/managecountry');
  243. }
  244. function savecountry()
  245. {
  246. $this->checkSession();
  247. $this->layout = 'default_user_cat';
  248. if($_SESSION['Admin_role']!=1)
  249. $this->redirect('/user_group_masters/noaccess');
  250. if(isset($_REQUEST['txtcountry']) && trim($_REQUEST['txtcountry'])!='')
  251. {
  252. $countrysql = "Select country_name from countries where country_name='".addslashes($_REQUEST['txtcountry'])."'";
  253. $countrysql_res = mysql_query($countrysql);
  254. $countrysql_num = mysql_num_rows($countrysql_res);
  255. if($countrysql_num==0)
  256. {
  257. $updatecountry = "INSERT INTO countries set country_name='".addslashes($_REQUEST['txtcountry'])."'";
  258. mysql_query($updatecountry);
  259. }
  260. }
  261. $this->redirect('admins/managecountry');
  262. }
  263. function managestate($stateId=null)
  264. {
  265. $this->checkSession();
  266. $this->layout = 'default_user_cat';
  267. if($_SESSION['Admin_role']!=1)
  268. $this->redirect('/user_group_masters/noaccess');
  269. if($stateId)
  270. {
  271. $this->set('stateId',$stateId);
  272. /// Country Name and state name
  273. $selectstate = "Select countries.country_name FROM countries where countries.id='".base64_decode($stateId)."'";
  274. $countrysql_res = mysql_query($selectstate);
  275. $countrysql_arr = mysql_fetch_array($countrysql_res);
  276. $this->set('countryName',$countrysql_arr['country_name']);
  277. }
  278. }
  279. function editstate($stateid=null)
  280. {
  281. $this->checkSession();
  282. $this->layout = 'default_user_cat';
  283. if($_SESSION['Admin_role']!=1)
  284. $this->redirect('/user_group_masters/noaccess');
  285. ///// Country Name ////
  286. $statesql = "Select countries.country_name , state.* from state , countries where state.id='".base64_decode($stateid)."' and state.c_id=countries.id";
  287. $statesql_res = mysql_query($statesql);
  288. $statesql_arr = mysql_fetch_array($statesql_res);
  289. $this->set('stateId',$stateid );
  290. $this->set('statename',$statesql_arr['Name']);
  291. $this->set('countryName',$statesql_arr['country_name']);
  292. $this->set('countryId',base64_encode($statesql_arr['c_id']));
  293. }
  294. function addstate($stateid=null)
  295. {
  296. $this->checkSession();
  297. $this->layout = 'default_user_cat';
  298. if($_SESSION['Admin_role']!=1)
  299. $this->redirect('/user_group_masters/noaccess');
  300. ///// Country Name ////
  301. $statesql = "Select countries.country_name, id from countries where countries.id='".base64_decode($stateid)."'";
  302. $statesql_res = mysql_query($statesql);
  303. $statesql_arr = mysql_fetch_array($statesql_res);
  304. $this->set('countryName',$statesql_arr['country_name']);
  305. $this->set('countryId',$stateid);
  306. }
  307. function saveeditstate()
  308. {
  309. $this->checkSession();
  310. $this->layout = 'default_user_cat';
  311. if($_SESSION['Admin_role']!=1)
  312. $this->redirect('/user_group_masters/noaccess');
  313. $statesql = "Select state.* from state , countries where state.id='".base64_decode($_REQUEST['hfstate'])."' and state.c_id=countries.id";
  314. $statesql_res = mysql_query($statesql);
  315. $statesql_arr = mysql_fetch_array($statesql_res);
  316. if(isset($_REQUEST['txtstate']) && trim($_REQUEST['txtstate'])!='')
  317. {
  318. $updatecountry = "UPDATE state set Name='".addslashes($_REQUEST['txtstate'])."' where id='".base64_decode($_REQUEST['hfstate'])."' ";
  319. mysql_query($updatecountry);
  320. $countryId = base64_encode($statesql_arr['c_id']);
  321. $this->redirect('admins/managestate/'.$countryId);
  322. }
  323. else
  324. $this->redirect('admins/managecountry');
  325. }
  326. function savestate()
  327. {
  328. $this->checkSession();
  329. $this->layout = 'default_user_cat';
  330. if($_SESSION['Admin_role']!=1)
  331. $this->redirect('/user_group_masters/noaccess');
  332. pr($_REQUEST);
  333. if(isset($_REQUEST['txtstate']) && trim($_REQUEST['txtstate'])!='')
  334. {
  335. $countrysql = "Select * from state where Name='".addslashes($_REQUEST['txtstate'])."' and c_id='".base64_decode($_REQUEST['hfstate'])."'";
  336. $countrysql_res = mysql_query($countrysql);
  337. $countrysql_num = mysql_num_rows($countrysql_res);
  338. if($countrysql_num==0)
  339. {
  340. $updatecountry = "INSERT INTO state set Name='".addslashes($_REQUEST['txtstate'])."',c_id='".base64_decode($_REQUEST['hfstate'])."'";
  341. mysql_query($updatecountry);
  342. }
  343. $countryId = $_REQUEST['hfstate'];
  344. $this->redirect('admins/managestate/'.$countryId);
  345. }
  346. else
  347. $this->redirect('admins/managecountry');
  348. }
  349. function delstate($coutryid=null)
  350. {
  351. ##### DELETING THE City list under that country and associated state ########
  352. $selectstate = "Select * FROM state where id='".base64_decode($coutryid)."'";
  353. $selectstate_res = mysql_query($selectstate);
  354. while($selectstate_arr = mysql_fetch_array($selectstate_res))
  355. {
  356. $txtCountryid=$selectstate_arr['c_id'];
  357. $delcitysql = "DELETE FROM city_master where state_id='".$selectstate_arr['id']."'";
  358. $delcitysql_res = mysql_query($delcitysql);
  359. }
  360. ##### DELETING THE City list under that country and associated state ########
  361. ##### DELETING THE State under that country ########
  362. $delstatesql = "DELETE FROM state where id='".base64_decode($coutryid)."'";
  363. $countrysql_res = mysql_query($delstatesql);
  364. ##### DELETING THE State under that country ########
  365. $this->redirect('admins/managestate/'.base64_encode($txtCountryid));
  366. }
  367. function managecity($stateId=null)
  368. {
  369. $this->checkSession();
  370. $this->layout = 'default_user_cat';
  371. if($_SESSION['Admin_role']!=1)
  372. $this->redirect('/user_group_masters/noaccess');
  373. if($stateId)
  374. {
  375. $this->set('stateId',$stateId);
  376. /// Country Name and state name
  377. $selectstate = "Select countries.country_name,countries.id as countryId ,state.id as stateid , state.Name FROM state ,countries where state.id='".base64_decode($stateId)."' and state.c_id=countries.id";
  378. $countrysql_res = mysql_query($selectstate);
  379. $countrysql_arr = mysql_fetch_array($countrysql_res);
  380. $this->set('countryName',$countrysql_arr['country_name']);
  381. $this->set('countryId',base64_encode($countrysql_arr['countryId']));
  382. $this->set('stateId',base64_encode($countrysql_arr['stateid']));
  383. $this->set('stateName',$countrysql_arr['Name']);
  384. }
  385. }
  386. function addcity($cityid=null)
  387. {
  388. $this->checkSession();
  389. $this->layout = 'default_user_cat';
  390. if($_SESSION['Admin_role']!=1)
  391. $this->redirect('/user_group_masters/noaccess');
  392. ///// Country Name ////
  393. $selectstate = "Select countries.country_name,countries.id as countryId ,state.id as stateid , state.Name FROM state ,countries where state.id='".base64_decode($cityid)."' and state.c_id=countries.id";
  394. $countrysql_res = mysql_query($selectstate);
  395. $countrysql_arr = mysql_fetch_array($countrysql_res);
  396. $this->set('stateId',base64_encode($countrysql_arr['stateid']));
  397. $this->set('stateName',$countrysql_arr['Name']);
  398. $this->set('countryName',$countrysql_arr['country_name']);
  399. $this->set('countryId',base64_encode($countrysql_arr['countryId']));
  400. }
  401. function editcity($cityid=null)
  402. {
  403. $this->checkSession();
  404. $this->layout = 'default_user_cat';
  405. if($_SESSION['Admin_role']!=1)
  406. $this->redirect('/user_group_masters/noaccess');
  407. ///// Country Name ////
  408. $selectstate = "Select countries.country_name,countries.id as countryId ,state.id as stateid , state.Name,city_master.city_name,city_master.city_id as cityid FROM state ,countries ,city_master where city_master.city_id='".base64_decode($cityid)."'and city_master.state_id=state.id and state.c_id=countries.id";
  409. $countrysql_res = mysql_query($selectstate);
  410. $countrysql_arr = mysql_fetch_array($countrysql_res);
  411. $this->set('cityId',$cityid );
  412. $this->set('cityname',$countrysql_arr['city_name']);
  413. $this->set('stateId',base64_encode($countrysql_arr['stateid']));
  414. $this->set('stateName',$countrysql_arr['Name']);
  415. $this->set('countryName',$countrysql_arr['country_name']);
  416. $this->set('countryId',base64_encode($countrysql_arr['countryId']));
  417. }
  418. function saveeditcity()
  419. {
  420. $this->checkSession();
  421. $this->layout = 'default_user_cat';
  422. if($_SESSION['Admin_role']!=1)
  423. $this->redirect('/user_group_masters/noaccess');
  424. $selectstate = "Select countries.country_name,countries.id as countryId ,state.id as stateid , state.Name,city_master.city_name,city_master.city_id as cityid FROM state ,countries ,city_master where city_master.city_id='".base64_decode($_REQUEST['hfcity'])."'and city_master.state_id=state.id and state.c_id=countries.id";
  425. $countrysql_res = mysql_query($selectstate);
  426. $countrysql_arr = mysql_fetch_array($countrysql_res);
  427. if(isset($_REQUEST['txtcity']) && trim($_REQUEST['txtcity'])!='')
  428. {
  429. $updatecountry = "UPDATE city_master set city_name='".addslashes($_REQUEST['txtcity'])."' where city_id='".base64_decode($_REQUEST['hfcity'])."' ";
  430. mysql_query($updatecountry);
  431. $countryId = base64_encode($countrysql_arr['stateid']);
  432. $this->redirect('admins/managecity/'.$countryId);
  433. }
  434. else
  435. $this->redirect('admins/managecountry');
  436. }
  437. function savecity()
  438. {
  439. $this->checkSession();
  440. $this->layout = 'default_user_cat';
  441. if($_SESSION['Admin_role']!=1)
  442. $this->redirect('/user_group_masters/noaccess');
  443. if(isset($_REQUEST['txtcity']) && trim($_REQUEST['txtcity'])!='')
  444. {
  445. $countrysql = "Select * from city_master where city_name='".addslashes($_REQUEST['txtcity'])."'";
  446. $countrysql_res = mysql_query($countrysql);
  447. $countrysql_num = mysql_num_rows($countrysql_res);
  448. if($countrysql_num==0)
  449. {
  450. $updatecountry = "INSERT INTO city_master set city_name='".addslashes($_REQUEST['txtcity'])."',state_id='".base64_decode($_REQUEST['stateid'])."'";
  451. mysql_query($updatecountry);
  452. }
  453. $countryId = $_REQUEST['stateid'];
  454. $this->redirect('admins/managecity/'.$countryId);
  455. }
  456. else
  457. $this->redirect('admins/managecountry');
  458. }
  459. function delcity($coutryid=null)
  460. {
  461. ##### DELETING THE City list under that country and associated state ########
  462. $selectstate = "Select * FROM city_master where city_id='".base64_decode($coutryid)."'";
  463. $selectstate_res = mysql_query($selectstate);
  464. while($selectstate_arr = mysql_fetch_array($selectstate_res))
  465. {
  466. $countryId = base64_encode($selectstate_arr['state_id']);
  467. $delcitysql = "DELETE FROM city_master where city_id='".$selectstate_arr['city_id']."'";
  468. $delcitysql_res = mysql_query($delcitysql);
  469. }
  470. ##### DELETING THE City list under that country and associated state ########
  471. $this->redirect('admins/managecity/'.$countryId);
  472. }
  473. #########################################################################################
  474. function login()
  475. {
  476. $this->layout = 'default_login';
  477. $this->pageTitle = 'Admin Login';
  478. if(!empty($this->data))
  479. {
  480. $this->data['Admin']['admin_user']=trim($this->data['Admin']['admin_user']);
  481. $this->data['Admin']['admin_pass']=trim($this->data['Admin']['admin_pass']);
  482. $someone = $this->Admin->findByAdmin_user($this->data['Admin']['admin_user']);
  483. if(!empty($someone['Admin']['admin_pass']) && $someone['Admin']['admin_pass'] == $this->data['Admin']['admin_pass'])
  484. {
  485. if($someone['Admin']['status']==0 && $someone['Admin']['is_delete']==0)
  486. {
  487. /*########################## for admin type ########################################*/
  488. $sql_aros_select="SELECT alias FROM aros WHERE id = ".$someone['Admin']['role_id'];
  489. $result_aros=mysql_query($sql_aros_select);
  490. $row_aros=mysql_fetch_assoc($result_aros);
  491. $this->Session->write('Admin', $someone['Admin']['admin_user']);
  492. $this->Session->write('Admin_id', $someone['Admin']['id']);
  493. $this->Session->write('Admin_type', $someone['Admin']['type']); //not used now
  494. $this->Session->write('Admin_cat', $row_aros['alias']);
  495. $this->Session->write('Admin_role',$someone['Admin']['role_id']); //for access permission
  496. if(isset($_SERVER[REQUEST_URL]))
  497. {
  498. $page = $_SERVER[REQUEST_URL];
  499. list($a, $b, $c, $d, $e) = explode("/", $page);
  500. $page_arr = explode("?", $e);
  501. $page_name = $d."/".$page_arr[0];
  502. $this->Session->write('Admin_page',$page_name);
  503. $this->Session->write('Admin_url',$page);
  504. }
  505. $this->redirect('/admins/afterlogin');
  506. }
  507. else
  508. {
  509. $this->set('error_block', true);
  510. }
  511. }
  512. else
  513. {
  514. $this->set('error_login', true);
  515. }
  516. }
  517. }
  518. function home()
  519. {
  520. $this->checkSession();
  521. }
  522. function afterlogin()
  523. {
  524. $this->checkSession();
  525. $this->layout = 'default_after_login';
  526. ####### Getting out the details to shown in header page ###########
  527. $this->set('ip', $_SERVER['REMOTE_ADDR']);
  528. $sql_admin_name = mysql_fetch_array(mysql_query("select * from admins where id=".$this->Session->read("Admin_id").""));
  529. $first_name=$sql_admin_name['first_name'];
  530. $last_name=$sql_admin_name['last_name'];
  531. $cond = " id=".$this->Session->read("Admin_id")."";
  532. $this->set('first_name', $first_name);
  533. $this->set('last_name', $last_name);
  534. ####### Getting out the details to shown in header page ###########
  535. ###### Getting out the list of management list ############
  536. $sql_select="select * from admin_menu where parent_id >1 and order_id=1";
  537. ###### Getting out the list of management list ############
  538. /* $this->set('id', $this->Session->read("Admin_id"));
  539. if ($this->Session->check('Admin'))
  540. {
  541. //$this->set('ad_name', findAll('Admin'));
  542. $this->set('ad_name', $this->Admin->findAll($this -> Session -> read("Admin_id")));
  543. }*/
  544. }
  545. function logout()
  546. {
  547. $this->layout = 'default_login';
  548. //$this->session->delete('Admin');
  549. //$this->session->delete('Admin_id');
  550. session_destroy();
  551. $this->redirect('/admins/login');
  552. }
  553. function createadmin()
  554. {
  555. $this->checkSession();
  556. $this->pageTitle = 'Create Admin';
  557. $this->layout = 'default_after_login';
  558. if (!empty($this->data))
  559. {
  560. $this->data['Admin']['menu'] = $_REQUEST['menu'];
  561. /*$select_user = "Select * from admins where admin_user='".$this->data['Admin']['admin_user']."'";
  562. $res_select_user = mysql_query($select_user);
  563. if(mysql_num_rows($res_select_user)==0)
  564. {*/
  565. if ($this->Admin->save($this->data))
  566. {
  567. $this->flash('Your post has been saved.','/admins');
  568. $this->redirect('/admins/manageadmin?menu='.$this->data['Admin']['menu']);
  569. }
  570. else
  571. {
  572. //$this->redirect('/admins/createadmin?menu='.$_REQUEST['menu']);
  573. $this->set('userMessage', 'Please correct the below errors.');
  574. $this->render();
  575. }
  576. /*}
  577. else
  578. {
  579. $this->flash('Admin username is already exist.','/admins');
  580. $this->redirect('/admins/createadmin?err=1');
  581. }*/
  582. }
  583. else
  584. {
  585. //$this->redirect('/admins/createadmin?menu='.$_REQUEST['menu']);
  586. }
  587. }
  588. function newadmin()
  589. {
  590. }
  591. function manageadmin()
  592. {
  593. if($_SESSION['Admin_role']==1)
  594. {
  595. $this->checkSession();
  596. $this->pageTitle = 'Manage Admin';
  597. $this->layout = 'default_after_login';
  598. if(isset($this->data))
  599. {
  600. if(!empty($this->data['Admin']['hid']))
  601. {
  602. if(isset($_REQUEST['box']))
  603. {
  604. $arr = $_REQUEST['box'];
  605. foreach($arr as $key => $value)
  606. {
  607. //echo $this->data['Admin']['action']."test";exit();
  608. if($this->data['Admin']['action'] == 'delete')
  609. {
  610. $sql = "delete from `admins` where `id` = '".$value."'";
  611. $res = mysql_query($sql);
  612. }
  613. else if($this->data['Admin']['action'] == 'block')
  614. {
  615. $sql = "update `admins` set `status` = '1' where `id` ='".$value."'";
  616. $res = mysql_query($sql);
  617. }
  618. else if($this->data['Admin']['action'] == 'unblock')
  619. {
  620. $sql = "update `admins` set `status` = '0' where `id` ='".$value."'";
  621. $res = mysql_query($sql);
  622. }
  623. }
  624. }
  625. $criteria="1";
  626. if(!empty($this->data['Admin']['id']) || !empty($this->data['Admin']['admin_email']) || !empty($this->data['Admin']['admin_user']))
  627. {
  628. //echo "aaaaaaa";exit();
  629. $id=trim($this->data['Admin']['id']);
  630. $usernames = addslashes($this->data['Admin']['admin_user']);
  631. $email = addslashes($this->data['Admin']['admin_email']);
  632. $criteria .= " and Admin.id LIKE '%".$id."%' and Admin.admin_email LIKE '%".$email."%' and Admin.admin_user LIKE '%".$usernames."%'";
  633. list($order,$limit,$page) = $this->Pagination->init($criteria);
  634. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  635. }
  636. else
  637. {
  638. $criteria= "1";
  639. list($order,$limit,$page) = $this->Pagination->init($criteria);
  640. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  641. }
  642. /*else if($this->data['Admin']['search'] == '2')
  643. {
  644. $emails=trim($this->data['Admin']['searchtxt']);
  645. $criteria .= " and Admin.admin_email LIKE '%".$emails."%'";
  646. list($order,$limit,$page) = $this->Pagination->init($criteria);
  647. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  648. }
  649. else if($this->data['Admin']['search'] == '0')
  650. {
  651. $criteria .= "1";
  652. list($order,$limit,$page) = $this->Pagination->init($criteria);
  653. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  654. }*/
  655. }
  656. }
  657. else if(empty($_GET['searchkey']) && !empty($_GET['search']))
  658. {
  659. $criteria="1";
  660. $this->data['Admin']['search'] = $_GET['search'];
  661. $search=addslashes($this->data['Admin']['search']);
  662. $criteria .= " and Admin.admin_user LIKE '".$search."%'";
  663. list($order,$limit,$page) = $this->Pagination->init($criteria);
  664. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  665. }
  666. else if(!empty($_GET['searchkey']) || !empty($_GET['search']))
  667. {
  668. $criteria="1";
  669. if($_GET['searchkey'] == 'block' && empty($_GET['search']))
  670. {
  671. $criteria .= " and Admin.status = '1'";
  672. list($order,$limit,$page) = $this->Pagination->init($criteria);
  673. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  674. //print_r(admins);die();
  675. }
  676. else if($_GET['searchkey'] == 'unblock' && empty($_GET['search']))
  677. {
  678. $criteria .= " and Admin.status = '0'";
  679. list($order,$limit,$page) = $this->Pagination->init($criteria);
  680. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  681. }
  682. else if(!empty($_GET['search']))
  683. {
  684. $this->data['Admin']['search'] = $_GET['search'];
  685. if($_GET['searchkey'] == 'block')
  686. $this->data['Admin']['searchkey'] = 1;
  687. else if($_GET['searchkey'] == 'unblock')
  688. $this->data['Admin']['searchkey'] = 0;
  689. $search=addslashes($this->data['Admin']['search']);
  690. $searchkey=$this->data['Admin']['searchkey'];
  691. $criteria .= " and Admin.admin_user LIKE '".$search."%' and Admin.status='".$searchkey."'";
  692. list($order,$limit,$page) = $this->Pagination->init($criteria);
  693. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  694. }
  695. }
  696. else
  697. {
  698. $criteria= "1";
  699. list($order,$limit,$page) = $this->Pagination->init($criteria);
  700. $this->set('admins', $this->Admin->findAll($criteria, NULL, $order, $limit, $page));
  701. }
  702. }
  703. else
  704. $this->redirect('/rolemasters/noaccess');
  705. }
  706. function updateadmin($id = null)
  707. {
  708. $this->checkSession();
  709. $this->pageTitle = 'Edit Admin';
  710. $this->layout = 'default_after_login';
  711. if (empty($this->data))
  712. {
  713. $this->Admin->id = $_REQUEST['id'];
  714. $this->data = $this->Admin->read(null, $id);
  715. }
  716. else
  717. {
  718. //pr($this->data);
  719. if ($this->Admin->save($this->data))
  720. {
  721. //$this->data['Admin']['menu'] = $_REQUEST['menu_id'];
  722. $this->flash('Your post has been saved.','/admins');
  723. $this->redirect('/admins/manageadmin?menu='.$this->data['Admin']['menu']);
  724. }
  725. }
  726. /*if (empty($this->data))
  727. {
  728. $this->Admin->id = $_REQUEST['id'];
  729. $this->data = $this->Admin->read(null, $id);
  730. }
  731. else
  732. {
  733. $qry="update `admins` set `admin_user`='".$this->data['Admin']['admin_user']."', `admin_pass`='".$this->data['Admin']['admin_pass']."', `admin_email`='".$this->data['Admin']['admin_email']."', `first_name`='".$this->data['Admin']['first_name']."',`last_name`='".$this->data['Admin']['last_name']."', `role_id`='".$this->data['Admin']['role_id']."' where `id`='".$_REQUEST['id']."'";
  734. $res=mysql_query($qry);
  735. if($res)
  736. {
  737. $this->flash('Your post has been updated.','/posts');
  738. $this->redirect('/admins/manageadmin?menu='.$this->data['Admin']['menu']);
  739. }
  740. }*/
  741. }
  742. function viewadmin()
  743. {
  744. $this->checkSession();
  745. $this->pageTitle = 'View Admin';
  746. $this->layout = 'default_after_login';
  747. $id=$_REQUEST['id'];
  748. $this->Admin->id = $id;
  749. $this->set('admins', $this->Admin->read());
  750. }
  751. function delete($id)
  752. {
  753. $this->checkSession();
  754. if(isset($_REQUEST['box']))
  755. {
  756. $arr = $_REQUEST['box'];
  757. foreach($arr as $key => $value)
  758. {
  759. $sql = "delete from `admins` where `id` = '".$value."'";
  760. $res = mysql_query($sql);
  761. }
  762. }
  763. else
  764. {
  765. $id = $_REQUEST['id'];
  766. if($id!=1)
  767. {
  768. $this->Admin->del($id);
  769. $this->flash('The admin with id: '.$id.' has been deleted.', '/admins');
  770. }
  771. }
  772. $this->redirect('/admins/manageadmin?menu='.$_REQUEST['menu_id']);
  773. }
  774. function active()
  775. {
  776. $this->checkSession();
  777. if(isset($_REQUEST['box']))
  778. {
  779. $arr = $_REQUEST['box'];
  780. foreach($arr as $key => $value)
  781. {
  782. $sql = "update `admins` set `status` = '0' where `id` ='".$value."'";
  783. $res = mysql_query($sql);
  784. }
  785. }
  786. else
  787. {
  788. $qry="update `admins` set `status`=0 where `id`='".$_REQUEST['id']."'";
  789. $res=mysql_query($qry);
  790. }
  791. $this->redirect('/admins/manageadmin?menu='.$_REQUEST['menu_id']);
  792. }
  793. function block()
  794. {
  795. $this->checkSession();
  796. if(isset($_REQUEST['box']))
  797. {
  798. $arr = $_REQUEST['box'];
  799. foreach($arr as $key => $value)
  800. {
  801. $sql = "update `admins` set `status` = '1' where `id` ='".$value."'";
  802. $res = mysql_query($sql);
  803. }
  804. }
  805. else
  806. {
  807. $qry="update `admins` set `status`='1' where `id`='".$_REQUEST['id']."'";
  808. $res=mysql_query($qry);
  809. }
  810. $this->redirect('/admins/manageadmin?menu='.$_REQUEST['menu_id']);
  811. }
  812. function paymentsetup()
  813. {
  814. $this->checkSession();
  815. if($_SESSION['Admin_role']==1)
  816. {
  817. $selectRec = "select * from admin_payment_setup where admin_id ='".$_SESSION['Admin_id']."'" ;
  818. $selectRecquery = mysql_query($selectRec);
  819. $this->set('paymentrec',mysql_num_rows($selectRecquery));
  820. if(mysql_num_rows($selectRecquery) > 0)
  821. {
  822. $selectRec_arr = mysql_fetch_array($selectRecquery);
  823. if($selectRec_arr['paypal_email']!="")
  824. {
  825. $this->set('paypalinfo',$selectRec_arr['paypal_email']);
  826. }
  827. else
  828. {
  829. $this->set('paypalinfo','Paypal emailid not set');
  830. }
  831. if($selectRec_arr['gcheckout_email']!="")
  832. {
  833. $this->set('googleinfo',$selectRec_arr['gcheckout_email']);
  834. }else
  835. {
  836. $this->set('googleinfo','Google checkout emailid not set');
  837. }
  838. //$this->set('googleinfo','Google checkout emailid not set');
  839. }
  840. else
  841. {
  842. $this->set('paypalinfo','Paypal email id');
  843. $this->set('googleinfo','Google checkout email id');
  844. }
  845. }
  846. else
  847. {
  848. $this->redirect('/rolemasters/noaccess');
  849. }
  850. }
  851. function savepaymentinfo()
  852. {
  853. $this->checkSession();
  854. $this->pageTitle = 'Payment Setup';
  855. $selectRec = "select * from admin_payment_setup where admin_id ='".$_SESSION['Admin_id']."'" ;
  856. $selectRecquery = mysql_query($selectRec);
  857. if(mysql_num_rows($selectRecquery) > 0)
  858. {
  859. $paysql = "Update admin_payment_setup set paypal_email='".$_REQUEST['paypalemailid']."',gcheckout_email='".$_REQUEST['googlecheckoutemailid']."' where admin_id ='".$_SESSION['Admin_id']."' ";
  860. }
  861. else
  862. {
  863. $paysql = "INSERT INTO admin_payment_setup set paypal_email='".$_REQUEST['paypalemailid']."',gcheckout_email='".$_REQUEST['googlecheckoutemailid']."', admin_id ='".$_SESSION['Admin_id']."' ";
  864. }
  865. @mysql_query($paysql);
  866. $backUrl = "admins/paymentsetup";
  867. $this->redirect($backUrl);
  868. }
  869. function paymentConfig()
  870. {
  871. $this->checkSession();
  872. if($_SESSION['Admin_role']!=1)
  873. $this->redirect('/rolemasters/noaccess');
  874. }
  875. function configedit()
  876. {
  877. $this->checkSession();
  878. if($_SESSION['Admin_role']!=1)
  879. $this->redirect('/rolemasters/noaccess');
  880. }
  881. function saveconfig()
  882. {
  883. $this->checkSession();
  884. if($_SESSION['Admin_role']==1)
  885. {
  886. if($_REQUEST['configval']>=0)
  887. {
  888. $updatesql = "Update admin_payment_config SET config_value='".$_REQUEST['configval']."' where id='".$_REQUEST['hid']."'";
  889. mysql_query($updatesql);
  890. /* Hard Coded for the update in the creative_template_pages table*/
  891. if(isset($_REQUEST['hid']) && $_REQUEST['hid']>0)
  892. {
  893. if($_REQUEST['hid']==45)
  894. {
  895. $tupdatesql = "UPDATE creative_template_pages set price='".$_REQUEST['configval']."' where template_type='1'" ;
  896. }
  897. if($_REQUEST['hid']==46)
  898. {
  899. $tupdatesql = "UPDATE creative_template_pages set price='".$_REQUEST['configval']."' where template_type='0'" ;
  900. }
  901. if($_REQUEST['hid']==47)
  902. {
  903. $tupdatesql = "UPDATE creative_template_pages set price='".$_REQUEST['configval']."' where template_type='2'" ;
  904. }
  905. @mysql_query($tupdatesql);
  906. }
  907. /* Hard Coded for the update in the creative_template_pages table*/
  908. }
  909. }
  910. $this->redirect('admins/paymentConfig');
  911. }
  912. function myaccounthistory()
  913. {
  914. $this->checkSession();
  915. $this->layout = 'default_user';
  916. ####################################################### ADMIN RELATED INFORMATOION
  917. $queryAdminPaymentSetup=mysql_query("SELECT paypal_email,gcheckout_email FROM admin_payment_setup WHERE admin_id='1'") or die("Error on line :".__LINE__.mysql_error());
  918. $fetchAdminPaymentSetup=mysql_fetch_assoc($queryAdminPaymentSetup);
  919. $this->set('profilpaypalemail',$fetchAdminPaymentSetup['paypal_email']);
  920. $gprofileid = explode('break',$fetchAdminPaymentSetup['gcheckout_email']);
  921. if(isset($gprofileid['0']))
  922. $this->set('profilGmerchantID',$gprofileid['0']);
  923. if(isset($gprofileid['1']))
  924. $this->set('profilGmerchantKey',$gprofileid['1']);
  925. ####################################################### ADMIN RELATED INFORMATOION
  926. //Get the payment details
  927. $getTotalPayment="
  928. SELECT sum(amount * if(DrCr = '+1',1,-1)) totalPaymentAmount, amount, DrCr ,'1' as tempid
  929. FROM xouser_transaction_details
  930. WHERE
  931. (xouser_transaction_details.payment_to='1' and xouser_transaction_details.DrCr='+1') OR xouser_transaction_details.user_id='1'
  932. GROUP BY tempid";
  933. $queryGetTotalPayment=mysql_fetch_assoc(mysql_query($getTotalPayment));
  934. $this->set("totalPaymentAmount",$queryGetTotalPayment['totalPaymentAmount']);
  935. ####################################################### USER RELATED INFORMATOION
  936. $pagehead='My Account';
  937. $urlshow='full';
  938. if(!isset($_REQUEST['show']))
  939. {
  940. $pagehead = 'All Account Activity';
  941. $extradd = " ";
  942. }
  943. if(isset($_REQUEST['show']) && $_REQUEST['show']=='full')
  944. {
  945. $pagehead = 'All Account Activity';
  946. $extradd = " ";
  947. }
  948. if(isset($_REQUEST['show']) && $_REQUEST['show']=='sent')
  949. {
  950. $pagehead = 'Payment Sent';
  951. $urlshow='sent';
  952. $extradd = " AND xotrandetail.DrCr = '-1'";
  953. }
  954. if(isset($_REQUEST['show']) && $_REQUEST['show']=='recieved')
  955. {
  956. $pagehead = 'Payments recieved';
  957. $urlshow='recieved';
  958. $extradd = " AND xotrandetail.DrCr = '+1'";
  959. }
  960. $this->pageTitle = $pagehead;
  961. $this->set('pageHead',$pagehead);
  962. $this->set('pageType',$urlshow);
  963. $select ="SELECT IF (xotrandetail.DrCr = '+1', 'From', 'To') AS tranfromto,IF (xotrandetail.user_id=1,if(xotrandetail.payment_to>1,paiduser.username,'admin'), users.username) AS tranName, (SELECT DATE_FORMAT( xotran.transaction_date, GET_FORMAT( DATE, 'USA' ) )) AS trandate, xotrandetail.id, xotrandetail.amount AS tranfee,xotran.invoice , xotran.transaction_desc ,
  964. xotrandetail.amount as tranAmount, IF (xotrandetail.DrCr = '+1',1,-1) AS sumoperation ,xotran.transaction_head, xotrandetail.payment_to ";
  965. $from="FROM xouser_transaction_details xotrandetail
  966. LEFT JOIN users ON (xotrandetail.user_id>1 and xotrandetail.user_id = users.id )
  967. LEFT JOIN users paiduser ON (xotrandetail.payment_to>1 and xotrandetail.payment_to = paiduser.id )
  968. LEFT JOIN xouser_transactions xotran ON ( xotrandetail.xouser_transaction_id = xotran.id )
  969. ";
  970. $where="WHERE 1 ".$extradd." AND (xotrandetail.payment_to='1' and DrCr='+1') OR xotrandetail.user_id='1' " ;
  971. ################# SEARCH CRITERIA ########
  972. if(isset($_REQUEST['serachtype']) && $_REQUEST['serachtype']=='within')
  973. {
  974. $withinType=$this->data['User']['within'];
  975. $week=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),(date("d")-7),date("Y")));
  976. $month=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),(date("m")-1),date("d"),date("Y")));
  977. $year=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),date("d"),(date("Y")-1)));
  978. $date=date("Y-m-d G:i:s");
  979. if($this->data['User']['within']=="past")
  980. { $curDate=$date; $this->set("curDate",$curDate); }
  981. if($this->data['User']['within']=="week")
  982. { $past=$week; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  983. if($this->data['User']['within']=="month")
  984. { $past=$month; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  985. if($this->data['User']['within']=="year")
  986. { $past=$year; $curDate=$date; $this->set("past",$past); $this->set("curDate",$curDate); }
  987. }
  988. if(isset($_REQUEST['serachtype']) && $_REQUEST['serachtype']=='daterange')
  989. {
  990. $this->set("past");
  991. $past=0;
  992. $curDate=0;
  993. $this->set("curDate");
  994. $fromDate=$_REQUEST['frmyear']."-".$_REQUEST['frmmonth']."-".$_REQUEST['frmday'];
  995. $len=strlen($fromDate);
  996. if($len==10)
  997. {
  998. $dateF=date("Y-m-d",strtotime($fromDate));
  999. $past=$dateF;
  1000. $this->set("past",$past);
  1001. }
  1002. else
  1003. {
  1004. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1005. }
  1006. $toDate=$_REQUEST['toyear']."-".$_REQUEST['tomonth']."-".$_REQUEST['todate'];
  1007. $len=strlen($toDate);
  1008. if($len==10)
  1009. {
  1010. $dateT=date("Y-m-d",strtotime($toDate));
  1011. $curDate=$dateT;
  1012. $this->set("curDate",$curDate);
  1013. }
  1014. else
  1015. {
  1016. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1017. }
  1018. }
  1019. if(isset($this->params['url']['cdate']))
  1020. $curDate=$this->params['url']['cdate'];
  1021. if(isset($this->params['url']['past']))
  1022. $past=$this->params['url']['past'];
  1023. if(isset($_REQUEST['serachtype']))
  1024. {
  1025. if(isset($withinType) && $withinType=="past")
  1026. $where.=" AND xotrandetail.creation < '".$curDate."'";
  1027. else
  1028. $where.=" AND xotrandetail.creation BETWEEN '".$past."' AND '".$curDate."'";
  1029. }
  1030. if(isset($fDate) && $fDate!=0 && isset($tDate) && $tDate!=0)
  1031. $where.=" AND xotrandetail.creation BETWEEN '".$fDate."' AND '".$tDate."'";
  1032. ##########################################
  1033. // echo $select.$from.$where;
  1034. $others=" order By xotrandetail.id asc";
  1035. $PassParameter="show=".$urlshow ;
  1036. if(isset($curDate))
  1037. $PassParameter.="&cdate=".$curDate."&";
  1038. if(isset($past))
  1039. $PassParameter.="&past=".$past."&";
  1040. if(isset($fDate))
  1041. $PassParameter.="&fd=".$fDate."&";
  1042. if(isset($tDate))
  1043. $PassParameter.="&td=".$tDate."&";
  1044. if(isset($this->params['url']['serachtype']) || isset($_REQUEST['serachtype']))
  1045. $PassParameter.="&serachtype=".$radio."&";
  1046. $fltr='';
  1047. $CountField="xotrandetail.id";
  1048. $this->set("controller","admins");
  1049. $this->set("action","myaccounthistory");
  1050. $this->set("parameter",$PassParameter);
  1051. $this->set("fltr",$fltr);
  1052. //echo $select.$from.$where.$others ;
  1053. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1054. $this->set("paymentMethods",$this->getPaymentMethods(1));
  1055. if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") || isset($_REQUEST['serachtype']))
  1056. {
  1057. $this->set('pagehead',$pagehead);
  1058. $this->render("myaccounthistory2","ajax");
  1059. }
  1060. }
  1061. function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
  1062. {
  1063. if(isset($arg['Page']))
  1064. $pageFlag=$arg['Page'];
  1065. $this->set("PassParameter",$PassParameter);
  1066. $SetUserNumberOfVpsPerPage=10; /* Defined in config->paths.php*/
  1067. $this->set("BackgroundClass",'pagination');
  1068. $this->set("SelectedPage",'pagination_over');
  1069. $this->set("Linkpage",'pagination_over');
  1070. $this->set("FirstImage",'fdd.gif');
  1071. $this->set("PreviousImage",'previous.gif');
  1072. $this->set("NextImage",'next.gif');
  1073. $this->set("LastImage",'rewd.gif');
  1074. $UserNumberOfVpsPerPage=10; /* Defined in config->paths.php*/
  1075. if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
  1076. $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
  1077. if(!isset($arg['Page'])) $arg['Page']=1;
  1078. if(!isset($arg['Offset'])) $arg['Offset']=0;
  1079. $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
  1080. //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
  1081. //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
  1082. $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
  1083. $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
  1084. $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
  1085. if($arg['Offset']==$NoOfVps)
  1086. {
  1087. if(isset($Offset))
  1088. {
  1089. $Offset=$Offset-$NumberOfVpsPerPage;
  1090. $Page--;
  1091. if($Offset<0)
  1092. {
  1093. $Offset=0;$Page=1;
  1094. }
  1095. }else{
  1096. $Offset=0;$Page=1;
  1097. }
  1098. }
  1099. $this->set("Page",$arg['Page']);
  1100. $this->set("Offset",$arg['Offset']);
  1101. $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
  1102. $this->set("NoOfPages",$NoOfPages);
  1103. $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
  1104. //print "$select $from $where $others";
  1105. $this->set("qryOthr","$select $from $where)");
  1106. $this->set("tesrqryOthr","$where $others)");
  1107. //echo $NumberOfVpsPerPage;
  1108. //echo "$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage" ;die();
  1109. $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
  1110. $this->set("query",$SelectRecord);
  1111. }
  1112. }
  1113. ?>