IsLoggedIn()) $Security->AutoLogin(); $Security->LoadCurrentUserLevel('products'); ?> Export = @$_GET["export"]; // Get export parameter $sExport = $products->Export; // Get export parameter, used in header $sExportFile = $products->TableVar; // Get export file, used in header ?> Export == "html") { // Printer friendly, no action required } if ($products->Export == "excel") { header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename=' . $sExportFile .'.xls'); } if ($products->Export == "word") { header('Content-Type: application/vnd.ms-word'); header('Content-Disposition: attachment; filename=' . $sExportFile .'.doc'); } if ($products->Export == "xml") { header('Content-Type: text/xml'); header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml'); } if ($products->Export == "csv") { header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv'); } ?> "") { $products->CurrentAction = $_GET["a"]; // Clear inline mode if ($products->CurrentAction == "cancel") { ClearInlineMode(); } // Switch to grid edit mode if ($products->CurrentAction == "gridedit") { GridEditMode(); } } else { // Create form object $objForm = new cFormObj; if (@$_POST["a_list"] <> "") { $products->CurrentAction = $_POST["a_list"]; // Get action // Grid Update if ($products->CurrentAction == "gridupdate" && @$_SESSION[EW_SESSION_INLINE_MODE] == "gridedit") { GridUpdate(); } } } // Get search criteria for advanced search $sSrchAdvanced = AdvancedSearchWhere(); // Build search criteria if ($sSrchAdvanced <> "") { if ($sSrchWhere <> "") $sSrchWhere .= " AND "; $sSrchWhere .= "(" . $sSrchAdvanced . ")"; } if ($sSrchBasic <> "") { if ($sSrchWhere <> "") $sSrchWhere .= " AND "; $sSrchWhere .= "(" . $sSrchBasic . ")"; } // Save search criteria if ($sSrchWhere <> "") { if ($sSrchAdvanced == "") ResetAdvancedSearchParms(); $products->setSearchWhere($sSrchWhere); // Save to Session $nStartRec = 1; // Reset start record counter $products->setStartRecordNumber($nStartRec); } else { RestoreSearchParms(); } // Build filter $sFilter = ""; if ($sDbDetailFilter <> "") { if ($sFilter <> "") $sFilter .= " AND "; $sFilter .= "(" . $sDbDetailFilter . ")"; } if ($sSrchWhere <> "") { if ($sFilter <> "") $sFilter .= " AND "; $sFilter .= "(" . $sSrchWhere . ")"; } // Load master record if ($products->getMasterFilter() <> "" && $products->getCurrentMasterTable() == "products_group") { $rsmaster = $products_group->LoadRs($sDbMasterFilter); $bMasterRecordExists = ($rsmaster && !$rsmaster->EOF); if (!$bMasterRecordExists) { $products->setMasterFilter(""); // Clear master filter $products->setDetailFilter(""); // Clear detail filter $_SESSION[EW_SESSION_MESSAGE] = "ركوردي يافت نشد"; // Set no record found Page_Terminate("products_grouplist.php"); // Return to caller } else { $products_group->LoadListRowValues($rsmaster); $products_group->RenderListRow(); $rsmaster->Close(); } } // Set up filter in Session $products->setSessionWhere($sFilter); $products->CurrentFilter = ""; // Set Up Sorting Order SetUpSortOrder(); // Export data only if ($products->Export == "xml" || $products->Export == "csv") { ExportData(); Page_Terminate(); // Terminate response } // Set Return Url $products->setReturnUrl("productslist.php"); ?> Export == "") { ?> Export == "") { ?> getMasterFilter() <> "" && $products->getCurrentMasterTable() == "products_group") { if ($bMasterRecordExists) { if ($products->getCurrentMasterTable() == $products->TableVar) $sMasterReturnUrl .= "?" . EW_TABLE_SHOW_MASTER . "="; ?> Export <> ""); $bSelectLimit = ($products->Export == "" && $products->SelectLimit); if (!$bSelectLimit) $rs = LoadRecordset(); $nTotalRecs = ($bSelectLimit) ? $products->SelectRecordCount() : $rs->RecordCount(); $nStartRec = 1; if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display همه ركوردها if (!$bExportAll) SetUpStartRec(); // Set up start record position if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs); ?> block(EW_PAGE_ID, EW_TABLE_NAME, 3); echo $block; } ?>

"") { ?>

Export == "") { ?>
CurrentAction <> "gridedit") { // Not grid edit mode ?> CanAdd()) { ?> اضافه   0) { ?> CanDelete()) { ?> حذف ركوردهاي انتخاب شده   CanEdit()) { ?> CanEdit()) { ?> 0) { ?> ذخيره   انصراف  
0) { ?> Export <> "") { $nStopRec = $nTotalRecs; } else { $nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display } $nRecCount = $nStartRec - 1; if (!$rs->EOF) { $rs->MoveFirst(); if (!$products->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly } $RowCnt = 0; if ($products->CurrentAction == "gridedit") $RowIndex = 0; while (!$rs->EOF && $nRecCount < $nStopRec) { $nRecCount++; if (intval($nRecCount) >= intval($nStartRec)) { $RowCnt++; $ColCnt++; if ($ColCnt > $nRecPerRow) $ColCnt = 1; if ($products->CurrentAction == "gridedit") $RowIndex++; // Init row class and style $products->CssClass = "ewTableRow"; $products->CssStyle = ""; // Init row event $products->RowClientEvents = ""; LoadRowValues($rs); // Load row values $products->RowType = EW_ROWTYPE_VIEW; // Render view if ($products->CurrentAction == "gridedit") { // Grid edit $products->RowType = EW_ROWTYPE_EDIT; // Render edit } if ($products->RowType == EW_ROWTYPE_EDIT && $products->EventCancelled) { // Update failed if ($products->CurrentAction == "gridedit") { RestoreCurrentRowFormValues(); // Restore form values } } if ($products->RowType == EW_ROWTYPE_EDIT) { // Edit row $products->CssClass = "ewTableEditRow"; $products->RowClientEvents = ""; } RenderRow(); ?> RowType == EW_ROWTYPE_EDIT) { ?> MoveNext(); } ?>
DisplayAttributes() ?>>
product_group->CellAttributes() ?> RowType == EW_ROWTYPE_EDIT) { // Edit Record ?> product_group->getSessionValue() <> "") { ?> product_group->ViewAttributes() ?>>product_group->ViewValue ?> product_group->ViewAttributes() ?>>product_group->ViewValue ?>
prouct_name->CellAttributes() ?> RowType == EW_ROWTYPE_EDIT) { // Edit Record ?> prouct_name->EditAttributes() ?>> prouct_name->ViewAttributes() ?>>prouct_name->ViewValue ?>
photo->CellAttributes() ?> RowType == EW_ROWTYPE_EDIT) { // Edit Record ?> photo->Upload->DbValue)) { ?> حفظ  حذف  جايگزيني
photo->EditAttributes() ?>> photo->HrefValue <> "") { ?> photo->Upload->DbValue)) { ?> photo->ViewAttributes() ?>> photo->Upload->DbValue)) { ?> photo->ViewAttributes() ?>>
RowType == EW_ROWTYPE_EDIT) { ?> CurrentAction == "gridedit") { ?> Export == "") { ?> CanEdit()) { ?> ويرايش | CanAdd()) { ?> كپي  | CanEdit() || $Security->CanDelete()) { ?>
 
Export == "") { ?> CurrentAction == "gridedit") { ?>
Close(); ?> Export == "") { ?>
0) { ?>
RecordCount > 0) { ?> FirstButton->Enabled) { ?> PrevButton->Enabled) { ?> NextButton->Enabled) { ?> LastButton->Enabled) { ?>
Page  اولين اولين قبلي قبلي بعدي بعدي آخرين آخرين  of PageCount ?>   *   Record FromIndex ?> to ToIndex ?> of RecordCount ?>
لطفا پارامترهاي جستجو را وارد كنيد ركوردي يافت نشد
     ركورد در صفحه 
Export == "") { ?> block(EW_PAGE_ID, EW_TABLE_NAME, 4); echo $block; } ?> Export == "") { ?> Close(); // Go to url if specified if ($url <> "") { ob_end_clean(); header("Location: $url"); } exit(); } ?> "") { if (is_numeric($sWrk)) { $nDisplayRecs = intval($sWrk); } else { if (strtolower($sWrk) == "all") { // Display همه ركوردها $nDisplayRecs = -1; } else { $nDisplayRecs = 20; // Non-numeric, load default } } $products->setRecordsPerPage($nDisplayRecs); // Save to Session // Reset start position $nStartRec = 1; $products->setStartRecordNumber($nStartRec); } else { if ($products->getRecordsPerPage() <> "") { $nDisplayRecs = $products->getRecordsPerPage(); // Restore from Session } else { $nDisplayRecs = 20; // Load default } } } // Exit out of inline mode function ClearInlineMode() { global $products; $products->CurrentAction = ""; // Clear action $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode } // Switch to Grid Edit Mode function GridEditMode() { $_SESSION[EW_SESSION_INLINE_MODE] = "gridedit"; // Enable grid edit } // Peform update to grid function GridUpdate() { global $conn, $objForm, $products; $rowindex = 1; $bGridUpdate = TRUE; // Begin transaction $conn->BeginTrans(); WriteAuditTrailDummy("*** batch update begin ***"); // Batch update begin $sKey = ""; // Update row index and get row key $objForm->Index = $rowindex; $sThisKey = strval($objForm->GetValue("k_key")); // Update all rows based on key while ($sThisKey <> "") { // Load all values & keys GetUploadFiles(); // Get upload files LoadFormValues(); // Get form values if (LoadKeyValues($sThisKey)) { // Get key values $products->SendEmail = FALSE; // Do not send email on update success $bGridUpdate = EditRow(); // Update this row } else { $bGridUpdate = FALSE; // update failed } if ($bGridUpdate) { if ($sKey <> "") $sKey .= ", "; $sKey .= $sThisKey; } else { break; } // Update row index and get row key $rowindex++; // next row $objForm->Index = $rowindex; $sThisKey = strval($objForm->GetValue("k_key")); } if ($bGridUpdate) { $conn->CommitTrans(); // Commit transaction WriteAuditTrailDummy("*** batch update success ***"); // Batch update success $_SESSION[EW_SESSION_MESSAGE] = "Correct operation was successful"; // Set update success message ClearInlineMode(); // Clear inline edit mode } else { $conn->RollbackTrans(); // Rollback transaction WriteAuditTrailDummy("*** batch update rollback ***"); // Batch update rollback if (@$_SESSION[EW_SESSION_MESSAGE] == "") { $_SESSION[EW_SESSION_MESSAGE] = "An error correction operation was"; // Set update failed message } $products->EventCancelled = TRUE; // Set event cancelled $products->CurrentAction = "gridedit"; // Stay in gridedit mode } } // Load key values function LoadKeyValues($sKey) { global $products; $arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, strval($sKey)); if (count($arrKeyFlds) >= 1) { $products->id->setFormValue($arrKeyFlds[0]); if (!is_numeric($products->id->FormValue)) { return FALSE; } } return TRUE; } // Restore form values for current row function RestoreCurrentRowFormValues() { global $objForm, $products; // Update row index and get row key $rowindex = 1; $objForm->Index = $rowindex; $sKey = strval($objForm->GetValue("k_key")); while ($sKey <> "") { $arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, strval($sKey)); if (count($arrKeyFlds) >= 1) { if (strval($arrKeyFlds[0]) == strval($products->id->CurrentValue)) { $objForm->Index = $rowindex; LoadFormValues(); // Load form values return; } } // Update row index and get row key $rowindex++; $objForm->Index = $rowindex; $sKey = strval($objForm->GetValue("k_key")); } } // Return Advanced Search Where based on QueryString parameters function AdvancedSearchWhere() { global $Security, $products; $sWhere = ""; // Field product_group BuildSearchSql($sWhere, $products->product_group, @$_GET["x_product_group"], @$_GET["z_product_group"], @$_GET["v_product_group"], @$_GET["y_product_group"], @$_GET["w_product_group"]); // Field prouct_name BuildSearchSql($sWhere, $products->prouct_name, @$_GET["x_prouct_name"], @$_GET["z_prouct_name"], @$_GET["v_prouct_name"], @$_GET["y_prouct_name"], @$_GET["w_prouct_name"]); // Field note2 BuildSearchSql($sWhere, $products->note2, @$_GET["x_note2"], @$_GET["z_note2"], @$_GET["v_note2"], @$_GET["y_note2"], @$_GET["w_note2"]); // Field note3 BuildSearchSql($sWhere, $products->note3, @$_GET["x_note3"], @$_GET["z_note3"], @$_GET["v_note3"], @$_GET["y_note3"], @$_GET["w_note3"]); // Field note4 BuildSearchSql($sWhere, $products->note4, @$_GET["x_note4"], @$_GET["z_note4"], @$_GET["v_note4"], @$_GET["y_note4"], @$_GET["w_note4"]); // Field note5 BuildSearchSql($sWhere, $products->note5, @$_GET["x_note5"], @$_GET["z_note5"], @$_GET["v_note5"], @$_GET["y_note5"], @$_GET["w_note5"]); //AdvancedSearchWhere = sWhere // Set up search parm if ($sWhere <> "") { // Field product_group SetSearchParm($products->product_group, @$_GET["x_product_group"], @$_GET["z_product_group"], @$_GET["v_product_group"], @$_GET["y_product_group"], @$_GET["w_product_group"]); // Field prouct_name SetSearchParm($products->prouct_name, @$_GET["x_prouct_name"], @$_GET["z_prouct_name"], @$_GET["v_prouct_name"], @$_GET["y_prouct_name"], @$_GET["w_prouct_name"]); // Field note2 SetSearchParm($products->note2, @$_GET["x_note2"], @$_GET["z_note2"], @$_GET["v_note2"], @$_GET["y_note2"], @$_GET["w_note2"]); // Field note3 SetSearchParm($products->note3, @$_GET["x_note3"], @$_GET["z_note3"], @$_GET["v_note3"], @$_GET["y_note3"], @$_GET["w_note3"]); // Field note4 SetSearchParm($products->note4, @$_GET["x_note4"], @$_GET["z_note4"], @$_GET["v_note4"], @$_GET["y_note4"], @$_GET["w_note4"]); // Field note5 SetSearchParm($products->note5, @$_GET["x_note5"], @$_GET["z_note5"], @$_GET["v_note5"], @$_GET["y_note5"], @$_GET["w_note5"]); } return $sWhere; } // Build search sql function BuildSearchSql(&$Where, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) { $sWrk = ""; $FldParm = substr($Fld->FldVar, 2); $FldVal = ew_StripSlashes($FldVal); if (is_array($FldVal)) $FldVal = implode(",", $FldVal); $FldVal2 = ew_StripSlashes($FldVal2); if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2); $FldOpr = strtoupper(trim($FldOpr)); if ($FldOpr == "") $FldOpr = "="; $FldOpr2 = strtoupper(trim($FldOpr2)); if ($FldOpr2 == "") $FldOpr2 = "="; if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) { if ($FldVal <> "") $FldVal = ($FldVal == "1") ? $Fld->TrueValue : $Fld->FalseValue; if ($FldVal2 <> "") $FldVal2 = ($FldVal2 == "1") ? $Fld->TrueValue : $Fld->FalseValue; } elseif ($Fld->FldDataType == EW_DATATYPE_DATE) { if ($FldVal <> "") $FldVal = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat); if ($FldVal2 <> "") $FldVal2 = ew_UnFormatDateTime($FldVal2, $Fld->FldDateTimeFormat); } if ($FldOpr == "BETWEEN") { $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) || ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2))); if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) { $sWrk = $Fld->FldExpression . " BETWEEN " . ew_QuotedValue($FldVal, $Fld->FldDataType) . " AND " . ew_QuotedValue($FldVal2, $Fld->FldDataType); } } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") { $sWrk = $Fld->FldExpression . " " . $FldOpr; } else { $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) || ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal))); if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) { $sWrk = $Fld->FldExpression . SearchString($FldOpr, $FldVal, $Fld->FldDataType); } $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) || ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2))); if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) { if ($sWrk <> "") { $sWrk .= " " . (($FldCond=="OR")?"OR":"AND") . " "; } $sWrk .= $Fld->FldExpression . SearchString($FldOpr2, $FldVal2, $Fld->FldDataType); } } if ($sWrk <> "") { if ($Where <> "") $Where .= " AND "; $Where .= "(" . $sWrk . ")"; } } // Return search string function SearchString($FldOpr, $FldVal, $FldType) { if ($FldOpr == "LIKE" || $FldOpr == "NOT LIKE") { return " " . $FldOpr . " " . ew_QuotedValue("%" . $FldVal . "%", $FldType); } elseif ($FldOpr == "STARTS WITH") { return " LIKE " . ew_QuotedValue($FldVal . "%", $FldType); } else { return " " . $FldOpr . " " . ew_QuotedValue($FldVal, $FldType); } } // Set search parm function SetSearchParm($Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) { global $products; $FldParm = substr($Fld->FldVar, 2); $FldVal = ew_StripSlashes($FldVal); if (is_array($FldVal)) $FldVal = implode(",", $FldVal); $FldVal2 = ew_StripSlashes($FldVal2); if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2); $products->setAdvancedSearch("x_" . $FldParm, $FldVal); $products->setAdvancedSearch("z_" . $FldParm, $FldOpr); $products->setAdvancedSearch("v_" . $FldParm, $FldCond); $products->setAdvancedSearch("y_" . $FldParm, $FldVal2); $products->setAdvancedSearch("w_" . $FldParm, $FldOpr2); } // Clear all search parameters function ResetSearchParms() { // Clear search where global $products; $sSrchWhere = ""; $products->setSearchWhere($sSrchWhere); // Clear advanced search parameters ResetAdvancedSearchParms(); } // Clear all advanced search parameters function ResetAdvancedSearchParms() { // Clear advanced search parameters global $products; $products->setAdvancedSearch("x_product_group", ""); $products->setAdvancedSearch("x_prouct_name", ""); $products->setAdvancedSearch("x_note2", ""); $products->setAdvancedSearch("x_note3", ""); $products->setAdvancedSearch("x_note4", ""); $products->setAdvancedSearch("x_note5", ""); } // Restore all search parameters function RestoreSearchParms() { global $sSrchWhere, $products; $sSrchWhere = $products->getSearchWhere(); // Restore advanced search settings RestoreAdvancedSearchParms(); } // Restore all advanced search parameters function RestoreAdvancedSearchParms() { // Restore advanced search parms global $products; $products->product_group->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_product_group"); $products->prouct_name->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_prouct_name"); $products->note2->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_note2"); $products->note3->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_note3"); $products->note4->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_note4"); $products->note5->AdvancedSearch->SearchValue = $products->getAdvancedSearch("x_note5"); } // Set up Sort parameters based on Sort Links clicked function SetUpSortOrder() { global $products; // Check for an Order parameter if (@$_GET["order"] <> "") { $products->CurrentOrder = ew_StripSlashes(@$_GET["order"]); $products->CurrentOrderType = @$_GET["ordertype"]; // Field product_group $products->UpdateSort($products->product_group); // Field prouct_name $products->UpdateSort($products->prouct_name); // Field photo $products->UpdateSort($products->photo); $products->setStartRecordNumber(1); // Reset start position } $sOrderBy = $products->getSessionOrderBy(); // Get order by from Session if ($sOrderBy == "") { if ($products->SqlOrderBy() <> "") { $sOrderBy = $products->SqlOrderBy(); $products->setSessionOrderBy($sOrderBy); } } } // Reset command based on querystring parameter farman= // - RESET: reset search parameters // - krf: reset search & master/detail parameters // - RESETSORT: reset sort parameters function ResetCmd() { global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy; global $products; // Get reset farman if (@$_GET["farman"] <> "") { $sCmd = $_GET["farman"]; // Reset search criteria if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "krf") { ResetSearchParms(); } // Reset master/detail keys if (strtolower($sCmd) == "krf") { $products->setMasterFilter(""); // Clear master filter $sDbMasterFilter = ""; $products->setDetailFilter(""); // Clear detail filter $sDbDetailFilter = ""; $products->product_group->setSessionValue(""); } // Reset Sort Criteria if (strtolower($sCmd) == "resetsort") { $sOrderBy = ""; $products->setSessionOrderBy($sOrderBy); $products->product_group->setSort(""); $products->prouct_name->setSort(""); $products->photo->setSort(""); } // Reset start position $nStartRec = 1; $products->setStartRecordNumber($nStartRec); } } ?> "") { $nStartRec = $_GET[EW_TABLE_START_REC]; $products->setStartRecordNumber($nStartRec); } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") { $nPageNo = $_GET[EW_TABLE_PAGE_NO]; if (is_numeric($nPageNo)) { $nStartRec = ($nPageNo-1)*$nDisplayRecs+1; if ($nStartRec <= 0) { $nStartRec = 1; } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) { $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; } $products->setStartRecordNumber($nStartRec); } else { $nStartRec = $products->getStartRecordNumber(); } } else { $nStartRec = $products->getStartRecordNumber(); } // Check if correct start record counter if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter $nStartRec = 1; // Reset start record counter $products->setStartRecordNumber($nStartRec); } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record $products->setStartRecordNumber($nStartRec); } elseif (($nStartRec-1) % $nDisplayRecs <> 0) { $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary $products->setStartRecordNumber($nStartRec); } } ?> photo->Upload->Index = $objForm->Index; if ($products->photo->Upload->UploadFile()) { // No action required } else { echo $products->photo->Upload->Message; exit(); } } ?> id->setFormValue($objForm->GetValue("x_id")); $products->product_group->setFormValue($objForm->GetValue("x_product_group")); $products->prouct_name->setFormValue($objForm->GetValue("x_prouct_name")); } // Restore form values function RestoreFormValues() { global $products; $products->id->CurrentValue = $products->id->FormValue; $products->product_group->CurrentValue = $products->product_group->FormValue; $products->prouct_name->CurrentValue = $products->prouct_name->FormValue; } ?> Recordset_Selecting($products->CurrentFilter); // Load list page sql $sSql = $products->SelectSQL(); if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt"; // Load recordset $conn->raiseErrorFn = 'ew_ErrorFn'; $rs = $conn->Execute($sSql); $conn->raiseErrorFn = ''; // Cهمه ركوردهاet Selected event $products->Recordset_Selected($rs); return $rs; } ?> SqlKeyFilter(); if (!is_numeric($products->id->CurrentValue)) { return FALSE; // Invalid key, exit } $sFilter = str_replace("@id@", ew_AdjustSql($products->id->CurrentValue), $sFilter); // Replace key value // Call Row Selecting event $products->Row_Selecting($sFilter); // Load sql based on filter $products->CurrentFilter = $sFilter; $sSql = $products->SQL(); if ($rs = $conn->Execute($sSql)) { if ($rs->EOF) { $LoadRow = FALSE; } else { $LoadRow = TRUE; $rs->MoveFirst(); LoadRowValues($rs); // Load row values // Call Row Selected event $products->Row_Selected($rs); } $rs->Close(); } else { $LoadRow = FALSE; } return $LoadRow; } // Load row values from recordset function LoadRowValues(&$rs) { global $products; $products->id->setDbValue($rs->fields('id')); $products->product_group->setDbValue($rs->fields('product_group')); $products->prouct_name->setDbValue($rs->fields('prouct_name')); $products->photo->Upload->DbValue = $rs->fields('photo'); $products->note1->setDbValue($rs->fields('note1')); $products->note2->setDbValue($rs->fields('note2')); $products->note3->setDbValue($rs->fields('note3')); $products->note4->setDbValue($rs->fields('note4')); $products->note5->setDbValue($rs->fields('note5')); $products->note6->setDbValue($rs->fields('note6')); $products->note7->setDbValue($rs->fields('note7')); $products->note8->setDbValue($rs->fields('note8')); $products->attach->Upload->DbValue = $rs->fields('attach'); } ?> Row_Rendering(); // Common render codes for all row types // product_group $products->product_group->CellCssStyle = ""; $products->product_group->CellCssClass = ""; // prouct_name $products->prouct_name->CellCssStyle = ""; $products->prouct_name->CellCssClass = ""; // photo $products->photo->CellCssStyle = ""; $products->photo->CellCssClass = ""; if ($products->RowType == EW_ROWTYPE_VIEW) { // View row // product_group if (!is_null($products->product_group->CurrentValue)) { $sSqlWrk = "SELECT `product_group` FROM `products_group` WHERE `id` = " . ew_AdjustSql($products->product_group->CurrentValue) . ""; $rswrk = $conn->Execute($sSqlWrk); if ($rswrk) { if (!$rswrk->EOF) { $products->product_group->ViewValue = $rswrk->fields('product_group'); } $rswrk->Close(); } else { $products->product_group->ViewValue = $products->product_group->CurrentValue; } } else { $products->product_group->ViewValue = NULL; } $products->product_group->CssStyle = ""; $products->product_group->CssClass = ""; $products->product_group->ViewCustomAttributes = ""; // prouct_name $products->prouct_name->ViewValue = $products->prouct_name->CurrentValue; $products->prouct_name->ViewValue = ew_Highlight($products->prouct_name->ViewValue, "", "", $products->getAdvancedSearch("x_prouct_name")); $products->prouct_name->CssStyle = ""; $products->prouct_name->CssClass = ""; $products->prouct_name->ViewCustomAttributes = ""; // photo if (!is_null($products->photo->Upload->DbValue)) { $products->photo->ViewValue = $products->photo->Upload->DbValue; $products->photo->ImageWidth = 160; $products->photo->ImageHeight = 0; $products->photo->ImageAlt = ""; } else { $products->photo->ViewValue = ""; } $products->photo->CssStyle = ""; $products->photo->CssClass = ""; $products->photo->ViewCustomAttributes = ""; // product_group $products->product_group->HrefValue = ""; // prouct_name $products->prouct_name->HrefValue = ""; // photo $products->photo->HrefValue = ""; } elseif ($products->RowType == EW_ROWTYPE_ADD) { // Add row } elseif ($products->RowType == EW_ROWTYPE_EDIT) { // Edit row // product_group $products->product_group->EditCustomAttributes = ""; if ($products->product_group->getSessionValue() <> "") { $products->product_group->CurrentValue = $products->product_group->getSessionValue(); if (!is_null($products->product_group->CurrentValue)) { $sSqlWrk = "SELECT `product_group` FROM `products_group` WHERE `id` = " . ew_AdjustSql($products->product_group->CurrentValue) . ""; $rswrk = $conn->Execute($sSqlWrk); if ($rswrk) { if (!$rswrk->EOF) { $products->product_group->ViewValue = $rswrk->fields('product_group'); } $rswrk->Close(); } else { $products->product_group->ViewValue = $products->product_group->CurrentValue; } } else { $products->product_group->ViewValue = NULL; } $products->product_group->CssStyle = ""; $products->product_group->CssClass = ""; $products->product_group->ViewCustomAttributes = ""; } else { $sSqlWrk = "SELECT `id`, `product_group` FROM `products_group`"; $rswrk = $conn->Execute($sSqlWrk); $arwrk = ($rswrk) ? $rswrk->GetRows() : array(); if ($rswrk) $rswrk->Close(); array_unshift($arwrk, array("", "Select Item")); $products->product_group->EditValue = $arwrk; } // prouct_name $products->prouct_name->EditCustomAttributes = ""; $products->prouct_name->EditValue = ew_HtmlEncode($products->prouct_name->CurrentValue); // photo $products->photo->EditCustomAttributes = ""; $products->photo->EditValue = $products->photo->CurrentValue; } elseif ($products->RowType == EW_ROWTYPE_SEARCH) { // Search row } // Call Row Rendered event $products->Row_Rendered(); } ?> SqlKeyFilter(); if (!is_numeric($products->id->CurrentValue)) { return FALSE; } $sFilter = str_replace("@id@", ew_AdjustSql($products->id->CurrentValue), $sFilter); // Replace key value $products->CurrentFilter = $sFilter; $sSql = $products->SQL(); $conn->raiseErrorFn = 'ew_ErrorFn'; $rs = $conn->Execute($sSql); $conn->raiseErrorFn = ''; if ($rs === FALSE) return FALSE; if ($rs->EOF) { $EditRow = FALSE; // Update Failed } else { // Save old values $rsold =& $rs->fields; $rsnew = array(); // Field product_group $products->product_group->SetDbValueDef($products->product_group->CurrentValue, 0); $rsnew['product_group'] =& $products->product_group->DbValue; // Field prouct_name $products->prouct_name->SetDbValueDef($products->prouct_name->CurrentValue, ""); $rsnew['prouct_name'] =& $products->prouct_name->DbValue; // Field photo $products->photo->Upload->SaveToSession(); // Save file value to Session if ($products->photo->Upload->Action == "2" || $products->photo->Upload->Action == "3") { // Update/Remove $products->photo->DbValue = $rs->fields('photo'); // Get original value if (is_null($products->photo->Upload->Value)) { $products->photo->Upload->DbValue = NULL; } else { $products->photo->Upload->DbValue = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH), $products->photo->Upload->FileName); } $rsnew['photo'] =& $products->photo->Upload->DbValue; } // Call Row Updating event $bUpdateRow = $products->Row_Updating($rsold, $rsnew); if ($bUpdateRow) { // Field photo if (!is_null($products->photo->Upload->Value)) ew_SaveFile(ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH), $rsnew['photo'], $products->photo->Upload->Value); if ($products->photo->DbValue <> "") @unlink(ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH) . $products->photo->DbValue); $conn->raiseErrorFn = 'ew_ErrorFn'; $EditRow = $conn->Execute($products->UpdateSQL($rsnew)); $conn->raiseErrorFn = ''; } else { if ($products->CancelMessage <> "") { $_SESSION[EW_SESSION_MESSAGE] = $products->CancelMessage; $products->CancelMessage = ""; } else { $_SESSION[EW_SESSION_MESSAGE] = "Cancel"; } $EditRow = FALSE; } } // Call Row Updated event if ($EditRow) { $products->Row_Updated($rsold, $rsnew); } if ($EditRow) { WriteAuditTrailOnEdit($rsold, $rsnew); } $rs->Close(); // Field photo $products->photo->Upload->RemoveFromSession(); // Remove file value from Session return $EditRow; } ?> RecordCount(); $nStartRec = 1; // Export all if (defined("EW_EXPORT_ALL")) { $nStopRec = $nTotalRecs; } else { // Export 1 page only SetUpStartRec(); // Set Up Start Record Position // Set the last record to display if ($nDisplayRecs < 0) { $nStopRec = $nTotalRecs; } else { $nStopRec = $nStartRec + $nDisplayRecs - 1; } } if ($products->Export == "xml") { $XmlDoc = new cXMLDocument(); } if ($products->Export == "csv") { $sCsvStr .= "product_group" . ","; $sCsvStr .= "prouct_name" . ","; $sCsvStr .= "photo" . ","; $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma $sCsvStr .= "\n"; } // Move to first record directly for performance reason $nRecCount = $nStartRec - 1; if (!$rs->EOF) { $rs->MoveFirst(); $rs->Move($nStartRec - 1); } while (!$rs->EOF && $nRecCount < $nStopRec) { $nRecCount++; if (intval($nRecCount) >= intval($nStartRec)) { LoadRowValues($rs); if ($products->Export == "xml") { $XmlDoc->BeginRow(); $XmlDoc->AddField('product_group', $products->product_group->CurrentValue); $XmlDoc->AddField('prouct_name', $products->prouct_name->CurrentValue); $XmlDoc->AddField('photo', $products->photo->CurrentValue); $XmlDoc->EndRow(); } if ($products->Export == "csv") { $sCsvStr .= '"' . str_replace('"', '""', strval($products->product_group->CurrentValue)) . '",'; $sCsvStr .= '"' . str_replace('"', '""', strval($products->prouct_name->CurrentValue)) . '",'; $sCsvStr .= '"' . str_replace('"', '""', strval($products->photo->CurrentValue)) . '",'; $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma $sCsvStr .= "\n"; } } $rs->MoveNext(); } // Close recordset $rs->Close(); if ($products->Export == "xml") { header("Content-Type: text/xml"); echo $XmlDoc->XML(); } if ($products->Export == "csv") { echo $sCsvStr; } } ?> "") { $sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER]; if ($sMasterTblVar == "") { $bValidMaster = TRUE; $sDbMasterFilter = ""; $sDbDetailFilter = ""; } if ($sMasterTblVar == "products_group") { $bValidMaster = TRUE; $sDbMasterFilter = $products->SqlMasterFilter_products_group(); $sDbDetailFilter = $products->SqlDetailFilter_products_group(); if (@$_GET["id"] <> "") { $GLOBALS["products_group"]->id->setQueryStringValue($_GET["id"]); $products->product_group->setQueryStringValue($GLOBALS["products_group"]->id->QueryStringValue); $products->product_group->setSessionValue($products->product_group->QueryStringValue); if (!is_numeric($GLOBALS["products_group"]->id->QueryStringValue)) $bValidMaster = FALSE; $sDbMasterFilter = str_replace("@id@", ew_AdjustSql($GLOBALS["products_group"]->id->QueryStringValue), $sDbMasterFilter); $sDbDetailFilter = str_replace("@product_group@", ew_AdjustSql($GLOBALS["products_group"]->id->QueryStringValue), $sDbDetailFilter); } else { $bValidMaster = FALSE; } } } if ($bValidMaster) { // Save current master table $products->setCurrentMasterTable($sMasterTblVar); // Reset start record counter (new master key) $nStartRec = 1; $products->setStartRecordNumber($nStartRec); $products->setMasterFilter($sDbMasterFilter); // Set up master filter $products->setDetailFilter($sDbDetailFilter); // Set up detail filter // Clear previous master session values if ($sMasterTblVar <> "products_group") { if ($products->product_group->QueryStringValue == "") $products->product_group->setSessionValue(""); } } else { $sDbMasterFilter = $products->getMasterFilter(); // Restore master filter $sDbDetailFilter = $products->getDetailFilter(); // Restore detail filter } } ?> "") $key .= EW_COMPOSITE_KEY_SEPARATOR; $key .= $rsold['id']; // Write Audit Trail $filePfx = "log"; $curDate = ntcodate(); $curTime = date("H:i:s"); $id = ew_ScriptName(); $user = CurrentUserID(); $action = "U"; foreach (array_keys($rsnew) as $fldname) { if ($products->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field if ($products->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // DateTime Field $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0)); } else { $modified = ($rsold[$fldname] <> $rsnew[$fldname]); } if ($modified) { if ($products->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo Field $oldvalue = ""; $newvalue = ""; } else { $oldvalue = $rsold[$fldname]; $newvalue = $rsnew[$fldname]; } ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue); } } } } ?>