Source code of file oscpmwin_v0.4.1.723/main.pas from the
osCommerce Product Manager for Windows.


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