Commit 5af369e8 by Elias Sarraf

Merge branch 'master' into cam2

parents 86de47e4 f1a2333b
...@@ -7,9 +7,9 @@ kgOrdersClient/css/__history/ ...@@ -7,9 +7,9 @@ kgOrdersClient/css/__history/
kgOrdersClient/config/__history/ kgOrdersClient/config/__history/
kgOrdersServer/__history kgOrdersServer/__history
kgOrdersServer/__recovery kgOrdersServer/__recovery
kgOrdersServer/*.log
kgOrdersServer/*.txt kgOrdersServer/*.txt
kgOrdersServer/doc/ kgOrdersServer/doc/
kgOrdersServer/logs
kgOrdersServer/Win32/ kgOrdersServer/Win32/
kgOrdersServer/Source/__history/ kgOrdersServer/Source/__history/
kgOrdersServer/Source/__recovery/ kgOrdersServer/Source/__recovery/
......
...@@ -38,6 +38,163 @@ object FAddOrder: TFAddOrder ...@@ -38,6 +38,163 @@ object FAddOrder: TFAddOrder
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
Top = 146
Width = 871
Height = 331
Align = alBottom
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 2
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 4
Options.Bands.Enabled = True
Options.ColumnSize.Stretch = True
Options.Editing.CalcFormat = '%g'
Options.Grouping.CalcFormat = '%g'
Options.Grouping.GroupCountFormat = '(%d)'
Options.IO.XMLEncoding = 'ISO-8859-1'
Options.Mouse.ClickMargin = 0
Options.Mouse.ColumnSizeMargin = 6
Options.Mouse.RowSizeMargin = 6
OnSelectedCell = TMSFNCGrid1SelectedCell
Columns = <
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 70.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 250.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 100.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 432.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 90.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
DefaultFont.Height = -11
DefaultFont.Name = 'Segoe UI'
DefaultFont.Style = []
TopRow = 1
Appearance.FixedLayout.Fill.Color = 16380654
Appearance.FixedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedLayout.Font.Color = 4539717
Appearance.FixedLayout.Font.Height = -13
Appearance.FixedLayout.Font.Name = 'Segoe UI'
Appearance.FixedLayout.Font.Style = [fsBold]
Appearance.NormalLayout.Fill.Color = 16578806
Appearance.NormalLayout.Font.Charset = DEFAULT_CHARSET
Appearance.NormalLayout.Font.Color = 8026746
Appearance.NormalLayout.Font.Height = -11
Appearance.NormalLayout.Font.Name = 'Segoe UI'
Appearance.NormalLayout.Font.Style = []
Appearance.GroupLayout.Fill.Color = 12817262
Appearance.GroupLayout.Font.Charset = DEFAULT_CHARSET
Appearance.GroupLayout.Font.Color = clBlack
Appearance.GroupLayout.Font.Height = -11
Appearance.GroupLayout.Font.Name = 'Segoe UI'
Appearance.GroupLayout.Font.Style = []
Appearance.SummaryLayout.Fill.Color = 14009785
Appearance.SummaryLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SummaryLayout.Font.Color = clBlack
Appearance.SummaryLayout.Font.Height = -11
Appearance.SummaryLayout.Font.Name = 'Segoe UI'
Appearance.SummaryLayout.Font.Style = []
Appearance.SelectedLayout.Fill.Color = 16441019
Appearance.SelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SelectedLayout.Font.Color = 4539717
Appearance.SelectedLayout.Font.Height = -11
Appearance.SelectedLayout.Font.Name = 'Segoe UI'
Appearance.SelectedLayout.Font.Style = []
Appearance.FocusedLayout.Fill.Color = 16039284
Appearance.FocusedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FocusedLayout.Font.Color = 4539717
Appearance.FocusedLayout.Font.Height = -11
Appearance.FocusedLayout.Font.Name = 'Segoe UI'
Appearance.FocusedLayout.Font.Style = []
Appearance.FixedSelectedLayout.Fill.Color = clLightsteelblue
Appearance.FixedSelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedSelectedLayout.Font.Color = clBlack
Appearance.FixedSelectedLayout.Font.Height = -11
Appearance.FixedSelectedLayout.Font.Name = 'Segoe UI'
Appearance.FixedSelectedLayout.Font.Style = []
Appearance.BandLayout.Fill.Color = 16711679
Appearance.BandLayout.Font.Charset = DEFAULT_CHARSET
Appearance.BandLayout.Font.Color = 8026746
Appearance.BandLayout.Font.Height = -11
Appearance.BandLayout.Font.Name = 'Segoe UI'
Appearance.BandLayout.Font.Style = []
Appearance.ProgressLayout.Format = '%.0f%%'
LeftCol = 0
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
end
object cbCorrugatedPlate: TWebCheckBox object cbCorrugatedPlate: TWebCheckBox
Left = 26 Left = 26
Top = 63 Top = 63
...@@ -253,13 +410,13 @@ object FAddOrder: TFAddOrder ...@@ -253,13 +410,13 @@ object FAddOrder: TFAddOrder
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 728 Left = 730
Top = 109 Top = 93
end end
object xdwdsCustomers: TXDataWebDataSet object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 600 Left = 600
Top = 109 Top = 95
object xdwdsCustomersID: TIntegerField object xdwdsCustomersID: TIntegerField
FieldName = 'ID' FieldName = 'ID'
end end
...@@ -276,7 +433,7 @@ object FAddOrder: TFAddOrder ...@@ -276,7 +433,7 @@ object FAddOrder: TFAddOrder
end end
object wdsCustomers: TWebDataSource object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers DataSet = xdwdsCustomers
Left = 470 Left = 468
Top = 109 Top = 93
end end
end end
...@@ -12,8 +12,8 @@ object FViewOrders: TFViewOrders ...@@ -12,8 +12,8 @@ object FViewOrders: TFViewOrders
OnCreate = WebFormCreate OnCreate = WebFormCreate
OnShow = WebFormShow OnShow = WebFormShow
object lblEntries: TWebLabel object lblEntries: TWebLabel
Left = 68 Left = 59
Top = 333 Top = 113
Width = 77 Width = 77
Height = 13 Height = 13
Caption = 'Showing 0 of ...' Caption = 'Showing 0 of ...'
...@@ -163,8 +163,8 @@ object FViewOrders: TFViewOrders ...@@ -163,8 +163,8 @@ object FViewOrders: TFViewOrders
TabStop = False TabStop = False
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebButton2: TWebButton object btnPDF: TWebButton
Left = 328 Left = 332
Top = 79 Top = 79
Width = 96 Width = 96
Height = 25 Height = 25
...@@ -177,6 +177,114 @@ object FViewOrders: TFViewOrders ...@@ -177,6 +177,114 @@ object FViewOrders: TFViewOrders
TabOrder = 8 TabOrder = 8
TabStop = False TabStop = False
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnPDFClick
end
object wdbtcOrders: TWebDBTableControl
Left = 26
Top = 132
Width = 631
Height = 200
ElementClassName = 'table'
ElementId = 'tblPhoneGrid'
BorderColor = clSilver
ChildOrder = 11
ElementFont = efCSS
ElementHeaderClassName = 'thead-light'
ElementPosition = epRelative
ElementTableClassName = 'table table-striped table-hover table-bordered text-sm'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
Columns = <
item
DataField = 'ID'
Title = 'ID'
end
item
DataField = 'companyName'
Title = 'Company Name'
end
item
DataField = 'jobName'
Title = 'Job Name'
end
item
DataField = 'orderDate'
Title = 'Order Date'
end
item
DataField = 'proofDue'
Title = 'Proof Due'
end
item
DataField = 'proofDone'
Title = 'Proof Done'
end
item
DataField = 'artDue'
Title = 'Art Due'
end
item
DataField = 'artDone'
Title = 'Art Done'
end
item
DataField = 'mountDue'
Title = 'Mount Due'
end
item
DataField = 'mountDone'
Title = 'Mount Done'
end
item
DataField = 'shipDue'
Title = 'Ship Due'
end
item
DataField = 'shipDone'
Title = 'Ship Done'
end
item
DataField = 'price'
Title = 'Price'
end
item
DataField = 'qbRefNum'
Title = 'Quickbooks Reference Number'
end
item
DataField = 'colors'
Title = 'Colors'
end
item
DataField = 'plateDue'
Title = 'Plate Due'
end
item
DataField = 'plateDone'
Title = 'Plate Done'
end
item
DataField = 'orderType'
Title = 'Order Type'
end>
DataSource = wdsOrders
end end
object pnlMessage: TWebPanel object pnlMessage: TWebPanel
Left = 52 Left = 52
...@@ -221,70 +329,70 @@ object FViewOrders: TFViewOrders ...@@ -221,70 +329,70 @@ object FViewOrders: TFViewOrders
Left = 28 Left = 28
Top = 410 Top = 410
end end
object XDataWebDataSet1: TXDataWebDataSet object xdwdsOrders: TXDataWebDataSet
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 70 Left = 70
Top = 410 Top = 410
object XDataWebDataSet1ID: TStringField object xdwdsOrdersID: TStringField
FieldName = 'ID' FieldName = 'ID'
end end
object XDataWebDataSet1companyName: TStringField object xdwdsOrderscompanyName: TStringField
FieldName = 'companyName' FieldName = 'companyName'
end end
object XDataWebDataSet1jobName: TStringField object xdwdsOrdersjobName: TStringField
FieldName = 'jobName' FieldName = 'jobName'
end end
object XDataWebDataSet1orderDate: TStringField object xdwdsOrdersorderDate: TStringField
FieldName = 'orderDate' FieldName = 'orderDate'
end end
object XDataWebDataSet1proofDue: TStringField object xdwdsOrdersproofDue: TStringField
FieldName = 'proofDue' FieldName = 'proofDue'
end end
object XDataWebDataSet1proofDone: TStringField object xdwdsOrdersproofDone: TStringField
FieldName = 'proofDone' FieldName = 'proofDone'
end end
object XDataWebDataSet1artDue: TStringField object xdwdsOrdersartDue: TStringField
FieldName = 'artDue' FieldName = 'artDue'
end end
object XDataWebDataSet1artDone: TStringField object xdwdsOrdersartDone: TStringField
FieldName = 'artDone' FieldName = 'artDone'
end end
object XDataWebDataSet1mountDue: TStringField object xdwdsOrdersmountDue: TStringField
FieldName = 'mountDue' FieldName = 'mountDue'
end end
object XDataWebDataSet1mountDone: TStringField object xdwdsOrdersmountDone: TStringField
FieldName = 'mountDone' FieldName = 'mountDone'
end end
object XDataWebDataSet1shipDue: TStringField object xdwdsOrdersshipDue: TStringField
FieldName = 'shipDue' FieldName = 'shipDue'
end end
object XDataWebDataSet1shipDone: TStringField object xdwdsOrdersshipDone: TStringField
FieldName = 'shipDone' FieldName = 'shipDone'
end end
object XDataWebDataSet1price: TStringField object xdwdsOrdersprice: TStringField
FieldName = 'price' FieldName = 'price'
end end
object XDataWebDataSet1qbRefNum: TStringField object xdwdsOrdersqbRefNum: TStringField
FieldName = 'qbRefNum' FieldName = 'qbRefNum'
end end
object XDataWebDataSet1colors: TStringField object xdwdsOrderscolors: TStringField
FieldName = 'colors' FieldName = 'colors'
end end
object XDataWebDataSet1plateDue: TStringField object xdwdsOrdersplateDue: TStringField
FieldName = 'plateDue' FieldName = 'plateDue'
end end
object XDataWebDataSet1plateDone: TStringField object xdwdsOrdersplateDone: TStringField
FieldName = 'plateDone' FieldName = 'plateDone'
end end
object XDataWebDataSet1orderType: TStringField object xdwdsOrdersorderType: TStringField
FieldName = 'orderType' FieldName = 'orderType'
end end
object XDataWebDataSet1SQL: TStringField object XDataWebDataSet1SQL: TStringField
FieldName = 'SQL' FieldName = 'SQL'
end end
end end
object WebDataSource1: TWebDataSource object wdsOrders: TWebDataSource
DataSet = XDataWebDataSet1 DataSet = xdwdsOrders
Left = 120 Left = 120
Top = 410 Top = 410
end end
......
<!-- <div class="container vh-100 d-flex flex-column pb-5" style="max-width: 80%;"> --> <div class="container h-100 d-flex flex-column mt-0" style="max-width: 95%;">
<!-- Alert Section --> <!-- Alert Section -->
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-12 col-md-8"> <div class="col-12 col-md-8">
...@@ -50,7 +49,10 @@ ...@@ -50,7 +49,10 @@
<button id="btnsetstatus" class="btn btn-secondary mt-3">Set Status</button> <button id="btnsetstatus" class="btn btn-secondary mt-3">Set Status</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btngeneratepdf" class="btn btn-secondary mt-3">Generate PDF</button> <button id="btngeneratepdf" class="btn btn-secondary mt-3" type="button">Generate PDF</button>
<div class="invalid-feedback">
No order selected. Please select an order to generate a PDF.
</div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btnfilters" class="btn btn-secondary mt-3">Filters</button> <button id="btnfilters" class="btn btn-secondary mt-3">Filters</button>
...@@ -58,57 +60,33 @@ ...@@ -58,57 +60,33 @@
</div> </div>
</div> </div>
<!-- Entries Label Section --> <!-- Entries Label Section -->
<div class="container mt-2"> <div class="d-flex justify-content-between w-100 mt-2">
<div class="row"> <label id="lblentries"></label>
<div class="col">
<label id="lblentries"></label>
</div>
</div>
</div> </div>
<!-- Table Section --> <!-- Table Section -->
<div id="order_table_section" class="overflow-auto mt-2 flex-grow-1"> <div id="order_table_section" class="overflow-auto mt-2"
style="max-height: calc(100vh - 380px); border-bottom: none; padding-bottom: 0;">
<table id="tblPhoneGrid" class="table table-striped table-bordered"> <table id="tblPhoneGrid" class="table table-striped table-bordered">
<thead style="position: sticky; top: 0; z-index: 1; background-color: white; border-bottom: 2px solid #dee2e6;"> <thead class="sticky-top bg-light">
<tr> <tr style="font-size: 0.875rem;">
<th>Order ID</th> <!-- Table headers are dynamically generated -->
<th>Company Name</th>
<th>Job Name</th>
<th>Order Date</th>
<th>Proof Due</th>
<th>Proof Date</th>
<th>Art Due</th>
<th>Art Done</th>
<th>Plate Due</th>
<th>Plate Done</th>
<th>Mount Due</th>
<th>Mount Done</th>
<th>Ship Due</th>
<th>Ship Done</th>
<th>Price</th>
<th>QuickBooks Ref Number</th>
<th>Colors</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="orderTableBody" class="align-middle">
<!-- Rows will be dynamically added --> <!-- Table rows are dynamically generated -->
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Pagination Section --> <!-- Pagination Section -->
<div class="container mt-4"> <div class="d-flex justify-content-center w-100 mt-4">
<div class="row justify-content-center"> <nav aria-label="Page navigation">
<nav aria-label="Page navigation"> <ul id="pagination" class="pagination">
<ul id="pagination" class="pagination"> <!-- Pagination items added dynamically -->
<!-- Pagination items added dynamically --> </ul>
</ul> </nav>
</nav>
</div>
</div> </div>
</div> </div>
......
...@@ -279,6 +279,20 @@ input[type="text"] { ...@@ -279,6 +279,20 @@ input[type="text"] {
color: #fff !important; color: #fff !important;
} }
.card {
border: none !important;
box-shadow: none !important; /* If shadow is causing the issue */
}
.color-column {
width: 200px; /* Fixed width for the column */
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis; /* Adds ellipsis */
}
.grid-container { .grid-container {
position: relative; /* Ensure the container is the reference for child positioning */ position: relative; /* Ensure the container is the reference for child positioning */
......
object KGOrdersDatabase: TKGOrdersDatabase object ApiDatabase: TApiDatabase
OnCreate = DataModuleCreate OnCreate = DataModuleCreate
Height = 358 Height = 358
Width = 519 Width = 519
......
// Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info // Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info
// from the data base and send it to the client. // from the data base and send it to the client.
// Author: ??? // Author: ???
unit KGOrders.Database; unit Api.Database;
interface interface
...@@ -11,7 +11,7 @@ uses ...@@ -11,7 +11,7 @@ uses
Common.Logging, Vcl.Forms, MySQLUniProvider; Common.Logging, Vcl.Forms, MySQLUniProvider;
type type
TKGOrdersDatabase = class(TDataModule) TApiDatabase = class(TDataModule)
ucKG: TUniConnection; ucKG: TUniConnection;
UniQuery1: TUniQuery; UniQuery1: TUniQuery;
MySQLUniProvider1: TMySQLUniProvider; MySQLUniProvider1: TMySQLUniProvider;
...@@ -113,79 +113,35 @@ type ...@@ -113,79 +113,35 @@ type
end; end;
var var
KGOrdersDatabase: TKGOrdersDatabase; ApiDatabase: TApiDatabase;
implementation implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'} {%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm} {$R *.dfm}
procedure TKGOrdersDatabase.DataModuleCreate(Sender: TObject); procedure TApiDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
begin begin
Logger.Log( 5, 'TKGOrdersDatabase.DataModuleCreate' ); Logger.Log( 3, 'TApiDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try try
Logger.Log( 5, '--iniFile entries:' ); ucKG.Connect;
iniStr := iniFile.ReadString('Database', 'Server', ''); except
if iniStr.IsEmpty then on E: Exception do
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Server: ' + iniStr );
ucKG.Server := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Database: ' + iniStr );
ucKG.Database := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin begin
Logger.Log( 5, '----Database->Username: ' + iniStr ); Logger.Log(3, '--TApiDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
ucKG.Username := iniStr;
end; end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TKGOrdersDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
iniFile.Free;
end; end;
end; end;
class procedure TKGOrdersDatabase.ExecSQL(const SQL: string); class procedure TApiDatabase.ExecSQL(const SQL: string);
var var
DB: TKGOrdersDatabase; DB: TApiDatabase;
begin begin
DB := TKGOrdersDatabase.Create(nil); DB := TApiDatabase.Create(nil);
try try
DB.UniQuery1.SQL.Text := SQL; DB.UniQuery1.SQL.Text := SQL;
DB.UniQuery1.ExecSQL; DB.UniQuery1.ExecSQL;
......
...@@ -2,12 +2,10 @@ object ApiServerModule: TApiServerModule ...@@ -2,12 +2,10 @@ object ApiServerModule: TApiServerModule
Height = 273 Height = 273
Width = 230 Width = 230
object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher
Active = True
Left = 86 Left = 86
Top = 30 Top = 30
end end
object XDataServer: TXDataServer object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/api/'
Dispatcher = SparkleHttpSysDispatcher Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api' ModelName = 'Api'
EntitySetPermissions = <> EntitySetPermissions = <>
......
...@@ -38,62 +38,16 @@ uses ...@@ -38,62 +38,16 @@ uses
{$R *.dfm} {$R *.dfm}
procedure TAuthDatabase.DataModuleCreate(Sender: TObject); procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
begin begin
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' ); Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try try
Logger.Log( 5, '--iniFile entries:' ); ucKG.Connect;
iniStr := iniFile.ReadString('Database', 'Server', ''); except
if iniStr.IsEmpty then on E: Exception do
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Server: ' + iniStr );
ucKG.Server := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Database: ' + iniStr );
ucKG.Database := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin begin
Logger.Log( 5, '----Database->Username: ' + iniStr ); Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
ucKG.Username := iniStr;
end; end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
iniFile.Free;
end; end;
end; end;
......
...@@ -6,7 +6,6 @@ object AuthServerModule: TAuthServerModule ...@@ -6,7 +6,6 @@ object AuthServerModule: TAuthServerModule
Top = 16 Top = 16
end end
object XDataServer: TXDataServer object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/auth/'
Dispatcher = SparkleHttpSysDispatcher Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Auth' ModelName = 'Auth'
EntitySetPermissions = <> EntitySetPermissions = <>
......
...@@ -47,7 +47,7 @@ object FData: TFData ...@@ -47,7 +47,7 @@ object FData: TFData
object DBAdvGrid1: TDBAdvGrid object DBAdvGrid1: TDBAdvGrid
Left = 6 Left = 6
Top = 84 Top = 84
Width = 632 Width = 689
Height = 154 Height = 154
ColCount = 11 ColCount = 11
DrawingStyle = gdsClassic DrawingStyle = gdsClassic
...@@ -628,7 +628,7 @@ object FData: TFData ...@@ -628,7 +628,7 @@ object FData: TFData
object DBAdvGrid2: TDBAdvGrid object DBAdvGrid2: TDBAdvGrid
Left = 6 Left = 6
Top = 237 Top = 237
Width = 631 Width = 985
Height = 199 Height = 199
ColCount = 20 ColCount = 20
DrawingStyle = gdsClassic DrawingStyle = gdsClassic
...@@ -1495,6 +1495,15 @@ object FData: TFData ...@@ -1495,6 +1495,15 @@ object FData: TFData
TabOrder = 10 TabOrder = 10
TextHint = 'Email Address' TextHint = 'Email Address'
end end
object btnPDF: TButton
Left = 330
Top = 38
Width = 75
Height = 25
Caption = 'Preview PDF'
TabOrder = 11
OnClick = btnPDFClick
end
object dsUsers: TDataSource object dsUsers: TDataSource
DataSet = uqUsers DataSet = uqUsers
Left = 482 Left = 482
......
...@@ -14,7 +14,7 @@ uses ...@@ -14,7 +14,7 @@ uses
BaseGrid, AdvGrid, DBAdvGrid, MemDS, DBAccess, Uni, Vcl.StdCtrls, Vcl.Mask, BaseGrid, AdvGrid, DBAdvGrid, MemDS, DBAccess, Uni, Vcl.StdCtrls, Vcl.Mask,
vcl.wwdbedit, vcl.wwdotdot, vcl.wwdbcomb, REST.Client, REST.Types, System.JSON, vcl.wwdbedit, vcl.wwdotdot, vcl.wwdbcomb, REST.Client, REST.Types, System.JSON,
System.Generics.Collections, AdvEdit, vcl.wwdblook, vcl.wwdbdatetimepicker, System.Generics.Collections, AdvEdit, vcl.wwdblook, vcl.wwdbdatetimepicker,
System.Hash; System.Hash, Api.Database;
type type
TFData = class(TForm) TFData = class(TForm)
...@@ -34,14 +34,16 @@ type ...@@ -34,14 +34,16 @@ type
edtFullName: TEdit; edtFullName: TEdit;
edtPhoneNumber: TEdit; edtPhoneNumber: TEdit;
edtEmailAddress: TEdit; edtEmailAddress: TEdit;
btnPDF: TButton;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure btnFindClick(Sender: TObject); procedure btnFindClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject);
private private
{ Private declarations } kgDB: TApiDatabase;
accountSID: string; accountSID: string;
authHeader: string; authHeader: string;
public public
{ Public declarations } function GetReportPDF(OrderID: string): string;
end; end;
var var
...@@ -51,11 +53,17 @@ implementation ...@@ -51,11 +53,17 @@ implementation
{$R *.dfm} {$R *.dfm}
uses KGOrders.Database, uLibrary; uses uLibrary, rOrders;
procedure TFData.btnPDFClick(Sender: TObject);
begin
GetReportPDF('');
end;
procedure TFData.FormCreate(Sender: TObject); procedure TFData.FormCreate(Sender: TObject);
begin begin
KGOrdersDatabase := TKGOrdersDatabase.Create(Self); kgDB := TApiDatabase.Create(Self);
end; end;
procedure TFData.btnFindClick(Sender: TObject); procedure TFData.btnFindClick(Sender: TObject);
...@@ -76,4 +84,29 @@ begin ...@@ -76,4 +84,29 @@ begin
end; end;
function TFData.GetReportPDF(OrderID: string): string;
var
rptOrders: TrptOrders; // Local instance
OrderIDList: TStringList;
begin
rptOrders := TrptOrders.Create(nil); // Always create locally
try
// Create a list of hardcoded OrderIDs for testing
OrderIDList := TStringList.Create;
try
OrderIDList.Add('18995');
OrderIDList.Add('18994');
OrderIDList.Add('18993'); // Add more OrderIDs as needed
// Generate the PDF Report with the list of OrderIDs
rptOrders.GenerateSimpleReport(350);
finally
OrderIDList.Free; // Free the TStringList
end;
finally
rptOrders.Free; // Ensure rptOrders is freed
end;
end;
end. end.
...@@ -209,6 +209,8 @@ type ...@@ -209,6 +209,8 @@ type
[HttpGet] function GetOrder(orderInfo: string): TFullOrder; [HttpGet] function GetOrder(orderInfo: string): TFullOrder;
[HttpGet] function GetCustomers(): TCustomerList; [HttpGet] function GetCustomers(): TCustomerList;
[HttpGet] function GetCustomer(ID: string): TCustomerItem; [HttpGet] function GetCustomer(ID: string): TCustomerItem;
[HttpGet] procedure GenerateReportPDF(searchOptions: string);
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string; function AddItem(itemInfo: string): string;
......
...@@ -41,7 +41,7 @@ uses ...@@ -41,7 +41,7 @@ uses
Common.Logging, Common.Logging,
Common.Config, Common.Config,
Sparkle.Utils, Sparkle.Utils,
KGOrders.Database, Api.Database,
Data; Data;
{$R *.dfm} {$R *.dfm}
...@@ -110,7 +110,7 @@ begin ...@@ -110,7 +110,7 @@ begin
try try
Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrders.dpr, it executes first' ); Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrdersServer.dpr, it executes first' );
iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' ); iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' );
if iniStr.IsEmpty then if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' ) Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' )
...@@ -130,11 +130,29 @@ begin ...@@ -130,11 +130,29 @@ begin
else else
Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) ); Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
Logger.Log( 1, '' );
iniStr := IniFile.ReadString( 'Database', 'Server', '' ); iniStr := IniFile.ReadString( 'Database', 'Server', '' );
if iniStr.IsEmpty then if iniStr.IsEmpty then
Logger.Log( 1, '--Database->Server: Entry not found' ) Logger.Log( 1, '--Database->Server: Entry not found' )
else else
Logger.Log( 1, '--Database->Server: ' + iniStr ); Logger.Log( 1, '--Database->Server: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Database: Entry not found' )
else
Logger.Log( 1, '----Database->Database: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Username: Entry not found' )
else
Logger.Log( 1, '----Database->Username: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Password: Entry not found' )
else
Logger.Log( 1, '----Database->Password: xxxxxxxx' );
Logger.Log( 1, '' ); Logger.Log( 1, '' );
finally finally
...@@ -149,6 +167,8 @@ begin ...@@ -149,6 +167,8 @@ begin
AppServerModule := TAppServerModule.Create(Self); AppServerModule := TAppServerModule.Create(Self);
AppServerModule.StartAppServer( serverConfig.url ); AppServerModule.StartAppServer( serverConfig.url );
UpdateGUI;
end; end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction); procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
...@@ -160,9 +180,6 @@ begin ...@@ -160,9 +180,6 @@ begin
end; end;
procedure TFMain.UpdateGUI; procedure TFMain.UpdateGUI;
const
cHttp = 'http://+';
cHttpLocalhost = 'http://localhost';
begin begin
if AuthServerModule.SparkleHttpSysDispatcher.Active then if AuthServerModule.SparkleHttpSysDispatcher.Active then
memoInfo.Lines.Add( 'AuthServer started at: ' + AuthServerModule.XDataServer.BaseUrl ) memoInfo.Lines.Add( 'AuthServer started at: ' + AuthServerModule.XDataServer.BaseUrl )
......
unit rOrders;
interface
uses
System.SysUtils, System.Classes, frxClass, frxExportBaseDialog, frxExportPDF,
Data.DB, DBAccess, Uni, UniProvider, MySQLUniProvider, System.IniFiles, Vcl.Forms,
MemDS, frxDBSet, frxTableObject, frCoreClasses, Common.Logging, System.IOUtils;
type
TrptOrders = class(TDataModule)
frxOrders: TfrxReport;
frxPDFExport1: TfrxPDFExport;
ucKG: TUniConnection;
uqOrders: TUniQuery;
frxReportTableObject1: TfrxReportTableObject;
frxDBOrders: TfrxDBDataset;
procedure DataModuleCreate(Sender: TObject);
private
public
procedure GenerateSimpleReport(OrderID: Integer);
procedure PrepareReport(const SQL: string);
procedure GeneratePDF;
end;
var
rptOrders: TrptOrders;
implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
procedure TrptOrders.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TrptOrders.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
end;
procedure TrptOrders.GenerateSimpleReport(OrderID: Integer);
begin
try
Logger.Log(5, 'Generating Report for Order ID: ' + OrderID.ToString);
uqOrders.Close;
uqOrders.SQL.Text := 'SELECT ORDER_ID FROM corrugated_plate_orders WHERE ORDER_ID = :OrderID';
uqOrders.ParamByName('OrderID').AsInteger := OrderID;
try
uqOrders.Open;
except
on E: Exception do
begin
Logger.Log(1, 'Error executing query: ' + E.Message);
Exit;
end;
end;
frxOrders.PrepareReport;
frxOrders.ShowReport;
finally
uqOrders.Close;
frxOrders.Clear;
Logger.Log(5, 'Report generation complete for Order ID: ' + OrderID.ToString);
end;
end;
procedure TrptOrders.PrepareReport(const SQL: string);
begin
// Prepare and load data into the query
uqOrders.Close;
uqOrders.SQL.Text := SQL;
uqOrders.Open;
end;
procedure TrptOrders.GeneratePDF;
var
ReportDir, ReportFileName: string;
begin
ReportDir := 'C:\Projects\KGOrders\Reports';
// Define output file
ReportFileName := TPath.Combine(ReportDir, 'OrderReport_' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.pdf');
// Prepare and export the report
frxOrders.PrepareReport;
frxPDFExport1.FileName := ReportFileName;
frxPDFExport1.ShowDialog := False;
frxOrders.Export(frxPDFExport1);
frxOrders.ShowPreparedReport;
Logger.Log(5, 'PDF saved to: ' + ReportFileName);
end;
end.
...@@ -5,46 +5,43 @@ interface ...@@ -5,46 +5,43 @@ interface
uses uses
System.Classes, Uni; System.Classes, Uni;
const procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
ADD_REC_AUDIT_ENTRY = '0';
EDIT_REC_AUDIT_ENTRY = '1';
DEL_REC_AUDIT_ENTRY = '2';
REVIEW_REC_AUDIT_ENTRY = '3';
VIEW_REC_AUDIT_ENTRY = '4';
FIND_REC_AUDIT_ENTRY = '5';
PRINT_REC_AUDIT_ENTRY = '6';
OTHER_REC_AUDIT_ENTRY = '99';
function GetServerTimeStamp( uq: TUniQuery ): TDateTime;
procedure DoQuery( uq: TUniQuery; sql: string ); procedure DoQuery( uq: TUniQuery; sql: string );
function CalculateAge( const dob, dt: TDateTime ): Integer; function CalculateAge( const dob, dt: TDateTime ): Integer;
function GetNextSeqVal( uq: TUniQuery; sequence: string ): string;
function FormatNamePersonnel( uq: TUniQuery; format: string ): string;
function FormatBkNum( bkNum: string ): string;
function GetAssociatedNumber( uq: TUniQuery; numberType: string ): string;
function FormatBookingAddress( uq: TUniQuery; format: string ): string;
function SetMasterAuditEntry( uq: TUniQuery; const entryId, auditType, linkId, agency, personnelId, recUser, details, searchKey, execSource: string ): Boolean;
function SetDetailAuditEntry( uq: TUniQuery; const entryId, title, auditType: string; auditList: TStringList ): Boolean;
function GetOfficerName( agency, officer: string; uq: TUniQuery ): string;
function GetRiciOfficerName( agency, officer: string; uq: TUniQuery ): string;
implementation implementation
uses uses
System.SysUtils, System.SysUtils,
System.IniFiles,
Vcl.Forms,
Data.DB; Data.DB;
function GetServerTimeStamp( uq: TUniQuery ): TDateTime; procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
var var
sql: string; iniFile: TIniFile;
serverDateTime: TDateTime; iniStr: string;
begin begin
sql := 'select sysdate as currentdatetime from dual'; iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + iniFilename );
try
DoQuery( uq, sql ); iniStr := iniFile.ReadString('Database', 'Server', '');
serverDateTime := uq.FieldByName('CURRENTDATETIME').AsDateTime; if not iniStr.IsEmpty then
uq.Close; uc.Server := iniStr;
Result := serverDateTime;
iniStr := iniFile.ReadString('Database', 'Database', '');
if not iniStr.IsEmpty then
uc.Database := iniStr;
iniStr := iniFile.ReadString('Database', 'Username', '');
if not iniStr.IsEmpty then
uc.Username := iniStr;
iniStr := iniFile.ReadString('Database', 'Password', '');
if not iniStr.IsEmpty then
uc.Password := iniStr;
finally
iniFile.Free;
end;
end; end;
procedure DoQuery(uq: TUniQuery; sql: string); procedure DoQuery(uq: TUniQuery; sql: string);
...@@ -82,204 +79,5 @@ begin ...@@ -82,204 +79,5 @@ begin
Result := age Result := age
end; end;
function GetNextSeqVal(uq: TUniQuery; sequence: string ): string;
var
sql: string;
begin
sql := 'select ' + sequence + '.NEXTVAL as nextseqval from dual';
uq.Close;
uq.SQL.Text := sql;
uq.Open;
Result := uq.FieldByName('NEXTSEQVAL').AsString;
end;
function FormatNamePersonnel( uq: TUniQuery; format: string ): string;
var
leng: Integer;
i: Integer;
officerText: String;
begin
leng := Length( format );
for i := 0 to leng - 1 do
begin
case format[i+1] of
'S':
officerText := officerText + uq.FieldByName('PF_LNAME').AsString;
'F':
if not uq.FieldByName('PF_FNAME').AsString.IsEmpty then
officerText := TrimRight( officerText + uq.FieldByName('PF_FNAME').AsString ) ;
'M':
if not uq.FieldByName('PF_MI').AsString.IsEmpty then
officerText := TrimRight( officerText + uq.FieldByName('PF_MI').AsString );
',':
officerText := officerText + ',';
'.':
officerText := officerText + '.';
' ':
officerText := officerText + ' ';
end;
end;
Result := officerText;
end;
function FormatBkNum( bkNum: string ): string;
var
bkNumStr: string;
begin
bkNumStr := bkNum;
Result := bkNumStr.Insert( 4, '-' );
end;
function GetAssociatedNumber( uq: TUniQuery; numberType: string): string;
var
TLocateOptions: set of TLocateOption;
begin
if uq.Locate('OTHER_AGENCY_CODE', numberType, TLocateOptions)
then Result := uq.FieldByName('IDENTIFICATION').AsString
end;
function FormatBookingAddress( uq: TUniQuery; format: string ): string;
var
addressText: AnsiString;
leng: Integer;
i : Integer;
begin
leng := Length( format );
for i := 0 to leng - 1 do
begin
case format[i+1] of
'S':
begin
addressText := addressText + uq.FieldByName('STREET_NUM').AsString;
if uq.FieldByName('STREET_NUM_HALF').AsString = 'Y' then
addressText := addressText + ' 1/2';
if uq.FieldByName('STREET_DIRECTION').AsString <> '' then
addressText := addressText + ' ' + uq.FieldByName('STREET_DIRECTION').AsString;
if uq.FieldByName('STREET_NAME').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STREET_NAME').AsString );
if uq.FieldByName('STREET_TYPE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STREET_TYPE').AsString );
if uq.FieldByName('APARTMENT_NUM').AsString <> '' then
addressText := addressText + ' APT: ' + TrimRight( uq.FieldByName('APARTMENT_NUM').AsString );
end;
'C':
if uq.FieldByName('CITY').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('CITY').AsString );
'T':
if uq.FieldByName('STATE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STATE').AsString );
'Z':
if uq.FieldByName('ZIP_CODE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('ZIP_CODE').AsString );
'R':
if uq.FieldByName('COUNTRY').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('COUNTRY').AsString );
',':
addressText := addressText + ',';
'.':
addressText := addressText + '.';
' ':
addressText := addressText + ' ';
end;
end;
Result := addressText;
end;
function SetMasterAuditEntry(uq: TUniQuery; const entryId, auditType, linkId, agency, personnelId, recUser, details, searchKey, execSource: string) : Boolean;
var
sql: string;
begin
sql := 'insert into auditmaster ';
sql := sql + '( AUDITMASTERID, SOURCEID, AUDITTYPE, AGENCY, PERSONNELID, RECUSER, RECDATE, DETAILS, SEARCHKEY, EXECSRC) ';
sql := sql + 'values (';
sql := sql + entryID + ', ';
sql := sql + QuotedStr(linkID) + ', ';
sql := sql + QuotedStr(auditType) + ', ';
sql := sql + QuotedStr(agency) + ', ';
sql := sql + personnelid + ', ';
sql := sql + QuotedStr(recUser) + ', ';
sql := sql + 'sysdate, ';
sql := sql + QuotedStr(details) + ', ';
sql := sql + QuotedStr(searchKey) + ', ';
sql := sql + QuotedStr(execSource) + ')';
uq.Close;
uq.SQL.Text := sql;
uq.Execute;
uq.Close;
Result := True;
end;
function SetDetailAuditEntry(uq: TUniQuery; const entryId, title, auditType: string; auditList: TStringList) : Boolean;
var
i: Integer;
sql: string;
begin
for i := 0 to auditList.Count - 1 do
begin
sql := 'insert into auditdetail values (';
sql := sql + entryId + ', ';
sql := sql + QuotedStr( auditList.Names[i] ) + ', ';
sql := sql + QuotedStr( '' ) + ', ';
sql := sql + QuotedStr( auditList.ValueFromIndex[i] ) + ', ';
sql := sql + auditType + ')';
uq.Close;
uq.SQL.Text := sql;
uq.Execute;
uq.Close;
end;
Result := True;
end;
function GetOfficerName( agency, officer: string; uq: TUniQuery ): string;
var
sql: string;
begin
if agency.IsEmpty or officer.IsEmpty then
Exit;
sql := 'select a.agency_id, p.agency, p.pf_nameid, pf_lname, pf_fname, pf_mi, pf_badge ';
sql := sql + 'from personnel p ';
sql := sql + 'join agencycodes a on a.agency = p.agency ';
sql := sql + 'where a.agency_id = ' + agency + ' and p.pf_nameid = ' + officer;
uq.Close;
uq.SQL.Text := sql;
uq.Open;
if uq.IsEmpty then
Result := agency + '-' + officer + ': not found'
else
begin
Result := uq.FieldByName('pf_lname').AsString + ', ' + uq.FieldByName('pf_fname').AsString;
Result := Result + ' ' + uq.FieldByName('pf_mi').AsString + ' (' + uq.FieldByName('pf_badge').AsString + ')';
end;
end;
function GetRiciOfficerName( agency, officer: string; uq: TUniQuery ): string;
var
sql: string;
begin
if agency.IsEmpty or officer.IsEmpty then
Exit;
sql := 'select * from rici.officer@rici_link where agency = ' + agency + ' and empno = ' + QuotedStr(officer);
uq.Close;
uq.SQL.Text := sql;
uq.Open;
if uq.IsEmpty then
Result := agency + '-' + officer + ': not found'
else
Result := uq.FieldByName('surname').AsString + ', ' + uq.FieldByName('given1').AsString + ' (' + uq.FieldByName('empno').AsString + ')';
end;
end. end.
...@@ -9,7 +9,7 @@ uses ...@@ -9,7 +9,7 @@ uses
Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule}, Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule},
Main in 'Source\Main.pas' {FMain}, Main in 'Source\Main.pas' {FMain},
Common.Logging in 'Source\Common.Logging.pas', Common.Logging in 'Source\Common.Logging.pas',
KGOrders.Database in 'Source\KGOrders.Database.pas' {KGOrdersDatabase: TDataModule}, Api.Database in 'Source\Api.Database.pas' {ApiDatabase: TDataModule},
Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas', Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas',
Common.Config in 'Source\Common.Config.pas', Common.Config in 'Source\Common.Config.pas',
Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule}, Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule},
...@@ -20,7 +20,8 @@ uses ...@@ -20,7 +20,8 @@ uses
Auth.ServiceImpl in 'Source\Auth.ServiceImpl.pas', Auth.ServiceImpl in 'Source\Auth.ServiceImpl.pas',
Lookup.ServiceImpl in 'Source\Lookup.ServiceImpl.pas', Lookup.ServiceImpl in 'Source\Lookup.ServiceImpl.pas',
App.Server.Module in 'Source\App.Server.Module.pas' {AppServerModule: TDataModule}, App.Server.Module in 'Source\App.Server.Module.pas' {AppServerModule: TDataModule},
Data in 'Source\Data.pas' {FData}; Data in 'Source\Data.pas' {FData},
rOrders in 'Source\rOrders.pas' {rptOrders: TDataModule};
type type
TMemoLogAppender = class( TInterfacedObject, ILogAppender ) TMemoLogAppender = class( TInterfacedObject, ILogAppender )
...@@ -37,7 +38,7 @@ type ...@@ -37,7 +38,7 @@ type
TFileLogAppender = class( TInterfacedObject, ILogAppender ) TFileLogAppender = class( TInterfacedObject, ILogAppender )
private private
FLogLevel: Integer; FLogLevel: Integer;
FFilename: string; FLogFile: string;
FCriticalSection: TCriticalSection; FCriticalSection: TCriticalSection;
public public
constructor Create(ALogLevel: Integer; AFilename: string); constructor Create(ALogLevel: Integer; AFilename: string);
...@@ -89,14 +90,18 @@ constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string); ...@@ -89,14 +90,18 @@ constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string);
var var
iniFile: TIniFile; iniFile: TIniFile;
fileNum: integer; fileNum: integer;
logsDir: string;
begin begin
FLogLevel := ALogLevel; FLogLevel := ALogLevel;
FCriticalSection := TCriticalSection.Create; FCriticalSection := TCriticalSection.Create;
logsDir := ExtractFilePath(Application.ExeName) + 'logs\';
if not DirectoryExists(logsDir) then
CreateDir(logsDir);
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try try
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 ); fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
// FFilename := AFilename + Format('%.*d',[4, fileNum]); FLogFile := logsDir + AFilename + Format( '%.4d', [fileNum] ) + '.log';
FFilename := AFilename + Format('%.4d',[fileNum]);
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 ); iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally finally
iniFile.Free; iniFile.Free;
...@@ -111,35 +116,33 @@ end; ...@@ -111,35 +116,33 @@ end;
procedure TFileLogAppender.Send(logLevel: integer; Log: ILog); procedure TFileLogAppender.Send(logLevel: integer; Log: ILog);
var var
FormattedMessage: string; formattedMessage: string;
LogFile: string; logTime: TDateTime;
LogTime: TDateTime; logMsg: string;
LogMsg: string; txtFile: TextFile;
FLogFile: TextFile;
begin begin
FCriticalSection.Acquire; FCriticalSection.Acquire;
try try
LogTime := Now; logTime := Now;
LogFile := ExtractFilePath(Application.ExeName) + FFilename + '.log';
FormattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', LogTime); formattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', logTime);
LogMsg := Log.GetMessage; logMsg := Log.GetMessage;
if LogMsg.IsEmpty then if logMsg.IsEmpty then
FormattedMessage := '' formattedMessage := ''
else else
FormattedMessage := FormattedMessage + '[' + IntToStr(logLevel) +'] ' + LogMsg; formattedMessage := formattedMessage + '[' + IntToStr(logLevel) +'] ' + logMsg;
try try
AssignFile( FLogFile, LogFile ); AssignFile( txtFile, FLogFile );
if FileExists(LogFile) then if FileExists(FLogFile) then
Append( FLogFile ) Append( txtFile )
else else
ReWrite( FLogFile ); ReWrite( txtFile );
if logLevel <= FLogLevel then if logLevel <= FLogLevel then
WriteLn( FLogFile, FormattedMessage ); WriteLn( txtFile, formattedMessage );
finally finally
CloseFile(FLogFile); CloseFile(txtFile);
end; end;
finally finally
FCriticalSection.Release; FCriticalSection.Release;
......
...@@ -133,8 +133,8 @@ ...@@ -133,8 +133,8 @@
<Form>FMain</Form> <Form>FMain</Form>
</DCCReference> </DCCReference>
<DCCReference Include="Source\Common.Logging.pas"/> <DCCReference Include="Source\Common.Logging.pas"/>
<DCCReference Include="Source\KGOrders.Database.pas"> <DCCReference Include="Source\Api.Database.pas">
<Form>KGOrdersDatabase</Form> <Form>ApiDatabase</Form>
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass> <DesignClass>TDataModule</DesignClass>
</DCCReference> </DCCReference>
...@@ -164,6 +164,11 @@ ...@@ -164,6 +164,11 @@
<Form>FData</Form> <Form>FData</Form>
<FormType>dfm</FormType> <FormType>dfm</FormType>
</DCCReference> </DCCReference>
<DCCReference Include="Source\rOrders.pas">
<Form>rptOrders</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
......
[Settings] [Settings]
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=5 FileLogLevel=5
LogFileNum=36 LogFileNum=30
webClientVersion=1.0.0 webClientVersion=1.0.0
[Database] [Database]
Server=192.168.159.132 --Server=192.168.159.132
--Server=192.168.198.131 Server=192.168.60.129
--Server=192.168.75.133 --Server=192.168.75.133
--Database= --Database=
--Username= --Username=
--Password= Password=emsys!012
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment