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


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