<?php

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

//
// Table class for sosialisasi
//
class csosialisasi extends cTable {
	var $sos_id;
	var $sos_tgl;
	var $ts_id;
	var $sos_co;
	var $sos_peserta;
	var $sos_prov;
	var $sos_kab;
	var $sos_kec;
	var $sos_desa;
	var $sos_alamat;
	var $sos_pot_lahan;
	var $sos_katinggian;
	var $sos_biaya;
	var $sos_kesimpulan;
	var $sos_foto;

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

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

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

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

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

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

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

		// sos_peserta
		$this->sos_peserta = new cField('sosialisasi', 'sosialisasi', 'x_sos_peserta', 'sos_peserta', '`sos_peserta`', '`sos_peserta`', 201, -1, FALSE, '`sos_peserta`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->sos_peserta->Sortable = TRUE; // Allow sort
		$this->sos_peserta->FldSelectMultiple = TRUE; // Multiple select
		$this->fields['sos_peserta'] = &$this->sos_peserta;

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

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

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

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

		// sos_alamat
		$this->sos_alamat = new cField('sosialisasi', 'sosialisasi', 'x_sos_alamat', 'sos_alamat', '`sos_alamat`', '`sos_alamat`', 200, -1, FALSE, '`sos_alamat`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXTAREA');
		$this->sos_alamat->Sortable = TRUE; // Allow sort
		$this->fields['sos_alamat'] = &$this->sos_alamat;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->sos_id->setDbValue($rs->fields('sos_id'));
		$this->sos_tgl->setDbValue($rs->fields('sos_tgl'));
		$this->ts_id->setDbValue($rs->fields('ts_id'));
		$this->sos_co->setDbValue($rs->fields('sos_co'));
		$this->sos_peserta->setDbValue($rs->fields('sos_peserta'));
		$this->sos_prov->setDbValue($rs->fields('sos_prov'));
		$this->sos_kab->setDbValue($rs->fields('sos_kab'));
		$this->sos_kec->setDbValue($rs->fields('sos_kec'));
		$this->sos_desa->setDbValue($rs->fields('sos_desa'));
		$this->sos_alamat->setDbValue($rs->fields('sos_alamat'));
		$this->sos_pot_lahan->setDbValue($rs->fields('sos_pot_lahan'));
		$this->sos_katinggian->setDbValue($rs->fields('sos_katinggian'));
		$this->sos_biaya->setDbValue($rs->fields('sos_biaya'));
		$this->sos_kesimpulan->setDbValue($rs->fields('sos_kesimpulan'));
		$this->sos_foto->Upload->DbValue = $rs->fields('sos_foto');
	}

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

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

	// Common render codes
		// sos_id
		// sos_tgl
		// ts_id
		// sos_co
		// sos_peserta
		// sos_prov
		// sos_kab
		// sos_kec
		// sos_desa
		// sos_alamat
		// sos_pot_lahan
		// sos_katinggian
		// sos_biaya
		// sos_kesimpulan
		// sos_foto
		// sos_id

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

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

		// ts_id
		if (strval($this->ts_id->CurrentValue) <> "") {
			$sFilterWrk = "`ts_id`" . ew_SearchString("=", $this->ts_id->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `ts_id`, `ts_judul` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `tema_sosialisasi`";
		$sWhereWrk = "";
		$this->ts_id->LookupFilters = array("dx1" => '`ts_judul`');
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->ts_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');
				$this->ts_id->ViewValue = $this->ts_id->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->ts_id->ViewValue = $this->ts_id->CurrentValue;
			}
		} else {
			$this->ts_id->ViewValue = NULL;
		}
		$this->ts_id->ViewCustomAttributes = "";

