Guest User

gottttt

a guest
Nov 22nd, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "123456";
  5. $password = "123456";
  6. $dbname = "123456";
  7.  
  8. include 'home.php';
  9. $user_home = new USER();
  10.  
  11.  
  12. echo "<pre>";print_r($_POST);
  13.  
  14. // Create connection
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16. // Check connection
  17. if ($conn->connect_error) {
  18. die("Connection failed: " . $conn->connect_error);
  19. }
  20.  
  21. $stmt = $user_home->runQuery("SELECT * FROM tbl_users");
  22. $stmt->execute(array(":uid" => $_SESSION['userSession']));
  23. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  24. $stmt->execute();
  25. $queryCondition='';
  26. // echo 'SELECT * FROM order_details '.$queryCondition;
  27. ?>
  28.  
  29. <?php
  30.  
  31. function getDesignerCollection()
  32. {
  33. $user_home = new USER();
  34. require_once '../../app/Mage.php';
  35. Mage::app();
  36. $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
  37. $stmts->execute(array(":uid"=>$_SESSION['userSession']));
  38. $rows = $stmts->fetch(PDO::FETCH_ASSOC);
  39.  
  40. $accountType=$rows['type'];
  41. if($accountType=="admin"){
  42.  
  43. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id',array('nin'=>'0'));
  44.  
  45. }
  46. else
  47. {
  48. $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id',array('like' => '%'.$_SESSION['userSession'].'%'));
  49. }
  50.  
  51. $i=0;
  52. foreach ($order as $orderData)
  53. {
  54.  
  55. $orderitems=$orderData['dproduct_id'];
  56. $orderitemsarray=explode(",",$orderitems);
  57. $k=0;
  58.  
  59. $oDate = new DateTime($orderData['created_at']);
  60. $sDate = $oDate->format("Y-m-d");
  61. while($k < count($orderitemsarray))
  62. {
  63. if($orderitemsarray[$k]!='0')
  64. {
  65.  
  66. $stmtorders = $user_home->runQuery("SELECT * FROM order_details WHERE designerorder_id=:designerorder_id");
  67. $stmtorders->execute(array(":designerorder_id"=>$orderData['entity_id']));
  68.  
  69. $roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
  70.  
  71. if($roworders['designerorder_id']==''){$dorderStatus="Unpaid";}else{$dorderStatus=$roworders['paid_status'];}
  72.  
  73. $productdetail=Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
  74.  
  75. $responce[]=array($orderData->getIncrementId(),$orderData->getIncrementId(),$orderitemsarray[$k],$productdetail->getName(),$designerName,$orderData['status'],$orderData['grand_total'],$orderData['customer_email'],$orderData['shipping_description'],$dorderStatus,$sDate);
  76.  
  77. }
  78. $k++; $i++;
  79. }
  80.  
  81. } echo json_encode($responce);
  82.  
  83. }
  84.  
  85. /* Date */
  86. $reg_user='';
  87.  
  88. //$post_at = "";
  89. //$post_at_to_date = "";
  90.  
  91. $post_at = '0000-00-00';
  92. $post_at_todate = '0000-00-00';
  93.  
  94. $queryCondition = "";
  95.  
  96. if( !empty( $_POST[ 'post_at' ] ) )
  97. {
  98. $post_at = date( 'Y-m-d', strtotime( $_POST[ 'post_at' ] ) );
  99. $post_at_todate = date( 'Y-m-d' );
  100. if( !empty( $_POST[ 'post_at_to_date' ] ) )
  101. {
  102. $post_at_to_date = date( 'Y-m-d', strtotime( $_POST[ 'post_at_to_date' ] ) );
  103. $post_at_todate = $post_at_to_date;
  104. }
  105. $queryCondition .= "WHERE DATE( created_at ) >= '" . $post_at . "' AND DATE( created_at ) <= '" . $post_at_todate . "'";
  106. }
  107.  
  108. $sqlquery = "SELECT * FROM order_details $queryCondition";
  109. //$sqlquery = "SELECT * FROM order_details where created_at >= '2016-11-17' AND created_at < = '2016-11-19'";
  110. var_dump( $sqlquery );
  111.  
  112.  
  113.  
  114.  
  115. $result = $conn->query($sqlquery);
  116.  
  117. if ($result->num_rows > 0) {
  118. echo $result->num_rows.'result found'."<br>";
  119. while($row = $result->fetch_assoc()) {
  120. echo "id: " . $row["id"]. " - date: " . $row["post_at"];
  121. echo "<br>";
  122. }
  123. } else {
  124. echo "0 results found <br>";
  125. }
  126. $conn->close();
  127. ?>
  128.  
  129. <head>
  130.  
  131. <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  132. <script src= "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>
  133.  
  134. <link rel="stylesheet" href="assets/css/jquery-ui.css">
  135. <script src="assets/js/jquery-1.10.2.js"></script>
  136. <script src="assets/js/jquery-ui.js"></script>
  137. <script src="assets/js/jquery-ui.js"></script>
  138.  
  139. <script>
  140. jQuery.datepicker.setDefaults({
  141. showOn: "button",
  142. buttonImage: "datepicker.png",
  143. buttonText: "Date Picker",
  144. buttonImageOnly: true,
  145. dateFormat: 'yy-mm-dd'
  146. });
  147. $(function() {
  148. $("#post_at").datepicker();
  149. $("#post_at_to_date").datepicker();
  150. });
  151. </script>
  152.  
  153. <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_msg_en.js"></script>
  154. <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_grid_all.js"></script>
  155.  
  156.  
  157. <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/skinstyle.css"/>
  158. <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/gt_grid.css"/>
  159.  
  160. </head>
  161.  
  162. <div>
  163. <div class="delete_grid" >
  164. Search:
  165. <select id="f_value2">
  166. <option value="entity_id">Order Id</option>
  167. <option value="designer_id">Designer Id</option>
  168. </select>
  169. <input type="text" onkeyup="doFilter()" value="" id="f_value1" >
  170.  
  171.  
  172. <br/>
  173.  
  174. <form name="frmSearch" method="post" action="">
  175. <input type="text" placeholder="From Date" id="post_at" value="" name="post_at" />
  176. <input type="text" placeholder="To Date" id="post_at_to_date" value="" name="post_at_to_date" />
  177. <input type="submit" name="search" value="search" />
  178. </form>
  179. </div>
  180. </div>
  181. <div id="myGrid"></div>
  182.  
  183. <script type="text/javascript">
  184.  
  185. var __TEST_DATA__=eval('<?php echo getDesignerCollection();?>');
  186. var grid_demo_id = "myGrid" ;
  187. var dsOption= {
  188. fields :[
  189. {name : 'entity_id' },
  190. {name : 'entity_id' },
  191. {name : 'product_id' },
  192. {name : 'product_name'},
  193. {name : 'designer_id' },
  194. {name : 'status' },
  195. {name : 'grand_total' },
  196. {name : 'customer_email' },
  197. {name : 'shipping_description' },
  198. {name : 'paid_status' },
  199. {name : 'created_at'},
  200. ],
  201. recordType : 'array',
  202. data : __TEST_DATA__
  203. }
  204.  
  205.  
  206. function my_renderId(value ,record,columnObj,grid,colNo,rowNo)
  207. {
  208. var no= record[columnObj.fieldIndex];
  209.  
  210. return "<input type='checkbox' value='"+record[0]+"' name='userID'/>";
  211. }
  212.  
  213. var colsOption = [
  214. {id: 'entity_id' , header: "Order Id" , width :"15",renderer : my_renderId},
  215. {id: 'entity_id' , header: "Order Id" , width :"75"},
  216.  
  217. {id: 'created_at' , header: "Order Date" , width :"120"}
  218.  
  219. ];
  220.  
  221. var gridOption={
  222. id : grid_demo_id,
  223. //height: "285", //"100%", // 330,
  224. pageSize:20,
  225. pageSizeList : [5,10,15,20],
  226. container : 'myGrid',
  227. replaceContainer : true,
  228. dataset : dsOption ,
  229. columns : colsOption ,
  230. toolbarContent : 'nav goto | pagesize | filter state | sortable | search',
  231. onRowClick:function(value, record , cell, row, colNO, rowNO,columnObj,grid){
  232. }
  233. };
  234. var mygrid=new Sigma.Grid(gridOption);
  235. Sigma.Util.onLoad( Sigma.Grid.render(mygrid) );
  236.  
  237. function doFilter() {
  238. var filterInfo=[
  239. {
  240. fieldName : $('select[id=f_value2]').val(),
  241. logic : "startWith",
  242. value : Sigma.Util.getValue("f_value1")
  243. },
  244. {
  245. fieldName : Sigma.Util.getValue("f_fieldName12"),
  246. logic : "greatEqual",
  247. value : Sigma.Util.getValue("f_value12")
  248. }
  249. ]
  250. var grid=Sigma.$grid("myGrid");
  251. var rowNOs=grid.applyFilter(filterInfo);
  252. }
  253. function doUnfilter(){
  254. var grid=Sigma.$grid("myGrid1");
  255. var rowNOs=grid.unfilterGrid();
  256.  
  257. }
  258.  
  259. function massAction()
  260. {
  261. var e=document.getElementById("massaction");
  262. var strUser = e.options[e.selectedIndex].value;
  263.  
  264. switch(strUser)
  265. {
  266. case "paid":
  267. retactiveVal=confirm("Are you sure want to Change the Paid status");
  268. if( retactiveVal == true )
  269. {
  270. massdesignerpaidstatus();
  271. return true;
  272. }else{
  273. return false;
  274. }
  275.  
  276. return false;
  277. }
  278. }
  279.  
  280. </script>
Add Comment
Please, Sign In to add comment