Advertisement
yhoezt_27

Untitled

Aug 7th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. (1) Pengambilan Nilai dari Form_Input -> Server
  2. function aktifitas(id)
  3. {
  4. $.ajax({
  5. type: "GET",
  6. url: "<?php echo site_url('kegiatan/cek_type_kegiatan/')?>/" + id,
  7. dataType: "JSON",
  8. success: function(response)
  9. {
  10. var list_id = [];
  11. $(".data-check:checked").each(function() {
  12. list_id.push(this.value);
  13. });
  14. if(list_id.length > 0)
  15. {
  16. if(confirm('aktifitas ' + response.data.nm_type + ' sejumlah ' + list_id.length +' data ?'))
  17. {
  18. $.ajax({
  19. type: "POST",
  20. data: {id_brng:list_id},
  21. url: "<?php echo site_url('kegiatan/ajax_bulk_aktifitas/')?>/" + response.data.id,
  22. dataType: "JSON",
  23. success: function(respon)
  24. {
  25. if(respon.status)
  26. {
  27. window.location.href = respon.redirect_back;
  28. }
  29. },
  30. error: function (xhr, status) {
  31. alert('Unknown error ' + status);
  32. }
  33. });
  34. }
  35. else
  36. {
  37. $(".data-check").prop('checked', false);
  38. }
  39. }
  40. else
  41. {
  42. alert('no data selected');
  43. }
  44. },
  45. error: function (jqXHR, textStatus, errorThrown)
  46. {
  47. alert(jqXHR.responseText);
  48. }
  49. });
  50. }
  51.  
  52. (2) Pengambilan Nilai (Server) -> $_SESSION
  53. function ajax_bulk_aktifitas($id)
  54. {
  55. $id_brng = array();
  56. $list_id = $this->input->post('id_brng');
  57. $cek_type = $this->m_all->cek($id, 'id', 'tb_type');
  58. if ($cek_type->num_rows() > 0)
  59. {
  60. foreach ($cek_type->result() as $var)
  61. {
  62. $masuk = $var->masuk; $keluar = $var->keluar; $nm_type = $var->nm_type;
  63. }
  64.  
  65. $this->session->set_userdata('url',site_url('kegiatan/action/'.$nm_type.'/'.$this->session->userdata('namauser')));
  66.  
  67. $status = true;
  68.  
  69. if ($keluar == '1')
  70. {
  71. foreach ($list_id as $key)
  72. {
  73. $cek_stock = $this->m_all->cek($key, 'id_brng', 'tb_stock');
  74. if ($cek_stock->num_rows() > 0)
  75. {
  76. foreach ($cek_stock->result() as $cs)
  77. {
  78. if (($cs->jumlah > 0) && ($cs->aktif == '1'))
  79. {
  80. $id_brng[] = $cs->id_brng;
  81. }
  82. }
  83. }
  84. }
  85.  
  86. if (count($id_brng))
  87. {
  88. $this->session->set_userdata('id_brng', $id_brng);
  89. }
  90. }
  91. else
  92. {
  93. $this->session->set_userdata('id_brng', $list_id);
  94. }
  95. }
  96. else $status = false;
  97.  
  98. if ($status)
  99. {
  100. $respon = array('status'=>'true','redirect_back'=>site_url('kegiatan/index'));
  101. }
  102. else $respon = array('status'=>'false');
  103.  
  104. echo json_encode($respon);
  105.  
  106. }
  107.  
  108. (3) PENGGUNAAN NILAI (SERVER)
  109. function action($nm_type,$user)
  110. {
  111. $cek_type = $this->m_all->cek($nm_type, 'nm_type', 'tb_type');
  112. if ($cek_type->num_rows() > 0)
  113. {
  114. $status = true;
  115. foreach ($cek_type->result() as $ct)
  116. {
  117. $masuk = $ct->masuk; $keluar = $ct->keluar;
  118. }
  119. }
  120. else $status = false;
  121.  
  122. if ($status == true)
  123. {
  124. $data['title'] = 'Aktifitas _'.$nm_type.' _ '.$user;
  125. $data['nm_type'] = $nm_type;
  126. $data['list_id'] = $this->session->userdata('id_brng');
  127. $data['masuk'] = $masuk;
  128. $data['keluar'] = $keluar;
  129. }
  130. else
  131. {
  132. $data['title'] = 'Aktifitas';
  133. $data['nm_type'] = '';
  134. }
  135.  
  136. $this->template->display('kegiatan/action',$data);
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement