SHARE
TWEET

llllll

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