Guest User

test1

a guest
Dec 21st, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.73 KB | None | 0 0
  1. <?php
  2.  
  3. include 'home.php';
  4.  
  5. $is_admin = false;
  6. $user_home = new USER();
  7.  
  8. /* to show selected date */
  9.  
  10. if (isset($_POST['post_at']) && $_POST['post_at'] != '')
  11. {
  12. $orderFromDate = $_POST['post_at'] . " 00:00:00 ";
  13. }
  14. else
  15. {
  16. $orderFromDate = '';
  17. }
  18.  
  19. if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '')
  20. {
  21. $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 ";
  22. }
  23. else
  24. {
  25. $orderToDate = '';
  26. }
  27.  
  28. /* to show selected date end*/
  29.  
  30. function getDesignerName($designerId)
  31. {
  32. $user_home = new USER();
  33. if (!$user_home->is_logged_in())
  34. {
  35. $user_home->redirect('index.php');
  36. }
  37.  
  38. $stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
  39. $stmt->execute(array(
  40. ":uid" => $designerId
  41. ));
  42. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  43. return $row['name'];
  44. }
  45.  
  46. /* Fetching magento db details end */
  47.  
  48. function getDesignerCollection()
  49. {
  50. global $is_admin;
  51. $user_home = new USER();
  52. require_once '../../app/Mage.php';
  53.  
  54. Mage::app();
  55.  
  56. $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
  57. $stmts->execute(array(
  58. ":uid" => $_SESSION['userSession']
  59. ));
  60. $rows = $stmts->fetch(PDO::FETCH_ASSOC);
  61.  
  62. $stmt = $user_home->runQuery("SELECT * FROM order_details");
  63. $stmt->execute(array(":uid" => $_SESSION['userSession']));
  64. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  65. $stmt->execute();
  66.  
  67. /* date search */
  68. if (isset($_POST['post_at']) && $_POST['post_at'] != '')
  69. {
  70. $orderFromDate = $_POST['post_at'] . " 00:00:00 ";
  71.  
  72. }
  73. else
  74. {
  75. $orderFromDate = '';
  76. }
  77.  
  78. if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '')
  79. {
  80. $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 ";
  81.  
  82. }
  83. else
  84. {
  85. $orderToDate = '';
  86. }
  87. /* date search end*/
  88.  
  89. $accountType = $rows['type'];
  90. if ($accountType == "admin")
  91. {
  92. $is_admin = true;
  93. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
  94. 'nin' => '0'
  95. ));
  96. if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
  97. 'gteq' => $orderFromDate
  98. ));
  99. if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
  100. 'lteq' => $orderToDate
  101. ));
  102. }
  103. else
  104. {
  105. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
  106. 'like' => '%' . $_SESSION['userSession'] . '%'
  107. ));
  108. if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
  109. 'gteq' => $orderFromDate
  110. ));
  111. if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
  112. 'lteq' => $orderToDate
  113. ));
  114. }
  115.  
  116. /* Fetching magento db details end */
  117.  
  118. $i = 0;
  119. foreach($order as $orderData)
  120. {
  121. $k = 0;
  122. $orderitems = $orderData['dproduct_id'];
  123. $orderitemsarray = explode(",", $orderitems);
  124.  
  125. $oDate = new DateTime($orderData['created_at']);
  126. $sDate = $oDate->format("M d, Y");
  127.  
  128. while ($k < count($orderitemsarray))
  129.  
  130. {
  131.  
  132. if ($orderitemsarray[$k] != '0')
  133. {
  134.  
  135. $stmtorders = $user_home->runQuery("SELECT * FROM order_details");
  136. $stmtorders->execute(array(":dorder_id" => $orderData['entity_id']));
  137.  
  138. $roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
  139.  
  140. $dorderStatus = $roworders['dpaid_status'];
  141.  
  142. $productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
  143. $designer_id = $productdetail->getDesignerID() ;
  144.  
  145. if($accountType == "admin")
  146. {
  147. $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
  148.  
  149. $stmt1 = $user_home->runQuery("SELECT * FROM order_details WHERE dproduct_id=:pid and designerorder_id=:doid");
  150. $stmt1->execute(array(
  151. ":doid" => $orderData->getIncrementId(),
  152. ":pid" => $orderitemsarray[$k],
  153. ));
  154.  
  155. $paid_status='';
  156. $delivery_status='';
  157. $due_date='';
  158.  
  159. while($datas = $stmt1->fetch())
  160.  
  161. {
  162. $paid_status=$datas['dpaid_status'];
  163. $delivery_status=$datas['delivery_status'];
  164. $due_date=$datas['due_date'];
  165. $oDate1 = new DateTime($datas['due_date']);
  166. $sDate1 = $oDate1->format("M d, Y");
  167.  
  168.  
  169. if($datas['dpaid_status']=='P'){$paid_status='Paid';}
  170. if($datas['dpaid_status']=='U'){$paid_status='Unpaid';}
  171.  
  172. if($datas['delivery_status']=='P'){$delivery_status='Pending';}
  173. if($datas['delivery_status']=='D'){$delivery_status='Delivered';}
  174. if($datas['delivery_status']=='R'){$delivery_status='Returned';}
  175. if($datas['delivery_status']=='C'){$delivery_status='Cancelled';}
  176.  
  177. }
  178.  
  179. if ( $paid_status == ''){
  180. $paid_status='blank';
  181. }
  182.  
  183. if ( $delivery_status == ''){
  184. $delivery_status='blank1';
  185. }
  186.  
  187.  
  188.  
  189.  
  190. $stmt = $user_home->runQuery("SELECT commission1 FROM tbl_users where userID=:uid"); //I assume user_id is field of database in tbl_user table
  191. $stmt->execute(array(":uid" => $_SESSION['userSession']));
  192. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  193. $commission = $row['commission1'] ;
  194.  
  195. $responce[] = array(
  196. $orderData->getIncrementId() ,
  197. $orderData->getIncrementId() ,
  198. $orderitemsarray[$k],
  199. $productdetail->getName() ,
  200. $designerName,
  201. $orderData['status'], // magento [ pending / processing/complete]
  202. $orderData['grand_total'], // magento
  203. $orderData['customer_email'], // magento
  204. $commission,
  205. $paid_status,
  206. $delivery_status,
  207. $due_date,
  208. $sDate // magento
  209. );
  210.  
  211. }
  212.  
  213. else
  214. {
  215.  
  216. if( $designer_id== $_SESSION['userSession'] )
  217. {
  218. $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
  219.  
  220. $stmt1 = $user_home->runQuery("SELECT * FROM order_details WHERE dproduct_id=:pid and designerorder_id=:doid");
  221. $stmt1->execute(array(
  222. ":doid" => $orderData->getIncrementId(),
  223. ":pid" => $orderitemsarray[$k],
  224. ));
  225.  
  226. $paid_status='';
  227. $delivery_status='';
  228. $due_date='';
  229.  
  230. while($datas = $stmt1->fetch())
  231.  
  232.  
  233. {
  234. $paid_status=$datas['dpaid_status'];
  235. $delivery_status=$datas['delivery_status'];
  236. $due_date=$datas['due_date'];
  237.  
  238. if($datas['dpaid_status']=='P'){$paid_status='Paid';}
  239. if($datas['dpaid_status']=='U'){$paid_status='Unpaid';}
  240.  
  241. if($datas['delivery_status']=='P'){$delivery_status='Pending';}
  242. if($datas['delivery_status']=='D'){$delivery_status='Delivered';}
  243. if($datas['delivery_status']=='R'){$delivery_status='Returned';}
  244. if($datas['delivery_status']=='C'){$delivery_status='Cancelled';}
  245.  
  246. }
  247.  
  248. if ( $paid_status == ''){
  249. $paid_status='blank';
  250. }
  251.  
  252. if ( $delivery_status == ''){
  253. $delivery_status='blank1';
  254. }
  255.  
  256.  
  257. $stmt = $user_home->runQuery("SELECT commission1 FROM tbl_users where userID=:uid"); //I assume user_id is field of database in tbl_user table
  258. $stmt->execute(array(":uid" => $_SESSION['userSession']));
  259. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  260. $commission = $row['commission1'] ;
  261.  
  262.  
  263.  
  264. $responce[] = array(
  265. $orderData->getIncrementId() ,
  266. $orderData->getIncrementId() ,
  267. $orderitemsarray[$k],
  268. $productdetail->getName() ,
  269. $designerName,
  270. $orderData['status'], // magento [ pending / processing/complete]
  271. $orderData['grand_total'], // magento
  272. $orderData['customer_email'], // magento
  273. $commission,
  274. $paid_status,
  275. $delivery_status,
  276. $due_date,
  277. $sDate // magento
  278. );
  279. }
  280.  
  281. }
  282.  
  283. }
  284.  
  285. $k++;
  286. $i++;
  287. }
  288.  
  289.  
  290. } // foreach
  291.  
  292.  
  293. return json_encode($responce);
  294.  
  295. } // designer collection
  296.  
  297.  
  298.  
  299.  
  300. ?>
  301.  
  302. <head>
  303.  
  304. <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  305. <script src= "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>
  306.  
  307. <link rel="stylesheet" href="assets/css/jquery-ui.css">
  308. <script src="assets/js/jquery-1.10.2.js"></script>
  309. <script src="assets/js/jquery-ui.js"></script>
  310. <script src="assets/js/jquery-ui.js"></script>
  311.  
  312.  
  313. <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_msg_en.js"></script>
  314. <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_grid_all.js"></script>
  315.  
  316.  
  317. <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/skinstyle.css"/>
  318. <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/gt_grid.css"/>
  319. <h2> Orders</h2><div id="msgresult" style="display:none;color:blue;text-align:center;">Paid status changed.</div>
  320.  
  321. </head>
  322.  
  323.  
  324. <div>
  325. <div class="delete_grid" >
  326.  
  327. <form>
  328. Search:
  329. <select id="f_value2">
  330. <option value="entity_id">Order Id</option>
  331. <option value="designer_id">Designer Id</option>
  332. </select>
  333. <input type="text" onkeyup="doFilter()" value="" id="f_value1" >
  334. <input type="reset" value="Reset" onClick="window.location.reload()">
  335. </form>
  336.  
  337. <br/>
  338.  
  339.  
  340.  
  341. <form name="frmSearch" method="post" action="">
  342. <input type="text" placeholder="From Date" id="post_at"
  343.  
  344. value="<?php
  345.  
  346. if ($orderFromDate != '')
  347. {
  348.  
  349. $newPostStartDate = date('Y-m-d', strtotime($_POST['post_at']));
  350. echo $newPostStartDate;
  351.  
  352. } ?>" name="post_at" />
  353.  
  354. <input type="text" placeholder="To Date" id="post_at_to_date"
  355.  
  356.  
  357. value="<?php
  358.  
  359. if ($orderToDate != '')
  360. {
  361.  
  362.  
  363. $newPostEndDate = date('Y-m-d', strtotime($_POST['post_at_to_date']));
  364. echo $newPostEndDate;
  365.  
  366. } ?>"name="post_at_to_date" />
  367.  
  368. <input type="submit" name="search" value="search" id="searchButton">
  369.  
  370.  
  371.  
  372. <input type="button" value="Reset" id="clear-dates">
  373. </form>
  374.  
  375.  
  376. <br/>
  377.  
  378. <?php
  379.  
  380. $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
  381. $stmts->execute(array(
  382. ":uid" => $_SESSION['userSession']
  383. ));
  384. $rows = $stmts->fetch(PDO::FETCH_ASSOC);
  385.  
  386. $accountType = $rows['type'];
  387. if ($accountType == "admin")
  388. {
  389. ?>
  390.  
  391.  
  392. <div class="delete_grid_select">
  393.  
  394. <div class="delete_grid_select1" id = "hide">
  395.  
  396. <form action='' method="post" enctype="multipart/form-data">
  397. <input type="hidden" name="delete_package_id" id="delete_package_id" value=""/>
  398. P/U:
  399.  
  400. <select name="massaction" id="massaction">
  401. <option value="">Select</option>
  402. <option value="P">Paid</option>
  403. <option value="U">Unpaid</option>
  404. </select>
  405.  
  406. <input type="button" value="Submit" id="delete-grid-button" onclick="massAction()" />
  407. </form>
  408.  
  409. <form action='' method="post" enctype="multipart/form-data">
  410. <input type="hidden" name="delete_package_id1" id="delete_package_id1" value=""/>
  411. P/D/R/C:
  412.  
  413. <select name="massaction1" id="massaction1">
  414. <option value="">Select</option>
  415. <option value="P">Pending</option>
  416. <option value="D">Delivered</option>
  417. <option value="R">Returned</option>
  418. <option value="C">Cancelled</option>
  419. </select>
  420.  
  421. <input type="button" value="Submit" id="delete-grid-button" onclick="massAction1()" />
  422. </form>
  423.  
  424.  
  425. </div>
  426.  
  427. <?php
  428. }
  429. else
  430. {
  431.  
  432. ?>
  433. <style type="text/css">
  434. #hide { display:none; }
  435. </style>
  436.  
  437. <?php
  438. }
  439. ?>
  440.  
  441. </div>
  442.  
  443.  
  444. </div>
  445. </div>
  446. <div id="myGrid"></div>
  447.  
  448. <script type="text/javascript">
  449.  
  450. var __TEST_DATA__=eval('<?php
  451. echo getDesignerCollection(); ?>');
  452. var grid_demo_id = "myGrid" ;
  453. var dsOption= {
  454. fields :[
  455. {name : 'entity_id' },
  456. {name : 'entity_id' },
  457. {name : 'product_id' },
  458. {name : 'product_name'},
  459. {name : 'designer_id' },
  460. {name : 'status' },
  461. {name : 'grand_total' },
  462. {name : 'customer_email' },
  463. {name : 'commission1' },
  464. {name : 'dpaid_status' },
  465. {name : 'delivery_status' },
  466. {name : 'due_date' },
  467. {name : 'created_at'},
  468. ],
  469. recordType : 'array',
  470. data : __TEST_DATA__
  471. }
  472.  
  473.  
  474. function my_renderId(value ,record,columnObj,grid,colNo,rowNo)
  475. {
  476. var no= record[columnObj.fieldIndex];
  477.  
  478. return "<input type='checkbox' value='"+record[0]+"-"+record[2]+"' name='userID[]'/>";
  479.  
  480. }
  481.  
  482. var colsOption = [
  483. {id: '' , header: "" , width :"15",renderer : my_renderId , width :"60"},
  484. {id: 'created_at' , header: "Order Date" , width :"120"},
  485. {id: 'entity_id' , header: "Order Id" , width :"75"},
  486. {id: 'product_id' , header: "Product Id" , width :"70"},
  487. {id: 'product_name' , header: "Product Name" , width :"200"},
  488. <?php if ($is_admin) echo "{id: 'designer_id' , header: 'Designer' , width :'110'},"; ?>
  489. // {id: 'status' , header: "Order Status" , width :"100"},
  490. // {id: 'grand_total' , header: " Order Amount" , width :"120"},
  491. // {id: 'customer_email' , header: "User Email" , width :"150"},
  492. {id: 'dpaid_status' , header: "Paid status" , width :"80"},
  493. {id: 'commission1' , header: "commission1" , width :"80"},
  494. {id: 'delivery_status' , header: "Deliver Status" , width :"130"},
  495. {id: 'due_date' , header: "Payment Due Date" , width :"140"},
  496.  
  497. ];
  498.  
  499. var gridOption={
  500. id : grid_demo_id,
  501.  
  502. // height: "285", //"100%", // 330,
  503.  
  504. pageSize:30,
  505. pageSizeList : [5,10,15,20],
  506. container : 'myGrid',
  507. replaceContainer : true,
  508. sortable : false,
  509.  
  510. dataset : dsOption ,
  511. columns : colsOption ,
  512. toolbarContent : 'nav goto | pagesize | filter state | sortable | search',
  513. onRowClick:function(value, record , cell, row, colNO, rowNO,columnObj,grid){
  514. }
  515. };
  516. var mygrid=new Sigma.Grid(gridOption);
  517. Sigma.Util.onLoad( Sigma.Grid.render(mygrid) );
  518.  
  519. function doFilter() {
  520. var filterInfo=[
  521. {
  522. fieldName : $('select[id=f_value2]').val(),
  523. logic : "startWith",
  524. value : Sigma.Util.getValue("f_value1")
  525. },
  526. {
  527. fieldName : Sigma.Util.getValue("f_fieldName12"),
  528. logic : "greatEqual",
  529. value : Sigma.Util.getValue("f_value12")
  530. }
  531. ]
  532. var grid=Sigma.$grid("myGrid");
  533. var rowNOs=grid.applyFilter(filterInfo);
  534. }
  535. function doUnfilter(){
  536. var grid=Sigma.$grid("myGrid1");
  537. var rowNOs=grid.unfilterGrid();
  538.  
  539. }
  540.  
  541.  
  542. function doUnfilter(){
  543. var grid=Sigma.$grid("myGrid1");
  544. var rowNOs=grid.unfilterGrid();
  545.  
  546. }
  547.  
  548. // payment
  549.  
  550. function massAction()
  551. {
  552. var e=document.getElementById("massaction");
  553. var strUser = e.options[e.selectedIndex].value;
  554.  
  555. massStatusChangeVerified(strUser);
  556.  
  557. }
  558.  
  559. // payment end
  560.  
  561. // Delivery
  562. function massAction1()
  563. {
  564. var e=document.getElementById("massaction1");
  565. var strUser1 = e.options[e.selectedIndex].value;
  566.  
  567. massStatusChangeVerified1(strUser1);
  568.  
  569. }
  570.  
  571. //Delivery end
  572.  
  573. //payment
  574.  
  575. function massStatusChangeVerified(status)
  576. {
  577. var vals = "";
  578. var checkboxes=$("input[name='userID[]']:checked").each( function () {
  579.  
  580. vals += ","+$(this).val();
  581.  
  582. })
  583. alert(vals);
  584. if(vals=='')
  585. {
  586. alert("No record selected");
  587. return false;
  588. }
  589. retactiveVal=confirm("Are you sure want to Change the status");
  590. if( retactiveVal == true )
  591. {
  592. if (vals) vals = vals.substring(1);
  593. document.getElementsByName('delete_package_id').value=vals;
  594. var url="http://sbdev2.kidsdial.com:81/php/site6/update_order_status.php?designer_id="+vals+"&order_status="+status;
  595. var request = jQuery.ajax( {
  596. url: url ,
  597. type: 'POST',
  598. } );
  599.  
  600. request.done( function (result)
  601. {
  602. document.getElementById('msgresult').style.display="block";
  603. var explode = function(){
  604. location.reload();
  605. };
  606. setTimeout(explode, 2000);
  607.  
  608.  
  609. } );
  610. request.fail( function ( error )
  611. {
  612. console.dir(error);
  613. } );return true;
  614. }else{
  615. return false;
  616. }
  617.  
  618. }
  619.  
  620. // payment end
  621.  
  622. //Delivery
  623.  
  624.  
  625. function massStatusChangeVerified1(status)
  626. {
  627. var vals = "";
  628. var checkboxes=$("input[name='userID[]']:checked").each( function () {
  629.  
  630. vals += ","+$(this).val();
  631.  
  632. })
  633. alert(vals);
  634. if(vals=='')
  635. {
  636. alert("No record selected");
  637. return false;
  638. }
  639. retactiveVal=confirm("Are you sure want to Change the status");
  640. if( retactiveVal == true )
  641. {
  642. if (vals) vals = vals.substring(1);
  643. document.getElementsByName('delete_package_id1').value=vals;
  644. var url="http://sbdev2.kidsdial.com:81/php/site6/update_delivery_status.php?designer_id="+vals+"&delivery_status="+status;
  645. var request = jQuery.ajax( {
  646. url: url ,
  647. type: 'POST',
  648. } );
  649.  
  650. request.done( function (result)
  651. {
  652. document.getElementById('msgresult').style.display="block";
  653. var explode = function(){
  654. location.reload();
  655. };
  656. setTimeout(explode, 2000);
  657.  
  658.  
  659. } );
  660. request.fail( function ( error )
  661. {
  662. console.dir(error);
  663. } );return true;
  664. }else{
  665. return false;
  666. }
  667.  
  668. }
  669.  
  670. //Delivery end
  671.  
  672. <!-- Date Picker -->
  673.  
  674.  
  675. jQuery.datepicker.setDefaults({
  676. showOn: "button",
  677. buttonImage: "assets/img/datepicker.png",
  678. buttonText: "Date Picker",
  679. buttonImageOnly: true,
  680. dateFormat: 'yy-mm-dd'
  681. });
  682. $(function() {
  683. $("#post_at").datepicker();
  684. $("#post_at_to_date").datepicker();
  685. });
  686.  
  687.  
  688. <!-- reset date -->
  689. var $dates = $('#post_at, #post_at_to_date').datepicker();
  690.  
  691.  
  692. $("#clear-dates").click(function(){
  693. location.reload();
  694. $("#post_at").removeAttr('value');
  695. $("#post_at_to_date").removeAttr('value');
  696. if(!$("#post_at_to_date").val()) {
  697. $( "#searchButton" ).trigger( "click" );
  698. }
  699. });
  700.  
  701. </script>
Add Comment
Please, Sign In to add comment