| 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/galaxynail.com/wadmin/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ajax_model extends CI_Model
{
function __construct() {
parent::__construct();
}
function save($tbl, $data, $name='', $id=0)
{
if($name)
{
$this->db->where($name, $id) ;
if($this->db->update($tbl, $data))
return $id ;
else return false;
}
else
{
if($this->db->insert($tbl,$data))
return $this->db->insert_id();
else return false;
}
}
function save_onoff($table,$data,$id,$name)
{
$this->db->where($name,$id);
$this->db->update($table,$data);
}
function get_last_order()
{
$this->db->order_by('CartID','DESC');
$this->db->where('Status !=','Status');
$this->db->where('IsDelete',0);
return $this->db->get('shoppingcart',5,0)->result();
}
/****
* Thong bao chuyen khoan moi nhat
*/
function get_transfer_notice_last()
{
$this->db->select('account.*,transfernotice.*');
$this->db->join('account','account.AccountID = transfernotice.AccountID');
$this->db->order_by('transfernotice.TransferID','DESC');
$this->db->limit('10');
return $this->db->get('transfernotice')->result();
}
/*****
* Tinh tong san pham trong moi don hang
* @param mixed $CartID
*/
function get_sum_product($CartID)
{
$this->db->select_sum('Quantity','total');
$this->db->from('cartdetail');
$this->db->where('CartID',$CartID);
$query = $this->db->get();
return $query->row()->total;
}
/********
* Tinh tong tien trong moi don hang
*
* @param mixed $CartID
*/
function get_sum_price($CartID)
{
$this->db->where('CartID',$CartID);
$list = $this->db->get('cartdetail')->result();
$total = 0;
foreach($list as $rs):
$total = $total + ($rs->Price * $rs->Quantity);
endforeach;
return $total;
}
/********
* Upload img
*/
function add_img($filename,$catid,$lb_ext,$size,$date_path)
{
$admin_id = $this->session->userdata('admin_id');
$session_info = $this->session->userdata('session_id');
$data = array(
'lb_name' => $filename,
'image_category_id' => $catid,
'lb_dir' => $date_path,
'lb_ext' => $lb_ext,
'lb_size' => $size,
'session_id' => $session_info,
'dt_create' => date('Y-m-d H:i:s'),
'admin_id' => $admin_id
);
$this->db->insert('sys_image_data',$data);
return $this->db->insert_id();;
}
function setActiveDeactive($table,$field,$id,$pub)
{
$this->db->set('bl_active',$pub);
$this->db->where($field,$id);
$this->db->update($table);
}
}
?>