fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6588] Property: clean up code / tune invoice handlin


From: Sigurd Nes
Subject: [Fmsystem-commits] [6588] Property: clean up code / tune invoice handling
Date: Sat, 13 Nov 2010 17:15:51 +0000

Revision: 6588
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6588
Author:   sigurdne
Date:     2010-11-13 17:15:50 +0000 (Sat, 13 Nov 2010)
Log Message:
-----------
Property: clean up code / tune invoice handling

Modified Paths:
--------------
    trunk/property/inc/class.bocategory.inc.php
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.boinvoice.inc.php
    trunk/property/inc/class.menu.inc.php
    trunk/property/inc/class.soXport.inc.php
    trunk/property/inc/class.socategory.inc.php
    trunk/property/inc/class.soinvoice.inc.php
    trunk/property/inc/class.solookup.inc.php
    trunk/property/inc/class.uicategory.inc.php
    trunk/property/inc/class.uiinvoice.inc.php
    trunk/property/inc/cron/default/Import_fra_basware_X205.php
    trunk/property/inc/export/default/Basware_X114
    trunk/property/js/yahoo/invoice.list_sub.js
    trunk/property/setup/phpgw_no.lang
    trunk/property/setup/setup.inc.php
    trunk/property/setup/tables_current.inc.php
    trunk/property/setup/tables_update.inc.php
    trunk/property/templates/base/category.xsl

Removed Paths:
-------------
    trunk/property/inc/class.bob_account.inc.php
    trunk/property/inc/class.bor_agreement.inc.php
    trunk/property/inc/class.sob_account.inc.php
    trunk/property/inc/class.sor_agreement.inc.php
    trunk/property/inc/class.sostandard_2.inc.php
    trunk/property/inc/class.sostandard_3.inc.php
    trunk/property/inc/class.uib_account.inc.php
    trunk/property/inc/class.uir_agreement.inc.php
    trunk/property/inc/class.uistandard_2.inc.php
    trunk/property/inc/class.uistandard_3.inc.php
    trunk/property/js/yahoo/account.index.js
    trunk/property/js/yahoo/uistandard_2.index.js
    trunk/property/js/yahoo/uistandard_3.index.js
    trunk/property/templates/base/b_account.xsl
    trunk/property/templates/base/r_agreement.xsl
    trunk/property/templates/base/standard_2.xsl
    trunk/property/templates/base/standard_3.xsl

Deleted: trunk/property/inc/class.bob_account.inc.php
===================================================================
--- trunk/property/inc/class.bob_account.inc.php        2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.bob_account.inc.php        2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,195 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_bob_account
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-
-               var $public_functions = array
-               (
-                       'read'                          => true,
-                       'read_single'           => true,
-                       'save'                          => true,
-                       'delete'                        => true,
-                       'check_perms'           => true
-               );
-
-               var $soap_functions = array(
-                       'list' => array(
-                               'in'  => 
array('int','int','struct','string','int'),
-                               'out' => array('array')
-                       ),
-                       'read' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array('array')
-                       ),
-                       'save' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       ),
-                       'delete' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       )
-               );
-
-               function property_bob_account($session=false)
-               {
-               //      $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->so               = 
CreateObject('property.sob_account');
-                       $this->socommon = CreateObject('property.socommon');
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = true;
-                       }
-
-                       $start  = phpgw::get_var('start', 'int', 'REQUEST', 0);
-                       $query  = phpgw::get_var('query');
-                       $sort   = phpgw::get_var('sort');
-                       $order  = phpgw::get_var('order');
-                       $filter = phpgw::get_var('filter', 'int');
-                       $cat_id = phpgw::get_var('cat_id', 'int');
-                       $allrows= phpgw::get_var('allrows', 'bool');
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(!empty($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       if(isset($allrows))
-                       {
-                               $this->allrows = $allrows;
-                       }
-               }
-
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$GLOBALS['phpgw']->session->appsession('session_data','b_account',$data);
-                       }
-               }
-
-               function read_sessiondata()
-               {
-                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','b_account');
-
-                       //_debug_array($data);
-
-                       $this->start    = $data['start'];
-                       $this->query    = $data['query'];
-                       $this->filter   = $data['filter'];
-                       $this->sort             = $data['sort'];
-                       $this->order    = $data['order'];
-                       $this->cat_id   = $data['cat_id'];
-                       $this->allrows  = $data['allrows'];
-               }
-
-
-               function read()
-               {
-                       $b_account = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'allrows'=>$this->allrows));
-
-                       $this->total_records = $this->so->total_records;
-
-                       return $b_account;
-               }
-
-               function read_single($id)
-               {
-                       return $this->so->read_single($id);
-               }
-
-               function select_part_of_town($part_of_town_id)
-               {
-                       return 
$this->socommon->select_part_of_town($part_of_town_id);
-               }
-
-               function save($b_account,$action='')
-               {
-                       if ($action=='edit')
-                       {
-                               if ($b_account['id'] != '')
-                               {
-
-                                       $receipt = $this->so->edit($b_account);
-                               }
-                       }
-                       else
-                       {
-                               $receipt = $this->so->add($b_account);
-                       }
-
-                       return $receipt;
-               }
-
-               function delete($id)
-               {
-                       $this->so->delete($id);
-               }
-       }
-

Modified: trunk/property/inc/class.bocategory.inc.php
===================================================================
--- trunk/property/inc/class.bocategory.inc.php 2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.bocategory.inc.php 2010-11-13 17:15:50 UTC (rev 
6588)
@@ -178,9 +178,26 @@
                        return $receipt;
                }
 
+               /**
+               * Get a list from and tag the selected item
+               *
+               * @param array $data
+               *
+               * @return array with information to include in forms
+               */
+
+               public function get_list($data)
+               {
+                       $values = $this->so->get_list($data);
+                       foreach ($values as &$entry)
+                       {
+                               $entry['selected'] = isset($data['selected']) 
&& $data['selected'] == $entry['id'] ? 1 : 0;
+                       }
+                       return $values;
+               }
+
                public function delete($id)
                {
                        $this->so->delete($id);
                }
        }
-

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.bocommon.inc.php   2010-11-13 17:15:50 UTC (rev 
6588)
@@ -495,6 +495,17 @@
 
                function 
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
                {
+                       if(is_array($format)) // i.e: called by ExecMethod()
+                       {
+                               $data                   = $format;
+                               $format                 = 
isset($data['format']) ? $data['format'] : '';
+                               $right                  = isset($data['right']) 
? $data['right'] : '';
+                               $selected               = 
isset($data['selected']) ? $data['selected'] : '';
+                               $acl_location   = isset($data['acl_location']) 
? $data['acl_location'] : '';
+                               $extra                  = isset($data['extra']) 
? $data['extra'] : '';
+                               $default                = 
isset($data['default']) ? $data['default'] : '';
+                       }
+
                        switch($format)
                        {
                                case 'select':
@@ -737,17 +748,16 @@
                        $b_account['lang_b_account']                    = 
isset($data['role']) && $data['role'] == 'group' ? lang('budget account group') 
: lang('Budget account');
                        if($data['b_account_id'] && !$data['b_account_name'])
                        {
+                               $b_account_object       = 
CreateObject('property.socategory');
                                if(isset($data['role']) && $data['role'] == 
'group')
                                {
-                                       $b_account_object       = 
CreateObject('property.socategory');
                                        
$b_account_object->get_location_info('b_account',false);
-                                       $b_account_data         = 
$b_account_object->read_single(array('id'=> $data['b_account_id']));
                                }
                                else
                                {
-                                       $b_account_object       = 
CreateObject('property.sob_account');
-                                       $b_account_data         = 
$b_account_object->read_single($data['b_account_id']);
+                                       
$b_account_object->get_location_info('budget_account',false);
                                }
+                               $b_account_data         = 
$b_account_object->read_single(array('id'=> $data['b_account_id']));
                                $b_account['value_b_account_name']      = 
$b_account_data['descr'];
                        }
 

Modified: trunk/property/inc/class.boinvoice.inc.php
===================================================================
--- trunk/property/inc/class.boinvoice.inc.php  2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.boinvoice.inc.php  2010-11-13 17:15:50 UTC (rev 
6588)
@@ -111,6 +111,38 @@
                                                                                
        'voucher_id'=>$voucher_id,'b_account_class' =>$this->b_account_class,
                                                                                
        'district_id' => $this->district_id));
 
+                       $soXport    = CreateObject('property.soXport');
+                       $soworkorder = CreateObject('property.soworkorder');
+                       $sos_agreement = CreateObject('property.sos_agreement');
+                       foreach ( $invoice as & $entry )
+                       {
+                               if( $entry['order_id'] )
+                               {
+                                       if($order_type = 
$soXport->check_order($entry['order_id']))
+                                       {
+                                               if($order_type == 'workorder')
+                                               {
+                                                       $workorder      = 
$soworkorder->read_single($entry['order_id']);
+
+                                                       
if($workorder['vendor_id'] && ($workorder['vendor_id'] != $entry['vendor_id']))
+                                                       {
+                                                               
$entry['vendor']                =  
$this->get_vendor_name($workorder['vendor_id']) . ' => ' . $entry['vendor'];
+                                                       }
+                                               }
+
+                                               if($order_type == 's_agreement')
+                                               {
+                                                       $s_agreement = 
$sos_agreement->read_single(array('s_agreement_id'=>$entry['order_id']));
+
+                                                       
if($s_agreement['vendor_id'] && ($s_agreement['vendor_id'] != 
$entry['vendor_id']))
+                                                       {
+                                                               
$entry['vendor']                = 
$this->get_vendor_name($s_agreement['vendor_id']) . ' => ' . $entry['vendor'];
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
                        $this->total_records = $this->so->total_records;
 
                        return $invoice;

Deleted: trunk/property/inc/class.bor_agreement.inc.php
===================================================================
--- trunk/property/inc/class.bor_agreement.inc.php      2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.bor_agreement.inc.php      2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,585 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage agreement
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_bor_agreement
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-               var $role;
-               var $member_id;
-
-               /**
-               * @var object $custom reference to custom fields object
-               */
-               protected $custom;
-
-               var $public_functions = array
-               (
-                       'read'                          => true,
-                       'read_single'           => true,
-                       'save'                          => true,
-                       'delete'                        => true,
-                       'check_perms'           => true
-               );
-
-               function property_bor_agreement($session=false)
-               {
-               //      $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->so = CreateObject('property.sor_agreement');
-                       $this->bocommon = CreateObject('property.bocommon');
-                       $this->custom           = 
createObject('property.custom_fields');
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = true;
-                       }
-
-                       $reset_query            = phpgw::get_var('reset_query', 
'bool');
-                       $sort   = phpgw::get_var('sort');
-                       $order  = phpgw::get_var('order');
-                       $allrows        = phpgw::get_var('allrows', 'bool');
-                       $role   = phpgw::get_var('role');
-
-                       if($reset_query)
-                       {
-                               $start  = '';
-                               $query  = '';
-                               $filter = '';
-                               $cat_id = '';
-                               $customer_id ='';
-                               $member_id      = '';
-                               $loc1   = '';
-                       }
-                       else
-                       {
-                               $start  = phpgw::get_var('start', 'int', 
'REQUEST', 0);
-                               $query  = phpgw::get_var('query');
-                               $filter = phpgw::get_var('filter', 'int');
-                               $cat_id = phpgw::get_var('cat_id', 'int');
-                               $customer_id    = phpgw::get_var('tenant_id', 
'int');
-                               $member_id      = phpgw::get_var('member_id', 
'int');
-                               $loc1   = phpgw::get_var('loc1');
-                       }
-
-
-                       $this->role     = $role;
-                       $this->so->role = $role;
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(!empty($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id) && !empty($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       else
-                       {
-                               unset($this->cat_id);
-                       }
-                       if(isset($allrows))
-                       {
-                               $this->allrows = $allrows;
-                       }
-                       if(isset($member_id))
-                       {
-                               $this->member_id = $member_id;
-                       }
-                       if(isset($customer_id))
-                       {
-                               $this->customer_id = $customer_id;
-                       }
-                       if(isset($loc1))
-                       {
-                               $this->loc1 = $loc1;
-                       }
-               }
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$GLOBALS['phpgw']->session->appsession('session_data','r_agreement',$data);
-                       }
-               }
-
-               function read_sessiondata()
-               {
-                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','r_agreement');
-
-                       //_debug_array($data);
-
-                       $this->start    = $data['start'];
-                       $this->query    = $data['query'];
-                       $this->filter   = $data['filter'];
-                       $this->sort             = $data['sort'];
-                       $this->order    = $data['order'];
-                       $this->cat_id   = $data['cat_id'];
-                       $this->customer_id= $data['customer_id'];
-                       $this->member_id= $data['member_id'];
-                       $this->allrows  = $data['allrows'];
-                       $this->loc1     = $data['loc1'];
-               }
-
-               function check_perms($has, $needed)
-               {
-                       return (!!($has & $needed) == true);
-               }
-
-
-               function select_vendor_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('select_vendor'));
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_vendor'));
-                                       break;
-                       }
-
-                       $input_list= $this->so->select_vendor_list();
-                       $vendor_list= 
$this->bocommon->select_list($selected,$input_list);
-
-                       return $vendor_list;
-               }
-
-               function read()
-               {
-                       $r_agreement = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'filter' => $this->filter,'cat_id' => 
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-                                                                               
        'customer_id'=>$this->customer_id, 'loc1' => $this->loc1));
-                       $this->total_records = $this->so->total_records;
-
-                       $this->uicols   = $this->so->uicols;
-
-                       for ($i=0; $i<count($r_agreement); $i++)
-                       {
-                               if($r_agreement[$i]['start_date'])
-                               {
-                                       $r_agreement[$i]['start_date']  = 
$GLOBALS['phpgw']->common->show_date($r_agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               }
-                               if($r_agreement[$i]['end_date'])
-                               {
-                                       $r_agreement[$i]['end_date']  = 
$GLOBALS['phpgw']->common->show_date($r_agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               }
-                       }
-                       return $r_agreement;
-               }
-
-               function read_details($id)
-               {
-                       $list = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'filter' => $this->filter,'cat_id' => 
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-                                                                               
        'r_agreement_id'=>$id,'detail'=>true));
