Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'home.php';
- $is_admin = false;
- $user_home = new USER();
- /* test */
- $servername = "localhost";
- $username = "root";
- $password = "Outthinking123@";
- $dbname = "designer6";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT dorder_id, designer_id, designerorder_id , dproduct_id, dpaid_status , delivery_status , due_date, commission FROM order_details";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- echo "<table><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>" . $row["dorder_id"]. "</td><td>" . $row["designer_id"]. " " . $row["designerorder_id"]. "</td>
- <td>" . $row["dproduct_id"]. " " . $row["dpaid_status"]. "</td>
- <td>" . $row["delivery_status"]. " " . $row["due_date"]. "</td>
- <td>" . $row["commission"]. " " . $row["commission"]. "</td>
- </tr>";
- }
- echo "</table>";
- } else {
- echo "0 results";
- }
- $conn->close();
- /* test end */
- /* to show selected date */
- if (isset($_POST['post_at']) && $_POST['post_at'] != '')
- {
- $orderFromDate = $_POST['post_at'] . " 00:00:00 ";
- }
- else
- {
- $orderFromDate = '';
- }
- if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '')
- {
- $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 ";
- }
- else
- {
- $orderToDate = '';
- }
- /* to show selected date end*/
- function getDesignerName($designerId)
- {
- $user_home = new USER();
- if (!$user_home->is_logged_in())
- {
- $user_home->redirect('index.php');
- }
- $stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
- $stmt->execute(array(
- ":uid" => $designerId
- ));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- return $row['name'];
- }
- /* Fetching magento db details end */
- function getDesignerCollection()
- {
- global $is_admin;
- $user_home = new USER();
- require_once '../../app/Mage.php';
- Mage::app();
- $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
- $stmts->execute(array(
- ":uid" => $_SESSION['userSession']
- ));
- $rows = $stmts->fetch(PDO::FETCH_ASSOC);
- $stmt = $user_home->runQuery("SELECT * FROM order_details");
- $stmt->execute(array(":uid" => $_SESSION['userSession']));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->execute();
- /* date search */
- if (isset($_POST['post_at']) && $_POST['post_at'] != '')
- {
- $orderFromDate = $_POST['post_at'] . " 00:00:00 ";
- }
- else
- {
- $orderFromDate = '';
- }
- if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '')
- {
- $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 ";
- }
- else
- {
- $orderToDate = '';
- }
- /* date search end*/
- $accountType = $rows['type'];
- if ($accountType == "admin")
- {
- $is_admin = true;
- $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
- 'nin' => '0'
- ));
- if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
- 'gteq' => $orderFromDate
- ));
- if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
- 'lteq' => $orderToDate
- ));
- }
- else
- {
- $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
- 'like' => '%' . $_SESSION['userSession'] . '%'
- ));
- if ($orderFromDate != '') $order->addFieldToFilter('created_at', array(
- 'gteq' => $orderFromDate
- ));
- if ($orderToDate != '') $order->addFieldToFilter('created_at', array(
- 'lteq' => $orderToDate
- ));
- }
- /* Fetching magento db details end */
- $i = 0;
- foreach($order as $orderData)
- {
- $k = 0;
- $orderitems = $orderData['dproduct_id'];
- $orderitemsarray = explode(",", $orderitems);
- $oDate = new DateTime($orderData['created_at']);
- $sDate = $oDate->format("M d, Y");
- while ($k < count($orderitemsarray))
- //while (($k < count($orderitemsarray)) && ($data = $stmt->fetch()))
- {
- if ($orderitemsarray[$k] != '0')
- {
- $stmtorders = $user_home->runQuery("SELECT * FROM order_details");
- $stmtorders->execute(array(":dorder_id" => $orderData['entity_id']));
- $roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
- $dorderStatus = $roworders['dpaid_status'];
- $productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
- $designer_id = $productdetail->getDesignerID() ;
- if($accountType == "admin")
- {
- $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
- $stmt1 = $user_home->runQuery("SELECT * FROM order_details WHERE dproduct_id=:pid and designerorder_id=:doid");
- $stmt1->execute(array(
- ":doid" => $orderData->getIncrementId(),
- ":pid" => $orderitemsarray[$k],
- ));
- $paid_status='';
- while($datas = $stmt1->fetch())
- {
- if ($roworders['dpaid_status'] != '')
- {
- $paid_status=$datas['dpaid_status'];
- }
- else
- {
- $paid_status='unpaid';
- }
- }
- $responce[] = array(
- $orderData->getIncrementId() ,
- $orderData->getIncrementId() ,
- $orderitemsarray[$k],
- $productdetail->getName() ,
- $designerName,
- $orderData['status'], // magento [ pending / processing/complete]
- $orderData['grand_total'], // magento
- $orderData['customer_email'], // magento
- $data['commission'],
- $paid_status,
- $sDate // magento
- );
- }
- else
- {
- if( $designer_id== $_SESSION['userSession'] )
- {
- $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
- $stmt1 = $user_home->runQuery("SELECT * FROM order_details WHERE dproduct_id=:pid and designerorder_id=:doid");
- $stmt1->execute(array(
- ":doid" => $orderData->getIncrementId(),
- ":pid" => $orderitemsarray[$k],
- ));
- $paid_status='';
- while($datas = $stmt1->fetch())
- {
- if ($roworders['dpaid_status'] != '')
- {
- $paid_status=$datas['dpaid_status'];
- }
- else
- {
- $paid_status='unpaid';
- }
- }
- $responce[] = array(
- $orderData->getIncrementId() ,
- $orderData->getIncrementId() ,
- $orderitemsarray[$k],
- $productdetail->getName() ,
- $designerName,
- $orderData['status'], // magento [ pending / processing/complete]
- $orderData['grand_total'], // magento
- $orderData['customer_email'], // magento
- $data['commission'],
- $paid_status,
- $sDate // magento
- );
- }
- }
- }
- $k++;
- $i++;
- }
- /* paid */
- /*
- $stmt = $user_home->runQuery("SELECT * FROM tbl_users");
- $stmt->execute(array(":uid" => $_SESSION['userSession']));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->execute();
- */
- while($data = $stmt->fetch())
- {
- $responce1[] = array(
- $data['designerorder_id'] ,
- $data['designerorder_id'] ,
- $orderitemsarray[$k],
- $productdetail->getName() ,
- $designerName,
- $orderData['status'], // magento [ pending / processing/complete]
- $orderData['grand_total'], // magento
- $orderData['customer_email'], // magento
- $data['commission'],
- $data['dpaid_status'],
- $sDate // magento
- );
- $k++;
- }
- /*paid end */
- } // foreach
- //json_encode($responce);
- //array_push($responce,$responce1);
- //json_encode($responce);
- //$result = array_merge($responce, $responce1);
- return json_encode($responce);
- } // designer collection
- ?>
- <head>
- <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
- <script src= "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>
- <link rel="stylesheet" href="assets/css/jquery-ui.css">
- <script src="assets/js/jquery-1.10.2.js"></script>
- <script src="assets/js/jquery-ui.js"></script>
- <script src="assets/js/jquery-ui.js"></script>
- <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_msg_en.js"></script>
- <script type="text/javascript" language="javascript" src="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/js/outthinking/gt_grid_all.js"></script>
- <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/skinstyle.css"/>
- <link rel="stylesheet" type="text/css" href="http://sbdev2.kidsdial.com:81/php/site6/bootstrap/css/outthinking/css/gt_grid.css"/>
- <h2> Orders</h2><div id="msgresult" style="display:none;color:blue;text-align:center;">Paid status changed.</div>
- </head>
- <div>
- <div class="delete_grid" >
- <form>
- Search:
- <select id="f_value2">
- <option value="entity_id">Order Id</option>
- <option value="designer_id">Designer Id</option>
- </select>
- <input type="text" onkeyup="doFilter()" value="" id="f_value1" >
- <input type="reset" value="Reset" onClick="window.location.reload()">
- </form>
- <br/>
- <form name="frmSearch" method="post" action="">
- <input type="text" placeholder="From Date" id="post_at"
- value="<?php
- if ($orderFromDate != '')
- {
- $newPostStartDate = date('Y-m-d', strtotime($_POST['post_at']));
- echo $newPostStartDate;
- } ?>" name="post_at" />
- <input type="text" placeholder="To Date" id="post_at_to_date"
- value="<?php
- if ($orderToDate != '')
- {
- $newPostEndDate = date('Y-m-d', strtotime($_POST['post_at_to_date']));
- echo $newPostEndDate;
- } ?>"name="post_at_to_date" />
- <input type="submit" name="search" value="search" id="searchButton">
- <input type="button" value="Reset" id="clear-dates">
- </form>
- <br/>
- <div class="delete_grid_select">
- <form action='' method="post" enctype="multipart/form-data">
- <input type="hidden" name="delete_package_id" id="delete_package_id" value=""/>
- Action:
- <select name="massaction" id="massaction">
- <option value="">Select</option>
- <option value="P">Paid</option>
- <option value="U">Unpaid</option>
- </select>
- <input type="button" value="Submit" id="delete-grid-button" onclick="massAction()" />
- </form>
- </div>
- </div>
- </div>
- <div id="myGrid"></div>
- <script type="text/javascript">
- var __TEST_DATA__=eval('<?php
- echo getDesignerCollection(); ?>');
- var grid_demo_id = "myGrid" ;
- var dsOption= {
- fields :[
- {name : 'entity_id' },
- {name : 'entity_id' },
- {name : 'product_id' },
- {name : 'product_name'},
- {name : 'designer_id' },
- {name : 'status' },
- {name : 'grand_total' },
- {name : 'customer_email' },
- {name : 'commission' },
- {name : 'dpaid_status' },
- {name : 'created_at'},
- ],
- recordType : 'array',
- data : __TEST_DATA__
- }
- function my_renderId(value ,record,columnObj,grid,colNo,rowNo)
- {
- var no= record[columnObj.fieldIndex];
- return "<input type='checkbox' value='"+record[0]+"-"+record[3]+"' name='userID[]'/>";
- }
- var colsOption = [
- {id: '' , header: "" , width :"15",renderer : my_renderId , width :"60"},
- {id: 'created_at' , header: "Order Date" , width :"120"},
- {id: 'entity_id' , header: "Order Id" , width :"75"},
- {id: 'product_id' , header: "Product Id" , width :"70"},
- {id: 'product_name' , header: "Product Name" , width :"200"},
- <?php if ($is_admin) echo "{id: 'designer_id' , header: 'Designer' , width :'110'},"; ?>
- // {id: 'status' , header: "Order Status" , width :"100"},
- // {id: 'grand_total' , header: " Order Amount" , width :"120"},
- // {id: 'customer_email' , header: "User Email" , width :"150"},
- {id: 'dpaid_status' , header: "Paid status" , width :"80"},
- // {id: 'commission' , header: "commission" , width :"80"},
- {id: 'dpaid_status1' , header: "Deliver Status" , width :"130"},
- {id: 'dpaid_status2' , header: "Payment Due Date" , width :"140"},
- ];
- var gridOption={
- id : grid_demo_id,
- // height: "285", //"100%", // 330,
- pageSize:30,
- pageSizeList : [5,10,15,20],
- container : 'myGrid',
- replaceContainer : true,
- sortable : false,
- dataset : dsOption ,
- columns : colsOption ,
- toolbarContent : 'nav goto | pagesize | filter state | sortable | search',
- onRowClick:function(value, record , cell, row, colNO, rowNO,columnObj,grid){
- }
- };
- var mygrid=new Sigma.Grid(gridOption);
- Sigma.Util.onLoad( Sigma.Grid.render(mygrid) );
- function doFilter() {
- var filterInfo=[
- {
- fieldName : $('select[id=f_value2]').val(),
- logic : "startWith",
- value : Sigma.Util.getValue("f_value1")
- },
- {
- fieldName : Sigma.Util.getValue("f_fieldName12"),
- logic : "greatEqual",
- value : Sigma.Util.getValue("f_value12")
- }
- ]
- var grid=Sigma.$grid("myGrid");
- var rowNOs=grid.applyFilter(filterInfo);
- }
- function doUnfilter(){
- var grid=Sigma.$grid("myGrid1");
- var rowNOs=grid.unfilterGrid();
- }
- function doUnfilter(){
- var grid=Sigma.$grid("myGrid1");
- var rowNOs=grid.unfilterGrid();
- }
- function massAction()
- {
- var e=document.getElementById("massaction");
- var strUser = e.options[e.selectedIndex].value;
- massStatusChangeVerified(strUser);
- /*
- switch(strUser)
- {
- case "paid":
- retactiveVal=confirm("Are you sure want to Change the Paid status");
- if( retactiveVal == true )
- {
- massdesignerpaidstatus();
- return true;
- }else{
- return false;
- }
- return false;
- }
- */
- }
- function massStatusChangeVerified(status)
- {
- var vals = "";
- var checkboxes=$("input[name='userID[]']:checked").each( function () {
- vals += ","+$(this).val();
- })
- alert(vals);
- //var checkboxes = document.getElementsByName('userID');
- //for (var i=0, n=checkboxes.length;i<n;i++) {
- // if (checkboxes[i].checked)
- //{
- //vals += ","+checkboxes[i].value;
- // }
- //}
- if(vals=='')
- {
- alert("No record selected");
- return false;
- }
- retactiveVal=confirm("Are you sure want to Change the status");
- if( retactiveVal == true )
- {
- if (vals) vals = vals.substring(1);
- document.getElementsByName('delete_package_id').value=vals;
- var url="http://sbdev2.kidsdial.com:81/php/site6/update_order_status.php?designer_id="+vals+"&order_status="+status;
- var request = jQuery.ajax( {
- url: url ,
- type: 'POST',
- } );
- request.done( function (result)
- {
- document.getElementById('msgresult').style.display="block";
- var explode = function(){
- location.reload();
- };
- setTimeout(explode, 2000);
- } );
- request.fail( function ( error )
- {
- console.dir(error);
- } );return true;
- }else{
- return false;
- }
- }
- function massdesignerpaidstatus()
- {
- var checkboxes = document.getElementsByName('userID');
- var vals = "";
- for (var i=0, n=checkboxes.length;i<n;i++) {
- if (checkboxes[i].checked)
- {
- vals += ","+checkboxes[i].value;
- }
- }
- if(vals=='')
- {
- alert("No record selected");
- return false;
- }
- if (vals) vals = vals.substring(1);
- document.getElementsByName('delete_package_id').value=vals;
- var url="http://sbdev2.kidsdial.com:81/php/site6/designerpaidstatus.php?order_id="+vals+"&designer_dpaid_status='Paid'";
- var request = jQuery.ajax( {
- url: url ,
- type: 'POST',
- } );
- request.done( function (result)
- {
- location.reload();
- } );
- request.fail( function ( error )
- {
- console.dir(error);
- } );
- }
- <!-- Date Picker -->
- jQuery.datepicker.setDefaults({
- showOn: "button",
- buttonImage: "assets/img/datepicker.png",
- buttonText: "Date Picker",
- buttonImageOnly: true,
- dateFormat: 'yy-mm-dd'
- });
- $(function() {
- $("#post_at").datepicker();
- $("#post_at_to_date").datepicker();
- });
- <!-- reset date -->
- var $dates = $('#post_at, #post_at_to_date').datepicker();
- $("#clear-dates").click(function(){
- location.reload();
- $("#post_at").removeAttr('value');
- $("#post_at_to_date").removeAttr('value');
- if(!$("#post_at_to_date").val()) {
- $( "#searchButton" ).trigger( "click" );
- }
- });
- </script>
Add Comment
Please, Sign In to add comment