<?php

// Global variable for table object
$Kedatangan_Ubi = NULL;

//
// Table class for Kedatangan Ubi
//
class crKedatangan_Ubi extends crTableBase {
	var $ShowGroupHeaderAsRow = FALSE;
	var $ShowCompactSummaryFooter = TRUE;
	var $co_nama;
	var $var_nama;
	var $koord_nama;
	var $pet_nama;
	var $k_id_kontrak;
	var $k_luas_lahan;
	var $k_es_tgl_panen;
	var $k_es_qty;
	var $k_ak_tgl_datang;
	var $k_ak_qty;

	//
	// Table class constructor
	//
	function __construct() {
		global $ReportLanguage, $gsLanguage;
		$this->TableVar = 'Kedatangan_Ubi';
		$this->TableName = 'Kedatangan Ubi';
		$this->TableType = 'REPORT';
		$this->DBID = 'DB';
		$this->ExportAll = FALSE;
		$this->ExportPageBreakCount = 0;

		// co_nama
		$this->co_nama = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_co_nama', 'co_nama', '`co_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->co_nama->Sortable = TRUE; // Allow sort
		$this->co_nama->GroupingFieldId = 1;
		$this->co_nama->ShowGroupHeaderAsRow = $this->ShowGroupHeaderAsRow;
		$this->co_nama->ShowCompactSummaryFooter = $this->ShowCompactSummaryFooter;
		$this->fields['co_nama'] = &$this->co_nama;
		$this->co_nama->DateFilter = "";
		$this->co_nama->SqlSelect = "";
		$this->co_nama->SqlOrderBy = "";
		$this->co_nama->FldDelimiter = $GLOBALS["EWR_CSV_DELIMITER"];
		$this->co_nama->FldGroupByType = "";
		$this->co_nama->FldGroupInt = "0";
		$this->co_nama->FldGroupSql = "";

		// var_nama
		$this->var_nama = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_var_nama', 'var_nama', '`var_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->var_nama->Sortable = TRUE; // Allow sort
		$this->var_nama->GroupingFieldId = 2;
		$this->var_nama->ShowGroupHeaderAsRow = $this->ShowGroupHeaderAsRow;
		$this->var_nama->ShowCompactSummaryFooter = $this->ShowCompactSummaryFooter;
		$this->fields['var_nama'] = &$this->var_nama;
		$this->var_nama->DateFilter = "";
		$this->var_nama->SqlSelect = "";
		$this->var_nama->SqlOrderBy = "";
		$this->var_nama->FldDelimiter = $GLOBALS["EWR_CSV_DELIMITER"];
		$this->var_nama->FldGroupByType = "";
		$this->var_nama->FldGroupInt = "0";
		$this->var_nama->FldGroupSql = "";

		// koord_nama
		$this->koord_nama = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_koord_nama', 'koord_nama', '`koord_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->koord_nama->Sortable = TRUE; // Allow sort
		$this->fields['koord_nama'] = &$this->koord_nama;
		$this->koord_nama->DateFilter = "";
		$this->koord_nama->SqlSelect = "";
		$this->koord_nama->SqlOrderBy = "";

		// pet_nama
		$this->pet_nama = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_pet_nama', 'pet_nama', '`pet_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->pet_nama->Sortable = TRUE; // Allow sort
		$this->fields['pet_nama'] = &$this->pet_nama;
		$this->pet_nama->DateFilter = "";
		$this->pet_nama->SqlSelect = "";
		$this->pet_nama->SqlOrderBy = "";

		// k_id_kontrak
		$this->k_id_kontrak = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_id_kontrak', 'k_id_kontrak', '`k_id_kontrak`', 200, EWR_DATATYPE_STRING, -1);
		$this->k_id_kontrak->Sortable = TRUE; // Allow sort
		$this->fields['k_id_kontrak'] = &$this->k_id_kontrak;
		$this->k_id_kontrak->DateFilter = "";
		$this->k_id_kontrak->SqlSelect = "";
		$this->k_id_kontrak->SqlOrderBy = "";

		// k_luas_lahan
		$this->k_luas_lahan = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_luas_lahan', 'k_luas_lahan', '`k_luas_lahan`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->k_luas_lahan->Sortable = TRUE; // Allow sort
		$this->k_luas_lahan->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['k_luas_lahan'] = &$this->k_luas_lahan;
		$this->k_luas_lahan->DateFilter = "";
		$this->k_luas_lahan->SqlSelect = "";
		$this->k_luas_lahan->SqlOrderBy = "";

		// k_es_tgl_panen
		$this->k_es_tgl_panen = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_es_tgl_panen', 'k_es_tgl_panen', '`k_es_tgl_panen`', 133, EWR_DATATYPE_DATE, 0);
		$this->k_es_tgl_panen->Sortable = TRUE; // Allow sort
		$this->k_es_tgl_panen->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EWR_DATE_FORMAT"], $ReportLanguage->Phrase("IncorrectDate"));
		$this->fields['k_es_tgl_panen'] = &$this->k_es_tgl_panen;
		$this->k_es_tgl_panen->DateFilter = "Month";
		$this->k_es_tgl_panen->SqlSelect = "";
		$this->k_es_tgl_panen->SqlOrderBy = "";
		$this->k_es_tgl_panen->FldDelimiter = $GLOBALS["EWR_CSV_DELIMITER"];
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Last30Days", $ReportLanguage->Phrase("Last30Days"), "ewr_IsLast30Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Last14Days", $ReportLanguage->Phrase("Last14Days"), "ewr_IsLast14Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Last7Days", $ReportLanguage->Phrase("Last7Days"), "ewr_IsLast7Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Next7Days", $ReportLanguage->Phrase("Next7Days"), "ewr_IsNext7Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Next14Days", $ReportLanguage->Phrase("Next14Days"), "ewr_IsNext14Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@Next30Days", $ReportLanguage->Phrase("Next30Days"), "ewr_IsNext30Days");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@LastMonth", $ReportLanguage->Phrase("LastMonth"), "ewr_IsLastMonth");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@ThisMonth", $ReportLanguage->Phrase("ThisMonth"), "ewr_IsThisMonth");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@NextMonth", $ReportLanguage->Phrase("NextMonth"), "ewr_IsNextMonth");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@LastTwoWeeks", $ReportLanguage->Phrase("LastTwoWeeks"), "ewr_IsLast2Weeks");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@LastWeek", $ReportLanguage->Phrase("LastWeek"), "ewr_IsLastWeek");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@ThisWeek", $ReportLanguage->Phrase("ThisWeek"), "ewr_IsThisWeek");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@NextWeek", $ReportLanguage->Phrase("NextWeek"), "ewr_IsNextWeek");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@NextTwoWeeks", $ReportLanguage->Phrase("NextTwoWeeks"), "ewr_IsNext2Weeks");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@LastYear", $ReportLanguage->Phrase("LastYear"), "ewr_IsLastYear");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@ThisYear", $ReportLanguage->Phrase("ThisYear"), "ewr_IsThisYear");
		ewr_RegisterFilter($this->k_es_tgl_panen, "@@NextYear", $ReportLanguage->Phrase("NextYear"), "ewr_IsNextYear");

		// k_es_qty
		$this->k_es_qty = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_es_qty', 'k_es_qty', '`k_es_qty`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->k_es_qty->Sortable = TRUE; // Allow sort
		$this->k_es_qty->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['k_es_qty'] = &$this->k_es_qty;
		$this->k_es_qty->DateFilter = "";
		$this->k_es_qty->SqlSelect = "";
		$this->k_es_qty->SqlOrderBy = "";

		// k_ak_tgl_datang
		$this->k_ak_tgl_datang = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_ak_tgl_datang', 'k_ak_tgl_datang', '`k_ak_tgl_datang`', 133, EWR_DATATYPE_DATE, 0);
		$this->k_ak_tgl_datang->Sortable = TRUE; // Allow sort
		$this->k_ak_tgl_datang->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EWR_DATE_FORMAT"], $ReportLanguage->Phrase("IncorrectDate"));
		$this->fields['k_ak_tgl_datang'] = &$this->k_ak_tgl_datang;
		$this->k_ak_tgl_datang->DateFilter = "Month";
		$this->k_ak_tgl_datang->SqlSelect = "";
		$this->k_ak_tgl_datang->SqlOrderBy = "";
		$this->k_ak_tgl_datang->FldDelimiter = $GLOBALS["EWR_CSV_DELIMITER"];
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Last30Days", $ReportLanguage->Phrase("Last30Days"), "ewr_IsLast30Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Last14Days", $ReportLanguage->Phrase("Last14Days"), "ewr_IsLast14Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Last7Days", $ReportLanguage->Phrase("Last7Days"), "ewr_IsLast7Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Next7Days", $ReportLanguage->Phrase("Next7Days"), "ewr_IsNext7Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Next14Days", $ReportLanguage->Phrase("Next14Days"), "ewr_IsNext14Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@Next30Days", $ReportLanguage->Phrase("Next30Days"), "ewr_IsNext30Days");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@LastMonth", $ReportLanguage->Phrase("LastMonth"), "ewr_IsLastMonth");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@ThisMonth", $ReportLanguage->Phrase("ThisMonth"), "ewr_IsThisMonth");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@NextMonth", $ReportLanguage->Phrase("NextMonth"), "ewr_IsNextMonth");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@LastTwoWeeks", $ReportLanguage->Phrase("LastTwoWeeks"), "ewr_IsLast2Weeks");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@LastWeek", $ReportLanguage->Phrase("LastWeek"), "ewr_IsLastWeek");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@ThisWeek", $ReportLanguage->Phrase("ThisWeek"), "ewr_IsThisWeek");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@NextWeek", $ReportLanguage->Phrase("NextWeek"), "ewr_IsNextWeek");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@NextTwoWeeks", $ReportLanguage->Phrase("NextTwoWeeks"), "ewr_IsNext2Weeks");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@LastYear", $ReportLanguage->Phrase("LastYear"), "ewr_IsLastYear");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@ThisYear", $ReportLanguage->Phrase("ThisYear"), "ewr_IsThisYear");
		ewr_RegisterFilter($this->k_ak_tgl_datang, "@@NextYear", $ReportLanguage->Phrase("NextYear"), "ewr_IsNextYear");

		// k_ak_qty
		$this->k_ak_qty = new crField('Kedatangan_Ubi', 'Kedatangan Ubi', 'x_k_ak_qty', 'k_ak_qty', '`k_ak_qty`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->k_ak_qty->Sortable = TRUE; // Allow sort
		$this->k_ak_qty->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['k_ak_qty'] = &$this->k_ak_qty;
		$this->k_ak_qty->DateFilter = "";
		$this->k_ak_qty->SqlSelect = "";
		$this->k_ak_qty->SqlOrderBy = "";
	}

	// Set Field Visibility
	function SetFieldVisibility($fldparm) {
		global $Security;
		return $this->$fldparm->Visible; // Returns original value
	}

	// Single column sort
	function UpdateSort(&$ofld) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sSortField = $ofld->FldExpression;
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
			if ($ofld->GroupingFieldId == 0)
				$this->setDetailOrderBy($sSortField . " " . $sThisSort); // Save to Session
		} else {
			if ($ofld->GroupingFieldId == 0) $ofld->setSort("");
		}
	}

	// Get Sort SQL
	function SortSql() {
		$sDtlSortSql = $this->getDetailOrderBy(); // Get ORDER BY for detail fields from session
		$argrps = array();
		foreach ($this->fields as $fld) {
			if ($fld->getSort() <> "") {
				$fldsql = $fld->FldExpression;
				if ($fld->GroupingFieldId > 0) {
					if ($fld->FldGroupSql <> "")
						$argrps[$fld->GroupingFieldId] = str_replace("%s", $fldsql, $fld->FldGroupSql) . " " . $fld->getSort();
					else
						$argrps[$fld->GroupingFieldId] = $fldsql . " " . $fld->getSort();
				}
			}
		}
		$sSortSql = "";
		foreach ($argrps as $grp) {
			if ($sSortSql <> "") $sSortSql .= ", ";
			$sSortSql .= $grp;
		}
		if ($sDtlSortSql <> "") {
			if ($sSortSql <> "") $sSortSql .= ", ";
			$sSortSql .= $sDtlSortSql;
		}
		return $sSortSql;
	}

	// Table level SQL
	// From

	var $_SqlFrom = "";

	function getSqlFrom() {
		return ($this->_SqlFrom <> "") ? $this->_SqlFrom : "`view1`";
	}

	function SqlFrom() { // For backward compatibility
		return $this->getSqlFrom();
	}

	function setSqlFrom($v) {
		$this->_SqlFrom = $v;
	}

	// Select
	var $_SqlSelect = "";

	function getSqlSelect() {
		return ($this->_SqlSelect <> "") ? $this->_SqlSelect : "SELECT * FROM " . $this->getSqlFrom();
	}

	function SqlSelect() { // For backward compatibility
		return $this->getSqlSelect();
	}

	function setSqlSelect($v) {
		$this->_SqlSelect = $v;
	}

	// Where
	var $_SqlWhere = "";

	function getSqlWhere() {
		$sWhere = ($this->_SqlWhere <> "") ? $this->_SqlWhere : "";
		return $sWhere;
	}

	function SqlWhere() { // For backward compatibility
		return $this->getSqlWhere();
	}

	function setSqlWhere($v) {
		$this->_SqlWhere = $v;
	}

	// Group By
	var $_SqlGroupBy = "";

	function getSqlGroupBy() {
		return ($this->_SqlGroupBy <> "") ? $this->_SqlGroupBy : "";
	}

	function SqlGroupBy() { // For backward compatibility
		return $this->getSqlGroupBy();
	}

	function setSqlGroupBy($v) {
		$this->_SqlGroupBy = $v;
	}

	// Having
	var $_SqlHaving = "";

	function getSqlHaving() {
		return ($this->_SqlHaving <> "") ? $this->_SqlHaving : "";
	}

	function SqlHaving() { // For backward compatibility
		return $this->getSqlHaving();
	}

	function setSqlHaving($v) {
		$this->_SqlHaving = $v;
	}

	// Order By
	var $_SqlOrderBy = "";

	function getSqlOrderBy() {
		return ($this->_SqlOrderBy <> "") ? $this->_SqlOrderBy : "`co_nama` ASC, `var_nama` ASC";
	}

	function SqlOrderBy() { // For backward compatibility
		return $this->getSqlOrderBy();
	}

	function setSqlOrderBy($v) {
		$this->_SqlOrderBy = $v;
	}

	// Table Level Group SQL
	// First Group Field

	var $_SqlFirstGroupField = "";

	function getSqlFirstGroupField() {
		return ($this->_SqlFirstGroupField <> "") ? $this->_SqlFirstGroupField : "`co_nama`";
	}

	function SqlFirstGroupField() { // For backward compatibility
		return $this->getSqlFirstGroupField();
	}

	function setSqlFirstGroupField($v) {
		$this->_SqlFirstGroupField = $v;
	}

	// Select Group
	var $_SqlSelectGroup = "";

	function getSqlSelectGroup() {
		return ($this->_SqlSelectGroup <> "") ? $this->_SqlSelectGroup : "SELECT DISTINCT " . $this->getSqlFirstGroupField() . " FROM " . $this->getSqlFrom();
	}

	function SqlSelectGroup() { // For backward compatibility
		return $this->getSqlSelectGroup();
	}

	function setSqlSelectGroup($v) {
		$this->_SqlSelectGroup = $v;
	}

	// Order By Group
	var $_SqlOrderByGroup = "";

	function getSqlOrderByGroup() {
		return ($this->_SqlOrderByGroup <> "") ? $this->_SqlOrderByGroup : "`co_nama` ASC";
	}

	function SqlOrderByGroup() { // For backward compatibility
		return $this->getSqlOrderByGroup();
	}

	function setSqlOrderByGroup($v) {
		$this->_SqlOrderByGroup = $v;
	}

	// Select Aggregate
	var $_SqlSelectAgg = "";

	function getSqlSelectAgg() {
		return ($this->_SqlSelectAgg <> "") ? $this->_SqlSelectAgg : "SELECT SUM(`k_luas_lahan`) AS `sum_k_luas_lahan`, SUM(`k_es_qty`) AS `sum_k_es_qty`, COUNT(NULLIF(`k_es_qty`,0)) AS `cnt_k_es_qty`, SUM(`k_ak_qty`) AS `sum_k_ak_qty`, COUNT(NULLIF(`k_ak_qty`,0)) AS `cnt_k_ak_qty` FROM " . $this->getSqlFrom();
	}

	function SqlSelectAgg() { // For backward compatibility
		return $this->getSqlSelectAgg();
	}

	function setSqlSelectAgg($v) {
		$this->_SqlSelectAgg = $v;
	}

	// Aggregate Prefix
	var $_SqlAggPfx = "";

	function getSqlAggPfx() {
		return ($this->_SqlAggPfx <> "") ? $this->_SqlAggPfx : "";
	}

	function SqlAggPfx() { // For backward compatibility
		return $this->getSqlAggPfx();
	}

	function setSqlAggPfx($v) {
		$this->_SqlAggPfx = $v;
	}

	// Aggregate Suffix
	var $_SqlAggSfx = "";

	function getSqlAggSfx() {
		return ($this->_SqlAggSfx <> "") ? $this->_SqlAggSfx : "";
	}

	function SqlAggSfx() { // For backward compatibility
		return $this->getSqlAggSfx();
	}

	function setSqlAggSfx($v) {
		$this->_SqlAggSfx = $v;
	}

	// Select Count
	var $_SqlSelectCount = "";

	function getSqlSelectCount() {
		return ($this->_SqlSelectCount <> "") ? $this->_SqlSelectCount : "SELECT COUNT(*) FROM " . $this->getSqlFrom();
	}

	function SqlSelectCount() { // For backward compatibility
		return $this->getSqlSelectCount();
	}

	function setSqlSelectCount($v) {
		$this->_SqlSelectCount = $v;
	}

	// Sort URL
	function SortUrl(&$fld) {
		return "";
	}

	// Setup lookup filters of a field
	function SetupLookupFilters($fld) {
		global $gsLanguage;
		switch ($fld->FldVar) {
		case "x_co_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `co_nama`, `co_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view1`";
		$sWhereWrk = "";
		$this->co_nama->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`co_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->co_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `co_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_var_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `var_nama`, `var_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view1`";
		$sWhereWrk = "";
		$this->var_nama->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`var_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->var_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `var_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_k_es_tgl_panen":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT CONCAT(CAST(YEAR(`k_es_tgl_panen`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_es_tgl_panen`),2,'0') AS CHAR(2))), CONCAT(CAST(YEAR(`k_es_tgl_panen`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_es_tgl_panen`),2,'0') AS CHAR(2))) AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view1`";
		$sWhereWrk = "";
		$this->k_es_tgl_panen->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`k_es_tgl_panen` = {filter_value}', "t0" => "", "fn0" => "", "ds" => "month", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->k_es_tgl_panen, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY CONCAT(CAST(YEAR(`k_es_tgl_panen`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_es_tgl_panen`),2,'0') AS CHAR(2))) ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_k_ak_tgl_datang":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT CONCAT(CAST(YEAR(`k_ak_tgl_datang`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_ak_tgl_datang`),2,'0') AS CHAR(2))), CONCAT(CAST(YEAR(`k_ak_tgl_datang`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_ak_tgl_datang`),2,'0') AS CHAR(2))) AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view1`";
		$sWhereWrk = "";
		$this->k_ak_tgl_datang->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`k_ak_tgl_datang` = {filter_value}', "t0" => "", "fn0" => "", "ds" => "month", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->k_ak_tgl_datang, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY CONCAT(CAST(YEAR(`k_ak_tgl_datang`) AS CHAR(4)), '|', CAST(LPAD(MONTH(`k_ak_tgl_datang`),2,'0') AS CHAR(2))) ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		}
	}

	// Setup AutoSuggest filters of a field
	function SetupAutoSuggestFilters($fld) {
		global $gsLanguage;
		switch ($fld->FldVar) {
		}
	}

	// Table level events
	// Page Selecting event
	function Page_Selecting(&$filter) {

		// Enter your code here
	}

	// Page Breaking event
	function Page_Breaking(&$break, &$content) {

		// Example:
		//$break = FALSE; // Skip page break, or
		//$content = "<div style=\"page-break-after:always;\">&nbsp;</div>"; // Modify page break content

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here
	}

	// Cell Rendered event
	function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue, &$LinkAttrs) {

		//$ViewValue = "xxx";
		//$ViewAttrs["style"] = "xxx";

	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>);

	}

	// User ID Filtering event
	function UserID_Filtering(&$filter) {

		// Enter your code here
	}

	// Load Filters event
	function Page_FilterLoad() {

		// Enter your code here
		// Example: Register/Unregister Custom Extended Filter
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter'); // With function, or
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A'); // No function, use Page_Filtering event
		//ewr_UnregisterFilter($this-><Field>, 'StartsWithA');

	}

	// Page Filter Validated event
	function Page_FilterValidated() {

		// Example:
		//$this->MyField1->SearchValue = "your search criteria"; // Search value

	}

	// Page Filtering event
	function Page_Filtering(&$fld, &$filter, $typ, $opr = "", $val = "", $cond = "", $opr2 = "", $val2 = "") {

		// Note: ALWAYS CHECK THE FILTER TYPE ($typ)! Example:
		//if ($typ == "dropdown" && $fld->FldName == "MyField") // Dropdown filter
		//	$filter = "..."; // Modify the filter
		//if ($typ == "extended" && $fld->FldName == "MyField") // Extended filter
		//	$filter = "..."; // Modify the filter
		//if ($typ == "popup" && $fld->FldName == "MyField") // Popup filter
		//	$filter = "..."; // Modify the filter
		//if ($typ == "custom" && $opr == "..." && $fld->FldName == "MyField") // Custom filter, $opr is the custom filter ID
		//	$filter = "..."; // Modify the filter

	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}

	// Lookup Selecting event
	function Lookup_Selecting($fld, &$filter) {

		// Enter your code here
	}
}
?>
