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
e92fbc25
Commit
e92fbc25
authored
Dec 18, 2024
by
Elias Sarraf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
a7e54751
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
70 deletions
+55
-70
View.Orders.pas
kgOrdersClient/View.Orders.pas
+1
-6
Data.pas
kgOrdersServer/Source/Data.pas
+1
-1
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+11
-22
rOrders.dfm
kgOrdersServer/Source/rOrders.dfm
+0
-0
rOrders.pas
kgOrdersServer/Source/rOrders.pas
+42
-41
rptOrders.fr3
kgOrdersServer/Source/rptOrders.fr3
+0
-0
No files found.
kgOrdersClient/View.Orders.pas
View file @
e92fbc25
...
@@ -82,6 +82,7 @@ type
...
@@ -82,6 +82,7 @@ type
[
async
]
procedure
Search
(
searchOptions
:
string
);
[
async
]
procedure
Search
(
searchOptions
:
string
);
[
async
]
procedure
GetOrders
(
searchOptions
:
string
);
[
async
]
procedure
GetOrders
(
searchOptions
:
string
);
[
async
]
procedure
getUser
();
[
async
]
procedure
getUser
();
procedure
GeneratePDF
(
OrderID
:
string
);
[
async
]
procedure
GenerateReportPDF
;
[
async
]
procedure
GenerateReportPDF
;
var
var
PageNumber
:
integer
;
PageNumber
:
integer
;
...
@@ -124,10 +125,7 @@ begin
...
@@ -124,10 +125,7 @@ begin
ShowMessage
(
'PDF Report Generated Successfully'
);
ShowMessage
(
'PDF Report Generated Successfully'
);
end
;
end
;
<<<<<<<
HEAD
=======
>>>>>>>
f1a2333
(
clean
up
code
)
procedure
TFViewOrders
.
WebFormCreate
(
Sender
:
TObject
);
procedure
TFViewOrders
.
WebFormCreate
(
Sender
:
TObject
);
// Initializes important values:
// Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
...
@@ -591,8 +589,6 @@ begin
...
@@ -591,8 +589,6 @@ begin
end
;
end
;
<<<<<<<
HEAD
=======
procedure
TFViewOrders
.
GeneratePDF
(
OrderID
:
string
);
procedure
TFViewOrders
.
GeneratePDF
(
OrderID
:
string
);
var
var
XDCResponse
:
TXDataClientResponse
;
XDCResponse
:
TXDataClientResponse
;
...
@@ -612,5 +608,4 @@ begin
...
@@ -612,5 +608,4 @@ begin
end
;
end
;
>>>>>>>
f1a2333
(
clean
up
code
)
end
.
end
.
kgOrdersServer/Source/Data.pas
View file @
e92fbc25
...
@@ -99,7 +99,7 @@ begin
...
@@ -99,7 +99,7 @@ begin
OrderIDList
.
Add
(
'18993'
);
// Add more OrderIDs as needed
OrderIDList
.
Add
(
'18993'
);
// Add more OrderIDs as needed
// Generate the PDF Report with the list of OrderIDs
// Generate the PDF Report with the list of OrderIDs
//
rptOrders.GenerateSimpleReport(350);
rptOrders
.
GenerateSimpleReport
(
350
);
finally
finally
OrderIDList
.
Free
;
// Free the TStringList
OrderIDList
.
Free
;
// Free the TStringList
end
;
end
;
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
e92fbc25
...
@@ -36,6 +36,7 @@ type
...
@@ -36,6 +36,7 @@ type
function
EditUser
(
const
editOptions
:
string
):
string
;
function
EditUser
(
const
editOptions
:
string
):
string
;
function
Search
(
phoneNum
:
string
):
TOrderList
;
function
Search
(
phoneNum
:
string
):
TOrderList
;
procedure
GenerateReportPDF
(
searchOptions
:
string
);
procedure
GenerateReportPDF
(
searchOptions
:
string
);
function
BuildOrderQuery
(
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
;
...
@@ -46,7 +47,6 @@ type
...
@@ -46,7 +47,6 @@ type
function
EditStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
string
):
string
;
function
EditStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
string
):
string
;
procedure
AfterConstruction
;
override
;
procedure
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
procedure
BeforeDestruction
;
override
;
function
BuildOrderQuery
(
searchOptions
:
string
):
string
;
end
;
end
;
implementation
implementation
...
@@ -167,25 +167,24 @@ end;
...
@@ -167,25 +167,24 @@ end;
procedure
TLookupService
.
GenerateReportPDF
(
searchOptions
:
string
);
procedure
TLookupService
.
GenerateReportPDF
(
searchOptions
:
string
);
var
var
SQL
:
string
;
SQL
:
string
;
rptOrders
:
TrptOrders
;
rptOrders
:
TrptOrders
;
// Local instance of rptOrders
begin
begin
// Create instance of rptOrders
rptOrders
:=
TrptOrders
.
Create
(
nil
);
rptOrders
:=
TrptOrders
.
Create
(
nil
);
try
try
// Generate
dynamic SQL based on searchOptions
// Generate
SQL dynamically using the existing GetOrders logic
SQL
:=
BuildOrderQuery
(
searchOptions
);
SQL
:=
BuildOrderQuery
(
searchOptions
);
// Log the SQL for debugging
Logger
.
log
(
5
,
'Generated SQL: '
+
SQL
);
// Prepare the report dataset
// Prepare the report dataset
rptOrders
.
PrepareReport
(
SQL
);
rptOrders
.
PrepareReport
(
SQL
);
// Generate
and save the PDF
// Generate
the PDF report
rptOrders
.
GeneratePDF
;
rptOrders
.
GeneratePDF
;
Logger
.
log
(
5
,
'PDF generated successfully.'
);
// Optionally, log success
Logger
.
log
(
5
,
'PDF Report successfully generated for searchOptions: '
+
searchOptions
);
finally
finally
rptOrders
.
Free
;
rptOrders
.
Free
;
// Ensure proper cleanup
end
;
end
;
end
;
end
;
...
@@ -231,7 +230,7 @@ begin
...
@@ -231,7 +230,7 @@ begin
end
;
end
;
// Build the SELECT query with dynamically generated subqueries
// Build the SELECT query with dynamically generated subqueries
SQL
:=
'SELECT o.ORDER_ID,
o.LOCATION,
c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
;
SQL
:=
'SELECT o.ORDER_ID, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
;
// Add dynamically generated subqueries
// Add dynamically generated subqueries
SQL
:=
SQL
+
generateSubQuery
(
filterType
,
statusType
,
'PROOF'
);
SQL
:=
SQL
+
generateSubQuery
(
filterType
,
statusType
,
'PROOF'
);
...
@@ -241,15 +240,7 @@ begin
...
@@ -241,15 +240,7 @@ begin
SQL
:=
SQL
+
generateSubQuery
(
filterType
,
statusType
,
'SHIP'
);
SQL
:=
SQL
+
generateSubQuery
(
filterType
,
statusType
,
'SHIP'
);
// Include additional static fields
// Include additional static fields
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM, '
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
;
// Dynamically determine colors field based on ORDER_TYPE
SQL
:=
SQL
+
'(CASE '
+
'WHEN o.ORDER_TYPE = ''web_plate'' THEN '
+
'(SELECT quantity_and_colors_qty_colors FROM web_plate_orders WHERE order_id = o.ORDER_ID) '
+
'ELSE (SELECT colors_colors FROM corrugated_plate_orders WHERE order_id = o.ORDER_ID) '
+
'END) AS COLORS '
;
// FROM clause
// FROM clause
SQL
:=
SQL
+
'FROM orders o '
+
SQL
:=
SQL
+
'FROM orders o '
+
...
@@ -272,15 +263,13 @@ begin
...
@@ -272,15 +263,13 @@ begin
' OFFSET '
+
IntToStr
((
PageNum
-
1
)
*
PageSize
);
' OFFSET '
+
IntToStr
((
PageNum
-
1
)
*
PageSize
);
Result
:=
SQL
;
Result
:=
SQL
;
Logger
.
log
(
5
,
'Generated SQL in Build
Order
Query: '
+
SQL
);
Logger
.
log
(
5
,
'Generated SQL in Build
order
Query: '
+
SQL
);
finally
finally
params
.
Free
;
params
.
Free
;
end
;
end
;
end
;
end
;
function
TLookupService
.
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
function
TLookupService
.
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
begin
begin
...
...
kgOrdersServer/Source/rOrders.dfm
View file @
e92fbc25
This diff is collapsed.
Click to expand it.
kgOrdersServer/Source/rOrders.pas
View file @
e92fbc25
...
@@ -5,42 +5,22 @@ interface
...
@@ -5,42 +5,22 @@ interface
uses
uses
System
.
SysUtils
,
System
.
Classes
,
frxClass
,
frxExportBaseDialog
,
frxExportPDF
,
System
.
SysUtils
,
System
.
Classes
,
frxClass
,
frxExportBaseDialog
,
frxExportPDF
,
Data
.
DB
,
DBAccess
,
Uni
,
UniProvider
,
MySQLUniProvider
,
System
.
IniFiles
,
Vcl
.
Forms
,
Data
.
DB
,
DBAccess
,
Uni
,
UniProvider
,
MySQLUniProvider
,
System
.
IniFiles
,
Vcl
.
Forms
,
MemDS
,
frxDBSet
,
System
.
IOUtils
,
Common
.
Logging
,
frxTableObject
,
frCoreClasse
s
;
MemDS
,
frxDBSet
,
frxTableObject
,
frCoreClasses
,
Common
.
Logging
,
System
.
IOUtil
s
;
type
type
TrptOrders
=
class
(
TDataModule
)
TrptOrders
=
class
(
TDataModule
)
frxOrders
:
TfrxReport
;
frxOrders
:
TfrxReport
;
frxPDFExport1
:
TfrxPDFExport
;
frxPDFExport1
:
TfrxPDFExport
;
ucKG
:
TUniConnection
;
ucKG
:
TUniConnection
;
frxDBOrders
:
TfrxDBDataset
;
uqOrders
:
TUniQuery
;
uqOrders
:
TUniQuery
;
uqOrdersORDER_ID
:
TIntegerField
;
frxReportTableObject1
:
TfrxReportTableObject
;
uqOrdersLOCATION
:
TStringField
;
frxDBOrders
:
TfrxDBDataset
;
uqOrdersCOMPANY_NAME
:
TStringField
;
uqOrdersJOB_NAME
:
TStringField
;
uqOrdersORDER_DATE
:
TDateField
;
uqOrdersORDER_TYPE
:
TStringField
;
uqOrdersPROOF_DUE
:
TDateField
;
uqOrdersPROOF_DONE
:
TDateTimeField
;
uqOrdersART_DUE
:
TDateField
;
uqOrdersART_DONE
:
TDateTimeField
;
uqOrdersPLATE_DUE
:
TDateField
;
uqOrdersPLATE_DONE
:
TDateTimeField
;
uqOrdersMOUNT_DUE
:
TDateField
;
uqOrdersMOUNT_DONE
:
TDateTimeField
;
uqOrdersSHIP_DUE
:
TDateField
;
uqOrdersSHIP_DONE
:
TDateTimeField
;
uqOrdersPRICE
:
TFloatField
;
uqOrdersQB_REF_NUM
:
TStringField
;
uqOrdersCOLORS
:
TStringField
;
procedure
DataModuleCreate
(
Sender
:
TObject
);
procedure
DataModuleCreate
(
Sender
:
TObject
);
<<<<<<<
HEAD
=======
private
private
>>>>>>>
f1a2333
(
clean
up
code
)
public
public
procedure
GenerateSimpleReport
(
OrderID
:
Integer
);
procedure
PrepareReport
(
const
SQL
:
string
);
procedure
PrepareReport
(
const
SQL
:
string
);
procedure
GeneratePDF
;
procedure
GeneratePDF
;
end
;
end
;
...
@@ -59,12 +39,8 @@ uses
...
@@ -59,12 +39,8 @@ uses
procedure
TrptOrders
.
DataModuleCreate
(
Sender
:
TObject
);
procedure
TrptOrders
.
DataModuleCreate
(
Sender
:
TObject
);
begin
begin
<<<<<<<
HEAD
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
=======
Logger
.
Log
(
3
,
'TAuthDatabase.DataModuleCreate'
);
Logger
.
Log
(
3
,
'TAuthDatabase.DataModuleCreate'
);
LoadDatabaseSettings
(
ucKG
,
'kgOrdersServer.ini'
);
LoadDatabaseSettings
(
ucKG
,
'kgOrdersServer.ini'
);
>>>>>>>
f1a2333
(
clean
up
code
)
try
try
ucKG
.
Connect
;
ucKG
.
Connect
;
except
except
...
@@ -75,9 +51,38 @@ begin
...
@@ -75,9 +51,38 @@ begin
end
;
end
;
end
;
end
;
procedure
TrptOrders
.
GenerateSimpleReport
(
OrderID
:
Integer
);
begin
try
Logger
.
Log
(
5
,
'Generating Report for Order ID: '
+
OrderID
.
ToString
);
uqOrders
.
Close
;
uqOrders
.
SQL
.
Text
:=
'SELECT ORDER_ID FROM corrugated_plate_orders WHERE ORDER_ID = :OrderID'
;
uqOrders
.
ParamByName
(
'OrderID'
).
AsInteger
:=
OrderID
;
try
uqOrders
.
Open
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
1
,
'Error executing query: '
+
E
.
Message
);
Exit
;
end
;
end
;
frxOrders
.
PrepareReport
;
frxOrders
.
ShowReport
;
finally
uqOrders
.
Close
;
frxOrders
.
Clear
;
Logger
.
Log
(
5
,
'Report generation complete for Order ID: '
+
OrderID
.
ToString
);
end
;
end
;
procedure
TrptOrders
.
PrepareReport
(
const
SQL
:
string
);
procedure
TrptOrders
.
PrepareReport
(
const
SQL
:
string
);
begin
begin
// Prepare and
open
the query
// Prepare and
load data into
the query
uqOrders
.
Close
;
uqOrders
.
Close
;
uqOrders
.
SQL
.
Text
:=
SQL
;
uqOrders
.
SQL
.
Text
:=
SQL
;
uqOrders
.
Open
;
uqOrders
.
Open
;
...
@@ -85,26 +90,22 @@ end;
...
@@ -85,26 +90,22 @@ end;
procedure
TrptOrders
.
GeneratePDF
;
procedure
TrptOrders
.
GeneratePDF
;
var
var
ReportFileName
:
string
;
Report
Dir
,
Report
FileName
:
string
;
begin
begin
ReportFileName
:=
TPath
.
Combine
(
'C:\Projects\KGOrders\Reports'
,
ReportDir
:=
'C:\Projects\KGOrders\Reports'
;
'OrderReport_'
+
FormatDateTime
(
'yyyymmdd_hhnnss'
,
Now
)
+
'.pdf'
);
// Define output file
ReportFileName
:=
TPath
.
Combine
(
ReportDir
,
'OrderReport_'
+
FormatDateTime
(
'yyyymmdd_hhnnss'
,
Now
)
+
'.pdf'
);
if
not
DirectoryExists
(
ExtractFilePath
(
ReportFileName
))
then
// Prepare and export the report
ForceDirectories
(
ExtractFilePath
(
ReportFileName
));
// Generate the report
frxOrders
.
PrepareReport
;
frxOrders
.
PrepareReport
;
frxPDFExport1
.
FileName
:=
ReportFileName
;
frxPDFExport1
.
FileName
:=
ReportFileName
;
frxPDFExport1
.
ShowDialog
:=
False
;
frxPDFExport1
.
ShowDialog
:=
False
;
frxOrders
.
Export
(
frxPDFExport1
);
frxOrders
.
Export
(
frxPDFExport1
);
Logger
.
log
(
5
,
'PDF saved to: '
+
ReportFileName
);
frxOrders
.
ShowPreparedReport
;
Logger
.
Log
(
5
,
'PDF saved to: '
+
ReportFileName
);
end
;
end
;
<<<<<<<
HEAD
=======
>>>>>>>
f1a2333
(
clean
up
code
)
end
.
end
.
end
.
kgOrdersServer/Source/rptOrders.fr3
View file @
e92fbc25
This diff is collapsed.
Click to expand it.
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