Jump to content
  • 0

How To Echo Total Amount_Due In Template Rather Than Modify System Files.


Question

Posted

as the picture shows,i want to echo total amount_due in client_main.pdt file,but not  modify system files.Because it is not conducive to update.

 

 

I used a very primitive way:

<?php if(isset($message)){
$pa = '%<p>(.*?)</p>%sim';
preg_match($pa, trim($message), $arr);
preg_match('/.\d{1,}.\d{1,2}/', $arr[1], $arr);
$total_due=$arr[0];
}else{
$total_due='0.00';
}
?>

20150815201312.jpg

1 answer to this question

Recommended Posts

  • 0
Posted

If you don't want to update core files, you can write a plugin that adds a widget to the client dashboard similar to the Invoices, Transactions, and Services widgets.

 

Otherwise, you'll need to update core files to make the data you want available to that template.

To do so, open the ClientMain controller in /app/controllers/client_main.php.

Find:

$this->set("client", $this->client);

Above that line add:

$this->set("max_due_currency", (isset($max_due_currency) ? $max_due_currency : null));
$this->set("max_due_amount", (isset($max_due_amount) ? $max_due_amount : null));

Open up the client_main.pdt template you mentioned, and use the CurrencyFormat helper to format the amount due, e.g.:

<?php
if ($this->Html->ifSet($max_due_currency) && $this->Html->ifSet($max_due_amount)) {
?>
<p><?php echo $this->CurrencyFormat->format($this->Html->ifSet($max_due_amount), $this->Html->ifSet($max_due_currency));?></p>
<?php
}
?>

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...