| Server IP : 103.48.194.25 / Your IP : 216.73.216.163 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 : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hocthongminh.net-bk/public_html/webadmin/components/product/controllers/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Promo extends MX_Controller
{
public function __construct()
{
parent::__construct();
$this->permit_library->check_permit();
$this->session->set_userdata(array('Url'=>uri_string()));
$this->load->model('common');
$this->load->model('promo_model','promo');
$this->load->model('product_model','product');
$this->pre_message = "";
}
// Thống kê toàn bộ gian hàng
function index($cid=0,$start=0)
{
$data['title'] = 'Danh sách sản phẩm';
$data['listcat'] = $this->product->getMaincat();
$data['add'] = 'product/addproduct';
//$data['export'] = 'product/exportExcel/'.$cid ;
$ord = (int) $this->input->post('orderby') ;
$config['base_url'] = site.'product/listproduct/'.$cid;
$config['total_rows'] = $this->promo->getNumProduct();
$data['num'] = $config['total_rows'];
$config['per_page'] = 30;
$config['uri_segment'] = 4;
$config['num_links'] = 10;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['list'] = $this->promo->getAllProduct($cid,$config['per_page'],$start, $ord);
$data['catid'] = $cid;
$data['start'] = $start;
$data['page'] = 'product/promo/index';
$this->load->view("layout/skin",$data);
}
function edit($pid=0)
{
$rs = $this->promo->get_detail($pid);
$data['title'] = 'Cập nhật :'.$rs->pro_name;
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('price','Giá sản phẩm','trim|required');
if($this->form_validation->run())
{
$req = $this->form_promo(); //trit($req);
if($this->promo->save($req,$pid))
{
$this->session->set_flashdata('message','Lưu thành công');
redirect('product/promo/index');
}
else
{
$this->pre_message ="Lưu không thành công";
}
}
}
$data['rs'] = $rs;
$data['proid'] = $rs->proid;
$data['message'] = $this->pre_message;
$data['page'] = 'product/promo/edit';
$this->load->view("layout/skin",$data);
}
private function form_promo($flag=0)
{
$req["proid"] = $this->input->post("proid");
$req["barcode"] = $this->input->post("barcode");
$req["proname"] = $this->input->post("proname");
$req['fromdate'] = $this->input->post("fromdate");
$req['todate'] = $this->input->post("todate");
$req['createdate'] = date("Y-m-d");
return $req;
}
function del($id=0,$catid=0,$start=0)
{
if($this->product->delproduct($id))
$this->session->set_flashdata('message','Đã xóa thành công');
else
$this->session->set_flashdata('message','Xóa không thành công');
redirect('product/promo/index/'.$start);
}
}