<?php
class User extends Admin_Controller{
public function __construct(){
parent::__construct();
// $this->load->library('grocery_CRUD');
// $this->load->model('grocery_CRUD_Model');
}
public function _example_output($output = null)
{
$this->load->view('user/show.blade.php',$output);
}
public function index(){
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
public function users_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_users');
$crud->set_subject('Users');
$crud->required_fields('id');
$crud->columns('id','email','password','fullname');
$crud->field_type('password', 'password');
$crud->callback_before_insert(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});
$crud->callback_before_update(function($post_array){
$post_array['password'] = md5($post_array['password'] );
return $post_array;
});
$output = $crud->render();
echo "dfsdfs";
$this->_example_output();
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function encrypt_password_callback($post_array) {
$post_array['password'] = md5($post_array['password']);
return $post_array;
}
public function danhmucsanpham_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_language("vietnamese");
$crud->set_theme('datatables');
$crud->set_table('tbl_danhmucsanpham')
->set_subject('Thông Tin Danh Mục Sản Phẩm')
->columns('ten_danhmuc','index');
$crud->display_as('Tên Danh Mục','Vị TrÃ')->display_as('Tên Danh Mục','Vị trÃ');
$output = $crud->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
public function sanpham_management()
{
$query = "SELECT * FROM tbl_danhmucsanpham";
$data = $this->db->query($query)->result_array();
$id_danhmuc;
// print_r($data);
foreach($data as $value){
$k = $value["id"];
$id_danhmuc[$k] = $value["ten_danhmuc"];
}
// try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_sanpham');
$crud->set_subject('Thông Tin Sản Phẩm');
$crud->required_fields('id');
$crud->columns('id','id_danhmuc','ten_sanpham','model_sanpham','gia_sanpham','info_sanpham','img_sanpham','alt_sanpham');
$crud->set_field_upload('img_sanpham','assets/uploads/sanpham');
$crud->field_type('id_danhmuc','dropdown',$id_danhmuc);
$output = $crud->render();
$this->_example_output($output);
// }catch(Exception $e){
// show_error($e->getMessage().' --- '.$e->getTraceAsString());
// }
}
}
?>