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