fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11754] property: percent alert


From: Sigurd Nes
Subject: [Fmsystem-commits] [11754] property: percent alert
Date: Wed, 26 Feb 2014 09:51:05 +0000

Revision: 11754
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11754
Author:   sigurdne
Date:     2014-02-26 09:51:04 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
property: percent alert

Modified Paths:
--------------
    trunk/property/inc/class.boworkorder.inc.php
    trunk/property/inc/class.soworkorder.inc.php

Modified: trunk/property/inc/class.boworkorder.inc.php
===================================================================
--- trunk/property/inc/class.boworkorder.inc.php        2014-02-26 08:46:05 UTC 
(rev 11753)
+++ trunk/property/inc/class.boworkorder.inc.php        2014-02-26 09:51:04 UTC 
(rev 11754)
@@ -885,9 +885,9 @@
 
                        if ($toarray)
                        {
-                               $percent = 
$this->so->get_order_budget_percent($order_id);
+                               $budget_info = 
$this->so->get_order_budget_percent($order_id);
 
-                               if($percent < 90)
+                               if($budget_info['percent'] < 90)
                                {
                                        return false;
                                }
@@ -903,10 +903,55 @@
                                        $from_email      = 
"{$from_name}<address@hidden>";
                                }
 
-                               $subject         = "Bestilling # {$order_id} 
har disponert {$percent} prosent av budsjettet";
+                               $subject         = "Bestilling # {$order_id} 
har disponert {$budget_info['percent']} prosent av budsjettet";
 
+                               $lang_budget = lang('budget');
+                               $lang_actual_cost = lang('actual cost');
+                               $lang_percent = lang('percent');
+                               $lang_obligation = lang('obligation');
                                $to = implode(';',$toarray);
+                               $cc = 'address@hidden';
                                $body = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.edit','id'=> $order_id),false,true).'">' . 
lang('workorder %1 has been edited',$order_id) .'</a>' . "\n";
+                               $body .= <<<HTML
+                               </br>
+                               <h2>{$workorder['title']}</h2>
+                               </br>
+                               </br>
+                               <table>
+                                       <tr>
+                                               <td>
+                                                       {$lang_budget}
+                                               </td>
+                                               <td align = 'right'>
+                                                       {$budget_info['budget']}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_actual_cost}
+                                               </td>
+                                               <td align = 'right'>
+                                                       
{$budget_info['actual_cost']}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_percent}
+                                               </td>
+                                               <td align = 'right'>
+                                                       
{$budget_info['percent']}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_obligation}
+                                               </td>
+                                               <td align = 'right'>
+                                                       
{$budget_info['obligation']}
+                                               </td>
+                                       </tr>
+                               </table>
+HTML;
 
                                if (!is_object($GLOBALS['phpgw']->send))
                                {
@@ -915,7 +960,7 @@
 
                                try
                                {
-                                       $ok = 
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body, false,false,false, 
$from_email, $from_name, 'html');
+                                       $ok = 
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body, false,$cc,false, 
$from_email, $from_name, 'html');
                                }
                                catch (phpmailerException $e)
                                {

Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php        2014-02-26 08:46:05 UTC 
(rev 11753)
+++ trunk/property/inc/class.soworkorder.inc.php        2014-02-26 09:51:04 UTC 
(rev 11754)
@@ -1763,7 +1763,8 @@
                function get_order_budget_percent($order_id)
                {
                        $_sub_budget = 0;
-                       $_sub_actual_cost = 0;
+                       $sum_actual_cost = 0;
+                       $sum_oblications = 0;
 
                        $budget = $this->get_budget($order_id);
                        foreach($budget as $entry)
@@ -1771,13 +1772,22 @@
                                if ($entry['active'] == 1)
                                {
                                        $_sub_budget += $entry['budget'];
-                                       $_sub_actual_cost += 
$entry['actual_cost'];
+                                       $sum_actual_cost += 
$entry['actual_cost'];
+                                       $sum_oblications += 
$entry['sum_oblications'];
                                }
                        }
                        $sum_budget = $_sub_budget == 0 ? 1 : $_sub_budget; // 
avoid zero-division
-                       $percent = round(($_sub_actual_cost/$sum_budget)*100, 
1);
+                       $percent = round(($sum_actual_cost/$sum_budget)*100, 1);
 
-                       return $percent;
+                       $budget_info = array
+                       (
+                               'percent'               => $percent,
+                               'budget'                => $sum_budget,
+                               'actual_cost'   => $sum_actual_cost,
+                               'obligation'    => $sum_oblications
+
+                       );
+                       return $budget_info;
                }
 
                /**




reply via email to

[Prev in Thread] Current Thread [Next in Thread]