-                       $this->total_records = $this->so->total_records;
-
-                       $this->uicols   = $this->so->uicols;
-
-                       for ($i=0; $i<count($list); $i++)
-                       {
-                               $list[$i]['index_date']  = 
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                       }
-
-                       return $list;
-               }
-
-               function read_prizing($data)
-               {
-                       $list = $this->so->read_prizing($data);
-                       $this->total_records = $this->so->total_records;
-
-                       $this->uicols   = $this->so->uicols;
-
-                       for ($i=0; $i<count($list); $i++)
-                       {
-                               $list[$i]['index_date']  = 
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               $list[$i]['from_date']  = 
$GLOBALS['phpgw']->common->show_date($list[$i]['from_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               $list[$i]['to_date']  = 
$GLOBALS['phpgw']->common->show_date($list[$i]['to_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               if($list[$i]['tenant_id'])
-                               {
-                                       $list[$i]['tenant'] = 
$this->so->get_tenant_name($list[$i]['tenant_id']);
-                               }
-                       }
-
-                       return $list;
-               }
-
-               function read_event($data)
-               {
-                       $boalarm                = 
CreateObject('property.boalarm');
-                       $event  = 
$this->so->read_single($data['r_agreement_id']);
-                       $event['alarm_date']=$event['termination_date'];
-                       $event['alarm'] = 
$boalarm->read_alarms($type='r_agreement',$data['r_agreement_id']);
-                       return $event;
-               }
-
-               function read_single($data)
-               {
-
-                       $values['attributes'] = $this->custom->find('property', 
'.r_agreement', 0, '', 'ASC', 'attrib_sort', true, true);
-
-                       if(isset($data['r_agreement_id']) && 
$data['r_agreement_id'])
-                       {
-                               $values = 
$this->so->read_single($data['r_agreement_id'], $values);
-                       }
-
-                       $values = $this->custom->prepare($values, 'property', 
'.r_agreement', $data['view']);
-
-                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-                       $values['start_date']           = 
$GLOBALS['phpgw']->common->show_date($values['start_date'],$dateformat);
-                       $values['end_date']             = 
$GLOBALS['phpgw']->common->show_date($values['end_date'],$dateformat);
-                       if($values['termination_date'])
-                       {
-                               $values['termination_date']= 
$GLOBALS['phpgw']->common->show_date($values['termination_date'],$dateformat);
-                       }
-
-                       $vfs = CreateObject('phpgwapi.vfs');
-                       $vfs->override_acl = 1;
-
-                       $values['files'] = $vfs->ls (array(
-                            'string' => '/property/rental_agreement/' . 
$data['r_agreement_id'],
-                            'relatives' => array(RELATIVE_NONE)));
-
-                       $vfs->override_acl = 0;
-
-                       if(!$values['files'][0]['file_id'])
-                       {
-                               unset($values['files']);
-                       }
-
-                       return $values;
-               }
-
-               function read_single_item($data)
-               {
-                       $values['attributes'] = $this->custom->find('property', 
'.r_agreement.detail', 0, '', 'ASC', 'attrib_sort', true, true);
-
-                       if(isset($data['r_agreement_id']) && 
$data['r_agreement_id'] && isset($data['id']) && $data['id'])
-                       {
-                               $values = $this->so->read_single_item($data, 
$values);
-                       }
-                       $values = $this->custom->prepare($values, 'property', 
'.r_agreement.detail');
-
-                       if($values['location_code'])
-                       {
-                               $solocation     = 
CreateObject('property.solocation');
-                               $values['location_data'] 
=$solocation->read_single($values['location_code']);
-                       }
-
-                       if($values['p_num'])
-                       {
-                               $soadmin_entity = 
CreateObject('property.soadmin_entity');
-                               $category = 
$soadmin_entity->read_single_category($values['p_entity_id'],$values['p_cat_id']);
-
-                               
$values['p'][$values['p_entity_id']]['p_num']=$values['p_num'];
-                               
$values['p'][$values['p_entity_id']]['p_entity_id']=$values['p_entity_id'];
-                               
$values['p'][$values['p_entity_id']]['p_cat_id']=$values['p_cat_id'];
-                               
$values['p'][$values['p_entity_id']]['p_cat_name'] = $category['name'];
-                       }
-                       return $values;
-               }
-
-               /**
-               * Arrange attributes within groups
-               *
-               * @param string  $location    the name of the location of the 
attribute
-               * @param array   $attributes  the array of the attributes to be 
grouped
-               *
-               * @return array the grouped attributes
-               */
-
-               public function get_attribute_groups($location, $attributes = 
array())
-               {
-                       return $this->custom->get_attribute_groups('property', 
$location, $attributes);
-               }
-
-               function save($values,$values_attribute='',$action='')
-               {
-
-                       $values['start_date']   = 
$this->bocommon->date_to_timestamp($values['start_date']);
-                       $values['end_date']     = 
$this->bocommon->date_to_timestamp($values['end_date']);
-                       $values['termination_date']     = 
$this->bocommon->date_to_timestamp($values['termination_date']);
-
-                       if(is_array($values_attribute))
-                       {
-                               $values_attribute = 
$this->custom->convert_attribute_save($values_attribute);
-                       }
-
-                       if ($action=='edit')
-//                     if ($values['r_agreement_id'])
-                       {
-                               if ($values['r_agreement_id'] != 0)
-                               {
-                                       
$receipt=$this->so->edit($values,$values_attribute);
-                               }
-                       }
-                       else
-                       {
-                               $receipt = 
$this->so->add($values,$values_attribute);
-                       }
-                       return $receipt;
-               }
-
-               function save_item($values,$values_attribute='')
-               {
-
-                       if($values['start_date'])
-                       {
-                               $values['start_date']   = 
$this->bocommon->date_to_timestamp($values['start_date']);
-                       }
-
-                       if($values['start_date'])
-                       {
-                               $values['end_date']     = 
$this->bocommon->date_to_timestamp($values['end_date']);
-                       }
-
-                       while (is_array($values['location']) && list(,$value) = 
each($values['location']))
-                       {
-                               if($value)
-                               {
-                                       $location[] = $value;
-                               }
-                       }
-
-                       $values['location_code'address@hidden("-", $location);
-
-                       if(is_array($values_attribute))
-                       {
-                               $values_attribute = 
$this->custom->convert_attribute_save($values_attribute);
-                       }
-
-                       if ($values['id'])
-                       {
-                               if ($values['id'] != 0)
-                               {
-                                       
$receipt=$this->so->edit_item($values,$values_attribute);
-                               }
-                       }
-                       else
-                       {
-                               $receipt = 
$this->so->add_item($values,$values_attribute);
-                       }
-                       return $receipt;
-               }
-
-
-               function update_item_history($values)
-               {
-                       if($values['start_date'])
-                       {
-                               $values['start_date']   = 
$this->bocommon->date_to_timestamp($values['start_date']);
-                       }
-
-                       if($values['start_date'])
-                       {
-                               $values['end_date']     = 
$this->bocommon->date_to_timestamp($values['end_date']);
-                       }
-
-                       $values['date'] = 
$this->bocommon->date_to_timestamp($values['date']);
-
-                       return $this->so->update_item_history($values);
-               }
-
-               function delete_last_index($r_agreement_id,$id)
-               {
-                       $this->so->delete_last_index($r_agreement_id,$id);
-               }
-
-
-               function delete_item($r_agreement_id,$item_id)
-               {
-                       $this->so->delete_item($r_agreement_id,$item_id);
-               }
-
-               function delete($r_agreement_id='')
-               {
-                       $this->so->delete($r_agreement_id);
-               }
-
-               function read_attrib($type_id='')
-               {
-                       $attrib = $this->so->read_attrib(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'allrows'=>$this->allrows));
-
-                       for ($i=0; $i<count($attrib); $i++)
-                       {
-                               $attrib[$i]['datatype'] = 
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
-                       }
-
-                       $this->total_records = $this->so->total_records;
-
-                       return $attrib;
-               }
-
-
-               function column_list($selected='',$allrows='')
-               {
-                       if(!$selected)
-                       {
-                               
$selected=$GLOBALS['phpgw_info']['user']['preferences']['property']['r_agreement_columns'];
-                       }
-                       $filter = array('list' => ''); // translates to "list 
IS NULL"
-                       $columns = 
$this->custom->find('property','.r_agreement', 0, '','','',true, false, 
$filter);
-                       
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-                       return $column_list;
-               }
-
-               function request_next_id()
-               {
-                               return $this->so->request_next_id();
-               }
-
-               function get_rental_type_list($selected = '')
-               {
-                       $input_list[0]['id'] = 1;
-                       $input_list[0]['name'] = lang('plain');
-                       $input_list[1]['id'] = 2;
-                       $input_list[1]['name'] = lang('Floor common');
-                       $input_list[2]['id'] = 3;
-                       $input_list[2]['name'] = lang('Building common');
-                       $input_list[3]['id'] = 4;
-                       $input_list[3]['name'] = lang('Shared use');
-
-                       $rental_type_list= 
$this->bocommon->select_list($selected,$input_list);
-
-                       return $rental_type_list;
-               }
-
-               function get_rental_type_list2($selected = '')
-               {
-                       $rental_type = array(
-                       1 => lang('plain'),
-                       2 => lang('Floor common'),
-                       3 => lang('Building common'),
-                       4 => lang('Shared use'),
-                       );
-
-                       return $rental_type[$selected];
-               }
-
-               function read_common($id)
-               {
-                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-                       $values = $this->so->read_common($id);
-
-                       $this->total_records = $this->so->total_records;
-
-                       for ($i=0; $i<count($values); $i++)
-                       {
-                               $values[$i]['from_date']  = 
$GLOBALS['phpgw']->common->show_date($values[$i]['from_date'],$dateformat);
-                               $values[$i]['to_date']  = 
$GLOBALS['phpgw']->common->show_date($values[$i]['to_date'],$dateformat);
-                       }
-
-
-                       return $values;
-               }
-
-               function read_single_common($data)
-               {
-                       $values = $this->so->read_single_common($data);
-
-                       return $values;
-               }
-               function read_common_history($data)
-               {
-                       $values = $this->so->read_common_history($data);
-                       $this->total_records = $this->so->total_records;
-                       for ($i=0; $i<count($values); $i++)
-                       {
-                               $values[$i]['from_date']  = 
$GLOBALS['phpgw']->common->show_date($values[$i]['from_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               $values[$i]['to_date']  = 
$GLOBALS['phpgw']->common->show_date($values[$i]['to_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                       }
-
-                       return $values;
-               }
-
-               function save_common($values)
-               {
-                       if($values['start_date'])
-                       {
-                               $values['start_date']   = 
$this->bocommon->date_to_timestamp($values['start_date']);
-                       }
-
-                       if($values['start_date'])
-                       {
-                               $values['end_date']     = 
$this->bocommon->date_to_timestamp($values['end_date']);
-                       }
-
-                       if ($values['c_id'])
-                       {
-                               if ($values['c_id'] != 0)
-                               {
-                                       
$receipt=$this->so->add_common_history($values);
-                               }
-                       }
-                       else
-                       {
-                               $receipt = $this->so->add_common($values);
-                       }
-                       return $receipt;
-               }
-               function delete_common_h($r_agreement_id,$c_id,$id)
-               {
-                       $this->so->delete_common_h($r_agreement_id,$c_id,$id);
-               }
-       }
-

Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php       2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.menu.inc.php       2010-11-13 17:15:50 UTC (rev 
6588)
@@ -166,6 +166,11 @@
                                                'text'  => lang('Accounting 
Categories'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uicategory.index', 'type' => 'b_account') )
                                        ),
+                                       'budget_account'        => array
+                                       (
+                                               'text'  => lang('budget 
account'),
+                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uicategory.index', 'type' => 'budget_account') )
+                                       ),
                                        'accounting_dimb'       => array
                                        (
                                                'text'  => lang('Accounting dim 
b'),
@@ -224,23 +229,7 @@
                                        (
                                                'text'  => lang('service 
agreement item Attributes'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute', 'appname' => 'property', 'location' 
=>'.s_agreement.detail', 'menu_selection' => 
'admin::property::agreement::service_agree_item_attribs') )
-                                       ),
-                                       'rental_agree_cats'     => array
-                                       (
-                                               'text'  => lang('rental 
agreement categories'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uicategory.index', 'type' => 'r_agreement') )
-                                       ),
-                                       'rental_agree_attribs'  => array
-                                       (
-                                               'text'  => lang('rental 
agreement Attributes'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute', 'appname' => 'property', 'location' 
=>'.r_agreement', 'menu_selection' => 
'admin::property::agreement::rental_agree_attribs') )
-                                       ),
-                                       'rental_agree_item_attribs'     => array
-                                       (
-                                               'text'  => lang('rental 
agreement item Attributes'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute', 'appname' => 'property', 'location' 
=>'.r_agreement.detail', 'menu_selection' => 
'admin::property::agreement::rental_agree_item_attribs') )
-                                       ),
-
+                                       )
                                );
 
                                foreach ( $locations as $location )
@@ -447,7 +436,7 @@
                                        'accounting'    => array
                                        (
                                                'text'  => lang('Accounting'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uib_account.index') ),
+                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uicategory.index', 'type' => 'budget_account') ),
                                                'children'      => 
$admin_children_accounting
                                        ),
                                        'admin_async'   => array
@@ -725,10 +714,10 @@
                                                        'url'   =>      
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiinvoice.consume')),
                                                        'text'  => 
lang('consume')
                                                ),
-                                               'budget'        => array
+                                               'budget_account'        => array
                                                (
-                                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.index')),
-                                                       'text'  => lang('Budget 
account')
+                                                       'text'  => lang('budget 
account'),
+                                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uicategory.index', 'type' => 'budget_account') )
                                                ),
                                                'vendor'        => array
                                                (
@@ -825,11 +814,6 @@
                                                        'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uis_agreement.index')),
                                                        'text'  => 
lang('Service')
                                                ),
-                                               'rental'        => array
-                                               (
-                                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.index')),
-                                                       'text'  => 
lang('Rental')
-                                               ),
                                                'alarm'         => array
                                                (
                                                        'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uialarm.list_alarm')),

Modified: trunk/property/inc/class.soXport.inc.php
===================================================================
--- trunk/property/inc/class.soXport.inc.php    2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.soXport.inc.php    2010-11-13 17:15:50 UTC (rev 
6588)
@@ -251,18 +251,21 @@
                                                false,
                                                $fields['item_type'],
                                                $fields['item_id'],
-                                               $fields['external_ref']
+                                               $fields['external_ref'],
+                                               isset($fields['currency']) && 
$fields['currency'] ? $fields['currency'] : 'NOK',
+                                               
$this->db->money_format($fields['belop']),
+                                               
$this->db->money_format($fields['godkjentbelop'])
                                                );
 
-                                       $bilagsnr       = $fields['bilagsnr'];
+                                       $bilagsnr       = 
(int)$fields['bilagsnr'];
 
                                        $values = 
$this->db->validate_insert($values);
 
                                        $sql= "INSERT INTO fm_ecobilag 
(project_id,kostra_id,pmwrkord_code,bilagsnr,splitt,kildeid,kidnr,typeid,fakturadato,"
                                        . " 
forfallsdato,regtid,artid,spvend_code,dimb,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
                                        . " 
fakturanr,spbudact_code,loc1,dima,dimd,mvakode,periode,merknad,oppsynsigndato,saksigndato,"
-                                       . " 
budsjettsigndato,utbetalingsigndato,item_type,item_id,external_ref, 
belop,godkjentbelop)"
-                                       . " VALUES ($values," . 
$this->db->money_format($fields['belop']) . "," . 
$this->db->money_format($fields['godkjentbelop']) . ")";
+                                       . " 
budsjettsigndato,utbetalingsigndato,item_type,item_id,external_ref,currency,belop,godkjentbelop)"
+                                       . " VALUES ({$values})";
 
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
@@ -270,7 +273,7 @@
                                }
                        }
 
-                       $this->db->query("UPDATE fm_idgenerator set value 
=$bilagsnr WHERE name = 'Bilagsnummer'");
+                       $this->db->query("UPDATE fm_idgenerator set value = 
{$bilagsnr} WHERE name = 'Bilagsnummer'");
 
                        $this->db->transaction_commit();
 

Deleted: trunk/property/inc/class.sob_account.inc.php
===================================================================
--- trunk/property/inc/class.sob_account.inc.php        2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.sob_account.inc.php        2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,157 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_sob_account
-       {
-               function __construct()
-               {
-                       $this->account  =       
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->db           = & $GLOBALS['phpgw']->db;
-                       $this->join                     = & $this->db->join;
-                       $this->like                     = & $this->db->like;
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               $start          = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
-                               $query          = 
isset($data['query'])?$data['query']:'';
-                               $sort           = isset($data['sort']) && 
$data['sort'] ? $data['sort']:'DESC';
-                               $order          = 
isset($data['order'])?$data['order']:'';
-                               $allrows        = 
isset($data['allrows'])?$data['allrows']:'';
-                       }
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $order $sort";
-
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by id asc';
-                       }
-
-                       $table = 'fm_b_account';
-
-                       if($query)
-                       {
-                               $query = $this->db->db_addslashes($query);
-                               $querymethod = " where id $this->like 
'%$query%' or descr $this->like '%$query%'";
-                       }
-
-                       $sql = "SELECT * FROM $table $querymethod";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->db->num_rows();
-
-                       if(!$allrows)
-                       {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
-                       }
-
-                       while ($this->db->next_record())
-                       {
-                               $b_account[] = array
-                               (
-                                       'id'    => $this->db->f('id'),
-                                       'descr'                 => 
$this->db->f('descr')
-                               );
-                       }
-                       return $b_account;
-               }
-
-               function read_single($id)
-               {
-
-                       $table = 'fm_b_account';
-
-                       $sql = "SELECT * FROM $table  where id='$id'";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       if ($this->db->next_record())
-                       {
-                               $b_account['id']                = 
$this->db->f('id');
-                               $b_account['descr']             = 
$this->db->f('descr');
-                               $b_account['cat_id']            = 
$this->db->f('category');
-                               $b_account['responsible']       = 
$this->db->f('responsible');
-
-                               return $b_account;
-                       }
-               }
-
-               function add($b_account)
-               {
-                       $table = 'fm_b_account';
-
-                       $b_account['descr'] = 
$this->db->db_addslashes($b_account['descr']);
-
-                       $this->db->query("INSERT INTO $table (id, 
descr,category,responsible) "
-                               . "VALUES ('" . $b_account['id'] . "','" . 
$b_account['descr']. "','" .$b_account['cat_id'] . "','" . 
$b_account['responsible'] . "')",__LINE__,__FILE__);
-
-                       $receipt['message'][]=array('msg'=>lang('budget account 
%1 has been saved',$b_account['id']));
-                       return $receipt;
-               }
-
-               function edit($b_account)
-               {
-
-                       $table = 'fm_b_account';
-
-                       $b_account['descr'] = 
$this->db->db_addslashes($b_account['descr']);
-
-                       $this->db->query("UPDATE $table set"
-                                       . " descr='" . $b_account['descr'] . 
"',"
-                                       . "responsible=" . 
$b_account['responsible'] . ","
-                                       . "category=" . 
(int)$b_account['cat_id']
-                                       . " WHERE id='" . $b_account['id']. 
"'",__LINE__,__FILE__);
-
-
-                       $receipt['message'][]=array('msg'=>lang('budget account 
%1 has been edited',$b_account['id']));
-                       return $receipt;
-               }
-
-               function delete($id)
-               {
-                       $table = 'fm_b_account';
-
-                       $this->db->query("DELETE FROM $table WHERE id='" . $id 
. "'",__LINE__,__FILE__);
-               }
-       }
-

Modified: trunk/property/inc/class.socategory.inc.php
===================================================================
--- trunk/property/inc/class.socategory.inc.php 2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.socategory.inc.php 2010-11-13 17:15:50 UTC (rev 
6588)
@@ -556,27 +556,6 @@
                                                'menu_selection' => 
'admin::property::request_condition'
                                        );
                                        break;
-                               case 'r_agreement':
-                                       $info = array
-                                       (
-                                               'table' => 
'fm_r_agreement_category',
-                                               'id'                            
=> array('name' => 'id', 'type' => 'int'),
-                                               'fields'                        
=> array
-                                               (
-                                                       array
-                                                       (
-                                                               'name' => 
'descr',
-                                                               'descr' => 
lang('descr'),
-                                                               'type' => 
'varchar'
-                                                       )
-                                               ),
-                                               'edit_msg'      => lang('edit'),
-                                               'add_msg'       => lang('add'),
-                                               'name'          => '',
-                                               'acl_location' => '.admin',
-                                               'menu_selection' => 
'admin::property::agreement::rental_agree_cats'
-                                       );
-                                       break;
                                case 'b_account':
                                        $info = array
                                        (
@@ -782,6 +761,78 @@
                                                'menu_selection'        => 
'admin::property::unit'
                                        );
                                        break;
+                               case 'budget_account':
+                                       $info = array
+                                       (
+                                               'table'                         
=> 'fm_b_account',
+                                               'id'                            
=> array('name' => 'id', 'type' => 'varchar'),
+                                               'fields'                        
=> array
+                                               (
+                                                       array
+                                                       (
+                                                               'name' => 
'descr',
+                                                               'descr' => 
lang('descr'),
+                                                               'type' => 
'varchar',
+                                                               'nullable'      
=> false,
+                                                               'size'          
=> 60
+                                                       ),
+                                                       array
+                                                       (
+                                                               'name'          
        => 'category',
+                                                               'descr'         
        => lang('category'),
+                                                               'type'          
        => 'select',
+                                                               'nullable'      
        => false,
+                                                               'values_def'    
=> array
+                                                               (
+                                                                       
'valueset'              => false,
+                                                                       
'method'                => 'property.bocategory.get_list',
+                                                                       
'method_input'  => array('type' => 'b_account', 'selected' => 
'##category##')//b_account_category
+                                                               )
+                                                       ),
+                                                       array
+                                                       (
+                                                               'name'          
=> 'mva',
+                                                               'descr'         
=> lang('tax code'),
+                                                               'type'          
=> 'int',
+                                                               'nullable'      
=> true,
+                                                               'size'          
=> 4
+                                                       ),
+                                                       array
+                                                       (
+                                                               'name'          
        => 'responsible',
+                                                               'descr'         
        => lang('responsible'),
+                                                               'type'          
        => 'select',
+                                                               'values_def'    
=> array
+                                                               (
+                                                                       
'valueset'              => false,
+                                                                       
'method'                => 'property.bocommon.get_user_list_right2',
+                                                                       
'method_input'  => array('selected' => '##responsible##', 'right' => 128, 
'acl_location' => '.invoice')
+                                                               )
+                                                       ),
+                                                       array
+                                                       (
+                                                               'name' => 
'active',
+                                                               'descr' => 
lang('active'),
+                                                               'type' => 
'checkbox',
+                                                               'default' => 
'checked'
+                                                       ),
+                                               ),
+                                               'edit_msg'                      
=> lang('edit'),
+                                               'add_msg'                       
=> lang('add'),
+                                               'name'                          
=> lang('budget account'),
+                                               'acl_location'          => 
'.b_account',
+                                               'menu_selection'        => 
'admin::property::responsibility_role',
+                                               'default'                       
=> array
+                                               (
+                                                       'user_id'               
=> array('add'  => '$this->account'),
+                                                       'entry_date'    => 
array('add'  => 'time()'),
+                                                       'modified_date' => 
array('edit' => 'time()'),
+                                               ),
+                                               'check_grant'           => false
+                                       );
+
+                                       break;
+
 //-------- ID type auto
                                case 'order_dim1':
                                        $info = array

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.soinvoice.inc.php  2010-11-13 17:15:50 UTC (rev 
6588)
@@ -107,7 +107,7 @@
 
                        if ($user_lid=='none' || !$user_lid):
                        {
-                               return;
+                               return array();
                        }
                        elseif ($user_lid!='all'):
                        {
@@ -210,7 +210,8 @@
                                        );
                        }
 
-                       $invoice = array();
+                       $invoice        = array();
+
                        if ($temp)
                        {
                                $role= $this->check_role();
@@ -219,13 +220,13 @@
                                {
                                        $voucher_id = 
$invoice_temp['voucher_id'];
 
-                                       $sql = "SELECT 
spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+                                       $sql = "SELECT 
pmwrkord_code,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
                                        . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota "
-                                       . " from $table $this->join fm_vendor 
ON fm_vendor.id = $table.spvend_code WHERE bilagsnr = $voucher_id "
-                                       . " group by 
bilagsnr,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota,currency "
+                                       . " FROM {$table} {$this->join} 
fm_vendor ON fm_vendor.id = {$table}.spvend_code WHERE bilagsnr = {$voucher_id} 
"
+                                       . " GROUP BY 
bilagsnr,pmwrkord_code,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
                                        . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota ";
+                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota,currency";
 
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
@@ -290,6 +291,8 @@
                                        $invoice[$i]['type']                    
                = $art_list[$this->db->f('artid')];
                                        $invoice[$i]['kidnr']                   
                = $this->db->f('kidnr');
                                        $invoice[$i]['kreditnota']              
                = $this->db->f('kreditnota');
+                                       $invoice[$i]['currency']                
                = $this->db->f('currency');
+                                       $invoice[$i]['order_id']                
                = $this->db->f('pmwrkord_code');
                                        $invoice[$i]['amount']                  
                = $invoice_temp['amount'];
                                        $invoice[$i]['num_days']                
                = 
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
                                        $invoice[$i]['timestamp_voucher_date']  
= $timestamp_voucher_date;
@@ -324,11 +327,11 @@
                {
                        if(is_array($data))
                        {
-                               $start          = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
+                               $start          = isset($data['start']) && 
$data['start'] ? (int)$data['start'] : 0;
                                $filter         = isset($data['filter']) ? 
$data['filter'] : 'none';
                                $sort           = isset($data['sort']) ? 
$data['sort'] : 'DESC';
                                $order          = isset($data['order']) ? 
$data['order'] : '';
-                               $voucher_id     = isset($data['voucher_id']) && 
$data['voucher_id'] ? $data['voucher_id'] : 0;
+                               $voucher_id     = isset($data['voucher_id']) && 
$data['voucher_id'] ? (int)$data['voucher_id'] : 0;
                                $paid           = isset($data['paid']) ? 
$data['paid'] : '';
                        }
 
@@ -356,7 +359,8 @@
                                $filtermethod = " WHERE ( bilagsnr= 
'$voucher_id')";
                        }
 
-                       $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,fm_workorder.claim_issued,
 fm_workorder.paid_percent, project_group FROM $table"
+                       $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,"
+                       . "fm_workorder.claim_issued, 
fm_workorder.paid_percent, project_group FROM $table"
                        . " $this->left_join fm_workorder ON fm_workorder.id = 
$table.pmwrkord_code"
                        . " $this->left_join fm_project ON 
fm_workorder.project_id = fm_project.id"
                        . " $this->join fm_vendor ON $table.spvend_code = 
fm_vendor.id $filtermethod";
@@ -392,7 +396,8 @@
                                        'vendor'                                
=> $this->db->f('org_name'),
                                        'paid_percent'                  => 
$this->db->f('paid_percent'),
                                        'project_group'                 => 
$this->db->f('project_group'),
-                                       'external_ref'                  => 
$this->db->f('external_ref')
+                                       'external_ref'                  => 
$this->db->f('external_ref'),
+                                       'currency'                              
=> $this->db->f('currency')
                                );
 
                                $i++;
@@ -913,29 +918,30 @@
                        $values = array();
                        while ($this->db->next_record())
                        {
-                               $values[] = Array(
-
-                               'location_code'         => $this->db->f('id'),
-                               'art'                   => 
$this->db->f('artid'),
-                               'type'                  => 
$this->db->f('typeid'),
-                               'dim_a'                 => $this->db->f('dima'),
-                               'dim_b'                 => $this->db->f('dimb'),
-                               'dim_d'                 => $this->db->f('dimd'),
-                               'tax'                   => 
$this->db->f('mvakode'),
-                               'invoice_id'            => 
$this->db->f('fakturanr'),
-                               'kid_nr'                => 
$this->db->f('kidnr'),
-                               'vendor_id'             => 
$this->db->f('spvend_code'),
-                               'janitor'               => 
$this->db->f('oppsynsmannid'),
-                               'supervisor'            => 
$this->db->f('saksbehandlerid'),
-                               'budget_responsible'    => 
$this->db->f('budsjettansvarligid'),
-                               'invoice_date'          => 
$this->db->f('fakturadato'),
-                               'project_id'            => 
$this->db->f('project_id'),
-                               'payment_date'          => 
$this->db->f('forfallsdato'),
-                               'merknad'               => 
$this->db->f('merknad'),
-                               'b_account_id'          => 
$this->db->f('spbudact_code'),
-                               'amount'                => 
$this->db->f('belop'),
-                               'order'                 => 
$this->db->f('pmwrkord_code'),
-                               'kostra_id'             => 
$this->db->f('kostra_id'),
+                               $values[] = array
+                               (
+                                       'location_code'         => 
$this->db->f('id'),
+                                       'art'                           => 
$this->db->f('artid'),
+                                       'type'                          => 
$this->db->f('typeid'),
+                                       'dim_a'                         => 
$this->db->f('dima'),
+                                       'dim_b'                         => 
$this->db->f('dimb'),
+                                       'dim_d'                         => 
$this->db->f('dimd'),
+                                       'tax'                           => 
$this->db->f('mvakode'),
+                                       'invoice_id'            => 
$this->db->f('fakturanr'),
+                                       'kid_nr'                        => 
$this->db->f('kidnr'),
+                                       'vendor_id'                     => 
$this->db->f('spvend_code'),
+                                       'janitor'                       => 
$this->db->f('oppsynsmannid'),
+                                       'supervisor'            => 
$this->db->f('saksbehandlerid'),
+                                       'budget_responsible'=> 
$this->db->f('budsjettansvarligid'),
+                                       'invoice_date'          => 
$this->db->f('fakturadato'),
+                                       'project_id'            => 
$this->db->f('project_id'),
+                                       'payment_date'          => 
$this->db->f('forfallsdato'),
+                                       'merknad'                       => 
$this->db->f('merknad'),
+                                       'b_account_id'          => 
$this->db->f('spbudact_code'),
+                                       'amount'                        => 
$this->db->f('belop'),
+                                       'order'                         => 
$this->db->f('pmwrkord_code'),
+                                       'kostra_id'                     => 
$this->db->f('kostra_id'),
+                                       'currency'                      => 
$this->db->f('currency')
                                );
                        }
 //_debug_array($values);
@@ -1191,4 +1197,3 @@
                        return $this->db->f('cnt');
                }
        }
