Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (1) Pengambilan Nilai dari Form_Input -> Server
- function aktifitas(id)
- {
- $.ajax({
- type: "GET",
- url: "<?php echo site_url('kegiatan/cek_type_kegiatan/')?>/" + id,
- dataType: "JSON",
- success: function(response)
- {
- var list_id = [];
- $(".data-check:checked").each(function() {
- list_id.push(this.value);
- });
- if(list_id.length > 0)
- {
- if(confirm('aktifitas ' + response.data.nm_type + ' sejumlah ' + list_id.length +' data ?'))
- {
- $.ajax({
- type: "POST",
- data: {id_brng:list_id},
- url: "<?php echo site_url('kegiatan/ajax_bulk_aktifitas/')?>/" + response.data.id,
- dataType: "JSON",
- success: function(respon)
- {
- if(respon.status)
- {
- window.location.href = respon.redirect_back;
- }
- },
- error: function (xhr, status) {
- alert('Unknown error ' + status);
- }
- });
- }
- else
- {
- $(".data-check").prop('checked', false);
- }
- }
- else
- {
- alert('no data selected');
- }
- },
- error: function (jqXHR, textStatus, errorThrown)
- {
- alert(jqXHR.responseText);
- }
- });
- }
- (2) Pengambilan Nilai (Server) -> $_SESSION
- function ajax_bulk_aktifitas($id)
- {
- $id_brng = array();
- $list_id = $this->input->post('id_brng');
- $cek_type = $this->m_all->cek($id, 'id', 'tb_type');
- if ($cek_type->num_rows() > 0)
- {
- foreach ($cek_type->result() as $var)
- {
- $masuk = $var->masuk; $keluar = $var->keluar; $nm_type = $var->nm_type;
- }
- $this->session->set_userdata('url',site_url('kegiatan/action/'.$nm_type.'/'.$this->session->userdata('namauser')));
- $status = true;
- if ($keluar == '1')
- {
- foreach ($list_id as $key)
- {
- $cek_stock = $this->m_all->cek($key, 'id_brng', 'tb_stock');
- if ($cek_stock->num_rows() > 0)
- {
- foreach ($cek_stock->result() as $cs)
- {
- if (($cs->jumlah > 0) && ($cs->aktif == '1'))
- {
- $id_brng[] = $cs->id_brng;
- }
- }
- }
- }
- if (count($id_brng))
- {
- $this->session->set_userdata('id_brng', $id_brng);
- }
- }
- else
- {
- $this->session->set_userdata('id_brng', $list_id);
- }
- }
- else $status = false;
- if ($status)
- {
- $respon = array('status'=>'true','redirect_back'=>site_url('kegiatan/index'));
- }
- else $respon = array('status'=>'false');
- echo json_encode($respon);
- }
- (3) PENGGUNAAN NILAI (SERVER)
- function action($nm_type,$user)
- {
- $cek_type = $this->m_all->cek($nm_type, 'nm_type', 'tb_type');
- if ($cek_type->num_rows() > 0)
- {
- $status = true;
- foreach ($cek_type->result() as $ct)
- {
- $masuk = $ct->masuk; $keluar = $ct->keluar;
- }
- }
- else $status = false;
- if ($status == true)
- {
- $data['title'] = 'Aktifitas _'.$nm_type.' _ '.$user;
- $data['nm_type'] = $nm_type;
- $data['list_id'] = $this->session->userdata('id_brng');
- $data['masuk'] = $masuk;
- $data['keluar'] = $keluar;
- }
- else
- {
- $data['title'] = 'Aktifitas';
- $data['nm_type'] = '';
- }
- $this->template->display('kegiatan/action',$data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement