fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16062] more on integration


From: sigurdne
Subject: [Fmsystem-commits] [16062] more on integration
Date: Fri, 9 Dec 2016 09:49:27 +0000 (UTC)

Revision: 16062
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16062
Author:   sigurdne
Date:     2016-12-09 09:49:27 +0000 (Fri, 09 Dec 2016)
Log Message:
-----------
more on integration

Modified Paths:
--------------
    trunk/property/inc/class.botts.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/inc/class.uiwo_hour.inc.php
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
    trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
    trunk/property/js/portico/project.edit.js
    trunk/property/js/portico/tts.view.js
    trunk/property/js/portico/workorder.edit.js

Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php      2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/inc/class.botts.inc.php      2016-12-09 09:49:27 UTC (rev 
16062)
@@ -1778,6 +1778,14 @@
                        return $this->so->add_relation($add_relation, $id);
                }
 
+               /**
+                * 
+                * @param type $ecodimb
+                * @param type $amount
+                * @param type $order_id
+                * @return array
+                * @throws Exception
+                */
                public function check_purchase_right($ecodimb = 0, $amount = 0, 
$order_id = 0)
                {
                        $need_approval = 
isset($this->config->config_data['workorder_approval']) ? 
$this->config->config_data['workorder_approval'] : '';
@@ -1892,11 +1900,11 @@
 
                                if ($supervisor_id)
                                {
-                                       $supervisors[$supervisor_id] = 
array('id' => $supervisor_id, 'required' => false);
+                                       $supervisors[$supervisor_id] = 
array('id' => $supervisor_id, 'required' => true);
 
                                        $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
 
-                                       if (!empty($prefs['approval_from']))
+                                       if (!empty($prefs['approval_from']) && 
empty($supervisors[$prefs['approval_from']]))
                                        {
                                                $supervisor_id = 
$prefs['approval_from'];
                                                $supervisors[$supervisor_id] = 
array('id' => $supervisor_id, 'required' => false);
@@ -1906,7 +1914,7 @@
                        }
 
                        if(!$check_external_register && 
!empty($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
-                               && 
!in_array($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'],$supervisors))
+                               && 
empty($supervisors[$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from']]))
                        {
                                $supervisor_id =  
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
                                $supervisors[$supervisor_id] = array('id' => 
$supervisor_id, 'required' => false, 'default' => true);
@@ -1962,6 +1970,13 @@
                        return json_decode($result, true);
                }
 
+               /**
+                * 
+                * @param array $supervisors
+                * @param int $order_id
+                * @return array
+                * @throws Exception
+                */
                protected function get_supervisor_approval($supervisors, 
$order_id = 0)
                {
                        $need_approval = 
isset($this->config->config_data['workorder_approval']) ? 
$this->config->config_data['workorder_approval'] : '';
@@ -1981,7 +1996,7 @@
                                                $location_item_id = 
$this->so->get_ticket_from_order($order_id);
                                                break;
                                        default:
-                                               throw new Exception('Not 
supported');
+                                               throw new Exception('Order type 
not supported');
                                }
                        }
 
@@ -2048,4 +2063,78 @@
                        return $supervisor_email;
                }
 
+               function validate_purchase_grant( $ecodimb, $budget_amount, 
$order_id )
+               {
+                       if($order_id)
+                       {
+                               $order_type = 
$this->bocommon->socommon->get_order_type($order_id);
+
+                               switch ($order_type)
+                               {
+                                       case 'workorder':
+                                               $location = 
'.project.workorder';
+                                               $location_item_id = $order_id;
+                                               $historylog = 
CreateObject('property.historylog', 'workorder');
+                                               $history_code = 'OA';
+                                               break;
+                                       case 'ticket':
+                                               $location = '.ticket';
+                                               $location_item_id = 
$this->so->get_ticket_from_order($order_id);
+                                               $historylog = 
CreateObject('property.historylog', 'tts');
+                                               $history_code = 'AA';
+                                               break;
+                                       default:
+                                               throw new Exception('Order type 
not supported');
+                               }
+                       }
+
+                       try
+                       {
+                               $check_purchase = 
$this->check_purchase_right($ecodimb, $budget_amount, $order_id);
+
+                       }
+                       catch (Exception $ex)
+                       {
+                               throw $ex;
+                       }
+
+                       $purchase_grant_ok = true;
+
+                       foreach ($check_purchase as $purchase_grant)
+                       {
+                               if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
+                               {
+                                       $purchase_grant_ok = false;
+                                       
phpgwapi_cache::message_set(lang('approval from %1 is required for order %2',
+                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString(), 
$order_id),
+                                                       'error'
+                                       );
+                               }
+                               else if( $purchase_grant['is_user'] && ( 
$purchase_grant['required']  && !$purchase_grant['approved']))
+                               {
+                                       $action_params = array(
+                                               'appname' => 'property',
+                                               'location' => $location,
+                                               'id' => $location_item_id,
+                                               'responsible' => '',
+                                               'responsible_type' => 'user',
+                                               'action' => 'approval',
+                                               'remark' => '',
+                                               'deadline' => ''
+                                       );
+
+                                       $_account_id = 
$purchase_grant['id'];//$this->account
+
+                                       $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($history_code, 
$location_item_id, $GLOBALS['phpgw']->accounts->get($_account_id)->__toString() 
. "::{$budget_amount}");
+                                       $purchase_grant_ok = true;
+                               }
+                       }
+                       return $purchase_grant_ok;
+               }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/inc/class.uiproject.inc.php  2016-12-09 09:49:27 UTC (rev 
16062)
@@ -2715,13 +2715,12 @@
                {
                        $tabs = array
                                (
-                               'general' => array('label' => lang('general'), 
'link' => '#general', 'function' => "set_tab('general')"),
-                               'location' => array('label' => 
lang('location'), 'link' => '#location', 'function' => "set_tab('location')"),
-                               'budget' => array('label' => lang('Time and 
budget'), 'link' => '#budget', 'function' => "set_tab('budget')"),
-                               'coordination' => array('label' => 
lang('coordination'), 'link' => '#coordination',
-                                       'function' => 
"set_tab('coordination')"),
-                               'documents' => array('label' => 
lang('documents'), 'link' => '#documents', 'function' => 
"set_tab('documents')"),
-                               'history' => array('label' => lang('history'), 
'link' => '#history', 'function' => "set_tab('history')"),
+                               'general' => array('label' => lang('general'), 
'link' => '#general'),//, 'function' => "set_tab('general')"),
+                               'location' => array('label' => 
lang('location'), 'link' => '#location'),//, 'function' => 
"set_tab('location')"),
+                               'budget' => array('label' => lang('Time and 
budget'), 'link' => '#budget'),//, 'function' => "set_tab('budget')"),
+                               'coordination' => array('label' => 
lang('coordination'), 'link' => '#coordination'),//,'function' => 
"set_tab('coordination')"),
+                               'documents' => array('label' => 
lang('documents'), 'link' => '#documents'),//, 'function' => 
"set_tab('documents')"),
+                               'history' => array('label' => lang('history'), 
'link' => '#history'),//, 'function' => "set_tab('history')"),
                        );
 
                        $tabs = array_merge($tabs, $tabs_);

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/inc/class.uitts.inc.php      2016-12-09 09:49:27 UTC (rev 
16062)
@@ -3688,67 +3688,19 @@
 
                        if (empty($purchase_grant_checked))
                        {
-                               $_budget_amount = 
$this->_get_budget_amount($id);
+                               $budget_amount = $this->_get_budget_amount($id);
 
-
                                try
                                {
-                                       $check_purchase = 
$this->bo->check_purchase_right($ticket['ecodimb'], $_budget_amount, $id);
-
+                                       $purchase_grant_ok = 
$this->bo->validate_purchase_grant( $ecodimb, $budget_amount, $order_id );
                                }
                                catch (Exception $ex)
                                {
                                        throw $ex;
                                }
 
+                               $purchase_grant_error = $purchase_grant_ok ? 
false : true;
 
-                               $purchase_grant_error = false;
-
-                               foreach ($check_purchase as $purchase_grant)
-                               {
-//                                     if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
-//                                     {
-//                                             $purchase_grant_error = true;
-//                                             
phpgwapi_cache::message_set(lang('approval from %1 is required',
-//                                                             
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
-//                                                             'error'
-//                                             );
-//                                     }
-
-                                       if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
-                                       {
-                                               $purchase_grant_error = true;
-                                               
phpgwapi_cache::message_set(lang('approval from %1 is required for order %2',
-                                                               
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString(), $id),
-                                                               'error'
-                                               );
-                                       }
-                                       else if( $purchase_grant['is_user'] && 
( $purchase_grant['required'] && $purchase_grant['requested'] && 
!$purchase_grant['approved']))
-                                       {
-                                               $action_params = array(
-                                                       'appname' => 'property',
-                                                       'location' => '.ticket',
-                                                       'id' => $id,
-                                                       'responsible' => '',
-                                                       'responsible_type' => 
'user',
-                                                       'action' => 'approval',
-                                                       'remark' => '',
-                                                       'deadline' => ''
-                                               );
-
-                                               $_account_id = 
$purchase_grant['id'];//$this->account
-
-                                               $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}");
-                                               $purchase_grant_error = false;
-                                       }
-
-                               }
                        }
 
 //                             _debug_array($check_purchase); die();

Modified: trunk/property/inc/class.uiwo_hour.inc.php
===================================================================
--- trunk/property/inc/class.uiwo_hour.inc.php  2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/inc/class.uiwo_hour.inc.php  2016-12-09 09:49:27 UTC (rev 
16062)
@@ -3460,55 +3460,16 @@
                private function _validate_purchase_grant( $id, $ecodimb )
                {
                        $_budget_amount = 
$this->boworkorder->get_budget_amount($id);
-                       $historylog = CreateObject('property.historylog', 
'workorder');
 
                        try
                        {
-                               $check_purchase = 
createObject('property.botts')->check_purchase_right($ecodimb, $_budget_amount, 
$id);
-
+                               $purchase_grant_ok = 
CreateObject('property.botts')->validate_purchase_grant( $ecodimb, 
$_budget_amount, $id);
                        }
                        catch (Exception $ex)
                        {
                                throw $ex;
                        }
 
-                       $purchase_grant_ok = true;
-
-                       foreach ($check_purchase as $purchase_grant)
-                       {
-                               if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
-                               {
-                                       $purchase_grant_ok = false;
-                                       
phpgwapi_cache::message_set(lang('approval from %1 is required for order %2',
-                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString(), $id),
-                                                       'error'
-                                       );
-                               }
-                               else if( $purchase_grant['is_user'] && ( 
$purchase_grant['required'] && $purchase_grant['requested'] && 
!$purchase_grant['approved']))
-                               {
-                                       $action_params = array(
-                                               'appname' => 'property',
-                                               'location' => 
'.project.workorder',
-                                               'id' => $id,
-                                               'responsible' => '',
-                                               'responsible_type' => 'user',
-                                               'action' => 'approval',
-                                               'remark' => '',
-                                               'deadline' => ''
-                                       );
-
-                                       $_account_id = 
$purchase_grant['id'];//$this->account
-
-                                       $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}");
-                                       $purchase_grant_ok = true;
-                               }
-                       }
                        return $purchase_grant_ok;
                }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2016-12-09 09:49:11 UTC 
(rev 16061)
+++ trunk/property/inc/class.uiworkorder.inc.php        2016-12-09 09:49:27 UTC 
(rev 16062)
@@ -2955,24 +2955,24 @@
                                (
                                'general' => array(
                                        'label' => lang('general'),
-                                       'link' => '#general',
-                                       'function' => "set_tab('general')"),
+                                       'link' => '#general'
+                                       ),
                                'budget' => array(
                                        'label' => lang('Time and budget'),
-                                       'link' => '#budget',
-                                       'function' => "set_tab('budget')"),
+                                       'link' => '#budget'
+                                       ),
                                'coordination' => array(
                                        'label' => lang('coordination'),
-                                       'link' => '#coordination',
-                                       'function' => 
"set_tab('coordination')"),
+                                       'link' => '#coordination'
+                                       ),
                                'documents' => array(
                                        'label' => lang('documents'),
-                                       'link' => '#documents',
-                                       'function' => "set_tab('documents')"),
+                                       'link' => '#documents'
+                                       ),
                                'history' => array(
                                        'label' => lang('history'),
-                                       'link' => '#history',
-                                       'function' => "set_tab('history')"),
+                                       'link' => '#history'
+                                       ),
                        );
                        $tabs = array_merge($tabs, $tabs_);
 

Modified: 
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
===================================================================
--- trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php  
2016-12-09 09:49:11 UTC (rev 16061)
+++ trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php  
2016-12-09 09:49:27 UTC (rev 16062)
@@ -63,45 +63,17 @@
                                $price += $budget['amount'];
                        }
 
-                       $purchase_grant_error = false;
-                       $check_purchase = 
CreateObject('property.botts')->check_purchase_right($_ticket['ecodimb'], 
$price, $_ticket['order_id']);
-                       foreach ($check_purchase as $purchase_grant)
+                       try
                        {
-                               if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
-                               {
-                                       $purchase_grant_error = true;
-                                       
phpgwapi_cache::message_set(lang('approval from %1 is required',
-                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
-                                                       'error'
-                                       );
-                               }
-                               else if( $purchase_grant['is_user'] && ( 
$purchase_grant['required'] && $purchase_grant['requested'] && 
!$purchase_grant['approved']))
-                               {
-                                       $action_params = array(
-                                               'appname' => 'property',
-                                               'location' => '.ticket',
-                                               'id' => $id,
-                                               'responsible' => '',
-                                               'responsible_type' => 'user',
-                                               'action' => 'approval',
-                                               'remark' => '',
-                                               'deadline' => ''
-                                       );
-
-                                       $_account_id = 
$purchase_grant['id'];//$this->account
-
-                                       $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() . "::{$price}");
-                                       $purchase_grant_error = false;
-                               }
+                               $purchase_grant_ok = 
CreateObject('property.botts')->validate_purchase_grant( $_ticket['ecodimb'], 
$price, $_ticket['order_id'] );
                        }
-                       if (!$this->debug && $purchase_grant_error)
+                       catch (Exception $ex)
                        {
+                               throw $ex;
+                       }
+
+                       if (!$this->debug && !$purchase_grant_ok)
+                       {
                                return 3;
                        }
        //              _debug_array($_ticket);die();

Modified: 
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
===================================================================
--- 
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php    
    2016-12-09 09:49:11 UTC (rev 16061)
+++ 
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php    
    2016-12-09 09:49:27 UTC (rev 16062)
@@ -31,10 +31,10 @@
         * @package property
         */
        
-       if (!$workorder['order_sent'])
+//     if (!$workorder['order_sent'])
        {
-//             $exporter_ordre = new lag_agresso_ordre_fra_workorder();
-//             $exporter_ordre->transfer($project, $workorder);
+               $exporter_ordre = new lag_agresso_ordre_fra_workorder();
+               $exporter_ordre->transfer($project, $workorder);
        }
 
        class lag_agresso_ordre_fra_workorder
@@ -57,21 +57,17 @@
 
                        $price = 
ExecMethod('property.boworkorder.get_budget_amount',$workorder['id']);
 
-                       $purchase_grant_error = false;
-                       $check_purchase = 
CreateObject('property.botts')->check_purchase_right($data['ecodimb'], $price, 
$workorder['id']);
-                       foreach ($check_purchase as $purchase_grant)
+                       try
                        {
-                               if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
-                               {
-                                       $purchase_grant_error = true;
-                                       
phpgwapi_cache::message_set(lang('approval from %1 is required',
-                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
-                                                       'error'
-                                       );
-                               }
+                               $purchase_grant_ok = 
CreateObject('property.botts')->validate_purchase_grant( $workorder['ecodimb'], 
$price, $workorder['id']);
                        }
-                       if (!$this->debug && $purchase_grant_error)
+                       catch (Exception $ex)
                        {
+                               throw $ex;
+                       }
+
+                       if (!$this->debug && !$purchase_grant_ok)
+                       {
                                return 3;
                        }
 

Modified: trunk/property/js/portico/project.edit.js
===================================================================
--- trunk/property/js/portico/project.edit.js   2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/js/portico/project.edit.js   2016-12-09 09:49:27 UTC (rev 
16062)
@@ -295,6 +295,9 @@
 
 function set_tab(active_tab)
 {
+//     var test = $('#tab-content').responsiveTabs('activate');
+//     alert(test);
+//console.log(test);
        $("#active_tab").val(active_tab);
        check_button_names();
 }

Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js       2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/js/portico/tts.view.js       2016-12-09 09:49:27 UTC (rev 
16062)
@@ -447,7 +447,14 @@
                                        }
                                        htmlString += left_cell;
                                        htmlString += "</td><td 
valign=\"top\">";
-                                       htmlString += obj[i].address;
+                                       if (obj[i].required === true || 
obj[i].default === true)
+                                       {
+                                               htmlString += '<b>[' + 
obj[i].address + ']</b>';
+                                       }
+                                       else
+                                       {
+                                               htmlString += obj[i].address;
+                                       }
                                        htmlString += "</td>";
                                        htmlString += "<td>";
 
@@ -467,9 +474,12 @@
                                        htmlString += "</tr>";
                                });
                                htmlString += "</tbody></table>";
-//console.log(htmlString);
                                $("#approval_container").html(htmlString);
                        }
+               },
+               error: function ()
+               {
+                       alert('feil med oppslag til fullmakter');
                }
        });
 }

Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2016-12-09 09:49:11 UTC (rev 
16061)
+++ trunk/property/js/portico/workorder.edit.js 2016-12-09 09:49:27 UTC (rev 
16062)
@@ -575,17 +575,10 @@
                                        {
                                                if (obj[i].approved !== true)
                                                {
-                                                       if (obj[i].required === 
true || obj[i].default === true)
+                                                       if (obj[i].required === 
true)
                                                        {
                                                                left_cell = 
"<input type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\"" 
+ obj[i].address + "\"></input>";
-                                                               if 
(obj[i].required === true)
-                                                               {
-                                                                       
required = 'checked="checked" disabled="disabled"';
-                                                               }
-                                                               else
-                                                               {
-                                                                       //      
                required = 'checked="checked"';
-                                                               }
+                                                               required = 
'checked="checked" disabled="disabled"';
                                                        }
                                                        else
                                                        {




reply via email to

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