gundambison

controller service

May 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if (!defined('BASEPATH'))
  4.     exit('No direct script access allowed');
  5.  
  6. class Service extends CI_Controller {
  7.  
  8.     public function __construct() {
  9.         parent::__construct();
  10.         $this->load->model('Mservice');
  11.     }
  12.  
  13.     function index() {
  14.         $data['title'] = 'Data Service Mobil';
  15.         $data['content'] = 'v_service';
  16.         // $data['datatables'] = $this->Mservice->service();
  17.         $this->load->view('template', $data);
  18.     }
  19.  
  20.     function get_data_user() {
  21.         $list = $this->Mservice->get_datatables();
  22.         $data = array();
  23.         $no = $_POST['start'];
  24.         foreach ($list as $field) {
  25.             $no++;
  26.             $row = array();
  27.             $row[] = $no;
  28.             $detail="rangka: ".$field->no_rangka.
  29.                     "<br/>nopol: ".$field->no_polisi;
  30.             $row[]=$detail;
  31.             $row[]="<button>edit</button><button>hapus</button>";
  32.             $data[] = $row;
  33.         }
  34.  
  35.         $output = array(
  36.             "draw" => $_POST['draw'],
  37.             "recordsTotal" => $this->Mservice->count_all(),
  38.             "recordsFiltered" => $this->Mservice->count_filtered(),
  39.             "data" => $data,
  40.         );
  41.         //output dalam format JSON
  42.         echo json_encode($output);
  43.        
  44.     }
  45.    
  46.     function get_data_user_old() {
  47.         $list = $this->Mservice->get_datatables();
  48.         $data = array();
  49.         $no = $_POST['start'];
  50.         foreach ($list as $field) {
  51.             $no++;
  52.             $row = array();
  53.             $row[] = $no;
  54.             $row[] = $field->no_rangka;
  55.             $row[] = $field->no_polisi;
  56.             $row[] = $field->model;
  57.             $row[] = $field->type;
  58.             $row[] = $field->transmission;
  59.             $row[] = $field->warna;
  60.             $row[] = $field->tahun;
  61.             $row[] = $field->km;
  62.             $row[] = $field->customer;
  63.             $row[] = $field->telephone;
  64.             $row[] = $field->handphone;
  65.             $row[] = $field->contact_person;
  66.             $row[] = $field->telephone_cp;
  67.             $row[] = $field->cabang_penjual;
  68.             $row[] = $field->cabang_service;
  69.             $row[] = $field->salesman;
  70.             $row[] = $field->last_service;
  71.             $row[] = $field->job;
  72.             $row[] = $field->pekerjaan_utama;
  73.             $row[] = $field->program_promo;
  74.             $row[] = $field->status_aktif;
  75.             $row[] = $field->hasil_fu1;
  76.             $row[] = $field->hasil_fu2;
  77.             $row[] = $field->hasil_fu3;
  78.             $data[] = $row;
  79.         }
  80.  
  81.         $output = array(
  82.             "draw" => $_POST['draw'],
  83.             "recordsTotal" => $this->Mservice->count_all(),
  84.             "recordsFiltered" => $this->Mservice->count_filtered(),
  85.             "data" => $data,
  86.         );
  87.         //output dalam format JSON
  88.         echo json_encode($output);
  89.     }
  90.  
  91.     ///pisahkan saja datanya...
  92.     //function untuk tambah data service, abaikan dahulu karena fokus ke edit data.
  93.     function addService() {
  94.         $add = array(
  95.             'no_rangka' => $this->input->post('no_rangka'),
  96.             'no_polisi' => $this->input->post('no_polisi'),
  97.             'model' => $this->input->post('model'),
  98.             'type' => $this->input->post('type'),
  99.             'transmission' => $this->input->post('transmission'),
  100.             'warna' => $this->input->post('warna'),
  101.             'tahun' => $this->input->post('tahun'),
  102.             'km' => $this->input->post('km'),
  103.             'customer' => $this->input->post('customer'),
  104.             'telephone' => $this->input->post('telephone'),
  105.             'handphone' => $this->input->post('handphone'),
  106.             'contact_person' => $this->input->post('contact_person'),
  107.             'telephone_cp' => $this->input->post('telephone_cp'),
  108.             'cabang_penjual' => $this->input->post('cabang_penjual'),
  109.             'cabang_service' => $this->input->post('cabang_service'),
  110.             'salesman' => $this->input->post('salesman'),
  111.             'last_service' => $this->input->post('last_service'),
  112.             'job' => $this->input->post('job'),
  113.             'pekerjaan_utama' => $this->input->post('pekerjaan_utama'),
  114.             'program_promo' => $this->input->post('program_promo'),
  115.             'status_aktif' => $this->input->post('status_aktif'),
  116.             'hasil_fu1' => $this->input->post('hasil_fu1'),
  117.             'hasil_fu2' => $this->input->post('hasil_fu2'),
  118.             'hasil_fu3' => $this->input->post('hasil_fu3'),
  119.                 //'model' => 0
  120.         );
  121.         $this->Mservice->addService($add);
  122.     }
  123.  
  124.     //funsi edit data, data yang ada di dalam database.
  125.     function editService($id) {
  126.         $flag = array('no_rangka' => $id);
  127.         $get = $this->Mservice->getService($flag)->row();
  128.         echo json_encode($get);
  129.     }
  130.  
  131.     //fungsi
  132.     function newService() {
  133.         $flag = array('no_rangka' => $this->input->post('oid'));
  134.         $edit = array(
  135.             'no_rangka' => $this->input->post('nno_rangka'),
  136.             'no_polisi' => $this->input->post('nno_polisi'),
  137.             'model' => $this->input->post('nmodel'),
  138.             'type' => $this->input->post('ntype'),
  139.             'transmission' => $this->input->post('ntransmission'),
  140.             'warna' => $this->input->post('nwarna'),
  141.             'tahun' => $this->input->post('ntahun'),
  142.             'km' => $this->input->post('nkm'),
  143.             'customer' => $this->input->post('ncustomer'),
  144.             'telephone' => $this->input->post('ntelephone'),
  145.             'handphone' => $this->input->post('nhandphone'),
  146.             'contact_person' => $this->input->post('ncontact_person'),
  147.             'telephone_cp' => $this->input->post('ntelephone_cp'),
  148.             'cabang_penjual' => $this->input->post('ncabang_penjual'),
  149.             'cabang_service' => $this->input->post('ncabang_service'),
  150.             'salesman' => $this->input->post('nsalesman'),
  151.             'last_service' => $this->input->post('nlast_service'),
  152.             'job' => $this->input->post('njob'),
  153.             'pekerjaan_utama' => $this->input->post('npekerjaan_utama'),
  154.             'program_promo' => $this->input->post('nprogram_promo'),
  155.             'status_aktif' => $this->input->post('nstatus_aktif'),
  156.             'hasil_fu1' => $this->input->post('nhasil_fu1'),
  157.             'hasil_fu2' => $this->input->post('nhasil_fu2'),
  158.             'hasil_fu3' => $this->input->post('nhasil_fu3')
  159.         );
  160.         $this->Mservice->editService($flag, $edit);
  161.     }
  162.  
  163.     function deleteService($id) {
  164.         $flag = array('no_rangka' => $id);
  165.         $this->Mservice->deleteService($flag);
  166.     }
  167.  
  168. }
Add Comment
Please, Sign In to add comment