This topic is locked

Smarty array(array()) change....

4/20/2008 5:49:23 PM
PHPRunner General questions
R
Rei author

Hi, I need your help.

I need to change the total sum of the page in xxxxx_print.php (report), is not a gobal!

This value is stored in the array $page:
$sum=array("Minutos"=>$pagetotals_sum["Minutos"]);

$page["page_totalMinutos_sum"]=GetData($sum,"Minutos","");
$page is passed to Smarty within another array:
$pages[]=$page;

$smarty->assign("pages",$pages);
I need to change the amount of {$page.page_totalMinutos_sum}
As it is an arrangement within another arrangement, using the methods $smarty->get_template_vars and $smarty->assign, I am not getting.
How to retrieve this information and put back in the arrangement of Smarty, after formatting as I need?
Thanks
Rei

J
Jane 4/21/2008

Hi,
use Print page: Before display event to change total value.

R
Rei author 4/21/2008

Jane Ok, I was using this event, thanks in any way.

I do not know exactly where the error was, but yesterday the night work.

But I am taking the whole array to recover $pages, change the content of the sub-positions keys page_totalHoras_sum and page_totalMinutos_sum and then submit again the array to Smarty $pages. I wonder if is to change only the sub-keys involved.
Thanks
Rei
For readers who need similar solution, to format or change data in the reports total sum, this works fine in Print page: Before display event:
$page="pages";

$page_totalHoras_sum="page_totalHoras_sum";

$page_totalMinutos_sum="page_totalMinutos_sum";

$vem=$smarty->get_template_vars($page);

$base=(intval($vem[0][$page_totalHoras_sum])60)+intval($vem[0][$page_totalMinutos_sum]);

$volta_h=floor($base / 60);

$volta_m=$base - ($volta_h
60);

$vem[0][$page_totalHoras_sum]=$volta_h;

$vem[0][$page_totalMinutos_sum]=$volta_m;

$smarty->assign($page,$vem);
$vem_h=$smarty->get_template_vars("global_totalHoras_sum");

$vem_m=$smarty->get_template_vars("global_totalMinutos_sum");

$base=$vem_m + ($vem_h 60);

$volta_h=floor($base / 60);

$volta_m=$base - ($volta_h
60);

$smarty->assign("global_totalHoras_sum",$volta_h,"");

$smarty->assign("global_totalMinutos_sum",$volta_m,"");
Before........................-...............After...................

..............................-.......................................

Horas...........Minutos.......-...............Horas............Minutos

.2..............30............-................2...............30.....

35..............45............-...............35...............45.....

.0..............45............-................0...............45.....

.0...............0............-................0................0.....

.0..............15............-................0...............15.....

..............................-.......................................

37H.............135M..........-...............[color="#FF0000"]39H..............M....

..............................-.......................................

37H.............135M..........-...............[color="#008000"]39H..............M....

[/font][/b]