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