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