Commit 1e9dbe96 by cam

Adding orders is now fully functional and fixed colors so it matched the database

parent fcb79526
......@@ -241,6 +241,7 @@ object FOrderEntry: TFOrderEntry
Top = 92
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000
......@@ -254,6 +255,7 @@ object FOrderEntry: TFOrderEntry
Top = 120
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtaccountcompanyname'
HeightPercent = 100.000000000000000000
......@@ -266,6 +268,7 @@ object FOrderEntry: TFOrderEntry
Top = 148
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtinquickbooks'
HeightPercent = 100.000000000000000000
......@@ -278,6 +281,7 @@ object FOrderEntry: TFOrderEntry
Top = 314
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtshipvia'
HeightPercent = 100.000000000000000000
......@@ -290,6 +294,7 @@ object FOrderEntry: TFOrderEntry
Top = 346
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtquantity'
HeightPercent = 100.000000000000000000
......@@ -314,6 +319,7 @@ object FOrderEntry: TFOrderEntry
Top = 402
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtinvoiceto'
HeightPercent = 100.000000000000000000
......@@ -326,6 +332,7 @@ object FOrderEntry: TFOrderEntry
Top = 430
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtshipto'
HeightPercent = 100.000000000000000000
......@@ -338,6 +345,7 @@ object FOrderEntry: TFOrderEntry
Top = 458
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtponumber'
HeightPercent = 100.000000000000000000
......@@ -350,6 +358,7 @@ object FOrderEntry: TFOrderEntry
Top = 486
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtjobname'
HeightPercent = 100.000000000000000000
......@@ -362,6 +371,7 @@ object FOrderEntry: TFOrderEntry
Top = 514
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtquickbooksitem'
HeightPercent = 100.000000000000000000
......@@ -386,6 +396,7 @@ object FOrderEntry: TFOrderEntry
Top = 314
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtdimensionallayout'
HeightPercent = 100.000000000000000000
......@@ -398,6 +409,7 @@ object FOrderEntry: TFOrderEntry
Top = 368
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtemail'
HeightPercent = 100.000000000000000000
......@@ -410,6 +422,7 @@ object FOrderEntry: TFOrderEntry
Top = 390
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtftp'
HeightPercent = 100.000000000000000000
......@@ -422,6 +435,7 @@ object FOrderEntry: TFOrderEntry
Top = 418
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtother'
HeightPercent = 100.000000000000000000
......@@ -434,6 +448,7 @@ object FOrderEntry: TFOrderEntry
Top = 446
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtexistingcuttingdie'
HeightPercent = 100.000000000000000000
......@@ -446,6 +461,7 @@ object FOrderEntry: TFOrderEntry
Top = 474
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrefartprintcard'
HeightPercent = 100.000000000000000000
......@@ -458,6 +474,7 @@ object FOrderEntry: TFOrderEntry
Top = 508
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrefartapdf'
HeightPercent = 100.000000000000000000
......@@ -470,6 +487,7 @@ object FOrderEntry: TFOrderEntry
Top = 207
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcadfile'
HeightPercent = 100.000000000000000000
......@@ -482,6 +500,7 @@ object FOrderEntry: TFOrderEntry
Top = 179
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtaroundno'
HeightPercent = 100.000000000000000000
......@@ -494,6 +513,7 @@ object FOrderEntry: TFOrderEntry
Top = 151
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtacrossno'
HeightPercent = 100.000000000000000000
......@@ -506,6 +526,7 @@ object FOrderEntry: TFOrderEntry
Top = 123
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtdiecutno'
HeightPercent = 100.000000000000000000
......@@ -518,6 +539,7 @@ object FOrderEntry: TFOrderEntry
Top = 95
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrscd'
HeightPercent = 100.000000000000000000
......@@ -530,6 +552,7 @@ object FOrderEntry: TFOrderEntry
Top = 64
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrscw'
HeightPercent = 100.000000000000000000
......@@ -542,6 +565,7 @@ object FOrderEntry: TFOrderEntry
Top = 39
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrscl'
HeightPercent = 100.000000000000000000
......@@ -554,6 +578,7 @@ object FOrderEntry: TFOrderEntry
Top = 506
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcustomadhesive'
HeightPercent = 100.000000000000000000
......@@ -566,6 +591,7 @@ object FOrderEntry: TFOrderEntry
Top = 478
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcustombacking'
HeightPercent = 100.000000000000000000
......@@ -578,6 +604,7 @@ object FOrderEntry: TFOrderEntry
Top = 450
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtstandardsetup'
HeightPercent = 100.000000000000000000
......@@ -590,6 +617,7 @@ object FOrderEntry: TFOrderEntry
Top = 430
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtstripmount'
HeightPercent = 100.000000000000000000
......@@ -602,6 +630,7 @@ object FOrderEntry: TFOrderEntry
Top = 334
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtloose'
HeightPercent = 100.000000000000000000
......@@ -614,6 +643,7 @@ object FOrderEntry: TFOrderEntry
Top = 261
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtrscstyle'
HeightPercent = 100.000000000000000000
......@@ -626,6 +656,7 @@ object FOrderEntry: TFOrderEntry
Top = 458
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtproofother'
HeightPercent = 100.000000000000000000
......@@ -638,6 +669,7 @@ object FOrderEntry: TFOrderEntry
Top = 328
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtproofshipto'
HeightPercent = 100.000000000000000000
......@@ -650,6 +682,7 @@ object FOrderEntry: TFOrderEntry
Top = 300
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtemailattn'
HeightPercent = 100.000000000000000000
......@@ -662,6 +695,7 @@ object FOrderEntry: TFOrderEntry
Top = 272
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtproofemail'
HeightPercent = 100.000000000000000000
......@@ -674,6 +708,7 @@ object FOrderEntry: TFOrderEntry
Top = 244
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtfaxattn'
HeightPercent = 100.000000000000000000
......@@ -686,6 +721,7 @@ object FOrderEntry: TFOrderEntry
Top = 219
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtfax'
HeightPercent = 100.000000000000000000
......@@ -698,6 +734,7 @@ object FOrderEntry: TFOrderEntry
Top = 117
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtclemson'
HeightPercent = 100.000000000000000000
......@@ -710,6 +747,7 @@ object FOrderEntry: TFOrderEntry
Top = 89
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcrosshairs'
HeightPercent = 100.000000000000000000
......@@ -722,6 +760,7 @@ object FOrderEntry: TFOrderEntry
Top = 64
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtmachineindent'
HeightPercent = 100.000000000000000000
......@@ -734,6 +773,7 @@ object FOrderEntry: TFOrderEntry
Top = 39
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcylindersize'
HeightPercent = 100.000000000000000000
......@@ -746,6 +786,7 @@ object FOrderEntry: TFOrderEntry
Top = 105
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtjobnumber'
HeightPercent = 100.000000000000000000
......@@ -758,6 +799,7 @@ object FOrderEntry: TFOrderEntry
Top = 72
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtplatematerial'
HeightPercent = 100.000000000000000000
......@@ -770,6 +812,7 @@ object FOrderEntry: TFOrderEntry
Top = 39
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtThickness'
HeightPercent = 100.000000000000000000
......@@ -974,6 +1017,7 @@ object FOrderEntry: TFOrderEntry
Top = 185
Width = 121
Height = 22
AutoSize = True
ChildOrder = 78
ElementID = 'edtspecialinstructions'
HeightPercent = 100.000000000000000000
......
......@@ -195,6 +195,7 @@ type
procedure WebButton1Click(Sender: TObject);
procedure addColorRow(num, Color, LPI, Size: string);
procedure btnConfirmClick(Sender: TObject);
[async] procedure AddCorrugatedOrder(orderJSON: TJSONObject);
private
FAgencyCode: string;
FCurrentReportType: string;
......@@ -222,12 +223,15 @@ var
colorCollection: TJSHTMLCollection;
color: TJSHTMLElement;
I, J: integer;
colorJSON: TJSONObject;
colorJSON, orderJSON, colorListJSON: TJSONObject;
fieldNames: TStringList;
itemList: TJSNodeList;
header, value: string;
Field: TField;
Response: TXDataClientResponse;
begin
//TJSONObject.Create;
orderJSON := TJSONObject.Create;
colorList := TJSONArray.Create;
container := document.getElementById('additionalFields');
colorCollection := container.children;
......@@ -243,8 +247,40 @@ begin
colorJSON.AddPair(header, value);
end;
colorList.Add(colorJSON);
colorListJSON := TJSONObject.Create;
colorListJSON.AddPair('items', colorList);
end;
XDataWebDataSet1.Edit;
XDataWebDataSet1colors_colors.Value := colorListJSON.ToString;
XDataWebDataSet1.Post;
XDataWebDataSet1.First;
while not XDataWebDataSet1.Eof do
begin
for Field in XDataWebDataSet1.Fields do
begin
if Field is TStringField then
begin
if Field.AsString = '' then
orderJSON.AddPair(Field.FieldName, '')
else
orderJSON.AddPair(Field.FieldName, Field.AsString); // Add all other fields
end
end;
XDataWebDataSet1.Next;
end;
console.log(colorList.ToString);
orderJSON.AddPair('COMPANY_ID', '749');
orderJSON.AddPair('USER_ID', '1011');
AddCorrugatedOrder(orderJSON);
end;
procedure TFOrderEntry.AddCorrugatedOrder(orderJSON: TJSONObject);
var
Response: TXDataClientResponse;
begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder',
[orderJSON.ToString]));
console.log(Response);
end;
class function TFOrderEntry.CreateForm(AElementID, orderInfo: string): TWebForm;
......@@ -336,11 +372,13 @@ var
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString: string;
tempString, strColorList: string;
colorObject: TJSObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrder',
[Order_ID]));
......@@ -349,15 +387,16 @@ begin
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(order);
XDataWebDataSet1.Open;
if XDataWebDataSet1colors_colors.Value <> '' then
begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1colors_colors.Value));
console.log(order);
colorList := TJSArray(colorObject['items']);
colorLength := colorList.length;
for i := 0 to colorLength - 1 do
for I := 0 to colorList.length -1 do
begin
color := TJSObject(colorList[i]);
addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size']));
end;
end;
if not (XDataWebDataSet1staff_fields_order_date.AsString = '') then
dtpOrderDate.Date := StrToDateTime(XDataWebDataSet1staff_fields_order_date.Value);
if not (XDataWebDataSet1staff_fields_proof_date.AsString = '') then
......
......@@ -9,10 +9,11 @@ unit View.Orders;
interface
uses
System.SysUtils, System.Classes, Web, WEBLib.Graphics, WEBLib.Forms, WEBLib.Dialogs,
Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls, WEBLib.Controls, WEBLib.Grids, WebLib.Lists,
XData.Web.Client, WEBLib.ExtCtrls, DB, XData.Web.JsonDataset,
XData.Web.Dataset, XData.Web.Connection, Vcl.Forms, DateUtils, WebAudio;
System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB;
type
TFViewOrders = class(TWebForm)
......@@ -81,8 +82,7 @@ var
implementation
uses
JS, XData.Model.Classes,
ConnectionModule, Auth.Service, View.Main;
XData.Model.Classes, View.Main;
{$R *.dfm}
......@@ -129,9 +129,10 @@ var
NewRow, Cell, P, Button, Audio: TJSHTMLElement;
colorObject: TJSObject;
colorList: TJSArray;
colorListJSON: TJSONArray;
colors: integer;
ClickHandler: TJSFunction;
id: string;
id, strColorList: string;
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
......@@ -294,6 +295,7 @@ begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1colors.Value));
colorList := TJSArray(colorObject['items']);
colors := colorList.flength;
console.log(colorList);
Cell.innerText := IntToStr(colors);
end;
NewRow.appendChild(Cell);
......
......@@ -192,6 +192,7 @@ type
function AddItem(itemInfo: string): string;
function DelUser(username: string): string;
function EditUser(const editOptions: string): string;
function AddCorrugatedOrder(orderInfo: string): TJSONObject;
end;
implementation
......
......@@ -273,6 +273,7 @@ begin
result.staff_fields_quickbooks_item := ordersDB.UniQuery1.FieldByName('staff_fields_quickbooks_item').AsString;
result.staff_fields_art_due := ordersDB.UniQuery1.FieldByName('staff_fields_art_due').AsString;
result.staff_fields_plate_due := ordersDB.UniQuery1.FieldByName('staff_fields_plate_due').AsString;
result.staff_fields_price := ordersDB.UniQuery1.FieldByName('staff_fields_price').AsString;
if orderType = 'corrugated_plate_order' then
result.staff_fields_mount_due := ordersDB.UniQuery1.FieldByName('staff_fields_mount_due').AsString;
result.staff_fields_art_location := ordersDB.UniQuery1.FieldByName('staff_fields_art_location').AsString;
......@@ -604,6 +605,7 @@ var
Pair: TJSONPair;
Field: TField;
DateFormat: TFormatSettings;
CurrDate: TDateTime;
begin
DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd';
......@@ -611,9 +613,9 @@ begin
JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject;
if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
SQL := 'select * from corrugated_plate_orders where ORDER_ID = ' + JSONData.GetValue('ORDER_ID').Value;
SQL := 'select * from corrugated_plate_orders where ORDER_ID = 0 and ORDER_ID <> 0';
doQuery(ordersDB.UniQuery1, SQL);
if( ordersDB.UniQuery1.IsEmpty ) then
if( True ) then
begin
try
ordersDB.UniQuery1.Insert;
......@@ -624,7 +626,7 @@ begin
begin
// handles any dates or datetimes
if (Field is TDateTimeField) and (Pair.JsonValue.Value <> '') then
TDateTimeField(Field).AsDateTime := StrToDateTime(Pair.JsonValue.Value, DateFormat)
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value)
else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value;
end;
......@@ -633,6 +635,23 @@ begin
// Post the new record to the database
ordersDB.UniQuery1.Post;
SQL := 'select * from orders where ORDER_ID = 0 and ORDER_ID <> 0';
doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Insert;
ordersDB.UniQuery1.FieldByName('COMPANY_ID').AsString := JSONData.GetValue<string>('COMPANY_ID');
ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString := 'corrugated_plate';
ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime := Now;
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;
Result := TJSONObject.Create.AddPair('status', 'success');
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
......
[Options]
LogFileNum=142
LogFileNum=168
UpdateTimerLength=0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment