This topic is locked
[SOLVED]

 Date On Report Page

1/7/2013 8:09:10 AM
PHPRunner General questions
S
sickacid author

Hi I want to print date (now) on a report page, how can I do?

C
cgphp 1/7/2013

You can add a template variable (http://xlinesoft.com/phprunner/docs/smarty_templates.htm) to the Report editor and assign it the current date.

S
sickacid author 1/7/2013

Can U do an example?



You can add a template variable (http://xlinesoft.com/phprunner/docs/smarty_templates.htm) to the Report editor and assign it the current date.

C
cgphp 1/7/2013

Enter the following code to the "Before display" event:

$xt->assign('current_date',now());



current_date is the name of the template variable you have created on the Report editor. To create a template variable, got to Report editor and switch to HTML view and enter the following code where you want to show the current date:

{$current_date}
S
sickacid author 1/7/2013

I'm sorry, maby I've done the wrong question, it works only on report page, but i need it on the print report page.

C
cgphp 1/7/2013

The procedure for the Print page is the same.

S
sickacid author 1/7/2013

I've done this after page counter:

<SPAN {$pages_attrs}>Pagina <B>{$pageno}</B> di <B>{$maxpages}</B> Report generato il: {$current_date}</SPAN>
i get in the report only "Report generato il: " and not the date, but in the report page i can see the date



The procedure for the Print page is the same.

C
cgphp 1/7/2013

Did you assign to the variable the date value?

S
sickacid author 1/7/2013

In before display i've done this:
$today = date("d/m/y");

$xt->assign('current_date', $today);
i've put in report page {$current_date} and it'works i see: 07/01/13

and the same in print report page, but there doesn't works



Did you assign to the variable the date value?

C
cgphp 1/7/2013

For the Print Report page, you can use javascript code instead of the template variable. Embed the following JS code directly into the HTML editor where you want to show the current date:



<script>

var today = new Date();

var dd = today.getDate();

var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
if(dd < 10)

{

dd = '0' + dd;

}

if(mm < 10)

{

mm = '0' + mm;

}

today = dd+'/'+mm+'/'+yyyy;

document.write(today);

</script>