Guest User

complete code`

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