| Server IP : 103.48.194.25 / Your IP : 216.73.216.47 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/pundarikanail.com-bk/wadmin/components/gallery/controllers/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Gallerycat extends MX_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('Gallerycat_model','gallerycat');
$this->pre_message = "";
}
function index($catid=0,$start=0)
{
$data['title'] = 'List Category Gallery';
$data['add'] = 'gallerycat/add';
$config['base_url'] = base_url().'gallery/gallerycat/index/'.$catid;
$data['num'] = $this->gallerycat->getNumGalleryCat();
$config['total_rows'] = $data['num'];
$config['per_page'] = 20;
$config['uri_segment'] = 4;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['list'] = $this->gallerycat->getAllGalleryCat($config['per_page'],$start);
$data['start'] = $start;
$this->create_json();
$data['page'] = 'gallery/cat/index';
$this->load->view('layout/skin',$data);
}
function add()
{
$data['title'] = 'Add new category';
$data['index'] = $this->gallerycat->get_list_maincat();
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('gcat_name','Mô tả','trim|required');
if($this->form_validation->run()== FALSE)
{
$this->pre_message = validation_errors();
}
else
{
$req = $this->build_data();
if($this->gallerycat->save($req))
{
$this->session->set_flashdata('message','Lưu thành công');
redirect('gallery/gallerycat/index');
}
}
}
$data['message'] = $this->pre_message;
$data['page'] = 'gallery/cat/add';
$this->load->view('layout/skin',$data);
}
function edit($id=0)
{
$data['list_cat'] = $this->gallerycat->get_list_maincat();
$data['rs'] = $this->gallerycat->getGalleryCat($id);
$data['title'] = 'Update: '.$data['rs']->gcat_name;
if(!empty($_POST['bt_submit']))
{
$this->form_validation->set_rules('gcat_name','Mô tả loại ảnh','trim|required');
if($this->form_validation->run() == FALSE)
{
$this->pre_message = validation_errors();
}else{
$req = $this->build_data();
if($this->gallerycat->save($req,$id))
{
$this->session->set_flashdata('message','Cập nhật loại ảnh thành công');
redirect('gallery/gallerycat/index');
}
}
}
$data['page'] = 'gallery/cat/edit';
$this->load->view('layout/skin',$data);
}
private function build_data($flag=0)
{
$req["gcat_name"] = $this->input->post("gcat_name");
$req["gcat_parent"] = $this->input->post("gcat_parent");
$req["gcat_summary"] = $this->input->post("gcat_summary");
$req["nb_order"] = $this->input->post("nb_order");
$req["bl_active"] = (int)$this->input->post("bl_active");
return $req;
}
function create_json()
{
$list = $this->gallerycat->get_list_active();
$json_str = json_encode($list);
write_file(ROOT_SITE.'cache/json_gallerycat.php', $json_str);
}
function del($id=0,$start=0)
{
if($this->gallerycat->del($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('gallery/gallerycat/index/'.$start);
}
function dels()
{
if(!empty($_POST['ar_id']))
{
$start = (int)$this->input->post('start');
$ar_id = $this->input->post('ar_id');
if(!empty($_POST['btn_submit']))
{
for($i = 0; $i < sizeof($ar_id); $i ++) {
if ($ar_id[$i]){
if($this->gallerycat->del($ar_id[$i]))
$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('gallery/gallerycat/index/'.$start);
}
}
?>