		// sos_co
		if (strval($this->sos_co->CurrentValue) <> "") {
			$sFilterWrk = "`co_id`" . ew_SearchString("=", $this->sos_co->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `co_id`, `co_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `co`";
		$sWhereWrk = "";
		$this->sos_co->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_co, $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->sos_co->ViewValue = $this->sos_co->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_co->ViewValue = $this->sos_co->CurrentValue;
			}
		} else {
			$this->sos_co->ViewValue = NULL;
		}
		$this->sos_co->ViewCustomAttributes = "";

		// sos_peserta
		if (strval($this->sos_peserta->CurrentValue) <> "") {
			$arwrk = explode(",", $this->sos_peserta->CurrentValue);
			$sFilterWrk = "";
			foreach ($arwrk as $wrk) {
				if ($sFilterWrk <> "") $sFilterWrk .= " OR ";
				$sFilterWrk .= "`pes_id`" . ew_SearchString("=", trim($wrk), EW_DATATYPE_NUMBER, "");
			}
		$sSqlWrk = "SELECT `pes_id`, `pes_nama` AS `DispFld`, `kab_id` AS `Disp2Fld`, `kec_id` AS `Disp3Fld`, `desa_id` AS `Disp4Fld` FROM `peserta`";
		$sWhereWrk = "";
		$this->sos_peserta->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_peserta, $sWhereWrk); // Call Lookup Selecting
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `pes_id` DESC";
			$rswrk = Conn()->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->sos_peserta->ViewValue = "";
				$ari = 0;
				while (!$rswrk->EOF) {
					$arwrk = array();
					$arwrk[1] = $rswrk->fields('DispFld');
					$arwrk[2] = $rswrk->fields('Disp2Fld');
					$arwrk[3] = $rswrk->fields('Disp3Fld');
					$arwrk[4] = $rswrk->fields('Disp4Fld');
					$this->sos_peserta->ViewValue .= $this->sos_peserta->DisplayValue($arwrk);
					$rswrk->MoveNext();
					if (!$rswrk->EOF) $this->sos_peserta->ViewValue .= ew_ViewOptionSeparator($ari); // Separate Options
					$ari++;
				}
				$rswrk->Close();
			} else {
				$this->sos_peserta->ViewValue = $this->sos_peserta->CurrentValue;
			}
		} else {
			$this->sos_peserta->ViewValue = NULL;
		}
		$this->sos_peserta->CellCssStyle .= "text-align: left;";
		$this->sos_peserta->ViewCustomAttributes = "";

		// sos_prov
		if (strval($this->sos_prov->CurrentValue) <> "") {
			$sFilterWrk = "`prov_id`" . ew_SearchString("=", $this->sos_prov->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `prov_id`, `prov_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `prov`";
		$sWhereWrk = "";
		$this->sos_prov->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_prov, $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->sos_prov->ViewValue = $this->sos_prov->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_prov->ViewValue = $this->sos_prov->CurrentValue;
			}
		} else {
			$this->sos_prov->ViewValue = NULL;
		}
		$this->sos_prov->ViewCustomAttributes = "";

		// sos_kab
		if (strval($this->sos_kab->CurrentValue) <> "") {
			$sFilterWrk = "`kab_id`" . ew_SearchString("=", $this->sos_kab->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `kab_id`, `kab_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kab`";
		$sWhereWrk = "";
		$this->sos_kab->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_kab, $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->sos_kab->ViewValue = $this->sos_kab->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_kab->ViewValue = $this->sos_kab->CurrentValue;
			}
		} else {
			$this->sos_kab->ViewValue = NULL;
		}
		$this->sos_kab->ViewCustomAttributes = "";

		// sos_kec
		if (strval($this->sos_kec->CurrentValue) <> "") {
			$sFilterWrk = "`kec_id`" . ew_SearchString("=", $this->sos_kec->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `kec_id`, `kec_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `kec`";
		$sWhereWrk = "";
		$this->sos_kec->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_kec, $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->sos_kec->ViewValue = $this->sos_kec->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_kec->ViewValue = $this->sos_kec->CurrentValue;
			}
		} else {
			$this->sos_kec->ViewValue = NULL;
		}
		$this->sos_kec->ViewCustomAttributes = "";

		// sos_desa
		if (strval($this->sos_desa->CurrentValue) <> "") {
			$sFilterWrk = "`desa_id`" . ew_SearchString("=", $this->sos_desa->CurrentValue, EW_DATATYPE_NUMBER, "");
		$sSqlWrk = "SELECT `desa_id`, `desa_nama` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `desa`";
		$sWhereWrk = "";
		$this->sos_desa->LookupFilters = array();
		ew_AddFilter($sWhereWrk, $sFilterWrk);
		$this->Lookup_Selecting($this->sos_desa, $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->sos_desa->ViewValue = $this->sos_desa->DisplayValue($arwrk);
				$rswrk->Close();
			} else {
				$this->sos_desa->ViewValue = $this->sos_desa->CurrentValue;
			}
		} else {
			$this->sos_desa->ViewValue = NULL;
		}
		$this->sos_desa->ViewCustomAttributes = "";

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

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

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

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

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

		// sos_foto
		$this->sos_foto->UploadPath = "foto_sosialisasi";
		if (!ew_Empty($this->sos_foto->Upload->DbValue)) {
			$this->sos_foto->ImageWidth = 80;
			$this->sos_foto->ImageHeight = 60;
			$this->sos_foto->ImageAlt = $this->sos_foto->FldAlt();
			$this->sos_foto->ViewValue = $this->sos_foto->Upload->DbValue;
		} else {
			$this->sos_foto->ViewValue = "";
		}
		$this->sos_foto->CellCssStyle .= "text-align: center;";
		$this->sos_foto->ViewCustomAttributes = "";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {

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

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

			// Write header
			$Doc->ExportTableHeader();
			if ($Doc->Horizontal) { // Horizontal format, write header
				$Doc->BeginExportRow();
				if ($ExportPageType == "view") {
					if ($this->sos_id->Exportable) $Doc->ExportCaption($this->sos_id);
					if ($this->sos_tgl->Exportable) $Doc->ExportCaption($this->sos_tgl);
					if ($this->ts_id->Exportable) $Doc->ExportCaption($this->ts_id);
					if ($this->sos_co->Exportable) $Doc->ExportCaption($this->sos_co);
					if ($this->sos_peserta->Exportable) $Doc->ExportCaption($this->sos_peserta);
					if ($this->sos_prov->Exportable) $Doc->ExportCaption($this->sos_prov);
					if ($this->sos_kab->Exportable) $Doc->ExportCaption($this->sos_kab);
					if ($this->sos_kec->Exportable) $Doc->ExportCaption($this->sos_kec);
					if ($this->sos_desa->Exportable) $Doc->ExportCaption($this->sos_desa);
					if ($this->sos_alamat->Exportable) $Doc->ExportCaption($this->sos_alamat);
					if ($this->sos_pot_lahan->Exportable) $Doc->ExportCaption($this->sos_pot_lahan);
					if ($this->sos_katinggian->Exportable) $Doc->ExportCaption($this->sos_katinggian);
					if ($this->sos_biaya->Exportable) $Doc->ExportCaption($this->sos_biaya);
					if ($this->sos_kesimpulan->Exportable) $Doc->ExportCaption($this->sos_kesimpulan);
					if ($this->sos_foto->Exportable) $Doc->ExportCaption($this->sos_foto);
				} else {
					if ($this->sos_id->Exportable) $Doc->ExportCaption($this->sos_id);
					if ($this->sos_tgl->Exportable) $Doc->ExportCaption($this->sos_tgl);
					if ($this->ts_id->Exportable) $Doc->ExportCaption($this->ts_id);
					if ($this->sos_co->Exportable) $Doc->ExportCaption($this->sos_co);
					if ($this->sos_peserta->Exportable) $Doc->ExportCaption($this->sos_peserta);
					if ($this->sos_prov->Exportable) $Doc->ExportCaption($this->sos_prov);
					if ($this->sos_kab->Exportable) $Doc->ExportCaption($this->sos_kab);
					if ($this->sos_kec->Exportable) $Doc->ExportCaption($this->sos_kec);
					if ($this->sos_desa->Exportable) $Doc->ExportCaption($this->sos_desa);
					if ($this->sos_alamat->Exportable) $Doc->ExportCaption($this->sos_alamat);
					if ($this->sos_pot_lahan->Exportable) $Doc->ExportCaption($this->sos_pot_lahan);
					if ($this->sos_katinggian->Exportable) $Doc->ExportCaption($this->sos_katinggian);
					if ($this->sos_biaya->Exportable) $Doc->ExportCaption($this->sos_biaya);
					if ($this->sos_kesimpulan->Exportable) $Doc->ExportCaption($this->sos_kesimpulan);
					if ($this->sos_foto->Exportable) $Doc->ExportCaption($this->sos_foto);
				}
				$Doc->EndExportRow();
			}
		}

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

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

				// Render row
				$this->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->ResetAttrs();
				$this->RenderListRow();
				if (!$Doc->ExportCustom) {
					$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled
					if ($ExportPageType == "view") {
						if ($this->sos_id->Exportable) $Doc->ExportField($this->sos_id);
						if ($this->sos_tgl->Exportable) $Doc->ExportField($this->sos_tgl);
						if ($this->ts_id->Exportable) $Doc->ExportField($this->ts_id);
						if ($this->sos_co->Exportable) $Doc->ExportField($this->sos_co);
						if ($this->sos_peserta->Exportable) $Doc->ExportField($this->sos_peserta);
						if ($this->sos_prov->Exportable) $Doc->ExportField($this->sos_prov);
						if ($this->sos_kab->Exportable) $Doc->ExportField($this->sos_kab);
						if ($this->sos_kec->Exportable) $Doc->ExportField($this->sos_kec);
						if ($this->sos_desa->Exportable) $Doc->ExportField($this->sos_desa);
						if ($this->sos_alamat->Exportable) $Doc->ExportField($this->sos_alamat);
						if ($this->sos_pot_lahan->Exportable) $Doc->ExportField($this->sos_pot_lahan);
						if ($this->sos_katinggian->Exportable) $Doc->ExportField($this->sos_katinggian);
						if ($this->sos_biaya->Exportable) $Doc->ExportField($this->sos_biaya);
						if ($this->sos_kesimpulan->Exportable) $Doc->ExportField($this->sos_kesimpulan);
						if ($this->sos_foto->Exportable) $Doc->ExportField($this->sos_foto);
					} else {
						if ($this->sos_id->Exportable) $Doc->ExportField($this->sos_id);
						if ($this->sos_tgl->Exportable) $Doc->ExportField($this->sos_tgl);
						if ($this->ts_id->Exportable) $Doc->ExportField($this->ts_id);
						if ($this->sos_co->Exportable) $Doc->ExportField($this->sos_co);
						if ($this->sos_peserta->Exportable) $Doc->ExportField($this->sos_peserta);
						if ($this->sos_prov->Exportable) $Doc->ExportField($this->sos_prov);
						if ($this->sos_kab->Exportable) $Doc->ExportField($this->sos_kab);
						if ($this->sos_kec->Exportable) $Doc->ExportField($this->sos_kec);
						if ($this->sos_desa->Exportable) $Doc->ExportField($this->sos_desa);
						if ($this->sos_alamat->Exportable) $Doc->ExportField($this->sos_alamat);
						if ($this->sos_pot_lahan->Exportable) $Doc->ExportField($this->sos_pot_lahan);
						if ($this->sos_katinggian->Exportable) $Doc->ExportField($this->sos_katinggian);
						if ($this->sos_biaya->Exportable) $Doc->ExportField($this->sos_biaya);
						if ($this->sos_kesimpulan->Exportable) $Doc->ExportField($this->sos_kesimpulan);
						if ($this->sos_foto->Exportable) $Doc->ExportField($this->sos_foto);
					}
					$Doc->EndExportRow($RowCnt);
				}
			}

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

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

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

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

		// Enter your code here
	}

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

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

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

	}

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

		// Enter your code here
	}

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

		// Enter your code here
	}

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

		//echo "Row Selected";
	}

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

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

		return TRUE;
	}

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

		//echo "Row Inserted"
	}

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

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

		return TRUE;
	}

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

		//echo "Row Updated";
	}

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

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

		return TRUE;
	}

	// Grid Inserting event
	function Grid_Inserting() {

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

		return TRUE;
	}

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

		//echo "Grid Inserted";
	}

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

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

		return TRUE;
	}

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

		//echo "Grid Updated";
	}

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

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

		return TRUE;
	}

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

		//echo "Row Deleted";
	}

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

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

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

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

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here
	}

	// Row Rendered event
	function Row_Rendered() {

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

	}

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

		// Enter your code here
	}
}
?>
