Hi,
For the hash cookies from the first video example it's constructed in the following way.
Report is generated by clicking on button so first we need to define in the object: Input / Button / Custome code:
onclick
Code: Select all
var start_date=$('#pdf_start_date').val();
var end_date=$('#pdf_end_date').val();
if (start_date==='') {start_date='2000-01-01';}
if (end_date==='') {end_date='2099-01-01';}
if ((new Date(start_date)-new Date(end_date))>0) {alert('Wrong date range!'); return;}
nuSetProperty('PAY_PDF_START', start_date);
nuSetProperty('PAY_PDF_END', end_date);
nuRunReport('FR1');
1st part of the code is to read the current values of 2 fields where I enter the date:
Code: Select all
var start_date=$('#pdf_start_date').val();
var end_date=$('#pdf_end_date').val();
next I make sure that it will always work, may happen that someone will just enter one field only or why to force people to enter both days if someone is interested only with start date or end date or if anyone wants the whole report he is not entering anything (then dates are assigned like from year 2000 to 2099):
Code: Select all
if (start_date==='') {start_date='2000-01-01';}
if (end_date==='') {end_date='2099-01-01';}
if ((new Date(start_date)-new Date(end_date))>0) {alert('Wrong date range!'); return;}
after if I am sure that my data with dates are properly declared I define the hash cookies which can be available in SQL (the same way as to define the hash cookies for PHP procedures):
Code: Select all
nuSetProperty('PAY_PDF_START', start_date);
nuSetProperty('PAY_PDF_END', end_date);
and next just to call the report with:
the query used for the report is following and is referring to the hash cookies defined just above:
Code: Select all
SELECT *,'1' as counter FROM payments LEFT JOIN recipient ON pay_for_whome=recipient_id LEFT JOIN charge ON pay_for_what=charge_id
WHERE pay_until_date BETWEEN '#PAY_PDF_START#' AND '#PAY_PDF_END#'
You can use as well the
Run function to generate report but then you will not have possibility to process the date data. Me personally prefer the above solution but of course you can try other possibilities.
When you are on the report you can refer and display directly the hash cookies in object type
Label for example:
reporthash.JPG
Additional info: if you generate report from specific
Edit form you can refer to the data objects from that form directly without the need to use nuSetProperty. You can use directly in your SQL code the hashed names like: #objectID#.