|
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/vajra.id/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';
function __construct() {
parent::__construct();
}
//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();
}
//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('payment_status', 1);
$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('id_orders, order_date, total_amount, payment_type, payment_date, recipient_name, address, city, state, country, postcode, phone');
$this->db->from('orders');
$this->db->order_by('id_orders', '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('payment_status', 1);
$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', 1);
$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();
}
}