<?php 

/*

Fungsi : Controller untuk Report PO-BA

*/



if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class Po_ba extends CI_Controller {

	

/*-------------Inisialisasi variabel--------------*/ 

	

	//Menu ID utk keperluan otorisasi

	var $menu_list_po  = 204;
/*-------------Inisialisasi variabel--------------*/ 	



/*------------Fungsi local------------------------*/	

	function __construct()

	{

		parent::__construct();
	$this->load->model('ppic/ppic_model', '', TRUE);

		$this->fungsi->check_login();
	}
	public function index()
	{	
		$this->ppic_list_ba_po();
	}
	

	/* Display list BA-PO */

	function ppic_list_ba_po()

	{	
	//Check otorisasi
	$this->fungsi->trans_auth($this->session->userdata('view'));
	
	//Otorisasi menu
		$this->fungsi->menu_auth($this->menu_list_ba);

		/* Setting Parameter Untuk Paging */
		$uri_segment = 4;
		$offset =    $this->uri->segment($uri_segment);
		
		$dn = $this->ppic_model->get_ba_paging($this->session->userdata('idcab'),$this->config->item('paging_limit'), $offset)->result();
		$num_rows = $this->ppic_model->count_all_ba($this->session->userdata('idcab'));
		
		$config['base_url'] = site_url('ppic/po_ba/ppic_list_ba_po/');
		
		if ($num_rows > 0) // Jika query menghasilkan data
				{
					// Membuat pagination			
					$config['total_rows'] = $num_rows;
					$config['per_page'] = $this->config->item('paging_limit');
					$config['uri_segment'] = $uri_segment;
					$this->pagination->initialize($config);
					$data['pagination'] = $this->pagination->create_links();
					$i = 0 + $offset;		

					$tmpl = array( 'table_open'    => '<table border="0" cellpadding="1" cellspacing="1" id="list">',
								  'row_alt_start'  => '<tr class="zebra">',
								  'row_alt_end'    => '</tr>'
								  );
					$this->table->set_template($tmpl);

					// Set heading untuk tabel
					$this->table->set_empty("&nbsp;");
					$this->table->set_heading('No. BA', 'Pengirim', 'Manifest', 'Volume', 'Driver', 'Options');

					$atts = array(
              'width'      => '100',
              'height'     => '100',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
              'screenx'    => '0',
              'screeny'    => '0'
            );

				

					foreach ($ba  as $bas)
					{	
	$this->table->add_row($bas->dnnumb, $bas->cabname, $bas->mnfst, $bas->vol, $bas->driver,  anchor_popup('branch/cabang_dn/print_dn_popup/'.$dns->iddn.'/'.$bas->idcab.'/'.$bas->year,'Print',array('class'=> 'print',$atts),$atts).' '.anchor('branch/cabang_dn/cancel_dn/'.$bas->iddn.'/'.$bas->idcab.'/'.$bas->year,'Cancel',array('class'=> 'delete',$atts),$atts));


					}
					$data['table'] = $this->table->generate();
				    }
			else
				{
					$data['message'] = 'No data';
				}		

		$data['menu_path'] = 'CIBITUNG > PPIC > LIST BERITA ACARA';
		$this->load->view('ppic/ppic_ba_list', $data);
	}	

}