fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16070] more on integration


From: sigurdne
Subject: [Fmsystem-commits] [16070] more on integration
Date: Sun, 11 Dec 2016 20:32:51 +0000 (UTC)

Revision: 16070
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16070
Author:   sigurdne
Date:     2016-12-11 20:32:51 +0000 (Sun, 11 Dec 2016)
Log Message:
-----------
more on integration

Modified Paths:
--------------
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/js/portico/workorder.edit.js
    trunk/property/setup/phpgw_no.lang

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2016-12-11 18:04:57 UTC (rev 
16069)
+++ trunk/property/inc/class.soproject.inc.php  2016-12-11 20:32:51 UTC (rev 
16070)
@@ -1763,6 +1763,8 @@
 
                                        
execMethod('property.sopending_action.close_pending_action', $action_params);
                                        unset($action_params);
+
+                                       
$this->approve_related_workorders($project['id']);
                                }
 
                                $workorder_closed_status = 
isset($this->config->config_data['workorder_closed_status']) && 
$this->config->config_data['workorder_closed_status'] ? 
$this->config->config_data['workorder_closed_status'] : 'closed';
@@ -3381,4 +3383,42 @@
                                }
                        }
                }
+
+               private function approve_related_workorders( $project_id )
+               {
+                       $project_id = (int)$project_id;
+                       $ids = array();
+                       $this->db->query("SELECT id FROM fm_workorder WHERE 
project_id = {$project_id}", __LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $ids[] = $this->db->f('id');
+                       }
+
+                       $historylog = CreateObject('property.historylog', 
'workorder');
+
+                       foreach ($ids as $order_id)
+                       {
+                               $action_params = array(
+                                       'appname' => 'property',
+                                       'location' => '.project.workorder',
+                                       'id' => $order_id,
+                                       'responsible' => $this->account,
+                                       'responsible_type' => 'user',
+                                       'action' => 'approval',
+                                       'remark' => '',
+                                       'deadline' => ''
+                               );
+
+                               
if(!execMethod('property.sopending_action.get_pending_action', $action_params))
+                               {
+                                       
execMethod('property.sopending_action.set_pending_action', $action_params);
+                               }
+                               
execMethod('property.sopending_action.close_pending_action', $action_params);
+                               $budget_amount = 
execMethod('property.boworkorder.get_budget_amount', $order_id);
+
+                               $historylog->add('OA', $order_id, 
$GLOBALS['phpgw']->accounts->get($this->account)->__toString() . 
"::{$budget_amount}");
+
+                               phpgwapi_cache::message_set(lang('order %1 
approved for amount %2', $order_id, $budget_amount),'message');
+                       }
+               }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2016-12-11 18:04:57 UTC (rev 
16069)
+++ trunk/property/inc/class.uiproject.inc.php  2016-12-11 20:32:51 UTC (rev 
16070)
@@ -1056,7 +1056,15 @@
                                                        {
                                                                if 
(isset($values['approval'][$_account_id]) && $values['approval'][$_account_id])
                                                                {
-                                                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $from_email, $from_name, 'html');
+                                                                       try
+                                                                       {
+                                                                               
$rcpt = $GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $from_email, $from_name, 'html');        
                                                                     
+                                                                       }
+                                                                       catch 
(Exception $e)
+                                                                       {
+                                                                               
phpgwapi_cache::message_set($e->getMessage(), 'error');
+                                                                       }
+
                                                                        
$action_params['responsible'] = $_account_id;
                                                                        
execMethod('property.sopending_action.set_pending_action', $action_params);
                                                                        if 
(!$rcpt)
@@ -1150,7 +1158,14 @@
 
                                                        $body = nl2br($body);
 
-                                                       $returncode = 
$GLOBALS['phpgw']->send->msg('email', $to, $subject, $body, false, false, 
false, $from_email, $from_name, 'html');
+                                                       try
+                                                       {
+                                                               $returncode = 
$GLOBALS['phpgw']->send->msg('email', $to, $subject, $body, false, false, 
false, $from_email, $from_name, 'html');
+                                                       }
+                                                       catch (Exception $e)
+                                                       {
+                                                               
phpgwapi_cache::message_set($e->getMessage(), 'error');
+                                                       }
 
                                                        if (!$returncode) // 
not nice, but better than failing silently
                                                        {

Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2016-12-11 18:04:57 UTC (rev 
16069)
+++ trunk/property/js/portico/workorder.edit.js 2016-12-11 20:32:51 UTC (rev 
16070)
@@ -537,7 +537,7 @@
        var contract_sum = Number($('#field_contract_sum').val());
        var budget_sum = Number($('#field_budget').val());
 
-       var total_amount = Math.max(contract_sum, budget_sum, 
Number(amount));// || Number(amount);
+       var total_amount = Math.max((contract_sum + Number(amount)), 
(budget_sum +Number(amount)) );// || Number(amount);
 
        $("#order_received_amount").val(total_amount);
 

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2016-12-11 18:04:57 UTC (rev 16069)
+++ trunk/property/setup/phpgw_no.lang  2016-12-11 20:32:51 UTC (rev 16070)
@@ -1209,6 +1209,7 @@
 order  property        no      Bestilling
 order approval revoked property        no      Bestillingsgodkjenning opphevet
 order approved property        no      Bestilling godkjent
+order %1 approved for amount %2        property        no      Bestilling %1 
er godkjent med beløp %2
 order order %1 is not approved property        no      Bestilling %1 er ikke 
godkjent
 order_dim1     property        no      Aktivitet
 order id       property        no      BestillingsNr




reply via email to

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