<?php
if (session_id() == "") session_start(); // Init session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg14.php" ?>
<?php include_once ((EW_USE_ADODB) ? "adodb5/adodb.inc.php" : "ewmysql14.php") ?>
<?php include_once "phpfn14.php" ?>
<?php include_once "kontrakinfo.php" ?>
<?php include_once "employeesinfo.php" ?>
<?php include_once "userfn14.php" ?>
<?php

//
// Page class
//

$kontrak_add = NULL; // Initialize page object first

class ckontrak_add extends ckontrak {

	// Page ID
	var $PageID = 'add';

	// Project ID
	var $ProjectID = '{CC60B42B-604B-412A-B014-2315920AF6AA}';

	// Table name
	var $TableName = 'kontrak';

	// Page object name
	var $PageObjName = 'kontrak_add';

	// Page headings
	var $Heading = '';
	var $Subheading = '';

	// Page heading
	function PageHeading() {
		global $Language;
		if ($this->Heading <> "")
			return $this->Heading;
		if (method_exists($this, "TableCaption"))
			return $this->TableCaption();
		return "";
	}

	// Page subheading
	function PageSubheading() {
		global $Language;
		if ($this->Subheading <> "")
			return $this->Subheading;
		if ($this->TableName)
			return $Language->Phrase($this->PageID);
		return "";
	}

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		if ($this->UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	function getWarningMessage() {
		return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
	}

	function setWarningMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
	}

	// Methods to clear message
	function ClearMessage() {
		$_SESSION[EW_SESSION_MESSAGE] = "";
	}

	function ClearFailureMessage() {
		$_SESSION[EW_SESSION_FAILURE_MESSAGE] = "";
	}

	function ClearSuccessMessage() {
		$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = "";
	}

	function ClearWarningMessage() {
		$_SESSION[EW_SESSION_WARNING_MESSAGE] = "";
	}

	function ClearMessages() {
		$_SESSION[EW_SESSION_MESSAGE] = "";
		$_SESSION[EW_SESSION_FAILURE_MESSAGE] = "";
		$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = "";
		$_SESSION[EW_SESSION_WARNING_MESSAGE] = "";
	}

	// Show message
	function ShowMessage() {
		$hidden = FALSE;
		$html = "";

		// Message
		$sMessage = $this->getMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sMessage;
			$html .= "<div class=\"alert alert-info ewInfo\">" . $sMessage . "</div>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$sWarningMessage = $this->getWarningMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($sWarningMessage, "warning");
		if ($sWarningMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sWarningMessage;
			$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
			$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sSuccessMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sErrorMessage;
			$html .= "<div class=\"alert alert-danger ewError\">" . $sErrorMessage . "</div>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo "<div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div>";
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p>" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Footer exists, display
			echo "<p>" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm;
		if ($this->UseTokenInUrl) {
			if ($objForm)
				return ($this->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($this->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}
	var $Token = "";
	var $TokenTimeout = 0;
	var $CheckToken = EW_CHECK_TOKEN;
	var $CheckTokenFn = "ew_CheckToken";
	var $CreateTokenFn = "ew_CreateToken";

	// Valid Post
	function ValidPost() {
		if (!$this->CheckToken || !ew_IsPost())
			return TRUE;
		if (!isset($_POST[EW_TOKEN_NAME]))
			return FALSE;
		$fn = $this->CheckTokenFn;
		if (is_callable($fn))
			return $fn($_POST[EW_TOKEN_NAME], $this->TokenTimeout);
		return FALSE;
	}

	// Create Token
	function CreateToken() {
		global $gsToken;
		if ($this->CheckToken) {
			$fn = $this->CreateTokenFn;
			if ($this->Token == "" && is_callable($fn)) // Create token
				$this->Token = $fn();
			$gsToken = $this->Token; // Save to global variable
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;
		global $UserTable, $UserTableConn;
		$GLOBALS["Page"] = &$this;
		$this->TokenTimeout = ew_SessionTimeoutTime();

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Parent constuctor
		parent::__construct();

		// Table object (kontrak)
		if (!isset($GLOBALS["kontrak"]) || get_class($GLOBALS["kontrak"]) == "ckontrak") {
			$GLOBALS["kontrak"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["kontrak"];
		}

		// Table object (employees)
		if (!isset($GLOBALS['employees'])) $GLOBALS['employees'] = new cemployees();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'add', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'kontrak', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"]))
			$GLOBALS["gTimer"] = new cTimer();

		// Debug message
		ew_LoadDebugMsg();

		// Open connection
		if (!isset($conn))
			$conn = ew_Connect($this->DBID);

		// User table object (employees)
		if (!isset($UserTable)) {
			$UserTable = new cemployees();
			$UserTableConn = Conn($UserTable->DBID);
		}
	}

	//
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsCustomExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;

		// Is modal
		$this->IsModal = (@$_GET["modal"] == "1" || @$_POST["modal"] == "1");

		// User profile
		$UserProfile = new cUserProfile();

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if ($Security->IsLoggedIn()) $Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName);
		if ($Security->IsLoggedIn()) $Security->TablePermission_Loaded();
		if (!$Security->CanAdd()) {
			$Security->SaveLastUrl();
			$this->setFailureMessage(ew_DeniedMsg()); // Set no permission
			if ($Security->CanList())
				$this->Page_Terminate(ew_GetUrl("kontraklist.php"));
			else
				$this->Page_Terminate(ew_GetUrl("login.php"));
		}

		// NOTE: Security object may be needed in other part of the script, skip set to Nothing
		// 
		// Security = null;
		// 
		// Create form object

		$objForm = new cFormObj();
		$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up current action
		$this->k_luas_lahan->SetVisibility();
		$this->pet_id->SetVisibility();
		$this->koord_id->SetVisibility();
		$this->kk_id->SetVisibility();
		$this->prov_id->SetVisibility();
		$this->kab_id->SetVisibility();
		$this->kec_id->SetVisibility();
		$this->desa_id->SetVisibility();
		$this->blok_id->SetVisibility();
		$this->sos_id->SetVisibility();
		$this->var_id->SetVisibility();
		$this->co_id->SetVisibility();
		$this->k_jumlah_bibit->SetVisibility();
		$this->k_asal_bibit->SetVisibility();
		$this->k_tgl_tanam->SetVisibility();
		$this->k_es_tgl_panen->SetVisibility();
		$this->k_es_perhektar->SetVisibility();
		$this->k_ket->SetVisibility();
		$this->k_cat->SetVisibility();
		$this->k_titik_koordinat->SetVisibility();
		$this->k_foto_lahan->SetVisibility();
		$this->k_dok->SetVisibility();
		$this->k_harga_bibit->SetVisibility();
		$this->k_bayar_bibit->SetVisibility();
		$this->k_pinjaman->SetVisibility();
		$this->k_bayar_pinjaman->SetVisibility();
		$this->k_sisa_hutang->SetVisibility();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();

		// Check token
		if (!$this->ValidPost()) {
			echo $Language->Phrase("InvalidPostRequest");
			$this->Page_Terminate();
			exit();
		}

		// Process auto fill
		if (@$_POST["ajax"] == "autofill") {
			$results = $this->GetAutoFill(@$_POST["name"], @$_POST["q"]);
			if ($results) {

				// Clean output buffer
				if (!EW_DEBUG_ENABLED && ob_get_length())
					ob_end_clean();
				echo $results;
				$this->Page_Terminate();
				exit();
			}
		}

		// Create Token
		$this->CreateToken();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $gsExportFile, $gTmpImages;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		// Export
		global $EW_EXPORT, $kontrak;
		if ($this->CustomExport <> "" && $this->CustomExport == $this->Export && array_key_exists($this->CustomExport, $EW_EXPORT)) {
				$sContent = ob_get_contents();
			if ($gsExportFile == "") $gsExportFile = $this->TableVar;
			$class = $EW_EXPORT[$this->CustomExport];
			if (class_exists($class)) {
				$doc = new $class($kontrak);
				$doc->Text = $sContent;
				if ($this->Export == "email")
					echo $this->ExportEmail($doc->Text);
				else
					$doc->Export();
				ew_DeleteTmpImages(); // Delete temp images
				exit();
			}
		}
		$this->Page_Redirecting($url);

		// Close connection
		ew_CloseConn();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();

			// Handle modal response
			if ($this->IsModal) { // Show as modal
				$row = array("url" => $url, "modal" => "1");
				$pageName = ew_GetPageName($url);
				if ($pageName != $this->GetListUrl()) { // Not List page
					$row["caption"] = $this->GetModalCaption($pageName);
					if ($pageName == "kontrakview.php")
						$row["view"] = "1";
				} else { // List page should not be shown as modal => error
					$row["error"] = $this->getFailureMessage();
					$this->clearFailureMessage();
				}
				header("Content-Type: application/json; charset=utf-8");
				echo ew_ConvertToUtf8(ew_ArrayToJson(array($row)));
			} else {
				ew_SaveDebugMsg();
				header("Location: " . $url);
			}
		}
		exit();
	}
	var $FormClassName = "form-horizontal ewForm ewAddForm";
	var $IsModal = FALSE;
	var $IsMobileOrModal = FALSE;
	var $DbMasterFilter = "";
	var $DbDetailFilter = "";
	var $StartRec;
	var $Priv = 0;
	var $OldRecordset;
	var $CopyRecord;

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError;
		global $gbSkipHeaderFooter;

		// Check modal
		if ($this->IsModal)
			$gbSkipHeaderFooter = TRUE;
		$this->IsMobileOrModal = ew_IsMobile() || $this->IsModal;
		$this->FormClassName = "ewForm ewAddForm form-horizontal";

		// Set up current action
		if (@$_POST["a_add"] <> "") {
			$this->CurrentAction = $_POST["a_add"]; // Get form action
		} else { // Not post back

			// Load key values from QueryString
			$this->CopyRecord = TRUE;
			if (@$_GET["k_id"] != "") {
				$this->k_id->setQueryStringValue($_GET["k_id"]);
				$this->setKey("k_id", $this->k_id->CurrentValue); // Set up key
			} else {
				$this->setKey("k_id", ""); // Clear key
				$this->CopyRecord = FALSE;
			}
			if ($this->CopyRecord) {
				$this->CurrentAction = "C"; // Copy record
			} else {
				$this->CurrentAction = "I"; // Display blank record
			}
		}

		// Load old record / default values
		$loaded = $this->LoadOldRecord();

		// Load form values
		if (@$_POST["a_add"] <> "") {
			$this->LoadFormValues(); // Load form values
		}

		// Validate form if post back
		if (@$_POST["a_add"] <> "") {
			if (!$this->ValidateForm()) {
				$this->CurrentAction = "I"; // Form error, reset action
				$this->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues(); // Restore form values
				$this->setFailureMessage($gsFormError);
			}
		}

		// Perform current action
		switch ($this->CurrentAction) {
			case "I": // Blank record
				break;
			case "C": // Copy an existing record
				if (!$loaded) { // Record not loaded
					if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("kontraklist.php"); // No matching record, return to list
				}
				break;
			case "A": // Add new record
				$this->SendEmail = TRUE; // Send email on add success
				if ($this->AddRow($this->OldRecordset)) { // Add successful
					if ($this->getSuccessMessage() == "")
						$this->setSuccessMessage($Language->Phrase("AddSuccess")); // Set up success message
					$sReturnUrl = $this->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "kontraklist.php")
						$sReturnUrl = $this->AddMasterUrl($sReturnUrl); // List page, return to List page with correct master key if necessary
					elseif (ew_GetPageName($sReturnUrl) == "kontrakview.php")
						$sReturnUrl = $this->GetViewUrl(); // View page, return to View page with keyurl directly
					$this->Page_Terminate($sReturnUrl); // Clean up and return
				} else {
					$this->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Add failed, restore form values
				}
		}

		// Set up Breadcrumb
		$this->SetupBreadcrumb();

		// Render row based on row type
		$this->RowType = EW_ROWTYPE_ADD; // Render add type

		// Render row
		$this->ResetAttrs();
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $Language;

		// Get upload data
		$this->k_foto_lahan->Upload->Index = $objForm->Index;
		$this->k_foto_lahan->Upload->UploadFile();
		$this->k_foto_lahan->CurrentValue = $this->k_foto_lahan->Upload->FileName;
		$this->k_dok->Upload->Index = $objForm->Index;
		$this->k_dok->Upload->UploadFile();
		$this->k_dok->CurrentValue = $this->k_dok->Upload->FileName;
	}

	// Load default values
	function LoadDefaultValues() {
		$this->k_id->CurrentValue = NULL;
		$this->k_id->OldValue = $this->k_id->CurrentValue;
		$this->k_id_kontrak->CurrentValue = NULL;
		$this->k_id_kontrak->OldValue = $this->k_id_kontrak->CurrentValue;
		$this->k_id_lama->CurrentValue = NULL;
		$this->k_id_lama->OldValue = $this->k_id_lama->CurrentValue;
		$this->k_no_kontrak->CurrentValue = NULL;
		$this->k_no_kontrak->OldValue = $this->k_no_kontrak->CurrentValue;
		$this->k_luas_lahan->CurrentValue = NULL;
		$this->k_luas_lahan->OldValue = $this->k_luas_lahan->CurrentValue;
		$this->pet_id->CurrentValue = NULL;
		$this->pet_id->OldValue = $this->pet_id->CurrentValue;
		$this->koord_id->CurrentValue = NULL;
		$this->koord_id->OldValue = $this->koord_id->CurrentValue;
		$this->kk_id->CurrentValue = NULL;
		$this->kk_id->OldValue = $this->kk_id->CurrentValue;
		$this->prov_id->CurrentValue = NULL;
		$this->prov_id->OldValue = $this->prov_id->CurrentValue;
		$this->kab_id->CurrentValue = NULL;
		$this->kab_id->OldValue = $this->kab_id->CurrentValue;
		$this->kec_id->CurrentValue = NULL;
		$this->kec_id->OldValue = $this->kec_id->CurrentValue;
		$this->desa_id->CurrentValue = NULL;
		$this->desa_id->OldValue = $this->desa_id->CurrentValue;
		$this->blok_id->CurrentValue = NULL;
		$this->blok_id->OldValue = $this->blok_id->CurrentValue;
		$this->sos_id->CurrentValue = NULL;
		$this->sos_id->OldValue = $this->sos_id->CurrentValue;
		$this->var_id->CurrentValue = NULL;
		$this->var_id->OldValue = $this->var_id->CurrentValue;
		$this->co_id->CurrentValue = NULL;
		$this->co_id->OldValue = $this->co_id->CurrentValue;
		$this->k_jumlah_bibit->CurrentValue = NULL;
		$this->k_jumlah_bibit->OldValue = $this->k_jumlah_bibit->CurrentValue;
		$this->k_asal_bibit->CurrentValue = NULL;
		$this->k_asal_bibit->OldValue = $this->k_asal_bibit->CurrentValue;
		$this->k_tgl_tanam->CurrentValue = NULL;
		$this->k_tgl_tanam->OldValue = $this->k_tgl_tanam->CurrentValue;
		$this->k_es_tgl_panen->CurrentValue = NULL;
		$this->k_es_tgl_panen->OldValue = $this->k_es_tgl_panen->CurrentValue;
		$this->k_ak_tgl_datang->CurrentValue = NULL;
		$this->k_ak_tgl_datang->OldValue = $this->k_ak_tgl_datang->CurrentValue;
		$this->k_es_qty->CurrentValue = NULL;
		$this->k_es_qty->OldValue = $this->k_es_qty->CurrentValue;
		$this->k_ak_qty->CurrentValue = NULL;
		$this->k_ak_qty->OldValue = $this->k_ak_qty->CurrentValue;
		$this->k_es_perhektar->CurrentValue = NULL;
		$this->k_es_perhektar->OldValue = $this->k_es_perhektar->CurrentValue;
		$this->k_ak_perhektar->CurrentValue = NULL;
		$this->k_ak_perhektar->OldValue = $this->k_ak_perhektar->CurrentValue;
		$this->k_skor->CurrentValue = NULL;
		$this->k_skor->OldValue = $this->k_skor->CurrentValue;
		$this->k_ket->CurrentValue = NULL;
		$this->k_ket->OldValue = $this->k_ket->CurrentValue;
		$this->k_cat->CurrentValue = NULL;
		$this->k_cat->OldValue = $this->k_cat->CurrentValue;
		$this->k_titik_koordinat->CurrentValue = "https://www.google.com/maps/place/";
		$this->k_foto_lahan->Upload->DbValue = NULL;
		$this->k_foto_lahan->OldValue = $this->k_foto_lahan->Upload->DbValue;
		$this->k_foto_lahan->CurrentValue = NULL; // Clear file related field
		$this->k_dok->Upload->DbValue = NULL;
		$this->k_dok->OldValue = $this->k_dok->Upload->DbValue;
		$this->k_dok->CurrentValue = NULL; // Clear file related field
		$this->k_harga_bibit->CurrentValue = NULL;
		$this->k_harga_bibit->OldValue = $this->k_harga_bibit->CurrentValue;
		$this->k_bayar_bibit->CurrentValue = NULL;
		$this->k_bayar_bibit->OldValue = $this->k_bayar_bibit->CurrentValue;
		$this->k_pinjaman->CurrentValue = NULL;
		$this->k_pinjaman->OldValue = $this->k_pinjaman->CurrentValue;
		$this->k_bayar_pinjaman->CurrentValue = NULL;
		$this->k_bayar_pinjaman->OldValue = $this->k_bayar_pinjaman->CurrentValue;
		$this->k_sisa_hutang->CurrentValue = NULL;
		$this->k_sisa_hutang->OldValue = $this->k_sisa_hutang->CurrentValue;
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm;
		$this->GetUploadFiles(); // Get upload files
		if (!$this->k_luas_lahan->FldIsDetailKey) {
			$this->k_luas_lahan->setFormValue($objForm->GetValue("x_k_luas_lahan"));
		}
		if (!$this->pet_id->FldIsDetailKey) {
			$this->pet_id->setFormValue($objForm->GetValue("x_pet_id"));
		}
		if (!$this->koord_id->FldIsDetailKey) {
			$this->koord_id->setFormValue($objForm->GetValue("x_koord_id"));
		}
		if (!$this->kk_id->FldIsDetailKey) {
			$this->kk_id->setFormValue($objForm->GetValue("x_kk_id"));
		}
		if (!$this->prov_id->FldIsDetailKey) {
			$this->prov_id->setFormValue($objForm->GetValue("x_prov_id"));
		}
		if (!$this->kab_id->FldIsDetailKey) {
			$this->kab_id->setFormValue($objForm->GetValue("x_kab_id"));
		}
		if (!$this->kec_id->FldIsDetailKey) {
			$this->kec_id->setFormValue($objForm->GetValue("x_kec_id"));
		}
		if (!$this->desa_id->FldIsDetailKey) {
			$this->desa_id->setFormValue($objForm->GetValue("x_desa_id"));
		}
		if (!$this->blok_id->FldIsDetailKey) {
			$this->blok_id->setFormValue($objForm->GetValue("x_blok_id"));
		}
		if (!$this->sos_id->FldIsDetailKey) {
			$this->sos_id->setFormValue($objForm->GetValue("x_sos_id"));
		}
		if (!$this->var_id->FldIsDetailKey) {
			$this->var_id->setFormValue($objForm->GetValue("x_var_id"));
		}
		if (!$this->co_id->FldIsDetailKey) {
			$this->co_id->setFormValue($objForm->GetValue("x_co_id"));
		}
		if (!$this->k_jumlah_bibit->FldIsDetailKey) {
			$this->k_jumlah_bibit->setFormValue($objForm->GetValue("x_k_jumlah_bibit"));
		}
		if (!$this->k_asal_bibit->FldIsDetailKey) {
			$this->k_asal_bibit->setFormValue($objForm->GetValue("x_k_asal_bibit"));
		}
		if (!$this->k_tgl_tanam->FldIsDetailKey) {
			$this->k_tgl_tanam->setFormValue($objForm->GetValue("x_k_tgl_tanam"));
			$this->k_tgl_tanam->CurrentValue = ew_UnFormatDateTime($this->k_tgl_tanam->CurrentValue, 5);
		}
		if (!$this->k_es_tgl_panen->FldIsDetailKey) {
			$this->k_es_tgl_panen->setFormValue($objForm->GetValue("x_k_es_tgl_panen"));
			$this->k_es_tgl_panen->CurrentValue = ew_UnFormatDateTime($this->k_es_tgl_panen->CurrentValue, 5);
		}
		if (!$this->k_es_perhektar->FldIsDetailKey) {
			$this->k_es_perhektar->setFormValue($objForm->GetValue("x_k_es_perhektar"));
		}
		if (!$this->k_ket->FldIsDetailKey) {
			$this->k_ket->setFormValue($objForm->GetValue("x_k_ket"));
		}
		if (!$this->k_cat->FldIsDetailKey) {
			$this->k_cat->setFormValue($objForm->GetValue("x_k_cat"));
		}
		if (!$this->k_titik_koordinat->FldIsDetailKey) {
			$this->k_titik_koordinat->setFormValue($objForm->GetValue("x_k_titik_koordinat"));
		}
		if (!$this->k_harga_bibit->FldIsDetailKey) {
			$this->k_harga_bibit->setFormValue($objForm->GetValue("x_k_harga_bibit"));
		}
		if (!$this->k_bayar_bibit->FldIsDetailKey) {
			$this->k_bayar_bibit->setFormValue($objForm->GetValue("x_k_bayar_bibit"));
		}
		if (!$this->k_pinjaman->FldIsDetailKey) {
			$this->k_pinjaman->setFormValue($objForm->GetValue("x_k_pinjaman"));
		}
		if (!$this->k_bayar_pinjaman->FldIsDetailKey) {
			$this->k_bayar_pinjaman->setFormValue($objForm->GetValue("x_k_bayar_pinjaman"));
		}
		if (!$this->k_sisa_hutang->FldIsDetailKey) {
			$this->k_sisa_hutang->setFormValue($objForm->GetValue("x_k_sisa_hutang"));
		}
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm;
		$this->k_luas_lahan->CurrentValue = $this->k_luas_lahan->FormValue;
		$this->pet_id->CurrentValue = $this->pet_id->FormValue;
		$this->koord_id->CurrentValue = $this->koord_id->FormValue;
		$this->kk_id->CurrentValue = $this->kk_id->FormValue;
		$this->prov_id->CurrentValue = $this->prov_id->FormValue;
		$this->kab_id->CurrentValue = $this->kab_id->FormValue;
		$this->kec_id->CurrentValue = $this->kec_id->FormValue;
		$this->desa_id->CurrentValue = $this->desa_id->FormValue;
		$this->blok_id->CurrentValue = $this->blok_id->FormValue;
		$this->sos_id->CurrentValue = $this->sos_id->FormValue;
		$this->var_id->CurrentValue = $this->var_id->FormValue;
		$this->co_id->CurrentValue = $this->co_id->FormValue;
		$this->k_jumlah_bibit->CurrentValue = $this->k_jumlah_bibit->FormValue;
		$this->k_asal_bibit->CurrentValue = $this->k_asal_bibit->FormValue;
		$this->k_tgl_tanam->CurrentValue = $this->k_tgl_tanam->FormValue;
		$this->k_tgl_tanam->CurrentValue = ew_UnFormatDateTime($this->k_tgl_tanam->CurrentValue, 5);
		$this->k_es_tgl_panen->CurrentValue = $this->k_es_tgl_panen->FormValue;
		$this->k_es_tgl_panen->CurrentValue = ew_UnFormatDateTime($this->k_es_tgl_panen->CurrentValue, 5);
		$this->k_es_perhektar->CurrentValue = $this->k_es_perhektar->FormValue;
		$this->k_ket->CurrentValue = $this->k_ket->FormValue;
		$this->k_cat->CurrentValue = $this->k_cat->FormValue;
		$this->k_titik_koordinat->CurrentValue = $this->k_titik_koordinat->FormValue;
		$this->k_harga_bibit->CurrentValue = $this->k_harga_bibit->FormValue;
		$this->k_bayar_bibit->CurrentValue = $this->k_bayar_bibit->FormValue;
		$this->k_pinjaman->CurrentValue = $this->k_pinjaman->FormValue;
		$this->k_bayar_pinjaman->CurrentValue = $this->k_bayar_pinjaman->FormValue;
		$this->k_sisa_hutang->CurrentValue = $this->k_sisa_hutang->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $Security, $Language;
		$sFilter = $this->KeyFilter();

		// Call Row Selecting event
		$this->Row_Selecting($sFilter);

		// Load SQL based on filter
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$conn = &$this->Connection();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql, $conn);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues($rs = NULL) {
		if ($rs && !$rs->EOF)
			$row = $rs->fields;
		else
			$row = $this->NewRow(); 

		// Call Row Selected event
		$this->Row_Selected($row);
		if (!$rs || $rs->EOF)
			return;
		$this->k_id->setDbValue($row['k_id']);
		$this->k_id_kontrak->setDbValue($row['k_id_kontrak']);
		$this->k_id_lama->setDbValue($row['k_id_lama']);
		$this->k_no_kontrak->setDbValue($row['k_no_kontrak']);
		$this->k_luas_lahan->setDbValue($row['k_luas_lahan']);
		$this->pet_id->setDbValue($row['pet_id']);
		if (array_key_exists('EV__pet_id', $rs->fields)) {
			$this->pet_id->VirtualValue = $rs->fields('EV__pet_id'); // Set up virtual field value
		} else {
			$this->pet_id->VirtualValue = ""; // Clear value
		}
		$this->koord_id->setDbValue($row['koord_id']);
		if (array_key_exists('EV__koord_id', $rs->fields)) {
			$this->koord_id->VirtualValue = $rs->fields('EV__koord_id'); // Set up virtual field value
		} else {
			$this->koord_id->VirtualValue = ""; // Clear value
		}
		$this->kk_id->setDbValue($row['kk_id']);
		$this->prov_id->setDbValue($row['prov_id']);
		if (array_key_exists('EV__prov_id', $rs->fields)) {
			$this->prov_id->VirtualValue = $rs->fields('EV__prov_id'); // Set up virtual field value
		} else {
			$this->prov_id->VirtualValue = ""; // Clear value
		}
		$this->kab_id->setDbValue($row['kab_id']);
		if (array_key_exists('EV__kab_id', $rs->fields)) {
			$this->kab_id->VirtualValue = $rs->fields('EV__kab_id'); // Set up virtual field value
		} else {
			$this->kab_id->VirtualValue = ""; // Clear value
		}
		$this->kec_id->setDbValue($row['kec_id']);
		if (array_key_exists('EV__kec_id', $rs->fields)) {
			$this->kec_id->VirtualValue = $rs->fields('EV__kec_id'); // Set up virtual field value
		} else {
			$this->kec_id->VirtualValue = ""; // Clear value
		}
		$this->desa_id->setDbValue($row['desa_id']);
		if (array_key_exists('EV__desa_id', $rs->fields)) {
			$this->desa_id->VirtualValue = $rs->fields('EV__desa_id'); // Set up virtual field value
		} else {
			$this->desa_id->VirtualValue = ""; // Clear value
		}
		$this->blok_id->setDbValue($row['blok_id']);
		if (array_key_exists('EV__blok_id', $rs->fields)) {
			$this->blok_id->VirtualValue = $rs->fields('EV__blok_id'); // Set up virtual field value
		} else {
			$this->blok_id->VirtualValue = ""; // Clear value
		}
		$this->sos_id->setDbValue($row['sos_id']);
		if (array_key_exists('EV__sos_id', $rs->fields)) {
			$this->sos_id->VirtualValue = $rs->fields('EV__sos_id'); // Set up virtual field value
		} else {
			$this->sos_id->VirtualValue = ""; // Clear value
		}
		$this->var_id->setDbValue($row['var_id']);
		$this->co_id->setDbValue($row['co_id']);
		$this->k_jumlah_bibit->setDbValue($row['k_jumlah_bibit']);
		$this->k_asal_bibit->setDbValue($row['k_asal_bibit']);
		$this->k_tgl_tanam->setDbValue($row['k_tgl_tanam']);
		$this->k_es_tgl_panen->setDbValue($row['k_es_tgl_panen']);
		$this->k_ak_tgl_datang->setDbValue($row['k_ak_tgl_datang']);
		$this->k_es_qty->setDbValue($row['k_es_qty']);
		$this->k_ak_qty->setDbValue($row['k_ak_qty']);
		$this->k_es_perhektar->setDbValue($row['k_es_perhektar']);
		$this->k_ak_perhektar->setDbValue($row['k_ak_perhektar']);
		$this->k_skor->setDbValue($row['k_skor']);
		$this->k_ket->setDbValue($row['k_ket']);
		$this->k_cat->setDbValue($row['k_cat']);
		$this->k_titik_koordinat->setDbValue($row['k_titik_koordinat']);
		$this->k_foto_lahan->Upload->DbValue = $row['k_foto_lahan'];
		$this->k_foto_lahan->setDbValue($this->k_foto_lahan->Upload->DbValue);
		$this->k_dok->Upload->DbValue = $row['k_dok'];
		$this->k_dok->setDbValue($this->k_dok->Upload->DbValue);
		$this->k_harga_bibit->setDbValue($row['k_harga_bibit']);
		$this->k_bayar_bibit->setDbValue($row['k_bayar_bibit']);
		$this->k_pinjaman->setDbValue($row['k_pinjaman']);
		$this->k_bayar_pinjaman->setDbValue($row['k_bayar_pinjaman']);
		$this->k_sisa_hutang->setDbValue($row['k_sisa_hutang']);
	}

	// Return a row with default values
	function NewRow() {
		$this->LoadDefaultValues();
		$row = array();
		$row['k_id'] = $this->k_id->CurrentValue;
		$row['k_id_kontrak'] = $this->k_id_kontrak->CurrentValue;
		$row['k_id_lama'] = $this->k_id_lama->CurrentValue;
		$row['k_no_kontrak'] = $this->k_no_kontrak->CurrentValue;
		$row['k_luas_lahan'] = $this->k_luas_lahan->CurrentValue;
		$row['pet_id'] = $this->pet_id->CurrentValue;
		$row['koord_id'] = $this->koord_id->CurrentValue;
		$row['kk_id'] = $this->kk_id->CurrentValue;
		$row['prov_id'] = $this->prov_id->CurrentValue;
		$row['kab_id'] = $this->kab_id->CurrentValue;
		$row['kec_id'] = $this->kec_id->CurrentValue;
		$row['desa_id'] = $this->desa_id->CurrentValue;
		$row['blok_id'] = $this->blok_id->CurrentValue;
		$row['sos_id'] = $this->sos_id->CurrentValue;
		$row['var_id'] = $this->var_id->CurrentValue;
		$row['co_id'] = $this->co_id->CurrentValue;
		$row['k_jumlah_bibit'] = $this->k_jumlah_bibit->CurrentValue;
		$row['k_asal_bibit'] = $this->k_asal_bibit->CurrentValue;
		$row['k_tgl_tanam'] = $this->k_tgl_tanam->CurrentValue;
		$row['k_es_tgl_panen'] = $this->k_es_tgl_panen->CurrentValue;
		$row['k_ak_tgl_datang'] = $this->k_ak_tgl_datang->CurrentValue;
		$row['k_es_qty'] = $this->k_es_qty->CurrentValue;
		$row['k_ak_qty'] = $this->k_ak_qty->CurrentValue;
		$row['k_es_perhektar'] = $this->k_es_perhektar->CurrentValue;
		$row['k_ak_perhektar'] = $this->k_ak_perhektar->CurrentValue;
		$row['k_skor'] = $this->k_skor->CurrentValue;
		$row['k_ket'] = $this->k_ket->CurrentValue;
		$row['k_cat'] = $this->k_cat->CurrentValue;
		$row['k_titik_koordinat'] = $this->k_titik_koordinat->CurrentValue;
		$row['k_foto_lahan'] = $this->k_foto_lahan->Upload->DbValue;
		$row['k_dok'] = $this->k_dok->Upload->DbValue;
		$row['k_harga_bibit'] = $this->k_harga_bibit->CurrentValue;
		$row['k_bayar_bibit'] = $this->k_bayar_bibit->CurrentValue;
		$row['k_pinjaman'] = $this->k_pinjaman->CurrentValue;
		$row['k_bayar_pinjaman'] = $this->k_bayar_pinjaman->CurrentValue;
		$row['k_sisa_hutang'] = $this->k_sisa_hutang->CurrentValue;
		return $row;
	}

	// Load DbValue from recordset
	function LoadDbValues(&$rs) {
		if (!$rs || !is_array($rs) && $rs->EOF)
			return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->k_id->DbValue = $row['k_id'];
		$this->k_id_kontrak->DbValue = $row['k_id_kontrak'];
		$this->k_id_lama->DbValue = $row['k_id_lama'];
		$this->k_no_kontrak->DbValue = $row['k_no_kontrak'];
		$this->k_luas_lahan->DbValue = $row['k_luas_lahan'];
		$this->pet_id->DbValue = $row['pet_id'];
		$this->koord_id->DbValue = $row['koord_id'];
		$this->kk_id->DbValue = $row['kk_id'];
		$this->prov_id->DbValue = $row['prov_id'];
		$this->kab_id->DbValue = $row['kab_id'];
		$this->kec_id->DbValue = $row['kec_id'];
		$this->desa_id->DbValue = $row['desa_id'];
		$this->blok_id->DbValue = $row['blok_id'];
		$this->sos_id->DbValue = $row['sos_id'];
		$this->var_id->DbValue = $row['var_id'];
		$this->co_id->DbValue = $row['co_id'];
		$this->k_jumlah_bibit->DbValue = $row['k_jumlah_bibit'];
		$this->k_asal_bibit->DbValue = $row['k_asal_bibit'];
		$this->k_tgl_tanam->DbValue = $row['k_tgl_tanam'];
		$this->k_es_tgl_panen->DbValue = $row['k_es_tgl_panen'];
		$this->k_ak_tgl_datang->DbValue = $row['k_ak_tgl_datang'];
		$this->k_es_qty->DbValue = $row['k_es_qty'];
		$this->k_ak_qty->DbValue = $row['k_ak_qty'];
		$this->k_es_perhektar->DbValue = $row['k_es_perhektar'];
		$this->k_ak_perhektar->DbValue = $row['k_ak_perhektar'];
		$this->k_skor->DbValue = $row['k_skor'];
		$this->k_ket->DbValue = $row['k_ket'];
		$this->k_cat->DbValue = $row['k_cat'];
		$this->k_titik_koordinat->DbValue = $row['k_titik_koordinat'];
		$this->k_foto_lahan->Upload->DbValue = $row['k_foto_lahan'];
		$this->k_dok->Upload->DbValue = $row['k_dok'];
		$this->k_harga_bibit->DbValue = $row['k_harga_bibit'];
		$this->k_bayar_bibit->DbValue = $row['k_bayar_bibit'];
		$this->k_pinjaman->DbValue = $row['k_pinjaman'];
		$this->k_bayar_pinjaman->DbValue = $row['k_bayar_pinjaman'];
		$this->k_sisa_hutang->DbValue = $row['k_sisa_hutang'];
	}

	// Load old record
	function LoadOldRecord() {

		// Load key values from Session
		$bValidKey = TRUE;
		if (strval($this->getKey("k_id")) <> "")
			$this->k_id->CurrentValue = $this->getKey("k_id"); // k_id
		else
			$bValidKey = FALSE;

		// Load old record
		$this->OldRecordset = NULL;
		if ($bValidKey) {
			$this->CurrentFilter = $this->KeyFilter();
			$sSql = $this->SQL();
			$conn = &$this->Connection();
			$this->OldRecordset = ew_LoadRecordset($sSql, $conn);
		}
		$this->LoadRowValues($this->OldRecordset); // Load row values
		return $bValidKey;
	}

	// Render row values based on field settings
	function RenderRow() {
		global $Security, $Language, $gsLanguage;

		// Initialize URLs
		// Call Row_Rendering event

		$this->Row_Rendering();

		// Common render codes for all row types
		// k_id
		// k_id_kontrak
		// k_id_lama
		// k_no_kontrak
		// 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

		if ($this->RowType == EW_ROWTYPE_VIEW) { // View row

		// 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_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_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_es_perhektar
			$this->k_es_perhektar->LinkCustomAttributes = "";
			$this->k_es_perhektar->HrefValue = "";
			$this->k_es_perhektar->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 = "";
		} elseif ($this->RowType == EW_ROWTYPE_ADD) { // Add row

			// k_luas_lahan
			$this->k_luas_lahan->EditAttrs["class"] = "form-control";
			$this->k_luas_lahan->EditCustomAttributes = "";
			$this->k_luas_lahan->EditValue = ew_HtmlEncode($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 = ew_HtmlEncode($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 = ew_HtmlEncode($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 = "";
			if (trim(strval($this->kk_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, `koord_id` AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$rowswrk = count($arwrk);
			for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
				$arwrk[$rowcntwrk][2] = ew_FormatDateTime($arwrk[$rowcntwrk][2], 5);
				$arwrk[$rowcntwrk][3] = ew_FormatDateTime($arwrk[$rowcntwrk][3], 5);
			}
			$this->kk_id->EditValue = $arwrk;

			// prov_id
			$this->prov_id->EditAttrs["class"] = "form-control";
			$this->prov_id->EditCustomAttributes = "";
			if (trim(strval($this->prov_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->prov_id->EditValue = $arwrk;

			// kab_id
			$this->kab_id->EditAttrs["class"] = "form-control";
			$this->kab_id->EditCustomAttributes = "";
			if (trim(strval($this->kab_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, `kab_prov_id` AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->kab_id->EditValue = $arwrk;

			// kec_id
			$this->kec_id->EditAttrs["class"] = "form-control";
			$this->kec_id->EditCustomAttributes = "";
			if (trim(strval($this->kec_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, `kec_prov_id` AS `SelectFilterFld`, `kec_kab_id` AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->kec_id->EditValue = $arwrk;

			// desa_id
			$this->desa_id->EditAttrs["class"] = "form-control";
			$this->desa_id->EditCustomAttributes = "";
			if (trim(strval($this->desa_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, `desa_prov_id` AS `SelectFilterFld`, `desa_kab_id` AS `SelectFilterFld2`, `desa_kec_id` AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->desa_id->EditValue = $arwrk;

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

			// sos_id
			$this->sos_id->EditAttrs["class"] = "form-control";
			$this->sos_id->EditCustomAttributes = "";
			if (trim(strval($this->sos_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$rowswrk = count($arwrk);
			for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
				$arwrk[$rowcntwrk][2] = ew_FormatDateTime($arwrk[$rowcntwrk][2], 0);
			}
			$this->sos_id->EditValue = $arwrk;

			// var_id
			$this->var_id->EditAttrs["class"] = "form-control";
			$this->var_id->EditCustomAttributes = "";
			if (trim(strval($this->var_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->var_id->EditValue = $arwrk;

			// co_id
			$this->co_id->EditAttrs["class"] = "form-control";
			$this->co_id->EditCustomAttributes = "";
			if (trim(strval($this->co_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$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`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			$this->co_id->EditValue = $arwrk;

			// k_jumlah_bibit
			$this->k_jumlah_bibit->EditAttrs["class"] = "form-control";
			$this->k_jumlah_bibit->EditCustomAttributes = "";
			$this->k_jumlah_bibit->EditValue = ew_HtmlEncode($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 = ew_HtmlEncode($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_HtmlEncode(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_HtmlEncode(ew_FormatDateTime($this->k_es_tgl_panen->CurrentValue, 5));
			$this->k_es_tgl_panen->PlaceHolder = ew_RemoveHtml($this->k_es_tgl_panen->FldCaption());

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

			// k_ket
			$this->k_ket->EditAttrs["class"] = "form-control";
			$this->k_ket->EditCustomAttributes = "";
			$this->k_ket->EditValue = ew_HtmlEncode($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 = ew_HtmlEncode($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 = ew_HtmlEncode($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;
			if (($this->CurrentAction == "I" || $this->CurrentAction == "C") && !$this->EventCancelled) ew_RenderUploadField($this->k_foto_lahan);

			// 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;
			if (($this->CurrentAction == "I" || $this->CurrentAction == "C") && !$this->EventCancelled) ew_RenderUploadField($this->k_dok);

			// k_harga_bibit
			$this->k_harga_bibit->EditAttrs["class"] = "form-control";
			$this->k_harga_bibit->EditCustomAttributes = "";
			$this->k_harga_bibit->EditValue = ew_HtmlEncode($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 = ew_HtmlEncode($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 = ew_HtmlEncode($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 = ew_HtmlEncode($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 = ew_HtmlEncode($this->k_sisa_hutang->CurrentValue);
			$this->k_sisa_hutang->PlaceHolder = ew_RemoveHtml($this->k_sisa_hutang->FldCaption());

			// Add refer script
			// k_luas_lahan

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

			// 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 = "";
			}

			// 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 = "";
			}

			// 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 = "";
			}

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

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

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

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

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

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

			// 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 = "";
			}

			// 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 = "";
			}

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

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

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

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

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

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

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

			// 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->EditValue) && !is_array($this->k_titik_koordinat->EditValue)) ? ew_RemoveHtml($this->k_titik_koordinat->EditValue) : $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 = "";
			}

			// 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;

			// 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;

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

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

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

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

			// k_sisa_hutang
			$this->k_sisa_hutang->LinkCustomAttributes = "";
			$this->k_sisa_hutang->HrefValue = "";
		}
		if ($this->RowType == EW_ROWTYPE_ADD || $this->RowType == EW_ROWTYPE_EDIT || $this->RowType == EW_ROWTYPE_SEARCH) // Add/Edit/Search row
			$this->SetupFieldTitles();

		// Call Row Rendered event
		if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!$this->k_luas_lahan->FldIsDetailKey && !is_null($this->k_luas_lahan->FormValue) && $this->k_luas_lahan->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_luas_lahan->FldCaption(), $this->k_luas_lahan->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_luas_lahan->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_luas_lahan->FldErrMsg());
		}
		if (!$this->pet_id->FldIsDetailKey && !is_null($this->pet_id->FormValue) && $this->pet_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->pet_id->FldCaption(), $this->pet_id->ReqErrMsg));
		}
		if (!$this->prov_id->FldIsDetailKey && !is_null($this->prov_id->FormValue) && $this->prov_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->prov_id->FldCaption(), $this->prov_id->ReqErrMsg));
		}
		if (!$this->kab_id->FldIsDetailKey && !is_null($this->kab_id->FormValue) && $this->kab_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->kab_id->FldCaption(), $this->kab_id->ReqErrMsg));
		}
		if (!$this->kec_id->FldIsDetailKey && !is_null($this->kec_id->FormValue) && $this->kec_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->kec_id->FldCaption(), $this->kec_id->ReqErrMsg));
		}
		if (!$this->desa_id->FldIsDetailKey && !is_null($this->desa_id->FormValue) && $this->desa_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->desa_id->FldCaption(), $this->desa_id->ReqErrMsg));
		}
		if (!$this->var_id->FldIsDetailKey && !is_null($this->var_id->FormValue) && $this->var_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->var_id->FldCaption(), $this->var_id->ReqErrMsg));
		}
		if (!$this->co_id->FldIsDetailKey && !is_null($this->co_id->FormValue) && $this->co_id->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->co_id->FldCaption(), $this->co_id->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_jumlah_bibit->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_jumlah_bibit->FldErrMsg());
		}
		if (!$this->k_tgl_tanam->FldIsDetailKey && !is_null($this->k_tgl_tanam->FormValue) && $this->k_tgl_tanam->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_tgl_tanam->FldCaption(), $this->k_tgl_tanam->ReqErrMsg));
		}
		if (!ew_CheckDate($this->k_tgl_tanam->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_tgl_tanam->FldErrMsg());
		}
		if (!$this->k_es_tgl_panen->FldIsDetailKey && !is_null($this->k_es_tgl_panen->FormValue) && $this->k_es_tgl_panen->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_es_tgl_panen->FldCaption(), $this->k_es_tgl_panen->ReqErrMsg));
		}
		if (!ew_CheckDate($this->k_es_tgl_panen->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_es_tgl_panen->FldErrMsg());
		}
		if (!$this->k_es_perhektar->FldIsDetailKey && !is_null($this->k_es_perhektar->FormValue) && $this->k_es_perhektar->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_es_perhektar->FldCaption(), $this->k_es_perhektar->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_es_perhektar->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_es_perhektar->FldErrMsg());
		}
		if (!$this->k_harga_bibit->FldIsDetailKey && !is_null($this->k_harga_bibit->FormValue) && $this->k_harga_bibit->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_harga_bibit->FldCaption(), $this->k_harga_bibit->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_harga_bibit->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_harga_bibit->FldErrMsg());
		}
		if (!$this->k_bayar_bibit->FldIsDetailKey && !is_null($this->k_bayar_bibit->FormValue) && $this->k_bayar_bibit->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_bayar_bibit->FldCaption(), $this->k_bayar_bibit->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_bayar_bibit->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_bayar_bibit->FldErrMsg());
		}
		if (!$this->k_pinjaman->FldIsDetailKey && !is_null($this->k_pinjaman->FormValue) && $this->k_pinjaman->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_pinjaman->FldCaption(), $this->k_pinjaman->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_pinjaman->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_pinjaman->FldErrMsg());
		}
		if (!$this->k_bayar_pinjaman->FldIsDetailKey && !is_null($this->k_bayar_pinjaman->FormValue) && $this->k_bayar_pinjaman->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_bayar_pinjaman->FldCaption(), $this->k_bayar_pinjaman->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_bayar_pinjaman->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_bayar_pinjaman->FldErrMsg());
		}
		if (!$this->k_sisa_hutang->FldIsDetailKey && !is_null($this->k_sisa_hutang->FormValue) && $this->k_sisa_hutang->FormValue == "") {
			ew_AddMessage($gsFormError, str_replace("%s", $this->k_sisa_hutang->FldCaption(), $this->k_sisa_hutang->ReqErrMsg));
		}
		if (!ew_CheckInteger($this->k_sisa_hutang->FormValue)) {
			ew_AddMessage($gsFormError, $this->k_sisa_hutang->FldErrMsg());
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			ew_AddMessage($gsFormError, $sFormCustomError);
		}
		return $ValidateForm;
	}

	// Add record
	function AddRow($rsold = NULL) {
		global $Language, $Security;
		$conn = &$this->Connection();

		// Load db values from rsold
		$this->LoadDbValues($rsold);
		if ($rsold) {
			$this->k_foto_lahan->OldUploadPath = "foto_lahan";
			$this->k_foto_lahan->UploadPath = $this->k_foto_lahan->OldUploadPath;
			$this->k_dok->OldUploadPath = "dokumen_kontrak_lahan";
			$this->k_dok->UploadPath = $this->k_dok->OldUploadPath;
		}
		$rsnew = array();

		// k_luas_lahan
		$this->k_luas_lahan->SetDbValueDef($rsnew, $this->k_luas_lahan->CurrentValue, 0, FALSE);

		// pet_id
		$this->pet_id->SetDbValueDef($rsnew, $this->pet_id->CurrentValue, NULL, FALSE);

		// koord_id
		$this->koord_id->SetDbValueDef($rsnew, $this->koord_id->CurrentValue, NULL, FALSE);

		// kk_id
		$this->kk_id->SetDbValueDef($rsnew, $this->kk_id->CurrentValue, NULL, FALSE);

		// prov_id
		$this->prov_id->SetDbValueDef($rsnew, $this->prov_id->CurrentValue, NULL, FALSE);

		// kab_id
		$this->kab_id->SetDbValueDef($rsnew, $this->kab_id->CurrentValue, NULL, FALSE);

		// kec_id
		$this->kec_id->SetDbValueDef($rsnew, $this->kec_id->CurrentValue, NULL, FALSE);

		// desa_id
		$this->desa_id->SetDbValueDef($rsnew, $this->desa_id->CurrentValue, NULL, FALSE);

		// blok_id
		$this->blok_id->SetDbValueDef($rsnew, $this->blok_id->CurrentValue, NULL, FALSE);

		// sos_id
		$this->sos_id->SetDbValueDef($rsnew, $this->sos_id->CurrentValue, NULL, FALSE);

		// var_id
		$this->var_id->SetDbValueDef($rsnew, $this->var_id->CurrentValue, NULL, FALSE);

		// co_id
		$this->co_id->SetDbValueDef($rsnew, $this->co_id->CurrentValue, NULL, FALSE);

		// k_jumlah_bibit
		$this->k_jumlah_bibit->SetDbValueDef($rsnew, $this->k_jumlah_bibit->CurrentValue, NULL, FALSE);

		// k_asal_bibit
		$this->k_asal_bibit->SetDbValueDef($rsnew, $this->k_asal_bibit->CurrentValue, NULL, FALSE);

		// k_tgl_tanam
		$this->k_tgl_tanam->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->k_tgl_tanam->CurrentValue, 5), NULL, FALSE);

		// k_es_tgl_panen
		$this->k_es_tgl_panen->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->k_es_tgl_panen->CurrentValue, 5), NULL, FALSE);

		// k_es_perhektar
		$this->k_es_perhektar->SetDbValueDef($rsnew, $this->k_es_perhektar->CurrentValue, NULL, FALSE);

		// k_ket
		$this->k_ket->SetDbValueDef($rsnew, $this->k_ket->CurrentValue, NULL, FALSE);

		// k_cat
		$this->k_cat->SetDbValueDef($rsnew, $this->k_cat->CurrentValue, NULL, FALSE);

		// k_titik_koordinat
		$this->k_titik_koordinat->SetDbValueDef($rsnew, $this->k_titik_koordinat->CurrentValue, NULL, FALSE);

		// k_foto_lahan
		if ($this->k_foto_lahan->Visible && !$this->k_foto_lahan->Upload->KeepFile) {
			$this->k_foto_lahan->Upload->DbValue = ""; // No need to delete old file
			if ($this->k_foto_lahan->Upload->FileName == "") {
				$rsnew['k_foto_lahan'] = NULL;
			} else {
				$rsnew['k_foto_lahan'] = $this->k_foto_lahan->Upload->FileName;
			}
			$this->k_foto_lahan->ImageWidth = 400; // Resize width
			$this->k_foto_lahan->ImageHeight = 300; // Resize height
		}

		// k_dok
		if ($this->k_dok->Visible && !$this->k_dok->Upload->KeepFile) {
			$this->k_dok->Upload->DbValue = ""; // No need to delete old file
			if ($this->k_dok->Upload->FileName == "") {
				$rsnew['k_dok'] = NULL;
			} else {
				$rsnew['k_dok'] = $this->k_dok->Upload->FileName;
			}
			$this->k_dok->ImageWidth = 420; // Resize width
			$this->k_dok->ImageHeight = 700; // Resize height
		}

		// k_harga_bibit
		$this->k_harga_bibit->SetDbValueDef($rsnew, $this->k_harga_bibit->CurrentValue, 0, FALSE);

		// k_bayar_bibit
		$this->k_bayar_bibit->SetDbValueDef($rsnew, $this->k_bayar_bibit->CurrentValue, 0, FALSE);

		// k_pinjaman
		$this->k_pinjaman->SetDbValueDef($rsnew, $this->k_pinjaman->CurrentValue, 0, FALSE);

		// k_bayar_pinjaman
		$this->k_bayar_pinjaman->SetDbValueDef($rsnew, $this->k_bayar_pinjaman->CurrentValue, 0, FALSE);

		// k_sisa_hutang
		$this->k_sisa_hutang->SetDbValueDef($rsnew, $this->k_sisa_hutang->CurrentValue, 0, FALSE);
		if ($this->k_foto_lahan->Visible && !$this->k_foto_lahan->Upload->KeepFile) {
			$this->k_foto_lahan->UploadPath = "foto_lahan";
			$OldFiles = ew_Empty($this->k_foto_lahan->Upload->DbValue) ? array() : explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_foto_lahan->Upload->DbValue));
			if (!ew_Empty($this->k_foto_lahan->Upload->FileName)) {
				$NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_foto_lahan->Upload->FileName));
				$NewFileCount = count($NewFiles);
				for ($i = 0; $i < $NewFileCount; $i++) {
					$fldvar = ($this->k_foto_lahan->Upload->Index < 0) ? $this->k_foto_lahan->FldVar : substr($this->k_foto_lahan->FldVar, 0, 1) . $this->k_foto_lahan->Upload->Index . substr($this->k_foto_lahan->FldVar, 1);
					if ($NewFiles[$i] <> "") {
						$file = $NewFiles[$i];
						if (file_exists(ew_UploadTempPath($fldvar, $this->k_foto_lahan->TblVar) . $file)) {
							$OldFileFound = FALSE;
							$OldFileCount = count($OldFiles);
							for ($j = 0; $j < $OldFileCount; $j++) {
								$file1 = $OldFiles[$j];
								if ($file1 == $file) { // Old file found, no need to delete anymore
									unset($OldFiles[$j]);
									$OldFileFound = TRUE;
									break;
								}
							}
							if ($OldFileFound) // No need to check if file exists further
								continue;
							$file1 = ew_UploadFileNameEx($this->k_foto_lahan->PhysicalUploadPath(), $file); // Get new file name
							if ($file1 <> $file) { // Rename temp file
								while (file_exists(ew_UploadTempPath($fldvar, $this->k_foto_lahan->TblVar) . $file1) || file_exists($this->k_foto_lahan->PhysicalUploadPath() . $file1)) // Make sure no file name clash
									$file1 = ew_UniqueFilename($this->k_foto_lahan->PhysicalUploadPath(), $file1, TRUE); // Use indexed name
								rename(ew_UploadTempPath($fldvar, $this->k_foto_lahan->TblVar) . $file, ew_UploadTempPath($fldvar, $this->k_foto_lahan->TblVar) . $file1);
								$NewFiles[$i] = $file1;
							}
						}
					}
				}
				$this->k_foto_lahan->Upload->DbValue = empty($OldFiles) ? "" : implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $OldFiles);
				$this->k_foto_lahan->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
				$this->k_foto_lahan->SetDbValueDef($rsnew, $this->k_foto_lahan->Upload->FileName, NULL, FALSE);
			}
		}
		if ($this->k_dok->Visible && !$this->k_dok->Upload->KeepFile) {
			$this->k_dok->UploadPath = "dokumen_kontrak_lahan";
			$OldFiles = ew_Empty($this->k_dok->Upload->DbValue) ? array() : explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_dok->Upload->DbValue));
			if (!ew_Empty($this->k_dok->Upload->FileName)) {
				$NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_dok->Upload->FileName));
				$NewFileCount = count($NewFiles);
				for ($i = 0; $i < $NewFileCount; $i++) {
					$fldvar = ($this->k_dok->Upload->Index < 0) ? $this->k_dok->FldVar : substr($this->k_dok->FldVar, 0, 1) . $this->k_dok->Upload->Index . substr($this->k_dok->FldVar, 1);
					if ($NewFiles[$i] <> "") {
						$file = $NewFiles[$i];
						if (file_exists(ew_UploadTempPath($fldvar, $this->k_dok->TblVar) . $file)) {
							$OldFileFound = FALSE;
							$OldFileCount = count($OldFiles);
							for ($j = 0; $j < $OldFileCount; $j++) {
								$file1 = $OldFiles[$j];
								if ($file1 == $file) { // Old file found, no need to delete anymore
									unset($OldFiles[$j]);
									$OldFileFound = TRUE;
									break;
								}
							}
							if ($OldFileFound) // No need to check if file exists further
								continue;
							$file1 = ew_UploadFileNameEx($this->k_dok->PhysicalUploadPath(), $file); // Get new file name
							if ($file1 <> $file) { // Rename temp file
								while (file_exists(ew_UploadTempPath($fldvar, $this->k_dok->TblVar) . $file1) || file_exists($this->k_dok->PhysicalUploadPath() . $file1)) // Make sure no file name clash
									$file1 = ew_UniqueFilename($this->k_dok->PhysicalUploadPath(), $file1, TRUE); // Use indexed name
								rename(ew_UploadTempPath($fldvar, $this->k_dok->TblVar) . $file, ew_UploadTempPath($fldvar, $this->k_dok->TblVar) . $file1);
								$NewFiles[$i] = $file1;
							}
						}
					}
				}
				$this->k_dok->Upload->DbValue = empty($OldFiles) ? "" : implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $OldFiles);
				$this->k_dok->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
				$this->k_dok->SetDbValueDef($rsnew, $this->k_dok->Upload->FileName, NULL, FALSE);
			}
		}

		// Call Row Inserting event
		$rs = ($rsold == NULL) ? NULL : $rsold->fields;
		$bInsertRow = $this->Row_Inserting($rs, $rsnew);
		if ($bInsertRow) {
			$conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
			$AddRow = $this->Insert($rsnew);
			$conn->raiseErrorFn = '';
			if ($AddRow) {
				if ($this->k_foto_lahan->Visible && !$this->k_foto_lahan->Upload->KeepFile) {
					$OldFiles = ew_Empty($this->k_foto_lahan->Upload->DbValue) ? array() : explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_foto_lahan->Upload->DbValue));
					if (!ew_Empty($this->k_foto_lahan->Upload->FileName)) {
						$NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->k_foto_lahan->Upload->FileName);
						$NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['k_foto_lahan']);
						$NewFileCount = count($NewFiles);
						for ($i = 0; $i < $NewFileCount; $i++) {
							$fldvar = ($this->k_foto_lahan->Upload->Index < 0) ? $this->k_foto_lahan->FldVar : substr($this->k_foto_lahan->FldVar, 0, 1) . $this->k_foto_lahan->Upload->Index . substr($this->k_foto_lahan->FldVar, 1);
							if ($NewFiles[$i] <> "") {
								$file = ew_UploadTempPath($fldvar, $this->k_foto_lahan->TblVar) . $NewFiles[$i];
								if (file_exists($file)) {
									if (@$NewFiles2[$i] <> "") // Use correct file name
										$NewFiles[$i] = $NewFiles2[$i];
									if (!$this->k_foto_lahan->Upload->ResizeAndSaveToFile($this->k_foto_lahan->ImageWidth, $this->k_foto_lahan->ImageHeight, EW_THUMBNAIL_DEFAULT_QUALITY, $NewFiles[$i], TRUE, $i)) {
										$this->setFailureMessage($Language->Phrase("UploadErrMsg7"));
										return FALSE;
									}
								}
							}
						}
					} else {
						$NewFiles = array();
					}
					$OldFileCount = count($OldFiles);
					for ($i = 0; $i < $OldFileCount; $i++) {
						if ($OldFiles[$i] <> "" && !in_array($OldFiles[$i], $NewFiles))
							@unlink($this->k_foto_lahan->OldPhysicalUploadPath() . $OldFiles[$i]);
					}
				}
				if ($this->k_dok->Visible && !$this->k_dok->Upload->KeepFile) {
					$OldFiles = ew_Empty($this->k_dok->Upload->DbValue) ? array() : explode(EW_MULTIPLE_UPLOAD_SEPARATOR, strval($this->k_dok->Upload->DbValue));
					if (!ew_Empty($this->k_dok->Upload->FileName)) {
						$NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->k_dok->Upload->FileName);
						$NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['k_dok']);
						$NewFileCount = count($NewFiles);
						for ($i = 0; $i < $NewFileCount; $i++) {
							$fldvar = ($this->k_dok->Upload->Index < 0) ? $this->k_dok->FldVar : substr($this->k_dok->FldVar, 0, 1) . $this->k_dok->Upload->Index . substr($this->k_dok->FldVar, 1);
							if ($NewFiles[$i] <> "") {
								$file = ew_UploadTempPath($fldvar, $this->k_dok->TblVar) . $NewFiles[$i];
								if (file_exists($file)) {
									if (@$NewFiles2[$i] <> "") // Use correct file name
										$NewFiles[$i] = $NewFiles2[$i];
									if (!$this->k_dok->Upload->ResizeAndSaveToFile($this->k_dok->ImageWidth, $this->k_dok->ImageHeight, EW_THUMBNAIL_DEFAULT_QUALITY, $NewFiles[$i], TRUE, $i)) {
										$this->setFailureMessage($Language->Phrase("UploadErrMsg7"));
										return FALSE;
									}
								}
							}
						}
					} else {
						$NewFiles = array();
					}
					$OldFileCount = count($OldFiles);
					for ($i = 0; $i < $OldFileCount; $i++) {
						if ($OldFiles[$i] <> "" && !in_array($OldFiles[$i], $NewFiles))
							@unlink($this->k_dok->OldPhysicalUploadPath() . $OldFiles[$i]);
					}
				}
			}
		} else {
			if ($this->getSuccessMessage() <> "" || $this->getFailureMessage() <> "") {

				// Use the message, do nothing
			} elseif ($this->CancelMessage <> "") {
				$this->setFailureMessage($this->CancelMessage);
				$this->CancelMessage = "";
			} else {
				$this->setFailureMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {

			// Call Row Inserted event
			$rs = ($rsold == NULL) ? NULL : $rsold->fields;
			$this->Row_Inserted($rs, $rsnew);
		}

		// k_foto_lahan
		ew_CleanUploadTempPath($this->k_foto_lahan, $this->k_foto_lahan->Upload->Index);

		// k_dok
		ew_CleanUploadTempPath($this->k_dok, $this->k_dok->Upload->Index);
		return $AddRow;
	}

	// Set up Breadcrumb
	function SetupBreadcrumb() {
		global $Breadcrumb, $Language;
		$Breadcrumb = new cBreadcrumb();
		$url = substr(ew_CurrentUrl(), strrpos(ew_CurrentUrl(), "/")+1);
		$Breadcrumb->Add("list", $this->TableVar, $this->AddMasterUrl("kontraklist.php"), "", $this->TableVar, TRUE);
		$PageId = ($this->CurrentAction == "C") ? "Copy" : "Add";
		$Breadcrumb->Add("add", $PageId, $url);
	}

	// Setup lookup filters of a field
	function SetupLookupFilters($fld, $pageId = null) {
		global $gsLanguage;
		$pageId = $pageId ?: $this->PageID;
		switch ($fld->FldVar) {
		case "x_pet_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `pet_id` AS `LinkFld`, `pet_nama` AS `DispFld`, `pet_alamat` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `petani`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`pet_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->pet_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `pet_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_koord_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `koord_id` AS `LinkFld`, `koord_nama` AS `DispFld`, `koord_alamat` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `koord`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`koord_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->koord_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `koord_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_kk_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `kk_id` AS `LinkFld`, `kk_periode` AS `DispFld`, `kk_tgl_mulai` AS `Disp2Fld`, `kk_tgl_akhir` AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kontrak_koord`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array("df2" => "5", "df3" => "5");
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`kk_id` IN ({filter_value})', "t0" => "3", "fn0" => "", "f1" => '`koord_id` IN ({filter_value})', "t1" => "3", "fn1" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->kk_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_prov_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `prov_id` AS `LinkFld`, `prov_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `prov`";
			$sWhereWrk = "";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`prov_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->prov_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `prov_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_kab_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `kab_id` AS `LinkFld`, `kab_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kab`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`kab_id` IN ({filter_value})', "t0" => "3", "fn0" => "", "f1" => '`kab_prov_id` IN ({filter_value})', "t1" => "3", "fn1" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->kab_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `kab_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_kec_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `kec_id` AS `LinkFld`, `kec_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kec`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`kec_id` IN ({filter_value})', "t0" => "3", "fn0" => "", "f1" => '`kec_prov_id` IN ({filter_value})', "t1" => "3", "fn1" => "", "f2" => '`kec_kab_id` IN ({filter_value})', "t2" => "3", "fn2" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->kec_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `kec_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_desa_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `desa_id` AS `LinkFld`, `desa_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `desa`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`desa_id` IN ({filter_value})', "t0" => "3", "fn0" => "", "f1" => '`desa_prov_id` IN ({filter_value})', "t1" => "3", "fn1" => "", "f2" => '`desa_kab_id` IN ({filter_value})', "t2" => "3", "fn2" => "", "f3" => '`desa_kec_id` IN ({filter_value})', "t3" => "3", "fn3" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->desa_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `desa_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_blok_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `blok_id` AS `LinkFld`, `blok_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `blok`";
			$sWhereWrk = "{filter}";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`blok_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->blok_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `blok_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_sos_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `sos_id` AS `LinkFld`, `sos_id` AS `DispFld`, `sos_tgl` AS `Disp2Fld`, `sos_alamat` AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sosialisasi`";
			$sWhereWrk = "";
			$fld->LookupFilters = array("df2" => "0");
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`sos_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->sos_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `sos_tgl` DESC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_var_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `var_id` AS `LinkFld`, `var_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `varietas`";
			$sWhereWrk = "";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`var_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->var_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `var_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_co_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `co_id` AS `LinkFld`, `co_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `co`";
			$sWhereWrk = "";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`co_id` IN ({filter_value})', "t0" => "3", "fn0" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->co_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `co_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		}
	}

	// Setup AutoSuggest filters of a field
	function SetupAutoSuggestFilters($fld, $pageId = null) {
		global $gsLanguage;
		$pageId = $pageId ?: $this->PageID;
		switch ($fld->FldVar) {
		case "x_pet_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `pet_id`, `pet_nama` AS `DispFld`, `pet_alamat` AS `Disp2Fld` FROM `petani`";
			$sWhereWrk = "`pet_nama` LIKE '{query_value}%' OR CONCAT(COALESCE(`pet_nama`, ''),'" . ew_ValueSeparator(1, $this->pet_id) . "',COALESCE(`pet_alamat`,'')) LIKE '{query_value}%'";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->pet_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `pet_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_koord_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `koord_id`, `koord_nama` AS `DispFld`, `koord_alamat` AS `Disp2Fld` FROM `koord`";
			$sWhereWrk = "`koord_nama` LIKE '{query_value}%' OR CONCAT(COALESCE(`koord_nama`, ''),'" . ew_ValueSeparator(1, $this->koord_id) . "',COALESCE(`koord_alamat`,'')) LIKE '{query_value}%'";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->koord_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `koord_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		case "x_blok_id":
			$sSqlWrk = "";
			$sSqlWrk = "SELECT `blok_id`, `blok_nama` AS `DispFld` FROM `blok`";
			$sWhereWrk = "`blok_nama` LIKE '{query_value}%'";
			$fld->LookupFilters = array();
			$fld->LookupFilters += array("s" => $sSqlWrk, "d" => "");
			$sSqlWrk = "";
			$this->Lookup_Selecting($this->blok_id, $sWhereWrk); // Call Lookup Selecting
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `blok_nama` ASC";
			if ($sSqlWrk <> "")
				$fld->LookupFilters["s"] .= $sSqlWrk;
			break;
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
<?php ew_Header(FALSE) ?>
<?php

// Create page object
if (!isset($kontrak_add)) $kontrak_add = new ckontrak_add();

// Page init
$kontrak_add->Page_Init();

// Page main
$kontrak_add->Page_Main();

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$kontrak_add->Page_Render();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">

// Form object
var CurrentPageID = EW_PAGE_ID = "add";
var CurrentForm = fkontrakadd = new ew_Form("fkontrakadd", "add");

// Validate form
fkontrakadd.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			elm = this.GetElements("x" + infix + "_k_luas_lahan");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_luas_lahan->FldCaption(), $kontrak->k_luas_lahan->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_luas_lahan");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_luas_lahan->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_pet_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->pet_id->FldCaption(), $kontrak->pet_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_prov_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->prov_id->FldCaption(), $kontrak->prov_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_kab_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->kab_id->FldCaption(), $kontrak->kab_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_kec_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->kec_id->FldCaption(), $kontrak->kec_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_desa_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->desa_id->FldCaption(), $kontrak->desa_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_var_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->var_id->FldCaption(), $kontrak->var_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_co_id");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->co_id->FldCaption(), $kontrak->co_id->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_jumlah_bibit");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_jumlah_bibit->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_tgl_tanam");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_tgl_tanam->FldCaption(), $kontrak->k_tgl_tanam->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_tgl_tanam");
			if (elm && !ew_CheckDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_tgl_tanam->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_es_tgl_panen");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_es_tgl_panen->FldCaption(), $kontrak->k_es_tgl_panen->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_es_tgl_panen");
			if (elm && !ew_CheckDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_es_tgl_panen->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_es_perhektar");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_es_perhektar->FldCaption(), $kontrak->k_es_perhektar->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_es_perhektar");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_es_perhektar->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_harga_bibit");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_harga_bibit->FldCaption(), $kontrak->k_harga_bibit->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_harga_bibit");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_harga_bibit->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_bayar_bibit");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_bayar_bibit->FldCaption(), $kontrak->k_bayar_bibit->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_bayar_bibit");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_bayar_bibit->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_pinjaman");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_pinjaman->FldCaption(), $kontrak->k_pinjaman->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_pinjaman");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_pinjaman->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_bayar_pinjaman");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_bayar_pinjaman->FldCaption(), $kontrak->k_bayar_pinjaman->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_bayar_pinjaman");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_bayar_pinjaman->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_k_sisa_hutang");
			if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm))
				return this.OnError(elm, "<?php echo ew_JsEncode2(str_replace("%s", $kontrak->k_sisa_hutang->FldCaption(), $kontrak->k_sisa_hutang->ReqErrMsg)) ?>");
			elm = this.GetElements("x" + infix + "_k_sisa_hutang");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($kontrak->k_sisa_hutang->FldErrMsg()) ?>");

			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}

	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}

// Form_CustomValidate event
fkontrakadd.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid.
 	return true;
 }

// Use JavaScript validation or not
fkontrakadd.ValidateRequired = <?php echo json_encode(EW_CLIENT_VALIDATE) ?>;

// Dynamic selection lists
fkontrakadd.Lists["x_pet_id"] = {"LinkField":"x_pet_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_pet_nama","x_pet_alamat","",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":"","LinkTable":"petani"};
fkontrakadd.Lists["x_pet_id"].Data = "<?php echo $kontrak_add->pet_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.AutoSuggests["x_pet_id"] = <?php echo json_encode(array("data" => "ajax=autosuggest&" . $kontrak_add->pet_id->LookupFilterQuery(TRUE, "add"))) ?>;
fkontrakadd.Lists["x_koord_id"] = {"LinkField":"x_koord_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_koord_nama","x_koord_alamat","",""],"ParentFields":[],"ChildFields":["x_kk_id"],"FilterFields":[],"Options":[],"Template":"","LinkTable":"koord"};
fkontrakadd.Lists["x_koord_id"].Data = "<?php echo $kontrak_add->koord_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.AutoSuggests["x_koord_id"] = <?php echo json_encode(array("data" => "ajax=autosuggest&" . $kontrak_add->koord_id->LookupFilterQuery(TRUE, "add"))) ?>;
fkontrakadd.Lists["x_kk_id"] = {"LinkField":"x_kk_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_kk_periode","x_kk_tgl_mulai","x_kk_tgl_akhir",""],"ParentFields":["x_koord_id"],"ChildFields":[],"FilterFields":["x_koord_id"],"Options":[],"Template":"","LinkTable":"kontrak_koord"};
fkontrakadd.Lists["x_kk_id"].Data = "<?php echo $kontrak_add->kk_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_prov_id"] = {"LinkField":"x_prov_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_prov_nama","","",""],"ParentFields":[],"ChildFields":["x_kab_id","x_kec_id","x_desa_id"],"FilterFields":[],"Options":[],"Template":"","LinkTable":"prov"};
fkontrakadd.Lists["x_prov_id"].Data = "<?php echo $kontrak_add->prov_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_kab_id"] = {"LinkField":"x_kab_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_kab_nama","","",""],"ParentFields":["x_prov_id"],"ChildFields":["x_kec_id","x_desa_id"],"FilterFields":["x_kab_prov_id"],"Options":[],"Template":"","LinkTable":"kab"};
fkontrakadd.Lists["x_kab_id"].Data = "<?php echo $kontrak_add->kab_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_kec_id"] = {"LinkField":"x_kec_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_kec_nama","","",""],"ParentFields":["x_prov_id","x_kab_id"],"ChildFields":["x_desa_id"],"FilterFields":["x_kec_prov_id","x_kec_kab_id"],"Options":[],"Template":"","LinkTable":"kec"};
fkontrakadd.Lists["x_kec_id"].Data = "<?php echo $kontrak_add->kec_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_desa_id"] = {"LinkField":"x_desa_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_desa_nama","","",""],"ParentFields":["x_prov_id","x_kab_id","x_kec_id"],"ChildFields":[],"FilterFields":["x_desa_prov_id","x_desa_kab_id","x_desa_kec_id"],"Options":[],"Template":"","LinkTable":"desa"};
fkontrakadd.Lists["x_desa_id"].Data = "<?php echo $kontrak_add->desa_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_blok_id"] = {"LinkField":"x_blok_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_blok_nama","","",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":"","LinkTable":"blok"};
fkontrakadd.Lists["x_blok_id"].Data = "<?php echo $kontrak_add->blok_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.AutoSuggests["x_blok_id"] = <?php echo json_encode(array("data" => "ajax=autosuggest&" . $kontrak_add->blok_id->LookupFilterQuery(TRUE, "add"))) ?>;
fkontrakadd.Lists["x_sos_id"] = {"LinkField":"x_sos_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_sos_id","x_sos_tgl","x_sos_alamat",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":"","LinkTable":"sosialisasi"};
fkontrakadd.Lists["x_sos_id"].Data = "<?php echo $kontrak_add->sos_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_var_id"] = {"LinkField":"x_var_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_var_nama","","",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":"","LinkTable":"varietas"};
fkontrakadd.Lists["x_var_id"].Data = "<?php echo $kontrak_add->var_id->LookupFilterQuery(FALSE, "add") ?>";
fkontrakadd.Lists["x_co_id"] = {"LinkField":"x_co_id","Ajax":true,"AutoFill":false,"DisplayFields":["x_co_nama","","",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":"","LinkTable":"co"};
fkontrakadd.Lists["x_co_id"].Data = "<?php echo $kontrak_add->co_id->LookupFilterQuery(FALSE, "add") ?>";

// Form object for search
</script>
<script type="text/javascript">

// Write your client script here, no need to add script tags.
</script>
<?php $kontrak_add->ShowPageHeader(); ?>
<?php
$kontrak_add->ShowMessage();
?>
<form name="fkontrakadd" id="fkontrakadd" class="<?php echo $kontrak_add->FormClassName ?>" action="<?php echo ew_CurrentPage() ?>" method="post">
<?php if ($kontrak_add->CheckToken) { ?>
<input type="hidden" name="<?php echo EW_TOKEN_NAME ?>" value="<?php echo $kontrak_add->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="kontrak">
<input type="hidden" name="a_add" id="a_add" value="A">
<input type="hidden" name="modal" value="<?php echo intval($kontrak_add->IsModal) ?>">
<div class="ewAddDiv"><!-- page* -->
<?php if ($kontrak->k_luas_lahan->Visible) { // k_luas_lahan ?>
	<div id="r_k_luas_lahan" class="form-group">
		<label id="elh_kontrak_k_luas_lahan" for="x_k_luas_lahan" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_luas_lahan->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_luas_lahan->CellAttributes() ?>>
<span id="el_kontrak_k_luas_lahan">
<input type="text" data-table="kontrak" data-field="x_k_luas_lahan" name="x_k_luas_lahan" id="x_k_luas_lahan" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_luas_lahan->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_luas_lahan->EditValue ?>"<?php echo $kontrak->k_luas_lahan->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_luas_lahan->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->pet_id->Visible) { // pet_id ?>
	<div id="r_pet_id" class="form-group">
		<label id="elh_kontrak_pet_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->pet_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->pet_id->CellAttributes() ?>>
<span id="el_kontrak_pet_id">
<?php
$wrkonchange = trim(" " . @$kontrak->pet_id->EditAttrs["onchange"]);
if ($wrkonchange <> "") $wrkonchange = " onchange=\"" . ew_JsEncode2($wrkonchange) . "\"";
$kontrak->pet_id->EditAttrs["onchange"] = "";
?>
<span id="as_x_pet_id" style="white-space: nowrap; z-index: 8940">
	<input type="text" name="sv_x_pet_id" id="sv_x_pet_id" value="<?php echo $kontrak->pet_id->EditValue ?>" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->pet_id->getPlaceHolder()) ?>" data-placeholder="<?php echo ew_HtmlEncode($kontrak->pet_id->getPlaceHolder()) ?>"<?php echo $kontrak->pet_id->EditAttributes() ?>>
</span>
<input type="hidden" data-table="kontrak" data-field="x_pet_id" data-value-separator="<?php echo $kontrak->pet_id->DisplayValueSeparatorAttribute() ?>" name="x_pet_id" id="x_pet_id" value="<?php echo ew_HtmlEncode($kontrak->pet_id->CurrentValue) ?>"<?php echo $wrkonchange ?>>
<script type="text/javascript">
fkontrakadd.CreateAutoSuggest({"id":"x_pet_id","forceSelect":false});
</script>
<?php if (AllowAdd(CurrentProjectID() . "petani") && !$kontrak->pet_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->pet_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_pet_id',url:'petaniaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_pet_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->pet_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->pet_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->koord_id->Visible) { // koord_id ?>
	<div id="r_koord_id" class="form-group">
		<label id="elh_kontrak_koord_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->koord_id->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->koord_id->CellAttributes() ?>>
<span id="el_kontrak_koord_id">
<?php
$wrkonchange = trim("ew_UpdateOpt.call(this); " . @$kontrak->koord_id->EditAttrs["onchange"]);
if ($wrkonchange <> "") $wrkonchange = " onchange=\"" . ew_JsEncode2($wrkonchange) . "\"";
$kontrak->koord_id->EditAttrs["onchange"] = "";
?>
<span id="as_x_koord_id" style="white-space: nowrap; z-index: 8930">
	<input type="text" name="sv_x_koord_id" id="sv_x_koord_id" value="<?php echo $kontrak->koord_id->EditValue ?>" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->koord_id->getPlaceHolder()) ?>" data-placeholder="<?php echo ew_HtmlEncode($kontrak->koord_id->getPlaceHolder()) ?>"<?php echo $kontrak->koord_id->EditAttributes() ?>>
</span>
<input type="hidden" data-table="kontrak" data-field="x_koord_id" data-value-separator="<?php echo $kontrak->koord_id->DisplayValueSeparatorAttribute() ?>" name="x_koord_id" id="x_koord_id" value="<?php echo ew_HtmlEncode($kontrak->koord_id->CurrentValue) ?>"<?php echo $wrkonchange ?>>
<script type="text/javascript">
fkontrakadd.CreateAutoSuggest({"id":"x_koord_id","forceSelect":false});
</script>
<?php if (AllowAdd(CurrentProjectID() . "koord") && !$kontrak->koord_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->koord_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_koord_id',url:'koordaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_koord_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->koord_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->koord_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->kk_id->Visible) { // kk_id ?>
	<div id="r_kk_id" class="form-group">
		<label id="elh_kontrak_kk_id" for="x_kk_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->kk_id->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->kk_id->CellAttributes() ?>>
<span id="el_kontrak_kk_id">
<select data-table="kontrak" data-field="x_kk_id" data-value-separator="<?php echo $kontrak->kk_id->DisplayValueSeparatorAttribute() ?>" id="x_kk_id" name="x_kk_id"<?php echo $kontrak->kk_id->EditAttributes() ?>>
<?php echo $kontrak->kk_id->SelectOptionListHtml("x_kk_id") ?>
</select>
</span>
<?php echo $kontrak->kk_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->prov_id->Visible) { // prov_id ?>
	<div id="r_prov_id" class="form-group">
		<label id="elh_kontrak_prov_id" for="x_prov_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->prov_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->prov_id->CellAttributes() ?>>
<span id="el_kontrak_prov_id">
<?php $kontrak->prov_id->EditAttrs["onchange"] = "ew_UpdateOpt.call(this); " . @$kontrak->prov_id->EditAttrs["onchange"]; ?>
<select data-table="kontrak" data-field="x_prov_id" data-value-separator="<?php echo $kontrak->prov_id->DisplayValueSeparatorAttribute() ?>" id="x_prov_id" name="x_prov_id"<?php echo $kontrak->prov_id->EditAttributes() ?>>
<?php echo $kontrak->prov_id->SelectOptionListHtml("x_prov_id") ?>
</select>
</span>
<?php echo $kontrak->prov_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->kab_id->Visible) { // kab_id ?>
	<div id="r_kab_id" class="form-group">
		<label id="elh_kontrak_kab_id" for="x_kab_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->kab_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->kab_id->CellAttributes() ?>>
<span id="el_kontrak_kab_id">
<?php $kontrak->kab_id->EditAttrs["onchange"] = "ew_UpdateOpt.call(this); " . @$kontrak->kab_id->EditAttrs["onchange"]; ?>
<select data-table="kontrak" data-field="x_kab_id" data-value-separator="<?php echo $kontrak->kab_id->DisplayValueSeparatorAttribute() ?>" id="x_kab_id" name="x_kab_id"<?php echo $kontrak->kab_id->EditAttributes() ?>>
<?php echo $kontrak->kab_id->SelectOptionListHtml("x_kab_id") ?>
</select>
</span>
<?php echo $kontrak->kab_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->kec_id->Visible) { // kec_id ?>
	<div id="r_kec_id" class="form-group">
		<label id="elh_kontrak_kec_id" for="x_kec_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->kec_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->kec_id->CellAttributes() ?>>
<span id="el_kontrak_kec_id">
<?php $kontrak->kec_id->EditAttrs["onchange"] = "ew_UpdateOpt.call(this); " . @$kontrak->kec_id->EditAttrs["onchange"]; ?>
<select data-table="kontrak" data-field="x_kec_id" data-value-separator="<?php echo $kontrak->kec_id->DisplayValueSeparatorAttribute() ?>" id="x_kec_id" name="x_kec_id"<?php echo $kontrak->kec_id->EditAttributes() ?>>
<?php echo $kontrak->kec_id->SelectOptionListHtml("x_kec_id") ?>
</select>
</span>
<?php echo $kontrak->kec_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->desa_id->Visible) { // desa_id ?>
	<div id="r_desa_id" class="form-group">
		<label id="elh_kontrak_desa_id" for="x_desa_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->desa_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->desa_id->CellAttributes() ?>>
<span id="el_kontrak_desa_id">
<select data-table="kontrak" data-field="x_desa_id" data-value-separator="<?php echo $kontrak->desa_id->DisplayValueSeparatorAttribute() ?>" id="x_desa_id" name="x_desa_id"<?php echo $kontrak->desa_id->EditAttributes() ?>>
<?php echo $kontrak->desa_id->SelectOptionListHtml("x_desa_id") ?>
</select>
</span>
<?php echo $kontrak->desa_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->blok_id->Visible) { // blok_id ?>
	<div id="r_blok_id" class="form-group">
		<label id="elh_kontrak_blok_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->blok_id->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->blok_id->CellAttributes() ?>>
<span id="el_kontrak_blok_id">
<?php
$wrkonchange = trim(" " . @$kontrak->blok_id->EditAttrs["onchange"]);
if ($wrkonchange <> "") $wrkonchange = " onchange=\"" . ew_JsEncode2($wrkonchange) . "\"";
$kontrak->blok_id->EditAttrs["onchange"] = "";
?>
<span id="as_x_blok_id" style="white-space: nowrap; z-index: 8870">
	<input type="text" name="sv_x_blok_id" id="sv_x_blok_id" value="<?php echo $kontrak->blok_id->EditValue ?>" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->blok_id->getPlaceHolder()) ?>" data-placeholder="<?php echo ew_HtmlEncode($kontrak->blok_id->getPlaceHolder()) ?>"<?php echo $kontrak->blok_id->EditAttributes() ?>>
</span>
<input type="hidden" data-table="kontrak" data-field="x_blok_id" data-value-separator="<?php echo $kontrak->blok_id->DisplayValueSeparatorAttribute() ?>" name="x_blok_id" id="x_blok_id" value="<?php echo ew_HtmlEncode($kontrak->blok_id->CurrentValue) ?>"<?php echo $wrkonchange ?>>
<script type="text/javascript">
fkontrakadd.CreateAutoSuggest({"id":"x_blok_id","forceSelect":false});
</script>
<?php if (AllowAdd(CurrentProjectID() . "blok") && !$kontrak->blok_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->blok_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_blok_id',url:'blokaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_blok_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->blok_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->blok_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->sos_id->Visible) { // sos_id ?>
	<div id="r_sos_id" class="form-group">
		<label id="elh_kontrak_sos_id" for="x_sos_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->sos_id->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->sos_id->CellAttributes() ?>>
<span id="el_kontrak_sos_id">
<select data-table="kontrak" data-field="x_sos_id" data-value-separator="<?php echo $kontrak->sos_id->DisplayValueSeparatorAttribute() ?>" id="x_sos_id" name="x_sos_id"<?php echo $kontrak->sos_id->EditAttributes() ?>>
<?php echo $kontrak->sos_id->SelectOptionListHtml("x_sos_id") ?>
</select>
<?php if (AllowAdd(CurrentProjectID() . "sosialisasi") && !$kontrak->sos_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->sos_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_sos_id',url:'sosialisasiaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_sos_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->sos_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->sos_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->var_id->Visible) { // var_id ?>
	<div id="r_var_id" class="form-group">
		<label id="elh_kontrak_var_id" for="x_var_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->var_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->var_id->CellAttributes() ?>>
<span id="el_kontrak_var_id">
<select data-table="kontrak" data-field="x_var_id" data-value-separator="<?php echo $kontrak->var_id->DisplayValueSeparatorAttribute() ?>" id="x_var_id" name="x_var_id"<?php echo $kontrak->var_id->EditAttributes() ?>>
<?php echo $kontrak->var_id->SelectOptionListHtml("x_var_id") ?>
</select>
<?php if (AllowAdd(CurrentProjectID() . "varietas") && !$kontrak->var_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->var_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_var_id',url:'varietasaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_var_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->var_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->var_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->co_id->Visible) { // co_id ?>
	<div id="r_co_id" class="form-group">
		<label id="elh_kontrak_co_id" for="x_co_id" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->co_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->co_id->CellAttributes() ?>>
<span id="el_kontrak_co_id">
<select data-table="kontrak" data-field="x_co_id" data-value-separator="<?php echo $kontrak->co_id->DisplayValueSeparatorAttribute() ?>" id="x_co_id" name="x_co_id"<?php echo $kontrak->co_id->EditAttributes() ?>>
<?php echo $kontrak->co_id->SelectOptionListHtml("x_co_id") ?>
</select>
<?php if (AllowAdd(CurrentProjectID() . "co") && !$kontrak->co_id->ReadOnly) { ?>
<button type="button" title="<?php echo ew_HtmlTitle($Language->Phrase("AddLink")) . "&nbsp;" . $kontrak->co_id->FldCaption() ?>" onclick="ew_AddOptDialogShow({lnk:this,el:'x_co_id',url:'coaddopt.php'});" class="ewAddOptBtn btn btn-default btn-sm" id="aol_x_co_id"><span class="glyphicon glyphicon-plus ewIcon"></span><span class="hide"><?php echo $Language->Phrase("AddLink") ?>&nbsp;<?php echo $kontrak->co_id->FldCaption() ?></span></button>
<?php } ?>
</span>
<?php echo $kontrak->co_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_jumlah_bibit->Visible) { // k_jumlah_bibit ?>
	<div id="r_k_jumlah_bibit" class="form-group">
		<label id="elh_kontrak_k_jumlah_bibit" for="x_k_jumlah_bibit" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_jumlah_bibit->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_jumlah_bibit->CellAttributes() ?>>
<span id="el_kontrak_k_jumlah_bibit">
<input type="text" data-table="kontrak" data-field="x_k_jumlah_bibit" name="x_k_jumlah_bibit" id="x_k_jumlah_bibit" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_jumlah_bibit->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_jumlah_bibit->EditValue ?>"<?php echo $kontrak->k_jumlah_bibit->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_jumlah_bibit->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_asal_bibit->Visible) { // k_asal_bibit ?>
	<div id="r_k_asal_bibit" class="form-group">
		<label id="elh_kontrak_k_asal_bibit" for="x_k_asal_bibit" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_asal_bibit->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_asal_bibit->CellAttributes() ?>>
<span id="el_kontrak_k_asal_bibit">
<input type="text" data-table="kontrak" data-field="x_k_asal_bibit" name="x_k_asal_bibit" id="x_k_asal_bibit" size="30" maxlength="50" placeholder="<?php echo ew_HtmlEncode($kontrak->k_asal_bibit->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_asal_bibit->EditValue ?>"<?php echo $kontrak->k_asal_bibit->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_asal_bibit->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_tgl_tanam->Visible) { // k_tgl_tanam ?>
	<div id="r_k_tgl_tanam" class="form-group">
		<label id="elh_kontrak_k_tgl_tanam" for="x_k_tgl_tanam" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_tgl_tanam->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_tgl_tanam->CellAttributes() ?>>
<span id="el_kontrak_k_tgl_tanam">
<input type="text" data-table="kontrak" data-field="x_k_tgl_tanam" data-format="5" name="x_k_tgl_tanam" id="x_k_tgl_tanam" placeholder="<?php echo ew_HtmlEncode($kontrak->k_tgl_tanam->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_tgl_tanam->EditValue ?>"<?php echo $kontrak->k_tgl_tanam->EditAttributes() ?>>
<?php if (!$kontrak->k_tgl_tanam->ReadOnly && !$kontrak->k_tgl_tanam->Disabled && !isset($kontrak->k_tgl_tanam->EditAttrs["readonly"]) && !isset($kontrak->k_tgl_tanam->EditAttrs["disabled"])) { ?>
<script type="text/javascript">
ew_CreateDateTimePicker("fkontrakadd", "x_k_tgl_tanam", {"ignoreReadonly":true,"useCurrent":false,"format":5});
</script>
<?php } ?>
</span>
<?php echo $kontrak->k_tgl_tanam->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_es_tgl_panen->Visible) { // k_es_tgl_panen ?>
	<div id="r_k_es_tgl_panen" class="form-group">
		<label id="elh_kontrak_k_es_tgl_panen" for="x_k_es_tgl_panen" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_es_tgl_panen->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_es_tgl_panen->CellAttributes() ?>>
<span id="el_kontrak_k_es_tgl_panen">
<input type="text" data-table="kontrak" data-field="x_k_es_tgl_panen" data-format="5" name="x_k_es_tgl_panen" id="x_k_es_tgl_panen" placeholder="<?php echo ew_HtmlEncode($kontrak->k_es_tgl_panen->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_es_tgl_panen->EditValue ?>"<?php echo $kontrak->k_es_tgl_panen->EditAttributes() ?>>
<?php if (!$kontrak->k_es_tgl_panen->ReadOnly && !$kontrak->k_es_tgl_panen->Disabled && !isset($kontrak->k_es_tgl_panen->EditAttrs["readonly"]) && !isset($kontrak->k_es_tgl_panen->EditAttrs["disabled"])) { ?>
<script type="text/javascript">
ew_CreateDateTimePicker("fkontrakadd", "x_k_es_tgl_panen", {"ignoreReadonly":true,"useCurrent":false,"format":5});
</script>
<?php } ?>
</span>
<?php echo $kontrak->k_es_tgl_panen->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_es_perhektar->Visible) { // k_es_perhektar ?>
	<div id="r_k_es_perhektar" class="form-group">
		<label id="elh_kontrak_k_es_perhektar" for="x_k_es_perhektar" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_es_perhektar->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_es_perhektar->CellAttributes() ?>>
<span id="el_kontrak_k_es_perhektar">
<input type="text" data-table="kontrak" data-field="x_k_es_perhektar" name="x_k_es_perhektar" id="x_k_es_perhektar" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_es_perhektar->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_es_perhektar->EditValue ?>"<?php echo $kontrak->k_es_perhektar->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_es_perhektar->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_ket->Visible) { // k_ket ?>
	<div id="r_k_ket" class="form-group">
		<label id="elh_kontrak_k_ket" for="x_k_ket" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_ket->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_ket->CellAttributes() ?>>
<span id="el_kontrak_k_ket">
<textarea data-table="kontrak" data-field="x_k_ket" name="x_k_ket" id="x_k_ket" cols="35" rows="4" placeholder="<?php echo ew_HtmlEncode($kontrak->k_ket->getPlaceHolder()) ?>"<?php echo $kontrak->k_ket->EditAttributes() ?>><?php echo $kontrak->k_ket->EditValue ?></textarea>
</span>
<?php echo $kontrak->k_ket->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_cat->Visible) { // k_cat ?>
	<div id="r_k_cat" class="form-group">
		<label id="elh_kontrak_k_cat" for="x_k_cat" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_cat->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_cat->CellAttributes() ?>>
<span id="el_kontrak_k_cat">
<textarea data-table="kontrak" data-field="x_k_cat" name="x_k_cat" id="x_k_cat" cols="35" rows="4" placeholder="<?php echo ew_HtmlEncode($kontrak->k_cat->getPlaceHolder()) ?>"<?php echo $kontrak->k_cat->EditAttributes() ?>><?php echo $kontrak->k_cat->EditValue ?></textarea>
</span>
<?php echo $kontrak->k_cat->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_titik_koordinat->Visible) { // k_titik_koordinat ?>
	<div id="r_k_titik_koordinat" class="form-group">
		<label id="elh_kontrak_k_titik_koordinat" for="x_k_titik_koordinat" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_titik_koordinat->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_titik_koordinat->CellAttributes() ?>>
<span id="el_kontrak_k_titik_koordinat">
<input type="text" data-table="kontrak" data-field="x_k_titik_koordinat" name="x_k_titik_koordinat" id="x_k_titik_koordinat" size="60" maxlength="200" placeholder="<?php echo ew_HtmlEncode($kontrak->k_titik_koordinat->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_titik_koordinat->EditValue ?>"<?php echo $kontrak->k_titik_koordinat->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_titik_koordinat->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_foto_lahan->Visible) { // k_foto_lahan ?>
	<div id="r_k_foto_lahan" class="form-group">
		<label id="elh_kontrak_k_foto_lahan" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_foto_lahan->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_foto_lahan->CellAttributes() ?>>
<span id="el_kontrak_k_foto_lahan">
<div id="fd_x_k_foto_lahan">
<span title="<?php echo $kontrak->k_foto_lahan->FldTitle() ? $kontrak->k_foto_lahan->FldTitle() : $Language->Phrase("ChooseFiles") ?>" class="btn btn-default btn-sm fileinput-button ewTooltip<?php if ($kontrak->k_foto_lahan->ReadOnly || $kontrak->k_foto_lahan->Disabled) echo " hide"; ?>" data-trigger="hover">
	<span><?php echo $Language->Phrase("ChooseFileBtn") ?></span>
	<input type="file" title=" " data-table="kontrak" data-field="x_k_foto_lahan" name="x_k_foto_lahan" id="x_k_foto_lahan" multiple="multiple"<?php echo $kontrak->k_foto_lahan->EditAttributes() ?>>
</span>
<input type="hidden" name="fn_x_k_foto_lahan" id= "fn_x_k_foto_lahan" value="<?php echo $kontrak->k_foto_lahan->Upload->FileName ?>">
<input type="hidden" name="fa_x_k_foto_lahan" id= "fa_x_k_foto_lahan" value="0">
<input type="hidden" name="fs_x_k_foto_lahan" id= "fs_x_k_foto_lahan" value="100">
<input type="hidden" name="fx_x_k_foto_lahan" id= "fx_x_k_foto_lahan" value="<?php echo $kontrak->k_foto_lahan->UploadAllowedFileExt ?>">
<input type="hidden" name="fm_x_k_foto_lahan" id= "fm_x_k_foto_lahan" value="<?php echo $kontrak->k_foto_lahan->UploadMaxFileSize ?>">
<input type="hidden" name="fc_x_k_foto_lahan" id= "fc_x_k_foto_lahan" value="<?php echo $kontrak->k_foto_lahan->UploadMaxFileCount ?>">
</div>
<table id="ft_x_k_foto_lahan" class="table table-condensed pull-left ewUploadTable"><tbody class="files"></tbody></table>
</span>
<?php echo $kontrak->k_foto_lahan->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_dok->Visible) { // k_dok ?>
	<div id="r_k_dok" class="form-group">
		<label id="elh_kontrak_k_dok" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_dok->FldCaption() ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_dok->CellAttributes() ?>>
<span id="el_kontrak_k_dok">
<div id="fd_x_k_dok">
<span title="<?php echo $kontrak->k_dok->FldTitle() ? $kontrak->k_dok->FldTitle() : $Language->Phrase("ChooseFiles") ?>" class="btn btn-default btn-sm fileinput-button ewTooltip<?php if ($kontrak->k_dok->ReadOnly || $kontrak->k_dok->Disabled) echo " hide"; ?>" data-trigger="hover">
	<span><?php echo $Language->Phrase("ChooseFileBtn") ?></span>
	<input type="file" title=" " data-table="kontrak" data-field="x_k_dok" name="x_k_dok" id="x_k_dok" multiple="multiple"<?php echo $kontrak->k_dok->EditAttributes() ?>>
</span>
<input type="hidden" name="fn_x_k_dok" id= "fn_x_k_dok" value="<?php echo $kontrak->k_dok->Upload->FileName ?>">
<input type="hidden" name="fa_x_k_dok" id= "fa_x_k_dok" value="0">
<input type="hidden" name="fs_x_k_dok" id= "fs_x_k_dok" value="50">
<input type="hidden" name="fx_x_k_dok" id= "fx_x_k_dok" value="<?php echo $kontrak->k_dok->UploadAllowedFileExt ?>">
<input type="hidden" name="fm_x_k_dok" id= "fm_x_k_dok" value="<?php echo $kontrak->k_dok->UploadMaxFileSize ?>">
<input type="hidden" name="fc_x_k_dok" id= "fc_x_k_dok" value="<?php echo $kontrak->k_dok->UploadMaxFileCount ?>">
</div>
<table id="ft_x_k_dok" class="table table-condensed pull-left ewUploadTable"><tbody class="files"></tbody></table>
</span>
<?php echo $kontrak->k_dok->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_harga_bibit->Visible) { // k_harga_bibit ?>
	<div id="r_k_harga_bibit" class="form-group">
		<label id="elh_kontrak_k_harga_bibit" for="x_k_harga_bibit" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_harga_bibit->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_harga_bibit->CellAttributes() ?>>
<span id="el_kontrak_k_harga_bibit">
<input type="text" data-table="kontrak" data-field="x_k_harga_bibit" name="x_k_harga_bibit" id="x_k_harga_bibit" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_harga_bibit->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_harga_bibit->EditValue ?>"<?php echo $kontrak->k_harga_bibit->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_harga_bibit->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_bayar_bibit->Visible) { // k_bayar_bibit ?>
	<div id="r_k_bayar_bibit" class="form-group">
		<label id="elh_kontrak_k_bayar_bibit" for="x_k_bayar_bibit" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_bayar_bibit->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_bayar_bibit->CellAttributes() ?>>
<span id="el_kontrak_k_bayar_bibit">
<input type="text" data-table="kontrak" data-field="x_k_bayar_bibit" name="x_k_bayar_bibit" id="x_k_bayar_bibit" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_bayar_bibit->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_bayar_bibit->EditValue ?>"<?php echo $kontrak->k_bayar_bibit->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_bayar_bibit->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_pinjaman->Visible) { // k_pinjaman ?>
	<div id="r_k_pinjaman" class="form-group">
		<label id="elh_kontrak_k_pinjaman" for="x_k_pinjaman" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_pinjaman->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_pinjaman->CellAttributes() ?>>
<span id="el_kontrak_k_pinjaman">
<input type="text" data-table="kontrak" data-field="x_k_pinjaman" name="x_k_pinjaman" id="x_k_pinjaman" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_pinjaman->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_pinjaman->EditValue ?>"<?php echo $kontrak->k_pinjaman->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_pinjaman->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_bayar_pinjaman->Visible) { // k_bayar_pinjaman ?>
	<div id="r_k_bayar_pinjaman" class="form-group">
		<label id="elh_kontrak_k_bayar_pinjaman" for="x_k_bayar_pinjaman" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_bayar_pinjaman->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_bayar_pinjaman->CellAttributes() ?>>
<span id="el_kontrak_k_bayar_pinjaman">
<input type="text" data-table="kontrak" data-field="x_k_bayar_pinjaman" name="x_k_bayar_pinjaman" id="x_k_bayar_pinjaman" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_bayar_pinjaman->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_bayar_pinjaman->EditValue ?>"<?php echo $kontrak->k_bayar_pinjaman->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_bayar_pinjaman->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kontrak->k_sisa_hutang->Visible) { // k_sisa_hutang ?>
	<div id="r_k_sisa_hutang" class="form-group">
		<label id="elh_kontrak_k_sisa_hutang" for="x_k_sisa_hutang" class="<?php echo $kontrak_add->LeftColumnClass ?>"><?php echo $kontrak->k_sisa_hutang->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></label>
		<div class="<?php echo $kontrak_add->RightColumnClass ?>"><div<?php echo $kontrak->k_sisa_hutang->CellAttributes() ?>>
<span id="el_kontrak_k_sisa_hutang">
<input type="text" data-table="kontrak" data-field="x_k_sisa_hutang" name="x_k_sisa_hutang" id="x_k_sisa_hutang" size="30" placeholder="<?php echo ew_HtmlEncode($kontrak->k_sisa_hutang->getPlaceHolder()) ?>" value="<?php echo $kontrak->k_sisa_hutang->EditValue ?>"<?php echo $kontrak->k_sisa_hutang->EditAttributes() ?>>
</span>
<?php echo $kontrak->k_sisa_hutang->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kontrak_add->IsModal) { ?>
<div class="form-group"><!-- buttons .form-group -->
	<div class="<?php echo $kontrak_add->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><?php echo $Language->Phrase("AddBtn") ?></button>
<button class="btn btn-default ewButton" name="btnCancel" id="btnCancel" type="button" data-href="<?php echo $kontrak_add->getReturnUrl() ?>"><?php echo $Language->Phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<script type="text/javascript">
fkontrakadd.Init();
</script>
<?php
$kontrak_add->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script type="text/javascript">

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$kontrak_add->Page_Terminate();
?>
