fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16000] more on integration


From: sigurdne
Subject: [Fmsystem-commits] [16000] more on integration
Date: Tue, 15 Nov 2016 14:40:54 +0000 (UTC)

Revision: 16000
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16000
Author:   sigurdne
Date:     2016-11-15 14:40:54 +0000 (Tue, 15 Nov 2016)
Log Message:
-----------
more on integration

Modified Paths:
--------------
    trunk/property/inc/class.botts.inc.php
    trunk/property/inc/class.boworkorder.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/js/portico/tts.view.js
    trunk/property/js/portico/workorder.edit.js
    trunk/property/templates/base/tts.xsl
    trunk/property/templates/base/workorder.xsl

Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php      2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/inc/class.botts.inc.php      2016-11-15 14:40:54 UTC (rev 
16000)
@@ -1786,6 +1786,57 @@
                                return array();
                        }
 
+///////////
+                       $supervisors = array();
+                       $invoice = CreateObject('property.soinvoice');
+                       if (isset($this->config->config_data['invoice_acl']) && 
$this->config->config_data['invoice_acl'] == 'dimb')
+                       {
+                               $sodimb_role_users = 
execMethod('property.sodimb_role_user.read', array
+                                       (
+                                       'dimb_id' => $ecodimb,
+                                       'role_id' => 2,
+                                       'query_start' => 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
+                                       'get_netto_list' => true
+                                       )
+                               );
+                               if (isset($sodimb_role_users[$ecodimb][2]) && 
is_array($sodimb_role_users[$ecodimb][2]))
+                               {
+                                       foreach 
($sodimb_role_users[$ecodimb][2] as $supervisor_id => $entry)
+                                       {
+                                               $supervisors[] = $supervisor_id;
+                                       }
+                               }
+
+                               $supervisors[] =  
$invoice->get_default_dimb_role_user(3, $ecodimb);
+                       }
+                       else
+                       {
+                               $supervisor_id = 0;
+
+                               if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
+                               {
+                                       $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
+                               }
+
+
+                               if ($supervisor_id)
+                               {
+                                       $supervisors[] = $supervisor_id;
+
+                                       $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
+
+                                       if (!empty($prefs['approval_from']))
+                                       {
+                                               $supervisors[] = 
$prefs['approval_from'];
+                                       }
+                                       unset($prefs);
+                               }
+                       }
+                       $supervisors = array_reverse($supervisors);
+
+                               
+////////////////
+
                        $config         = CreateObject('admin.soconfig', 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket'));
                        $check_external_register= 
!!$config->config_data['external_register']['check_external_register'];
 
@@ -1843,14 +1894,18 @@
                                        [aktiv] => (bool) true
                                */
 
-                               $supervisor_id = 
$GLOBALS['phpgw']->accounts->name2id($supervisor_lid);
+                               $supervisors[] = 
$GLOBALS['phpgw']->accounts->name2id($supervisor_lid);
                        }
                        else
                        {
-                               $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
+                               
if(!empty($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
+                                       && 
!in_array($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'],$supervisors))
+                               {
+                                       $supervisors[] =  
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
+                               }
                        }
 
-                       return $this->get_supervisor_email($supervisor_id, 
$order_id);
+                       return $this->get_supervisor_email($supervisors, 
$order_id);
                }
 
                public function check_external_register($param)
@@ -1895,7 +1950,7 @@
                        return json_decode($result, true);
                }
 
-               protected function get_supervisor_email($supervisor_id, 
$order_id)
+               protected function get_supervisor_email($supervisors, $order_id)
                {
                        $need_approval = 
isset($this->config->config_data['workorder_approval']) ? 
$this->config->config_data['workorder_approval'] : '';
 
@@ -1916,63 +1971,19 @@
                        }
 
                        $supervisor_email = array();
-                       if ($supervisor_id && $need_approval)
+                       if ($supervisors && $need_approval)
                        {
-                               $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
-                               $pending_action = 
CreateObject('property.sopending_action');
-
-                               $action_params = array(
-                                       'appname' => 'property',
-                                       'location' => $location,
-                                       'id'            => $location_item_id,
-                                       'responsible' => $supervisor_id,
-                                       'responsible_type' => 'user',
-                                       'action' => 'approval',
-                                       'deadline' => '',
-                                       'created_by' => '',
-                                       'allrows' => false,
-                                       'closed' => true
-                               );
-
-                               $approvals = 
$pending_action->get_pending_action($action_params);
-                               if(!$approvals)
+                               foreach ($supervisors as $supervisor_id)
                                {
-                                       $action_params['closed'] = false;
-                               }
+                                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
 
-                               $requests = 
$pending_action->get_pending_action($action_params);
+                                       $pending_action = 
CreateObject('property.sopending_action');
 
-                               $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
-                               if (isset($prefs['email']) && $prefs['email'])
-                               {
-                                       $supervisor_email[] = array(
-                                               'id' => $supervisor_id,
-                                               'address' => $prefs['email'],
-                                               'required'      => true,
-                                               'requested'     => 
!!$requests[0]['action_requested'],
-                                               'requested_time'=> 
$GLOBALS['phpgw']->common->show_date($requests[0]['action_requested'], 
$dateformat),
-                                               'approved'      => 
!!$approvals[0]['action_performed'],
-                                               'approved_time'  => 
$GLOBALS['phpgw']->common->show_date($approvals[0]['action_performed'], 
$dateformat),
-                                               'is_user'       => 
$supervisor_id == $this->account ? true : false
-                                       );
-                               }
-                               else
-                               {
-                                       $supervisor_email[] = array(
-                                               'id' => $supervisor_id,
-                                               'address' => 
$GLOBALS['phpgw']->accounts->id2name($supervisor_id) . '@bergen.kommune.no',
-                                               'required'      => true
-                                       );
-                               }
-
-                               if (isset($prefs['approval_from']) && 
$prefs['approval_from'])
-                               {
                                        $action_params = array(
                                                'appname' => 'property',
                                                'location' => $location,
                                                'id'            => 
$location_item_id,
-                                               'responsible' => 
$prefs['approval_from'],
+                                               'responsible' => $supervisor_id,
                                                'responsible_type' => 'user',
                                                'action' => 'approval',
                                                'deadline' => '',
@@ -1989,29 +2000,33 @@
 
                                        $requests = 
$pending_action->get_pending_action($action_params);
 
-                                       $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
-
-                                       if (isset($prefs2['email']) && 
$prefs2['email'])
+                                       $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
+                                       if (isset($prefs['email']) && 
$prefs['email'])
                                        {
                                                $supervisor_email[] = array(
-                                                       'id' => 
$prefs['approval_from'],
-                                                       'address' => 
$prefs2['email'],
-                                                       'required'      => 
false,
+                                                       'id' => $supervisor_id,
+                                                       'address' => 
$prefs['email'],
+                                                       'required'      => true,
                                                        'requested'     => 
!!$requests[0]['action_requested'],
                                                        'requested_time'=> 
$GLOBALS['phpgw']->common->show_date($requests[0]['action_requested'], 
$dateformat),
                                                        'approved'      => 
!!$approvals[0]['action_performed'],
                                                        'approved_time'  => 
$GLOBALS['phpgw']->common->show_date($approvals[0]['action_performed'], 
$dateformat),
-                                                       'is_user'       => 
$prefs['approval_from'] == $this->account ? true : false
+                                                       'is_user'       => 
$supervisor_id == $this->account ? true : false
                                                );
-                                               $supervisor_email = 
array_reverse($supervisor_email);
                                        }
-                                       unset($prefs2);
+                                       else
+                                       {
+                                               $supervisor_email[] = array(
+                                                       'id' => $supervisor_id,
+                                                       'address' => 
$GLOBALS['phpgw']->accounts->id2name($supervisor_id) . '@bergen.kommune.no',
+                                                       'required'      => true
+                                               );
+                                       }
+                               
+                                       unset($prefs);
                                }
-                               unset($prefs);
                        }
-
                        return $supervisor_email;
                }
 
-
        }
\ No newline at end of file

Modified: trunk/property/inc/class.boworkorder.inc.php
===================================================================
--- trunk/property/inc/class.boworkorder.inc.php        2016-11-14 15:30:52 UTC 
(rev 15999)
+++ trunk/property/inc/class.boworkorder.inc.php        2016-11-15 14:40:54 UTC 
(rev 16000)
@@ -665,7 +665,7 @@
                                                break;
                                        case 'SC': $type = lang('Status 
confirmed');
                                                break;
-                                       case 'AP': $type = lang('Ask for 
approval');
+                                       case 'AP': $type = lang('Request for 
approval');
                                                break;
                                        case 'ON': $type = lang('Owner 
notified');
                                                break;
@@ -1041,4 +1041,22 @@
                                'time'  => 
$GLOBALS['phpgw']->common->show_date(time())
                                );
                }
+
+               function get_budget_amount($id)
+               {
+                       static $_budget_amount = 0;
+                       if(!$_budget_amount)
+                       {
+                               $budgets = $this->get_budget($id);
+                               foreach ($budgets as $budget)
+                               {
+                                       if ($budget['active'] == 1)
+                                       {
+                                               $_budget_amount += 
$budget['budget'];
+                                       }
+                               }
+                       }
+                       return $_budget_amount;
+               }
+
        }
\ No newline at end of file

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/inc/class.uitts.inc.php      2016-11-15 14:40:54 UTC (rev 
16000)
@@ -2850,7 +2850,6 @@
                                'year_list' => array('options' => 
$this->bocommon->select_list($ticket['actual_cost_year'] ? 
$ticket['actual_cost_year'] : date('Y'), $year_list)),
                                'period_list' => array('options' => 
execMethod('property.boinvoice.period_list', date('Ym'))),
                                'need_approval' => $need_approval,
-       //                      'value_approval_mail_address' => 
$supervisor_email,
                                'contact_data' => $contact_data,
                                'lookup_type' => $lookup_type,
                                'simple' => $this->simple,

Modified: trunk/property/inc/class.uiwo_hour.inc.php
===================================================================
--- trunk/property/inc/class.uiwo_hour.inc.php  2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/inc/class.uiwo_hour.inc.php  2016-11-15 14:40:54 UTC (rev 
16000)
@@ -1330,6 +1330,14 @@
                                        }
                                        unset($_ok);
                                }
+                               else
+                               {
+                                       
if(!$this->_validate_purchase_grant($workorder_id, $project['ecodimb'] ? 
$project['ecodimb'] : $workorder['ecodimb']))
+                                       {
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'property.uiwo_hour.view',
+                                                       'workorder_id' => 
$workorder_id, 'from' => phpgw::get_var('from')));
+                                       }
+                               }
 
                                $criteria = array
                                        (
@@ -1864,6 +1872,14 @@
                                }
                                unset($_ok);
                        }
+                       else
+                       {
+                               
if(!$this->_validate_purchase_grant($workorder_id, $project['ecodimb'] ? 
$project['ecodimb'] : $workorder['ecodimb']))
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'property.uiwo_hour.view',
+                                               'workorder_id' => 
$workorder_id, 'from' => phpgw::get_var('from')));
+                               }
+                       }
 
                        $content = 
$this->_get_order_details($common_data['content'], $show_cost);
 
@@ -3394,4 +3410,29 @@
                        }
                        return $formatted_gab_id;
                }
+
+
+               private function _validate_purchase_grant( $id, $ecodimb )
+               {
+                       $_budget_amount = 
$this->boworkorder->get_budget_amount($id);
+
+                       $purchase_grant_ok = false;
+                       $check_purchase = 
createObject('property.botts')->check_purchase_right($ecodimb, $_budget_amount, 
$id);
+                       if($check_purchase)
+                       {
+                               $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',
+                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
+                                                       'error'
+                                       );
+                               }
+                       }
+                       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-11-14 15:30:52 UTC 
(rev 15999)
+++ trunk/property/inc/class.uiworkorder.inc.php        2016-11-15 14:40:54 UTC 
(rev 16000)
@@ -49,6 +49,7 @@
                var $currentapp;
                var $criteria_id;
                var $filter_year;
+               var $account;
                var $public_functions = array
                        (
                        'columns' => true,
@@ -725,20 +726,25 @@
                                        'msg' => lang('Hmm... looks like a 
repost!'));
                        }
 
-                       if (isset($config->config_data['invoice_acl']) && 
$config->config_data['invoice_acl'] == 'dimb')
+                       if (isset($config->config_data['invoice_acl']) && 
$config->config_data['invoice_acl'] == 'dimb' && !empty($values['do_approve']))
                        {
                                if (!$this->acl_manage)
                                {
-                                       $approve_role = 
execMethod('property.boinvoice.check_role', $project['ecodimb'] ? 
$project['ecodimb'] : $values['ecodimb']);
-                                       if (!$approve_role['is_janitor'] && 
!$approve_role['is_supervisor'] && !$approve_role['is_budget_responsible'])
+                                       foreach ($values['do_approve'] as 
$_account_id => $_dummy)
                                        {
-                                               $this->receipt['error'][] = 
array(
-                                                       'msg' => lang('you are 
not approved for this dimb: %1', $project['ecodimb'] ? $project['ecodimb'] : 
$values['ecodimb'] ));
-                                               $error_id = true;
-                                       }
+                                               if($_account_id != 
$this->account)
+                                               {
+                                                       continue;
+                                               }
 
-                                       if (isset($values['approved']) && 
$values['approved'] && (!isset($values['approved_orig']) || 
!$values['approved_orig']))
-                                       {
+                                               $approve_role = 
execMethod('property.boinvoice.check_role', $project['ecodimb'] ? 
$project['ecodimb'] : $values['ecodimb']);
+                                               if 
(!$approve_role['is_janitor'] && !$approve_role['is_supervisor'] && 
!$approve_role['is_budget_responsible'])
+                                               {
+                                                       
$this->receipt['error'][] = array(
+                                                               'msg' => 
lang('you are not approved for this dimb: %1', $project['ecodimb'] ? 
$project['ecodimb'] : $values['ecodimb'] ));
+                                                       $error_id = true;
+                                               }
+                                               
                                                if 
(!$approve_role['is_supervisor'] && !$approve_role['is_budget_responsible'])
                                                {
                                                        
$this->receipt['error'][] = array(
@@ -960,58 +966,87 @@
 
                                $this->_handle_files($values);
 
-                               if ($values['approval'] && 
$values['mail_address'] && $config->config_data['workorder_approval'])
+                               // start approval
+
+                               $_budget_amount = 
$this->bo->get_budget_amount($id);
+
+                               if (isset($values['approval']) && 
$values['approval'] && $config->config_data['workorder_approval'])
                                {
                                        $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
                                        $coordinator_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
 
-                                       $subject = lang('Approval') . ": " . 
$id;
-                                       $message = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array(
-                                                       'menuaction' => 
'property.uiworkorder.edit',
-                                                       'id' => $id), false, 
true) . '">' . lang('Workorder %1 needs approval', $id) . '</a>';
+                                       $subject = lang(Approval) . ": " . $id;
+                                       $message = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uiworkorder.edit',
+                                                       'id' => $id), false, 
true) . '">' . lang('Workorder %1 needs approval', $ticket['order_id']) . 
'</a>';
 
-                                       if 
(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server'])
+                                       if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
                                        {
-                                               if 
(!is_object($GLOBALS['phpgw']->send))
-                                               {
-                                                       $GLOBALS['phpgw']->send 
= CreateObject('phpgwapi.send');
-                                               }
+                                               $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['mail_address'] as $_account_id => $_address)
+                                       if (!is_object($GLOBALS['phpgw']->send))
+                                       {
+                                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                                       }
+
+                                       $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)
+                                       {
+                                               $action_params['responsible'] = 
$_account_id;
+                                               try
                                                {
-                                                       if 
(isset($values['approval'][$_account_id]) && $values['approval'][$_account_id])
+                                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
+                                                       if ($rcpt)
                                                        {
-                                                               
$action_params['responsible'] = $_account_id;
-                                                               $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
-                                                               if ($rcpt)
-                                                               {
-                                                                       
$historylog->add('AP', $id, lang('%1 is notified', $_address));
-                                                                       
$receipt['message'][] = array(
-                                                                               
'msg' => lang('%1 is notified', $_address));
-                                                               }
-
-                                                               
execMethod('property.sopending_action.set_pending_action', $action_params);
+                                                               
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message');
                                                        }
                                                }
+                                               catch (Exception $exc)
+                                               {
+                                                       $receipt['error'][] = 
array('msg' => $exc->getMessage());
+                                               }
+                                               $historylog->add('AP', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
+                                               
execMethod('property.sopending_action.set_pending_action', $action_params);
                                        }
-                                       else
+
+                               }
+
+                               if (!empty($values['do_approve']) && 
is_array($values['do_approve']))
+                               {
+                                       $action_params = array(
+                                               'appname' => 'property',
+                                               'location' => 
'.project.workorder',
+                                               'id' => $id,
+                                               'responsible' => '',
+                                               'responsible_type' => 'user',
+                                               'action' => 'approval',
+                                               'remark' => '',
+                                               'deadline' => ''
+                                       );
+
+                                       foreach ($values['do_approve'] as 
$_account_id => $_dummy)
                                        {
-                                               $this->receipt['error'][] = 
array(
-                                                       'msg' => lang('SMTP 
server is not set! (admin section)'));
+                                               $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}");
                                        }
                                }
+
+                               //end approval
                                $toarray = array();
                                $toarray_sms = array();
 
@@ -1495,86 +1530,6 @@
                                'id' => $id
                        );
 
-                       $supervisor_email = array();
-                       if ($need_approval = 
isset($config->config_data['workorder_approval']) ? 
$config->config_data['workorder_approval'] : '')
-                       {
-                               $invoice = CreateObject('property.soinvoice');
-                               if (isset($config->config_data['invoice_acl']) 
&& $config->config_data['invoice_acl'] == 'dimb')
-                               {
-
-                                       $sodimb_role_users = 
execMethod('property.sodimb_role_user.read', array
-                                               (
-                                               'dimb_id' => $values['ecodimb'],
-                                               'role_id' => 2,
-                                               'query_start' => 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
-                                               'get_netto_list' => true
-                                               )
-                                       );
-                                       if 
(isset($sodimb_role_users[$values['ecodimb']][2]) && 
is_array($sodimb_role_users[$values['ecodimb']][2]))
-                                       {
-                                               foreach 
($sodimb_role_users[$values['ecodimb']][2] as $supervisor_id => $entry)
-                                               {
-                                                       $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
-                                                       $supervisor_email[] = 
array
-                                                               (
-                                                               'id' => 
$supervisor_id,
-                                                               'address' => 
$prefs['email'],
-                                                               'default' => 
$entry['default_user'],
-                                                       );
-                                               }
-                                       }
-
-//                                     $supervisor_id = 
$invoice->get_default_dimb_role_user(2, $values['ecodimb']);
-
-                                       $supervisor2_id = 
$invoice->get_default_dimb_role_user(3, $values['ecodimb']);
-                                       $prefs2 = 
$this->bocommon->create_preferences('property', $supervisor2_id);
-                                       $supervisor_email[] = array
-                                               (
-                                               'id' => $supervisor2_id,
-                                               'address' => $prefs2['email'],
-                                       );
-                                       unset($prefs);
-                                       unset($prefs2);
-                                       unset($invoice);
-                               }
-                               else
-                               {
-                                       $supervisor_id = 0;
-
-                                       if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'])
-                                       {
-                                               $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
-                                       }
-
-
-                                       if ($supervisor_id)
-                                       {
-                                               $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
-                                               $supervisor_email[] = array
-                                                       (
-                                                       'id' => $supervisor_id,
-                                                       'address' => 
$prefs['email'],
-                                               );
-
-                                               if 
(isset($prefs['approval_from']))
-                                               {
-                                                       $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
-
-                                                       if 
(isset($prefs2['email']))
-                                                       {
-                                                               
$supervisor_email[] = array
-                                                                       (
-                                                                       'id' => 
$prefs['approval_from'],
-                                                                       
'address' => $prefs2['email'],
-                                                               );
-                                                               
$supervisor_email = array_reverse($supervisor_email);
-                                                       }
-                                                       unset($prefs2);
-                                               }
-                                               unset($prefs);
-                                       }
-                               }
-                       }
                        $workorder_status = 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['workorder_status'])
 ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['workorder_status'] : 
'');
                        if (!$values['status'])
                        {
@@ -2329,7 +2284,7 @@
                                'lang_budget' => lang('Budget'),
                                'value_budget' => 
isset($this->receipt['error']) && $this->receipt['error'] ? 
$_POST['values']['budget'] : '',
                                'check_for_budget' => abs($budget),
-                               'value_budget' => $budget,
+                               'check_value_budget' => $budget,
                                'lang_budget_statustext' => lang('Enter the 
budget'),
                                'lang_incl_tax' => lang('incl tax'),
                                'lang_calculation' => lang('Calculation'),
@@ -2402,10 +2357,9 @@
                                'value_approved' => isset($values['approved']) 
? $values['approved'] : '',
                                'value_continuous' => 
isset($values['continuous']) ? $values['continuous'] : '',
                                'value_fictive_periodization' => 
isset($values['fictive_periodization']) ? $values['fictive_periodization'] : '',
-                               'need_approval' => $need_approval,
+                               'need_approval' => 
!empty($config->config_data['workorder_approval']),
                                'lang_ask_approval' => lang('Ask for approval'),
                                'lang_ask_approval_statustext' => lang('Check 
this to send a mail to your supervisor for approval'),
-                               'value_approval_mail_address' => 
$supervisor_email,
                                'currency' => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
                                'link_view_file' => 
$GLOBALS['phpgw']->link('/index.php', $link_file_data),
                                'link_to_files' => 
(isset($config->config_data['files_url']) ? $config->config_data['files_url'] : 
''),
@@ -3017,5 +2971,4 @@
 
                        return phpgwapi_jquery::tabview_generate($tabs, 
$active_tab);
                }
-
        }
\ No newline at end of file

Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js       2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/js/portico/tts.view.js       2016-11-15 14:40:54 UTC (rev 
16000)
@@ -378,7 +378,7 @@
                }
        });
 
-       $("#budget").change(function ()
+       $("#field_budget").change(function ()
        {
                populateTableChkApproval();
        });
@@ -394,7 +394,7 @@
                return;
        }
 
-       var total_amount = Number(amount) + Number($('#budget').val());
+       var total_amount = Number(amount) + Number($('#field_budget').val());
        $("#order_received_amount").val(total_amount);
 
        var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount, order_id: order_id};
@@ -409,7 +409,7 @@
                {
                        if (data != null)
                        {
-                               htmlString = "<table><thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
+                               htmlString = "<table class='pure-table 
pure-table-striped'><thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
                                var obj = data;
                                var required = '';
 
@@ -477,16 +477,12 @@
 {
 
        var test = document.getElementById('send_order_button');
-       var width = 200;
-       if (test !== null)
+       if (test == null)
        {
-               width = 280;
-       }
-       else
-       {
                return;
        }
-
+       //var width = 200;
+       var width =  $("#submitbox").width();
        $("#submitbox").css({
                position: 'absolute',
                right: '10px',

Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/js/portico/workorder.edit.js 2016-11-15 14:40:54 UTC (rev 
16000)
@@ -1,4 +1,4 @@
-
+var amount = 0;
 var vendor_id;
 
 function calculate_order()
@@ -396,23 +396,13 @@
 //             parent.hide_popupBox();
        });
 
-
        var test = document.getElementById('save_button');
-       var width = 200;
-       if (test !== null)
+       if (test === null)
        {
-               width = 160;
-       }
-       else
-       {
                return;
        }
 
-       test = document.getElementById('calculate_button');
-       if (test !== null)
-       {
-               width = 380;
-       }
+       var width =  $("#submitbox").width();
 
        $("#submitbox").css({
                position: 'absolute',
@@ -487,7 +477,7 @@
                }
        });
 
-       $("#budget").change(function ()
+       $("#field_budget").change(function ()
        {
                populateTableChkApproval();
        });
@@ -503,7 +493,7 @@
                return;
        }
 
-       var total_amount = Number(value_budget) + 
Number($('#field_budget').val());
+       var total_amount = Number(amount) + Number($('#field_budget').val());
        $("#order_received_amount").val(total_amount);
 
        var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount, order_id: order_id};
@@ -518,7 +508,9 @@
                {
                        if (data != null)
                        {
-                               htmlString = "<table><thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
+                               htmlString = "<table class='pure-table 
pure-table-striped'>";
+                               htmlString += "<thead><th>" + 
$.number(total_amount, 0, ',', '.') + "</th><th></th><th></th></thead>";
+                               htmlString += "<thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
                                var obj = data;
                                var required = '';
 
@@ -576,7 +568,6 @@
                                        htmlString += "</tr>";
                                });
                                htmlString += "</tbody></table>";
-//console.log(htmlString);
                                $("#approval_container").html(htmlString);
                        }
                }

Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl       2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/templates/base/tts.xsl       2016-11-15 14:40:54 UTC (rev 
16000)
@@ -963,7 +963,7 @@
                                                                                
<label>
                                                                                
        <xsl:value-of select="php:function('lang', 'cost estimate')"/>
                                                                                
</label>
-                                                                               
<input id="budget" type="text" name="values[budget]">
+                                                                               
<input id="field_budget" type="text" name="values[budget]">
                                                                                
        <xsl:attribute name="title">
                                                                                
                <xsl:value-of select="php:function('lang', 'Enter the 
budget')"/>
                                                                                
        </xsl:attribute>
@@ -1061,7 +1061,7 @@
                                                                                
                <label>
                                                                                
                        <xsl:value-of select="php:function('lang', 
'approval')"/>
                                                                                
                </label>
-                                                                               
                <div id="approval_container" class="pure-table pure-u-md-1-2">
+                                                                               
                <div id="approval_container" class="pure-u-md-1-2">
                                                                                
                </div>
                                                                                
        </div>
                                                                                
</xsl:when>

Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2016-11-14 15:30:52 UTC (rev 
15999)
+++ trunk/property/templates/base/workorder.xsl 2016-11-15 14:40:54 UTC (rev 
16000)
@@ -173,7 +173,7 @@
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
                        <div id="floating-box">
                                <div id="submitbox">
-                                       <table width="200px">
+                                       <table>
                                                <tbody>
                                                        <tr>
                                                                <xsl:choose>
@@ -419,40 +419,17 @@
                                                <xsl:call-template 
name="status_select"/>
                                        </div>
                                        <xsl:choose>
-                                               <xsl:when 
test="need_approval='1' and mode='edit'">
+                                               <xsl:when 
test="need_approval='1'">
                                                        <div 
class="pure-control-group">
-                                                               <label 
for="name">
-                                                                       
<xsl:value-of select="lang_ask_approval"/>
+                                                               <label>
+                                                                       
<xsl:value-of select="php:function('lang', 'approval')"/>
                                                                </label>
-                                                               <div 
class="pure-custom">
-                                                                       <table>
-                                                                               
<xsl:for-each select="value_approval_mail_address">
-                                                                               
        <tr>
-                                                                               
                <td>
-                                                                               
                        <input type="checkbox" name="values[approval][{id}]" 
value="True">
-                                                                               
                                <xsl:attribute name="title">
-                                                                               
                                        <xsl:value-of 
select="//lang_ask_approval_statustext"/>
-                                                                               
                                </xsl:attribute>
-                                                                               
                        </input>
-                                                                               
                </td>
-                                                                               
                <td>
-                                                                               
                        <input type="text" name="values[mail_address][{id}]" 
value="{address}">
-                                                                               
                                <xsl:attribute name="title">
-                                                                               
                                        <xsl:value-of 
select="//lang_ask_approval_statustext"/>
-                                                                               
                                </xsl:attribute>
-                                                                               
                        </input>
-                                                                               
                        <xsl:if test="default = '1'">
-                                                                               
                                <xsl:text>&lt;=</xsl:text>
-                                                                               
                        </xsl:if>
-                                                                               
                </td>
-                                                                               
        </tr>
-                                                                               
</xsl:for-each>
-                                                                       </table>
+                                                               <div 
id="approval_container" class="pure-u-md-1-2">
                                                                </div>
                                                        </div>
                                                </xsl:when>
                                        </xsl:choose>
-                                       <xsl:choose>
+                                       <!--xsl:choose>
                                                <xsl:when 
test="value_workorder_id!=''">
                                                        <div 
class="pure-control-group">
                                                                <label 
for="name">
@@ -476,7 +453,7 @@
                                                                </input>
                                                        </div>
                                                </xsl:when>
-                                       </xsl:choose>
+                                       </xsl:choose-->
                                        <div class="pure-control-group">
                                                <label for="name">
                                                        <xsl:value-of 
select="lang_remark"/>
@@ -985,17 +962,6 @@
                                                        </xsl:for-each>
                                                </div>
                                        </div>
-                                       <xsl:choose>
-                                               <xsl:when 
test="need_approval='1'">
-                                                       <div 
class="pure-control-group">
-                                                               <label>
-                                                                       
<xsl:value-of select="php:function('lang', 'approval')"/>
-                                                               </label>
-                                                               <div 
id="approval_container" class="pure-table pure-u-md-1-2">
-                                                               </div>
-                                                       </div>
-                                               </xsl:when>
-                                       </xsl:choose>
                                        <div class="pure-control-group">
                                                <label for="name">
                                                        <xsl:choose>
@@ -1270,7 +1236,7 @@
                        <script type="text/javascript">
                                var lang = <xsl:value-of 
select="php:function('js_lang', 'please enter either a budget or contrakt 
sum')"/>;
                                var check_for_budget = <xsl:value-of 
select="check_for_budget"/>;
-                               var value_budget = <xsl:value-of 
select="value_budget"/>;
+                               var amount = <xsl:value-of 
select="check_value_budget"/>;
                                var base_java_url = <xsl:value-of 
select="base_java_url"/>;
                                var location_item_id = '<xsl:value-of 
select="location_item_id"/>';
                                var order_id = '<xsl:value-of 
select="value_workorder_id"/>';




reply via email to

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