PUBLIC oreport
SET CLASSLIB TO ab\aw\samples\fic\classe\ficsample.vcx ADDITIVE
oreport=NEWOBJECT("report")
oreport.Show
RETURN
**************************************************
#INCLUDE "ab\ab.h"
DEFINE CLASS report AS ficfrm
Height = 477
Width = 815
DoCreate = .T.
Caption = "Reporting"
Name = "Report"
cntOK.opgStyle.optClassic.Value = 1
cntOK.opgStyle.optClassic.Left = 0
cntOK.opgStyle.optClassic.Top = 0
cntOK.opgStyle.optClassic.Name = "optClassic"
cntOK.opgStyle.optBS.Left = 0
cntOK.opgStyle.optBS.Top = 30
cntOK.opgStyle.optBS.Name = "optBS"
cntOK.opgStyle.Top = 145
cntOK.opgStyle.Name = "opgStyle"
cntOK.cmdOK.Name = "cmdOK"
cntOK.imgSrce.Top = 45
cntOK.imgSrce.Name = "imgSrce"
cntOK.imgHelp.Top = 95
cntOK.imgHelp.Name = "imgHelp"
cntOK.Top = 5
cntOK.Left = 710
cntOK.Height = 211
cntOK.ZOrderSet = 1
cntOK.Name = "cntOK"
waitpic.Left = -5
waitpic.Top = 0
waitpic.ZOrderSet = 3
waitpic.Name = "waitpic"
lblFiC.Height = 15
lblFiC.Left = 10
lblFiC.Top = 460
lblFiC.Width = 305
lblFiC.ZOrderSet = 4
lblFiC.Name = "lblFiC"
lblTime.Height = 15
lblTime.Left = 408
lblTime.Top = 459
lblTime.Width = 338
lblTime.ZOrderSet = 7
lblTime.Name = "lblTime"
ADD OBJECT tutoinfoboxfic AS ficebxsrcecode WITH ;
Anchor = 30, ;
Height = 125, ;
Left = 10, ;
Top = 325, ;
Width = 790, ;
ZOrderSet = 0, ;
Name = "tutoInfoBoxFiC"
ADD OBJECT chkdisable AS ficchk WITH ;
Top = 10, ;
Left = 565, ;
Height = 17, ;
Width = 129, ;
FontName = "Consolas", ;
Anchor = 9, ;
Alignment = 1, ;
Caption = "Disabled", ;
ZOrderSet = 2, ;
wcpropsave = "Caption", ;
Name = "chkDisable"
ADD OBJECT lblorders AS ficlbl WITH ;
FontBold = .T., ;
FontSize = 12, ;
Anchor = 41, ;
Caption = "Orders", ;
Height = 17, ;
Left = 341, ;
Top = 7, ;
Width = 214, ;
ZOrderSet = 5, ;
wbsctag = "h3", ;
Name = "lblOrders"
ADD OBJECT opginto AS ficopg WITH ;
ButtonCount = 3, ;
Anchor = 56, ;
BorderStyle = 0, ;
Value = 1, ;
Height = 29, ;
Left = 181, ;
Top = 230, ;
Width = 146, ;
ZOrderSet = 6, ;
wbsclbllinked = "lblInto", ;
Name = "opgInto", ;
Ficopt1.FontName = "Consolas", ;
Ficopt1.Anchor = 130, ;
Ficopt1.Caption = "Form", ;
Ficopt1.Value = 1, ;
Ficopt1.Height = 29, ;
Ficopt1.Left = -1, ;
Ficopt1.Style = 1, ;
Ficopt1.Top = 0, ;
Ficopt1.Width = 46, ;
Ficopt1.Name = "optForm", ;
Ficopt2.FontName = "Consolas", ;
Ficopt2.Anchor = 160, ;
Ficopt2.Caption = "Tab", ;
Ficopt2.Height = 29, ;
Ficopt2.Left = 48, ;
Ficopt2.Style = 1, ;
Ficopt2.Top = 0, ;
Ficopt2.Width = 47, ;
Ficopt2.Name = "optPage", ;
Ficopt3.Anchor = 40, ;
Ficopt3.Caption = "Win", ;
Ficopt3.Height = 29, ;
Ficopt3.Left = 98, ;
Ficopt3.Style = 1, ;
Ficopt3.Top = 0, ;
Ficopt3.Width = 47, ;
Ficopt3.Name = "optWin"
ADD OBJECT grdcustomer AS ficgrd WITH ;
Anchor = 195, ;
AllowHeaderSizing = .F., ;
DeleteMark = .F., ;
Height = 190, ;
Left = 10, ;
RecordSource = "customer_lcad", ;
Top = 30, ;
Width = 320, ;
ZOrderSet = 8, ;
AllowCellSelection = .F., ;
Name = "grdCustomer"
ADD OBJECT grdorders AS ficgrd WITH ;
Anchor = 105, ;
AllowHeaderSizing = .F., ;
DeleteMark = .F., ;
Height = 190, ;
Left = 340, ;
RecordSource = "orders", ;
ScrollBars = 2, ;
Top = 30, ;
Width = 358, ;
ZOrderSet = 9, ;
AllowCellSelection = .F., ;
wbsclbllinked = "lblOrders", ;
Name = "grdOrders"
ADD OBJECT cmdrptasync AS ficcmd WITH ;
Top = 275, ;
Left = 640, ;
Height = 31, ;
Width = 163, ;
FontName = "Consolas", ;
FontSize = 8, ;
Anchor = 146, ;
Caption = "Print!", ;
ZOrderSet = 10, ;
Name = "cmdRptAsync"
ADD OBJECT cmdrptsync AS ficcmd WITH ;
Top = 227, ;
Left = 640, ;
Height = 31, ;
Width = 163, ;
FontName = "Consolas", ;
FontSize = 8, ;
Anchor = 146, ;
Caption = "Print!", ;
ZOrderSet = 10, ;
Name = "cmdRptSync"
ADD OBJECT opgprint AS ficopg WITH ;
ButtonCount = 3, ;
Anchor = 176, ;
BorderStyle = 0, ;
Value = 0, ;
Height = 29, ;
Left = 401, ;
Top = 227, ;
Width = 223, ;
ZOrderSet = 11, ;
Name = "opgPrint", ;
Ficopt1.FontName = "Consolas", ;
Ficopt1.Anchor = 130, ;
Ficopt1.Caption = "FoxyPreviewer", ;
Ficopt1.Height = 29, ;
Ficopt1.Left = -1, ;
Ficopt1.Style = 1, ;
Ficopt1.Top = 0, ;
Ficopt1.Width = 105, ;
Ficopt1.Name = "optFoxy", ;
Ficopt2.FontName = "Consolas", ;
Ficopt2.Anchor = 160, ;
Ficopt2.Caption = "XFRX", ;
Ficopt2.Height = 29, ;
Ficopt2.Left = 105, ;
Ficopt2.Style = 1, ;
Ficopt2.Top = 0, ;
Ficopt2.Width = 48, ;
Ficopt2.Name = "optXFRX", ;
Ficopt3.FontName = "Consolas", ;
Ficopt3.Anchor = 40, ;
Ficopt3.Caption = "FRX2any", ;
Ficopt3.Height = 29, ;
Ficopt3.Left = 155, ;
Ficopt3.Style = 1, ;
Ficopt3.Top = 0, ;
Ficopt3.Width = 66, ;
Ficopt3.Name = "optFRX2any"
ADD OBJECT lblcust AS ficlbl WITH ;
FontBold = .T., ;
FontSize = 12, ;
Anchor = 131, ;
Caption = "Customers", ;
Height = 17, ;
Left = 10, ;
Top = 7, ;
Width = 205, ;
ZOrderSet = 12, ;
wbsctag = "h3", ;
Name = "lblCust"
ADD OBJECT lblinto AS ficlbl WITH ;
FontBold = .T., ;
Anchor = 176, ;
Alignment = 2, ;
Caption = "Print PDF report into", ;
Height = 17, ;
Left = 15, ;
Top = 237, ;
Width = 156, ;
ZOrderSet = 13, ;
Name = "lblInto"
ADD OBJECT lblwith AS ficlbl WITH ;
FontBold = .T., ;
Anchor = 176, ;
Alignment = 2, ;
Caption = "using", ;
Height = 17, ;
Left = 340, ;
Top = 235, ;
Width = 52, ;
ZOrderSet = 14, ;
Name = "lblWith"
ADD OBJECT cmdcust AS ficcmd WITH ;
Top = 6, ;
Left = 229, ;
Height = 21, ;
Width = 100, ;
Anchor = 161, ;
Caption = "Update", ;
Name = "cmdCust"
PROCEDURE Load
set database to tastrade
set deleted on
set filter to indexseek(customer.customer_ID, .F., 'orders', 'customer_i') in customer
set filter to indexseek(customer_lcad.customer_ID, .F., 'orders', 'customer_i') in customer_lcad
return DoDefault()
ENDPROC
PROCEDURE chkdisable.refresh_
lparameters void_parameter_reminder_implement_your_Refresh_code_in_this_method
this.Caption = cRefAppend(this.Caption, Iif(Cast(this.Value as L), 'on', 'off'), .T.)
ENDPROC
PROCEDURE chkdisable.Click
lparameters nButton, nShift, nXcoord, nYcoord
if thisform.wlHTMLgen
return
endif
this.Parent.grdOrders.Enabled = !Cast(this.Value as L)
this.Refresh
ENDPROC
PROCEDURE opginto.Valid
if thisform.wlHTMLgen
return
endif
if InList(m.this.Value, 2, 3) and !this.Buttons(m.this.Value).lPopupAck
thisForm.wMessageBox(;
ICase(;
thisForm.wcLangUser = 'fr', [Cette option nécessite que l'utilisateur autorise les popups sur ce site (selon le navigateur)],;
[This option requires that user allows popups on this site (browser dependent)];
);
, 64;
)
this.Buttons(m.this.Value).lPopupAck = .T.
endif
ENDPROC
PROCEDURE opginto.Init
local instantiate
instantiate = m.thisForm.wlWeb and DoDefault()
if m.instantiate
this.optPage.AddProperty('lPopupAck')
this.optWin.AddProperty('lPopupAck')
store ICase(;
thisForm.wcLangUser = 'fr', [Nécessite que l'utilisateur autorise les popups sur ce site],;
[Requires that user allows popups on this site];
) to this.optPage.ToolTipText, this.optWin.ToolTipText
endif
return m.instantiate
ENDPROC
PROCEDURE grdorders.wafterrowchange
LPARAMETERS tuRow
if thisForm.wlHTMLgen
return .F.
endif
return DoDefault(@m.tuRow)
ENDPROC
PROCEDURE cmdrptasync.Click
IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
local cScriptJS
text to cScriptJS textmerge noshow flags 1 pretext 7
var oGrid = jQuery("#<<thisForm.grdCustomer.wcID>>").prop('oGrid');
jQuery.ajax('custOrderReport.tuto', {
data:{
"custID": oGrid.getRowProperty('tuRow', oGrid.getCurrentRow())
, "PDFengine": jQuery("#<<thisForm.opgPrint.wcID>>").find("input[type=radio]:checked").next().text()
}
, success: function(data, status){
jQuery.notify({
title: ''
, message: (data.success ? 'Your report is ready! Click to display' : 'Your report failed because ' + data.result)
, url: (data.success ? data.result : '')
, target: '_blank'
}
, {
delay: 10000
, element: '#<<thisForm.wcID>>'
}
)
}
, error: function(jqXHR, status, error){
console.log(error);
}
, complete: function(){
jQuery(this).find('i').hide()
}
, context: this
});
jQuery(this).find('i').show()
endtext
RETURN m.cScriptJS
ENDIF
ENDPROC
PROCEDURE cmdrptasync.Init
return thisForm.wlWeb and DoDefault()
ENDPROC
PROCEDURE cmdrptasync.refresh_
this.Caption = ICase(;
thisForm.wcLangUser = 'fr', [Impression asynchrone],;
[Asynchronous report];
);
+ ' <i class="fa fa-refresh fa-spin text-success" style="display:none;"></i>'
ENDPROC
PROCEDURE cmdrptsync.refresh_
this.Enabled = !thisForm.wlWeb or this.Parent.opgPrint.Value > 0
this.Caption = ICase(;
thisForm.wcLangUser = 'fr', [Impression synchrone],;
[Synchronous report];
);
ENDPROC
PROCEDURE cmdrptsync.Init
if thisForm.wlLAN
this.Left = this.Parent.grdOrders.Left
this.Width = this.Parent.grdOrders.Width
endif
return DoDefault()
ENDPROC
PROCEDURE cmdrptsync.Click
IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
#if .f.
Value returned indicates to FoxInCloud Application Server how browser should handle this event:
RETURN .T.
RETURN <JavaScript code>
RETURN .F.
For more details and options, see code inherited from aw*
#endif
RETURN .T.
ENDIF
local success as Boolean;
, result;
, abSelect as abSelect of abData.prg;
, customerID;
, company;
, nSeconds;
, lcPDFout;
, lcPDFengine;
success = .T.
abSelect = abSelect(thisForm.grdCustomer.RecordSource)
customerID = Trim(customer_ID)
company = Trim(company_name)
nSeconds = Seconds()
if thisForm.wlWeb
lcPDFengine = ICase(;
this.parent.opgPrint.Value = 1,;
'FoxyPreviewer',;
this.parent.opgPrint.Value = 2,;
'XFRX',;
'FRX2any';
)
* Generate PDF using the appropriate generator
success = custOrderReport(;
@m.result;
,@m.lcPDFout;
, m.customerID;
, m.lcPDFengine;
)
* Now display generated PDF to the User
do case
case !m.success
case thisForm.opgInto.Value = 1
thisForm.wForm(;
'reportChild.scx';
, .F.;
, m.lcPDFout;
)
external form reportChild
otherwise
success = thisForm.wFileSaveAs(;
m.lcPDFout;
,@m.result;
, Iif(m.thisForm.opgInto.Value = 3;
, 'TastradeReport';
, '';
);
)
endcase
thisForm.wMessageBox(Iif(m.success;
, Textmerge('';
+ [FoxInCloud generated an order report for customer '<<m.company>>'] + ' ';
+ [using the '<<m.lcPDFengine>>' PDF generator,] + ' ';
+ [and displayed it into a ];
+ ICase(;
thisForm.opgInto.Value = 1,;
[child form within the same browser Tab],;
thisForm.opgInto.Value = 2,;
[new browser Tab],;
thisForm.opgInto.Value = 3,;
[new browser Window],;
[];
) + [, ];
+ [all in <<cSeconds(m.nSeconds)>>];
);
, m.result;
))
else
report form customer for customer_ID = m.customerID preview
endif
return m.success
ENDPROC
PROCEDURE opgprint.Init
this.optFoxy.Enabled = Type('_screen.oFoxyPreviewer') == 'O'
this.optXFRX.Enabled = File('xfrx.fxp') or File('xfrx.app')
this.optFRX2any.Enabled = File('FRX2Any.vcx') or lDevMode() and File('FRX2Any.app')
local iOpt as Integer, oOpt as awOpt of aw.vcx
for iOpt = 1 to this.ButtonCount
oOpt = m.this.Buttons(m.iOpt)
if m.oOpt.Enabled
this.Value = Evl(m.this.Value, m.iOpt)
else
m.oOpt.ToolTipText = ICase(;
thisForm.wcLangUser = 'fr', [cette option de génération de PDF est soit non installée, soit sa version des démonstration est incompatible avec le fonctionnement de VFP en mode COM],;
[this PDF generation option is not installed and/or its demo version does not support VFP running as a COM object];
)
endif
endfor
return m.thisForm.wlWeb and DoDefault()
ENDPROC
PROCEDURE opgprint.Valid
if m.thisForm.wlHTMLgen
return
endif
thisForm.Refresh
ENDPROC
PROCEDURE lblinto.Init
local success as Boolean
success = m.thisForm.wlWeb and DoDefault()
if m.success and thisForm.wBSlHTMLgen and .F.
this.Left = this.Parent.opgInto.Left
this.Top = this.Parent.opgInto.Top - 5
this.Parent.opgInto.Top = this.Top + this.Height + 1
endif
return m.success
ENDPROC
PROCEDURE lblwith.Init
local success as Boolean
success = m.thisForm.wlWeb and DoDefault()
if m.success and thisForm.wBSlHTMLgen and .F.
this.Left = this.Parent.opgInto.Left
this.Top = this.Parent.opgInto.Top - 5
this.Parent.opgInto.Top = this.Top + this.Height + 1
endif
return m.success
ENDPROC
PROCEDURE cmdcust.refresh_
this.Caption = ICase(;
thisForm.wcLangUser = 'fr', [Modifier],;
[Update];
);
ENDPROC
PROCEDURE cmdcust.Click
lparameters nButton, nShift, nXcoord, nYcoord
IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
RETURN .T.
ENDIF
thisForm.wForm('dataUpdate.scx')
external form dataUpdate
ENDPROC
ENDDEFINE