belajarmasak

controller_daribos_gunawan

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