<?php

CLASS gcab extends RasioProject
{
	protected $set;
	protected $enableCk = true;

	public function __construct($config)
	{
		$this->getConfig($config);
		$this->validation();
		$this->set();
	}

	protected function set()
	{
		$this->set->em 			= $this->em;
		$this->set->modul 		= 'Group Profit Center';
		$this->set->dBaseH 		= 'grp_cab';
		$this->set->dBaseD 		= false;
		$this->set->dBasePk 	= array('kd_grp_cab');
		$this->set->dSort 		= 'asc';
		$this->set->form 		= $this->setForm();
		$this->set->clearForm 	= array();
		$this->set->notNull 	= array("kd_grp_cab", "kd_grp_cab");
		$this->set->grid 		= $this->setGrid();
		$this->set->cetak 		= $this->setPrint();
		$this->set->button 		= array("First", "Prev", "Next", "Last", "Browse", "Add", "Del", "Edit", "prinT");
		$this->set->addClear 	= true;
		return $this->set;
	}
	
	protected function setForm()
	{
		$form[] = array('row' => 25, 'col' => 25, "label" => array("name" => "Kode", "width" => 100), "input" => array("type" => 'text',	'attr' => array("name" => 'kd_grp_cab', "size" => 5)));
		$form[] = array('row' => 50, 'col' => 25, "label" => array("name" => "Nama", "width" => 100), "input" => array("type" => 'text',	'attr' => array("name" => 'nm_grp_cab', "size" => 30)));
		return $form;
	}
	
	protected function setGrid()
	{
		$kode = new Kode;
		$res->page 	= 50;
		$res->sortA = $kode->getPk($this->set->dBasePk);
		$res->sortT = 'asc';
		
		$res->attr[]	= array("label" => 'Kode', 'attr' => 'a.kd_grp_cab', "sort" => 'true', "width" => 100, 'align' => 'left', 'focus' => 'true');
		$res->attr[]	= array("label" => 'Group', 'attr' => 'a.nm_grp_cab', "sort" => 'true', "width" => 300, 'align' => 'left');
		
		return $res;
	}
	
	protected function setPrint()
	{
		$kode = new Kode;
		$res->sortA = $kode->getPk($this->set->dBasePk);
		$res->sortT = 'asc';
		$res->width = '600px';
		
		$res->attr[]	= array("label" => 'Kode', 'attr' => 'a.kd_grp_cab', "sort" => 'true', "width" => 100, 'align' => 'left', 'filter' => true);
		$res->attr[]	= array("label" => 'Group', 'attr' => 'a.nm_grp_cab', "sort" => 'true', 'align' => 'left', 'filter' => true);
		
		return $res;
	}
	
	public function Index()
	{
		if($_GET['loadAct'] == 'akses'){
			$this->Akses();
			return;
		}
		if($_GET['loadAct'] == 'AksesAct'){
			$this->AksesAct();
			return;
		}
	
		$this->data = $this->set;
		$this->view = "default/index";
	}
	
	public function data()
	{
		$basic = new Basic;
		$this->data = $basic->data($_GET, $this->set);
		$this->view = "default/displayData";
		$this->layout = "view";
	}
	
	public function Find()
	{
		$basic = new Basic;
		$this->data = $basic->find($_GET, $this->set);
		$this->view = "default/displayForm";
		$this->layout = "view";
	}
	
	protected function validasi()
	{
		$basic = new Basic;
		$error[] = $basic->validasiBasic($_POST, $this->set);
		return $basic->getError($error);
	}
	
	public function proses()
	{
		$basic = new Basic;
		$validasi = $this->validasi();
		if($validasi == true){
			$basic->proses($_POST, $this->set);
		}
		$this->layout = "null";
	}
	
	public function Delete()
	{
		$basic = new Basic;
		$this->data = $basic->delete($_GET, $this->set);
		$this->layout = "null";
	}
	
	public function cetak()
	{
		$basic = new Basic;
		$this->data->data = $basic->printer($_GET, $this->set);
		$this->data->width = $this->set->cetak->width;
		$this->view = "default/cetak";
		$this->layout = "print";
	}
	
	public function load()
	{
		$basic = new Basic;
		$this->data = $basic->load($_GET, $this->set);
		$this->layout = "null";
	}
	
	public function popUp()
	{
		$basic = new Basic;
		$this->data = $basic->data($_GET, $this->set);
		$this->view = "default/displayDataPopUp";
		$this->layout = "view";
	}
}