Commit 8f8b9ad9 by Jansa Jose

daily commit

parent 238e55f8
......@@ -41,5 +41,17 @@ class Orders extends CI_Controller {
}
echo json_encode($return_arr);exit;
}
public function changeOrderStatus(){
$status = 0;
$return_arr = array('status'=>'0');
if(!isset($_POST) || empty($_POST) || !isset($_POST['order_id']) || empty($_POST['order_id']) || empty(decode_param($_POST['order_id']))){
echo json_encode($return_arr);exit;
}
$status = $this->Order_model->changeOrderStatus($_POST);
$return_arr['status'] = $status;
echo json_encode($return_arr);exit;
}
}
?>
\ No newline at end of file
......@@ -6,7 +6,8 @@ class Order_model extends CI_Model {
}
public function getOrders(){
$this->db->select("ORD.format_order_id,ORD.quantity,ORD.amount,ORD.status,PRD.product_name,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,ORD.order_id");
$this->db->select("ORD.*,PRD.product_name,
TRIM(CONCAT(CUST.first_name,' ',IFNULL(CUST.last_name,''))) as customer_name");
$this->db->from('orders AS ORD');
$this->db->join('products AS PRD','PRD.product_id = ORD.product_id');
$this->db->join('customers AS CUST','CUST.customer_id = ORD.customer_id');
......@@ -20,7 +21,8 @@ class Order_model extends CI_Model {
if($order_id == ''){
return 0;
}
$result = $this->db->query("SELECT ORD.*,PRD.product_name,PRD.short_description,PRDB.brand_name,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,
$result = $this->db->query("SELECT ORD.*,PRD.product_name,PRD.short_description,PRDB.brand_name,
TRIM(CONCAT(CUST.first_name,' ',IFNULL(CUST.last_name,''))) AS customer_name,
CASE WHEN ORD.status = 0 THEN 'Inactive'
WHEN ORD.status = 1 THEN 'Payment Processing'
WHEN ORD.status = 2 THEN 'Order Places'
......@@ -30,7 +32,7 @@ class Order_model extends CI_Model {
WHEN ORD.status = 6 THEN 'Returned'
WHEN ORD.status = 7 THEN 'Cancelled'
WHEN ORD.status = 8 THEN 'Deleted'
ELSE 'Payment Failed' END AS status
ELSE 'Payment Failed' END AS ord_status
FROM orders AS ORD
JOIN products AS PRD on PRD.product_id = ORD.product_id
JOIN product_brand AS PRDB on PRDB.brand_id = PRD.brand_id
......@@ -48,6 +50,23 @@ class Order_model extends CI_Model {
return (empty($result))?'':$result->result();
}
public function changeOrderStatus($data=array()){
$order_id = decode_param($data['order_id']);
if(empty($order_id) || $data['status'] == '' || empty($data['expected_date'])){
return 0;
}
if($data['status'] == '3' || $data['status'] == '4'){
$data['expected_delivery'] = $data['expected_date'];
}else if($data['status'] == '5'){
$data['delivered'] = $data['expected_date'];
}
unset($data['expected_date'],$data['order_id']);
$status = 0;
if($this->db->update('orders',$data,array('order_id'=>$order_id))){
$status = 1;
}
return $status;
}
}
?>
......@@ -29,12 +29,12 @@
<tr>
<th class="hidden">ID</th>
<th width="12%;">Order ID</th>
<th width="18%;">Product</th>
<th width="14%;">Customer</th>
<th width="22%;">Product</th>
<th width="15%;">Customer</th>
<th width="9%;">Quantity</th>
<th width="9%;">Amount</th>
<th width="18%;">Status</th>
<th width="20%;">Action</th>
<th width="17%;">Status</th>
<th width="16%;">Action</th>
</tr>
</thead>
<tbody>
......@@ -47,15 +47,18 @@
<th class="center"><?= $odrData->customer_name ?></th>
<th class="center"><?= $odrData->quantity ?></th>
<th class="center"><?= $odrData->amount ?></th>
<th class="center">
<th class="center" id="orderStatus_<?= encode_param($odrData->order_id) ?>">
<?php
switch($odrData->status){
case 0: echo 'Inactive'; break;
case 1: echo 'Payment Processing'; break;
case 2: echo 'Order Places'; break;
case 3: echo 'Order Packed'; break;
case 4: echo 'Order Shipped'; break;
case 5: echo 'Ordered Delivered'; break;
case 3: echo 'Order Packed <br>
(Deliver by '.$odrData->expected_delivery.')'; break;
case 4: echo 'Order Shipped <br>
(Deliver by '.$odrData->expected_delivery.')'; break;
case 5: echo 'Ordered Delivered <br>
(Deliver by '.$odrData->delivered.')'; break;
case 6: echo 'Returned'; break;
case 7: echo 'Cancelled'; break;
case 8: echo 'Deleted'; break;
......@@ -68,8 +71,9 @@
order_id="<?= encode_param($odrData->order_id) ?>">
<i class="fa fa-fw fa-eye"></i>View
</a>
<a class="btn btn-sm btn-success" id="changeOrderStatus" style="background-color:#ac2925" order_id="<?= encode_param($odrData->order_id) ?>"><i class="fa fa-cog"></i>Change Status</a>
<?php if($odrData->status == '2' || $odrData->status == '3' || $odrData->status == '4'){ ?>
<a class="btn btn-sm btn-success" order_status="<?= $odrData->status ?>" id="changeOrderStatus" style="background-color:#4CAF50;" order_id="<?= encode_param($odrData->order_id) ?>"><i class="fa fa-cog"></i>Status</a>
<?php } ?>
</td>
</tr>
<?php } }?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment