Commit 3ff5c8d6 by Elias Sarraf

Merge remote-tracking branch 'origin/mac'

parents bb05403e 0565250e
...@@ -26,7 +26,6 @@ object FAddOrder: TFAddOrder ...@@ -26,7 +26,6 @@ object FAddOrder: TFAddOrder
Width = 121 Width = 121
Height = 22 Height = 22
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Text = 'edtSearch'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = edtSearchChange OnChange = edtSearchChange
end end
...@@ -37,14 +36,14 @@ object FAddOrder: TFAddOrder ...@@ -37,14 +36,14 @@ object FAddOrder: TFAddOrder
Height = 22 Height = 22
ChildOrder = 1 ChildOrder = 1
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Text = 'WebEdit1'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object TMSFNCGrid1: TTMSFNCGrid object TMSFNCGrid1: TTMSFNCGrid
Left = 0 Left = 0
Top = 166 Top = 146
Width = 871 Width = 871
Height = 303 Height = 331
Align = alBottom
ParentDoubleBuffered = False ParentDoubleBuffered = False
DoubleBuffered = True DoubleBuffered = True
TabOrder = 2 TabOrder = 2
...@@ -242,13 +241,13 @@ object FAddOrder: TFAddOrder ...@@ -242,13 +241,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
...@@ -265,7 +264,7 @@ object FAddOrder: TFAddOrder ...@@ -265,7 +264,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 ...'
...@@ -207,8 +207,8 @@ object FViewOrders: TFViewOrders ...@@ -207,8 +207,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
...@@ -221,73 +221,181 @@ object FViewOrders: TFViewOrders ...@@ -221,73 +221,181 @@ 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 XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
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
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"> <div class="row">
<div class="col-sm"> <div class="col-sm">
...@@ -46,7 +45,10 @@ ...@@ -46,7 +45,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>
...@@ -54,57 +56,33 @@ ...@@ -54,57 +56,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 */
......
...@@ -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
......
...@@ -34,14 +34,15 @@ type ...@@ -34,14 +34,15 @@ 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 }
accountSID: string; accountSID: string;
authHeader: string; authHeader: string;
public public
{ Public declarations } function GetReportPDF(OrderID: string): string;
end; end;
var var
...@@ -51,7 +52,13 @@ implementation ...@@ -51,7 +52,13 @@ implementation
{$R *.dfm} {$R *.dfm}
uses KGOrders.Database, uLibrary; uses KGOrders.Database, uLibrary, rOrders;
procedure TFData.btnPDFClick(Sender: TObject);
begin
GetReportPDF('');
end;
procedure TFData.FormCreate(Sender: TObject); procedure TFData.FormCreate(Sender: TObject);
begin begin
...@@ -76,4 +83,30 @@ begin ...@@ -76,4 +83,30 @@ 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;
......
...@@ -11,8 +11,14 @@ interface ...@@ -11,8 +11,14 @@ interface
uses uses
XData.Server.Module, XData.Server.Module,
XData.Service.Common, XData.Service.Common,
KGOrders.Database, Data.DB, KGOrders.Database, Data.DB, frxClass, frxExportPDF,
Lookup.Service, System.Hash, System.Classes, System.JSON; Lookup.Service, System.Hash, System.JSON, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, MemDS, DBAccess, Uni,
hyiedefs, hyieutils, iexBitmaps, iesettings, iexLayers, iexRulers,
iexToolbars, iexUserInteractions, imageenio, imageenproc, QuickRpt, QRCtrls,
dbimageen, Vcl.ExtCtrls, ieview, imageenview, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP,
iexProcEffects, frxDBSet, frxExportBaseDialog, frCoreClasses, rOrders, Common.Logging;
type type
...@@ -29,6 +35,8 @@ type ...@@ -29,6 +35,8 @@ type
function GetCustomer(ID: string): TCustomerItem; function GetCustomer(ID: string): TCustomerItem;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function Search(phoneNum: string): TOrderList; function Search(phoneNum: string): TOrderList;
procedure GenerateReportPDF(searchOptions: string);
function BuildOrderQuery(searchOptions: string): string;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string; function AddItem(itemInfo: string): string;
function DelUser(username: string): string; function DelUser(username: string): string;
...@@ -44,7 +52,6 @@ type ...@@ -44,7 +52,6 @@ type
implementation implementation
uses uses
System.SysUtils,
System.Generics.Collections, System.Generics.Collections,
XData.Sys.Exceptions, uLibrary; XData.Sys.Exceptions, uLibrary;
...@@ -156,6 +163,113 @@ begin ...@@ -156,6 +163,113 @@ begin
end; end;
procedure TLookupService.GenerateReportPDF(searchOptions: string);
var
SQL: string;
rptOrders: TrptOrders; // Local instance of rptOrders
begin
// Create instance of rptOrders
rptOrders := TrptOrders.Create(nil);
try
// Generate SQL dynamically using the existing GetOrders logic
SQL := BuildOrderQuery(searchOptions);
// Prepare the report dataset
rptOrders.PrepareReport(SQL);
// Generate the PDF report
rptOrders.GeneratePDF;
// Optionally, log success
Logger.log(5, 'PDF Report successfully generated for searchOptions: ' + searchOptions);
finally
rptOrders.Free; // Ensure proper cleanup
end;
end;
function TLookupService.BuildOrderQuery(searchOptions: string): string;
var
params: TStringList;
PageNum, PageSize: integer;
startDate, endDate, filterType, statusType, statusSuffix: string;
statusTableShort, statusTableLong, whereSQL, SQL: string;
begin
params := TStringList.Create;
try
params.StrictDelimiter := true;
params.Delimiter := '&';
params.DelimitedText := searchOptions;
// Parse parameters
PageNum := StrToIntDef(params.Values['pagenumber'], 1);
PageSize := StrToIntDef(params.Values['pagesize'], 50);
startDate := params.Values['startDate'];
endDate := params.Values['endDate'];
filterType := params.Values['filterType'];
statusType := '';
statusSuffix := '';
if filterType <> '' then
begin
statusType := filterType.Split(['_'])[0];
statusSuffix := filterType.Split(['_'])[1];
filterType := statusType + '_' + statusSuffix;
end;
// Determine status table
if statusSuffix = 'DUE' then
begin
statusTableShort := 'oss';
statusTableLong := 'orders_status_schedule';
end
else
begin
statusTableShort := 'os';
statusTableLong := 'orders_status';
end;
// Build the SELECT query with dynamically generated subqueries
SQL := 'SELECT o.ORDER_ID, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, ';
// Add dynamically generated subqueries
SQL := SQL + generateSubQuery(filterType, statusType, 'PROOF');
SQL := SQL + generateSubQuery(filterType, statusType, 'ART');
SQL := SQL + generateSubQuery(filterType, statusType, 'PLATE');
SQL := SQL + generateSubQuery(filterType, statusType, 'MOUNT');
SQL := SQL + generateSubQuery(filterType, statusType, 'SHIP');
// Include additional static fields
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ';
// FROM clause
SQL := SQL + 'FROM orders o ' +
'JOIN customers c ON o.COMPANY_ID = c.CUSTOMER_ID ' +
'LEFT JOIN qb_sales_orders qb ON qb.ORDER_ID = o.ORDER_ID ';
// WHERE clause
whereSQL := 'WHERE 1=1 ';
if startDate <> '' then
whereSQL := whereSQL + ' AND o.ORDER_DATE >= ' + QuotedStr(startDate);
if endDate <> '' then
whereSQL := whereSQL + ' AND o.ORDER_DATE <= ' + QuotedStr(endDate);
if statusType <> '' then
whereSQL := whereSQL + ' AND ' + statusTableShort + '.ORDER_STATUS = ' + QuotedStr(statusType);
// Add WHERE and ORDER clauses
SQL := SQL + whereSQL +
' ORDER BY o.ORDER_DATE DESC ' +
' LIMIT ' + IntToStr(PageSize) +
' OFFSET ' + IntToStr((PageNum - 1) * PageSize);
Result := SQL;
Logger.log(5, 'Generated SQL in Build order Query: ' + SQL);
finally
params.Free;
end;
end;
function TLookupService.generateSelectSQL(filterType, startDate, endDate: string): string; function TLookupService.generateSelectSQL(filterType, startDate, endDate: string): string;
begin begin
...@@ -520,11 +634,9 @@ begin ...@@ -520,11 +634,9 @@ begin
result.general_special_instructions := ordersDB.UniQuery1.FieldByName('general_special_instructions').AsString result.general_special_instructions := ordersDB.UniQuery1.FieldByName('general_special_instructions').AsString
else else
//result.specialInstructions := ordersDB.UniQuery1.FieldByName('general_comments').AsString //result.specialInstructions := ordersDB.UniQuery1.FieldByName('general_comments').AsString
end; end;
function TLookupService.GetItems(searchOptions: string): TItemList; function TLookupService.GetItems(searchOptions: string): TItemList;
var var
params: TStringList; params: TStringList;
...@@ -988,6 +1100,8 @@ begin ...@@ -988,6 +1100,8 @@ begin
end; end;
end; end;
initialization initialization
RegisterServiceType(TLookupService); RegisterServiceType(TLookupService);
......
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
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
procedure TrptOrders.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
begin
// Load database connection settings from INI file
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
try
ucKG.Server := iniFile.ReadString('Database', 'Server', '');
ucKG.Connect;
finally
iniFile.Free;
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.
...@@ -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 )
......
...@@ -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>
......
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