<?php

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

//
// Table class for order_bibit
//
class corder_bibit extends cTable {
	var $ob_id;
	var $ob_co;
	var $ob_k_tanam;
	var $ob_pembeli;
	var $ob_tgl_kirim;
	var $ob_var;
	var $ob_jumlah;
	var $status;
	var $ob_tgl_real_kirim;
	var $ob_jumlah_real_kirim;

	//
	// Table class constructor
	//
	function __construct() {
		global $Language;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();
		$this->TableVar = 'order_bibit';
		$this->TableName = 'order_bibit';
		$this->TableType = 'TABLE';

		// Update Table
		$this->UpdateTable = "`order_bibit`";
		$this->DBID = 'DB';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
		$this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
		$this->ExportPageSize = "a4"; // Page size (PDF only)
		$this->ExportExcelPageOrientation = ""; // Page orientation (PHPExcel only)
		$this->ExportExcelPageSize = ""; // Page size (PHPExcel only)
		$this->ExportWordPageOrientation = "portrait"; // Page orientation (PHPWord only)
		$this->ExportWordColumnWidth = NULL; // Cell width (PHPWord only)
		$this->DetailAdd = FALSE; // Allow detail add
		$this->DetailEdit = FALSE; // Allow detail edit
		$this->DetailView = FALSE; // Allow detail view
		$this->ShowMultipleDetails = FALSE; // Show multiple details
		$this->GridAddRowCount = 5;
		$this->AllowAddDeleteRow = TRUE; // Allow add/delete row
		$this->UserIDAllowSecurity = 0; // User ID Allow
		$this->BasicSearch = new cBasicSearch($this->TableVar);

		// ob_id
		$this->ob_id = new cField('order_bibit', 'order_bibit', 'x_ob_id', 'ob_id', '`ob_id`', '`ob_id`', 3, -1, FALSE, '`ob_id`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'NO');
		$this->ob_id->Sortable = TRUE; // Allow sort
		$this->ob_id->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_id'] = &$this->ob_id;

		// ob_co
		$this->ob_co = new cField('order_bibit', 'order_bibit', 'x_ob_co', 'ob_co', '`ob_co`', '`ob_co`', 3, -1, FALSE, '`ob_co`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->ob_co->Sortable = TRUE; // Allow sort
		$this->ob_co->UsePleaseSelect = TRUE; // Use PleaseSelect by default
		$this->ob_co->PleaseSelectText = $Language->Phrase("PleaseSelect"); // PleaseSelect text
		$this->ob_co->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_co'] = &$this->ob_co;

		// ob_k_tanam
		$this->ob_k_tanam = new cField('order_bibit', 'order_bibit', 'x_ob_k_tanam', 'ob_k_tanam', '`ob_k_tanam`', '`ob_k_tanam`', 3, -1, FALSE, '`ob_k_tanam`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->ob_k_tanam->Sortable = TRUE; // Allow sort
		$this->ob_k_tanam->UsePleaseSelect = TRUE; // Use PleaseSelect by default
		$this->ob_k_tanam->PleaseSelectText = $Language->Phrase("PleaseSelect"); // PleaseSelect text
		$this->ob_k_tanam->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_k_tanam'] = &$this->ob_k_tanam;

		// ob_pembeli
		$this->ob_pembeli = new cField('order_bibit', 'order_bibit', 'x_ob_pembeli', 'ob_pembeli', '`ob_pembeli`', '`ob_pembeli`', 200, -1, FALSE, '`ob_pembeli`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ob_pembeli->Sortable = TRUE; // Allow sort
		$this->fields['ob_pembeli'] = &$this->ob_pembeli;

		// ob_tgl_kirim
		$this->ob_tgl_kirim = new cField('order_bibit', 'order_bibit', 'x_ob_tgl_kirim', 'ob_tgl_kirim', '`ob_tgl_kirim`', ew_CastDateFieldForLike('`ob_tgl_kirim`', 0, "DB"), 133, 0, FALSE, '`ob_tgl_kirim`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ob_tgl_kirim->Sortable = TRUE; // Allow sort
		$this->ob_tgl_kirim->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EW_DATE_FORMAT"], $Language->Phrase("IncorrectDate"));
		$this->fields['ob_tgl_kirim'] = &$this->ob_tgl_kirim;

		// ob_var
		$this->ob_var = new cField('order_bibit', 'order_bibit', 'x_ob_var', 'ob_var', '`ob_var`', '`ob_var`', 3, -1, FALSE, '`ob_var`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->ob_var->Sortable = TRUE; // Allow sort
		$this->ob_var->UsePleaseSelect = TRUE; // Use PleaseSelect by default
		$this->ob_var->PleaseSelectText = $Language->Phrase("PleaseSelect"); // PleaseSelect text
		$this->ob_var->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_var'] = &$this->ob_var;

		// ob_jumlah
		$this->ob_jumlah = new cField('order_bibit', 'order_bibit', 'x_ob_jumlah', 'ob_jumlah', '`ob_jumlah`', '`ob_jumlah`', 3, -1, FALSE, '`ob_jumlah`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ob_jumlah->Sortable = TRUE; // Allow sort
		$this->ob_jumlah->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_jumlah'] = &$this->ob_jumlah;

		// status
		$this->status = new cField('order_bibit', 'order_bibit', 'x_status', 'status', '`status`', '`status`', 200, -1, FALSE, '`status`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'RADIO');
		$this->status->Sortable = TRUE; // Allow sort
		$this->status->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['status'] = &$this->status;

		// ob_tgl_real_kirim
		$this->ob_tgl_real_kirim = new cField('order_bibit', 'order_bibit', 'x_ob_tgl_real_kirim', 'ob_tgl_real_kirim', '`ob_tgl_real_kirim`', ew_CastDateFieldForLike('`ob_tgl_real_kirim`', 0, "DB"), 133, 0, FALSE, '`ob_tgl_real_kirim`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ob_tgl_real_kirim->Sortable = TRUE; // Allow sort
		$this->ob_tgl_real_kirim->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EW_DATE_FORMAT"], $Language->Phrase("IncorrectDate"));
		$this->fields['ob_tgl_real_kirim'] = &$this->ob_tgl_real_kirim;

		// ob_jumlah_real_kirim
		$this->ob_jumlah_real_kirim = new cField('order_bibit', 'order_bibit', 'x_ob_jumlah_real_kirim', 'ob_jumlah_real_kirim', '`ob_jumlah_real_kirim`', '`ob_jumlah_real_kirim`', 3, -1, FALSE, '`ob_jumlah_real_kirim`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ob_jumlah_real_kirim->Sortable = TRUE; // Allow sort
		$this->ob_jumlah_real_kirim->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ob_jumlah_real_kirim'] = &$this->ob_jumlah_real_kirim;
	}

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

	// Column CSS classes
	var $LeftColumnClass = "col-sm-2 control-label ewLabel";
	var $RightColumnClass = "col-sm-10";
	var $OffsetColumnClass = "col-sm-10 col-sm-offset-2";

	// Set left column class (must be predefined col-*-* classes of Bootstrap grid system)
	function SetLeftColumnClass($class) {
		if (preg_match('/^col\-(\w+)\-(\d+)$/', $class, $match)) {
			$this->LeftColumnClass = $class . " control-label ewLabel";
			$this->RightColumnClass = "col-" . $match[1] . "-" . strval(12 - intval($match[2]));
			$this->OffsetColumnClass = $this->RightColumnClass . " " . str_replace($match[1], $match[1] + "-offset", $class);
		}
	}

	// 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);
			$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
		} else {
			$ofld->setSort("");
		}
	}

	// Table level SQL
	var $_SqlFrom = "";

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

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

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

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

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

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

	function getSqlWhere() { // Where
		$sWhere = ($this->_SqlWhere <> "") ? $this->_SqlWhere : "";
		$this->TableFilter = "";
		ew_AddFilter($sWhere, $this->TableFilter);
		return $sWhere;
	}

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

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

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

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

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

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

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

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

	function getSqlOrderBy() { // Order By
		return ($this->_SqlOrderBy <> "") ? $this->_SqlOrderBy : "`ob_id` DESC";
	}

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

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

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		return $sFilter;
	}

	// Check if User ID security allows view all
	function UserIDAllow($id = "") {
		$allow = EW_USER_ID_ALLOW;
		switch ($id) {
			case "add":
			case "copy":
			case "gridadd":
			case "register":
			case "addopt":
				return (($allow & 1) == 1);
			case "edit":
			case "gridedit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return (($allow & 4) == 4);
			case "delete":
				return (($allow & 2) == 2);
			case "view":
				return (($allow & 32) == 32);
			case "search":
				return (($allow & 64) == 64);
			default:
				return (($allow & 8) == 8);
		}
	}

	// Get SQL
	function GetSQL($where, $orderby) {
		return ew_BuildSelectSql($this->getSqlSelect(), $this->getSqlWhere(),
			$this->getSqlGroupBy(), $this->getSqlHaving(), $this->getSqlOrderBy(),
			$where, $orderby);
	}

	// Table SQL
	function SQL() {
		$filter = $this->CurrentFilter;
		$filter = $this->ApplyUserIDFilters($filter);
		$sort = $this->getSessionOrderBy();
		return $this->GetSQL($filter, $sort);
	}

	// Table SQL with List page filter
	var $UseSessionForListSQL = TRUE;

	function ListSQL() {
		$sFilter = $this->UseSessionForListSQL ? $this->getSessionWhere() : "";
		ew_AddFilter($sFilter, $this->CurrentFilter);
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$this->Recordset_Selecting($sFilter);
		$sSelect = $this->getSqlSelect();
		$sSort = $this->UseSessionForListSQL ? $this->getSessionOrderBy() : "";
		return ew_BuildSelectSql($sSelect, $this->getSqlWhere(), $this->getSqlGroupBy(),
			$this->getSqlHaving(), $this->getSqlOrderBy(), $sFilter, $sSort);
	}

	// Get ORDER BY clause
	function GetOrderBy() {
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql("", "", "", "", $this->getSqlOrderBy(), "", $sSort);
	}

	// Try to get record count
	function TryGetRecordCount($sql) {
		$cnt = -1;
		$pattern = "/^SELECT \* FROM/i";
		if (($this->TableType == 'TABLE' || $this->TableType == 'VIEW' || $this->TableType == 'LINKTABLE') && preg_match($pattern, $sql)) {
			$sql = "SELECT COUNT(*) FROM" . preg_replace($pattern, "", $sql);
		} else {
			$sql = "SELECT COUNT(*) FROM (" . $sql . ") EW_COUNT_TABLE";
		}
		$conn = &$this->Connection();
		if ($rs = $conn->Execute($sql)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// Get record count based on filter (for detail record count in master table pages)
	function LoadRecordCount($filter) {
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $filter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : "SELECT * FROM " . $this->getSqlFrom();
		$groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
		$having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
		$sql = ew_BuildSelectSql($select, $this->getSqlWhere(), $groupBy, $having, "", $this->CurrentFilter, "");
		$cnt = $this->TryGetRecordCount($sql);
		if ($cnt == -1) {
			if ($rs = $this->LoadRs($this->CurrentFilter)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Get record count (for current List page)
	function ListRecordCount() {
		$filter = $this->getSessionWhere();
		ew_AddFilter($filter, $this->CurrentFilter);
		$filter = $this->ApplyUserIDFilters($filter);
		$this->Recordset_Selecting($filter);
		$select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : "SELECT * FROM " . $this->getSqlFrom();
		$groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
		$having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
		$sql = ew_BuildSelectSql($select, $this->getSqlWhere(), $groupBy, $having, "", $filter, "");
		$cnt = $this->TryGetRecordCount($sql);
		if ($cnt == -1) {
			$conn = &$this->Connection();
			if ($rs = $conn->Execute($sql)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// INSERT statement
	function InsertSQL(&$rs) {
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom)
				continue;
			$names .= $this->fields[$name]->FldExpression . ",";
			$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
		}
		$names = preg_replace('/,+$/', "", $names);
		$values = preg_replace('/,+$/', "", $values);
		return "INSERT INTO " . $this->UpdateTable . " ($names) VALUES ($values)";
	}

	// Insert
	function Insert(&$rs) {
		$conn = &$this->Connection();
		$bInsert = $conn->Execute($this->InsertSQL($rs));
		if ($bInsert) {

			// Get insert id if necessary
			$this->ob_id->setDbValue($conn->Insert_ID());
			$rs['ob_id'] = $this->ob_id->DbValue;
		}
		return $bInsert;
	}

	// UPDATE statement
	function UpdateSQL(&$rs, $where = "", $curfilter = TRUE) {
		$sql = "UPDATE " . $this->UpdateTable . " SET ";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom)
				continue;
			$sql .= $this->fields[$name]->FldExpression . "=";
			$sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
		}
		$sql = preg_replace('/,+$/', "", $sql);
		$filter = ($curfilter) ? $this->CurrentFilter : "";
		if (is_array($where))
			$where = $this->ArrayToFilter($where);
		ew_AddFilter($filter, $where);
		if ($filter <> "")	$sql .= " WHERE " . $filter;
		return $sql;
	}

	// Update
	function Update(&$rs, $where = "", $rsold = NULL, $curfilter = TRUE) {
		$conn = &$this->Connection();
		$bUpdate = $conn->Execute($this->UpdateSQL($rs, $where, $curfilter));
		return $bUpdate;
	}

	// DELETE statement
	function DeleteSQL(&$rs, $where = "", $curfilter = TRUE) {
		$sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
		if (is_array($where))
			$where = $this->ArrayToFilter($where);
		if ($rs) {
			if (array_key_exists('ob_id', $rs))
				ew_AddFilter($where, ew_QuotedName('ob_id', $this->DBID) . '=' . ew_QuotedValue($rs['ob_id'], $this->ob_id->FldDataType, $this->DBID));
		}
		$filter = ($curfilter) ? $this->CurrentFilter : "";
		ew_AddFilter($filter, $where);
		if ($filter <> "")
			$sql .= $filter;
		else
			$sql .= "0=1"; // Avoid delete
		return $sql;
	}

	// Delete
	function Delete(&$rs, $where = "", $curfilter = TRUE) {
		$bDelete = TRUE;
		$conn = &$this->Connection();
		if ($bDelete)
			$bDelete = $conn->Execute($this->DeleteSQL($rs, $where, $curfilter));
		return $bDelete;
	}

	// Key filter WHERE clause
	function SqlKeyFilter() {
		return "`ob_id` = @ob_id@";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		if (!is_numeric($this->ob_id->CurrentValue))
			return "0=1"; // Invalid key
		if (is_null($this->ob_id->CurrentValue))
			return "0=1"; // Invalid key
		else
			$sKeyFilter = str_replace("@ob_id@", ew_AdjustSql($this->ob_id->CurrentValue, $this->DBID), $sKeyFilter); // Replace key value
		return $sKeyFilter;
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "order_bibitlist.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// Get modal caption
	function GetModalCaption($pageName) {
		global $Language;
		if ($pageName == "order_bibitview.php")
			return $Language->Phrase("View");
		elseif ($pageName == "order_bibitedit.php")
			return $Language->Phrase("Edit");
		elseif ($pageName == "order_bibitadd.php")
			return $Language->Phrase("Add");
		else
			return "";
	}

	// List URL
	function GetListUrl() {
		return "order_bibitlist.php";
	}

	// View URL
	function GetViewUrl($parm = "") {
		if ($parm <> "")
			$url = $this->KeyUrl("order_bibitview.php", $this->UrlParm($parm));
		else
			$url = $this->KeyUrl("order_bibitview.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
		return $this->AddMasterUrl($url);
	}

	// Add URL
	function GetAddUrl($parm = "") {
		if ($parm <> "")
			$url = "order_bibitadd.php?" . $this->UrlParm($parm);
		else
			$url = "order_bibitadd.php";
		return $this->AddMasterUrl($url);
	}

	// Edit URL
	function GetEditUrl($parm = "") {
		$url = $this->KeyUrl("order_bibitedit.php", $this->UrlParm($parm));
		return $this->AddMasterUrl($url);
	}

	// Inline edit URL
	function GetInlineEditUrl() {
		$url = $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
		return $this->AddMasterUrl($url);
	}

	// Copy URL
	function GetCopyUrl($parm = "") {
		$url = $this->KeyUrl("order_bibitadd.php", $this->UrlParm($parm));
		return $this->AddMasterUrl($url);
	}

	// Inline copy URL
	function GetInlineCopyUrl() {
		$url = $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
		return $this->AddMasterUrl($url);
	}

	// Delete URL
	function GetDeleteUrl() {
		return $this->KeyUrl("order_bibitdelete.php", $this->UrlParm());
	}

	// Add master url
	function AddMasterUrl($url) {
		return $url;
	}

	function KeyToJson() {
		$json = "";
		$json .= "ob_id:" . ew_VarToJson($this->ob_id->CurrentValue, "number", "'");
		return "{" . $json . "}";
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		if (!is_null($this->ob_id->CurrentValue)) {
			$sUrl .= "ob_id=" . urlencode($this->ob_id->CurrentValue);
		} else {
			return "javascript:ew_Alert(ewLanguage.Phrase('InvalidRecord'));";
		}
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&amp;ordertype=" . $fld->ReverseSort());
			return $this->AddMasterUrl(ew_CurrentPage() . "?" . $sUrlParm);
		} else {
			return "";
		}
	}

	// Get record keys from $_POST/$_GET/$_SESSION
	function GetRecordKeys() {
		global $EW_COMPOSITE_KEY_SEPARATOR;
		$arKeys = array();
		$arKey = array();
		if (isset($_POST["key_m"])) {
			$arKeys = $_POST["key_m"];
			$cnt = count($arKeys);
		} elseif (isset($_GET["key_m"])) {
			$arKeys = $_GET["key_m"];
			$cnt = count($arKeys);
		} elseif (!empty($_GET) || !empty($_POST)) {
			$isPost = ew_IsPost();
			if ($isPost && isset($_POST["ob_id"]))
				$arKeys[] = $_POST["ob_id"];
			elseif (isset($_GET["ob_id"]))
				$arKeys[] = $_GET["ob_id"];
			else
				$arKeys = NULL; // Do not setup

			//return $arKeys; // Do not return yet, so the values will also be checked by the following code
		}

		// Check keys
		$ar = array();
		if (is_array($arKeys)) {
			foreach ($arKeys as $key) {
				if (!is_numeric($key))
					continue;
				$ar[] = $key;
			}
		}
		return $ar;
	}

	// Get key filter
	function GetKeyFilter() {
		$arKeys = $this->GetRecordKeys();
		$sKeyFilter = "";
		foreach ($arKeys as $key) {
			if ($sKeyFilter <> "") $sKeyFilter .= " OR ";
			$this->ob_id->CurrentValue = $key;
			$sKeyFilter .= "(" . $this->KeyFilter() . ")";
		}
		return $sKeyFilter;
	}

	// Load rows based on filter
	function &LoadRs($filter) {

		// Set up filter (SQL WHERE clause) and get return SQL
		//$this->CurrentFilter = $filter;
		//$sql = $this->SQL();

		$sql = $this->GetSQL($filter, "");
		$conn = &$this->Connection();
		$rs = $conn->Execute($sql);
		return $rs;
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->ob_id->setDbValue($rs->fields('ob_id'));
		$this->ob_co->setDbValue($rs->fields('ob_co'));
		$this->ob_k_tanam->setDbValue($rs->fields('ob_k_tanam'));
		$this->ob_pembeli->setDbValue($rs->fields('ob_pembeli'));
		$this->ob_tgl_kirim->setDbValue($rs->fields('ob_tgl_kirim'));
		$this->ob_var->setDbValue($rs->fields('ob_var'));
		$this->ob_jumlah->setDbValue($rs->fields('ob_jumlah'));
		$this->status->setDbValue($rs->fields('status'));
		$this->ob_tgl_real_kirim->setDbValue($rs->fields('ob_tgl_real_kirim'));
		$this->ob_jumlah_real_kirim->setDbValue($rs->fields('ob_jumlah_real_kirim'));
	}

	// Render list row values
	function RenderListRow() {
		global $Security, $gsLanguage, $Language;

		// Call Row Rendering event
		$this->Row_Rendering();

	// Common render codes
		// ob_id
		// ob_co
		// ob_k_tanam
		// ob_pembeli
		// ob_tgl_kirim
		// ob_var
		// ob_jumlah
		// status
		// ob_tgl_real_kirim
		// ob_jumlah_real_kirim
		// ob_id

		$this->ob_id->ViewValue = $this->ob_id->CurrentValue;
		$this->ob_id->ViewCustomAttributes = "";

		// ob_co
		if (strval($this->ob_co->CurrentValue) <> "") {
			$sFilterWrk = "`co_id`" . ew_SearchString("=", $this->ob_co->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `co_id`, `co_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `co`";
		$sWhereWrk = "";
		$this->ob_co->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ob_co, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$this->ob_co->ViewValue = $this->ob_co->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ob_co->ViewValue = $this->ob_co->CurrentValue;
			}
		} else {
			$this->ob_co->ViewValue = NULL;
		}
		$this->ob_co->ViewCustomAttributes = "";

		// ob_k_tanam
		if (strval($this->ob_k_tanam->CurrentValue) <> "") {
			$sFilterWrk = "`k_id`" . ew_SearchString("=", $this->ob_k_tanam->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `k_id`, `k_id_kontrak` AS `DispFld`, `k_luas_lahan` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kontrak`";
		$sWhereWrk = "";
		$this->ob_k_tanam->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ob_k_tanam, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$arwrk[2] = $rswrk->fields('Disp2Fld');
				$this->ob_k_tanam->ViewValue = $this->ob_k_tanam->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ob_k_tanam->ViewValue = $this->ob_k_tanam->CurrentValue;
			}
		} else {
			$this->ob_k_tanam->ViewValue = NULL;
		}
		$this->ob_k_tanam->ViewCustomAttributes = "";

		// ob_pembeli
		$this->ob_pembeli->ViewValue = $this->ob_pembeli->CurrentValue;
		$this->ob_pembeli->ViewCustomAttributes = "";

		// ob_tgl_kirim
		$this->ob_tgl_kirim->ViewValue = $this->ob_tgl_kirim->CurrentValue;
		$this->ob_tgl_kirim->ViewValue = ew_FormatDateTime($this->ob_tgl_kirim->ViewValue, 0);
		$this->ob_tgl_kirim->ViewCustomAttributes = "";

		// ob_var
		if (strval($this->ob_var->CurrentValue) <> "") {
			$sFilterWrk = "`var_id`" . ew_SearchString("=", $this->ob_var->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `var_id`, `var_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `varietas`";
		$sWhereWrk = "";
		$this->ob_var->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ob_var, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$this->ob_var->ViewValue = $this->ob_var->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ob_var->ViewValue = $this->ob_var->CurrentValue;
			}
		} else {
			$this->ob_var->ViewValue = NULL;
		}
		$this->ob_var->ViewCustomAttributes = "";

		// ob_jumlah
		$this->ob_jumlah->ViewValue = $this->ob_jumlah->CurrentValue;
		$this->ob_jumlah->ViewCustomAttributes = "";

		// status
		if (strval($this->status->CurrentValue) <> "") {
			$sFilterWrk = "`status_order_bibit`" . ew_SearchString("=", $this->status->CurrentValue, EW_DATATYPE_STRING, "");
		$sSqlWrk = "SELECT `status_order_bibit`, `status_order_bibit` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `status_order_bibit`";
		$sWhereWrk = "";
		$this->status->LookupFilters = array("dx1" => '`status_order_bibit`');
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->status, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$this->status->ViewValue = $this->status->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->status->ViewValue = $this->status->CurrentValue;
			}
		} else {
			$this->status->ViewValue = NULL;
		}
		$this->status->ViewCustomAttributes = "";

		// ob_tgl_real_kirim
		$this->ob_tgl_real_kirim->ViewValue = $this->ob_tgl_real_kirim->CurrentValue;
		$this->ob_tgl_real_kirim->ViewValue = ew_FormatDateTime($this->ob_tgl_real_kirim->ViewValue, 0);
		$this->ob_tgl_real_kirim->ViewCustomAttributes = "";

		// ob_jumlah_real_kirim
		$this->ob_jumlah_real_kirim->ViewValue = $this->ob_jumlah_real_kirim->CurrentValue;
		$this->ob_jumlah_real_kirim->ViewCustomAttributes = "";

		// ob_id
		$this->ob_id->LinkCustomAttributes = "";
		$this->ob_id->HrefValue = "";
		$this->ob_id->TooltipValue = "";

		// ob_co
		$this->ob_co->LinkCustomAttributes = "";
		$this->ob_co->HrefValue = "";
		$this->ob_co->TooltipValue = "";

		// ob_k_tanam
		$this->ob_k_tanam->LinkCustomAttributes = "";
		$this->ob_k_tanam->HrefValue = "";
		$this->ob_k_tanam->TooltipValue = "";

		// ob_pembeli
		$this->ob_pembeli->LinkCustomAttributes = "";
		$this->ob_pembeli->HrefValue = "";
		$this->ob_pembeli->TooltipValue = "";

		// ob_tgl_kirim
		$this->ob_tgl_kirim->LinkCustomAttributes = "";
		$this->ob_tgl_kirim->HrefValue = "";
		$this->ob_tgl_kirim->TooltipValue = "";

		// ob_var
		$this->ob_var->LinkCustomAttributes = "";
		$this->ob_var->HrefValue = "";
		$this->ob_var->TooltipValue = "";

		// ob_jumlah
		$this->ob_jumlah->LinkCustomAttributes = "";
		$this->ob_jumlah->HrefValue = "";
		$this->ob_jumlah->TooltipValue = "";

		// status
		$this->status->LinkCustomAttributes = "";
		$this->status->HrefValue = "";
		$this->status->TooltipValue = "";

		// ob_tgl_real_kirim
		$this->ob_tgl_real_kirim->LinkCustomAttributes = "";
		$this->ob_tgl_real_kirim->HrefValue = "";
		$this->ob_tgl_real_kirim->TooltipValue = "";

		// ob_jumlah_real_kirim
		$this->ob_jumlah_real_kirim->LinkCustomAttributes = "";
		$this->ob_jumlah_real_kirim->HrefValue = "";
		$this->ob_jumlah_real_kirim->TooltipValue = "";

		// Call Row Rendered event
		$this->Row_Rendered();

		// Save data for Custom Template
		$this->Rows[] = $this->CustomTemplateFieldValues();
	}

	// Render edit row values
	function RenderEditRow() {
		global $Security, $gsLanguage, $Language;

		// Call Row Rendering event
		$this->Row_Rendering();

		// ob_id
		$this->ob_id->EditAttrs["class"] = "form-control";
		$this->ob_id->EditCustomAttributes = "";
		$this->ob_id->EditValue = $this->ob_id->CurrentValue;
		$this->ob_id->ViewCustomAttributes = "";

		// ob_co
		$this->ob_co->EditAttrs["class"] = "form-control";
		$this->ob_co->EditCustomAttributes = "";
		if (strval($this->ob_co->CurrentValue) <> "") {
			$sFilterWrk = "`co_id`" . ew_SearchString("=", $this->ob_co->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `co_id`, `co_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `co`";
		$sWhereWrk = "";
		$this->ob_co->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ob_co, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$this->ob_co->EditValue = $this->ob_co->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ob_co->EditValue = $this->ob_co->CurrentValue;
			}
		} else {
			$this->ob_co->EditValue = NULL;
		}
		$this->ob_co->ViewCustomAttributes = "";

		// ob_k_tanam
		$this->ob_k_tanam->EditAttrs["class"] = "form-control";
		$this->ob_k_tanam->EditCustomAttributes = "";

		// ob_pembeli
		$this->ob_pembeli->EditAttrs["class"] = "form-control";
		$this->ob_pembeli->EditCustomAttributes = "";
		$this->ob_pembeli->EditValue = $this->ob_pembeli->CurrentValue;
		$this->ob_pembeli->PlaceHolder = ew_RemoveHtml($this->ob_pembeli->FldCaption());

		// ob_tgl_kirim
		$this->ob_tgl_kirim->EditAttrs["class"] = "form-control";
		$this->ob_tgl_kirim->EditCustomAttributes = "";
		$this->ob_tgl_kirim->EditValue = $this->ob_tgl_kirim->CurrentValue;
		$this->ob_tgl_kirim->EditValue = ew_FormatDateTime($this->ob_tgl_kirim->EditValue, 0);
		$this->ob_tgl_kirim->ViewCustomAttributes = "";

		// ob_var
		$this->ob_var->EditAttrs["class"] = "form-control";
		$this->ob_var->EditCustomAttributes = "";
		if (strval($this->ob_var->CurrentValue) <> "") {
			$sFilterWrk = "`var_id`" . ew_SearchString("=", $this->ob_var->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `var_id`, `var_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `varietas`";
		$sWhereWrk = "";
		$this->ob_var->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ob_var, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$this->ob_var->EditValue = $this->ob_var->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ob_var->EditValue = $this->ob_var->CurrentValue;
			}
		} else {
			$this->ob_var->EditValue = NULL;
		}
		$this->ob_var->ViewCustomAttributes = "";

		// ob_jumlah
		$this->ob_jumlah->EditAttrs["class"] = "form-control";
		$this->ob_jumlah->EditCustomAttributes = "";
		$this->ob_jumlah->EditValue = $this->ob_jumlah->CurrentValue;
		$this->ob_jumlah->PlaceHolder = ew_RemoveHtml($this->ob_jumlah->FldCaption());

		// status
		$this->status->EditCustomAttributes = "";

		// ob_tgl_real_kirim
		$this->ob_tgl_real_kirim->EditAttrs["class"] = "form-control";
		$this->ob_tgl_real_kirim->EditCustomAttributes = "";
		$this->ob_tgl_real_kirim->EditValue = ew_FormatDateTime($this->ob_tgl_real_kirim->CurrentValue, 8);
		$this->ob_tgl_real_kirim->PlaceHolder = ew_RemoveHtml($this->ob_tgl_real_kirim->FldCaption());

		// ob_jumlah_real_kirim
		$this->ob_jumlah_real_kirim->EditAttrs["class"] = "form-control";
		$this->ob_jumlah_real_kirim->EditCustomAttributes = "";
		$this->ob_jumlah_real_kirim->EditValue = $this->ob_jumlah_real_kirim->CurrentValue;
		$this->ob_jumlah_real_kirim->PlaceHolder = ew_RemoveHtml($this->ob_jumlah_real_kirim->FldCaption());

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Aggregate list row values
	function AggregateListRowValues() {
			if (is_numeric($this->ob_jumlah->CurrentValue))
				$this->ob_jumlah->Total += $this->ob_jumlah->CurrentValue; // Accumulate total
			if (is_numeric($this->ob_jumlah_real_kirim->CurrentValue))
				$this->ob_jumlah_real_kirim->Total += $this->ob_jumlah_real_kirim->CurrentValue; // Accumulate total
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
			$this->ob_jumlah->CurrentValue = $this->ob_jumlah->Total;
			$this->ob_jumlah->ViewValue = $this->ob_jumlah->CurrentValue;
			$this->ob_jumlah->ViewCustomAttributes = "";
			$this->ob_jumlah->HrefValue = ""; // Clear href value
			$this->ob_jumlah_real_kirim->CurrentValue = $this->ob_jumlah_real_kirim->Total;
			$this->ob_jumlah_real_kirim->ViewValue = $this->ob_jumlah_real_kirim->CurrentValue;
			$this->ob_jumlah_real_kirim->ViewCustomAttributes = "";
			$this->ob_jumlah_real_kirim->HrefValue = ""; // Clear href value

		// Call Row Rendered event
		$this->Row_Rendered();
	}
	var $ExportDoc;

	// Export data in HTML/CSV/Word/Excel/Email/PDF format
	function ExportDocument(&$Doc, &$Recordset, $StartRec, $StopRec, $ExportPageType = "") {
		if (!$Recordset || !$Doc)
			return;
		if (!$Doc->ExportCustom) {

			// Write header
			$Doc->ExportTableHeader();
			if ($Doc->Horizontal) { // Horizontal format, write header
				$Doc->BeginExportRow();
				if ($ExportPageType == "view") {
					if ($this->ob_id->Exportable) $Doc->ExportCaption($this->ob_id);
					if ($this->ob_co->Exportable) $Doc->ExportCaption($this->ob_co);
					if ($this->ob_k_tanam->Exportable) $Doc->ExportCaption($this->ob_k_tanam);
					if ($this->ob_pembeli->Exportable) $Doc->ExportCaption($this->ob_pembeli);
					if ($this->ob_tgl_kirim->Exportable) $Doc->ExportCaption($this->ob_tgl_kirim);
					if ($this->ob_var->Exportable) $Doc->ExportCaption($this->ob_var);
					if ($this->ob_jumlah->Exportable) $Doc->ExportCaption($this->ob_jumlah);
					if ($this->status->Exportable) $Doc->ExportCaption($this->status);
					if ($this->ob_tgl_real_kirim->Exportable) $Doc->ExportCaption($this->ob_tgl_real_kirim);
					if ($this->ob_jumlah_real_kirim->Exportable) $Doc->ExportCaption($this->ob_jumlah_real_kirim);
				} else {
					if ($this->ob_id->Exportable) $Doc->ExportCaption($this->ob_id);
					if ($this->ob_co->Exportable) $Doc->ExportCaption($this->ob_co);
					if ($this->ob_k_tanam->Exportable) $Doc->ExportCaption($this->ob_k_tanam);
					if ($this->ob_pembeli->Exportable) $Doc->ExportCaption($this->ob_pembeli);
					if ($this->ob_tgl_kirim->Exportable) $Doc->ExportCaption($this->ob_tgl_kirim);
					if ($this->ob_var->Exportable) $Doc->ExportCaption($this->ob_var);
					if ($this->ob_jumlah->Exportable) $Doc->ExportCaption($this->ob_jumlah);
					if ($this->status->Exportable) $Doc->ExportCaption($this->status);
					if ($this->ob_tgl_real_kirim->Exportable) $Doc->ExportCaption($this->ob_tgl_real_kirim);
					if ($this->ob_jumlah_real_kirim->Exportable) $Doc->ExportCaption($this->ob_jumlah_real_kirim);
				}
				$Doc->EndExportRow();
			}
		}

		// Move to first record
		$RecCnt = $StartRec - 1;
		if (!$Recordset->EOF) {
			$Recordset->MoveFirst();
			if ($StartRec > 1)
				$Recordset->Move($StartRec - 1);
		}
		while (!$Recordset->EOF && $RecCnt < $StopRec) {
			$RecCnt++;
			if (intval($RecCnt) >= intval($StartRec)) {
				$RowCnt = intval($RecCnt) - intval($StartRec) + 1;

				// Page break
				if ($this->ExportPageBreakCount > 0) {
					if ($RowCnt > 1 && ($RowCnt - 1) % $this->ExportPageBreakCount == 0)
						$Doc->ExportPageBreak();
				}
				$this->LoadListRowValues($Recordset);
				$this->AggregateListRowValues(); // Aggregate row values

				// Render row
				$this->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->ResetAttrs();
				$this->RenderListRow();
				if (!$Doc->ExportCustom) {
					$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled
					if ($ExportPageType == "view") {
						if ($this->ob_id->Exportable) $Doc->ExportField($this->ob_id);
						if ($this->ob_co->Exportable) $Doc->ExportField($this->ob_co);
						if ($this->ob_k_tanam->Exportable) $Doc->ExportField($this->ob_k_tanam);
						if ($this->ob_pembeli->Exportable) $Doc->ExportField($this->ob_pembeli);
						if ($this->ob_tgl_kirim->Exportable) $Doc->ExportField($this->ob_tgl_kirim);
						if ($this->ob_var->Exportable) $Doc->ExportField($this->ob_var);
						if ($this->ob_jumlah->Exportable) $Doc->ExportField($this->ob_jumlah);
						if ($this->status->Exportable) $Doc->ExportField($this->status);
						if ($this->ob_tgl_real_kirim->Exportable) $Doc->ExportField($this->ob_tgl_real_kirim);
						if ($this->ob_jumlah_real_kirim->Exportable) $Doc->ExportField($this->ob_jumlah_real_kirim);
					} else {
						if ($this->ob_id->Exportable) $Doc->ExportField($this->ob_id);
						if ($this->ob_co->Exportable) $Doc->ExportField($this->ob_co);
						if ($this->ob_k_tanam->Exportable) $Doc->ExportField($this->ob_k_tanam);
						if ($this->ob_pembeli->Exportable) $Doc->ExportField($this->ob_pembeli);
						if ($this->ob_tgl_kirim->Exportable) $Doc->ExportField($this->ob_tgl_kirim);
						if ($this->ob_var->Exportable) $Doc->ExportField($this->ob_var);
						if ($this->ob_jumlah->Exportable) $Doc->ExportField($this->ob_jumlah);
						if ($this->status->Exportable) $Doc->ExportField($this->status);
						if ($this->ob_tgl_real_kirim->Exportable) $Doc->ExportField($this->ob_tgl_real_kirim);
						if ($this->ob_jumlah_real_kirim->Exportable) $Doc->ExportField($this->ob_jumlah_real_kirim);
					}
					$Doc->EndExportRow($RowCnt);
				}
			}

			// Call Row Export server event
			if ($Doc->ExportCustom)
				$this->Row_Export($Recordset->fields);
			$Recordset->MoveNext();
		}

		// Export aggregates (horizontal format only)
		if ($Doc->Horizontal) {
			$this->RowType = EW_ROWTYPE_AGGREGATE;
			$this->ResetAttrs();
			$this->AggregateListRow();
			if (!$Doc->ExportCustom) {
				$Doc->BeginExportRow(-1);
				if ($this->ob_id->Exportable) $Doc->ExportAggregate($this->ob_id, '');
				if ($this->ob_co->Exportable) $Doc->ExportAggregate($this->ob_co, '');
				if ($this->ob_k_tanam->Exportable) $Doc->ExportAggregate($this->ob_k_tanam, '');
				if ($this->ob_pembeli->Exportable) $Doc->ExportAggregate($this->ob_pembeli, '');
				if ($this->ob_tgl_kirim->Exportable) $Doc->ExportAggregate($this->ob_tgl_kirim, '');
				if ($this->ob_var->Exportable) $Doc->ExportAggregate($this->ob_var, '');
				if ($this->ob_jumlah->Exportable) $Doc->ExportAggregate($this->ob_jumlah, 'TOTAL');
				if ($this->status->Exportable) $Doc->ExportAggregate($this->status, '');
				if ($this->ob_tgl_real_kirim->Exportable) $Doc->ExportAggregate($this->ob_tgl_real_kirim, '');
				if ($this->ob_jumlah_real_kirim->Exportable) $Doc->ExportAggregate($this->ob_jumlah_real_kirim, 'TOTAL');
				$Doc->EndExportRow();
			}
		}
		if (!$Doc->ExportCustom) {
			$Doc->ExportTableFooter();
		}
	}

	// Get auto fill value
	function GetAutoFill($id, $val) {
		$rsarr = array();
		$rowcnt = 0;

		// Output
		if (is_array($rsarr) && $rowcnt > 0) {
			$fldcnt = count($rsarr[0]);
			for ($i = 0; $i < $rowcnt; $i++) {
				for ($j = 0; $j < $fldcnt; $j++) {
					$str = strval($rsarr[$i][$j]);
					$str = ew_ConvertToUtf8($str);
					if (isset($post["keepCRLF"])) {
						$str = str_replace(array("\r", "\n"), array("\\r", "\\n"), $str);
					} else {
						$str = str_replace(array("\r", "\n"), array(" ", " "), $str);
					}
					$rsarr[$i][$j] = $str;
				}
			}
			return ew_ArrayToJson($rsarr);
		} else {
			return FALSE;
		}
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here
	}

	// Recordset Selected event
	function Recordset_Selected(&$rs) {

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

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

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Inserting event
	function Row_Inserting($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted($rsold, &$rsnew) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated($rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict($rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Grid Inserting event
	function Grid_Inserting() {

		// Enter your code here
		// To reject grid insert, set return value to FALSE

		return TRUE;
	}

	// Grid Inserted event
	function Grid_Inserted($rsnew) {

		//echo "Grid Inserted";
	}

	// Grid Updating event
	function Grid_Updating($rsold) {

		// Enter your code here
		// To reject grid update, set return value to FALSE

		return TRUE;
	}

	// Grid Updated event
	function Grid_Updated($rsold, $rsnew) {

		//echo "Grid Updated";
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// 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) {

		//var_dump($fld->FldName, $fld->LookupFilters, $filter); // Uncomment to view the filter
		// Enter your code here

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here
	}

	// 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
	}
}
?>
