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


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