Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Service extends CI_Controller {
- public function __construct() {
- parent::__construct();
- $this->load->model('Mservice');
- }
- function index() {
- $data['title'] = 'Data Service Mobil';
- $data['content'] = 'v_service';
- // $data['datatables'] = $this->Mservice->service();
- $this->load->view('template', $data);
- }
- function get_data_user() {
- $list = $this->Mservice->get_datatables();
- $data = array();
- $no = $_POST['start'];
- foreach ($list as $field) {
- $no++;
- $row = array();
- $row[] = $no;
- $detail="rangka: ".$field->no_rangka.
- "<br/>nopol: ".$field->no_polisi;
- $row[]=$detail;
- $row[]="<button>edit</button><button>hapus</button>";
- $data[] = $row;
- }
- $output = array(
- "draw" => $_POST['draw'],
- "recordsTotal" => $this->Mservice->count_all(),
- "recordsFiltered" => $this->Mservice->count_filtered(),
- "data" => $data,
- );
- //output dalam format JSON
- echo json_encode($output);
- }
- function get_data_user_old() {
- $list = $this->Mservice->get_datatables();
- $data = array();
- $no = $_POST['start'];
- foreach ($list as $field) {
- $no++;
- $row = array();
- $row[] = $no;
- $row[] = $field->no_rangka;
- $row[] = $field->no_polisi;
- $row[] = $field->model;
- $row[] = $field->type;
- $row[] = $field->transmission;
- $row[] = $field->warna;
- $row[] = $field->tahun;
- $row[] = $field->km;
- $row[] = $field->customer;
- $row[] = $field->telephone;
- $row[] = $field->handphone;
- $row[] = $field->contact_person;
- $row[] = $field->telephone_cp;
- $row[] = $field->cabang_penjual;
- $row[] = $field->cabang_service;
- $row[] = $field->salesman;
- $row[] = $field->last_service;
- $row[] = $field->job;
- $row[] = $field->pekerjaan_utama;
- $row[] = $field->program_promo;
- $row[] = $field->status_aktif;
- $row[] = $field->hasil_fu1;
- $row[] = $field->hasil_fu2;
- $row[] = $field->hasil_fu3;
- $data[] = $row;
- }
- $output = array(
- "draw" => $_POST['draw'],
- "recordsTotal" => $this->Mservice->count_all(),
- "recordsFiltered" => $this->Mservice->count_filtered(),
- "data" => $data,
- );
- //output dalam format JSON
- echo json_encode($output);
- }
- ///pisahkan saja datanya...
- //function untuk tambah data service, abaikan dahulu karena fokus ke edit data.
- function addService() {
- $add = array(
- 'no_rangka' => $this->input->post('no_rangka'),
- 'no_polisi' => $this->input->post('no_polisi'),
- 'model' => $this->input->post('model'),
- 'type' => $this->input->post('type'),
- 'transmission' => $this->input->post('transmission'),
- 'warna' => $this->input->post('warna'),
- 'tahun' => $this->input->post('tahun'),
- 'km' => $this->input->post('km'),
- 'customer' => $this->input->post('customer'),
- 'telephone' => $this->input->post('telephone'),
- 'handphone' => $this->input->post('handphone'),
- 'contact_person' => $this->input->post('contact_person'),
- 'telephone_cp' => $this->input->post('telephone_cp'),
- 'cabang_penjual' => $this->input->post('cabang_penjual'),
- 'cabang_service' => $this->input->post('cabang_service'),
- 'salesman' => $this->input->post('salesman'),
- 'last_service' => $this->input->post('last_service'),
- 'job' => $this->input->post('job'),
- 'pekerjaan_utama' => $this->input->post('pekerjaan_utama'),
- 'program_promo' => $this->input->post('program_promo'),
- 'status_aktif' => $this->input->post('status_aktif'),
- 'hasil_fu1' => $this->input->post('hasil_fu1'),
- 'hasil_fu2' => $this->input->post('hasil_fu2'),
- 'hasil_fu3' => $this->input->post('hasil_fu3'),
- //'model' => 0
- );
- $this->Mservice->addService($add);
- }
- //funsi edit data, data yang ada di dalam database.
- function editService($id) {
- $flag = array('no_rangka' => $id);
- $get = $this->Mservice->getService($flag)->row();
- echo json_encode($get);
- }
- //fungsi
- function newService() {
- $flag = array('no_rangka' => $this->input->post('oid'));
- $edit = array(
- 'no_rangka' => $this->input->post('nno_rangka'),
- 'no_polisi' => $this->input->post('nno_polisi'),
- 'model' => $this->input->post('nmodel'),
- 'type' => $this->input->post('ntype'),
- 'transmission' => $this->input->post('ntransmission'),
- 'warna' => $this->input->post('nwarna'),
- 'tahun' => $this->input->post('ntahun'),
- 'km' => $this->input->post('nkm'),
- 'customer' => $this->input->post('ncustomer'),
- 'telephone' => $this->input->post('ntelephone'),
- 'handphone' => $this->input->post('nhandphone'),
- 'contact_person' => $this->input->post('ncontact_person'),
- 'telephone_cp' => $this->input->post('ntelephone_cp'),
- 'cabang_penjual' => $this->input->post('ncabang_penjual'),
- 'cabang_service' => $this->input->post('ncabang_service'),
- 'salesman' => $this->input->post('nsalesman'),
- 'last_service' => $this->input->post('nlast_service'),
- 'job' => $this->input->post('njob'),
- 'pekerjaan_utama' => $this->input->post('npekerjaan_utama'),
- 'program_promo' => $this->input->post('nprogram_promo'),
- 'status_aktif' => $this->input->post('nstatus_aktif'),
- 'hasil_fu1' => $this->input->post('nhasil_fu1'),
- 'hasil_fu2' => $this->input->post('nhasil_fu2'),
- 'hasil_fu3' => $this->input->post('nhasil_fu3')
- );
- $this->Mservice->editService($flag, $edit);
- }
- function deleteService($id) {
- $flag = array('no_rangka' => $id);
- $this->Mservice->deleteService($flag);
- }
- }
Add Comment
Please, Sign In to add comment