UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token return $PageUrl; } // Message function getMessage() { return @$_SESSION[EW_SESSION_MESSAGE]; } function setMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v); } function getFailureMessage() { return @$_SESSION[EW_SESSION_FAILURE_MESSAGE]; } function setFailureMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v); } function getSuccessMessage() { return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE]; } function setSuccessMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v); } function getWarningMessage() { return @$_SESSION[EW_SESSION_WARNING_MESSAGE]; } function setWarningMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v); } // Show message function ShowMessage() { $hidden = FALSE; $html = ""; // Message $sMessage = $this->getMessage(); $this->Message_Showing($sMessage, ""); if ($sMessage <> "") { // Message in Session, display $html .= "
" . $sMessage . "
"; $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session } // Warning message $sWarningMessage = $this->getWarningMessage(); $this->Message_Showing($sWarningMessage, "warning"); if ($sWarningMessage <> "") { // Message in Session, display $html .= "" . $sWarningMessage . " |
" . $sSuccessMessage . " |
" . $sErrorMessage . " |
" . $sHeader . "
"; } } // Show Page Footer function ShowPageFooter() { $sFooter = $this->PageFooter; $this->Page_DataRendered($sFooter); if ($sFooter <> "") { // Fotoer 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; } } // // Page class constructor // function __construct() { global $conn, $Language, $UserAgent; // User agent $UserAgent = ew_UserAgent(); $GLOBALS["Page"] = &$this; // Language object if (!isset($Language)) $Language = new cLanguage(); // Parent constuctor parent::__construct(); // Table object (dog) if (!isset($GLOBALS["dog"])) { $GLOBALS["dog"] = &$this; $GLOBALS["Table"] = &$GLOBALS["dog"]; } // Table object (dealers) if (!isset($GLOBALS['dealers'])) $GLOBALS['dealers'] = new cdealers(); // Table object (owner) if (!isset($GLOBALS['owner'])) $GLOBALS['owner'] = new cowner(); // Table object (sales) if (!isset($GLOBALS['sales'])) $GLOBALS['sales'] = new csales(); // Page ID if (!defined("EW_PAGE_ID")) define("EW_PAGE_ID", 'add', TRUE); // Table name (for backward compatibility) if (!defined("EW_TABLE_NAME")) define("EW_TABLE_NAME", 'dog', TRUE); // Start timer if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer(); // Open connection if (!isset($conn)) $conn = ew_Connect(); } // // Page_Init // function Page_Init() { global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm; // Security $Security = new cAdvancedSecurity(); if (!$Security->IsLoggedIn()) $Security->AutoLogin(); # if (!$Security->IsLoggedIn()) { # $Security->SaveLastUrl(); # $this->Page_Terminate("login.php"); # } $Security->TablePermission_Loading(); # $Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName); # $Security->TablePermission_Loaded(); # if (!$Security->IsLoggedIn()) { # $Security->SaveLastUrl(); # $this->Page_Terminate("login.php"); # } # if (!$Security->CanAdd()) { # $Security->SaveLastUrl(); # $this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission # $this->Page_Terminate("doglist.php"); # } # $Security->UserID_Loading(); # if ($Security->IsLoggedIn()) $Security->LoadUserID(); # $Security->UserID_Loaded(); # if ($Security->IsLoggedIn() && strval($Security->CurrentUserID()) == "") { # $this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission # $this->Page_Terminate("doglist.php"); # } // Create form object $objForm = new cFormObj(); $this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Global Page Loading event (in userfn*.php) Page_Loading(); // Page Load event $this->Page_Load(); } // // Page_Terminate // function Page_Terminate($url = "") { global $conn; // Page Unload event $this->Page_Unload(); // Global Page Unloaded event (in userfn*.php) Page_Unloaded(); $this->Page_Redirecting($url); // Close connection $conn->Close(); // Go to URL if specified if ($url <> "") { if (!EW_DEBUG_ENABLED && ob_get_length()) ob_end_clean(); header("Location: " . $url); } exit(); } var $DbMasterFilter = ""; var $DbDetailFilter = ""; var $Priv = 0; var $OldRecordset; var $CopyRecord; // // Page main // function Page_Main() { global $objForm, $Language, $gsFormError; // Process form if post back if (@$_POST["a_add"] <> "") { $this->CurrentAction = $_POST["a_add"]; // Get form action $this->CopyRecord = $this->LoadOldRecord(); // Load old recordset $this->LoadFormValues(); // Load form values } else { // Not post back // Load key values from QueryString $this->CopyRecord = TRUE; if (@$_GET["dog_id"] != "") { $this->dog_id->setQueryStringValue($_GET["dog_id"]); $this->setKey("dog_id", $this->dog_id->CurrentValue); // Set up key } else { $this->setKey("dog_id", ""); // Clear key $this->CopyRecord = FALSE; } if ($this->CopyRecord) { $this->CurrentAction = "C"; // Copy record } else { $this->CurrentAction = "I"; // Display blank record $this->LoadDefaultValues(); // Load default values } } // Validate form if post back if (@$_POST["a_add"] <> "") { if (!$this->ValidateForm()) { $this->CurrentAction = "I"; // Form error, reset action $this->EventCancelled = TRUE; // Event cancelled $this->RestoreFormValues(); // Restore form values $this->setFailureMessage($gsFormError); } } // Perform action based on action code switch ($this->CurrentAction) { case "I": // Blank record, no action required break; case "C": // Copy an existing record if (!$this->LoadRow()) { // Load record based on key if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found $this->Page_Terminate("doglist.php"); // No matching record, return to list } break; case "A": // Add new record $this->SendEmail = TRUE; // Send email on add success if ($this->AddRow($this->OldRecordset)) { // Add successful if ($this->getSuccessMessage() == "") $this->setSuccessMessage($Language->Phrase("AddSuccess")); // Set up success message $sReturnUrl = $this->getReturnUrl(); if (ew_GetPageName($sReturnUrl) == "dogview.php") $sReturnUrl = $this->GetViewUrl(); // View paging, return to view page with keyurl directly $this->Page_Terminate($sReturnUrl); // Clean up and return } else { $this->EventCancelled = TRUE; // Event cancelled $this->RestoreFormValues(); // Add failed, restore form values } } // Render row based on row type $this->RowType = EW_ROWTYPE_ADD; // Render add type // Render row $this->ResetAttrs(); $this->RenderRow(); } // Get upload files function GetUploadFiles() { global $objForm; // Get upload data $index = $objForm->Index; // Save form index $objForm->Index = -1; $confirmPage = (strval($objForm->GetValue("a_confirm")) <> ""); $objForm->Index = $index; // Restore form index } // Load default values function LoadDefaultValues() { $this->dealer_id->CurrentValue = CurrentUserID(); $this->submit_date->CurrentValue = Date('Y/d/m'); $this->first_name->CurrentValue = NULL; $this->first_name->OldValue = $this->first_name->CurrentValue; $this->last_name->CurrentValue = NULL; $this->last_name->OldValue = $this->last_name->CurrentValue; $this->address->CurrentValue = NULL; $this->address->OldValue = $this->address->CurrentValue; $this->city->CurrentValue = NULL; $this->city->OldValue = $this->city->CurrentValue; $this->state->CurrentValue = NULL; $this->state->OldValue = $this->state->CurrentValue; $this->zip->CurrentValue = NULL; $this->zip->OldValue = $this->zip->CurrentValue; $this->home_phone->CurrentValue = NULL; $this->home_phone->OldValue = $this->home_phone->CurrentValue; $this->work_phone->CurrentValue = NULL; $this->work_phone->OldValue = $this->work_phone->CurrentValue; $this->_email->CurrentValue = NULL; $this->_email->OldValue = $this->_email->CurrentValue; $this->password->CurrentValue = NULL; $this->password->OldValue = $this->password->CurrentValue; $this->d2->CurrentValue = NULL; $this->d2->OldValue = $this->d2->CurrentValue; $this->d1->CurrentValue = NULL; $this->d1->OldValue = $this->d1->CurrentValue; $this->car_lot->CurrentValue = NULL; $this->car_lot->OldValue = $this->car_lot->CurrentValue; } // Load form values function LoadFormValues() { // Load from form global $objForm; if (!$this->dealer_id->FldIsDetailKey) { $this->dealer_id->setFormValue($objForm->GetValue("x_dealer_id")); } if (!$this->submit_date->FldIsDetailKey) { $this->submit_date->setFormValue($objForm->GetValue("x_submit_date")); $this->submit_date->CurrentValue = ew_UnFormatDateTime($this->submit_date->CurrentValue, 5); } if (!$this->first_name->FldIsDetailKey) { $this->first_name->setFormValue($objForm->GetValue("x_first_name")); } if (!$this->last_name->FldIsDetailKey) { $this->last_name->setFormValue($objForm->GetValue("x_last_name")); } if (!$this->address->FldIsDetailKey) { $this->address->setFormValue($objForm->GetValue("x_address")); } if (!$this->city->FldIsDetailKey) { $this->city->setFormValue($objForm->GetValue("x_city")); } if (!$this->state->FldIsDetailKey) { $this->state->setFormValue($objForm->GetValue("x_state")); } if (!$this->zip->FldIsDetailKey) { $this->zip->setFormValue($objForm->GetValue("x_zip")); } if (!$this->home_phone->FldIsDetailKey) { $this->home_phone->setFormValue($objForm->GetValue("x_home_phone")); } if (!$this->work_phone->FldIsDetailKey) { $this->work_phone->setFormValue($objForm->GetValue("x_work_phone")); } if (!$this->_email->FldIsDetailKey) { $this->_email->setFormValue($objForm->GetValue("x__email")); } if (!$this->password->FldIsDetailKey) { $this->password->setFormValue($objForm->GetValue("x_password")); } if (!$this->d2->FldIsDetailKey) { $this->d2->setFormValue($objForm->GetValue("x_d2")); } if (!$this->d1->FldIsDetailKey) { $this->d1->setFormValue($objForm->GetValue("x_d1")); } if (!$this->car_lot->FldIsDetailKey) { $this->car_lot->setFormValue($objForm->GetValue("x_car_lot")); } } // Restore form values function RestoreFormValues() { global $objForm; $this->LoadOldRecord(); $this->dealer_id->CurrentValue = $this->dealer_id->FormValue; $this->submit_date->CurrentValue = $this->submit_date->FormValue; $this->submit_date->CurrentValue = ew_UnFormatDateTime($this->submit_date->CurrentValue, 5); $this->first_name->CurrentValue = $this->first_name->FormValue; $this->last_name->CurrentValue = $this->last_name->FormValue; $this->address->CurrentValue = $this->address->FormValue; $this->city->CurrentValue = $this->city->FormValue; $this->state->CurrentValue = $this->state->FormValue; $this->zip->CurrentValue = $this->zip->FormValue; $this->home_phone->CurrentValue = $this->home_phone->FormValue; $this->work_phone->CurrentValue = $this->work_phone->FormValue; $this->_email->CurrentValue = $this->_email->FormValue; $this->password->CurrentValue = $this->password->FormValue; $this->d2->CurrentValue = $this->d2->FormValue; $this->d1->CurrentValue = $this->d1->FormValue; $this->car_lot->CurrentValue = $this->car_lot->FormValue; } // Load row based on key values function LoadRow() { global $conn, $Security, $Language; $sFilter = $this->KeyFilter(); // Call Row Selecting event $this->Row_Selecting($sFilter); // Load SQL based on filter $this->CurrentFilter = $sFilter; $sSql = $this->SQL(); $res = FALSE; $rs = ew_LoadRecordset($sSql); if ($rs && !$rs->EOF) { $res = TRUE; $this->LoadRowValues($rs); // Load row values $rs->Close(); } // Check if valid user id if ($res) { $res = $this->ShowOptionLink('add'); if (!$res) { $sUserIdMsg = $Language->Phrase("NoPermission"); $this->setFailureMessage($sUserIdMsg); } } return $res; } // Load row values from recordset function LoadRowValues(&$rs) { global $conn; if (!$rs || $rs->EOF) return; // Call Row Selected event $row = &$rs->fields; $this->Row_Selected($row); $this->dog_id->setDbValue($rs->fields('dog_id')); $this->dealer_id->setDbValue($rs->fields('dealer_id')); $this->dog_tag_id->setDbValue($rs->fields('dog_tag_id')); $this->dogid->setDbValue($rs->fields('dogid')); $this->submit_date->setDbValue($rs->fields('submit_date')); $this->first_name->setDbValue($rs->fields('first_name')); $this->last_name->setDbValue($rs->fields('last_name')); $this->address->setDbValue($rs->fields('address')); $this->city->setDbValue($rs->fields('city')); $this->state->setDbValue($rs->fields('state')); $this->zip->setDbValue($rs->fields('zip')); $this->home_phone->setDbValue($rs->fields('home_phone')); $this->work_phone->setDbValue($rs->fields('work_phone')); $this->_email->setDbValue($rs->fields('email')); $this->password->setDbValue($rs->fields('password')); $this->social_sec->setDbValue($rs->fields('social_sec')); $this->d2->setDbValue($rs->fields('d2')); $this->d1->setDbValue($rs->fields('d1')); $this->car_lot->setDbValue($rs->fields('car_lot')); } // Load old record function LoadOldRecord() { // Load key values from Session $bValidKey = TRUE; if (strval($this->getKey("dog_id")) <> "") $this->dog_id->CurrentValue = $this->getKey("dog_id"); // dog_id else $bValidKey = FALSE; // Load old recordset if ($bValidKey) { $this->CurrentFilter = $this->KeyFilter(); $sSql = $this->SQL(); $this->OldRecordset = ew_LoadRecordset($sSql); $this->LoadRowValues($this->OldRecordset); // Load row values } else { $this->OldRecordset = NULL; } return $bValidKey; } // Render row values based on field settings function RenderRow() { global $conn, $Security, $Language; global $gsLanguage; // Initialize URLs // Call Row_Rendering event $this->Row_Rendering(); // Common render codes for all row types // dog_id // dealer_id // dog_tag_id // dogid // submit_date // first_name // last_name // address // city // state // zip // home_phone // work_phone // email // password // social_sec // d2 // d1 // car_lot if ($this->RowType == EW_ROWTYPE_VIEW) { // View row // dog_id $this->dog_id->ViewValue = $this->dog_id->CurrentValue; $this->dog_id->ViewCustomAttributes = ""; // dealer_id $this->dealer_id->ViewValue = $this->dealer_id->CurrentValue; $this->dealer_id->ViewCustomAttributes = ""; // dog_tag_id $this->dog_tag_id->ViewValue = $this->dog_tag_id->CurrentValue; $this->dog_tag_id->ViewCustomAttributes = ""; // dogid $this->dogid->ViewValue = $this->dogid->CurrentValue; $this->dogid->ViewCustomAttributes = ""; // submit_date $this->submit_date->ViewValue = $this->submit_date->CurrentValue; $this->submit_date->ViewValue = ew_FormatDateTime($this->submit_date->ViewValue, 5); $this->submit_date->ViewCustomAttributes = ""; // first_name $this->first_name->ViewValue = $this->first_name->CurrentValue; $this->first_name->ViewCustomAttributes = ""; // last_name $this->last_name->ViewValue = $this->last_name->CurrentValue; $this->last_name->ViewCustomAttributes = ""; // address $this->address->ViewValue = $this->address->CurrentValue; $this->address->ViewCustomAttributes = ""; // city $this->city->ViewValue = $this->city->CurrentValue; $this->city->ViewCustomAttributes = ""; // state $this->state->ViewValue = $this->state->CurrentValue; $this->state->ViewCustomAttributes = ""; // zip $this->zip->ViewValue = $this->zip->CurrentValue; $this->zip->ViewCustomAttributes = ""; // home_phone $this->home_phone->ViewValue = $this->home_phone->CurrentValue; $this->home_phone->ViewCustomAttributes = ""; // work_phone $this->work_phone->ViewValue = $this->work_phone->CurrentValue; $this->work_phone->ViewCustomAttributes = ""; // email $this->_email->ViewValue = $this->_email->CurrentValue; $this->_email->ViewCustomAttributes = ""; // password $this->password->ViewValue = $this->password->CurrentValue; $this->password->ViewCustomAttributes = ""; // social_sec $this->social_sec->ViewValue = $this->social_sec->CurrentValue; $this->social_sec->ViewCustomAttributes = ""; // d2 if (strval($this->d2->CurrentValue) <> "") { $this->d2->ViewValue = ""; $arwrk = explode(",", strval($this->d2->CurrentValue)); $cnt = count($arwrk); for ($ari = 0; $ari < $cnt; $ari++) { switch (trim($arwrk[$ari])) { case $this->d2->FldTagValue(1): $this->d2->ViewValue .= $this->d2->FldTagCaption(1) <> "" ? $this->d2->FldTagCaption(1) : trim($arwrk[$ari]); break; default: $this->d2->ViewValue .= trim($arwrk[$ari]); } if ($ari < $cnt-1) $this->d2->ViewValue .= ew_ViewOptionSeparator($ari); } } else { $this->d2->ViewValue = NULL; } $this->d2->ViewCustomAttributes = ""; // d1 if (strval($this->d1->CurrentValue) <> "") { $sFilterWrk = "`name`" . ew_SearchString("=", $this->d1->CurrentValue, EW_DATATYPE_STRING); $sSqlWrk = "SELECT DISTINCT `name`, `name` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sales`"; $sWhereWrk = ""; $lookuptblfilter = "`dealer_id` = '".CurrentUserID()."'"; if (strval($lookuptblfilter) <> "") { ew_AddFilter($sWhereWrk, $lookuptblfilter); } if ($sFilterWrk <> "") { ew_AddFilter($sWhereWrk, $sFilterWrk); } if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $sSqlWrk .= " ORDER BY `name` ASC"; $rswrk = $conn->Execute($sSqlWrk); if ($rswrk && !$rswrk->EOF) { // Lookup values found $this->d1->ViewValue = $rswrk->fields('DispFld'); $rswrk->Close(); } else { $this->d1->ViewValue = $this->d1->CurrentValue; } } else { $this->d1->ViewValue = NULL; } $this->d1->ViewCustomAttributes = ""; // car_lot $this->car_lot->ViewValue = $this->car_lot->CurrentValue; $this->car_lot->ViewCustomAttributes = ""; // dealer_id $this->dealer_id->LinkCustomAttributes = ""; $this->dealer_id->HrefValue = ""; $this->dealer_id->TooltipValue = ""; // submit_date $this->submit_date->LinkCustomAttributes = ""; $this->submit_date->HrefValue = ""; $this->submit_date->TooltipValue = ""; // first_name $this->first_name->LinkCustomAttributes = ""; $this->first_name->HrefValue = ""; $this->first_name->TooltipValue = ""; // last_name $this->last_name->LinkCustomAttributes = ""; $this->last_name->HrefValue = ""; $this->last_name->TooltipValue = ""; // address $this->address->LinkCustomAttributes = ""; $this->address->HrefValue = ""; $this->address->TooltipValue = ""; // city $this->city->LinkCustomAttributes = ""; $this->city->HrefValue = ""; $this->city->TooltipValue = ""; // state $this->state->LinkCustomAttributes = ""; $this->state->HrefValue = ""; $this->state->TooltipValue = ""; // zip $this->zip->LinkCustomAttributes = ""; $this->zip->HrefValue = ""; $this->zip->TooltipValue = ""; // home_phone $this->home_phone->LinkCustomAttributes = ""; $this->home_phone->HrefValue = ""; $this->home_phone->TooltipValue = ""; // work_phone $this->work_phone->LinkCustomAttributes = ""; $this->work_phone->HrefValue = ""; $this->work_phone->TooltipValue = ""; // email $this->_email->LinkCustomAttributes = ""; $this->_email->HrefValue = ""; $this->_email->TooltipValue = ""; // password $this->password->LinkCustomAttributes = ""; $this->password->HrefValue = ""; $this->password->TooltipValue = ""; // d2 $this->d2->LinkCustomAttributes = ""; if (!ew_Empty($this->dealer_id->CurrentValue)) { $this->d2->HrefValue = ((!empty($this->dealer_id->ViewValue)) ? $this->dealer_id->ViewValue : $this->dealer_id->CurrentValue); // Add prefix/suffix $this->d2->LinkAttrs["target"] = ""; // Add target if ($this->Export <> "") $this->d2->HrefValue = ew_ConvertFullUrl($this->d2->HrefValue); } else { $this->d2->HrefValue = ""; } $this->d2->TooltipValue = ""; // d1 $this->d1->LinkCustomAttributes = ""; $this->d1->HrefValue = ""; $this->d1->TooltipValue = ""; // car_lot $this->car_lot->LinkCustomAttributes = ""; $this->car_lot->HrefValue = ""; $this->car_lot->TooltipValue = ""; } elseif ($this->RowType == EW_ROWTYPE_ADD) { // Add row // dealer_id $this->dealer_id->EditCustomAttributes = ""; $this->dealer_id->CurrentValue = CurrentUserID(); // submit_date $this->submit_date->EditCustomAttributes = ""; $this->submit_date->CurrentValue = ew_FormatDateTime(Date('Y/d/m'), 5); // first_name $this->first_name->EditCustomAttributes = ""; $this->first_name->EditValue = ew_HtmlEncode($this->first_name->CurrentValue); // last_name $this->last_name->EditCustomAttributes = ""; $this->last_name->EditValue = ew_HtmlEncode($this->last_name->CurrentValue); // address $this->address->EditCustomAttributes = ""; $this->address->EditValue = ew_HtmlEncode($this->address->CurrentValue); // city $this->city->EditCustomAttributes = ""; $this->city->EditValue = ew_HtmlEncode($this->city->CurrentValue); // state $this->state->EditCustomAttributes = ""; $this->state->EditValue = ew_HtmlEncode($this->state->CurrentValue); // zip $this->zip->EditCustomAttributes = ""; $this->zip->EditValue = ew_HtmlEncode($this->zip->CurrentValue); // home_phone $this->home_phone->EditCustomAttributes = ""; $this->home_phone->EditValue = ew_HtmlEncode($this->home_phone->CurrentValue); // work_phone $this->work_phone->EditCustomAttributes = ""; $this->work_phone->EditValue = ew_HtmlEncode($this->work_phone->CurrentValue); // email $this->_email->EditCustomAttributes = ""; $this->_email->EditValue = ew_HtmlEncode($this->_email->CurrentValue); // password $this->password->EditCustomAttributes = ""; $this->password->EditValue = ew_HtmlEncode($this->password->CurrentValue); // d2 $this->d2->EditCustomAttributes = ""; $arwrk = array(); $arwrk[] = array($this->d2->FldTagValue(1), $this->d2->FldTagCaption(1) <> "" ? $this->d2->FldTagCaption(1) : $this->d2->FldTagValue(1)); $this->d2->EditValue = $arwrk; // d1 $this->d1->EditCustomAttributes = ""; $sFilterWrk = ""; $sSqlWrk = "SELECT DISTINCT `name`, `name` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, `dealer_id` AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sales`"; $sWhereWrk = ""; $lookuptblfilter = "`dealer_id` = '".CurrentUserID()."'"; if (strval($lookuptblfilter) <> "") { ew_AddFilter($sWhereWrk, $lookuptblfilter); } if ($sFilterWrk <> "") { ew_AddFilter($sWhereWrk, $sFilterWrk); } if (!$GLOBALS["dog"]->UserIDAllow("add")) $sWhereWrk = $GLOBALS["sales"]->AddUserIDFilter($sWhereWrk); if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk; $sSqlWrk .= " ORDER BY `name` ASC"; $rswrk = $conn->Execute($sSqlWrk); $arwrk = ($rswrk) ? $rswrk->GetRows() : array(); if ($rswrk) $rswrk->Close(); array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", "")); $this->d1->EditValue = $arwrk; // car_lot $this->car_lot->EditCustomAttributes = ""; $this->car_lot->EditValue = ew_HtmlEncode($this->car_lot->CurrentValue); // Edit refer script // dealer_id $this->dealer_id->HrefValue = ""; // submit_date $this->submit_date->HrefValue = ""; // first_name $this->first_name->HrefValue = ""; // last_name $this->last_name->HrefValue = ""; // address $this->address->HrefValue = ""; // city $this->city->HrefValue = ""; // state $this->state->HrefValue = ""; // zip $this->zip->HrefValue = ""; // home_phone $this->home_phone->HrefValue = ""; // work_phone $this->work_phone->HrefValue = ""; // email $this->_email->HrefValue = ""; // password $this->password->HrefValue = ""; // d2 if (!ew_Empty($this->dealer_id->CurrentValue)) { $this->d2->HrefValue = ((!empty($this->dealer_id->EditValue)) ? $this->dealer_id->EditValue : $this->dealer_id->CurrentValue); // Add prefix/suffix $this->d2->LinkAttrs["target"] = ""; // Add target if ($this->Export <> "") $this->d2->HrefValue = ew_ConvertFullUrl($this->d2->HrefValue); } else { $this->d2->HrefValue = ""; } // d1 $this->d1->HrefValue = ""; // car_lot $this->car_lot->HrefValue = ""; } if ($this->RowType == EW_ROWTYPE_ADD || $this->RowType == EW_ROWTYPE_EDIT || $this->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row $this->SetupFieldTitles(); } // Call Row Rendered event if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT) $this->Row_Rendered(); } // Validate form function ValidateForm() { global $Language, $gsFormError; // Initialize form error message $gsFormError = ""; // Check if validation required if (!EW_SERVER_VALIDATE) return ($gsFormError == ""); if (!is_null($this->first_name->FormValue) && $this->first_name->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->first_name->FldCaption()); } if (!is_null($this->last_name->FormValue) && $this->last_name->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->last_name->FldCaption()); } if (!is_null($this->address->FormValue) && $this->address->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->address->FldCaption()); } if (!is_null($this->city->FormValue) && $this->city->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->city->FldCaption()); } if (!is_null($this->state->FormValue) && $this->state->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->state->FldCaption()); } if (!is_null($this->zip->FormValue) && $this->zip->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->zip->FldCaption()); } if (!is_null($this->home_phone->FormValue) && $this->home_phone->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->home_phone->FldCaption()); } if (!is_null($this->_email->FormValue) && $this->_email->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->_email->FldCaption()); } if (!ew_CheckEmail($this->_email->FormValue)) { ew_AddMessage($gsFormError, $this->_email->FldErrMsg()); } if (!is_null($this->password->FormValue) && $this->password->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->password->FldCaption()); } if ($this->d2->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->d2->FldCaption()); } if (!is_null($this->d1->FormValue) && $this->d1->FormValue == "") { ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $this->d1->FldCaption()); } // Return validate result $ValidateForm = ($gsFormError == ""); // Call Form_CustomValidate event $sFormCustomError = ""; $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError); if ($sFormCustomError <> "") { ew_AddMessage($gsFormError, $sFormCustomError); } return $ValidateForm; } // Add record function AddRow($rsold = NULL) { global $conn, $Language, $Security; // Check if valid User ID $bValidUser = FALSE; if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin $bValidUser = $Security->IsValidUserID($this->dealer_id->CurrentValue); if (!$bValidUser) { $sUserIdMsg = str_replace("%c", CurrentUserID(), $Language->Phrase("UnAuthorizedUserID")); $sUserIdMsg = str_replace("%u", $this->dealer_id->CurrentValue, $sUserIdMsg); $this->setFailureMessage($sUserIdMsg); return FALSE; } } $rsnew = array(); // dealer_id $this->dealer_id->SetDbValueDef($rsnew, $this->dealer_id->CurrentValue, 0, strval($this->dealer_id->CurrentValue) == ""); // submit_date $this->submit_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->submit_date->CurrentValue, 5), NULL, FALSE); // first_name $this->first_name->SetDbValueDef($rsnew, $this->first_name->CurrentValue, NULL, FALSE); // last_name $this->last_name->SetDbValueDef($rsnew, $this->last_name->CurrentValue, NULL, FALSE); // address $this->address->SetDbValueDef($rsnew, $this->address->CurrentValue, NULL, FALSE); // city $this->city->SetDbValueDef($rsnew, $this->city->CurrentValue, NULL, FALSE); // state $this->state->SetDbValueDef($rsnew, $this->state->CurrentValue, NULL, FALSE); // zip $this->zip->SetDbValueDef($rsnew, $this->zip->CurrentValue, NULL, FALSE); // home_phone $this->home_phone->SetDbValueDef($rsnew, $this->home_phone->CurrentValue, NULL, FALSE); // work_phone $this->work_phone->SetDbValueDef($rsnew, $this->work_phone->CurrentValue, NULL, FALSE); // email $this->_email->SetDbValueDef($rsnew, $this->_email->CurrentValue, NULL, FALSE); // password $this->password->SetDbValueDef($rsnew, $this->password->CurrentValue, NULL, FALSE); // d2 $this->d2->SetDbValueDef($rsnew, $this->d2->CurrentValue, NULL, FALSE); // d1 $this->d1->SetDbValueDef($rsnew, $this->d1->CurrentValue, NULL, FALSE); // car_lot $this->car_lot->SetDbValueDef($rsnew, $this->car_lot->CurrentValue, NULL, FALSE); // Call Row Inserting event $rs = ($rsold == NULL) ? NULL : $rsold->fields; $bInsertRow = $this->Row_Inserting($rs, $rsnew); if ($bInsertRow) { $conn->raiseErrorFn = 'ew_ErrorFn'; $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; } // Get insert id if necessary if ($AddRow) { $this->dog_id->setDbValue($conn->Insert_ID()); $rsnew['dog_id'] = $this->dog_id->DbValue; } if ($AddRow) { // Call Row Inserted event $rs = ($rsold == NULL) ? NULL : $rsold->fields; $this->Row_Inserted($rs, $rsnew); } return $AddRow; } // Show link optionally based on User ID function ShowOptionLink($id = "") { global $Security; if ($Security->IsLoggedIn() && !$Security->IsAdmin() && !$this->UserIDAllow($id)) return $Security->IsValidUserID($this->dealer_id->CurrentValue); return TRUE; } // 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 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; } } ?> Page_Init(); // Page main $dog_add->Page_Main(); ?>Phrase("Add") ?> Phrase("TblTypeTABLE") ?>TableCaption() ?>
ShowPageHeader(); ?> ShowMessage(); ?> ShowPageFooter(); if (EW_DEBUG_ENABLED) echo ew_DebugMsg(); ?> Page_Terminate(); ?> # <%@ LANGUAGE="VBScript" %> #" # response.write " | " # %> # |
#
#
#
# Quick Register
# |
#
# # # |
#
#
# | |
" # response.write " | " # %> # |
© 1999 Bird Dog Club®, LLC. All Rights Reserved
#