<?php

CLASS sub 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 		= 'Master Sub';
		$this->set->dBaseH 		= 'sub';
		$this->set->dBaseD 		= false;
		$this->set->dBasePk 	= array('kd_sub');
		$this->set->where 		= array("(jenis = '33' or jenis = '35' or jenis = '37' or jenis = '11' or jenis = '12' or jenis = '4')");
		$this->set->dSort 		= 'asc';
		$this->set->multisort 	= 'jenis asc, kd_sub asc';
		$this->set->form 		= $this->setForm();
		$this->set->clearForm 	= array("ket_induk");
		$this->set->notNull 	= array("kd_sub", "nm_sub", "alamat", "kota");
		$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()
	{
		return array();
	}
	
	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_sub', "sort" => 'true', "width" => 120, 'align' => 'left');
		$res->attr[]	= array("label" => 'Nama', 'attr' => 'a.nm_sub', "sort" => 'true', "width" => 150, 'align' => 'left');
		$res->attr[]	= array("label" => 'Alamat', 'attr' => 'a.alamat', "sort" => 'true', "width" => 200, 'align' => 'left');
		$res->attr[]	= array("label" => 'Kota', 'attr' => 'a.kota', "sort" => 'true', "width" => 150, 'align' => 'left');
		$res->attr[]	= array("label" => 'Keterangan', 'attr' => 'a.ket', "sort" => 'true', "width" => 100, 'align' => 'left');
		
		return $res;
	}
	
	protected function setPrint()
	{
		return array();
	}
	
	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";
	}
	
	
	public function load()
	{
		$basic = new Basic;
		$this->data = $basic->load($_GET, $this->set);
		$this->layout = "null";
	}
	
	public function sub()
	{
		$data = $this->em->getFind("sub", "*", array("kd_sub = '".$_GET['idRef']."'"));
		
		$res = $data;
		$res->target = $_GET['target'];
		echo json_encode($res);
		$this->layout = "null";
	}
	
	public function popUp()
	{
		$basic = new Basic;
		$this->data = $basic->data($_GET, $this->set);
		$this->view = "default/displayDataPopUp";
		$this->layout = "view";
	}
}