UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token return $PageUrl; } // Page URLs var $AddUrl; var $EditUrl; var $CopyUrl; var $DeleteUrl; var $ViewUrl; var $ListUrl; // 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 = "" . $sMessage; $html .= "
" . $sMessage . "
"; $_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 = "" . $sWarningMessage; $html .= "
" . $sWarningMessage . "
"; $_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 = "" . $sSuccessMessage; $html .= "
" . $sSuccessMessage . "
"; $_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 = "" . $sErrorMessage; $html .= "
" . $sErrorMessage . "
"; $_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session } echo "
" . $html . "
"; } var $PageHeader; var $PageFooter; // Show Page Header function ShowPageHeader() { $sHeader = $this->PageHeader; $this->Page_DataRendering($sHeader); if ($sHeader <> "") { // Header exists, display echo "

" . $sHeader . "

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

" . $sFooter . "

"; } } // 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_IsHttpPost()) 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; $this->FormActionName .= '_' . $this->FormName; $this->FormKeyName .= '_' . $this->FormName; $this->FormOldKeyName .= '_' . $this->FormName; $this->FormBlankRowName .= '_' . $this->FormName; $this->FormKeyCountName .= '_' . $this->FormName; $GLOBALS["Grid"] = &$this; $this->TokenTimeout = ew_SessionTimeoutTime(); // Language object if (!isset($Language)) $Language = new cLanguage(); // Parent constuctor parent::__construct(); // Table object (tassigment) if (!isset($GLOBALS["tassigment"]) || get_class($GLOBALS["tassigment"]) == "ctassigment") { $GLOBALS["tassigment"] = &$this; // $GLOBALS["MasterTable"] = &$GLOBALS["Table"]; // if (!isset($GLOBALS["Table"])) $GLOBALS["Table"] = &$GLOBALS["tassigment"]; } $this->AddUrl = "tassigmentadd.php"; // Table object (users) if (!isset($GLOBALS['users'])) $GLOBALS['users'] = new cusers(); // Page ID if (!defined("EW_PAGE_ID")) define("EW_PAGE_ID", 'grid', TRUE); // Table name (for backward compatibility) if (!defined("EW_TABLE_NAME")) define("EW_TABLE_NAME", 'tassigment', TRUE); // Start timer if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer(); // Open connection if (!isset($conn)) $conn = ew_Connect($this->DBID); // User table object (users) if (!isset($UserTable)) { $UserTable = new cusers(); $UserTableConn = Conn($UserTable->DBID); } // List options $this->ListOptions = new cListOptions(); $this->ListOptions->TableVar = $this->TableVar; // Other options $this->OtherOptions['addedit'] = new cListOptions(); $this->OtherOptions['addedit']->Tag = "div"; $this->OtherOptions['addedit']->TagClassName = "ewAddEditOption"; } // // Page_Init // function Page_Init() { global $gsExport, $gsCustomExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm; // 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->CanList()) { $Security->SaveLastUrl(); $this->setFailureMessage(ew_DeniedMsg()); // Set no permission $this->Page_Terminate(ew_GetUrl("index.php")); } // Get grid add count $gridaddcnt = @$_GET[EW_TABLE_GRID_ADD_ROW_COUNT]; if (is_numeric($gridaddcnt) && $gridaddcnt > 0) $this->GridAddRowCount = $gridaddcnt; // Set up list options $this->SetupListOptions(); $this->idkAccomodation->SetVisibility(); $this->idkSeeker->SetVisibility(); $this->Date_ass->SetVisibility(); $this->Date_end->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") { // Process auto fill for detail table 'tass_notes' if (@$_POST["grid"] == "ftass_notesgrid") { if (!isset($GLOBALS["tass_notes_grid"])) $GLOBALS["tass_notes_grid"] = new ctass_notes_grid; $GLOBALS["tass_notes_grid"]->Page_Init(); $this->Page_Terminate(); exit(); } $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(); // Set up master detail parameters $this->SetUpMasterParms(); // Setup other options $this->SetupOtherOptions(); } // // Page_Terminate // function Page_Terminate($url = "") { global $gsExportFile, $gTmpImages; // Export global $EW_EXPORT, $tassigment; 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($tassigment); $doc->Text = $sContent; if ($this->Export == "email") echo $this->ExportEmail($doc->Text); else $doc->Export(); ew_DeleteTmpImages(); // Delete temp images exit(); } } // $GLOBALS["Table"] = &$GLOBALS["MasterTable"]; unset($GLOBALS["Grid"]); if ($url == "") return; $this->Page_Redirecting($url); // Go to URL if specified if ($url <> "") { if (!EW_DEBUG_ENABLED && ob_get_length()) ob_end_clean(); header("Location: " . $url); } exit(); } // Class variables var $ListOptions; // List options var $ExportOptions; // Export options var $SearchOptions; // Search options var $OtherOptions = array(); // Other options var $FilterOptions; // Filter options var $ListActions; // List actions var $SelectedCount = 0; var $SelectedIndex = 0; var $ShowOtherOptions = FALSE; var $DisplayRecs = 20; var $StartRec; var $StopRec; var $TotalRecs = 0; var $RecRange = 10; var $Pager; var $DefaultSearchWhere = ""; // Default search WHERE clause var $SearchWhere = ""; // Search WHERE clause var $RecCnt = 0; // Record count var $EditRowCnt; var $StartRowCnt = 1; var $RowCnt = 0; var $Attrs = array(); // Row attributes and cell attributes var $RowIndex = 0; // Row index var $KeyCount = 0; // Key count var $RowAction = ""; // Row action var $RowOldKey = ""; // Row old key (for copy) var $RecPerRow = 0; var $MultiColumnClass; var $MultiColumnEditClass = "col-sm-12"; var $MultiColumnCnt = 12; var $MultiColumnEditCnt = 12; var $GridCnt = 0; var $ColCnt = 0; var $DbMasterFilter = ""; // Master filter var $DbDetailFilter = ""; // Detail filter var $MasterRecordExists; var $MultiSelectKey; var $Command; var $RestoreSearch = FALSE; var $tass_notes_Count; var $DetailPages; var $Recordset; var $OldRecordset; // // Page main // function Page_Main() { global $objForm, $Language, $gsFormError, $gsSearchError, $Security; // Search filters $sSrchAdvanced = ""; // Advanced search filter $sSrchBasic = ""; // Basic search filter $sFilter = ""; // Get command $this->Command = strtolower(@$_GET["cmd"]); if ($this->IsPageRequest()) { // Validate request // Set up records per page $this->SetUpDisplayRecs(); // Handle reset command $this->ResetCmd(); // Hide list options if ($this->Export <> "") { $this->ListOptions->HideAllOptions(array("sequence")); $this->ListOptions->UseDropDownButton = FALSE; // Disable drop down button $this->ListOptions->UseButtonGroup = FALSE; // Disable button group } elseif ($this->CurrentAction == "gridadd" || $this->CurrentAction == "gridedit") { $this->ListOptions->HideAllOptions(); $this->ListOptions->UseDropDownButton = FALSE; // Disable drop down button $this->ListOptions->UseButtonGroup = FALSE; // Disable button group } // Show grid delete link for grid add / grid edit if ($this->AllowAddDeleteRow) { if ($this->CurrentAction == "gridadd" || $this->CurrentAction == "gridedit") { $item = $this->ListOptions->GetItem("griddelete"); if ($item) $item->Visible = TRUE; } } // Set up sorting order $this->SetUpSortOrder(); } // Restore display records if ($this->getRecordsPerPage() <> "") { $this->DisplayRecs = $this->getRecordsPerPage(); // Restore from Session } else { $this->DisplayRecs = 20; // Load default } // Load Sorting Order $this->LoadSortOrder(); // Build filter $sFilter = ""; if (!$Security->CanList()) $sFilter = "(0=1)"; // Filter all records // Restore master/detail filter $this->DbMasterFilter = $this->GetMasterFilter(); // Restore master filter $this->DbDetailFilter = $this->GetDetailFilter(); // Restore detail filter ew_AddFilter($sFilter, $this->DbDetailFilter); ew_AddFilter($sFilter, $this->SearchWhere); // Load master record if ($this->CurrentMode <> "add" && $this->GetMasterFilter() <> "" && $this->getCurrentMasterTable() == "tospiti") { global $tospiti; $rsmaster = $tospiti->LoadRs($this->DbMasterFilter); $this->MasterRecordExists = ($rsmaster && !$rsmaster->EOF); if (!$this->MasterRecordExists) { $this->setFailureMessage($Language->Phrase("NoRecord")); // Set no record found $this->Page_Terminate("tospitilist.php"); // Return to master page } else { $tospiti->LoadListRowValues($rsmaster); $tospiti->RowType = EW_ROWTYPE_MASTER; // Master row $tospiti->RenderListRow(); $rsmaster->Close(); } } // Load master record if ($this->CurrentMode <> "add" && $this->GetMasterFilter() <> "" && $this->getCurrentMasterTable() == "taccomodations") { global $taccomodations; $rsmaster = $taccomodations->LoadRs($this->DbMasterFilter); $this->MasterRecordExists = ($rsmaster && !$rsmaster->EOF); if (!$this->MasterRecordExists) { $this->setFailureMessage($Language->Phrase("NoRecord")); // Set no record found $this->Page_Terminate("taccomodationslist.php"); // Return to master page } else { $taccomodations->LoadListRowValues($rsmaster); $taccomodations->RowType = EW_ROWTYPE_MASTER; // Master row $taccomodations->RenderListRow(); $rsmaster->Close(); } } // Set up filter in session $this->setSessionWhere($sFilter); $this->CurrentFilter = ""; // Load record count first if (!$this->IsAddOrEdit()) { $bSelectLimit = $this->UseSelectLimit; if ($bSelectLimit) { $this->TotalRecs = $this->SelectRecordCount(); } else { if ($this->Recordset = $this->LoadRecordset()) $this->TotalRecs = $this->Recordset->RecordCount(); } } } // Set up number of records displayed per page function SetUpDisplayRecs() { $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE]; if ($sWrk <> "") { if (is_numeric($sWrk)) { $this->DisplayRecs = intval($sWrk); } else { if (strtolower($sWrk) == "all") { // Display all records $this->DisplayRecs = -1; } else { $this->DisplayRecs = 20; // Non-numeric, load default } } $this->setRecordsPerPage($this->DisplayRecs); // Save to Session // Reset start position $this->StartRec = 1; $this->setStartRecordNumber($this->StartRec); } } // Exit inline mode function ClearInlineMode() { $this->LastAction = $this->CurrentAction; // Save last action $this->CurrentAction = ""; // Clear action $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode } // Switch to Grid Add mode function GridAddMode() { $_SESSION[EW_SESSION_INLINE_MODE] = "gridadd"; // Enabled grid add } // Switch to Grid Edit mode function GridEditMode() { $_SESSION[EW_SESSION_INLINE_MODE] = "gridedit"; // Enable grid edit } // Perform update to grid function GridUpdate() { global $Language, $objForm, $gsFormError; $bGridUpdate = TRUE; // Get old recordset $this->CurrentFilter = $this->BuildKeyFilter(); if ($this->CurrentFilter == "") $this->CurrentFilter = "0=1"; $sSql = $this->SQL(); $conn = &$this->Connection(); if ($rs = $conn->Execute($sSql)) { $rsold = $rs->GetRows(); $rs->Close(); } // Call Grid Updating event if (!$this->Grid_Updating($rsold)) { if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("GridEditCancelled")); // Set grid edit cancelled message return FALSE; } $sKey = ""; // Update row index and get row key $objForm->Index = -1; $rowcnt = strval($objForm->GetValue($this->FormKeyCountName)); if ($rowcnt == "" || !is_numeric($rowcnt)) $rowcnt = 0; // Update all rows based on key for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) { $objForm->Index = $rowindex; $rowkey = strval($objForm->GetValue($this->FormKeyName)); $rowaction = strval($objForm->GetValue($this->FormActionName)); // Load all values and keys if ($rowaction <> "insertdelete") { // Skip insert then deleted rows $this->LoadFormValues(); // Get form values if ($rowaction == "" || $rowaction == "edit" || $rowaction == "delete") { $bGridUpdate = $this->SetupKeyValues($rowkey); // Set up key values } else { $bGridUpdate = TRUE; } // Skip empty row if ($rowaction == "insert" && $this->EmptyRow()) { // No action required // Validate form and insert/update/delete record } elseif ($bGridUpdate) { if ($rowaction == "delete") { $this->CurrentFilter = $this->KeyFilter(); $bGridUpdate = $this->DeleteRows(); // Delete this row } else if (!$this->ValidateForm()) { $bGridUpdate = FALSE; // Form error, reset action $this->setFailureMessage($gsFormError); } else { if ($rowaction == "insert") { $bGridUpdate = $this->AddRow(); // Insert this row } else { if ($rowkey <> "") { $this->SendEmail = FALSE; // Do not send email on update success $bGridUpdate = $this->EditRow(); // Update this row } } // End update } } if ($bGridUpdate) { if ($sKey <> "") $sKey .= ", "; $sKey .= $rowkey; } else { break; } } } if ($bGridUpdate) { // Get new recordset if ($rs = $conn->Execute($sSql)) { $rsnew = $rs->GetRows(); $rs->Close(); } // Call Grid_Updated event $this->Grid_Updated($rsold, $rsnew); $this->ClearInlineMode(); // Clear inline edit mode } else { if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("UpdateFailed")); // Set update failed message } return $bGridUpdate; } // Build filter for all keys function BuildKeyFilter() { global $objForm; $sWrkFilter = ""; // Update row index and get row key $rowindex = 1; $objForm->Index = $rowindex; $sThisKey = strval($objForm->GetValue($this->FormKeyName)); while ($sThisKey <> "") { if ($this->SetupKeyValues($sThisKey)) { $sFilter = $this->KeyFilter(); if ($sWrkFilter <> "") $sWrkFilter .= " OR "; $sWrkFilter .= $sFilter; } else { $sWrkFilter = "0=1"; break; } // Update row index and get row key $rowindex++; // Next row $objForm->Index = $rowindex; $sThisKey = strval($objForm->GetValue($this->FormKeyName)); } return $sWrkFilter; } // Set up key values function SetupKeyValues($key) { $arrKeyFlds = explode($GLOBALS["EW_COMPOSITE_KEY_SEPARATOR"], $key); if (count($arrKeyFlds) >= 1) { $this->idAssigment->setFormValue($arrKeyFlds[0]); if (!is_numeric($this->idAssigment->FormValue)) return FALSE; } return TRUE; } // Perform Grid Add function GridInsert() { global $Language, $objForm, $gsFormError; $rowindex = 1; $bGridInsert = FALSE; $conn = &$this->Connection(); // Call Grid Inserting event if (!$this->Grid_Inserting()) { if ($this->getFailureMessage() == "") { $this->setFailureMessage($Language->Phrase("GridAddCancelled")); // Set grid add cancelled message } return FALSE; } // Init key filter $sWrkFilter = ""; $addcnt = 0; $sKey = ""; // Get row count $objForm->Index = -1; $rowcnt = strval($objForm->GetValue($this->FormKeyCountName)); if ($rowcnt == "" || !is_numeric($rowcnt)) $rowcnt = 0; // Insert all rows for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) { // Load current row values $objForm->Index = $rowindex; $rowaction = strval($objForm->GetValue($this->FormActionName)); if ($rowaction <> "" && $rowaction <> "insert") continue; // Skip if ($rowaction == "insert") { $this->RowOldKey = strval($objForm->GetValue($this->FormOldKeyName)); $this->LoadOldRecord(); // Load old recordset } $this->LoadFormValues(); // Get form values if (!$this->EmptyRow()) { $addcnt++; $this->SendEmail = FALSE; // Do not send email on insert success // Validate form if (!$this->ValidateForm()) { $bGridInsert = FALSE; // Form error, reset action $this->setFailureMessage($gsFormError); } else { $bGridInsert = $this->AddRow($this->OldRecordset); // Insert this row } if ($bGridInsert) { if ($sKey <> "") $sKey .= $GLOBALS["EW_COMPOSITE_KEY_SEPARATOR"]; $sKey .= $this->idAssigment->CurrentValue; // Add filter for this record $sFilter = $this->KeyFilter(); if ($sWrkFilter <> "") $sWrkFilter .= " OR "; $sWrkFilter .= $sFilter; } else { break; } } } if ($addcnt == 0) { // No record inserted $this->ClearInlineMode(); // Clear grid add mode and return return TRUE; } if ($bGridInsert) { // Get new recordset $this->CurrentFilter = $sWrkFilter; $sSql = $this->SQL(); if ($rs = $conn->Execute($sSql)) { $rsnew = $rs->GetRows(); $rs->Close(); } // Call Grid_Inserted event $this->Grid_Inserted($rsnew); $this->ClearInlineMode(); // Clear grid add mode } else { if ($this->getFailureMessage() == "") { $this->setFailureMessage($Language->Phrase("InsertFailed")); // Set insert failed message } } return $bGridInsert; } // Check if empty row function EmptyRow() { global $objForm; if ($objForm->HasValue("x_idkAccomodation") && $objForm->HasValue("o_idkAccomodation") && $this->idkAccomodation->CurrentValue <> $this->idkAccomodation->OldValue) return FALSE; if ($objForm->HasValue("x_idkSeeker") && $objForm->HasValue("o_idkSeeker") && $this->idkSeeker->CurrentValue <> $this->idkSeeker->OldValue) return FALSE; if ($objForm->HasValue("x_Date_ass") && $objForm->HasValue("o_Date_ass") && $this->Date_ass->CurrentValue <> $this->Date_ass->OldValue) return FALSE; if ($objForm->HasValue("x_Date_end") && $objForm->HasValue("o_Date_end") && $this->Date_end->CurrentValue <> $this->Date_end->OldValue) return FALSE; return TRUE; } // Validate grid form function ValidateGridForm() { global $objForm; // Get row count $objForm->Index = -1; $rowcnt = strval($objForm->GetValue($this->FormKeyCountName)); if ($rowcnt == "" || !is_numeric($rowcnt)) $rowcnt = 0; // Validate all records for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) { // Load current row values $objForm->Index = $rowindex; $rowaction = strval($objForm->GetValue($this->FormActionName)); if ($rowaction <> "delete" && $rowaction <> "insertdelete") { $this->LoadFormValues(); // Get form values if ($rowaction == "insert" && $this->EmptyRow()) { // Ignore } else if (!$this->ValidateForm()) { return FALSE; } } } return TRUE; } // Get all form values of the grid function GetGridFormValues() { global $objForm; // Get row count $objForm->Index = -1; $rowcnt = strval($objForm->GetValue($this->FormKeyCountName)); if ($rowcnt == "" || !is_numeric($rowcnt)) $rowcnt = 0; $rows = array(); // Loop through all records for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) { // Load current row values $objForm->Index = $rowindex; $rowaction = strval($objForm->GetValue($this->FormActionName)); if ($rowaction <> "delete" && $rowaction <> "insertdelete") { $this->LoadFormValues(); // Get form values if ($rowaction == "insert" && $this->EmptyRow()) { // Ignore } else { $rows[] = $this->GetFieldValues("FormValue"); // Return row as array } } } return $rows; // Return as array of array } // Restore form values for current row function RestoreCurrentRowFormValues($idx) { global $objForm; // Get row based on current index $objForm->Index = $idx; $this->LoadFormValues(); // Load form values } // Set up sort parameters function SetUpSortOrder() { // Check for "order" parameter if (@$_GET["order"] <> "") { $this->CurrentOrder = ew_StripSlashes(@$_GET["order"]); $this->CurrentOrderType = @$_GET["ordertype"]; $this->setStartRecordNumber(1); // Reset start position } } // Load sort order parameters function LoadSortOrder() { $sOrderBy = $this->getSessionOrderBy(); // Get ORDER BY from Session if ($sOrderBy == "") { if ($this->getSqlOrderBy() <> "") { $sOrderBy = $this->getSqlOrderBy(); $this->setSessionOrderBy($sOrderBy); } } } // Reset command // - cmd=reset (Reset search parameters) // - cmd=resetall (Reset search and master/detail parameters) // - cmd=resetsort (Reset sort parameters) function ResetCmd() { // Check if reset command if (substr($this->Command,0,5) == "reset") { // Reset master/detail keys if ($this->Command == "resetall") { $this->setCurrentMasterTable(""); // Clear master table $this->DbMasterFilter = ""; $this->DbDetailFilter = ""; $this->idkSeeker->setSessionValue(""); $this->idkAccomodation->setSessionValue(""); } // Reset sorting order if ($this->Command == "resetsort") { $sOrderBy = ""; $this->setSessionOrderBy($sOrderBy); $this->setSessionOrderByList($sOrderBy); } // Reset start position $this->StartRec = 1; $this->setStartRecordNumber($this->StartRec); } } // Set up list options function SetupListOptions() { global $Security, $Language; // "griddelete" if ($this->AllowAddDeleteRow) { $item = &$this->ListOptions->Add("griddelete"); $item->CssStyle = "white-space: nowrap;"; $item->OnLeft = FALSE; $item->Visible = FALSE; // Default hidden } // Add group option item $item = &$this->ListOptions->Add($this->ListOptions->GroupOptionName); $item->Body = ""; $item->OnLeft = FALSE; $item->Visible = FALSE; // "view" $item = &$this->ListOptions->Add("view"); $item->CssStyle = "white-space: nowrap;"; $item->Visible = $Security->CanView(); $item->OnLeft = FALSE; // "edit" $item = &$this->ListOptions->Add("edit"); $item->CssStyle = "white-space: nowrap;"; $item->Visible = $Security->CanEdit(); $item->OnLeft = FALSE; // "delete" $item = &$this->ListOptions->Add("delete"); $item->CssStyle = "white-space: nowrap;"; $item->Visible = $Security->CanDelete(); $item->OnLeft = FALSE; // Drop down button for ListOptions $this->ListOptions->UseImageAndText = TRUE; $this->ListOptions->UseDropDownButton = FALSE; $this->ListOptions->DropDownButtonPhrase = $Language->Phrase("ButtonListOptions"); $this->ListOptions->UseButtonGroup = FALSE; if ($this->ListOptions->UseButtonGroup && ew_IsMobile()) $this->ListOptions->UseDropDownButton = TRUE; $this->ListOptions->ButtonClass = "btn-sm"; // Class for button group $item = &$this->ListOptions->GetItem($this->ListOptions->GroupOptionName); $item->Visible = $this->ListOptions->GroupOptionVisible(); } // Render list options function RenderListOptions() { global $Security, $Language, $objForm; $this->ListOptions->LoadDefault(); // Set up row action and key if (is_numeric($this->RowIndex) && $this->CurrentMode <> "view") { $objForm->Index = $this->RowIndex; $ActionName = str_replace("k_", "k" . $this->RowIndex . "_", $this->FormActionName); $OldKeyName = str_replace("k_", "k" . $this->RowIndex . "_", $this->FormOldKeyName); $KeyName = str_replace("k_", "k" . $this->RowIndex . "_", $this->FormKeyName); $BlankRowName = str_replace("k_", "k" . $this->RowIndex . "_", $this->FormBlankRowName); if ($this->RowAction <> "") $this->MultiSelectKey .= "RowAction . "\">"; if ($objForm->HasValue($this->FormOldKeyName)) $this->RowOldKey = strval($objForm->GetValue($this->FormOldKeyName)); if ($this->RowOldKey <> "") $this->MultiSelectKey .= "RowOldKey) . "\">"; if ($this->RowAction == "delete") { $rowkey = $objForm->GetValue($this->FormKeyName); $this->SetupKeyValues($rowkey); } if ($this->RowAction == "insert" && $this->CurrentAction == "F" && $this->EmptyRow()) $this->MultiSelectKey .= ""; } // "delete" if ($this->AllowAddDeleteRow) { if ($this->CurrentMode == "add" || $this->CurrentMode == "copy" || $this->CurrentMode == "edit") { $option = &$this->ListOptions; $option->UseButtonGroup = TRUE; // Use button group for grid delete button $option->UseImageAndText = TRUE; // Use image and text for grid delete button $oListOpt = &$option->Items["griddelete"]; if (!$Security->CanDelete() && is_numeric($this->RowIndex) && ($this->RowAction == "" || $this->RowAction == "edit")) { // Do not allow delete existing record $oListOpt->Body = " "; } else { $oListOpt->Body = "Phrase("DeleteLink")) . "\" data-caption=\"" . ew_HtmlTitle($Language->Phrase("DeleteLink")) . "\" onclick=\"return ew_DeleteGridRow(this, " . $this->RowIndex . ");\">" . $Language->Phrase("DeleteLink") . ""; } } } if ($this->CurrentMode == "view") { // View mode // "view" $oListOpt = &$this->ListOptions->Items["view"]; $viewcaption = ew_HtmlTitle($Language->Phrase("ViewLink")); if ($Security->CanView()) { $oListOpt->Body = "ViewUrl) . "\">" . $Language->Phrase("ViewLink") . ""; } else { $oListOpt->Body = ""; } // "edit" $oListOpt = &$this->ListOptions->Items["edit"]; $editcaption = ew_HtmlTitle($Language->Phrase("EditLink")); if ($Security->CanEdit()) { $oListOpt->Body = "Phrase("EditLink")) . "\" data-caption=\"" . ew_HtmlTitle($Language->Phrase("EditLink")) . "\" href=\"" . ew_HtmlEncode($this->EditUrl) . "\">" . $Language->Phrase("EditLink") . ""; } else { $oListOpt->Body = ""; } // "delete" $oListOpt = &$this->ListOptions->Items["delete"]; if ($Security->CanDelete()) $oListOpt->Body = "Phrase("DeleteLink")) . "\" data-caption=\"" . ew_HtmlTitle($Language->Phrase("DeleteLink")) . "\" href=\"" . ew_HtmlEncode($this->DeleteUrl) . "\">" . $Language->Phrase("DeleteLink") . ""; else $oListOpt->Body = ""; } // End View mode if ($this->CurrentMode == "edit" && is_numeric($this->RowIndex)) { $this->MultiSelectKey .= "idAssigment->CurrentValue . "\">"; } $this->RenderListOptionsExt(); } // Set record key function SetRecordKey(&$key, $rs) { $key = ""; if ($key <> "") $key .= $GLOBALS["EW_COMPOSITE_KEY_SEPARATOR"]; $key .= $rs->fields('idAssigment'); } // Set up other options function SetupOtherOptions() { global $Language, $Security; $option = &$this->OtherOptions["addedit"]; $option->UseDropDownButton = FALSE; $option->DropDownButtonPhrase = $Language->Phrase("ButtonAddEdit"); $option->UseButtonGroup = TRUE; $option->ButtonClass = "btn-sm"; // Class for button group $item = &$option->Add($option->GroupOptionName); $item->Body = ""; $item->Visible = FALSE; // Add if ($this->CurrentMode == "view") { // Check view mode $item = &$option->Add("add"); $addcaption = ew_HtmlTitle($Language->Phrase("AddLink")); $item->Body = "AddUrl) . "\">" . $Language->Phrase("AddLink") . ""; $item->Visible = ($this->AddUrl <> "" && $Security->CanAdd()); } } // Render other options function RenderOtherOptions() { global $Language, $Security; $options = &$this->OtherOptions; if (($this->CurrentMode == "add" || $this->CurrentMode == "copy" || $this->CurrentMode == "edit") && $this->CurrentAction != "F") { // Check add/copy/edit mode if ($this->AllowAddDeleteRow) { $option = &$options["addedit"]; $option->UseDropDownButton = FALSE; $option->UseImageAndText = TRUE; $item = &$option->Add("addblankrow"); $item->Body = "Phrase("AddBlankRow")) . "\" data-caption=\"" . ew_HtmlTitle($Language->Phrase("AddBlankRow")) . "\" href=\"javascript:void(0);\" onclick=\"ew_AddGridRow(this);\">" . $Language->Phrase("AddBlankRow") . ""; $item->Visible = $Security->CanAdd(); $this->ShowOtherOptions = $item->Visible; } } if ($this->CurrentMode == "view") { // Check view mode $option = &$options["addedit"]; $item = &$option->GetItem("add"); $this->ShowOtherOptions = $item && $item->Visible; } } function RenderListOptionsExt() { global $Security, $Language; } // Set up starting record parameters function SetUpStartRec() { if ($this->DisplayRecs == 0) return; if ($this->IsPageRequest()) { // Validate request if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter $this->StartRec = $_GET[EW_TABLE_START_REC]; $this->setStartRecordNumber($this->StartRec); } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") { $PageNo = $_GET[EW_TABLE_PAGE_NO]; if (is_numeric($PageNo)) { $this->StartRec = ($PageNo-1)*$this->DisplayRecs+1; if ($this->StartRec <= 0) { $this->StartRec = 1; } elseif ($this->StartRec >= intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1) { $this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; } $this->setStartRecordNumber($this->StartRec); } } } $this->StartRec = $this->getStartRecordNumber(); // Check if correct start record counter if (!is_numeric($this->StartRec) || $this->StartRec == "") { // Avoid invalid start record counter $this->StartRec = 1; // Reset start record counter $this->setStartRecordNumber($this->StartRec); } elseif (intval($this->StartRec) > intval($this->TotalRecs)) { // Avoid starting record > total records $this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to last page first record $this->setStartRecordNumber($this->StartRec); } elseif (($this->StartRec-1) % $this->DisplayRecs <> 0) { $this->StartRec = intval(($this->StartRec-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to page boundary $this->setStartRecordNumber($this->StartRec); } } // Get upload files function GetUploadFiles() { global $objForm, $Language; // Get upload data } // Load default values function LoadDefaultValues() { $this->idkAccomodation->CurrentValue = NULL; $this->idkAccomodation->OldValue = $this->idkAccomodation->CurrentValue; $this->idkSeeker->CurrentValue = NULL; $this->idkSeeker->OldValue = $this->idkSeeker->CurrentValue; $this->Date_ass->CurrentValue = NULL; $this->Date_ass->OldValue = $this->Date_ass->CurrentValue; $this->Date_end->CurrentValue = NULL; $this->Date_end->OldValue = $this->Date_end->CurrentValue; } // Load form values function LoadFormValues() { // Load from form global $objForm; $objForm->FormName = $this->FormName; if (!$this->idkAccomodation->FldIsDetailKey) { $this->idkAccomodation->setFormValue($objForm->GetValue("x_idkAccomodation")); } $this->idkAccomodation->setOldValue($objForm->GetValue("o_idkAccomodation")); if (!$this->idkSeeker->FldIsDetailKey) { $this->idkSeeker->setFormValue($objForm->GetValue("x_idkSeeker")); } $this->idkSeeker->setOldValue($objForm->GetValue("o_idkSeeker")); if (!$this->Date_ass->FldIsDetailKey) { $this->Date_ass->setFormValue($objForm->GetValue("x_Date_ass")); $this->Date_ass->CurrentValue = ew_UnFormatDateTime($this->Date_ass->CurrentValue, 7); } $this->Date_ass->setOldValue($objForm->GetValue("o_Date_ass")); if (!$this->Date_end->FldIsDetailKey) { $this->Date_end->setFormValue($objForm->GetValue("x_Date_end")); $this->Date_end->CurrentValue = ew_UnFormatDateTime($this->Date_end->CurrentValue, 7); } $this->Date_end->setOldValue($objForm->GetValue("o_Date_end")); if (!$this->idAssigment->FldIsDetailKey && $this->CurrentAction <> "gridadd" && $this->CurrentAction <> "add") $this->idAssigment->setFormValue($objForm->GetValue("x_idAssigment")); } // Restore form values function RestoreFormValues() { global $objForm; if ($this->CurrentAction <> "gridadd" && $this->CurrentAction <> "add") $this->idAssigment->CurrentValue = $this->idAssigment->FormValue; $this->idkAccomodation->CurrentValue = $this->idkAccomodation->FormValue; $this->idkSeeker->CurrentValue = $this->idkSeeker->FormValue; $this->Date_ass->CurrentValue = $this->Date_ass->FormValue; $this->Date_ass->CurrentValue = ew_UnFormatDateTime($this->Date_ass->CurrentValue, 7); $this->Date_end->CurrentValue = $this->Date_end->FormValue; $this->Date_end->CurrentValue = ew_UnFormatDateTime($this->Date_end->CurrentValue, 7); } // Load recordset function LoadRecordset($offset = -1, $rowcnt = -1) { // Load List page SQL $sSql = $this->SelectSQL(); $conn = &$this->Connection(); // Load recordset $dbtype = ew_GetConnectionType($this->DBID); if ($this->UseSelectLimit) { $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"]; if ($dbtype == "MSSQL") { $rs = $conn->SelectLimit($sSql, $rowcnt, $offset, array("_hasOrderBy" => trim($this->getOrderBy()) || trim($this->getSessionOrderByList()))); } else { $rs = $conn->SelectLimit($sSql, $rowcnt, $offset); } $conn->raiseErrorFn = ''; } else { $rs = ew_LoadRecordset($sSql, $conn); } // Call Recordset Selected event $this->Recordset_Selected($rs); return $rs; } // 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) { if (!$rs || $rs->EOF) return; // Call Row Selected event $row = &$rs->fields; $this->Row_Selected($row); $this->idAssigment->setDbValue($rs->fields('idAssigment')); $this->idkAccomodation->setDbValue($rs->fields('idkAccomodation')); if (array_key_exists('EV__idkAccomodation', $rs->fields)) { $this->idkAccomodation->VirtualValue = $rs->fields('EV__idkAccomodation'); // Set up virtual field value } else { $this->idkAccomodation->VirtualValue = ""; // Clear value } $this->idkSeeker->setDbValue($rs->fields('idkSeeker')); if (array_key_exists('EV__idkSeeker', $rs->fields)) { $this->idkSeeker->VirtualValue = $rs->fields('EV__idkSeeker'); // Set up virtual field value } else { $this->idkSeeker->VirtualValue = ""; // Clear value } $this->Date_ass->setDbValue($rs->fields('Date_ass')); $this->Date_end->setDbValue($rs->fields('Date_end')); } // Load DbValue from recordset function LoadDbValues(&$rs) { if (!$rs || !is_array($rs) && $rs->EOF) return; $row = is_array($rs) ? $rs : $rs->fields; $this->idAssigment->DbValue = $row['idAssigment']; $this->idkAccomodation->DbValue = $row['idkAccomodation']; $this->idkSeeker->DbValue = $row['idkSeeker']; $this->Date_ass->DbValue = $row['Date_ass']; $this->Date_end->DbValue = $row['Date_end']; } // Load old record function LoadOldRecord() { // Load key values from Session $bValidKey = TRUE; $arKeys[] = $this->RowOldKey; $cnt = count($arKeys); if ($cnt >= 1) { if (strval($arKeys[0]) <> "") $this->idAssigment->CurrentValue = strval($arKeys[0]); // idAssigment else $bValidKey = FALSE; } else { $bValidKey = FALSE; } // Load old recordset 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 } else { $this->OldRecordset = NULL; } return $bValidKey; } // Render row values based on field settings function RenderRow() { global $Security, $Language, $gsLanguage; // Initialize URLs $this->ViewUrl = $this->GetViewUrl(); $this->EditUrl = $this->GetEditUrl(); $this->CopyUrl = $this->GetCopyUrl(); $this->DeleteUrl = $this->GetDeleteUrl(); // Call Row_Rendering event $this->Row_Rendering(); // Common render codes for all row types // idAssigment // idkAccomodation // idkSeeker // Date_ass // Date_end if ($this->RowType == EW_ROWTYPE_VIEW) { // View row // idAssigment $this->idAssigment->ViewValue = $this->idAssigment->CurrentValue; $this->idAssigment->ViewCustomAttributes = ""; // idkAccomodation if ($this->idkAccomodation->VirtualValue <> "") { $this->idkAccomodation->ViewValue = $this->idkAccomodation->VirtualValue; } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; if (strval($this->idkAccomodation->CurrentValue) <> "") { $sFilterWrk = "`idAccomodation`" . ew_SearchString("=", $this->idkAccomodation->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; case "it": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; default: $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkAccomodation, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $this->idkAccomodation->ViewValue = $this->idkAccomodation->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; } } else { $this->idkAccomodation->ViewValue = NULL; } } $this->idkAccomodation->ViewCustomAttributes = ""; // idkSeeker if ($this->idkSeeker->VirtualValue <> "") { $this->idkSeeker->ViewValue = $this->idkSeeker->VirtualValue; } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; if (strval($this->idkSeeker->CurrentValue) <> "") { $sFilterWrk = "`idSeeker`" . ew_SearchString("=", $this->idkSeeker->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; case "it": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; default: $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkSeeker, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $arwrk[3] = ew_FormatDateTime($rswrk->fields('Disp3Fld'), 7); $arwrk[4] = $rswrk->fields('Disp4Fld'); $this->idkSeeker->ViewValue = $this->idkSeeker->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; } } else { $this->idkSeeker->ViewValue = NULL; } } $this->idkSeeker->ViewCustomAttributes = ""; // Date_ass $this->Date_ass->ViewValue = $this->Date_ass->CurrentValue; $this->Date_ass->ViewValue = ew_FormatDateTime($this->Date_ass->ViewValue, 7); $this->Date_ass->ViewCustomAttributes = ""; // Date_end $this->Date_end->ViewValue = $this->Date_end->CurrentValue; $this->Date_end->ViewValue = ew_FormatDateTime($this->Date_end->ViewValue, 7); $this->Date_end->ViewCustomAttributes = ""; // idkAccomodation $this->idkAccomodation->LinkCustomAttributes = ""; if (!ew_Empty($this->idkAccomodation->CurrentValue)) { $this->idkAccomodation->HrefValue = "taccomodationsview.php?showdetail=&idAccomodation=" . $this->idkAccomodation->CurrentValue; // Add prefix/suffix $this->idkAccomodation->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkAccomodation->HrefValue = ew_ConvertFullUrl($this->idkAccomodation->HrefValue); } else { $this->idkAccomodation->HrefValue = ""; } $this->idkAccomodation->TooltipValue = ""; // idkSeeker $this->idkSeeker->LinkCustomAttributes = ""; if (!ew_Empty($this->idkSeeker->CurrentValue)) { $this->idkSeeker->HrefValue = "tospitiview.php?showdetail=&idSeeker=" . $this->idkSeeker->CurrentValue; // Add prefix/suffix $this->idkSeeker->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkSeeker->HrefValue = ew_ConvertFullUrl($this->idkSeeker->HrefValue); } else { $this->idkSeeker->HrefValue = ""; } $this->idkSeeker->TooltipValue = ""; // Date_ass $this->Date_ass->LinkCustomAttributes = ""; $this->Date_ass->HrefValue = ""; $this->Date_ass->TooltipValue = ""; // Date_end $this->Date_end->LinkCustomAttributes = ""; $this->Date_end->HrefValue = ""; $this->Date_end->TooltipValue = ""; } elseif ($this->RowType == EW_ROWTYPE_ADD) { // Add row // idkAccomodation $this->idkAccomodation->EditAttrs["class"] = "form-control"; $this->idkAccomodation->EditCustomAttributes = ""; if ($this->idkAccomodation->getSessionValue() <> "") { $this->idkAccomodation->CurrentValue = $this->idkAccomodation->getSessionValue(); $this->idkAccomodation->OldValue = $this->idkAccomodation->CurrentValue; if ($this->idkAccomodation->VirtualValue <> "") { $this->idkAccomodation->ViewValue = $this->idkAccomodation->VirtualValue; } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; if (strval($this->idkAccomodation->CurrentValue) <> "") { $sFilterWrk = "`idAccomodation`" . ew_SearchString("=", $this->idkAccomodation->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; case "it": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; default: $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkAccomodation, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $this->idkAccomodation->ViewValue = $this->idkAccomodation->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; } } else { $this->idkAccomodation->ViewValue = NULL; } } $this->idkAccomodation->ViewCustomAttributes = ""; } else { $this->idkAccomodation->EditValue = ew_HtmlEncode($this->idkAccomodation->CurrentValue); $this->idkAccomodation->PlaceHolder = ew_RemoveHtml($this->idkAccomodation->FldCaption()); } // idkSeeker $this->idkSeeker->EditAttrs["class"] = "form-control"; $this->idkSeeker->EditCustomAttributes = ""; if ($this->idkSeeker->getSessionValue() <> "") { $this->idkSeeker->CurrentValue = $this->idkSeeker->getSessionValue(); $this->idkSeeker->OldValue = $this->idkSeeker->CurrentValue; if ($this->idkSeeker->VirtualValue <> "") { $this->idkSeeker->ViewValue = $this->idkSeeker->VirtualValue; } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; if (strval($this->idkSeeker->CurrentValue) <> "") { $sFilterWrk = "`idSeeker`" . ew_SearchString("=", $this->idkSeeker->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; case "it": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; default: $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkSeeker, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $arwrk[3] = ew_FormatDateTime($rswrk->fields('Disp3Fld'), 7); $arwrk[4] = $rswrk->fields('Disp4Fld'); $this->idkSeeker->ViewValue = $this->idkSeeker->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; } } else { $this->idkSeeker->ViewValue = NULL; } } $this->idkSeeker->ViewCustomAttributes = ""; } else { $this->idkSeeker->EditValue = ew_HtmlEncode($this->idkSeeker->CurrentValue); $this->idkSeeker->PlaceHolder = ew_RemoveHtml($this->idkSeeker->FldCaption()); } // Date_ass $this->Date_ass->EditAttrs["class"] = "form-control"; $this->Date_ass->EditCustomAttributes = ""; $this->Date_ass->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->Date_ass->CurrentValue, 7)); $this->Date_ass->PlaceHolder = ew_RemoveHtml($this->Date_ass->FldCaption()); // Date_end $this->Date_end->EditAttrs["class"] = "form-control"; $this->Date_end->EditCustomAttributes = ""; $this->Date_end->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->Date_end->CurrentValue, 7)); $this->Date_end->PlaceHolder = ew_RemoveHtml($this->Date_end->FldCaption()); // Add refer script // idkAccomodation $this->idkAccomodation->LinkCustomAttributes = ""; if (!ew_Empty($this->idkAccomodation->CurrentValue)) { $this->idkAccomodation->HrefValue = "taccomodationsview.php?showdetail=&idAccomodation=" . $this->idkAccomodation->CurrentValue; // Add prefix/suffix $this->idkAccomodation->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkAccomodation->HrefValue = ew_ConvertFullUrl($this->idkAccomodation->HrefValue); } else { $this->idkAccomodation->HrefValue = ""; } // idkSeeker $this->idkSeeker->LinkCustomAttributes = ""; if (!ew_Empty($this->idkSeeker->CurrentValue)) { $this->idkSeeker->HrefValue = "tospitiview.php?showdetail=&idSeeker=" . $this->idkSeeker->CurrentValue; // Add prefix/suffix $this->idkSeeker->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkSeeker->HrefValue = ew_ConvertFullUrl($this->idkSeeker->HrefValue); } else { $this->idkSeeker->HrefValue = ""; } // Date_ass $this->Date_ass->LinkCustomAttributes = ""; $this->Date_ass->HrefValue = ""; // Date_end $this->Date_end->LinkCustomAttributes = ""; $this->Date_end->HrefValue = ""; } elseif ($this->RowType == EW_ROWTYPE_EDIT) { // Edit row // idkAccomodation $this->idkAccomodation->EditAttrs["class"] = "form-control"; $this->idkAccomodation->EditCustomAttributes = ""; if ($this->idkAccomodation->getSessionValue() <> "") { $this->idkAccomodation->CurrentValue = $this->idkAccomodation->getSessionValue(); $this->idkAccomodation->OldValue = $this->idkAccomodation->CurrentValue; if ($this->idkAccomodation->VirtualValue <> "") { $this->idkAccomodation->ViewValue = $this->idkAccomodation->VirtualValue; } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; if (strval($this->idkAccomodation->CurrentValue) <> "") { $sFilterWrk = "`idAccomodation`" . ew_SearchString("=", $this->idkAccomodation->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; case "it": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; default: $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = ""; $this->idkAccomodation->LookupFilters = array(); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkAccomodation, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $this->idkAccomodation->ViewValue = $this->idkAccomodation->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkAccomodation->ViewValue = $this->idkAccomodation->CurrentValue; } } else { $this->idkAccomodation->ViewValue = NULL; } } $this->idkAccomodation->ViewCustomAttributes = ""; } else { $this->idkAccomodation->EditValue = ew_HtmlEncode($this->idkAccomodation->CurrentValue); $this->idkAccomodation->PlaceHolder = ew_RemoveHtml($this->idkAccomodation->FldCaption()); } // idkSeeker $this->idkSeeker->EditAttrs["class"] = "form-control"; $this->idkSeeker->EditCustomAttributes = ""; if ($this->idkSeeker->getSessionValue() <> "") { $this->idkSeeker->CurrentValue = $this->idkSeeker->getSessionValue(); $this->idkSeeker->OldValue = $this->idkSeeker->CurrentValue; if ($this->idkSeeker->VirtualValue <> "") { $this->idkSeeker->ViewValue = $this->idkSeeker->VirtualValue; } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; if (strval($this->idkSeeker->CurrentValue) <> "") { $sFilterWrk = "`idSeeker`" . ew_SearchString("=", $this->idkSeeker->CurrentValue, EW_DATATYPE_NUMBER, ""); switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; case "it": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; default: $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = ""; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; } ew_AddFilter($sWhereWrk, $sFilterWrk); $this->Lookup_Selecting($this->idkSeeker, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $rswrk = Conn()->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $arwrk = array(); $arwrk[1] = $rswrk->fields('DispFld'); $arwrk[2] = $rswrk->fields('Disp2Fld'); $arwrk[3] = ew_FormatDateTime($rswrk->fields('Disp3Fld'), 7); $arwrk[4] = $rswrk->fields('Disp4Fld'); $this->idkSeeker->ViewValue = $this->idkSeeker->DisplayValue($arwrk); $rswrk->Close(); } else { $this->idkSeeker->ViewValue = $this->idkSeeker->CurrentValue; } } else { $this->idkSeeker->ViewValue = NULL; } } $this->idkSeeker->ViewCustomAttributes = ""; } else { $this->idkSeeker->EditValue = ew_HtmlEncode($this->idkSeeker->CurrentValue); $this->idkSeeker->PlaceHolder = ew_RemoveHtml($this->idkSeeker->FldCaption()); } // Date_ass $this->Date_ass->EditAttrs["class"] = "form-control"; $this->Date_ass->EditCustomAttributes = ""; $this->Date_ass->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->Date_ass->CurrentValue, 7)); $this->Date_ass->PlaceHolder = ew_RemoveHtml($this->Date_ass->FldCaption()); // Date_end $this->Date_end->EditAttrs["class"] = "form-control"; $this->Date_end->EditCustomAttributes = ""; $this->Date_end->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->Date_end->CurrentValue, 7)); $this->Date_end->PlaceHolder = ew_RemoveHtml($this->Date_end->FldCaption()); // Edit refer script // idkAccomodation $this->idkAccomodation->LinkCustomAttributes = ""; if (!ew_Empty($this->idkAccomodation->CurrentValue)) { $this->idkAccomodation->HrefValue = "taccomodationsview.php?showdetail=&idAccomodation=" . $this->idkAccomodation->CurrentValue; // Add prefix/suffix $this->idkAccomodation->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkAccomodation->HrefValue = ew_ConvertFullUrl($this->idkAccomodation->HrefValue); } else { $this->idkAccomodation->HrefValue = ""; } // idkSeeker $this->idkSeeker->LinkCustomAttributes = ""; if (!ew_Empty($this->idkSeeker->CurrentValue)) { $this->idkSeeker->HrefValue = "tospitiview.php?showdetail=&idSeeker=" . $this->idkSeeker->CurrentValue; // Add prefix/suffix $this->idkSeeker->LinkAttrs["target"] = "_self"; // Add target if ($this->Export <> "") $this->idkSeeker->HrefValue = ew_ConvertFullUrl($this->idkSeeker->HrefValue); } else { $this->idkSeeker->HrefValue = ""; } // Date_ass $this->Date_ass->LinkCustomAttributes = ""; $this->Date_ass->HrefValue = ""; // Date_end $this->Date_end->LinkCustomAttributes = ""; $this->Date_end->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; // Check if validation required if (!EW_SERVER_VALIDATE) return ($gsFormError == ""); if (!$this->idkAccomodation->FldIsDetailKey && !is_null($this->idkAccomodation->FormValue) && $this->idkAccomodation->FormValue == "") { ew_AddMessage($gsFormError, str_replace("%s", $this->idkAccomodation->FldCaption(), $this->idkAccomodation->ReqErrMsg)); } if (!$this->idkSeeker->FldIsDetailKey && !is_null($this->idkSeeker->FormValue) && $this->idkSeeker->FormValue == "") { ew_AddMessage($gsFormError, str_replace("%s", $this->idkSeeker->FldCaption(), $this->idkSeeker->ReqErrMsg)); } if (!ew_CheckEuroDate($this->Date_ass->FormValue)) { ew_AddMessage($gsFormError, $this->Date_ass->FldErrMsg()); } if (!ew_CheckEuroDate($this->Date_end->FormValue)) { ew_AddMessage($gsFormError, $this->Date_end->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; } // // Delete records based on current filter // function DeleteRows() { global $Language, $Security; if (!$Security->CanDelete()) { $this->setFailureMessage($Language->Phrase("NoDeletePermission")); // No delete permission return FALSE; } $DeleteRows = TRUE; $sSql = $this->SQL(); $conn = &$this->Connection(); $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"]; $rs = $conn->Execute($sSql); $conn->raiseErrorFn = ''; if ($rs === FALSE) { return FALSE; } elseif ($rs->EOF) { $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found $rs->Close(); return FALSE; //} else { // $this->LoadRowValues($rs); // Load row values } $rows = ($rs) ? $rs->GetRows() : array(); // Clone old rows $rsold = $rows; if ($rs) $rs->Close(); // Call row deleting event if ($DeleteRows) { foreach ($rsold as $row) { $DeleteRows = $this->Row_Deleting($row); if (!$DeleteRows) break; } } if ($DeleteRows) { $sKey = ""; foreach ($rsold as $row) { $sThisKey = ""; if ($sThisKey <> "") $sThisKey .= $GLOBALS["EW_COMPOSITE_KEY_SEPARATOR"]; $sThisKey .= $row['idAssigment']; $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"]; $DeleteRows = $this->Delete($row); // Delete $conn->raiseErrorFn = ''; if ($DeleteRows === FALSE) break; if ($sKey <> "") $sKey .= ", "; $sKey .= $sThisKey; } } else { // Set up error message if ($this->getSuccessMessage() <> "" || $this->getFailureMessage() <> "") { // Use the message, do nothing } elseif ($this->CancelMessage <> "") { $this->setFailureMessage($this->CancelMessage); $this->CancelMessage = ""; } else { $this->setFailureMessage($Language->Phrase("DeleteCancelled")); } } if ($DeleteRows) { } else { } // Call Row Deleted event if ($DeleteRows) { foreach ($rsold as $row) { $this->Row_Deleted($row); } } return $DeleteRows; } // Update record based on key values function EditRow() { global $Security, $Language; $sFilter = $this->KeyFilter(); $sFilter = $this->ApplyUserIDFilters($sFilter); $conn = &$this->Connection(); $this->CurrentFilter = $sFilter; $sSql = $this->SQL(); $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"]; $rs = $conn->Execute($sSql); $conn->raiseErrorFn = ''; if ($rs === FALSE) return FALSE; if ($rs->EOF) { $this->setFailureMessage($Language->Phrase("NoRecord")); // Set no record message $EditRow = FALSE; // Update Failed } else { // Save old values $rsold = &$rs->fields; $this->LoadDbValues($rsold); $rsnew = array(); // idkAccomodation $this->idkAccomodation->SetDbValueDef($rsnew, $this->idkAccomodation->CurrentValue, 0, $this->idkAccomodation->ReadOnly); // idkSeeker $this->idkSeeker->SetDbValueDef($rsnew, $this->idkSeeker->CurrentValue, 0, $this->idkSeeker->ReadOnly); // Date_ass $this->Date_ass->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->Date_ass->CurrentValue, 7), NULL, $this->Date_ass->ReadOnly); // Date_end $this->Date_end->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->Date_end->CurrentValue, 7), NULL, $this->Date_end->ReadOnly); // Check referential integrity for master table 'tospiti' $bValidMasterRecord = TRUE; $sMasterFilter = $this->SqlMasterFilter_tospiti(); $KeyValue = isset($rsnew['idkSeeker']) ? $rsnew['idkSeeker'] : $rsold['idkSeeker']; if (strval($KeyValue) <> "") { $sMasterFilter = str_replace("@idSeeker@", ew_AdjustSql($KeyValue), $sMasterFilter); } else { $bValidMasterRecord = FALSE; } if ($bValidMasterRecord) { if (!isset($GLOBALS["tospiti"])) $GLOBALS["tospiti"] = new ctospiti(); $rsmaster = $GLOBALS["tospiti"]->LoadRs($sMasterFilter); $bValidMasterRecord = ($rsmaster && !$rsmaster->EOF); $rsmaster->Close(); } if (!$bValidMasterRecord) { $sRelatedRecordMsg = str_replace("%t", "tospiti", $Language->Phrase("RelatedRecordRequired")); $this->setFailureMessage($sRelatedRecordMsg); $rs->Close(); return FALSE; } // Check referential integrity for master table 'taccomodations' $bValidMasterRecord = TRUE; $sMasterFilter = $this->SqlMasterFilter_taccomodations(); $KeyValue = isset($rsnew['idkAccomodation']) ? $rsnew['idkAccomodation'] : $rsold['idkAccomodation']; if (strval($KeyValue) <> "") { $sMasterFilter = str_replace("@idAccomodation@", ew_AdjustSql($KeyValue), $sMasterFilter); } else { $bValidMasterRecord = FALSE; } if ($bValidMasterRecord) { if (!isset($GLOBALS["taccomodations"])) $GLOBALS["taccomodations"] = new ctaccomodations(); $rsmaster = $GLOBALS["taccomodations"]->LoadRs($sMasterFilter); $bValidMasterRecord = ($rsmaster && !$rsmaster->EOF); $rsmaster->Close(); } if (!$bValidMasterRecord) { $sRelatedRecordMsg = str_replace("%t", "taccomodations", $Language->Phrase("RelatedRecordRequired")); $this->setFailureMessage($sRelatedRecordMsg); $rs->Close(); return FALSE; } // Call Row Updating event $bUpdateRow = $this->Row_Updating($rsold, $rsnew); if ($bUpdateRow) { $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"]; if (count($rsnew) > 0) $EditRow = $this->Update($rsnew, "", $rsold); else $EditRow = TRUE; // No field to update $conn->raiseErrorFn = ''; if ($EditRow) { } } 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("UpdateCancelled")); } $EditRow = FALSE; } } // Call Row_Updated event if ($EditRow) $this->Row_Updated($rsold, $rsnew); $rs->Close(); return $EditRow; } // Add record function AddRow($rsold = NULL) { global $Language, $Security; // Set up foreign key field value from Session if ($this->getCurrentMasterTable() == "tospiti") { $this->idkSeeker->CurrentValue = $this->idkSeeker->getSessionValue(); } if ($this->getCurrentMasterTable() == "taccomodations") { $this->idkAccomodation->CurrentValue = $this->idkAccomodation->getSessionValue(); } // Check referential integrity for master table 'tospiti' $bValidMasterRecord = TRUE; $sMasterFilter = $this->SqlMasterFilter_tospiti(); if (strval($this->idkSeeker->CurrentValue) <> "") { $sMasterFilter = str_replace("@idSeeker@", ew_AdjustSql($this->idkSeeker->CurrentValue, "DB"), $sMasterFilter); } else { $bValidMasterRecord = FALSE; } if ($bValidMasterRecord) { if (!isset($GLOBALS["tospiti"])) $GLOBALS["tospiti"] = new ctospiti(); $rsmaster = $GLOBALS["tospiti"]->LoadRs($sMasterFilter); $bValidMasterRecord = ($rsmaster && !$rsmaster->EOF); $rsmaster->Close(); } if (!$bValidMasterRecord) { $sRelatedRecordMsg = str_replace("%t", "tospiti", $Language->Phrase("RelatedRecordRequired")); $this->setFailureMessage($sRelatedRecordMsg); return FALSE; } // Check referential integrity for master table 'taccomodations' $bValidMasterRecord = TRUE; $sMasterFilter = $this->SqlMasterFilter_taccomodations(); if (strval($this->idkAccomodation->CurrentValue) <> "") { $sMasterFilter = str_replace("@idAccomodation@", ew_AdjustSql($this->idkAccomodation->CurrentValue, "DB"), $sMasterFilter); } else { $bValidMasterRecord = FALSE; } if ($bValidMasterRecord) { if (!isset($GLOBALS["taccomodations"])) $GLOBALS["taccomodations"] = new ctaccomodations(); $rsmaster = $GLOBALS["taccomodations"]->LoadRs($sMasterFilter); $bValidMasterRecord = ($rsmaster && !$rsmaster->EOF); $rsmaster->Close(); } if (!$bValidMasterRecord) { $sRelatedRecordMsg = str_replace("%t", "taccomodations", $Language->Phrase("RelatedRecordRequired")); $this->setFailureMessage($sRelatedRecordMsg); return FALSE; } $conn = &$this->Connection(); // Load db values from rsold if ($rsold) { $this->LoadDbValues($rsold); } $rsnew = array(); // idkAccomodation $this->idkAccomodation->SetDbValueDef($rsnew, $this->idkAccomodation->CurrentValue, 0, FALSE); // idkSeeker $this->idkSeeker->SetDbValueDef($rsnew, $this->idkSeeker->CurrentValue, 0, FALSE); // Date_ass $this->Date_ass->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->Date_ass->CurrentValue, 7), NULL, FALSE); // Date_end $this->Date_end->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->Date_end->CurrentValue, 7), 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) { } } 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); } return $AddRow; } // Set up master/detail based on QueryString function SetUpMasterParms() { // Hide foreign keys $sMasterTblVar = $this->getCurrentMasterTable(); if ($sMasterTblVar == "tospiti") { $this->idkSeeker->Visible = FALSE; if ($GLOBALS["tospiti"]->EventCancelled) $this->EventCancelled = TRUE; } if ($sMasterTblVar == "taccomodations") { $this->idkAccomodation->Visible = FALSE; if ($GLOBALS["taccomodations"]->EventCancelled) $this->EventCancelled = TRUE; } $this->DbMasterFilter = $this->GetMasterFilter(); // Get master filter $this->DbDetailFilter = $this->GetDetailFilter(); // Get detail filter } // Setup lookup filters of a field function SetupLookupFilters($fld, $pageId = null) { global $gsLanguage; $pageId = $pageId ?: $this->PageID; switch ($fld->FldVar) { case "x_idkAccomodation": $sSqlWrk = ""; switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idAccomodation` AS `LinkFld`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = "{filter}"; $this->idkAccomodation->LookupFilters = array(); break; case "it": $sSqlWrk = "SELECT `idAccomodation` AS `LinkFld`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = "{filter}"; $this->idkAccomodation->LookupFilters = array(); break; default: $sSqlWrk = "SELECT `idAccomodation` AS `LinkFld`, `Town` AS `DispFld`, `Address` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `taccomodations`"; $sWhereWrk = "{filter}"; $this->idkAccomodation->LookupFilters = array(); break; } $fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`idAccomodation` = {filter_value}', "t0" => "19", "fn0" => ""); $sSqlWrk = ""; $this->Lookup_Selecting($this->idkAccomodation, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; if ($sSqlWrk <> "") $fld->LookupFilters["s"] .= $sSqlWrk; break; case "x_idkSeeker": $sSqlWrk = ""; switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idSeeker` AS `LinkFld`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "{filter}"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; case "it": $sSqlWrk = "SELECT `idSeeker` AS `LinkFld`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "{filter}"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; default: $sSqlWrk = "SELECT `idSeeker` AS `LinkFld`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "{filter}"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; } $fld->LookupFilters += array("s" => $sSqlWrk, "d" => "", "f0" => '`idSeeker` = {filter_value}', "t0" => "19", "fn0" => ""); $sSqlWrk = ""; $this->Lookup_Selecting($this->idkSeeker, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; 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_idkAccomodation": $sSqlWrk = ""; switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld` FROM `taccomodations`"; $sWhereWrk = "`Town` LIKE '{query_value}%' OR CONCAT(`Town`,'" . ew_ValueSeparator(1, $this->idkAccomodation) . "',`Address`) LIKE '{query_value}%'"; $this->idkAccomodation->LookupFilters = array(); break; case "it": $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld` FROM `taccomodations`"; $sWhereWrk = "`Town` LIKE '{query_value}%' OR CONCAT(`Town`,'" . ew_ValueSeparator(1, $this->idkAccomodation) . "',`Address`) LIKE '{query_value}%'"; $this->idkAccomodation->LookupFilters = array(); break; default: $sSqlWrk = "SELECT `idAccomodation`, `Town` AS `DispFld`, `Address` AS `Disp2Fld` FROM `taccomodations`"; $sWhereWrk = "`Town` LIKE '{query_value}%' OR CONCAT(`Town`,'" . ew_ValueSeparator(1, $this->idkAccomodation) . "',`Address`) LIKE '{query_value}%'"; $this->idkAccomodation->LookupFilters = array(); break; } $fld->LookupFilters += array("s" => $sSqlWrk, "d" => ""); $sSqlWrk = ""; $this->Lookup_Selecting($this->idkAccomodation, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $sSqlWrk .= " LIMIT " . EW_AUTO_SUGGEST_MAX_ENTRIES; if ($sSqlWrk <> "") $fld->LookupFilters["s"] .= $sSqlWrk; break; case "x_idkSeeker": $sSqlWrk = ""; switch (@$gsLanguage) { case "en": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "`Name` LIKE '{query_value}%' OR CONCAT(`Name`,'" . ew_ValueSeparator(1, $this->idkSeeker) . "',`Surname`,'" . ew_ValueSeparator(2, $this->idkSeeker) . "'," . ew_CastDateFieldForLike('`BirthDate`', 7, "DB") . ",'" . ew_ValueSeparator(3, $this->idkSeeker) . "',`BirthPlace`) LIKE '{query_value}%'"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; case "it": $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "`Name` LIKE '{query_value}%' OR CONCAT(`Name`,'" . ew_ValueSeparator(1, $this->idkSeeker) . "',`Surname`,'" . ew_ValueSeparator(2, $this->idkSeeker) . "'," . ew_CastDateFieldForLike('`BirthDate`', 7, "DB") . ",'" . ew_ValueSeparator(3, $this->idkSeeker) . "',`BirthPlace`) LIKE '{query_value}%'"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; default: $sSqlWrk = "SELECT `idSeeker`, `Name` AS `DispFld`, `Surname` AS `Disp2Fld`, `BirthDate` AS `Disp3Fld`, `BirthPlace` AS `Disp4Fld` FROM `tospiti`"; $sWhereWrk = "`Name` LIKE '{query_value}%' OR CONCAT(`Name`,'" . ew_ValueSeparator(1, $this->idkSeeker) . "',`Surname`,'" . ew_ValueSeparator(2, $this->idkSeeker) . "'," . ew_CastDateFieldForLike('`BirthDate`', 7, "DB") . ",'" . ew_ValueSeparator(3, $this->idkSeeker) . "',`BirthPlace`) LIKE '{query_value}%'"; $this->idkSeeker->LookupFilters = array("df3" => "7"); break; } $fld->LookupFilters += array("s" => $sSqlWrk, "d" => ""); $sSqlWrk = ""; $this->Lookup_Selecting($this->idkSeeker, $sWhereWrk); // Call Lookup selecting if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $sSqlWrk .= " LIMIT " . EW_AUTO_SUGGEST_MAX_ENTRIES; 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; } } ?>