|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/angkasapuraretail.com/public_html/application/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Order_m extends MY_Model {
protected $_table_name = 'orders';
protected $_primary_key = 'id_orders';
protected $_order_by = 'id_orders';
public $add_order_rules = array(
array(
'field' => 'customer_id',
'label' => 'Customer',
'rules' => 'trim|required'
),
array(
'field' => 'marketplace_id',
'label' => 'Marketplace',
'rules' => 'trim|required'
),
);
function __construct() {
parent::__construct();
}
public function add_order($data){
$this->db->insert('orders', $data);
return $this->db->insert_id();
}
//function count all record for orders
public function record_count() {
return $this->db->get('orders')->num_rows();
}
//pagination included
function get_all_orders($limit, $start) {
$this->db->select('*');
$this->db->from('orders');
// $this->db->join('customers', 'customers.id_customers = orders.customer_id');
$this->db->order_by('id_orders', 'desc');
$this->db->limit($limit, $start);
$query = $this->db->get();
return $query->result();
}
public function report_record_count() {
$this->db->select('*');
$this->db->from('orders');
// $this->db->join('customers', 'customers.id_customers = orders.customer_id');
return $this->db->where_in('payment_status',
array(
'3',
'4',
'5',
)
)->get()->num_rows();
}
//pagination included
function report_get_all_orders($limit, $start) {
$this->db->select('*');
$this->db->from('orders');
// $this->db->join('customers', 'customers.id_customers = orders.customer_id');
$this->db->where_in('payment_status',
array(
'3',
'4',
'5',
)
);
$this->db->order_by('id_orders', 'desc');
$this->db->limit($limit, $start);
$query = $this->db->get();
return $query->result();
}
function excel_export() {
$this->db->select('
orders_id,
item_name,
item_price,
quantity,
subtotal,
warehouse_id,
chosen_shipping_id,
shipping_fee,
is_backorder,
status,
no_resi
');
$this->db->from('orders_detail');
$this->db->order_by('orders_id', 'desc');
$query = $this->db->get();
return $query->result();
}
//get specific order with its customer details
function get_order($id) {
$this->db->select('*');
$this->db->from('orders');
$this->db->where('id_orders', $id);
$query = $this->db->get();
return $query->row();
}
//update credit card payment status
function update_payment_status($id, $data) {
$this->db->where('id_orders', $id);
$this->db->update('orders', $data);
}
function get_order_history($id_customer) {
$this->db->select('*');
$this->db->from('orders');
$this->db->where('customer_id', $id_customer);
$this->db->order_by('id_orders', 'DESC');
$query = $this->db->get();
return $query->result();
}
//function count record based on chosen date range
function record_count_search_date($date_start, $date_end) {
$this->db->select('*');
$this->db->from('orders');
$this->db->where_in('payment_status',
array(
'3',
'4',
'5',
)
);
// $this->db->where('payment_status', 3);
$this->db->where('order_date >=', $date_start);
$this->db->where('order_date <=', $date_end);
$query = $this->db->get();
return $query->num_rows();
}
//function find store by filtering between 2 dates
function find_order_by_date($limit, $start, $date_start, $date_end) {
$this->db->select('*');
$this->db->from('orders');
// $this->db->where('payment_status', 3);
$this->db->where_in('payment_status',
array(
'3',
'4',
'5',
)
);
$this->db->where('order_date >=', $date_start);
$this->db->where('order_date <=', $date_end);
$this->db->order_by('order_date', 'DESC');
$this->db->limit($limit, $start);
$query = $this->db->get();
return $query->result();
}
function find_order_filter_date($date_start, $date_end) {
$this->db->select('id_orders, sales_id, customer_id, order_date, payment_status, payment_type, recipient_name, total_amount, ppn, shipping_fee, free_shipping_fee, redeemed_voucher_amount, minus_reward_amount, address, district');
$this->db->from('orders');
$this->db->where_in('payment_status',
array(
'3',
'4',
'5',
)
);
if(!empty($date_start)) {
$this->db->where('order_date >=', $date_start);
}
if(!empty($date_end)) {
$this->db->where('order_date <=', $date_end);
}
$this->db->order_by('order_date', 'DESC');
$query = $this->db->get();
return $query->result();
}
function find_orderdetails_filter_date($date_start, $date_end) {
$this->db->select('*');
$this->db->from('orders_detail');
$this->db->join('orders', 'orders_detail.orders_id = orders.id_orders');
$this->db->where_in('orders.payment_status',
array(
'3',
'4',
'5',
)
);
if(!empty($date_start)) {
$this->db->where('orders.order_date >=', $date_start);
}
if(!empty($date_end)) {
$this->db->where('orders.order_date <=', $date_end);
}
$this->db->order_by('orders.order_date', 'DESC');
$query = $this->db->get();
return $query->result();
}
}