<?php

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

//
// Table class for kontrak
//
class ckontrak extends cTable {
	var $k_id;
	var $k_id_kontrak;
	var $k_id_lama;
	var $k_no_kontrak;
	var $k_luas_lahan;
	var $pet_id;
	var $koord_id;
	var $kk_id;
	var $prov_id;
	var $kab_id;
	var $kec_id;
	var $desa_id;
	var $blok_id;
	var $sos_id;
	var $var_id;
	var $co_id;
	var $k_jumlah_bibit;
	var $k_asal_bibit;
	var $k_tgl_tanam;
	var $k_es_tgl_panen;
	var $k_ak_tgl_datang;
	var $k_es_qty;
	var $k_ak_qty;
	var $k_es_perhektar;
	var $k_ak_perhektar;
	var $k_skor;
	var $k_ket;
	var $k_cat;
	var $k_titik_koordinat;
	var $k_foto_lahan;
	var $k_dok;
	var $k_harga_bibit;
	var $k_bayar_bibit;
	var $k_pinjaman;
	var $k_bayar_pinjaman;
	var $k_sisa_hutang;

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

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

		// Update Table
		$this->UpdateTable = "`kontrak`";
		$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);

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

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

		// k_id_lama
		$this->k_id_lama = new cField('kontrak', 'kontrak', 'x_k_id_lama', 'k_id_lama', '`k_id_lama`', '`k_id_lama`', 200, -1, FALSE, '`k_id_lama`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_id_lama->Sortable = FALSE; // Allow sort
		$this->fields['k_id_lama'] = &$this->k_id_lama;

		// k_no_kontrak
		$this->k_no_kontrak = new cField('kontrak', 'kontrak', 'x_k_no_kontrak', 'k_no_kontrak', '`k_no_kontrak`', '`k_no_kontrak`', 200, -1, FALSE, '`k_no_kontrak`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_no_kontrak->Sortable = FALSE; // Allow sort
		$this->fields['k_no_kontrak'] = &$this->k_no_kontrak;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		// k_tgl_tanam
		$this->k_tgl_tanam = new cField('kontrak', 'kontrak', 'x_k_tgl_tanam', 'k_tgl_tanam', '`k_tgl_tanam`', ew_CastDateFieldForLike('`k_tgl_tanam`', 5, "DB"), 133, 5, FALSE, '`k_tgl_tanam`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_tgl_tanam->Sortable = TRUE; // Allow sort
		$this->k_tgl_tanam->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EW_DATE_SEPARATOR"], $Language->Phrase("IncorrectDateYMD"));
		$this->fields['k_tgl_tanam'] = &$this->k_tgl_tanam;

		// k_es_tgl_panen
		$this->k_es_tgl_panen = new cField('kontrak', 'kontrak', 'x_k_es_tgl_panen', 'k_es_tgl_panen', '`k_es_tgl_panen`', ew_CastDateFieldForLike('`k_es_tgl_panen`', 5, "DB"), 133, 5, FALSE, '`k_es_tgl_panen`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_es_tgl_panen->Sortable = TRUE; // Allow sort
		$this->k_es_tgl_panen->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EW_DATE_SEPARATOR"], $Language->Phrase("IncorrectDateYMD"));
		$this->fields['k_es_tgl_panen'] = &$this->k_es_tgl_panen;

		// k_ak_tgl_datang
		$this->k_ak_tgl_datang = new cField('kontrak', 'kontrak', 'x_k_ak_tgl_datang', 'k_ak_tgl_datang', '`k_ak_tgl_datang`', ew_CastDateFieldForLike('`k_ak_tgl_datang`', 5, "DB"), 133, 5, FALSE, '`k_ak_tgl_datang`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_ak_tgl_datang->Sortable = TRUE; // Allow sort
		$this->k_ak_tgl_datang->FldDefaultErrMsg = str_replace("%s", $GLOBALS["EW_DATE_SEPARATOR"], $Language->Phrase("IncorrectDateYMD"));
		$this->fields['k_ak_tgl_datang'] = &$this->k_ak_tgl_datang;

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

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

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

		// k_ak_perhektar
		$this->k_ak_perhektar = new cField('kontrak', 'kontrak', 'x_k_ak_perhektar', 'k_ak_perhektar', '`k_ak_perhektar`', '`k_ak_perhektar`', 5, -1, FALSE, '`k_ak_perhektar`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_ak_perhektar->Sortable = TRUE; // Allow sort
		$this->k_ak_perhektar->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['k_ak_perhektar'] = &$this->k_ak_perhektar;

		// k_skor
		$this->k_skor = new cField('kontrak', 'kontrak', 'x_k_skor', 'k_skor', '`k_skor`', '`k_skor`', 5, -1, FALSE, '`k_skor`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->k_skor->Sortable = TRUE; // Allow sort
		$this->k_skor->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['k_skor'] = &$this->k_skor;

		// k_ket
		$this->k_ket = new cField('kontrak', 'kontrak', 'x_k_ket', 'k_ket', '`k_ket`', '`k_ket`', 201, -1, FALSE, '`k_ket`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXTAREA');
		$this->k_ket->Sortable = TRUE; // Allow sort
		$this->fields['k_ket'] = &$this->k_ket;

		// k_cat
		$this->k_cat = new cField('kontrak', 'kontrak', 'x_k_cat', 'k_cat', '`k_cat`', '`k_cat`', 201, -1, FALSE, '`k_cat`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXTAREA');
		$this->k_cat->Sortable = TRUE; // Allow sort
		$this->fields['k_cat'] = &$this->k_cat;

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

		// k_foto_lahan
		$this->k_foto_lahan = new cField('kontrak', 'kontrak', 'x_k_foto_lahan', 'k_foto_lahan', '`k_foto_lahan`', '`k_foto_lahan`', 200, -1, TRUE, '`k_foto_lahan`', FALSE, FALSE, FALSE, 'IMAGE', 'FILE');
		$this->k_foto_lahan->Sortable = TRUE; // Allow sort
		$this->k_foto_lahan->ImageResize = TRUE;
		$this->k_foto_lahan->UploadMultiple = TRUE;
		$this->k_foto_lahan->Upload->UploadMultiple = TRUE;
		$this->k_foto_lahan->UploadMaxFileCount = 0;
		$this->fields['k_foto_lahan'] = &$this->k_foto_lahan;

		// k_dok
		$this->k_dok = new cField('kontrak', 'kontrak', 'x_k_dok', 'k_dok', '`k_dok`', '`k_dok`', 200, -1, TRUE, '`k_dok`', FALSE, FALSE, FALSE, 'IMAGE', 'FILE');
		$this->k_dok->Sortable = TRUE; // Allow sort
		$this->k_dok->ImageResize = TRUE;
		$this->k_dok->UploadMultiple = TRUE;
		$this->k_dok->Upload->UploadMultiple = TRUE;
		$this->k_dok->UploadMaxFileCount = 0;
		$this->fields['k_dok'] = &$this->k_dok;

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

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

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

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

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

	// 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
			$sSortFieldList = ($ofld->FldVirtualExpression <> "") ? $ofld->FldVirtualExpression : $sSortField;
			$this->setSessionOrderByList($sSortFieldList . " " . $sThisSort); // Save to Session
		} else {
			$ofld->setSort("");
		}
	}

	// Session ORDER BY for List page
	function getSessionOrderByList() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ORDER_BY_LIST];
	}

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

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

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

	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 $_SqlSelectList = "";

	function getSqlSelectList() { // Select for List page
		$select = "";
		$select = "SELECT * FROM (" .
			"SELECT *, (SELECT CONCAT(COALESCE(`pet_nama`, ''),'" . ew_ValueSeparator(1, $this->pet_id) . "',COALESCE(`pet_alamat`,'')) FROM `petani` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`pet_id` = `kontrak`.`pet_id` LIMIT 1) AS `EV__pet_id`, (SELECT CONCAT(COALESCE(`koord_nama`, ''),'" . ew_ValueSeparator(1, $this->koord_id) . "',COALESCE(`koord_alamat`,'')) FROM `koord` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`koord_id` = `kontrak`.`koord_id` LIMIT 1) AS `EV__koord_id`, (SELECT `prov_nama` FROM `prov` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`prov_id` = `kontrak`.`prov_id` LIMIT 1) AS `EV__prov_id`, (SELECT `kab_nama` FROM `kab` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`kab_id` = `kontrak`.`kab_id` LIMIT 1) AS `EV__kab_id`, (SELECT `kec_nama` FROM `kec` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`kec_id` = `kontrak`.`kec_id` LIMIT 1) AS `EV__kec_id`, (SELECT `desa_nama` FROM `desa` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`desa_id` = `kontrak`.`desa_id` LIMIT 1) AS `EV__desa_id`, (SELECT `blok_nama` FROM `blok` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`blok_id` = `kontrak`.`blok_id` LIMIT 1) AS `EV__blok_id`, (SELECT CONCAT(COALESCE(`sos_id`, ''),'" . ew_ValueSeparator(1, $this->sos_id) . "',COALESCE(`sos_tgl`,''),'" . ew_ValueSeparator(2, $this->sos_id) . "',COALESCE(`sos_alamat`,'')) FROM `sosialisasi` `EW_TMP_LOOKUPTABLE` WHERE `EW_TMP_LOOKUPTABLE`.`sos_id` = `kontrak`.`sos_id` LIMIT 1) AS `EV__sos_id` FROM `kontrak`" .
			") `EW_TMP_TABLE`";
		return ($this->_SqlSelectList <> "") ? $this->_SqlSelectList : $select;
	}

	function SqlSelectList() { // For backward compatibility
		return $this->getSqlSelectList();
	}

	function setSqlSelectList($v) {
		$this->_SqlSelectList = $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 : "`k_id_kontrak` 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);
		if ($this->UseVirtualFields()) {
			$sSelect = $this->getSqlSelectList();
			$sSort = $this->UseSessionForListSQL ? $this->getSessionOrderByList() : "";
		} else {
			$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->UseVirtualFields()) ? $this->getSessionOrderByList() : $this->getSessionOrderBy();
		return ew_BuildSelectSql("", "", "", "", $this->getSqlOrderBy(), "", $sSort);
	}

	// Check if virtual fields is used in SQL
	function UseVirtualFields() {
		$sWhere = $this->UseSessionForListSQL ? $this->getSessionWhere() : $this->CurrentFilter;
		$sOrderBy = $this->UseSessionForListSQL ? $this->getSessionOrderByList() : "";
		if ($sWhere <> "")
			$sWhere = " " . str_replace(array("(",")"), array("",""), $sWhere) . " ";
		if ($sOrderBy <> "")
			$sOrderBy = " " . str_replace(array("(",")"), array("",""), $sOrderBy) . " ";
		if ($this->BasicSearch->getKeyword() <> "")
			return TRUE;
		if ($this->pet_id->AdvancedSearch->SearchValue <> "" ||
			$this->pet_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->pet_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->pet_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->koord_id->AdvancedSearch->SearchValue <> "" ||
			$this->koord_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->koord_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->koord_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->prov_id->AdvancedSearch->SearchValue <> "" ||
			$this->prov_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->prov_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->prov_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->kab_id->AdvancedSearch->SearchValue <> "" ||
			$this->kab_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->kab_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->kab_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->kec_id->AdvancedSearch->SearchValue <> "" ||
			$this->kec_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->kec_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->kec_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->desa_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->blok_id->AdvancedSearch->SearchValue <> "" ||
			$this->blok_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->blok_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->blok_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if ($this->sos_id->AdvancedSearch->SearchValue <> "" ||
			$this->sos_id->AdvancedSearch->SearchValue2 <> "" ||
			strpos($sWhere, " " . $this->sos_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		if (strpos($sOrderBy, " " . $this->sos_id->FldVirtualExpression . " ") !== FALSE)
			return TRUE;
		return FALSE;
	}

	// 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() : "";
		if ($this->UseVirtualFields())
			$sql = ew_BuildSelectSql($this->getSqlSelectList(), $this->getSqlWhere(), $groupBy, $having, "", $filter, "");
		else
			$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->k_id->setDbValue($conn->Insert_ID());
			$rs['k_id'] = $this->k_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('k_id', $rs))
				ew_AddFilter($where, ew_QuotedName('k_id', $this->DBID) . '=' . ew_QuotedValue($rs['k_id'], $this->k_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 "`k_id` = @k_id@";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		if (!is_numeric($this->k_id->CurrentValue))
			return "0=1"; // Invalid key
		if (is_null($this->k_id->CurrentValue))
			return "0=1"; // Invalid key
		else
			$sKeyFilter = str_replace("@k_id@", ew_AdjustSql($this->k_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 "kontraklist.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 == "kontrakview.php")
			return $Language->Phrase("View");
		elseif ($pageName == "kontrakedit.php")
			return $Language->Phrase("Edit");
		elseif ($pageName == "kontrakadd.php")
			return $Language->Phrase("Add");
		else
			return "";
	}

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

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

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

	// Edit URL
	function GetEditUrl($parm = "") {
		$url = $this->KeyUrl("kontrakedit.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("kontrakadd.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("kontrakdelete.php", $this->UrlParm());
	}

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

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

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		if (!is_null($this->k_id->CurrentValue)) {
			$sUrl .= "k_id=" . urlencode($this->k_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["k_id"]))
				$arKeys[] = $_POST["k_id"];
			elseif (isset($_GET["k_id"]))
				$arKeys[] = $_GET["k_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->k_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->k_id->setDbValue($rs->fields('k_id'));
		$this->k_id_kontrak->setDbValue($rs->fields('k_id_kontrak'));
		$this->k_id_lama->setDbValue($rs->fields('k_id_lama'));
		$this->k_no_kontrak->setDbValue($rs->fields('k_no_kontrak'));
		$this->k_luas_lahan->setDbValue($rs->fields('k_luas_lahan'));
		$this->pet_id->setDbValue($rs->fields('pet_id'));
		$this->koord_id->setDbValue($rs->fields('koord_id'));
		$this->kk_id->setDbValue($rs->fields('kk_id'));
		$this->prov_id->setDbValue($rs->fields('prov_id'));
		$this->kab_id->setDbValue($rs->fields('kab_id'));
		$this->kec_id->setDbValue($rs->fields('kec_id'));
		$this->desa_id->setDbValue($rs->fields('desa_id'));
		$this->blok_id->setDbValue($rs->fields('blok_id'));
		$this->sos_id->setDbValue($rs->fields('sos_id'));
		$this->var_id->setDbValue($rs->fields('var_id'));
		$this->co_id->setDbValue($rs->fields('co_id'));
		$this->k_jumlah_bibit->setDbValue($rs->fields('k_jumlah_bibit'));
		$this->k_asal_bibit->setDbValue($rs->fields('k_asal_bibit'));
		$this->k_tgl_tanam->setDbValue($rs->fields('k_tgl_tanam'));
		$this->k_es_tgl_panen->setDbValue($rs->fields('k_es_tgl_panen'));
		$this->k_ak_tgl_datang->setDbValue($rs->fields('k_ak_tgl_datang'));
		$this->k_es_qty->setDbValue($rs->fields('k_es_qty'));
		$this->k_ak_qty->setDbValue($rs->fields('k_ak_qty'));
		$this->k_es_perhektar->setDbValue($rs->fields('k_es_perhektar'));
		$this->k_ak_perhektar->setDbValue($rs->fields('k_ak_perhektar'));
		$this->k_skor->setDbValue($rs->fields('k_skor'));
		$this->k_ket->setDbValue($rs->fields('k_ket'));
		$this->k_cat->setDbValue($rs->fields('k_cat'));
		$this->k_titik_koordinat->setDbValue($rs->fields('k_titik_koordinat'));
		$this->k_foto_lahan->Upload->DbValue = $rs->fields('k_foto_lahan');
		$this->k_dok->Upload->DbValue = $rs->fields('k_dok');
		$this->k_harga_bibit->setDbValue($rs->fields('k_harga_bibit'));
		$this->k_bayar_bibit->setDbValue($rs->fields('k_bayar_bibit'));
		$this->k_pinjaman->setDbValue($rs->fields('k_pinjaman'));
		$this->k_bayar_pinjaman->setDbValue($rs->fields('k_bayar_pinjaman'));
		$this->k_sisa_hutang->setDbValue($rs->fields('k_sisa_hutang'));
	}

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

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

	// Common render codes
		// k_id

		$this->k_id->CellCssStyle = "white-space: nowrap;";

		// k_id_kontrak
		// k_id_lama

		$this->k_id_lama->CellCssStyle = "white-space: nowrap;";

		// k_no_kontrak
		$this->k_no_kontrak->CellCssStyle = "white-space: nowrap;";

		// k_luas_lahan
		// pet_id
		// koord_id
		// kk_id
		// prov_id
		// kab_id
		// kec_id
		// desa_id
		// blok_id
		// sos_id
		// var_id
		// co_id
		// k_jumlah_bibit
		// k_asal_bibit
		// k_tgl_tanam
		// k_es_tgl_panen
		// k_ak_tgl_datang
		// k_es_qty
		// k_ak_qty
		// k_es_perhektar
		// k_ak_perhektar
		// k_skor
		// k_ket
		// k_cat
		// k_titik_koordinat
		// k_foto_lahan
		// k_dok
		// k_harga_bibit
		// k_bayar_bibit
		// k_pinjaman
		// k_bayar_pinjaman
		// k_sisa_hutang
		// k_id

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

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

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

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

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

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

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

		// kk_id
		if (strval($this->kk_id->CurrentValue) <> "") {
			$sFilterWrk = "`kk_id`" . ew_SearchString("=", $this->kk_id->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `kk_id`, `kk_periode` AS `DispFld`, `kk_tgl_mulai` AS `Disp2Fld`, `kk_tgl_akhir` AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kontrak_koord`";
		$sWhereWrk = "";
		$this->kk_id->LookupFilters = array("df2" => "5", "df3" => "5");
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->kk_id, $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] = ew_FormatDateTime($rswrk->fields('Disp2Fld'), 5);
				$arwrk[3] = ew_FormatDateTime($rswrk->fields('Disp3Fld'), 5);
				$this->kk_id->ViewValue = $this->kk_id->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->kk_id->ViewValue = $this->kk_id->CurrentValue;
			}
		} else {
			$this->kk_id->ViewValue = NULL;
		}
		$this->kk_id->ViewCustomAttributes = "";

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

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

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

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

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

		// sos_id
		if ($this->sos_id->VirtualValue <> "") {
			$this->sos_id->ViewValue = $this->sos_id->VirtualValue;
		} else {
		if (strval($this->sos_id->CurrentValue) <> "") {
			$sFilterWrk = "`sos_id`" . ew_SearchString("=", $this->sos_id->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `sos_id`, `sos_id` AS `DispFld`, `sos_tgl` AS `Disp2Fld`, `sos_alamat` AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sosialisasi`";
		$sWhereWrk = "";
		$this->sos_id->LookupFilters = array("df2" => "0");
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_id, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `sos_tgl` DESC";
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$arwrk = array();
				$arwrk[1] = $rswrk->fields('DispFld');
				$arwrk[2] = ew_FormatDateTime($rswrk->fields('Disp2Fld'), 0);
				$arwrk[3] = $rswrk->fields('Disp3Fld');
				$this->sos_id->ViewValue = $this->sos_id->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_id->ViewValue = $this->sos_id->CurrentValue;
			}
		} else {
			$this->sos_id->ViewValue = NULL;
		}
		}
		$this->sos_id->ViewCustomAttributes = "";

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

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

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

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

		// k_tgl_tanam
		$this->k_tgl_tanam->ViewValue = $this->k_tgl_tanam->CurrentValue;
		$this->k_tgl_tanam->ViewValue = ew_FormatDateTime($this->k_tgl_tanam->ViewValue, 5);
		$this->k_tgl_tanam->ViewCustomAttributes = "";

		// k_es_tgl_panen
		$this->k_es_tgl_panen->ViewValue = $this->k_es_tgl_panen->CurrentValue;
		$this->k_es_tgl_panen->ViewValue = ew_FormatDateTime($this->k_es_tgl_panen->ViewValue, 5);
		$this->k_es_tgl_panen->ViewCustomAttributes = "";

		// k_ak_tgl_datang
		$this->k_ak_tgl_datang->ViewValue = $this->k_ak_tgl_datang->CurrentValue;
		$this->k_ak_tgl_datang->ViewValue = ew_FormatDateTime($this->k_ak_tgl_datang->ViewValue, 5);
		$this->k_ak_tgl_datang->ViewCustomAttributes = "";

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

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

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

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

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

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

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

		// k_titik_koordinat
		$this->k_titik_koordinat->ViewValue = $this->k_titik_koordinat->CurrentValue;
		$this->k_titik_koordinat->CellCssStyle .= "text-align: left;";
		$this->k_titik_koordinat->ViewCustomAttributes = "";

		// k_foto_lahan
		$this->k_foto_lahan->UploadPath = "foto_lahan";
		if (!ew_Empty($this->k_foto_lahan->Upload->DbValue)) {
			$this->k_foto_lahan->ImageWidth = 40;
			$this->k_foto_lahan->ImageHeight = 30;
			$this->k_foto_lahan->ImageAlt = $this->k_foto_lahan->FldAlt();
			$this->k_foto_lahan->ViewValue = $this->k_foto_lahan->Upload->DbValue;
		} else {
			$this->k_foto_lahan->ViewValue = "";
		}
		$this->k_foto_lahan->CellCssStyle .= "text-align: left;";
		$this->k_foto_lahan->ViewCustomAttributes = "";

		// k_dok
		$this->k_dok->UploadPath = "dokumen_kontrak_lahan";
		if (!ew_Empty($this->k_dok->Upload->DbValue)) {
			$this->k_dok->ImageWidth = 42;
			$this->k_dok->ImageHeight = 70;
			$this->k_dok->ImageAlt = $this->k_dok->FldAlt();
			$this->k_dok->ViewValue = $this->k_dok->Upload->DbValue;
		} else {
			$this->k_dok->ViewValue = "";
		}
		$this->k_dok->ViewCustomAttributes = "";

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

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

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

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

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

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

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

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

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

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

		// pet_id
		$this->pet_id->LinkCustomAttributes = "";
		if (!ew_Empty($this->pet_id->CurrentValue)) {
			$this->pet_id->HrefValue = "petaniview.php?showdetail=&pet_id=" . $this->pet_id->CurrentValue; // Add prefix/suffix
			$this->pet_id->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->pet_id->HrefValue = ew_FullUrl($this->pet_id->HrefValue, "href");
		} else {
			$this->pet_id->HrefValue = "";
		}
		$this->pet_id->TooltipValue = "";

		// koord_id
		$this->koord_id->LinkCustomAttributes = "";
		if (!ew_Empty($this->koord_id->CurrentValue)) {
			$this->koord_id->HrefValue = "koordview.php?showdetail=&koord_id=" . $this->koord_id->CurrentValue; // Add prefix/suffix
			$this->koord_id->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->koord_id->HrefValue = ew_FullUrl($this->koord_id->HrefValue, "href");
		} else {
			$this->koord_id->HrefValue = "";
		}
		$this->koord_id->TooltipValue = "";

		// kk_id
		$this->kk_id->LinkCustomAttributes = "";
		if (!ew_Empty($this->kk_id->CurrentValue)) {
			$this->kk_id->HrefValue = "kontrak_koordview.php?showdetail=&kk_id=" . $this->kk_id->CurrentValue; // Add prefix/suffix
			$this->kk_id->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->kk_id->HrefValue = ew_FullUrl($this->kk_id->HrefValue, "href");
		} else {
			$this->kk_id->HrefValue = "";
		}
		$this->kk_id->TooltipValue = "";

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

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

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

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

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

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

		// var_id
		$this->var_id->LinkCustomAttributes = "";
		if (!ew_Empty($this->var_id->CurrentValue)) {
			$this->var_id->HrefValue = "varietasview.php?showdetail=&var_id=" . $this->var_id->CurrentValue; // Add prefix/suffix
			$this->var_id->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->var_id->HrefValue = ew_FullUrl($this->var_id->HrefValue, "href");
		} else {
			$this->var_id->HrefValue = "";
		}
		$this->var_id->TooltipValue = "";

		// co_id
		$this->co_id->LinkCustomAttributes = "";
		if (!ew_Empty($this->co_id->CurrentValue)) {
			$this->co_id->HrefValue = "coview.php?showdetail=&co_id=" . $this->co_id->CurrentValue; // Add prefix/suffix
			$this->co_id->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->co_id->HrefValue = ew_FullUrl($this->co_id->HrefValue, "href");
		} else {
			$this->co_id->HrefValue = "";
		}
		$this->co_id->TooltipValue = "";

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

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

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

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

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

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

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

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

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

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

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

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

		// k_titik_koordinat
		$this->k_titik_koordinat->LinkCustomAttributes = "";
		if (!ew_Empty($this->k_titik_koordinat->CurrentValue)) {
			$this->k_titik_koordinat->HrefValue = ((!empty($this->k_titik_koordinat->ViewValue) && !is_array($this->k_titik_koordinat->ViewValue)) ? ew_RemoveHtml($this->k_titik_koordinat->ViewValue) : $this->k_titik_koordinat->CurrentValue); // Add prefix/suffix
			$this->k_titik_koordinat->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->k_titik_koordinat->HrefValue = ew_FullUrl($this->k_titik_koordinat->HrefValue, "href");
		} else {
			$this->k_titik_koordinat->HrefValue = "";
		}
		$this->k_titik_koordinat->TooltipValue = "";

		// k_foto_lahan
		$this->k_foto_lahan->LinkCustomAttributes = "";
		$this->k_foto_lahan->UploadPath = "foto_lahan";
		if (!ew_Empty($this->k_foto_lahan->Upload->DbValue)) {
			$this->k_foto_lahan->HrefValue = "%u"; // Add prefix/suffix
			$this->k_foto_lahan->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->k_foto_lahan->HrefValue = ew_FullUrl($this->k_foto_lahan->HrefValue, "href");
		} else {
			$this->k_foto_lahan->HrefValue = "";
		}
		$this->k_foto_lahan->HrefValue2 = $this->k_foto_lahan->UploadPath . $this->k_foto_lahan->Upload->DbValue;
		$this->k_foto_lahan->TooltipValue = "";
		if ($this->k_foto_lahan->UseColorbox) {
			if (ew_Empty($this->k_foto_lahan->TooltipValue))
				$this->k_foto_lahan->LinkAttrs["title"] = $Language->Phrase("ViewImageGallery");
			$this->k_foto_lahan->LinkAttrs["data-rel"] = "kontrak_x_k_foto_lahan";
			ew_AppendClass($this->k_foto_lahan->LinkAttrs["class"], "ewLightbox");
		}

		// k_dok
		$this->k_dok->LinkCustomAttributes = "";
		$this->k_dok->UploadPath = "dokumen_kontrak_lahan";
		if (!ew_Empty($this->k_dok->Upload->DbValue)) {
			$this->k_dok->HrefValue = "%u"; // Add prefix/suffix
			$this->k_dok->LinkAttrs["target"] = "_blank"; // Add target
			if ($this->Export <> "") $this->k_dok->HrefValue = ew_FullUrl($this->k_dok->HrefValue, "href");
		} else {
			$this->k_dok->HrefValue = "";
		}
		$this->k_dok->HrefValue2 = $this->k_dok->UploadPath . $this->k_dok->Upload->DbValue;
		$this->k_dok->TooltipValue = "";
		if ($this->k_dok->UseColorbox) {
			if (ew_Empty($this->k_dok->TooltipValue))
				$this->k_dok->LinkAttrs["title"] = $Language->Phrase("ViewImageGallery");
			$this->k_dok->LinkAttrs["data-rel"] = "kontrak_x_k_dok";
			ew_AppendClass($this->k_dok->LinkAttrs["class"], "ewLightbox");
		}

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

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

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

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

		// k_sisa_hutang
		$this->k_sisa_hutang->LinkCustomAttributes = "";
		$this->k_sisa_hutang->HrefValue = "";
		$this->k_sisa_hutang->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();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		// k_ak_perhektar
		$this->k_ak_perhektar->EditAttrs["class"] = "form-control";
		$this->k_ak_perhektar->EditCustomAttributes = "";
		$this->k_ak_perhektar->EditValue = $this->k_ak_perhektar->CurrentValue;
		$this->k_ak_perhektar->PlaceHolder = ew_RemoveHtml($this->k_ak_perhektar->FldCaption());
		if (strval($this->k_ak_perhektar->EditValue) <> "" && is_numeric($this->k_ak_perhektar->EditValue)) $this->k_ak_perhektar->EditValue = ew_FormatNumber($this->k_ak_perhektar->EditValue, -2, -1, -2, 0);

		// k_skor
		$this->k_skor->EditAttrs["class"] = "form-control";
		$this->k_skor->EditCustomAttributes = "";
		$this->k_skor->EditValue = $this->k_skor->CurrentValue;
		$this->k_skor->PlaceHolder = ew_RemoveHtml($this->k_skor->FldCaption());
		if (strval($this->k_skor->EditValue) <> "" && is_numeric($this->k_skor->EditValue)) $this->k_skor->EditValue = ew_FormatNumber($this->k_skor->EditValue, -2, -1, -2, 0);

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

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

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

		// k_foto_lahan
		$this->k_foto_lahan->EditAttrs["class"] = "form-control";
		$this->k_foto_lahan->EditCustomAttributes = "";
		$this->k_foto_lahan->UploadPath = "foto_lahan";
		if (!ew_Empty($this->k_foto_lahan->Upload->DbValue)) {
			$this->k_foto_lahan->ImageWidth = 40;
			$this->k_foto_lahan->ImageHeight = 30;
			$this->k_foto_lahan->ImageAlt = $this->k_foto_lahan->FldAlt();
			$this->k_foto_lahan->EditValue = $this->k_foto_lahan->Upload->DbValue;
		} else {
			$this->k_foto_lahan->EditValue = "";
		}
		if (!ew_Empty($this->k_foto_lahan->CurrentValue))
				$this->k_foto_lahan->Upload->FileName = $this->k_foto_lahan->CurrentValue;

		// k_dok
		$this->k_dok->EditAttrs["class"] = "form-control";
		$this->k_dok->EditCustomAttributes = "";
		$this->k_dok->UploadPath = "dokumen_kontrak_lahan";
		if (!ew_Empty($this->k_dok->Upload->DbValue)) {
			$this->k_dok->ImageWidth = 42;
			$this->k_dok->ImageHeight = 70;
			$this->k_dok->ImageAlt = $this->k_dok->FldAlt();
			$this->k_dok->EditValue = $this->k_dok->Upload->DbValue;
		} else {
			$this->k_dok->EditValue = "";
		}
		if (!ew_Empty($this->k_dok->CurrentValue))
				$this->k_dok->Upload->FileName = $this->k_dok->CurrentValue;

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

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

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

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

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

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

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

	// Aggregate list row (for rendering)
	function AggregateListRow() {
			$this->k_luas_lahan->CurrentValue = $this->k_luas_lahan->Total;
			$this->k_luas_lahan->ViewValue = $this->k_luas_lahan->CurrentValue;
			$this->k_luas_lahan->ViewCustomAttributes = "";
			$this->k_luas_lahan->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->k_id_kontrak->Exportable) $Doc->ExportCaption($this->k_id_kontrak);
					if ($this->k_luas_lahan->Exportable) $Doc->ExportCaption($this->k_luas_lahan);
					if ($this->pet_id->Exportable) $Doc->ExportCaption($this->pet_id);
					if ($this->koord_id->Exportable) $Doc->ExportCaption($this->koord_id);
					if ($this->kk_id->Exportable) $Doc->ExportCaption($this->kk_id);
					if ($this->prov_id->Exportable) $Doc->ExportCaption($this->prov_id);
					if ($this->kab_id->Exportable) $Doc->ExportCaption($this->kab_id);
					if ($this->kec_id->Exportable) $Doc->ExportCaption($this->kec_id);
					if ($this->desa_id->Exportable) $Doc->ExportCaption($this->desa_id);
					if ($this->blok_id->Exportable) $Doc->ExportCaption($this->blok_id);
					if ($this->sos_id->Exportable) $Doc->ExportCaption($this->sos_id);
					if ($this->var_id->Exportable) $Doc->ExportCaption($this->var_id);
					if ($this->co_id->Exportable) $Doc->ExportCaption($this->co_id);
					if ($this->k_jumlah_bibit->Exportable) $Doc->ExportCaption($this->k_jumlah_bibit);
					if ($this->k_asal_bibit->Exportable) $Doc->ExportCaption($this->k_asal_bibit);
					if ($this->k_tgl_tanam->Exportable) $Doc->ExportCaption($this->k_tgl_tanam);
					if ($this->k_es_tgl_panen->Exportable) $Doc->ExportCaption($this->k_es_tgl_panen);
					if ($this->k_ak_tgl_datang->Exportable) $Doc->ExportCaption($this->k_ak_tgl_datang);
					if ($this->k_es_qty->Exportable) $Doc->ExportCaption($this->k_es_qty);
					if ($this->k_ak_qty->Exportable) $Doc->ExportCaption($this->k_ak_qty);
					if ($this->k_es_perhektar->Exportable) $Doc->ExportCaption($this->k_es_perhektar);
					if ($this->k_ak_perhektar->Exportable) $Doc->ExportCaption($this->k_ak_perhektar);
					if ($this->k_skor->Exportable) $Doc->ExportCaption($this->k_skor);
					if ($this->k_ket->Exportable) $Doc->ExportCaption($this->k_ket);
					if ($this->k_cat->Exportable) $Doc->ExportCaption($this->k_cat);
					if ($this->k_titik_koordinat->Exportable) $Doc->ExportCaption($this->k_titik_koordinat);
					if ($this->k_foto_lahan->Exportable) $Doc->ExportCaption($this->k_foto_lahan);
					if ($this->k_dok->Exportable) $Doc->ExportCaption($this->k_dok);
					if ($this->k_harga_bibit->Exportable) $Doc->ExportCaption($this->k_harga_bibit);
					if ($this->k_bayar_bibit->Exportable) $Doc->ExportCaption($this->k_bayar_bibit);
					if ($this->k_pinjaman->Exportable) $Doc->ExportCaption($this->k_pinjaman);
					if ($this->k_bayar_pinjaman->Exportable) $Doc->ExportCaption($this->k_bayar_pinjaman);
					if ($this->k_sisa_hutang->Exportable) $Doc->ExportCaption($this->k_sisa_hutang);
				} else {
					if ($this->k_id->Exportable) $Doc->ExportCaption($this->k_id);
					if ($this->k_id_kontrak->Exportable) $Doc->ExportCaption($this->k_id_kontrak);
					if ($this->k_luas_lahan->Exportable) $Doc->ExportCaption($this->k_luas_lahan);
					if ($this->pet_id->Exportable) $Doc->ExportCaption($this->pet_id);
					if ($this->koord_id->Exportable) $Doc->ExportCaption($this->koord_id);
					if ($this->kk_id->Exportable) $Doc->ExportCaption($this->kk_id);
					if ($this->prov_id->Exportable) $Doc->ExportCaption($this->prov_id);
					if ($this->kab_id->Exportable) $Doc->ExportCaption($this->kab_id);
					if ($this->kec_id->Exportable) $Doc->ExportCaption($this->kec_id);
					if ($this->desa_id->Exportable) $Doc->ExportCaption($this->desa_id);
					if ($this->blok_id->Exportable) $Doc->ExportCaption($this->blok_id);
					if ($this->sos_id->Exportable) $Doc->ExportCaption($this->sos_id);
					if ($this->var_id->Exportable) $Doc->ExportCaption($this->var_id);
					if ($this->co_id->Exportable) $Doc->ExportCaption($this->co_id);
					if ($this->k_jumlah_bibit->Exportable) $Doc->ExportCaption($this->k_jumlah_bibit);
					if ($this->k_asal_bibit->Exportable) $Doc->ExportCaption($this->k_asal_bibit);
					if ($this->k_tgl_tanam->Exportable) $Doc->ExportCaption($this->k_tgl_tanam);
					if ($this->k_es_tgl_panen->Exportable) $Doc->ExportCaption($this->k_es_tgl_panen);
					if ($this->k_ak_tgl_datang->Exportable) $Doc->ExportCaption($this->k_ak_tgl_datang);
					if ($this->k_es_qty->Exportable) $Doc->ExportCaption($this->k_es_qty);
					if ($this->k_ak_qty->Exportable) $Doc->ExportCaption($this->k_ak_qty);
					if ($this->k_es_perhektar->Exportable) $Doc->ExportCaption($this->k_es_perhektar);
					if ($this->k_ak_perhektar->Exportable) $Doc->ExportCaption($this->k_ak_perhektar);
					if ($this->k_skor->Exportable) $Doc->ExportCaption($this->k_skor);
					if ($this->k_ket->Exportable) $Doc->ExportCaption($this->k_ket);
					if ($this->k_cat->Exportable) $Doc->ExportCaption($this->k_cat);
					if ($this->k_titik_koordinat->Exportable) $Doc->ExportCaption($this->k_titik_koordinat);
					if ($this->k_foto_lahan->Exportable) $Doc->ExportCaption($this->k_foto_lahan);
					if ($this->k_dok->Exportable) $Doc->ExportCaption($this->k_dok);
					if ($this->k_harga_bibit->Exportable) $Doc->ExportCaption($this->k_harga_bibit);
					if ($this->k_bayar_bibit->Exportable) $Doc->ExportCaption($this->k_bayar_bibit);
					if ($this->k_pinjaman->Exportable) $Doc->ExportCaption($this->k_pinjaman);
					if ($this->k_bayar_pinjaman->Exportable) $Doc->ExportCaption($this->k_bayar_pinjaman);
					if ($this->k_sisa_hutang->Exportable) $Doc->ExportCaption($this->k_sisa_hutang);
				}
				$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->k_id_kontrak->Exportable) $Doc->ExportField($this->k_id_kontrak);
						if ($this->k_luas_lahan->Exportable) $Doc->ExportField($this->k_luas_lahan);
						if ($this->pet_id->Exportable) $Doc->ExportField($this->pet_id);
						if ($this->koord_id->Exportable) $Doc->ExportField($this->koord_id);
						if ($this->kk_id->Exportable) $Doc->ExportField($this->kk_id);
						if ($this->prov_id->Exportable) $Doc->ExportField($this->prov_id);
						if ($this->kab_id->Exportable) $Doc->ExportField($this->kab_id);
						if ($this->kec_id->Exportable) $Doc->ExportField($this->kec_id);
						if ($this->desa_id->Exportable) $Doc->ExportField($this->desa_id);
						if ($this->blok_id->Exportable) $Doc->ExportField($this->blok_id);
						if ($this->sos_id->Exportable) $Doc->ExportField($this->sos_id);
						if ($this->var_id->Exportable) $Doc->ExportField($this->var_id);
						if ($this->co_id->Exportable) $Doc->ExportField($this->co_id);
						if ($this->k_jumlah_bibit->Exportable) $Doc->ExportField($this->k_jumlah_bibit);
						if ($this->k_asal_bibit->Exportable) $Doc->ExportField($this->k_asal_bibit);
						if ($this->k_tgl_tanam->Exportable) $Doc->ExportField($this->k_tgl_tanam);
						if ($this->k_es_tgl_panen->Exportable) $Doc->ExportField($this->k_es_tgl_panen);
						if ($this->k_ak_tgl_datang->Exportable) $Doc->ExportField($this->k_ak_tgl_datang);
						if ($this->k_es_qty->Exportable) $Doc->ExportField($this->k_es_qty);
						if ($this->k_ak_qty->Exportable) $Doc->ExportField($this->k_ak_qty);
						if ($this->k_es_perhektar->Exportable) $Doc->ExportField($this->k_es_perhektar);
						if ($this->k_ak_perhektar->Exportable) $Doc->ExportField($this->k_ak_perhektar);
						if ($this->k_skor->Exportable) $Doc->ExportField($this->k_skor);
						if ($this->k_ket->Exportable) $Doc->ExportField($this->k_ket);
						if ($this->k_cat->Exportable) $Doc->ExportField($this->k_cat);
						if ($this->k_titik_koordinat->Exportable) $Doc->ExportField($this->k_titik_koordinat);
						if ($this->k_foto_lahan->Exportable) $Doc->ExportField($this->k_foto_lahan);
						if ($this->k_dok->Exportable) $Doc->ExportField($this->k_dok);
						if ($this->k_harga_bibit->Exportable) $Doc->ExportField($this->k_harga_bibit);
						if ($this->k_bayar_bibit->Exportable) $Doc->ExportField($this->k_bayar_bibit);
						if ($this->k_pinjaman->Exportable) $Doc->ExportField($this->k_pinjaman);
						if ($this->k_bayar_pinjaman->Exportable) $Doc->ExportField($this->k_bayar_pinjaman);
						if ($this->k_sisa_hutang->Exportable) $Doc->ExportField($this->k_sisa_hutang);
					} else {
						if ($this->k_id->Exportable) $Doc->ExportField($this->k_id);
						if ($this->k_id_kontrak->Exportable) $Doc->ExportField($this->k_id_kontrak);
						if ($this->k_luas_lahan->Exportable) $Doc->ExportField($this->k_luas_lahan);
						if ($this->pet_id->Exportable) $Doc->ExportField($this->pet_id);
						if ($this->koord_id->Exportable) $Doc->ExportField($this->koord_id);
						if ($this->kk_id->Exportable) $Doc->ExportField($this->kk_id);
						if ($this->prov_id->Exportable) $Doc->ExportField($this->prov_id);
						if ($this->kab_id->Exportable) $Doc->ExportField($this->kab_id);
						if ($this->kec_id->Exportable) $Doc->ExportField($this->kec_id);
						if ($this->desa_id->Exportable) $Doc->ExportField($this->desa_id);
						if ($this->blok_id->Exportable) $Doc->ExportField($this->blok_id);
						if ($this->sos_id->Exportable) $Doc->ExportField($this->sos_id);
						if ($this->var_id->Exportable) $Doc->ExportField($this->var_id);
						if ($this->co_id->Exportable) $Doc->ExportField($this->co_id);
						if ($this->k_jumlah_bibit->Exportable) $Doc->ExportField($this->k_jumlah_bibit);
						if ($this->k_asal_bibit->Exportable) $Doc->ExportField($this->k_asal_bibit);
						if ($this->k_tgl_tanam->Exportable) $Doc->ExportField($this->k_tgl_tanam);
						if ($this->k_es_tgl_panen->Exportable) $Doc->ExportField($this->k_es_tgl_panen);
						if ($this->k_ak_tgl_datang->Exportable) $Doc->ExportField($this->k_ak_tgl_datang);
						if ($this->k_es_qty->Exportable) $Doc->ExportField($this->k_es_qty);
						if ($this->k_ak_qty->Exportable) $Doc->ExportField($this->k_ak_qty);
						if ($this->k_es_perhektar->Exportable) $Doc->ExportField($this->k_es_perhektar);
						if ($this->k_ak_perhektar->Exportable) $Doc->ExportField($this->k_ak_perhektar);
						if ($this->k_skor->Exportable) $Doc->ExportField($this->k_skor);
						if ($this->k_ket->Exportable) $Doc->ExportField($this->k_ket);
						if ($this->k_cat->Exportable) $Doc->ExportField($this->k_cat);
						if ($this->k_titik_koordinat->Exportable) $Doc->ExportField($this->k_titik_koordinat);
						if ($this->k_foto_lahan->Exportable) $Doc->ExportField($this->k_foto_lahan);
						if ($this->k_dok->Exportable) $Doc->ExportField($this->k_dok);
						if ($this->k_harga_bibit->Exportable) $Doc->ExportField($this->k_harga_bibit);
						if ($this->k_bayar_bibit->Exportable) $Doc->ExportField($this->k_bayar_bibit);
						if ($this->k_pinjaman->Exportable) $Doc->ExportField($this->k_pinjaman);
						if ($this->k_bayar_pinjaman->Exportable) $Doc->ExportField($this->k_bayar_pinjaman);
						if ($this->k_sisa_hutang->Exportable) $Doc->ExportField($this->k_sisa_hutang);
					}
					$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->k_id->Exportable) $Doc->ExportAggregate($this->k_id, '');
				if ($this->k_id_kontrak->Exportable) $Doc->ExportAggregate($this->k_id_kontrak, '');
				if ($this->k_luas_lahan->Exportable) $Doc->ExportAggregate($this->k_luas_lahan, 'TOTAL');
				if ($this->pet_id->Exportable) $Doc->ExportAggregate($this->pet_id, '');
				if ($this->koord_id->Exportable) $Doc->ExportAggregate($this->koord_id, '');
				if ($this->kk_id->Exportable) $Doc->ExportAggregate($this->kk_id, '');
				if ($this->prov_id->Exportable) $Doc->ExportAggregate($this->prov_id, '');
				if ($this->kab_id->Exportable) $Doc->ExportAggregate($this->kab_id, '');
				if ($this->kec_id->Exportable) $Doc->ExportAggregate($this->kec_id, '');
				if ($this->desa_id->Exportable) $Doc->ExportAggregate($this->desa_id, '');
				if ($this->blok_id->Exportable) $Doc->ExportAggregate($this->blok_id, '');
				if ($this->sos_id->Exportable) $Doc->ExportAggregate($this->sos_id, '');
				if ($this->var_id->Exportable) $Doc->ExportAggregate($this->var_id, '');
				if ($this->co_id->Exportable) $Doc->ExportAggregate($this->co_id, '');
				if ($this->k_jumlah_bibit->Exportable) $Doc->ExportAggregate($this->k_jumlah_bibit, '');
				if ($this->k_asal_bibit->Exportable) $Doc->ExportAggregate($this->k_asal_bibit, '');
				if ($this->k_tgl_tanam->Exportable) $Doc->ExportAggregate($this->k_tgl_tanam, '');
				if ($this->k_es_tgl_panen->Exportable) $Doc->ExportAggregate($this->k_es_tgl_panen, '');
				if ($this->k_ak_tgl_datang->Exportable) $Doc->ExportAggregate($this->k_ak_tgl_datang, '');
				if ($this->k_es_qty->Exportable) $Doc->ExportAggregate($this->k_es_qty, '');
				if ($this->k_ak_qty->Exportable) $Doc->ExportAggregate($this->k_ak_qty, '');
				if ($this->k_es_perhektar->Exportable) $Doc->ExportAggregate($this->k_es_perhektar, '');
				if ($this->k_ak_perhektar->Exportable) $Doc->ExportAggregate($this->k_ak_perhektar, '');
				if ($this->k_skor->Exportable) $Doc->ExportAggregate($this->k_skor, '');
				if ($this->k_ket->Exportable) $Doc->ExportAggregate($this->k_ket, '');
				if ($this->k_cat->Exportable) $Doc->ExportAggregate($this->k_cat, '');
				if ($this->k_titik_koordinat->Exportable) $Doc->ExportAggregate($this->k_titik_koordinat, '');
				if ($this->k_foto_lahan->Exportable) $Doc->ExportAggregate($this->k_foto_lahan, '');
				if ($this->k_dok->Exportable) $Doc->ExportAggregate($this->k_dok, '');
				if ($this->k_harga_bibit->Exportable) $Doc->ExportAggregate($this->k_harga_bibit, '');
				if ($this->k_bayar_bibit->Exportable) $Doc->ExportAggregate($this->k_bayar_bibit, '');
				if ($this->k_pinjaman->Exportable) $Doc->ExportAggregate($this->k_pinjaman, '');
				if ($this->k_bayar_pinjaman->Exportable) $Doc->ExportAggregate($this->k_bayar_pinjaman, '');
				if ($this->k_sisa_hutang->Exportable) $Doc->ExportAggregate($this->k_sisa_hutang, '');
				$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
	}
}
?>
