Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KGOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
KGOrders
Commits
7c01cce8
Commit
7c01cce8
authored
Jan 09, 2025
by
cam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with status schedule not being updated properly
Also added needed documentation
parent
7a2dffa1
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
148 additions
and
202 deletions
+148
-202
View.AddOrder.pas
kgOrdersClient/View.AddOrder.pas
+6
-5
View.Items.pas
kgOrdersClient/View.Items.pas
+9
-43
View.OrderEntryCorrugated.dfm
kgOrdersClient/View.OrderEntryCorrugated.dfm
+25
-2
View.OrderEntryCorrugated.html
kgOrdersClient/View.OrderEntryCorrugated.html
+7
-1
View.OrderEntryCorrugated.pas
kgOrdersClient/View.OrderEntryCorrugated.pas
+17
-0
View.Orders.pas
kgOrdersClient/View.Orders.pas
+5
-90
View.Search.pas
kgOrdersClient/View.Search.pas
+4
-0
Lookup.Service.pas
kgOrdersServer/Source/Lookup.Service.pas
+0
-1
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+74
-59
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+1
-1
No files found.
kgOrdersClient/View.AddOrder.pas
View file @
7c01cce8
// 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
;
interface
...
...
@@ -56,7 +58,6 @@ implementation
procedure
TFAddOrder
.
btnCancelClick
(
Sender
:
TObject
);
begin
edtID
.
Text
:=
''
;
Close
;
end
;
...
...
@@ -89,6 +90,7 @@ begin
end
;
[
async
]
procedure
TFAddOrder
.
getCustomers
();
// retrieves customer list from server
var
xdcResponse
:
TXDataClientResponse
;
customerList
:
TJSObject
;
...
...
@@ -107,6 +109,7 @@ begin
end
;
procedure
TFAddOrder
.
PopulateGridManually
;
// populates the grid with customers manually.
var
RowIndex
:
Integer
;
begin
...
...
@@ -122,10 +125,6 @@ begin
TMSFNCGrid1
.
Cells
[
2
,
0
]
:=
'Name'
;
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
xdwdsCustomers
.
First
;
RowIndex
:=
1
;
...
...
@@ -152,11 +151,13 @@ end;
procedure
TFAddOrder
.
TMSFNCGrid1SelectedCell
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
// When a cell is clicked it puts the ID in the text box
begin
edtID
.
Text
:=
TMSFNCGrid1
.
Cells
[
0
,
ARow
];
end
;
procedure
TFAddOrder
.
ApplyFilter
;
// filters the grid based on search textbox contents.
var
fd
:
TTMSFNCGridFilterData
;
i
:
Integer
;
...
...
kgOrdersClient/View.Items.pas
View file @
7c01cce8
...
...
@@ -26,7 +26,6 @@ type
cbStatus
:
TWebCheckBox
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
btnApplyClick
(
Sender
:
TObject
);
procedure
btnSearchClick
(
Sender
:
TObject
);
procedure
wcbPageSizeChange
(
Sender
:
TObject
);
private
FChildForm
:
TWebForm
;
...
...
@@ -34,7 +33,6 @@ type
procedure
ClearTable
();
procedure
GeneratePagination
(
TotalPages
:
Integer
);
function
GenerateSearchOptions
():
string
;
[
async
]
procedure
Search
(
searchOptions
:
string
);
[
async
]
procedure
GetItems
(
searchOptions
:
string
);
[
async
]
procedure
getUser
();
[
async
]
procedure
AddItem
(
itemOptions
:
string
);
...
...
@@ -86,11 +84,10 @@ 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
// ID: item ID
// Name: item name
// Description: item description
// Status: inactive or active
var
NewRow
,
Cell
,
P
,
Button
,
Audio
:
TJSHTMLElement
;
begin
...
...
@@ -293,6 +290,9 @@ begin
end
;
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
xdcResponse
:
TXDataClientResponse
;
itemList
:
TJSObject
;
...
...
@@ -355,6 +355,7 @@ begin
end
;
procedure
TFViewItems
.
AddItem
(
itemOptions
:
string
);
// adds an item to the database.
var
xdcResponse
:
TXDataClientResponse
;
begin
...
...
@@ -363,48 +364,13 @@ begin
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
);
// gets a new amount of items based when the page size is changed
begin
PageNumber
:=
1
;
getItems
(
GenerateSearchOptions
());
end
;
procedure
TFViewItems
.
btnSearchClick
(
Sender
:
TObject
);
// item Search method
begin
//Search(edtSearch.Text);
end
;
procedure
TFViewItems
.
ClearTable
();
// clears the table
var
...
...
kgOrdersClient/View.OrderEntryCorrugated.dfm
View file @
7c01cce8
...
...
@@ -797,8 +797,8 @@ object FOrderEntry: TFOrderEntry
DataSource = WebDataSource1
end
object btnConfirm: TWebButton
Left =
7
52
Top = 5
58
Left =
6
52
Top = 5
60
Width = 96
Height = 25
Caption = 'Confirm'
...
...
@@ -965,6 +965,29 @@ object FOrderEntry: TFOrderEntry
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
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
Connection = DMConnection.ApiConnection
Left = 244
...
...
kgOrdersClient/View.OrderEntryCorrugated.html
View file @
7c01cce8
...
...
@@ -300,7 +300,13 @@
</div>
<div
class=
"row"
>
<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>
...
...
kgOrdersClient/View.OrderEntryCorrugated.pas
View file @
7c01cce8
// Order Entry page of Corruguated Orders. Used for both editting and adding
// orders.
unit
View
.
OrderEntryCorrugated
;
interface
...
...
@@ -187,6 +189,8 @@ type
WebDBComboBox1
:
TWebDBComboBox
;
cbEmail
:
TWebCheckBox
;
XDataWebDataSet1supplied_by_customer_order_date
:
TStringField
;
btnEdit
:
TWebButton
;
btnCancel
:
TWebButton
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
HideNotification
();
procedure
ShowNotification
(
Notification
:
string
);
...
...
@@ -198,6 +202,7 @@ type
procedure
addColorRow
(
num
,
Color
,
LPI
,
Size
:
string
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
[
async
]
procedure
AddCorrugatedOrder
(
orderJSON
:
TJSONObject
);
procedure
btnCancelClick
(
Sender
:
TObject
);
private
FAgencyCode
:
string
;
FCurrentReportType
:
string
;
...
...
@@ -221,6 +226,7 @@ uses
View
.
Home
,
View
.
Main
;
procedure
TFOrderEntry
.
btnConfirmClick
(
Sender
:
TObject
);
// Converts all the information on the page into a JSON to then send to the server
var
colorList
:
TJSONArray
;
container
:
TJSElement
;
...
...
@@ -358,6 +364,7 @@ begin
end
;
procedure
TFOrderEntry
.
AddCorrugatedOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
Response
:
TXDataClientResponse
;
begin
...
...
@@ -386,6 +393,9 @@ begin
end
;
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
asm
const
container
=
document
.
getElementById
(
'additionalFields'
);
...
...
@@ -440,6 +450,11 @@ begin
addColorRow
(
''
,
''
,
''
,
''
);
end
;
procedure
TFOrderEntry
.
btnCancelClick
(
Sender
:
TObject
);
begin
FViewMain
.
ViewOrders
(
''
);
end
;
procedure
TFOrderEntry
.
WebFormCreate
(
Sender
:
TObject
);
begin
if
not
DMConnection
.
ApiConnection
.
Connected
then
...
...
@@ -450,6 +465,7 @@ begin
end
;
procedure
TFOrderEntry
.
getOrder
(
Order_ID
:
string
);
// retrieves an order from the server then loads the info into the page
var
xdcResponse
:
TXDataClientResponse
;
orderList
:
TJSObject
;
...
...
@@ -598,6 +614,7 @@ begin
end
;
procedure
TFOrderEntry
.
getCustomer
(
customerID
:
string
);
// gets a customer from the database then loads the appropiate fields
var
xdcResponse
:
TXDataClientResponse
;
customer
:
TJSObject
;
...
...
kgOrdersClient/View.Orders.pas
View file @
7c01cce8
...
...
@@ -64,7 +64,6 @@ type
procedure
btnSearchClick
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
btnPDFClick
(
Sender
:
TObject
);
procedure
wcbPageSizeChange
(
Sender
:
TObject
);
procedure
wlcbOrderByChange
(
Sender
:
TObject
);
...
...
@@ -79,10 +78,7 @@ type
procedure
ShowNotification
(
Notification
:
string
);
procedure
ShowAddOrderForm
();
procedure
ShowSearchForm
();
[
async
]
procedure
Search
(
searchOptions
:
string
);
[
async
]
procedure
GetOrders
(
searchOptions
:
string
);
[
async
]
procedure
getUser
();
procedure
GeneratePDF
(
OrderID
:
string
);
[
async
]
procedure
GenerateReportPDF
;
var
PageNumber
:
integer
;
...
...
@@ -129,6 +125,7 @@ begin
end
;
[
async
]
procedure
TFViewOrders
.
GenerateReportPDF
;
// sends the search to the server which then sends back a pdf of the results
var
xdcResponse
:
TXDataClientResponse
;
searchOptions
,
pdfURL
:
string
;
...
...
@@ -198,20 +195,6 @@ begin
getOrders
(
generateSearchOptions
());
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
;
var
localInfo
:
string
;
...
...
@@ -230,6 +213,7 @@ end;
procedure
TFViewOrders
.
ShowAddOrderForm
();
// displays the add order pop-up so the user can choose a customer
var
newform
:
TFAddOrder
;
begin
...
...
@@ -252,6 +236,7 @@ begin
end
;
procedure
TFViewOrders
.
ShowSearchForm
();
// displays the search pop-up that allows the user to filter the order list
var
newform
:
TFSearch
;
begin
...
...
@@ -513,6 +498,8 @@ end;
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
xdcResponse
:
TXDataClientResponse
;
orderList
:
TJSObject
;
...
...
@@ -578,65 +565,13 @@ begin
HideNotification
();
end
;
procedure
TFViewOrders
.
btnConfirmClick
(
Sender
:
TObject
);
begin
//orderEntry('', 'ADD');
end
;
procedure
TFViewOrders
.
btnSearchClick
(
Sender
:
TObject
);
var
filterSection
:
TJSHTMLElement
;
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
();
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
();
// clears the table
var
...
...
@@ -718,24 +653,4 @@ begin
end
;
end
;
procedure
TFViewOrders
.
GeneratePDF
(
OrderID
:
string
);
var
XDCResponse
:
TXDataClientResponse
;
PDFBase64
:
string
;
PDFBlob
:
TJSUint8Array
;
PDFLink
:
TJSHTMLElement
;
begin
// XDCResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderPDF', [OrderID]));
// PDFBase64 := string(XDCResponse.Result);
//
// // Convert Base64 to binary and create a link to download it
// PDFBlob := TJSUint8Array.new(TJSBase64.decodeBase64(PDFBase64));
// PDFLink := TJSHTMLElement(document.createElement('a'));
// PDFLink.setAttribute('href', 'data:application/pdf;base64,' + PDFBase64);
// PDFLink.setAttribute('download', 'Order_' + OrderID + '.pdf');
// PDFLink.click;
end
;
end
.
kgOrdersClient/View.Search.pas
View file @
7c01cce8
// Search pop-up form used to filter the list.
// Author: Cameron Hayes
unit
View
.
Search
;
interface
...
...
@@ -105,6 +107,7 @@ begin
end
;
procedure
TFSearch
.
WebFormShow
(
Sender
:
TObject
);
// Auto fills information based on previous search
var
params
:
TStringList
;
DateFormatSettings
:
TFormatSettings
;
...
...
@@ -241,6 +244,7 @@ begin
end
;
[
async
]
procedure
TFSearch
.
getCustomers
();
// Gets a list of customers from the server
var
xdcResponse
:
TXDataClientResponse
;
customerList
:
TJSObject
;
...
...
kgOrdersServer/Source/Lookup.Service.pas
View file @
7c01cce8
...
...
@@ -224,7 +224,6 @@ type
[
ServiceContract
,
Model
(
API_MODEL
)]
ILookupService
=
interface
(
IInvokable
)
[
'{F24E1468-5279-401F-A877-CD48B44F4416}'
]
[
HttpGet
]
function
Search
(
phoneNum
:
string
):
TOrderList
;
[
HttpGet
]
function
GetUsers
(
searchOptions
:
string
):
TUserList
;
[
HttpGet
]
function
GetItems
(
searchOptions
:
string
):
TItemList
;
[
HttpGet
]
function
GetOrders
(
searchOptions
:
string
):
TOrderList
;
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
7c01cce8
// Implementation of the Lookup Service interface used to send call information
// to the client.
// Implementation of the Lookup Service interface used to send information
// to the client. Very overcrowded. Probably should move SQL functions to new
// file.
// Authors:
// Cameron Hayes
// Mac ...
...
...
@@ -34,16 +35,13 @@ type
function
GetCustomers
():
TCustomerList
;
function
GetCustomer
(
ID
:
string
):
TCustomerItem
;
function
EditUser
(
const
editOptions
:
string
):
string
;
function
Search
(
phoneNum
:
string
):
TOrderList
;
function
GenerateReportPDF
(
searchOptions
:
string
):
string
;
function
AddUser
(
userInfo
:
string
):
string
;
function
AddItem
(
itemInfo
:
string
):
string
;
function
DelUser
(
username
:
string
):
string
;
function
GenerateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
function
GenerateSubQuery
(
currStatus
:
string
):
string
;
function
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
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
GetColorCount
(
colors
:
string
):
string
;
function
GenerateStatusSelectSQL
(
statusTableShort
,
statusTableLong
,
startDate
,
endDate
,
statusType
:
string
):
string
;
...
...
@@ -73,6 +71,8 @@ begin
end
;
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
SQL
:
string
;
customer
:
TCustomerItem
;
...
...
@@ -103,6 +103,8 @@ begin
end
;
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
SQL
:
string
;
ADDRESS
:
TAddressItem
;
...
...
@@ -131,44 +133,9 @@ begin
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
;
// Generates a report pdf based on the last search (if any) Linked to rOrders
// file which does most of the work.
var
SQL
:
string
;
rptOrders
:
TrptOrders
;
// Local instance of rptOrders
...
...
@@ -192,14 +159,13 @@ begin
end
;
end
;
function
TLookupService
.
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
begin
end
;
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
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,'
;
...
...
@@ -209,6 +175,11 @@ begin
end
;
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
result
:=
'exists ( select 1 from '
+
statusTableLong
+
' '
+
statusTableShort
+
' where '
+
statusTableShort
+
'.ORDER_ID = '
+
...
...
@@ -229,6 +200,12 @@ begin
end
;
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
statusType
:
string
;
begin
...
...
@@ -267,6 +244,9 @@ begin
end
;
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
if
status
.
filterType
<>
'ORDER_DATE'
then
begin
...
...
@@ -276,8 +256,9 @@ begin
' '
+
status
.
statusTableShort
+
' where '
+
status
.
statusTableShort
+
'.ORDER_ID = o.ORDER_ID '
+
'AND '
+
status
.
statusTableShort
+
'.ORDER_STATUS = '
+
quotedStr
(
status
.
statusType
)
+
') AND '
+
generateStatusSelectSQL
(
status
.
altStatusTableShort
,
status
.
altStatusTableLong
,
status
.
startDate
,
status
.
endDate
,
status
.
statusType
);
quotedStr
(
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
else
result
:=
result
+
' AND '
+
generateStatusSelectSQL
(
status
.
statusTableShort
,
status
.
statusTableLong
,
status
.
startDate
,
status
.
endDate
,
status
.
statusType
);
...
...
@@ -297,6 +278,9 @@ begin
end
;
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
params
:
TStringList
;
PageNum
:
integer
;
...
...
@@ -390,6 +374,9 @@ begin
end
;
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
colorObject
:
TJSONObject
;
colorList
:
TJSONArray
;
...
...
@@ -478,6 +465,9 @@ begin
end
;
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
orderType
:
string
;
orderID
:
string
;
...
...
@@ -658,6 +648,10 @@ begin
end
;
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
params
:
TStringList
;
PageNum
:
integer
;
...
...
@@ -709,6 +703,9 @@ begin
end
;
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
SQL
:
string
;
user
:
TUserItem
;
...
...
@@ -748,6 +745,8 @@ begin
end
;
function
TLookupService
.
EditUser
(
const
editOptions
:
string
):
string
;
// Edits the user.
// editOptions: all user information that will be changed.
var
params
:
TStringList
;
user
:
string
;
...
...
@@ -834,6 +833,10 @@ begin
end
;
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
JSONData
,
ResponseData
:
TJSONObject
;
SQL
:
string
;
...
...
@@ -943,9 +946,14 @@ begin
end
;
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
SQL
:
string
;
mode
:
string
;
change
:
boolean
;
begin
mode
:=
order
.
GetValue
<
string
>(
'mode'
);
if
mode
=
'ADD'
then
...
...
@@ -956,7 +964,7 @@ begin
end
else
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
);
ordersDB
.
UniQuery1
.
Edit
;
end
;
...
...
@@ -966,12 +974,16 @@ begin
if
(
(
StatusType
=
'PROOF'
)
or
(
StatusType
=
'SHIP'
)
)
then
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'
);
if
mode
<>
'EDIT'
then
ordersDB
.
UniQuery1
.
FieldByName
(
'ORIGINAL_STATUS_DATE'
).
AsString
:=
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_date'
);
end
else
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'
));
if
mode
<>
'EDIT'
then
ordersDB
.
UniQuery1
.
FieldByName
(
'ORIGINAL_STATUS_DATE'
).
AsDateTime
:=
StrToDateTime
(
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_due'
));
end
;
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_ID'
).
AsString
:=
order
.
GetValue
<
string
>(
'USER_ID'
);
...
...
@@ -979,20 +991,19 @@ begin
if
mode
=
'ADD'
then
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION'
).
AsInteger
:=
1
else
begin
if
change
then
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION'
).
AsInteger
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION'
).
AsInteger
+
1
;
end
;
ordersDB
.
UniQuery1
.
Post
;
Result
:=
'success'
;
end
;
function
TLookupService
.
EditStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
string
):
string
;
var
SQL
:
string
;
begin
end
;
function
TLookupService
.
AddUser
(
userInfo
:
string
):
string
;
// Adds a user to the database
// userInfo - user information being added
var
user
:
string
;
password
:
string
;
...
...
@@ -1060,6 +1071,8 @@ begin
end
;
function
TLookupService
.
AddItem
(
itemInfo
:
string
):
string
;
// Adds an item to the database
// itemInfo: item info to add to database
var
params
:
TStringList
;
Name
:
string
;
...
...
@@ -1099,8 +1112,10 @@ begin
end
;
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
SQL
:
string
;
params
:
TStringList
;
begin
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
7c01cce8
[Settings]
MemoLogLevel
=
4
FileLogLevel
=
5
LogFileNum
=
79
LogFileNum
=
86
webClientVersion
=
1.0.0
[Database]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment