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