<?php

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

//
// Table class for Kedatangan Dan Verifikasi
//
class crKedatangan_Dan_Verifikasi extends crTableBase {
	var $ShowGroupHeaderAsRow = FALSE;
	var $ShowCompactSummaryFooter = TRUE;
	var $datang_id;
	var $datang_tgl;
	var $datang_jumlah;
	var $ds_nama;
	var $datang_terpakai;
	var $var_nama;
	var $sup_nama;
	var $pet_nama;
	var $co_nama;
	var $k_id_kontrak;
	var $k_luas_lahan;
	var $k_es_tgl_panen;
	var $k_es_qty;
	var $ver_tgl;
	var $ver_presentasi_rijek;
	var $ver_hasil_id;
	var $ver_foto;
	var $qc_nama;
	var $ver_catatan;

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

		// datang_id
		$this->datang_id = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_datang_id', 'datang_id', '`datang_id`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->datang_id->Sortable = TRUE; // Allow sort
		$this->datang_id->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['datang_id'] = &$this->datang_id;
		$this->datang_id->DateFilter = "";
		$this->datang_id->SqlSelect = "";
		$this->datang_id->SqlOrderBy = "";

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

		// datang_jumlah
		$this->datang_jumlah = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_datang_jumlah', 'datang_jumlah', '`datang_jumlah`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->datang_jumlah->Sortable = TRUE; // Allow sort
		$this->datang_jumlah->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['datang_jumlah'] = &$this->datang_jumlah;
		$this->datang_jumlah->DateFilter = "";
		$this->datang_jumlah->SqlSelect = "";
		$this->datang_jumlah->SqlOrderBy = "";

		// ds_nama
		$this->ds_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ds_nama', 'ds_nama', '`ds_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->ds_nama->Sortable = TRUE; // Allow sort
		$this->fields['ds_nama'] = &$this->ds_nama;
		$this->ds_nama->DateFilter = "";
		$this->ds_nama->SqlSelect = "";
		$this->ds_nama->SqlOrderBy = "";

		// datang_terpakai
		$this->datang_terpakai = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_datang_terpakai', 'datang_terpakai', '`datang_terpakai`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->datang_terpakai->Sortable = TRUE; // Allow sort
		$this->datang_terpakai->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['datang_terpakai'] = &$this->datang_terpakai;
		$this->datang_terpakai->DateFilter = "";
		$this->datang_terpakai->SqlSelect = "";
		$this->datang_terpakai->SqlOrderBy = "";

		// var_nama
		$this->var_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_var_nama', 'var_nama', '`var_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->var_nama->Sortable = TRUE; // Allow sort
		$this->fields['var_nama'] = &$this->var_nama;
		$this->var_nama->DateFilter = "";
		$this->var_nama->SqlSelect = "";
		$this->var_nama->SqlOrderBy = "";

		// sup_nama
		$this->sup_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_sup_nama', 'sup_nama', '`sup_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->sup_nama->Sortable = TRUE; // Allow sort
		$this->fields['sup_nama'] = &$this->sup_nama;
		$this->sup_nama->DateFilter = "";
		$this->sup_nama->SqlSelect = "";
		$this->sup_nama->SqlOrderBy = "";

		// pet_nama
		$this->pet_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', '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 = "";

		// co_nama
		$this->co_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_co_nama', 'co_nama', '`co_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->co_nama->Sortable = TRUE; // Allow sort
		$this->fields['co_nama'] = &$this->co_nama;
		$this->co_nama->DateFilter = "";
		$this->co_nama->SqlSelect = "";
		$this->co_nama->SqlOrderBy = "";

		// k_id_kontrak
		$this->k_id_kontrak = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', '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_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', '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_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', '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 = "";
		$this->k_es_tgl_panen->SqlSelect = "";
		$this->k_es_tgl_panen->SqlOrderBy = "";
		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_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', '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 = "";

		// ver_tgl
		$this->ver_tgl = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ver_tgl', 'ver_tgl', '`ver_tgl`', 135, EWR_DATATYPE_DATE, 0);
		$this->ver_tgl->Sortable = TRUE; // Allow sort
		$this->ver_tgl->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EWR_DATE_FORMAT"], $ReportLanguage->Phrase("IncorrectDate"));
		$this->fields['ver_tgl'] = &$this->ver_tgl;
		$this->ver_tgl->DateFilter = "";
		$this->ver_tgl->SqlSelect = "";
		$this->ver_tgl->SqlOrderBy = "";

		// ver_presentasi_rijek
		$this->ver_presentasi_rijek = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ver_presentasi_rijek', 'ver_presentasi_rijek', '`ver_presentasi_rijek`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->ver_presentasi_rijek->Sortable = TRUE; // Allow sort
		$this->ver_presentasi_rijek->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['ver_presentasi_rijek'] = &$this->ver_presentasi_rijek;
		$this->ver_presentasi_rijek->DateFilter = "";
		$this->ver_presentasi_rijek->SqlSelect = "";
		$this->ver_presentasi_rijek->SqlOrderBy = "";

