fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15889] Syncromind: merge 15841:15888 from trunk


From: sigurdne
Subject: [Fmsystem-commits] [15889] Syncromind: merge 15841:15888 from trunk
Date: Mon, 24 Oct 2016 13:34:35 +0000 (UTC)

Revision: 15889
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15889
Author:   sigurdne
Date:     2016-10-24 13:34:35 +0000 (Mon, 24 Oct 2016)
Log Message:
-----------
Syncromind: merge 15841:15888 from trunk

Modified Paths:
--------------
    branches/dev-syncromind-2/eventplanner/inc/class.uiapplication.inc.php
    branches/dev-syncromind-2/eventplanner/inc/class.uicommon.inc.php
    branches/dev-syncromind-2/eventplanner/js/portico/application.edit.js
    branches/dev-syncromind-2/eventplanner/setup/tables_current.inc.php
    branches/dev-syncromind-2/eventplanner/templates/base/application.xsl
    branches/dev-syncromind-2/helpdesk/inc/class.menu.inc.php
    branches/dev-syncromind-2/helpdesk/templates/base/config.tpl
    branches/dev-syncromind-2/phpgwapi/inc/class.sessions.inc.php
    branches/dev-syncromind-2/phpgwapi/setup/phpgw_no.lang
    branches/dev-syncromind-2/property/inc/class.bocommon.inc.php
    branches/dev-syncromind-2/property/inc/class.bolookup.inc.php
    branches/dev-syncromind-2/property/inc/class.botts.inc.php
    branches/dev-syncromind-2/property/inc/class.socommon.inc.php
    branches/dev-syncromind-2/property/inc/class.sogeneric.inc.php
    branches/dev-syncromind-2/property/inc/class.sopending_action.inc.php
    branches/dev-syncromind-2/property/inc/class.sotts.inc.php
    branches/dev-syncromind-2/property/inc/class.uilookup.inc.php
    branches/dev-syncromind-2/property/inc/class.uitts.inc.php
    
branches/dev-syncromind-2/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
    
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
    
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
    
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
    branches/dev-syncromind-2/property/inc/soap_client/bra5/soap.php
    branches/dev-syncromind-2/property/js/portico/tts.view.js
    branches/dev-syncromind-2/property/setup/phpgw_no.lang
    branches/dev-syncromind-2/property/setup/setup.inc.php
    branches/dev-syncromind-2/property/setup/tables_current.inc.php
    branches/dev-syncromind-2/property/setup/tables_update.inc.php
    branches/dev-syncromind-2/property/templates/base/tts.xsl

Added Paths:
-----------
    branches/dev-syncromind-2/eventplanner/inc/class.bobooking.inc.php
    branches/dev-syncromind-2/eventplanner/inc/class.sobooking.inc.php
    branches/dev-syncromind-2/eventplanner/inc/class.uibooking.inc.php
    branches/dev-syncromind-2/eventplanner/inc/model/class.booking.inc.php
    branches/dev-syncromind-2/eventplanner/js/portico/booking.index.js
    branches/dev-syncromind-2/eventplanner/templates/base/booking.xsl

Property Changed:
----------------
    branches/dev-syncromind-2/


Property changes on: branches/dev-syncromind-2
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935,15165-15215,15218-15220,15222-15304,15306-15337,15339,15341-15398,15400-15421,15423-15474,15476-15607,15609,15611,15613-15652,15654-15732,15734,15736-15746,15750-15770,15772-15775,15777-15795,15797-15798,15800-15812,15814-15838,15840
   + /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935,15165-15215,15218-15220,15222-15304,15306-15337,15339,15341-15398,15400-15421,15423-15474,15476-15607,15609,15611,15613-15652,15654-15732,15734,15736-15746,15750-15770,15772-15775,15777-15795,15797-15798,15800-15812,15814-15838,15840,15842-15888

Copied: branches/dev-syncromind-2/eventplanner/inc/class.bobooking.inc.php 
(from rev 15888, trunk/eventplanner/inc/class.bobooking.inc.php)
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/class.bobooking.inc.php          
                (rev 0)
+++ branches/dev-syncromind-2/eventplanner/inc/class.bobooking.inc.php  
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,104 @@
+<?php
+       /**
+        * phpGroupWare
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License v2 or later
+        * @internal
+        * @package eventplanner
+        * @subpackage booking
+        * @version $Id:$
+        */
+
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 2 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('eventplanner.sobooking');
+
+       include_class('eventplanner', 'booking', 'inc/model/');
+
+       class eventplanner_bobooking extends eventplanner_bocommon
+       {
+               protected static
+                       $bo,
+                       $fields,
+                       $acl_location;
+
+               public function __construct()
+               {
+                       $this->fields = eventplanner_booking::get_fields();
+                       $this->acl_location = 
eventplanner_booking::acl_location;
+               }
+
+               /**
+                * Implementing classes must return an instance of itself.
+                *
+                * @return the class instance.
+                */
+               public static function get_instance()
+               {
+                       if (self::$bo == null)
+                       {
+                               self::$bo = new eventplanner_bobooking();
+                       }
+                       return self::$bo;
+               }
+
+               public function store($object)
+               {
+                       $this->store_pre_commit($object);
+                       $ret = 
eventplanner_sobooking::get_instance()->store($object);
+                       $this->store_post_commit($object);
+                       return $ret;
+               }
+
+               public function read($params)
+               {
+                       if(empty($params['filters']['active']))
+                       {
+                               $params['filters']['active'] = 1;
+                       }
+                       else
+                       {
+                               unset($params['filters']['active']);
+                       }
+                       $values =  
eventplanner_sobooking::get_instance()->read($params);
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+                       foreach ($values['results'] as &$entry)
+                       {
+                               $entry['created'] = 
$GLOBALS['phpgw']->common->show_date($entry['created']);
+                               $entry['modified'] = 
$GLOBALS['phpgw']->common->show_date($entry['modified']);
+                               $entry['from_'] = 
$GLOBALS['phpgw']->common->show_date($entry['from_']);
+                               $entry['to_'] = 
$GLOBALS['phpgw']->common->show_date($entry['to_']);
+                       }
+                       return $values;
+               }
+
+               public function read_single($id, $return_object = true)
+               {
+                       if ($id)
+                       {
+                               $values = 
eventplanner_sobooking::get_instance()->read_single($id, $return_object);
+                       }
+                       else
+                       {
+                               $values = new eventplanner_booking();
+                       }
+
+                       return $values;
+               }
+       }
\ No newline at end of file

Copied: branches/dev-syncromind-2/eventplanner/inc/class.sobooking.inc.php 
(from rev 15888, trunk/eventplanner/inc/class.sobooking.inc.php)
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/class.sobooking.inc.php          
                (rev 0)
+++ branches/dev-syncromind-2/eventplanner/inc/class.sobooking.inc.php  
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,116 @@
+<?php
+       /**
+        * phpGroupWare - property: a part of a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package eventplanner
+        * @subpackage booking
+        * @version $Id: $
+        */
+       phpgw::import_class('phpgwapi.socommon');
+
+       class eventplanner_sobooking extends phpgwapi_socommon
+       {
+
+               protected static $so;
+
+               public function __construct()
+               {
+                       parent::__construct('eventplanner_booking', 
eventplanner_booking::get_fields());
+               }
+
+               /**
+                * Implementing classes must return an instance of itself.
+                *
+                * @return the class instance.
+                */
+               public static function get_instance()
+               {
+                       if (self::$so == null)
+                       {
+                               self::$so = 
CreateObject('eventplanner.sobooking');
+                       }
+                       return self::$so;
+               }
+
+
+               protected function populate( array $data )
+               {
+                       $object = new eventplanner_booking();
+                       foreach ($this->fields as $field => $field_info)
+                       {
+                               $object->set_field($field, $data[$field]);
+                       }
+
+                       return $object;
+               }
+
+               protected function update( $object )
+               {
+                       $this->db->transaction_begin();
+       //              $status_text = eventplanner_booking::get_status_list();
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+                       $lang_active = lang('active');
+                       $lang_inactive = lang('inactive');
+
+                       $original = 
$this->read_single($object->get_id());//returned as array()
+                       foreach ($this->fields as $field => $params)
+                       {
+                               $new_value = $object->$field;
+                               $old_value = $original[$field];
+                               if (!empty($params['history']) && ($new_value 
!= $old_value))
+                               {
+                                       $label = !empty($params['label']) ? 
lang($params['label']) : $field;
+                                       switch ($field)
+                                       {
+                                               case 'status':
+                                                       $old_value = 
$status_text[$old_value];
+                                                       $new_value = 
$status_text[$new_value];
+                                                       break;
+                                               case 'active':
+                                                       $old_value = $old_value 
? $lang_active : $lang_inactive;
+                                                       $new_value = $new_value 
? $lang_active : $lang_inactive;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       $value_set = array
+                                       (
+                                               'booking_id'    => 
$object->get_id(),
+                                               'time'          => time(),
+                                               'author'        => 
$GLOBALS['phpgw_info']['user']['fullname'],
+                                               'comment'       => $label . ':: 
' . lang('old value') . ': ' . $this->db->db_addslashes($old_value) . ', ' 
.lang('new value') . ': ' . $this->db->db_addslashes($new_value),
+                                               'type'  => 'history',
+                                       );
+
+                                       $this->db->query( 'INSERT INTO 
eventplanner_booking_comment (' .  implode( ',', array_keys( $value_set ) )   . 
') VALUES ('
+                                       . $this->db->validate_insert( 
array_values( $value_set ) ) . ')',__LINE__,__FILE__);
+                               }
+
+                       }
+
+                       parent::update($object);
+
+                       return  $this->db->transaction_commit();
+               }
+
+       }
\ No newline at end of file

Modified: branches/dev-syncromind-2/eventplanner/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/class.uiapplication.inc.php      
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/eventplanner/inc/class.uiapplication.inc.php      
2016-10-24 13:34:35 UTC (rev 15889)
@@ -234,6 +234,11 @@
                                'link' => '#demands',
                                'function' => "set_tab('demands')"
                        );
+                       $tabs['calendar'] = array(
+                               'label' => lang('calendar'),
+                               'link' => '#calendar',
+                               'function' => "set_tab('calendar')"
+                       );
 
                        $bocommon = CreateObject('property.bocommon');
 
@@ -263,7 +268,7 @@
                                array('key' => 'author', 'label' => 
lang('User'), 'sortable' => true, 'resizeable' => true),
                                array('key' => 'comment', 'label' => 
lang('Note'), 'sortable' => true, 'resizeable' => true)
                        );
- 
+
                        $datatable_def[] = array(
                                'container' => 'datatable-container_0',
                                'requestUrl' => "''",
@@ -275,6 +280,69 @@
                                )
                        );
 
+                       $dates_def = array(
+                               array('key' => 'id',  'hidden' => true),
+                               array('key' => 'from_', 'label' => 
lang('From'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'to_', 'label' => lang('To'), 
'sortable' => false, 'resizeable' => true),
+                               array('key' => 'active', 'label' => 
lang('active'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'where', 'label' => 
lang('where'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'customer_name', 'label' => 
lang('who'), 'sortable' => true, 'resizeable' => true),
+                               array('key' => 'comment', 'label' => 
lang('Note'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'application_id', 'hidden' => 
true),
+                       );
+
+                       $tabletools = array(
+                               array(
+                                       'my_name' => 'add',
+                                       'text' => lang('add'),
+                                       'type' => 'custom',
+                                       'className' => 'add',
+                                       'custom_code' => "
+                                                               add_booking();"
+                               ),
+                               array('my_name' => 'select_all'),
+                               array('my_name' => 'select_none'),
+                               array(
+                                       'my_name' => 'enable',
+                                       'text' => lang('enable'),
+                                       'type' => 'custom',
+                                       'custom_code' => "
+                                                               
onActionsClick('enable');"
+                               ),
+                               array(
+                                       'my_name' => 'disable',
+                                       'text' => lang('disable'),
+                                       'type' => 'custom',
+                                       'custom_code' => "
+                                                               
onActionsClick('disable');"
+                               ),
+                               array(
+                                       'my_name' => 'edit',
+                                       'text' => lang('edit'),
+                                       'type' => 'custom',
+                                       'custom_code' => "
+                                                               
onActionsClick('edit');"
+                               )
+                       );
+
+                       $datatable_def[] = array(
+                               'container' => 'datatable-container_1',
+                               'requestUrl' => 
json_encode(self::link(array('menuaction' => 'eventplanner.uibooking.query',
+                                       'filter_application_id' => $id,
+                                       'filter_active' => 1,
+                                       'phpgw_return_as' => 'json'))),
+//                             'requestUrl' => "''",
+                               'tabletools' => $tabletools,
+                               'ColumnDefs' => $dates_def,
+                               'data' => json_encode(array()),
+                               'config' => array(
+                                       array('disableFilter' => true),
+                                       array('disablePagination' => true)
+                               )
+                       );
+                       $GLOBALS['phpgw']->jqcal->add_listener('from_', 
'datetime');
+                       $GLOBALS['phpgw']->jqcal->add_listener('to_', 
'datetime');
+
                        $application_type_list = 
execMethod('eventplanner.bogeneric.get_list', array('type' => 
'application_type'));
                        $types = (array)$application->types;
                        if($types)

Copied: branches/dev-syncromind-2/eventplanner/inc/class.uibooking.inc.php 
(from rev 15888, trunk/eventplanner/inc/class.uibooking.inc.php)
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/class.uibooking.inc.php          
                (rev 0)
+++ branches/dev-syncromind-2/eventplanner/inc/class.uibooking.inc.php  
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,230 @@
+<?php
+/**
+        * phpGroupWare - eventplanner: a part of a Facilities Management 
System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this booking was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package eventplanner
+        * @subpackage booking
+        * @version $Id: $
+        */
+       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.datetime');
+
+       include_class('eventplanner', 'booking', 'inc/model/');
+
+       class eventplanner_uibooking extends eventplanner_uicommon
+       {
+
+               public $public_functions = array(
+                       'add' => true,
+                       'index' => true,
+                       'query' => true,
+                       'view' => true,
+                       'edit' => true,
+                       'save' => true,
+                       'save_ajax'     => true
+               );
+
+               protected
+                       $fields,
+                       $permissions;
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       self::set_active_menu('eventplanner::booking');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('booking');
+                       $this->bo = createObject('eventplanner.bobooking');
+                       $this->fields = eventplanner_booking::get_fields();
+                       $this->permissions = 
eventplanner_booking::get_instance()->get_permission_array();
+               }
+
+
+               public function index()
+               {
+                       if (empty($this->permissions[PHPGW_ACL_READ]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       if (phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
+
+                       phpgwapi_jquery::load_widget('autocomplete');
+
+                       $function_msg = lang('booking');
+
+                       $data = array(
+                               'datatable_name' => $function_msg,
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                                       array(
+                                                               'type' => 
'autocomplete',
+                                                               'name' => 
'application',
+                                                               'app' => 
'eventplanner',
+                                                               'ui' => 
'application',
+                                                               'label_attr' => 
'title',
+                                                               'text' => 
lang('application') . ':',
+                                                               
'requestGenerator' => 'requestWithApplicationFilter'
+                                                       ),
+                                                       array(
+                                                               'type' => 
'checkbox',
+                                                               'name' => 
'filter_active',
+                                                               'text' => 
lang('showall'),
+                                                               'value' =>  1,
+                                                               'checked'=> 1,
+                                                       )
+                                               )
+                                       )
+                               ),
+                               'datatable' => array(
+                                       'source' => self::link(array(
+                                               'menuaction' => 
'eventplanner.uibooking.index',
+                                               'phpgw_return_as' => 'json'
+                                       )),
+                                       'allrows' => true,
+                                       'new_item' => 
self::link(array('menuaction' => 'eventplanner.uibooking.add')),
+                                       'editor_action' => '',
+                                       'field' => parent::_get_fields()
+                               )
+                       );
+
+                       $parameters = array(
+                               'parameter' => array(
+                                       array(
+                                               'name' => 'id',
+                                               'source' => 'id'
+                                       )
+                               )
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'view',
+                               'text' => lang('show'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'eventplanner.uibooking.view'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'edit',
+                               'text' => lang('edit'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'eventplanner.uibooking.edit'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       self::add_javascript('eventplanner', 'portico', 
'booking.index.js');
+                       phpgwapi_jquery::load_widget('numberformat');
+
+                       self::render_template_xsl('datatable_jquery', $data);
+               }
+
+               /*
+                * Edit the price item with the id given in the http variable 
'id'
+                */
+
+               public function edit( $values = array(), $mode = 'edit' )
+               {
+                       $active_tab = !empty($values['active_tab']) ? 
$values['active_tab'] : phpgw::get_var('active_tab', 'string', 'REQUEST', 
'first_tab');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('edit');
+                       if (empty($this->permissions[PHPGW_ACL_ADD]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       if (!empty($values['object']))
+                       {
+                               $booking = $values['object'];
+                       }
+                       else
+                       {
+                               $id = !empty($values['id']) ? $values['id'] : 
phpgw::get_var('id', 'int');
+                               $booking = $this->bo->read_single($id);
+                       }
+
+                       $tabs = array();
+                       $tabs['first_tab'] = array(
+                               'label' => lang('booking'),
+                               'link' => '#first_tab',
+                               'function' => "set_tab('first_tab')"
+                       );
+
+                       $bocommon = CreateObject('property.bocommon');
+
+                       $comments = (array)$booking->comments;
+                       foreach ($comments as $key => &$comment)
+                       {
+                               $comment['value_count'] = $key +1;
+                               $comment['value_date'] = 
$GLOBALS['phpgw']->common->show_date($comment['time']);
+                       }
+
+                       $comments_def = array(
+                               array('key' => 'from_', 'label' => 
lang('From'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'to_', 'label' => lang('To'), 
'sortable' => false, 'resizeable' => true),
+                               array('key' => 'author', 'label' => 
lang('User'), 'sortable' => false, 'resizeable' => true),
+                               array('key' => 'comment', 'label' => 
lang('Note'), 'sortable' => false, 'resizeable' => true)
+                       );
+ 
+                       $datatable_def[] = array(
+                               'container' => 'datatable-container_0',
+                               'requestUrl' => "''",
+                               'ColumnDefs' => $comments_def,
+                               'data' => json_encode($comments),
+                               'config' => array(
+                                       array('disableFilter' => true),
+                                       array('disablePagination' => true)
+                               )
+                       );
+
+                       $data = array(
+                               'datatable_def' => $datatable_def,
+                               'form_action' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uibooking.save')),
+                               'cancel_url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uibooking.index',)),
+                               'booking' => $booking,
+                               'mode' => $mode,
+                               'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+                               'value_active_tab' => $active_tab
+                       );
+                       phpgwapi_jquery::formvalidator_generate(array());
+                       self::add_javascript('eventplanner', 'portico', 
'booking.edit.js');
+                       self::render_template_xsl(array('booking', 
'datatable_inline'), array($mode => $data));
+               }
+               
+               public function save()
+               {
+                       parent::save();
+               }
+               public function save_ajax()
+               {
+                       return parent::save(true);
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind-2/eventplanner/inc/class.uicommon.inc.php
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/class.uicommon.inc.php   
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/eventplanner/inc/class.uicommon.inc.php   
2016-10-24 13:34:35 UTC (rev 15889)
@@ -112,7 +112,7 @@
                        $this->edit();
                }
 
-               public function save()
+               public function save($ajax = false)
                {
                        $called_class = get_called_class();
 
@@ -135,23 +135,59 @@
                        {
                                if($object->store($object))
                                {
-                                       
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
-                                       self::redirect(array(
-                                               'menuaction' => 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit",
-                                               'id'            => 
$object->get_id(),
-                                               'active_tab' => $active_tab
-                                               )
-                                       );
+                                       if($ajax)
+                                       {
+                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                               return array(
+                                                       'status_kode' => 'ok',
+                                                       'status' => lang('ok'),
+                                                       'msg' => 
lang('messages_saved_form')
+                                               );
+                                       }
+                                       else
+                                       {
+                                               
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
+                                               self::redirect(array(
+                                                       'menuaction' => 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit",
+                                                       'id'            => 
$object->get_id(),
+                                                       'active_tab' => 
$active_tab
+                                                       )
+                                               );
+                                       }
                                }
                                else
                                {
-                                       
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
-                                       $this->edit(array('object'      => 
$object, 'active_tab' => $active_tab));
+                                       if($ajax)
+                                       {
+                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                               return array(
+                                                       'status_kode' => 
'error',
+                                                       'status' => 
lang('error'),
+                                                       'msg' => 
lang('messages_form_error')
+                                               );
+                                       }
+                                       else
+                                       {
+                                               
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
+                                               $this->edit(array('object'      
=> $object, 'active_tab' => $active_tab));
+                                       }
                                }
                        }
                        else
                        {
-                               $this->edit(array('object'      => $object, 
'active_tab' => $active_tab));
+                               if($ajax)
+                               {
+                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                       return array(
+                                               'status_kode' => 'error',
+                                               'status' => lang('error'),
+                                               'msg' => lang('Did not 
validate')
+                                       );
+                               }
+                               else
+                               {
+                                       $this->edit(array('object'      => 
$object, 'active_tab' => $active_tab));
+                               }
                        }
                }
 

Copied: branches/dev-syncromind-2/eventplanner/inc/model/class.booking.inc.php 
(from rev 15888, trunk/eventplanner/inc/model/class.booking.inc.php)
===================================================================
--- branches/dev-syncromind-2/eventplanner/inc/model/class.booking.inc.php      
                        (rev 0)
+++ branches/dev-syncromind-2/eventplanner/inc/model/class.booking.inc.php      
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,224 @@
+<?php
+       /**
+        * phpGroupWare - eventplanner: a part of a Facilities Management 
System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package eventplanner
+        * @subpackage booking
+        * @version $Id: $
+        */
+
+       phpgw::import_class('eventplanner.bobooking');
+
+       include_class('phpgwapi', 'model', 'inc/model/');
+
+       class eventplanner_booking extends phpgwapi_model
+       {
+
+               const STATUS_REGISTERED = 1;
+               const STATUS_PENDING = 2;
+               const STATUS_REJECTED = 3;
+               const STATUS_APPROVED = 4;
+               const acl_location = '.booking';
+
+               protected
+                       $id,
+                       $active,
+                       $completed,
+                       $cost,
+                       $from_,
+                       $to_,
+                       $application_id,
+                       $application_name,
+                       $customer_id,
+                       $customer_name,
+                       $created,
+                       $secret;
+
+               protected $field_of_responsibility_name = '.booking';
+
+               public function __construct( int $id = null )
+               {
+                       parent::__construct((int)$id);
+                       $this->field_of_responsibility_name = 
self::acl_location;
+               }
+
+               /**
+                * Implementing classes must return an instance of itself.
+                *
+                * @return the class instance.
+                */
+               public static function get_instance()
+               {
+                       return new eventplanner_booking();
+               }
+
+               public static function get_status_list()
+               {
+                       return array(
+                               self::STATUS_REGISTERED => lang('registered'),
+                               self::STATUS_PENDING    => lang('pending'),
+                               self::STATUS_REJECTED => lang('rejected'),
+                               self::STATUS_APPROVED   => lang('approved')
+                       );
+               }
+
+               public static function get_fields($debug = true)
+               {
+                        $fields = array(
+                               'id' => array('action'=> PHPGW_ACL_READ,
+                                       'type' => 'int',
+                                       'label' => 'id',
+                                       'sortable'=> true,
+                                       'formatter' => 
'JqueryPortico.formatLink',
+                                       ),
+                               'active' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'int',
+                                       'history'       => true
+                                       ),
+                               'completed' => array('action'=>  PHPGW_ACL_EDIT,
+                                       'type' => 'int',
+                                       'history'       => true
+                                       ),
+                               'cost' => array('action'=>  PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'decimal'
+                                       ),
+                               'from_' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'date',
+                                       'label' => 'from',
+                                       'history' => true,
+                                       'required' => true,
+                                       ),
+                               'to_' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'date',
+                                       'label' => 'to',
+                                       'history' => true,
+                                       'required' => true,
+                               ),
+                               'application_id' => array('action'=> 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'int',
+                                       'label' => 'application',
+                                       'sortable' => true,
+                                       'required' => true,
+                                       ),
+                               'application_name' => array('action'=>  
PHPGW_ACL_READ,
+                                       'type' => 'string',
+                                       'query' => true,
+                                       'label' => 'application',
+                                       'join' => array(
+                                               'table' => 
'eventplanner_application',
+                                               'fkey' => 'application_id',
+                                               'key' => 'id',
+                                               'column' => 'title'
+                                               )
+                                       ),
+                               'customer_id' => array('action'=> PHPGW_ACL_ADD 
| PHPGW_ACL_EDIT,
+                                       'type' => 'int',
+                                       'label' => 'customer',
+                                       'sortable' => true,
+                                       'history' => true,
+                                       ),
+                               'customer_name' => array('action'=>  
PHPGW_ACL_READ,
+                                       'type' => 'string',
+                                       'query' => true,
+                                       'label' => 'customer',
+                                       'join' => array(
+                                               'table' => 
'eventplanner_customer',
+                                               'fkey' => 'customer_id',
+                                               'key' => 'id',
+                                               'column' => 'name'
+                                               )
+                                       ),
+                               'created' => array('action'=> PHPGW_ACL_READ,
+                                       'type' => 'date',
+                                       'label' => 'created',
+                                       'sortable' => true,
+                                       ),
+                               'secret' => array('action'=> PHPGW_ACL_ADD,
+                                       'type' => 'string',
+                                       'label' => 'secret',
+                                       'sortable' => false,
+                                       ),
+                               );
+
+                       if($debug)
+                       {
+                               foreach ($fields as $field => $field_info)
+                               {
+                                       
if(!property_exists('eventplanner_booking', $field))
+                                       {
+                                          
phpgwapi_cache::message_set('$'."{$field},", 'error');
+                                       }
+
+                               }
+                       }
+                       return $fields;
+               }
+
+               /**
+                * Implement in subclasses to perform actions on entity before 
validation
+                */
+               protected function preValidate( &$entity )
+               {
+                       if (!empty($entity->comment))
+                       {
+                               $entity->comment_input = array(
+                                       'time' => time(),
+                                       'author' => 
$GLOBALS['phpgw_info']['user']['fullname'],
+                                       'comment' => $entity->comment,
+                                       'type' => 'comment'
+                               );
+                       }
+
+                       $entity->modified = time();
+                       $entity->active = (int)$entity->active;
+
+                       if($entity->get_id())
+                       {
+                       }
+                       else
+                       {
+                               $entity->status = 
eventplanner_booking::STATUS_REGISTERED;
+                               $entity->secret = self::generate_secret();
+                       }
+               }
+
+               protected function generate_secret( $length = 10 )
+               {
+                       return substr(base64_encode(rand(1000000000, 
9999999999)), 0, $length);
+               }
+
+               public function serialize()
+               {
+                       return self::toArray();
+               }
+
+               public function store()
+               {
+                       return 
eventplanner_bobooking::get_instance()->store($this);
+               }
+
+               public function read_single($id)
+               {
+                       return 
eventplanner_bobooking::get_instance()->read_single($id, true);
+               }
+       }

Modified: branches/dev-syncromind-2/eventplanner/js/portico/application.edit.js
===================================================================
--- branches/dev-syncromind-2/eventplanner/js/portico/application.edit.js       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/eventplanner/js/portico/application.edit.js       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -27,29 +27,100 @@
 
        calculate_stage_size();
 
-       $.formUtils.addValidator({
-               name: 'naming',
-               validatorFunction: function (value, $el, config, languaje, 
$form)
+//     $.formUtils.addValidator({
+//             name: 'naming',
+//             validatorFunction: function (value, $el, config, languaje, 
$form)
+//             {
+//                     var v = false;
+//                     var firstname = $('#firstname').val();
+//                     var lastname = $('#lastname').val();
+//                     var company_name = $('#company_name').val();
+//                     var department = $('#department').val();
+//                     if ((firstname != "" && lastname != "") || 
(company_name != "" && department != ""))
+//                     {
+//                             v = true;
+//                     }
+//                     return v;
+//             },
+//             errorMessage: lang['Name or company is required'],
+//             errorMessageKey: ''
+//     });
+
+
+       $("#from_").change(function ()
+       {
+               $("#to_").val($("#from_").val());
+       });
+
+       var width = 200;
+
+       $("#submitbox").css({
+               position: 'absolute',
+               right: '10px',
+               border: '1px solid #B5076D',
+               padding: '0 5px 5px 5px',
+               width: width + 'px',
+               "background - color": '#FFF',
+               display: "block",
+       });
+
+       var offset = $("#submitbox").offset();
+       var topPadding = 180;
+
+       if ($("#center_content").length === 1)
+       {
+               $("#center_content").scroll(function ()
                {
-                       var v = false;
-                       var firstname = $('#firstname').val();
-                       var lastname = $('#lastname').val();
-                       var company_name = $('#company_name').val();
-                       var department = $('#department').val();
-                       if ((firstname != "" && lastname != "") || 
(company_name != "" && department != ""))
+                       if ($("#center_content").scrollTop() > offset.top)
                        {
-                               v = true;
+                               $("#submitbox").stop().animate({
+                                       marginTop: 
$("#center_content").scrollTop() - offset.top + topPadding
+                               }, 100);
                        }
-                       return v;
-               },
-               errorMessage: lang['Name or company is required'],
-               errorMessageKey: ''
-       });
+                       else
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: 0
+                               }, 100);
+                       }
+                       ;
+               });
+       }
+       else
+       {
+               $(window).scroll(function ()
+               {
+                       if ($(window).scrollTop() > offset.top)
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: $(window).scrollTop() - 
offset.top + topPadding
+                               }, 100);
+                       }
+                       else
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: 0
+                               }, 100);
+                       }
+                       ;
+               });
+       }
+
 });
 
 function set_tab(tab)
 {
        $("#active_tab").val(tab);
+       if (tab === 'calendar')
+       {
+               $("#floating-box").hide();
+               $("#submit_group_bottom").hide();
+       }
+       else
+       {
+               $("#floating-box").show();
+               $("#submit_group_bottom").show();
+       }
 }
 
 function calculate_total_amount()
@@ -59,7 +130,7 @@
        var number_of_units = $("#number_of_units").val();
        var charge_per_unit = $("#charge_per_unit").val();
 
-       if(charge_per_unit && number_of_units)
+       if (charge_per_unit && number_of_units)
        {
                total_amount = number_of_units * charge_per_unit;
        }
@@ -73,10 +144,114 @@
        var stage_width = $("#stage_width").val();
        var stage_depth = $("#stage_depth").val();
 
-       if(stage_width && stage_depth)
+       if (stage_width && stage_depth)
        {
                total_size = stage_width * stage_depth;
        }
        $("#stage_size").val(total_size);
 }
 
+add_booking = function ()
+{
+       oArgs = {
+               menuaction: 'eventplanner.uibooking.save_ajax',
+               application_id: $("#application_id").val()
+       };
+
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+       var htmlString = '';
+       $("#receipt").html("");
+
+       $.ajax({
+               type: 'POST',
+               dataType: 'json',
+               data: {from_: $("#from_").val(), to_: $("#to_").val(), active: 
1},
+               url: requestUrl,
+               success: function (data)
+               {
+                       if (data != null)
+                       {
+                               if (data.status_kode == 'ok')
+                               {
+                                       $("#from_").val('');
+                                       $("#to_").val('');
+                                       htmlString += "<div 
class=\"msg_good\">";
+                               }
+                               else
+                               {
+                                       htmlString += "<div class=\"error\">";
+                               }
+                               htmlString += data.msg;
+                               htmlString += '</div>';
+                               $("#receipt").html(htmlString);
+                       }
+               }
+       });
+       JqueryPortico.updateinlineTableHelper('datatable-container_1');
+};
+
+this.onActionsClick = function (action)
+{
+       $("#receipt").html("");
+       if (action === 'add')
+       {
+               add_booking();
+       }
+
+       var api = $('#datatable-container_1').dataTable().api();
+       var selected = api.rows({selected: true}).data();
+
+       var numSelected = selected.length;
+
+       if (numSelected === 0)
+       {
+               alert('None selected');
+               return false;
+       }
+       var ids = [];
+       for (var n = 0; n < selected.length; ++n)
+       {
+               var aData = selected[n];
+               ids.push(aData['id']);
+       }
+
+       if (ids.length > 0)
+       {
+               var data = {"ids": ids, "action": action, from_: 
$("#from_").val(), to_: $("#to_").val()};
+
+               oArgs = {
+                       menuaction: 'eventplanner.uibooking.update',
+                       application_id: $("#application_id").val()
+               };
+
+               var requestUrl = phpGWLink('index.php', oArgs, true);
+
+               $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       data: data,
+                       success: function (data)
+                       {
+                               if (data != null)
+                               {
+                                       if (data.status_kode == 'ok')
+                                       {
+                                               $("#from_").val('');
+                                               $("#to_").val('');
+                                               htmlString += "<div 
class=\"msg_good\">";
+                                       }
+                                       else
+                                       {
+                                               htmlString += "<div 
class=\"error\">";
+                                       }
+                                       htmlString += data.msg;
+                                       htmlString += '</div>';
+                                       $("#receipt").html(htmlString);
+                               }
+                       }
+               });
+
+               JqueryPortico.updateinlineTableHelper('datatable-container_4');
+       }
+};

Copied: branches/dev-syncromind-2/eventplanner/js/portico/booking.index.js 
(from rev 15888, trunk/eventplanner/js/portico/booking.index.js)
===================================================================
--- branches/dev-syncromind-2/eventplanner/js/portico/booking.index.js          
                (rev 0)
+++ branches/dev-syncromind-2/eventplanner/js/portico/booking.index.js  
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,4 @@
+function requestWithApplicationFilter(request)
+{
+       return request// +  '&filter_active=1';
+}

Modified: branches/dev-syncromind-2/eventplanner/setup/tables_current.inc.php
===================================================================
--- branches/dev-syncromind-2/eventplanner/setup/tables_current.inc.php 
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/eventplanner/setup/tables_current.inc.php 
2016-10-24 13:34:35 UTC (rev 15889)
@@ -267,11 +267,12 @@
                                'to_' => array('type' => 'int', 'precision' => 
'8', 'nullable' => False),
                                'active' => array('type' => 'int', 'precision' 
=> 4, 'nullable' => False, 'default' => '1'),
                                'completed' => array('type' => 'int', 
'precision' => 4, 'nullable' => False,'default' => '0'),
-                               'cost' => array('type' => 'decimal', 
'precision' => 10, 'scale' => 2, 'nullable' => True,'default' => '0.0'),
+                               'cost' => array('type' => 'decimal', 
'precision' => 20, 'scale' => 2, 'nullable' => True,'default' => '0.00'),
                                'application_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
                                'reminder' => array('type' => 'int', 
'precision' => 4, 'nullable' => False, 'default' => '0'),
                                'secret' => array('type' => 'text', 'nullable' 
=> False),
-                               'sms_total' => array('type' => 'int', 
'precision' => 4, 'nullable' => True)
+                               'sms_total' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
+                               'created' => array('type' => 'int', 'precision' 
=> '8',  'nullable' => False, 'default' => 'current_timestamp'),
                        ),
                        'pk' => array('id'),
                        'fk' => array(

Modified: branches/dev-syncromind-2/eventplanner/templates/base/application.xsl
===================================================================
--- branches/dev-syncromind-2/eventplanner/templates/base/application.xsl       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/eventplanner/templates/base/application.xsl       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -18,10 +18,19 @@
 
 <!-- add / edit  -->
 <xsl:template xmlns:php="http://php.net/xsl"; match="edit">
+       <style type="text/css">
+               #floating-box {
+               position: relative;
+               z-index: 1000;
+               }
+               #submitbox {
+               display: none;
+               }       </style>
        <xsl:variable name="date_format">
                <xsl:value-of select="php:function('get_phpgw_info', 
'user|preferences|common|dateformat')" />
        </xsl:variable>
 
+       <div id='receipt'></div>
        <div>
                <xsl:variable name="form_action">
                        <xsl:value-of select="form_action"/>
@@ -33,6 +42,39 @@
                <form id="form" name="form" method="post" 
action="{$form_action}" class="pure-form pure-form-aligned">
                        <div id="tab-content">
                                <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                               <div id="floating-box">
+                               <div id="submitbox">
+                                       <table width="200px">
+                                               <tbody>
+                                                       <tr>
+                                                               <td 
width="200px">
+                                                                       
<xsl:variable name="lang_savel">
+                                                                               
<xsl:value-of select="php:function('lang', 'save')"/>
+                                                                       
</xsl:variable>
+                                                                       <input 
type="submit" class="pure-button pure-button-primary" name="save">
+                                                                               
<xsl:attribute name="value">
+                                                                               
        <xsl:value-of select="$lang_savel"/>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="$lang_savel"/>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                               <td>
+                                                                       
<xsl:variable name="lang_cancel">
+                                                                               
<xsl:value-of select="php:function('lang', 'cancel')"/>
+                                                                       
</xsl:variable>
+                                                                       <input 
type="button" class="pure-button pure-button-primary" name="done" 
value="{$lang_cancel}" onClick="window.location = '{cancel_url}';">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'Back to the ticket list')"/>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                       </tr>
+                                               </tbody>
+                                       </table>
+                               </div>
+                       </div>
                                <input type="hidden" id="active_tab" 
name="active_tab" value="{value_active_tab}"/>
                                <div id="first_tab">
                                        <fieldset>
@@ -41,7 +83,7 @@
                                                                <label>
                                                                        
<xsl:value-of select="php:function('lang', 'id')"/>
                                                                </label>
-                                                               <input 
type="hidden" name="id" value="{application/id}"/>
+                                                               <input 
type="hidden" id="application_id" name="id" value="{application/id}"/>
                                                                <xsl:value-of 
select="application/id"/>
                                                        </div>
                                                </xsl:if>
@@ -645,8 +687,70 @@
                                                </div>
                                        </fieldset>
                                </div>
+                               <div id='calendar'>
+                                       <fieldset>
+                                       
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'date start')"/>
+                                                       </label>
+                                                       <xsl:if 
test="application/date_start != 0 and application/date_start != ''">
+                                                               <xsl:value-of 
select="php:function('date', $date_format, number(application/date_start))"/>
+                                                       </xsl:if>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'date end')"/>
+                                                       </label>
+                                                       <xsl:if 
test="application/date_end != 0 and application/date_end != ''">
+                                                               <xsl:value-of 
select="php:function('date', $date_format, number(application/date_end))"/>
+                                                       </xsl:if>
+                                               </div>
+
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'from')"/>
+                                                       </label>
+                                                       <input type="text" 
id="from_" name="from_" size="16" readonly="readonly">
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'to')"/>
+                                                       </label>
+                                                       <input type="text" 
id="to_" name="to_" size="16" readonly="readonly">
+                                                       </input>
+                                               </div>
+
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'dates')"/>
+                                                       </label>
+                                                       <div 
class="pure-custom">
+                                                               <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_1'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
        <xsl:with-param name="container" select ='container'/>
+                                                                               
        <xsl:with-param name="requestUrl" select ='requestUrl'/>
+                                                                               
        <xsl:with-param name="ColumnDefs" select ='ColumnDefs'/>
+                                                                               
        <xsl:with-param name="tabletools" select ='tabletools'/>
+                                                                               
        <xsl:with-param name="data" select ='data'/>
+                                                                               
        <xsl:with-param name="config" select ='config'/>
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                               </xsl:for-each>
+                                                       </div>
+                                               </div>
+
+
+                                       </fieldset>
+
+
+
+                               </div>
+
                        </div>
-                       <div class="proplist-col">
+                       <div id="submit_group_bottom" class="proplist-col">
                                <input type="submit" class="pure-button 
pure-button-primary" name="save">
                                        <xsl:attribute name="value">
                                                <xsl:value-of 
select="php:function('lang', 'save')"/>

Copied: branches/dev-syncromind-2/eventplanner/templates/base/booking.xsl (from 
rev 15888, trunk/eventplanner/templates/base/booking.xsl)
===================================================================
--- branches/dev-syncromind-2/eventplanner/templates/base/booking.xsl           
                (rev 0)
+++ branches/dev-syncromind-2/eventplanner/templates/base/booking.xsl   
2016-10-24 13:34:35 UTC (rev 15889)
@@ -0,0 +1,302 @@
+
+<!-- $Id: price_item.xsl 12604 2015-01-15 17:06:11Z nelson224 $ -->
+<xsl:template match="data">
+       <xsl:choose>
+               <xsl:when test="edit">
+                       <xsl:apply-templates select="edit" />
+               </xsl:when>
+               <xsl:when test="view">
+                       <xsl:apply-templates select="view" />
+               </xsl:when>
+       </xsl:choose>
+
+</xsl:template>
+
+<!-- add / edit  -->
+<xsl:template xmlns:php="http://php.net/xsl"; match="edit">
+       <xsl:variable name="date_format">
+               <xsl:value-of select="php:function('get_phpgw_info', 
'user|preferences|common|dateformat')" />
+       </xsl:variable>
+       <xsl:variable name="form_action">
+               <xsl:value-of select="form_action"/>
+       </xsl:variable>
+       <xsl:variable name="mode">
+               <xsl:value-of select="mode"/>
+       </xsl:variable>
+
+       <div>
+               <script type="text/javascript">
+                       var lang = <xsl:value-of 
select="php:function('js_lang', 'Name or company is required')"/>;
+               </script>
+               <form id="form" name="form" method="post" 
action="{$form_action}" class="pure-form pure-form-aligned">
+                       <div id="tab-content">
+                               <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                               <input type="hidden" id="active_tab" 
name="active_tab" value="{value_active_tab}"/>
+                               <div id="first_tab">
+                                       <fieldset>
+                                               <xsl:if test="booking/id > 0">
+                                                       <div 
class="pure-control-group">
+                                                               <label>
+                                                                       
<xsl:value-of select="php:function('lang', 'id')"/>
+                                                               </label>
+                                                               <input 
type="hidden" name="id" value="{booking/id}"/>
+                                                               <xsl:value-of 
select="booking/id"/>
+                                                       </div>
+                                               </xsl:if>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'active')"/>
+                                                       </label>
+                                                       <input type="checkbox" 
name="active" id="active" value="1">
+                                                               <xsl:if 
test="booking/active = 1">
+                                                                       
<xsl:attribute name="checked" value="checked"/>
+                                                               </xsl:if>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <xsl:variable 
name="lang_category">
+                                                               <xsl:value-of 
select="php:function('lang', 'category')"/>
+                                                       </xsl:variable>
+                                                       <label>
+                                                               <xsl:value-of 
select="$lang_category"/>
+                                                       </label>
+                                                       <select 
name="category_id">
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="$lang_category"/>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-error-msg">
+                                                                       
<xsl:value-of select="$lang_category"/>
+                                                               </xsl:attribute>
+                                                               
<xsl:apply-templates select="category_list/options"/>
+                                                       </select>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'name')"/>
+                                                       </label>
+                                                       <input type="text" 
name="name" value="{booking/name}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'name')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <xsl:variable 
name="lang_address_1">
+                                                               <xsl:value-of 
select="php:function('lang', 'address_1')"/>
+                                                       </xsl:variable>
+                                                       <xsl:variable 
name="lang_address_2">
+                                                               <xsl:value-of 
select="php:function('lang', 'address_2')"/>
+                                                       </xsl:variable>
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'address')"/>
+                                                       </label>
+                                                       <input type="text" 
name="address_1" value="{booking/address_1}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="$lang_address_1"/>
+                                                               </xsl:attribute>
+
+                                                       </input>
+                                                       <input type="text" 
name="address_2" value="{booking/address_2}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="$lang_address_2"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'postal_code_place')"/>
+                                                       </label>
+                                                       <input type="text" 
name="zip_code" value="{booking/zip_code}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'zip_code')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <input type="text" 
name="city" value="{booking/city}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'city')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'booking_organization_number')"/>
+                                                       </label>
+                                                       <input type="text" 
id="lastname" name="booking_organization_number" 
value="{booking/booking_organization_number}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'booking_organization_number')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'contact name')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_name" value="{booking/contact_name}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'contact_name')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'email')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_email" id="contact_email" value="{booking/contact_email}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>email</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'email')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="valid_email = 1">
+                                                                       
<xsl:text> </xsl:text>
+                                                                       <a 
href="{link_create_user}">
+                                                                               
<xsl:value-of select="php:function('lang', 'create_user_based_on_email_link')"/>
+                                                                       </a>
+                                                               </xsl:when>
+                                                       </xsl:choose>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'contact phone')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_phone" value="{booking/contact_phone}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'contact_phone')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'account_number')"/>
+                                                       </label>
+                                                       <input type="text" 
name="account_number" value="{booking/account_number}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'account_number')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'description')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="description">
+                                                               <xsl:value-of 
select="booking/description"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'remark')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="remark">
+                                                               <xsl:value-of 
select="booking/remark"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'comment')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="comment">
+                                                               <xsl:value-of 
select="booking/comment"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'details')"/>
+                                                       </label>
+                                                       <div 
class="pure-custom">
+                                                               <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_0'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
        <xsl:with-param name="container" select ='container'/>
+                                                                               
        <xsl:with-param name="requestUrl" select ='requestUrl'/>
+                                                                               
        <xsl:with-param name="ColumnDefs" select ='ColumnDefs'/>
+                                                                               
        <xsl:with-param name="data" select ='data'/>
+                                                                               
        <xsl:with-param name="config" select ='config'/>
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                               </xsl:for-each>
+                                                       </div>
+                                               </div>
+                                       </fieldset>
+                               </div>
+                       </div>
+                       <div class="proplist-col">
+                               <input type="submit" class="pure-button 
pure-button-primary" name="save">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="php:function('lang', 'save')"/>
+                                       </xsl:attribute>
+                               </input>
+                               <xsl:variable name="cancel_url">
+                                       <xsl:value-of select="cancel_url"/>
+                               </xsl:variable>
+                               <input type="button" class="pure-button 
pure-button-primary" name="cancel" onClick="window.location = '{cancel_url}';">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="php:function('lang', 'cancel')"/>
+                                       </xsl:attribute>
+                               </input>
+                       </div>
+               </form>
+       </div>
+</xsl:template>
+
+<xsl:template match="options">
+       <option value="{id}">
+               <xsl:if test="selected != 0">
+                       <xsl:attribute name="selected" value="selected"/>
+               </xsl:if>
+               <xsl:value-of disable-output-escaping="yes" select="name"/>
+       </option>
+</xsl:template>
+
+
+<xsl:template xmlns:php="http://php.net/xsl"; match="view">
+       <div>
+               <form id="form" name="form" method="post" action="" 
class="pure-form pure-form-aligned">
+                       <div id="tab-content">
+                               <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                               <div id="showing">
+
+                               </div>
+                       </div>
+                       <div class="proplist-col">
+                               <xsl:variable name="cancel_url">
+                                       <xsl:value-of select="cancel_url"/>
+                               </xsl:variable>
+                               <input type="button" class="pure-button 
pure-button-primary" name="cancel" value="{lang_cancel}" 
onMouseout="window.status='';return true;" onClick="window.location = 
'{cancel_url}';"/>
+                       </div>
+               </form>
+       </div>
+</xsl:template>

Modified: branches/dev-syncromind-2/helpdesk/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind-2/helpdesk/inc/class.menu.inc.php   2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/helpdesk/inc/class.menu.inc.php   2016-10-24 
13:34:35 UTC (rev 15889)
@@ -45,12 +45,21 @@
                        $acl = & $GLOBALS['phpgw']->acl;
                        $menus = array();
 
+                       $config = CreateObject('phpgwapi.config', 
'helpdesk')->read();
+                       if (!empty($config['app_name']))
+                       {
+                               $lang_app_name = $config['app_name'];
+                       }
+                       else
+                       {
+                               $lang_app_name = lang('helpdesk');
+                       }
 
                        $menus['navbar'] = array
                                (
                                        'helpdesk' => array
                                        (
-                                               'text'  => lang('helpdesk'),
+                                               'text'  => $lang_app_name,
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
"helpdesk.uitts.index") ),
                                                'image' => array('helpdesk', 
'navbar'),
                                                'order' => 35,

Modified: branches/dev-syncromind-2/helpdesk/templates/base/config.tpl
===================================================================
--- branches/dev-syncromind-2/helpdesk/templates/base/config.tpl        
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/helpdesk/templates/base/config.tpl        
2016-10-24 13:34:35 UTC (rev 15889)
@@ -12,6 +12,11 @@
                <tr class="row_off">
                        <td 
colspan="2">&nbsp;<b>{lang_helpdesk}/{lang_settings}</b></td>
                </tr>
+               <tr class="row_on">
+                       <td>{lang_app_name}: <br>
+                               {lang_default}: {lang_Helpdesk}</td>
+                       <td><input name="newsettings[app_name]" 
value="{value_app_name}"></td>
+               </tr>
                <tr class="row_off">
                        <td>{lang_show_billable_hours}:</td>
                        <td>

Modified: branches/dev-syncromind-2/phpgwapi/inc/class.sessions.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/class.sessions.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/phpgwapi/inc/class.sessions.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -154,10 +154,7 @@
                                $use_cookies = true;
                                $this->_sessionid       = 
phpgw::get_var(session_name(), 'string', 'COOKIE');
 
-                               if(!$this->_sessionid)
-                               {
-                                       
$GLOBALS['phpgw']->hooks->process('set_cookie_domain', array('mobilefrontend', 
'bookingfrontend', 'activitycalendarfrontend'));
-                               }
+                               
$GLOBALS['phpgw']->hooks->process('set_cookie_domain', array('mobilefrontend', 
'bookingfrontend', 'activitycalendarfrontend'));
 
                                $this->_phpgw_set_cookie_params();
                        }

Modified: branches/dev-syncromind-2/phpgwapi/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind-2/phpgwapi/setup/phpgw_no.lang      2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/phpgwapi/setup/phpgw_no.lang      2016-10-24 
13:34:35 UTC (rev 15889)
@@ -32,7 +32,7 @@
 delete common  no      Slett
 domain common  no      Database
 domain name for mail-address, eg. %1   common  no      Domene-navnet for 
E-Postadressen, %1
-done   common  no      Avslutt
+done   common  no      Avbryt
 e-mail common  no      E-Post
 email-address of the user, eg. %1      common  no      E-Postadressen til 
brukeren, %1
 edit   common  no      Editer

Modified: branches/dev-syncromind-2/property/inc/class.bocommon.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bocommon.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.bocommon.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -2552,10 +2552,10 @@
                        $filter = array('active' => 1);
                        $values = $sogeneric->read(array('filter' => 
$filter,'query' => $query));
 
-                       foreach ($values as &$value)
-                       {
-                               $value['name'] = "{$value['id']} 
{$value['name']}";
-                       }
+//                     foreach ($values as &$value)
+//                     {
+//                             $value['name'] = "{$value['id']} 
{$value['name']}";
+//                     }
 
                        return array('ResultSet' => array('Result' => $values));
                }

Modified: branches/dev-syncromind-2/property/inc/class.bolookup.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bolookup.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.bolookup.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -261,6 +261,7 @@
                                        }
                                }
                        }
+                       $filter['active'] = 1;
                        $data['filter'] = $filter;
 
                        $values = $sogeneric->read($data);

Modified: branches/dev-syncromind-2/property/inc/class.botts.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.botts.inc.php  2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.botts.inc.php  2016-10-24 
13:34:35 UTC (rev 15889)
@@ -475,19 +475,21 @@
                        $status_text = array(
                                'R' => lang('Re-opened'),
                                'X' => lang('Closed'),
-                               'O' => 
isset($this->config->config_data['tts_lang_open']) && 
$this->config->config_data['tts_lang_open'] ? 
$this->config->config_data['tts_lang_open'] : lang('Open'),
+                               'O' => 
!empty($this->config->config_data['tts_lang_open']) ? 
$this->config->config_data['tts_lang_open'] : lang('Open'),
                                'A' => lang('Re-assigned'),
                                'G' => lang('Re-assigned group'),
                                'P' => lang('Priority changed'),
                                'T' => lang('Category changed'),
                                'S' => lang('Subject changed'),
-                               'B' => lang('Billing rate'),
+                               'B' => lang('Budget changed'),
                                'H' => lang('Billing hours'),
                                'F' => lang('finnish date'),
                                'SC' => lang('Status changed'),
                                'M' => lang('Sent by email to'),
                                'MS' => lang('Sent by sms'),
                                'AC' => lang('actual cost changed'),
+                               'AR' => lang('Request for approval'),
+                               'AA' => lang('approved'),
                        );
 
                        $custom_status = $this->so->get_custom_status();
@@ -900,6 +902,10 @@
                                                break;
                                        case 'RM': $type = lang('remark');
                                                break;
+                                       case 'AR': $type = lang('request for 
approval');
+                                               break;
+                                       case 'AA': $type = lang('approved');
+                                               break;
                                        default:
                                        // nothing
                                }
@@ -1790,5 +1796,226 @@
                        return $this->so->add_relation($add_relation, $id);
                }
 
+               public function check_purchase_right($ecodimb = 0, $amount = 0, 
$ticket_id = 0)
+               {
+                       $need_approval = 
isset($this->config->config_data['workorder_approval']) ? 
$this->config->config_data['workorder_approval'] : '';
+                       if(!$need_approval)
+                       {
+                               return array();
+                       }
 
+                       $config         = CreateObject('admin.soconfig', 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket'));
+                       $check_external_register= 
!!$config->config_data['external_register']['check_external_register'];
+
+                       if($check_external_register && $ecodimb)
+                       {
+                               $url            = 
$config->config_data['external_register']['url'];
+                               $username       = 
$config->config_data['external_register']['username'];
+                               $password       = 
$config->config_data['external_register']['password'];
+                               $sub_check = 'fullmakter';
+                               $fullmakter = 
$this->check_external_register(array(
+                                       'url'           => $url,
+                                       'username'      => $username,
+                                       'password'      => $password,
+                                       'sub_check'     => $sub_check,
+                                       'id'            => sprintf("%06s", 
$ecodimb)
+                                       )
+                               );
+
+                               /**
+                                * some magic...to decide $supervisor_lid
+                                */
+                               if(isset($fullmakter[0]))
+                               {
+                                       if($amount > 5000 && $amount <= 100000)
+                                       {
+                                               $supervisor_lid = 
strtolower($fullmakter[0]['inntil100k']);
+                                       }
+                                       else if ($amount > 100000 && $amount <= 
1000000)
+                                       {
+                                               $supervisor_lid = 
strtolower($fullmakter[0]['fra100kTil1m']);
+                                       }
+                                       else if ($amount > 1000000 && $amount 
<= 5000000)
+                                       {
+                                               $supervisor_lid = 
strtolower($fullmakter[0]['fra1mTil5m']);
+                                       }
+                                       else if ($amount > 5000000)
+                                       {
+                                               $supervisor_lid = 
strtolower($fullmakter[0]['ubegrenset']);
+                                       }
+                                       else
+                                       {
+                                               $supervisor_lid = ''; // maybe 
add a required configurable failsafe as backup...
+                                       }
+                               }
+       //                      $supervisor_lid = 'hc483';
+
+                               /*
+                                       [inntil100k] => (string) DV645
+                                       [fra100kTil1m] => (string) DV645
+                                       [fra1mTil5m] => (string) YN450
+                                       [ubegrenset] => (string) JG406
+                                       [periodeFra] => (string) 200300
+                                       [periodeTil] => (string) 209912
+                                       [status] => (string) N
+                                       [aktiv] => (bool) true
+                               */
+
+                               $supervisor_id = 
$GLOBALS['phpgw']->accounts->name2id($supervisor_lid);
+                       }
+                       else
+                       {
+                               $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
+                       }
+
+                       return $this->get_supervisor_email($supervisor_id, 
$ticket_id);
+               }
+
+               public function check_external_register($param)
+               {
+                       $id = $param['id'];
+       //              $url = 
"http://tjenester.usrv.ubergenkom.no/api/tilskudd/{$sub_check}";;
+                       $url = "{$param['url']}/{$param['sub_check']}";
+                       $extravars = array
+                       (
+                               'id'            => $id,
+                       );
+
+                       $url .= '?' . http_build_query($extravars, null, '&');
+
+                       $post_data = array();
+
+                       $ch = curl_init();
+       //              curl_setopt($ch, CURLOPT_PROXY, $proxy);
+                       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
+                       curl_setopt($ch, CURLOPT_URL, $url);
+                       curl_setopt($ch, CURLOPT_USERPWD, 
"{$param['username']}:{$param['password']}");
+                       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+                       // Set The Response Format to Json
+                       curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
'Content-Type: application/json'));
+                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+                       //set data to be posted
+                       if($post_data)
+                       {
+                               $post_items = array();
+                               foreach ( $post_data as $key => $value)
+                               {
+                                       $post_items[] = "{$key}={$value}";
+                               }
+                               curl_setopt($ch, CURLOPT_POSTFIELDS, implode 
('&', $post_items));
+                       }
+
+                       $result = curl_exec($ch);
+
+                       $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+                       curl_close($ch);
+
+                       return json_decode($result, true);
+               }
+
+               protected function get_supervisor_email($supervisor_id, 
$ticket_id)
+               {
+                       $need_approval = 
isset($this->config->config_data['workorder_approval']) ? 
$this->config->config_data['workorder_approval'] : '';
+                       $supervisor_email = array();
+                       if ($supervisor_id && $need_approval)
+                       {
+                               $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+                               $pending_action = 
CreateObject('property.sopending_action');
+
+                               $action_params = array(
+                                       'appname' => 'property',
+                                       'location' => '.ticket',
+                                       'id'            => $ticket_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)
+                               {
+                                       $action_params['closed'] = false;
+                               }
+
+                               $requests = 
$pending_action->get_pending_action($action_params);
+
+                               $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' => '.ticket',
+                                               'id'            => $ticket_id,
+                                               'responsible' => 
$prefs['approval_from'],
+                                               'responsible_type' => 'user',
+                                               'action' => 'approval',
+                                               'deadline' => '',
+                                               'created_by' => '',
+                                               'allrows' => false,
+                                               'closed' => true
+                                       );
+
+                                       $approvals = 
$pending_action->get_pending_action($action_params);
+                                       if(!$approvals)
+                                       {
+                                               $action_params['closed'] = 
false;
+                                       }
+
+                                       $requests = 
$pending_action->get_pending_action($action_params);
+
+                                       $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
+
+                                       if (isset($prefs2['email']) && 
$prefs2['email'])
+                                       {
+                                               $supervisor_email[] = array(
+                                                       'id' => 
$prefs['approval_from'],
+                                                       'address' => 
$prefs2['email'],
+                                                       'required'      => 
false,
+                                                       '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
+                                               );
+                                               $supervisor_email = 
array_reverse($supervisor_email);
+                                       }
+                                       unset($prefs2);
+                               }
+                               unset($prefs);
+                       }
+
+
+
+
+                       return $supervisor_email;
+               }
+
+
        }
\ No newline at end of file

Modified: branches/dev-syncromind-2/property/inc/class.socommon.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.socommon.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.socommon.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -166,12 +166,83 @@
                        return $this->db->affected_rows();
                }
 
+               /**
+                * unquote (stripslashes) recursivly the whole array
+                *
+                * @param $arr array to unquote (var-param!)
+                */
+               public function unquote(&$arr)
+               {
+                       if (!is_array($arr))
+                       {
+                               $arr = stripslashes($arr);
+                               return;
+                       }
+                       foreach($arr as $key => $value)
+                       {
+                               if (is_array($value))
+                               {
+                                       $this->unquote($arr[$key]);
+                               }
+                               else
+                               {
+                                       $arr[$key] = stripslashes($value);
+                               }
+                       }
+               }
+
                function create_preferences( $app = '', $user_id = '' )
                {
-                       $this->db->query("SELECT preference_value FROM 
phpgw_preferences where preference_app = '$app' AND preference_owner=" . 
(int)$user_id);
-                       $this->db->next_record();
-                       $value = unserialize($this->db->f('preference_value'));
-                       return $value;
+                       $this->db->query("SELECT preference_value, 
preference_owner FROM phpgw_preferences where preference_app = '{$app}'"
+                       . " AND preference_owner IN (-1,-2," . (int)$user_id 
.')', __LINE__, __FILE__);
+                       $forced = $default = $user = array();
+                       while($this->db->next_record())
+                       {
+                               // The following ereg is required for 
PostgreSQL to work
+                               $value = 
unserialize($this->db->f('preference_value'));
+                               $this->unquote($value);
+                               if (!is_array($value))
+                               {
+                                       continue;
+                               }
+                               switch($this->db->f('preference_owner'))
+                               {
+                                       case -1:        // forced
+                                               $forced[$app] = $value;
+                                               break;
+                                       case -2:        // default
+                                               $default[$app] = $value;
+                                               break;
+                                       default:        // user
+                                               $user[$app] = $value;
+                                               break;
+                               }
+                       }
+                       $data = $user;
+
+                       // now use defaults if needed (user-value unset or 
empty)
+                       //
+                       foreach($default as $app => $values)
+                       {
+                               foreach($values as $var => $value)
+                               {
+                                       if (!isset($data[$app][$var]) || 
$data[$app][$var] === '')
+                                       {
+                                               $data[$app][$var] = $value;
+                                       }
+                               }
+                       }
+                       // now set/force forced values
+                       //
+                       foreach($forced as $app => $values)
+                       {
+                               foreach($values as $var => $value)
+                               {
+                                       $data[$app][$var] = $value;
+                               }
+                       }
+
+                       return $data[$app];
                }
 
                function read_single_tenant( $id )

Modified: branches/dev-syncromind-2/property/inc/class.sogeneric.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sogeneric.inc.php      
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.sogeneric.inc.php      
2016-10-24 13:34:35 UTC (rev 15889)
@@ -414,16 +414,24 @@
                                                (
                                                'table' => 'fm_vendor',
                                                'id' => array('name' => 'id', 
'type' => 'int'),
-                                               'fields' => array
-                                                       (
-                                                       array
-                                                               (
+                                               'fields' => array(
+                                                       array(
+                                                               'name' => 
'active',
+                                                               'descr' => 
lang('active'),
+                                                               'type' => 
'checkbox',
+                                                               'default' => 
'checked',
+                                                               'filter' => 
true,
+                                                               'sortable' => 
true,
+                                                               'values_def' => 
array(
+                                                                       
'valueset' => array(array('id' => 1, 'name' => lang('active'))),
+                                                               )
+                                                       ),
+                                                       array(
                                                                'name' => 
'contact_phone',
                                                                'descr' => 
lang('contact phone'),
                                                                'type' => 
'varchar'
                                                        ),
-                                                       array
-                                                               (
+                                                       array(
                                                                'name' => 
'category',
                                                                'descr' => 
lang('category'),
                                                                'type' => 
'select',

Modified: branches/dev-syncromind-2/property/inc/class.sopending_action.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sopending_action.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.sopending_action.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -222,8 +222,7 @@
                        $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
                        $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'] : '';
-                       $data['id']; //possible bigint
+                       $item_id = isset($data['id']) && $data['id'] ? 
$data['id'] : '';//possible bigint
                        $responsible = (int)$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']) : '';
@@ -232,6 +231,7 @@
                        $sort = isset($data['sort']) && $data['sort'] ? 
$data['sort'] : 'DESC';
                        $order = isset($data['order']) ? $data['order'] : '';
                        $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
+                       $closed = isset($data['closed']) ? $data['closed'] : '';
                        $results = isset($data['results']) ? 
(int)$data['results'] : 0;
 
                        if (!in_array($responsible_type, 
$this->valid_responsible_types))
@@ -247,7 +247,7 @@
                        }
 
                        $ret = array();
-                       $condition = " WHERE action_performed IS NULL AND 
expired_on IS NULL AND num = '{$action}' AND location_id = {$location_id}";
+                       $condition = " WHERE num = '{$action}' AND location_id 
= {$location_id}";
 
                        if ($responsible)
                        {
@@ -278,6 +278,16 @@
                                $ordermethod = ' ORDER BY created_on DESC';
                        }
 
+                       if($closed)
+                       {
+                               $ordermethod = ' ORDER BY action_performed 
DESC';
+                               $condition .= " AND action_performed IS NOT 
NULL";
+                       }
+                       else
+                       {
+                               $condition .= " AND action_performed IS NULL 
AND expired_on IS NULL ";
+                       }
+
                        $sql = "SELECT fm_action_pending.* FROM 
fm_action_pending {$this->join} fm_action_pending_category"
                                . " ON fm_action_pending.action_category = 
fm_action_pending_category.id {$condition}";
 

Modified: branches/dev-syncromind-2/property/inc/class.sotts.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sotts.inc.php  2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.sotts.inc.php  2016-10-24 
13:34:35 UTC (rev 15889)
@@ -845,6 +845,10 @@
                                $ticket['order_sent'] = 
$this->db->f('order_sent');
                                $ticket['order_received'] = 
$this->db->f('order_received');
                                $ticket['order_received_amount'] = 
$this->db->f('order_received_amount');
+                               $mail_recipients = 
trim($this->db->f('mail_recipients'), ',');
+                               $ticket['mail_recipients'] = $mail_recipients ? 
explode(',', $mail_recipients) : array();
+                               $file_attachments = 
trim($this->db->f('file_attachments'), ',');
+                               $ticket['file_attachments'] = $file_attachments 
? explode(',', $file_attachments) : array();
 
                                $user_id = (int)$this->db->f('user_id');
 
@@ -1686,6 +1690,39 @@
                                $value_set['ecodimb'] = $ticket['ecodimb'];
                                $value_set['branch_id'] = $ticket['branch_id'];
                                $value_set['tax_code'] = $ticket['tax_code'];
+
+                               if(isset($ticket['vendor_email']) && 
is_array($ticket['vendor_email']))
+                               {
+                                       $vendor_email = array();
+                                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                                       foreach ($ticket['vendor_email'] as 
$_temp)
+                                       {
+                                               if ($_temp)
+                                               {
+                                                       if 
($validator->check_email_address($_temp))
+                                                       {
+                                                               $vendor_email[] 
= $_temp;
+                                                       }
+                                                       else
+                                                       {
+                                                               
$receipt['error'][] = array('msg' => lang('%1 is not a valid address', $_temp));
+                                                       }
+                                               }
+                                       }
+                                       $value_set['mail_recipients'] = 
implode(',', $vendor_email);
+                                       unset($_temp);
+                               }
+
+                               if(isset($ticket['file_attach']) && 
is_array($ticket['file_attach']))
+                               {
+                                       $file_attachments = array();
+                                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                                       foreach ($ticket['file_attach'] as 
$_temp)
+                                       {
+                                               $file_attachments[] = 
(int)$_temp;
+                                       }
+                                       $value_set['file_attachments'] = 
implode(',', $file_attachments);
+                               }
                        }
 
                        $value_set = $this->db->validate_update($value_set);

Modified: branches/dev-syncromind-2/property/inc/class.uilookup.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uilookup.inc.php       
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.uilookup.inc.php       
2016-10-24 13:34:35 UTC (rev 15889)
@@ -431,7 +431,7 @@
                                        'sort' => $order[0]['dir'],
                                        'dir' => $order[0]['dir'],
                                        'allrows' => phpgw::get_var('length', 
'int') == -1,
-                                       'filter' => ''
+                                       'filter' => array()
                                );
 
                                $values = $this->bo->read_vendor($params);

Modified: branches/dev-syncromind-2/property/inc/class.uitts.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uitts.inc.php  2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/class.uitts.inc.php  2016-10-24 
13:34:35 UTC (rev 15889)
@@ -1276,7 +1276,7 @@
                                );
                        }
                        //_debug_array($insert_record);
-                       if ((isset($values['save']) && $values['save']) || 
(isset($values['apply']) && $values['apply']))
+                       if (!empty($values['save']) || !empty($values['apply']))
                        {
                                $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record', 'property');
 
@@ -1653,15 +1653,22 @@
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
                        $values = $this->bo->read_single($id);
 
+                       $file_attachments = isset($values['file_attachments']) 
&& is_array($values['file_attachments']) ? $values['file_attachments'] : 
array();
+
                        $content_files = array();
 
                        foreach ($values['files'] as $_entry)
                        {
-                               $content_files[] = array
-                                       (
+                               $_checked = '';
+                               if (in_array($_entry['file_id'], 
$file_attachments))
+                               {
+                                       $_checked = 'checked="checked"';
+                               }
+
+                               $content_files[] = array(
                                        'file_name' => '<a href="' . 
$link_view_file . '&amp;file_id=' . $_entry['file_id'] . '" target="_blank" 
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
                                        'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to delete file') . '">',
-                                       'attach_file' => '<input 
type="checkbox" name="values[file_attach][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to attach file') . '">'
+                                       'attach_file' => '<input 
type="checkbox"' .$_checked . ' name="values[file_attach][]" value="' . 
$_entry['file_id'] . '" title="' . lang('Check to attach file') . '">'
                                );
                        }
 
@@ -1737,7 +1744,7 @@
                                $access_order = true;
                        }
 
-                       if (isset($values['save']))
+                       if (!empty($values['save']) || 
!empty($values['send_order']))
                        {
                                if (!$this->acl_edit)
                                {
@@ -2103,31 +2110,9 @@
 
                                $need_approval = 
isset($this->bo->config->config_data['workorder_approval']) ? 
$this->bo->config->config_data['workorder_approval'] : '';
 
-               //              $supervisor_email = 
$this->get_supervisor_email($supervisor_id,  $need_approval);
                                // approval
                        }
 
-                       $vendor_email = array();
-                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
-                       if (isset($values['vendor_email']) && 
is_array($values['vendor_email']))
-                       {
-                               foreach ($values['vendor_email'] as $_temp)
-                               {
-                                       if ($_temp)
-                                       {
-                                               if 
($validator->check_email_address($_temp))
-                                               {
-                                                       $vendor_email[] = 
$_temp;
-                                               }
-                                               else
-                                               {
-                                                       $receipt['error'][] = 
array('msg' => lang('%1 is not a valid address', $_temp));
-                                               }
-                                       }
-                               }
-                       }
-                       unset($_temp);
-
                        $preview_html = phpgw::get_var('preview_html', 'bool');
                        $preview_pdf = phpgw::get_var('preview_pdf', 'bool');
 
@@ -2136,263 +2121,102 @@
                                $this->_pdf_order($id, true);
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }
-
-                       if ($vendor_email || $preview_html)
+                       if ($preview_html)
                        {
-                               $subject = lang('workorder') . ": 
{$ticket['order_id']}";
+                               $this->_html_order($id, true);
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
 
-                               $organisation = '';
-                               $contact_name = '';
-                               $contact_email = '';
-                               $contact_phone = '';
+                       $_budget_amount = $this->_get_budget_amount($id);
 
-                               if 
(isset($this->bo->config->config_data['org_name']))
-                               {
-                                       $organisation = 
$this->bo->config->config_data['org_name'];
-                               }
+                       if (isset($values['approval']) && $values['approval'] 
&& $this->bo->config->config_data['workorder_approval'])
+                       {
+                               $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
+                               $coordinator_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
 
-                               $on_behalf_of_assigned = 
phpgw::get_var('on_behalf_of_assigned', 'bool');
-                               if ($on_behalf_of_assigned && 
isset($ticket['assignedto_name']))
-                               {
-                                       $user_name = $ticket['assignedto_name'];
-                                       
$GLOBALS['phpgw']->preferences->set_account_id($ticket['assignedto'], true);
-                                       
$GLOBALS['phpgw_info']['user']['preferences'] = 
$GLOBALS['phpgw']->preferences->data;
-                                       if (!$preview_html && !$preview_pdf)
-                                       {
-                                               $_behalf_alert = lang('this 
order is sent by %1 on behalf of %2', 
$GLOBALS['phpgw_info']['user']['fullname'], $user_name);
-                                               $historylog->add('C', $id, 
$_behalf_alert);
-                                               unset($_behalf_alert);
-                                       }
-                               }
-                               else
-                               {
-                                       $user_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
-                               }
-                               $ressursnr = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr'];
-                               $location = lang('Address') . ": 
{$ticket['address']}<br>";
+                               $subject = lang(Approval) . ": " . 
$ticket['order_id'];
+                               $message = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uitts.view',
+                                               'id' => $id), false, true) . 
'">' . lang('Workorder %1 needs approval', $ticket['order_id']) . '</a>';
 
-                               $address_element = 
$this->bo->get_address_element($ticket['location_code']);
-
-                               foreach ($address_element as $address_entry)
+                               if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
                                {
-                                       $location .= "{$address_entry['text']}: 
{$address_entry['value']} <br>";
+                                       $receipt['error'][] = array('msg' => 
lang('SMTP server is not set! (admin section)'));
                                }
 
-                               $location = rtrim($location, '<br>');
-
-                               $order_description = $ticket['order_descr'];
-
-                               if (isset($contact_data['value_contact_name']) 
&& $contact_data['value_contact_name'])
+                               if (!is_object($GLOBALS['phpgw']->send))
                                {
-                                       $contact_name = 
$contact_data['value_contact_name'];
+                                       $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
                                }
-                               if (isset($contact_data['value_contact_email']) 
&& $contact_data['value_contact_email'])
-                               {
-                                       $contact_email = "<a 
href='mailto:{$contact_data['value_contact_email']}'>{$contact_data['value_contact_email']}</a>";
-                               }
-                               if (isset($contact_data['value_contact_tel']) 
&& $contact_data['value_contact_tel'])
-                               {
-                                       $contact_phone = 
$contact_data['value_contact_tel'];
-                               }
 
-                               $order_id = $ticket['order_id'];
-
-                               $user_phone = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['cellphone'];
-                               $user_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
-                               $order_email_template = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['order_email_template'];
-
-                               $body = nl2br(str_replace(array
-                                       (
-                                       '__vendor_name__',
-                                       '__organisation__',
-                                       '__user_name__',
-                                       '__user_phone__',
-                                       '__user_email__',
-                                       '__ressursnr__',
-                                       '__location__',
-                                       '__order_description__',
-                                       '__contact_name__',
-                                       '__contact_email__',
-                                       '__contact_phone__',
-                                       '__order_id__',
-                                       '[b]',
-                                       '[/b]'
-                                               ), array
-                                       (
-                                       $vendor_data['value_vendor_name'],
-                                       $organisation,
-                                       $user_name,
-                                       $user_phone,
-                                       $user_email,
-                                       $ressursnr,
-                                       $location,
-                                       $order_description,
-                                       $contact_name,
-                                       $contact_email,
-                                       $contact_phone,
-                                       $order_id,
-                                       '<b>',
-                                       '</b>'
-                                               ), $order_email_template));
-
-                               $html = "<html><head><meta 
http-equiv=\"Content-Type\" content=\"text/html; 
charset=utf-8\"><title>{$subject}</title></head>";
-
-                               $body .='</br>';
-                               $body .='</br>';
-                               $body .= '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uitts.view',
-                                               'id' => $id), false, true) . 
'">' . lang('Ticket') . ' #' . $id . '</a>';
-                               $html .= "<body>{$body}</body></html>";
-
-
-                               if ($preview_html)
+                               $action_params = array(
+                                       'appname' => 'property',
+                                       'location' => '.ticket',
+                                       'id' => $id,
+                                       'responsible' => '',
+                                       'responsible_type' => 'user',
+                                       'action' => 'approval',
+                                       'remark' => '',
+                                       'deadline' => ''
+                               );
+                               $bcc = '';//$coordinator_email;
+                               foreach ($values['approval'] as $_account_id => 
$_address)
                                {
-
-                                       
$GLOBALS['phpgw_info']['flags']['noheader'] = true;
-                                       
$GLOBALS['phpgw_info']['flags']['nofooter'] = true;
-                                       
$GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
-                                       echo $html;
-                                       $GLOBALS['phpgw']->common->phpgw_exit();
-                               }
-
-
-                               if (isset($values['file_attach']) && 
is_array($values['file_attach']))
-                               {
-                                       $bofiles = 
CreateObject('property.bofiles');
-                                       $attachments = 
$bofiles->get_attachments($values['file_attach']);
-                                       $_attachment_log = array();
-                                       foreach ($attachments as $_attachment)
+                                       $action_params['responsible'] = 
$_account_id;
+                                       try
                                        {
-                                               $_attachment_log[] = 
$_attachment['name'];
-                                       }
-                                       $attachment_log = ' ' . 
lang('attachments') . ' : ' . implode(', ', $_attachment_log);
-                               }
-
-                               if (isset($values['send_order_format']) && 
$values['send_order_format'] == 'pdf')
-                               {
-                                       $pdfcode = $this->_pdf_order($id);
-                                       if ($pdfcode)
-                                       {
-                                               $dir = 
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
-
-                                               //save the file
-                                               if (!file_exists($dir))
+                                               $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
+                                               if ($rcpt)
                                                {
-                                                       mkdir($dir, 0777);
+                                                       
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message');
                                                }
-                                               $fname = tempnam($dir . '/', 
'PDF_') . '.pdf';
-                                               $fp = fopen($fname, 'w');
-                                               fwrite($fp, $pdfcode);
-                                               fclose($fp);
-
-                                               $attachments[] = array
-                                                       (
-                                                       'file' => $fname,
-                                                       'name' => 
"order_{$id}.pdf",
-                                                       'type' => 
'application/pdf'
-                                               );
                                        }
-                                       $body = lang('order') . '.</br></br>' . 
lang('see attachment');
-                               }
-
-                               if 
(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server'])
-                               {
-                                       if (!is_object($GLOBALS['phpgw']->send))
+                                       catch (Exception $exc)
                                        {
-                                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                                               $receipt['error'][] = 
array('msg' => $exc->getMessage());
                                        }
-
-                                       $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
-                                       $coordinator_email = 
"{$coordinator_name}<{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}>";
-                                       $cc = '';
-                                       $bcc = $coordinator_email;
-                                       if 
(isset($contact_data['value_contact_email']) && 
$contact_data['value_contact_email'])
-                                       {
-                                               $cc = 
$contact_data['value_contact_email'];
-                                       }
-
-                                       $_to = implode(';', $vendor_email);
-
-                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_to, $subject, stripslashes($body), '', 
$cc, $bcc, $coordinator_email, $coordinator_name, 'html', '', $attachments, 
true);
-                                       if ($rcpt)
-                                       {
-                                               $receipt['message'][] = 
array('msg' => lang('%1 is notified', $_address));
-                                               $historylog->add('M', $id, 
"{$_to}{$attachment_log}");
-                                               $receipt['message'][] = 
array('msg' => lang('Workorder is sent by email!'));
-                                               //Sigurd: Consider remove
-                                               /*
-                                                 $action_params = array
-                                                 (
-                                                 'appname'                     
=> 'property',
-                                                 'location'                    
=> '.ticket',
-                                                 'id'                          
=> $id,
-                                                 'responsible'         => 
$values['vendor_id'],
-                                                 'responsible_type'  => 
'vendor',
-                                                 'action'                      
=> 'remind',
-                                                 'remark'                      
=> '',
-                                                 'deadline'                    
=> ''
-                                                 );
-
-                                                 $reminds = 
execMethod('property.sopending_action.set_pending_action', $action_params);
-                                                */
-                                       }
+                                       $historylog->add('AR', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
+                                       
execMethod('property.sopending_action.set_pending_action', $action_params);
                                }
-                               else
-                               {
-                                       $receipt['error'][] = array('msg' => 
lang('SMTP server is not set! (admin section)'));
-                               }
+                               
                        }
-
-                       // start approval
-                       if (isset($values['approval']) && $values['approval'] 
&& $this->bo->config->config_data['workorder_approval'])
+       
+                       if (!empty($values['do_approve']) && 
is_array($values['do_approve']))
                        {
-                               $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
-                               $coordinator_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
+                               $action_params = array(
+                                       'appname' => 'property',
+                                       'location' => '.ticket',
+                                       'id' => $id,
+                                       'responsible' => '',
+                                       'responsible_type' => 'user',
+                                       'action' => 'approval',
+                                       'remark' => '',
+                                       'deadline' => ''
+                               );
 
-                               $subject = lang(Approval) . ": " . 
$ticket['order_id'];
-                               $message = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uitts.view',
-                                               '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'])
+                               foreach ($values['do_approve'] as $_account_id 
=> $_dummy)
                                {
-                                       if (!is_object($GLOBALS['phpgw']->send))
+                                       $action_params['responsible'] = 
$_account_id;
+                                       
if(!execMethod('property.sopending_action.get_pending_action', $action_params))
                                        {
-                                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
-                                       }
-
-                                       $action_params = array
-                                               (
-                                               'appname' => 'property',
-                                               'location' => '.ticket',
-                                               '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;
-                                               $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_address, $subject, 
stripslashes($message), '', $cc, $bcc, $coordinator_email, $coordinator_name, 
'html');
-                                               if ($rcpt)
-                                               {
-                                                       $receipt['message'][] = 
array('msg' => lang('%1 is notified', $_address));
-                                               }
-
                                                
execMethod('property.sopending_action.set_pending_action', $action_params);
                                        }
+                                       
execMethod('property.sopending_action.close_pending_action', $action_params);
+                                       $historylog->add('AA', $id, 
$GLOBALS['phpgw']->accounts->get($_account_id)->__toString() . 
"::{$_budget_amount}");
                                }
-                               else
-                               {
-                                       $receipt['error'][] = array('msg' => 
lang('SMTP server is not set! (admin section)'));
-                               }
                        }
 
+
                        // end approval
                        // -------- end order section
 
+                       if(!empty($values['send_order']))
+                       {
+                               $send_order_format = 
!empty($values['send_order_format']) ? $values['send_order_format'] : 'html';
+                               $purchase_grant_checked = 
!empty($values['purchase_grant_checked']) ? true : false;
+                               $purchase_grant_error = 
!empty($values['purchase_grant_error']) ? true : false;
 
+                               $this->_send_order($ticket, $send_order_format, 
$purchase_grant_checked, $purchase_grant_error);
+                       }
 
                        $additional_notes = 
$this->bo->read_additional_notes($id);
                        $record_history = $this->bo->read_record_history($id);
@@ -2480,12 +2304,21 @@
                        //_debug_Array($additional_notes);die();
                        //---datatable 
settings---------------------------------------------------
 
