Source code of file oscpmwin_v0.4.1.683/main.pas from the
osCommerce Product Manager for Windows.
0000: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001: osCommerce Product Manager for Windows (oscpmwin).
0002: Copyright �2003-2006 by Mario A. Valdez-Ramirez.
0003:
0004: You can contact Mario A. Valdez-Ramirez
0005: by email at mario@mariovaldez.org or paper mail at
0006: Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:
0008: This program is free software; you can redistribute it and/or modify
0009: it under the terms of the GNU General Public License as published by
0010: the Free Software Foundation; either version 2 of the License, or (at
0011: your option) any later version.
0012:
0013: This program is distributed in the hope that it will be useful, but
0014: WITHOUT ANY WARRANTY; without even the implied warranty of
0015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016: General Public License for more details.
0017:
0018: You should have received a copy of the GNU General Public License
0019: along with this program; if not, write to the Free Software
0020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022: UNIT main;
0023:
0024: INTERFACE
0025:
0026: USES
0027: Windows, SysUtils, Classes, Graphics, Controls, Forms,
0028: ComCtrls, ExtCtrls, Menus, StdCtrls,
0029: ImgList, Buttons, clipbrd, oscpmdata, Dialogs, ShlObj, modules,
0030: FR_Class, FR_DSet, ToolWin;
0031:
0032: TYPE
0033: Topm_Form_Main = CLASS (TForm)
0034: N1: TMenuItem;
0035: N2: TMenuItem;
0036: N3: TMenuItem;
0037: N4: TMenuItem;
0038: N8: TMenuItem;
0039: opm_ImageList_List: TImageList;
0040: opm_ImageList_Status: TImageList;
0041: opm_ImageList_Tree: TImageList;
0042: opm_Image_Status: TImage;
0043: opm_ListView_Main: TListView;
0044: opm_MainMenu_Main: TMainMenu;
0045: opm_MenuItem_About: TMenuItem;
0046: opm_MenuItem_Catalog: TMenuItem;
0047: opm_MenuItem_Config: TMenuItem;
0048: opm_MenuItem_Connect: TMenuItem;
0049: opm_MenuItem_Database: TMenuItem;
0050: opm_MenuItem_Disconnect: TMenuItem;
0051: opm_MenuItem_Exit: TMenuItem;
0052: opm_MenuItem_Help: TMenuItem;
0053: opm_MenuItem_License: TMenuItem;
0054: opm_MenuItem_Product: TMenuItem;
0055: opm_MenuItem_ProductAdd: TMenuItem;
0056: opm_MenuItem_ProductCopyAsText: TMenuItem;
0057: opm_MenuItem_ProductDel: TMenuItem;
0058: opm_MenuItem_ProductEdit: TMenuItem;
0059: opm_MenuItem_ProductExport: TMenuItem;
0060: opm_MenuItem_ProductSelAll: TMenuItem;
0061: opm_MenuItem_RefreshCategories: TMenuItem;
0062: opm_MenuItem_RefreshProducts: TMenuItem;
0063: opm_MenuItem_SearchProduct: TMenuItem;
0064: opm_Panel_Main: TPanel;
0065: opm_PopMenuItem_CatCollapse2: TMenuItem;
0066: opm_PopMenuItem_CatCollapse: TMenuItem;
0067: opm_PopMenuItem_CatExpand2: TMenuItem;
0068: opm_PopMenuItem_CatExpand: TMenuItem;
0069: opm_PopMenuItem_ConnConn: TMenuItem;
0070: opm_PopMenuItem_ConnDisconn: TMenuItem;
0071: opm_PopMenuItem_PAdd: TMenuItem;
0072: opm_PopMenuItem_PAvailability: TMenuItem;
0073: opm_PopMenuItem_PAvailable: TMenuItem;
0074: opm_PopMenuItem_PCat: TMenuItem;
0075: opm_PopMenuItem_PCopyAsText: TMenuItem;
0076: opm_PopMenuItem_PDelete: TMenuItem;
0077: opm_PopMenuItem_PEdit: TMenuItem;
0078: opm_PopMenuItem_PExport: TMenuItem;
0079: opm_PopMenuItem_PMan: TMenuItem;
0080: opm_PopMenuItem_PMod: TMenuItem;
0081: opm_PopMenuItem_PModel: TMenuItem;
0082: opm_PopMenuItem_PNotAvailable: TMenuItem;
0083: opm_PopMenuItem_PPrice: TMenuItem;
0084: opm_PopMenuItem_PQuantity: TMenuItem;
0085: opm_PopMenuItem_PSelAll: TMenuItem;
0086: opm_PopMenuItem_PSpecial: TMenuItem;
0087: opm_PopMenuItem_PWeight: TMenuItem;
0088: opm_PopupMenu_CatList: TPopupMenu;
0089: opm_PopupMenu_Connection: TPopupMenu;
0090: opm_PopupMenu_PList: TPopupMenu;
0091: opm_SaveDialog_Export: TSaveDialog;
0092: opm_Splitter_Main: TSplitter;
0093: opm_StatusBar_Main: TStatusBar;
0094: opm_TreeView_Main: TTreeView;
0095: opm_MenuItem_Tools: TMenuItem;
0096: opm_MenuItem_ExternalModules: TMenuItem;
0097: N7: TMenuItem;
0098: opm_PopMenuItem_CatRename: TMenuItem;
0099: opm_PopMenuItem_PPrint: TMenuItem;
0100: opm_MenuItem_ProductPrint: TMenuItem;
0101: opm_PrintDialog_Print: TPrintDialog;
0102: opm_frReport_ProdList: TfrReport;
0103: opm_frUserDataset_ProdList: TfrUserDataset;
0104: opm_PopMenuItem_PCopyAsPre: TMenuItem;
0105: opm_MenuItem_ProductCopyAsPre: TMenuItem;
0106: opm_MenuItem_ProductCopy: TMenuItem;
0107: opm_PopMenuItem_PCopy: TMenuItem;
0108: opm_PopMenuItem_CatDelete: TMenuItem;
0109: opm_PopMenuItem_CatAdd: TMenuItem;
0110: opm_ImageList_Toolbar: TImageList;
0111: opm_ToolBar_Main: TToolBar;
0112: opm_ToolButton_Connect: TToolButton;
0113: opm_ToolButton_Disconnect: TToolButton;
0114: opm_ToolButton_Config: TToolButton;
0115: opm_ToolButton_Refresh: TToolButton;
0116: opm_ToolButton_AddProduct: TToolButton;
0117: opm_ToolButton_EditProduct: TToolButton;
0118: opm_ToolButton_Search: TToolButton;
0119: opm_ToolButton_Sep3: TToolButton;
0120: opm_ToolButton_Sep4: TToolButton;
0121: opm_ToolButton_Sep6: TToolButton;
0122: opm_ToolButton_DeleteProduct: TToolButton;
0123: opm_Panel_ToolbarLanguage: TPanel;
0124: opm_ToolButton_Sep1: TToolButton;
0125: opm_ComboBox_DisplayLang: TComboBox;
0126: opm_ToolButton_Exit: TToolButton;
0127: opm_ToolButton_ExportProduct: TToolButton;
0128: opm_ToolButton_PrintProduct: TToolButton;
0129: opm_ToolButton_AddCat: TToolButton;
0130: opm_ToolButton_RenCat: TToolButton;
0131: opm_ToolButton_DelCat: TToolButton;
0132: opm_ToolButton_Sep2: TToolButton;
0133: N5: TMenuItem;
0134: opm_MenuItem_CategoryAdd: TMenuItem;
0135: opm_MenuItem_CategoryDelete: TMenuItem;
0136: opm_MenuItem_CategoryRename: TMenuItem;
0137: opm_ImageList_MainMenu: TImageList;
0138: opm_Panel_ToolbarQuickSearch: TPanel;
0139: Sep7: TToolButton;
0140: opm_Edit_QuickSearch: TEdit;
0141: opm_SpeedButton_QuickSearch: TSpeedButton;
0142: opm_MenuItem_CheckUpdates: TMenuItem;
0143: N6: TMenuItem;
0144: N9: TMenuItem;
0145: opm_MenuItem_ManAdd: TMenuItem;
0146: opm_MenuItem_ManDelete: TMenuItem;
0147: opm_MenuItem_ManRename: TMenuItem;
0148: opm_MenuItem_Backup: TMenuItem;
0149: N10: TMenuItem;
0150: N11: TMenuItem;
0151: opm_PopMenuItem_PCopyPR: TMenuItem;
0152: opm_PopMenuItem_PPastePR: TMenuItem;
0153: N12: TMenuItem;
0154: opm_MenuItem_PRCopy: TMenuItem;
0155: opm_MenuItem_PRPaste: TMenuItem;
0156: opm_MenuItem_Fullscreen: TMenuItem;
0157: N13: TMenuItem;
0158: opm_MenuItem_ManCurrency: TMenuItem;
0159: opm_MenuItem_Website: TMenuItem;
0160: N14: TMenuItem;
0161: opm_MenuItem_Forums: TMenuItem;
0162: N15: TMenuItem;
0163: opm_MenuItem_ShowSQLLog: TMenuItem;
0164: opm_PopMenuItem_PPrintPDF: TMenuItem;
0165: opm_MenuItem_ProductPrintPDF: TMenuItem;
0166: opm_MenuItem_ShowPHPInfo: TMenuItem;
0167: procedure FormClose(Sender: TObject; var Action: TCloseAction);
0168: procedure FormCreate(Sender: TObject);
0169: procedure opm_ComboBox_DisplayLangSelect(Sender: TObject);
0170: procedure opm_ListView_MainDblClick(Sender: TObject);
0171: procedure opm_MenuItem_AboutClick(Sender: TObject);
0172: procedure opm_MenuItem_ConfigClick(Sender: TObject);
0173: procedure opm_MenuItem_ConnectClick(Sender: TObject);
0174: procedure opm_MenuItem_DisconnectClick(Sender: TObject);
0175: procedure opm_MenuItem_ExitClick(Sender: TObject);
0176: procedure opm_MenuItem_LicenseClick(Sender: TObject);
0177: procedure opm_MenuItem_RefreshCategoriesClick(Sender: TObject);
0178: procedure opm_MenuItem_RefreshProductsClick(Sender: TObject);
0179: procedure opm_MenuItem_SearchProductClick(Sender: TObject);
0180: procedure opm_PopMenuItem_CatCollapse2Click(Sender: TObject);
0181: procedure opm_PopMenuItem_CatCollapseClick(Sender: TObject);
0182: procedure opm_PopMenuItem_CatExpand2Click(Sender: TObject);
0183: procedure opm_PopMenuItem_CatExpandClick(Sender: TObject);
0184: procedure opm_PopMenuItem_PAddClick(Sender: TObject);
0185: procedure opm_PopMenuItem_PAvailableClick(Sender: TObject);
0186: procedure opm_PopMenuItem_PCatClick(Sender: TObject);
0187: procedure opm_PopMenuItem_PCopyAsTextClick(Sender: TObject);
0188: procedure opm_PopMenuItem_PDeleteClick(Sender: TObject);
0189: procedure opm_PopMenuItem_PExportClick(Sender: TObject);
0190: procedure opm_PopMenuItem_PManClick(Sender: TObject);
0191: procedure opm_PopMenuItem_PModelClick(Sender: TObject);
0192: procedure opm_PopMenuItem_PNotAvailableClick(Sender: TObject);
0193: procedure opm_PopMenuItem_PPriceClick(Sender: TObject);
0194: procedure opm_PopMenuItem_PQuantityClick(Sender: TObject);
0195: procedure opm_PopMenuItem_PSelAllClick(Sender: TObject);
0196: procedure opm_PopMenuItem_PSpecialClick(Sender: TObject);
0197: procedure opm_PopMenuItem_PWeightClick(Sender: TObject);
0198: procedure opm_TreeView_MainChange(Sender: TObject; Node: TTreeNode);
0199: procedure opm_TreeView_MainCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
0200: procedure opm_TreeView_MainContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
0201: procedure opm_TreeView_MainDblClick(Sender: TObject);
0202: procedure opm_TreeView_MainDragDrop(Sender, Source: TObject; X, Y: Integer);
0203: procedure opm_TreeView_MainDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
0204: procedure opm_TreeView_MainExpanding(Sender: TObject; Node: TTreeNode; var AllowExpansion: Boolean);
0205: procedure opm_TreeView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
0206: procedure opm_TreeView_MainKeyPress(Sender: TObject; var Key: Char);
0207: procedure opm_MenuItem_ExternalModulesClick(Sender: TObject);
0208: procedure opm_PopMenuItem_CatRenameClick(Sender: TObject);
0209: procedure opm_ListView_MainColumnClick(Sender: TObject; Column: TListColumn);
0210: procedure opm_PopMenuItem_PPrintClick(Sender: TObject);
0211: procedure opm_frReport_ProdListGetValue(const ParName: String; var ParValue: Variant);
0212: procedure opm_frUserDataset_ProdListCheckEOF(Sender: TObject; var Eof: Boolean);
0213: procedure opm_frUserDataset_ProdListFirst(Sender: TObject);
0214: procedure opm_frUserDataset_ProdListNext(Sender: TObject);
0215: procedure opm_PopMenuItem_PCopyAsPreClick(Sender: TObject);
0216: procedure FormShow(Sender: TObject);
0217: procedure opm_PopMenuItem_CatDeleteClick(Sender: TObject);
0218: procedure opm_PopMenuItem_CatAddClick(Sender: TObject);
0219: procedure opm_ListView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
0220: procedure opm_ListView_MainChange(Sender: TObject; Item: TListItem; Change: TItemChange);
0221: procedure opm_SpeedButton_QuickSearchClick(Sender: TObject);
0222: procedure opm_Edit_QuickSearchKeyPress(Sender: TObject; var Key: Char);
0223: procedure opm_MenuItem_CheckUpdatesClick(Sender: TObject);
0224: procedure opm_MenuItem_ManAddClick(Sender: TObject);
0225: procedure opm_MenuItem_ManRenameClick(Sender: TObject);
0226: procedure opm_MenuItem_ManDeleteClick(Sender: TObject);
0227: procedure opm_MenuItem_BackupClick(Sender: TObject);
0228: procedure opm_MenuItem_FullscreenClick(Sender: TObject);
0229: procedure opm_PopMenuItem_PCopyPRClick(Sender: TObject);
0230: procedure opm_PopMenuItem_PPastePRClick(Sender: TObject);
0231: procedure opm_MenuItem_ManCurrencyClick(Sender: TObject);
0232: procedure opm_ListView_MainCustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
0233: procedure opm_MenuItem_WebsiteClick(Sender: TObject);
0234: procedure opm_MenuItem_ForumsClick(Sender: TObject);
0235: procedure opm_MenuItem_ShowSQLLogClick(Sender: TObject);
0236: procedure opm_PopMenuItem_PPrintPDFClick(Sender: TObject);
0237: procedure opm_MenuItem_ShowPHPInfoClick(Sender: TObject);
0238: private
0239: FUNCTION FNopm_Apply_Operation (SourceValue, Conversion: STRING; ValueType : INTEGER; AllowNegative : BOOLEAN) : STRING;
0240: FUNCTION FNopm_GetProductByID (ProdID, LangID : LONGINT; VAR ProdList : opmT_ProductList) : opmR_Product;
0241: FUNCTION FNopm_GetRealLangIDByIndex (VAR LangList : opmT_LanguageList; LangIndex : LONGINT) : LONGINT;
0242: PROCEDURE PRopm_Update_StatusBar (ConnectedStat : LONGINT; StatusString : STRING; ProductTotal : LONGINT; CurCurr : STRING);
0243: PROCEDURE PRopm_AddCatTreeNode (VAR CatList : opmT_CategoryList; CatCurrentID : LONGINT; CurNode : TTreeNode; TreeDepth : INTEGER);
0244: FUNCTION FNopm_FirstCat_byParent (VAR CatList : opmT_CategoryList; ParentID : LONGINT) : LONGINT;
0245: PROCEDURE PRopm_AddProduct (NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
0246: PROCEDURE PRopm_ClearCategoryList (VAR CatList : TStringList);
0247: PROCEDURE PRopm_ClearLanguageList (VAR LangList : TStringList);
0248: PROCEDURE PRopm_ClearManufacturerList (VAR ManList : TStringList);
0249: PROCEDURE PRopm_ClearProductList (VAR ListView : TListView);
0250: PROCEDURE PRopm_ClearTaxList (VAR TaxList : TStringList);
0251: PROCEDURE PRopm_ClearCurrencyList (VAR CurrencyList : TStringList);
0252: PROCEDURE PRopm_Disconnect;
0253: PROCEDURE PRopm_Create_ExportList (VAR ExportString : STRING; VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; JustifyCols : BOOLEAN);
0254: PROCEDURE PRopm_DeleteProduct (ProdID : LONGINT);
0255: PROCEDURE PRopm_LoadCategoryBoxList (VAR CatList : opmT_CategoryList; CatCurrentID, TreeDepth : LONGINT; VAR CatIndex : LONGINT; VAR CatBoxList : TStringList);
0256: PROCEDURE PRopm_LoadCategoryList (VAR CatList : opmT_CategoryList; VAR CatBoxList : TStringList);
0257: PROCEDURE PRopm_LoadConfiguration;
0258: PROCEDURE PRopm_LoadLanguageList (VAR LangList : opmT_LanguageList; VAR LangBoxList : TStringList);
0259: PROCEDURE PRopm_LoadManufacturerList (VAR ManList : opmT_ManufacturerList; VAR ManBoxList : TStringList);
0260: PROCEDURE PRopm_LoadProductListByCat (ProductCat : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList);
0261: PROCEDURE PRopm_LoadTaxList (VAR TaxList : opmT_TaxList; VAR TaxBoxList : TStringList);
0262: PROCEDURE PRopm_Connect;
0263: PROCEDURE PRopm_RenderCategoryDisplay (VAR CatList : opmT_CategoryList; VAR TreeControl : TTreeView; CurCatID : LONGINT);
0264: PROCEDURE PRopm_RenderLanguageDisplay (VAR ListControl : TComboBox; VAR LangList : opmT_LanguageList);
0265: PROCEDURE PRopm_RenderProductDisplay (VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; VAR ProdList : opmT_ProductList; VAR ListControl : TListView; CurProdID : LONGINT);
0266: PROCEDURE PRopm_SaveConfiguration;
0267: PROCEDURE PRopm_SearchProducts (PCategory, PManufacturer: LONGINT; PModel, PName, PDesc : STRING; PSPrice, PImgURL, PAvailable : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList; MultiString : STRING);
0268: PROCEDURE PRopm_SetControls_Disconnected;
0269: PROCEDURE PRopm_SetDisplay (RememberVisual : WORD);
0270: PROCEDURE PRopm_SetControls_FullConnected;
0271: PROCEDURE PRopm_SetUnknown;
0272: PROCEDURE PRopm_UpdateProdData (ProdID : LONGINT; ProdTable, ProdField, ProdDataStr : STRING; PDataIsNum : BOOLEAN; SecIDField, SecIDData : STRING; SQLQueryType : INTEGER);
0273: PROCEDURE PRopm_UpdateProduct (CurProdRecord, NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
0274: PROCEDURE PRopm_UpdateCatName (CatData : opmT_SingleCatList; TotalCats : LONGINT);
0275: PROCEDURE PRopm_AddCategory (CatData : opmT_SingleCatList; TotalCats : LONGINT; ParentCat : LONGINT);
0276: PROCEDURE PRopm_DeleteCategory (CatID : LONGINT);
0277: PROCEDURE PRopm_ResetVars;
0278: PROCEDURE PRopm_ResetServerVars;
0279: PROCEDURE PRopm_Valid_CatOps (WeAreConnected : BOOLEAN; SelectedCat : TTreeNode);
0280: PROCEDURE PRopm_Valid_ProdOps (WeAreConnected : BOOLEAN; SelectedProduct : TListItem; SelectedProds : LONGINT; SelectedCat : TTreeNode; CopiedProduct : LONGINT);
0281: PROCEDURE PRopm_Valid_GralOps (WeAreConnected : BOOLEAN);
0282: FUNCTION FNopm_ClearCurrency : opmR_Currency;
0283: PROCEDURE QuickSearch (QSString : STRING);
0284: PROCEDURE PRopm_FullScreen (SetReset : BOOLEAN);
0285: public
0286: FUNCTION FNopm_GetCategory (VAR CatList : opmT_CategoryList; CatID : LONGINT; SearchBy : INTEGER) : opmR_Category;
0287: FUNCTION FNopm_GetManufacturer (VAR ManList : opmT_ManufacturerList; ManID : LONGINT; SearchBy : INTEGER) : opmR_Manufacturer;
0288: FUNCTION FNopm_GetDescriptionByID (ProdID, LangID : LONGINT; VAR DescList : opmT_DescriptionList) : opmR_Description;
0289: PROCEDURE PRopm_SetUILang (LangISOID : STRING);
0290: FUNCTION FNopm_Create_ExchangeList (VAR ExchangeList : opmT_ExchangeList; IndexData, TargetData : STRING) : LONGINT;
0291: PROCEDURE PRopm_Reload_ProductList (SearchLoad : BOOLEAN);
0292: PROCEDURE PRopm_GetCategory_Data (CatID : LONGINT; VAR CatData : opmT_SingleCatList);
0293: FUNCTION FNopm_GetCurrency (VAR CurrList : opmT_CurrencyList; CurrID : LONGINT; SearchBy : INTEGER) : opmR_Currency;
0294: PROCEDURE PRopm_AddCurrency (CurrencyRec : opmR_Currency);
0295: PROCEDURE PRopm_DelCurrency (CurrencyRec : opmR_Currency);
0296: PROCEDURE PRopm_UpdateCurrency (CurrencyRec : opmR_Currency; Bulking : BOOLEAN);
0297: PROCEDURE PRopm_SetDefault_Currency (CurrCode : STRING);
0298: FUNCTION FNopm_LoadCurrencyList (VAR CurrencyList : opmT_CurrencyList; VAR CurrencyBoxList : TStringList) : opmR_Currency;
0299: end;
0300:
0301:
0302: var
0303: opm_Form_Main: Topm_Form_Main;
0304:
0305:
0306: FUNCTION FNopm_Sort_ProductList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
0307:
0308: implementation
0309:
0310: USES gnugettext, config, license, about, pedit, pimgzoom, search, askuser,
0311: balloons, regconfig, attention, dataman, network, askupload, runmod,
0312: colorsel, strutils, math, askcat, ShellApi, configmod, progress,
0313: currencyman, currencyedit, currupd, sqllog, phpinfo, fr_e_tnpdf;
0314:
0315: {$R *.dfm}
0316:
0317:
0318:
0319: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0320: Enable/disable those controls valid when the client is
0321: connected and the product list is downloaded.
0322: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0323: PROCEDURE Topm_Form_Main.PRopm_SetControls_FullConnected;
0324: BEGIN
0325: PRopm_Update_StatusBar (opmC_ConnStatYes, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0326: opm_ListView_Main.Enabled := TRUE;
0327: opm_TreeView_Main.Enabled := TRUE;
0328: opm_ComboBox_DisplayLang.Enabled := TRUE;
0329: PRopm_Valid_GralOps (FNopm_ConnectionState);
0330: PRopm_Valid_CatOps (FNopm_ConnectionState, opm_TreeView_Main.Selected);
0331: PRopm_Valid_ProdOps (FNopm_ConnectionState, NIL, 0, NIL, 0);
0332: END;
0333:
0334:
0335: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0336: Enable/disable those controls valid when the client is
0337: disconnected.
0338: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0339: PROCEDURE Topm_Form_Main.PRopm_SetControls_Disconnected;
0340: BEGIN
0341: PRopm_Update_StatusBar (opmC_ConnStatNo, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0342: opm_ListView_Main.Enabled := FALSE;
0343: opm_TreeView_Main.Enabled := FALSE;
0344: opm_ComboBox_DisplayLang.Enabled := FALSE;
0345: PRopm_Valid_GralOps (FNopm_ConnectionState);
0346: PRopm_Valid_CatOps (FNopm_ConnectionState, NIL);
0347: PRopm_Valid_ProdOps (FNopm_ConnectionState, NIL, 0, NIL, 0);
0348: END;
0349:
0350:
0351: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0352: Enable/disable those controls valid when the the state
0353: of the client connection is unknown (or waiting for a
0354: connection).
0355: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0356: PROCEDURE Topm_Form_Main.PRopm_SetUnknown;
0357: BEGIN
0358: PRopm_Update_StatusBar (opmC_ConnStatUnknown, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0359: opm_ListView_Main.Enabled := FALSE;
0360: opm_TreeView_Main.Enabled := FALSE;
0361: PRopm_Valid_GralOps (FNopm_ConnectionState);
0362: PRopm_Valid_CatOps (FNopm_ConnectionState, NIL);
0363: PRopm_Valid_ProdOps (FNopm_ConnectionState, NIL, 0, NIL, 0);
0364: END;
0365:
0366:
0367: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0368: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0369: PROCEDURE Topm_Form_Main.PRopm_Connect;
0370: VAR
0371: StrResult : STRING;
0372: BEGIN
0373: StrResult := '';
0374: PRopm_SetUnknown;
0375: IF (opmG_DBStorePass = 0) THEN
0376: BEGIN
0377: opm_Form_AskUser.AU_Title := _('Connecting to database...');
0378: opm_Form_AskUser.AU_Directions := _('Enter the database password');
0379: opm_Form_AskUser.AU_TextOrList := TRUE;
0380: opm_Form_AskUser.AU_PassChar := opmC_PasswordChar;
0381: opm_Form_AskUser.AU_MaxLen := opmC_DBPassword_MaxLen;
0382: opm_Form_AskUser.AU_DataText := opmG_DBPassword;
0383: IF (opm_Form_AskUser.ShowModal = mrOk) THEN opmG_DBPassword := opm_Form_AskUser.AU_DataText ELSE opmG_DBPassword := '';
0384: END;
0385: StrResult := FNopm_OpenDBConnection (opmG_DBUsername, opmG_DBPassword);
0386: IF (StrResult = '') THEN
0387: BEGIN
0388: PRopm_ResetVars;
0389: END
0390: ELSE
0391: BEGIN
0392: PRopm_SetControls_Disconnected;
0393: FNopm_Message (StrResult, mtError, [mbOk], opmG_UISilent);
0394: END;
0395: END;
0396:
0397:
0398: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0399: Closes the connection to the database server.
0400: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0401: PROCEDURE Topm_Form_Main.PRopm_Disconnect;
0402: VAR
0403: StrResult : STRING;
0404: BEGIN
0405: PRopm_SetUnknown;
0406: StrResult := FNopm_CloseDBConnection;
0407: PRopm_SetControls_Disconnected;
0408: PRopm_ResetVars;
0409: PRopm_ResetServerVars;
0410: IF (StrResult <> '') THEN FNopm_Message (StrResult, mtError, [mbOk], opmG_UISilent);
0411: END;
0412:
0413: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0414: Takes a source value, a target conversion value, and a value type.
0415: Then applies the operation or target value to the source value and
0416: return the result (in an integer or currency type according to the
0417: value type). The target values can be simple numbers or operations.
0418: A simple value will simply overwrite the source value with the target
0419: one. An operation will transform the source value. Valid operations
0420: are addition (+X), substraction (-X), percetage increase (+X%),
0421: percentage decrease (-X%).
0422: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0423: FUNCTION Topm_Form_Main.FNopm_Apply_Operation (SourceValue, Conversion : STRING;
0424: ValueType : INTEGER; AllowNegative : BOOLEAN) : STRING;
0425: VAR
0426: TmpOperand, TmpSource, TmpTarget : CURRENCY;
0427: TmpValue : STRING;
0428: BEGIN
0429: TmpValue := FNopm_CleanNumber (Conversion, opmC_ValIsNumOp);
0430: TmpOperand := STRTOCURR (FNopm_CleanNumber (Conversion, opmC_ValIsCurrency));
0431: TmpSource := STRTOCURR (FNopm_CleanNumber (SourceValue, opmC_ValIsCurrency));
0432: IF (TmpValue[LENGTH (TmpValue)] = '%') THEN
0433: BEGIN
0434: TmpOperand := (TmpSource / 100) * TmpOperand;
0435: END;
0436: IF ((TmpValue[1] = '-') OR (TmpValue[1] = '+')) THEN
0437: BEGIN
0438: TmpTarget := TmpSource + TmpOperand;
0439: IF (AllowNegative = FALSE) THEN IF (TmpTarget < 0) THEN TmpTarget := 0;
0440: END
0441: ELSE
0442: BEGIN
0443: TmpTarget := ABS (TmpOperand);
0444: END;
0445: IF (ValueType = opmC_ValIsInteger) THEN
0446: BEGIN
0447: FNopm_Apply_Operation := INTTOSTR (ROUND (TmpTarget));
0448: END
0449: ELSE
0450: BEGIN
0451: FNopm_Apply_Operation := CURRTOSTRF (TmpTarget, ffFixed, 15);
0452: END;
0453: END;
0454:
0455:
0456: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0457: Shows the configuration form and then check if any values were
0458: changed (in the global configuration vars) to apply those changes
0459: to the user interface.
0460: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0461: procedure Topm_Form_Main.opm_MenuItem_ConfigClick(Sender: TObject);
0462: begin
0463: IF (opm_Form_Config.ShowModal = mrOk) THEN
0464: BEGIN
0465: IF (opmG_UIDragDrop > 0) THEN
0466: opm_ListView_Main.DragMode := dmAutomatic
0467: ELSE
0468: opm_ListView_Main.DragMode := dmManual;
0469: PRopm_SetUILang (opmG_UIGUILang);
0470: PRmvHint_EnableHints ((opmG_UIToolTips > 0));
0471: IF (opmG_UIWBDebug > 0) THEN
0472: BEGIN
0473: opm_Form_PEdit.opm_Memo_UploadDEBUG.Enabled := TRUE;
0474: opm_Form_PEdit.opm_Memo_UploadDEBUG.Visible := TRUE;
0475: END
0476: ELSE
0477: BEGIN
0478: opm_Form_PEdit.opm_Memo_UploadDEBUG.Enabled := FALSE;
0479: opm_Form_PEdit.opm_Memo_UploadDEBUG.Visible := FALSE;
0480: END;
0481: END;
0482: opm_PRAddModules_ToMenu (opm_MenuItem_ExternalModules);
0483: end;
0484:
0485: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0486: Terminates the application.
0487: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0488: procedure Topm_Form_Main.opm_MenuItem_ExitClick(Sender: TObject);
0489: begin
0490: Close;
0491: end;
0492:
0493: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0494: Opens the DB connection, load the language, category and manufacturer
0495: lists in memory, build the language menu and the category tree,
0496: clears the product list and enable some controls.
0497: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0498: procedure Topm_Form_Main.opm_MenuItem_ConnectClick(Sender: TObject);
0499: VAR
0500: ResStr : STRING;
0501: ResCode : LONGINT;
0502: begin
0503: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0504: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 1, _('Detecting extensions...'));
0505: PRopm_Prepare_HTTPClient (NIL, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
0506: ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'noop', '', ResStr);
0507: IF (ResCode = 0) THEN
0508: BEGIN
0509: PRopm_ResetServerVars;
0510: ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'capa', '', ResStr);
0511: IF (ResCode = 0) THEN
0512: BEGIN
0513: opmG_Capa_MorePics6 := (ANSIPOS (opmC_Capa_MorePics6, ResStr) > 0);
0514: opmG_Capa_TotalB2B := (ANSIPOS (opmC_Capa_TotalB2B, ResStr) > 0);
0515: opmG_Capa_PollBooth := (ANSIPOS (opmC_Capa_PollBooth, ResStr) > 0);
0516: opmG_Capa_HeaderTags := (ANSIPOS (opmC_Capa_HeaderTags, ResStr) > 0);
0517: opm_Form_Progress.PRopm_PDUpdate_Progress (12, 1, _('Connecting...'));
0518: ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'phpinfo', '', ResStr);
0519: IF (ResCode = 0) THEN
0520: BEGIN
0521: opmG_PHPInfo := ResStr;
0522: END
0523: ELSE
0524: BEGIN
0525: FNopm_Message (_('There was an error while trying to get the PHP configuration from the server.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
0526: END;
0527: PRopm_Connect;
0528: IF (FNopm_ConnectionState = TRUE) THEN
0529: BEGIN
0530: opm_Form_Progress.PRopm_PDUpdate_Progress (24, 1, _('Loading language list...'));
0531: PRopm_LoadLanguageList (opmG_LanguageList, opmG_LanguageBoxList);
0532: opm_Form_Progress.PRopm_PDUpdate_Progress (36, 1, _('Loading category list...'));
0533: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
0534: opm_Form_Progress.PRopm_PDUpdate_Progress (48, 1, _('Loading manufacturers list...'));
0535: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
0536: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Loading taxes list...'));
0537: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
0538: opm_Form_Progress.PRopm_PDUpdate_Progress (72, 1, _('Loading currency list...'));
0539: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
0540: opm_Form_Progress.PRopm_PDUpdate_Progress (84, 1, _('Rendering...'));
0541: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
0542: opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, '');
0543: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
0544: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, '');
0545: PRopm_ClearProductList (opm_ListView_Main);
0546: opm_Form_Progress.PRopm_PDUpdate_Progress (100, 1, '');
0547: PRopm_SetControls_FullConnected;
0548: END;
0549: END
0550: ELSE
0551: BEGIN
0552: FNopm_Message (_('There was an error while trying to get the osCommerce addons list.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
0553: END;
0554: END
0555: ELSE
0556: BEGIN
0557: FNopm_Message (FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
0558: END;
0559: opm_Form_Progress.PRopm_PDClose;
0560: end;
0561:
0562:
0563:
0564: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0565: Closes the DB connection, clear the language, category, manufacturer
0566: and product lists, clear the display of the language menu, product list
0567: and category tree, and enable some controls.
0568: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0569: procedure Topm_Form_Main.opm_MenuItem_DisconnectClick(Sender: TObject);
0570: begin
0571: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0572: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Disconnecting...'));
0573: PRopm_Disconnect;
0574: opm_Form_Progress.PRopm_PDClose;
0575: IF (FNopm_ConnectionState = FALSE) THEN
0576: BEGIN
0577: PRopm_ClearLanguageList (opmG_LanguageBoxList);
0578: PRopm_ClearCategoryList (opmG_CategoryBoxList);
0579: PRopm_ClearManufacturerList (opmG_ManufacturerBoxList);
0580: PRopm_ClearTaxList (opmG_TaxBoxList);
0581: PRopm_ClearCurrencyList (opmG_CurrencyBoxList);
0582: opm_CurrentCurrency := FNopm_ClearCurrency;
0583: PRopm_ClearProductList (opm_ListView_Main);
0584: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
0585: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
0586: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
0587: opmG_Capa_MorePics6 := FALSE;
0588: opmG_Capa_TotalB2B := FALSE;
0589: opmG_Capa_PollBooth := FALSE;
0590: opmG_Capa_HeaderTags := FALSE;
0591: opmG_PHPInfo := '';
0592: END;
0593: end;
0594:
0595:
0596: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0597: Creates some objects, load the configuration from the Windows registry,
0598: reset all vars, set several parameters of the visual components,
0599: set the language of the user interface.
0600: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0601: procedure Topm_Form_Main.FormCreate(Sender: TObject);
0602: begin
0603: opmG_TMPPath := FNopm_GetTemporaryPath;
0604: opm_CurrentLang := 0;
0605: PRopm_LoadConfiguration;
0606: PRopm_ResetVars;
0607: PRopm_ResetServerVars;
0608: PRopm_ResetLog;
0609: PRopm_SetDisplay (opmG_UIRememberDisplay);
0610: PRopm_SetControls_Disconnected;
0611: opm_PRLoad_ModuleList;
0612: opm_PRAddModules_ToMenu (opm_MenuItem_ExternalModules);
0613: IF (FNopm_CheckLanguage (opmG_UIGUILang) = FALSE) THEN UseLanguage (opmC_Def_GUILang) ELSE UseLanguage (opmG_UIGUILang);
0614: TranslateComponent (self);
0615: PRmvHint_EnableHints (opmG_UIToolTips > 0);
0616: end;
0617:
0618:
0619: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0620: Resets some variables used to keep track of the product information.
0621: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0622: PROCEDURE Topm_Form_Main.PRopm_ResetVars;
0623: BEGIN
0624: opm_TotalCategories := 0;
0625: opm_TotalManufacturers := 0;
0626: opm_TotalLanguages := 0;
0627: opm_TotalProducts := 0;
0628: opm_TotalTaxes := 0;
0629: opm_TotalCurrencies := 0;
0630: opm_CurrentCategory := 0;
0631: opm_CurrentMan := 0;
0632: opm_CurrentProdID := 0;
0633: opm_Search_PCategory := 0;
0634: opm_Search_PManufacturer := 0;
0635: opm_Search_PModel := '';
0636: opm_Search_PName := '';
0637: opm_Search_Quick := '';
0638: opm_CanExpandTree_Flag := TRUE;
0639: opm_WeAreSearching := FALSE;
0640: opm_WeAreFullScreen := FALSE;
0641: opm_CurrentProdID_CB := 0;
0642: opm_StopTreeOnChange := FALSE;
0643: opmG_PList_LastOrderColumn := 4;
0644: opmG_PList_LastOrderType := FALSE;
0645: END;
0646:
0647:
0648:
0649: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0650: Resets some variables used to keep track of the server information.
0651: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0652: PROCEDURE Topm_Form_Main.PRopm_ResetServerVars;
0653: BEGIN
0654: opmG_Capa_MorePics6 := FALSE;
0655: opmG_Capa_TotalB2B :=FALSE;
0656: opmG_Capa_PollBooth :=FALSE;
0657: opmG_Capa_HeaderTags := FALSE;
0658: opmG_PHPInfo := '';
0659: END;
0660:
0661:
0662:
0663: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0664: Loads the configuration options from the Windows registry.
0665: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0666: PROCEDURE Topm_Form_Main.PRopm_LoadConfiguration;
0667: BEGIN
0668: opmG_ETABase := FNopm_StrToInt (FNReg_ReadSetting ('OSCETABase', opmC_Def_ETABase, opmC_RegistryKey, opmC_RKConfig));
0669: opmG_PDFAuthor := FNReg_ReadSetting ('OSCPDFAuthor', opmC_Def_PDFAuthor, opmC_RegistryKey, opmC_RKConfig);
0670: opmG_DBTable_Categories := FNReg_ReadSetting ('OSCTable01', opmC_Def_DBTable_Categories, opmC_RegistryKey, opmC_RKConfig);
0671: opmG_DBTable_Manufacturers := FNReg_ReadSetting ('OSCTable02', opmC_Def_DBTable_Manufacturers, opmC_RegistryKey, opmC_RKConfig);
0672: opmG_DBTable_Languages := FNReg_ReadSetting ('OSCTable03', opmC_Def_DBTable_Languages, opmC_RegistryKey, opmC_RKConfig);
0673: opmG_DBTable_Products := FNReg_ReadSetting ('OSCTable04', opmC_Def_DBTable_Products, opmC_RegistryKey, opmC_RKConfig);
0674: opmG_DBTable_Specials := FNReg_ReadSetting ('OSCTable05', opmC_Def_DBTable_Specials, opmC_RegistryKey, opmC_RKConfig);
0675: opmG_DBTable_ProductsDescription := FNReg_ReadSetting ('OSCTable06', opmC_Def_DBTable_ProductsDescription, opmC_RegistryKey, opmC_RKConfig);
0676: opmG_DBTable_TaxClass := FNReg_ReadSetting ('OSCTable07', opmC_Def_DBTable_TaxClass, opmC_RegistryKey, opmC_RKConfig);
0677: opmG_DBTable_Currencies := FNReg_ReadSetting ('OSCTable08', opmC_Def_DBTable_Currencies, opmC_RegistryKey, opmC_RKConfig);
0678: opmG_DBTable_Configuration := FNReg_ReadSetting ('OSCTable09', opmC_Def_DBTable_Configuration, opmC_RegistryKey, opmC_RKConfig);
0679: opmG_DBTable_ProductsToCategories := FNReg_ReadSetting ('OSCTable10', opmC_Def_DBTable_ProductsToCategories, opmC_RegistryKey, opmC_RKConfig);
0680: opmG_DBTable_CategoriesDescription := FNReg_ReadSetting ('OSCTable11', opmC_Def_DBTable_CategoriesDescription, opmC_RegistryKey, opmC_RKConfig);
0681: opmG_DBTable_TaxRates := FNReg_ReadSetting ('OSCTable13', opmC_Def_DBTable_TaxRates, opmC_RegistryKey, opmC_RKConfig);
0682: opmG_DBTable_ManufacturersInfo := FNReg_ReadSetting ('OSCTable14', opmC_Def_DBTable_ManufacturersInfo, opmC_RegistryKey, opmC_RKConfig);
0683: opmG_DBUsername := FNReg_ReadSetting ('OSCUsername', opmC_Def_Username, opmC_RegistryKey, opmC_RKConfig);
0684: opmG_DBPassword := FNReg_ReadSetting ('OSCPassword', opmC_Def_Password, opmC_RegistryKey, opmC_RKConfig);
0685: opmG_WBImgURL := FNReg_ReadSetting ('OSCImgURL', opmC_Def_ImgURL, opmC_RegistryKey, opmC_RKConfig);
0686: opmG_WBUploadURL := FNReg_ReadSetting ('OSCUploadURL', opmC_Def_UploadURL, opmC_RegistryKey, opmC_RKConfig);
0687: opmG_WBProxyHost := FNopm_CleanHostName (FNReg_ReadSetting ('OSCProxyHost', opmC_Def_ProxyHost, opmC_RegistryKey, opmC_RKConfig));
0688: opmG_WBProxyPort := FNopm_StrToInt (FNReg_ReadSetting ('OSCProxyPort', INTTOSTR (opmC_Def_ProxyPort), opmC_RegistryKey, opmC_RKConfig));
0689: opmG_ModConnWait := FNopm_StrToInt (FNReg_ReadSetting ('OSCModConnWait', INTTOSTR (opmC_Def_ModConnWait), opmC_RegistryKey, opmC_RKConfig));
0690: opmG_HTTPConnWait := FNopm_StrToInt (FNReg_ReadSetting ('OSCHTTPConnWait', INTTOSTR (opmC_Def_HTTPConnWait), opmC_RegistryKey, opmC_RKConfig));
0691: opmG_ModConnRetries := FNopm_StrToInt (FNReg_ReadSetting ('OSCModConnRetries', INTTOSTR (opmC_Def_ModConnRetries), opmC_RegistryKey, opmC_RKConfig));
0692: opmG_HTTPConnRetries := FNopm_StrToInt (FNReg_ReadSetting ('OSCHTTPConnRetries', INTTOSTR (opmC_Def_HTTPConnRetries), opmC_RegistryKey, opmC_RKConfig));
0693: opmG_WBImgX := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgX', INTTOSTR (opmC_Def_ImgX), opmC_RegistryKey, opmC_RKConfig));
0694: opmG_WBImgY := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgY', INTTOSTR (opmC_Def_ImgY), opmC_RegistryKey, opmC_RKConfig));
0695: opmG_WBImgQ := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgQ', INTTOSTR (opmC_Def_ImgQ), opmC_RegistryKey, opmC_RKConfig));
0696: opmG_WBPaddingColor := FNopm_StrToInt (FNReg_ReadSetting ('OSCPaddingColor', INTTOSTR (opmC_Def_PaddingColor), opmC_RegistryKey, opmC_RKConfig));
0697: IF (opmG_WBImgURL[LENGTH (opmG_WBImgURL)] <> '/') THEN opmG_WBImgURL := opmG_WBImgURL + '/';
0698: opm_CurrentLang := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCLanguage', INTTOSTR (opmC_Def_DisplayLang), opmC_RegistryKey, opmC_RKRoot)));
0699: opmG_UIHotTracking := FNopm_StrToInt (FNReg_ReadSetting ('OSCHotTracking', INTTOSTR (opmC_Def_HotTracking), opmC_RegistryKey, opmC_RKConfig));
0700: opmG_UIClickLoad := FNopm_StrToInt (FNReg_ReadSetting ('OSCAutoLoad', INTTOSTR (opmC_Def_AutoLoad), opmC_RegistryKey, opmC_RKConfig));
0701: opmG_UIDragDrop := FNopm_StrToInt (FNReg_ReadSetting ('OSCDragDrop', INTTOSTR (opmC_Def_DragDrop), opmC_RegistryKey, opmC_RKConfig));
0702: opmG_UIImgDragDrop := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgDragDrop', INTTOSTR (opmC_Def_ImgDragDrop), opmC_RegistryKey, opmC_RKConfig));
0703: opmG_UIToolTips := FNopm_StrToInt (FNReg_ReadSetting ('OSCToolTips', INTTOSTR (opmC_Def_ToolTips), opmC_RegistryKey, opmC_RKConfig));
0704: opmG_UIStripes := FNopm_StrToInt (FNReg_ReadSetting ('OSCStripes', INTTOSTR (opmC_Def_Stripes), opmC_RegistryKey, opmC_RKConfig));
0705: opmG_UICacheIList := FNopm_StrToInt (FNReg_ReadSetting ('OSCCacheIList', INTTOSTR (opmC_Def_CacheIList), opmC_RegistryKey, opmC_RKConfig));
0706: opmG_UseProxy := FNopm_StrToInt (FNReg_ReadSetting ('OSCUseProxy', INTTOSTR (opmC_Def_UseProxy), opmC_RegistryKey, opmC_RKConfig));
0707: opmG_ProxyApply := FNopm_StrToInt (FNReg_ReadSetting ('OSCProxyApply', INTTOSTR (opmC_Def_ProxyApply), opmC_RegistryKey, opmC_RKConfig));
0708: opmG_DBStorePass := FNopm_StrToInt (FNReg_ReadSetting ('OSCStorePass', INTTOSTR (opmC_Def_StorePass), opmC_RegistryKey, opmC_RKConfig));
0709: opmG_UISilent := FNopm_StrToInt (FNReg_ReadSetting ('OSCSilent', INTTOSTR (opmC_Def_Silent), opmC_RegistryKey, opmC_RKConfig));
0710: opmG_UIConfirmDels := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmDels', INTTOSTR (opmC_Def_ConfirmDels), opmC_RegistryKey, opmC_RKConfig));
0711: opmG_UIConfirmDrag := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmDrag', INTTOSTR (opmC_Def_ConfirmDrag), opmC_RegistryKey, opmC_RKConfig));
0712: opmG_UIConfirmMods := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmMods', INTTOSTR (opmC_Def_ConfirmMods), opmC_RegistryKey, opmC_RKConfig));
0713: opmG_UIAllowZeroPrice := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowZeroPrice', INTTOSTR (opmC_Def_AllowZeroPrice), opmC_RegistryKey, opmC_RKConfig));
0714: opmG_UIAllowEditImageName := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowEditImageName', INTTOSTR (opmC_Def_AllowEditImageName), opmC_RegistryKey, opmC_RKConfig));
0715: opmG_UIAllowNegativeQuantity := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowNegativeQuantity', INTTOSTR (opmC_Def_AllowNegativeQuantity), opmC_RegistryKey, opmC_RKConfig));
0716: opmG_UIAutoDownImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCAutoDownImg', INTTOSTR (opmC_Def_AutoDownImg), opmC_RegistryKey, opmC_RKConfig));
0717: opmG_UIFontName := FNReg_ReadSetting ('UIFontName', opmC_DefaultFont, opmC_RegistryKey, opmC_RKVisual);
0718: opmG_UIFontHeight := FNopm_StrToInt (FNReg_ReadSetting ('UIFontHeight', INTTOSTR (opmC_DefaultFontHeight), opmC_RegistryKey, opmC_RKVisual));
0719: opmG_UIFontCharset := FNopm_StrToInt (FNReg_ReadSetting ('UIFontCharset', INTTOSTR (opmC_DefaultFontCharset), opmC_RegistryKey, opmC_RKVisual));
0720: opmG_Clip_ColSize := FNopm_StrToInt (FNReg_ReadSetting ('Clip_ColSize', INTTOSTR (opmC_Def_Clip_ColSize), opmC_RegistryKey, opmC_RKVisual));
0721: opmG_PRNDirectPrint := FNopm_StrToInt (FNReg_ReadSetting ('PRNDirectPrint', INTTOSTR (opmC_Def_PRNDirectPrint), opmC_RegistryKey, opmC_RKVisual));
0722: opmG_Past_PAvailDate := FNopm_StrToInt (FNReg_ReadSetting ('PastAvailDate', INTTOSTR (opmC_Def_Past_PAvailDate), opmC_RegistryKey, opmC_RKVisual));
0723: opmG_Past_PManufacturer := FNopm_StrToInt (FNReg_ReadSetting ('PastManufacturer', INTTOSTR (opmC_Def_Past_PManufacturer), opmC_RegistryKey, opmC_RKVisual));
0724: opmG_Past_PTaxClass := FNopm_StrToInt (FNReg_ReadSetting ('PastTaxClass', INTTOSTR (opmC_Def_Past_PTaxClass), opmC_RegistryKey, opmC_RKVisual));
0725: opmG_Past_PImageDir := FNReg_ReadSetting ('PastImageDir', opmC_Def_Past_PImageDir, opmC_RegistryKey, opmC_RKVisual);
0726: opmG_WBNoCacheImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCNoCacheImg', INTTOSTR (opmC_Def_NoCacheImg), opmC_RegistryKey, opmC_RKConfig));
0727: opmG_WBResizeImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCResizeImg', INTTOSTR (opmC_Def_ResizeImg), opmC_RegistryKey, opmC_RKConfig));
0728: opmG_WBPaddingImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCPaddingImg', INTTOSTR (opmC_Def_PaddingImg), opmC_RegistryKey, opmC_RKConfig));
0729: opmG_WBKeepARImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCKeepARImg', INTTOSTR (opmC_Def_KeepARImg), opmC_RegistryKey, opmC_RKConfig));
0730: opmG_UIConfirmExit := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmExit', INTTOSTR (opmC_Def_ConfirmExit), opmC_RegistryKey, opmC_RKConfig));
0731: opmG_UICenterImage := FNopm_StrToInt (FNReg_ReadSetting ('OSCCenterImage', INTTOSTR (opmC_Def_CenterImage), opmC_RegistryKey, opmC_RKConfig));
0732: opmG_DBDebugLog := FNopm_StrToInt (FNReg_ReadSetting ('OSCDBDebugLog', INTTOSTR (opmC_Def_DBDebugLog), opmC_RegistryKey, opmC_RKConfig));
0733: opmG_HTTPCompress := FNopm_StrToInt (FNReg_ReadSetting ('OSCHTTPCompress', INTTOSTR (opmC_Def_HTTPCompress), opmC_RegistryKey, opmC_RKConfig));
0734: opmG_UIWBDebug := FNopm_StrToInt (FNReg_ReadSetting ('OSCWBDebug', INTTOSTR (opmC_Def_WBDebug), opmC_RegistryKey, opmC_RKConfig));
0735: opmG_UIGUILang := FNReg_ReadSetting ('OSCGUILang', opmC_Def_GUILang, opmC_RegistryKey, opmC_RKConfig);
0736: IF (FNopm_CheckLanguage (opmG_UIGUILang) = FALSE) THEN opmG_UIGUILang := opmC_Def_GUILang;
0737: opmG_UIRememberDisplay := FNopm_StrToInt (FNReg_ReadSetting ('OSCRememberPosition', INTTOSTR (opmC_Def_RememberDisplay), opmC_RegistryKey, opmC_RKConfig));
0738: opmG_UIWindow_XSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCWinX', INTTOSTR (opmC_DefWindow_XSize), opmC_RegistryKey, opmC_RKVisual)));
0739: IF ((opmG_UIWindow_XSize < opmC_MinWindow_XSize) OR (opmG_UIWindow_XSize > opmC_MaxWindow_XSize)) THEN opmG_UIWindow_XSize := opmC_DefWindow_XSize;
0740: opmG_UIWindow_YSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCWinY', INTTOSTR (opmC_DefWindow_YSize), opmC_RegistryKey, opmC_RKVisual)));
0741: IF ((opmG_UIWindow_YSize < opmC_MinWindow_YSize) OR (opmG_UIWindow_YSize > opmC_MaxWindow_YSize)) THEN opmG_UIWindow_YSize := opmC_DefWindow_YSize;
0742: opmG_UICatList_XSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCListX', INTTOSTR (opmC_DefCatList_Size), opmC_RegistryKey, opmC_RKVisual)));
0743: IF ((opmG_UICatList_XSize < opmC_MinCatList_Size) OR (opmG_UICatList_XSize > opmC_MaxCatList_Size)) THEN opmG_UICatList_XSize := opmC_DefCatList_Size;
0744: IF ((opmG_UICatList_XSize + 100) > opmG_UIWindow_XSize) THEN opmG_UIWindow_XSize := opmG_UICatList_XSize + 100;
0745: opmG_UICol0X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col0X', INTTOSTR (opmC_Def_Col0X), opmC_RegistryKey, opmC_RKVisual)));
0746: IF (opmG_UICol0X < opmC_MinColX) THEN opmG_UICol0X := opmC_MinColX;
0747: opmG_UICol1X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col1X', INTTOSTR (opmC_Def_Col1X), opmC_RegistryKey, opmC_RKVisual)));
0748: IF (opmG_UICol1X < opmC_MinColX) THEN opmG_UICol1X := opmC_MinColX;
0749: opmG_UICol2X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col2X', INTTOSTR (opmC_Def_Col2X), opmC_RegistryKey, opmC_RKVisual)));
0750: IF (opmG_UICol2X < opmC_MinColX) THEN opmG_UICol2X := opmC_MinColX;
0751: opmG_UICol3X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col3X', INTTOSTR (opmC_Def_Col3X), opmC_RegistryKey, opmC_RKVisual)));
0752: IF (opmG_UICol3X < opmC_MinColX) THEN opmG_UICol3X := opmC_MinColX;
0753: opmG_UICol4X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col4X', INTTOSTR (opmC_Def_Col4X), opmC_RegistryKey, opmC_RKVisual)));
0754: IF (opmG_UICol4X < opmC_MinColX) THEN opmG_UICol4X := opmC_MinColX;
0755: opmG_UICol5X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col5X', INTTOSTR (opmC_Def_Col5X), opmC_RegistryKey, opmC_RKVisual)));
0756: IF (opmG_UICol5X < opmC_MinColX) THEN opmG_UICol5X := opmC_MinColX;
0757: opmG_UICol6X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col6X', INTTOSTR (opmC_Def_Col6X), opmC_RegistryKey, opmC_RKVisual)));
0758: IF (opmG_UICol6X < opmC_MinColX) THEN opmG_UICol6X := opmC_MinColX;
0759: opmG_UICol7X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col7X', INTTOSTR (opmC_Def_Col7X), opmC_RegistryKey, opmC_RKVisual)));
0760: IF (opmG_UICol7X < opmC_MinColX) THEN opmG_UICol7X := opmC_MinColX;
0761: opmG_UICol8X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col8X', INTTOSTR (opmC_Def_Col8X), opmC_RegistryKey, opmC_RKVisual)));
0762: IF (opmG_UICol8X < opmC_MinColX) THEN opmG_UICol8X := opmC_MinColX;
0763: opmG_UICol9X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col9X', INTTOSTR (opmC_Def_Col9X), opmC_RegistryKey, opmC_RKVisual)));
0764: IF (opmG_UICol9X < opmC_MinColX) THEN opmG_UICol9X := opmC_MinColX;
0765: opmG_UICol10X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col10X', INTTOSTR (opmC_Def_Col10X), opmC_RegistryKey, opmC_RKVisual)));
0766: IF (opmG_UICol10X < opmC_MinColX) THEN opmG_UICol10X := opmC_MinColX;
0767: opmG_UICol20X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col20X', INTTOSTR (opmC_Def_Col20X), opmC_RegistryKey, opmC_RKVisual)));
0768: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol20X := opmC_MinColX;
0769: opmG_UICol21X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col21X', INTTOSTR (opmC_Def_Col21X), opmC_RegistryKey, opmC_RKVisual)));
0770: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol21X := opmC_MinColX;
0771: opmG_UICol22X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col22X', INTTOSTR (opmC_Def_Col22X), opmC_RegistryKey, opmC_RKVisual)));
0772: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol22X := opmC_MinColX;
0773: PRReg_ReadPastList ('Username', opmC_RegistryKey, opmC_RKServers, opmG_PastUsername_BoxList, opmC_MaxPast_Usernames);
0774: PRReg_ReadPastList ('ImgURL', opmC_RegistryKey, opmC_RKServers, opmG_PastImgURL_BoxList, opmC_MaxPast_ImgURL);
0775: PRReg_ReadPastList ('UploadURL', opmC_RegistryKey, opmC_RKServers, opmG_PastUploadURL_BoxList, opmC_MaxPast_UploadURL);
0776: PRReg_ReadPastList ('Proxy', opmC_RegistryKey, opmC_RKServers, opmG_PastProxy_BoxList, opmC_MaxPast_Proxy);
0777: END;
0778:
0779:
0780: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0781: Saves some configuration options to the Windows registry.
0782: Only options about the user interface are stored here, other
0783: options are stored when running the configuration form.
0784: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0785: PROCEDURE Topm_Form_Main.PRopm_SaveConfiguration;
0786: BEGIN
0787: PRReg_WriteSetting ('OSCWinX', INTTOSTR (opm_Form_Main.Width), opmC_RegistryKey, opmC_RKVisual);
0788: PRReg_WriteSetting ('OSCWinY', INTTOSTR (opm_Form_Main.Height), opmC_RegistryKey, opmC_RKVisual);
0789: PRReg_WriteSetting ('OSCListX', INTTOSTR (opm_TreeView_Main.Width), opmC_RegistryKey, opmC_RKVisual);
0790: PRReg_WriteSetting ('Col0X', INTTOSTR (opm_ListView_Main.Column[0].Width), opmC_RegistryKey, opmC_RKVisual);
0791: PRReg_WriteSetting ('Col1X', INTTOSTR (opm_ListView_Main.Column[1].Width), opmC_RegistryKey, opmC_RKVisual);
0792: PRReg_WriteSetting ('Col2X', INTTOSTR (opm_ListView_Main.Column[2].Width), opmC_RegistryKey, opmC_RKVisual);
0793: PRReg_WriteSetting ('Col3X', INTTOSTR (opm_ListView_Main.Column[3].Width), opmC_RegistryKey, opmC_RKVisual);
0794: PRReg_WriteSetting ('Col4X', INTTOSTR (opm_ListView_Main.Column[4].Width), opmC_RegistryKey, opmC_RKVisual);
0795: PRReg_WriteSetting ('Col5X', INTTOSTR (opm_ListView_Main.Column[5].Width), opmC_RegistryKey, opmC_RKVisual);
0796: PRReg_WriteSetting ('Col6X', INTTOSTR (opm_ListView_Main.Column[6].Width), opmC_RegistryKey, opmC_RKVisual);
0797: PRReg_WriteSetting ('Col7X', INTTOSTR (opm_ListView_Main.Column[7].Width), opmC_RegistryKey, opmC_RKVisual);
0798: PRReg_WriteSetting ('Col8X', INTTOSTR (opm_ListView_Main.Column[8].Width), opmC_RegistryKey, opmC_RKVisual);
0799: PRReg_WriteSetting ('Col9X', INTTOSTR (opm_ListView_Main.Column[9].Width), opmC_RegistryKey, opmC_RKVisual);
0800: PRReg_WriteSetting ('Col10X', INTTOSTR (opm_ListView_Main.Column[10].Width), opmC_RegistryKey, opmC_RKVisual);
0801: PRReg_WriteSetting ('Col20X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[1].Width), opmC_RegistryKey, opmC_RKVisual);
0802: PRReg_WriteSetting ('Col21X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[2].Width), opmC_RegistryKey, opmC_RKVisual);
0803: PRReg_WriteSetting ('Col22X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[3].Width), opmC_RegistryKey, opmC_RKVisual);
0804: PRReg_WriteSetting ('OSCLanguage', INTTOSTR (opm_CurrentLang), opmC_RegistryKey, opmC_RKRoot);
0805: PRReg_WriteSetting ('OSCGUILang', opmG_UIGUILang, opmC_RegistryKey, opmC_RKConfig);
0806: PRReg_WriteSetting ('PastAvailDate', INTTOSTR (opmG_Past_PAvailDate), opmC_RegistryKey, opmC_RKVisual);
0807: PRReg_WriteSetting ('PastManufacturer', INTTOSTR (opmG_Past_PManufacturer), opmC_RegistryKey, opmC_RKVisual);
0808: PRReg_WriteSetting ('PastTaxClass', INTTOSTR (opmG_Past_PTaxClass), opmC_RegistryKey, opmC_RKVisual);
0809: PRReg_WriteSetting ('PastImageDir', opmG_Past_PImageDir, opmC_RegistryKey, opmC_RKVisual);
0810: END;
0811:
0812:
0813:
0814: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0815: Sets several parameters of the visual components before
0816: starting.
0817: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0818: PROCEDURE Topm_Form_Main.PRopm_SetDisplay (RememberVisual : WORD);
0819: BEGIN
0820: opm_Form_Main.DoubleBuffered := TRUE;
0821: opm_Form_Main.Caption := opmC_AppName1 + ' ' + opmC_Version + ' (build ' + opmG_ExeBuildVersion + ')';
0822: opm_Form_Main.Constraints.MinWidth := opmC_MinWindow_XSize;
0823: opm_Form_Main.Constraints.MinHeight := opmC_MinWindow_YSize;
0824: opm_Form_Main.Constraints.MaxWidth := opmC_MaxWindow_XSize;
0825: opm_Form_Main.Constraints.MaxHeight := opmC_MaxWindow_YSize;
0826:
0827: opm_StatusBar_Main.Height := 16 + (opmC_Bevel_Size * 2);
0828: opm_StatusBar_Main.Panels[0].Width := 16 + (opmC_Bevel_Size * 2);
0829: opm_StatusBar_Main.Panels[1].Width := opmC_DefGauge_Size + (opmC_Bevel_Size * 2);
0830: opm_StatusBar_Main.Panels[2].Width := opmC_DefGauge_Size + (opmC_Bevel_Size * 2);
0831: opm_StatusBar_Main.Panels[3].Width := opmC_DefCatList_Size;
0832: opm_StatusBar_Main.Panels[4].Width := opmC_DefCatList_Size;
0833: opm_StatusBar_Main.Panels[5].Width := opmC_DefCurPan_Size;
0834: opm_StatusBar_Main.Panels[6].Width := opmC_DefMemPan_Size;
0835:
0836: opm_Image_Status.Parent := opm_StatusBar_Main;
0837: opm_Image_Status.Top := (opmC_Bevel_Size + 1);
0838: opm_Image_Status.Left := (opmC_Bevel_Size + 1);
0839: opm_Image_Status.Height := (opm_StatusBar_Main.Height - (opmC_Bevel_Size * 2));
0840: opm_Image_Status.Width := 16;
0841: opm_ImageList_Status.GetIcon (0, opm_Image_Status.Picture.Icon);
0842:
0843: opmG_StripeColor := FNopm_HighlightColor (ColorToRGB (clWindow));
0844:
0845: opm_TreeView_Main.ReadOnly := TRUE;
0846: opm_TreeView_Main.DoubleBuffered := TRUE;
0847: opm_TreeView_Main.Constraints.MinWidth := opmC_MinCatList_Size;
0848: opm_ListView_Main.Columns.Clear;
0849: opm_ListView_Main.Checkboxes := FALSE;
0850: opm_ListView_Main.ReadOnly := TRUE;
0851: opm_ListView_Main.RowSelect := TRUE;
0852: opm_ListView_Main.MultiSelect := TRUE;
0853: opm_ListView_Main.DoubleBuffered := TRUE;
0854: opm_ListView_Main.ViewStyle := vsReport;
0855: opm_ListView_Main.Columns.Add;
0856: opm_ListView_Main.Columns.Add;
0857: opm_ListView_Main.Columns.Add;
0858: opm_ListView_Main.Columns.Add;
0859: opm_ListView_Main.Columns.Add;
0860: opm_ListView_Main.Columns.Add;
0861: opm_ListView_Main.Columns.Add;
0862: opm_ListView_Main.Columns.Add;
0863: opm_ListView_Main.Columns.Add;
0864: opm_ListView_Main.Columns.Add;
0865: opm_ListView_Main.Columns.Add;
0866: opm_ListView_Main.Columns.Items[0].Caption := _('Available');
0867: opm_ListView_Main.Columns.Items[1].Caption := _('ID');
0868: opm_ListView_Main.Columns.Items[2].Caption := _('Model');
0869: opm_ListView_Main.Columns.Items[3].Caption := _('Category');
0870: opm_ListView_Main.Columns.Items[4].Caption := _('Name');
0871: opm_ListView_Main.Columns.Items[5].Caption := _('Manufacturer');
0872: opm_ListView_Main.Columns.Items[6].Caption := _('Quantity');
0873: opm_ListView_Main.Columns.Items[7].Caption := _('Price');
0874: opm_ListView_Main.Columns.Items[8].Caption := _('Weight');
0875: opm_ListView_Main.Columns.Items[9].Caption := _('Availability date');
0876: opm_ListView_Main.Columns.Items[10].Caption := _('Image');
0877: opm_ListView_Main.Columns.Items[0].Alignment := opmC_Def_Col0Align;
0878: opm_ListView_Main.Columns.Items[1].Alignment := opmC_Def_Col1Align;
0879: opm_ListView_Main.Columns.Items[2].Alignment := opmC_Def_Col2Align;
0880: opm_ListView_Main.Columns.Items[3].Alignment := opmC_Def_Col3Align;
0881: opm_ListView_Main.Columns.Items[4].Alignment := opmC_Def_Col4Align;
0882: opm_ListView_Main.Columns.Items[5].Alignment := opmC_Def_Col5Align;
0883: opm_ListView_Main.Columns.Items[6].Alignment := opmC_Def_Col6Align;
0884: opm_ListView_Main.Columns.Items[7].Alignment := opmC_Def_Col7Align;
0885: opm_ListView_Main.Columns.Items[8].Alignment := opmC_Def_Col8Align;
0886: opm_ListView_Main.Columns.Items[9].Alignment := opmC_Def_Col9Align;
0887: opm_ListView_Main.Columns.Items[10].Alignment := opmC_Def_Col10Align;
0888: IF (opmG_UIHotTracking > 0) THEN
0889: BEGIN
0890: opm_TreeView_Main.HotTrack := TRUE;
0891: opm_ListView_Main.HotTrack := FALSE;
0892: opm_ListView_Main.HotTrackStyles := [htHandPoint, htUnderlineHot];
0893: END
0894: ELSE
0895: BEGIN
0896: opm_TreeView_Main.HotTrack := FALSE;
0897: opm_ListView_Main.HotTrack := FALSE;
0898: opm_ListView_Main.HotTrackStyles := [];
0899: END;
0900: IF (opmG_UIDragDrop > 0) THEN
0901: opm_ListView_Main.DragMode := dmAutomatic
0902: ELSE
0903: opm_ListView_Main.DragMode := dmManual;
0904:
0905: IF (RememberVisual > 0) THEN
0906: BEGIN
0907: opm_Form_Main.Width := opmG_UIWindow_XSize;
0908: opm_Form_Main.Height := opmG_UIWindow_YSize;
0909: opm_TreeView_Main.Width := opmG_UICatList_XSize;
0910: opm_ListView_Main.Column[0].Width := opmG_UICol0X;
0911: opm_ListView_Main.Column[1].Width := opmG_UICol1X;
0912: opm_ListView_Main.Column[2].Width := opmG_UICol2X;
0913: opm_ListView_Main.Column[3].Width := opmG_UICol3X;
0914: opm_ListView_Main.Column[4].Width := opmG_UICol4X;
0915: opm_ListView_Main.Column[5].Width := opmG_UICol5X;
0916: opm_ListView_Main.Column[6].Width := opmG_UICol6X;
0917: opm_ListView_Main.Column[7].Width := opmG_UICol7X;
0918: opm_ListView_Main.Column[8].Width := opmG_UICol8X;
0919: opm_ListView_Main.Column[9].Width := opmG_UICol9X;
0920: opm_ListView_Main.Column[10].Width := opmG_UICol10X;
0921: END
0922: ELSE
0923: BEGIN
0924: opm_Form_Main.Width := opmC_DefWindow_XSize;
0925: opm_Form_Main.Height := opmC_DefWindow_YSize;
0926: opm_TreeView_Main.Width := opmC_DefCatList_Size;
0927: opm_ListView_Main.Column[0].Width := opmC_Def_Col0X;
0928: opm_ListView_Main.Column[1].Width := opmC_Def_Col1X;
0929: opm_ListView_Main.Column[2].Width := opmC_Def_Col2X;
0930: opm_ListView_Main.Column[3].Width := opmC_Def_Col3X;
0931: opm_ListView_Main.Column[4].Width := opmC_Def_Col4X;
0932: opm_ListView_Main.Column[5].Width := opmC_Def_Col5X;
0933: opm_ListView_Main.Column[6].Width := opmC_Def_Col6X;
0934: opm_ListView_Main.Column[7].Width := opmC_Def_Col7X;
0935: opm_ListView_Main.Column[8].Width := opmC_Def_Col8X;
0936: opm_ListView_Main.Column[9].Width := opmC_Def_Col9X;
0937: opm_ListView_Main.Column[10].Width := opmC_Def_Col10X;
0938: END;
0939: END;
0940:
0941:
0942:
0943: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0944: Updates the status bar information according to the parameters:
0945: connection status (to change connection icon), main progress bar,
0946: secondary progress bar, message caption and total products.
0947: Any option can be left unchanged.
0948: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0949: PROCEDURE Topm_Form_Main.PRopm_Update_StatusBar (ConnectedStat : LONGINT; StatusString : STRING; ProductTotal : LONGINT; CurCurr : STRING);
0950: BEGIN
0951: IF (StatusString <> '') THEN
0952: opm_StatusBar_Main.Panels[3].Text := StatusString;
0953: IF (ConnectedStat <> opmC_ConnStatIgnore) THEN
0954: BEGIN
0955: opm_ImageList_Status.GetIcon (ConnectedStat, opm_Image_Status.Picture.Icon);
0956: END;
0957: IF (ProductTotal <> opmC_PTotalIgnore) THEN
0958: opm_StatusBar_Main.Panels[4].Text := INTTOSTR (ProductTotal) + ' ' + _('products');
0959: IF (CurCurr <> '') THEN
0960: opm_StatusBar_Main.Panels[5].Text := CurCurr
0961: ELSE
0962: opm_StatusBar_Main.Panels[5].Text := _('???');
0963: opm_StatusBar_Main.Panels[6].Text := _('Mem:') + ' ' + INTTOSTR (FNopm_GetMemoryLoad) + '%';
0964: END;
0965:
0966:
0967:
0968: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0969: Load the list of categories in memory and populate the
0970: category boxlist.
0971: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0972: PROCEDURE Topm_Form_Main.PRopm_LoadCategoryList (VAR CatList : opmT_CategoryList; VAR CatBoxList : TStringList);
0973: VAR
0974: CurCat : LONGINT;
0975: BEGIN
0976: CatList[0].ID := -1;
0977: CatList[0].Parent := 0;
0978: CatList[0].Name := '';
0979: opm_TotalCategories := 1;
0980: PRopm_WriteLog ('BEGIN record loading (LoadCatList)...');
0981: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select ' + opmG_DBTable_Categories + '.categories_id, ' + opmG_DBTable_Categories + '.parent_id, ' + opmG_DBTable_CategoriesDescription + '.categories_name from ' + opmG_DBTable_Categories + ', ' + opmG_DBTable_CategoriesDescription + ' where ' + opmG_DBTable_CategoriesDescription + '.categories_id= ' + opmG_DBTable_Categories + '.categories_id and language_id=' + INTTOSTR (opm_CurrentLang) + ' ORDER BY ' + opmG_DBTable_Categories + '.parent_id, ' + opmG_DBTable_CategoriesDescription + '.categories_name', opmG_DBQuery_Recordset) = 0) THEN
0982: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
0983: BEGIN
0984: FOR CurCat := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
0985: BEGIN
0986: CatList[CurCat + 1].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCat, 0]);
0987: CatList[CurCat + 1].Parent := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCat, 1]);
0988: CatList[CurCat + 1].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCat, 2]);
0989: IF (CatList[CurCat + 1].Name = '') THEN CatList[CurCat + 1].Name := opmC_Unamed_Cat;
0990: END;
0991: PRopm_WriteLog ('END record loading.');
0992: opm_TotalCategories := (opmG_DBQuery_Recordset.DataRows + 1);
0993: END;
0994: {
0995: HERE GO THE VIRTUAL CATEGORIES DEFINITIONS...
0996: CatList[CurCat].ID := opmC_SC_TrashCanID;
0997: CatList[CurCat].Parent := opmC_SC_Parent;
0998: CatList[CurCat].Name := _('Deleted products');
0999: CatList[CurCat].TreeIndex := opmC_SC_TrashCanIndex;
1000: CatList[CurCat].ListIndex := opmC_SC_TrashCanIndex;
1001: INC (CurCat);
1002: }
1003: PRopm_Close_WebDBQuery;
1004: CatBoxList.Clear;
1005: PRopm_LoadCategoryBoxList (CatList, 0, 0, CurCat, CatBoxList);
1006: CatList[0].ID := 0;
1007: END;
1008:
1009:
1010:
1011: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012: Scan the category list and recursively build the category boxlist.
1013: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1014: PROCEDURE Topm_Form_Main.PRopm_LoadCategoryBoxList (VAR CatList : opmT_CategoryList; CatCurrentID, TreeDepth : LONGINT; VAR CatIndex : LONGINT; VAR CatBoxList : TStringList);
1015: VAR
1016: CurCat : LONGINT;
1017: BEGIN
1018: IF (CatCurrentID = 0) THEN CatIndex := 0;
1019: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1020: BEGIN
1021: IF ((CatList[CurCat].Parent = CatCurrentID) AND (CatList[CurCat].Parent < opmC_SC_Parent)) THEN
1022: BEGIN
1023: CatBoxList.Add (STRINGOFCHAR (opmC_CatList_Spacer, (TreeDepth * 2)) + CatList[CurCat].Name);
1024: CatList[CurCat].ListIndex := CatIndex;
1025: INC (CatIndex);
1026: PRopm_LoadCategoryBoxList (CatList, CatList[CurCat].ID, (TreeDepth + 1), CatIndex, CatBoxList);
1027: END;
1028: END;
1029: END;
1030:
1031:
1032: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1033: Recursively build the category tree view.
1034: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1035: PROCEDURE Topm_Form_Main.PRopm_AddCatTreeNode (VAR CatList : opmT_CategoryList; CatCurrentID : LONGINT; CurNode : TTreeNode; TreeDepth : INTEGER);
1036: VAR
1037: CurCat : LONGINT;
1038: NewNode : TTreeNode;
1039: Start : LONGINT;
1040: BEGIN
1041: Start := FNopm_FirstCat_byParent (CatList, CatCurrentID);
1042: FOR CurCat := Start TO (opm_TotalCategories - 1) DO
1043: BEGIN
1044: IF ((CatList[CurCat].Parent = CatCurrentID) AND (CatList[CurCat].ID > 0) AND (CatList[CurCat].Parent < opmC_SC_Parent)) THEN
1045: BEGIN
1046: NewNode := opm_TreeView_Main.Items.AddChild (CurNode, CatList[CurCat].Name);
1047: NewNode.ImageIndex := 2;
1048: NewNode.SelectedIndex := 3;
1049: {DO NOT USE AbsoluteIndex, for performance, ListIndex already have the correct value.}
1050: {CatList[CurCat].TreeIndex := NewNode.AbsoluteIndex;}
1051: CatList[CurCat].TreeIndex := CatList[CurCat].ListIndex;
1052: PRopm_AddCatTreeNode (CatList, CatList[CurCat].ID, NewNode, (TreeDepth + 1));
1053: END
1054: ELSE IF (CatList[CurCat].Parent > CatCurrentID) THEN BREAK;
1055: END;
1056: END;
1057:
1058:
1059: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1060: Assumes the category array is sorted by parent_id.
1061: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1062: FUNCTION Topm_Form_Main.FNopm_FirstCat_byParent (VAR CatList : opmT_CategoryList; ParentID : LONGINT) : LONGINT;
1063: VAR
1064: First, Last, Middle : LONGINT;
1065: BEGIN
1066: IF ((ParentID > 0) AND (opm_TotalCategories > 10)) THEN
1067: BEGIN
1068: First := 0;
1069: Last := opm_TotalCategories;
1070: WHILE (First <= Last) DO
1071: BEGIN
1072: Middle := ((Last + First) DIV 2);
1073: IF (CatList[Middle].Parent < ParentID) THEN
1074: BEGIN
1075: First := (Middle + 1);
1076: END
1077: ELSE IF (CatList[Middle].Parent > ParentID) THEN
1078: BEGIN
1079: Last := (Middle - 1);
1080: END
1081: ELSE
1082: BEGIN
1083: FNopm_FirstCat_byParent := Middle;
1084: WHILE (Middle > 0) DO
1085: BEGIN
1086: IF (CatList[Middle].Parent = CatList[Middle - 1].Parent) THEN DEC (Middle)
1087: ELSE
1088: BEGIN
1089: FNopm_FirstCat_byParent := Middle;
1090: EXIT
1091: END;
1092: END;
1093: EXIT;
1094: END;
1095: END;
1096: FNopm_FirstCat_byParent := (opm_TotalCategories - 1);
1097: END
1098: ELSE FNopm_FirstCat_byParent := 0;
1099: END;
1100:
1101:
1102: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103: Loads the list of manufacturers and populate the
1104: manufacturer boxlist.
1105: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1106: PROCEDURE Topm_Form_Main.PRopm_LoadManufacturerList (VAR ManList : opmT_ManufacturerList; VAR ManBoxList : TStringList);
1107: VAR
1108: CurMan : LONGINT;
1109: BEGIN
1110: ManBoxList.Clear;
1111: ManList[0].ID := 0;
1112: ManList[0].Name := '';
1113: ManList[0].ListIndex := 0;
1114: ManBoxList.Add ('');
1115: opm_TotalManufacturers := 1;
1116: PRopm_WriteLog ('BEGIN record loading (LoadManList)...');
1117: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select manufacturers_id, manufacturers_name from ' + opmG_DBTable_Manufacturers + ' order by manufacturers_name', opmG_DBQuery_Recordset) = 0) THEN
1118: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1119: BEGIN
1120: FOR CurMan := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1121: BEGIN
1122: ManList[CurMan + 1].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurMan, 0]);
1123: ManList[CurMan + 1].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurMan, 1]);
1124: IF (ManList[CurMan + 1].Name = '') THEN ManList[CurMan + 1].Name := opmC_Unamed_Man;
1125: ManBoxList.Add (ManList[CurMan + 1].Name);
1126: ManList[CurMan + 1].ListIndex := (CurMan + 1);
1127: END;
1128: PRopm_WriteLog ('END record loading.');
1129: opm_TotalManufacturers := (opmG_DBQuery_Recordset.DataRows + 1);
1130: END;
1131: PRopm_Close_WebDBQuery;
1132: END;
1133:
1134:
1135: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1136: Loads the list of available languages and populate the
1137: language boxlist.
1138: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1139: PROCEDURE Topm_Form_Main.PRopm_LoadLanguageList (VAR LangList : opmT_LanguageList; VAR LangBoxList : TStringList);
1140: VAR
1141: CurLang : LONGINT;
1142: DisplayLangValid : BOOLEAN;
1143: BEGIN
1144: DisplayLangValid := FALSE;
1145: LangBoxList.Clear;
1146: opm_TotalLanguages := 0;
1147: PRopm_WriteLog ('BEGIN record loading (LoadLangList)...');
1148: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select languages_id, name from ' + opmG_DBTable_Languages + ' order by name', opmG_DBQuery_Recordset) = 0) THEN
1149: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1150: BEGIN
1151: FOR CurLang := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1152: BEGIN
1153: LangList[CurLang].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurLang, 0]);
1154: LangList[CurLang].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurLang, 1]);
1155: IF (opm_CurrentLang = LangList[CurLang].ID) THEN DisplayLangValid := TRUE;
1156: LangList[CurLang].ListIndex := CurLang;
1157: opmG_LanguageBoxList.Add (LangList[CurLang].Name);
1158: END;
1159: END;
1160: PRopm_WriteLog ('END record loading.');
1161: opm_TotalLanguages := opmG_DBQuery_Recordset.DataRows;
1162: IF (DisplayLangValid = FALSE) THEN
1163: BEGIN
1164: IF (opm_TotalLanguages > 0) THEN opm_CurrentLang := LangList[0].ID
1165: ELSE opm_CurrentLang := opmC_Def_DisplayLang;
1166: END;
1167: PRopm_Close_WebDBQuery;
1168: END;
1169:
1170:
1171: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1172: Loads the product list according to the given category.
1173: This routine don't modify the current display.
1174: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1175: PROCEDURE Topm_Form_Main.PRopm_LoadProductListByCat (ProductCat : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList);
1176: VAR
1177: CurProd : LONGINT;
1178: SQLStr : STRING;
1179: BEGIN
1180: BEGIN
1181: opm_TotalProducts := 0;
1182: opm_WeAreSearching := FALSE;
1183: IF (opmG_Capa_MorePics6 = FALSE) THEN
1184: BEGIN
1185: IF (ProductCat > 0) THEN
1186: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1187: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1188: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1189: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1190: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1191: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1192: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1193: 'from (' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ') ' +
1194: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1195: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1196: 'and ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' +
1197: opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (ProductCat) + ' ' +
1198: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name'
1199: ELSE
1200: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1201: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1202: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1203: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1204: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1205: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1206: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1207: 'from (' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ') ' +
1208: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1209: 'LEFT JOIN ' + opmG_DBTable_ProductsToCategories + ' ON ' + opmG_DBTable_ProductsToCategories + '.products_id = ' + opmG_DBTable_Products + '.products_id ' +
1210: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1211: 'and (' + opmG_DBTable_ProductsToCategories + '.categories_id is null ' +
1212: 'or ' + opmG_DBTable_ProductsToCategories + '.categories_id < 1) ' +
1213: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1214: END
1215: ELSE
1216: BEGIN
1217: IF (ProductCat > 0) THEN
1218: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1219: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1220: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1221: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1222: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1223: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1224: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1225: ', products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6 ' +
1226: 'from (' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ') ' +
1227: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1228: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1229: 'and ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' +
1230: opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (ProductCat) + ' ' +
1231: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name'
1232: ELSE
1233: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1234: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1235: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1236: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1237: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1238: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1239: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1240: ', products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6 ' +
1241: 'from (' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ') ' +
1242: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1243: 'LEFT JOIN ' + opmG_DBTable_ProductsToCategories + ' ON ' + opmG_DBTable_ProductsToCategories + '.products_id = ' + opmG_DBTable_Products + '.products_id ' +
1244: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1245: 'and (' + opmG_DBTable_ProductsToCategories + '.categories_id is null ' +
1246: 'or ' + opmG_DBTable_ProductsToCategories + '.categories_id < 1) ' +
1247: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1248: END;
1249: IF (FNopm_WebDB_Query (opmG_WBUploadURL, SQLStr, opmG_DBQuery_Recordset) = 0) THEN
1250: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1251: BEGIN
1252: PRopm_WriteLog ('BEGIN record loading (LoadProdList)...');
1253: FOR CurProd := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1254: BEGIN
1255: ProdList[CurProd].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 0]);
1256: ProdList[CurProd].Model := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 2]);
1257: ProdList[CurProd].Quantity := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 1]);
1258: ProdList[CurProd].Price := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 3], opmC_ValIsCurrency));
1259: ProdList[CurProd].Weight := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 4], opmC_ValIsCurrency));
1260: ProdList[CurProd].ManufacturerID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 5]);
1261: ProdList[CurProd].CategoryID := ProductCat;
1262: ProdList[CurProd].DisplayName := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 6]);
1263: IF (ProdList[CurProd].DisplayName = '') THEN ProdList[CurProd].DisplayName := opmC_Unamed_Prod;
1264: ProdList[CurProd].Available := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 7]);
1265: ProdList[CurProd].ImageURL := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 10]);
1266: ProdList[CurProd].Special := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 11], opmC_ValIsCurrency));
1267: ProdList[CurProd].LanguageID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 12]);
1268: ProdList[CurProd].Tax := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 13]);
1269:
1270: IF (opmG_Capa_MorePics6 = TRUE) THEN
1271: BEGIN
1272: ProdList[CurProd].ImageURL1 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 18]);
1273: ProdList[CurProd].ImageURL2 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 19]);
1274: ProdList[CurProd].ImageURL3 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 20]);
1275: ProdList[CurProd].ImageURL4 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 21]);
1276: ProdList[CurProd].ImageURL5 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 22]);
1277: ProdList[CurProd].ImageURL6 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 23]);
1278: END
1279: ELSE
1280: BEGIN
1281: ProdList[CurProd].ImageURL1 := '';
1282: ProdList[CurProd].ImageURL2 := '';
1283: ProdList[CurProd].ImageURL3 := '';
1284: ProdList[CurProd].ImageURL4 := '';
1285: ProdList[CurProd].ImageURL5 := '';
1286: ProdList[CurProd].ImageURL6 := '';
1287: END;
1288:
1289: ProdList[CurProd].CreationDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 16]);
1290: IF (ProdList[CurProd].CreationDate < opmG_Fallback_DateTime) THEN
1291: ProdList[CurProd].CreationDate := opmG_Fallback_DateTime;
1292: ProdList[CurProd].ChangeDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 17]);
1293: IF (ProdList[CurProd].ChangeDate < ProdList[CurProd].CreationDate) THEN
1294: ProdList[CurProd].ChangeDate := ProdList[CurProd].CreationDate;
1295: ProdList[CurProd].AvailDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 15]);
1296: IF (ProdList[CurProd].AvailDate < ProdList[CurProd].CreationDate) THEN
1297: ProdList[CurProd].AvailDate := ProdList[CurProd].CreationDate;
1298:
1299: DescList[CurProd].ID := ProdList[CurProd].ID;
1300: DescList[CurProd].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 6]);
1301: IF (DescList[CurProd].Name = '') THEN DescList[CurProd].Name := opmC_Unamed_Prod;
1302: DescList[CurProd].Description := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 8]);
1303: DescList[CurProd].URL := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 9]);
1304: DescList[CurProd].Viewed := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 14]);
1305: DescList[CurProd].LanguageID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 12]);
1306: END;
1307: PRopm_WriteLog ('END record loading.');
1308: opm_TotalProducts := opmG_DBQuery_Recordset.DataRows;
1309: END;
1310: PRopm_Close_WebDBQuery;
1311: END;
1312: END;
1313:
1314:
1315: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1316: Loads the list of available tax classes into
1317: the taxes boxlist.
1318: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1319: PROCEDURE Topm_Form_Main.PRopm_LoadTaxList (VAR TaxList : opmT_TaxList; VAR TaxBoxList : TStringList);
1320: VAR
1321: CurTax : LONGINT;
1322: BEGIN
1323: TaxBoxList.Clear;
1324: TaxList[0].ID := 0;
1325: TaxList[0].Name := '';
1326: TaxList[0].ListIndex := 0;
1327: TaxList[0].SumRate := 0;
1328: TaxBoxList.Add ('');
1329: opm_TotalTaxes := 1;
1330: PRopm_WriteLog ('BEGIN record loading (LoadTaxList)...');
1331: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select ' + opmG_DBTable_TaxClass + '.tax_class_id, tax_class_title, sum(tax_rate) from (' + opmG_DBTable_TaxClass + ') left join ' + opmG_DBTable_TaxRates + ' on ' + opmG_DBTable_TaxClass + '.tax_class_id=' + opmG_DBTable_TaxRates + '.tax_class_id group by tax_class_id order by tax_class_title', opmG_DBQuery_Recordset) = 0) THEN
1332: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1333: BEGIN
1334: FOR CurTax := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1335: BEGIN
1336: TaxList[CurTax + 1].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurTax, 0]);
1337: TaxList[CurTax + 1].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurTax, 1]);
1338: TaxList[CurTax + 1].SumRate := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurTax, 2], opmC_ValIsCurrency));
1339: IF (TaxList[CurTax + 1].Name = '') THEN TaxList[CurTax + 1].Name := opmC_Unamed_Tax;
1340: TaxList[CurTax + 1].Name := TaxList[CurTax + 1].Name + ' (' + CURRTOSTR (TaxList[CurTax + 1].SumRate) + '%)';
1341: TaxBoxList.Add (TaxList[CurTax + 1].Name);
1342: TaxList[CurTax + 1].ListIndex := (CurTax + 1);
1343: END;
1344: PRopm_WriteLog ('END record loading.');
1345: opm_TotalTaxes := (opmG_DBQuery_Recordset.DataRows + 1);
1346: END;
1347: PRopm_Close_WebDBQuery;
1348: END;
1349:
1350:
1351:
1352:
1353: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1354: Loads the list of available currencies into
1355: the currency boxlist.
1356: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1357: FUNCTION Topm_Form_Main.FNopm_LoadCurrencyList (VAR CurrencyList : opmT_CurrencyList; VAR CurrencyBoxList : TStringList) : opmR_Currency;
1358: VAR
1359: CurCurr : LONGINT;
1360: DefCurrID : LONGINT;
1361: DefCurrR : opmR_Currency;
1362: BEGIN
1363: CurrencyBoxList.Clear;
1364: DefCurrID := -1;
1365: DefCurrR.ID := -1;
1366: DefCurrR.Code := opmC_Unamed_CurrencyCode;
1367: opm_TotalCurrencies := 0;
1368: PRopm_WriteLog ('BEGIN record loading (LoadDefCurrency)...');
1369: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select ' + opmG_DBTable_Currencies + '.currencies_id from ' + opmG_DBTable_Currencies +
1370: ', ' + opmG_DBTable_Configuration + ' where ' + opmG_DBTable_Configuration + '.configuration_key="DEFAULT_CURRENCY" and ' +
1371: opmG_DBTable_Configuration + '.configuration_value=' + opmG_DBTable_Currencies + '.code', opmG_DBQuery_Recordset) = 0) THEN
1372: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1373: BEGIN
1374: DefCurrID := ABS (FNopm_StrToInt (opmG_DBQuery_Recordset.Data[0, 0]));
1375: PRopm_WriteLog ('END record loading.');
1376: END;
1377: PRopm_Close_WebDBQuery;
1378: PRopm_WriteLog ('BEGIN record loading (LoadCurrencyList)...');
1379: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select currencies_id, title, code, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from ' + opmG_DBTable_Currencies + ' order by title, code', opmG_DBQuery_Recordset) = 0) THEN
1380: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1381: BEGIN
1382: FOR CurCurr := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1383: BEGIN
1384: CurrencyList[CurCurr].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCurr, 0]);
1385: CurrencyList[CurCurr].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 1]);
1386: CurrencyList[CurCurr].Code := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 2]);
1387: CurrencyList[CurCurr].Left := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 3]);
1388: CurrencyList[CurCurr].Right := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 4]);
1389: CurrencyList[CurCurr].DecimalSep := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 5]);
1390: CurrencyList[CurCurr].ThousandSep := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCurr, 6]);
1391: CurrencyList[CurCurr].Precision := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCurr, 7]);
1392: CurrencyList[CurCurr].Value := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurCurr, 8], opmC_ValIsCurrency));
1393: CurrencyList[CurCurr].NewValue := 0;
1394: IF (CurrencyList[CurCurr].Name = '') THEN CurrencyList[CurCurr].Name := opmC_Unamed_Currency;
1395: IF (CurrencyList[CurCurr].Code = '') THEN CurrencyList[CurCurr].Code := opmC_Unamed_CurrencyCode;
1396: IF (CurrencyList[CurCurr].ID = DefCurrID) THEN
1397: BEGIN
1398: CurrencyList[CurCurr].Default := TRUE;
1399: DefCurrR := CurrencyList[CurCurr];
1400: CurrencyBoxList.Add (CurrencyList[CurCurr].Name + ' [' + CurrencyList[CurCurr].Code + '] = ' + CURRTOSTR (CurrencyList[CurCurr].Value) + ' (' + _('DEFAULT') + ')');
1401: END
1402: ELSE
1403: BEGIN
1404: CurrencyBoxList.Add (CurrencyList[CurCurr].Name + ' [' + CurrencyList[CurCurr].Code + '] = ' + CURRTOSTR (CurrencyList[CurCurr].Value));
1405: CurrencyList[CurCurr].Default := FALSE;
1406: END;
1407: CurrencyList[CurCurr].ListIndex := CurCurr;
1408: END;
1409: PRopm_WriteLog ('END record loading.');
1410: END;
1411: FNopm_LoadCurrencyList := DefCurrR;
1412: opm_TotalCurrencies := (opmG_DBQuery_Recordset.DataRows);
1413: PRopm_Close_WebDBQuery;
1414: END;
1415:
1416:
1417:
1418:
1419: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420: Clears the current currency record
1421: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1422: FUNCTION Topm_Form_Main.FNopm_ClearCurrency : opmR_Currency;
1423: VAR
1424: CurCurrR : opmR_Currency;
1425: BEGIN
1426: CurCurrR.Code := '';
1427: CurCurrR.Left := '';
1428: CurCurrR.Right := '';
1429: FNopm_ClearCurrency := CurCurrR;
1430: END;
1431:
1432:
1433:
1434:
1435: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1436: Start the building of the category tree.
1437: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1438: PROCEDURE Topm_Form_Main.PRopm_RenderCategoryDisplay (VAR CatList : opmT_CategoryList; VAR TreeControl : TTreeView; CurCatID : LONGINT);
1439: VAR
1440: MainNode, CurrentNode : TTreeNode;
1441: CurCat : opmR_Category;
1442: CatCount : LONGINT;
1443: BEGIN
1444: opm_StopTreeOnChange := TRUE;
1445: PRopm_WriteLog ('RenderCategoryDisplay BEGIN');
1446: TreeControl.Items.BeginUpdate;
1447: TreeControl.Items.Clear;
1448: IF (opm_TotalCategories > 0) THEN
1449: BEGIN
1450: MainNode := TreeControl.Items.AddFirst (NIL, ''); { PENDIENTE !!!! Agregar nombre del servidor o la tienda. }
1451: MainNode.ImageIndex := 0;
1452: MainNode.SelectedIndex := 1;
1453: PRopm_AddCatTreeNode (CatList, 0, MainNode, 0);
1454: FOR CatCount := 0 TO (opm_TotalCategories - 1) DO
1455: IF (CatList[CatCount].Parent = opmC_SC_Parent) THEN
1456: BEGIN
1457: CurrentNode := TreeControl.Items.Add (MainNode, CatList[CatCount].Name);
1458: CatList[CatCount].TreeIndex := CurrentNode.AbsoluteIndex;
1459: CurrentNode.ImageIndex := CatList[CatCount].ID - opmC_SC_BaseID + 3;
1460: CurrentNode.SelectedIndex := CatList[CatCount].ID - opmC_SC_BaseID + 4;
1461: END;
1462: TreeControl.FullCollapse;
1463: TreeControl.Items[0].Expand (FALSE);
1464: CurCat := FNopm_GetCategory (CatList, CurCatID, opmC_FindByID);
1465: IF ((CurCat.TreeIndex >= 0) AND (TreeControl.Items.Count >= CurCat.TreeIndex)) THEN
1466: BEGIN
1467: TreeControl.Items[CurCat.TreeIndex].Selected := TRUE;
1468: END;
1469: END;
1470: TreeControl.Items.EndUpdate;
1471: PRopm_WriteLog ('RenderCategoryDisplay END');
1472: opm_StopTreeOnChange := FALSE;
1473: END;
1474:
1475:
1476: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1477: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1478: PROCEDURE Topm_Form_Main.PRopm_RenderLanguageDisplay (VAR ListControl : TComboBox; VAR LangList : opmT_LanguageList);
1479: VAR
1480: CurLang : LONGINT;
1481: DisplayLangIndex : LONGINT;
1482: BEGIN
1483: PRopm_WriteLog ('RenderLanguageDisplay BEGIN');
1484: ListControl.Items.Clear;
1485: ListControl.Items := opmG_LanguageBoxList;
1486: DisplayLangIndex := -1;
1487: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1488: IF (opm_CurrentLang = LangList[CurLang].ID) THEN DisplayLangIndex := CurLang;
1489: ListControl.ItemIndex := DisplayLangIndex;
1490: PRopm_WriteLog ('RenderLanguageDisplay END');
1491: END;
1492:
1493:
1494: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1495: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1496: PROCEDURE Topm_Form_Main.PRopm_RenderProductDisplay (VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; VAR ProdList : opmT_ProductList; VAR ListControl : TListView; CurProdID : LONGINT);
1497: VAR
1498: CurProd, DispProd : LONGINT;
1499: CurItem : TListItem;
1500: CurMan : opmR_Manufacturer;
1501: CurCat : opmR_Category;
1502: BEGIN
1503: PRopm_WriteLog ('RenderProductDisplay BEGIN');
1504: ListControl.Column[opmG_PList_LastOrderColumn].ImageIndex := -1;
1505: ListControl.Items.BeginUpdate;
1506: ListControl.Items.Clear;
1507: DispProd := 0;
1508: FOR CurProd := 0 TO (opm_TotalProducts - 1) DO
1509: BEGIN
1510: IF (ProdList[CurProd].LanguageID = opm_CurrentLang) THEN
1511: BEGIN
1512: CurItem := ListControl.Items.Add;
1513: IF (ProdList[CurProd].Available > 0) THEN CurItem.ImageIndex := 0 ELSE CurItem.ImageIndex := 1;
1514: CurItem.SubItems.Add (INTTOSTR (ProdList[CurProd].ID));
1515: CurItem.SubItems.Add (ProdList[CurProd].Model);
1516: CurCat := FNopm_GetCategory (CatList, ProdList[CurProd].CategoryID, opmC_FindByID);
1517: CurItem.SubItems.Add (CurCat.Name);
1518: CurItem.SubItems.Add (ProdList[CurProd].DisplayName);
1519: CurMan := FNopm_GetManufacturer (ManList, ProdList[CurProd].ManufacturerID, opmC_FindByID);
1520: CurItem.SubItems.Add (CurMan.Name);
1521: CurItem.SubItems.Add (INTTOSTR (ProdList[CurProd].Quantity));
1522: IF (ProdList[CurProd].Special > 0) THEN
1523: CurItem.SubItems.Add (FNopm_CleanNumber (CURRTOSTR (ProdList[CurProd].Special), opmC_ValIsCurrency))
1524: ELSE
1525: CurItem.SubItems.Add (FNopm_CleanNumber (CURRTOSTR (ProdList[CurProd].Price), opmC_ValIsCurrency));
1526: CurItem.SubItems.Add (CURRTOSTR (ProdList[CurProd].Weight));
1527: CurItem.SubItems.Add (FNopm_DateToString (ProdList[CurProd].AvailDate));
1528: CurItem.SubItems.Add ('');
1529: IF (ProdList[CurProd].Special > 0) THEN CurItem.SubItemImages[6] := 2;
1530: IF ((ProdList[CurProd].ImageURL1 <> '') OR
1531: (ProdList[CurProd].ImageURL2 <> '') OR
1532: (ProdList[CurProd].ImageURL3 <> '') OR
1533: (ProdList[CurProd].ImageURL4 <> '') OR
1534: (ProdList[CurProd].ImageURL5 <> '') OR
1535: (ProdList[CurProd].ImageURL6 <> '')) THEN
1536: CurItem.SubItemImages[9] := 10
1537: ELSE IF (ProdList[CurProd].ImageURL <> '') THEN
1538: CurItem.SubItemImages[9] := 6
1539: ELSE
1540: CurItem.SubItemImages[9] := 7;
1541: INC (DispProd);
1542: IF (CurProdID = ProdList[CurProd].ID) THEN
1543: BEGIN
1544: ListControl.Selected := CurItem;
1545: ListControl.ItemFocused := CurItem;
1546: END;
1547: END;
1548: END;
1549: ListControl.Column[opmG_PList_LastOrderColumn].ImageIndex := 9;
1550: ListControl.CustomSort (@FNopm_Sort_ProductList, opmG_PList_LastOrderColumn);
1551: ListControl.Items.EndUpdate;
1552: PRopm_Update_StatusBar (opmC_ConnStatIgnore, '', DispProd, opm_CurrentCurrency.Code);
1553: PRopm_WriteLog ('RenderProductDisplay END');
1554: END;
1555:
1556:
1557: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1558: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1559: PROCEDURE Topm_Form_Main.PRopm_ClearCategoryList (VAR CatList : TStringList);
1560: BEGIN
1561: CatList.Clear;
1562: opm_CurrentCategory := 0;
1563: opm_TotalCategories := 0;
1564: END;
1565:
1566:
1567: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1568: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1569: PROCEDURE Topm_Form_Main.PRopm_ClearLanguageList (VAR LangList : TStringList);
1570: BEGIN
1571: LangList.Clear;
1572: opm_TotalLanguages := 0;
1573: END;
1574:
1575:
1576: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1577: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1578: PROCEDURE Topm_Form_Main.PRopm_ClearManufacturerList (VAR ManList : TStringList);
1579: BEGIN
1580: ManList.Clear;
1581: opm_TotalManufacturers := 0;
1582: END;
1583:
1584:
1585: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1586: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1587: PROCEDURE Topm_Form_Main.PRopm_ClearTaxList (VAR TaxList : TStringList);
1588: BEGIN
1589: TaxList.Clear;
1590: opm_TotalTaxes := 0;
1591: END;
1592:
1593:
1594: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1595: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1596: PROCEDURE Topm_Form_Main.PRopm_ClearCurrencyList (VAR CurrencyList : TStringList);
1597: BEGIN
1598: CurrencyList.Clear;
1599: opm_TotalCurrencies := 0;
1600: END;
1601:
1602:
1603: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1604: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1605: PROCEDURE Topm_Form_Main.PRopm_ClearProductList (VAR ListView : TListView);
1606: BEGIN
1607: ListView.Items.BeginUpdate;
1608: ListView.Items.Clear;
1609: ListView.Items.EndUpdate;
1610: opm_TotalProducts := 0;
1611: END;
1612:
1613:
1614: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1615: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1616: PROCEDURE Topm_Form_Main.PRopm_SearchProducts (PCategory, PManufacturer: LONGINT;
1617: PModel, PName, PDesc : STRING;
1618: PSPrice, PImgURL, PAvailable : LONGINT;
1619: VAR ProdList : opmT_ProductList;
1620: VAR DescList : opmT_DescriptionList;
1621: MultiString : STRING);
1622: VAR
1623: SelectStr, FromStr, WhereStr, OrderStr : STRING;
1624: CurProd : LONGINT;
1625: BEGIN
1626: IF (opmG_Capa_MorePics6 = FALSE) THEN
1627: SelectStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' + opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1628: '' + opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' + opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1629: '' + opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsToCategories + '.categories_id, ' + opmG_DBTable_ProductsDescription + '.language_id, ' + opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1630: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S")'
1631: ELSE
1632: SelectStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' + opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1633: '' + opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' + opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1634: '' + opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsToCategories + '.categories_id, ' + opmG_DBTable_ProductsDescription + '.language_id, ' + opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1635: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S"), ' +
1636: 'products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6';
1637: FromStr := ' from (' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ') left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id where';
1638: OrderStr := ' order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1639: IF (PCategory > 0) THEN
1640: WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' + opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (PCategory)
1641: ELSE
1642: WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id';
1643: IF (PManufacturer > 0) THEN
1644: IF (WhereStr <> '')
1645: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.manufacturers_id=' + INTTOSTR (PManufacturer)
1646: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.manufacturers_id=' + INTTOSTR (PManufacturer);
1647: IF (MultiString <> '') THEN
1648: BEGIN
1649: MultiString := FNopm_CleanSQLString (MultiString, TRUE);
1650: IF (WhereStr <> '') THEN WhereStr := WhereStr + ' and ' ELSE WhereStr := WhereStr + ' ';
1651: WhereStr := WhereStr + '(' + opmG_DBTable_Products + '.products_model like "%' + MultiString + '%"';
1652: WhereStr := WhereStr + ' or ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + MultiString + '%"';
1653: WhereStr := WhereStr + ' or ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + MultiString + '%")';
1654: END
1655: ELSE
1656: BEGIN
1657: IF (PModel <> '') THEN
1658: IF (WhereStr <> '')
1659: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_model like "%' + FNopm_CleanSQLString (PModel, TRUE) + '%"'
1660: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_model like "%' + FNopm_CleanSQLString (PModel, TRUE) + '%"';
1661: IF (PName <> '') THEN
1662: IF (WhereStr <> '')
1663: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + FNopm_CleanSQLString (PName, TRUE) + '%"'
1664: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + FNopm_CleanSQLString (PName, TRUE) + '%"';
1665: IF (PDesc <> '') THEN
1666: IF (WhereStr <> '')
1667: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + FNopm_CleanSQLString (PDesc, TRUE) + '%"'
1668: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + FNopm_CleanSQLString (PDesc, TRUE) + '%"';
1669: END;
1670: IF (PAvailable = opmC_SearchYes) THEN
1671: IF (WhereStr <> '')
1672: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_status > 0'
1673: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_status > 0'
1674: ELSE IF (PAvailable = opmC_SearchNo) THEN
1675: IF (WhereStr <> '')
1676: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_status = 0'
1677: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_status = 0';
1678: IF (PImgURL = opmC_SearchYes) THEN
1679: IF (WhereStr <> '')
1680: THEN WhereStr := WhereStr + ' and ' + '(' + opmG_DBTable_Products + '.products_image <> "" and ' + opmG_DBTable_Products + '.products_image IS NOT NULL)'
1681: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Products + '.products_image <> "" and ' + opmG_DBTable_Products + '.products_image IS NOT NULL)'
1682: ELSE IF (PImgURL = opmC_SearchNo) THEN
1683: IF (WhereStr <> '')
1684: THEN WhereStr := WhereStr + ' and ' + '(' + opmG_DBTable_Products + '.products_image = "" or ' + opmG_DBTable_Products + '.products_image IS NULL)'
1685: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Products + '.products_image = "" or ' + opmG_DBTable_Products + '.products_image IS NULL)';
1686: IF (PSPrice = opmC_SearchYes) THEN
1687: IF (WhereStr <> '')
1688: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Specials + '.specials_new_products_price > 0'
1689: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Specials + '.specials_new_products_price > 0'
1690: ELSE IF (PSPrice = opmC_SearchNo) THEN
1691: IF (WhereStr <> '')
1692: THEN WhereStr := WhereStr + ' and (' + opmG_DBTable_Specials + '.specials_new_products_price = 0 or ' + opmG_DBTable_Specials + '.specials_new_products_price IS NULL)'
1693: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Specials + '.specials_new_products_price = 0 or ' + opmG_DBTable_Specials + '.specials_new_products_price IS NULL)';
1694: IF (WhereStr <> '')
1695: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id'
1696: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id';
1697: opm_WeAreSearching := TRUE;
1698: IF (FNopm_WebDB_Query (opmG_WBUploadURL, SelectStr + FromStr + WhereStr + OrderStr, opmG_DBQuery_Recordset) = 0) THEN
1699: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1700: BEGIN
1701: PRopm_WriteLog ('BEGIN record loading (LoadSearchList)...');
1702: FOR CurProd := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1703: BEGIN
1704: ProdList[CurProd].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 0]);
1705: ProdList[CurProd].Model := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 2]);
1706: ProdList[CurProd].Quantity := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 1]);
1707: ProdList[CurProd].Price := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 3], opmC_ValIsCurrency));
1708: ProdList[CurProd].Weight := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 4], opmC_ValIsCurrency));
1709: ProdList[CurProd].ManufacturerID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 5]);
1710: ProdList[CurProd].CategoryID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 12]);
1711: ProdList[CurProd].DisplayName := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 6]);
1712: IF (ProdList[CurProd].DisplayName = '') THEN ProdList[CurProd].DisplayName := opmC_Unamed_Prod;
1713: ProdList[CurProd].Available := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 7]);
1714: ProdList[CurProd].ImageURL := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 10]);
1715: ProdList[CurProd].Special := STRTOCURR (FNopm_CleanNumber (opmG_DBQuery_Recordset.Data[CurProd, 11], opmC_ValIsCurrency));
1716: ProdList[CurProd].LanguageID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 13]);
1717: ProdList[CurProd].Tax := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 14]);
1718:
1719: ProdList[CurProd].CreationDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 17]);
1720: IF (ProdList[CurProd].CreationDate < opmG_Fallback_DateTime) THEN
1721: ProdList[CurProd].CreationDate := opmG_Fallback_DateTime;
1722: ProdList[CurProd].ChangeDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 18]);
1723: IF (ProdList[CurProd].ChangeDate < ProdList[CurProd].CreationDate) THEN
1724: ProdList[CurProd].ChangeDate := ProdList[CurProd].CreationDate;
1725: ProdList[CurProd].AvailDate := FNopm_StringToDate (opmG_DBQuery_Recordset.Data[CurProd, 16]);
1726: IF (ProdList[CurProd].AvailDate < ProdList[CurProd].CreationDate) THEN
1727: ProdList[CurProd].AvailDate := ProdList[CurProd].CreationDate;
1728:
1729: IF (opmG_Capa_MorePics6 = TRUE) THEN
1730: BEGIN
1731: ProdList[CurProd].ImageURL1 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 19]);
1732: ProdList[CurProd].ImageURL2 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 20]);
1733: ProdList[CurProd].ImageURL3 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 21]);
1734: ProdList[CurProd].ImageURL4 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 22]);
1735: ProdList[CurProd].ImageURL5 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 23]);
1736: ProdList[CurProd].ImageURL6 := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 24]);
1737: END
1738: ELSE
1739: BEGIN
1740: ProdList[CurProd].ImageURL1 := '';
1741: ProdList[CurProd].ImageURL2 := '';
1742: ProdList[CurProd].ImageURL3 := '';
1743: ProdList[CurProd].ImageURL4 := '';
1744: ProdList[CurProd].ImageURL5 := '';
1745: ProdList[CurProd].ImageURL6 := '';
1746: END;
1747:
1748: DescList[CurProd].ID := ProdList[CurProd].ID;
1749: DescList[CurProd].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 6]);
1750: IF (DescList[CurProd].Name = '') THEN DescList[CurProd].Name := opmC_Unamed_Prod;
1751: DescList[CurProd].Description := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 8]);
1752: DescList[CurProd].URL := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurProd, 9]);
1753: DescList[CurProd].Viewed := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 15]);
1754: DescList[CurProd].LanguageID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurProd, 13]);
1755: END;
1756: PRopm_WriteLog ('END record loading.');
1757: opm_TotalProducts := opmG_DBQuery_Recordset.DataRows;
1758: END;
1759: PRopm_Close_WebDBQuery;
1760: END;
1761:
1762:
1763:
1764:
1765: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1766: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1767: FUNCTION Topm_Form_Main.FNopm_GetCategory (VAR CatList : opmT_CategoryList; CatID : LONGINT; SearchBy : INTEGER) : opmR_Category;
1768: VAR
1769: CurCatR : opmR_Category;
1770: CurCat : LONGINT;
1771: BEGIN
1772: CurCatR.ID := 0;
1773: CurCatR.Parent := 0;
1774: CurCatR.Name := '';
1775: CurCatR.ListIndex := 0;
1776: CurCatR.TreeIndex := 0;
1777: FNopm_GetCategory := CurCatR;
1778: IF (SearchBy = opmC_FindByID) THEN
1779: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1780: BEGIN
1781: IF (CatList[CurCat].ID = CatID) THEN
1782: BEGIN
1783: CurCatR.ID := CatList[CurCat].ID;
1784: CurCatR.Parent := CatList[CurCat].Parent;
1785: CurCatR.Name := CatList[CurCat].Name;
1786: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1787: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1788: FNopm_GetCategory := CurCatR;
1789: BREAK;
1790: END;
1791: END
1792: ELSE IF (SearchBy = opmC_FindByIndex) THEN
1793: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1794: BEGIN
1795: IF (CatList[CurCat].ListIndex = CatID) THEN
1796: BEGIN
1797: CurCatR.ID := CatList[CurCat].ID;
1798: CurCatR.Parent := CatList[CurCat].Parent;
1799: CurCatR.Name := CatList[CurCat].Name;
1800: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1801: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1802: FNopm_GetCategory := CurCatR;
1803: BREAK;
1804: END;
1805: END
1806: ELSE
1807: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1808: BEGIN
1809: IF (CatList[CurCat].TreeIndex = CatID) THEN
1810: BEGIN
1811: CurCatR.ID := CatList[CurCat].ID;
1812: CurCatR.Parent := CatList[CurCat].Parent;
1813: CurCatR.Name := CatList[CurCat].Name;
1814: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1815: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1816: FNopm_GetCategory := CurCatR;
1817: BREAK;
1818: END;
1819: END;
1820: END;
1821:
1822:
1823:
1824: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1825: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1826: PROCEDURE Topm_Form_Main.PRopm_GetCategory_Data (CatID : LONGINT; VAR CatData : opmT_SingleCatList);
1827: VAR
1828: CurCat : LONGINT;
1829: MaxCat : LONGINT;
1830: CurLang : LONGINT;
1831: TmpCatList : opmT_SingleCatList;
1832: BEGIN
1833: CatData[0].ID := -1;
1834: CatData[0].Parent := 0;
1835: CatData[0].Name := '';
1836: CatData[0].LanguageID := -1;
1837: PRopm_WriteLog ('BEGIN record loading (LoadCatDataList)...');
1838: IF (FNopm_WebDB_Query (opmG_WBUploadURL, 'select ' + opmG_DBTable_Categories + '.categories_id, ' + opmG_DBTable_Categories + '.parent_id, ' + opmG_DBTable_CategoriesDescription + '.categories_name, ' + opmG_DBTable_CategoriesDescription + '.language_id from (' + opmG_DBTable_Categories + ') left join ' + opmG_DBTable_CategoriesDescription + ' on ' + opmG_DBTable_Categories + '.categories_id=' + opmG_DBTable_CategoriesDescription + '.categories_id where ' + opmG_DBTable_Categories + '.categories_id=' + INTTOSTR (CatID) + ' ORDER BY ' + opmG_DBTable_CategoriesDescription + '.language_id', opmG_DBQuery_Recordset) = 0) THEN
1839: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
1840: BEGIN
1841: FOR CurCat := 0 TO (opmG_DBQuery_Recordset.DataRows - 1) DO
1842: BEGIN
1843: CatData[CurCat].ID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCat, 0]);
1844: CatData[CurCat].Parent := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCat, 1]);
1845: CatData[CurCat].Name := FNopm_CleanString (opmG_DBQuery_Recordset.Data[CurCat, 2]);
1846: CatData[CurCat].LanguageID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[CurCat, 3]);
1847: IF (CatData[CurCat].Name = '') THEN CatData[CurCat].Name := opmC_Unamed_Cat;
1848: END;
1849: PRopm_WriteLog ('END record loading.');
1850: MaxCat := opmG_DBQuery_Recordset.DataRows;
1851: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1852: BEGIN
1853: TmpCatList[CurLang].ID := -1;
1854: TmpCatList[CurLang].Parent := 0;
1855: TmpCatList[CurLang].Name := '';
1856: TmpCatList[CurLang].LanguageID := -1;
1857: END;
1858: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1859: BEGIN
1860: FOR CurCat := 0 TO MaxCat DO
1861: BEGIN
1862: IF (CatData[CurCat].LanguageID = opmG_LanguageList[CurLang].ID) THEN
1863: BEGIN
1864: TmpCatList[CurLang] := CatData[CurCat];
1865: BREAK;
1866: END;
1867: END;
1868: END;
1869: CatData := TmpCatList;
1870: END;
1871: PRopm_Close_WebDBQuery;
1872: END;
1873:
1874:
1875:
1876: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1877: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1878: FUNCTION Topm_Form_Main.FNopm_GetRealLangIDByIndex (VAR LangList : opmT_LanguageList; LangIndex : LONGINT) : LONGINT;
1879: VAR
1880: CurLang : LONGINT;
1881: BEGIN
1882: FNopm_GetRealLangIDByIndex := 0;
1883: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1884: BEGIN
1885: IF (LangList[CurLang].ListIndex = LangIndex) THEN
1886: BEGIN
1887: FNopm_GetRealLangIDByIndex := LangList[CurLang].ID;
1888: BREAK;
1889: END;
1890: END;
1891: END;
1892:
1893:
1894:
1895: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1896: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1897: FUNCTION Topm_Form_Main.FNopm_GetManufacturer (VAR ManList : opmT_ManufacturerList; ManID : LONGINT; SearchBy : INTEGER) : opmR_Manufacturer;
1898: VAR
1899: CurManR : opmR_Manufacturer;
1900: CurMan : LONGINT;
1901: BEGIN
1902: CurManR.ID := 0;
1903: CurManR.Name := '';
1904: CurManR.ListIndex := 0;
1905: FNopm_GetManufacturer := CurManR;
1906: IF (SearchBy = opmC_FindByID) THEN
1907: FOR CurMan := 0 TO (opm_TotalManufacturers - 1) DO
1908: BEGIN
1909: IF (ManList[CurMan].ID = ManID) THEN
1910: BEGIN
1911: FNopm_GetManufacturer := ManList[CurMan];
1912: BREAK;
1913: END;
1914: END
1915: ELSE
1916: FOR CurMan := 0 TO (opm_TotalManufacturers - 1) DO
1917: BEGIN
1918: IF (ManList[CurMan].ListIndex = ManID) THEN
1919: BEGIN
1920: FNopm_GetManufacturer := ManList[CurMan];
1921: BREAK;
1922: END;
1923: END;
1924: END;
1925:
1926:
1927:
1928: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1929: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1930: FUNCTION Topm_Form_Main.FNopm_GetCurrency (VAR CurrList : opmT_CurrencyList; CurrID : LONGINT; SearchBy : INTEGER) : opmR_Currency;
1931: VAR
1932: CurCurrR : opmR_Currency;
1933: CurCurr : LONGINT;
1934: BEGIN
1935: CurCurrR.ID := -1;
1936: CurCurrR.Name := '';
1937: CurCurrR.Code := '';
1938: CurCurrR.Left := '';
1939: CurCurrR.Right := '';
1940: CurCurrR.DecimalSep := '';
1941: CurCurrR.ThousandSep := '';
1942: CurCurrR.Precision := 0;
1943: CurCurrR.Value := 0;
1944: CurCurrR.NewValue := 0;
1945: CurCurrR.ListIndex := -1;
1946: CurCurrR.Default := FALSE;
1947: FNopm_GetCurrency := CurCurrR;
1948: IF (SearchBy = opmC_FindByID) THEN
1949: FOR CurCurr := 0 TO (opm_TotalCurrencies - 1) DO
1950: BEGIN
1951: IF (CurrList[CurCurr].ID = CurrID) THEN
1952: BEGIN
1953: FNopm_GetCurrency := CurrList[CurCurr];
1954: BREAK;
1955: END;
1956: END
1957: ELSE
1958: FOR CurCurr := 0 TO (opm_TotalCurrencies - 1) DO
1959: BEGIN
1960: IF (CurrList[CurCurr].ListIndex = CurrID) THEN
1961: BEGIN
1962: FNopm_GetCurrency := CurrList[CurCurr];
1963: BREAK;
1964: END;
1965: END;
1966: END;
1967:
1968:
1969:
1970: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1971: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1972: FUNCTION Topm_Form_Main.FNopm_GetProductByID (ProdID, LangID : LONGINT; VAR ProdList : opmT_ProductList) : opmR_Product;
1973: VAR
1974: CurProdR : opmR_Product;
1975: CurProd : LONGINT;
1976: BEGIN
1977: CurProdR.ID := -1;
1978: CurProdR.Model := '';
1979: CurProdR.Quantity := 0;
1980: CurProdR.Price := 0;
1981: CurProdR.Weight := 0;
1982: CurProdR.ManufacturerID := 0;
1983: CurProdR.CategoryID := 0;
1984: CurProdR.DisplayName := '';
1985: CurProdR.ImageURL := '';
1986: CurProdR.Available := 0;
1987: CurProdR.Special := 0;
1988: CurProdR.LanguageID := LangID;
1989: CurProdR.Tax := 0;
1990: FNopm_GetProductByID := CurProdR;
1991: FOR CurProd := 0 TO (opm_TotalProducts - 1) DO
1992: BEGIN
1993: IF ((ProdList[CurProd].ID = ProdID) AND (ProdList[CurProd].LanguageID = LangID)) THEN
1994: BEGIN
1995: FNopm_GetProductByID := ProdList[CurProd];
1996: BREAK;
1997: END;
1998: END;
1999: END;
2000:
2001:
2002:
2003: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2004: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2005: FUNCTION Topm_Form_Main.FNopm_GetDescriptionByID (ProdID, LangID : LONGINT; VAR DescList : opmT_DescriptionList) : opmR_Description;
2006: VAR
2007: CurDescR : opmR_Description;
2008: CurDesc : LONGINT;
2009: BEGIN
2010: CurDescR.ID := -1;
2011: CurDescR.Name := '';
2012: CurDescR.Description := '';
2013: CurDescR.URL := '';
2014: CurDescR.LanguageID := LangID;
2015: CurDescR.Viewed := 0;
2016: FNopm_GetDescriptionByID := CurDescR;
2017: FOR CurDesc := 0 TO (opm_TotalProducts - 1) DO
2018: BEGIN
2019: IF ((DescList[CurDesc].ID = ProdID) AND (DescList[CurDesc].LanguageID = LangID)) THEN
2020: BEGIN
2021: FNopm_GetDescriptionByID := DescList[CurDesc];
2022: BREAK;
2023: END;
2024: END;
2025: END;
2026:
2027:
2028:
2029:
2030:
2031: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2032: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2033: procedure Topm_Form_Main.opm_TreeView_MainChange(Sender: TObject; Node: TTreeNode);
2034: begin
2035: IF (opm_StopTreeOnChange = FALSE) THEN
2036: BEGIN
2037: opm_TreeView_Main.Enabled := FALSE;
2038: IF (opm_TreeView_Main.Selected <> NIL) THEN
2039: BEGIN
2040: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, Node.AbsoluteIndex, opmC_FindByNode);
2041: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2042: IF (opm_CurrentCatRecord.ID < opmC_SC_BaseID) THEN
2043: BEGIN
2044: IF (opmG_UIClickLoad > 0) THEN
2045: BEGIN
2046: PRopm_Sound ('MenuPopup', opmG_UISilent);
2047: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2048: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Loading product list...'));
2049: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
2050: opm_Form_Progress.PRopm_PDClose;
2051: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2052: IF (opm_CurrentCatRecord.ID >= 0) THEN
2053: PRopm_Valid_CatOps (FNopm_ConnectionState, opm_TreeView_Main.Selected)
2054: ELSE
2055: PRopm_Valid_CatOps (FNopm_ConnectionState, NIL);
2056: PRopm_Valid_ProdOps (FNopm_ConnectionState, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected, opm_CurrentProdID_CB);
2057: END;
2058: END
2059: ELSE
2060: BEGIN
2061: { CLICK IN SPECIAL NODE, PROCESS HERE... }
2062: PRopm_Valid_CatOps (FNopm_ConnectionState, NIL);
2063: PRopm_Valid_ProdOps (FNopm_ConnectionState, NIL, 0, NIL, 0);
2064: END
2065: END
2066: ELSE
2067: BEGIN
2068: PRopm_Valid_CatOps (FNopm_ConnectionState, NIL);
2069: PRopm_Valid_ProdOps (FNopm_ConnectionState, NIL, 0, NIL, 0);
2070: END;
2071: opm_TreeView_Main.Enabled := TRUE;
2072: opm_Form_Main.FocusControl (opm_TreeView_Main);
2073: END;
2074: end;
2075:
2076:
2077: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2078: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2079: procedure Topm_Form_Main.opm_MenuItem_RefreshCategoriesClick (Sender: TObject);
2080: begin
2081: opm_TreeView_Main.Enabled := FALSE;
2082: PRopm_Sound ('MenuPopup', opmG_UISilent);
2083: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2084: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 1, _('Loading language list...'));
2085: PRopm_LoadLanguageList (opmG_LanguageList, opmG_LanguageBoxList);
2086: opm_Form_Progress.PRopm_PDUpdate_Progress (20, 1, _('Loading category list...'));
2087: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
2088: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Loading manufacturers list...'));
2089: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
2090: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Loading taxes list...'));
2091: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
2092: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
2093: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
2094: opm_Form_Progress.PRopm_PDClose;
2095: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
2096: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
2097: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2098: opm_TreeView_Main.Enabled := TRUE;
2099: opm_Form_Main.FocusControl (opm_TreeView_Main);
2100: end;
2101:
2102:
2103: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2104: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2105: procedure Topm_Form_Main.opm_MenuItem_RefreshProductsClick(Sender: TObject);
2106: VAR
2107: CurItem : TListItem;
2108: BEGIN
2109: CurItem := opm_ListView_Main.Selected;
2110: IF (CurItem <> NIL) THEN opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2111: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2112: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Loading product list.'));
2113: PRopm_Reload_ProductList (opm_WeAreSearching);
2114: opm_Form_Progress.PRopm_PDClose;
2115: end;
2116:
2117:
2118: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2119: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2120: procedure Topm_Form_Main.opm_ComboBox_DisplayLangSelect(Sender: TObject);
2121: begin
2122: PRopm_Sound ('MenuPopup', opmG_UISilent);
2123: opm_CurrentLang := FNopm_GetRealLangIDByIndex (opmG_LanguageList, opm_ComboBox_DisplayLang.ItemIndex);
2124: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2125: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 1, _('Loading language list...'));
2126: PRopm_LoadLanguageList (opmG_LanguageList, opmG_LanguageBoxList);
2127: opm_Form_Progress.PRopm_PDUpdate_Progress (20, 1, _('Loading category list...'));
2128: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
2129: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Loading manufacturers list...'));
2130: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
2131: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Loading taxes list...'));
2132: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
2133: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
2134: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
2135: opm_Form_Progress.PRopm_PDClose;
2136: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
2137: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
2138: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2139: end;
2140:
2141: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2142: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2143: procedure Topm_Form_Main.opm_MenuItem_SearchProductClick(Sender: TObject);
2144: begin
2145: IF (opm_Form_SearchProduct.ShowModal = mrOk) THEN
2146: BEGIN
2147: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2148: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Searching product...'));
2149: opm_Search_Quick := '';
2150: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, opm_Search_Quick);
2151: opm_Form_Progress.PRopm_PDClose;
2152: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2153: PRopm_Valid_ProdOps (FNopm_ConnectionState, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, NIL, opm_CurrentProdID_CB);
2154: END;
2155: end;
2156:
2157:
2158:
2159: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2160: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2161: procedure Topm_Form_Main.opm_ListView_MainDblClick(Sender: TObject);
2162: var
2163: CurItem : TListItem;
2164: CurLang : LONGINT;
2165: begin
2166: CurItem := opm_ListView_Main.Selected;
2167: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2168: BEGIN
2169: opm_ListView_Main.Enabled := FALSE;
2170: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2171: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2172: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2173: opm_CurrentSingleDescList[CurLang] := FNopm_GetDescriptionByID (opm_CurrentProdRecord.ID, opmG_LanguageList[CurLang].ID, opmG_DescriptionList);
2174: IF (opm_Form_PEdit.ShowModal = mrOk) THEN
2175: BEGIN
2176: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2177: BEGIN
2178: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2179: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Updating product data...'));
2180: PRopm_UpdateProduct (opm_CurrentProdRecord, opm_CurrentPEditRecord, opm_CurrentSingleDescList);
2181: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading product list.'));
2182: PRopm_Reload_ProductList (opm_WeAreSearching);
2183: opm_Form_Progress.PRopm_PDClose;
2184: END;
2185: END;
2186: opm_ListView_Main.Enabled := TRUE;
2187: opm_Form_Main.FocusControl (opm_ListView_Main);
2188: END;
2189: end;
2190:
2191:
2192:
2193:
2194:
2195: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2196: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2197: PROCEDURE Topm_Form_Main.PRopm_UpdateProduct (CurProdRecord, NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
2198: VAR
2199: UStrProducts, UStrProdCats, IStrProdCats, DStrProdDesc, IStrProdDesc, DStrProdSpec, IStrProdSpec : STRING;
2200: CurLang : LONGINT;
2201: BEGIN
2202: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, _('Preparing update query...'));
2203: UStrProducts := '';
2204: UStrProdCats := '';
2205: IStrProdCats := '';
2206: DStrProdSpec := '';
2207: IStrProdSpec := '';
2208: IF (opmG_Capa_MorePics6 = FALSE) THEN
2209: UStrProducts := 'update ' + opmG_DBTable_Products + ' set products_model="' + NewProdRecord.Model + '",'
2210: + ' products_quantity=' + INTTOSTR (NewProdRecord.Quantity) + ','
2211: + ' manufacturers_id=' + INTTOSTR (NewProdRecord.ManufacturerID) + ','
2212: + ' products_image="' + TRIM (NewProdRecord.ImageURL) + '",'
2213: + ' products_price=' + CURRTOSTR (NewProdRecord.Price) + ','
2214: + ' products_weight=' + CURRTOSTR (NewProdRecord.Weight) + ','
2215: + ' products_status=' + INTTOSTR (NewProdRecord.Available) + ','
2216: + ' products_last_modified=now()' + ', '
2217: + ' products_tax_class_id=' + INTTOSTR (NewProdRecord.Tax) + ', '
2218: + ' products_date_available="' + FNopm_DateToString (NewProdRecord.AvailDate) + '"'
2219: + ' where products_id=' + INTTOSTR (NewProdRecord.ID)
2220: ELSE
2221: UStrProducts := 'update ' + opmG_DBTable_Products + ' set products_model="' + NewProdRecord.Model + '",'
2222: + ' products_quantity=' + INTTOSTR (NewProdRecord.Quantity) + ','
2223: + ' manufacturers_id=' + INTTOSTR (NewProdRecord.ManufacturerID) + ','
2224: + ' products_image="' + TRIM (NewProdRecord.ImageURL) + '",'
2225: + ' products_price=' + CURRTOSTR (NewProdRecord.Price) + ','
2226: + ' products_weight=' + CURRTOSTR (NewProdRecord.Weight) + ','
2227: + ' products_status=' + INTTOSTR (NewProdRecord.Available) + ','
2228: + ' products_last_modified=now()' + ', '
2229: + ' products_tax_class_id=' + INTTOSTR (NewProdRecord.Tax) + ', '
2230: + ' products_date_available="' + FNopm_DateToString (NewProdRecord.AvailDate) + '", '
2231: + ' products_subimage1="' + TRIM (NewProdRecord.ImageURL1) + '",'
2232: + ' products_subimage2="' + TRIM (NewProdRecord.ImageURL2) + '",'
2233: + ' products_subimage3="' + TRIM (NewProdRecord.ImageURL3) + '",'
2234: + ' products_subimage4="' + TRIM (NewProdRecord.ImageURL4) + '",'
2235: + ' products_subimage5="' + TRIM (NewProdRecord.ImageURL5) + '",'
2236: + ' products_subimage6="' + TRIM (NewProdRecord.ImageURL6) + '"'
2237: + ' where products_id=' + INTTOSTR (NewProdRecord.ID);
2238: IF (CurProdRecord.CategoryID <> NewProdRecord.CategoryID) THEN
2239: BEGIN
2240: UStrProdCats := 'delete from ' + opmG_DBTable_ProductsToCategories + ''
2241: + ' where products_id=' + INTTOSTR (NewProdRecord.ID) + ' and categories_id=' + INTTOSTR (CurProdRecord.CategoryID);
2242: IStrProdCats := 'insert into ' + opmG_DBTable_ProductsToCategories + ' (products_id, categories_id)' + ''
2243: + ' values (' + INTTOSTR (CurProdRecord.ID) + ', ' + INTTOSTR (NewProdRecord.CategoryID) + ')';
2244: END
2245: ELSE
2246: BEGIN
2247: UStrProdCats := '';
2248: IStrProdCats := '';
2249: END;
2250: IF (CurProdRecord.Special <> NewProdRecord.Special) THEN
2251: DStrProdSpec := 'delete from ' + opmG_DBTable_Specials + '' + ''
2252: + ' where products_id=' + INTTOSTR (NewProdRecord.ID)
2253: ELSE
2254: DStrProdSpec := '';
2255: IF ((ROUND (NewProdRecord.Special) > 0) AND (CurProdRecord.Special <> NewProdRecord.Special)) THEN
2256: IStrProdSpec := 'insert into ' + opmG_DBTable_Specials + ' (products_id, specials_new_products_price, specials_date_added, specials_last_modified)' + ''
2257: + ' values (' + INTTOSTR (NewProdRecord.ID) + ', ' + CURRTOSTR (NewProdRecord.Special) + ', now(), now())'
2258: ELSE
2259: IStrProdSpec := '';
2260: opm_Form_Progress.PRopm_PDUpdate_Progress (12, 2, 'Updating general product data...');
2261: IF (UStrProducts <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, UStrProducts, opmG_DBQuery_Recordset);
2262: opm_Form_Progress.PRopm_PDUpdate_Progress (24, 2, 'Updating category relationships...');
2263: IF (UStrProdCats <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, UStrProdCats, opmG_DBQuery_Recordset);
2264: opm_Form_Progress.PRopm_PDUpdate_Progress (36, 2, '');
2265: IF (IStrProdCats <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdCats, opmG_DBQuery_Recordset);
2266: opm_Form_Progress.PRopm_PDUpdate_Progress (48, 2, 'Updating special prices...');
2267: IF (DStrProdSpec <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, DStrProdSpec, opmG_DBQuery_Recordset);
2268: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 2, '');
2269: IF (IStrProdSpec <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdSpec, opmG_DBQuery_Recordset);
2270: opm_Form_Progress.PRopm_PDUpdate_Progress (72, 2, 'Updating product descriptions...');
2271: DStrProdDesc := 'delete from ' + opmG_DBTable_ProductsDescription + ''
2272: + ' where products_id=' + INTTOSTR (NewProdRecord.ID);
2273: FNopm_WebDB_Query (opmG_WBUploadURL, DStrProdDesc, opmG_DBQuery_Recordset);
2274: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2275: IF (SingleDescList[CurLang].ID > 0) THEN
2276: BEGIN
2277: IStrProdDesc := 'insert into ' + opmG_DBTable_ProductsDescription + ' (products_name, products_description, products_url, products_id, language_id)' + ''
2278: + ' values ("' + FNopm_CleanSQLString (SingleDescList[CurLang].Name, FALSE) + '",'
2279: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].Description, FALSE) + '",'
2280: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].URL, FALSE) + '", '
2281: + INTTOSTR (SingleDescList[CurLang].ID) + ', ' + INTTOSTR (SingleDescList[CurLang].LanguageID) + ')';
2282: FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdDesc, opmG_DBQuery_Recordset);
2283: opm_Form_Progress.PRopm_PDUpdate_Progress (84 + (CurLang * ROUND (12 / opm_TotalLanguages)), 2, '');
2284: END;
2285: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2286: END;
2287:
2288:
2289:
2290:
2291: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2292: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2293: PROCEDURE Topm_Form_Main.PRopm_UpdateProdData (ProdID : LONGINT; ProdTable, ProdField, ProdDataStr : STRING;
2294: PDataIsNum : BOOLEAN; SecIDField, SecIDData : STRING;
2295: SQLQueryType : INTEGER);
2296: VAR
2297: UStrProducts, DStrProducts : STRING;
2298: BEGIN
2299: UStrProducts := '';
2300: DStrProducts := '';
2301: IF (ProdID > 0) AND (ProdTable <> '') AND (ProdField <> '') AND (ProdDataStr <> '') THEN
2302: BEGIN
2303: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 2, _('Updating product data...'));
2304: IF (SQLQueryType = opmC_SQLUpdate) THEN
2305: BEGIN
2306: IF (PDataIsNum = TRUE) THEN
2307: UStrProducts := 'update ' + ProdTable + ' set ' + ProdField + '=' + ProdDataStr + ''
2308: + ' where products_id=' + INTTOSTR (ProdID)
2309: ELSE
2310: UStrProducts := 'update ' + ProdTable + ' set ' + ProdField + '="' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '"'
2311: + ' where products_id=' + INTTOSTR (ProdID);
2312: IF (SecIDField <> '') THEN UStrProducts := UStrProducts + ' and ' + SecIDField + '=' + SecIDData;
2313: FNopm_WebDB_Query (opmG_WBUploadURL, UStrProducts, opmG_DBQuery_Recordset);
2314: END;
2315: IF ((SQLQueryType = opmC_SQLDelIns) OR (SQLQueryType = opmC_SQLDelInsNoZero)) THEN
2316: BEGIN
2317: DStrProducts := 'delete from ' + ProdTable + '' + ' where products_id=' + INTTOSTR (ProdID);
2318: IF (PDataIsNum = TRUE) THEN
2319: BEGIN
2320: IF NOT ((SQLQueryType = opmC_SQLDelInsNoZero) AND (STRTOCURR (ProdDataStr) = 0)) THEN
2321: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2322: + ' values (' + INTTOSTR (ProdID) + ', ' + FNopm_CleanSQLString (ProdDataStr, FALSE) + ')';
2323: END
2324: ELSE
2325: BEGIN
2326: IF NOT ((SQLQueryType = opmC_SQLDelInsNoZero) AND (ProdDataStr = '')) THEN
2327: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2328: + ' values (' + INTTOSTR (ProdID) + ', "' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '")';
2329: END;
2330: FNopm_WebDB_Query (opmG_WBUploadURL, DStrProducts, opmG_DBQuery_Recordset);
2331: FNopm_WebDB_Query (opmG_WBUploadURL, UStrProducts, opmG_DBQuery_Recordset);
2332: END;
2333: IF (SQLQueryType = opmC_SQLInsert) THEN
2334: BEGIN
2335: IF (PDataIsNum = TRUE) THEN
2336: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2337: + ' values (' + INTTOSTR (ProdID) + ', ' + FNopm_CleanSQLString (ProdDataStr, FALSE) + ')'
2338: ELSE
2339: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2340: + ' values (' + INTTOSTR (ProdID) + ', "' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '")';
2341: FNopm_WebDB_Query (opmG_WBUploadURL, UStrProducts, opmG_DBQuery_Recordset);
2342: END;
2343: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, ' ');
2344: END;
2345: END;
2346:
2347:
2348: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2349: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2350: PROCEDURE Topm_Form_Main.PRopm_DeleteProduct (ProdID : LONGINT);
2351: VAR
2352: DStrProducts, DStrProdDesc, DStrProdSpec, DStrProdCats : STRING;
2353: ResStr : STRING;
2354: ResCode : LONGINT;
2355: BEGIN
2356: IF (ProdID > 0) THEN
2357: BEGIN
2358: opm_CurrentProdRecord := FNopm_GetProductByID (ProdID, opm_CurrentLang, opmG_ProductList);
2359: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, _('Deleting general product data...'));
2360: PRopm_Prepare_HTTPClient (NIL, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
2361: DStrProducts := 'delete from ' + opmG_DBTable_Products + ' where products_id=' + INTTOSTR (ProdID);
2362: DStrProdCats := 'delete from ' + opmG_DBTable_ProductsToCategories + ' where products_id=' + INTTOSTR (ProdID);
2363: DStrProdSpec := 'delete from ' + opmG_DBTable_Specials + ' where products_id=' + INTTOSTR (ProdID);
2364: DStrProdDesc := 'delete from ' + opmG_DBTable_ProductsDescription + ' where products_id=' + INTTOSTR (ProdID);
2365: IF (FNopm_WebDB_Query (opmG_WBUploadURL, DStrProducts, opmG_DBQuery_Recordset) = 0) THEN
2366: BEGIN
2367: opm_Form_Progress.PRopm_PDUpdate_Progress (20, 2, 'Deleting product image...');
2368: ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL, ResStr);
2369: IF (opmG_Capa_MorePics6 = TRUE) THEN
2370: BEGIN
2371: opm_Form_Progress.PRopm_PDUpdate_Progress (23, 2, 'Deleting extra product images...');
2372: IF (opm_CurrentProdRecord.ImageURL1 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL1, ResStr);
2373: opm_Form_Progress.PRopm_PDUpdate_Progress (26, 2, '');
2374: IF (opm_CurrentProdRecord.ImageURL2 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL2, ResStr);
2375: opm_Form_Progress.PRopm_PDUpdate_Progress (29, 2, '');
2376: IF (opm_CurrentProdRecord.ImageURL3 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL3, ResStr);
2377: opm_Form_Progress.PRopm_PDUpdate_Progress (32, 2, '');
2378: IF (opm_CurrentProdRecord.ImageURL4 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL4, ResStr);
2379: opm_Form_Progress.PRopm_PDUpdate_Progress (35, 2, '');
2380: IF (opm_CurrentProdRecord.ImageURL5 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL5, ResStr);
2381: opm_Form_Progress.PRopm_PDUpdate_Progress (38, 2, '');
2382: IF (opm_CurrentProdRecord.ImageURL6 <> '') THEN ResCode := Rescode + FNopm_Send_Command (opmG_WBUploadURL, 'delete1', opm_CurrentProdRecord.ImageURL6, ResStr);
2383: END;
2384: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 2, 'Deleting category relationships...');
2385: FNopm_WebDB_Query (opmG_WBUploadURL, DStrProdCats, opmG_DBQuery_Recordset);
2386: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 2, 'Deleting special prices...');
2387: FNopm_WebDB_Query (opmG_WBUploadURL, DStrProdSpec, opmG_DBQuery_Recordset);
2388: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 2, 'Deleting product descriptions...');
2389: FNopm_WebDB_Query (opmG_WBUploadURL, DStrProdDesc, opmG_DBQuery_Recordset);
2390: IF (ResCode > 0) THEN FNopm_Message (_('There were errors while trying to delete one or more product images.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
2391: END;
2392: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, ' ');
2393: END;
2394: END;
2395:
2396:
2397:
2398:
2399: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2400: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2401: PROCEDURE Topm_Form_Main.PRopm_AddProduct (NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
2402: VAR
2403: IStrProducts, IStrProdCats, IStrProdDesc, IStrProdSpec : STRING;
2404: LastID : LONGINT;
2405: CurLang : LONGINT;
2406: BEGIN
2407: LastID := 0;
2408: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, _('Adding product record...'));
2409: IF (opmG_Capa_MorePics6 = FALSE) THEN
2410: IStrProducts := 'insert into ' + opmG_DBTable_Products + ' (products_model, products_quantity, manufacturers_id, products_price, products_weight, products_status, products_last_modified, products_date_added, products_tax_class_id, products_date_available, products_image)' + ''
2411: + ' values ("' + NewProdRecord.Model + '", '
2412: + INTTOSTR (NewProdRecord.Quantity) + ', ' + INTTOSTR (NewProdRecord.ManufacturerID) + ', '
2413: + CURRTOSTR (NewProdRecord.Price) + ', ' + CURRTOSTR (NewProdRecord.Weight) + ', '
2414: + INTTOSTR (NewProdRecord.Available) + ', ' + 'now(), now(), '
2415: + INTTOSTR (NewProdRecord.Tax) + ', "' + FNopm_DateToString (NewProdRecord.AvailDate) + '", "' + TRIM (NewProdRecord.ImageURL) + '")'
2416: ELSE
2417: IStrProducts := 'insert into ' + opmG_DBTable_Products + ' (products_model, products_quantity, manufacturers_id, products_price, products_weight, products_status, products_last_modified, products_date_added, products_tax_class_id, products_date_available, products_image, '
2418: + 'products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6)' + ''
2419: + ' values ("' + NewProdRecord.Model + '", '
2420: + INTTOSTR (NewProdRecord.Quantity) + ', ' + INTTOSTR (NewProdRecord.ManufacturerID) + ', '
2421: + CURRTOSTR (NewProdRecord.Price) + ', ' + CURRTOSTR (NewProdRecord.Weight) + ', '
2422: + INTTOSTR (NewProdRecord.Available) + ', ' + 'now(), now(), '
2423: + INTTOSTR (NewProdRecord.Tax) + ', "' + FNopm_DateToString (NewProdRecord.AvailDate) + '", "' + TRIM (NewProdRecord.ImageURL) + '", "'
2424: + TRIM (NewProdRecord.ImageURL1) + '", "' + TRIM (NewProdRecord.ImageURL2) + '", "' + TRIM (NewProdRecord.ImageURL3) + '", "'
2425: + TRIM (NewProdRecord.ImageURL4) + '", "' + TRIM (NewProdRecord.ImageURL3) + '", "' + TRIM (NewProdRecord.ImageURL6) + '")';
2426: opm_Form_Progress.PRopm_PDUpdate_Progress (20, 2, 'Saving general product data...');
2427: IF (FNopm_WebDB_Query (opmG_WBUploadURL, IStrProducts, opmG_DBQuery_Recordset) = 0) THEN
2428: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
2429: BEGIN
2430: LastID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[0, 0]);;
2431: END;
2432: IF (LastID > 0) THEN
2433: BEGIN
2434: IF (NewProdRecord.CategoryID >= 0) THEN
2435: IStrProdCats := 'insert into ' + opmG_DBTable_ProductsToCategories + ' (products_id, categories_id)' + ''
2436: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (NewProdRecord.CategoryID) + ')'
2437: ELSE IStrProdCats := '';
2438: IF (ROUND (NewProdRecord.Special) > 0) THEN
2439: IStrProdSpec := 'insert into ' + opmG_DBTable_Specials + ' (products_id, specials_new_products_price, specials_date_added, specials_last_modified)' + ''
2440: + ' values (' + INTTOSTR (LastID) + ', ' + CURRTOSTR (NewProdRecord.Special) + ', now(), now())'
2441: ELSE
2442: IStrProdSpec := '';
2443: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 2, 'Saving category relationships...');
2444: FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdCats, opmG_DBQuery_Recordset);
2445: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 2, 'Saving special prices...');
2446: IF (IStrProdSpec <> '') THEN FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdSpec, opmG_DBQuery_Recordset);
2447: END;
2448: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 2, 'Saving product descriptions...');
2449: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2450: IF (SingleDescList[CurLang].ID = opmC_InsertProdID) THEN
2451: BEGIN
2452: IStrProdDesc := 'insert into ' + opmG_DBTable_ProductsDescription + ' (products_name, products_description, products_url, products_id, language_id, products_viewed)' + ''
2453: + ' values ("' + FNopm_CleanSQLString (SingleDescList[CurLang].Name, FALSE) + '",'
2454: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].Description, FALSE) + '",'
2455: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].URL, FALSE) + '", '
2456: + INTTOSTR (LastID) + ', ' + INTTOSTR (SingleDescList[CurLang].LanguageID) + ', 0)';
2457: FNopm_WebDB_Query (opmG_WBUploadURL, IStrProdDesc, opmG_DBQuery_Recordset);
2458: opm_Form_Progress.PRopm_PDUpdate_Progress (80 + (CurLang * ROUND (20 / opm_TotalLanguages)), 2, '');
2459: END;
2460: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2461: END;
2462:
2463:
2464:
2465: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2466: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2467: PROCEDURE Topm_Form_Main.PRopm_Valid_CatOps (WeAreConnected : BOOLEAN; SelectedCat : TTreeNode);
2468: BEGIN
2469: IF (WeAreConnected = TRUE) THEN
2470: BEGIN
2471: opm_MenuItem_RefreshCategories.Enabled := TRUE;
2472: opm_MenuItem_ManAdd.Enabled := TRUE;
2473: opm_MenuItem_ManRename.Enabled := TRUE;
2474: opm_MenuItem_ManDelete.Enabled := TRUE;
2475: opm_MenuItem_ManCurrency.Enabled := TRUE;
2476: opm_MenuItem_SearchProduct.Enabled := TRUE;
2477: opm_MenuItem_Backup.Enabled := TRUE;
2478: opm_ToolButton_Search.Enabled := TRUE;
2479: opm_Edit_QuickSearch.Enabled := TRUE;
2480: opm_SpeedButton_QuickSearch.Enabled := TRUE;
2481: IF (SelectedCat <> NIL) THEN
2482: BEGIN
2483: opm_MenuItem_CategoryAdd.Enabled := TRUE;
2484: opm_ToolButton_AddCat.Enabled := TRUE;
2485: opm_PopMenuItem_CatAdd.Enabled := TRUE;
2486: opm_PopMenuItem_CatExpand2.Enabled := TRUE;
2487: opm_PopMenuItem_CatCollapse2.Enabled := TRUE;
2488: opm_PopMenuItem_CatExpand.Enabled := TRUE;
2489: opm_PopMenuItem_CatCollapse.Enabled := TRUE;
2490: IF (SelectedCat.AbsoluteIndex <> 0) THEN
2491: BEGIN
2492: opm_MenuItem_CategoryRename.Enabled := TRUE;
2493: opm_ToolButton_RenCat.Enabled := TRUE;
2494: opm_PopMenuItem_CatRename.Enabled := TRUE;
2495: opm_MenuItem_CategoryDelete.Enabled := TRUE;
2496: opm_ToolButton_DelCat.Enabled := TRUE;
2497: opm_PopMenuItem_CatDelete.Enabled := TRUE;
2498: END
2499: ELSE
2500: BEGIN
2501: opm_MenuItem_CategoryRename.Enabled := FALSE;
2502: opm_ToolButton_RenCat.Enabled := FALSE;
2503: opm_PopMenuItem_CatRename.Enabled := FALSE;
2504: opm_MenuItem_CategoryDelete.Enabled := FALSE;
2505: opm_ToolButton_DelCat.Enabled := FALSE;
2506: opm_PopMenuItem_CatDelete.Enabled := FALSE;
2507: END;
2508: END
2509: ELSE
2510: BEGIN
2511: opm_MenuItem_CategoryAdd.Enabled := FALSE;
2512: opm_ToolButton_AddCat.Enabled := FALSE;
2513: opm_PopMenuItem_CatAdd.Enabled := FALSE;
2514: opm_MenuItem_CategoryRename.Enabled := FALSE;
2515: opm_ToolButton_RenCat.Enabled := FALSE;
2516: opm_PopMenuItem_CatRename.Enabled := FALSE;
2517: opm_MenuItem_CategoryDelete.Enabled := FALSE;
2518: opm_ToolButton_DelCat.Enabled := FALSE;
2519: opm_PopMenuItem_CatDelete.Enabled := FALSE;
2520: opm_PopMenuItem_CatExpand2.Enabled := FALSE;
2521: opm_PopMenuItem_CatCollapse2.Enabled := FALSE;
2522: opm_PopMenuItem_CatExpand.Enabled := FALSE;
2523: opm_PopMenuItem_CatCollapse.Enabled := FALSE;
2524: END;
2525: END
2526: ELSE
2527: BEGIN
2528: opm_MenuItem_RefreshCategories.Enabled := FALSE;
2529: opm_MenuItem_ManAdd.Enabled := FALSE;
2530: opm_MenuItem_ManRename.Enabled := FALSE;
2531: opm_MenuItem_ManDelete.Enabled := FALSE;
2532: opm_MenuItem_ManCurrency.Enabled := FALSE;
2533: opm_MenuItem_SearchProduct.Enabled := FALSE;
2534: opm_MenuItem_Backup.Enabled := FALSE;
2535: opm_ToolButton_Search.Enabled := FALSE;
2536: opm_Edit_QuickSearch.Enabled := FALSE;
2537: opm_SpeedButton_QuickSearch.Enabled := FALSE;
2538: opm_MenuItem_CategoryAdd.Enabled := FALSE;
2539: opm_ToolButton_AddCat.Enabled := FALSE;
2540: opm_PopMenuItem_CatAdd.Enabled := FALSE;
2541: opm_MenuItem_CategoryRename.Enabled := FALSE;
2542: opm_ToolButton_RenCat.Enabled := FALSE;
2543: opm_PopMenuItem_CatRename.Enabled := FALSE;
2544: opm_MenuItem_CategoryDelete.Enabled := FALSE;
2545: opm_ToolButton_DelCat.Enabled := FALSE;
2546: opm_PopMenuItem_CatDelete.Enabled := FALSE;
2547: opm_PopMenuItem_CatExpand2.Enabled := FALSE;
2548: opm_PopMenuItem_CatCollapse2.Enabled := FALSE;
2549: opm_PopMenuItem_CatExpand.Enabled := FALSE;
2550: opm_PopMenuItem_CatCollapse.Enabled := FALSE;
2551: END;
2552: END;
2553:
2554:
2555: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2556: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2557: PROCEDURE Topm_Form_Main.PRopm_Valid_ProdOps (WeAreConnected : BOOLEAN; SelectedProduct : TListItem; SelectedProds : LONGINT; SelectedCat : TTreeNode; CopiedProduct : LONGINT);
2558: BEGIN
2559: IF (WeAreConnected = TRUE) THEN
2560: BEGIN
2561: IF (((SelectedCat <> NIL) OR (SelectedProduct <> NIL)) AND (SelectedProds < 2)) THEN
2562: BEGIN
2563: opm_MenuItem_ProductAdd.Enabled := TRUE;
2564: opm_ToolButton_AddProduct.Enabled := TRUE;
2565: opm_PopMenuItem_PAdd.Enabled := TRUE;
2566: END
2567: ELSE
2568: BEGIN
2569: opm_MenuItem_ProductAdd.Enabled := FALSE;
2570: opm_ToolButton_AddProduct.Enabled := FALSE;
2571: opm_PopMenuItem_PAdd.Enabled := FALSE;
2572: END;
2573: IF (SelectedCat <> NIL) THEN
2574: BEGIN
2575: opm_MenuItem_RefreshProducts.Enabled := TRUE;
2576: opm_MenuItem_ProductSelAll.Enabled := TRUE;
2577: opm_PopMenuItem_PSelAll.Enabled := TRUE;
2578: opm_ToolButton_Refresh.Enabled := TRUE;
2579: IF (CopiedProduct > 0) THEN
2580: BEGIN
2581: opm_PopMenuItem_PPastePR.Enabled := TRUE;
2582: opm_MenuItem_PRPaste.Enabled := TRUE;
2583: END
2584: ELSE
2585: BEGIN
2586: opm_PopMenuItem_PPastePR.Enabled := FALSE;
2587: opm_MenuItem_PRPaste.Enabled := FALSE;
2588: END;
2589: END
2590: ELSE
2591: BEGIN
2592: opm_MenuItem_RefreshProducts.Enabled := FALSE;
2593: opm_MenuItem_ProductSelAll.Enabled := FALSE;
2594: opm_PopMenuItem_PSelAll.Enabled := FALSE;
2595: opm_ToolButton_Refresh.Enabled := FALSE;
2596: opm_PopMenuItem_PPastePR.Enabled := FALSE;
2597: opm_MenuItem_PRPaste.Enabled := FALSE;
2598: END;
2599: IF (SelectedProduct <> NIL) THEN
2600: BEGIN
2601: IF (SelectedProds > 1) THEN
2602: BEGIN
2603: opm_MenuItem_ProductEdit.Enabled := FALSE;
2604: opm_ToolButton_EditProduct.Enabled := FALSE;
2605: opm_PopMenuItem_PEdit.Enabled := FALSE;
2606: opm_PopMenuItem_PModel.Enabled := FALSE;
2607: opm_PopMenuItem_PWeight.Enabled := FALSE;
2608: opm_PopMenuItem_PCopyPR.Enabled := FALSE;
2609: opm_MenuItem_PRCopy.Enabled := FALSE;
2610: END
2611: ELSE
2612: BEGIN
2613: opm_MenuItem_ProductEdit.Enabled := TRUE;
2614: opm_ToolButton_EditProduct.Enabled := TRUE;
2615: opm_PopMenuItem_PEdit.Enabled := TRUE;
2616: opm_PopMenuItem_PModel.Enabled := TRUE;
2617: opm_PopMenuItem_PWeight.Enabled := TRUE;
2618: opm_PopMenuItem_PCopyPR.Enabled := TRUE;
2619: opm_MenuItem_PRCopy.Enabled := TRUE;
2620: END;
2621: opm_MenuItem_ProductDel.Enabled := TRUE;
2622: opm_MenuItem_ProductCopy.Enabled := TRUE;
2623: opm_MenuItem_ProductCopyAsText.Enabled := TRUE;
2624: opm_MenuItem_ProductCopyAsPre.Enabled := TRUE;
2625: opm_MenuItem_ProductExport.Enabled := TRUE;
2626: opm_MenuItem_ProductPrint.Enabled := TRUE;
2627: opm_MenuItem_ProductPrintPDF.Enabled := TRUE;
2628: opm_ToolButton_DeleteProduct.Enabled := TRUE;
2629: opm_ToolButton_ExportProduct.Enabled := TRUE;
2630: opm_ToolButton_PrintProduct.Enabled := TRUE;
2631: opm_PopMenuItem_PMod.Enabled := TRUE;
2632: opm_PopMenuItem_PAvailability.Enabled := TRUE;
2633: opm_PopMenuItem_PAvailable.Enabled := TRUE;
2634: opm_PopMenuItem_PNotAvailable.Enabled := TRUE;
2635: opm_PopMenuItem_PPrice.Enabled := TRUE;
2636: opm_PopMenuItem_PSpecial.Enabled := TRUE;
2637: opm_PopMenuItem_PQuantity.Enabled := TRUE;
2638: opm_PopMenuItem_PCat.Enabled := TRUE;
2639: opm_PopMenuItem_PMan.Enabled := TRUE;
2640: opm_PopMenuItem_PDelete.Enabled := TRUE;
2641: opm_PopMenuItem_PCopy.Enabled := TRUE;
2642: opm_PopMenuItem_PCopyAsText.Enabled := TRUE;
2643: opm_PopMenuItem_PCopyAsPre.Enabled := TRUE;
2644: opm_PopMenuItem_PExport.Enabled := TRUE;
2645: opm_PopMenuItem_PPrint.Enabled := TRUE;
2646: opm_PopMenuItem_PPrintPDF.Enabled := TRUE;
2647: END
2648: ELSE
2649: BEGIN
2650: opm_MenuItem_ProductEdit.Enabled := FALSE;
2651: opm_MenuItem_ProductDel.Enabled := FALSE;
2652: opm_MenuItem_ProductCopy.Enabled := FALSE;
2653: opm_MenuItem_ProductCopyAsText.Enabled := FALSE;
2654: opm_MenuItem_ProductCopyAsPre.Enabled := FALSE;
2655: opm_MenuItem_ProductExport.Enabled := FALSE;
2656: opm_MenuItem_ProductPrint.Enabled := FALSE;
2657: opm_MenuItem_ProductPrintPDF.Enabled := FALSE;
2658: opm_MenuItem_PRCopy.Enabled := FALSE;
2659: opm_ToolButton_EditProduct.Enabled := FALSE;
2660: opm_ToolButton_DeleteProduct.Enabled := FALSE;
2661: opm_ToolButton_ExportProduct.Enabled := FALSE;
2662: opm_ToolButton_PrintProduct.Enabled := FALSE;
2663: opm_PopMenuItem_PEdit.Enabled := FALSE;
2664: opm_PopMenuItem_PMod.Enabled := FALSE;
2665: opm_PopMenuItem_PAvailability.Enabled := FALSE;
2666: opm_PopMenuItem_PAvailable.Enabled := FALSE;
2667: opm_PopMenuItem_PNotAvailable.Enabled := FALSE;
2668: opm_PopMenuItem_PPrice.Enabled := FALSE;
2669: opm_PopMenuItem_PSpecial.Enabled := FALSE;
2670: opm_PopMenuItem_PQuantity.Enabled := FALSE;
2671: opm_PopMenuItem_PCat.Enabled := FALSE;
2672: opm_PopMenuItem_PMan.Enabled := FALSE;
2673: opm_PopMenuItem_PModel.Enabled := FALSE;
2674: opm_PopMenuItem_PWeight.Enabled := FALSE;
2675: opm_PopMenuItem_PDelete.Enabled := FALSE;
2676: opm_PopMenuItem_PCopy.Enabled := FALSE;
2677: opm_PopMenuItem_PCopyAsText.Enabled := FALSE;
2678: opm_PopMenuItem_PCopyAsPre.Enabled := FALSE;
2679: opm_PopMenuItem_PExport.Enabled := FALSE;
2680: opm_PopMenuItem_PPrint.Enabled := FALSE;
2681: opm_PopMenuItem_PPrintPDF.Enabled := FALSE;
2682: opm_PopMenuItem_PCopyPR.Enabled := FALSE;
2683: END;
2684: END
2685: ELSE
2686: BEGIN
2687: opm_MenuItem_RefreshProducts.Enabled := FALSE;
2688: opm_MenuItem_ProductAdd.Enabled := FALSE;
2689: opm_MenuItem_ProductEdit.Enabled := FALSE;
2690: opm_MenuItem_ProductDel.Enabled := FALSE;
2691: opm_MenuItem_ProductSelAll.Enabled := FALSE;
2692: opm_MenuItem_ProductCopy.Enabled := FALSE;
2693: opm_MenuItem_ProductCopyAsText.Enabled := FALSE;
2694: opm_MenuItem_ProductCopyAsPre.Enabled := FALSE;
2695: opm_MenuItem_ProductExport.Enabled := FALSE;
2696: opm_MenuItem_ProductPrint.Enabled := FALSE;
2697: opm_MenuItem_ProductPrintPDF.Enabled := FALSE;
2698: opm_MenuItem_PRCopy.Enabled := FALSE;
2699: opm_MenuItem_PRPaste.Enabled := FALSE;
2700: opm_ToolButton_Refresh.Enabled := FALSE;
2701: opm_ToolButton_AddProduct.Enabled := FALSE;
2702: opm_ToolButton_EditProduct.Enabled := FALSE;
2703: opm_ToolButton_DeleteProduct.Enabled := FALSE;
2704: opm_ToolButton_ExportProduct.Enabled := FALSE;
2705: opm_ToolButton_PrintProduct.Enabled := FALSE;
2706: opm_PopMenuItem_PEdit.Enabled := FALSE;
2707: opm_PopMenuItem_PMod.Enabled := FALSE;
2708: opm_PopMenuItem_PAvailability.Enabled := FALSE;
2709: opm_PopMenuItem_PAvailable.Enabled := FALSE;
2710: opm_PopMenuItem_PNotAvailable.Enabled := FALSE;
2711: opm_PopMenuItem_PPrice.Enabled := FALSE;
2712: opm_PopMenuItem_PSpecial.Enabled := FALSE;
2713: opm_PopMenuItem_PQuantity.Enabled := FALSE;
2714: opm_PopMenuItem_PCat.Enabled := FALSE;
2715: opm_PopMenuItem_PMan.Enabled := FALSE;
2716: opm_PopMenuItem_PModel.Enabled := FALSE;
2717: opm_PopMenuItem_PWeight.Enabled := FALSE;
2718: opm_PopMenuItem_PAdd.Enabled := FALSE;
2719: opm_PopMenuItem_PDelete.Enabled := FALSE;
2720: opm_PopMenuItem_PSelAll.Enabled := FALSE;
2721: opm_PopMenuItem_PCopy.Enabled := FALSE;
2722: opm_PopMenuItem_PCopyAsText.Enabled := FALSE;
2723: opm_PopMenuItem_PCopyAsPre.Enabled := FALSE;
2724: opm_PopMenuItem_PExport.Enabled := FALSE;
2725: opm_PopMenuItem_PPrint.Enabled := FALSE;
2726: opm_PopMenuItem_PPrintPDF.Enabled := FALSE;
2727: opm_PopMenuItem_PCopyPR.Enabled := FALSE;
2728: END;
2729: END;
2730:
2731:
2732: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2733: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2734: PROCEDURE Topm_Form_Main.PRopm_Valid_GralOps (WeAreConnected : BOOLEAN);
2735: BEGIN
2736: IF (WeAreConnected = TRUE) THEN
2737: BEGIN
2738: opm_MenuItem_Connect.Enabled := FALSE;
2739: opm_ToolButton_Connect.Enabled := FALSE;
2740: opm_PopMenuItem_ConnConn.Enabled := FALSE;
2741: opm_MenuItem_Disconnect.Enabled := TRUE;
2742: opm_ToolButton_Disconnect.Enabled := TRUE;
2743: opm_PopMenuItem_ConnDisconn.Enabled := TRUE;
2744: END
2745: ELSE
2746: BEGIN
2747: opm_MenuItem_Connect.Enabled := TRUE;
2748: opm_ToolButton_Connect.Enabled := TRUE;
2749: opm_PopMenuItem_ConnConn.Enabled := TRUE;
2750: opm_MenuItem_Disconnect.Enabled := FALSE;
2751: opm_ToolButton_Disconnect.Enabled := FALSE;
2752: opm_PopMenuItem_ConnDisconn.Enabled := FALSE;
2753: END;
2754: END;
2755:
2756:
2757:
2758:
2759:
2760:
2761: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2762: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2763: procedure Topm_Form_Main.opm_ListView_MainChange(Sender: TObject; Item: TListItem; Change: TItemChange);
2764: begin
2765: PRopm_Valid_ProdOps (FNopm_ConnectionState, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected, opm_CurrentProdID_CB);
2766: end;
2767:
2768:
2769: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2770: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2771: PROCEDURE Topm_Form_Main.PRopm_Reload_ProductList (SearchLoad : BOOLEAN);
2772: BEGIN
2773: IF (SearchLoad = FALSE) THEN
2774: BEGIN
2775: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2776: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
2777: END
2778: ELSE
2779: BEGIN
2780: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, opm_Search_Quick);
2781: END;
2782: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2783: END;
2784:
2785:
2786: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2787: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2788: procedure Topm_Form_Main.opm_PopMenuItem_PAvailableClick(Sender: TObject);
2789: VAR
2790: CurItem : TListItem;
2791: ProgStep, Progress : LONGINT;
2792: BEGIN
2793: CurItem := opm_ListView_Main.Selected;
2794: Progress := 0;
2795: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2796: BEGIN
2797: opm_ListView_Main.Enabled := FALSE;
2798: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2799: BEGIN
2800: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
2801: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2802: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 1, _('Updating availability...'));
2803: WHILE (CurItem <> NIL) DO
2804: BEGIN
2805: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, '');
2806: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2807: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_status', '1', TRUE, '', '', opmC_SQLUpdate);
2808: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2809: INC (Progress, ProgStep);
2810: END;
2811: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
2812: PRopm_Reload_ProductList (opm_WeAreSearching);
2813: opm_Form_Progress.PRopm_PDClose;
2814: END;
2815: opm_ListView_Main.Enabled := TRUE;
2816: opm_Form_Main.FocusControl (opm_ListView_Main);
2817: END;
2818: END;
2819:
2820: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2821: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2822: procedure Topm_Form_Main.opm_PopMenuItem_PNotAvailableClick(Sender: TObject);
2823: VAR
2824: CurItem : TListItem;
2825: ProgStep, Progress : LONGINT;
2826: BEGIN
2827: CurItem := opm_ListView_Main.Selected;
2828: Progress := 0;
2829: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2830: BEGIN
2831: opm_ListView_Main.Enabled := FALSE;
2832: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2833: BEGIN
2834: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
2835: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2836: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 1, _('Updating availability...'));
2837: WHILE (CurItem <> NIL) DO
2838: BEGIN
2839: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, '');
2840: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2841: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_status', '0', TRUE, '', '', opmC_SQLUpdate);
2842: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2843: INC (Progress, ProgStep);
2844: END;
2845: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
2846: PRopm_Reload_ProductList (opm_WeAreSearching);
2847: opm_Form_Progress.PRopm_PDClose;
2848: END;
2849: opm_ListView_Main.Enabled := TRUE;
2850: opm_Form_Main.FocusControl (opm_ListView_Main);
2851: END;
2852: END;
2853:
2854: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2855: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2856: procedure Topm_Form_Main.opm_PopMenuItem_PPriceClick(Sender: TObject);
2857: VAR
2858: CurItem : TListItem;
2859: Operand, NewPrice : STRING;
2860: ProgStep, Progress : LONGINT;
2861: BEGIN
2862: CurItem := opm_ListView_Main.Selected;
2863: Progress := 0;
2864: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2865: BEGIN
2866: opm_ListView_Main.Enabled := FALSE;
2867: opm_Form_AskUser.AU_Directions := _('Type the new price (xxx, -xxx, +xxx, -xxx%, +xxx%):') + ' [' + TRIM (opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right) + ']';
2868: opm_Form_AskUser.AU_TextOrList := TRUE;
2869: opm_Form_AskUser.AU_PassChar := #0;
2870: opm_Form_AskUser.AU_MaxLen := opmC_ProdPrice_MaxLen;
2871: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
2872: IF (opm_ListView_Main.SelCount > 1) THEN
2873: BEGIN
2874: opm_Form_AskUser.AU_Title := _('Change price for products');
2875: opm_Form_AskUser.AU_DataText := '0.00';
2876: END
2877: ELSE
2878: BEGIN
2879: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2880: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2881: opm_Form_AskUser.AU_Title := _('Change price for product ') + opm_CurrentProdRecord.DisplayName;
2882: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Price);
2883: END;
2884: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
2885: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2886: BEGIN
2887: Operand := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
2888: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2889: WHILE (CurItem <> NIL) DO
2890: BEGIN
2891: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating prices...'));
2892: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2893: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2894: NewPrice := FNopm_Apply_Operation (CURRTOSTR (opm_CurrentProdRecord.Price), Operand, opmC_ValIsCurrency, FALSE);
2895: IF ((STRTOCURR (NewPrice) = 0) AND (opmG_UIAllowZeroPrice = 0)) THEN
2896: FNopm_Message (_('Zero value not allowed.'), mtError, [mbOk], opmG_UISilent)
2897: ELSE
2898: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_price', NewPrice, TRUE, '', '', opmC_SQLUpdate);
2899: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2900: INC (Progress, ProgStep);
2901: END;
2902: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
2903: PRopm_Reload_ProductList (opm_WeAreSearching);
2904: opm_Form_Progress.PRopm_PDClose;
2905: END;
2906: opm_ListView_Main.Enabled := TRUE;
2907: opm_Form_Main.FocusControl (opm_ListView_Main);
2908: END;
2909: END;
2910:
2911:
2912: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2913: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2914: procedure Topm_Form_Main.opm_PopMenuItem_PSpecialClick(Sender: TObject);
2915: VAR
2916: CurItem : TListItem;
2917: NewSpecial, NewPrice : STRING;
2918: ProgStep, Progress : LONGINT;
2919: BEGIN
2920: CurItem := opm_ListView_Main.Selected;
2921: Progress := 0;
2922: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2923: BEGIN
2924: opm_ListView_Main.Enabled := FALSE;
2925: opm_Form_AskUser.AU_Directions := _('Type the new special price (xxx, -xxx, +xxx, -xxx%, +xxx%, 0 to disable):') + ' [' + TRIM (opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right) + ']';
2926: opm_Form_AskUser.AU_TextOrList := TRUE;
2927: opm_Form_AskUser.AU_PassChar := #0;
2928: opm_Form_AskUser.AU_MaxLen := opmC_ProdSpecial_MaxLen;
2929: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
2930: IF (opm_ListView_Main.SelCount > 1) THEN
2931: BEGIN
2932: opm_Form_AskUser.AU_Title := _('Change special price for products');
2933: opm_Form_AskUser.AU_DataText := '0.00';
2934: END
2935: ELSE
2936: BEGIN
2937: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2938: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2939: opm_Form_AskUser.AU_Title := _('Change special price for product ') + opm_CurrentProdRecord.DisplayName;
2940: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Price);
2941: END;
2942: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
2943: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2944: BEGIN
2945: NewSpecial := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
2946: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
2947: WHILE (CurItem <> NIL) DO
2948: BEGIN
2949: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating special prices...'));
2950: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2951: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2952: NewPrice := FNopm_Apply_Operation (CURRTOSTR (opm_CurrentProdRecord.Price), NewSpecial, opmC_ValIsCurrency, FALSE);
2953: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Specials, 'specials_new_products_price', NewPrice, TRUE, '', '', opmC_SQLDelInsNoZero);
2954: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2955: INC (Progress, ProgStep);
2956: END;
2957: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
2958: PRopm_Reload_ProductList (opm_WeAreSearching);
2959: opm_Form_Progress.PRopm_PDClose;
2960: END;
2961: opm_ListView_Main.Enabled := TRUE;
2962: opm_Form_Main.FocusControl (opm_ListView_Main);
2963: END;
2964: END;
2965:
2966: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2967: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2968: procedure Topm_Form_Main.opm_PopMenuItem_PQuantityClick(Sender: TObject);
2969: VAR
2970: CurItem : TListItem;
2971: Operand, NewQuantity : STRING;
2972: ProgStep, Progress : LONGINT;
2973: BEGIN
2974: CurItem := opm_ListView_Main.Selected;
2975: Progress := 0;
2976: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
2977: BEGIN
2978: opm_ListView_Main.Enabled := FALSE;
2979: opm_Form_AskUser.AU_Directions := _('Type the new quantity (xxx, -xxx, +xxx, -xxx%, +xxx%):');
2980: opm_Form_AskUser.AU_TextOrList := TRUE;
2981: opm_Form_AskUser.AU_PassChar := #0;
2982: opm_Form_AskUser.AU_MaxLen := opmC_ProdQuantity_MaxLen;
2983: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
2984: IF (opm_ListView_Main.SelCount > 1) THEN
2985: BEGIN
2986: opm_Form_AskUser.AU_Title := _('Change quantity for products');
2987: opm_Form_AskUser.AU_DataText := '0';
2988: END
2989: ELSE
2990: BEGIN
2991: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2992: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2993: opm_Form_AskUser.AU_Title := _('Change quantity for product ') + opm_CurrentProdRecord.DisplayName;
2994: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Quantity);
2995: END;
2996: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
2997: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2998: BEGIN
2999: Operand := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
3000: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3001: WHILE (CurItem <> NIL) DO
3002: BEGIN
3003: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating quantity...'));
3004: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3005: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3006: NewQuantity := FNopm_Apply_Operation (INTTOSTR (opm_CurrentProdRecord.Quantity), Operand, opmC_ValIsInteger, (opmG_UIAllowNegativeQuantity = 1));
3007: IF ((STRTOINT (NewQuantity) < 0) AND (opmG_UIAllowNegativeQuantity = 0)) THEN
3008: FNopm_Message (_('Negative value not allowed.'), mtError, [mbOk], opmG_UISilent)
3009: ELSE
3010: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_quantity', NewQuantity, TRUE, '', '', opmC_SQLUpdate);
3011: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3012: INC (Progress, ProgStep);
3013: END;
3014: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
3015: PRopm_Reload_ProductList (opm_WeAreSearching);
3016: opm_Form_Progress.PRopm_PDClose;
3017: END;
3018: opm_ListView_Main.Enabled := TRUE;
3019: opm_Form_Main.FocusControl (opm_ListView_Main);
3020: END;
3021: END;
3022:
3023:
3024: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3025: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3026: procedure Topm_Form_Main.opm_PopMenuItem_PManClick(Sender: TObject);
3027: VAR
3028: CurItem : TListItem;
3029: CurMan : opmR_Manufacturer;
3030: ProgStep, Progress : LONGINT;
3031: BEGIN
3032: CurItem := opm_ListView_Main.Selected;
3033: Progress := 0;
3034: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
3035: BEGIN
3036: opm_ListView_Main.Enabled := FALSE;
3037: opm_Form_AskUser.AU_Directions := _('Select the new manufacturer:');
3038: opm_Form_AskUser.AU_TextOrList := FALSE;
3039: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
3040: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
3041: IF (opm_ListView_Main.SelCount > 1) THEN
3042: BEGIN
3043: opm_Form_AskUser.AU_Title := _('Change manufacturer for products');
3044: opm_Form_AskUser.AU_ListItem := 0;
3045: END
3046: ELSE
3047: BEGIN
3048: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3049: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3050: opm_CurrentManRecord := FNopm_GetManufacturer (opmG_ManufacturerList, opm_CurrentProdRecord.ManufacturerID, opmC_FindByID);
3051: opm_Form_AskUser.AU_Title := _('Change manufacturer for product ') + opm_CurrentProdRecord.DisplayName;
3052: opm_Form_AskUser.AU_ListItem := opm_CurrentManRecord.ListIndex;
3053: END;
3054: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3055: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3056: BEGIN
3057: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
3058: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3059: WHILE (CurItem <> NIL) DO
3060: BEGIN
3061: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating manufacturer...'));
3062: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3063: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3064: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'manufacturers_id', INTTOSTR (CurMan.ID), TRUE, '', '', opmC_SQLUpdate);
3065: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3066: INC (Progress, ProgStep);
3067: END;
3068: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
3069: PRopm_Reload_ProductList (opm_WeAreSearching);
3070: opm_Form_Progress.PRopm_PDClose;
3071: END;
3072: opm_ListView_Main.Enabled := TRUE;
3073: opm_Form_Main.FocusControl (opm_ListView_Main);
3074: END;
3075: end;
3076:
3077: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3078: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3079: procedure Topm_Form_Main.opm_PopMenuItem_PCatClick(Sender: TObject);
3080: VAR
3081: CurItem : TListItem;
3082: CurCat : opmR_Category;
3083: ProgStep, Progress : LONGINT;
3084: BEGIN
3085: CurItem := opm_ListView_Main.Selected;
3086: Progress := 0;
3087: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
3088: BEGIN
3089: opm_ListView_Main.Enabled := FALSE;
3090: opm_Form_AskUser.AU_Directions := _('Select the new category:');
3091: opm_Form_AskUser.AU_TextOrList := FALSE;
3092: opm_Form_AskUser.AU_DataList := opmG_CategoryBoxList;
3093: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
3094: IF (opm_ListView_Main.SelCount > 1) THEN
3095: BEGIN
3096: opm_Form_AskUser.AU_Title := _('Change category for products');
3097: opm_Form_AskUser.AU_ListItem := 0;
3098: END
3099: ELSE
3100: BEGIN
3101: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3102: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3103: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, opm_CurrentProdRecord.CategoryID, opmC_FindByID);
3104: opm_Form_AskUser.AU_Title := _('Change category for product ') + opm_CurrentProdRecord.DisplayName;
3105: opm_Form_AskUser.AU_ListItem := opm_CurrentCatRecord.ListIndex;
3106: END;
3107: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3108: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3109: BEGIN
3110: CurCat := FNopm_GetCategory (opmG_CategoryList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
3111: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3112: WHILE (CurItem <> NIL) DO
3113: BEGIN
3114: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating category...'));
3115: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3116: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3117: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_ProductsToCategories, 'categories_id', INTTOSTR (CurCat.ID), TRUE, 'categories_id', INTTOSTR (opm_CurrentProdRecord.CategoryID), opmC_SQLUpdate);
3118: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3119: INC (Progress, ProgStep);
3120: END;
3121: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
3122: PRopm_Reload_ProductList (opm_WeAreSearching);
3123: opm_Form_Progress.PRopm_PDClose;
3124: END;
3125: opm_ListView_Main.Enabled := TRUE;
3126: opm_Form_Main.FocusControl (opm_ListView_Main);
3127: END;
3128: end;
3129:
3130: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3131: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3132: procedure Topm_Form_Main.opm_TreeView_MainDragDrop (Sender, Source: TObject; X, Y: Integer);
3133: VAR
3134: DropNode : TTreeNode;
3135: CurCat : opmR_Category;
3136: CurItem : TListItem;
3137: ProgStep, Progress : LONGINT;
3138: begin
3139: IF ((Source IS TListView) AND (opmG_UIDragDrop > 0) AND (opm_TreeView_Main.Selected <> NIL)) THEN
3140: BEGIN
3141: DropNode := opm_TreeView_Main.GetNodeAt (X, Y);
3142: CurItem := opm_ListView_Main.Selected;
3143: Progress := 0;
3144: IF ((CurItem <> NIL) AND (DropNode <> NIL)) THEN
3145: IF ((opmG_UIConfirmDrag = 0) OR ((opmG_UIConfirmDrag > 0) AND (FNopm_Message (_('Do you want to move these products to category ') + CurCat.Name + '?', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes))) THEN
3146: BEGIN
3147: opm_ListView_Main.Enabled := FALSE;
3148: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
3149: BEGIN
3150: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3151: CurCat := FNopm_GetCategory (opmG_CategoryList, DropNode.AbsoluteIndex, opmC_FindByNode);
3152: WHILE (CurItem <> NIL) DO
3153: BEGIN
3154: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, _('Updating category...'));
3155: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3156: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3157: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, opm_CurrentProdRecord.CategoryID, opmC_FindByID);
3158: IF (CurCat.ID < opmC_SC_BaseID) THEN
3159: PRopm_UpdateProdData (opm_CurrentProdRecord.ID, opmG_DBTable_ProductsToCategories, 'categories_id', INTTOSTR (CurCat.ID), TRUE, 'categories_id', INTTOSTR (opm_CurrentProdRecord.CategoryID), opmC_SQLUpdate);
3160: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3161: INC (Progress, ProgStep);
3162: END;
3163: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
3164: PRopm_Reload_ProductList (opm_WeAreSearching);
3165: opm_Form_Progress.PRopm_PDClose;
3166: END;
3167: opm_ListView_Main.Enabled := TRUE;
3168: opm_Form_Main.FocusControl (opm_ListView_Main);
3169: END;
3170: END;
3171: end;
3172:
3173:
3174: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3175: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3176: procedure Topm_Form_Main.opm_PopMenuItem_PModelClick(Sender: TObject);
3177: VAR
3178: CurItem : TListItem;
3179: BEGIN
3180: CurItem := opm_ListView_Main.Selected;
3181: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
3182: BEGIN
3183: opm_ListView_Main.Enabled := FALSE;
3184: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3185: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3186: opm_Form_AskUser.AU_Title := _('Change model for product ') + opm_CurrentProdRecord.DisplayName;
3187: opm_Form_AskUser.AU_Directions := _('Type the new model:');
3188: opm_Form_AskUser.AU_TextOrList := TRUE;
3189: opm_Form_AskUser.AU_PassChar := #0;
3190: opm_Form_AskUser.AU_MaxLen := opmC_ProdModel_MaxLen;
3191: opm_Form_AskUser.AU_DataText := FNopm_CleanString (opm_CurrentProdRecord.Model);
3192: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3193: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3194: BEGIN
3195: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3196: opm_Form_Progress.PRopm_PDUpdate_Progress (33, 1, _('Updating model...'));
3197: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_model', FNopm_CleanSQLString (opm_Form_AskUser.AU_DataText, FALSE), FALSE, '', '', opmC_SQLUpdate);
3198: opm_Form_Progress.PRopm_PDUpdate_Progress (66, 1, _('Loading product list...'));
3199: PRopm_Reload_ProductList (opm_WeAreSearching);
3200: opm_Form_Progress.PRopm_PDClose;
3201: END;
3202: opm_ListView_Main.Enabled := TRUE;
3203: opm_Form_Main.FocusControl (opm_ListView_Main);
3204: END;
3205: END;
3206:
3207: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3208: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3209: procedure Topm_Form_Main.opm_PopMenuItem_PWeightClick(Sender: TObject);
3210: VAR
3211: CurItem : TListItem;
3212: NewWeight : STRING;
3213: BEGIN
3214: CurItem := opm_ListView_Main.Selected;
3215: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
3216: BEGIN
3217: opm_ListView_Main.Enabled := FALSE;
3218: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3219: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3220: opm_Form_AskUser.AU_Title := _('Change weight for product ') + opm_CurrentProdRecord.DisplayName;
3221: opm_Form_AskUser.AU_Directions := _('Type the new weight:');
3222: opm_Form_AskUser.AU_TextOrList := TRUE;
3223: opm_Form_AskUser.AU_PassChar := #0;
3224: opm_Form_AskUser.AU_MaxLen := opmC_ProdWeight_MaxLen;
3225: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Weight);
3226: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3227: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3228: BEGIN
3229: NewWeight := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
3230: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3231: opm_Form_Progress.PRopm_PDUpdate_Progress (33, 1, _('Updating weight...'));
3232: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_weight', FNopm_Apply_Operation (CURRTOSTR (opm_CurrentProdRecord.Weight), NewWeight, opmC_ValIsCurrency, FALSE), TRUE, '', '', opmC_SQLUpdate);
3233: opm_Form_Progress.PRopm_PDUpdate_Progress (66, 1, _('Loading product list...'));
3234: PRopm_Reload_ProductList (opm_WeAreSearching);
3235: opm_Form_Progress.PRopm_PDClose;
3236: END;
3237: opm_ListView_Main.Enabled := TRUE;
3238: opm_Form_Main.FocusControl (opm_ListView_Main);
3239: END;
3240: END;
3241:
3242: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3243: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3244: procedure Topm_Form_Main.opm_PopMenuItem_CatExpandClick(Sender: TObject);
3245: begin
3246: opm_TreeView_Main.FullExpand;
3247: end;
3248:
3249: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3250: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3251: procedure Topm_Form_Main.opm_PopMenuItem_CatCollapseClick(Sender: TObject);
3252: begin
3253: opm_TreeView_Main.FullCollapse;
3254: end;
3255:
3256: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3257: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3258: procedure Topm_Form_Main.opm_PopMenuItem_CatExpand2Click(Sender: TObject);
3259: begin
3260: opm_TreeView_Main.Selected.Expanded := TRUE;
3261: end;
3262:
3263: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3264: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3265: procedure Topm_Form_Main.opm_PopMenuItem_CatCollapse2Click(Sender: TObject);
3266: begin
3267: opm_TreeView_Main.Selected.Expanded := FALSE;
3268: end;
3269:
3270: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3271: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3272: procedure Topm_Form_Main.opm_TreeView_MainContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
3273: begin
3274: opm_TreeView_Main.Selected := opm_TreeView_Main.GetNodeAt (MousePos.X, MousePos.Y);
3275: end;
3276:
3277: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3278: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3279: procedure Topm_Form_Main.opm_TreeView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
3280: begin
3281: CASE Key OF
3282: VK_SPACE : opm_TreeView_Main.Selected.Expanded := NOT (opm_TreeView_Main.Selected.Expanded);
3283: VK_RETURN : opm_TreeView_MainDblClick (Sender);
3284: VK_DELETE : opm_PopMenuItem_CatDeleteClick (Sender);
3285: VK_INSERT : opm_PopMenuItem_CatAddClick (Sender);
3286: END;
3287: end;
3288:
3289: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3290: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3291: procedure Topm_Form_Main.opm_TreeView_MainKeyPress(Sender: TObject; var Key: Char);
3292: begin
3293: IF ((Key = ' ') OR (Key = #13)) THEN
3294: Key := #0;
3295: end;
3296:
3297:
3298: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3299: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3300: procedure Topm_Form_Main.opm_TreeView_MainDragOver (Sender, Source: TObject;
3301: X, Y: Integer; State: TDragState;
3302: var Accept: Boolean);
3303: begin
3304: IF ((Source IS TListView) AND (opmG_UIDragDrop > 0)) THEN
3305: BEGIN
3306: Accept := TRUE;
3307: END
3308: ELSE
3309: BEGIN
3310: Accept := FALSE;
3311: END;
3312: end;
3313:
3314: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3315: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3316: procedure Topm_Form_Main.opm_MenuItem_LicenseClick(Sender: TObject);
3317: begin
3318: opm_Form_License.ShowModal;
3319: end;
3320:
3321:
3322: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3323: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3324: procedure Topm_Form_Main.opm_MenuItem_AboutClick(Sender: TObject);
3325: begin
3326: opm_Form_About.ShowModal;
3327: {$IFDEF OSCPMDEBUG}
3328: FNopm_Message (_('THIS IS A SPECIAL DEBUG-VERSION. Use it only to report crashes and fatal errors. DO NOT DISTRIBUTE. The full open-source version can be found in the website.'), mtInformation, [mbOk], opmG_UISilent);
3329: {$ENDIF}
3330: end;
3331:
3332:
3333: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3334: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3335: procedure Topm_Form_Main.FormClose(Sender: TObject; var Action: TCloseAction);
3336: begin
3337: IF (opmG_UIConfirmExit > 0) THEN
3338: BEGIN
3339: IF (FNopm_Message (_('Do you really want to quit the ') + opmC_AppName1 +'?', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
3340: BEGIN
3341: Application.HelpCommand (HELP_QUIT, 0);
3342: FNopm_CloseDBConnection;
3343: IF (opm_WeAreFullScreen) THEN PRopm_FullScreen (FALSE);
3344: PRopm_SaveConfiguration;
3345: Action := caFree;
3346: END
3347: ELSE
3348: Action := caNone;
3349: END
3350: ELSE
3351: BEGIN
3352: FNopm_CloseDBConnection;
3353: IF (opm_WeAreFullScreen) THEN PRopm_FullScreen (FALSE);
3354: PRopm_SaveConfiguration;
3355: END;
3356: end;
3357:
3358: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3359: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3360: procedure Topm_Form_Main.opm_TreeView_MainDblClick(Sender: TObject);
3361: begin
3362: IF (opm_CurrentCatRecord.ID < opmC_SC_BaseID) THEN
3363: IF (opmG_UIClickLoad <= 0) THEN
3364: BEGIN
3365: PRopm_Sound ('MenuPopup', opmG_UISilent);
3366: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3367: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Loading product list...'));
3368: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
3369: opm_Form_Progress.PRopm_PDClose;
3370: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
3371: PRopm_Valid_CatOps (FNopm_ConnectionState, opm_TreeView_Main.Selected);
3372: PRopm_Valid_ProdOps (FNopm_ConnectionState, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected, opm_CurrentProdID_CB);
3373: END;
3374: end;
3375:
3376: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3377: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3378: procedure Topm_Form_Main.opm_TreeView_MainExpanding(Sender: TObject; Node: TTreeNode; var AllowExpansion: Boolean);
3379: begin
3380: AllowExpansion := opm_CanExpandTree_Flag;
3381: opm_CanExpandTree_Flag := TRUE;
3382: end;
3383:
3384: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3385: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3386: procedure Topm_Form_Main.opm_TreeView_MainCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
3387: begin
3388: AllowCollapse := opm_CanExpandTree_Flag;
3389: opm_CanExpandTree_Flag := TRUE;
3390: end;
3391:
3392:
3393:
3394: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3395: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3396: PROCEDURE Topm_Form_Main.PRopm_SetUILang (LangISOID : STRING);
3397: BEGIN
3398: IF (FNopm_CheckLanguage (LangISOID) = FALSE) THEN LangISOID := opmC_Def_GUILang;
3399: UseLanguage(LangISOID);
3400: RetranslateComponent (opm_Form_Main);
3401: RetranslateComponent (opm_Form_License);
3402: RetranslateComponent (opm_Form_About);
3403: RetranslateComponent (opm_Form_PEdit);
3404: RetranslateComponent (opm_Form_ImageZoom);
3405: RetranslateComponent (opm_Form_SearchProduct);
3406: RetranslateComponent (opm_Form_UploadImage);
3407: RetranslateComponent (opm_Form_AskUser);
3408: RetranslateComponent (opm_Form_Config);
3409: RetranslateComponent (opm_Form_Runmod);
3410: RetranslateComponent (opm_Form_Colorsel);
3411: RetranslateComponent (opm_Form_ConfigMod);
3412: RetranslateComponent (opm_Form_AskCat);
3413: RetranslateComponent (opm_Form_Progress);
3414: RetranslateComponent (opm_Form_CurrencyMan);
3415: RetranslateComponent (opm_Form_CurrencyEdit);
3416: RetranslateComponent (opm_Form_Currupd);
3417: END;
3418:
3419:
3420:
3421:
3422: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3423: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3424: procedure Topm_Form_Main.opm_PopMenuItem_PDeleteClick(Sender: TObject);
3425: VAR
3426: CurItem : TListItem;
3427: ProgStep, Progress : LONGINT;
3428: BEGIN
3429: CurItem := opm_ListView_Main.Selected;
3430: Progress := 0;
3431: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
3432: BEGIN
3433: opm_ListView_Main.Enabled := FALSE;
3434: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete the selected products?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3435: BEGIN
3436: ProgStep := ROUND (90 / opm_ListView_Main.SelCount);
3437: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3438: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Deleting product...'));
3439: WHILE (CurItem <> NIL) DO
3440: BEGIN
3441: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 1, '');
3442: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3443: PRopm_DeleteProduct (opm_CurrentProdID);
3444: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3445: INC (Progress, ProgStep);
3446: END;
3447: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
3448: PRopm_Reload_ProductList (opm_WeAreSearching);
3449: opm_Form_Progress.PRopm_PDClose;
3450: END;
3451: opm_ListView_Main.Enabled := TRUE;
3452: opm_Form_Main.FocusControl (opm_ListView_Main);
3453: END;
3454: end;
3455:
3456:
3457: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3458: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3459: procedure Topm_Form_Main.opm_PopMenuItem_PAddClick(Sender: TObject);
3460: VAR
3461: CurLang : LONGINT;
3462: begin
3463: opm_CurrentPEditRecord.ID := 0;
3464: opm_CurrentPEditRecord.Model := '';
3465: opm_CurrentPEditRecord.Quantity := 0;
3466: opm_CurrentPEditRecord.Price := 0;
3467: opm_CurrentPEditRecord.Weight := 0;
3468: opm_CurrentPEditRecord.ManufacturerID := opmG_Past_PManufacturer;
3469: opm_CurrentPEditRecord.CategoryID := opm_CurrentCategory;
3470: opm_CurrentPEditRecord.DisplayName := '';
3471: opm_CurrentPEditRecord.Available := 1;
3472: opm_CurrentPEditRecord.ImageURL := '';
3473: opm_CurrentPEditRecord.ImageURL1 := '';
3474: opm_CurrentPEditRecord.ImageURL2 := '';
3475: opm_CurrentPEditRecord.ImageURL3 := '';
3476: opm_CurrentPEditRecord.ImageURL4 := '';
3477: opm_CurrentPEditRecord.ImageURL5 := '';
3478: opm_CurrentPEditRecord.ImageURL6 := '';
3479: opm_CurrentPEditRecord.Special := 0;
3480: opm_CurrentPEditRecord.LanguageID := opm_CurrentLang;
3481: opm_CurrentPEditRecord.Tax := opmG_Past_PTaxClass;
3482: opm_CurrentPEditRecord.AvailDate := opmG_Past_PAvailDate;
3483: opm_CurrentPEditRecord.CreationDate := opmG_Past_PAvailDate;
3484: opm_CurrentPEditRecord.ChangeDate := opmG_Past_PAvailDate;
3485: opm_CurrentProdRecord := opm_CurrentPEditRecord;
3486: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
3487: BEGIN
3488: opm_CurrentSingleDescList[CurLang].ID := opmC_InsertProdID;
3489: opm_CurrentSingleDescList[CurLang].Name := '';
3490: opm_CurrentSingleDescList[CurLang].Description := '';
3491: opm_CurrentSingleDescList[CurLang].URL := '';
3492: opm_CurrentSingleDescList[CurLang].LanguageID := opmG_LanguageList[CurLang].ID;
3493: opm_CurrentSingleDescList[CurLang].Viewed := 0;
3494: END;
3495: FOR CurLang := opm_TotalLanguages TO opmC_Max_Languages_PerList DO
3496: BEGIN
3497: opm_CurrentSingleDescList[CurLang].ID := 0;
3498: opm_CurrentSingleDescList[CurLang].Name := '';
3499: opm_CurrentSingleDescList[CurLang].Description := '';
3500: opm_CurrentSingleDescList[CurLang].URL := '';
3501: opm_CurrentSingleDescList[CurLang].LanguageID := 0;
3502: opm_CurrentSingleDescList[CurLang].Viewed := 0;
3503: END;
3504: IF (opm_Form_PEdit.ShowModal = mrOk) THEN
3505: BEGIN
3506: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
3507: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Saving product...'));
3508: PRopm_AddProduct (opm_CurrentPEditRecord, opm_CurrentSingleDescList);
3509: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading product list...'));
3510: PRopm_Reload_ProductList (opm_WeAreSearching);
3511: opm_Form_Progress.PRopm_PDClose;
3512: opmG_Past_PAvailDate := ROUND (opm_CurrentPEditRecord.AvailDate);
3513: opmG_Past_PManufacturer := opm_CurrentPEditRecord.ManufacturerID;
3514: opmG_Past_PTaxClass := opm_CurrentPEditRecord.Tax;
3515: END;
3516: end;
3517:
3518:
3519:
3520: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3521: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3522: PROCEDURE Topm_Form_Main.PRopm_Create_ExportList (VAR ExportString : STRING; VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; JustifyCols : BOOLEAN);
3523: VAR
3524: CurItem : TListItem;
3525: ExportLine : STRING;
3526: CurProd : opmR_Product;
3527: CurCat : opmR_Category;
3528: CurMan : opmR_Manufacturer;
3529: CurDesc : opmR_Description;
3530: MaxWidths : ARRAY [0..20] OF LONGINT;
3531: FmtString : ARRAY [0..20] OF STRING;
3532: BEGIN
3533: ExportString := '';
3534: CurItem := opm_ListView_Main.Selected;
3535: { IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN}
3536: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE)) THEN
3537: BEGIN
3538: opm_ListView_Main.Enabled := FALSE;
3539: IF (JustifyCols = TRUE) THEN
3540: BEGIN
3541: WHILE (CurItem <> NIL) DO
3542: BEGIN
3543: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3544: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3545: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3546: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3547: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3548: MaxWidths [0] := MAX (LENGTH (INTTOSTR (CurProd.ID)), MaxWidths [0]);
3549: MaxWidths [1] := MAX (LENGTH (FNopm_NumToYesNo (CurProd.Available)), MaxWidths [1]);
3550: MaxWidths [2] := MAX (LENGTH (FNopm_CleanString (CurProd.Model)), MaxWidths [2]);
3551: MaxWidths [3] := MAX (LENGTH (INTTOSTR (CurProd.CategoryID)), MaxWidths [3]);
3552: MaxWidths [4] := MAX (LENGTH (FNopm_CleanString (CurCat.Name)), MaxWidths [4]);
3553: MaxWidths [5] := MAX (LENGTH (INTTOSTR (CurProd.ManufacturerID)), MaxWidths [5]);
3554: MaxWidths [6] := MAX (LENGTH (FNopm_CleanString (CurMan.Name)), MaxWidths [6]);
3555: MaxWidths [7] := MAX (LENGTH (FNopm_CleanString (CurProd.DisplayName)), MaxWidths [7]);
3556: MaxWidths [8] := MAX (LENGTH (INTTOSTR (CurProd.Quantity)), MaxWidths [8]);
3557: MaxWidths [9] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsCurrency)), MaxWidths [9]);
3558: MaxWidths [10] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsCurrency)), MaxWidths [10]);
3559: MaxWidths [11] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsCurrency)), MaxWidths [11]);
3560: MaxWidths [12] := MAX (LENGTH (FNopm_CleanString (FNopm_NoCRLF (CurDesc.Description))), MaxWidths [12]);
3561: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3562: END;
3563: MaxWidths [0] := MIN (opmG_Clip_ColSize, MaxWidths [0]);
3564: MaxWidths [1] := MIN (opmG_Clip_ColSize, MaxWidths [1]);
3565: MaxWidths [2] := MIN (opmG_Clip_ColSize, MaxWidths [2]);
3566: MaxWidths [3] := MIN (opmG_Clip_ColSize, MaxWidths [3]);
3567: MaxWidths [4] := MIN (opmG_Clip_ColSize, MaxWidths [4]);
3568: MaxWidths [5] := MIN (opmG_Clip_ColSize, MaxWidths [5]);
3569: MaxWidths [6] := MIN (opmG_Clip_ColSize, MaxWidths [6]);
3570: MaxWidths [7] := MIN (opmG_Clip_ColSize, MaxWidths [7]);
3571: MaxWidths [8] := MIN (opmG_Clip_ColSize, MaxWidths [8]);
3572: MaxWidths [9] := MIN (opmG_Clip_ColSize, MaxWidths [9]);
3573: MaxWidths [10] := MIN (opmG_Clip_ColSize, MaxWidths [10]);
3574: MaxWidths [11] := MIN (opmG_Clip_ColSize, MaxWidths [11]);
3575: MaxWidths [12] := MIN (opmG_Clip_ColSize, MaxWidths [12]);
3576: FmtString [0] := '%' + INTTOSTR (MaxWidths [0]) + '.' + INTTOSTR (MaxWidths [0]) + 's' + opmC_ExportJSeparator;
3577: FmtString [1] := '%-' + INTTOSTR (MaxWidths [1]) + '.' + INTTOSTR (MaxWidths [1]) + 's' + opmC_ExportJSeparator;
3578: FmtString [2] := '%-' + INTTOSTR (MaxWidths [2]) + '.' + INTTOSTR (MaxWidths [2]) + 's' + opmC_ExportJSeparator;
3579: FmtString [3] := '%' + INTTOSTR (MaxWidths [3]) + '.' + INTTOSTR (MaxWidths [3]) + 's' + opmC_ExportJSeparator;
3580: FmtString [4] := '%-' + INTTOSTR (MaxWidths [4]) + '.' + INTTOSTR (MaxWidths [4]) + 's' + opmC_ExportJSeparator;
3581: FmtString [5] := '%' + INTTOSTR (MaxWidths [5]) + '.' + INTTOSTR (MaxWidths [5]) + 's' + opmC_ExportJSeparator;
3582: FmtString [6] := '%-' + INTTOSTR (MaxWidths [6]) + '.' + INTTOSTR (MaxWidths [6]) + 's' + opmC_ExportJSeparator;
3583: FmtString [7] := '%-' + INTTOSTR (MaxWidths [7]) + '.' + INTTOSTR (MaxWidths [7]) + 's' + opmC_ExportJSeparator;
3584: FmtString [8] := '%' + INTTOSTR (MaxWidths [8]) + '.' + INTTOSTR (MaxWidths [8]) + 's' + opmC_ExportJSeparator;
3585: FmtString [9] := '%' + INTTOSTR (MaxWidths [9]) + '.' + INTTOSTR (MaxWidths [9]) + 's' + opmC_ExportJSeparator;
3586: FmtString [10] := '%' + INTTOSTR (MaxWidths [10]) + '.' + INTTOSTR (MaxWidths [10]) + 's' + opmC_ExportJSeparator;
3587: FmtString [11] := '%' + INTTOSTR (MaxWidths [11]) + '.' + INTTOSTR (MaxWidths [11]) + 's' + opmC_ExportJSeparator;
3588: FmtString [12] := '%-' + INTTOSTR (MaxWidths [12]) + '.' + INTTOSTR (MaxWidths [12]) + 's' + opmC_ExportJSeparator;
3589: END;
3590: CurItem := opm_ListView_Main.Selected;
3591: IF (CurItem <> NIL) THEN
3592: BEGIN
3593: ExportLine := '';
3594: IF (JustifyCols = TRUE) THEN
3595: BEGIN
3596: ExportLine := ExportLine + FORMAT (FmtString [0], [_('Product ID')]);
3597: ExportLine := ExportLine + FORMAT (FmtString [1], [_('Available')]);
3598: ExportLine := ExportLine + FORMAT (FmtString [2], [_('Model')]);
3599: ExportLine := ExportLine + FORMAT (FmtString [3], [_('Category ID')]);
3600: ExportLine := ExportLine + FORMAT (FmtString [4], [_('Category name')]);
3601: ExportLine := ExportLine + FORMAT (FmtString [5], [_('Manufacturer ID')]);
3602: ExportLine := ExportLine + FORMAT (FmtString [6], [_('Manufacturer name')]);
3603: ExportLine := ExportLine + FORMAT (FmtString [7], [_('Product name')]);
3604: ExportLine := ExportLine + FORMAT (FmtString [8], [_('Quantity')]);
3605: ExportLine := ExportLine + FORMAT (FmtString [9], [_('Price')]);
3606: ExportLine := ExportLine + FORMAT (FmtString [10], [_('Special price')]);
3607: ExportLine := ExportLine + FORMAT (FmtString [11], [_('Weight')]);
3608: ExportLine := ExportLine + FORMAT (FmtString [12], [_('Description')]);
3609: ExportString := ExportString + opmC_ExportJSeparator + ExportLine + #13#10;
3610: ExportString := ExportString + DUPESTRING (opmC_ExportJHSeparator, LENGTH (opmC_ExportJSeparator + ExportLine)) + #13#10;
3611: END
3612: ELSE
3613: BEGIN
3614: ExportLine := ExportLine + _('Product ID') + opmC_ExportSeparator;
3615: ExportLine := ExportLine + _('Available') + opmC_ExportSeparator;
3616: ExportLine := ExportLine + _('Model') + opmC_ExportSeparator;
3617: ExportLine := ExportLine + _('Category ID') + opmC_ExportSeparator;
3618: ExportLine := ExportLine + _('Category name') + opmC_ExportSeparator;
3619: ExportLine := ExportLine + _('Manufacturer ID') + opmC_ExportSeparator;
3620: ExportLine := ExportLine + _('Manufacturer name') + opmC_ExportSeparator;
3621: ExportLine := ExportLine + _('Product name') + opmC_ExportSeparator;
3622: ExportLine := ExportLine + _('Quantity') + opmC_ExportSeparator;
3623: ExportLine := ExportLine + _('Price') + opmC_ExportSeparator;
3624: ExportLine := ExportLine + _('Special price') + opmC_ExportSeparator;
3625: ExportLine := ExportLine + _('Weight') + opmC_ExportSeparator;
3626: ExportLine := ExportLine + _('Description') + opmC_ExportSeparator;
3627: ExportString := ExportString + ExportLine + #13#10;
3628: END;
3629: ExportLine := '';
3630: WHILE (CurItem <> NIL) DO
3631: BEGIN
3632: IF (JustifyCols = TRUE) THEN
3633: BEGIN
3634: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3635: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3636: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3637: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3638: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3639: ExportLine := ExportLine + FORMAT (FmtString [0], [INTTOSTR (CurProd.ID)]);
3640: ExportLine := ExportLine + FORMAT (FmtString [1], [FNopm_NumToYesNo (CurProd.Available)]);
3641: ExportLine := ExportLine + FORMAT (FmtString [2], [FNopm_CleanString (CurProd.Model)]);
3642: ExportLine := ExportLine + FORMAT (FmtString [3], [INTTOSTR (CurProd.CategoryID)]);
3643: ExportLine := ExportLine + FORMAT (FmtString [4], [FNopm_CleanString (CurCat.Name)]);
3644: ExportLine := ExportLine + FORMAT (FmtString [5], [INTTOSTR (CurProd.ManufacturerID)]);
3645: ExportLine := ExportLine + FORMAT (FmtString [6], [FNopm_CleanString (CurMan.Name)]);
3646: ExportLine := ExportLine + FORMAT (FmtString [7], [FNopm_CleanString (CurProd.DisplayName)]);
3647: ExportLine := ExportLine + FORMAT (FmtString [8], [INTTOSTR (CurProd.Quantity)]);
3648: ExportLine := ExportLine + FORMAT (FmtString [9], [FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsCurrency)]);
3649: ExportLine := ExportLine + FORMAT (FmtString [10], [FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsCurrency)]);
3650: ExportLine := ExportLine + FORMAT (FmtString [11], [FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsCurrency)]);
3651: ExportLine := ExportLine + FORMAT (FmtString [12], [FNopm_CleanString (FNopm_NoCRLF (FNopm_StripHTML (CurDesc.Description)))]);
3652: ExportString := ExportString + opmC_ExportJSeparator + ExportLine + #13#10;
3653: END
3654: ELSE
3655: BEGIN
3656: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3657: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3658: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3659: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3660: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3661: ExportLine := ExportLine + INTTOSTR (CurProd.ID) + opmC_ExportSeparator;
3662: ExportLine := ExportLine + INTTOSTR (CurProd.Available) + opmC_ExportSeparator;
3663: ExportLine := ExportLine + FNopm_CleanString (CurProd.Model) + opmC_ExportSeparator;
3664: ExportLine := ExportLine + INTTOSTR (CurProd.CategoryID) + opmC_ExportSeparator;
3665: ExportLine := ExportLine + FNopm_CleanString (CurCat.Name) + opmC_ExportSeparator;
3666: ExportLine := ExportLine + INTTOSTR (CurProd.ManufacturerID) + opmC_ExportSeparator;
3667: ExportLine := ExportLine + FNopm_CleanString (CurMan.Name) + opmC_ExportSeparator;
3668: ExportLine := ExportLine + FNopm_CleanString (CurProd.DisplayName) + opmC_ExportSeparator;
3669: ExportLine := ExportLine + INTTOSTR (CurProd.Quantity) + opmC_ExportSeparator;
3670: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsCurrency) + opmC_ExportSeparator;
3671: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsCurrency) + opmC_ExportSeparator;
3672: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsCurrency) + opmC_ExportSeparator;
3673: ExportLine := ExportLine + FNopm_CleanString (FNopm_NoCRLF (FNopm_StripHTML (CurDesc.Description))) + opmC_ExportSeparator;
3674: ExportString := ExportString + ExportLine + #13#10;
3675: END;
3676: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3677: ExportLine := '';
3678: END;
3679: END;
3680: opm_ListView_Main.Enabled := TRUE;
3681: opm_Form_Main.FocusControl (opm_ListView_Main);
3682: END;
3683: END;
3684:
3685:
3686: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3687: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3688: procedure Topm_Form_Main.opm_PopMenuItem_PExportClick(Sender: TObject);
3689: VAR
3690: ExportFile : TEXTFILE;
3691: ExportText : STRING;
3692: BEGIN
3693: opm_SaveDialog_Export.DefaultExt := opmC_Def_ExportExt;
3694: opm_SaveDialog_Export.FileName := opmC_Def_ExportFilename;
3695: opm_SaveDialog_Export.Filter := _('Text record files') + ' (' + opmC_Def_ExportFilter + ')|' + opmC_Def_ExportFilter + '|' + _('All files (*.*)');
3696: opm_SaveDialog_Export.Title := _('Exporting product list...');
3697: IF (opm_SaveDialog_Export.Execute = TRUE) THEN
3698: BEGIN
3699: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, FALSE);
3700: TRY
3701: AssignFile (ExportFile, opm_SaveDialog_Export.FileName);
3702: Rewrite (ExportFile);
3703: WRITELN (ExportFile, ExportText);
3704: CloseFile (ExportFile);
3705: EXCEPT
3706: ON E : Exception DO
3707: BEGIN
3708: FNopm_Message (_('Error while exporting product list') + #13#10 + opm_SaveDialog_Export.FileName + #13#10 + E.Message, mtError, [mbOk], opmG_UISilent);
3709: END;
3710: END;
3711: SHAddToRecentDocs (SHARD_PATH, PCHAR (opm_SaveDialog_Export.FileName));
3712: END;
3713: END;
3714:
3715:
3716: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3717: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3718: procedure Topm_Form_Main.opm_PopMenuItem_PCopyAsTextClick(Sender: TObject);
3719: VAR
3720: ExportText : STRING;
3721: BEGIN
3722: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, FALSE);
3723: Clipboard.AsText := ExportText;
3724: END;
3725:
3726:
3727: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3728: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3729: procedure Topm_Form_Main.opm_PopMenuItem_PCopyAsPreClick(Sender: TObject);
3730: VAR
3731: ExportText : STRING;
3732: BEGIN
3733: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, TRUE);
3734: Clipboard.AsText := ExportText;
3735: END;
3736:
3737:
3738: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3739: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3740: procedure Topm_Form_Main.opm_PopMenuItem_PSelAllClick(Sender: TObject);
3741: begin
3742: opm_ListView_Main.SelectAll;
3743: end;
3744:
3745:
3746: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3747: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3748: FUNCTION Topm_Form_Main.FNopm_Create_ExchangeList (VAR ExchangeList : opmT_ExchangeList;
3749: IndexData, TargetData : STRING) : LONGINT;
3750: VAR
3751: CurItem : TListItem;
3752: CurProd : opmR_Product;
3753: ProdCount : LONGINT;
3754: BEGIN
3755: CurItem := opm_ListView_Main.Selected;
3756: ProdCount := 0;
3757: { IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN }
3758: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE)) THEN
3759: BEGIN
3760: opm_ListView_Main.Enabled := FALSE;
3761: WHILE (CurItem <> NIL) DO
3762: BEGIN
3763: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3764: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3765: IF (IndexData = opmC_SyncField_ProductID) THEN
3766: ExchangeList[ProdCount].IndexString := INTTOSTR (CurProd.ID)
3767: ELSE
3768: ExchangeList[ProdCount].IndexString := CurProd.Model;
3769: IF (TargetData = opmC_SyncField_ProductQuantity) THEN
3770: ExchangeList[ProdCount].CurrentString := INTTOSTR (CurProd.Quantity)
3771: ELSE IF (TargetData = opmC_SyncField_ProductPrice) THEN
3772: ExchangeList[ProdCount].CurrentString := CURRTOSTR (CurProd.Price)
3773: ELSE IF (TargetData = opmC_SyncField_ProductImage) THEN
3774: ExchangeList[ProdCount].CurrentString := CurProd.ImageURL
3775: ELSE IF (TargetData = opmC_SyncField_ProductWeight) THEN
3776: ExchangeList[ProdCount].CurrentString := CURRTOSTR (CurProd.Weight)
3777: ELSE IF (TargetData = opmC_SyncField_ProductStatus) THEN
3778: ExchangeList[ProdCount].CurrentString := INTTOSTR (CurProd.Available)
3779: ELSE ExchangeList[ProdCount].CurrentString := '';
3780: ExchangeList[ProdCount].ResultString := '';
3781: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3782: INC (ProdCount);
3783: END;
3784: opm_ListView_Main.Enabled := TRUE;
3785: opm_Form_Main.FocusControl (opm_ListView_Main);
3786: END;
3787: FNopm_Create_ExchangeList := ProdCount;
3788: END;
3789:
3790:
3791: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3792: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3793: procedure Topm_Form_Main.opm_MenuItem_ExternalModulesClick (Sender: TObject);
3794: begin
3795: opm_PRSetValidModules (opm_MenuItem_ExternalModules, opm_ListView_Main.SelCount);
3796: end;
3797:
3798:
3799:
3800: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3801: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3802: FUNCTION FNopm_Sort_ProductList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
3803: BEGIN
3804: CASE Column OF
3805: 1, 6, 7, 8 :
3806: IF (opmG_PList_LastOrderType = FALSE) THEN
3807: FNopm_Sort_ProductList := ROUND ((STRTOCURR (Item1.SubItems[Column - 1]) - STRTOCURR (Item2.SubItems[Column - 1])))
3808: ELSE
3809: FNopm_Sort_ProductList := ROUND ((STRTOCURR (Item1.SubItems[Column - 1]) - STRTOCURR (Item2.SubItems[Column - 1])) * -1);
3810: 0 :
3811: IF (opmG_PList_LastOrderType = FALSE) THEN
3812: FNopm_Sort_ProductList := ROUND ((Item1.ImageIndex - Item2.ImageIndex))
3813: ELSE
3814: FNopm_Sort_ProductList := ROUND ((Item1.ImageIndex - Item2.ImageIndex) * -1);
3815: ELSE
3816: IF (opmG_PList_LastOrderType = FALSE) THEN
3817: FNopm_Sort_ProductList := AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])
3818: ELSE
3819: FNopm_Sort_ProductList := ((AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])) * -1);
3820: END;
3821: END;
3822:
3823:
3824: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3825: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3826: procedure Topm_Form_Main.opm_ListView_MainColumnClick(Sender: TObject; Column: TListColumn);
3827: begin
3828: IF (Column.Index >= 0) AND (Column.Index < 10) THEN
3829: BEGIN
3830: opm_ListView_Main.Column[opmG_PList_LastOrderColumn].ImageIndex := -1;
3831: IF (opmG_PList_LastOrderColumn = Column.Index) THEN
3832: opmG_PList_LastOrderType := NOT (opmG_PList_LastOrderType)
3833: ELSE
3834: opmG_PList_LastOrderType := FALSE;
3835: IF (opmG_PList_LastOrderType = TRUE) THEN
3836: Column.ImageIndex := 8
3837: ELSE
3838: Column.ImageIndex := 9;
3839: opmG_PList_LastOrderColumn := Column.Index;
3840: TListView (Sender).CustomSort (@FNopm_Sort_ProductList, Column.Index);
3841: END;
3842: end;
3843:
3844:
3845:
3846: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3847: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3848: procedure Topm_Form_Main.opm_PopMenuItem_PPrintClick(Sender: TObject);
3849: BEGIN
3850: opmG_Cur_PPrintEOF := FALSE;
3851: opmG_Cur_PPrintTitle := opmC_AppName1 + ' ' + opmC_AppName2 + ' (' + opmC_AppShortName + ') ' + opmC_Version + ' (build ' + opmG_ExeBuildVersion + ')';
3852: { opmG_Cur_PPrintTitle2 := DATETIMETOSTR (NOW) + ' ' + opmG_DBHost + ' / ' + opmG_DBDatabase;}
3853: opmG_Cur_PPrintTitle2 := DATETIMETOSTR (NOW) + ' '; { PENDIENTE AGREGAR NOMBRE DE SERVIDOR O TIENDA. }
3854: TRY
3855: opm_frReport_ProdList.LoadFromFile (ExtractFilePath (Application.Exename) + opmC_DirReports + '/' + opmC_Report_ProdList1);
3856: IF (opmG_PRNDirectPrint > 0) THEN
3857: BEGIN
3858: opm_frReport_ProdList.PrepareReport;
3859: opm_frReport_ProdList.PrintPreparedReport('', 1);
3860: END
3861: ELSE opm_frReport_ProdList.ShowReport;
3862: EXCEPT
3863: ON E : Exception DO
3864: BEGIN
3865: FNopm_Message (_('Error while printing product list') + #13#10 + E.Message, mtError, [mbOk], opmG_UISilent);
3866: END;
3867: END;
3868: END;
3869:
3870:
3871: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3872: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3873: procedure Topm_Form_Main.opm_PopMenuItem_PPrintPDFClick(Sender: TObject);
3874: begin
3875: opm_SaveDialog_Export.DefaultExt := opmC_Def_PrintPDFExt;
3876: opm_SaveDialog_Export.FileName := opmC_Def_PrintPDFFilename;
3877: opm_SaveDialog_Export.Filter := _('Acrobat Reader files') + ' (' + opmC_Def_PrintPDFFilter + ')|' + opmC_Def_PrintPDFFilter + '|' + _('All files (*.*)');
3878: opm_SaveDialog_Export.Title := _('Printing product list to PDF...');
3879: IF (opm_SaveDialog_Export.Execute = TRUE) THEN
3880: BEGIN
3881: opm_Form_AskUser.AU_Title := _('Printing to PDF');
3882: opm_Form_AskUser.AU_DataText := '';
3883: opm_Form_AskUser.AU_Directions := _('Type the subject of the PDF file:');
3884: opm_Form_AskUser.AU_TextOrList := TRUE;
3885: opm_Form_AskUser.AU_PassChar := #0;
3886: opm_Form_AskUser.AU_MaxLen := opmC_PDFAuthor_MaxLen;
3887: IF (opm_Form_AskUser.ShowModal = mrOk) THEN opmG_Cur_PDFSubject := FNopm_CleanString (opm_Form_AskUser.AU_DataText) ELSE opmG_Cur_PDFSubject := '';
3888: opmG_Cur_PPrintEOF := FALSE;
3889: opmG_Cur_PPrintTitle := opmC_AppName1 + ' ' + opmC_AppName2 + ' (' + opmC_AppShortName + ') ' + opmC_Version + ' (build ' + opmG_ExeBuildVersion + ')';
3890: {opmG_Cur_PPrintTitle2 := DATETIMETOSTR (NOW) + ' ' + opmG_DBHost + ' / ' + opmG_DBDatabase;}
3891: opmG_Cur_PPrintTitle2 := DATETIMETOSTR (NOW) + ' '; { PENDIENTE AGREGAR NOMBRE DE SERVIDOR O TIENDA. }
3892: TRY
3893: opm_frReport_ProdList.LoadFromFile (ExtractFilePath (Application.Exename) + opmC_DirReports + '/' + opmC_Report_ProdList1);
3894: opm_frReport_ProdList.PrepareReport;
3895: opm_frReport_ProdList.ExportTo (TfrTNPDFExportFilter, opm_SaveDialog_Export.FileName);
3896: SHAddToRecentDocs (SHARD_PATH, PCHAR (opm_SaveDialog_Export.FileName));
3897: EXCEPT
3898: ON E : Exception DO
3899: BEGIN
3900: FNopm_Message (_('Error while printing product list') + #13#10 + E.Message, mtError, [mbOk], opmG_UISilent);
3901: END;
3902: END;
3903: END;
3904: end;
3905:
3906:
3907:
3908: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3909: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3910: procedure Topm_Form_Main.opm_frReport_ProdListGetValue (const ParName: String; var ParValue: Variant);
3911: VAR
3912: CurCat : opmR_Category;
3913: CurMan : opmR_Manufacturer;
3914: CurDescR : opmR_Description;
3915: begin
3916: IF (ParName = 'RepTitle') THEN ParValue := opmG_Cur_PPrintTitle
3917: ELSE IF (ParName = 'RepSubtitle') THEN ParValue := opmG_Cur_PPrintTitle2
3918: ELSE IF (ParName = 'RepHeadID') THEN ParValue := _('Product ID')
3919: ELSE IF (ParName = 'RepHeadAvailable') THEN ParValue := _('Available')
3920: ELSE IF (ParName = 'RepHeadModel') THEN ParValue := _('Model')
3921: ELSE IF (ParName = 'RepHeadCategory') THEN ParValue := _('Category name')
3922: ELSE IF (ParName = 'RepHeadManufacturer') THEN ParValue := _('Manufacturer name')
3923: ELSE IF (ParName = 'RepHeadName') THEN ParValue := _('Product name')
3924: ELSE IF (ParName = 'RepHeadQuantity') THEN ParValue := _('Quantity')
3925: ELSE IF (ParName = 'RepHeadPrice') THEN ParValue := _('Price')
3926: ELSE IF (ParName = 'RepHeadSpecial') THEN ParValue := _('Special price')
3927: ELSE IF (ParName = 'RepHeadWeight') THEN ParValue := _('Weight')
3928: ELSE IF (ParName = 'RepHeadImage') THEN ParValue := _('URL')
3929: ELSE IF (ParName = 'RepHeadTax') THEN ParValue := _('Weight')
3930: ELSE IF (ParName = 'RepHeadAvailDate') THEN ParValue := _('Availability date')
3931: ELSE IF (ParName = 'RepHeadCreatDate') THEN ParValue := _('Creation date')
3932: ELSE IF (ParName = 'RepHeadChangeDate') THEN ParValue := _('Change date')
3933: ELSE IF (ParName = 'RepHeadDescription') THEN ParValue := _('Description')
3934: ELSE IF (ParName = 'RepHeadURL') THEN ParValue := _('URL')
3935: ELSE IF (ParName = 'RepHeadViewed') THEN ParValue := _('Times viewed')
3936: ELSE IF (ParName = 'ProdID') THEN ParValue := opmG_Cur_PPrintRecord.ID
3937: ELSE IF (ParName = 'ProdAvailable') THEN ParValue := FNopm_NumToYesNo (opmG_Cur_PPrintRecord.Available)
3938: ELSE IF (ParName = 'ProdModel') THEN ParValue := opmG_Cur_PPrintRecord.Model
3939: ELSE IF (ParName = 'ProdCategory') THEN
3940: BEGIN
3941: CurCat := FNopm_GetCategory (opmG_CategoryList, opmG_Cur_PPrintRecord.CategoryID, opmC_FindByID);
3942: ParValue := CurCat.Name;
3943: END
3944: ELSE IF (ParName = 'ProdManufacturer') THEN
3945: BEGIN
3946: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opmG_Cur_PPrintRecord.ManufacturerID, opmC_FindByID);
3947: ParValue := CurMan.Name;
3948: END
3949: ELSE IF (ParName = 'ProdName') THEN ParValue := opmG_Cur_PPrintRecord.DisplayName
3950: ELSE IF (ParName = 'ProdQuantity') THEN ParValue := opmG_Cur_PPrintRecord.Quantity
3951: ELSE IF (ParName = 'ProdPrice') THEN ParValue := opmG_Cur_PPrintRecord.Price
3952: ELSE IF (ParName = 'ProdSpecial') THEN ParValue := opmG_Cur_PPrintRecord.Special
3953: ELSE IF (ParName = 'ProdWeight') THEN ParValue := opmG_Cur_PPrintRecord.Weight
3954: ELSE IF (ParName = 'ProdImage') THEN ParValue := opmG_Cur_PPrintRecord.ImageURL
3955: ELSE IF (ParName = 'ProdTax') THEN ParValue := opmG_Cur_PPrintRecord.Tax
3956: ELSE IF (ParName = 'ProdAvailDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.AvailDate)
3957: ELSE IF (ParName = 'ProdCreatDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.CreationDate)
3958: ELSE IF (ParName = 'ProdChangeDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.ChangeDate)
3959: ELSE IF (ParName = 'ProdDescription') THEN
3960: BEGIN
3961: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3962: ParValue := CurDescR.Description;
3963: END
3964: ELSE IF (ParName = 'ProdURL') THEN
3965: BEGIN
3966: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3967: ParValue := CurDescR.URL;
3968: END
3969: ELSE IF (ParName = 'ProdViewed') THEN
3970: BEGIN
3971: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3972: ParValue := CurDescR.Viewed;
3973: END;
3974: end;
3975:
3976:
3977: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3978: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3979: procedure Topm_Form_Main.opm_frUserDataset_ProdListCheckEOF(Sender: TObject; var Eof: Boolean);
3980: begin
3981: EOF := opmG_Cur_PPrintEOF;
3982: end;
3983:
3984:
3985:
3986: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3987: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3988: procedure Topm_Form_Main.opm_frUserDataset_ProdListFirst(Sender: TObject);
3989: BEGIN
3990: opmG_Cur_PPrintEOF := FALSE;
3991: opmG_Cur_PrintListItem := opm_ListView_Main.Selected;
3992: IF (opmG_Cur_PrintListItem <> NIL) THEN
3993: BEGIN
3994: opmG_Cur_PPrintID := STRTOINT (TRIM (opmG_Cur_PrintListItem.SubItems.Strings[0]));
3995: opmG_Cur_PPrintRecord := FNopm_GetProductByID (opmG_Cur_PPrintID, opm_CurrentLang, opmG_ProductList);
3996: END
3997: ELSE opmG_Cur_PPrintEOF := TRUE;
3998: end;
3999:
4000: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4001: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4002: procedure Topm_Form_Main.opm_frUserDataset_ProdListNext(Sender: TObject);
4003: begin
4004: opmG_Cur_PrintListItem := opm_ListView_Main.GetNextItem (opmG_Cur_PrintListItem, sdAll, [isSelected]);
4005: IF (opmG_Cur_PrintListItem <> NIL) THEN
4006: BEGIN
4007: opmG_Cur_PPrintID := STRTOINT (TRIM (opmG_Cur_PrintListItem.SubItems.Strings[0]));
4008: opmG_Cur_PPrintRecord := FNopm_GetProductByID (opmG_Cur_PPrintID, opm_CurrentLang, opmG_ProductList);
4009: END
4010: ELSE opmG_Cur_PPrintEOF := TRUE;
4011: end;
4012:
4013:
4014: procedure Topm_Form_Main.FormShow(Sender: TObject);
4015: begin
4016: {$IFDEF OSCPMDEBUG}
4017: FNopm_Message (_('THIS IS A SPECIAL DEBUG-VERSION. Use it only to report crashes and fatal errors. DO NOT DISTRIBUTE. The full open-source version can be found in the website.'), mtInformation, [mbOk], opmG_UISilent);
4018: {$ENDIF}
4019: end;
4020:
4021:
4022:
4023: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4024: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4025: procedure Topm_Form_Main.opm_PopMenuItem_CatDeleteClick (Sender: TObject);
4026: begin
4027: IF ((opm_CurrentCategory > 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
4028: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete this category?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4029: BEGIN
4030: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4031: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Deleting category record...'));
4032: PRopm_DeleteCategory (opm_CurrentCategory);
4033: opm_Form_Progress.PRopm_PDClose;
4034: END;
4035: end;
4036:
4037:
4038:
4039: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4040: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4041: procedure Topm_Form_Main.opm_PopMenuItem_CatAddClick(Sender: TObject);
4042: VAR
4043: CatParent : LONGINT;
4044: begin
4045: IF ((opm_CurrentCategory >= 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
4046: BEGIN
4047: CatParent := opm_CurrentCatRecord.ID;
4048: opm_Form_AskCat.AC_Title := _('Add new category');
4049: opm_Form_AskCat.AC_Directions := _('Enter the name of the new category and its translations.');
4050: opm_Form_AskCat.AC_MaxLen := opmC_CatName_MaxLen;
4051: opm_Form_AskCat.AC_ClearCats := TRUE;
4052: IF (opm_Form_AskCat.ShowModal = mrOk) THEN
4053: BEGIN
4054: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4055: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Adding category record...'));
4056: PRopm_AddCategory (opm_Form_AskCat.AC_CategoryData, opm_TotalLanguages, CatParent);
4057: opm_Form_Progress.PRopm_PDClose;
4058: END;
4059: END;
4060: end;
4061:
4062:
4063: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4064: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4065: procedure Topm_Form_Main.opm_PopMenuItem_CatRenameClick (Sender: TObject);
4066: begin
4067: IF ((opm_CurrentCategory > 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
4068: BEGIN
4069: opm_Form_AskCat.AC_Title := _('Rename category') + ' ' + opm_CurrentCatRecord.Name;
4070: opm_Form_AskCat.AC_Directions := _('Enter the new name of the category and its translations.');
4071: opm_Form_AskCat.AC_MaxLen := opmC_CatName_MaxLen;
4072: opm_Form_AskCat.AC_ClearCats := FALSE;
4073: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4074: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Getting single category data...'));
4075: PRopm_GetCategory_Data (opm_CurrentCategory, opm_Form_AskCat.AC_CategoryData);
4076: opm_Form_Progress.PRopm_PDClose;
4077: IF (opm_Form_AskCat.ShowModal = mrOk) THEN
4078: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this category name?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4079: BEGIN
4080: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4081: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Updating category record...'));
4082: PRopm_UpdateCatName (opm_Form_AskCat.AC_CategoryData, opm_TotalLanguages);
4083: opm_Form_Progress.PRopm_PDClose;
4084: END;
4085: END;
4086: end;
4087:
4088:
4089:
4090: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4091: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4092: PROCEDURE Topm_Form_Main.PRopm_UpdateCatName (CatData : opmT_SingleCatList; TotalCats : LONGINT);
4093: VAR
4094: CurCat : LONGINT;
4095: UStrCatName : STRING;
4096: Progress, ProgStep : LONGINT;
4097: BEGIN
4098: Progress := 0;
4099: ProgStep := ROUND (90 / TotalCats);
4100: FOR CurCat := 0 TO (TotalCats - 1) DO
4101: BEGIN
4102: IF ((CatData[CurCat].ID > 0) AND (CatData[CurCat].Parent >= 0) AND
4103: (CatData[CurCat].Name <> '') AND (CatData[CurCat].LanguageID >= 0)) THEN
4104: BEGIN
4105: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 2, _('Updating category record..'));
4106: UStrCatName := 'update ' + opmG_DBTable_CategoriesDescription + ' set categories_name="' + CatData[CurCat].Name + '"'
4107: + ' where categories_id=' + INTTOSTR (CatData[CurCat].ID) + ' and language_id=' + INTTOSTR (CatData[CurCat].LanguageID);
4108: FNopm_WebDB_Query (opmG_WBUploadURL, UStrCatName, opmG_DBQuery_Recordset);
4109: END;
4110: INC (Progress, ProgStep);
4111: END;
4112: opm_Form_Progress.PRopm_PDUpdate_Progress (93, 2, _('Loading category list...'));
4113: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
4114: opm_Form_Progress.PRopm_PDUpdate_Progress (96, 2, _('Rendering...'));
4115: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
4116: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4117: END;
4118:
4119:
4120: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4121: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4122: PROCEDURE Topm_Form_Main.PRopm_AddCategory (CatData : opmT_SingleCatList; TotalCats : LONGINT; ParentCat : LONGINT);
4123: VAR
4124: CurCat : LONGINT;
4125: IStrCat, IStrCatDesc : STRING;
4126: Progress, ProgStep : LONGINT;
4127: LastID : LONGINT;
4128: BEGIN
4129: Progress := 0;
4130: ProgStep := ROUND (90 / TotalCats);
4131: LastID := 0;
4132: IF (ParentCat >= 0) THEN
4133: BEGIN
4134: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 2, _('Adding category record..'));
4135: IStrCat := 'insert into ' + opmG_DBTable_Categories + ' (parent_id, date_added) values (' + INTTOSTR (ParentCat) + ', now())';
4136: IF (FNopm_WebDB_Query (opmG_WBUploadURL, IStrCat, opmG_DBQuery_Recordset) = 0) THEN
4137: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
4138: BEGIN
4139: LastID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[0, 0]);;
4140: END;
4141: END;
4142: IF (LastID > 0) THEN
4143: FOR CurCat := 0 TO (TotalCats - 1) DO
4144: BEGIN
4145: IF (CatData[CurCat].LanguageID >= 0) THEN
4146: BEGIN
4147: opm_Form_Progress.PRopm_PDUpdate_Progress (Progress, 2, _('Adding category descriptions..'));
4148: IStrCatDesc := 'insert into ' + opmG_DBTable_CategoriesDescription + ' (categories_id, language_id, categories_name)'
4149: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (CatData[CurCat].LanguageID) + ', "' + CatData[CurCat].Name + '")';
4150: FNopm_WebDB_Query (opmG_WBUploadURL, IStrCatDesc, opmG_DBQuery_Recordset);
4151: END;
4152: INC (Progress, ProgStep);
4153: END;
4154: opm_Form_Progress.PRopm_PDUpdate_Progress (93, 2, _('Loading category list...'));
4155: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
4156: opm_Form_Progress.PRopm_PDUpdate_Progress (96, 2, _('Rendering...'));
4157: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
4158: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4159: END;
4160:
4161:
4162:
4163: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4164: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4165: PROCEDURE Topm_Form_Main.PRopm_DeleteCategory (CatID : LONGINT);
4166: VAR
4167: DStrCat, UStrCat, DStrCatDesc, UProdCats, SParentCat : STRING;
4168: ParentCat : LONGINT;
4169: BEGIN
4170: ParentCat := opm_CurrentCategory;
4171: IF (CatID > 0) THEN
4172: BEGIN
4173: opm_Form_Progress.PRopm_PDUpdate_Progress (15, 2, _('Searching parent category..'));
4174: ParentCat := 0;
4175: SParentCat := 'select parent_id from ' + opmG_DBTable_Categories + ' where categories_id=' + INTTOSTR (CatID);
4176: IF (FNopm_WebDB_Query (opmG_WBUploadURL, SParentCat, opmG_DBQuery_Recordset) = 0) THEN
4177: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
4178: BEGIN
4179: ParentCat := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[0, 0]);
4180: IF (ParentCat < 0) THEN ParentCat := 0;
4181: END;
4182: DStrCat := 'delete from ' + opmG_DBTable_Categories + ' where categories_id=' + INTTOSTR (CatID);
4183: UStrCat := 'update ' + opmG_DBTable_Categories + ' set parent_id=' + INTTOSTR (ParentCat) + ' where parent_id=' + INTTOSTR (CatID);
4184: DStrCatDesc := 'delete from ' + opmG_DBTable_CategoriesDescription + ' where categories_id=' + INTTOSTR (CatID);
4185: UProdCats := 'update ' + opmG_DBTable_ProductsToCategories + ' set categories_id=' + INTTOSTR (ParentCat) + ' where categories_id=' + INTTOSTR (CatID);
4186: IF (FNopm_WebDB_Query (opmG_WBUploadURL, DStrCat, opmG_DBQuery_Recordset) = 0) THEN
4187: IF (opmG_DBQuery_Recordset.DataRows >= 0) THEN
4188: BEGIN
4189: opm_Form_Progress.PRopm_PDUpdate_Progress (30, 2, _('Moving categories from category..'));
4190: FNopm_WebDB_Query (opmG_WBUploadURL, UStrCat, opmG_DBQuery_Recordset);
4191: opm_Form_Progress.PRopm_PDUpdate_Progress (45, 2, _('Deleting category record..'));
4192: FNopm_WebDB_Query (opmG_WBUploadURL, DStrCatDesc, opmG_DBQuery_Recordset);
4193: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 2, _('Deleting category descriptions..'));
4194: FNopm_WebDB_Query (opmG_WBUploadURL, UProdCats, opmG_DBQuery_Recordset);
4195: opm_Form_Progress.PRopm_PDUpdate_Progress (75, 2, _('Moving products from category..'));
4196: END;
4197: END;
4198: opm_CurrentCategory := ParentCat;
4199: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, opm_CurrentCategory, opmC_FindByID);
4200: opm_Form_Progress.PRopm_PDUpdate_Progress (90, 2, _('Loading category list...'));
4201: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
4202: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 2, _('Rendering...'));
4203: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
4204: PRopm_Reload_ProductList (opm_WeAreSearching);
4205: END;
4206:
4207:
4208:
4209: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4210: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4211: procedure Topm_Form_Main.opm_ListView_MainKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
4212: begin
4213: CASE Key OF
4214: VK_RETURN : opm_ListView_MainDblClick (Sender);
4215: VK_DELETE : opm_PopMenuItem_PDeleteClick (Sender);
4216: VK_INSERT : opm_PopMenuItem_PAddClick (Sender);
4217: END;
4218:
4219: end;
4220:
4221:
4222: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4223: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4224: PROCEDURE Topm_Form_Main.QuickSearch (QSString : STRING);
4225: BEGIN
4226: opm_Search_Quick := TRIM (QSString);
4227: IF (opm_Search_Quick <> '') THEN
4228: BEGIN
4229: opm_Search_PCategory := 0;
4230: opm_Search_PManufacturer := 0;
4231: opm_Search_PModel := '';
4232: opm_Search_PName := '';
4233: opm_Search_PDesc := '';
4234: opm_Search_PSPrice := 0;
4235: opm_Search_PImagURL := 0;
4236: opm_Search_PAvailable := 0;
4237: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4238: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Searching product...'));
4239: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, opm_Search_Quick);
4240: opm_Form_Progress.PRopm_PDClose;
4241: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4242: PRopm_Valid_ProdOps (FNopm_ConnectionState, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, NIL, opm_CurrentProdID_CB);
4243: END;
4244: END;
4245:
4246:
4247: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4248: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4249: procedure Topm_Form_Main.opm_SpeedButton_QuickSearchClick(Sender: TObject);
4250: BEGIN
4251: QuickSearch (opm_Edit_QuickSearch.Text);
4252: END;
4253:
4254:
4255: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4256: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4257: procedure Topm_Form_Main.opm_Edit_QuickSearchKeyPress(Sender: TObject; var Key: Char);
4258: BEGIN
4259: IF (ORD (Key) = VK_RETURN) THEN QuickSearch (opm_Edit_QuickSearch.Text);
4260: END;
4261:
4262:
4263:
4264: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4265: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4266: procedure Topm_Form_Main.opm_MenuItem_CheckUpdatesClick(Sender: TObject);
4267: VAR
4268: ResStr : STRING;
4269: ResCode : LONGINT;
4270: RemoteVer, RemoteURL : STRING;
4271: CompRes : LONGINT;
4272: BEGIN
4273: RemoteVer := '';
4274: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4275: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Checking for updates...'));
4276: PRopm_Prepare_HTTPClient (opm_Form_Progress.opm_ProgressBar_Progress2, opm_Form_Progress.opm_Label_ProgressMsg2, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 2])));
4277: ResCode := FNopm_Send_SimpleCommand (opmC_CheckUpdates_URL, 'check', opmC_Version + '.' + opmG_ExeBuildVersion, ResStr);
4278: IF (ResCode = 0) THEN
4279: BEGIN
4280: opm_Form_Progress.PRopm_PDClose;
4281: RemoteVer := TRIM (COPY (ResStr, (ANSIPOS (opmC_WebScriptOKCode, ResStr) + LENGTH (opmC_WebScriptOKCode)), (ANSIPOS (' http', ResStr) - LENGTH (opmC_WebScriptOKCode))));
4282: RemoteURL := TRIM (COPY (ResStr, ANSIPOS (' http', ResStr), LENGTH (ResStr)));
4283: CompRes := FNopm_CompareVersions (opmC_Version + '.' + opmG_ExeBuildVersion, RemoteVer);
4284: IF (CompRes = opmC_VersionIsOlder) THEN
4285: BEGIN
4286: IF (FNopm_Message (_('There is a new version available. Do you want to download it?') + ' [' + RemoteVer + ']', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
4287: ShellExecute (handle,'Open', PCHAR (RemoteURL), NIL, NIL, SW_NORMAL);
4288: END
4289: ELSE
4290: FNopm_Message (_('There is not a new version available.'), mtInformation, [mbOk], opmG_UISilent);
4291: END
4292: ELSE
4293: BEGIN
4294: opm_Form_Progress.PRopm_PDClose;
4295: FNopm_Message (_('Cannot contact the software website. Check your network connection and proxy settings.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
4296: END;
4297: END;
4298:
4299:
4300: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4301: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4302: procedure Topm_Form_Main.opm_MenuItem_ManAddClick(Sender: TObject);
4303: VAR
4304: ManName : STRING;
4305: LastID : LONGINT;
4306: IStrMans, IStrManInfo : STRING;
4307: CurLang : LONGINT;
4308: BEGIN
4309: opm_Form_AskUser.AU_Title := _('Add new manufacturer');
4310: opm_Form_AskUser.AU_DataText := '';
4311: opm_Form_AskUser.AU_Directions := _('Type the name of the new manufacturer (avoid using HTML tags):');
4312: opm_Form_AskUser.AU_TextOrList := TRUE;
4313: opm_Form_AskUser.AU_PassChar := #0;
4314: opm_Form_AskUser.AU_MaxLen := opmC_ManName_MaxLen;
4315: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4316: BEGIN
4317: ManName := FNopm_CleanString (opm_Form_AskUser.AU_DataText);
4318: IF (ManName = '') THEN ManName := opmC_Unamed_Man;
4319: LastID := 0;
4320: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4321: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Adding manufacturer record...'));
4322: opm_Form_Progress.PRopm_PDUpdate_Progress (0, 2, _('Adding manufacturer data...'));
4323: IStrMans := 'insert into ' + opmG_DBTable_Manufacturers + ' (manufacturers_name, date_added, last_modified)' + ''
4324: + ' values ("' + FNopm_CleanSQLString (ManName, FALSE) + '", now(), now())';
4325: IF (FNopm_WebDB_Query (opmG_WBUploadURL, IStrMans, opmG_DBQuery_Recordset) = 0) THEN
4326: IF (opmG_DBQuery_Recordset.DataRows > 0) THEN
4327: BEGIN
4328: LastID := FNopm_StrToInt (opmG_DBQuery_Recordset.Data[0, 0]);
4329: END;
4330: IF (LastID > 0) THEN
4331: BEGIN
4332: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
4333: BEGIN
4334: opm_Form_Progress.PRopm_PDUpdate_Progress ((50 + (CurLang * ROUND (50 / opm_TotalLanguages))), 2, _('Adding manufacturer extra data...'));
4335: IStrManInfo := 'insert into ' + opmG_DBTable_ManufacturersInfo + ' (manufacturers_id, languages_id, manufacturers_url, url_clicked)' + ''
4336: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (opmG_LanguageList[CurLang].ID) + ', "", 0)';
4337: FNopm_WebDB_Query (opmG_WBUploadURL, IStrManInfo, opmG_DBQuery_Recordset);
4338: END;
4339: END;
4340: opm_Form_Progress.PRopm_PDUpdate_Progress (70, 1, _('Loading manufacturers list...'));
4341: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4342: opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, _('Loading product list...'));
4343: PRopm_Reload_ProductList (opm_WeAreSearching);
4344: opm_Form_Progress.PRopm_PDClose;
4345: END;
4346: END;
4347:
4348:
4349:
4350:
4351: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4352: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4353: procedure Topm_Form_Main.opm_MenuItem_ManRenameClick(Sender: TObject);
4354: VAR
4355: CurMan : opmR_Manufacturer;
4356: ManName : STRING;
4357: UStrMans : STRING;
4358: BEGIN
4359: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
4360: opm_Form_AskUser.AU_Title := _('Rename manufacturer');
4361: opm_Form_AskUser.AU_ListItem := 0;
4362: opm_Form_AskUser.AU_Directions := _('Select the manufacturer to rename:');
4363: opm_Form_AskUser.AU_TextOrList := FALSE;
4364: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4365: BEGIN
4366: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
4367: IF (CurMan.ID > 0) THEN
4368: BEGIN
4369: opm_Form_AskUser.AU_Title := _('Rename manufacturer');
4370: opm_Form_AskUser.AU_DataText := CurMan.Name;
4371: opm_Form_AskUser.AU_Directions := _('Edit the name of the manufacturer (avoid using HTML tags):');
4372: opm_Form_AskUser.AU_TextOrList := TRUE;
4373: opm_Form_AskUser.AU_PassChar := #0;
4374: opm_Form_AskUser.AU_MaxLen := opmC_ManName_MaxLen;
4375: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4376: BEGIN
4377: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this manufacturer name?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4378: BEGIN
4379: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4380: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Updating manufacturer record...'));
4381: ManName := FNopm_CleanString (opm_Form_AskUser.AU_DataText);
4382: IF (ManName = '') THEN ManName := opmC_Unamed_Man;
4383: UStrMans := 'update ' + opmG_DBTable_Manufacturers + ' set manufacturers_name="' + FNopm_CleanSQLString (ManName, FALSE) + '" where manufacturers_id=' + INTTOSTR (CurMan.ID);
4384: FNopm_WebDB_Query (opmG_WBUploadURL, UStrMans, opmG_DBQuery_Recordset);
4385: opm_Form_Progress.PRopm_PDUpdate_Progress (70, 1, _('Loading manufacturers list...'));
4386: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4387: opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, _('Loading product list...'));
4388: PRopm_Reload_ProductList (opm_WeAreSearching);
4389: opm_Form_Progress.PRopm_PDClose;
4390: END;
4391: END;
4392: END
4393: ELSE FNopm_Message (_('You must select a valid manufacturer.'), mtWarning, [mbOk], opmG_UISilent);
4394: END;
4395: END;
4396:
4397:
4398:
4399: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4400: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4401: procedure Topm_Form_Main.opm_MenuItem_ManDeleteClick(Sender: TObject);
4402: VAR
4403: CurMan : opmR_Manufacturer;
4404: DStrMans, DStrMansInfo, UStrProdMan : STRING;
4405: BEGIN
4406: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
4407: opm_Form_AskUser.AU_Title := _('Delete manufacturer');
4408: opm_Form_AskUser.AU_ListItem := 0;
4409: opm_Form_AskUser.AU_Directions := _('Select the manufacturer to delete (all products by this manufacturer will be reassigned to a null manufacturer):');
4410: opm_Form_AskUser.AU_TextOrList := FALSE;
4411: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4412: BEGIN
4413: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
4414: IF (CurMan.ID > 0) THEN
4415: BEGIN
4416: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete this manufacturer?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4417: BEGIN
4418: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4419: opm_Form_Progress.PRopm_PDUpdate_Progress (20, 1, _('Deleting manufacturer record...'));
4420: DStrMans := 'delete from ' + opmG_DBTable_Manufacturers + ' where manufacturers_id=' + INTTOSTR (CurMan.ID);
4421: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Deleting manufacturer record...'));
4422: FNopm_WebDB_Query (opmG_WBUploadURL, DStrMans, opmG_DBQuery_Recordset);
4423: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Deleting manufacturer record...'));
4424: DStrMansInfo := 'delete from ' + opmG_DBTable_ManufacturersInfo + ' where manufacturers_id=' + INTTOSTR (CurMan.ID);
4425: FNopm_WebDB_Query (opmG_WBUploadURL, DStrMansInfo, opmG_DBQuery_Recordset);
4426: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Deleting manufacturer record...'));
4427: UStrProdMan := 'update ' + opmG_DBTable_Products + ' set manufacturers_id=0 where manufacturers_id=' + INTTOSTR (CurMan.ID);
4428: FNopm_WebDB_Query (opmG_WBUploadURL, UStrProdMan, opmG_DBQuery_Recordset);
4429: opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, _('Loading manufacturers list...'));
4430: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4431: opm_Form_Progress.PRopm_PDUpdate_Progress (95, 1, _('Loading product list...'));
4432: PRopm_Reload_ProductList (opm_WeAreSearching);
4433: opm_Form_Progress.PRopm_PDClose;
4434: END;
4435: END
4436: ELSE FNopm_Message (_('You must select a valid manufacturer.'), mtWarning, [mbOk], opmG_UISilent);
4437: END;
4438: END;
4439:
4440:
4441:
4442: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4443: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4444: procedure Topm_Form_Main.opm_MenuItem_BackupClick(Sender: TObject);
4445: VAR
4446: RecFileName : STRING;
4447: ResStr : STRING;
4448: ResCode : LONGINT;
4449: BEGIN
4450: IF (FNopm_Message (_('Do you really want to download a database backup of the store?') + #13#10 + _('This operation may take a few minutes.'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
4451: BEGIN
4452: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4453: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Getting database backup...'));
4454: PRopm_Prepare_HTTPClient (opm_Form_Progress.opm_ProgressBar_Progress2, opm_Form_Progress.opm_Label_ProgressMsg2, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
4455: ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'noop', '', ResStr);
4456: IF (ResCode = 0) THEN
4457: BEGIN
4458: RecFileName := FNopm_Receive_File (opmG_WBUploadURL, 'backup', opmG_TMPPath + opmC_TmpBak_Filename);
4459: opm_Form_Progress.PRopm_PDClose;
4460: IF (RecFileName <> '') THEN
4461: BEGIN
4462: opm_SaveDialog_Export.DefaultExt := opmC_Def_BackupExt;
4463: // opm_SaveDialog_Export.FileName := STRINGREPLACE (opmG_DBHost, '.', '', [rfReplaceAll, rfIgnoreCase]) + '_' + RecFileName;
4464: opm_SaveDialog_Export.FileName := STRINGREPLACE ('OSC', '.', '', [rfReplaceAll, rfIgnoreCase]) + '_' + RecFileName; { PENDIENTE USART NOMBRE DE TIENDA. }
4465: opm_SaveDialog_Export.Filter := _('Backup files') + ' (' + opmC_Def_BackupFilter + ')|' + opmC_Def_BackupFilter + '|' + _('All files (*.*)');
4466: opm_SaveDialog_Export.Title := _('Saving database backup...');
4467: IF (opm_SaveDialog_Export.Execute = TRUE) THEN
4468: BEGIN
4469: IF (MoveFile (PCHAR (opmG_TMPPath + opmC_TmpBak_Filename), PCHAR (opm_SaveDialog_Export.FileName)) = TRUE) THEN
4470: SHAddToRecentDocs (SHARD_PATH, PCHAR (opm_SaveDialog_Export.FileName))
4471: ELSE
4472: BEGIN
4473: FNopm_Message ('Error while downloading the database backup file.', mtError, [mbOk], opmG_UISilent);
4474: END;
4475: END;
4476: END
4477: ELSE
4478: BEGIN
4479: FNopm_Message ('Error while downloading the database backup file.', mtError, [mbOk], opmG_UISilent);
4480: END;
4481: END
4482: ELSE
4483: BEGIN
4484: opm_Form_Progress.PRopm_PDClose;
4485: FNopm_Message (_('There was an error while trying to request a backup to the server.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
4486: END;
4487: END;
4488: end;
4489:
4490:
4491: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4492: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4493: procedure Topm_Form_Main.opm_MenuItem_FullscreenClick(Sender: TObject);
4494: begin
4495: opm_WeAreFullScreen := NOT (opm_WeAreFullScreen);
4496: PRopm_Sound ('Maximize', opmG_UISilent);
4497: PRopm_FullScreen (opm_WeAreFullScreen);
4498: end;
4499:
4500:
4501: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4502: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4503: PROCEDURE Topm_Form_Main.PRopm_FullScreen (SetReset : BOOLEAN);
4504: BEGIN
4505: IF (SetReset = FALSE) THEN
4506: BEGIN
4507: opm_Form_Main.Left := opmG_UIWindow_XPos;
4508: opm_Form_Main.Top := opmG_UIWindow_YPos;
4509: opm_Form_Main.Width := opmG_UIWindow_XSize;
4510: opm_Form_Main.Height := opmG_UIWindow_YSize;
4511: opm_StopTreeOnChange := TRUE;
4512: opm_Form_Main.BorderStyle := bsSizeable;
4513: opm_StopTreeOnChange := FALSE;
4514: END
4515: ELSE
4516: BEGIN
4517: opmG_UIWindow_XPos := opm_Form_Main.Left;
4518: opmG_UIWindow_YPos := opm_Form_Main.Top;
4519: opmG_UIWindow_XSize := opm_Form_Main.Width;
4520: opmG_UIWindow_YSize := opm_Form_Main.Height;
4521: opm_StopTreeOnChange := TRUE;
4522: opm_Form_Main.BorderStyle := bsNone;
4523: opm_StopTreeOnChange := FALSE;
4524: opm_Form_Main.Top := 0;
4525: opm_Form_Main.Left := 0;
4526: opm_Form_Main.Width := Screen.WorkAreaWidth;
4527: opm_Form_Main.Height := Screen.WorkAreaHeight;
4528: END;
4529: END;
4530:
4531:
4532: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4533: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4534: procedure Topm_Form_Main.opm_PopMenuItem_PCopyPRClick(Sender: TObject);
4535: VAR
4536: CurItem : TListItem;
4537: CurLang : LONGINT;
4538: BEGIN
4539: CurItem := opm_ListView_Main.Selected;
4540: IF ((CurItem <> NIL) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
4541: BEGIN
4542: opm_ListView_Main.Enabled := FALSE;
4543: opm_CurrentProdID_CB := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
4544: opm_CurrentProdRecord_CB := FNopm_GetProductByID (opm_CurrentProdID_CB, opm_CurrentLang, opmG_ProductList);
4545: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
4546: BEGIN
4547: opm_CurrentSingleDescList_CB[CurLang] := FNopm_GetDescriptionByID (opm_CurrentProdRecord_CB.ID, opmG_LanguageList[CurLang].ID, opmG_DescriptionList);
4548: opm_CurrentSingleDescList_CB[CurLang].ID := opmC_InsertProdID;
4549: END;
4550: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opm_CurrentProdRecord_CB.DisplayName, opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4551: opm_ListView_Main.Enabled := TRUE;
4552: opm_Form_Main.FocusControl (opm_ListView_Main);
4553: END
4554: ELSE
4555: BEGIN
4556: opm_CurrentProdID_CB := 0;
4557: END;
4558: end;
4559:
4560:
4561:
4562: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4563: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4564: procedure Topm_Form_Main.opm_PopMenuItem_PPastePRClick(Sender: TObject);
4565: begin
4566: IF ((opm_CurrentProdID_CB > 0) AND (opm_ListView_Main.Enabled = TRUE) AND (opm_ListView_Main.Focused)) THEN
4567: BEGIN
4568: opm_ListView_Main.Enabled := FALSE;
4569: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4570: opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Saving product...'));
4571: opm_CurrentProdRecord_CB.Available := 0;
4572: opm_CurrentProdRecord_CB.CategoryID := opm_CurrentCategory;
4573: PRopm_AddProduct (opm_CurrentProdRecord_CB, opm_CurrentSingleDescList_CB);
4574: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading product list...'));
4575: PRopm_Reload_ProductList (opm_WeAreSearching);
4576: opm_Form_Progress.PRopm_PDClose;
4577: opm_ListView_Main.Enabled := TRUE;
4578: opm_Form_Main.FocusControl (opm_ListView_Main);
4579: END;
4580: end;
4581:
4582:
4583: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4584: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4585: procedure Topm_Form_Main.opm_MenuItem_ManCurrencyClick(Sender: TObject);
4586: begin
4587: opm_Form_CurrencyMan.ShowModal;
4588: end;
4589:
4590:
4591:
4592:
4593: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4594: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4595: PROCEDURE Topm_Form_Main.PRopm_AddCurrency (CurrencyRec : opmR_Currency);
4596: VAR
4597: IStrCurr : STRING;
4598: BEGIN
4599: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4600: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Adding currency record...'));
4601: IStrCurr := 'insert into ' + opmG_DBTable_Currencies + ' (title, code, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value, last_updated) ' +
4602: 'values ("' + CurrencyRec.Name + '", "' + CurrencyRec.Code + '", "' + CurrencyRec.Left + '", "' + CurrencyRec.Right + '", "' + CurrencyRec.DecimalSep + '", "' +
4603: CurrencyRec.ThousandSep + '", "' + INTTOSTR (CurrencyRec.Precision) + '", ' + CURRTOSTR (CurrencyRec.Value) + ', now())';
4604: FNopm_WebDB_Query (opmG_WBUploadURL, IStrCurr, opmG_DBQuery_Recordset);
4605: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
4606: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
4607: opm_Form_Progress.PRopm_PDClose;
4608: END;
4609:
4610:
4611: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4612: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4613: PROCEDURE Topm_Form_Main.PRopm_DelCurrency (CurrencyRec : opmR_Currency);
4614: VAR
4615: DStrCurr : STRING;
4616: BEGIN
4617: IF (CurrencyRec.ID >= 0) THEN
4618: BEGIN
4619: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4620: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Deleting currency record...'));
4621: DStrCurr := 'delete from ' + opmG_DBTable_Currencies + ' where currencies_id=' + INTTOSTR (CurrencyRec.ID);
4622: FNopm_WebDB_Query (opmG_WBUploadURL, DStrCurr, opmG_DBQuery_Recordset);
4623: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
4624: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
4625: opm_Form_Progress.PRopm_PDClose;
4626: END;
4627: END;
4628:
4629:
4630:
4631: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4632: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4633: PROCEDURE Topm_Form_Main.PRopm_UpdateCurrency (CurrencyRec : opmR_Currency; Bulking : BOOLEAN);
4634: VAR
4635: UStrCurr : STRING;
4636: BEGIN
4637: IF (CurrencyRec.ID >= 0) THEN
4638: BEGIN
4639: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4640: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Updating currency record...'));
4641: UStrCurr := 'update ' + opmG_DBTable_Currencies +
4642: ' set title="' + CurrencyRec.Name + '", code="' + CurrencyRec.Code + '", symbol_left="' + CurrencyRec.Left + '",' +
4643: ' symbol_right="' + CurrencyRec.Right + '", decimal_point="' + CurrencyRec.DecimalSep + '", thousands_point="' + CurrencyRec.ThousandSep + '",' +
4644: ' decimal_places="' + INTTOSTR (CurrencyRec.Precision) + '", value=' + CURRTOSTR (CurrencyRec.Value) + ', last_updated=now() ' +
4645: ' where currencies_id=' + INTTOSTR (CurrencyRec.ID);
4646: FNopm_WebDB_Query (opmG_WBUploadURL, UStrCurr, opmG_DBQuery_Recordset);
4647: IF (Bulking = FALSE) THEN
4648: BEGIN
4649: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
4650: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
4651: END;
4652: opm_Form_Progress.PRopm_PDClose;
4653: END;
4654: END;
4655:
4656:
4657: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4658: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4659: PROCEDURE Topm_Form_Main.PRopm_SetDefault_Currency (CurrCode : STRING);
4660: VAR
4661: UStrCurr : STRING;
4662: BEGIN
4663: IF (CurrCode <> '') THEN
4664: BEGIN
4665: opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
4666: opm_Form_Progress.PRopm_PDUpdate_Progress (40, 1, _('Updating currency record...'));
4667: UStrCurr := 'update ' + opmG_DBTable_Configuration +
4668: ' set configuration_value="' + CurrCode + '", last_modified=now() ' +
4669: ' where configuration_key="DEFAULT_CURRENCY"';
4670: FNopm_WebDB_Query (opmG_WBUploadURL, UStrCurr, opmG_DBQuery_Recordset);
4671: opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Updating currency record...'));
4672: UStrCurr := 'update ' + opmG_DBTable_Currencies +
4673: ' set value=1, last_updated=now() ' +
4674: ' where code="' + CurrCode + '"';
4675: FNopm_WebDB_Query (opmG_WBUploadURL, UStrCurr, opmG_DBQuery_Recordset);
4676: opm_Form_Progress.PRopm_PDUpdate_Progress (80, 1, _('Loading currency list...'));
4677: opm_CurrentCurrency := FNopm_LoadCurrencyList (opmG_CurrencyList, opmG_CurrencyBoxList);
4678: opm_Form_Progress.PRopm_PDClose;
4679: END;
4680: END;
4681:
4682:
4683: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4684: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4685: procedure Topm_Form_Main.opm_ListView_MainCustomDrawItem (Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
4686: begin
4687: IF ((opmG_UIStripes > 0) AND ODD (Item.Index)) THEN opm_ListView_Main.Canvas.Brush.Color := opmG_StripeColor ELSE opm_ListView_Main.Canvas.Brush.Color := clWindow;
4688: end;
4689:
4690:
4691:
4692: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4693: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4694: procedure Topm_Form_Main.opm_MenuItem_WebsiteClick(Sender: TObject);
4695: begin
4696: ShellExecute (handle,'Open', PCHAR (opmC_HomepageURL + '?' + opmC_RedirParameter + '=' + opmC_Version + '.' + opmG_ExeBuildVersion), NIL, NIL, SW_NORMAL);
4697: end;
4698:
4699:
4700:
4701: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4702: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4703: procedure Topm_Form_Main.opm_MenuItem_ForumsClick(Sender: TObject);
4704: begin
4705: ShellExecute (handle,'Open', PCHAR (opmC_WebForumsURL + '?' + opmC_RedirParameter + '=' + opmC_Version + '.' + opmG_ExeBuildVersion), NIL, NIL, SW_NORMAL);
4706: end;
4707:
4708:
4709: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4710: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4711: procedure Topm_Form_Main.opm_MenuItem_ShowPHPInfoClick(Sender: TObject);
4712: begin
4713: opm_Form_PHPInfo.ShowModal;
4714: end;
4715:
4716:
4717: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4718: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4719: procedure Topm_Form_Main.opm_MenuItem_ShowSQLLogClick(Sender: TObject);
4720: begin
4721: opm_Form_SQLLog.ShowModal;
4722: end;
4723:
4724:
4725:
4726: END.
4727:
4728:
4729: