<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Order_Model extends CI_Model {

    var $tableName = 'tbl_order';
    var $tableOrderItem = 'tbl_order_items';

  function getOrderList() {     
        $this->db->where('is_delete', 'no');
        $query = $this->db->get($this->tableName);
        $result = $query->result_array();
        return $result;
    }
    
    function getOrderListById($orderId) {   
        $this->db->where('order_id', $orderId);
        $this->db->where('is_delete', 'no');
        $query = $this->db->get($this->tableName);
        $result = $query->row_array();
        return $result;
    }
    
    function getOrderItemListById($orderId) {       
        if ($orderId != '')
            $this->db->where('order_id', $orderId);
        $query = $this->db->get($this->tableOrderItem);
        $result = $query->result_array();
        return $result;
    } 

    public function updateStatus($orderId, $status) {
        $this->db->set('order_status', $status);
        $this->db->where('order_id', $orderId);
        $response = $this->db->update($this->tableName);
        return $response;
    }

  public function delete($orderId) {
        $this->db->set('is_delete', 'yes');
        $this->db->where('order_id', $orderId);
       $response = $this->db->update($this->tableName);
        return $response;
    }

}