+                       $z = 1;
+                       foreach ($record_history as &$history_entry)
+                       {
+                               $history_entry['sort_key'] = $z++;
+                               
+                       }
                        $datatable_def[] = array
                                (
                                'container' => 'datatable-container_1',
                                'requestUrl' => "''",
-                               'ColumnDefs' => array(array('key' => 
'value_date', 'label' => lang('Date'), 'sortable' => true,
+                               'ColumnDefs' => array(
+                                       array('key' => 'sort_key', 'label' => 
'#', 'sortable' => true,
                                                'resizeable' => true),
+                                       array('key' => 'value_date', 'label' => 
lang('Date'), 'sortable' => false,
+                                               'resizeable' => true),
                                        array('key' => 'value_user', 'label' => 
lang('User'), 'sortable' => true, 'resizeable' => true),
                                        array('key' => 'value_action', 'label' 
=> lang('Action'), 'sortable' => true,
                                                'resizeable' => true),
@@ -2503,14 +2336,26 @@
 
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
-                       for ($z = 0; $z < count($ticket['files']); $z++)
+
+                       $file_attachments = isset($ticket['file_attachments']) 
&& is_array($ticket['file_attachments']) ? $ticket['file_attachments'] : 
array();
+
+                       $content_files = array();
+
+                       foreach ($ticket['files'] as $_entry)
                        {
-                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $ticket['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$ticket['files'][$z]['name'] . '</a>';
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'">';
-                               $content_files[$z]['attach_file'] = '<input 
type="checkbox" name="values[file_attach][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to attach file') . 
'">';
+                               $_checked = '';
+                               if (in_array($_entry['file_id'], 
$file_attachments))
+                               {
+                                       $_checked = 'checked="checked"';
+                               }
+
+                               $content_files[] = array(
+                                       'file_name' => '<a href="' . 
$link_view_file . '&amp;file_id=' . $_entry['file_id'] . '" target="_blank" 
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
+                                       'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to delete file') . '">',
+                                       'attach_file' => '<input 
type="checkbox"' .$_checked . ' name="values[file_attach][]" value="' . 
$_entry['file_id'] . '" title="' . lang('Check to attach file') . '">'
+                               );
                        }
 
-
                        $attach_file_def = array
                                (
                                array('key' => 'file_name', 'label' => 
lang('Filename'), 'sortable' => false,
@@ -2540,6 +2385,20 @@
 
                        $content_email = 
$this->bocommon->get_vendor_email(isset($ticket['vendor_id']) ? 
$ticket['vendor_id'] : 0);
 
+                       if (isset($ticket['mail_recipients']) && 
is_array($ticket['mail_recipients']))
+                       {
+                               $_recipients_found = array();
+                               foreach ($content_email as &$vendor_email)
+                               {
+                                       if 
(in_array($vendor_email['value_email'], $ticket['mail_recipients']))
+                                       {
+                                               $vendor_email['value_select'] = 
str_replace("type='checkbox'", "type='checkbox' checked='checked'", 
$vendor_email['value_select']);
+                                               $_recipients_found[] = 
$vendor_email['value_email'];
+                                       }
+                               }
+                               $value_extra_mail_address = implode(',', 
array_diff($ticket['mail_recipients'], $_recipients_found));
+                       }
+
                        $datatable_def[] = array
                                (
                                'container' => 'datatable-container_3',
@@ -3084,7 +2943,8 @@
                                'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
                                'value_order_sent'      => 
!!$ticket['order_sent'],
                                'value_order_received'  => 
$ticket['order_received'] ? 
$GLOBALS['phpgw']->common->show_date($ticket['order_received']) : '[ DD/MM/YYYY 
- H:i ]',
-                               'value_order_received_amount' => (int) 
$ticket['order_received_amount']
+                               'value_order_received_amount' => (int) 
$ticket['order_received_amount'],
+                               'value_extra_mail_address' => 
$value_extra_mail_address,
                        );
 
                        phpgwapi_jquery::load_widget('numberformat');
@@ -3120,170 +2980,13 @@
 
                public function check_purchase_right()
                {
-                       $need_approval = 
isset($this->bo->config->config_data['workorder_approval']) ? 
$this->bo->config->config_data['workorder_approval'] : '';
-                       if(!$need_approval)
-                       {
-                               return;
-                       }
+                       $ecodimb        = phpgw::get_var('ecodimb');
+                       $amount         = phpgw::get_var('amount', 'int');
+                       $ticket_id      =  phpgw::get_var('ticket_id', 'int');
 
-                       $config         = CreateObject('admin.soconfig', 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket'));
-                       $check_external_register= 
!!$config->config_data['external_register']['check_external_register'];
-
-                       $id = sprintf("%06s", phpgw::get_var('ecodimb'));
-       //              $id ='013000';
-
-                       $amount =phpgw::get_var('amount', 'int');
-
-                       if($check_external_register && $id)
-                       {
-                               $url            = 
$config->config_data['external_register']['url'];
-                               $username       = 
$config->config_data['external_register']['username'];
-                               $password       = 
$config->config_data['external_register']['password'];
-                               $sub_check = 'fullmakter';
-                               $fullmakter = 
$this->check_external_register(array(
-                                       'url'           => $url,
-                                       'username'      => $username,
-                                       'password'      => $password,
-                                       'sub_check'     => $sub_check,
-                                       'id'            => $id
-                                       )
-                               );
-
-                               /**
-                                * some magic...to decide $supervisor_lid
-                                */
-                               if(isset($fullmakter[0]))
-                               {
-                                       if($amount > 5000 && $amount <= 100000)
-                                       {
-                                               $supervisor_lid = 
strtolower($fullmakter[0]['inntil100k']);
-                                       }
-                                       else if ($amount > 100000 && $amount <= 
1000000)
-                                       {
-                                               $supervisor_lid = 
strtolower($fullmakter[0]['fra100kTil1m']);
-                                       }
-                                       else if ($amount > 1000000 && $amount 
<= 5000000)
-                                       {
-                                               $supervisor_lid = 
strtolower($fullmakter[0]['fra1mTil5m']);
-                                       }
-                                       else if ($amount > 5000000)
-                                       {
-                                               $supervisor_lid = 
strtolower($fullmakter[0]['ubegrenset']);
-                                       }
-                                       else
-                                       {
-                                               $supervisor_lid = ''; // maybe 
add a required configurable failsafe as backup...
-                                       }
-                               }
-       //                      $supervisor_lid = 'hc483';
-
-                               /*
-                                       [inntil100k] => (string) DV645
-                                       [fra100kTil1m] => (string) DV645
-                                       [fra1mTil5m] => (string) YN450
-                                       [ubegrenset] => (string) JG406
-                                       [periodeFra] => (string) 200300
-                                       [periodeTil] => (string) 209912
-                                       [status] => (string) N
-                                       [aktiv] => (bool) true
-                               */
-
-                               $supervisor_id = 
$GLOBALS['phpgw']->accounts->name2id($supervisor_lid);
-                       }
-                       else
-                       {
-                               $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
-                       }
-
-                       return $this->get_supervisor_email($supervisor_id);
+                       return $this->bo->check_purchase_right($ecodimb, 
$amount, $ticket_id);
                }
 
-               public function check_external_register($param)
-               {
-                       $id = $param['id'];
-       //              $url = 
"http://tjenester.usrv.ubergenkom.no/api/tilskudd/{$sub_check}";;
-                       $url = "{$param['url']}/{$param['sub_check']}";
-                       $extravars = array
-                       (
-                               'id'            => $id,
-                       );
-
-                       $url .= '?' . http_build_query($extravars, null, '&');
-
-                       $post_data = array();
-
-                       $ch = curl_init();
-       //              curl_setopt($ch, CURLOPT_PROXY, $proxy);
-                       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
-                       curl_setopt($ch, CURLOPT_URL, $url);
-                       curl_setopt($ch, CURLOPT_USERPWD, 
"{$param['username']}:{$param['password']}");
-                       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
-                       // Set The Response Format to Json
-                       curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
'Content-Type: application/json'));
-                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-                       //set data to be posted
-                       if($post_data)
-                       {
-                               $post_items = array();
-                               foreach ( $post_data as $key => $value)
-                               {
-                                       $post_items[] = "{$key}={$value}";
-                               }
-                               curl_setopt($ch, CURLOPT_POSTFIELDS, implode 
('&', $post_items));
-                       }
-
-                       $result = curl_exec($ch);
-
-                       $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-                       curl_close($ch);
-
-                       return json_decode($result, true);
-               }
-
-               protected function get_supervisor_email($supervisor_id)
-               {
-                       $need_approval = 
isset($this->bo->config->config_data['workorder_approval']) ? 
$this->bo->config->config_data['workorder_approval'] : '';
-                       $supervisor_email = array();
-                       if ($supervisor_id && $need_approval)
-                       {
-                               $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
-                                       );
-                               }
-                               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'])
-                               {
-                                       $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
-
-                                       if (isset($prefs2['email']) && 
$prefs2['email'])
-                                       {
-                                               $supervisor_email[] = array(
-                                                       'id' => 
$prefs['approval_from'],
-                                                       'address' => 
$prefs2['email'],
-                                                       'required'      => false
-                                               );
-                                               $supervisor_email = 
array_reverse($supervisor_email);
-                                       }
-                                       unset($prefs2);
-                               }
-                               unset($prefs);
-                       }
-                       return $supervisor_email;
-               }
-
                /**
                 * Gets vendor canidated to be used as vendor - called as ajax 
from edit form
                 *
@@ -3393,8 +3096,7 @@
                {
                        if (!$this->acl_read)
                        {
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
-                                       'perm' => 1, 'acl_location' => 
$this->acl_location));
+                               phpgw::no_access();
                        }
 
                        $GLOBALS['phpgw_info']['flags']['noheader'] = true;
@@ -3412,39 +3114,9 @@
                                $show_cost = phpgw::get_var('show_cost', 
'bool');
                        }
 
-                       $ticket = $this->bo->read_single($id, $values);
+                       $ticket = $this->bo->read_single($id);
 
-                       if 
(isset($this->bo->config->config_data['invoice_acl']) && 
$this->bo->config->config_data['invoice_acl'] == 'dimb')
-                       {
-                               $approve_role = 
execMethod('property.boinvoice.check_role', $ticket['ecodimb']);
 
-                               $_ok = false;
-                               if ($approve_role['is_supervisor'])
-                               {
-                                       $_ok = true;
-                               }
-                               else if ($approve_role['is_budget_responsible'])
-                               {
-                                       $_ok = true;
-                               }
-
-                               //FIXME
-                               /*
-                                 else if( 
$common_data['workorder']['approved'] )
-                                 {
-                                 $_ok = true;
-                                 }
-                                */
-                               if (!$_ok)
-                               {
-                                       phpgwapi_cache::message_set(lang('order 
is not approved'), 'error');
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'property.uitts.view',
-                                               'id' => $id));
-                               }
-                               unset($_ok);
-                       }
-
-                       //FIXME
                        $content = array(); 
//$this->_get_order_details($common_data['content'],        $show_cost);
 
                        $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
@@ -3549,25 +3221,7 @@
 
                        if (isset($ticket['vendor_id']) && $ticket['vendor_id'])
                        {
-                               $contacts = CreateObject('property.sogeneric');
-                               $contacts->get_location_info('vendor', false);
-
-                               $custom = 
createObject('property.custom_fields');
-                               $vendor_data['attributes'] = 
$custom->find('property', '.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
-
-                               $vendor_data = 
$contacts->read_single(array('id' => $ticket['vendor_id']), $vendor_data);
-                               if (is_array($vendor_data))
-                               {
-                                       foreach ($vendor_data['attributes'] as 
$attribute)
-                                       {
-                                               if ($attribute['name'] == 
'org_name')
-                                               {
-                                                       $ticket['vendor_name'] 
= $attribute['value'];
-                                                       break;
-                                               }
-                                       }
-                               }
-                               unset($contacts);
+                               $ticket['vendor_name'] = 
$this->_get_vendor_name($ticket['vendor_id']);
                        }
 
                        $data = array
@@ -3696,6 +3350,173 @@
                        }
                }
 
+               private function _html_order( $id = 0, $preview = false, 
$show_cost = false )
+               {
+                       if (!$this->acl_read)
+                       {
+                               phpgw::no_access();
+                       }
+
+                       if (!$id)
+                       {
+                               $id = phpgw::get_var('id'); // in case of bigint
+                               $show_cost = phpgw::get_var('show_cost', 
'bool');
+                       }
+
+                       if (!$show_cost)
+                       {
+                               $show_cost = phpgw::get_var('show_cost', 
'bool');
+                       }
+
+                       $ticket = $this->bo->read_single($id);
+                       $subject = lang('workorder') . ": 
{$ticket['order_id']}";
+
+                       $organisation = '';
+                       $contact_name = '';
+                       $contact_email = '';
+                       $contact_phone = '';
+
+                       if (isset($this->bo->config->config_data['org_name']))
+                       {
+                               $organisation = 
$this->bo->config->config_data['org_name'];
+                       }
+
+                       $on_behalf_of_assigned = 
phpgw::get_var('on_behalf_of_assigned', 'bool');
+                       if ($on_behalf_of_assigned && 
isset($ticket['assignedto_name']))
+                       {
+                               $user_name = $ticket['assignedto_name'];
+                               
$GLOBALS['phpgw']->preferences->set_account_id($ticket['assignedto'], true);
+                               $GLOBALS['phpgw_info']['user']['preferences'] = 
$GLOBALS['phpgw']->preferences->data;
+                               if (!$preview)
+                               {
+                                       $_behalf_alert = lang('this order is 
sent by %1 on behalf of %2', $GLOBALS['phpgw_info']['user']['fullname'], 
$user_name);
+                                       $historylog->add('C', $id, 
$_behalf_alert);
+                                       unset($_behalf_alert);
+                               }
+                       }
+                       else
+                       {
+                               $user_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
+                       }
+                       $ressursnr = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr'];
+                       $location = lang('Address') . ": 
{$ticket['address']}<br>";
+
+                       $address_element = 
$this->bo->get_address_element($ticket['location_code']);
+
+                       foreach ($address_element as $address_entry)
+                       {
+                               $location .= "{$address_entry['text']}: 
{$address_entry['value']} <br>";
+                       }
+
+                       $location = rtrim($location, '<br>');
+
+                       $order_description = $ticket['order_descr'];
+
+                       if (isset($contact_data['value_contact_name']) && 
$contact_data['value_contact_name'])
+                       {
+                               $contact_name = 
$contact_data['value_contact_name'];
+                       }
+                       if (isset($contact_data['value_contact_email']) && 
$contact_data['value_contact_email'])
+                       {
+                               $contact_email = "<a 
href='mailto:{$contact_data['value_contact_email']}'>{$contact_data['value_contact_email']}</a>";
+                       }
+                       if (isset($contact_data['value_contact_tel']) && 
$contact_data['value_contact_tel'])
+                       {
+                               $contact_phone = 
$contact_data['value_contact_tel'];
+                       }
+
+                       $order_id = $ticket['order_id'];
+
+                       $user_phone = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['cellphone'];
+                       $user_email = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
+                       $order_email_template = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['order_email_template'];
+
+                       $body = nl2br(str_replace(array
+                               (
+                               '__vendor_name__',
+                               '__organisation__',
+                               '__user_name__',
+                               '__user_phone__',
+                               '__user_email__',
+                               '__ressursnr__',
+                               '__location__',
+                               '__order_description__',
+                               '__contact_name__',
+                               '__contact_email__',
+                               '__contact_phone__',
+                               '__order_id__',
+                               '[b]',
+                               '[/b]'
+                                       ), array
+                               (
+                               $this->_get_vendor_name($ticket['vendor_id']),
+                               $organisation,
+                               $user_name,
+                               $user_phone,
+                               $user_email,
+                               $ressursnr,
+                               $location,
+                               $order_description,
+                               $contact_name,
+                               $contact_email,
+                               $contact_phone,
+                               $order_id,
+                               '<b>',
+                               '</b>'
+                                       ), $order_email_template));
+
+                       $html = "<html><head><meta http-equiv=\"Content-Type\" 
content=\"text/html; charset=utf-8\"><title>{$subject}</title></head>";
+
+                       $body .='</br>';
+                       $body .='</br>';
+                       $body .= '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uitts.view',
+                                       'id' => $id), false, true) . '">' . 
lang('Ticket') . ' #' . $id . '</a>';
+                       $html .= "<body>{$body}</body></html>";
+
+
+                       if ($preview)
+                       {
+
+                               $GLOBALS['phpgw_info']['flags']['noheader'] = 
true;
+                               $GLOBALS['phpgw_info']['flags']['nofooter'] = 
true;
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
+                               echo $html;
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       return $html;
+               }
+
+
+
+               private function _get_vendor_name($vendor_id = 0)
+               {
+                       $vendor_name = '';
+                       if (!empty($vendor_id))
+                       {
+                               $contacts = CreateObject('property.sogeneric');
+                               $contacts->get_location_info('vendor', false);
+
+                               $custom = 
createObject('property.custom_fields');
+                               $vendor_data['attributes'] = 
$custom->find('property', '.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
+
+                               $vendor_data = 
$contacts->read_single(array('id' => $ticket['vendor_id']), $vendor_data);
+                               if (is_array($vendor_data))
+                               {
+                                       foreach ($vendor_data['attributes'] as 
$attribute)
+                                       {
+                                               if ($attribute['name'] == 
'org_name')
+                                               {
+                                                       $vendor_name = 
$attribute['value'];
+                                                       break;
+                                               }
+                                       }
+                               }
+                               unset($contacts);
+                       }
+                       return $vendor_name;
+               }
+
                /**
                 *
                 */
@@ -3774,4 +3595,129 @@
                        return $user_list;
                }
 
+               private function _send_order( $ticket, $send_order_format, 
$purchase_grant_checked = false, $purchase_grant_error = false )
+               {
+                       $_to = !empty($ticket['mail_recipients'][0]) ? 
implode(';', $ticket['mail_recipients']) : '';
+
+                       $subject = lang('workorder') . ": 
{$ticket['order_id']}";
+
+                       if (!$_to)
+                       {
+                               phpgwapi_cache::message_set(lang('missing 
recipient for order %1', $ticket['order_id']),'error' );
+                               return false;
+                       }
+
+                       if (isset($ticket['file_attachments']) && 
is_array($ticket['file_attachments']))
+                       {
+                               $attachments = 
CreateObject('property.bofiles')->get_attachments($ticket['file_attachments']);
+                               $_attachment_log = array();
+                               foreach ($attachments as $_attachment)
+                               {
+                                       $_attachment_log[] = 
$_attachment['name'];
+                               }
+                               $attachment_log = ' ' . lang('attachments') . ' 
: ' . implode(', ', $_attachment_log);
+                       }
+
+                       if ($send_order_format == 'pdf')
+                       {
+                               $pdfcode = $this->_pdf_order($id);
+                               if ($pdfcode)
+                               {
+                                       $dir = 
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
+
+                                       //save the file
+                                       if (!file_exists($dir))
+                                       {
+                                               mkdir($dir, 0777);
+                                       }
+                                       $fname = tempnam($dir . '/', 'PDF_') . 
'.pdf';
+                                       $fp = fopen($fname, 'w');
+                                       fwrite($fp, $pdfcode);
+                                       fclose($fp);
+
+                                       $attachments[] = array
+                                               (
+                                               'file' => $fname,
+                                               'name' => "order_{$id}.pdf",
+                                               'type' => 'application/pdf'
+                                       );
+                               }
+                               $body = lang('order') . '.</br></br>' . 
lang('see attachment');
+                       }
+                       else
+                       {
+                               $body = $this->_html_order($id);
+                       }
+
+                       if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
+                       {
+                               phpgwapi_cache::message_set(lang('SMTP server 
is not set! (admin section)'),'error' );
+                       }
+                       if (!is_object($GLOBALS['phpgw']->send))
+                       {
+                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                       }
+
+                       $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
+                       $coordinator_email = 
"{$coordinator_name}<{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}>";
+                       $cc = '';
+                       $bcc = $coordinator_email;
+                       if (isset($contact_data['value_contact_email']) && 
$contact_data['value_contact_email'])
+                       {
+                               $cc = $contact_data['value_contact_email'];
+                       }
+
+                       if (empty($purchase_grant_checked))
+                       {
+                               $_budget_amount = 
$this->_get_budget_amount($id);
+
+                               $purchase_grant_error = false;
+                               $check_purchase = 
$this->bo->check_purchase_right($ticket['ecodimb'], $_budget_amount, $id);
+                               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'
+                                               );
+                                       }
+                               }
+                       }
+
+//                             _debug_array($check_purchase); die();
+
+                       if(!$purchase_grant_error)
+                       {
+                               try
+                               {
+                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_to, $subject, stripslashes($body), '', 
$cc, $bcc, $coordinator_email, $coordinator_name, 'html', '', $attachments, 
true);
+                                       if ($rcpt)
+                                       {
+                                               
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message' );
+                                               $historylog->add('M', $id, 
"{$_to}{$attachment_log}");
+                                               
phpgwapi_cache::message_set(lang('Workorder is sent by email!'),'message' );
+                                       }
+                               }
+                               catch (Exception $exc)
+                               {
+                                       
phpgwapi_cache::message_set($exc->getMessage(),'error' );
+                               }
+                       }
+               }
+
+               private function _get_budget_amount($id)
+               {
+                       static $_budget_amount = 0;
+                       if(!$_budget_amount)
+                       {
+                               $budgets = $this->bo->get_budgets($id);
+                               foreach ($budgets as $budget)
+                               {
+                                       $_budget_amount += $budget['amount'];
+                               }
+                       }
+                       return $_budget_amount;
+               }
        }
\ No newline at end of file

Modified: 
branches/dev-syncromind-2/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
--- 
branches/dev-syncromind-2/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
       2016-10-24 10:38:02 UTC (rev 15888)
+++ 
branches/dev-syncromind-2/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
       2016-10-24 13:34:35 UTC (rev 15889)
@@ -58,20 +58,21 @@
                         * prosjekt
                         * tjeneste
                         */
+                       $fellesdata->update_vendor();
        //              $fellesdata->update_agresso_prosjekt(); //for mange 
treff
        //              $fellesdata->update_art();                              
//for mange treff
-                       $fellesdata->update_tjeneste();
-                       $fellesdata->update_dimb(); // ansvar
+       //              $fellesdata->update_tjeneste();
+       //              $fellesdata->update_dimb(); // ansvar, or mange treff
                        $fellesdata->get_org_unit_ids_from_top();
 
 
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/art
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/ansvar?id=013000
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/objekt?id=5001
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/prosjekt?id=5001
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/tjeneste?id=88010
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/art
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/ansvar?id=013000
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/objekt?id=5001
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt?id=5001
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
 
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/leverandorer?leverandorNr=722920
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
                        if ($this->debug)
                        {
                                _debug_array($fellesdata->unit_ids);
@@ -356,10 +357,10 @@
                function update_agresso_prosjekt()
                {
                        //det er for mange...16396 stk...
-                       return;
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/prosjekt
+                       //return;
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt
 
-                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/tilskudd/prosjekt';
+                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt';
                        $values = array();
                        try
                        {
@@ -370,17 +371,45 @@
                        {
                                echo $exc->getTraceAsString();
                        }
+/**
+            [tab] => A
+            [dimValue] => A00001
+            [description] => ADM.BYGG VEDTATT BUDSJETT 2001
+            [periodFrom] => 200612
+            [periodTo] => 209912
+            [status] => N
 
-                       _debug_array($values);
+ */
+                       if($values)
+                       {
+                               $GLOBALS['phpgw']->db->query("UPDATE 
fm_external_project SET active = 0" , __LINE__, __FILE__);
+                       }
 
+                       foreach ($values as $entry)
+                       {
+                               $active = $entry['status'] == 'C' ? 0 : 1;
+                               $GLOBALS['phpgw']->db->query("SELECT id FROM 
fm_external_project WHERE id ='{$entry['dimValue']}'", __LINE__, __FILE__);
+                               if($GLOBALS['phpgw']->db->next_record())
+                               {
+                                       $sql = "UPDATE fm_external_project SET 
name = '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE 
id = '{$entry['dimValue']}'";
+                               }
+                               else
+                               {
+                                       $name = 
$GLOBALS['phpgw']->db->db_addslashes("{$entry['dimValue']} 
{$entry['description']}");
+                                       $sql = "INSERT INTO fm_external_project 
(id, name, active)"
+                                               . " VALUES 
('{$entry['dimValue']}', '{$name}',  {$active})";
+                               }
+                               $GLOBALS['phpgw']->db->query($sql, __LINE__, 
__FILE__);
+                       }
+
                }
                function update_art()
                {
                        //det er for mange...
                        return;
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/art
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/art
 
-                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/tilskudd/art';
+                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/art';
                        $values = array();
                        try
                        {
@@ -396,10 +425,12 @@
 
                function update_tjeneste()
                {
-                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/tilskudd/tjeneste?id=88010
+                       //det er for mange...
+                       return;
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
                        //fm_eco_service
 
-                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/tilskudd/tjeneste';
+                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste';
                        $values = array();
                        try
                        {
@@ -439,6 +470,207 @@
                        }
                }
 
+               function update_vendor()
+               {
+                       $metadata = 
$GLOBALS['phpgw']->db->metadata('fm_vendor_temp');
+//_debug_array($metadata);
+                       if (!$metadata)
+                       {
+                               $sql_table = <<<SQL
+                               CREATE TABLE fm_vendor_temp
+                               (
+                                 id integer NOT NULL,
+                                 status character varying(1),
+                                 navn character varying(255),
+                                 adresse character varying(255),
+                                 postnummer character varying(50),
+                                 sted character varying(50),
+                                 organisasjonsnr character varying(50),
+                                 bankkontonr character varying(50),
+                                 aktiv integer,
+                                 CONSTRAINT fm_vendor_temp_pkey PRIMARY KEY 
(id)
+                               );
+SQL;
+                               $GLOBALS['phpgw']->db->query($sql_table, 
__LINE__, __FILE__);
+                       }
+                       $GLOBALS['phpgw']->db->query('DELETE FROM 
fm_vendor_temp', __LINE__, __FILE__);
+
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**
+                       //fm_vendor
+
+                       $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**';
+//                     $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=100304';
+                       $error = false;
+
+                       $values = array();
+                       try
+                       {
+                               $values = $this->check_external_register($url);
+
+                       }
+                       catch (Exception $exc)
+                       {
+                               $error = true;
+                               echo $exc->getTraceAsString();
+                       }
+
+                       $sql = 'INSERT INTO fm_vendor_temp (id, status, navn, 
adresse, postnummer, sted, organisasjonsnr, bankkontonr, aktiv)'
+                               . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)';
+
+                       //remove duplicates
+
+                       if(empty($values[0]['leverandornummer']))
+                       {
+                               _debug_array($values);
+                               $error = true;
+                       }
+                       $vendors = array();
+                       foreach ($values as $entry)
+                       {
+                               $vendors[$entry['leverandornummer']] = $entry;
+                       }
+
+                       unset($entry);
+//                     _debug_array($vendors);die();
+
+                       $valueset = array();
+
+                       foreach ($vendors as $key => $entry)
+                       {
+                               $valueset[] = array
+                                       (
+                                       1 => array
+                                               (
+                                               'value' => 
(int)$entry['leverandornummer'],
+                                               'type' => PDO::PARAM_INT
+                                       ),
+                                       2 => array
+                                               (
+                                               'value' => $entry['status'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       3 => array
+                                               (
+                                               'value' => $entry['navn'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       4 => array
+                                               (
+                                               'value' => $entry['adresse'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       5 => array
+                                               (
+                                               'value' => $entry['postnummer'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       6 => array
+                                               (
+                                               'value' => $entry['sted'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       7 => array
+                                               (
+                                               'value' => 
$entry['organisasjonsNr'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       8 => array
+                                               (
+                                               'value' => 
$entry['bankkontoNr'],
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       9 => array
+                                               (
+                                               'value' => (int)$entry['aktiv'],
+                                               'type' => PDO::PARAM_INT
+                                       )
+                               );
+                       }
+
+                       if($valueset && !$error)
+                       {
+                               $GLOBALS['phpgw']->db->insert($sql, $valueset, 
__LINE__, __FILE__);
+                       }
+
+/*
+            [leverandornummer] => 9906
+            [status] => N
+            [navn] => Bergen Vann KF (BV)
+            [adresse] => Postboks 7700
+            [postnummer] => 5020
+            [sted] => BERGEN
+            [organisasjonsNr] => 987328096
+            [bankkontoNr] => 52020801786
+            [aktiv] => 1
+*/
+//                     _debug_array($valueset);die();
+
+
+                       $sql = "SELECT fm_vendor_temp.*"
+                               . " FROM fm_vendor RIGHT OUTER JOIN 
fm_vendor_temp ON (fm_vendor.id = fm_vendor_temp.id)"
+                               . " WHERE fm_vendor.id IS NULL";
+
+                       $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+                       $vendors = array();
+                       while ($GLOBALS['phpgw']->db->next_record())
+                       {
+                               $vendors[] = array(
+                                       1 => array(
+                                               'value' => 
(int)$GLOBALS['phpgw']->db->f('id'),
+                                               'type' => PDO::PARAM_INT
+                                       ),
+                                       2 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('navn'),
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       3 => array(
+                                               'value' => 1,
+                                               'type' => PDO::PARAM_INT
+                                       ),
+                                       4 => array(
+                                               'value' => 6,
+                                               'type' => PDO::PARAM_INT
+                                       ),
+                                       5 => array(
+                                               'value' => 
(int)$GLOBALS['phpgw']->db->f('aktiv'),
+                                               'type' => PDO::PARAM_INT
+                                       ),
+                                       6 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('adresse'),
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       7 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('postnummer'),
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       8 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('sted'),
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       9 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('organisasjonsnr'),
+                                               'type' => PDO::PARAM_STR
+                                       ),
+                                       10 => array(
+                                               'value' => 
$GLOBALS['phpgw']->db->f('bankkontonr'),
+                                               'type' => PDO::PARAM_STR
+                                       )
+                               );
+                       }
+                       $sql = 'INSERT INTO fm_vendor (id, org_name,category, 
owner_id, active, adresse, postnr, poststed, org_nr, konto_nr)'
+                               . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+                       if($vendors)
+                       {
+                               $GLOBALS['phpgw']->db->insert($sql, $vendors, 
__LINE__, __FILE__);
+                       }
+
+                       $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET 
active = 0", __LINE__, __FILE__);
+
+                       $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET 
active = 1"
+                               . " FROM fm_vendor_temp WHERE fm_vendor.id = 
fm_vendor_temp.id", __LINE__, __FILE__);
+
+               }
+
                public function check_external_register($url)
                {
 

Modified: 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
--- 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
  2016-10-24 10:38:02 UTC (rev 15888)
+++ 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
  2016-10-24 13:34:35 UTC (rev 15889)
@@ -95,10 +95,10 @@
                        );
 
                        $DetailInfo = array();
+//                     $DetailInfo[] = array(
+//                             'TaxCode' => $param['tax_code'] // Moms kode
+//                     );
                        $DetailInfo[] = array(
-                               'TaxCode' => $param['tax_code'] // Moms kode
-                       );
-                       $DetailInfo[] = array(
                                'ReferenceCode' => array(
                                        'Code' => 'A0',
                                        'Value' => $param['dim0'] // Art
@@ -140,14 +140,14 @@
                                        'Value' => $param['dim6'] // Aktivitet
                                )
                        );
-/*
+
                        $DetailInfo[] = array(
                                'ReferenceCode' => array(
                                        'Code' => 'A1',
                                        'Value' => $param['tax_code'] // Moms 
kode
                                )
                        );
-*/
+
                        $Detail = array();
                        $i = 1;
                        foreach ($param['lines'] as $line)
@@ -161,7 +161,7 @@
                                        'UnitCode' => 'STK',
                                        'Quantity' => 1,
                                        'Price' => $line['price'],
-                                       'Linetotal'=> $line['price'],
+                                       'LineTotal'=> $line['price'],
                                        'DetailInfo' => $DetailInfo
                                );
 
@@ -304,13 +304,13 @@
                        {
                                $transfer_ok = true;
 
-                               $GLOBALS['phpgw_info']['flags']['noheader'] = 
true;
-                               $GLOBALS['phpgw_info']['flags']['nofooter'] = 
true;
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
-                               $size = strlen($content);
-                               $browser = CreateObject('phpgwapi.browser');
-                               $browser->content_header(basename($filename), 
'', $size);
-                               echo $content;
+//                             $GLOBALS['phpgw_info']['flags']['noheader'] = 
true;
+//                             $GLOBALS['phpgw_info']['flags']['nofooter'] = 
true;
+//                             $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
+//                             $size = strlen($content);
+//                             $browser = CreateObject('phpgwapi.browser');
+//                             $browser->content_header(basename($filename), 
'', $size);
+//                             echo $content;
                        }
                        return $transfer_ok;
                }

Modified: 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
===================================================================
--- 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
    2016-10-24 10:38:02 UTC (rev 15888)
+++ 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
    2016-10-24 13:34:35 UTC (rev 15889)
@@ -46,6 +46,7 @@
 
                private $acl_location;
                private $values;
+               private $ordered_amount = 1;
                var $debug = true;
 
                function __construct( $acl_location, $id )
@@ -55,15 +56,34 @@
                                case '.ticket':
                                        $this->acl_location = $acl_location;
                                        $this->values = 
ExecMethod('property.sotts.read_single', $id);
+                                       $this->ordered_amount = 
$this->_get_ordered_ticket_amount($id);
                                        break;
                                default:
                                        $this->acl_location = 
'.project.workorder';
                                        $this->values = 
ExecMethod('property.soworkorder.read_single', $id);
                                        $this->values['order_id'] = $id;
+                                       $this->ordered_amount = 
$this->_get_ordered_workorder_amount($id);
                                        break;
                        }
                }
 
+               private function _get_ordered_ticket_amount($id)
+               {
+                       $amount = 0;
+                       $budgets = ExecMethod('property.botts.get_budgets',$id);
+                       foreach ($budgets as $budget)
+                       {
+
+                               $amount += $budget['amount'];
+                       }
+                       return $amount ? $amount : 1;
+               }
+
+               private function _get_ordered_workorder_amount($id)
+               {
+                       throw new Exception('Implement me');
+               }
+
                public function transfer( $id, $received_amount )
                {
                        $values = $this->values;
@@ -95,8 +115,8 @@
                                'order_id' => $values['order_id'],
                                'lines' => array(
                                        array(
-                                               'UnitCode' => 'SUM',
-                                               'Amount' => ($received_amount),
+                                               'UnitCode' => 'STK',
+                                               'Quantity' => 
($received_amount/$this->ordered_amount),
                                        )
                                )
                        );

Modified: 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
===================================================================
--- 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
      2016-10-24 10:38:02 UTC (rev 15888)
+++ 
branches/dev-syncromind-2/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
      2016-10-24 13:34:35 UTC (rev 15889)
@@ -31,10 +31,11 @@
         * @package property
         */
        //if (false)
-       if (isset($data['order_id']) && $data['order_id'] && 
isset($data['save']) && $data['save'] && isset($data['vendor_email'][0]) && 
$data['vendor_email'][0])
+       if (!empty($data['order_id']) && !empty($data['send_order'])  && 
!empty($data['vendor_email'][0]))
        {
                $exporter_ordre = new lag_agresso_ordre_fra_melding();
-               $exporter_ordre->transfer($id);
+               $data['purchase_grant_error'] = $exporter_ordre->transfer($id) 
== 3 ? true : false;
+               $data['purchase_grant_checked'] = true;
        }
 
        class lag_agresso_ordre_fra_melding
@@ -62,7 +63,24 @@
                                $price += $budget['amount'];
                        }
 
-//             _debug_array($_ticket);die();
+                       $purchase_grant_error = false;
+                       $check_purchase = 
CreateObject('property.botts')->check_purchase_right($data['ecodimb'], $price, 
$id);
+                       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 (!$this->debug && $purchase_grant_error)
+                       {
+                               return 3;
+                       }
+       //              _debug_array($_ticket);die();
 
                        $contacts = CreateObject('property.sogeneric');
                        $contacts->get_location_info('vendor', false);
@@ -177,8 +195,7 @@
                                'lines' => array(
                                        array(
                                                'unspsc_code' => 
$_ticket['unspsc_code'] ? $_ticket['unspsc_code'] : 'UN-72000000',
-//                                             'descr' => 
$_ticket['order_descr'] ? strip_tags($_ticket['order_descr']) : 'Bygnings-, 
konstruksjons- og vedlikeholdstjenester'
-                                               'descr' => 
$_ticket['unspsc_code'] ? $this->get_unspsc_code_descr($_ticket['unspsc_code']) 
: 'Bygnings-, konstruksjons- og vedlikeholdstjenester',
+                                               'descr' => '',
                                                'price' => $price,
                                        )
                                )
@@ -195,6 +212,7 @@
 
                        if ($export_ok)
                        {
+                               phpgwapi_cache::message_set("Ordre 
#{$_ticket['order_id']} er overført");
                                $this->log_transfer( $id );
                        }
                }

Modified: branches/dev-syncromind-2/property/inc/soap_client/bra5/soap.php
===================================================================
--- branches/dev-syncromind-2/property/inc/soap_client/bra5/soap.php    
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/inc/soap_client/bra5/soap.php    
2016-10-24 13:34:35 UTC (rev 15889)
@@ -140,7 +140,7 @@
        /**
         * @global object $GLOBALS['server']
         */
-       ini_set('memory_limit', '512M');
+//     ini_set('memory_limit', '512M');
        ini_set('display_errors', true);
        error_reporting(-1);
        /**

Modified: branches/dev-syncromind-2/property/js/portico/tts.view.js
===================================================================
--- branches/dev-syncromind-2/property/js/portico/tts.view.js   2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/js/portico/tts.view.js   2016-10-24 
13:34:35 UTC (rev 15889)
@@ -71,7 +71,7 @@
 
 this.confirm_session = function (action)
 {
-       if (action == 'save' || action == 'apply')
+       if (action === 'save' || action === 'apply'  || action === 'send_order')
        {
                conf = {
                        modules: 'date, security, file',
@@ -108,6 +108,7 @@
                                        document.getElementById(action).value = 
1;
                                        try
                                        {
+                                               //Extra logic for custom js
                                                validate_submit();
                                        }
                                        catch (e)
@@ -396,7 +397,7 @@
        var total_amount = Number(amount) + Number($('#budget').val());
        $("#order_received_amount").val(total_amount);
 
-       var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount};
+       var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount, ticket_id: location_item_id};
        var requestUrl = phpGWLink('index.php', oArgs, true);
        var htmlString = "";
 
@@ -408,7 +409,7 @@
                {
                        if (data != null)
                        {
-                               htmlString = "<table>";
+                               htmlString = "<table><thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
                                var obj = data;
                                var required = '';
 
@@ -418,22 +419,119 @@
 
                                        htmlString += "<tr><td>";
 
-                                       if (obj[i].required == true)
+                                       var left_cell = "Ikke relevant";
+
+                                       if (obj[i].requested === true)
                                        {
-                                               htmlString += "<input 
type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\"" + 
obj[i].address + "\"></input>";
-                                               required = 'checked="checked" 
disabled="disabled"';
+                                               left_cell = 
obj[i].requested_time;
                                        }
-                                       htmlString += "<input type=\"checkbox\" 
name=\"values[approval][" + obj[i].id + "]\" value=\"" + obj[i].address + "\"" 
+ required + "></input>";
+                                       else if (obj[i].is_user !== true)
+                                       {
+                                               if (obj[i].approved !== true)
+                                               {
+                                                       if (obj[i].required === 
true)
+                                                       {
+                                                               required = 
'checked="checked" disabled="disabled"';
+                                                               left_cell = 
"<input type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\"" 
+ obj[i].address + "\"></input>";
+                                                       }
+                                                       else
+                                                       {
+                                                               left_cell = '';
+                                                       }
+                                                       left_cell += "<input 
type=\"checkbox\" name=\"values[approval][" + obj[i].id + "]\" value=\"" + 
obj[i].address + "\"" + required + "></input>";
+                                               }
+                                       }
+                                       else if (obj[i].is_user === true)
+                                       {
+                                               left_cell = '(Meg selv...)';
+                                       }
+                                       htmlString += left_cell;
                                        htmlString += "</td><td 
valign=\"top\">";
                                        htmlString += obj[i].address;
-                                       htmlString += "</td></tr>";
+                                       htmlString += "</td>";
+                                       htmlString += "<td>";
+
+                                       if (obj[i].approved === true)
+                                       {
+                                               htmlString += 
obj[i].approved_time;
+                                       }
+                                       else
+                                       {
+                                               if (obj[i].is_user === true)
+                                               {
+                                                       htmlString += "<input 
type=\"checkbox\" name=\"values[do_approve][" + obj[i].id + "]\" value=\"" + 
obj[i].id + "\"></input>";
+                                               }
+                                       }
+                                       htmlString += "</td>";
+
+                                       htmlString += "</tr>";
                                });
-                               htmlString += "</table>";
-
+                               htmlString += "</tbody></table>";
+//console.log(htmlString);
                                $("#approval_container").html(htmlString);
                        }
                }
        });
+}
+$(document).ready(function ()
+{
 
-}
-;
+       var test = document.getElementById('send_order_button');
+       var width = 200;
+       if (test !== null)
+       {
+               width = 280;
+       }
+
+       $("#submitbox").css({
+               position: 'absolute',
+               right: '10px',
+               border: '1px solid #B5076D',
+               padding: '0 10px 10px 10px',
+               width: width + 'px',
+               "background - color": '#FFF',
+               display: "block",
+       });
+
+       var offset = $("#submitbox").offset();
+       var topPadding = 180;
+
+       if ($("#center_content").length === 1)
+       {
+               $("#center_content").scroll(function ()
+               {
+                       if ($("#center_content").scrollTop() > offset.top)
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: 
$("#center_content").scrollTop() - offset.top + topPadding
+                               }, 100);
+                       }
+                       else
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: 0
+                               }, 100);
+                       }
+                       ;
+               });
+       }
+       else
+       {
+               $(window).scroll(function ()
+               {
+                       if ($(window).scrollTop() > offset.top)
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: $(window).scrollTop() - 
offset.top + topPadding
+                               }, 100);
+                       }
+                       else
+                       {
+                               $("#submitbox").stop().animate({
+                                       marginTop: 0
+                               }, 100);
+                       }
+                       ;
+               });
+       }
+});

Modified: branches/dev-syncromind-2/property/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind-2/property/setup/phpgw_no.lang      2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/setup/phpgw_no.lang      2016-10-24 
13:34:35 UTC (rev 15889)
@@ -2066,4 +2066,7 @@
 mine roles     property        no      Mine roller
 account type   property        no      Rolletype
 update ticket  property        no      Oppdater melding
-make relation  property        no      Opprett kopling
\ No newline at end of file
+make relation  property        no      Opprett kopling
+request for approval   property        no      Anmodning om godkjenning
+approval from %1 is required   property        no      Godkjenning fra %1 er 
påkrevd
+missing recipient for order %1 property        no      Mangler mottaker for 
ordre %1
\ No newline at end of file

Modified: branches/dev-syncromind-2/property/setup/setup.inc.php
===================================================================
--- branches/dev-syncromind-2/property/setup/setup.inc.php      2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/setup/setup.inc.php      2016-10-24 
13:34:35 UTC (rev 15889)
@@ -11,7 +11,7 @@
         * @version $Id$
        */
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.707';
+       $setup_info['property']['version']              = '0.9.17.709';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: branches/dev-syncromind-2/property/setup/tables_current.inc.php
===================================================================
--- branches/dev-syncromind-2/property/setup/tables_current.inc.php     
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/setup/tables_current.inc.php     
2016-10-24 13:34:35 UTC (rev 15889)
@@ -88,7 +88,7 @@
                'fm_vendor' => array(
                        'fd' => array(
                                'id' => array('type' => 'int', 'precision' => 
'4', 'nullable' => False),
-                               'entry_date' => array('type' => 'int', 
'precision' => '4', 'nullable' => True),
+                               'entry_date' => array('type' => 'int', 
'precision' => 8, 'nullable' => True, 'default' => 'current_timestamp'),
                                'org_name' => array('type' => 'varchar', 
'precision' => '100', 'nullable' => True),
                                'email' => array('type' => 'varchar', 
'precision' => '64', 'nullable' => True),
                                'contact_phone' => array('type' => 'varchar', 
'precision' => '20', 'nullable' => True),
@@ -96,7 +96,8 @@
                                'member_of' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => True),
                                'category' => array('type' => 'int', 
'precision' => '2', 'nullable' => True),
                                'mva' => array('type' => 'int', 'precision' => 
'4', 'nullable' => True),
-                               'owner_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => True)
+                               'owner_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => True),
+                               'active' => array('type' => 'int', 'precision' 
=> '2', 'nullable' => True, 'default' => 1)
                        ),
                        'pk' => array('id'),
                        'fk' => array(),
@@ -1169,6 +1170,8 @@
                                'order_sent' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'order_received' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'order_received_amount' => array('type' => 
'decimal', 'precision' => '20', 'scale' => '2', 'nullable' => True, 'default' 
=> '0.00'),
+                               'mail_recipients' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True),
+                               'file_attachments' => array('type' => 
'varchar', 'precision' => 255, 'nullable' => True),
                        ),
                        'pk' => array('id'),
                        'ix' => array(),

Modified: branches/dev-syncromind-2/property/setup/tables_update.inc.php
===================================================================
--- branches/dev-syncromind-2/property/setup/tables_update.inc.php      
2016-10-24 10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/setup/tables_update.inc.php      
2016-10-24 13:34:35 UTC (rev 15889)
@@ -9376,4 +9376,63 @@
                }
        }
 
-       
\ No newline at end of file
+       /**
+       * Update property version from 0.9.17.707 to 0.9.17.708
+       *
+       */
+       $test[] = '0.9.17.707';
+
+       function property_upgrade0_9_17_707()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+               $GLOBALS['phpgw_setup']->oProc->AddColumn("fm_vendor", 
'active', array(
+                       'type' => 'int',
+                       'precision' => 2,
+                       'nullable' => True,
+                       'default' => 1
+                       )
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_vendor', 
'entry_date',
+                               array('type' => 'int', 'precision' => 8, 
'nullable' => True, 'default' => 'current_timestamp')
+                       );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.708';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+
+       /**
+       * Update property version from 0.9.17.708 to 0.9.17.709
+       *
+       */
+       $test[] = '0.9.17.708';
+
+       function property_upgrade0_9_17_708()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_tts_tickets', 
'mail_recipients', array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => True
+                       )
+               );
+               $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_tts_tickets', 
'file_attachments', array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => True
+                       )
+               );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.709';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+

Modified: branches/dev-syncromind-2/property/templates/base/tts.xsl
===================================================================
--- branches/dev-syncromind-2/property/templates/base/tts.xsl   2016-10-24 
10:38:02 UTC (rev 15888)
+++ branches/dev-syncromind-2/property/templates/base/tts.xsl   2016-10-24 
13:34:35 UTC (rev 15889)
@@ -230,6 +230,14 @@
 
 <!-- view -->
 <xsl:template xmlns:php="http://php.net/xsl"; match="view">
+       <style type="text/css">
+               #floating-box {
+               position: relative;
+               z-index: 1000;
+               }
+               #submitbox {
+               display: none;
+               }       </style>
        <script type="text/javascript">
                self.name="first_Window";
                <xsl:value-of select="lookup_functions"/>
@@ -303,6 +311,54 @@
        <form class="pure-form pure-form-aligned" ENCTYPE="multipart/form-data" 
id="form" name="form" method="post" action="{$form_action}">
                <div id="tab-content">
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                       <div id="floating-box">
+                               <div id="submitbox">
+                                       <table width="200px">
+                                               <tbody>
+                                                       <tr>
+                                                               <td 
width="200px">
+                                                                       <input 
type="button" class="pure-button pure-button-primary" name="save" 
onClick="confirm_session('save');">
+                                                                               
<xsl:attribute name="value">
+                                                                               
        <xsl:value-of select="php:function('lang', 'save')"/>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'save the ticket')"/>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="access_order = 1">
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="value_order_id!=''">
+                                                                               
                <td>
+                                                                               
                        <xsl:variable name="lang_send_order">
+                                                                               
                                <xsl:value-of select="php:function('lang', 
'send order')"/>
+                                                                               
                        </xsl:variable>
+                                                                               
                        <input type="button" class="pure-button 
pure-button-primary" id="send_order_button" name="send_order" 
value="{$lang_send_order}" onClick="confirm_session('send_order');">
+                                                                               
                                <xsl:attribute name="title">
+                                                                               
                                        <xsl:value-of 
select="$lang_send_order"/>
+                                                                               
                                </xsl:attribute>
+                                                                               
                        </input>
+                                                                               
                </td>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                       
</xsl:when>
+                                                               </xsl:choose>
+                                                               <td>
+                                                                       
<xsl:variable name="lang_done">
+                                                                               
<xsl:value-of select="php:function('lang', 'done')"/>
+                                                                       
</xsl:variable>
+                                                                       <input 
type="button" class="pure-button pure-button-primary" name="done" 
value="{$lang_done}" onClick="document.cancel_form.submit();">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'Back to the ticket list')"/>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                       </tr>
+                                               </tbody>
+                                       </table>
+                               </div>
+                       </div>
                        <div id="general">
                                <fieldset>
                                        <div class="pure-control-group">
@@ -1002,7 +1058,7 @@
                                                                                
<xsl:when test="need_approval='1'">
                                                                                
        <div class="pure-control-group">
                                                                                
                <label>
-                                                                               
                        <xsl:value-of select="php:function('lang', 'ask for 
approval')"/>
+                                                                               
                        <xsl:value-of select="php:function('lang', 
'approval')"/>
                                                                                
                </label>
                                                                                
                <div id="approval_container" class="pure-table pure-u-md-1-2">
                                                                                
                </div>
@@ -1052,7 +1108,7 @@
                                                                                
                        </label>
                                                                                
                </td>
                                                                                
                <td>
-                                                                               
                        <input type="text" name="values[vendor_email][]" 
value="">
+                                                                               
                        <input type="text" name="values[vendor_email][]" 
value="{value_extra_mail_address}">
                                                                                
                                <xsl:attribute name="title">
                                                                                
                                        <xsl:value-of 
select="php:function('lang', 'The order will also be sent to this one')"/>
                                                                                
                                </xsl:attribute>
@@ -1212,6 +1268,26 @@
                                        <xsl:value-of 
select="php:function('lang', 'save the ticket')"/>
                                </xsl:attribute>
                        </input>
+                       <input type="hidden" id="send_order" 
name="values[send_order]" value=""/>
+                       <xsl:choose>
+                               <xsl:when test="access_order = 1">
+                                       <xsl:choose>
+                                               <xsl:when 
test="value_order_id!=''">
+                                                       <xsl:variable 
name="lang_send_order">
+                                                               <xsl:value-of 
select="php:function('lang', 'send order')"/>
+                                                       </xsl:variable>
+                                                       <input type="button" 
class="pure-button pure-button-primary" name="send_order" 
onClick="confirm_session('send_order');">
+                                                               <xsl:attribute 
name="value">
+                                                                       
<xsl:value-of select="$lang_send_order"/>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="$lang_send_order"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </xsl:when>
+                       </xsl:choose>
                        <xsl:variable name="lang_done">
                                <xsl:value-of select="php:function('lang', 
'done')"/>
                        </xsl:variable>
@@ -1222,7 +1298,7 @@
                        </input>
                </div>
        </form>
-       
+
        <xsl:variable name="done_action">
                <xsl:value-of select="done_action"/>
        </xsl:variable>




reply via email to

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