belajarmasak

Service-individual

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