JezK
Edit File: pemesanan_data.php
<?php include_once('includes/connect_database.php'); ?> <div id="content" class="container col-md-12"> <?php if(isset($_GET['id'])){ $ID = $_GET['id']; }else{ $ID = ""; } // create array variable to handle error $error = array(); // create array variable to store data from database $data = array(); if(isset($_POST['btnSave'])){ $post=$_POST; $tdata=$a=[]; $cnt=count($_POST['Menu_ID']); for($i=0;$i<$cnt; $i++) { $a['Menu_ID']=$post['Menu_ID'][$i]; $a['Menu_name']=$post['Menu_name'][$i]; $a['company_id']=$post['company_id'][$i]; $a['company_name']=$post['company_name'][$i]; $a['Category_ID']=$post['Category_ID'][$i]; $a['mrp']=$post['mrp'][$i]; $a['shipper']=$post['shipper'][$i]; $a['Menu_image']=$post['Menu_image'][$i]; $a['main_company']=$post['main_company'][$i]; $a['cart_status']=$post['cart_status'][$i]; $a['cart_count']=$post['cart_count'][$i]; $a['packages']=$post['pkg'][$i]; $a['Quantity']=$post['qtn'][$i]; $a['Price']=$post['price'][$i]; $a['batch']=$post['batch'][$i]; $tdata[]=$a; } $orderdata=json_encode($tdata); // print_r($orderdata);exit; $process = $post['status']; $tax = $post['tax']; $total_amount = $post['total_amount']; $userid = $post['userid']; $sql_query = "UPDATE tbl_reservation SET Order_list= ?,tax_total=?, total_amount=?, Status = ? WHERE ID = ?"; $stmt = $connect->stmt_init(); if($stmt->prepare($sql_query)) { // Bind your variables to replace the ?s $stmt->bind_param('sssss',$orderdata,$tax,$total_amount, $process, $ID); // Execute query $stmt->execute(); // store result $update_result = $stmt->store_result(); $stmt->close(); } $date=date('Y-m-d H:i:s'); $title="Order ".$ID." Details"; if($process==1) { $type=4; $user=$userid; $notifyMesg="Your Order ".$ID." has been Accepted"; $mess="Your Order ".$ID." has been Accepted"; $mailtxt="Dear User,<br/> Your order ".$ID." has been accepted successfully."; }else if($process==2) { $type=5; $user=$userid; $notifyMesg="Your Order ".$ID." has been delivered successfully"; $mess="Your Order ".$ID." has been delivered successfully"; $mailtxt="Dear User,<br/> Your order ".$ID." has been delivered successfully."; }else if($process==3) { $type=6; $user=$userid; $notifyMesg="Your Order ".$ID." has been rejected"; $mess="Your Order ".$ID." has been rejected"; $mailtxt="Dear User,<br/> Your order ".$ID." has been rejected. Please contact admin for further details."; } $sql_query1="INSERT INTO notification set title=?,message=?,create_date=?,user_id=?,order_id=?,user_type=1"; $stmt1 = $connect->stmt_init(); if($stmt1->prepare($sql_query1)) { // Bind your variables to replace the ?s $stmt1->bind_param('sssss',$title,$mess,$date,$userid,$ID); // Execute query $stmt1->execute(); $stmt1->close(); } include("android_single.php"); // check update result if($update_result){ $error['update_data'] = " <span class='label label-success'>Successfully updated</span>"; }else{ $error['update_data'] = " <span class='label label-danger'>Failed</span>"; } } // get data from reservation table /*$sql_query = "SELECT * FROM tbl_reservation WHERE tbl_reservation.ID = ?";*/ $sql_query = "SELECT tbl_reservation.tax_total,tbl_reservation.total_amount,tbl_reservation.ID,mstusers.userid,mstusers.Email,trnuser.address,firm_name,dlno,tinno,Phone1,Date_n_Time,Comment,Status,tbl_reservation.Order_list from tbl_reservation join mstusers on mstusers.Userid = tbl_reservation.userid JOIN trnuser on trnuser.Userid=tbl_reservation.userid WHERE tbl_reservation.ID = ?"; $stmt = $connect->stmt_init(); if($stmt->prepare($sql_query)) { // Bind your variables to replace the ?s $stmt->bind_param('s', $ID); // Execute query $stmt->execute(); // store result $stmt->store_result(); $stmt->bind_result($data['tax_total'], $data['total_amount'], $data['ID'], $data['userid'], $data['Email'], $data['address'], $data['firm_name'], $data['dlno'], $data['tinno'], $data['Phone1'], $data['Date_n_Time'], $data['Comment'], $data['Status'], $data['Order_list'] ); $stmt->fetch(); $stmt->close(); } // parse order list into array $order_list = explode(',',$data['Order_list']); $orderlist=json_decode($data['Order_list'],true); ?> <style type="text/css"> @media print { body * { visibility: hidden; } #print_area * { visibility: visible; } #print_area { position: absolute !important; top: 40px; left: 250px; } #h_diplay {text-align:left !important;display:block} * { color: black; background: white; } table { font-size: 80%; } } #h_diplay {display:none} </style> <div class="col-md-7 col-md-offset-2"> <center> <h1>Order Detail</h1> <?php echo isset($error['update_data']) ? $error['update_data'] : '';?> </center> <form method="post"> <br> <div class="col-md-12 table-responsive"> <div id="print_area"> <table class='table table-striped table-bordered' width="100%" > <tr> <th colspan="3"> Order ID </th> <td colspan="4"> <?php echo $data['ID']; ?><input type="hidden" name="ID" value="<?=$data['ID']?>" /><input type="hidden" name="userid" value="<?=$data['userid']?>" /> </td> </tr> <tr> <th colspan="3"> Order Date </th> <td colspan="4"> <?php echo $data['Date_n_Time']; ?> </td> </tr> <tr> <th colspan="3">Name: <br/> Address:</th> <td colspan="4"><?php echo $data['firm_name']; ?><br/> <?php echo $data['address']; ?></td> </tr> <tr> <th colspan="3">Email: <br/>Phone:</th> <td colspan="4"> <?php echo $data['Email']; ?><br/> <?php echo $data['Phone1']; ?> </td> </tr> <tr> <th>S.No</th> <th>Product Name</th> <th>Company</th> <th>Box Pack</th> <th>Quantity</th> <th>Price</th> <th>Batch Number</th> </tr> <?php $i=1; print_r($orderlist); foreach($orderlist as $list){?> <tr> <td><?php echo $i++; ?><input type="hidden" name="Menu_ID[]" style="width:100%" value="<?php echo $list['Menu_ID']?>"/></td> <td><?php echo $list['Menu_name']; ?><input type="hidden" name="Menu_name[]" value="<?=$list['Menu_name']?>" /></td> <td><?php echo $list['company_name']; ?> <input type="hidden" name="company_id[]" style="width:100%" value="<?php echo $list['company_id']?>"/> <input type="hidden" name="company_name[]" style="width:100%" value="<?php echo $list['company_name']?>"/> <input type="hidden" name="Category_ID[]" style="width:100%" value="<?php echo $list['Category_ID']?>"/> <input type="hidden" name="mrp[]" style="width:100%" value="<?php echo $list['mrp']?>"/> <input type="hidden" name="shipper[]" style="width:100%" value="<?php echo $list['shipper']?>"/> <input type="hidden" name="Menu_image[]" style="width:100%" value="<?php echo $list['Menu_image']?>"/> <input type="hidden" name="main_company[]" style="width:100%" value="<?php echo $list['main_company']?>"/> <input type="hidden" name="cart_status[]" style="width:100%" value="<?php echo $list['cart_status']?>"/> <input type="hidden" name="cart_count[]" style="width:100%" value="<?php echo $list['cart_count']?>"/> </td> <td><?php echo isset($list['packages'])? $list['packages'] : ""; ?></td> <td><?php echo isset($list['Quantity'])? $list['Quantity'] : ""; ?></td> <td><?php echo isset( $list['Price'])? $list['Price']: "";?></td> <td><?php echo isset ($list['batch'])? $list['batch']: ""; ?></td> </tr> <?php } ?> <tr> <td colspan="3">Tax</td> <td colspan="4"><?php echo isset ($data['tax_total'])? $data['tax_total']: ""; ?></td> </tr> <tr> <td colspan="3">Total</td> <td colspan="4"><?php echo isset ($data['total_amount'])? $data['total_amount']: ""; ?></td> </tr> <tr> <th colspan="7">Comment</th> </tr> <tr> <td colspan="7"><?php echo $data['Comment']?></td> </tr> <tr> <th colspan="3">Status</th> <td colspan="4"> <select name="status" class="form-control" style="font-size:16px"> <option value="0" <?php echo ($data['Status']==0)? "selected": ""; ?>>Order Processed</option> <option value="1" <?php echo ($data['Status']==1)? "selected": ""; ?>>Order Accepted</option> <option value="2" <?php echo ($data['Status']==2)? "selected": ""; ?>>Order Delivered</option> <option value="3" <?php echo ($data['Status']==3)? "selected": ""; ?>>Order Rejected</option> </select> </td> </tr> </table> </div> <div class="text-center" style="margin-bottom:2px;"> <input type="submit" class="btn btn-primary" id="btnSave" value="Save" name="btnSave"/> <button class="btn btn-success" onclick="printDiv()">Print</button></div> </div> </form> </div> <div class="separator"> </div> </div> <?php include_once('includes/close_database.php'); ?>