Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Insertdo extends CI_Controller {
- private $limit = 10;
- function __construct()
- {
- parent::__construct();
- $this->is_logged_in();
- $this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT');
- $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
- $this->output->set_header('Pragma: no-chace');
- $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- // load model
- $this->load->model('minsertdo');
- }
- function cekLevel()
- {
- if($this->session->userdata('level') == "admin")
- {
- $this->load->view('vapp_header');
- $this->load->view('vapp_nav_menu');
- } else {
- $this->load->view('vapp_header');
- $this->load->view('vapp_nav_menu2');
- }
- }
- function index($offset = 0)
- {
- $data['title'] = "Insert DO";
- // offset
- $uri_segment = 4;
- $offset = $this->uri->segment($uri_segment);
- // load data
- $cfields = $this->minsertdo->listData($this->limit, $offset)->result();
- // generate pagination
- $this->load->library('pagination');
- $config['base_url'] = site_url('erp/insertdo/index/');
- $config['total_rows'] = $this->minsertdo->count_allData();
- $config['per_page'] = $this->limit;
- $config['uri_segment'] = $uri_segment;
- $this->pagination->initialize($config);
- $data['pagination'] = $this->pagination->create_links();
- // generate table data
- $this->load->library('table');
- $this->table->set_empty(" ");
- $this->table->set_heading('No', 'NO POLISI', 'NAMA DRIVER', 'PERUSAHAAN', 'TUJUAN', 'TGL. UANG JALAN', 'JML UANG JALAN', '');
- $i = 0 + $offset;
- foreach ($cfields as $cf)
- {
- $this->table->add_row(++$i, $cf->no_polisi, $cf->nama_driver, $cf->name_partner, $cf->name_location, $cf->tgl_uj, $cf->jml_uj,
- anchor('erp/insertdo/new_insertdo/'.$cf->id_timeline,'Insert DO',array('class'=>'delete'))
- );
- }
- $data['table'] = $this->table->generate();
- // load view
- $this->cekLevel();
- $this->load->view('vinsert_do/vinsert_do',$data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- /* Add Insert DO
- --------------------------------------------------------------------------*/
- function new_insertdo($id_timeline)
- {
- // set common properties
- $data['back'] = anchor('erp/insertdo','Back',array('class'=>'back'));
- $data['proses'] = site_url('erp/insertdo/act_insertdo');
- $data['title'] = 'Insert DO';
- $data['message'] = '';
- $data['category'] = $this->minsertdo->get_partner();
- $cf = $this->minsertdo->get_by_id($id_timeline)->row();
- // prefill form values
- $this->form_data = new stdClass();
- $this->form_data->id_timeline = $id_timeline;
- $this->form_data->no_polisi = $cf->no_polisi;
- $this->form_data->id_driver = $cf->id_driver;
- $this->form_data->id_partner = $cf->id_partner;
- $this->form_data->id_class_partner = $cf->id_class_partner;
- $this->form_data->tgl_uj = $cf->tgl_uj;
- $this->form_data->jml_uj = $cf->jml_uj;
- $this->form_data->tgl_ido = $cf->tgl_ido;
- $this->form_data->no_do = $cf->no_do;
- $this->form_data->jml_muatan = $cf->jml_muatan;
- // load view
- $this->cekLevel();
- $this->load->view('vinsert_do/vnewinsert_do',$data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- function src_insertdo($id_timeline)
- {
- $data['src_do'] = $this->minsertdo->get_by_id($id_timeline)->row();
- $this->load->library('table');
- $this->table->set_empty(" ");
- $this->table->set_heading('NO POLISI', 'NAMA DRIVER', 'PERUSAHAAN', 'TUJUAN', 'TGL. UANG JALAN', 'JML UANG JALAN', '');
- $src_do = $this->minsertdo->get_by_id($id_timeline)->row();
- $this->table->add_row($src_do->no_polisi, $src_do->nama_driver, $src_do->name_partner, $src_do->name_location, $src_do->tgl_uj, $src_do->jml_uj,
- anchor('erp/insertdo/new_insertdo/'.$src_do->id_timeline,'Insert DO',array('class'=>'delete'))
- );
- $data['show_src_do']= $this->table->generate();
- $data['title'] = 'Insert DO';
- $this->cekLevel();
- $this->load->view('vinsert_do/vsrc_insert_do', $data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- function act_insertdo()
- {
- $data['back'] = anchor('erp/insertdo','Back',array('class'=>'back'));
- $data['proses'] = site_url('erp/insertdo/act_insertdo');
- $data['title'] = 'Insert DO';
- $data['message'] = '';
- $data['category'] = $this->minsertdo->get_partner();
- // set validation properties
- $this->_set_rules();
- $this->_set_fields();
- // run validation
- if ($this->form_validation->run() == FALSE)
- {
- $data['message'] = '';
- }
- else
- {
- // save data
- $id = $this->input->post('id_timeline');
- $updatedata = array(
- 'no_polisi' => $this->input->post('no_polisi'),
- 'id_driver' => $this->input->post('id_driver'),
- 'id_partner' => $this->input->post('id_partner'),
- 'id_class_partner' => $this->input->post('id_class_partner'),
- 'tgl_uj' => $this->input->post('tgl_uj'),
- 'jml_uj' => $this->input->post('jml_uj'),
- 'tgl_ido' => $this->input->post('tgl_ido'),
- 'no_do' => $this->input->post('no_do'),
- 'jml_muatan' => $this->input->post('jml_muatan'),
- 'status' => "pending",
- 'id' => $this->session->userdata('id')
- );
- $id_driver = $this->input->post('id_driver');
- $rotation = array(
- 'status' => "pending"
- );
- $this->minsertdo->rotasi($id_driver, $rotation);
- $this->minsertdo->update($id, $updatedata);
- redirect('erp/insertdo/success');
- }
- // load view
- $this->cekLevel();
- $this->load->view('vinsert_do/vnewinsert_do',$data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- function success()
- {
- $data['back'] = anchor('erp/insertdo','Insert DO',array('class'=>'back'));
- $data['message'] = '<div class="success">Insert DO success</div>';
- // load view
- $this->cekLevel();
- $this->load->view('success', $data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- /* cari
- --------------------------------------------------------------------------*/
- function do_src()
- {
- $this->load->model('minsertdo');
- $this->_set_fieldssrc();
- $this->_set_fieldssrc();
- $this->form_validation->set_rules('nama_driver', 'Nama_driver', 'required');
- $this->form_validation->set_message('required', '* required');
- $this->form_validation->set_message('isset', '* required');
- $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
- if ($this->form_validation->run() == FALSE)
- {
- $data['message'] = '';
- }
- else
- {
- $nama_driver = $this->input->post('nama_driver');
- $this->minsertdo->search_do($nama_driver);
- }
- $data['title'] = "Insert DO";
- // offset
- $uri_segment = 4;
- $offset = $this->uri->segment($uri_segment);
- //load data search
- $this->load->model('minsertdo');
- $this->load->library('table');
- $this->table->set_empty(" ");
- $this->table->set_heading('No', 'NO POLISI', 'NAMA DRIVER', 'PERUSAHAAN', 'TUJUAN', 'TGL. UANG JALAN', 'JML UANG JALAN', '');
- $i = 0 + $offset;
- $isi = $this->minsertdo->search_do($nama_driver);
- foreach ($isi as $baris)
- {
- $this->table->add_row(++$i, $baris->no_polisi, $baris->nama_driver, $baris->name_partner, $baris->name_location, $baris->tgl_uj, $baris->jml_uj,
- anchor('erp/insertdo/new_insertdo/'.$baris->id_timeline,'Insert DO',array('class'=>'delete'))
- );
- }
- $data['src_show_do']= $this->table->generate();
- // load view
- $this->cekLevel();
- $this->load->view('vinsert_do/vinsert_do_search',$data);
- $this->load->view('vapp_right_menu');
- $this->load->view('vapp_footer');
- }
- function _set_fieldssrc()
- {
- $this->form_data = new stdClass();
- $this->form_data->nama_driver = '';
- }
- /* Add Devinisi Order
- --------------------------------------------------------------------------*/
- //function untuk menampilkan tujuan submodul dari partner
- function show_subcategory($id)
- {
- $tmp = '';
- $data = $this->minsertdo->get_subcategory($id);
- if(!empty($data))
- {
- $tmp .= "<option value=''>Pilih Tempat</option>";
- $valYgDIpilih=$this->form_data->id_partner;
- foreach($data as $row)
- {
- if($valYgDIpilih == $row->id_partner)
- {
- $sel ='selected';
- }
- else
- {
- $sel='';
- }
- $tmp .= "<option $sel value='".$row->id_class_partner."'>".$row->name_location."</option>";
- }
- }
- else
- {
- $tmp .= "<option value=''>Pilih Tempat</option>";
- }
- die($tmp);
- }
- // set empty default form field values
- function _set_fields()
- {
- $this->form_data = new stdClass();
- $this->form_data->id_timeline = '';
- $this->form_data->no_polisi = '';
- $this->form_data->id_driver = '';
- $this->form_data->id_partner = '';
- $this->form_data->id_class_partner = '';
- $this->form_data->tgl_uj = '';
- $this->form_data->jml_uj = '';
- $this->form_data->tgl_ido = '';
- $this->form_data->no_do = '';
- $this->form_data->jml_muatan = '';
- }
- // validation rules
- function _set_rules()
- {
- $this->form_validation->set_rules('id_timeline', 'id timeline', 'trim|required');
- $this->form_validation->set_rules('no_polisi', 'no polisi', 'trim|required');
- $this->form_validation->set_rules('id_driver', 'nama driver', 'trim|required');
- $this->form_validation->set_rules('id_partner', 'perusahaan', 'trim|required');
- $this->form_validation->set_rules('id_class_partner', 'tujuan', 'trim|required');
- $this->form_validation->set_rules('tgl_uj', 'tanggal uang jala', 'trim|required');
- $this->form_validation->set_rules('jml_uj', 'jumlah uang jalan', 'trim|required');
- $this->form_validation->set_rules('tgl_ido', 'tanggal insert do', 'trim|required');
- $this->form_validation->set_rules('no_do', 'no do', 'trim|required');
- $this->form_validation->set_rules('jml_muatan', 'jumlah muatan', 'trim|required');
- $this->form_validation->set_message('isset', '* required');
- $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
- }
- //valiation login
- function is_logged_in()
- {
- $is_logged_in = $this->session->userdata('is_logged_in');
- if(!isset($is_logged_in) || $is_logged_in != true)
- {
- echo 'You don\'t have permission to access this page. <a href="app">Login</a>';
- die();
- //$this->load->view('login_form');
- }
- }
- }
- /* End of file insertdo.php */
- /* Location: ./application/controllers/insertdo.php */
Advertisement
Add Comment
Please, Sign In to add comment