<?php

CLASS msat 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 		= 'Satuan';
		$this->set->dBaseH 		= 'satuan';
		$this->set->dBaseD 		= false;
		$this->set->dBasePk 	= array('nmsat');
		$this->set->where 		= array("kd_inv = '".$_GET['kd_inv']."'");
		$this->set->dSort 		= 'asc';
		$this->set->clearForm 	= array();
		$this->set->notNull 	= array();
		$this->set->grid 		= $this->setGrid();
		return $this->set;
	}
	
	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.kdsat', "sort" => 'true', "width" => 50, 'align' => 'left', 'focus' => 'true');
		$res->attr[]	= array("label" => 'Nama', 'attr' => 'a.nmsat', "sort" => 'true', "width" => 200, 'align' => 'left');
		$res->attr[]	= array("label" => 'Skala', 'attr' => 'a.skala', "sort" => 'true', "width" => 80, 'align' => 'left');
		
		return $res;
	}
	
	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 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 popUp()
	{
		$basic = new Basic;
		$this->data = $basic->data($_GET, $this->set);
		$this->view = "default/displayDataPopUp";
		$this->layout = "view";
	}
	
	public function findPo()
	{
		$data = $this->em->getFind("satuan", '*', array("nmsat = '".$_GET['idRef']."'", "kd_inv = '".$_GET['kd_inv']."'"));

		$id = explode("_", $_GET['target']);
		
		$res->target = $_GET['target'];
		$res->_no 	= $id[1];
		$res->data 	= $data;
		echo json_encode($res);
		$this->layout = "null";
	}
	
	public function loadDisplay()
	{
		$pk = $this->set->dBasePk[0];
		$data = $this->em->getFind($this->set->dBaseH, '*', array("nmsat = '".$_GET['idRef']."'", "kd_inv = '".$_GET['kd_inv']."'"));
		$basic = new Basic;
		$res = $basic->loadDisplay($data, $_GET);
		echo json_encode($res);
		$this->layout = "null";
	}
}