| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/thegioimaycongnghiep.vn/public_html/webadmin/models/ |
Upload File : |
<?php
class Order_model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->helper('str') ;
}
function get_all_order($num=30,$offset=0)
{
$this->db->order_by('cart_id','DESC');
$this->db->where('bl_active',1);
return $this->db->get('cart',$num,$offset)->result();
}
function get_num_order()
{
$this->db->order_by('cart_id','DESC');
$this->db->where('bl_active',1);
return $this->db->get('cart')->num_rows();
}
function get_order_by_id($id)
{
$this->db->where('cart_id',$id);
return $this->db->get('cart')->row();
}
function get_all_change_order($status=0,$num=30,$offset=0)
{
$this->db->where('status',$status);
//$this->db->where('is_delete',0);
$this->db->order_by('cart_id','DESC');
return $this->db->get('cart',$num,$offset)->result();
}
function get_num_change_order($status=0)
{
$this->db->where('status',$status);
//$this->db->where('is_delete',0);
return $this->db->get('cart')->num_rows();
}
function get_cart_detail($id)
{
$this->db->select('product.*,cartdetail.*');
$this->db->join('product','product.proid = cartdetail.proid');
$this->db->where('cartdetail.cart_id',$id);
return $this->db->get('cartdetail')->result();
}
function get_product_name($id)
{
$this->db->select('product.pro_name');
$this->db->join('product','product.proid = cartdetail.proid');
$this->db->where('cartdetail.cart_id',$id);
$query = $this->db->get('cartdetail') ;
return $query->result();
}
function get_all_city()
{
$this->db->where('CountryID',1);
$this->db->where('parent_id',0);
return $this->db->get('city')->result();
}
function get_list_district_by_city($CityID)
{
$this->db->where('parent_id',$CityID);
return $this->db->get('city')->result();
}
function get_city_by_id($id)
{
$this->db->where('CityID',$id);
$rs = $this->db->get('city')->row();
if($rs){
return $rs->CityName;
}else{
return '';
}
}
function get_payment_by_id($id)
{
if(empty($id)) $id=1 ;
$this->db->where('PaymentID',$id);
return $this->db->get('payment')->row()->PaymentName;
}
function get_country_by_id($id){
$id = ($id==0)?'1':$id;
$this->db->where('CountryID',$id);
return $this->db->get('country')->row()->CountryName;
}
function get_shipping_by_id($ShippingID){
if(empty($ShippingID)) $ShippingID=5 ;
$this->db->where('ShippingID',$ShippingID);
return $this->db->get('shippingtype')->row();
}
function get_all_giftcards($cart_id){
$this->db->where('cart_id',$cart_id);
return $this->db->get('giftcards_cart')->result();
}
function get_all_discount($cart_id){
$this->db->where('cart_id',$cart_id);
return $this->db->get('discount_cart')->result();
}
// Lưu thông tin dơn hang
function saveorder()
{
$id = $this->uri->segment(3);
$data['status'] = (int)$this->input->post('status');
$data['is_payment'] = (int)$this->input->post('is_payment');
$data['cusnote'] = $this->input->post('cusnote');
$data['admin_note'] = $this->input->post('admin_note');
$data['dt_modify'] = date('Y-m-d H:i:s') ;
$this->db->where('cart_id',$id);
if($this->db->update('cart',$data))
{
return true;
}else{
return false;
}
}
//lay email templates don hang admin (cart_admin);
function get_email_templates($key){
$this->db->where('Key',$key);
return $this->db->get('email_templates')->row();
}
// Hiển thị tình trang đơn hàng
function get_status($status)
{
if($status == 'Open'){
return 'Đang mở';
}else if($status =='Processed'){
return 'Đang xử lý';
}else if($status == 'Canceled'){
return 'Đã hủy';
}else{
return 'Hoàn thành';
}
}
/*****
* Tinh tong san pham trong moi don hang
*
* @param mixed $cart_id
*/
function get_sum_product($cart_id)
{
$this->db->select_sum('Quantity','total');
$this->db->from('cartdetail');
$this->db->where('cart_id',$cart_id);
$query = $this->db->get();
return $query->row()->total;
}
/********
* Tinh tong tien trong moi don hang
*
* @param mixed $cart_id
*/
/*function get_sum_price($cart_id)
{
$this->db->where('cart_id',$cart_id);
$list = $this->db->get('cartdetail')->result();
$total = 0;
foreach($list as $rs):
$total = $total + ($rs->price * $rs->Quantity);
endforeach;
return $total;
}*/
function delete($id)
{
$data = array(
'is_delete' => 1,
'bl_active' => 0,
'dt_modify' => date('Y-m-d H:i:s')
);
$this->db->where('cart_id',$id);
if($this->db->update('cart',$data)){
return true;
}else{
return false;
}
}
function get_thongke_donhang()
{
$tungay = $this->input->post('tungay');
$denngay = $this->input->post('denngay');
$order = $this->input->post('order');
$order_type = $this->input->post('order_type');
$tinhtrang = (int)$this->input->post('tinhtrang');
$datebegin = strtotime($tungay);
$dateend = strtotime($denngay);
$this->db->where('IsDelete',0);
if($tinhtrang!=0){
$this->db->where('Status',$tinhtrang);
}
$this->db->where('dt_create >',$datebegin);
$this->db->where('dt_create <',$dateend);
$this->db->order_by($order,$order_type);
return $this->db->get('shoppingcart')->result();
}
}
?>