Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Admin extends CI_Controller{
- function __construct(){
- parent::__construct();
- $this->load->helper('url');
- $this->load->model('m_admin');
- if($this->session->userdata('status') != "login"){
- redirect('login');
- }
- }
- function index(){
- $data['vendor']=$this->m_admin->vendor();
- $this->load->view('admin/header',$data);
- $this->load->view('admin/home',$data);
- $this->load->view('admin/footer',$data);
- }
- function vendor(){
- $this->load->library('pagination');
- $this->load->library('table');
- $config['base_url'] = '/admin/vendor/';
- $config['total_rows'] = $this->db->get('vendor')->num_rows();
- $config['per_page'] = 10;
- $this->pagination->initialize($config);
- //---- curiga yg ini
- $data['records'] = $this->db->get('vendor', $config['per_page'], $this->uri->segment(3));
- echo "page =".$config['per_page']."<br>segmen=". $this->uri->segment(3));
- echo "<pre>".print_r($_REQUEST,1)."</pre>";
- $data['vendor']=$this->m_admin->vendor();
- $this->load->view('admin/header');
- $this->load->view('admin/vendor/V_vendorList',$data);
- $this->load->view('admin/footer');
- }
- function tambah_vendor(){
- $this->load->library('form_validation');
- $this->form_validation->set_rules('category','category','required');
- $this->form_validation->set_rules('name','name','required');
- $this->form_validation->set_rules('address','address','required');
- if($this->form_validation->run() != true ){
- $data['vendorCategory'] = $this->m_admin->vendorCategory();
- $this->load->view('admin/header');
- $this->load->view('admin/vendor/v_vendorAdd',$data);
- $this->load->view('admin/footer');
- }else{
- $category = $this->input->post('category');
- $name = $this->input->post('name');
- $address = $this->input->post('address');
- $config['upload_path'] = './gambar_posting/';
- $config['allowed_types'] = 'gif|jpg|png';
- $this->load->library('upload', $config);
- $this->upload->do_upload('icon');
- $data = array('upload_data' => $this->upload->data());
- $d = array(
- 'category' => $category,
- 'name' => $name,
- 'address' => $address,
- 'icon' => $data['upload_data']['file_name']
- );
- $this->m_admin->tambah_vendor($d);
- redirect('admin/vendor/oke','refresh');
- }
- }
- function edit_vendor($id){
- $this->load->library('form_validation');
- $data['vendor'] = $this->m_admin->edit_vendor($id);
- $data['vendorCategory'] = $this->m_admin->vendorCategory();
- $this->load->view('admin/header');
- $this->load->view('admin/vendor/V_vendorEdit',$data);
- $this->load->view('admin/footer');
- }
- function update_vendor(){
- $this->load->library('form_validation');
- $id = $this->input->post('id');
- $this->form_validation->set_rules('category','category','required');
- $this->form_validation->set_rules('name','name','required');
- $this->form_validation->set_rules('address','address','required');
- if($this->form_validation->run() != true ){
- $data['vendor'] = $this->m_admin->edit_vendor($id);
- $data['vendorCategory'] = $this->m_admin->vendorCategory();
- $this->load->view('admin/header');
- $this->load->view('admin/vendor/V_vendorEdit',$data);
- $this->load->view('admin/footer');
- }else{
- $category = $this->input->post('category');
- $name = $this->input->post('name');
- $address = $this->input->post('address');
- if($_FILES['icon']['name'] == ""){
- $d = array(
- 'category' => $category,
- 'name' => $name,
- 'address' => $address
- );
- $this->m_admin->update_vendor($d,$id);
- redirect('admin/vendor/diupdate','refresh');
- }else{
- $config['upload_path'] = './gambar_posting/';
- $config['allowed_types'] = 'gif|jpg|png';
- $this->load->library('upload', $config);
- $this->upload->do_upload('icon');
- $data = array('upload_data' => $this->upload->data());
- $d = array(
- 'category' => $category,
- 'name' => $name,
- 'address' => $address,
- 'icon' => $data['upload_data']['file_name']
- );
- $this->m_admin->update_vendor($d,$id);
- redirect('admin/vendor/diupdate','refresh');
- }
- }
- }
- function hapus_vendor($id){
- $this->m_admin->hapus_vendor($id);
- redirect('admin/vendor/dihapus');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement