<?php

CLASS kas 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 		= 'Daftar Kas';
		$this->set->dBaseH 		= 'acc_set';
		$this->set->dBaseD 		= false;
		$this->set->dBasePk 	= array('kdac');
		$this->set->where 		= array("(tipe = 'KAS')");
		$this->set->dSort 		= 'asc';
		$this->set->form 		= $this->setForm();
		$this->set->clearForm 	= array("ket_induk");
		$this->set->notNull 	= array("kdac", "nmac", "induk", "grup", "detil");
		$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.kdac', "sort" => 'true', "width" => 70, 'align' => 'left');
		$res->attr[]	= array("label" => 'Nama', 'attr' => 'a.nmac', "sort" => 'true', "width" => 200, 'align' => 'left');
		
		return $res;
	}
	
	protected function setPrint()
	{
		return array();
	}
	
	public function Index()
	{
		$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 load()
	{
		$basic = new Basic;
		$this->data = $basic->load($_GET, $this->set);
		$this->layout = "null";
	}
	
	public function Find()
	{
		$basic = new Basic;
		$this->data = $basic->find($_GET, $this->set);
		$this->view = "default/displayForm";
		$this->layout = "view";
	}
	
	public function account()
	{
		$data = $this->em->getFind("acc", "nmac", array("kdac = '".$_GET['idRef']."'"));
		
		$res->target = $_GET['target'];
		$res->nama 	= $data->nmac;
		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";
	}
	
	public function Select()
	{
		$data = $this->em->getFindBy($this->set->dBaseH, "kdac as kode, CONCAT(kdac, '___', nmac) as nama", array("(tipe = 'KAS')"), "kd_cabang");
		
		$res->jum 	= count($data);
		$res->data 	= $data;
		$res->div 	= strtoupper($_GET['idDiv']);
		
		echo json_encode($res);
		$this->layout = "null";
	}
}