fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16610] more on integration


From: sigurdne
Subject: [Fmsystem-commits] [16610] more on integration
Date: Fri, 21 Apr 2017 10:21:04 -0400 (EDT)

Revision: 16610
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16610
Author:   sigurdne
Date:     2017-04-21 10:21:03 -0400 (Fri, 21 Apr 2017)
Log Message:
-----------
more on integration

Modified Paths:
--------------
    trunk/property/inc/class.hook_helper.inc.php
    trunk/property/inc/class.menu.inc.php
    trunk/property/inc/class.sodimb_role_user.inc.php
    trunk/property/inc/class.sopending_action.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.soworkorder.inc.php
    trunk/property/inc/class.uidimb_role_user.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/property/setup/setup.inc.php

Modified: trunk/property/inc/class.hook_helper.inc.php
===================================================================
--- trunk/property/inc/class.hook_helper.inc.php        2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.hook_helper.inc.php        2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -1003,12 +1003,15 @@
                                        //                      
$portalbox->set_controls($key,$value);
                                }
 
+                               $users_for_substitute = 
CreateObject('property.sodimb_role_user')->get_users_for_substitute( 
$accound_id);
+                               $users_for_substitute[] = $accound_id;
+
+
                                $action_params = array
                                        (
                                        'appname' => 'property',
                                        'location' => '.project',
-                                       //      'id'                            
=> $id,
-                                       'responsible' => $accound_id,
+                                       'responsible' => $users_for_substitute,
                                        'responsible_type' => 'user',
                                        'action' => 'approval',
                                        'deadline' => '',
@@ -1170,4 +1173,38 @@
                        $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$save_app;
                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] = 
$maxmatches;
                }
+
+               function after_navbar( )
+               {
+                       $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
+                       $user_id = $GLOBALS['phpgw_info']['user']['account_id'];
+                       $substitute_user_id = 
$sodimb_role_user->get_substitute( $user_id);
+                       $lang_substitute = 
$GLOBALS['phpgw']->translation->translate('substitute', array(), false, 
'property');
+                       if($substitute_user_id)
+                       {
+                               echo '<div class="msg_good">';
+                               echo $lang_substitute .': ' . 
$GLOBALS['phpgw']->accounts->get($substitute_user_id)->__toString();
+                               echo '</div>';
+                       }
+
+                       $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute( $user_id);
+                       $names = array();
+                       foreach ($users_for_substitute as $user_for_substitute)
+                       {
+                               $names[] = 
$GLOBALS['phpgw']->accounts->get($user_for_substitute)->__toString();
+                       }
+                       if($names)
+                       {
+                               echo '<div class="msg_good">';
+                               echo $lang_substitute .' for : ' . implode(', 
', $names);
+                               echo '</div>';
+                       }
+
+                       if(in_array($substitute_user_id, $users_for_substitute))
+                       {
+                               echo '<div class="error">';
+                               echo $lang_substitute .': ' . lang('circle 
reference');
+                               echo '</div>';
+                       }
+               }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php       2017-04-21 08:30:28 UTC (rev 
16609)
+++ trunk/property/inc/class.menu.inc.php       2017-04-21 14:21:03 UTC (rev 
16610)
@@ -349,7 +349,14 @@
                                        'dimb_role_user2' => array
                                                (
                                                'text' => lang('dimb role 
user'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uidimb_role_user.index'))
+                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uidimb_role_user.index')),
+                                               'children' => array(
+                                                       'substitute' => array
+                                                       (
+                                                               'text' => 
lang('substitute'),
+                                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uidimb_role_user.list_substitute')),
+                                                       )
+                                               )
                                        ),
                                        'accounting_dimd' => array
                                                (

Modified: trunk/property/inc/class.sodimb_role_user.inc.php
===================================================================
--- trunk/property/inc/class.sodimb_role_user.inc.php   2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.sodimb_role_user.inc.php   2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -304,18 +304,39 @@
                        return $ok;
                }
 
-               public function update_substitute( $user_id, 
$substitute_user_id )
+               /**
+                * A user can only have one substitute
+                * @param int $user_id
+                * @param int $substitute_user_id
+                * @return boolean true on success
+                */
+               public function update_substitute( $user_id, 
$substitute_user_id = 0 )
                {
                        $this->db->transaction_begin();
                        $this->db->query('DELETE FROM 
fm_ecodimb_role_user_substitute WHERE user_id = ' . (int)$user_id, __LINE__, 
__FILE__);
-                       $this->db->query('INSERT INTO 
fm_ecodimb_role_user_substitute (user_id, substitute_user_id ) VALUES (' . 
(int)$user_id . ',' . (int) $substitute_user_id . ')', __LINE__, __FILE__);
+                       if($substitute_user_id)
+                       {
+                               $this->db->query('INSERT INTO 
fm_ecodimb_role_user_substitute (user_id, substitute_user_id ) VALUES (' . 
(int)$user_id . ',' . (int) $substitute_user_id . ')', __LINE__, __FILE__);
+                       }
                        if($this->db->transaction_commit())
                        {
-                               phpgwapi_cache::message_set(lang('substitute') 
.': ' . $GLOBALS['phpgw']->accounts->get($substitute_user_id)->__toString(), 
'message');
+                               if($substitute_user_id)
+                               {
+                                       
phpgwapi_cache::message_set(lang('substitute') .': ' . 
$GLOBALS['phpgw']->accounts->get($substitute_user_id)->__toString(), 'message');
+                               }
+                               else
+                               {
+                                       
phpgwapi_cache::message_set(lang('substitute') . ' ' .lang('deleted'), 
'message');
+                               }
                                return true;
                        }
                }
 
+               /**
+                * Get the substitute for a user
+                * @param int $user_id
+                * @return int $substitute_user_id
+                */
                public function get_substitute( $user_id)
                {
                        $this->db->query('SELECT substitute_user_id FROM 
fm_ecodimb_role_user_substitute WHERE user_id = ' . (int)$user_id, __LINE__, 
__FILE__);
@@ -322,4 +343,20 @@
                        $this->db->next_record();
                        return (int)$this->db->f('substitute_user_id');
                }
+
+               /**
+                * Get the users that the substitute is given responsibility for
+                * @param int $substitute_user_id
+                * @return array $users
+                */
+               public function get_users_for_substitute( $substitute_user_id)
+               {
+                       $this->db->query('SELECT user_id FROM 
fm_ecodimb_role_user_substitute WHERE substitute_user_id = ' . 
(int)$substitute_user_id, __LINE__, __FILE__);
+                       $users = array();
+                       while ($this->db->next_record())
+                       {
+                               $users[] = $this->db->f('user_id');
+                       }
+                       return $users;
+               }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.sopending_action.inc.php
===================================================================
--- trunk/property/inc/class.sopending_action.inc.php   2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.sopending_action.inc.php   2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -223,7 +223,7 @@
                        $appname = isset($data['appname']) && $data['appname'] 
? $data['appname'] : '';
                        $location = isset($data['location']) && 
$data['location'] ? $data['location'] : '';
                        $item_id = isset($data['id']) && $data['id'] ? 
$data['id'] : '';//possible bigint
-                       $responsible = (int)$data['responsible'];
+                       $responsible = $data['responsible'];
                        $responsible_type = isset($data['responsible_type']) && 
$data['responsible_type'] ? $data['responsible_type'] : 'user';
                        $action = isset($data['action']) && $data['action'] ? 
$this->db->db_addslashes($data['action']) : '';
                        $deadline = isset($data['deadline']) && 
$data['deadline'] ? (int)$data['deadline'] : 0;
@@ -249,10 +249,14 @@
                        $ret = array();
                        $condition = " WHERE num = '{$action}' AND location_id 
= {$location_id}";
 
-                       if ($responsible)
+                       if (is_array($responsible))
                        {
-                               $condition .= " AND responsible = 
{$responsible}";
+                               $condition .= ' AND responsible IN(' . 
implode(', ', $responsible) . ')';
                        }
+                       else if ((int)$responsible)
+                       {
+                               $condition .= " AND responsible = ". 
(int)$responsible;
+                       }
 
                        if ($item_id)
                        {
@@ -303,7 +307,7 @@
                                $this->db->query($sql . $ordermethod, __LINE__, 
__FILE__);
                        }
 
-                       $ret = $this->db->resultSet;
+                       $ret = (array)$this->db->resultSet;
 
                        $interlink = CreateObject('property.interlink');
 

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2017-04-21 08:30:28 UTC (rev 
16609)
+++ trunk/property/inc/class.soproject.inc.php  2017-04-21 14:21:03 UTC (rev 
16610)
@@ -1759,12 +1759,16 @@
                                {
                                        $close_pending_action = true;
 
+
+                                       $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
+                                       $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute($this->account);
+                                       $take_responsibility_for = 
array($this->account);
+
                                        $action_params = array
                                                (
                                                'appname' => 'property',
                                                'location' => '.project',
                                                'id' => (int)$project['id'],
-                                               'responsible' => $this->account,
                                                'responsible_type' => 'user',
                                                'action' => 'approval',
                                                'remark' => '',
@@ -1771,7 +1775,21 @@
                                                'deadline' => ''
                                        );
 
-                                       
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       $approvals = 
execMethod('property.sopending_action.get_pending_action', $action_params);
+
+                                       foreach ($approvals as $approval)
+                                       {
+                                               
if(in_array($approval['responsible'],$users_for_substitute))
+                                               {
+                                                       
$take_responsibility_for[] = $approval['responsible'];
+                                               }
+                                       }
+
+                                       foreach ($take_responsibility_for as 
$__account_id)
+                                       {
+                                               $action_params['responsible'] = 
$__account_id;
+                                               
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       }
                                        unset($action_params);
 
                                        
$this->approve_related_workorders($project['id']);
@@ -3423,14 +3441,17 @@
                        }
 
                        $historylog = CreateObject('property.historylog', 
'workorder');
+                       $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
 
                        foreach ($ids as $order_id)
                        {
+                               $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute($this->account);
+                               $take_responsibility_for = 
array($this->account);
+
                                $action_params = array(
                                        'appname' => 'property',
                                        'location' => '.project.workorder',
                                        'id' => $order_id,
-                                       'responsible' => $this->account,
                                        'responsible_type' => 'user',
                                        'action' => 'approval',
                                        'remark' => '',
@@ -3438,24 +3459,38 @@
                                        'closed' => true
 
                                );
-                               //check for approved
-                               
if(execMethod('property.sopending_action.get_pending_action', $action_params))
+
+                               $approvals = 
execMethod('property.sopending_action.get_pending_action', $action_params);
+
+                               foreach ($approvals as $approval)
                                {
-                                       continue;
+                                       
if(in_array($approval['responsible'],$users_for_substitute))
+                                       {
+                                               $take_responsibility_for[] = 
$approval['responsible'];
+                                       }
                                }
 
-                               unset($action_params['closed']);
-                               //approval_substitute
-                               
if(!execMethod('property.sopending_action.get_pending_action', $action_params))
+                               foreach ($take_responsibility_for as 
$__account_id)
                                {
-                                       
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);
+                                       $action_params['responsible'] = 
$__account_id;
+                                       //check for approved
+                                       
if(execMethod('property.sopending_action.get_pending_action', $action_params))
+                                       {
+                                               continue;
+                                       }
+                                       unset($action_params['closed']);
+                                       //approval_substitute
+                                       
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}");
+                                       $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');
+                                       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.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php        2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.soworkorder.inc.php        2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -1638,19 +1638,36 @@
                                $this->db->next_record();
                                if ($this->db->f('approved') || 
$workorder['approved'])
                                {
+                                       $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
+                                       $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute($this->account);
+                                       $take_responsibility_for = 
array($this->account);
+
                                        $action_params = array
-                                               (
+                                       (
                                                'appname' => 'property',
                                                'location' => 
'.project.workorder',
                                                'id' => $workorder['id'],
-                                               'responsible' => $this->account,
                                                'responsible_type' => 'user',
                                                'action' => 'approval',
                                                'remark' => '',
                                                'deadline' => ''
                                        );
+                                       $approvals = 
execMethod('property.sopending_action.get_pending_action', $action_params);
 
-                                       
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       foreach ($approvals as $approval)
+                                       {
+                                               
if(in_array($approval['responsible'],$users_for_substitute))
+                                               {
+                                                       
$take_responsibility_for[] = $approval['responsible'];
+                                               }
+                                       }
+
+                                       foreach ($take_responsibility_for as 
$__account_id)
+                                       {
+                                               $action_params['responsible'] = 
$__account_id;
+                                               
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       }
+
                                        unset($action_params);
                                }
                                //Sigurd: Consider remove
@@ -3027,12 +3044,15 @@
                                $this->db->next_record();
                                if ($this->db->f('approved'))
                                {
+                                       $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
+                                       $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute($this->account);
+                                       $take_responsibility_for = 
array($this->account);
+
                                        $action_params = array
-                                               (
+                                       (
                                                'appname' => 'property',
                                                'location' => 
'.project.workorder',
                                                'id' => $order_id,
-                                               'responsible' => $this->account,
                                                'responsible_type' => 'user',
                                                'action' => 'approval',
                                                'remark' => '',
@@ -3039,7 +3059,21 @@
                                                'deadline' => ''
                                        );
 
-                                       
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       $approvals = 
execMethod('property.sopending_action.get_pending_action', $action_params);
+
+                                       foreach ($approvals as $approval)
+                                       {
+                                               
if(in_array($approval['responsible'],$users_for_substitute))
+                                               {
+                                                       
$take_responsibility_for[] = $approval['responsible'];
+                                               }
+                                       }
+
+                                       foreach ($take_responsibility_for as 
$__account_id)
+                                       {
+                                               $action_params['responsible'] = 
$__account_id;
+                                               
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       }
                                        unset($action_params);
                                }
                                //Sigurd: Consider remove

Modified: trunk/property/inc/class.uidimb_role_user.inc.php
===================================================================
--- trunk/property/inc/class.uidimb_role_user.inc.php   2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.uidimb_role_user.inc.php   2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -311,8 +311,9 @@
                {
                        $user_id = $this->account_id;
                        $substitute_user_id = 
phpgw::get_var('substitute_user_id', 'int', 'POST');
+                       $save = phpgw::get_var('save', 'string', 'POST');
 
-                       if($substitute_user_id)
+                       if($save)
                        {
                                $this->bo->update_substitute($user_id, 
$substitute_user_id);
                        }

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2017-04-21 08:30:28 UTC (rev 
16609)
+++ trunk/property/inc/class.uiproject.inc.php  2017-04-21 14:21:03 UTC (rev 
16610)
@@ -1044,6 +1044,10 @@
                                                        'deadline' => ''
                                                );
 
+                                               /**
+                                                * For now - handled by 
uiworkorder.
+                                                * consider remove - beware of 
the substitute logic...see uiworkorder
+                                                */
                                                if 
(isset($values['mail_address']) && is_array($values['mail_address']))
                                                {
                                                        foreach 
($values['mail_address'] as $_account_id => $_address)

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2017-04-21 08:30:28 UTC 
(rev 16609)
+++ trunk/property/inc/class.uiworkorder.inc.php        2017-04-21 14:21:03 UTC 
(rev 16610)
@@ -913,9 +913,14 @@
                                }
 
                                $_budget_amount = 
$this->bo->get_budget_amount($id);
+                               $sodimb_role_user = 
CreateObject('property.sodimb_role_user');
 
                                if (isset($values['approval']) && 
$values['approval'] && $config->config_data['workorder_approval'])
                                {
+                                       if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
+                                       {
+                                               $receipt['error'][] = 
array('msg' => lang('SMTP server is not set! (admin section)'));
+                                       }
 
                                        $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
                                        $coordinator_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
@@ -955,6 +960,13 @@
 
                                                                if(!$approvals)
                                                                {
+                                                                       
$substitute = $sodimb_role_user->get_substitute($_account_id);
+                                                                       
+                                                                       
if($substitute)
+                                                                       {
+                                                                               
$_account_id = $substitute;
+                                                                       }
+
                                                                        
$_budget_amount = 
$this->bo->get_accumulated_budget_amount($values['project_id']);
 
                                                                        
$pending_action->set_pending_action($action_params_approved);
@@ -1022,61 +1034,65 @@
                                                        $message = '<a href ="' 
. $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
$approval_menuaction,
                                                        'id' => $id), false, 
true) . '">' . lang('Workorder %1 needs approval', $id) . '</a>';
                                                        $_orders = array($id);
-                                                       break;
-                                       }
 
-                                       if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
-                                       {
-                                               $receipt['error'][] = 
array('msg' => lang('SMTP server is not set! (admin section)'));
-                                       }
+                                                       $action_params = array(
+                                                               'appname' => 
'property',
+                                                               'location' => 
'.project.workorder',
+                                                               'id' => $id,
+                                                               'responsible' 
=> '',
+                                                               
'responsible_type' => 'user',
+                                                               'action' => 
'approval',
+                                                               'remark' => '',
+                                                               'deadline' => ''
+                                                       );
+                                                       $bcc = 
'';//$coordinator_email;
+                                                       foreach 
($values['approval'] as $_account_id => $_address)
+                                                       {
+                                                               $substitute = 
$sodimb_role_user->get_substitute($_account_id);
 
+                                                               /**
+                                                                * Alert the 
substitute
+                                                                */
+                                                               if($substitute)
+                                                               {
+                                                                       
$_account_id = $substitute;
+                                                               }
 
-                                       $action_params = array(
-                                               'appname' => 'property',
-                                               'location' => 
'.project.workorder',
-                                               'id' => $id,
-                                               'responsible' => '',
-                                               'responsible_type' => 'user',
-                                               'action' => 'approval',
-                                               'remark' => '',
-                                               'deadline' => ''
-                                       );
-                                       $bcc = '';//$coordinator_email;
-                                       foreach ($values['approval'] as 
$_account_id => $_address)
-                                       {
-                                               $prefs = 
$this->bocommon->create_preferences('property', $_account_id);
-                                               if (!empty($prefs['email']))
-                                               {
-                                                       $_address = 
$prefs['email'];
-                                               }
-                                               else
-                                               {
-                                                       $email_domain = 
!empty($GLOBALS['phpgw_info']['server']['email_domain']) ? 
$GLOBALS['phpgw_info']['server']['email_domain'] : 'bergen.kommune.no';
-                                                       $_address = 
$GLOBALS['phpgw']->accounts->id2lid($_account_id) . "@{$email_domain}";
-                                               }
+                                                               $prefs = 
$this->bocommon->create_preferences('property', $_account_id);
+                                                               if 
(!empty($prefs['email']))
+                                                               {
+                                                                       
$_address = $prefs['email'];
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$email_domain = !empty($GLOBALS['phpgw_info']['server']['email_domain']) ? 
$GLOBALS['phpgw_info']['server']['email_domain'] : 'bergen.kommune.no';
+                                                                       
$_address = $GLOBALS['phpgw']->accounts->id2lid($_account_id) . 
"@{$email_domain}";
+                                                               }
 
-                                               if($approval_level == 'order')
-                                               {
-                                                       foreach ($_orders as 
$_order_id)
-                                                       {
-                                                               
$action_params['responsible'] = $_account_id;
-                                                               
$action_params['id'] = $_order_id;
-                                                               try
+                                                               
if($approval_level == 'order')
                                                                {
-                                                                       
$historylog->add('AP', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
-                                                                       
execMethod('property.sopending_action.set_pending_action', $action_params);
-                                                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
-                                                                       if 
($rcpt)
+                                                                       foreach 
($_orders as $_order_id)
                                                                        {
-                                                                               
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message');
+                                                                               
$action_params['responsible'] = $_account_id;
+                                                                               
$action_params['id'] = $_order_id;
+                                                                               
try
+                                                                               
{
+                                                                               
        $historylog->add('AP', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
+                                                                               
        execMethod('property.sopending_action.set_pending_action', 
$action_params);
+                                                                               
        $rcpt = $GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
+                                                                               
        if ($rcpt)
+                                                                               
        {
+                                                                               
                phpgwapi_cache::message_set(lang('%1 is notified', 
$_address),'message');
+                                                                               
        }
+                                                                               
}
+                                                                               
catch (Exception $exc)
+                                                                               
{
+                                                                               
        phpgwapi_cache::message_set($exc->getMessage(),'error');
+                                                                               
}
                                                                        }
                                                                }
-                                                               catch 
(Exception $exc)
-                                                               {
-                                                                       
phpgwapi_cache::message_set($exc->getMessage(),'error');
-                                                               }
                                                        }
-                                               }
+                                                       break;
                                        }
                                }
 
@@ -1095,13 +1111,29 @@
 
                                        foreach ($values['do_approve'] as 
$_account_id => $_dummy)
                                        {
-                                               $action_params['responsible'] = 
$_account_id;
-                                               
if(!execMethod('property.sopending_action.get_pending_action', $action_params))
+                                               $users_for_substitute = 
$sodimb_role_user->get_users_for_substitute($_account_id);
+
+                                               $approvals = 
execMethod('property.sopending_action.get_pending_action', $action_params);
+
+                                               $take_responsibility_for = 
array($_account_id);
+                                               foreach ($approvals as 
$approval)
                                                {
-                                                       
execMethod('property.sopending_action.set_pending_action', $action_params);
+                                                       
if(in_array($approval['responsible'],$users_for_substitute))
+                                                       {
+                                                               
$take_responsibility_for[] = $approval['responsible'];
+                                                       }
                                                }
-                                               
execMethod('property.sopending_action.close_pending_action', $action_params);
-                                               $historylog->add('OA', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
+                                               foreach 
($take_responsibility_for as $__account_id)
+                                               {
+                                                       
$action_params['responsible'] = $__account_id;
+                                                       
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);
+                                                       $historylog->add('OA', 
$id, $GLOBALS['phpgw']->accounts->get($__account_id)->__toString() . 
"::{$_budget_amount}");
+                                               }
+                                               
unset($action_params['responsible']);
                                        }
                                }
 

Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php  2017-04-21 08:30:28 UTC (rev 16609)
+++ trunk/property/setup/setup.inc.php  2017-04-21 14:21:03 UTC (rev 16610)
@@ -239,7 +239,8 @@
                'addgroup'                              => 
'property.hook_helper.clear_userlist',
                'deletegroup'                   => 
'property.hook_helper.clear_userlist',
                'editgroup'                             => 
'property.hook_helper.clear_userlist',
-               'registration'                  => 
'property.hook_helper.add_location_contact'
+               'registration'                  => 
'property.hook_helper.add_location_contact',
+               'after_navbar'                  => 
'property.hook_helper.after_navbar',
        );
 
        /* Dependencies for this app to work */




reply via email to

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