<?php

CLASS Post extends RasioProject
{
	protected $set;
	protected $enableCk = false;
	protected $report;
	protected $baseTitle;

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

	protected function set()
	{
		$this->report       = new Report;
		$this->set->em      = $this->em;
		$this->set->kode    = 'ACC-001';
		$this->set->date    = date("d/m/Y H:i");
		$this->set->modul     = 'Posting Ulang';
		$this->set->form    = $this->setForm();
		$this->set->notNull   = array("tgl");
		$this->set->button    = array("Posting");
		$this->baseTitle      = $this->set->modul;
		return $this->set;
	}

	protected function setForm()
	{
		$row = $row + 0;
		$form[] = array('row' =>  $row,  'col' => 0,   "label" => array("name" => "Mulai Tgl",   "width" => 100),  "input" => array("type" => 'text', 'mode' => 'date',  'attr' => array("name" => 'tgl', "size" => 10, 'class' => 'tanggal', 'value' => date("01/m/Y"))));
		$row = $row + 25;
		$form[] = array('row' =>  $row,  'col' => 0,   "label" => array("name" => "S/d Tgl",   "width" => 100),  "input" => array("type" => 'text', 'mode' => 'date',  'attr' => array("name" => 'tgl2', "size" => 10, 'class' => 'tanggal', 'value' => date("d/m/Y"))));

		return $form;
	}


	public function Index()
	{
		$this->data = $this->set;
		$this->view = "default/report";
	}

	public function View()
	{
	    ini_set("display_errors","On");
		$this->layout = "null";
		$date = new Date;
		$tgl  = $date->serialDate($_GET['tgl']);
		$tgl2 = $date->serialDate($_GET['tgl2']);


		$basic = new Basic;
		$kunci = $basic->kunciNotDb($this->set, $tgl);
		if($kunci == false){
			$this->layout = "null";
			return;
		}


		$url  = $this->baseUrl.'up/postingHpp/&tgl='.$tgl.'&akhir='.$tgl2;
		
		if($tgl < '2022-01-01'){
			echo "<script>alert('Posting Ulang min Tgl. ".$_GET['tgl']."');</script>";
			return;
		}
		
		echo "
			<script type='text/javascript'>
				window.open('".$url."', 'postingUlangPopUp', 'width=500, height=500, left=100, top=100');
				window.close();
			</script>
		";
	}
}