| 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/khonguyenlieu.vn/public_html/webadmin/models/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class menufacture_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function getAllMenufacture($num,$offset)
{
//$this->db->order_by('MenufactureName','ASC');
$this->db->order_by('MenufactureID','DESC');
$query = $this->db->get('menufacture',$num,$offset);
return $query->result();
}
function getNumMenufacture()
{
$query = $this->db->get('menufacture');
return $query->num_rows();
}
function save($id=0)
{
$data = array(
'MenufactureName' => (string) $this->input->post('MenufactureName'),
'Description' => (string) $this->input->post('Description'),
'nb_order' => (int) $this->input->post('nb_order'),
'is_hot' => (int) $this->input->post('is_hot'),
'metatitle' => (string) $this->input->post('metatitle'),
'metadesc' => (string) $this->input->post('metadesc'),
'metakey' => (string) $this->input->post('metakey'),
'create_time' => (int) time(),
'bl_active' => (int) $this->input->post('bl_active')
);
//upload hinh anh
$img = $this->input->post("MenufactureImg");
$img_name = end(explode('/', $img)) ;
if($img)
{
if(file_exists(ROOT_IMG.'menufacture/'.$img_name))
{
unlink(ROOT_IMG.'menufacture/'.$img_name);
}
fn_resize_image(ROOT_IMG.$img,ROOT_IMG.'menufacture/'.$img_name, 200, 200);
$data["MenufactureImg"] = $img_name;
}
if($id!=0)
{
$this->db->where('MenufactureID',$id);
if($this->db->update('menufacture',$data)){
return true;
}else{
return false;
}
}else{
if($this->db->insert('menufacture',$data)){
return true;
}else{
return false;
}
}
}
function get_menufacture_by_id($id){
$this->db->where('MenufactureID',$id);
$query = $this->db->get('menufacture');
return $query->row();
}
function delete($id)
{
$check = $this->get_menufacture_by_id($id);
if(file_exists('../uploads/menufacture/'.$check->MenufactureImg)){
unlink('../uploads/menufacture/'.$check->MenufactureImg);
}
$this->db->where('MenufactureID',$id);
$query = $this->db->delete('menufacture');
if($query){
return true;
}else{
return false;
}
}
function get_all_manufacture_write_file()
{
$this->db->where('bl_active',1);
//$this->db->where('MenufactureImg !=','');
$query = $this->db->get('menufacture');
return $query->result();
}
}
?>