-

Modified: trunk/property/inc/class.solookup.inc.php
===================================================================
--- trunk/property/inc/class.solookup.inc.php   2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.solookup.inc.php   2010-11-13 17:15:50 UTC (rev 
6588)
@@ -207,12 +207,19 @@
                        $where = 'WHERE';
 
                        $filtermethod = '';
-                       if($role != 'group' && $parent)
+
+                       if($role != 'group')
                        {
-                               $filtermethod = " WHERE category = {$parent}";
+                               $filtermethod .= " {$where} active = 1";
                                $where = 'AND';
                        }
 
+                       if($parent)
+                       {
+                               $filtermethod .= " {$where} category = 
{$parent}";
+                               $where = 'AND';
+                       }
+
                        if($query)
                        {
                                $query = $this->db->db_addslashes($query);
@@ -288,14 +295,14 @@
 
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db->num_rows();
-                       if(!$allrows)
-                       {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       if(!$allrows)
+                       {
+                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
+                       else
+                       {
+                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       }
 
                        $street = array();
                        while ($this->db->next_record())
@@ -344,14 +351,14 @@
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db->num_rows();
 
-                       if(!$allrows)
-                       {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       if(!$allrows)
+                       {
+                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
+                       else
+                       {
+                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       }
 
                        $tenant = array();
                        while ($this->db->next_record())

Deleted: trunk/property/inc/class.sor_agreement.inc.php
===================================================================
--- trunk/property/inc/class.sor_agreement.inc.php      2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.sor_agreement.inc.php      2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,1290 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage agreement
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_sor_agreement
-       {
-               var $role;
-
-               function __construct()
-               {
-                       $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->db           = & $GLOBALS['phpgw']->db;
-                       $this->db2          = clone($this->db);
-
-                       $this->join                     = $this->db->join;
-                       $this->left_join        = $this->db->left_join;
-                       $this->like                     = $this->db->like;
-               }
-
-               function select_vendor_list()
-               {
-                       return ;
-                       $table = 'fm_r_agreement';
-                       $this->db->query("SELECT vendor_id,org_name FROM $table 
$this->join fm_vendor on fm_r_agreement.vendor_id=fm_vendor.id GROUP BY 
org_name,vendor_id ");
-
-                       $i = 0;
-                       while ($this->db->next_record())
-                       {
-                               $vendor[$i]['id']                               
= $this->db->f('vendor_id');
-                               $vendor[$i]['name']                             
= stripslashes($this->db->f('org_name'));
-                               $i++;
-                       }
-                       return $vendor;
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               $start                  = 
(isset($data['start'])?$data['start']:0);
-                               $filter                 = 
(isset($data['filter'])?$data['filter']:'none');
-                               $query                  = 
(isset($data['query'])?$data['query']:'');
-                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order                  = 
(isset($data['order'])?$data['order']:'');
-                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:'');
-                               $customer_id            = 
(isset($data['customer_id'])?$data['customer_id']:'');
-                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
-                               $member_id              = 
(isset($data['member_id'])?$data['member_id']:0);
-                               $r_agreement_id = 
(isset($data['r_agreement_id'])?$data['r_agreement_id']:'');
-                               $detail                 = 
(isset($data['detail'])?$data['detail']:'');
-                               $loc1                   = 
(isset($data['loc1'])?$data['loc1']:'');
-
-                       }
-
-                       $choice_table = 'phpgw_cust_choice';
-                       $attribute_table = 'phpgw_cust_attribute';
-
-                       if(!$detail)
-                       {
-                               $entity_table = 'fm_r_agreement';
-                               $category_table = 'fm_r_agreement_category';
-                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', '.r_agreement'); 
-                               $attribute_filter = " location_id = 
{$location_id}";
-
-                               $paranthesis .='(';
-                               $joinmethod .= " $this->join $category_table ON 
( $entity_table.category =$category_table.id))";
-
-                               $cols = $entity_table . 
".*,$category_table.descr as category";
-
-/*                             if($loc1)
-                               {
-                                       $paranthesis .='(';
-                                       $joinmethod .= " $this->join 
fm_r_agreement_item ON ( $entity_table.id =fm_r_agreement_item.agreement_id))";
-
-
-                                       $cols .= ",location_code";
-                               }
-`*/
-//                             $cols .= ",org_name";
-//                             $paranthesis .='(';
-//                             $joinmethod .= " $this->join fm_tenant ON ( 
$entity_table.customer_id =fm_tenant.id))";
-
-                               $cols_return[]                  = 'id';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'id';
-                               $uicols['descr'][]              = lang('ID');
-                               $uicols['statustext'][]         = lang('ID');
-
-                               $cols_return[]                  = 'name';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'name';
-                               $uicols['descr'][]              = lang('name');
-                               $uicols['statustext'][]         = lang('name');
-
-                               $cols_return[]                  = 
'customer_name';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 
'customer_name';
-                               $uicols['descr'][]              = 
lang('customer');
-                               $uicols['statustext'][]         = 
lang('customer');
-
-                               $cols_return[]                  = 'category';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'category';
-                               $uicols['descr'][]              = 
lang('category');
-                               $uicols['statustext'][]         = 
lang('category');
-
-                               $cols_return[]                  = 'start_date';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'start_date';
-                               $uicols['descr'][]              = lang('start');
-                               $uicols['statustext'][]         = lang('start 
date');
-
-                               $cols_return[]                  = 'end_date';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'end_date';
-                               $uicols['descr'][]              = lang('end');
-                               $uicols['statustext'][]         = lang('end 
date');
-
-                       }
-                       else
-                       {
-                               $allrows=true;
-                               $entity_table = 'fm_r_agreement_item';
-                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', '.r_agreement.detail'); 
-                               $attribute_filter = " location_id = 
{$location_id}";
-
-                               $paranthesis .='(';
-                               $joinmethod .= " $this->join  
fm_r_agreement_item_history ON ( $entity_table.agreement_id 
=fm_r_agreement_item_history.agreement_id AND $entity_table.id 
=fm_r_agreement_item_history.item_id))";
-
-
-
-                               $cols = "$entity_table.*, 
fm_r_agreement_item_history.cost,fm_r_agreement_item_history.id as 
index_count,fm_r_agreement_item_history.index_date,fm_r_agreement_item_history.item_id,fm_r_agreement_item_history.this_index,
 rental_type_id";
-
-                               $cols_return[]                  = 
'agreement_id';
-                               $uicols['input_type'][]         = 'hidden';
-                               $uicols['name'][]               = 
'agreement_id';
-                               $uicols['descr'][]              = 
lang('agreement_id');
-                               $uicols['statustext'][]         = 
lang('agreement_id');
-
-                               $cols_return[]                  = 'item_id';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'item_id';
-                               $uicols['descr'][]              = lang('ID');
-                               $uicols['statustext'][]         = lang('ID');
-
-                               $cols_return[]                  = 'id';
-                               $uicols['input_type'][]         = 'hidden';
-                               $uicols['name'][]               = 'id';
-                               $uicols['descr'][]                      = false;
-                               $uicols['statustext'][]         = false;
-
-                               $cols_return[]                  = 
'location_code';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 
'location_code';
-                               $uicols['descr'][]              = 
lang('location');
-                               $uicols['statustext'][]         = 
lang('location');
-
-                               $cols_return[]                  = 'address';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'address';
-                               $uicols['descr'][]              = 
lang('address');
-                               $uicols['statustext'][]         = 
lang('address');
-
-/*                             $cols_return[]                  = 'p_num';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'p_num';
-                               $uicols['descr'][]              = lang('entity 
num');
-                               $uicols['statustext'][]         = lang('entity 
num');
-*/
-                               $cols_return[]                  = 'cost';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'cost';
-                               $uicols['descr'][]              = lang('cost');
-                               $uicols['statustext'][]         = lang('cost');
-
-                               $cols_return[]                  = 'this_index';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'this_index';
-                               $uicols['descr'][]              = lang('index');
-                               $uicols['statustext'][]         = lang('index');
-
-                               $cols_return[]                  = 'index_count';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'index_count';
-                               $uicols['descr'][]              = 
lang('index_count');
-                               $uicols['statustext'][]         = 
lang('index_count');
-
-                               $cols_return[]                  = 'index_date';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 'index_date';
-                               $uicols['descr'][]              = lang('date');
-                               $uicols['statustext'][]         = lang('date');
-
-                               $cols_return[]                  = 
'rental_type_id';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]               = 
'rental_type_id';
-                               $uicols['descr'][]              = lang('rental 
type');
-                               $uicols['statustext'][]         = lang('rental 
type');
-                       }
-
-                       $from .= " FROM $paranthesis $entity_table ";
-
-                       $sql = "SELECT $cols $from $joinmethod";
-
-                       $i      = count($uicols['name']);
-
-                       
$user_columns=$GLOBALS['phpgw_info']['user']['preferences']['property']['r_agreement_columns'
 . !!$r_agreement_id];
-                       $user_column_filter = '';
-                       if (isset($user_columns) AND is_array($user_columns) 
AND $user_columns[0])
-                       {
-                               $user_column_filter = " OR ($attribute_filter 
AND id IN (" . implode(',',$user_columns) .'))';
-                       }
-
-                       $this->db->query("SELECT * FROM $attribute_table WHERE 
list=1 AND $attribute_filter $user_column_filter ");
-
-                       while ($this->db->next_record())
-                       {
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]                       = 
$this->db->f('column_name');
-                               $uicols['descr'][]                      = 
$this->db->f('input_text');
-                               $uicols['statustext'][]         = 
$this->db->f('statustext');
-                               $uicols['datatype'][$i]         = 
$this->db->f('datatype');
-                               $cols_return_extra[]= array(
-                                       'name'  => $this->db->f('column_name'),
-                                       'datatype'      => 
$this->db->f('datatype'),
-                                       'attrib_id'     => $this->db->f('id')
-                               );
-
-                               $i++;
-                       }
-
-                       $this->uicols   = $uicols;
-
-//_debug_array($cols_return_extra);
-                       if ($order)
-                       {
-                               if ($order=='id')
-                               {
-                                       $ordermethod = " order by 
$entity_table.$order $sort";
-                               }
-                               else
-                               {
-                                       $ordermethod = " order by $order $sort";
-                               }
-                       }
-                       else
-                       {
-                               $ordermethod = " order by $entity_table.id 
DESC";
-                       }
-
-                       $where= 'WHERE';
-
-/*                     if ($filter=='all')
-                       {
-                               if (is_array($grants))
-                               {
-                                       while (list($user) = each($grants))
-                                       {
-                                               $public_user_list[] = $user;
-                                       }
-                                       reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
-
-                                       $where= 'AND';
-                               }
-
-                       }
-                       else
-                       {
-                               $filtermethod = " $where 
$entity_table.user_id=$filter ";
-                               $where= 'AND';
-                       }
-*/
-
-                       if ($r_agreement_id)
-                       {
-                               $filtermethod .= " $where 
$entity_table.agreement_id=$r_agreement_id AND current_index = 1";
-                               $where= 'AND';
-                       }
-
-                       if ($cat_id)
-                       {
-                               $filtermethod .= " $where 
$entity_table.category='$cat_id' ";
-                               $where= 'AND';
-                       }
-
-                       if ($customer_id)
-                       {
-                               $filtermethod .= " $where 
$entity_table.customer_id='$customer_id' ";
-                               $where= 'AND';
-                       }
-
-                       if ($member_id>0)
-                       {
-                               $filtermethod .= " $where 
$entity_table.member_of $this->like '%,$member_id,%' ";
-                               $where= 'AND';
-                       }
-
-                       if ($loc1)
-                       {
-                               $this->db->query("SELECT agreement_id FROM 
fm_r_agreement_item WHERE location_code $this->like '$loc1%' group by 
agreement_id");
-                               while ($this->db->next_record())
-                               {
-                                       $filter_id[]                    = 
$this->db->f('agreement_id');
-
-                               }
-
-                               if(is_array($filter_id))
-                               {
-                                       $filtermethod .= " $where 
$entity_table.id in (" . implode(',', $filter_id)  .")";
-                                       $where= 'AND';
-                               }
-                       }
-
-                       if ($status)
-                       {
-                               $filtermethod .= " $where 
$entity_table.status='$status' ";
-                               $where= 'AND';
-                       }
-
-
-                       if($query)
-                       {
-                               $query = preg_replace("/'/",'',$query);
-                               $query = preg_replace('/"/','',$query);
-
-                               $this->db->query("SELECT * FROM 
$attribute_table WHERE search=1 AND $attribute_filter");
-
-                               while ($this->db->next_record())
-                               {
-                                       if($this->db->f('datatype')=='V' || 
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
-                                       {
-                                               $querymethod[]= 
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
-                                       }
-                                       else
-                                       {
-                                               $querymethod[]= 
"$entity_table." . $this->db->f('column_name') . " = '$query'";
-                                       }
-                               }
-
-                               if (isset($querymethod) AND 
is_array($querymethod))
-                               {
-                                       $querymethod = " $where (" . implode (' 
OR ',$querymethod) . ')';
-                                       $where = 'AND';
-                               }
-                       }
-
-                       $sql .= " $filtermethod $querymethod";
-//echo $sql;
-
-                       $this->db2->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->db2->num_rows();
-                       if(!$allrows)
-                       {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
-                       }
-
-                       $j=0;
-                       $n=count($cols_return);
-//_debug_array($cols_return);
-
-                       $contacts                       = 
CreateObject('phpgwapi.contacts');
-
-                       while ($this->db->next_record())
-                       {
-                               for ($i=0;$i<$n;$i++)
-                               {
-                                       $r_agreement_list[$j][$cols_return[$i]] 
= stripslashes($this->db->f($cols_return[$i]));
-                                       $r_agreement_list[$j]['grants'] = 
(int)$grants[$this->db->f('user_id')];
-                               }
-
-                               for ($i=0;$i<count($cols_return_extra);$i++)
-                               {
-                                       $value='';
-                                       
$value=$this->db->f($cols_return_extra[$i]['name']);
-
-                                       
if(($cols_return_extra[$i]['datatype']=='R' || 
$cols_return_extra[$i]['datatype']=='LB') && $value)
-                                       {
-                                               $sql="SELECT value FROM 
$choice_table WHERE $attribute_filter AND attrib_id=" 
.$cols_return_extra[$i]['attrib_id']. "  AND id=" . $value;
-                                               $this->db2->query($sql);
-                                               $this->db2->next_record();
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='AB' && $value)
-                                       {
-                                               $contact_data   = 
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']]   = 
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
-
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='VENDOR' && $value)
-                                       {
-                                               $sql="SELECT org_name FROM 
fm_vendor where id=$value";
-                                               $this->db2->query($sql);
-                                               $this->db2->next_record();
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']] = 
$this->db2->f('org_name');
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='CH' && $value)
-                                       {
-                                               $ch= unserialize($value);
-
-                                               if (isset($ch) AND 
is_array($ch))
-                                               {
-                                                       for 
($k=0;$k<count($ch);$k++)
-                                                       {
-                                                               $sql="SELECT 
value FROM $choice_table WHERE $attribute_filter AND attrib_id=" 
.$cols_return_extra[$i]['attrib_id']. "  AND id=" . $ch[$k];
-                                                               
$this->db2->query($sql);
-                                                               while 
($this->db2->next_record())
-                                                               {
-                                                                       
$ch_value[]=$this->db2->f('value');
-                                                               }
-                                                       }
-                                                       
$r_agreement_list[$j][$cols_return_extra[$i]['name']] = @implode(",", 
$ch_value);
-                                                       unset($ch_value);
-                                               }
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='D' && $value)
-                                       {
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='timestamp' && $value)
-                                       {
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$value);
-                                       }
-                                       else 
if($cols_return_extra[$i]['datatype']=='link' && $value)
-                                       {
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']]= 
phpgw::safe_redirect($value);
-                                       }
-                                       else
-                                       {
-                                               
$r_agreement_list[$j][$cols_return_extra[$i]['name']]=$value;
-                                       }
-                               }
-
-                               $j++;
-                       }
-//html_print_r($r_agreement_list);
-                       return $r_agreement_list;
-               }
-
-               function read_prizing($data)
-               {
-                       if(is_array($data))
-                       {
-                               $r_agreement_id = 
(isset($data['r_agreement_id'])?$data['r_agreement_id']:0);
-                               $item_id        = 
(isset($data['item_id'])?$data['item_id']:0);
-                       }
-
-                       $entity_table = 'fm_r_agreement_item_history';
-
-                       $cols = 
"fm_r_agreement_item_history.cost,fm_r_agreement_item_history.id as 
index_count,"
-                               . " 
fm_r_agreement_item_history.index_date,fm_r_agreement_item_history.item_id,"
-                               . " 
fm_r_agreement_item_history.this_index,tenant_id,to_date,from_date";
-
-                       $cols_return[]                  = 'item_id';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'item_id';
-                       $uicols['descr'][]                      = lang('ID');
-                       $uicols['statustext'][]         = lang('ID');
-
-                       $cols_return[]                  = 'id';
-                       $uicols['input_type'][]         = 'hidden';
-                       $uicols['name'][]                       = 'id';
-                       $uicols['descr'][]                      = false;
-                       $uicols['statustext'][]         = false;
-
-                       $cols_return[]                  = 'cost';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'cost';
-                       $uicols['descr'][]                      = lang('cost');
-                       $uicols['statustext'][]         = lang('cost');
-
-                       $cols_return[]                  = 'this_index';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'this_index';
-                       $uicols['descr'][]                      = lang('index');
-                       $uicols['statustext'][]         = lang('index');
-
-                       $cols_return[]                  = 'index_count';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'index_count';
-                       $uicols['descr'][]                      = 
lang('index_count');
-                       $uicols['statustext'][]         = lang('index_count');
-
-                       $cols_return[]                  = 'index_date';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'index_date';
-                       $uicols['descr'][]                      = lang('entry 
date');
-                       $uicols['statustext'][]         = lang('entry date');
-
-                       $cols_return[]                  = 'from_date';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'from_date';
-                       $uicols['descr'][]                      = lang('from 
date');
-                       $uicols['statustext'][]         = lang('from date');
-
-                       $cols_return[]                  = 'to_date';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'to_date';
-                       $uicols['descr'][]                      = lang('to 
date');
-                       $uicols['statustext'][]         = lang('to date');
-
-                       $cols_return[]                  = 'tenant_id';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'tenant';
-                       $uicols['descr'][]                      = 
lang('Tenant');
-                       $uicols['statustext'][]         = lang('Tenant');
-
-                       $from .= " FROM $entity_table ";
-
-                       $sql = "SELECT $cols $from $joinmethod";
-
-
-                       $this->uicols   = $uicols;
-
-                       $ordermethod = " order by $entity_table.id ASC";
-
-                       $where= 'WHERE';
-
-
-                       if ($r_agreement_id)
-                       {
-                               $filtermethod .= " $where 
$entity_table.agreement_id=$r_agreement_id AND item_id=$item_id";
-                               $where= 'AND';
-                       }
-
-
-                       $sql .= " $filtermethod";
-//echo $sql;
-
-                       $this->db2->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->db2->num_rows();
-                       if(!$allrows)
-                       {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
-                       }
-
-                       $j=0;
-                       $n=count($cols_return);
-//_debug_array($cols_return);
-                       while ($this->db->next_record())
-                       {
-                               for ($i=0;$i<$n;$i++)
-                               {
-                                       $r_agreement_list[$j][$cols_return[$i]] 
= $this->db->f($cols_return[$i]);
-                                       $r_agreement_list[$j]['agreement_id'] = 
$r_agreement_id;
-                               }
-                               $j++;
-                       }
-//_debug_array($r_agreement_list);
-                       return $r_agreement_list;
-               }
-
-               function get_tenant_name($id)
-               {
-                       $this->db->query("SELECT first_name,last_name FROM 
fm_tenant WHERE id = $id");
-                       $this->db->next_record();
-                       return stripslashes($this->db->f('first_name')) . ' ' . 
stripslashes($this->db->f('last_name'));
-
-               }
-
-               function read_single($r_agreement_id, $values = array())
-               {
-                       $table = 'fm_r_agreement';
-
-                       $this->db->query("SELECT * from $table where 
id='$r_agreement_id'");
-
-                       if($this->db->next_record())
-                       {
-                               $values['id']                   = 
(int)$this->db->f('id');
-                               $values['entry_date']           = 
$this->db->f('entry_date');
-                               $values['cat_id']                       = 
$this->db->f('category');
-                               $values['member_of']            = 
explode(',',$this->db->f('member_of'));
-                               $values['cat_id']                       = 
$this->db->f('category');
-                               $values['start_date']           = 
$this->db->f('start_date');
-                               $values['end_date']             = 
$this->db->f('end_date');
-                               $values['termination_date']= 
$this->db->f('termination_date');
-                               $values['customer_id']          = 
$this->db->f('customer_id');
-                               $values['b_account_id'] = 
$this->db->f('account_id');
-                               $values['name']                 = 
stripslashes($this->db->f('name'));
-                               $values['descr']                        = 
stripslashes($this->db->f('descr'));
-                               $values['user_id']                      = 
$this->db->f('user_id');
-
-                               if ( isset($values['attributes']) && 
is_array($values['attributes']) )
-                               {
-                                       foreach ( $values['attributes'] as 
&$attr )
-                                       {
-                                               $attr['value']  = 
$this->db->f($attr['column_name']);
-                                       }
-                               }
-                       }
-
-                       return $values;
-               }
-
-               function read_single_item($data, $values = array())
-               {
-                       $table = 'fm_r_agreement_item';
-
-                       $r_agreement_id =$data['r_agreement_id'];
-                       $id =$data['id'];
-
-                       $this->db->query("SELECT * from $table where 
agreement_id=$r_agreement_id AND id=$id");
-
-                       if($this->db->next_record())
-                       {
-                               $values['agreement_id']                 = 
(int)$this->db->f('agreement_id');
-                               $values['id']                                   
= (int)$this->db->f('id');
-                               $values['entry_date']                   = 
$this->db->f('entry_date');
-                               $values['location_code']                = 
$this->db->f('location_code');
-                               $values['p_num']                                
= $this->db->f('p_num');
-                               $values['p_entity_id']                  = 
$this->db->f('p_entity_id');
-                               $values['p_cat_id']                             
= $this->db->f('p_cat_id');
-                               $values['cost']                                 
= $this->db->f('cost');
-                               $values['tenant_id']                    = 
$this->db->f('tenant_id');
-                               $values['rental_type_id']               = 
$this->db->f('rental_type_id');
-
-                               if ( isset($values['attributes']) && 
is_array($values['attributes']) )
-                               {
-                                       foreach ( $values['attributes'] as 
&$attr )
-                                       {
-                                               $attr['value']  = 
$this->db->f($attr['column_name']);
-                                       }
-                               }
-                       }
-                       return $values;
-               }
-
-               function add($r_agreement,$values_attribute='')
-               {
-//_debug_array($r_agreement);
-                       $table = 'fm_r_agreement';
-                       $r_agreement['name'] = 
$this->db->db_addslashes($r_agreement['name']);
-                       $r_agreement['descr'] = 
$this->db->db_addslashes($r_agreement['descr']);
-
-                       if($r_agreement['member_of'])
-                       {
-                               $r_agreement['member_of']=',' . 
implode(',',$r_agreement['member_of']) . ',';
-                       }
-
-
-                       $this->db->transaction_begin();
-                       $id = $this->db->next_id('fm_r_agreement');
-
-                       $vals[] = $id;
-                       $vals[] = $r_agreement['name'];
-                       $vals[] = $r_agreement['descr'];
-                       $vals[] = time();
-                       $vals[] = $r_agreement['cat_id'];
-                       $vals[] = $r_agreement['member_of'];
-                       $vals[] = $r_agreement['start_date'];
-                       $vals[] = $r_agreement['end_date'];
-                       $vals[] = $r_agreement['termination_date'];
-                       $vals[] = $r_agreement['customer_id'];
-                       $vals[] = $r_agreement['customer_name'];
-                       $vals[] = $r_agreement['b_account_id'];
-                       $vals[] = $this->account;
-
-                       if(isset($r_agreement['extra']) && 
is_array($r_agreement['extra']))
-                       {
-                               foreach ($r_agreement['extra'] as $input_name 
=> $value)
-                               {
-                                       if(isset($value) && $value)
-                                       {
-                                               $cols[] = $input_name;
-                                               $vals[] = $value;
-                                       }
-                               }
-                       }
-
-                       if (isset($values_attribute) AND 
is_array($values_attribute))
-                       {
-                               foreach($values_attribute as $entry)
-                               {
-                                       if($entry['value'])
-                                       {
-                                               $cols[] = $entry['name'];
-                                               $vals[] = $entry['value'];
-                                       }
-                               }
-                       }
-
-                       if($cols)
-                       {
-                               $cols   = "," . implode(",", $cols);
-                       }
-
-                       $vals   = $this->db->validate_insert($vals);
-
-                       $this->db->query("INSERT INTO $table 
(id,name,descr,entry_date,category,member_of,start_date,end_date,termination_date,customer_id,customer_name,account_id,user_id
 $cols) "
-                               . "VALUES ($vals)",__LINE__,__FILE__);
-
-//                     $this->db->query("INSERT INTO fm_orders (id,type) 
VALUES ($id,'r_agreement')");
-
-                       $receipt['r_agreement_id']= 
$id;//$this->db->get_last_insert_id($table,'id');
-
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been saved',$receipt['r_agreement_id']));
-
-                       $this->db->transaction_commit();
-                       return $receipt;
-               }
-
-               function add_item($values,$values_attribute='')
-               {
-//_debug_array($values);
-                       $table = 'fm_r_agreement_item';
-
-                       $cols[] = 'location_code';
-                       $vals[] = $values['location_code'];
-                       $cols[] = 'rental_type_id';
-                       $vals[] = $values['rental_type_id'];
-
-/*                     while (is_array($values['location']) && 
list($input_name,$value) = each($values['location']))
-                       {
-                               if($value)
-                               {
-                                       $cols[] = $input_name;
-                                       $vals[] = $value;
-                               }
-                       }
-*/
-                       if(isset($values['extra']) && 
is_array($values['extra']))
-                       {
-                               foreach ($values['extra'] as $input_name => 
$value)
-                               {
-                                       if(isset($value) && $value)
-                                       {
-                                               $cols[] = $input_name;
-                                               $vals[] = $value;
-                                       }
-                               }
-                       }
-
-                       if (isset($values_attribute) AND 
is_array($values_attribute))
-                       {
-                               foreach($values_attribute as $entry)
-                               {
-                                       if($entry['value'])
-                                       {
-                                               $cols[] = $entry['name'];
-                                               $vals[] = $entry['value'];
-                                       }
-                               }
-                       }
-
-                       if($values['street_name'])
-                       {
-                               $address[]= $values['street_name'];
-                               $address[]= $values['street_number'];
-                               $address = $this->db->db_addslashes(implode(" 
", $address));
-                       }
-
-                       if(!$address)
-                       {
-                               $address = 
$this->db->db_addslashes($values['location_name']);
-                       }
-
-                       $cols[] = 'address';
-                       $vals[] = $address;
-                       $cols[] = 'cost';
-                       $vals[] = $this->floatval($values['cost']);
-
-                       if($cols)
-                       {
-                               $cols   = "," . implode(",", $cols);
-                               $vals   = "," . 
$this->db->validate_insert($vals);
-                       }
-
-                       $this->db->transaction_begin();
-                       $id = 
$this->db->next_id($table,array('agreement_id'=>$values['r_agreement_id']));
-
-                       $this->db->query("INSERT INTO $table 
(id,agreement_id,entry_date,user_id $cols) "
-                               . "VALUES ($id," . $values['r_agreement_id'] 
."," . time()
-                               . "," . $this->account . " $vals)");
-
-
-                       $this->db->query("SELECT start_date FROM fm_r_agreement 
WHERE id=" . $values['r_agreement_id']);
-                       $this->db->next_record();
-
-                       if(!$values['start_date'])
-                       {
-                               $start_date     = $this->db->f('start_date');
-                       }
-                       else
-                       {
-                               $start_date     = $values['start_date'];
-
-                       }
-
-                       if ($values['end_date'])
-                       {
-                               $end_date = $values['end_date'];
-                       }
-                       else
-                       {
-                               $end_date = mktime(0, 0, 0, 12, 31, 
date(Y,$start_date)); // last day of start year
-                       }
-
-
-                       $this->db->query("INSERT INTO 
fm_r_agreement_item_history 
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,user_id,tenant_id,from_date,to_date)
 "
-                               . "VALUES (" . $values['r_agreement_id'] . "," 
. $id .",1,1,1," . $this->floatval($values['cost']) . "," . (int)$start_date . 
"," . time()
-                               . "," . $this->account . "," . 
(int)$values['tenant_id'] . "," . (int)$start_date . "," . (int)$end_date . 
")");
-
-                       $receipt['r_agreement_id']= $values['r_agreement_id'];
-                       $receipt['id']= $id;
-
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been saved',$receipt['r_agreement_id']));
-
-                       $this->db->transaction_commit();
-                       return $receipt;
-               }
-
-               function edit($values,$values_attribute='')
-               {
-//_debug_array($values_attribute);
-                       $table = 'fm_r_agreement';
-
-                       $values['name'] = 
$this->db->db_addslashes($values['name']);
-
-                       if($values['member_of'])
-                       {
-                               $values['member_of']=',' . 
implode(',',$values['member_of']) . ',';
-                       }
-
-                       if(isset($values['extra']) && 
is_array($values['extra']))
-                       {
-                               foreach ($values['extra'] as $column => $value)
-                               {
-                                       $value_set[$column]     = $value;
-                               }
-                       }
-
-                       if (isset($values_attribute) AND 
is_array($values_attribute))
-                       {
-                               foreach($values_attribute as $entry)
-                               {
-                                       if($entry['datatype']!='AB' && 
$entry['datatype']!='VENDOR')
-                                       {
-                                               if($entry['datatype'] == 'C' || 
$entry['datatype'] == 'T' || $entry['datatype'] == 'V' || $entry['datatype'] == 
'link')
-                                               {
-                                                       
$value_set[$entry['name']] = $this->db->db_addslashes($entry['value']);
-                                               }
-                                               else
-                                               {
-                                                       
$value_set[$entry['name']]      = $entry['value'];
-                                               }
-                                       }
-                               }
-                       }
-
-                       $value_set['name']      = $values['name'];
-                       $value_set['descr']     = $values['descr'];
-                       $value_set['customer_id']= $values['customer_id'];
-                       $value_set['customer_name']= $values['customer_name'];
-                       if($value_set)
-                       {
-                               $value_set      = ',' . 
$this->db->validate_update($value_set);
-                       }
-
-                       $this->db->query("UPDATE $table set entry_date='" . 
time() . "', category='"
-                                                       . $values['cat_id'] . 
"', member_of='" . $values['member_of'] . "', start_date=" . 
intval($values['start_date']) . ", end_date=" . intval($values['end_date']) . 
", termination_date=" . intval($values['termination_date']) . ", account_id=" . 
intval($values['b_account_id']) .  " $value_set WHERE id=" . 
intval($values['r_agreement_id']));
-
-                       $this->db->query("UPDATE fm_r_agreement_item_history 
set index_date=" . intval($values['start_date']) . " WHERE id=1 AND 
agreement_id= " . intval($values['r_agreement_id']));
-
-                       $receipt['r_agreement_id']= $values['r_agreement_id'];
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been edited',$values['r_agreement_id']));
-                       return $receipt;
-               }
-
-               function edit_item($values,$values_attribute='')
-               {
-//_debug_array($values);
-//_debug_array($values_attribute);
-                       $table = 'fm_r_agreement_item';
-
-                       while (is_array($values['extra']) && 
list($column,$value) = each($values['extra']))
-                       {
-                               $value_set[$column]     = $value;
-                       }
-
-                       if (isset($values_attribute) AND 
is_array($values_attribute))
-                       {
-                               foreach($values_attribute as $entry)
-                               {
-                                       if($entry['datatype']!='AB' && 
$entry['datatype']!='VENDOR')
-                                       {
-                                               if($entry['datatype'] == 'C' || 
$entry['datatype'] == 'T' || $entry['datatype'] == 'V' || $entry['datatype'] == 
'link')
-                                               {
-                                                       
$value_set[$entry['name']] = $this->db->db_addslashes($entry['value']);
-                                               }
-                                               else
-                                               {
-                                                       
$value_set[$entry['name']]      = $entry['value'];
-                                               }
-                                       }
-                               }
-                       }
-
-                       if($values['street_name'])
-                       {
-                               $address[]= $values['street_name'];
-                               $address[]= $values['street_number'];
-                               $address        = 
$this->db->db_addslashes(implode(" ", $address));
-                       }
-
-                       if(!$address)
-                       {
-                               $address = 
$this->db->db_addslashes($values['location_name']);
-                       }
-
-                       $value_set['location_code']     = 
$values['location_code'];
-                       $value_set['cost']      = $values['cost'];
-                       $value_set['address']   = $address;
-                       $value_set['rental_type_id']    = 
$values['rental_type_id'];
-
-
-                       if($value_set)
-                       {
-                               $value_set      = ',' . 
$this->db->validate_update($value_set);
-                       }
-
-                       $this->db->query("UPDATE $table set entry_date=" . 
time() . "$value_set WHERE agreement_id=" . intval($values['r_agreement_id']) . 
' AND id=' . intval($values['id']));
-
-                       $this->db->query("UPDATE fm_r_agreement_item_history 
set cost = this_index *" . $this->floatval($values['cost']) . " WHERE 
agreement_id=" . intval($values['r_agreement_id']) . ' AND item_id=' . 
intval($values['id']));
-
-                       $receipt['r_agreement_id']= $values['r_agreement_id'];
-                       $receipt['id']= $values['id'];
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been edited',$values['r_agreement_id']));
-                       return $receipt;
-               }
-
-               function update_item_history($values)
-               {
-//_debug_array($values);
-                       
$values['new_index']=$this->floatval($values['new_index']);
-                       $this->db->transaction_begin();
-
-                       while (is_array($values['select']) && 
list($item_id,$value) = each($values['select']))
-                       {
-
-                               $this->db->query("UPDATE 
fm_r_agreement_item_history set current_index = NULL WHERE agreement_id=" . 
intval($values['agreement_id']) . ' AND item_id=' . intval($item_id));
-
-                               $this->db->query("SELECT tenant_id,to_date from 
fm_r_agreement_item_history WHERE agreement_id=" . 
intval($values['agreement_id']) . ' AND item_id=' . intval($item_id) . ' AND 
id=' . intval($values['id'][$item_id]));
-
-                               $this->db->next_record();
-
-                               if(!$values['tenant_id'])
-                               {
-                                       $values['tenant_id'] = 
$this->db->f('tenant_id');
-                               }
-
-                               if ($values['start_date'])
-                               {
-                                       $start_date = $values['start_date'];
-                                       if($start_date < 
$this->db->f('to_date'))
-                                       {
-                                               $start_date = 
$this->db->f('to_date') + (3600 * 24);
-                                       }
-                               }
-                               else
-                               {
-                                       $start_date     = 
$this->db->f('to_date') + (3600 * 24);
-                               }
-
-                               if ($values['end_date'])
-                               {
-                                       $end_date = $values['end_date'];
-                               }
-                               else
-                               {
-                                       $end_date = mktime(0, 0, 0, 12, 31, 
date(Y,$start_date)); // last day of start year
-                               }
-
-                               $this->db->query("INSERT INTO 
fm_r_agreement_item_history 
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,tenant_id,user_id,from_date,to_date)"
-                                       . "VALUES (" . $values['agreement_id'] 
. "," . $item_id ."," . ($values['id'][$item_id]+1) .",1,'" . 
$values['new_index']
-                                       . "','" . ($value * 
$values['new_index'])  . "'," . (int)$values['date'] . "," . time()  . "," . 
(int)$values['tenant_id']
-                                       . "," . $this->account . "," . 
(int)$start_date . "," . (int)$end_date . ")");
-
-                       }
-
-                       $this->db->transaction_commit();
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been updated for index',$values['agreement_id']));
-
-                       return $receipt;
-               }
-
-               function floatval($strValue)
-               {
-                       $floatValue = 
preg_replace("/(^[0-9]*)(\\.|,)([0-9]*)(.*)/", "\\1.\\3", $strValue);
-                       if(!is_numeric($floatValue))
-                       {
-                               $floatValue = preg_replace("/(^[0-9]*)(.*)/", 
"\\1", $strValue);
-                       }
-                       if(!is_numeric($floatValue))
-                       {
-                               $floatValue = 0;
-                       }
-                       return $floatValue;
-               }
-
-
-               function delete_last_index($r_agreement_id,$item_id)
-               {
-                       $this->db->transaction_begin();
-                       $this->db->query("SELECT max(id) as index_count FROM 
fm_r_agreement_item_history WHERE agreement_id=$r_agreement_id AND 
item_id=$item_id");
-                       $this->db->next_record();
-                       $index_count    = $this->db->f('index_count');
-                       if($index_count>1)
-                       {
-                               $this->db->query("DELETE FROM 
fm_r_agreement_item_history WHERE agreement_id=$r_agreement_id AND 
item_id=$item_id AND id=$index_count");
-                               $this->db->query("UPDATE 
fm_r_agreement_item_history set current_index = 1 WHERE 
agreement_id=$r_agreement_id AND item_id=$item_id AND id =" . ($index_count-1));
-                       }
-                       $this->db->transaction_commit();
-               }
-
-               function delete_item($r_agreement_id,$item_id)
-               {
-                       $this->db->transaction_begin();
-                       $this->db->query("DELETE FROM fm_r_agreement_item WHERE 
agreement_id=$r_agreement_id AND id=$item_id");
-                       $this->db->query("DELETE FROM 
fm_r_agreement_item_history WHERE agreement_id=$r_agreement_id AND 
item_id=$item_id");
-                       $this->db->transaction_commit();
-               }
-
-
-               function delete($r_agreement_id)
-               {
-                       $table = 'fm_r_agreement';
-                       $this->db->transaction_begin();
-                       $this->db->query("DELETE FROM $table WHERE id=" . 
intval($r_agreement_id));
-                       $this->db->query("DELETE FROM fm_r_agreement_item WHERE 
agreement_id=" . intval($r_agreement_id));
-                       $this->db->query("DELETE FROM 
fm_r_agreement_item_history WHERE agreement_id=" . intval($r_agreement_id));
-                       $this->db->query("DELETE FROM fm_orders WHERE id=" . 
intval($r_agreement_id));
-                       $this->db->transaction_commit();
-               }
-
-
-               function request_next_id()
-               {
-                       $this->db->query("SELECT max(id) as id FROM 
fm_r_agreement",__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $next_id= $this->db->f('id')+1;
-                       return $next_id;
-               }
-
-               function add_common($values)
-               {
-                       $table = 'fm_r_agreement_common';
-
-                       $cols[] = 'b_account';
-                       $vals[] = $values['b_account'];
-                       $cols[] = 'remark';
-                       $vals[] = $this->db->db_addslashes($values['remark']);
-
-                       $cols   = "," . implode(",", $cols);
-                       $vals   = "," . $this->db->validate_insert($vals);
-
-                       $this->db->transaction_begin();
-                       $c_id = 
$this->db->next_id($table,array('agreement_id'=>$values['r_agreement_id']));
-
-                       $this->db->query("INSERT INTO $table 
(id,agreement_id,entry_date,user_id $cols) "
-                               . "VALUES ($c_id," . $values['r_agreement_id'] 
."," . time()
-                               . "," . $this->account . " 
$vals)",__LINE__,__FILE__);
-
-                       $this->db->query("SELECT start_date, end_date FROM 
fm_r_agreement WHERE id=" . $values['r_agreement_id'],__LINE__,__FILE__);
-                       $this->db->next_record();
-                       if ($values['start_date'])
-                       {
-                               $start_date = $values['start_date'];
-                               if ($start_date < $this->db->f('start_date'))
-                               {
-                                       $start_date     = 
$this->db->f('start_date');
-                               }
-                       }
-                       else
-                       {
-                               $start_date     = $this->db->f('start_date');
-                       }
-
-                       if ($values['end_date'])
-                       {
-                               $end_date = $values['end_date'];
-                       }
-                       else
-                       {
-                                       $end_date = mktime(0, 0, 0, 12, 31, 
date(Y,$start_date)); // last day of start year
-                       }
-
-
-                       $this->db->query("INSERT INTO fm_r_agreement_c_history 
(agreement_id,c_id,id,current_record,budget_cost,from_date,to_date,user_id,override_fraction)
 "
-                               . "VALUES (" . $values['r_agreement_id'] . "," 
. $c_id .",1,1," . $this->floatval($values['budget_cost']) . "," . $start_date 
. "," . $end_date
-                               . "," . $this->account . "," . 
$this->floatval($values['override_fraction']) .")",__LINE__,__FILE__);
-
-                       $receipt['r_agreement_id']= $values['r_agreement_id'];
-                       $receipt['c_id']= $c_id;
-
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been saved',$receipt['r_agreement_id']));
-
-                       $this->db->transaction_commit();
-                       return $receipt;
-               }
-
-               function add_common_history($values)
-               {
-                       $table = 'fm_r_agreement_c_history';
-
-                       $this->db->transaction_begin();
-                       $id = 
$this->db->next_id($table,array('agreement_id'=>$values['r_agreement_id'],'c_id'
 =>$values['c_id']));
-
-                       $this->db->query("SELECT from_date, to_date FROM $table 
WHERE agreement_id=" . $values['r_agreement_id'] . " AND c_id=" . 
$values['c_id'] . " AND id =" .($id-1),__LINE__,__FILE__);
-                       $this->db->next_record();
-                       if ($values['start_date'])
-                       {
-                               $start_date = $values['start_date'];
-                               if($start_date < $this->db->f('to_date'))
-                               {
-                                       $start_date = $this->db->f('to_date') + 
(3600 * 24);
-                               }
-                       }
-                       else
-                       {
-                               $start_date     = $this->db->f('to_date') + 
(3600 * 24);
-                       }
-
-                       if ($values['end_date'])
-                       {
-                               $end_date = $values['end_date'];
-                       }
-                       else
-                       {
-                                       $end_date = mktime(0, 0, 0, 12, 31, 
date(Y,$start_date)); // last day of start year
-                       }
-
-
-                       $this->db->query("INSERT INTO fm_r_agreement_c_history 
(agreement_id,c_id,id,current_record,budget_cost,from_date,to_date,user_id,override_fraction)
 "
-                               . "VALUES (" . $values['r_agreement_id'] . "," 
. $values['c_id'] . "," . $id .",1," . $this->floatval($values['budget_cost']) 
. "," . $start_date . "," . $end_date
-                               . "," . $this->account . "," . 
$this->floatval($values['override_fraction']) .")",__LINE__,__FILE__);
-
-
-                       $this->db->query("UPDATE fm_r_agreement_c_history set 
current_record = NULL WHERE agreement_id =" . $values['r_agreement_id'] . 'AND 
c_id=' . $values['c_id'] . 'AND id=' . ($id-1),__LINE__,__FILE__);
-                       $receipt['r_agreement_id']= $values['r_agreement_id'];
-                       $receipt['c_id']= $values['c_id'];
-
-                       $receipt['message'][] = array('msg'=>lang('agreement %1 
has been saved',$receipt['r_agreement_id']));
-
-                       $this->db->transaction_commit();
-                       return $receipt;
-               }
-
-
-               function read_common($agreement_id)
-               {
-                       $sql ="SELECT b_account,budget_cost, 
actual_cost,fm_r_agreement_c_history.id,from_date,"
-                       . " 
to_date,fm_r_agreement_c_history.c_id,override_fraction,remark "
-                       . " FROM fm_r_agreement_common $this->join  
fm_r_agreement_c_history "
-                       . " ON ( fm_r_agreement_common.agreement_id 
=fm_r_agreement_c_history.agreement_id "
-                       . " AND fm_r_agreement_common.id 
=fm_r_agreement_c_history.c_id)"
-                       . " WHERE  fm_r_agreement_common.agreement_id = 
$agreement_id AND current_record = 1 ORDER BY fm_r_agreement_c_history.c_id 
ASC";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $this->total_records = $this->db->num_rows();
-
-                       while ($this->db->next_record())
-                       {
-                               $common[] = array
-                               (
-                                       'agreement_id'  => $agreement_id,
-                                       'c_id'          => $this->db->f('c_id'),
-                                       'b_account_id'  => 
$this->db->f('b_account'),
-                                       'from_date'     => 
$this->db->f('from_date'),
-                                       'to_date'       => 
$this->db->f('to_date'),
-                                       'budget_cost'   => 
$this->db->f('budget_cost'),
-                                       'actual_cost'   => 
$this->db->f('actual_cost'),
-                                       'override_fraction'     => 
$this->db->f('override_fraction'),
-                                       'remark'        => 
stripslashes($this->db->f('remark')),
-                               );
-                       }
-
-//_debug_array($common);
-                       return $common;
-               }
-
-
-               function read_single_common($data)
-               {
-                       $r_agreement_id =$data['r_agreement_id'];
-                       $id =$data['c_id'];
-
-                       $this->db->query("SELECT * FROM fm_r_agreement_common 
WHERE agreement_id=$r_agreement_id AND id=$id",__LINE__,__FILE__);
-
-                       if($this->db->next_record())
-                       {
-                               $common = array
-                               (
-                                       'agreement_id'  => $r_agreement_id,
-                                       'c_id'          => $id,
-                                       'b_account_id'  => 
$this->db->f('b_account'),
-                                       'remark'        => 
stripslashes($this->db->f('remark')),
-                                       'override_fraction'     => 
$this->db->f('override_fraction')
-                               );
-                       }
-                       return $common;
-               }
-
-               function read_common_history($data)
-               {
-                       if(is_array($data))
-                       {
-                               $r_agreement_id = 
(isset($data['r_agreement_id'])?$data['r_agreement_id']:0);
-                               $c_id   = 
(isset($data['c_id'])?$data['c_id']:0);
-                       }
-
-                       $table = 'fm_r_agreement_common';
-//echo $sql;
-                       $sql ="SELECT b_account,budget_cost, 
actual_cost,fm_r_agreement_c_history.id,from_date,"
-                       . " 
to_date,fm_r_agreement_c_history.c_id,override_fraction,remark "
-                       . " FROM fm_r_agreement_common $this->join  
fm_r_agreement_c_history "
-                       . " ON ( fm_r_agreement_common.agreement_id 
=fm_r_agreement_c_history.agreement_id "
-                       . " AND fm_r_agreement_common.id 
=fm_r_agreement_c_history.c_id)"
-                       . " WHERE  fm_r_agreement_common.agreement_id = 
$r_agreement_id AND c_id=$c_id ORDER BY fm_r_agreement_c_history.c_id ASC";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $this->total_records = $this->db->num_rows();
-
-                       while ($this->db->next_record())
-                       {
-                               $common[] = array
-                               (
-                                       'agreement_id'  => $id,
-                                       'c_id'          => $this->db->f('c_id'),
-                                       'id'            => $this->db->f('id'),
-                                       'b_account_id'  => 
$this->db->f('b_account'),
-                                       'from_date'     => 
$this->db->f('from_date'),
-                                       'to_date'       => 
$this->db->f('to_date'),
-                                       'budget_cost'   => 
$this->db->f('budget_cost'),
-                                       'actual_cost'   => 
$this->db->f('actual_cost'),
-                                       'override_fraction'     => 
$this->db->f('override_fraction'),
-                                       'remark'        => 
stripslashes($this->db->f('remark')),
-                               );
-                       }
-
-                       return $common;
-               }
-
-               function delete_common_h($r_agreement_id,$c_id,$id)
-               {
-                       $this->db->transaction_begin();
-                       $this->db->query("DELETE FROM fm_r_agreement_c_history 
WHERE agreement_id=$r_agreement_id AND c_id=$c_id AND 
id=$id",__LINE__,__FILE__);
-                       $this->db->transaction_commit();
-               }
-       }
-

Deleted: trunk/property/inc/class.sostandard_2.inc.php
===================================================================
--- trunk/property/inc/class.sostandard_2.inc.php       2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.sostandard_2.inc.php       2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,214 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_sostandard_2
-       {
-
-               function __construct()
-               {
-                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->_db                      = & 
$GLOBALS['phpgw']->db;
-                       $this->_like            = & $this->_db->like;
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               $start          = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
-                               $query          = isset($data['query']) ? 
$data['query'] : '';
-                               $sort           = isset($data['sort']) && 
$data['sort'] ? $data['sort']:'DESC';
-                               $order          = isset($data['order']) ? 
$data['order'] : '';
-                               $type           = isset($data['type']) ? 
$data['type'] : '';
-                               $allrows        = isset($data['allrows']) ? 
$data['allrows'] : '';
-                       }
-
-                       $standard = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               return $standard;
-                       }
-
-                       if ($order)
-                       {
-                               $ordermethod = " ORDER BY $order $sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' ORDER BY id ASC';
-                       }
-
-                       if($query)
-                       {
-                               $query = $this->_db->db_addslashes($query);
-
-                               $querymethod = " WHERE id $this->_like 
'%$query%' OR descr $this->_like '%$query%'";
-                       }
-
-                       $sql = "SELECT * FROM $table $querymethod";
-
-                       $this->_db->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->_db->num_rows();
-
-                       if(!$allrows)
-                       {
-                               $this->_db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-                       }
-                       else
-                       {
-                               $this->_db->query($sql . 
$ordermethod,__LINE__,__FILE__);
-                       }
-
-                       while ($this->_db->next_record())
-                       {
-                               $standard[] = array
-                               (
-                                       'id'    => $this->_db->f('id'),
-                                       'descr' => $this->_db->f('descr')
-                               );
-                       }
-                       return $standard;
-               }
-
-
-               function select_table($type)
-               {
-
-                       switch($type)
-                       {
-                               case 'workorder_status':
-                                       $table='fm_workorder_status';
-                                       break;
-                               case 'request_status':
-                                       $table='fm_request_status';
-                                       break;
-                               case 'agreement_status':
-                                       $table='fm_agreement_status';
-                                       break;
-                               case 'building_part':
-                                       $table='fm_building_part';
-                                       break;
-                               case 'document_status':
-                                       $table='fm_document_status';
-                                       break;
-                               case 'unit':
-                                       $table='fm_standard_unit';
-                                       break;
-                       }
-
-                       return $table;
-               }
-
-
-               function read_single($id,$type)
-               {
-                       $standard = array();
-
-                       if (!$table = $this->select_table($type))
-                       {
-                               return $standard;
-                       }
-
-                       $sql = "SELECT * FROM $table WHERE id='{$id}'";
-
-                       $this->_db->query($sql,__LINE__,__FILE__);
-
-                       if ($this->_db->next_record())
-                       {
-                               $standard = array
-                               (
-                                       'id'            => $this->_db->f('id'),
-                                       'descr'         => 
$this->_db->f('descr', true)
-                               );
-                       }
-                       return $standard;
-               }
-
-               function add($standard,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $standard['descr'] = 
$this->_db->db_addslashes($standard['descr']);
-
-                       $this->_db->transaction_begin();
-
-                       $this->_db->query("INSERT INTO $table (id, descr) "
-                               . "VALUES ('" . $standard['id'] . "','" . 
$standard['descr']. "')",__LINE__,__FILE__);
-
-                       $this->_db->transaction_commit();
-                       $receipt['message'][] = array('msg' => lang('standard 
has been saved'));
-                       return $receipt;
-               }
-
-               function edit($standard,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $standard['descr'] = 
$this->_db->db_addslashes($standard['descr']);
-
-                       $this->_db->transaction_begin();
-
-                       $this->_db->query("UPDATE $table set descr='" . 
$standard['descr']
-                                                       . "' WHERE id='" . 
$standard['id']. "'",__LINE__,__FILE__);
-
-                       $this->_db->transaction_commit();
-                       $receipt['message'][] = array('msg' => lang('standard 
has been edited'));
-                       return $receipt;
-               }
-
-               function delete($id,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $this->_db->transaction_begin();
-                       $this->_db->query("DELETE FROM $table WHERE 
id='{$id}'",__LINE__,__FILE__);
-                       $this->_db->transaction_commit();
-               }
-       }
-

Deleted: trunk/property/inc/class.sostandard_3.inc.php
===================================================================
--- trunk/property/inc/class.sostandard_3.inc.php       2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.sostandard_3.inc.php       2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,203 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_sostandard_3
-       {
-               function __construct()
-               {
-                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->socommon         = 
CreateObject('property.socommon');
-                       $this->_db                      = & 
$GLOBALS['phpgw']->db;
-                       $this->_join            = & $this->_db->join;
-                       $this->_like            = & $this->_db->like;
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               $start          = isset($data['start']) && 
$data['start'] ? $data['start']:0;
-                               $query          = 
isset($data['query'])?$data['query']:'';
-                               $sort           = isset($data['sort']) && 
$data['sort'] ? $data['sort']:'DESC';
-                               $order          = 
isset($data['order'])?$data['order']:'';
-                               $type           = isset($data['type']) 
?$data['type']: '';
-                       }
-
-                       $standard = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               return $standard;
-                       }
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $order $sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by id asc';
-                       }
-
-                       if($query)
-                       {
-                               $query = $this->_db->db_addslashes($query);
-                               // FIXME: change fm_async_method.name to 
fm_async_method.num
-                               //$querymethod = " WHERE num $this->_like 
'%$query%' or descr $this->_like '%$query%'";
-                               $querymethod = " WHERE descr $this->_like 
'%$query%'";
-                       }
-
-                       $sql = "SELECT * FROM $table $querymethod";
-
-                       $this->_db->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->_db->num_rows();
-                       $this->_db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
-
-                       while ($this->_db->next_record())
-                       {
-                               $standard[] = array
-                               (
-                                       'id'    => $this->_db->f('id'),
-                                       'num'   => $this->_db->f('num', true),
-                                       'descr' => $this->_db->f('descr',true)
-                               );
-                       }
-                       return $standard;
-               }
-
-               function select_table($type)
-               {
-                       $table = '';
-                       switch($type)
-                       {
-                               case 'branch':
-                                       $table='fm_branch';
-                                       break;
-                               case 'key_location':
-                                       $table='fm_key_loc';
-                                       break;
-                               case 'async':
-                                       $table='fm_async_method';
-                                       break;
-                       }
-                       return $table;
-               }
-
-               function read_single($id, $type)
-               {
-                       $id = (int) $id;
-                       $standard = array();
-
-                       if (!$table = $this->select_table($type))
-                       {
-                               return $standard;
-                       }
-
-                       $sql = "SELECT * FROM $table WHERE id={$id}";
-
-                       $this->_db->query($sql,__LINE__,__FILE__);
-
-                       if ($this->_db->next_record())
-                       {
-                               $standard = array
-                               (
-                                       'id'            => $this->_db->f('id'),
-                                       'num'           => $this->_db->f('num', 
true),
-                                       'descr'         => 
$this->_db->f('descr', true)
-                               );
-                       }
-                       return $standard;
-               }
-
-               function add($standard,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $standard['num'] = 
$this->_db->db_addslashes($standard['num']);
-                       $standard['descr'] = 
$this->_db->db_addslashes($standard['descr']);
-
-                       $this->_db->transaction_begin();
-                       $standard['id'] = $this->socommon->next_id($table);
-                       $this->_db->query("INSERT INTO $table (id, num, descr) "
-                               . "VALUES ('" . $standard['id'] . "','" . 
$standard['num'] . "','" . $standard['descr']. "')",__LINE__,__FILE__);
-
-                       $this->_db->transaction_commit();
-                       $receipt['id'] = $standard['id'];
-                       $receipt['message'][] = array('msg' => lang('standard 
has been saved'));
-
-                       return $receipt;
-               }
-
-               function edit($standard,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $standard['num'] = 
$this->_db->db_addslashes($standard['num']);
-                       $standard['descr'] = 
$this->_db->db_addslashes($standard['descr']);
-
-                       $this->_db->transaction_begin();
-                       $this->_db->query("UPDATE $table set descr='" . 
$standard['descr'] . "', num='". $standard['num']
-                                                       . "' WHERE id='" . 
$standard['id']. "'",__LINE__,__FILE__);
-
-                       $this->_db->transaction_commit();
-
-                       $receipt['id'] = $standard['id'];
-                       $receipt['message'][] = array('msg' =>lang('standard 
has been edited'));
-                       return $receipt;
-               }
-
-               function delete($id,$type)
-               {
-                       $receipt = array();
-                       if (!$table = $this->select_table($type))
-                       {
-                               $receipt['error'][] = array('msg' => lang('not 
a valid type'));
-                               return $receipt;
-                       }
-
-                       $this->_db->transaction_begin();
-                       $this->_db->query("DELETE FROM $table WHERE id=" . 
(int)$id ,__LINE__,__FILE__);
-                       $this->_db->transaction_commit();
-               }
-       }
-

Deleted: trunk/property/inc/class.uib_account.inc.php
===================================================================
--- trunk/property/inc/class.uib_account.inc.php        2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.uib_account.inc.php        2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,618 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id$
-       */
-       phpgw::import_class('phpgwapi.yui');
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class property_uib_account
-       {
-               var $grants;
-               var $start;
-               var $query;
-               var $sort;
-               var $order;
-               var $sub;
-               var $currentapp;
-
-               var $public_functions = array
-               (
-                       'index'  => true,
-                       'edit'   => true,
-                       'delete' => true,
-                       'download'      => true
-               );
-
-               function property_uib_account()
-               {
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
-                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
'property::invoice::budget';
-
-                       $this->account                  = 
$GLOBALS['phpgw_info']['user']['account_id'];
-
-                       $this->bo                       = 
CreateObject('property.bob_account',true);
-                       $this->bocommon                 = 
CreateObject('property.bocommon');
-
-                       $this->acl                              = & 
$GLOBALS['phpgw']->acl;
-                       $this->acl_location             = '.b_account';
-                       $this->acl_read                 = 
$this->acl->check('.b_account', PHPGW_ACL_READ, 'property');
-                       $this->acl_add                  = 
$this->acl->check('.b_account', PHPGW_ACL_ADD, 'property');
-                       $this->acl_edit                 = 
$this->acl->check('.b_account', PHPGW_ACL_EDIT, 'property');
-                       $this->acl_delete               = 
$this->acl->check('.b_account', PHPGW_ACL_DELETE, 'property');
-
-                       $this->start                    = $this->bo->start;
-                       $this->query                    = $this->bo->query;
-                       $this->sort                     = $this->bo->sort;
-                       $this->order                    = $this->bo->order;
-                       $this->allrows                  = $this->bo->allrows;
-               }
-
-               function save_sessiondata()
-               {
-                       $data = array
-                       (
-                               'start'         => $this->start,
-                               'query'         => $this->query,
-                               'sort'          => $this->sort,
-                               'order'         => $this->order,
-                               'allrows'       => $this->allrows
-                       );
-                       $this->bo->save_sessiondata($data);
-               }
-
-               function download()
-               {
-                       $list = $this->bo->read();
-                       $uicols['name'][0]      = 'id';
-                       $uicols['descr'][0]     = lang('Budget account');
-                       $uicols['name'][1]      = 'descr';
-                       $uicols['descr'][1]     = lang('Description');
-
-                       
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
-               }
-
-               function index()
-               {
-                       if(!$this->acl_read)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
-                       }
-
-                       $datatable = array();
-
-                       if( phpgw::get_var('phpgw_return_as') != 'json' )
-                       {
-                               $datatable['config']['base_url'] = 
$GLOBALS['phpgw']->link('/index.php', array
-                       (
-                               'menuaction'                    => 
'property.uib_account.index'//,
-                               ));
-
-                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uib_account.index'";
-
-                               $link_data = array
-                               (
-                                       'menuaction'    => 
'property.uib_account.index'//,
-                                       //'id'          => $id
-                               );
-
-                               $datatable['config']['allow_allrows'] = true;
-
-                               $datatable['actions']['form'] = array(
-                               array(
-                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
-                                                       array(
-                                                               'menuaction'    
=> 'property.uib_account.index'//,
-                                                       )
-                                               ),
-                                       'fields'        => array(
-                                           'field' => array
-                                                               (
-                                                                               
                                array
-                                                                               
                                (
-                                                                               
                                        'type'  => 'button',
-                                                                               
                                        'id'    => 'btn_export',
-                                                                               
                                        'value' => lang('download'),
-                                                                               
                                        'tab_index' => 9
-                                                                               
                                ),
-                                                                               
                                array(
-                                                                               
        'type'  => 'button',
-                                                                               
        'id'    => 'btn_new',
-                                                                               
        'value' => lang('add'),
-                                                                               
        'tab_index' => 8
-                                                                               
    ),
-                                                                       array( 
//boton     SEARCH
-                                                                           
'id' => 'btn_search',
-                                                                           
'name' => 'search',
-                                                                           
'value'    => lang('search'),
-                                                                           
'type' => 'button',
-                                                                           
'tab_index' => 7
-                                                                       ),
-                                                                               
                                array( // TEXT INPUT
-                                                                           
'name'     => 'query',
-                                                                           
'id'     => 'txt_query',
-                                                                           
'value'    => '',//$query,
-                                                                           
'type' => 'text',
-                                                                           
'onkeypress' => 'return pulsar(event)',
-                                                                           
'size'    => 28,
-                                                                           
'tab_index' => 6
-                                                                       )
-                                                                               
)
-                                                                               
)
-                                        )
-                               );
-                       }
-
-                       $b_account_list = $this->bo->read($type);
-
-                       $uicols['name'][0]      = 'id';
-                       $uicols['descr'][0]     = lang('Budget account');
-                       $uicols['name'][1]      = 'descr';
-                       $uicols['descr'][1]     = lang('Description');
-
-                       $j = 0;
-                       $count_uicols_name = count($uicols['name']);
-
-                       if (isset($b_account_list) AND 
is_array($b_account_list))
-                       {
-                               foreach($b_account_list as $account_entry)
-                               {
-                                       for ($k=0;$k<$count_uicols_name;$k++)
-                                       {
-                                               
if($uicols['input_type'][$k]!='hidden')
-                                               {
-                                                       
$datatable['rows']['row'][$j]['column'][$k]['name']                     = 
$uicols['name'][$k];
-                                                       
$datatable['rows']['row'][$j]['column'][$k]['value']                            
= $account_entry[$uicols['name'][$k]];
-                                               }
-                                       }
-                                       $j++;
-                               }
-                       }
-
-                       $datatable['rowactions']['action'] = array();
-
-                       $parameters = array
-                       (
-                               'parameter' => array
-                               (
-                                       array
-                                       (
-                                               'name'          => 'id',
-                                               'source'        => 'id'
-                                       ),
-                               )
-                       );
-
-                       if($this->acl_edit)
-                       {
-                               $datatable['rowactions']['action'][] = array(
-                                                       'my_name'               
        => 'edit',
-                                                       'statustext'    => 
lang('edit the account'),
-                                                       'text'                  
=> lang('edit'),
-                                                       'action'                
=> $GLOBALS['phpgw']->link('/index.php',array
-                                                                       (
-                                                                               
'menuaction'    => 'property.uib_account.edit'
-                                                                       )),
-                                               'parameters'    => $parameters
-                                               );
-                       }
-
-                       if($this->acl_delete)
-                       {
-                               $datatable['rowactions']['action'][] = array(
-                                                       'my_name'               
        => 'delete',
-                                                       'statustext'    => 
lang('delete the actor'),
-                                                       'text'                  
=> lang('delete'),
-                                                       'confirm_msg'   => 
lang('do you really want to delete this entry'),
-                                                       'action'                
=> $GLOBALS['phpgw']->link('/index.php',array
-                                                                       (
-                                                                               
'menuaction'    => 'property.uib_account.delete'
-                                                                       )),
-                                               'parameters'    => $parameters
-                                               );
-                       }
-
-                       $datatable['rowactions']['action'][] = array(
-                                       'my_name'               => 'add',
-                                       'text'                  => lang('add'),
-                                       'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
-                                       (
-                                               'menuaction'    => 
'property.uib_account.edit'
-                                       )));
-
-                       for ($i=0;$i<$count_uicols_name;$i++)
-                       {
-                               if($uicols['input_type'][$i]!='hidden')
-                               {
-                                       
$datatable['headers']['header'][$i]['formatter']                = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
-                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
-                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
-                                       
$datatable['headers']['header'][$i]['visible']                  = true;
-                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
-                                       if($uicols['name'][$i]=='id')
-                                       {
-                                               
$datatable['headers']['header'][$i]['sortable']         = true;
-                                               
$datatable['headers']['header'][$i]['sort_field']       = 'id';
-                                       }
-                               }
-                       }
-
-                       //path for property.js
-                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
-
-                       // Pagination and sort values
-                       $datatable['pagination']['records_start']       = 
(int)$this->bo->start;
-                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       $datatable['pagination']['records_returned']= 
count($b_account_list);
-                       $datatable['pagination']['records_total']       = 
$this->bo->total_records;
-
-                       $appname                                        = 
lang('budget account');
-                       $function_msg                           = lang('list 
budget account');
-
-                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
-                       {
-                               $datatable['sorting']['order']                  
= 'id'; // name key Column in myColumnDef
-                               $datatable['sorting']['sort']                   
= 'desc'; // ASC / DESC
-                       }
-                       else
-                       {
-                               $datatable['sorting']['order']                  
= phpgw::get_var('order', 'string'); // name of column of Database
-                               $datatable['sorting']['sort']                   
= phpgw::get_var('sort', 'string'); // ASC / DESC
-                       }
-
-                       phpgwapi_yui::load_widget('dragdrop');
-                       phpgwapi_yui::load_widget('datatable');
-                       phpgwapi_yui::load_widget('menu');
-                       phpgwapi_yui::load_widget('connection');
-                       phpgwapi_yui::load_widget('loader');
-                       phpgwapi_yui::load_widget('tabview');
-                       phpgwapi_yui::load_widget('paginator');
-                       phpgwapi_yui::load_widget('animation');
-
-                       //-- BEGIN----------------------------- JSON CODE 
------------------------------
-               //values for Pagination
-                       $json = array
-                       (
-                               'recordsReturned'       => 
$datatable['pagination']['records_returned'],
-                               'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
-                               'startIndex'            => 
$datatable['pagination']['records_start'],
-                                       'sort'                          => 
$datatable['sorting']['order'],
-                               'dir'                           => 
$datatable['sorting']['sort'],
-                                       'records'                       => 
array()
-                       );
-
-                               // values for datatable
-                       if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
-                               foreach( $datatable['rows']['row'] as $row )
-                               {
-                                       $json_row = array();
-                                       foreach( $row['column'] as $column)
-                                       {
-                                               if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
-                                               {
-                                                       
$json_row[$column['name']] = "<a href='#' id='".$column['link']."' 
onclick='javascript:filter_data(this.id);'>" .$column['value']."</a>";
-                                               }
-                                               elseif(isset($column['format']) 
&& $column['format']== "link")
-                                               {
-                                                 $json_row[$column['name']] = 
"<a href='".$column['link']."'>" .$column['value']."</a>";
-                                               }else
-                                               {
-                                                 $json_row[$column['name']] = 
$column['value'];
-                                               }
-                                       }
-                                       $json['records'][] = $json_row;
-                               }
-                       }
-
-                               // right in datatable
-                               if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
-                               {
-                                       $json ['rights'] = 
$datatable['rowactions']['action'];
-                               }
-
-                               if( phpgw::get_var('phpgw_return_as') == 'json' 
)
-                               {
-                               return $json;
-                               }
-
-
-                       $datatable['json_data'] = json_encode($json);
-                       //-------------------- JSON CODE ----------------------
-
-                       $template_vars = array();
-                       $template_vars['datatable'] = $datatable;
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
-               $GLOBALS['phpgw']->xslttpl->set_var('phpgw', $template_vars);
-
-               if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
-               {
-                       $GLOBALS['phpgw']->css = createObject('phpgwapi.css');
-               }
-
-               $GLOBALS['phpgw']->css->validate_file('datatable');
-                       $GLOBALS['phpgw']->css->validate_file('property');
-                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
-                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'account.index', 'property' );
-
-
-
-                       //_debug_array($datatable);die;
-                       /*if(!$this->acl_read)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
-                       }
-
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('b_account', 
'nextmatchs', 'search_field'));
-
-                       $b_account_list = $this->bo->read($type);
-
-                       while (is_array($b_account_list) && list(,$b_account) = 
each($b_account_list))
-                       {
-                               if($this->acl_edit)
-                               {
-                                       $link_edit      = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.edit', 'id'=> $b_account['id']));
-                               }
-
-                               if($this->acl_delete)
-                               {
-                                       $link_delete    = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.delete', 'id'=> $b_account['id']));
-                               }
-
-                               $content[] = array
-                               (
-                                       'id'                            => 
$b_account['id'],
-                                       'first'                         => 
$b_account['descr'],
-                                       'link_edit'                     => 
$link_edit,
-                                       'link_delete'                   => 
$link_delete,
-                                       'lang_view_b_accounttext'       => 
lang('view the budget account'),
-                                       'lang_edit_b_accounttext'       => 
lang('edit the budget account'),
-                                       'lang_delete_b_accounttext'     => 
lang('delete the budget account'),
-                                       'text_view'                     => 
lang('view'),
-                                       'text_edit'                     => 
lang('edit'),
-                                       'text_delete'                   => 
lang('delete')
-                               );
-
-               }
-
-//_debug_array($content);
-
-                       $table_header[] = array
-                       (
-
-                               'lang_descr'            => lang('Descr'),
-                               'lang_edit'             => lang('edit'),
-                               'lang_delete'           => lang('delete'),
-                               'sort_id'               => 
$this->nextmatchs->show_sort_order(array(
-                                                                               
        'sort'  => $this->sort,
-                                                                               
        'var'   => 'id',
-                                                                               
        'order' => $this->order,
-                                                                               
        'extra' => array('menuaction' => 'property.uib_account.index')
-                                                                               
)),
-                               'lang_id'       => lang('budget account'),
-                       );
-
-                       $table_add[] = array
-                       (
-                               'lang_add'                      => lang('add'),
-                               'lang_add_b_accounttext'        => lang('add a 
budget account'),
-                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.edit')),
-                               'lang_done'                     => lang('done'),
-                               'lang_done_b_accounttext'       => lang('back 
to admin'),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php')
-                       );
-
-                       if(!$this->allrows)
-                       {
-                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       }
-                       else
-                       {
-                               $record_limit   = $this->bo->total_records;
-                       }
-
-
-                       $data = array
-                       (
-                               'menu'                                          
=> $this->bocommon->get_menu(),
-                               'allow_allrows'                         => true,
-                               'allrows'                               => 
$this->allrows,
-                               'start_record'                          => 
$this->start,
-                               'record_limit'                          => 
$record_limit,
-                               'num_records'                           => 
count($b_account_list),
-                               'all_records'                           => 
$this->bo->total_records,
-                               'link_url'                              => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.index', 'type'=> $type)),
-                               'img_path'                              => 
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-                               'lang_searchfield_b_accounttext'        => 
lang('Enter the search string. To show all entries, empty this field and press 
the SUBMIT button again'),
-                               'lang_searchbutton_b_accounttext'       => 
lang('Submit the search string'),
-                               'query'                                 => 
$this->query,
-                               'lang_search'                           => 
lang('search'),
-                               'table_header'                          => 
$table_header,
-                               'values'                                => 
$content,
-                               'table_add'                             => 
$table_add
-                       );
-
-                       $appname                = lang('budget account');
-                       $function_msg           = lang('list budget account');
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
-               //      $GLOBALS['phpgw']->xslttpl->pp();
-                       $this->save_sessiondata();*/
-               }
-
-               function edit()
-               {
-                       if(!$this->acl_add && !$this->acl_edit)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>2, 'acl_location'=> $this->acl_location));
-                       }
-
-                       $id     = phpgw::get_var('id', 'int');
-                       $values                 = phpgw::get_var('values');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account'));
-
-                       if ($values['save'])
-                       {
-                               if(!$id && !ctype_digit($values['id']))
-                               {
-                                       
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));
-                                       unset($values['id']);
-                               }
-
-                               if(!isset($values['responsible']) || 
!$values['responsible'])
-                               {
-                                       
$receipt['error'][]=array('msg'=>lang('Please select a budget reponsible!'));
-                               }
-
-                               if($id)
-                               {
-                                       $values['id']=$id;
-                                       $action='edit';
-                               }
-                               else
-                               {
-                                       $id =   $values['id'];
-                               }
-
-                               if(!$receipt['error'])
-                               {
-                                       $receipt = 
$this->bo->save($values,$action);
-                               }
-                       }
-
-                       if ($id)
-                       {
-                               $b_account = $this->bo->read_single($id);
-                               $function_msg = lang('edit budget account');
-                               $action='edit';
-                       }
-                       else
-                       {
-                               $function_msg = lang('add budget account');
-                               $action='add';
-                       }
-
-
-                       $link_data = array
-                       (
-                               'menuaction'    => 'property.uib_account.edit',
-                               'id'            => $id
-                       );
-//_debug_array($b_account);
-
-                       $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                           => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'form_action'                           => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'done_action'                           => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.index', 'type'=> $type)),
-                               'lang_id'                               => 
lang('budget account'),
-                               'lang_descr'                            => 
lang('Descr'),
-                               'lang_save'                             => 
lang('save'),
-                               'lang_done'                             => 
lang('done'),
-                               'value_id'                              => $id,
-                               'lang_id_b_accounttext'                 => 
lang('Enter the budget account'),
-                               'lang_descr_b_accounttext'              => 
lang('Enter a description the budget account'),
-                               'lang_done_b_accounttext'               => 
lang('Back to the list'),
-                               'lang_save_b_accounttext'               => 
lang('Save the budget account'),
-                               'value_descr'                           => 
$b_account['descr'],
-                               'lang_responsible'                      => 
lang('Responsible'),
-                               'lang_user_statustext'                  => 
lang('Select the budget responsible'),
-                               'select_user_name'                      => 
'values[responsible]',
-                               'lang_no_user'                          => 
lang('Select responsible'),
-                               'user_list'                             => 
$this->bocommon->get_user_list_right2('select',128,$b_account['responsible'],'.invoice'),
-
-                               'lang_category'                         => 
lang('category'),
-                               'lang_no_cat'                           => 
lang('no category'),
-                               'lang_cat_statustext'                   => 
lang('Select the category the selection belongs to. To do not use a category 
select NO CATEGORY'),
-                               'select_name'                           => 
'values[cat_id]',
-                               'cat_list'                              => 
$this->bocommon->select_category_list(array('format'=>'select','selected' => 
$b_account['cat_id'],'type' =>'b_account','order'=>'id')),
-                       );
-
-                       $appname                                                
= lang('budget account');
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
-               //      $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function delete()
-               {
-                       if(!$this->acl_delete)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>8, 'acl_location'=> $this->acl_location));
-                       }
-
-                       $id             = phpgw::get_var('id'); // string
-                       //$confirm              = phpgw::get_var('confirm', 
'bool', 'POST');
-
-                       $link_data = array
-                       (
-                               'menuaction' => 'property.uib_account.index'
-                       );
-
-                       if( phpgw::get_var('phpgw_return_as') == 'json' )
-                       {
-                               $this->bo->delete($id);
-                               return "id ".$id." ".lang("has been deleted");
-                               
//$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
-                       }
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
-                       $data = array
-                       (
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uib_account.delete', 'id'=> $id)),
-                               'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
-                               'lang_yes'                      => lang('yes'),
-                               'lang_yes_b_accounttext'        => lang('Delete 
the entry'),
-                               'lang_no_b_accounttext'         => lang('Back 
to the list'),
-                               'lang_no'                       => lang('no')
-                       );
-
-                       $appname                = lang('budget account');
-                       $function_msg           = lang('delete budget account');
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
-               //      $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-       }
-

Modified: trunk/property/inc/class.uicategory.inc.php
===================================================================
--- trunk/property/inc/class.uicategory.inc.php 2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.uicategory.inc.php 2010-11-13 17:15:50 UTC (rev 
6588)
@@ -456,9 +456,20 @@
 
                                        if(!$id && 
!$values[$this->location_info['id']['name']] && 
$this->location_info['id']['type'] !='auto')
                                        {
-                                               
$receipt['error'][]=array('msg'=>lang('Please enter an id!'));                  
                                                
+                                               
$receipt['error'][]=array('msg'=>lang('missing value for %1', lang('id')));     
                                                                
                                        }
 
+                                       foreach ( 
$this->location_info['fields'] as $field_info )
+                                       {
+                                               if 
(isset($field_info['nullable']) && $field_info['nullable'] != true)
+                                               {
+                                                       if( 
!$values[$field_info['name']] )
+                                                       {
+                                                               
$receipt['error'][]=array('msg'=>lang('missing value for %1', 
$field_info['descr']));                                                         
          
+                                                       }
+                                               }
+                                       }
+
                                        if($values['id'] && 
$this->location_info['id']['type'] == 'int' && !ctype_digit($values['id']))
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));

Modified: trunk/property/inc/class.uiinvoice.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice.inc.php  2010-11-12 13:34:53 UTC (rev 
6587)
+++ trunk/property/inc/class.uiinvoice.inc.php  2010-11-13 17:15:50 UTC (rev 
6588)
@@ -606,18 +606,18 @@
                        $content = array();
                        //the first time, $content is empty, because 
$user_lid=''.In the seconfd time, user_lid=all; It is done using  base_java_url.
                        $content = 
$this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
-                       //_debug_array($content);
+
                        $uicols = array (
-                               'input_type'    =>      array('hidden','hidden' 
,'hidden'       ,'hidden'       ,'hidden','hidden','hidden','hidden','hidden'   
,'link','link'          
,'hidden','hidden','hidden',$paid?'varchar':'input','varchar','varchar'  
,'hidden','varchar','varchar','varchar',$paid?'hidden':'input',$paid?'hidden':'input','special','special','special','special2'),
-                               'type'                  =>      
array('number',''               ,''             ,''             
,'number','number',''     ,'number',''  ,'url' ,'msg_box'       ,''    ,''    
,''    ,$paid?'':'text'           ,''     ,'text',''    ,''     ,''     ,''     
,$paid?'':'checkbox' ,$paid?'':'radio'     ,''     ,''     ,''     ,''     ),
+                               'input_type'    =>      array('hidden','hidden' 
,'hidden'       ,'hidden'       ,'hidden','hidden','hidden','hidden','hidden'   
,'link','link'          
,'hidden','hidden','hidden',$paid?'varchar':'input','varchar','varchar','varchar'
  
,'hidden','varchar','varchar','varchar',$paid?'hidden':'input',$paid?'hidden':'input','special','special','special','special2'),
+                               'type'                  =>      
array('number',''               ,''             ,''             
,'number','number',''     ,'number',''  ,'url' ,'msg_box'       ,''    ,''    
,''    ,$paid?'':'text'           ,''     ,'text','text',''    ,''     ,''     
,''     ,$paid?'':'checkbox' ,$paid?'':'radio'      ,''     ,''     ,''     ,'' 
    ),
 
-                               'col_name'              =>      
array('payment_date','transfer','kreditnota','sign','vendor_name','counter_num','counter','voucher_id_num','voucher_id','voucher_id_lnk','voucher_date_lnk','sign_orig'
 
,'num_days_orig','timestamp_voucher_date','num_days','amount_lnk','vendor','invoice_count','invoice_count_lnk','type_lnk','period','kreditnota_tmp','sign_tmp'
 ,'janitor_lnk','supervisor_lnk','budget_responsible_lnk','transfer_lnk'),
-                               'name'                  =>      
array('payment_date','dummy','dummy','dummy','vendor','counter','counter','voucher_id'
    ,'voucher_id','voucher_id'    ,'voucher_date'    ,'sign_orig','num_days'    
 ,'timestamp_voucher_date','num_days','amount'    ,'vendor'    
,'invoice_count','invoice_count'    ,'type'    
,'period','kreditnota','empty_fild','janitor'    ,'supervisor'    
,'budget_responsible'    ,'transfer_id'),
+                               'col_name'              =>      
array('payment_date','transfer','kreditnota','sign','vendor_name','counter_num','counter','voucher_id_num','voucher_id','voucher_id_lnk','voucher_date_lnk','sign_orig'
 
,'num_days_orig','timestamp_voucher_date','num_days','amount_lnk','currency','vendor','invoice_count','invoice_count_lnk','type_lnk','period','kreditnota_tmp','sign_tmp'
 ,'janitor_lnk','supervisor_lnk','budget_responsible_lnk','transfer_lnk'),
+                               'name'                  =>      
array('payment_date','dummy','dummy','dummy','vendor','counter','counter','voucher_id'
    ,'voucher_id','voucher_id'    ,'voucher_date'    ,'sign_orig','num_days'    
 ,'timestamp_voucher_date','num_days','amount'    ,'currency','vendor'    
,'invoice_count','invoice_count'    ,'type'    
,'period','kreditnota','empty_fild','janitor'    ,'supervisor'    
,'budget_responsible'    ,'transfer_id'),
 
-                               'formatter'             =>      
array('','','','','','','','','','','','','','','','myFormatDate','','','','',$paid?'':'myPeriodDropDown','','','','','',''),
+                               'formatter'             =>      
array('','','','','','','','','','','','','','','','myFormatDate','','','','','',$paid?'':'myPeriodDropDown','','','','','',''),
 
-                               'descr'                 =>      
array('dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy',lang('voucher'),lang('Voucher
 
Date'),'dummy','dummy','dummy',lang('Days'),lang('Sum'),lang('Vendor'),'dummy',lang('Count'),lang('Type'),lang('Period'),lang('KreditNota'),lang('None'),lang('Janitor'),lang('Supervisor'),lang('Budget
 Responsible'),lang('Transfer')),
-                               'className'             =>      
array('','','','','','','','','','','centerClasss','','','',$paid?'rightClasss':'','rightClasss','','','rightClasss','',$paid?'centerClasss':'comboClasss','centerClasss','centerClasss','','','centerClasss','centerClasss')
+                               'descr'                 =>      
array('dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy',lang('voucher'),lang('Voucher
 
Date'),'dummy','dummy','dummy',lang('Days'),lang('Sum'),lang('currency'),lang('Vendor'),'dummy',lang('Count'),lang('Type'),lang('Period'),lang('KreditNota'),lang('None'),lang('Janitor'),lang('Supervisor'),lang('Budget
 Responsible'),lang('Transfer')),
+                               'className'             =>      
array('','','','','','','','','','','centerClasss','','','',$paid?'rightClasss':'','rightClasss','','','','rightClasss','',$paid?'centerClasss':'comboClasss','centerClasss','centerClasss','','','centerClasss','centerClasss')
                                );
 
                        //url to detail of voucher
@@ -1274,15 +1274,17 @@
                                array(
                                        'col_name'=>'budget_Account',   
'label'=>lang('Budget account'),'className'=>'centerClasss', 'sortable'=>true,  
'sort_field'=>'spbudact_code',  'visible'=>true),
                                array(
-                                       'col_name'=>'sum',                      
'label'=>lang('Sum'),                   'className'=>'rightClasss', 
'sortable'=>true,   'sort_field'=>'belop',                  'visible'=>true),
+                                       'col_name'=>'sum',                      
        'label'=>lang('Sum'),                   'className'=>'rightClasss', 
'sortable'=>true,   'sort_field'=>'belop',                  'visible'=>true),
                                array(
+                                       'col_name'=>'currency',                 
'label'=>lang('currency'),              'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                       'visible'=>true),
+                               array(
                                        'col_name'=>'dim_A',                    
'label'=>lang('Dim A'),                 'className'=>'centerClasss', 
'sortable'=>true,  'sort_field'=>'dima',                   'visible'=>true),
                                array(
                                        'col_name'=>'dim_B',                    
'label'=>lang('Dim B'),                 'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                               
'visible'=>true),
                                array(
                                        'col_name'=>'dim_D',                    
'label'=>lang('Dim D'),                 'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                               
'visible'=>true),
                                array(
-                                       'col_name'=>'Tax_code',         
'label'=>lang('Tax code'),              'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                               
'visible'=>true),
+                                       'col_name'=>'Tax_code',                 
'label'=>lang('Tax code'),              'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                               
'visible'=>true),
                                array(
                                        'col_name'=>'Remark',                   
'label'=>lang('Remark'),                'className'=>'centerClasss', 
'sortable'=>false, 'sort_field'=>'',                               
'visible'=>true),
                                array(
@@ -1406,6 +1408,11 @@
 
                                                elseif(($i == 8))
                                                {
+                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['currency'];
+                                               }
+
+                                               elseif(($i == 9))
+                                               {
                                                        if($invoices['paid'] == 
true)
                                                        {
                                                                
$json_row[$uicols[$i]['col_name']]  .= $invoices['dima'];
@@ -1415,7 +1422,7 @@
                                                                
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dima][".$j."]' 
id='values[dima][".$j."]'  class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['dima']."'/>";
                                                        }
                                                }
-                                               elseif(($i == 9))
+                                               elseif(($i == 10))
                                                {
                                                        if($invoices['paid'] == 
true)
                                                        {
@@ -1442,7 +1449,7 @@
 
                                                        }
                                                }
-                                               elseif(($i == 10))
+                                               elseif(($i == 11))
                                                {
                                                        if($invoices['paid'] == 
true)
                                                        {
@@ -1453,7 +1460,7 @@
                                                                
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dimd][".$j."]' 
id='values[dimd][".$j."]'  class='myValuesForPHP'  type='text' size='4' 
value='".$invoices['dimd']."'/>";
                                                        }
                                                }
-                                               elseif(($i == 11))
+                                               elseif(($i == 12))
                                                {
                                                        if($invoices['paid'] == 
true)
                                                        {
@@ -1480,7 +1487,7 @@
 
                                                        }
                                                }
-                                               elseif(($i == 12))
+                                               elseif(($i == 13))
                                                {
                                                        if($invoices['remark'] 
== true)
                                                        {
@@ -1496,7 +1503,7 @@
                                                                
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
                                                        }
                                                }
-                                               elseif(($i == 13))
+                                               elseif(($i == 14))
                                                {
                                                        
if(isset($invoices['external_ref']) && $invoices['external_ref'])
                                                        {
@@ -1508,7 +1515,7 @@
                                                                
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
                                                        }
                                                }
-                                               elseif($i == 14)
+                                               elseif($i == 15)
                                                {
                                                        
$json_row[$uicols[$i]['col_name']]  = $invoices['counter'];
                                                }                               
        

Deleted: trunk/property/inc/class.uir_agreement.inc.php
===================================================================
--- trunk/property/inc/class.uir_agreement.inc.php      2010-11-12 13:34:53 UTC 
(rev 6587)
+++ trunk/property/inc/class.uir_agreement.inc.php      2010-11-13 17:15:50 UTC 
(rev 6588)
@@ -1,1838 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 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/bbb_/ekstern/
-       * @package property
-       * @subpackage agreement
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       phpgw::import_class('phpgwapi.yui');
-
-       class property_uir_agreement
-       {
-               var $grants;
-               var $cat_id;
-               var $start;
-               var $query;
-               var $sort;
-               var $order;
-               var $filter;
-
-               var $public_functions = array
-               (
-                       'index'                         => true,
-                       'view'                          => true,
-                       'edit'                          => true,
-                       'delete'                        => true,
-                       'columns'                       => true,
-                       'edit_item'                     => true,
-                       'view_item'                     => true,
-                       'view_file'                     => true,
-                       'download'                              => true,
-                       'edit_common'           => true,
-                       'delete_common_h'       => true
-               );
-
-               function property_uir_agreement()
-               {
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
-                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
'property::agreement::rental';
-                       $this->nextmatchs               = 
CreateObject('phpgwapi.nextmatchs');
-                       $this->account                  = 
$GLOBALS['phpgw_info']['user']['account_id'];
-
-                       $this->bo                               = 
CreateObject('property.bor_agreement',true);
-                       $this->bocommon                 = 
CreateObject('property.bocommon');
-
-                       $this->role                             = 
$this->bo->role;
-
-                       $this->cats                             = 
CreateObject('phpgwapi.categories', -1, 'property', '.tenant');
-
-                       $this->acl                              = & 
$GLOBALS['phpgw']->acl;
-                       $this->acl_location             = '.r_agreement';
-
-                       $this->acl_read                 = 
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
-                       $this->acl_add                  = 
$this->acl->check($this->acl_location, PHPGW_ACL_ADD, 'property');
-                       $this->acl_edit                 = 
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'property');
-                       $this->acl_delete               = 
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE, 'property');
-                       $this->acl_manage               = 
$this->acl->check($this->acl_location, 16, 'property');
-
-                       $this->start                    = $this->bo->start;
-                       $this->query                    = $this->bo->query;
-                       $this->sort                             = 
$this->bo->sort;
-                       $this->order                    = $this->bo->order;
-                       $this->filter                   = $this->bo->filter;
-                       $this->cat_id                   = $this->bo->cat_id;
-                       $this->customer_id              = 
$this->bo->customer_id;
-                       $this->allrows                  = $this->bo->allrows;
-                       $this->member_id                = $this->bo->member_id;
-                       $this->loc1                     = $this->bo->loc1;
-               }
-
-               function save_sessiondata()
-               {
-                       $data = array
-                       (
-                               'start'                 => $this->start,
-                               'query'                 => $this->query,
-                               'sort'                  => $this->sort,
-                               'order'                 => $this->order,
-                               'filter'                => $this->filter,
-                               'cat_id'                => $this->cat_id,
-                               'customer_id'   => $this->customer_id,
-                               'allrows'               => $this->allrows,
-                               'member_id'             => $this->member_id,
-                               'loc1'                  => $this->loc1
-                       );
-                       $this->bo->save_sessiondata($data);
-               }
-
-               function columns()
-               {
-
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
-
-                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
-
-                       $values = phpgw::get_var('values');
-
-                       if ($values['save'])
-                       {
-
-                               
$GLOBALS['phpgw']->preferences->account_id=$this->account;
-                               $GLOBALS['phpgw']->preferences->read();
-                               
$GLOBALS['phpgw']->preferences->add('property','r_agreement_columns',$values['columns'],'user');
-                               
$GLOBALS['phpgw']->preferences->save_repository();
-
-                               $receipt['message'][] = array('msg' => 
lang('columns is updated'));
-                       }
-
-                       $function_msg   = lang('Select Column');
-
-                       $link_data = array
-                       (
-                               'menuaction'    => 
'property.uir_agreement.columns',
-                               'role'          => $this->role
-                       );
-
-                       $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'column_list'   => 
$this->bo->column_list($values['columns'],$allrows=true),
-                               'function_msg'  => $function_msg,
-                               'form_action'   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'lang_columns'  => lang('columns'),
-                               'lang_none'             => lang('None'),
-                               'lang_save'             => lang('save'),
-                               'select_name'   => 'period'
-                       );
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
$function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
-               //      $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function view_file()
-               {
-                       if(!$this->acl_read)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
-                       }
-
-                       $bofiles        = CreateObject('property.bofiles');
-                       $bofiles->view_file('rental_agreement');
-               }
-
-               function index()
-               {
-                       if(!$this->acl_read)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
-                       }
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('r_agreement',
-                                                                               
'receipt',
-                                                                               
'search_field_grouped',
-                                                                               
'nextmatchs',
-                                                                               
));
-
-                       $receipt = 
$GLOBALS['phpgw']->session->appsession('session_data','r_agreement_receipt');
-                       
$GLOBALS['phpgw']->session->appsession('session_data','r_agreement_receipt','');
-
-                       $list = $this->bo->read();
-
-                       $uicols         = $this->bo->uicols;
-
-                       $j=0;
-
-                       if (isset($list) AND is_array($list))
-                       {
-                               foreach($list as $entry)
-                               {
-                                       for 
($i=0;$i<count($uicols['name']);$i++)
-                                       {
-                                               
if($uicols['input_type'][$i]!='hidden')
-                                               {
-                                                       
$content[$j]['row'][$i]['value']        = $entry[$uicols['name'][$i]];
-                                                       
$content[$j]['row'][$i]['name']         = $uicols['name'][$i];
-                                               }
-                                       }
-
-                                       if($this->acl_read)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']           = lang('view the entity');
-                                               $content[$j]['row'][$i]['text'] 
                        = lang('view');
-                                               
$content[$j]['row'][$i++]['link']                       = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.view', 'id'=> $entry['id'], 'role'=> $this->role));
-                                       }
-                                       if($this->acl_edit)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']           = lang('edit the r_agreement');
-                                               $content[$j]['row'][$i]['text'] 
                        = lang('edit');
-                                               
$content[$j]['row'][$i++]['link']                       = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.edit', 'id'=> $entry['id'], 'role'=> $this->role));
-                                       }
-                                       if($this->acl_delete)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']           = lang('delete the 
r_agreement');
-                                               $content[$j]['row'][$i]['text'] 
                        = lang('delete');
-                                               
$content[$j]['row'][$i++]['link']                       = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.delete', 'r_agreement_id'=> $entry['id'], 'role'=> 
$this->role));
-                                       }
-
-                                       $j++;
-                               }
-                       }
-
-//html_print_r($content);
-                       for ($i=0;$i<count($uicols['descr']);$i++)
-                       {
-                               if($uicols['input_type'][$i]!='hidden')
-                               {
-                                       $table_header[$i]['header']     = 
$uicols['descr'][$i];
-                                       $table_header[$i]['width']      = '5%';
-                                       $table_header[$i]['align']      = 
'center';
-                                       if($uicols['datatype'][$i]!='T' && 
$uicols['datatype'][$i]!='CH')
-                                       {
-                                               $table_header[$i]['sort_link']  
=true;
-                                               $table_header[$i]['sort']       
        = $this->nextmatchs->show_sort_order(array
-                                                       (
-                                                               'sort'  => 
$this->sort,
-                                                               'var'   =>      
$uicols['name'][$i],
-                                                               'order' =>      
$this->order,
-                                                               'extra'         
=> array('menuaction'   => 'property.uir_agreement.index',
-                                                                               
                        'query'                 => $this->query,
-                                                                               
                        'lookup'                => $lookup,
-                                                                               
                        'district_id'   => $this->district_id,
-                                                                               
                        'start_date'    => $start_date,
-                                                                               
                        'role'                  => $this->role,
-                                                                               
                        'member_id'             => $this->member_id,
-                                                                               
                        'allrows'               => $this->allrows,
-                                                                               
                        'end_date'              => $end_date
-                                                                               
                        )
-                                                       ));
-                                       }
-                               }
-                       }
-
-                       if($this->acl_read)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('view');
-                               $i++;
-                       }
-                       if($this->acl_edit)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('edit');
-                               $i++;
-                       }
-                       if($this->acl_delete)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('delete');
-                               $i++;
-                       }
-
-
-                       if($this->acl_add)
-                       {
-                               $table_add = array
-                               (
-                                       'lang_add'                              
=> lang('add'),
-                                       'lang_add_statustext'   => lang('add a 
rental agreement'),
-                                       'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.edit', 'role'=> $this->role))
-                               );
-                       }
-
-                       $link_data = array
-                       (
-                               'menuaction'    => 
'property.uir_agreement.index',
-                               'sort'                  => $this->sort,
-                               'order'                 => $this->order,
-                               'cat_id'                => $this->cat_id,
-                               'filter'                => $this->filter,
-                               'query'                 => $this->query,
-                               'role'                  => $this->role,
-                               'member_id'             => $this->member_id,
-                               'customer_id'   => $this->customer_id,
-                               'loc1'                  => $this->loc1,
-
-                       );
-
-                       if(!$this->allrows)
-                       {
-                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       }
-                       else
-                       {
-                               $record_limit   = $this->bo->total_records;
-                       }
-
-                       $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-                       $link_columns = array
-                       (
-                               'menuaction'    => 
'property.uir_agreement.columns',
-                               'role'          => $this->role
-                       );
-
-                       $member_of_data = 
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals' 
=> true,link_data => $link_data));
-
-                       
$GLOBALS['phpgw']->js->validate_file('overlib','overlib','property');
-
-//_debug_array($member_of_data);
-                       $data = array
-                       (
-                               'menu'                                          
        => $this->bocommon->get_menu(),
-                               'lang_columns'                                  
=> lang('columns'),
-                               'link_columns'                                  
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
-                               'lang_columns_help'                             
=> lang('Choose columns'),
-                               'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'allow_allrows'                                 
=> true,
-                               'allrows'                                       
        => $this->allrows,
-                               'start_record'                                  
=> $this->start,
-                               'record_limit'                                  
=> $record_limit,
-                               'num_records'                                   
=> count($list),
-                               'all_records'                                   
=> $this->bo->total_records,
-                               'link_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-                               'lang_no_cat'                                   
=> lang('no category'),
-                               'lang_cat_statustext'                   => 
lang('Select the category the r_agreement belongs to. To do not use a category 
select NO CATEGORY'),
-                               'select_name'                                   
=> 'cat_id',
-                               'cat_list'                                      
        => 
$this->bocommon->select_category_list(array('format'=>'select','selected' => 
$this->cat_id,'type' =>'r_agreement','order'=>'descr')),
-
-                               'select_action'                                 
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
-//                             'lang_no_vendor'                                
=> lang('no vendor'),
-//                             'lang_vendor_statustext'                        
=> lang('Select the vendor the r_agreement belongs to.'),
-//                             'vendor_list'                                   
=> $this->bo->select_vendor_list('filter',$this->vendor_id),
-
-                               'lang_no_member'                                
=> lang('no member'),
-                               'member_of_name'                                
=> 'member_id',
-                               'member_of_list'                                
=> $member_of_data['cat_list'],
-
-                               'filter_list'                                   
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
-                               'lang_filter_statustext'                => 
lang('Select the filter. To show all entries select SHOW ALL'),
-                               'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
-                               'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
-                               'query'                                         
        => $this->query,
-                               'lang_search'                                   
=> lang('search'),
-                               'table_header'                                  
=> $table_header,
-                               'values'                                        
        => $content,
-                               'table_add'                                     
        => $table_add,
-
-                               'tenant_link'                                   
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uilookup.tenant')),
-                               'lang_select_tenant_statustext' => lang('Select 
the customer by clicking this link'),
-                               'lang_tenant'                                   
=> lang('customer'),
-                               'property_link'                                 
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uilocation.index', 'lookup'=>1, 'type_id'=>1, 'lookup_name'=>0)),
-                               'lang_select_property_statustext'=> 
lang('Select the property by clicking this link'),
-                               'lang_property_statustext'              => 
lang('Search by property'),
-                               'lang_property'                                 
=> lang('property'),
-                               'customer_id'                                   
=> $this->customer_id,
-                               'loc1'                                          
        => $this->loc1,
-                       );
-                       $this->save_sessiondata();
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('rental agreement') . ': ' . lang('list ' . $this->role);
-
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
-               //      $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function list_content($list,$uicols,$edit_item='',$view_only='')
-               {
-                       $j=0;
-
-                       if (isset($list) AND is_array($list))
-                       {
-                               foreach($list as $entry)
-                               {
-                                       $content[$j]['id']                      
= $entry['id'];
-                                       $content[$j]['item_id']         = 
$entry['item_id'];
-                                       $content[$j]['index_count']     = 
$entry['index_count'];
-                                       $content[$j]['cost']            = 
$entry['cost'];
-                                       for 
($i=0;$i<count($uicols['name']);$i++)
-                                       {
-                                               
if($uicols['input_type'][$i]!='hidden')
-                                               {
-                                                       
$content[$j]['row'][$i]['name']                         = $uicols['name'][$i];
-
-                                                       if($uicols['name'][$i] 
== 'rental_type_id')
-                                                       {
-                                                               
$content[$j]['row'][$i]['value'] = 
$this->bo->get_rental_type_list2($entry[$uicols['name'][$i]]);
-                                                       }
-                                                       else
-                                                       {
-                                                               
$content[$j]['row'][$i]['value']                        = 
$entry[$uicols['name'][$i]];
-                                                       }
-                                               }
-                                       }
-
-                                       if($this->acl_read && !$edit_item && 
!$view_only)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']                   = lang('view the 
entity');
-                                               $content[$j]['row'][$i]['text'] 
                                = lang('view');
-                                               
$content[$j]['row'][$i++]['link']                               = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.view_item', 'r_agreement_id'=> $entry['agreement_id'], 
'id'=> $entry['id']));
-                                       }
-                                       if($this->acl_edit && !$edit_item && 
!$view_only)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']                   = lang('edit the 
r_agreement');
-                                               $content[$j]['row'][$i]['text'] 
                                = lang('edit');
-                                               
$content[$j]['row'][$i++]['link']                               = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.edit_item', 'r_agreement_id'=> $entry['agreement_id'], 
'id'=> $entry['id']));
-                                       }
-                                       if($this->acl_delete && !$edit_item && 
!$view_only)
-                                       {
-                                               
$content[$j]['row'][$i]['statustext']                   = lang('delete this 
item');
-                                               $content[$j]['row'][$i]['text'] 
                                = lang('delete');
-                                               
$content[$j]['row'][$i++]['link']                               = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uir_agreement.edit', 'delete_item'=>1, 'id'=> $entry['agreement_id'], 
'item_id'=> $entry['id']));
-                                       }
-
-                                       $j++;
-                               }
-                       }
-
-//html_print_r($content);
-                       for ($i=0;$i<count($uicols['descr']);$i++)
-                       {
-                               if($uicols['input_type'][$i]!='hidden')
-                               {
-                                       $table_header[$i]['header']     = 
$uicols['descr'][$i];
-                                       $table_header[$i]['width']              
= '5%';
-                                       $table_header[$i]['align']              
= 'center';
-                               }
-                       }
-
-                       if($this->acl_read && !$edit_item && !$view_only)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('view');
-                               $i++;
-                       }
-                       if($this->acl_edit && !$edit_item && !$view_only)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('edit');
-                               $i++;
-                       }
-                       if($this->acl_delete && !$edit_item && !$view_only)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('delete');
-                               $i++;
-                       }
-                       if($this->acl_manage && !$edit_item && !$view_only)
-                       {
-                               $table_header[$i]['width']                      
= '5%';
-                               $table_header[$i]['align']                      
= 'center';
-                               $table_header[$i]['header']                     
= lang('Update');
-                               $i++;
-                       }
-
-                       return 
array('content'=>$content,'table_header'=>$table_header);
-               }
-
-
-               function edit()
-               {
-                       $id                             = phpgw::get_var('id', 
'int');
-                       $values                 = phpgw::get_var('values');
-                       $delete_item    = phpgw::get_var('delete_item', 'bool');
-                       $item_id                = phpgw::get_var('item_id', 
'int', 'GET');
-                       $active_tab             = phpgw::get_var('tab', 
'string', 'REQUEST', 'general');
-
-                       $config                 = 
CreateObject('phpgwapi.config','property');
-                       $boalarm                = 
CreateObject('property.boalarm');
-
-                       if($delete_item && $id && $item_id)
-                       {
-                               $this->bo->delete_item($id,$item_id);
-                       }
-
-                       $values_attribute  = phpgw::get_var('values_attribute');
-
-                       $insert_record_r_agreement = 
$GLOBALS['phpgw']->session->appsession('insert_record_values.r_agreement','property');
-
-//_debug_array($insert_record_r_agreement);
-                       for ($j=0;$j<count($insert_record_r_agreement);$j++)
-                       {
-                               
$insert_record['extra'][$insert_record_r_agreement[$j]] = 
$insert_record_r_agreement[$j];
-                       }
-
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('r_agreement', 'attributes_form', 
'files'));
-
-                       if (is_array($values))
-                       {
-                               while (is_array($insert_record['extra']) && 
list($key,$column) = each($insert_record['extra']))
-                               {
-                                       if($_POST[$key])
-                                       {
-                                               $values['extra'][$column]       
= $_POST[$key];
-                                       }
-                               }
-
-//_debug_array($values);
-
-                               if ($values['save'] || $values['apply'])
-                               {
-                                       $values['customer_id']          = 
phpgw::get_var('tenant_id', 'int', 'POST');
-                                       $values['customer_name']        = 
phpgw::get_var('last_name', 'string', 'POST');
-                                       $first_name                             
        = phpgw::get_var('first_name', 'string', 'POST');
-                                       if($first_name)
-                                       {
-                                               $values['customer_name'] = 
$first_name . ' ' . $values['customer_name'];
-                                       }
-
-                                       $values['b_account_id']         = 
phpgw::get_var('b_account_id', 'int', 'POST');
-                                       $values['b_account_name']       = 
phpgw::get_var('b_account_name', 'string', 'POST');
-
-                                       if(!$values['cat_id'])
-                                       {
-                                               
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
-                                       }
-
-                                       if(!$values['last_name'])
-                                       {
-//                                             
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
-                                       }
-
-
-                                       if($id)
-                                       {
-                                               $values['r_agreement_id']=$id;
-                                               $action='edit';
-                                       }
-                                       else
-                                       {
-                                               
$values['r_agreement_id']=$this->bo->request_next_id();
-                                       }
-
-                                       $bofiles        = 
CreateObject('property.bofiles');
-                                       if(isset($id) && $id && 
isset($values['file_action']) && is_array($values['file_action']))
-                                       {
-                                               
$bofiles->delete_file("/rental_agreement/{$id}/", $values);
-                                       }
-
-                                       if(isset($_FILES['file']['name']) && 
$_FILES['file']['name'])
-                                       {
-                                               
$values['file_name']=str_replace (' ','_',$_FILES['file']['name']);
-                                               $to_file = 
"{$bofiles->fakebase}/rental_agreement/{$values['r_agreement_id']}/{$values['file_name']}";
-
-                                               
if(!$values['document_name_orig'] && $bofiles->vfs->file_exists(array(
-                                                               'string' => 
$to_file,
-                                                               'relatives' => 
Array(RELATIVE_NONE)
-                                                       )))
-                                               {
-                                                       
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
-                                               }
-                                       }
-
-                                       if(!$receipt['error'])
-                                       {
-//                                             $values['r_agreement_id']       
= $id;
-
-                                               $receipt = 
$this->bo->save($values,$values_attribute,$action);
-                                               $id = 
$receipt['r_agreement_id'];
-                                               $this->cat_id = 
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
-                                               if($values['file_name'])
-                                               {
-                                                       
$bofiles->create_document_dir("rental_agreement/{$id}");
-                                                       
$bofiles->vfs->override_acl = 1;
-
-                                                       if(!$bofiles->vfs->cp 
(array (
-                                                               'from'  => 
$_FILES['file']['tmp_name'],
-                                                               'to'    => 
$to_file,
-                                                               'relatives'     
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
-                                                       {
-                                                               
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
-                                                       }
-                                                       
$bofiles->vfs->override_acl = 0;
-                                               }
-
-
-                                               if ($values['save'])
-                                               {
-                                                       
$GLOBALS['phpgw']->session->appsession('session_data','r_agreement_receipt',$receipt);
-                                                       
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uir_agreement.index', 'role'=> $this->role));
-                                               }
-                                       }
-                               }
-                               else if($values['update'])
-                               {
-                                       if(!$values['date'])
-                                       {
-                                               
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
-                                       }
-                                       if(!$values['new_index'])
-                                       {
-                                               
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
-                                       }
-
-                                       if(!$receipt['error'])
-                                       {
-                                               $receipt = 
$this->bo->update($values);
-                                       }
-
-                               }
-                               else if($values['delete_alarm'] && 
count($values['alarm']))
-                               {
-
-                                       if(!$receipt['error'])
-                                       {
-                                               $receipt = 
$boalarm->delete_alarm('r_agreement',$values['alarm']);
-                                       }
-
-                               }
-                               else if(($values['enable_alarm'] || 
$values['disable_alarm']) && count($values['alarm']))
-                               {
-
-                                       if(!$receipt['error'])
-                                       {
-                                               $receipt = 
$boalarm->enable_alarm('r_agreement',$values['alarm'],$values['enable_alarm']);
-                                       }
-
-                               }
-                               else if($values['add_alarm'])
-                               {
-                                       $time = 
intval($values['time']['days'])*24*3600 +
-                                               
intval($values['time']['hours'])*3600 +
-                                               
intval($values['time']['mins'])*60;
-
-                                       if ($time > 0)
-                                       {
-                                               $receipt = 
$boalarm->add_alarm('r_agreement',$this->bo->read_event(array('r_agreement_id'=>$id)),$time,$values['user_id']);
-                                       }
-                               }
-                               else if (!$values['save'] && !$values['apply'] 
&& !$values['update'])
-                               {
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uir_agreement.index', 'role'=> $this->role));
-                               }
-                       }
-
-                       $r_agreement = 
$this->bo->read_single(array('r_agreement_id'=>$id));
-
-                       /* Preserve attribute values from post */
-                       if(isset($receipt['error']) && (isset( 
$values_attribute) && is_array( $values_attribute)))
-                       {
-                               $r_agreement = 
$this->bocommon->preserve_attribute_values($r_agreement,$values_attribute);
-                       }
-
-                       $jscal = CreateObject('phpgwapi.jscalendar');
-                       $jscal->add_listener('values_start_date');
-                       $jscal->add_listener('values_end_date');
-                       $jscal->add_listener('values_termination_date');
-
-                       if ($id)
-                       {               
-                               $this->cat_id = 
($r_agreement['cat_id']?$r_agreement['cat_id']:$this->cat_id);
-                               $this->member_id = 
($r_agreement['member_of']?$r_agreement['member_of']:$this->member_id);
-                               $list = $this->bo->read_details($id);
-
-                               if($list)
-                               {
-                                       $jscal->add_listener('values_date');
-                               }
-
-                               $uicols         = $this->bo->uicols;
-                               $list           = 
$this->list_content($list,$uicols);
-                               $content        = $list['content'];
-                               $table_header=$list['table_header'];
-                               for ($i=0; 
$i<count($list['content'][0]['row']); $i++)
-                               {
-                                       $set_column[]=true;
-                               }
-
-                               if ($content)
-                               {
-                                       $table_update[] = array
-                                       (
-                                               'img_cal'                       
                => $GLOBALS['phpgw']->common->image('phpgwapi','cal'),

@@ Diff output truncated at 153600 characters. @@



reply via email to

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