PageRenderTime 68ms CodeModel.GetById 3ms RepoModel.GetById 1ms app.codeStats 0ms

/application/modules/group_manivest_detail/controllers/Group_manivest_detail.php

https://bitbucket.org/bo_hmb/bo_hmb
PHP | 304 lines | 202 code | 64 blank | 38 comment | 20 complexity | 7e646e019eb31e4b0508299d729d3c00 MD5 | raw file
Possible License(s): Apache-2.0, MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Group_manivest_detail extends AdminController {
  3. public function __construct()
  4. {
  5. parent::__construct();
  6. $this->tanggal = date("Y-m-d");
  7. $this->jam = date("H:i:s");
  8. $this->bulan = date('m');
  9. $this->tahun = date('Y');
  10. // Module components
  11. $this->data['module'] = 'Group Manivest Detail';
  12. $this->data['pluginCss'] = $this->load->view('assets/_pluginCss', $this->data, true);
  13. $this->data['pluginJs'] = $this->load->view('assets/_pluginJs', $this->data, true);
  14. $this->load->model('M_group_manivest_detail');
  15. // $this->load->model('M_movement');
  16. // $this->output->enable_profiler(TRUE);
  17. if($this->cekCurrentUser > 0) {
  18. $this->group = $this->ion_auth->get_users_groups( $this->currentUser->id)->result();
  19. foreach ($this->group as $key => $value) {
  20. $userGroup[$value->name] = $value->description;
  21. }
  22. $this->userLevel = $userGroup;
  23. }
  24. }
  25. public function group_manivest()
  26. {
  27. // Page components
  28. // $this->data['userGroup'] = $this->userLevel;
  29. $this->data['pageTitle'] = 'Group Manivest Detail';
  30. $this->data['pageCss'] = $this->load->view('assets/_pageCss', $this->data, true);;
  31. $this->data['pageJs'] = $this->load->view('assets/_pageJs', $this->data, true);
  32. // $this->data['idmovement'] = $this->uri->segment(3);
  33. $this->data['group_manivest'] = $this->M_group_manivest_detail->get_group_manivest(array('id' => $this->uri->segment(3)))->row();
  34. $this->data['content'] = $this->load->view('main', $this->data, true);
  35. // Render page
  36. $this->renderPage();
  37. }
  38. public function load_data($id)
  39. {
  40. // $id_movement = $this->input->post('id_movement',TRUE);
  41. $jam = $this->input->post('jam',TRUE);
  42. $agenda = $this->input->post('agenda',TRUE);
  43. $cols = array();
  44. // if (!empty($id_movement)) { $cols['id_movement'] = $id_movement; }
  45. if (!empty($jam)) { $cols['jam'] = $jam; }
  46. if (!empty($agenda)) { $cols['agenda'] = $agenda; }
  47. if(array_key_exists('Super Admin', $this->userLevel)) {
  48. $where = "pendaftar.active = '1' AND jadwal.id = '".$id."'";
  49. } else {
  50. $where = "pendaftar.active = '1' AND jadwal.id = '".$id."'";
  51. }
  52. $list = $this->M_group_manivest_detail->get_datatables($where, $cols);
  53. $last_query = $this->db->last_query();
  54. // die(print_r($last_query));
  55. $iTotalRecords = $this->M_group_manivest_detail->count_all($where);
  56. $iDisplayLength = intval($_REQUEST['length']);
  57. $iDisplayLength = $iDisplayLength < 0 ? $iTotalRecords : $iDisplayLength;
  58. $iDisplayStart = intval($_REQUEST['start']);
  59. $sEcho = intval($_REQUEST['draw']);
  60. $records = array();
  61. $records["data"] = array();
  62. $end = $iDisplayStart + $iDisplayLength;
  63. $end = $end > $iTotalRecords ? $iTotalRecords : $end;
  64. $no = $iDisplayStart;
  65. foreach ($list as $r) {
  66. $no++;
  67. // <button class="btn btn-xs btn-outline red btn-update-status" data-id="'.$r->id.'" data-toggle="confirmation" data-placement="top" data-btn-ok-label="Yes" data-btn-ok-icon="icon-user-following" data-btn-ok-class="btn-success" data-btn-cancel-label="No" data-btn-cancel-icon="icon-user-unfollow" data-btn-cancel-class="btn-danger"><i class="fa fa-trash"></i></button>
  68. $btn_action = '<div class="btn-group btn-group-xs btn-group-solid">
  69. <button type="button" class="btn btn-xs yellow btn-outline btn-edit tooltips" data-container="body" data-placement="top" data-original-title="Tooltip in top" data-id="'.$r->id_formulir.'"><i class="fa fa-edit"></i></button>
  70. </div>';
  71. if($r->stts == '1')
  72. {
  73. $status = 'OK';
  74. $label = 'success';
  75. $checkbox = '<span class="label label-sm label-'.$label.'">'.$status.'</span>';
  76. }else{
  77. $checkbox = '<label class="mt-checkbox mt-checkbox-single mt-checkbox-outline"><input name="checkbox[]" type="checkbox" class="checkboxes" value="'.$r->id_pendaftar.'"/><span></span></label>';
  78. $status = 'Belum Lunas';
  79. $label = 'danger';
  80. }
  81. // $btn_action='';
  82. $records["data"][] = array(
  83. $no,
  84. $r->title,
  85. // $r->no_pendaftaran,
  86. $r->nm_lengkap,
  87. $r->no_pasport,
  88. $r->tgl_lahir,
  89. $r->tmp_lahir,
  90. $r->create_pasport,
  91. $r->exp_pasport,
  92. $r->kota_paspor,
  93. // $r->nm_cabang,
  94. // $r->age,
  95. // $r->hubungan,
  96. $r->nm_marketing,
  97. $checkbox.''.$btn_action,
  98. );
  99. }
  100. if (isset($_REQUEST["customActionType"]) && $_REQUEST["customActionType"] == "group_action") {
  101. $records["customActionStatus"] = "OK"; // pass custom message(useful for getting status of group actions)
  102. $records["customActionMessage"] = "Group action successfully has been completed. Well done!"; // pass custom message(useful for getting status of group actions)
  103. }
  104. $records["draw"] = $sEcho;
  105. $records["recordsTotal"] = $iTotalRecords;
  106. $records["recordsFiltered"] = $iTotalRecords;
  107. echo json_encode($records);
  108. }
  109. function update_multiple()
  110. {
  111. // db transaction
  112. $this->db->trans_begin();
  113. // prospect detail
  114. $totdata = $this->input->post('checkbox');
  115. if($totdata != null) {
  116. // $this->load->model('prospect/m_prospect_detail');
  117. foreach ($totdata as $key => $value) {
  118. $data = array(
  119. 'stts' => '1',
  120. 'user_update' => $this->currentUser->id,
  121. );
  122. $query = $this->M_group_manivest_detail->_update(array('id' => $this->input->post('checkbox')[$key]), $data);
  123. }
  124. }else { $queryDetail = TRUE; }
  125. // db transaction
  126. // $this->db->trans_complete();
  127. // Check if query was success
  128. if ($this->db->trans_status() === FALSE)
  129. {
  130. $this->db->trans_rollback();
  131. // generate an error... or use the log_message() function to log your error
  132. $response = array('status' => false, 'action' => 'Failed', 'message' => 'Failed to update');
  133. }else{
  134. $this->db->trans_commit();
  135. $response = array('status' => true, 'action' => 'Success', 'message' => 'Update successfully');
  136. }
  137. return response($response, 'json');
  138. }
  139. public function load_detail()
  140. {
  141. $id = $this->input->get('id');
  142. $data['main'] = $this->m_customer->get_where(array('id' => $id ))->row();
  143. return response($this->load->view('detail', $data, TRUE), 'html');
  144. }
  145. public function load_add_form($id)
  146. {
  147. $data['title'] = 'Tambah Data Movedet';
  148. $data['movement'] = $id;
  149. return response($this->load->view('add_', $data, TRUE), 'html');
  150. }
  151. public function add()
  152. {
  153. // $this->validateInput();
  154. $data = array(
  155. 'id_movement' => $this->input->post('id_movement',TRUE),
  156. 'jam' => $this->input->post('jam',TRUE),
  157. 'agenda' => $this->input->post('agenda',TRUE),
  158. 'active' => '1',
  159. );
  160. $query = $this->M_group_manivest_detail->_insert($data);
  161. // Check if query was success
  162. if ($query) {
  163. $response = array('status' => true, 'action' => 'Success', 'message' => 'Data berhasil ditambahkan');
  164. } else {
  165. $response = array('status' => false, 'action' => 'Failed', 'message' => 'Data gagal ditambahkan');
  166. }
  167. return response($response, 'json');
  168. }
  169. public function load_edit_form()
  170. {
  171. $id = $this->input->get('id');
  172. $data['main'] = $this->M_group_manivest_detail->get_where_form(array('id' => $id))->row();
  173. return response($this->load->view('edit_formulir_mini', $data, TRUE), 'html');
  174. }
  175. public function edit_mini()
  176. {
  177. // Check if ajax request
  178. $this->ajaxRequest();
  179. // Validate the submitted data
  180. // $this->validateInput();
  181. // Preparing the data before update
  182. $id = $this->input->post('id');
  183. $data = array(
  184. 'nm_lengkap' => $this->input->post('nm_lengkap',TRUE),
  185. 'tmp_lahir' => $this->input->post('tmp_lahir',TRUE),
  186. 'tgl_lahir' => $this->input->post('tgl_lahir',TRUE),
  187. 'jk' => $this->input->post('jk',TRUE),
  188. 'create_pasport' => $this->input->post('create_pasport',TRUE),
  189. 'no_pasport' => $this->input->post('no_pasport',TRUE),
  190. 'exp_pasport' => $this->input->post('exp_pasport',TRUE),
  191. 'kota_paspor' => $this->input->post('kota_paspor',TRUE),
  192. );
  193. $query = $this->M_group_manivest_detail->_update_formulir(array('id' => $id), $data);
  194. // Check if query was success
  195. if ($query) {
  196. $results = array('status' => true, 'action' => 'Success', 'message' => 'updated successfully');
  197. } else {
  198. $results = array('status' => false, 'action' => 'Failed', 'message' => 'Failed to update');
  199. }
  200. // Return the result to the view
  201. return response($results);
  202. }
  203. public function delete()
  204. {
  205. $id = $this->input->post('id');
  206. $data = array(
  207. 'active' => '0',
  208. );
  209. // die(print_r($data));
  210. $query = $this->M_group_manivest_detail->_update(array('id' => $id), $data);
  211. // Check if query was success
  212. if ($query) {
  213. $results = array('status' => true, 'action' => 'Success', 'message' => 'berhasil');
  214. } else {
  215. $results = array('status' => false, 'action' => 'Failed', 'message' => 'Gagal');
  216. }
  217. // Return the result to the view
  218. return response($results, 'json');
  219. }
  220. public function validateInput()
  221. {
  222. // Load form validation library
  223. $this->load->library('form_validation');
  224. // Set validation rules
  225. //id_movement,jam,agenda
  226. $this->form_validation->set_rules('id_movement', 'nm hotel', 'trim|required');
  227. $this->form_validation->set_rules('jam', 'kota lokasi', 'trim|required');
  228. $this->form_validation->set_rules('agenda', 'alamat', 'trim|required');
  229. // Run the validation
  230. if ($this->form_validation->run() === false) {
  231. $response = array(
  232. 'status' => false,
  233. 'action' => 'Failed',
  234. 'message' => $this->form_validation->error_string('<h5>', '</h5>')
  235. );
  236. return response($response, 'json');
  237. }
  238. }
  239. }
  240. ?>