belajarmasak

Service-dropdown

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