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


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