		// ver_hasil_id
		$this->ver_hasil_id = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ver_hasil_id', 'ver_hasil_id', '`ver_hasil_id`', 200, EWR_DATATYPE_STRING, -1);
		$this->ver_hasil_id->Sortable = TRUE; // Allow sort
		$this->fields['ver_hasil_id'] = &$this->ver_hasil_id;
		$this->ver_hasil_id->DateFilter = "";
		$this->ver_hasil_id->SqlSelect = "";
		$this->ver_hasil_id->SqlOrderBy = "";

		// ver_foto
		$this->ver_foto = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ver_foto', 'ver_foto', '`ver_foto`', 200, EWR_DATATYPE_STRING, -1);
		$this->ver_foto->Sortable = FALSE; // Allow sort
		$this->ver_foto->UploadPath = EWR_UPLOAD_DEST_PATH;
		$this->ver_foto->ImageResize = TRUE;
		$this->fields['ver_foto'] = &$this->ver_foto;
		$this->ver_foto->DateFilter = "";
		$this->ver_foto->SqlSelect = "";
		$this->ver_foto->SqlOrderBy = "";

		// qc_nama
		$this->qc_nama = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_qc_nama', 'qc_nama', '`qc_nama`', 200, EWR_DATATYPE_STRING, -1);
		$this->qc_nama->Sortable = TRUE; // Allow sort
		$this->fields['qc_nama'] = &$this->qc_nama;
		$this->qc_nama->DateFilter = "";
		$this->qc_nama->SqlSelect = "SELECT DISTINCT `qc_nama`, `qc_nama` AS `DispFld` FROM " . $this->getSqlFrom();
		$this->qc_nama->SqlOrderBy = "`qc_nama`";

		// ver_catatan
		$this->ver_catatan = new crField('Kedatangan_Dan_Verifikasi', 'Kedatangan Dan Verifikasi', 'x_ver_catatan', 'ver_catatan', '`ver_catatan`', 201, EWR_DATATYPE_MEMO, -1);
		$this->ver_catatan->Sortable = TRUE; // Allow sort
		$this->fields['ver_catatan'] = &$this->ver_catatan;
		$this->ver_catatan->DateFilter = "";
		$this->ver_catatan->SqlSelect = "";
		$this->ver_catatan->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 : "`view_datang`";
	}

	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 : "";
	}

	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 : "";
	}

	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 : "";
	}

	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(`datang_jumlah`) AS `sum_datang_jumlah`, SUM(`datang_terpakai`) AS `sum_datang_terpakai`, SUM(`ver_presentasi_rijek`) AS `sum_ver_presentasi_rijek` 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_ds_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `ds_nama`, `ds_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->ds_nama->LookupFilters = array("dx1" => '`ds_nama`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`ds_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->ds_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `ds_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 `view_datang`";
		$sWhereWrk = "{filter}";
		$this->var_nama->LookupFilters = array("dx1" => '`var_nama`');
			$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_sup_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `sup_nama`, `sup_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->sup_nama->LookupFilters = array("dx1" => '`sup_nama`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`sup_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->sup_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `sup_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_pet_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `pet_nama`, `pet_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->pet_nama->LookupFilters = array("dx1" => '`pet_nama`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`pet_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->pet_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `pet_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_co_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `co_nama`, `co_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->co_nama->LookupFilters = array("dx1" => '`co_nama`');
			$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_k_id_kontrak":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `k_id_kontrak`, `k_id_kontrak` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->k_id_kontrak->LookupFilters = array("dx1" => '`k_id_kontrak`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`k_id_kontrak` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->k_id_kontrak, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `k_id_kontrak` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_ver_hasil_id":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `ver_hasil_id`, `ver_hasil_id` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->ver_hasil_id->LookupFilters = array("dx1" => '`ver_hasil_id`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`ver_hasil_id` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->ver_hasil_id, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `ver_hasil_id` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_qc_nama":
			$sSqlWrk = "";
		$sSqlWrk = "SELECT DISTINCT `qc_nama`, `qc_nama` AS `DispFld`, '' AS `DispFld2`, '' AS `DispFld3`, '' AS `DispFld4` FROM `view_datang`";
		$sWhereWrk = "{filter}";
		$this->qc_nama->LookupFilters = array("dx1" => '`qc_nama`');
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "DB", "f0" => '`qc_nama` = {filter_value}', "t0" => "200", "fn0" => "", "dlm" => ewr_Encrypt($fld->FldDelimiter));
			$sSqlWrk = "";
		$this->Lookup_Selecting($this->qc_nama, $sWhereWrk); // Call Lookup selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `qc_nama` 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
	}
}
?>
