Commit b85b892c by Cam Hayes

Web Report Pdfis completely finished and ready to begin cutting die orders

parent 8fc96250
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1085,16 +1085,17 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1085,16 +1085,17 @@ object FOrderEntryWeb: TFOrderEntryWeb
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick OnClick = btnConfirmClick
end end
object btnEdit: TWebButton object btnPDF: TWebButton
Left = 867 Left = 867
Top = 568 Top = 568
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Edit' Caption = 'PDF'
ChildOrder = 79 ChildOrder = 79
ElementID = 'btnedit' ElementID = 'btnpdf'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnPDFClick
end end
object btnCancel: TWebButton object btnCancel: TWebButton
Left = 761 Left = 761
......
...@@ -363,7 +363,7 @@ ...@@ -363,7 +363,7 @@
<button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button> <button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btnedit" class="btn btn-primary btn-sm float-end my-2">Edit</button> <button id="btnpdf" class="btn btn-primary btn-sm float-end my-2">PDF</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -127,7 +127,7 @@ type ...@@ -127,7 +127,7 @@ type
WebLabel11: TWebLabel; WebLabel11: TWebLabel;
Comments: TWebDBEdit; Comments: TWebDBEdit;
btnConfirm: TWebButton; btnConfirm: TWebButton;
btnEdit: TWebButton; btnPDF: TWebButton;
btnCancel: TWebButton; btnCancel: TWebButton;
XDataWebDataSet1plates_job_number: TStringField; XDataWebDataSet1plates_job_number: TStringField;
XDataWebDataSet1supplied_by_customer_plates: TStringField; XDataWebDataSet1supplied_by_customer_plates: TStringField;
...@@ -210,6 +210,8 @@ type ...@@ -210,6 +210,8 @@ type
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
[async] procedure AddWebOrder(orderJSON: TJSONObject); [async] procedure AddWebOrder(orderJSON: TJSONObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject);
[async] procedure GenerateReportPDF;
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -325,6 +327,30 @@ begin ...@@ -325,6 +327,30 @@ begin
FViewMain.ViewOrders(info); FViewMain.ViewOrders(info);
end; end;
procedure TFOrderEntryWeb.btnPDFClick(Sender: TObject);
begin
GenerateReportPDF;
end;
[async] procedure TFOrderEntryWeb.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results
var
xdcResponse: TXDataClientResponse;
searchOptions, pdfURL: string;
jsObject: TJSObject;
begin
// Call the server method to generate the PDF
console.log(orderID);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderWebPDF', [orderID]));
jsObject := JS.TJSObject(xdcResponse.Result);
pdfURL := JS.toString(jsObject.Properties['value']);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window.open(pdfURL, '_blank');
end;
procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject); procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server // sends the order JSON object to the server
var var
...@@ -455,10 +481,12 @@ begin ...@@ -455,10 +481,12 @@ begin
if XDataWebDataSet1quantity_and_colors_qty_colors.Value <> '' then if XDataWebDataSet1quantity_and_colors_qty_colors.Value <> '' then
begin begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1quantity_and_colors_qty_colors.Value)); colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1quantity_and_colors_qty_colors.Value));
console.log(colorObject);
colorList := TJSArray(colorObject['items']); colorList := TJSArray(colorObject['items']);
for I := 0 to colorList.length -1 do for I := 0 to colorList.length -1 do
begin begin
color := TJSObject(colorList[i]); color := TJSObject(colorList[i]);
console.log(color);
addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size'])); addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size']));
end; end;
end; end;
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{DB6F5DBF-7E4B-45DA-AFFA-6C8DF15BA740}</ProjectGuid> <ProjectGuid>{DB6F5DBF-7E4B-45DA-AFFA-6C8DF15BA740}</ProjectGuid>
<ProjectVersion>20.1</ProjectVersion> <ProjectVersion>20.2</ProjectVersion>
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<MainSource>webKGOrders.dpr</MainSource> <MainSource>webKGOrders.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
...@@ -225,33 +225,13 @@ ...@@ -225,33 +225,13 @@
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="4"> <Deployment Version="5">
<DeployFile LocalName="Win32\Debug\webCharms.exe" Configuration="Debug" Class="ProjectOutput"/> <DeployFile LocalName="Win32\Debug\webCharms.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployFile LocalName="Win32\Debug\webKGOrders.exe" Configuration="Debug" Class="ProjectOutput"> <DeployFile LocalName="Win32\Debug\webKGOrders.exe" Configuration="Debug" Class="ProjectOutput"/>
<Platform Name="Win32"> <DeployFile LocalName="config\config.json" Configuration="Debug" Class="ProjectFile"/>
<RemoteName>webKGOrders.exe</RemoteName> <DeployFile LocalName="css\app.css" Configuration="Debug" Class="ProjectFile"/>
<Overwrite>true</Overwrite> <DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile"/>
</Platform>
</DeployFile>
<DeployFile LocalName="config\config.json" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="css\app.css" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile"/> <DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="template\bootstrap\bootstrap.min.css" Configuration="Debug" Class="ProjectFile"/> <DeployFile LocalName="template\bootstrap\bootstrap.min.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\bootstrap.min.js" Configuration="Debug" Class="ProjectFile"/> <DeployFile LocalName="template\bootstrap\bootstrap.min.js" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\dataTables.bootstrap.css" Configuration="Debug" Class="ProjectFile"/> <DeployFile LocalName="template\bootstrap\dataTables.bootstrap.css" Configuration="Debug" Class="ProjectFile"/>
...@@ -276,16 +256,6 @@ ...@@ -276,16 +256,6 @@
<Operation>0</Operation> <Operation>0</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="AndroidClasses">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider"> <DeployClass Name="AndroidFileProvider">
<Platform Name="Android"> <Platform Name="Android">
<RemoteDir>res\xml</RemoteDir> <RemoteDir>res\xml</RemoteDir>
...@@ -296,12 +266,6 @@ ...@@ -296,12 +266,6 @@
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiFile"> <DeployClass Name="AndroidLibnativeArmeabiFile">
<Platform Name="Android"> <Platform Name="Android">
<RemoteDir>library\lib\armeabi</RemoteDir> <RemoteDir>library\lib\armeabi</RemoteDir>
......
...@@ -327,6 +327,35 @@ type ...@@ -327,6 +327,35 @@ type
general_comments: string; general_comments: string;
end; end;
TCuttingDie = class
public
// Company
COMPANY_ID: integer;
NAME: string;
SHORT_NAME: string;
inQuickBooks: string;
ADDRESS_LIST: TList<TAddressItem>;
ITEMS: TItemList;
// Staff Fields:
staff_fields_order_date: string;
staff_fields_proof_date: string;
staff_fields_ship_date: string;
staff_fields_ship_via: string;
staff_fields_quantity: string;
staff_fields_price: string;
staff_fields_invoice_to: string;
staff_fields_ship_to: string;
staff_fields_po_number: string;
staff_fields_job_name: string;
staff_fields_quickbooks_item: string;
// General
general_special_instructions: string;
end;
type type
[ServiceContract, Model(API_MODEL)] [ServiceContract, Model(API_MODEL)]
...@@ -341,6 +370,7 @@ type ...@@ -341,6 +370,7 @@ type
[HttpGet] function GetCustomer(ID: string): TCustomerItem; [HttpGet] function GetCustomer(ID: string): TCustomerItem;
[HttpGet] function GenerateOrderListPDF(searchOptions: string): string; [HttpGet] function GenerateOrderListPDF(searchOptions: string): string;
[HttpGet] function GenerateOrderCorrugatedPDF(orderID: string): string; [HttpGet] function GenerateOrderCorrugatedPDF(orderID: string): string;
[HttpGet] function GenerateOrderWebPDF(orderID: string): string;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
......
...@@ -34,20 +34,26 @@ type ...@@ -34,20 +34,26 @@ type
function GetOrder(orderInfo: string): TFullOrder; function GetOrder(orderInfo: string): TFullOrder;
function GetCustomers(): TCustomerList; function GetCustomers(): TCustomerList;
function GetCustomer(ID: string): TCustomerItem; function GetCustomer(ID: string): TCustomerItem;
function GetWebOrder(orderInfo: string): TWebOrder;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function GenerateOrderListPDF(searchOptions: string): string; function GenerateOrderListPDF(searchOptions: string): string;
function GenerateOrderCorrugatedPDF(orderID: string): string; function GenerateOrderCorrugatedPDF(orderID: string): string;
function GenerateOrderWebPDF(orderID: 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 GenerateSubQuery(currStatus: string): string;
function AddCorrugatedOrder(orderInfo: string): TJSONObject; function AddCorrugatedOrder(orderInfo: string): TJSONObject;
function AddWebOrder(orderInfo: string): TJSONObject; function AddWebOrder(orderInfo: string): TJSONObject;
function AddCuttingDieOrder(orderInfo: string): TJSONObject; function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function GenerateSubQuery(currStatus: string): string;
function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string; function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
function GenerateOrdersSQL(searchOptions: string): TSQLQuery; function GenerateOrdersSQL(searchOptions: string): TSQLQuery;
function GetColorCount(colors: string): string; function GetColorCount(colors: string): string;
function GetWebOrder(orderInfo: string): TWebOrder;
function GenerateStatusSelectSQL(statusTableShort, statusTableLong, startDate, endDate, statusType: string): string; function GenerateStatusSelectSQL(statusTableShort, statusTableLong, startDate, endDate, statusType: string): string;
function GenerateStatusWhereSQL(status: TStatusSearchInfo): string; function GenerateStatusWhereSQL(status: TStatusSearchInfo): string;
function CreateStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo; function CreateStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo;
...@@ -61,7 +67,7 @@ implementation ...@@ -61,7 +67,7 @@ implementation
uses uses
System.Generics.Collections, System.Generics.Collections,
XData.Sys.Exceptions, uLibrary; XData.Sys.Exceptions, uLibrary, rOrderWeb;
procedure TLookupService.AfterConstruction; procedure TLookupService.AfterConstruction;
begin begin
...@@ -181,6 +187,26 @@ begin ...@@ -181,6 +187,26 @@ begin
end; end;
end; end;
function TLookupService.GenerateOrderWebPDF(orderID: string): string;
var
SQL: string;
rptOrderWeb: TrptOrderWeb; // Local instance of the report
begin
rptOrderWeb := TrptOrderWeb.Create(nil);
try
// Generate SQL query for a single order
SQL := 'SELECT * FROM web_plate_orders WHERE ORDER_ID = ' + orderID;
// Prepare the report with the query
Result := rptOrderWeb.PrepareReport(SQL);
// Optionally log success
Logger.Log(5, 'PDF Report successfully generated for order ID: ' + orderID);
finally
rptOrderWeb.Free;
end;
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 // Generates the subquery in order to retrieve all the status due/done dates
...@@ -1529,49 +1555,14 @@ begin ...@@ -1529,49 +1555,14 @@ begin
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode'); mode := JSONData.GetValue<string>('mode');
if mode = 'ADD' then AddToOrdersTable(mode, 'web_plate', JSONData);
begin
SQL := 'select * from orders where ORDER_ID = 0 and ORDER_ID <> 0';
doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Insert;
end
else
begin
SQL := 'select * from orders where ORDER_ID = ' + IntToStr(ORDER_ID);
doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Edit;
end;
temp := JSONData.GetValue<string>('COMPANY_ID');
ordersDB.UniQuery1.FieldByName('COMPANY_ID').AsString := JSONData.GetValue<string>('COMPANY_ID');
ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString := 'web_plate';
if mode = 'ADD' then
ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime := Now
else
begin
// No idea why I need this line but without it an error gets thrown
ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime := ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime;
end;
if JSONData.GetValue<string>('staff_fields_price') = '' then
ordersDB.UniQuery1.FieldByName('PRICE').AsString := '0'
else
ordersDB.UniQuery1.FieldByName('PRICE').AsString := JSONData.GetValue<string>('staff_fields_price');
ordersDB.UniQuery1.FieldByName('JOB_NAME').AsString := JSONData.GetValue<string>('staff_fields_job_name');
ordersDB.UniQuery1.FieldByName('USER_ID').AsString := JSONData.GetValue<string>('USER_ID');
ordersDB.UniQuery1.FieldByName('LOCATION').AsString := JSONData.GetValue<string>('staff_fields_art_location');
ordersDB.UniQuery1.Post;
ordersDB.UniQuery1.Close; if mode = 'ADD' then
if mode = 'ADD' then begin
begin ordersDB.UniQuery1.SQL.Text := 'SELECT LAST_INSERT_ID() AS OrderID'; // Use database's method to get the last inserted ID
ordersDB.UniQuery1.SQL.Text := 'SELECT LAST_INSERT_ID() AS OrderID'; // Use database's method to get the last inserted ID ordersDB.UniQuery1.Open;
ordersDB.UniQuery1.Open; ORDER_ID := ordersDB.UniQuery1.FieldByName('OrderID').AsInteger;
ORDER_ID := ordersDB.UniQuery1.FieldByName('OrderID').AsInteger; end;
end;
if mode = 'ADD' then if mode = 'ADD' then
SQL := 'select * from cutting_die_orders where ORDER_ID = 0 and ORDER_ID <> 0' SQL := 'select * from cutting_die_orders where ORDER_ID = 0 and ORDER_ID <> 0'
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -13,29 +13,6 @@ type ...@@ -13,29 +13,6 @@ type
frxPDFExport1: TfrxPDFExport; frxPDFExport1: TfrxPDFExport;
frxDBOrderCorrugated: TfrxDBDataset; frxDBOrderCorrugated: TfrxDBDataset;
frxOrderCorrugated: TfrxReport; frxOrderCorrugated: TfrxReport;
uqColors: TUniQuery;
uqColorshash1: TStringField;
uqColorshash2: TStringField;
uqColorshash3: TStringField;
uqColorshash4: TStringField;
uqColorshash5: TStringField;
uqColorshash6: TStringField;
uqColorshash7: TStringField;
uqColorscolor1: TStringField;
uqColorscolor2: TStringField;
uqColorscolor3: TStringField;
uqColorscolor4: TStringField;
uqColorscolor5: TStringField;
uqColorscolor6: TStringField;
uqColorscolor7: TStringField;
uqColorslpi1: TStringField;
uqColorslpi2: TStringField;
uqColorslpi3: TStringField;
uqColorslpi4: TStringField;
uqColorslpi5: TStringField;
uqColorslpi6: TStringField;
uqColorslpi7: TStringField;
uqColorssize1: TStringField;
uqOrderCorrugated: TUniQuery; uqOrderCorrugated: TUniQuery;
uqOrderCorrugatedORDER_ID: TIntegerField; uqOrderCorrugatedORDER_ID: TIntegerField;
uqOrderCorrugatedCOMPANY_ID: TIntegerField; uqOrderCorrugatedCOMPANY_ID: TIntegerField;
...@@ -164,10 +141,10 @@ begin ...@@ -164,10 +141,10 @@ begin
row := frxOrderCorrugated.FindObject('ColorRow' + IntToStr(i + 1)) as TfrxCustomTableRow; row := frxOrderCorrugated.FindObject('ColorRow' + IntToStr(i + 1)) as TfrxCustomTableRow;
colorObject := colorArray.Items[i] as TJSONObject; colorObject := colorArray.Items[i] as TJSONObject;
row.Cells[4].Text := colorObject.GetValue<string>('#'); row.Cells[0].Text := colorObject.GetValue<string>('#');
row.Cells[5].Text := colorObject.GetValue<string>('Color'); row.Cells[1].Text := colorObject.GetValue<string>('Color');
row.Cells[6].Text := colorObject.GetValue<string>('LPI'); row.Cells[2].Text := colorObject.GetValue<string>('LPI');
row.Cells[7].Text := colorObject.GetValue<string>('Size'); row.Cells[3].Text := colorObject.GetValue<string>('Size');
end; end;
colorsObject.Free; colorsObject.Free;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
unit rOrderWeb;
interface
uses
System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging,
frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON,
frxTableObject, frxUtils;
type
TrptOrderWeb = class(TDataModule)
ucKG: TUniConnection;
frxPDFExport1: TfrxPDFExport;
frxDBOrderWeb: TfrxDBDataset;
frxOrderWeb: TfrxReport;
uqOrderWeb: TUniQuery;
uqOrderWebORDER_ID: TIntegerField;
uqOrderWebCOMPANY_ID: TIntegerField;
uqOrderWebUSER_ID: TIntegerField;
uqOrderWebORDER_DATE: TDateTimeField;
uqOrderWebSTART_DATE: TDateField;
uqOrderWebEND_DATE: TDateField;
uqOrderWebORDER_STATUS: TStringField;
uqOrderWebSCHED_JSON: TStringField;
uqOrderWebstaff_fields_order_date: TDateField;
uqOrderWebstaff_fields_proof_date: TDateField;
uqOrderWebstaff_fields_ship_date: TDateField;
uqOrderWebstaff_fields_ship_via: TStringField;
uqOrderWebstaff_fields_price: TStringField;
uqOrderWebstaff_fields_invoice_to: TStringField;
uqOrderWebstaff_fields_invoice_attention: TStringField;
uqOrderWebstaff_fields_ship_to: TStringField;
uqOrderWebstaff_fields_ship_attention: TStringField;
uqOrderWebstaff_fields_po_number: TStringField;
uqOrderWebstaff_fields_job_name: TStringField;
uqOrderWebstaff_fields_art_due: TDateField;
uqOrderWebstaff_fields_plate_due: TDateField;
uqOrderWebplates_job_number: TStringField;
uqOrderWebsupplied_by_customer_b_w_or_co: TStringField;
uqOrderWebsupplied_by_customer_plates: TStringField;
uqOrderWebsupplied_by_customer_sample: TStringField;
uqOrderWebsupplied_by_customer_dimension: TStringField;
uqOrderWebsupplied_by_customer_other: TStringField;
uqOrderWebsupplied_by_customer_disk: TStringField;
uqOrderWebsupplied_by_customer_e_mail: TStringField;
uqOrderWebsupplied_by_customer_ftp: TStringField;
uqOrderWebplates_plate_material: TStringField;
uqOrderWebplates_thickness: TStringField;
uqOrderWebsupplied_by_customer_total_inc: TStringField;
uqOrderWebsupplied_by_customer_sheets_us: TStringField;
uqOrderWebsupplied_by_customer_initials: TStringField;
uqOrderWebproofing_pdf: TStringField;
uqOrderWebproofing_pdf_to: TStringField;
uqOrderWebproofing_pdf_date_1: TDateField;
uqOrderWebproofing_pdf_date_2: TDateField;
uqOrderWebproofing_pdf_date_3: TDateField;
uqOrderWebproofing_full_size_ink_jet_for: TStringField;
uqOrderWebproofing_ink_jet_to: TStringField;
uqOrderWebproofing_ink_jet_to_2: TStringField;
uqOrderWebproofing_ink_jet_date_1: TDateField;
uqOrderWebproofing_ink_jet_date_2: TDateField;
uqOrderWebproofing_ink_jet_date_3: TDateField;
uqOrderWebproofing_color_contract: TStringField;
uqOrderWebproofing_color_contrac_to: TStringField;
uqOrderWebproofing_color_contrac_date_1: TDateField;
uqOrderWebproofing_color_contrac_date_2: TDateField;
uqOrderWebproofing_digital_color_key: TStringField;
uqOrderWebproofing_digital_color_to: TStringField;
uqOrderWebproofing_digital_color_date_1: TDateField;
uqOrderWebquantity_and_colors_press_name: TStringField;
uqOrderWebquantity_and_colors_anilox_info: TStringField;
uqOrderWebplate_marks_microdots: TStringField;
uqOrderWebplate_marks_microdots_comments: TStringField;
uqOrderWebplate_marks_crosshairs: TStringField;
uqOrderWebplate_marks_crosshairs_comments: TStringField;
uqOrderWebplate_marks_color_bars: TStringField;
uqOrderWebplate_marks_color_bars_comments: TStringField;
uqOrderWebplate_marks_other: TStringField;
uqOrderWebplate_marks_other_comments: TStringField;
uqOrderWebprint_orientation_print_orient: TStringField;
uqOrderWeblayout_around: TStringField;
uqOrderWeblayout_accross: TStringField;
uqOrderWeblayout_surface_print: TStringField;
uqOrderWeblayout_reverse_print: TStringField;
uqOrderWeblayout_cylinder_repeat: TStringField;
uqOrderWeblayout_cutoff_dimension: TStringField;
uqOrderWeblayout_pitch: TStringField;
uqOrderWeblayout_teeth: TStringField;
uqOrderWeblayout_bleed: TStringField;
uqOrderWeblayout_cutback: TStringField;
uqOrderWeblayout_minimum_trap_dim: TStringField;
uqOrderWeblayout_maximum_trap_dim: TStringField;
uqOrderWebupc_size: TStringField;
uqOrderWebupc_bar_width_reduction: TStringField;
uqOrderWebquantity_and_colors_qty_colors: TStringField;
uqOrderWebgeneral_comments: TStringField;
uqOrderWebstaff_fields_quickbooks_item: TStringField;
uqOrderWebstaff_fields_quantity: TStringField;
uqOrderWebupc_distortion_percent: TStringField;
uqOrderWebupc_distortion_amount: TStringField;
uqOrderWebstaff_fields_art_location: TStringField;
private
{ Private declarations }
public
{ Public declarations }
function PrepareReport(SQL: string): string;
function GeneratePDF: string;
procedure PopulateColorTable();
end;
var
rptOrderWeb: TrptOrderWeb;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
uses
uLibrary, Common.Config;
procedure TrptOrderWeb.PopulateColorTable;
var
row: TfrxCustomTableRow;
colorArray: TJSONArray;
colorsObject, colorObject: TJSONObject;
colorsString: string;
i, rowIndex: Integer;
temp: TObject;
begin
logger.Log(1, 'Adding Color Rows');
colorsString := uqOrderWeb.FieldByName('quantity_and_colors_qty_colors').AsString;
colorsObject := TJSONObject.ParseJSONValue(colorsString) as TJSONObject;
colorArray := TJSONArray(colorsObject.GetValue<TJSONArray>('items'));
for i := 0 to colorArray.Count - 1 do
begin
row := frxOrderWeb.FindObject('ColorRow' + IntToStr(i + 1)) as TfrxCustomTableRow;
colorObject := colorArray.Items[i] as TJSONObject;
row.Cells[0].Text := colorObject.GetValue<string>('#');
row.Cells[1].Text := colorObject.GetValue<string>('Color');
row.Cells[2].Text := colorObject.GetValue<string>('LPI');
row.Cells[3].Text := colorObject.GetValue<string>('Size');
end;
colorsObject.Free;
end;
function TrptOrderWeb.PrepareReport(SQL: string): string;
var
orderList : TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString, strColorList: string;
colorObject: TJSONObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
items: TJSObject;
begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
//SQL := 'select * from corrugated_plate_orders where ORDER_ID = 18381';
doQuery(uqOrderWeb, SQL);
if ( string( uqOrderWeb.FieldByName('quantity_and_colors_qty_colors').AsString ) ) <> '' then
begin
PopulateColorTable();
end;
result := GeneratePDF;
Logger.Log(3, 'Report preparation complete.');
end;
function TrptOrderWeb.GeneratePDF: string;
var
ReportDir, ReportFileName: string;
reportURL: string;
begin
ReportDir := ServerConfig.reportsFolder;
if not DirectoryExists(ReportDir) then
begin
ForceDirectories(ReportDir);
Logger.Log(5, 'Reports directory created: ' + ReportDir);
end;
reportURL := 'reports\' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.pdf';
ReportFileName := reportDir + reportUrl;
frxPDFExport1.FileName := ReportFileName;
frxPDFExport1.ShowDialog := False;
try
frxOrderWeb.PrepareReport;
frxOrderWeb.Export(frxPDFExport1);
//frxOrders.ShowPreparedReport;
finally
frxOrderWeb.Clear; // Clears the report to avoid memory bloat
end;
Logger.Log(5, 'PDF saved to: ' + ReportFileName);
result := reportURL;
end;
end.
...@@ -23,7 +23,8 @@ uses ...@@ -23,7 +23,8 @@ uses
App.Server.Module in 'Source\App.Server.Module.pas' {AppServerModule: TDataModule}, App.Server.Module in 'Source\App.Server.Module.pas' {AppServerModule: TDataModule},
Data in 'Source\Data.pas' {FData}, Data in 'Source\Data.pas' {FData},
rOrderList in 'Source\rOrderList.pas' {rptOrderList: TDataModule}, rOrderList in 'Source\rOrderList.pas' {rptOrderList: TDataModule},
rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule}; rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule},
rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule};
type type
TMemoLogAppender = class( TInterfacedObject, ILogAppender ) TMemoLogAppender = class( TInterfacedObject, ILogAppender )
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{2A3028D9-BC39-4625-9BA5-0338012E2824}</ProjectGuid> <ProjectGuid>{2A3028D9-BC39-4625-9BA5-0338012E2824}</ProjectGuid>
<ProjectVersion>20.1</ProjectVersion> <ProjectVersion>20.2</ProjectVersion>
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config> <Config Condition="'$(Config)'==''">Debug</Config>
...@@ -175,6 +175,11 @@ ...@@ -175,6 +175,11 @@
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass> <DesignClass>TDataModule</DesignClass>
</DCCReference> </DCCReference>
<DCCReference Include="Source\rOrderWeb.pas">
<Form>rptOrderWeb</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
...@@ -202,7 +207,8 @@ ...@@ -202,7 +207,8 @@
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="4"> <Deployment Version="5">
<DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput"> <DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32"> <Platform Name="Win32">
<RemoteName>kgOrdersServer.exe</RemoteName> <RemoteName>kgOrdersServer.exe</RemoteName>
...@@ -221,16 +227,6 @@ ...@@ -221,16 +227,6 @@
<Operation>0</Operation> <Operation>0</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="AndroidClasses">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider"> <DeployClass Name="AndroidFileProvider">
<Platform Name="Android"> <Platform Name="Android">
<RemoteDir>res\xml</RemoteDir> <RemoteDir>res\xml</RemoteDir>
...@@ -241,12 +237,6 @@ ...@@ -241,12 +237,6 @@
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiFile"> <DeployClass Name="AndroidLibnativeArmeabiFile">
<Platform Name="Android"> <Platform Name="Android">
<RemoteDir>library\lib\armeabi</RemoteDir> <RemoteDir>library\lib\armeabi</RemoteDir>
......
[Settings] [Settings]
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=5 FileLogLevel=5
LogFileNum=196 LogFileNum=206
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