Commit 221d090f by cam

Quickbooks Item List is now under the calls tab.

parent 15e7be69
......@@ -46,12 +46,10 @@
<table class="table table-responsive table-striped table-bordered" id="tblPhoneGrid">
<thead class="thead-dark">
<tr>
<th scope="col">Phone Number</th>
<th scope="col">Caller</th>
<th scope="col">Time</th>
<th scope="col">Duration</th>
<th scope="col">Transcript</th>
<th scope="col">Listen</th>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
......
......@@ -31,12 +31,13 @@ type
procedure btnSearchClick(Sender: TObject);
private
FChildForm: TWebForm;
procedure AddRowToTable(PhoneNumber, Caller, Time, Duration, Transcript, MediaUrl: string);
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();
var
PageNumber: integer;
......@@ -90,7 +91,7 @@ begin
end;
procedure TFViewCalls.AddRowToTable(PhoneNumber, Caller, Time, Duration, Transcript, MediaUrl: string);
procedure TFViewCalls.AddRowToTable(ID, Name, Description, Status: string);
// Adds rows to the table
// PhoneNumber: phone number of the location
// Caller: phone number of the caller
......@@ -102,81 +103,28 @@ var
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
// Phone Number Cell
// Item ID Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Phone Number');
Cell.innerText := PhoneNumber;
Cell.setAttribute('data-label', 'Item ID');
Cell.innerText := ID;
NewRow.appendChild(Cell);
// Caller Cell
// Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Caller');
Cell.innerText := Caller;
Cell.setAttribute('data-label', 'Name');
Cell.innerText := Name;
NewRow.appendChild(Cell);
// Time Cell
// Description Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Time');
Cell.innerText := DateTimeToStr(IncHour(StrToDateTime(Time), -4));;
Cell.setAttribute('data-label', 'Description');
Cell.innerText := Description;
NewRow.appendChild(Cell);
// Duration Cell
// Status Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Duration');
Cell.innerText := Duration;
NewRow.appendChild(Cell);
// Transcript Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Transcript');
P := TJSHTMLElement(document.createElement('p'));
P.className := 'transcript';
P.innerText := Transcript;
Cell.appendChild(P);
NewRow.appendChild(Cell);
// Listen Button Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Listen');
Button := TJSHTMLElement(document.createElement('button'));
Button.className := 'btn btn-primary';
Button.innerHTML := '<i class="fa fa-play"></i>';
Button.addEventListener('click', procedure(Event: TJSMouseEvent)
begin
Audio := TJSHTMLElement(document.createElement('audio'));
{Button.disabled = true;
Audio.id = 'myAudio';
Audio.src = MediaUrl; // Replace with your audio file URL
Audio.preload = 'auto';
Audio.play();}
{ var playerWindow = window.open('', 'audioPlayer', 'width=400,height=200');
var playerContent = `
<div class="player-container">
<audio controls>
<source src=` + MediaUrl + `>
Your browser does not support the audio element.
</audio>
</div>
`;
playerWindow.document.body.innerHTML = playerContent;}
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('audioModal'), {
keyboard: false });
confirmationModal.show();
var audioPlayer = document.getElementById('audioPlayer');
var sourceElement = document.getElementById('audioSource');
sourceElement.src = MediaUrl;
audioPlayer.load();
end;
Audio.addEventListener('ended', procedure
begin
asm
Button.disabled = false;
end;
end);
end);
Cell.appendChild(Button);
Cell.setAttribute('data-label', 'Status');
Cell.innerText := Status;
NewRow.appendChild(Cell);
// Appends new rows to the table body
......@@ -207,7 +155,7 @@ begin
if PageNumber > 1 then
begin
Dec(PageNumber);
GetCalls(GenerateSearchOptions());
GetItems(GenerateSearchOptions());
end;
end);
PageItem.appendChild(PageLink);
......@@ -247,7 +195,7 @@ begin
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetCalls(GenerateSearchOptions());
GetItems(GenerateSearchOptions());
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
......@@ -286,7 +234,7 @@ begin
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetCalls(GenerateSearchOptions());
GetItems(GenerateSearchOptions());
end);
PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem);
......@@ -323,7 +271,7 @@ begin
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum;
GetCalls(generateSearchOptions());
GetItems(generateSearchOptions());
end);
end;
PageItem.appendChild(PageLink);
......@@ -343,7 +291,7 @@ begin
if PageNumber < TotalPages then
begin
Inc(PageNumber);
GetCalls(GenerateSearchOptions());
GetItems(GenerateSearchOptions());
end;
end);
PageItem.appendChild(PageLink);
......@@ -351,6 +299,52 @@ begin
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);
// Retrieves list of calls from the server that meet the criteria searchOptions
......@@ -365,7 +359,7 @@ var
callListLength: integer;
begin
if PageNumber > 0 then
{if PageNumber > 0 then
begin
asm
startSpinner();
......@@ -399,7 +393,7 @@ begin
' of ' + IntToStr(callListLength);
end;
GeneratePagination(TotalPages);
end;
end; }
end;
procedure TFViewCalls.btnApplyClick(Sender: TObject);
......@@ -420,7 +414,8 @@ begin
'&enddate=' + EndDate +
'&orderby=' + OrderBy +
'&caller=' + Caller;
GetCalls(searchOptions);
console.log('GetItems');
GetItems(searchOptions);
end;
procedure TFViewCalls.Search(searchOptions: string);
......@@ -434,7 +429,7 @@ var
callListLength: integer;
begin
if PageNumber > 0 then
{if PageNumber > 0 then
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.Search',
[searchOptions]));
......@@ -450,7 +445,7 @@ begin
end;
TotalPages := (callListLength + PageSize - 1) div PageSize;
lblEntries.Caption := 'Showing entries for phone number: ' + searchOptions;
end;
end; }
end;
procedure TFViewCalls.btnSearchClick(Sender: TObject);
......
......@@ -69,6 +69,20 @@ type
data: TList<TUserItem>;
end;
TItemItem = class
public
ID: string;
name: string;
description: string;
status: string;
end;
TItemList = class
public
count: integer;
data: TList<TItemItem>;
end;
type
[ServiceContract]
......@@ -77,6 +91,7 @@ type
[HttpGet] function GetCalls(searchOptions: string): TCallList;
[HttpGet] function Search(phoneNum: string): TCallList;
[HttpGet] function GetUsers(searchOptions: string): TUserList;
[HttpGet] function GetItems(searchOptions: string): TItemList;
function AddUser(userInfo: string): string;
function DelUser(username: string): string;
function EditUser(const editOptions: string): string;
......
......@@ -21,6 +21,7 @@ type
strict private
callsDB: TFDatabaseModule;
private
function GetItems(searchOptions: string): TItemList;
function GetUsers(searchOptions: string): TUserList;
function GetCalls(searchOptions: string): TCallList;
function EditUser(const editOptions: string): string;
......@@ -199,6 +200,57 @@ begin
callsDB.UniQuery1.Close;
end;
function TLookupService.GetItems(searchOptions: string): TItemList;
var
params: TStringList;
PageNum: integer;
PageSize: integer;
OrderBy: string;
offset: string;
limit: string;
SQL: string;
item: TItemItem;
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 qb_items ' + 'limit ' + limit + ' offset ' + offset;
doQuery(callsDB.UniQuery1, SQL);
Result:= TItemList.Create;
Result.data := TList<TItemItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.data );
while not callsDB.UniQuery1.Eof do
begin
item := TItemItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( item );
Result.data.Add( item );
item.ID := callsDB.UniQuery1.FieldByName('qb_items_id').AsString;
item.name := callsDB.UniQuery1.FieldByName('qb_item_name').AsString;
item.description := callsDB.UniQuery1.FieldByName('item_desc').AsString;
item.status := callsDB.UniQuery1.FieldByName('status').AsString;
callsDB.UniQuery1.Next;
end;
callsDB.UniQuery1.Close;
SQL:= 'select count(*) as total_count from qb_items';
doQuery(callsDB.UniQuery1, SQL);
Result.count := callsDB.UniQuery1.FieldByName('total_count').AsInteger;
callsDB.UniQuery1.Close;
end;
function TLookupService.GetUsers(searchOptions: string): TUserList;
var
SQL: string;
......@@ -363,7 +415,7 @@ begin
//newUser := params.Values['newuser'];
//hashString := DateTimeToStr(dateCreated) + params.Values['password'];
//hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
SQL := 'select * from users where username = ' + QuotedStr(params.Values['username'].toLower);
SQL := 'select * from users where USER_NAME = ' + QuotedStr(params.Values['username'].toLower);
callsDB.UniQuery1.Close;
callsDB.UniQuery1.SQL.Text := SQL;
callsDB.UniQuery1.Open;
......
[Options]
LogFileNum=21
LogFileNum=29
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