Commit f47d5190 by cam

Orders Page is now properly displaying orders

parent c99d264d
...@@ -40,6 +40,23 @@ object FViewCalls: TFViewCalls ...@@ -40,6 +40,23 @@ object FViewCalls: TFViewCalls
'25' '25'
'50') '50')
end end
object wcbSortBy: TWebComboBox
Left = 442
Top = 52
Width = 145
Height = 21
ElementClassName = 'custom-select'
ElementID = 'wcbsortby'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'Date'
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'Date'
'Phone Number')
end
object btnApply: TWebButton object btnApply: TWebButton
Left = 478 Left = 478
Top = 128 Top = 128
...@@ -55,30 +72,20 @@ object FViewCalls: TFViewCalls ...@@ -55,30 +72,20 @@ object FViewCalls: TFViewCalls
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnApplyClick OnClick = btnApplyClick
end end
object edtName: TWebEdit object edtSearch: TWebEdit
Left = 342 Left = 48
Top = 0 Top = 382
Width = 121
Height = 22
ChildOrder = 10
ElementClassName = 'form-control'
ElementID = 'edtname'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtDescription: TWebEdit
Left = 478
Top = 0
Width = 121 Width = 121
Height = 22 Height = 22
ChildOrder = 10 HelpType = htKeyword
ChildOrder = 8
ElementClassName = 'form-control' ElementClassName = 'form-control'
ElementID = 'edtdescription' ElementID = 'edtsearch'
ElementFont = efCSS ElementFont = efCSS
HeightStyle = ssAuto HeightStyle = ssAuto
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
HideSelection = False
TextHint = 'Format: (XXX) XXX-XXXX'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
...@@ -87,7 +94,58 @@ object FViewCalls: TFViewCalls ...@@ -87,7 +94,58 @@ object FViewCalls: TFViewCalls
Top = 240 Top = 240
end end
object XDataWebDataSet1: TXDataWebDataSet object XDataWebDataSet1: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 440 Left = 440
Top = 300 Top = 300
object XDataWebDataSet1companyName: TStringField
FieldName = 'companyName'
end
object XDataWebDataSet1jobName: TStringField
FieldName = 'jobName'
end
object XDataWebDataSet1orderDate: TStringField
FieldName = 'orderDate'
end
object XDataWebDataSet1proofDue: TStringField
FieldName = 'proofDue'
end
object XDataWebDataSet1proofDone: TStringField
FieldName = 'proofDone'
end
object XDataWebDataSet1artDue: TStringField
FieldName = 'artDue'
end
object XDataWebDataSet1artDone: TStringField
FieldName = 'artDone'
end
object XDataWebDataSet1mountDue: TStringField
FieldName = 'mountDue'
end
object XDataWebDataSet1mountDone: TStringField
FieldName = 'mountDone'
end
object XDataWebDataSet1shipDue: TStringField
FieldName = 'shipDue'
end
object XDataWebDataSet1shipDone: TStringField
FieldName = 'shipDone'
end
object XDataWebDataSet1price: TStringField
FieldName = 'price'
end
object XDataWebDataSet1qbRefNum: TIntegerField
FieldName = 'qbRefNum'
end
object XDataWebDataSet1colors: TIntegerField
FieldName = 'colors'
end
object XDataWebDataSet1ID: TIntegerField
FieldName = 'ID'
end
end
object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1
Left = 450
Top = 388
end end
end end
...@@ -5,33 +5,39 @@ ...@@ -5,33 +5,39 @@
<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">
<form class="form-inline"> <form class="form-inline">
<div class="row"> <div class="col-sm py-2">
<div class="col-sm-6"> <label class='pe-2'style="font-weight: 700;">Location:</label>
<label style="font-weight: 700;">Name:</label> <select class="custom-select" id="wcblocation" style="font-size: 1.00rem;"></select>
<input class="form-control input-sm" id="edtname">
</div> </div>
<div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<label class= 'pe-2'style="font-weight: 700;">Description:</label> <label class='pe-2'style="font-weight: 700;">Phone Number:</label>
<input class="form-control input-sm" id="edtdescription"> <input class="form-control input-sm" id="edtsearch">
</div> </div>
</div> </div>
</form> </form>
<form class="form-inline">
<div class="row"> <div class="row">
<div class="col-sm"> <div class="col-sm-6">
<form class='form-inline'> <label style="font-weight: 700;">Start Date:</label>
<div class="col-sm"> <input class="form-control input-sm" id="dtpstartdate" type="date">
<div class="form-cells"><input type="checkbox" id="cbstatus"></div>
<div class="form-cells ps-1 py-2"><label style="font-weight: 700;font-size: 15px" id="lblactive">Active?</label></div>
</div> </div>
</form> <div class="col-sm-6">
<label class= 'pe-2'style="font-weight: 700;">End Date:</label>
<input class="form-control input-sm" id="dtpenddate" type="date">
</div> </div>
</div> </div>
</form>
<form class="form-inline"> <form class="form-inline">
<div class= "row"> <div class= "row">
<div class="col-sm-5"> <div class="col-sm-5">
<label class="py-2" style="font-weight: 700;">Show <select class="custom-select" id="wcbpagesize" style="font-size: 1.00rem;"></select> entries</label> <label class="py-2" style="font-weight: 700;">Show <select class="custom-select" id="wcbpagesize" style="font-size: 1.00rem;"></select> entries</label>
</div> </div>
<div class="col-sm-5"> <div class="col-sm-5">
<label class="py-2" style="font-weight: 700;">Sorted by:</label>
<select class="custom-select" id="wcbsortby" style="font-size: 1.00rem;"></select>
</div>
<div class="col-sm-2">
<button class= "ps-3" id="btnapply"></button> <button class= "ps-3" id="btnapply"></button>
</div> </div>
</div> </div>
...@@ -40,10 +46,21 @@ ...@@ -40,10 +46,21 @@
<table class="table table-responsive table-striped table-bordered" id="tblPhoneGrid"> <table class="table table-responsive table-striped table-bordered" id="tblPhoneGrid">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th scope="col">ID</th> <th scope="col">Order ID</th>
<th scope="col">Name</th> <th scope="col">Company Name</th>
<th scope="col">Description</th> <th scope="col">Job Name</th>
<th scope="col">Status</th> <th scope="col">Order Date</th>
<th scope="col">Proof Due</th>
<th scope="col">Proof Date</th>
<th scope="col">Art Due</th>
<th scope="col">Art Done</th>
<th scope="col">Mount Due</th>
<th scope="col">Mount Done</th>
<th scope="col">Ship Due</th>
<th scope="col">Ship Done</th>
<th scope="col">Price</th>
<th scope="col">Quickbooks Reference Number</th>
<th scope="col">Colors</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -80,27 +97,10 @@ ...@@ -80,27 +97,10 @@
</div> </div>
<script> <script>
document.getElementById('tblPhoneGrid').addEventListener('click', function(event) { // JavaScript function to stop audio
// Check if the clicked element is a table cell (td) function stopAudio() {
if (event.target.tagName === 'TD') { var audioPlayer = document.getElementById('audioPlayer');
const row = event.target.parentNode; audioPlayer.pause(); // Pause the audio
const cells = row.getElementsByTagName('td'); audioPlayer.currentTime = 0; // Reset audio to beginning
// Extract data from the row
const id = cells[0].textContent;
const name = cells[1].textContent;
const description = cells[2].textContent;
const status = cells[3].textContent.trim().toLowerCase();
// Populate form fields
document.getElementById('edtname').value = name;
document.getElementById('edtdescription').value = description;
// Set the checkbox based on the status
const isActive = status === 'active';
document.getElementById('cbstatus').checked = isActive;
console.log(`Row clicked! ID: ${id}, Name: ${name}, Description: ${description}, Status: ${status}`);
} }
});
</script> </script>
...@@ -20,21 +20,36 @@ type ...@@ -20,21 +20,36 @@ type
XDataWebDataSet1: TXDataWebDataSet; XDataWebDataSet1: TXDataWebDataSet;
lblEntries: TWebLabel; lblEntries: TWebLabel;
wcbPageSize: TWebComboBox; wcbPageSize: TWebComboBox;
wcbSortBy: TWebComboBox;
btnApply: TWebButton; btnApply: TWebButton;
edtName: TWebEdit; edtSearch: TWebEdit;
edtDescription: TWebEdit; WebDataSource1: TWebDataSource;
XDataWebDataSet1companyName: TStringField;
XDataWebDataSet1jobName: TStringField;
XDataWebDataSet1orderDate: TStringField;
XDataWebDataSet1proofDue: TStringField;
XDataWebDataSet1proofDone: TStringField;
XDataWebDataSet1artDue: TStringField;
XDataWebDataSet1artDone: TStringField;
XDataWebDataSet1mountDue: TStringField;
XDataWebDataSet1mountDone: TStringField;
XDataWebDataSet1shipDue: TStringField;
XDataWebDataSet1shipDone: TStringField;
XDataWebDataSet1price: TStringField;
XDataWebDataSet1qbRefNum: TIntegerField;
XDataWebDataSet1colors: TIntegerField;
XDataWebDataSet1ID: TIntegerField;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject); procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject); procedure btnSearchClick(Sender: TObject);
private private
FChildForm: TWebForm; FChildForm: TWebForm;
procedure AddRowToTable(ID, Name, Description, Status: string); procedure AddRowToTable(temp: string);
procedure ClearTable(); procedure ClearTable();
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
function GenerateSearchOptions(): string; function GenerateSearchOptions(): string;
[async] procedure Search(searchOptions: string); [async] procedure Search(searchOptions: string);
[async] procedure GetCalls(searchOptions: string); [async] procedure GetCalls(searchOptions: string);
[async] procedure GetItems(searchOptions: string);
[async] procedure getUser(); [async] procedure getUser();
var var
PageNumber: integer; PageNumber: integer;
...@@ -69,7 +84,7 @@ begin ...@@ -69,7 +84,7 @@ begin
PageNumber := 1; PageNumber := 1;
TotalPages := 1; // Initial total pages TotalPages := 1; // Initial total pages
wcbPageSize.Text := '10'; wcbPageSize.Text := '10';
getItems(GenerateSearchOptions()); getCalls(GenerateSearchOptions());
end; end;
procedure TFViewCalls.getUser(); procedure TFViewCalls.getUser();
...@@ -78,11 +93,15 @@ var ...@@ -78,11 +93,15 @@ var
userList, user: TJSObject; userList, user: TJSObject;
data: TJSArray; data: TJSArray;
begin begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetUsers',
[JS.toString(AuthService.TokenPayload.Properties['user_name'])]));
userList := TJSObject(xdcResponse.Result);
data := TJSArray(userList['data']);
user := TJSObject(data[0]);
end; end;
procedure TFViewCalls.AddRowToTable(ID, Name, Description, Status: string); procedure TFViewCalls.AddRowToTable(temp: string);
// Adds rows to the table // Adds rows to the table
// PhoneNumber: phone number of the location // PhoneNumber: phone number of the location
// Caller: phone number of the caller // Caller: phone number of the caller
...@@ -94,30 +113,97 @@ var ...@@ -94,30 +113,97 @@ var
begin begin
NewRow := TJSHTMLElement(document.createElement('tr')); NewRow := TJSHTMLElement(document.createElement('tr'));
// Item ID Cell // Order ID Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order ID');
Cell.innerText := XDataWebDataSet1ID.AsString;
NewRow.appendChild(Cell);
// Company Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Company Name');
Cell.innerText := XDataWebDataSet1companyName.Value;
NewRow.appendChild(Cell);
// Job Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Job Name');
Cell.innerText := XDataWebDataSet1jobName.Value;
NewRow.appendChild(Cell);
// Order Date Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order Date');
Cell.innerText := XDataWebDataSet1orderDate.Value;
NewRow.appendChild(Cell);
// Proof Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Proof Due');
Cell.innerText := XDataWebDataSet1proofDue.Value;
NewRow.appendChild(Cell);
// Proof Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Proof Done');
Cell.innerText := XDataWebDataSet1proofDone.Value;
NewRow.appendChild(Cell);
// Art Due Cell
Cell := TJSHTMLElement(document.createElement('td')); Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Item ID'); Cell.setAttribute('data-label', 'Art Due');
Cell.innerText := ID; Cell.innerText := XDataWebDataSet1artDue.Value;
NewRow.appendChild(Cell); NewRow.appendChild(Cell);
// Name Cell // Art Done Cell
Cell := TJSHTMLElement(document.createElement('td')); Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Name'); Cell.setAttribute('data-label', 'Art Done');
Cell.innerText := Name; Cell.innerText := XDataWebDataSet1artDone.Value;
NewRow.appendChild(Cell); NewRow.appendChild(Cell);
// Description Cell // Mount Due Cell
Cell := TJSHTMLElement(document.createElement('td')); Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Description'); Cell.setAttribute('data-label', 'Mount Due');
Cell.innerText := Description; Cell.innerText := XDataWebDataSet1mountDue.Value;
NewRow.appendChild(Cell); NewRow.appendChild(Cell);
// Status Cell // Mount Done Cell
Cell := TJSHTMLElement(document.createElement('td')); Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Status'); Cell.setAttribute('data-label', 'Mount Done');
Cell.innerText := Status; Cell.innerText := XDataWebDataSet1mountDone.Value;
NewRow.appendChild(Cell); NewRow.appendChild(Cell);
// Ship Due Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Ship Due');
Cell.innerText := XDataWebDataSet1shipDue.Value;
NewRow.appendChild(Cell);
// Ship Done Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Ship Done');
Cell.innerText := XDataWebDataSet1shipDone.Value;
NewRow.appendChild(Cell);
// Price Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Price');
Cell.innerText := XDataWebDataSet1jobName.Value;
NewRow.appendChild(Cell);
// QuickBooks Reference Number Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Quickbooks Reference Number');
Cell.innerText := XDataWebDataSet1qbRefNum.AsString;
NewRow.appendChild(Cell);
// Colors Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Colors');
Cell.innerText := XDataWebDataSet1colors.AsString;
NewRow.appendChild(Cell);
// Appends new rows to the table body // Appends new rows to the table body
TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow); TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow);
end; end;
...@@ -146,7 +232,7 @@ begin ...@@ -146,7 +232,7 @@ begin
if PageNumber > 1 then if PageNumber > 1 then
begin begin
Dec(PageNumber); Dec(PageNumber);
GetItems(GenerateSearchOptions()); GetCalls(GenerateSearchOptions());
end; end;
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
...@@ -186,7 +272,7 @@ begin ...@@ -186,7 +272,7 @@ begin
begin begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(GenerateSearchOptions()); GetCalls(GenerateSearchOptions());
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem); PaginationElement.appendChild(PageItem);
...@@ -225,7 +311,7 @@ begin ...@@ -225,7 +311,7 @@ begin
begin begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(GenerateSearchOptions()); GetCalls(GenerateSearchOptions());
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem); PaginationElement.appendChild(PageItem);
...@@ -262,7 +348,7 @@ begin ...@@ -262,7 +348,7 @@ begin
begin begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(generateSearchOptions()); GetCalls(generateSearchOptions());
end); end);
end; end;
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
...@@ -282,7 +368,7 @@ begin ...@@ -282,7 +368,7 @@ begin
if PageNumber < TotalPages then if PageNumber < TotalPages then
begin begin
Inc(PageNumber); Inc(PageNumber);
GetItems(GenerateSearchOptions()); GetCalls(GenerateSearchOptions());
end; end;
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
...@@ -290,52 +376,6 @@ begin ...@@ -290,52 +376,6 @@ begin
end; end;
procedure TFViewCalls.GetItems(searchOptions: string);
var
xdcResponse: TXDataClientResponse;
itemList : TJSObject;
i: integer;
data: TJSArray;
item: TJSObject;
itemListLength: integer;
begin
console.log('correct');
if PageNumber > 0 then
begin
asm
startSpinner();
end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[searchOptions]));
itemList := TJSObject(xdcResponse.Result);
data := TJSArray(itemList['data']);
itemListLength := integer(itemList['count']);
ClearTable();
asm
setTimeout(endSpinner, 2000);
end;
for i := 0 to data.Length - 1 do
begin
item := TJSObject(data[i]);
AddRowToTable(string(item['ID']), string(item['name']), string(item['description']),
string(item['status']));
end;
TotalPages := (itemListLength + PageSize - 1) div PageSize;
if (PageNumber * PageSize) < itemListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(itemListLength);
end
else
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(itemListLength) +
' of ' + IntToStr(itemListLength);
end;
GeneratePagination(TotalPages);
end;
end;
procedure TFViewCalls.GetCalls(searchOptions: string); procedure TFViewCalls.GetCalls(searchOptions: string);
// Retrieves list of calls from the server that meet the criteria searchOptions // Retrieves list of calls from the server that meet the criteria searchOptions
...@@ -343,32 +383,39 @@ procedure TFViewCalls.GetCalls(searchOptions: string); ...@@ -343,32 +383,39 @@ procedure TFViewCalls.GetCalls(searchOptions: string);
// user input. // user input.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
callList : TJSObject; orderList : TJSObject;
i: integer; i: integer;
data: TJSArray; data: TJSArray;
call: TJSObject; order: TJSObject;
callListLength: integer; 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.GetCalls', xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrders',
[searchOptions])); [searchOptions]));
callList := TJSObject(xdcResponse.Result); orderList := TJSObject(xdcResponse.Result);
data := TJSArray(callList['data']); data := TJSArray(orderList['data']);
callListLength := integer(callList['count']); callListLength := integer(orderList['count']);
ClearTable(); ClearTable();
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(orderList['data']);
XDataWebDataSet1.Open;
console.log(orderList['data']);
asm asm
setTimeout(endSpinner, 2000); setTimeout(endSpinner, 2000);
end; end;
for i := 0 to data.Length - 1 do for i := 0 to data.Length - 1 do
begin begin
call := TJSObject(data[i]); order := TJSObject(data[i]);
AddRowToTable(string(call['toNumber']), string(call['fromNumber']), string(call['dateCreated']), {console.log(order);
string(call['duration']), string(call['transcription']), string(call['mediaUrl'])); console.log(XDataWebDataSet1proofDue.Value);
console.log(XDataWebDataSet1ID.Value);}
AddRowToTable(tempString);
end; end;
TotalPages := (callListLength + PageSize - 1) div PageSize; TotalPages := (callListLength + PageSize - 1) div PageSize;
if (PageNumber * PageSize) < callListLength then if (PageNumber * PageSize) < callListLength then
...@@ -384,7 +431,7 @@ begin ...@@ -384,7 +431,7 @@ begin
' of ' + IntToStr(callListLength); ' of ' + IntToStr(callListLength);
end; end;
GeneratePagination(TotalPages); GeneratePagination(TotalPages);
end; } end;
end; end;
procedure TFViewCalls.btnApplyClick(Sender: TObject); procedure TFViewCalls.btnApplyClick(Sender: TObject);
...@@ -394,12 +441,11 @@ searchOptions: string; ...@@ -394,12 +441,11 @@ searchOptions: string;
begin begin
PageNumber := 1; PageNumber := 1;
PageSize := StrToInt(wcbPageSize.Text); PageSize := StrToInt(wcbPageSize.Text);
OrderBy := wcbSortBy.Text;
searchOptions := '&pagenumber=' + IntToStr(PageNumber) + searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) + '&pagesize=' + IntToStr(PageSize) +
'&orderby=' + OrderBy; '&orderby=' + OrderBy;
GetCalls(searchOptions);
console.log('GetItems');
GetItems(searchOptions);
end; end;
procedure TFViewCalls.Search(searchOptions: string); procedure TFViewCalls.Search(searchOptions: string);
...@@ -413,7 +459,7 @@ var ...@@ -413,7 +459,7 @@ var
callListLength: integer; callListLength: integer;
begin begin
{if PageNumber > 0 then if PageNumber > 0 then
begin begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.Search', xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.Search',
[searchOptions])); [searchOptions]));
...@@ -424,18 +470,18 @@ begin ...@@ -424,18 +470,18 @@ begin
for i := 0 to data.Length - 1 do for i := 0 to data.Length - 1 do
begin begin
call := TJSObject(data[i]); call := TJSObject(data[i]);
AddRowToTable(string(call['toNumber']), string(call['fromNumber']), string(call['dateCreated']), {AddRowToTable(string(call['toNumber']), string(call['fromNumber']), string(call['dateCreated']),
string(call['duration']), string(call['transcription']), string(call['mediaUrl'])); string(call['duration']), string(call['transcription']), string(call['mediaUrl']));}
end; end;
TotalPages := (callListLength + PageSize - 1) div PageSize; TotalPages := (callListLength + PageSize - 1) div PageSize;
lblEntries.Caption := 'Showing entries for phone number: ' + searchOptions; lblEntries.Caption := 'Showing entries for phone number: ' + searchOptions;
end; } end;
end; end;
procedure TFViewCalls.btnSearchClick(Sender: TObject); procedure TFViewCalls.btnSearchClick(Sender: TObject);
// calls Search method // calls Search method
begin begin
//Search(edtSearch.Text); Search(edtSearch.Text);
end; end;
procedure TFViewCalls.ClearTable(); procedure TFViewCalls.ClearTable();
...@@ -452,7 +498,9 @@ function TFViewCalls.GenerateSearchOptions(): string; ...@@ -452,7 +498,9 @@ function TFViewCalls.GenerateSearchOptions(): string;
var var
searchOptions: string; searchOptions: string;
begin begin
PageNumber := 1;
PageSize := StrToInt(wcbPageSize.Text); PageSize := StrToInt(wcbPageSize.Text);
OrderBy := wcbSortBy.Text;
searchOptions := '&pagenumber=' + IntToStr(PageNumber) + searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) + '&pagesize=' + IntToStr(PageSize) +
'&orderby=' + OrderBy; '&orderby=' + OrderBy;
......
object FViewItems: TFViewItems
Width = 676
Height = 480
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
OnCreate = WebFormCreate
object lblEntries: TWebLabel
Left = 0
Top = 336
Width = 77
Height = 13
Caption = 'Showing 0 of ...'
ElementID = 'lblentries'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcbPageSize: TWebComboBox
Left = 0
Top = 0
Width = 145
Height = 21
ElementClassName = 'custom-select'
ElementID = 'wcbpagesize'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = '10'
WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange
ItemIndex = -1
Items.Strings = (
'10'
'25'
'50')
end
object btnApply: TWebButton
Left = 478
Top = 128
Width = 96
Height = 25
Caption = 'Apply'
ChildOrder = 7
ElementClassName = 'btn btn-light'
ElementID = 'btnapply'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnApplyClick
end
object edtName: TWebEdit
Left = 342
Top = 0
Width = 121
Height = 22
ChildOrder = 10
ElementClassName = 'form-control'
ElementID = 'edtname'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtDescription: TWebEdit
Left = 478
Top = 0
Width = 121
Height = 22
ChildOrder = 10
ElementClassName = 'form-control'
ElementID = 'edtdescription'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object cbStatus: TWebCheckBox
Left = 354
Top = 52
Width = 113
Height = 22
ChildOrder = 5
ElementClassName = 'custom-control custom-checkbox'
ElementButtonClassName = 'custom-control-input'
ElementLabelClassName = 'custom-control-label'
ElementID = 'cbstatus'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 426
Top = 240
end
object XDataWebDataSet1: TXDataWebDataSet
Left = 440
Top = 300
end
end
<div class="row">
<div class="col-12">
<h1 class="page-header pt-3" id="view.calls.title" style="font-size: 24px;">Calls</h1>
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-12 col-md-8">
<form class="form-inline">
<div class="row">
<div class="col-sm-6">
<label style="font-weight: 700;">Name:</label>
<input class="form-control input-sm" id="edtname">
</div>
<div class="col-sm-6">
<label class= 'pe-2'style="font-weight: 700;">Description:</label>
<input class="form-control input-sm" id="edtdescription">
</div>
</div>
</form>
<div class="row">
<div class="col-sm">
<form class='form-inline'>
<div class="col-sm">
<div class="form-cells"><input type="checkbox" id="cbstatus"></div>
<div class="form-cells ps-1 py-2"><label style="font-weight: 700;font-size: 15px" id="lblactive">Active?</label></div>
</div>
</form>
</div>
</div>
<form class="form-inline">
<div class= "row">
<div class="col-sm-5">
<label class="py-2" style="font-weight: 700;">Show <select class="custom-select" id="wcbpagesize" style="font-size: 1.00rem;"></select> entries</label>
</div>
<div class="col-sm-5">
<button class= "ps-3" id="btnapply"></button>
</div>
</div>
</form>
<table class="table table-responsive table-striped table-bordered" id="tblPhoneGrid">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<!-- Rows will be added dynamically via Delphi code -->
</tbody>
</table>
<label id="lblentries"></label>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added dynamically via Delphi code -->
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="audioModal" tabindex="-1" aria-labelledby="audioModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="audioModalLabel">Audio Player</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" onclick="stopAudio()"></button>
</div>
<div class="modal-body">
<audio controls id="audioPlayer">
<source src="" type="audio/mp3" id="audioSource">
Your browser does not support the audio element.
</audio>
</div>
</div>
</div>
</div>
<script>
document.getElementById('tblPhoneGrid').addEventListener('click', function(event) {
// Check if the clicked element is a table cell (td)
if (event.target.tagName === 'TD') {
const row = event.target.parentNode;
const cells = row.getElementsByTagName('td');
// Extract data from the row
const id = cells[0].textContent;
const name = cells[1].textContent;
const description = cells[2].textContent;
const status = cells[3].textContent.trim().toLowerCase();
// Populate form fields
document.getElementById('edtname').value = name;
document.getElementById('edtdescription').value = description;
// Set the checkbox based on the status
const isActive = status === 'active';
document.getElementById('cbstatus').checked = isActive;
console.log(`Row clicked! ID: ${id}, Name: ${name}, Description: ${description}, Status: ${status}`);
}
});
</script>
// Displays calls and their associated recordings in the grid. Allows the user
// to sort the entries, filter their search, and search for a specific person.
// Authors:
// Cameron Hayes
// Mac ...
unit View.Items;
interface
uses
System.SysUtils, System.Classes, Web, WEBLib.Graphics, WEBLib.Forms, WEBLib.Dialogs,
Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls, WEBLib.Controls, WEBLib.Grids, WebLib.Lists,
XData.Web.Client, WEBLib.ExtCtrls, DB, XData.Web.JsonDataset,
XData.Web.Dataset, XData.Web.Connection, Vcl.Forms, DateUtils, WebAudio;
type
TFViewItems = class(TWebForm)
XDataWebClient1: TXDataWebClient;
XDataWebDataSet1: TXDataWebDataSet;
lblEntries: TWebLabel;
wcbPageSize: TWebComboBox;
btnApply: TWebButton;
edtName: TWebEdit;
edtDescription: TWebEdit;
cbStatus: TWebCheckBox;
procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject);
private
FChildForm: TWebForm;
procedure AddRowToTable(ID, Name, Description, Status: string);
procedure ClearTable();
procedure GeneratePagination(TotalPages: Integer);
function GenerateSearchOptions(): string;
[async] procedure Search(searchOptions: string);
[async] procedure GetCalls(searchOptions: string);
[async] procedure GetItems(searchOptions: string);
[async] procedure getUser();
[async] procedure AddItem(itemOptions: string);
var
PageNumber: integer;
PageSize: integer;
TotalPages: integer;
StartDate: string;
EndDate: string;
OrderBy: string;
Caller: string;
public
end;
var
FViewItems: TFViewItems;
implementation
uses
JS, XData.Model.Classes,
ConnectionModule, Auth.Service;
{$R *.dfm}
procedure TFViewItems.WebFormCreate(Sender: TObject);
// Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
// TotalPages: Total number of pages returned from the search.
// PageSize: Number of entries per page.
begin
DMConnection.ApiConnection.Connected := True;
PageNumber := 1;
TotalPages := 1; // Initial total pages
wcbPageSize.Text := '10';
getItems(GenerateSearchOptions());
end;
procedure TFViewItems.getUser();
var
xdcResponse: TXDataClientResponse;
userList, user: TJSObject;
data: TJSArray;
begin
end;
procedure TFViewItems.AddRowToTable(ID, Name, Description, Status: 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;
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
// Item ID Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Item ID');
Cell.innerText := ID;
NewRow.appendChild(Cell);
// Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Name');
Cell.innerText := Name;
NewRow.appendChild(Cell);
// Description Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Description');
Cell.innerText := Description;
NewRow.appendChild(Cell);
// Status Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Status');
Cell.innerText := Status;
NewRow.appendChild(Cell);
// Appends new rows to the table body
TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow);
end;
procedure TFViewItems.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
var
PaginationElement, PageItem, PageLink: TJSHTMLElement;
I, Start, Finish: Integer;
begin
PaginationElement := TJSHTMLElement(document.getElementById('pagination'));
PaginationElement.innerHTML := ''; // Clear existing pagination
// Previous Button
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
if PageNumber = 1 then
PageItem.classList.add('disabled');
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := 'Previous';
PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
begin
if PageNumber > 1 then
begin
Dec(PageNumber);
GetItems(GenerateSearchOptions());
end;
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
// Page Numbers
if PageNumber <= 4 then
// If page number is low enough no early elipsis needed
Begin
Start := 2;
Finish := 5;
End
else if (PageNumber >= (TotalPages - 3)) then
// If page number is high enough no late elipsis needed
begin
Start := TotalPages - 3;
Finish := TotalPages - 1;
end
else
begin
Start := PageNumber - 1;
Finish := PageNumber + 1;
end;
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
if 1 = PageNumber then
PageItem.classList.add('selected-number'); // Add the selected-number class
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := '1';
PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
var
PageNum: Integer;
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetItems(GenerateSearchOptions());
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
// Adds Elipse to pagination if page number is too big
if PageNumber > 4 then
begin
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
PageItem.classList.add('disabled');
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := '...';
PageLink.setAttribute('href', 'javascript:void(0)');
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
end;
// Adds Page, page - 1, and page + 1 to pagination
for I := Start to Finish do
begin
if ( I > 1) and (I < TotalPages) then
begin
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
if I = PageNumber then
PageItem.classList.add('selected-number'); // Add the selected-number class
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := IntToStr(I);
PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
var
PageNum: Integer;
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetItems(GenerateSearchOptions());
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
end;
end;
// adds ellipse if number is too small
if PageNumber < TotalPages - 4 then
begin
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
PageItem.classList.add('disabled');
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := '...';
PageLink.setAttribute('href', 'javascript:void(0)');
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
end;
if TotalPages <> 1 then
begin
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
if TotalPages = PageNumber then
PageItem.classList.add('selected-number');
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := IntToStr(TotalPages);
PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
var
PageNum: Integer;
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetItems(generateSearchOptions());
end);
end;
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
// Next Button
PageItem := TJSHTMLElement(document.createElement('li'));
PageItem.className := 'page-item';
if PageNumber = TotalPages then
PageItem.classList.add('disabled');
PageLink := TJSHTMLElement(document.createElement('a'));
PageLink.className := 'page-link';
PageLink.innerText := 'Next';
PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
begin
if PageNumber < TotalPages then
begin
Inc(PageNumber);
GetItems(GenerateSearchOptions());
end;
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
end;
procedure TFViewItems.GetItems(searchOptions: string);
var
xdcResponse: TXDataClientResponse;
itemList : TJSObject;
i: integer;
data: TJSArray;
item: TJSObject;
itemListLength: integer;
begin
console.log('correct');
if PageNumber > 0 then
begin
asm
startSpinner();
end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[searchOptions]));
itemList := TJSObject(xdcResponse.Result);
data := TJSArray(itemList['data']);
itemListLength := integer(itemList['count']);
ClearTable();
asm
setTimeout(endSpinner, 2000);
end;
for i := 0 to data.Length - 1 do
begin
item := TJSObject(data[i]);
AddRowToTable(string(item['ID']), string(item['name']), string(item['description']),
string(item['status']));
end;
TotalPages := (itemListLength + PageSize - 1) div PageSize;
if (PageNumber * PageSize) < itemListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(itemListLength);
end
else
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(itemListLength) +
' of ' + IntToStr(itemListLength);
end;
GeneratePagination(TotalPages);
end;
end;
procedure TFViewItems.GetCalls(searchOptions: string);
// Retrieves list of calls from the server that meet the criteria searchOptions
// searchOptions: information about how to generate the SQL statement based on
// user input.
var
xdcResponse: TXDataClientResponse;
callList : TJSObject;
i: integer;
data: TJSArray;
call: TJSObject;
callListLength: integer;
begin
{if PageNumber > 0 then
begin
asm
startSpinner();
end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCalls',
[searchOptions]));
callList := TJSObject(xdcResponse.Result);
data := TJSArray(callList['data']);
callListLength := integer(callList['count']);
ClearTable();
asm
setTimeout(endSpinner, 2000);
end;
for i := 0 to data.Length - 1 do
begin
call := TJSObject(data[i]);
AddRowToTable(string(call['toNumber']), string(call['fromNumber']), string(call['dateCreated']),
string(call['duration']), string(call['transcription']), string(call['mediaUrl']));
end;
TotalPages := (callListLength + PageSize - 1) div PageSize;
if (PageNumber * PageSize) < callListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(callListLength);
end
else
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(callListLength) +
' of ' + IntToStr(callListLength);
end;
GeneratePagination(TotalPages);
end; }
end;
procedure TFViewItems.btnApplyClick(Sender: TObject);
// Button that effectively functions as a GetCalls() button
var
itemOptions: string;
begin
PageNumber := 1;
PageSize := StrToInt(wcbPageSize.Text);
itemOptions := '&name=' + edtName.Text +
'&description=' + edtDescription.Text +
'&status=' + BoolToStr(cbStatus.Checked);
console.log('GetItems');
AddItem(itemOptions);
end;
procedure TFViewItems.AddItem(itemOptions: string);
var
xdcResponse: TXDataClientResponse;
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddItem',
[itemOptions]));
getItems(GenerateSearchOptions());
end;
procedure TFViewItems.Search(searchOptions: string);
// Search method that searches the database for a specific phone number
var
xdcResponse: TXDataClientResponse;
callList : TJSObject;
i: integer;
data: TJSArray;
call: TJSObject;
callListLength: integer;
begin
{if PageNumber > 0 then
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.Search',
[searchOptions]));
callList := TJSObject(xdcResponse.Result);
data := TJSArray(callList['data']);
callListLength := integer(callList['count']);
ClearTable();
for i := 0 to data.Length - 1 do
begin
call := TJSObject(data[i]);
AddRowToTable(string(call['toNumber']), string(call['fromNumber']), string(call['dateCreated']),
string(call['duration']), string(call['transcription']), string(call['mediaUrl']));
end;
TotalPages := (callListLength + PageSize - 1) div PageSize;
lblEntries.Caption := 'Showing entries for phone number: ' + searchOptions;
end; }
end;
procedure TFViewItems.wcbPageSizeChange(Sender: TObject);
begin
PageNumber := 1;
getItems(GenerateSearchOptions());
end;
procedure TFViewItems.btnSearchClick(Sender: TObject);
// calls Search method
begin
//Search(edtSearch.Text);
end;
procedure TFViewItems.ClearTable();
// clears the table
var
tbody: TJSHTMLElement;
begin
tbody := TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]);
tbody.innerHTML := '';
end;
function TFViewItems.GenerateSearchOptions(): string;
// Generates searchOptions for get calls.
var
searchOptions: string;
begin
PageSize := StrToInt(wcbPageSize.Text);
searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) +
'&orderby=' + OrderBy;
Result := searchOptions;
end;
end.
...@@ -27,8 +27,8 @@ object FViewMain: TFViewMain ...@@ -27,8 +27,8 @@ object FViewMain: TFViewMain
Caption = ' User Profile' Caption = ' User Profile'
end end
object wllblLogout: TWebLinkLabel object wllblLogout: TWebLinkLabel
Left = 551 Left = 548
Top = 85 Top = 103
Width = 41 Width = 41
Height = 15 Height = 15
ElementID = 'dropdown.menu.logout' ElementID = 'dropdown.menu.logout'
...@@ -60,8 +60,8 @@ object FViewMain: TFViewMain ...@@ -60,8 +60,8 @@ object FViewMain: TFViewMain
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object lblCallsList: TWebLinkLabel object lblCallsList: TWebLinkLabel
Left = 564 Left = 560
Top = 56 Top = 69
Width = 29 Width = 29
Height = 15 Height = 15
ElementID = 'dropdown.menu.itemlist' ElementID = 'dropdown.menu.itemlist'
...@@ -73,7 +73,7 @@ object FViewMain: TFViewMain ...@@ -73,7 +73,7 @@ object FViewMain: TFViewMain
end end
object lblUsers: TWebLinkLabel object lblUsers: TWebLinkLabel
Left = 561 Left = 561
Top = 70 Top = 86
Width = 28 Width = 28
Height = 15 Height = 15
ElementID = 'dropdown.menu.users' ElementID = 'dropdown.menu.users'
...@@ -83,6 +83,19 @@ object FViewMain: TFViewMain ...@@ -83,6 +83,19 @@ object FViewMain: TFViewMain
OnClick = lblUsersClick OnClick = lblUsersClick
Caption = 'Users' Caption = 'Users'
end end
object lblorders: TWebLabel
Left = 556
Top = 52
Width = 35
Height = 15
Caption = 'Orders'
ElementID = 'lblorders'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblordersClick
end
object WebPanel1: TWebPanel object WebPanel1: TWebPanel
Left = 77 Left = 77
Top = 112 Top = 112
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<a class="dropdown-item" id="dropdown.menu.userprofile" href="#"><i class="fa fa-user fa-fw"></i><span> User Profile</span></a> <a class="dropdown-item" id="dropdown.menu.userprofile" href="#"><i class="fa fa-user fa-fw"></i><span> User Profile</span></a>
</li> </li>
<li> <li>
<a class="dropdown-item" id="lblorders" href="#"><i class="fa fa-home fa-fw"></i><span> Orders</span></a>
</li>
<li>
<a class="dropdown-item" id="dropdown.menu.itemlist" href="#"><i class="fa fa-phone fa-fw"></i><span> Items</span></a> <a class="dropdown-item" id="dropdown.menu.itemlist" href="#"><i class="fa fa-phone fa-fw"></i><span> Items</span></a>
</li> </li>
<li> <li>
......
...@@ -21,6 +21,7 @@ type ...@@ -21,6 +21,7 @@ type
XDataWebClient: TXDataWebClient; XDataWebClient: TXDataWebClient;
lblCallsList: TWebLinkLabel; lblCallsList: TWebLinkLabel;
lblUsers: TWebLinkLabel; lblUsers: TWebLinkLabel;
lblorders: TWebLabel;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure mnuLogoutClick(Sender: TObject); procedure mnuLogoutClick(Sender: TObject);
procedure wllblUserProfileClick(Sender: TObject); procedure wllblUserProfileClick(Sender: TObject);
...@@ -28,6 +29,7 @@ type ...@@ -28,6 +29,7 @@ type
procedure lblHomeClick(Sender: TObject); procedure lblHomeClick(Sender: TObject);
procedure lblCallsListClick(Sender: TObject); procedure lblCallsListClick(Sender: TObject);
procedure lblUsersClick(Sender: TObject); procedure lblUsersClick(Sender: TObject);
procedure lblordersClick(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FUserInfo: string; FUserInfo: string;
...@@ -57,9 +59,10 @@ uses ...@@ -57,9 +59,10 @@ uses
View.Login, View.Login,
View.UserProfile, View.UserProfile,
View.Home, View.Home,
View.Calls, View.Items,
View.Users, View.Users,
View.EditUser; View.EditUser,
View.Calls;
{$R *.dfm} {$R *.dfm}
...@@ -87,6 +90,11 @@ begin ...@@ -87,6 +90,11 @@ begin
ShowForm(TFViewHome); ShowForm(TFViewHome);
end; end;
procedure TFViewMain.lblordersClick(Sender: TObject);
begin
ShowForm(TFViewCalls);
end;
procedure TFViewMain.lblUsersClick(Sender: TObject); procedure TFViewMain.lblUsersClick(Sender: TObject);
begin begin
ShowForm(TFViewUsers); ShowForm(TFViewUsers);
...@@ -94,7 +102,7 @@ end; ...@@ -94,7 +102,7 @@ end;
procedure TFViewMain.lblCallsListClick(Sender: TObject); procedure TFViewMain.lblCallsListClick(Sender: TObject);
begin begin
ShowForm(TFViewCalls); ShowForm(TFViewItems);
end; end;
procedure TFViewMain.mnuLogoutClick(Sender: TObject); procedure TFViewMain.mnuLogoutClick(Sender: TObject);
......
...@@ -13,11 +13,12 @@ uses ...@@ -13,11 +13,12 @@ uses
View.ErrorPage in 'View.ErrorPage.pas' {FViewErrorPage: TWebForm} {*.html}, View.ErrorPage in 'View.ErrorPage.pas' {FViewErrorPage: TWebForm} {*.html},
App.Config in 'App.Config.pas', App.Config in 'App.Config.pas',
Paginator.Plugins in 'Paginator.Plugins.pas', Paginator.Plugins in 'Paginator.Plugins.pas',
View.Calls in 'View.Calls.pas' {FViewCalls: TWebForm} {*.html}, View.Items in 'View.Items.pas' {FViewItems: TWebForm} {*.html},
View.Main in 'View.Main.pas' {FViewMain: TWebForm} {*.html}, View.Main in 'View.Main.pas' {FViewMain: TWebForm} {*.html},
View.Home in 'View.Home.pas' {FViewHome: TWebForm} {*.html}, View.Home in 'View.Home.pas' {FViewHome: TWebForm} {*.html},
View.Users in 'View.Users.pas' {FViewUsers: TWebForm} {*.html}, View.Users in 'View.Users.pas' {FViewUsers: TWebForm} {*.html},
View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html}; View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html},
View.Calls in 'View.Calls.pas' {FViewCalls: TWebForm} {*.html};
{$R *.res} {$R *.res}
......
...@@ -136,8 +136,8 @@ ...@@ -136,8 +136,8 @@
</DCCReference> </DCCReference>
<DCCReference Include="App.Config.pas"/> <DCCReference Include="App.Config.pas"/>
<DCCReference Include="Paginator.Plugins.pas"/> <DCCReference Include="Paginator.Plugins.pas"/>
<DCCReference Include="View.Calls.pas"> <DCCReference Include="View.Items.pas">
<Form>FViewCalls</Form> <Form>FViewItems</Form>
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass> <DesignClass>TWebForm</DesignClass>
</DCCReference> </DCCReference>
...@@ -161,6 +161,11 @@ ...@@ -161,6 +161,11 @@
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass> <DesignClass>TWebForm</DesignClass>
</DCCReference> </DCCReference>
<DCCReference Include="View.Calls.pas">
<Form>FViewCalls</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/> <None Include="index.html"/>
<None Include="template\css\app.css"/> <None Include="template\css\app.css"/>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
......
...@@ -83,6 +83,32 @@ type ...@@ -83,6 +83,32 @@ type
data: TList<TItemItem>; data: TList<TItemItem>;
end; end;
TOrderItem = class
public
ID: integer;
companyName: string;
jobName: string;
orderDate: string;
proofDue: string;
proofDone: string;
artDue: string;
artDone: string;
mountDue: string;
mountDone: string;
shipDue: string;
shipDone: string;
price: string;
qbRefNum: integer;
colors: integer;
end;
TOrderList = class
Public
count: integer;
data: TList<TOrderItem>
end;
type type
[ServiceContract] [ServiceContract]
...@@ -92,6 +118,7 @@ type ...@@ -92,6 +118,7 @@ type
[HttpGet] function Search(phoneNum: string): TCallList; [HttpGet] function Search(phoneNum: string): TCallList;
[HttpGet] function GetUsers(searchOptions: string): TUserList; [HttpGet] function GetUsers(searchOptions: string): TUserList;
[HttpGet] function GetItems(searchOptions: string): TItemList; [HttpGet] function GetItems(searchOptions: string): TItemList;
[HttpGet] function GetOrders(searchOptions: string): TOrderList;
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;
......
...@@ -24,6 +24,7 @@ type ...@@ -24,6 +24,7 @@ type
function GetItems(searchOptions: string): TItemList; function GetItems(searchOptions: string): TItemList;
function GetUsers(searchOptions: string): TUserList; function GetUsers(searchOptions: string): TUserList;
function GetCalls(searchOptions: string): TCallList; function GetCalls(searchOptions: string): TCallList;
function GetOrders(searchOptions: string): TOrderList;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function Search(phoneNum: string): TCallList; function Search(phoneNum: string): TCallList;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
...@@ -201,6 +202,68 @@ begin ...@@ -201,6 +202,68 @@ begin
callsDB.UniQuery1.Close; callsDB.UniQuery1.Close;
end; end;
function TLookupService.GetOrders(searchOptions: string): TOrderList;
var
params: TStringList;
PageNum: integer;
PageSize: integer;
OrderBy: string;
offset: string;
limit: string;
SQL: string;
Order: TOrderItem;
begin
params := TStringList.Create;
params.StrictDelimiter := true;
// parse the searchOptions
params.Delimiter := '&';
params.DelimitedText := searchOptions;
PageNum := StrToInt(params.Values['pagenumber']);
PageSize := StrToInt(params.Values['pagesize']);
OrderBy := params.Values['orderby'];
offset := IntToStr((PageNum - 1) * PageSize);
limit := IntToStr(PageSize);
SQL := 'select * from web_plate_orders ' + 'limit ' + limit + ' offset ' + offset;
doQuery(callsDB.UniQuery1, SQL);
Result:= TOrderList.Create;
Result.data := TList<TOrderItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.data );
while not callsDB.UniQuery1.Eof do
begin
Order := TOrderItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Order );
Result.data.Add( Order );
order.ID := callsDB.UniQuery1.FieldByName('ORDER_ID').AsInteger;
order.companyName := '???';
order.jobName := callsDB.UniQuery1.FieldByName('staff_fields_job_name').AsString;
order.orderDate := callsDB.UniQuery1.FieldByName('ORDER_DATE').AsString;
order.proofDue := callsDB.UniQuery1.FieldByName('staff_fields_proof_date').AsString;
order.proofDone := '???';
order.artDue := callsDB.UniQuery1.FieldByName('staff_fields_art_due').AsString;
order.artDone := '???';
order.mountDue := '???';
order.mountDone := '???';
order.shipDue := callsDB.UniQuery1.FieldByName('staff_fields_ship_date').AsString;
order.shipDone := '???';
order.price := callsDB.UniQuery1.FieldByName('staff_fields_price').AsString;
order.qbRefNum := -1;
order.colors := -1;
callsDB.UniQuery1.Next;
end;
callsDB.UniQuery1.Close;
SQL:= 'select count(*) as total_count from web_plate_orders';
doQuery(callsDB.UniQuery1, SQL);
Result.count := callsDB.UniQuery1.FieldByName('total_count').AsInteger;
callsDB.UniQuery1.Close;
end;
function TLookupService.GetItems(searchOptions: string): TItemList; function TLookupService.GetItems(searchOptions: string): TItemList;
var var
params: TStringList; params: TStringList;
...@@ -471,6 +534,8 @@ begin ...@@ -471,6 +534,8 @@ begin
doQuery(callsDB.UniQuery1, SQL); doQuery(callsDB.UniQuery1, SQL);
if callsDB.UniQuery1.IsEmpty then if callsDB.UniQuery1.IsEmpty then
begin begin
callsDB.UniQuery1.Insert;
callsDB.UniQuery1.FieldByName('qb_item_name').AsString := Name; callsDB.UniQuery1.FieldByName('qb_item_name').AsString := Name;
callsDB.UniQuery1.FieldByName('item_desc').AsString := Description; callsDB.UniQuery1.FieldByName('item_desc').AsString := Description;
if Status then if Status then
......
object FMain: TFMain object FMain: TFMain
Left = 0 Left = 0
Top = 0 Top = 0
Caption = 'envoy Calls Server 2' Caption = 'KG Orders Server'
ClientHeight = 597 ClientHeight = 597
ClientWidth = 764 ClientWidth = 764
Color = clBtnFace Color = clBtnFace
......
[Options] [Options]
LogFileNum=32 LogFileNum=46
UpdateTimerLength=0 UpdateTimerLength=0
......
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