Commit 7c01cce8 by cam

Fixed issue with status schedule not being updated properly

Also added needed documentation
parent 7a2dffa1
// Pop-Up menu that appears when Add Order button is clicked on orders page.
// Used to select customer before entering an order.
unit View.AddOrder; unit View.AddOrder;
interface interface
...@@ -56,7 +58,6 @@ implementation ...@@ -56,7 +58,6 @@ implementation
procedure TFAddOrder.btnCancelClick(Sender: TObject); procedure TFAddOrder.btnCancelClick(Sender: TObject);
begin begin
edtID.Text := '';
Close; Close;
end; end;
...@@ -89,6 +90,7 @@ begin ...@@ -89,6 +90,7 @@ begin
end; end;
[async] procedure TFAddOrder.getCustomers(); [async] procedure TFAddOrder.getCustomers();
// retrieves customer list from server
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
customerList: TJSObject; customerList: TJSObject;
...@@ -107,6 +109,7 @@ begin ...@@ -107,6 +109,7 @@ begin
end; end;
procedure TFAddOrder.PopulateGridManually; procedure TFAddOrder.PopulateGridManually;
// populates the grid with customers manually.
var var
RowIndex: Integer; RowIndex: Integer;
begin begin
...@@ -122,10 +125,6 @@ begin ...@@ -122,10 +125,6 @@ begin
TMSFNCGrid1.Cells[2, 0] := 'Name'; TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[3, 0] := 'Address'; TMSFNCGrid1.Cells[3, 0] := 'Address';
// TMSFNCGrid1.ColumnWidths[0] := 40;
// TMSFNCGrid1.ColumnWidths[1] := 80;
// TMSFNCGrid1.ColumnWidths[2] := 250;
// Populate the grid with data from the dataset // Populate the grid with data from the dataset
xdwdsCustomers.First; xdwdsCustomers.First;
RowIndex := 1; RowIndex := 1;
...@@ -152,11 +151,13 @@ end; ...@@ -152,11 +151,13 @@ end;
procedure TFAddOrder.TMSFNCGrid1SelectedCell(Sender: TObject; ACol, procedure TFAddOrder.TMSFNCGrid1SelectedCell(Sender: TObject; ACol,
ARow: Integer); ARow: Integer);
// When a cell is clicked it puts the ID in the text box
begin begin
edtID.Text := TMSFNCGrid1.Cells[0, ARow]; edtID.Text := TMSFNCGrid1.Cells[0, ARow];
end; end;
procedure TFAddOrder.ApplyFilter; procedure TFAddOrder.ApplyFilter;
// filters the grid based on search textbox contents.
var var
fd: TTMSFNCGridFilterData; fd: TTMSFNCGridFilterData;
i: Integer; i: Integer;
......
...@@ -26,7 +26,6 @@ type ...@@ -26,7 +26,6 @@ type
cbStatus: TWebCheckBox; cbStatus: TWebCheckBox;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject); procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject); procedure wcbPageSizeChange(Sender: TObject);
private private
FChildForm: TWebForm; FChildForm: TWebForm;
...@@ -34,7 +33,6 @@ type ...@@ -34,7 +33,6 @@ type
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 GetItems(searchOptions: string); [async] procedure GetItems(searchOptions: string);
[async] procedure getUser(); [async] procedure getUser();
[async] procedure AddItem(itemOptions: string); [async] procedure AddItem(itemOptions: string);
...@@ -86,11 +84,10 @@ end; ...@@ -86,11 +84,10 @@ end;
procedure TFViewItems.AddRowToTable(ID, Name, Description, Status: string); procedure TFViewItems.AddRowToTable(ID, Name, Description, Status: string);
// Adds rows to the table // Adds rows to the table
// PhoneNumber: phone number of the location // ID: item ID
// Caller: phone number of the caller // Name: item name
// Duration: duration of the call // Description: item description
// Transcript: transcription of the recording // Status: inactive or active
// MediaUrl: Link to the recording
var var
NewRow, Cell, P, Button, Audio: TJSHTMLElement; NewRow, Cell, P, Button, Audio: TJSHTMLElement;
begin begin
...@@ -293,6 +290,9 @@ begin ...@@ -293,6 +290,9 @@ begin
end; end;
procedure TFViewItems.GetItems(searchOptions: string); procedure TFViewItems.GetItems(searchOptions: string);
// retrieves items from the server.
// searchOptions: info to limit how many items we retrieve from the server.
// probably not needed due to database size.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
itemList : TJSObject; itemList : TJSObject;
...@@ -355,6 +355,7 @@ begin ...@@ -355,6 +355,7 @@ begin
end; end;
procedure TFViewItems.AddItem(itemOptions: string); procedure TFViewItems.AddItem(itemOptions: string);
// adds an item to the database.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
begin begin
...@@ -363,48 +364,13 @@ begin ...@@ -363,48 +364,13 @@ begin
getItems(GenerateSearchOptions()); getItems(GenerateSearchOptions());
end; 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); procedure TFViewItems.wcbPageSizeChange(Sender: TObject);
// gets a new amount of items based when the page size is changed
begin begin
PageNumber := 1; PageNumber := 1;
getItems(GenerateSearchOptions()); getItems(GenerateSearchOptions());
end; end;
procedure TFViewItems.btnSearchClick(Sender: TObject);
// item Search method
begin
//Search(edtSearch.Text);
end;
procedure TFViewItems.ClearTable(); procedure TFViewItems.ClearTable();
// clears the table // clears the table
var var
......
...@@ -797,8 +797,8 @@ object FOrderEntry: TFOrderEntry ...@@ -797,8 +797,8 @@ object FOrderEntry: TFOrderEntry
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object btnConfirm: TWebButton object btnConfirm: TWebButton
Left = 752 Left = 652
Top = 558 Top = 560
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Confirm' Caption = 'Confirm'
...@@ -965,6 +965,29 @@ object FOrderEntry: TFOrderEntry ...@@ -965,6 +965,29 @@ object FOrderEntry: TFOrderEntry
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object btnEdit: TWebButton
Left = 870
Top = 560
Width = 96
Height = 25
Caption = 'Edit'
ChildOrder = 79
ElementID = 'btnedit'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCancel: TWebButton
Left = 764
Top = 560
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementID = 'btncancel'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 244 Left = 244
......
...@@ -300,7 +300,13 @@ ...@@ -300,7 +300,13 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<button id="btnconfirm" class="btn btn-primary btn-sm float-end">Confirm</button> <button id="btnconfirm" class="btn btn-primary btn-sm float-end my-2">Confirm</button>
</div>
<div class="col-auto">
<button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button>
</div>
<div class="col-auto">
<button id="btnedit" class="btn btn-primary btn-sm float-end my-2">Edit</button>
</div> </div>
</div> </div>
</div> </div>
......
// Order Entry page of Corruguated Orders. Used for both editting and adding
// orders.
unit View.OrderEntryCorrugated; unit View.OrderEntryCorrugated;
interface interface
...@@ -187,6 +189,8 @@ type ...@@ -187,6 +189,8 @@ type
WebDBComboBox1: TWebDBComboBox; WebDBComboBox1: TWebDBComboBox;
cbEmail: TWebCheckBox; cbEmail: TWebCheckBox;
XDataWebDataSet1supplied_by_customer_order_date: TStringField; XDataWebDataSet1supplied_by_customer_order_date: TStringField;
btnEdit: TWebButton;
btnCancel: TWebButton;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
...@@ -198,6 +202,7 @@ type ...@@ -198,6 +202,7 @@ type
procedure addColorRow(num, Color, LPI, Size: string); procedure addColorRow(num, Color, LPI, Size: string);
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
[async] procedure AddCorrugatedOrder(orderJSON: TJSONObject); [async] procedure AddCorrugatedOrder(orderJSON: TJSONObject);
procedure btnCancelClick(Sender: TObject);
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -221,6 +226,7 @@ uses ...@@ -221,6 +226,7 @@ uses
View.Home, View.Main; View.Home, View.Main;
procedure TFOrderEntry.btnConfirmClick(Sender: TObject); procedure TFOrderEntry.btnConfirmClick(Sender: TObject);
// Converts all the information on the page into a JSON to then send to the server
var var
colorList: TJSONArray; colorList: TJSONArray;
container: TJSElement; container: TJSElement;
...@@ -358,6 +364,7 @@ begin ...@@ -358,6 +364,7 @@ begin
end; end;
procedure TFOrderEntry.AddCorrugatedOrder(orderJSON: TJSONObject); procedure TFOrderEntry.AddCorrugatedOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server
var var
Response: TXDataClientResponse; Response: TXDataClientResponse;
begin begin
...@@ -386,6 +393,9 @@ begin ...@@ -386,6 +393,9 @@ begin
end; end;
procedure TFOrderEntry.addColorRow(num: string; Color: string; LPI: string; Size: string); procedure TFOrderEntry.addColorRow(num: string; Color: string; LPI: string; Size: string);
// Java script code to add a row of colors when a button is clicked
// all variables are information to be placed in the boxes when loading an order.
// TODO: convert to Delphi
begin begin
asm asm
const container = document.getElementById('additionalFields'); const container = document.getElementById('additionalFields');
...@@ -440,6 +450,11 @@ begin ...@@ -440,6 +450,11 @@ begin
addColorRow('','','',''); addColorRow('','','','');
end; end;
procedure TFOrderEntry.btnCancelClick(Sender: TObject);
begin
FViewMain.ViewOrders('');
end;
procedure TFOrderEntry.WebFormCreate(Sender: TObject); procedure TFOrderEntry.WebFormCreate(Sender: TObject);
begin begin
if not DMConnection.ApiConnection.Connected then if not DMConnection.ApiConnection.Connected then
...@@ -450,6 +465,7 @@ begin ...@@ -450,6 +465,7 @@ begin
end; end;
procedure TFOrderEntry.getOrder(Order_ID: string); procedure TFOrderEntry.getOrder(Order_ID: string);
// retrieves an order from the server then loads the info into the page
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
orderList : TJSObject; orderList : TJSObject;
...@@ -598,6 +614,7 @@ begin ...@@ -598,6 +614,7 @@ begin
end; end;
procedure TFOrderEntry.getCustomer(customerID: string); procedure TFOrderEntry.getCustomer(customerID: string);
// gets a customer from the database then loads the appropiate fields
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
customer : TJSObject; customer : TJSObject;
......
...@@ -64,7 +64,6 @@ type ...@@ -64,7 +64,6 @@ type
procedure btnSearchClick(Sender: TObject); procedure btnSearchClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject); procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject); procedure btnPDFClick(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject); procedure wcbPageSizeChange(Sender: TObject);
procedure wlcbOrderByChange(Sender: TObject); procedure wlcbOrderByChange(Sender: TObject);
...@@ -79,10 +78,7 @@ type ...@@ -79,10 +78,7 @@ type
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure ShowAddOrderForm(); procedure ShowAddOrderForm();
procedure ShowSearchForm(); procedure ShowSearchForm();
[async] procedure Search(searchOptions: string);
[async] procedure GetOrders(searchOptions: string); [async] procedure GetOrders(searchOptions: string);
[async] procedure getUser();
procedure GeneratePDF(OrderID: string);
[async] procedure GenerateReportPDF; [async] procedure GenerateReportPDF;
var var
PageNumber: integer; PageNumber: integer;
...@@ -129,6 +125,7 @@ begin ...@@ -129,6 +125,7 @@ begin
end; end;
[async] procedure TFViewOrders.GenerateReportPDF; [async] procedure TFViewOrders.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
searchOptions, pdfURL: string; searchOptions, pdfURL: string;
...@@ -198,20 +195,6 @@ begin ...@@ -198,20 +195,6 @@ begin
getOrders(generateSearchOptions()); getOrders(generateSearchOptions());
end; end;
procedure TFViewOrders.getUser();
var
xdcResponse: TXDataClientResponse;
userList, user: TJSObject;
data: TJSArray;
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;
class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm; class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm;
var var
localInfo: string; localInfo: string;
...@@ -230,6 +213,7 @@ end; ...@@ -230,6 +213,7 @@ end;
procedure TFViewOrders.ShowAddOrderForm(); procedure TFViewOrders.ShowAddOrderForm();
// displays the add order pop-up so the user can choose a customer
var var
newform: TFAddOrder; newform: TFAddOrder;
begin begin
...@@ -252,6 +236,7 @@ begin ...@@ -252,6 +236,7 @@ begin
end; end;
procedure TFViewOrders.ShowSearchForm(); procedure TFViewOrders.ShowSearchForm();
// displays the search pop-up that allows the user to filter the order list
var var
newform: TFSearch; newform: TFSearch;
begin begin
...@@ -513,6 +498,8 @@ end; ...@@ -513,6 +498,8 @@ end;
procedure TFViewOrders.GetOrders(searchOptions: string); procedure TFViewOrders.GetOrders(searchOptions: string);
// retrieves a list of orders that fit a given search criteria
// searchOptions: search info to be sent to the server
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
orderList: TJSObject; orderList: TJSObject;
...@@ -578,65 +565,13 @@ begin ...@@ -578,65 +565,13 @@ begin
HideNotification(); HideNotification();
end; end;
procedure TFViewOrders.btnConfirmClick(Sender: TObject);
begin
//orderEntry('', 'ADD');
end;
procedure TFViewOrders.btnSearchClick(Sender: TObject); procedure TFViewOrders.btnSearchClick(Sender: TObject);
var var
filterSection: TJSHTMLElement; filterSection: TJSHTMLElement;
begin begin
{if btnFilters.Caption = 'Show Filters' then
begin
btnFilters.Caption := 'Hide Filters';
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
if Assigned(filterSection) then
filterSection.style.setProperty('display', 'block');
end
else
begin
btnFilters.Caption := 'Show Filters';
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
if Assigned(filterSection) then
filterSection.style.setProperty('display', 'none');
end;}
ShowSearchForm(); ShowSearchForm();
end; end;
procedure TFViewOrders.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 TFViewOrders.ClearTable(); procedure TFViewOrders.ClearTable();
// clears the table // clears the table
var var
...@@ -718,24 +653,4 @@ begin ...@@ -718,24 +653,4 @@ begin
end; end;
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.
// Search pop-up form used to filter the list.
// Author: Cameron Hayes
unit View.Search; unit View.Search;
interface interface
...@@ -105,6 +107,7 @@ begin ...@@ -105,6 +107,7 @@ begin
end; end;
procedure TFSearch.WebFormShow(Sender: TObject); procedure TFSearch.WebFormShow(Sender: TObject);
// Auto fills information based on previous search
var var
params: TStringList; params: TStringList;
DateFormatSettings: TFormatSettings; DateFormatSettings: TFormatSettings;
...@@ -241,6 +244,7 @@ begin ...@@ -241,6 +244,7 @@ begin
end; end;
[async] procedure TFSearch.getCustomers(); [async] procedure TFSearch.getCustomers();
// Gets a list of customers from the server
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
customerList: TJSObject; customerList: TJSObject;
......
...@@ -224,7 +224,6 @@ type ...@@ -224,7 +224,6 @@ type
[ServiceContract, Model(API_MODEL)] [ServiceContract, Model(API_MODEL)]
ILookupService = interface(IInvokable) ILookupService = interface(IInvokable)
['{F24E1468-5279-401F-A877-CD48B44F4416}'] ['{F24E1468-5279-401F-A877-CD48B44F4416}']
[HttpGet] function Search(phoneNum: string): TOrderList;
[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; [HttpGet] function GetOrders(searchOptions: string): TOrderList;
......
// Implementation of the Lookup Service interface used to send call information // Implementation of the Lookup Service interface used to send information
// to the client. // to the client. Very overcrowded. Probably should move SQL functions to new
// file.
// Authors: // Authors:
// Cameron Hayes // Cameron Hayes
// Mac ... // Mac ...
...@@ -34,16 +35,13 @@ type ...@@ -34,16 +35,13 @@ type
function GetCustomers(): TCustomerList; function GetCustomers(): TCustomerList;
function GetCustomer(ID: string): TCustomerItem; function GetCustomer(ID: string): TCustomerItem;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function Search(phoneNum: string): TOrderList;
function GenerateReportPDF(searchOptions: string): string; function GenerateReportPDF(searchOptions: string): string;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string; function AddItem(itemInfo: string): string;
function DelUser(username: string): string; function DelUser(username: string): string;
function GenerateSelectSQL(filterType, startDate, endDate: string): string;
function GenerateSubQuery(currStatus: string): string; function GenerateSubQuery(currStatus: 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 EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string;
function GenerateOrdersSQL(searchOptions: string): TSQLQuery; function GenerateOrdersSQL(searchOptions: string): TSQLQuery;
function GetColorCount(colors: string): string; function GetColorCount(colors: string): string;
function GenerateStatusSelectSQL(statusTableShort, statusTableLong, startDate, endDate, statusType: string): string; function GenerateStatusSelectSQL(statusTableShort, statusTableLong, startDate, endDate, statusType: string): string;
...@@ -73,6 +71,8 @@ begin ...@@ -73,6 +71,8 @@ begin
end; end;
function TLookupService.GetCustomers: TCustomerList; function TLookupService.GetCustomers: TCustomerList;
// Retrieves a list of customers and sends it to the client in object form.
// The object contains the ID, Name, Short Name, and the shipping address.
var var
SQL: string; SQL: string;
customer: TCustomerItem; customer: TCustomerItem;
...@@ -103,6 +103,8 @@ begin ...@@ -103,6 +103,8 @@ begin
end; end;
function TLookupService.GetCustomer(ID: string): TCustomerItem; function TLookupService.GetCustomer(ID: string): TCustomerItem;
// Gets one specific customer from the ID given by the client. This is used for
// the OrderEntry forms.
var var
SQL: string; SQL: string;
ADDRESS: TAddressItem; ADDRESS: TAddressItem;
...@@ -131,44 +133,9 @@ begin ...@@ -131,44 +133,9 @@ begin
end; end;
function TLookupService.Search(phoneNum: string): TOrderList;
// Searchs the database for a specific from phone number then returns a list of
// calls from said number
// SQL: String of the sql query used to retrieve info from the database
// call: object representing the call information we want to send to the client
// Return: A list of calls
var
SQL: string;
order: TOrderItem;
begin
SQL := 'select * ' +
'from calls inner join recordings on calls.sid = recordings.call_sid ' +
'where from_formatted = ' + QuotedStr(PhoneNum) + ' order by calls.date_created desc';
doQuery(ordersDB.UniQuery1, SQL);
Result:= TOrderList.Create;
Result.data := TList<TOrderItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.data );
while not ordersDB.UniQuery1.Eof do
begin
order := TOrderItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( order );
Result.data.Add( order );
//TODO
end;
ordersDB.UniQuery1.Close;
SQL:= '';
doQuery(ordersDB.UniQuery1, SQL);
Result.count := ordersDB.UniQuery1.FieldByName('total_count').AsInteger;
end;
function TLookupService.GenerateReportPDF(searchOptions: string): string; function TLookupService.GenerateReportPDF(searchOptions: string): string;
// Generates a report pdf based on the last search (if any) Linked to rOrders
// file which does most of the work.
var var
SQL: string; SQL: string;
rptOrders: TrptOrders; // Local instance of rptOrders rptOrders: TrptOrders; // Local instance of rptOrders
...@@ -192,14 +159,13 @@ begin ...@@ -192,14 +159,13 @@ begin
end; end;
end; end;
function TLookupService.generateSelectSQL(filterType, startDate, endDate: string): string;
begin
end;
function TLookupService.generateSubQuery(currStatus: string): string; function TLookupService.generateSubQuery(currStatus: string): string;
// Generates the subquery in order to retrieve all the status due/done dates
// This must be a subquery because there are at most 5 different entries which
// causes the query to return 5 different entries on a join. There is probably
// a work around but I couldn't get the SQL to work with it. Manually goes through
// all 5 statuses.
// currStatus: current status SQL is getting generated for.
begin begin
result := '(select oss.STATUS_DATE from orders_status_schedule oss ' + result := '(select oss.STATUS_DATE from orders_status_schedule oss ' +
'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = ' + quotedStr(currStatus) + ') AS '+ currStatus + '_DUE,'; 'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = ' + quotedStr(currStatus) + ') AS '+ currStatus + '_DUE,';
...@@ -209,6 +175,11 @@ begin ...@@ -209,6 +175,11 @@ begin
end; end;
function TLookupService.generateStatusSelectSQL(statusTableShort: string; statusTableLong: string; startDate: string; endDate: string; statusType: string): string; function TLookupService.generateStatusSelectSQL(statusTableShort: string; statusTableLong: string; startDate: string; endDate: string; statusType: string): string;
// Generates the SQL query to figure out whether or not an entry exists within
// a given time frame.
// statusTableShort: short name for the status tables (os or oss)
// statusTableLong: full name for the status table
// startDate/endDate: starting date/ending date for when the status is due/done.
begin begin
result := 'exists ( select 1 from ' + statusTableLong + ' ' + result := 'exists ( select 1 from ' + statusTableLong + ' ' +
statusTableShort + ' where ' + statusTableShort + '.ORDER_ID = ' + statusTableShort + ' where ' + statusTableShort + '.ORDER_ID = ' +
...@@ -229,6 +200,12 @@ begin ...@@ -229,6 +200,12 @@ begin
end; end;
function TLookupService.createStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo; function TLookupService.createStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo;
// Takes all the status info recieved from the client and puts it into an object
// for convinence and to make it easier to expand. Returns said object.
// params: string list recieved from the client with all the search params
// statusNum: which status number we are on to make it easier to tell what info
// we want to take from client. I.E. differentiate between startDate1 and
// startDate2
var var
statusType: string; statusType: string;
begin begin
...@@ -267,6 +244,9 @@ begin ...@@ -267,6 +244,9 @@ begin
end; end;
function TLookupService.generateStatusWhereSQL(status: TStatusSearchInfo): string; function TLookupService.generateStatusWhereSQL(status: TStatusSearchInfo): string;
// Generates the where SQL for each status to apply the filters used from the
// clients search.
// status - status information obtained from the client.
begin begin
if status.filterType <> 'ORDER_DATE' then if status.filterType <> 'ORDER_DATE' then
begin begin
...@@ -276,8 +256,9 @@ begin ...@@ -276,8 +256,9 @@ begin
' ' + status.statusTableShort + ' where ' ' ' + status.statusTableShort + ' where '
+ status.statusTableShort +'.ORDER_ID = o.ORDER_ID ' + + status.statusTableShort +'.ORDER_ID = o.ORDER_ID ' +
'AND ' + status.statusTableShort + '.ORDER_STATUS = ' + 'AND ' + status.statusTableShort + '.ORDER_STATUS = ' +
quotedStr(status.statusType) + ') AND ' + quotedStr(status.statusType) + ')';
generateStatusSelectSQL(status.altStatusTableShort, status.altStatusTableLong, status.startDate, status.endDate, status.statusType); // out dated useage. uncomment if you want to return entries where dues are null, but dones exist or vice versa.
//generateStatusSelectSQL(status.altStatusTableShort, status.altStatusTableLong, status.startDate, status.endDate, status.statusType);
end end
else else
result := result + ' AND ' + generateStatusSelectSQL(status.statusTableShort, status.statusTableLong, status.startDate, status.endDate, status.statusType); result := result + ' AND ' + generateStatusSelectSQL(status.statusTableShort, status.statusTableLong, status.startDate, status.endDate, status.statusType);
...@@ -297,6 +278,9 @@ begin ...@@ -297,6 +278,9 @@ begin
end; end;
function TLookupService.generateOrdersSQL(searchOptions: string): TSQLQuery; function TLookupService.generateOrdersSQL(searchOptions: string): TSQLQuery;
// Generates the orderSQL to retrieve entries specified by the search recieved
// from the client.
// searchOptions: search information sent form client to be parsed.
var var
params: TStringList; params: TStringList;
PageNum: integer; PageNum: integer;
...@@ -390,6 +374,9 @@ begin ...@@ -390,6 +374,9 @@ begin
end; end;
function TLookupService.getColorCount(colors: string): string; function TLookupService.getColorCount(colors: string): string;
// Colors are stored in a JSON in the database so this function parses the
// stringified JSON and returns the count of colors.
// colors: stringified JSON to be parsed.
var var
colorObject: TJSONObject; colorObject: TJSONObject;
colorList: TJSONArray; colorList: TJSONArray;
...@@ -478,6 +465,9 @@ begin ...@@ -478,6 +465,9 @@ begin
end; end;
function TLookupService.GetOrder(orderInfo: string): TFullOrder; function TLookupService.GetOrder(orderInfo: string): TFullOrder;
// Gets on singular order from the database for the order entry page.
// orderInfo: the ORDER_ID.
// TODO seperate this into GetCorrugatedOrder and GetWebOrder.
var var
orderType: string; orderType: string;
orderID: string; orderID: string;
...@@ -658,6 +648,10 @@ begin ...@@ -658,6 +648,10 @@ begin
end; end;
function TLookupService.GetItems(searchOptions: string): TItemList; function TLookupService.GetItems(searchOptions: string): TItemList;
// retrueves all the quickbooks items for the items page on client.
// searchOptions: probably not needed but adds limits to the page to prevent
// table on client side from getting too long. This table currently has about 27
// entries so probably not needed.
var var
params: TStringList; params: TStringList;
PageNum: integer; PageNum: integer;
...@@ -709,6 +703,9 @@ begin ...@@ -709,6 +703,9 @@ begin
end; end;
function TLookupService.GetUsers(searchOptions: string): TUserList; function TLookupService.GetUsers(searchOptions: string): TUserList;
// Gets a list of all users for the user edit page.
// searchOptions: username of a specific user otherwise empty.
// TODO: change SQL to hide passwords instead of storing them in plain text.
var var
SQL: string; SQL: string;
user: TUserItem; user: TUserItem;
...@@ -748,6 +745,8 @@ begin ...@@ -748,6 +745,8 @@ begin
end; end;
function TLookupService.EditUser(const editOptions: string): string; function TLookupService.EditUser(const editOptions: string): string;
// Edits the user.
// editOptions: all user information that will be changed.
var var
params: TStringList; params: TStringList;
user: string; user: string;
...@@ -834,6 +833,10 @@ begin ...@@ -834,6 +833,10 @@ begin
end; end;
function TLookupService.AddCorrugatedOrder(orderInfo: string): TJSONObject; function TLookupService.AddCorrugatedOrder(orderInfo: string): TJSONObject;
// Adds corrugated order to the database. This process is done in 3 different
// tables so if any changes are made make sure to check orders, corrugated_plate_orders
// and orders_status_schedule. This also functions as an edit function.
// orderInfo - all the inputted order information from client side.
var var
JSONData, ResponseData: TJSONObject; JSONData, ResponseData: TJSONObject;
SQL: string; SQL: string;
...@@ -943,9 +946,14 @@ begin ...@@ -943,9 +946,14 @@ begin
end; end;
function TLookupService.AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string; function TLookupService.AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
// Adds/edits orders_status_schedule table.
// StatusType: name of the status getting added to the schedule.
// Order: JSON object containing all of the order info sent from client
// ORDER_ID: order id sent from client if we are in edit mode empty if in add mode
var var
SQL: string; SQL: string;
mode: string; mode: string;
change: boolean;
begin begin
mode := order.GetValue<string>('mode'); mode := order.GetValue<string>('mode');
if mode = 'ADD' then if mode = 'ADD' then
...@@ -956,7 +964,7 @@ begin ...@@ -956,7 +964,7 @@ begin
end end
else else
begin begin
SQL := 'select * from orders_status_schedule where ORDER_ID = ' + IntToStr(ORDER_ID); SQL := 'select * from orders_status_schedule where ORDER_ID = ' + IntToStr(ORDER_ID) + ' AND ORDER_STATUS = ' + quotedStr(StatusType);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Edit; ordersDB.UniQuery1.Edit;
end; end;
...@@ -966,12 +974,16 @@ begin ...@@ -966,12 +974,16 @@ begin
if( (StatusType = 'PROOF') or (StatusType = 'SHIP') ) then if( (StatusType = 'PROOF') or (StatusType = 'SHIP') ) then
begin begin
change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString <> order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date'); ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
if mode <> 'EDIT' then
ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date'); ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
end end
else else
begin begin
change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime <> StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'));
ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due')); ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'));
if mode <> 'EDIT' then
ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due')); ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'));
end; end;
ordersDB.UniQuery1.FieldByName('USER_ID').AsString := order.GetValue<string>('USER_ID'); ordersDB.UniQuery1.FieldByName('USER_ID').AsString := order.GetValue<string>('USER_ID');
...@@ -979,20 +991,19 @@ begin ...@@ -979,20 +991,19 @@ begin
if mode = 'ADD' then if mode = 'ADD' then
ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger := 1 ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger := 1
else else
begin
if change then
ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger := ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger + 1; ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger := ordersDB.UniQuery1.FieldByName('ORDER_REVISION').AsInteger + 1;
end;
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
Result := 'success'; Result := 'success';
end; end;
function TLookupService.EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string;
var
SQL: string;
begin
end;
function TLookupService.AddUser(userInfo:string): string; function TLookupService.AddUser(userInfo:string): string;
// Adds a user to the database
// userInfo - user information being added
var var
user: string; user: string;
password: string; password: string;
...@@ -1060,6 +1071,8 @@ begin ...@@ -1060,6 +1071,8 @@ begin
end; end;
function TLookupService.AddItem(itemInfo: string): string; function TLookupService.AddItem(itemInfo: string): string;
// Adds an item to the database
// itemInfo: item info to add to database
var var
params: TStringList; params: TStringList;
Name: string; Name: string;
...@@ -1099,8 +1112,10 @@ begin ...@@ -1099,8 +1112,10 @@ begin
end; end;
function TLookupService.DelUser(username: string): string; function TLookupService.DelUser(username: string): string;
// deletes a user. not currently implemented definitely needs touching up to avoid
// deleting users prematurely.
// username: username to be deleted.
var var
SQL: string; SQL: string;
params: TStringList; params: TStringList;
begin begin
......
[Settings] [Settings]
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=5 FileLogLevel=5
LogFileNum=79 LogFileNum=86
webClientVersion=1.0.0 webClientVersion=1.0.0
[Database] [Database]
......
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