Advertisement
Guest User

full6

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