belajarmasak

controllernya

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