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