Commit 39bcaa4d by Mac Stephens

Changed table to twebdbtablecontrol, still working on styling

parent 38b88255
...@@ -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,7 +207,7 @@ object FViewOrders: TFViewOrders ...@@ -207,7 +207,7 @@ object FViewOrders: TFViewOrders
TabStop = False TabStop = False
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebButton2: TWebButton object btnPDF: TWebButton
Left = 328 Left = 328
Top = 79 Top = 79
Width = 96 Width = 96
...@@ -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: 85%;">
<!-- 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>
...@@ -67,34 +69,20 @@ ...@@ -67,34 +69,20 @@
</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="container mt-4">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// to sort the entries, filter their search, and search for a specific person. // to sort the entries, filter their search, and search for a specific person.
// Authors: // Authors:
// Cameron Hayes // Cameron Hayes
// Mac ... // Mac Stephens
unit View.Orders; unit View.Orders;
...@@ -13,44 +13,45 @@ uses ...@@ -13,44 +13,45 @@ uses
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls, WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage, WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls, ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, View.AddOrder; XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, View.AddOrder,
WEBLib.Grids;
type type
TFViewOrders = class(TWebForm) TFViewOrders = class(TWebForm)
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
XDataWebDataSet1: TXDataWebDataSet; xdwdsOrders: TXDataWebDataSet;
lblEntries: TWebLabel; lblEntries: TWebLabel;
wcbSortBy: TWebComboBox; wcbSortBy: TWebComboBox;
btnApply: TWebButton; btnApply: TWebButton;
edtSearch: TWebEdit; edtSearch: TWebEdit;
WebDataSource1: TWebDataSource; wdsOrders: TWebDataSource;
XDataWebDataSet1companyName: TStringField; xdwdsOrderscompanyName: TStringField;
XDataWebDataSet1jobName: TStringField; xdwdsOrdersjobName: TStringField;
XDataWebDataSet1orderDate: TStringField; xdwdsOrdersorderDate: TStringField;
XDataWebDataSet1proofDue: TStringField; xdwdsOrdersproofDue: TStringField;
XDataWebDataSet1proofDone: TStringField; xdwdsOrdersproofDone: TStringField;
XDataWebDataSet1artDue: TStringField; xdwdsOrdersartDue: TStringField;
XDataWebDataSet1artDone: TStringField; xdwdsOrdersartDone: TStringField;
XDataWebDataSet1mountDue: TStringField; xdwdsOrdersmountDue: TStringField;
XDataWebDataSet1mountDone: TStringField; xdwdsOrdersmountDone: TStringField;
XDataWebDataSet1shipDue: TStringField; xdwdsOrdersshipDue: TStringField;
XDataWebDataSet1shipDone: TStringField; xdwdsOrdersshipDone: TStringField;
XDataWebDataSet1price: TStringField; xdwdsOrdersprice: TStringField;
XDataWebDataSet1ID: TStringField; xdwdsOrdersID: TStringField;
XDataWebDataSet1qbRefNum: TStringField; xdwdsOrdersqbRefNum: TStringField;
XDataWebDataSet1colors: TStringField; xdwdsOrderscolors: TStringField;
btnAddOrder: TWebButton; btnAddOrder: TWebButton;
btnFilters: TWebButton; btnFilters: TWebButton;
dtpStartDate: TWebDateTimePicker; dtpStartDate: TWebDateTimePicker;
dtpEndDate: TWebDateTimePicker; dtpEndDate: TWebDateTimePicker;
XDataWebDataSet1plateDue: TStringField; xdwdsOrdersplateDue: TStringField;
XDataWebDataSet1plateDone: TStringField; xdwdsOrdersplateDone: TStringField;
XDataWebDataSet1orderType: TStringField; xdwdsOrdersorderType: TStringField;
pnlMessage: TWebPanel; pnlMessage: TWebPanel;
lblMessage: TWebLabel; lblMessage: TWebLabel;
btnCloseNotification: TWebButton; btnCloseNotification: TWebButton;
WebButton1: TWebButton; WebButton1: TWebButton;
WebButton2: TWebButton; btnPDF: TWebButton;
wdsCustomers: TWebDataSource; wdsCustomers: TWebDataSource;
xdwdsCustomers: TXDataWebDataSet; xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersNAME: TStringField; xdwdsCustomersNAME: TStringField;
...@@ -59,6 +60,7 @@ type ...@@ -59,6 +60,7 @@ type
xdwdsSave: TXDataWebDataSet; xdwdsSave: TXDataWebDataSet;
wdsSave: TWebDataSource; wdsSave: TWebDataSource;
xdwdsSaveCURR_ID: TIntegerField; xdwdsSaveCURR_ID: TIntegerField;
wdbtcOrders: TWebDBTableControl;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject); procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject); procedure btnSearchClick(Sender: TObject);
...@@ -67,9 +69,9 @@ type ...@@ -67,9 +69,9 @@ type
procedure btnCloseNotificationClick(Sender: TObject); procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject);
private private
FChildForm: TWebForm; FChildForm: TWebForm;
procedure AddRowToTable(temp: string);
procedure ClearTable(); procedure ClearTable();
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
function GenerateSearchOptions(): string; function GenerateSearchOptions(): string;
...@@ -80,6 +82,7 @@ type ...@@ -80,6 +82,7 @@ type
[async] procedure Search(searchOptions: string); [async] procedure Search(searchOptions: string);
[async] procedure GetOrders(searchOptions: string); [async] procedure GetOrders(searchOptions: string);
[async] procedure getUser(); [async] procedure getUser();
procedure GeneratePDF(OrderID: string);
var var
PageNumber: integer; PageNumber: integer;
PageSize: integer; PageSize: integer;
...@@ -105,6 +108,38 @@ uses ...@@ -105,6 +108,38 @@ uses
{$R *.dfm} {$R *.dfm}
procedure TFViewOrders.btnPDFClick(Sender: TObject);
var
SelectedOrderID: string;
PDFButton: TJSHTMLElement;
begin
PDFButton := TJSHTMLElement(document.getElementById('btngeneratepdf'));
// Check if an order is selected
if not xdwdsOrders.IsEmpty then
begin
SelectedOrderID := xdwdsOrdersID.Value;
if SelectedOrderID <> '' then
begin
GeneratePDF(SelectedOrderID);
// Remove invalid state if it exists
PDFButton.classList.remove('is-invalid');
end
else
begin
// Add the 'is-invalid' class to trigger Bootstrap validation styling
PDFButton.classList.add('is-invalid');
end;
end
else
begin
// Add the 'is-invalid' class to trigger Bootstrap validation styling
PDFButton.classList.add('is-invalid');
end;
end;
procedure TFViewOrders.WebFormCreate(Sender: TObject); procedure TFViewOrders.WebFormCreate(Sender: TObject);
// Initializes important values: // Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc // PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
...@@ -186,191 +221,7 @@ begin ...@@ -186,191 +221,7 @@ begin
end; end;
procedure TFViewOrders.AddRowToTable(temp: string);
// Adds rows to the table
// PhoneNumber: phone number of the location
// Caller: phone number of the caller
// Duration: duration of the call
// Transcript: transcription of the recording
// MediaUrl: Link to the recording
var
NewRow, Cell, P, Button, Audio: TJSHTMLElement;
colorObject: TJSObject;
colorList: TJSArray;
colorListJSON: TJSONArray;
colors: integer;
ClickHandler: TJSFunction;
id, strColorList: string;
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
NewRow.addEventListener('click', procedure
begin
orderEntry(NewRow.Attrs['id'], '', 'EDIT');
end);
// Order ID Cell
NewRow.Attrs['id'] := XDataWebDataSet1ID.Value;
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order ID');
if XDataWebDataSet1ID.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1ID.Value;
NewRow.appendChild(Cell);
// Company Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Company Name');
if XDataWebDataSet1companyName.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1companyName.Value;
NewRow.appendChild(Cell);
// Job Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Job Name');
if XDataWebDataSet1jobName.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1jobName.Value;
NewRow.appendChild(Cell);
// Order Date Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order Date');
if XDataWebDataSet1orderDate.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1orderDate.Value;
NewRow.appendChild(Cell);
// Proof Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Proof Due');
if XDataWebDataSet1proofDue.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1proofDue.Value;
NewRow.appendChild(Cell);
// Proof Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Proof Done');
if XDataWebDataSet1proofDone.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1proofDone.Value;
NewRow.appendChild(Cell);
// Art Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Art Due');
if XDataWebDataSet1artDue.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1artDue.Value;
NewRow.appendChild(Cell);
// Art Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Art Done');
if XDataWebDataSet1artDone.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1artDone.Value;
NewRow.appendChild(Cell);
// Plate Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Plate Due');
if XDataWebDataSet1plateDue.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1plateDue.Value;
NewRow.appendChild(Cell);
// Plate Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Plate Done');
if XDataWebDataSet1plateDone.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1plateDone.Value;
NewRow.appendChild(Cell);
// Mount Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Mount Due');
if XDataWebDataSet1mountDue.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1mountDue.Value;
NewRow.appendChild(Cell);
// Mount Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Mount Done');
if XDataWebDataSet1mountDone.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1mountDone.Value;
NewRow.appendChild(Cell);
// Ship Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Ship Due');
if XDataWebDataSet1shipDue.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1shipDue.Value;
NewRow.appendChild(Cell);
// Ship Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Ship Done');
if XDataWebDataSet1shipDone.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1shipDone.Value;
NewRow.appendChild(Cell);
// Price Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Price');
if XDataWebDataSet1price.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1price.Value;
NewRow.appendChild(Cell);
// QuickBooks Reference Number Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Quickbooks Reference Number');
if XDataWebDataSet1qbRefNum.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := XDataWebDataSet1qbRefNum.Value;
NewRow.appendChild(Cell);
// Colors Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Colors');
if XDataWebDataSet1colors.Value = '' then
Cell.innerText := '0'
else
begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1colors.Value));
colorList := TJSArray(colorObject['items']);
colors := colorList.flength;
Cell.innerText := IntToStr(colors);
end;
NewRow.appendChild(Cell);
// Appends new rows to the table body
TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow);
end;
procedure TFViewOrders.GeneratePagination(TotalPages: Integer); procedure TFViewOrders.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table. // Generates pagination for the table.
...@@ -572,63 +423,34 @@ end; ...@@ -572,63 +423,34 @@ end;
procedure TFViewOrders.GetOrders(searchOptions: string); procedure TFViewOrders.GetOrders(searchOptions: string);
// Retrieves list of orders from the server that meet the criteria searchOptions
// searchOptions: information about how to generate the SQL statement based on
// user input.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
orderList : TJSObject; orderList: TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString: string;
begin begin
if PageNumber > 0 then if PageNumber > 0 then
begin begin
asm asm
startSpinner(); startSpinner();
end; end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrders', xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrders', [searchOptions]));
[searchOptions])); orderList := TJSObject(xdcResponse.Result);
orderList := TJSObject(xdcResponse.Result);
data := TJSArray(orderList['data']); // Load data into the dataset
callListLength := integer(orderList['count']); xdwdsOrders.Close;
ClearTable(); xdwdsOrders.SetJsonData(orderList['data']);
XDataWebDataSet1.Close; xdwdsOrders.Open;
XDataWebDataSet1.SetJsonData(orderList['data']);
XDataWebDataSet1.Open;
asm asm
setTimeout(endSpinner, 2000); setTimeout(endSpinner, 2000);
end; end;
for i := 0 to data.Length - 1 do
begin lblEntries.Caption := 'Total entries: ' + IntToStr(integer(orderList['count']));
order := TJSObject(data[i]); // Optional: Continue using pagination if needed
AddRowToTable(tempString); GeneratePagination((integer(orderList['count']) + PageSize - 1) div PageSize);
XDataWebDataSet1.Next;
end;
TotalPages := (callListLength + PageSize - 1) div PageSize;
if callListLength = 0 then
begin
lblEntries.Caption := 'No entries found';
end
else if (PageNumber * PageSize) < callListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(callListLength);
end
else if (PageNumber * PageSize) >= callListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(callListLength) +
' of ' + IntToStr(callListLength);
end;
GeneratePagination(TotalPages);
end; end;
end; end;
procedure TFViewOrders.btnAddOrderClick(Sender: TObject); procedure TFViewOrders.btnAddOrderClick(Sender: TObject);
begin begin
ShowOrderListForm(); ShowOrderListForm();
...@@ -769,4 +591,24 @@ begin ...@@ -769,4 +591,24 @@ begin
end; end;
procedure TFViewOrders.GeneratePDF(OrderID: string);
var
XDCResponse: TXDataClientResponse;
PDFBase64: string;
PDFBlob: TJSUint8Array;
PDFLink: TJSHTMLElement;
begin
// XDCResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderPDF', [OrderID]));
// PDFBase64 := string(XDCResponse.Result);
//
// // Convert Base64 to binary and create a link to download it
// PDFBlob := TJSUint8Array.new(TJSBase64.decodeBase64(PDFBase64));
// PDFLink := TJSHTMLElement(document.createElement('a'));
// PDFLink.setAttribute('href', 'data:application/pdf;base64,' + PDFBase64);
// PDFLink.setAttribute('download', 'Order_' + OrderID + '.pdf');
// PDFLink.click;
end;
end. end.
{ {
"AuthUrl" : "http://localhost:2004/emsys/kgOrders/auth/", "AuthUrl" : "http://localhost:2004/emsys/kgOrders/auth/",
"ApiUrl" : "http://localhost:2004/emsys/kgOrders/api/", "ApiUrl" : "http://localhost:2004/emsys/kgOrders/api/"
} }
...@@ -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 */
......
...@@ -216,6 +216,7 @@ type ...@@ -216,6 +216,7 @@ type
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function AddCorrugatedOrder(orderInfo: string): TJSONObject; function AddCorrugatedOrder(orderInfo: string): TJSONObject;
function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string; function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
function GenerateOrderPDF(OrderID: string): string;
end; end;
implementation implementation
......
...@@ -11,7 +11,7 @@ interface ...@@ -11,7 +11,7 @@ interface
uses uses
XData.Server.Module, XData.Server.Module,
XData.Service.Common, XData.Service.Common,
KGOrders.Database, Data.DB, KGOrders.Database, Data.DB, rOrders, frxClass, frxExportPDF,
Lookup.Service, System.Hash, System.Classes, System.JSON; Lookup.Service, System.Hash, System.Classes, System.JSON;
...@@ -39,6 +39,7 @@ type ...@@ -39,6 +39,7 @@ type
function EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string; function EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string;
procedure AfterConstruction; override; procedure AfterConstruction; override;
procedure BeforeDestruction; override; procedure BeforeDestruction; override;
function GenerateOrderPDF(OrderID: string): string;
end; end;
implementation implementation
...@@ -988,6 +989,39 @@ begin ...@@ -988,6 +989,39 @@ begin
end; end;
end; end;
function TLookupService.GenerateOrderPDF(OrderID: string): string;
var
ReportFileName: string;
Stream: TMemoryStream;
Base64PDF: string;
begin
// try
// // Create an instance of the rptOrders DataModule
// rptOrders := TrptOrders.Create(nil);
// Stream := TMemoryStream.Create;
//
// // Prepare the report using the rptOrders DataModule
// rptOrders.PrepareReport(OrderID);
//
// // Export the report to a PDF file in memory
// rptOrders.frxReport.Export(rptOrders.frxReport.FindComponent('frxPDFExport') as TfrxPDFExport, Stream);
//
// // Optionally save PDF to a file (optional)
// ReportFileName := TPath.Combine('C:\Reports\', 'Order_' + OrderID + '.pdf');
// Stream.SaveToFile(ReportFileName);
//
// // Convert to Base64 if you want to send it back as a string
// Stream.Position := 0;
// Base64PDF := TNetEncoding.Base64.EncodeBytesToString(Stream.Memory, Stream.Size);
// Result := Base64PDF;
// finally
// rptOrders.Free;
// Stream.Free;
// end;
end;
initialization initialization
RegisterServiceType(TLookupService); RegisterServiceType(TLookupService);
......
object rptOrders: TrptOrders
Left = 0
Top = 0
Caption = 'rptOrders'
ClientHeight = 441
ClientWidth = 624
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
TextHeight = 15
object frxReport1: TfrxReport
Version = '2024.2.1'
DotMatrixReport = False
IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection]
PreviewOptions.Zoom = 1.000000000000000000
PrintOptions.Printer = 'Default'
PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 45639.622835810190000000
ReportOptions.LastChange = 45639.622835810190000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
'begin'
''
'end.')
Left = 282
Top = 158
Datasets = <>
Variables = <>
Style = <>
end
object frxPDFExport1: TfrxPDFExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
EmbedFontsIfProtected = False
InteractiveFormsFontSubset = 'A-Z,a-z,0-9,#43-#47 '
OpenAfterExport = False
PrintOptimized = False
Outline = False
Background = False
HTMLTags = True
Quality = 95
Author = 'FastReport'
Subject = 'FastReport PDF export'
Creator = 'FastReport'
ProtectionFlags = [ePrint, eModify, eCopy, eAnnot]
HideToolbar = False
HideMenubar = False
HideWindowUI = False
FitWindow = False
CenterWindow = False
PrintScaling = False
PdfA = False
PDFStandard = psNone
PDFVersion = pv17
Left = 282
Top = 106
end
end
unit rOrders;
interface
uses
System.SysUtils, System.Classes, frxClass, frxDBSet,
frxExportBaseDialog, frxExportPDF, frCoreClasses, Uni, Data.DB,
XData.Service.Common, Aurelius.Mapping.Attributes, System.JSON, System.Generics.Collections;
type
TrptOrders = class(TDataModule)
frxReport: TfrxReport;
frxPDFExport: TfrxPDFExport;
frxDBDataset: TfrxDBDataset;
DataSource: TDataSource;
UniQuery: TUniQuery;
frxReport1: TfrxReport;
frxPDFExport1: TfrxPDFExport;
private
{ Private declarations }
public
{ Public declarations }
procedure PrepareReport(OrderID: string);
end;
var
rptOrders: TrptOrders;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
{ TrptOrders }
procedure TrptOrders.PrepareReport(OrderID: string);
var
SQL: string;
begin
try
// 1. **Prepare the Query**
SQL := 'SELECT * FROM orders WHERE ORDER_ID = :OrderID';
UniQuery.Close;
UniQuery.SQL.Text := SQL;
UniQuery.ParamByName('OrderID').AsString := OrderID;
UniQuery.Open;
// 2. **Connect the Query to the Report**
frxDBDataset.DataSet := UniQuery;
// 3. **Set Report Variables (if needed)**
frxReport.Variables['OrderID'] := QuotedStr(OrderID);
// 4. **Prepare the Report**
frxReport.PrepareReport(True);
except
on E: Exception do
raise Exception.Create('Error preparing the report: ' + E.Message);
end;
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};
type type
TMemoLogAppender = class( TInterfacedObject, ILogAppender ) TMemoLogAppender = class( TInterfacedObject, ILogAppender )
......
...@@ -164,6 +164,10 @@ ...@@ -164,6 +164,10 @@
<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>
</DCCReference>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
......
[Settings] [Settings]
MemoLogLevel=5 MemoLogLevel=5
FileLogLevel=5 FileLogLevel=5
LogFileNum=21 LogFileNum=25
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.198.131
--Server=192.168.75.133 Server=192.168.102.130
Password=emsys!012 --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