fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8798] Merge 8775:8797 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [8798] Merge 8775:8797 from trunk
Date: Tue, 07 Feb 2012 07:35:51 +0000

Revision: 8798
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8798
Author:   sigurdne
Date:     2012-02-07 07:35:50 +0000 (Tue, 07 Feb 2012)
Log Message:
-----------
Merge 8775:8797 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php
    
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php
    branches/Version-1_0-branch/controller/inc/class.menu.inc.php
    branches/Version-1_0-branch/controller/inc/class.socase.inc.php
    branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php
    branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php
    branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
    branches/Version-1_0-branch/controller/inc/class.soprocedure.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
    branches/Version-1_0-branch/controller/inc/class.uidocument.inc.php
    branches/Version-1_0-branch/controller/inc/class.uiprocedure.inc.php
    branches/Version-1_0-branch/controller/js/controller/ajax.js
    branches/Version-1_0-branch/controller/setup/phpgw_no.lang
    branches/Version-1_0-branch/controller/setup/setup.inc.php
    branches/Version-1_0-branch/controller/setup/tables_current.inc.php
    branches/Version-1_0-branch/controller/setup/tables_update.inc.php
    
branches/Version-1_0-branch/controller/templates/base/add_component_to_control.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    
branches/Version-1_0-branch/controller/templates/base/procedure/view_procedures_for_control.xsl
    branches/Version-1_0-branch/property/inc/class.soXport.inc.php
    branches/Version-1_0-branch/property/inc/class.sotts.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.uitts.inc.php
    
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
    branches/Version-1_0-branch/property/inc/hook_home.inc.php
    branches/Version-1_0-branch/property/setup/phpgw_no.lang
    branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
    branches/Version-1_0-branch/rental/templates/base/contract_list.php

Added Paths:
-----------
    
branches/Version-1_0-branch/controller/inc/class.uicontrol_group_component.inc.php
    
branches/Version-1_0-branch/controller/templates/base/add_component_to_control_group.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_group_component_tabs.xsl
    
branches/Version-1_0-branch/controller/templates/base/view_component_for_control_group.xsl
    
branches/Version-1_0-branch/property/inc/custom/default/ticket_redirect_based_on_status.php

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797

Modified: 
branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php   
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php   
2012-02-07 07:35:50 UTC (rev 8798)
@@ -37,7 +37,8 @@
                                        }                       
                     else
                     {
-                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = lang('None');
+                               // FIXME Sigurd Nes 4. februar 2012: det er 
feil i datasettet om denne slår til
+                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = 
$from_entity['customer_number'];//lang('None');
                     }
                 } 
                 else 

Modified: 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php
===================================================================
--- 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php   
    2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php   
    2012-02-07 07:35:50 UTC (rev 8798)
@@ -153,6 +153,7 @@
                        $method = "initialize_completed_{$type}";
                        $this->$method($reservation, $entity);
                        $this->set_description($type, $reservation, $entity);
+
                        $this->add($entity);
                }
                

Modified: branches/Version-1_0-branch/controller/inc/class.menu.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.menu.inc.php       
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.menu.inc.php       
2012-02-07 07:35:50 UTC (rev 8798)
@@ -2,7 +2,7 @@
        /**
        * phpGroupWare - controller: a part of a Facilities Management System.
        *
-       * @author Erink Holm-Larsen <address@hidden>
+       * @author Erik Holm-Larsen <address@hidden>
        * @author Torstein Vadla <address@hidden>
        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
        * This file is part of phpGroupWare.
@@ -88,7 +88,15 @@
                                        (
                                                'text'  => 
lang('Control_group'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol_group.index') ),
-                                               'image' => array('property', 
'location_1')
+                                               'image' => array('property', 
'location_1'),
+                                               'children' => array(
+                                                                               
        'component_for_control_group' => array
+                                                                               
        (
+                                                                               
                'text'  => lang('component'),
+                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_group_component.index') ),
+                                                                               
                'image' => array('property', 'entity_1')
+                                                                               
        )
+                                                                               
)
                                        ),
                                        'procedure' => array
                                        (

Modified: branches/Version-1_0-branch/controller/inc/class.socase.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socase.inc.php     
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.socase.inc.php     
2012-02-07 07:35:50 UTC (rev 8798)
@@ -81,10 +81,10 @@
                        }
                }
                
-               public function get_cases_by_message($message_ticket_id, 
$return_type = "return_object")
+               public function get_cases_by_message($location_id, 
$location_item_id, $return_type = "return_object")
                {
                        $sql = "SELECT * FROM controller_check_item_case "; 
-                       $sql .= "WHERE location_item_id = $message_ticket_id";
+                       $sql .= "WHERE location_id = {$location_id} AND 
location_item_id = {$location_item_id}";
 
                        $this->db->query($sql);
 

Modified: branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php       
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php       
2012-02-07 07:35:50 UTC (rev 8798)
@@ -471,11 +471,14 @@
                        }
                }
                
-               public function get_check_items_by_message($message_ticket_id, 
$return_type = "return_array" ){
+               public function get_check_items_by_message($location_id, 
$location_item_id, $return_type = "return_array" )
+               {
+                       $location_id            = (int)$location_id;
+                       $location_item_id       = (int)$location_item_id;
                        $sql  = "SELECT ci.* "; 
                        $sql .= "FROM controller_check_item ci "; 
                        $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
-                       $sql .= "WHERE cic.location_item_id = 
$message_ticket_id ";
+                       $sql .= "WHERE cic.location_id = {$location_id} AND 
cic.location_item_id = {$location_item_id} ";
                                                                
                        $this->db->query($sql);
                        

Modified: branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php       
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php       
2012-02-07 07:35:50 UTC (rev 8798)
@@ -306,7 +306,7 @@
                
                $sql =  "SELECT c.id as c_id, title, start_date, end_date, 
cl.id as cl_id, c.repeat_type, c.repeat_interval, cl.deadline, count(ci.id) ";
                $sql .= "FROM controller_check_list cl, controller_control c, 
controller_check_item ci ";
-               $sql .= "WHERE cl.location_code = $location_code ";
+               $sql .= "WHERE cl.location_code = '{$location_code}' ";
                $sql .= "AND c.repeat_type < 2 ";
                $sql .= "AND cl.control_id = c.id ";
                $sql .= "AND cl.id = ci.check_list_id ";
@@ -360,7 +360,7 @@
                
                $sql =  "SELECT c.id as c_id, sum(cl.num_open_cases) as count ";
                $sql .= "FROM controller_check_list cl, controller_control c ";
-               $sql .= "WHERE cl.location_code = $location_code ";
+               $sql .= "WHERE cl.location_code = '{$location_code}' ";
                $sql .= "AND c.id = $control_id ";
                $sql .= "AND c.repeat_type < 2 ";
                $sql .= "AND cl.control_id = c.id ";
@@ -448,7 +448,7 @@
                $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
                $sql .= "FROM controller_control c ";
                $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
-               $sql .= "WHERE cl.location_code = '{$location_code} ";
+               $sql .= "WHERE cl.location_code = '{$location_code}' ";
                
                if( is_numeric($repeat_type) )
                        $sql .= "AND c.repeat_type = $repeat_type ";

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php    
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php    
2012-02-07 07:35:50 UTC (rev 8798)
@@ -346,4 +346,76 @@
                        //var_dump($control_group);
                        return $control_group;
                }
+               
+               function get_control_groups_by_control_area($control_area_id)
+               {
+                       $controls_array = array();
+
+                       $sql = "SELECT * FROM controller_control_group WHERE 
control_area_id=$control_area_id";
+                       $this->db->query($sql);
+
+                       while($this->db->next_record()) {
+                               $control_group = new 
controller_control_group((int) $this->db->f('id'));
+
+                               
$control_group->set_group_name($this->unmarshal($this->db->f('group_name'), 
'string'));
+                               
$control_group->set_procedure_id($this->unmarshal($this->db->f('procedure_id'), 
'int'));
+                               
$control_group->set_procedure_name($this->unmarshal($this->db->f('procedure_title'),
 'string'));
+                               
$control_group->set_control_area_id($this->unmarshal($this->db->f('control_area_id'),
 'int'));
+                               $category = 
execMethod('phpgwapi.categories.return_single', 
$this->unmarshal($this->db->f('control_area_id', 'int')));
+                               
$control_group->set_control_area_name($category[0]['name']);
+                               
//$control_group->set_control_area_name($this->unmarshal($this->db->f('control_area_name'),
 'string'));
+                               
$control_group->set_building_part_id($this->unmarshal($this->db->f('building_part_id'),
 'int'));
+                               
$control_group->set_building_part_descr($this->unmarshal($this->db->f('building_part_descr'),
 'string'));
+
+                               $control_groups_array[] = 
$control_group->toArray();
+                       }
+
+                       if( count( $control_groups_array ) > 0 ){
+                               return $control_groups_array; 
+                       }
+                       else
+                       {
+                               return null;
+                       }
+               }
+               
+               public function get_control_group_component($noOfObjects = 
null, $bim_type = null)
+               {
+                       $filters = array();
+                       if($noOfObjects != null && is_numeric($noOfObjects))
+                       {
+                               $limit = "LIMIT {$noOfObjects}";
+                       }
+                       else
+                       {
+                               $limit = "LIMIT 10";
+                       }
+
+                       $joins = " {$this->left_join} controller_control_group 
ON (controller_control_group_component_list.control_group_id = 
controller_control_group.id)";
+                       $joins .= " {$this->left_join} fm_bim_item ON 
(controller_control_group_component_list.component_id = fm_bim_item.id)";
+                       $joins .= " {$this->left_join} fm_bim_type ON 
(fm_bim_item.type= fm_bim_type.id)";
+                       //$joins .= " {$this->left_join} fm_responsibility_role 
ON (c.responsibility_id = fm_responsibility_role.id)";
+                       $sql  = "SELECT controller_control_group.id AS 
control_group_id, controller_control_group.group_name AS control_group_name, 
fm_bim_type.name AS type_name, fm_bim_item.id AS bim_id, fm_bim_item.guid as 
bim_item_guid FROM controller_control_group_component_list {$joins} {$limit}";
+                       $controlGroupArray = array();
+                       //var_dump($sql);
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       $i=1;
+                       while($this->db->next_record())
+                       {
+                               $controlGroupArray[$i]['id'] = 
$this->db->f('control_group_id');
+                               $controlGroupArray[$i]['title'] = 
$this->db->f('control_group_name');
+                               $controlGroupArray[$i]['bim_id'] = 
$this->db->f('bim_id');
+                               $controlGroupArray[$i]['bim_item_guid'] = 
$this->db->f('bim_item_guid');
+                               $controlGroupArray[$i]['bim_type'] = 
$this->db->f('type_name');
+                               $i++;
+                       }
+
+                       return $controlGroupArray;
+               }
+               
+               function add_component_to_control_group($control_group_id, 
$component_id)
+               {
+                       $sql =  "INSERT INTO 
controller_control_group_component_list (control_group_id, component_id) 
values($control_group_id, $component_id)";
+                       $this->db->query($sql);
+               }
        }

Modified: branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php 
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php 
2012-02-07 07:35:50 UTC (rev 8798)
@@ -229,6 +229,21 @@
                
        }
        
+       public function list_document_types()
+       {
+               $sql = "SELECT id, title FROM controller_document_types";
+               $this->db->query($sql, __LINE__, __FILE__);
+               $results = array();
+               while($this->db->next_record()){
+                       $result[] = $this->db->f('id', true);
+                       $result[] = $this->db->f('title', true);
+                       $results[] = $result;
+               }
+               //$document_type_list = $results;
+               return $results;
+               
+       }
+       
        private function get_document_path(string $document_type, $id)
        {
                $root_directory = self::$ROOT_FOR_DOCUMENTS;

Modified: branches/Version-1_0-branch/controller/inc/class.soprocedure.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.soprocedure.inc.php        
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.soprocedure.inc.php        
2012-02-07 07:35:50 UTC (rev 8798)
@@ -29,6 +29,7 @@
        */      
 
        phpgw::import_class('controller.socommon');
+       phpgw::import_class('controller.uidocument');
 
        include_class('controller', 'procedure', 'inc/model/');
        include_class('controller', 'document', 'inc/model/');
@@ -225,7 +226,12 @@
                                        
$document->set_description($this->unmarshal($this->db->f('document_description',
 true), 'string'));
                                        
                                        if($return_type == "return_array")
-                                               $documents_array[] = 
$document->toArray();
+                                       {
+                                               $doc_as_array = 
$document->toArray();
+                                               $doc_as_array['document_link'] 
= controller_uidocument::link(array('menuaction' => 
'controller.uidocument.view', 'id' => $document->get_id()));
+                                               //_debug_array($doc_as_array);
+                                               $documents_array[] = 
$doc_as_array;
+                                       }
                                        else
                                                $documents_array[] = $document;
                                }

Modified: branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicase.inc.php     
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.uicase.inc.php     
2012-02-07 07:35:50 UTC (rev 8798)
@@ -298,14 +298,14 @@
                
                public function updateStatusForCases($location_id, 
$location_item_id, $updateStatus = 0){
                        
-                       $cases_array = $this->so->get_cases_by_message( 
$location_item_id );
+                       $cases_array = $this->so->get_cases_by_message( 
$location_id, $location_item_id );
                        
                        foreach($cases_array as $case){
                                $case->set_status( $updateStatus );
                                $this->so->update( $case );     
                        }
                        
-                       $check_items = 
$this->so_check_item->get_check_items_by_message($message_ticket_id, 
"return_object");
+                       $check_items = 
$this->so_check_item->get_check_items_by_message($location_id, 
$location_item_id, "return_object");
                        
                        if($updateStatus == 0){
 

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php    
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php    
2012-02-07 07:35:50 UTC (rev 8798)
@@ -54,7 +54,8 @@
                        'edit'  =>      true,
                        'view'  =>      true,
                        'add'   =>      true,
-                       'save_group_order'      =>      true
+                       'save_group_order'      =>      true,
+                       'get_control_groups_by_control_area' => true
                );
 
                public function __construct()
@@ -708,5 +709,17 @@
                        }
                }
 
+               // Returns control group list info as JSON
+               public function get_control_groups_by_control_area()
+               {
+                       $control_area_id = phpgw::get_var('control_area_id');
+                       
+                       $control_groups_array = 
$this->so->get_control_groups_by_control_area($control_area_id);
+                       
+                       if(count($control_groups_array)>0)
+                               return json_encode( $control_groups_array );
+                       else
+                               return null;
+               }
 
        }

Copied: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_group_component.inc.php
 (from rev 8797, trunk/controller/inc/class.uicontrol_group_component.inc.php)
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.uicontrol_group_component.inc.php
                          (rev 0)
+++ 
branches/Version-1_0-branch/controller/inc/class.uicontrol_group_component.inc.php
  2012-02-07 07:35:50 UTC (rev 8798)
@@ -0,0 +1,399 @@
+<?php
+       /**
+       * phpGroupWare - controller: a part of a Facilities Management System.
+       *
+       * @author Erik Holm-Larsen <address@hidden>
+       * @author Torstein Vadla <address@hidden>
+       * @copyright Copyright (C) 2011,2012 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/
+       * @package property
+       * @subpackage controller
+       * @version $Id$
+       */      
+
+
+       phpgw::import_class('phpgwapi.yui');
+       phpgw::import_class('controller.uicommon');
+       phpgw::import_class('controller.socontrol_area');
+       //phpgw::import_class('bim.sobimitem');
+
+       class controller_uicontrol_group_component extends controller_uicommon
+       {
+               var $cat_id;
+               var $start;
+               var $query;
+               var $sort;
+               var $order;
+               var $filter;
+               var $currentapp;
+               var $type_id;
+               var $location_code;
+
+               private $so_control_area;
+               private $so_control_group;
+               private $so_control;  
+               private $so_bim;
+
+               var $public_functions = array(
+                                                                               
'index' => true,
+                                                                               
'add_component_to_control_group' => true,
+                                                                               
'get_component_types_by_category' => true
+                                                                       );
+
+               function __construct()
+               {
+                       parent::__construct();
+
+                       $this->bo                                       = 
CreateObject('property.bolocation',true);
+                       $this->bocommon                         = & 
$this->bo->bocommon;
+                       $this->so_control_area          = 
CreateObject('controller.socontrol_area');
+                       $this->so_control_group         = 
CreateObject('controller.socontrol_group');
+                       $this->so_control                       = 
CreateObject('controller.socontrol');
+                       //$this->so_bim                         = 
CreateObject('bim.sobimitem_impl');
+                       //$this->so_bim                         = new 
sobimitem_impl();
+
+                       $this->type_id                          = 
$this->bo->type_id;
+
+                       $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->part_of_town_id          = 
$this->bo->part_of_town_id;
+                       $this->district_id                      = 
$this->bo->district_id;
+                       $this->status                           = 
$this->bo->status;
+                       $this->allrows                          = 
$this->bo->allrows;
+                       $this->lookup                           = 
$this->bo->lookup;
+                       $this->location_code            = 
$this->bo->location_code;
+
+                       
self::set_active_menu('controller::control_group::component_for_control_group');
+               }
+
+               function index()
+               {
+                       if(phpgw::get_var('phpgw_return_as') == 'json') {
+                               return $this->query();
+                       }
+                       $bim_types = $this->so_control->get_bim_types();
+
+                       // Sigurd: START as categories
+                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
+                       $cats->supress_info     = true;
+
+                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => $this->_category_acl));
+                       array_unshift($control_areas['cat_list'],array 
('cat_id'=>'','name'=> lang('select value')));
+                       $control_areas_array = array();
+                       foreach($control_areas['cat_list'] as $cat_list)
+                       {
+                               $control_areas_array[] = array
+                               (
+                                       'id'    => $cat_list['cat_id'],
+                                       'name'  => $cat_list['name'],
+                               );              
+                       }
+                       // END as categories
+                       
+                       $control_groups_array = 
$this->so_control_group->get_control_groups_by_control_area($control_areas_array[1]['id']);
+                       //_debug_array($control_groups_array);
+                       //$control_id = $control_groups_array[0]['id'];
+                       array_unshift($control_groups_array,array 
('id'=>'','group_name'=> lang('select value')));
+
+//                     if($control_id == null)
+//                             $control_id = 0;
+
+                       $tabs = array( array(
+                                               'label' => 
lang('View_component_for_control_group')
+                                       ), array(
+                                               'label' => 
lang('Add_component_for_control_group'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_group_component.add_component_to_control_group'))
+                                       ));
+
+                       $data = array(
+                               'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+                               'view'                                  => 
"view_component_for_control_group",
+                               'control_area_array'    => $control_areas_array,
+                               'control_group_array'   => 
$control_groups_array,
+                               'locations_table' => array(
+                                       'source' => 
self::link(array('menuaction' => 
'controller.uicontrol_group_component.index','phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => 
lang('ControlId'),
+                                                       'sortable'      => true,
+                                               ),
+                                               array(
+                                                       'key'   =>      'title',
+                                                       'label' =>      
lang('Title'),
+                                                       'sortable'      =>      
false
+                                               ),
+                                               array(
+                                                       'key' => 'bim_id',
+                                                       'label' => 
lang('Bim_id'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 'bim_name',
+                                                       'label' => 
lang('Bim_name'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 'bim_type',
+                                                       'label' => 
lang('Bim_type'),
+                                                       'sortable'      => false
+                                               )
+                                       )
+                               )
+                       );
+
+
+                       phpgwapi_yui::load_widget('paginator');
+
+                       self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
+
+                       
self::render_template_xsl(array('control_group_component_tabs', 'common', 
'view_component_for_control_group'), $data);
+               }
+
+               function add_component_to_control_group()
+               {
+                       if(phpgw::get_var('save_component'))
+                       {
+                               //add component to control using component item 
ID
+                               $items_checked = array();
+                               $items = phpgw::get_var('values_assign');
+                               $item_arr = explode('|',$items);
+                               foreach($item_arr as $item)
+                               {
+                                       $items_checked[] = explode(';',$item);
+                               }
+                               //var_dump($items_checked);
+
+                               $control_group_id = 
phpgw::get_var('control_group_id');
+                               //var_dump($control_id);
+                               if($control_group_id != null && 
is_numeric($control_group_id))
+                               {
+                                       //add chosen component to control
+                                       foreach($items_checked as $it)
+                                       {
+                                               
$this->so_control_group->add_component_to_control_group($control_group_id, 
$it[0]);
+                                       }
+                               }
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_group_component.index'));
+
+                       }
+                       else
+                       {
+                               if(phpgw::get_var('phpgw_return_as') == 'json') 
{
+                                       return $this->get_component();
+                               }
+
+                               $bim_types = $this->so_control->get_bim_types();
+
+                               // Sigurd: START as categories
+                               $cats   = CreateObject('phpgwapi.categories', 
-1, 'controller', '.control');
+                               $cats->supress_info     = true;
+       
+                               $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => $this->_category_acl));
+                               array_unshift($control_areas['cat_list'],array 
('cat_id'=>'','name'=> lang('select value')));
+                               $control_areas_array = array();
+                               foreach($control_areas['cat_list'] as $cat_list)
+                               {
+                                       $control_areas_array[] = array
+                                       (
+                                               'id'    => $cat_list['cat_id'],
+                                               'name'  => $cat_list['name'],
+                                       );              
+                               }
+                               // END as categories
+
+                               $tabs = array( array(
+                                                       'label' => 
lang('View_component_for_control_group'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_group_component.index'))
+
+                                               ), array(
+                                                       'label' => 
lang('Add_component_for_control_group')
+                                               ));
+
+                               $data = array(
+                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                                       'view'                                  
        => "add_component_to_control_group",
+                                       'control_group_filters'         => 
array(
+                                       'control_area_array'            => 
$control_areas_array,
+                                       'control_group_array'           => 
$control_group_array
+                                       ),
+                                       'filter_form'                           
=> array(
+                                               'bim_types'                     
=> $bim_types
+                                       ),
+                                       'datatable' => array(
+                                               'source' => 
self::link(array('menuaction' => 
'controller.uicontrol_group_component.add_component_to_control_group', 
'phpgw_return_as' => 'json')),
+                                               'field' => array(
+                                                       array(
+                                                               'key' => 'id',
+                                                               'label' => 
lang('ID'),
+                                                               'sortable'      
=> true,
+                                                               'formatter' => 
'YAHOO.portico.formatLink'
+                                                       ),
+                                                       array(
+                                                               'key'   =>      
'guid',
+                                                               'label' =>      
lang('GUID'),
+                                                               'sortable'      
=>      false
+                                                       ),
+                                                       array(
+                                                               'key' => 'type',
+                                                               'label' => 
lang('type'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'checked',
+                                                               'label' => 
'Velg',
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'YAHOO.widget.DataTable.formatCheckbox',
+                                                               'className' => 
'mychecks'
+                                                       ),
+                                                       array(
+                                                               'key' => 
'actions',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 
'labels',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 'ajax',
+                                                               'hidden' => true
+                                                       )
+                                               )
+                                       )
+                               );
+
+
+                               phpgwapi_yui::load_widget('paginator');
+
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               self::add_javascript('controller', 
'controller', 'jquery.js');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+
+                               
self::render_template_xsl(array('control_group_component_tabs', 'common', 
'add_component_to_control_group'), $data);
+                       }
+               }
+
+               public function query()
+               {
+                       $control_group_list = 
$this->so_control_group->get_control_group_component();
+
+                       foreach($control_group_list as $control_group)
+                       {
+                               $control_group['bim_name'] = 
$this->so_control->getBimItemAttributeValue($control['bim_item_guid'], 
'description');
+                               $results['results'][]= $control_group;
+                       }
+
+                       $results['total_records'] = 10;
+                       $results['start'] = 1;
+                       $results['sort'] = 'id';
+                       array_walk($results['results'], array($this, 
'add_links'), array($type));
+
+                       return $this->yui_results($results);
+               }
+
+               public function get_component()
+               {
+
+                       /*$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');
+                       $lookup_tenant                  = 
phpgw::get_var('lookup_tenant', 'bool');
+                       $district_id                    = 
phpgw::get_var('district_id', 'int');
+                       $part_of_town_id                = 
phpgw::get_var('part_of_town_id', 'int');
+                       $status                                 = 
phpgw::get_var('status');
+                       $type_id                                = 
phpgw::get_var('type_id', 'int');
+                       $allrows                                = 
phpgw::get_var('allrows', 'bool');
+                       $location_code                  = 
phpgw::get_var('location_code');*/
+
+                       $type_id = phpgw::get_var('bim_type_id');
+
+                       $start = phpgw::get_var('startIndex');
+
+                       $component_list = array();
+
+                       $sort = "ASC";
+
+                       $component_list = 
$this->so_control->getAllBimItems(10,$type_id);
+                       //var_dump($component_list); 
+
+
+                       $results = array();
+                       foreach($component_list as $component)
+                       {
+                               $component['checked'] = false;
+                               $results['results'][]= $component;
+                               $i++;
+                       }
+
+                       $results['total_records'] = count($component_list);
+                       $results['start'] = $start;
+                       $results['sort'] = 'id';
+                       $results['dir'] = "ASC";
+
+                       array_walk($results['results'], array($this, 
'add_links'), array($type));
+
+                       return $this->yui_results($results);
+               }
+
+               public function add_actions(&$value, $key, $params)
+               {
+                       unset($value['query_location']);
+
+                       $value['ajax'] = array();
+                       $value['actions'] = array();
+                       $value['labels'] = array();
+
+                       $value['ajax'][] = false;
+                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 'property.uilocation.view', 
'location_code' => $value['location_code'])));
+                       $value['labels'][] = lang('show');
+
+                       $value['ajax'][] = true;
+                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uicomposite.add_unit', 'location_code' => $value['location_code'])));
+                       $value['labels'][] = lang('add_location');
+               }
+
+               public function get_component_types_by_category()
+               {
+                       $category = phpgw::get_var('ifc');
+                       if($ifc != null)
+                       {
+                               if($ifc = 1)
+                                       $ifc = true;
+                               else
+                                       $ifc = false;
+                       }
+
+
+                       $bim_types = $this->so_control->get_bim_types($ifc);
+                       if(count($bim_types)>0)
+                               return json_encode( $bim_types );
+                       else
+                               return null;
+               }
+       }

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php 
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php 
2012-02-07 07:35:50 UTC (rev 8798)
@@ -182,129 +182,174 @@
                
                function register_control_to_location()
                {
-                       if(phpgw::get_var('phpgw_return_as') == 'json') {
-                               return $this->query();
+                       if(phpgw::get_var('save_component'))
+                       {
+                               //add component to control using component item 
ID
+                               $items_checked = array();
+                               $items = phpgw::get_var('values_assign');
+                               $item_arr = explode('|',$items);
+                               foreach($item_arr as $item)
+                               {
+                                       $items_checked[] = explode(';',$item);
+                               }
+                               //var_dump($items_checked);
+
+                               $control_id = phpgw::get_var('control_id');
+                               //$location_code = 
phpgw::get_var('location_code');
+                               
+                               $control_location  = null;
+                               $control_location_id = 0;
+                               
+                               foreach($items_checked as $location_code)
+                               {
+                                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code[0]);
+                                       
+                                       if($control_location == null )
+                                       {                                       
+                                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code[0]);
+                                       }
+                               }
+                               
+                               if($control_location_id > 0)
+                                       return json_encode( array( "status" => 
"saved" ) );
+                               else
+                                       return json_encode( array( "status" => 
"not_saved" ) );
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicheck_list_for_component.index'));
+
                        }
-                       $building_types  = 
execMethod('property.soadmin_location.read',array());
-                       
-                       $type_id = 1;
-                       
-                       $category_types = 
$this->bocommon->select_category_list(array(
-                                                                               
                                                                
'format'=>'filter',
-                                                                               
                                                                'selected' => 
$this->cat_id,
-                                                                               
                                                                'type' 
=>'location',
-                                                                               
                                                                'type_id' 
=>$type_id,
-                                                                               
                                                                'order'=>'descr'
-                                                                               
                                                        ));
-                       
-                       $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
-                       $default_value = array ('id'=>'','name'=>lang('no 
district'));
-                       array_unshift($district_list,$default_value);
-                       
-                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
-                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
-                       array_unshift($part_of_town_list,$default_value);
-                       
-                       $_role_criteria = array
+                       else
+                       {
+                               if(phpgw::get_var('phpgw_return_as') == 'json') 
{
+                                       return $this->query();
+                               }
+                               $building_types  = 
execMethod('property.soadmin_location.read',array());
+                               
+                               $type_id = 1;
+                               
+                               $category_types = 
$this->bocommon->select_category_list(array(
+                                                                               
                                                                        
'format'=>'filter',
+                                                                               
                                                                        
'selected' => $this->cat_id,
+                                                                               
                                                                        'type' 
=>'location',
+                                                                               
                                                                        
'type_id' =>$type_id,
+                                                                               
                                                                        
'order'=>'descr'
+                                                                               
                                                                ));
+                               
+                               $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no district'));
+                               array_unshift($district_list,$default_value);
+                               
+                               $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no part of town'));
+                               
array_unshift($part_of_town_list,$default_value);
+                               
+                               $_role_criteria = array
+                                               (
+                                                       'type'          => 
'responsibility_role',
+                                                       'filter'        => 
array('location' => ".location.{$type_id}"),
+                                                       'order'         => 
'name'
+                                               );
+       
+                               $responsibility_roles_list = 
execMethod('property.sogeneric.get_list',$_role_criteria);
+                               $default_value = array 
('id'=>'','name'=>lang('no role'));
+                               array_unshift 
($responsibility_roles,$default_value);
+                               
+                               // Sigurd: START as categories
+                               $cats   = CreateObject('phpgwapi.categories', 
-1, 'controller', '.control');
+                               $cats->supress_info     = true;
+                               
+                               $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
+                                                               
+                               $control_areas_array2 = array();
+                               foreach($control_areas['cat_list'] as $cat_list)
+                               {
+                                       $control_areas_array2[] = array
                                        (
-                                               'type'          => 
'responsibility_role',
-                                               'filter'        => 
array('location' => ".location.{$type_id}"),
-                                               'order'         => 'name'
-                                       );
-
-                       $responsibility_roles_list = 
execMethod('property.sogeneric.get_list',$_role_criteria);
-                       $default_value = array ('id'=>'','name'=>lang('no 
role'));
-                       array_unshift ($responsibility_roles,$default_value);
-                       
-                       // Sigurd: START as categories
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
-                       
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
-                                                       
-                       $control_areas_array2 = array();
-                       foreach($control_areas['cat_list'] as $cat_list)
-                       {
-                               $control_areas_array2[] = array
-                               (
-                                       'id'    => $cat_list['cat_id'],
-                                       'name'  => $cat_list['name'],
-                               );              
-                       }
-                       // END as categories
-                       
-                       
-                       $tabs = array( array(
-                                               'label' => 
lang('View_locations_for_control'),
-                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
-                       
-                                       ), array(
-                                               'label' => 
lang('Add_locations_for_control')
-                                       ));
-                                       
-                       $data = array(
-                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
-                               'view'                                          
=> "register_control_to_location",
-                               'control_filters'                       => 
array(
-                                       'control_areas_array2'  => 
$control_areas_array2,
-                                       'control_array'                         
=> $control_array
-                               ),
-                               'filter_form'                           => 
array(
-                                       'building_types'                        
=> $building_types,
-                                       'category_types'                        
=> $category_types,
-                                       'district_list'                         
=> $district_list,
-                                       'part_of_town_list'             => 
$part_of_town_list
-                               ),
-                               'datatable' => array(
-                                       'source' => 
self::link(array('menuaction' => 'controller.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 'register_control')),
-                                       'field' => array(
-                                               array(
-                                                       'key' => 
'location_code',
-                                                       'label' => 
lang('Property'),
-                                                       'sortable'      => true,
-                                                       'formatter' => 
'YAHOO.portico.formatLink'
-                                               ),
-                                               array(
-                                                       'key'   =>      
'loc1_name',
-                                                       'label' =>      
lang('Property name'),
-                                                       'sortable'      =>      
false
-                                               ),
-                                               array(
-                                                       'key' => 'adresse1',
-                                                       'label' => 
lang('Address'),
-                                                       'sortable'      => false
-                                               ),
-                                               array(
-                                                       'key' => 'postnummer',
-                                                       'label' => lang('Zip 
code'),
-                                                       'sortable'      => false
-                                               ),
-                                               array(
-                                                       'key' => 'actions',
-                                                       'hidden' => true
-                                               ),
-                                               array(
-                                                       'key' => 'labels',
-                                                       'hidden' => true
-                                               ),
-                                               array(
-                                                       'key' => 'ajax',
-                                                       'hidden' => true
-                                               ),array(
-                                                       'key' => 'parameters',
-                                                       'hidden' => true
-                                               )                               
                
+                                               'id'    => $cat_list['cat_id'],
+                                               'name'  => $cat_list['name'],
+                                       );              
+                               }
+                               // END as categories
+                               
+                               
+                               $tabs = array( array(
+                                                       'label' => 
lang('View_locations_for_control'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
+                               
+                                               ), array(
+                                                       'label' => 
lang('Add_locations_for_control')
+                                               ));
+                                               
+                               $data = array(
+                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                                       'view'                                  
        => "register_control_to_location",
+                                       'control_filters'                       
=> array(
+                                               'control_areas_array2'  => 
$control_areas_array2,
+                                               'control_array'                 
        => $control_array
+                                       ),
+                                       'filter_form'                           
=> array(
+                                               'building_types'                
        => $building_types,
+                                               'category_types'                
        => $category_types,
+                                               'district_list'                 
        => $district_list,
+                                               'part_of_town_list'             
=> $part_of_town_list
+                                       ),
+                                       'datatable' => array(
+                                               'source' => 
self::link(array('menuaction' => 'controller.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 'register_control')),
+                                               'field' => array(
+                                                       array(
+                                                               'key' => 
'location_code',
+                                                               'label' => 
lang('Property'),
+                                                               'sortable'      
=> true,
+                                                               'formatter' => 
'YAHOO.portico.formatLink'
+                                                       ),
+                                                       array(
+                                                               'key'   =>      
'loc1_name',
+                                                               'label' =>      
lang('Property name'),
+                                                               'sortable'      
=>      false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'adresse1',
+                                                               'label' => 
lang('Address'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'postnummer',
+                                                               'label' => 
lang('Zip code'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                                       'key' 
=> 'checked',
+                                                                       'label' 
=> 'Velg',
+                                                                       
'sortable' => false,
+                                                                       
'formatter' => 'YAHOO.widget.DataTable.formatCheckbox',
+                                                                       
'className' => 'mychecks'
+                                                       ),
+                                                       array(
+                                                               'key' => 
'actions',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 
'labels',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 'ajax',
+                                                               'hidden' => true
+                                                       ),array(
+                                                               'key' => 
'parameters',
+                                                               'hidden' => true
+                                                       )                       
                        
+                                               )
                                        )
-                               )
-                       );
-                       
-                       phpgwapi_yui::load_widget('paginator');
-                       
-                       self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
-                       self::add_javascript('controller', 'controller', 
'jquery.js');
-                       self::add_javascript('controller', 'controller', 
'ajax.js');
-
-                       
self::render_template_xsl(array('control_location/control_location_tabs', 
'control_location/register_control_to_location', 'common'), $data);           
+                               );
+                               
+                               phpgwapi_yui::load_widget('paginator');
+                               
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               self::add_javascript('controller', 
'controller', 'jquery.js');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+       
+                               
self::render_template_xsl(array('control_location/control_location_tabs', 
'control_location/register_control_to_location', 'common'), $data);
+                       }               
                }
                
                // Returns locations for a control
@@ -360,7 +405,7 @@
                        $results['sort'] = 'location_code';
                        $results['dir'] = "ASC";
                                                
-                       array_walk($results['results'], array($this, 
'add_actions'), array($type));
+                       array_walk($results['results'], array($this, 
'add_links'), array($type));
                                                        
                        return $this->yui_results($results);
                }
@@ -394,10 +439,11 @@
                        $value['actions'] = array();
                        $value['labels'] = array();
                        $value['parameters'] = array();
-                       
+/*                     
                        $value['ajax'][] = true;
                        $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uicontrol_location.register_control_to_location_2','location_code' 
=> $value['location_code'], 'phpgw_return_as' => 'json')));
                        $value['labels'][] = lang('add_location');
                        $value['parameters'][] = "control_id";
+                       */
                }
        }

Modified: branches/Version-1_0-branch/controller/inc/class.uidocument.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uidocument.inc.php 
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.uidocument.inc.php 
2012-02-07 07:35:50 UTC (rev 8798)
@@ -44,7 +44,8 @@
                                'add'           => true,
                                'view'          => true,
                                'delete'        => true,
-                               'show'          => true
+                               'show'          => true,
+                               'document_types'        => true
                        );
                
                public function __construct()
@@ -106,6 +107,36 @@
                        return $this->yui_results($result_data, 
'total_records', 'results');
                }
                
+               public function get_document_types()
+               {
+                       $result_objects = $this->so->list_document_types();
+                       
+                       //Serialize the documents found
+/*                     $rows = array();
+                       foreach ($result_objects as $result) {
+                               if(isset($result))
+                               {
+                                       $rows[] = $result->serialize();
+                               }
+                       }
+*/
+                       
+                       $editable = phpgw::get_var('editable') == '1' ? true : 
false;
+                       $result_data = array('results' => $result_objects);
+                       
+                       //Add context menu columns (actions and labels)
+                       //array_walk($result_objects, array($this, 
'add_actions'), array('admin', isset($procedure) ? 
$procedure->has_permission(PHPGW_ACL_EDIT) : false, $this->type_of_user, 
$editable));
+                       array_walk(
+                                       $result_data['results'],
+                                       array($this, '_add_links'),
+                                       
"controller.uidocument.edit_document_type");
+                               
+                       
+                       //Build a YUI result from the data
+                       //$result_data = array('results' => $result_objects, 
'total_records' => $result_count); 
+                       return $this->yui_results($result_data, 
'total_records', 'results');
+               }
+               
                /**
                 * Add data for context menu
                 *
@@ -139,6 +170,11 @@
                                                $value['labels'][] = 
lang('delete');
                                        }
                                        break;
+                               case 'admin':
+                                       $value['ajax'][] = true;
+                                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uidocument.edit_document_type', 'id' => $value['id'])));
+                                       $value['labels'][] = lang('Edit 
document type');
+                                       break;
                        }
                }
                
@@ -435,4 +471,44 @@
                                
self::render_template_xsl(array('procedure/procedure_tabs', 'common', 
'procedure/procedure_documents'), $data);
                        }
                }
+               
+               public function document_types()
+               {
+                       
//self::set_active_menu('controller::control_item2::control_item_list2');
+                       if(phpgw::get_var('phpgw_return_as') == 'json') {
+                               return $this->get_document_types();
+                               
self::render_template_xsl(array('procedure/procedure_tabs', 'common', 
'procedure/procedure_documents'), $data);
+                       }
+                       self::add_javascript('controller', 'yahoo', 
'datatable.js');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('paginator');
+
+                       $data = array(
+                               'form' => array(
+                               ),
+                               'datatable' => array(
+                                       'source' => 
self::link(array('menuaction' => 'controller.uidocument.document_types', 
'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable'      => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key' => 'title',
+                                                       'label' => 
lang('Procedure title'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 'link',
+                                                       'hidden' => true
+                                               )
+                                       )
+                               ),
+                       );
+//_debug_array($data);
+
+                       self::render_template_xsl('datatable', $data);
+               }
        }
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/inc/class.uiprocedure.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uiprocedure.inc.php        
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/inc/class.uiprocedure.inc.php        
2012-02-07 07:35:50 UTC (rev 8798)
@@ -309,11 +309,23 @@
                                $control_areas_array2 = array();
                                foreach($control_areas['cat_list'] as $cat_list)
                                {
-                                       $control_areas_array2[] = array
-                                       (
-                                               'id'    => $cat_list['cat_id'],
-                                               'name'  => $cat_list['name'],
-                                       );              
+                                       if($cat_list['cat_id'] == 
$procedure->get_control_area_id())
+                                       {
+                                               $control_areas_array2[] = array
+                                               (
+                                                       'id'    => 
$cat_list['cat_id'],
+                                                       'name'  => 
$cat_list['name'],
+                                                       'selected' => 1,
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $control_areas_array2[] = array
+                                               (
+                                                       'id'    => 
$cat_list['cat_id'],
+                                                       'name'  => 
$cat_list['name'],
+                                               );
+                                       }
                                }
                                // END as categories
 /*                             $control_area_array = 
$this->so_control_area->get_control_area_array();
@@ -427,7 +439,7 @@
                                }
                                
                                $category    = 
execMethod('phpgwapi.categories.return_single', 
$procedure->get_control_area_id());
-                               
$procedure->set_control_area_name($category_name = $category[0]['name']);
+                               
$procedure->set_control_area_name($category[0]['name']);
                                
 
                                $procedure_array = $procedure->toArray();
@@ -534,6 +546,9 @@
                        
                        $procedure = $this->so->get_single($procedure_id);
                        
+                       $category    = 
execMethod('phpgwapi.categories.return_single', 
$procedure->get_control_area_id());
+                       $procedure->set_control_area_name($category[0]['name']);
+                       
                        $data = array
                        (
                                'location'      => $location_array,

Modified: branches/Version-1_0-branch/controller/js/controller/ajax.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-02-07 07:35:50 UTC (rev 8798)
@@ -38,15 +38,47 @@
                                                  htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].title + "</option>";
                                        });
                                                                                
                          
-                                         $("#control_id").innerHTML( 
htmlString );
+                                         $("#control_id").html( htmlString );
                                        }else {
                                        htmlString  += "<option>Ingen 
kontroller</option>"
-                                       $("#control_id").innerHTML( htmlString 
);
+                                       $("#control_id").html( htmlString );
                                }
                          }  
                        });
                        
     });
+
+       // file: uicheck_list.xsl
+       // When control area is selected, controls are fetched from db and 
control select list is populated
+       $("#control_group_area_list option").click(function () {
+                var control_area_id = $(this).val();
+                
+         var requestUrl = 
"index.php?menuaction=controller.uicontrol_group.get_control_groups_by_control_area&phpgw_return_as=json"
+         
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl + "&control_area_id=" + 
control_area_id,
+                         success: function(data) {
+                                 if( data != null){
+                                         var obj = jQuery.parseJSON(data);
+                                               
+                                         $.each(obj, function(i) {
+                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].group_name + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#control_group_id").html( 
htmlString );
+                                       }else {
+                                       htmlString  += "<option>Ingen 
kontrollgrupper</option>"
+                                       $("#control_group_id").html( htmlString 
);
+                               }
+                         }  
+                       });
+                       
+    });
+
        
        // file: add_component_to_control.xsl
        // When component category is selected, corresponding component types 
are fetched from db and component type select list is populated

Modified: branches/Version-1_0-branch/controller/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2012-02-07 
07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2012-02-07 
07:35:50 UTC (rev 8798)
@@ -291,9 +291,9 @@
 start_date     controller      no      Start dato
 planned_date   controller      no      Planlagt dato
 end_date       controller      no      Slutt dato
-View_locations_for_control     controller      no      Vis 
bygg/kontroll-knytning      
-Add_locations_for_control      controller      no      Legg til knytning for 
bygg
-View_component_for_control     controller      no      Vis bygg/utstyr-knytning
+View_locations_for_control     controller      no      Vis knytning mot 
lokasjon
+Add_locations_for_control      controller      no      Legg til knytning mot 
lokasjon
+View_component_for_control     controller      no      Vis knytning mot utstyr
 Add_component_for_control      controller      no      Legg til knytning mot 
utstyr
 component_for_control  controller      no      Utstyr tilknyttet kontroll
 Choose_component_type  controller      no      Velg utstyrstype
@@ -311,4 +311,7 @@
 Document title controller      no      Dokumentets tittel
 Document name  controller      no      Filnavn
 Document description   controller      no      Beskrivelse
-select value   controller      no      Velg
\ No newline at end of file
+select value   controller      no      Velg
+component_for_control_group    controller      no      Utstyr tilknyttet 
kontrollgrupper
+View_component_for_control_group       controller      no      Vis knytning 
mot utstyr
+Add_component_for_control_group        controller      no      Legg til 
knytning mot utstyr
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/setup.inc.php  2012-02-07 
07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/setup/setup.inc.php  2012-02-07 
07:35:50 UTC (rev 8798)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.25';
+       $setup_info['controller']['version'] = '0.1.26';
        $setup_info['controller']['app_order'] = 100;
        $setup_info['controller']['enable'] = 1;
        $setup_info['controller']['app_group']  = 'office';

Modified: branches/Version-1_0-branch/controller/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-02-07 07:35:50 UTC (rev 8798)
@@ -162,6 +162,17 @@
                        'ix' => array(),
                        'uc' => array()
                ),
+               'controller_control_group_component_list' => array(
+                               'fd' => array(
+                                       'id' => array('type' => 'auto', 
'nullable' => false),
+                                       'control_group_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false),
+                                       'component_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
+                               ),
+                       'pk' => array('id'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
                'controller_document_types' => array(
                        'fd' => array(
                                'id' => array('type' => 'auto', 'nullable' => 
false),

Modified: branches/Version-1_0-branch/controller/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_update.inc.php  
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/setup/tables_update.inc.php  
2012-02-07 07:35:50 UTC (rev 8798)
@@ -529,3 +529,28 @@
                        return 
$GLOBALS['setup_info']['controller']['currentver'];
                }               
        }
+       
+       /* Update Controller from v 0.1.25 to 0.1.26
+        * Added table for connecting gontrol groups to components  
+       */
+       
+       $test[] = '0.1.25';
+       function controller_upgrade0_1_25()
+       {
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'controller_control_group_component_list', array(
+                               'fd' => array(
+                                       'id' => array('type' => 'auto', 
'nullable' => false),
+                                       'control_group_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false),
+                                       'component_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
+                               ),
+                               'pk' => array('id'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+                       )
+               );                      
+
+               $GLOBALS['setup_info']['controller']['currentver'] = '0.1.26';
+               return $GLOBALS['setup_info']['controller']['currentver'];
+       }

Modified: 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control.xsl
  2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control.xsl
  2012-02-07 07:35:50 UTC (rev 8798)
@@ -32,7 +32,7 @@
        </div>
 </xsl:template>
 
-<xsl:template match="control_filters" name="control_filters">
+<xsl:template match="control_filters" name="control_filters" 
xmlns:php="http://php.net/xsl";>
        <div style="margin: 10px;padding: 10px; width: 25%;">
                
                <!-- When control area is chosen, an ajax request is executed. 
The operation fetches controls from db and populates the control list.
@@ -68,7 +68,7 @@
        </div>
 </xsl:template>
 
-<xsl:template match="filter_form">
+<xsl:template match="filter_form" xmlns:php="http://php.net/xsl";>
        <form id="queryForm">
                <xsl:attribute name="method">
                        <xsl:value-of select="phpgw:conditional(not(method), 
'GET', method)"/>
@@ -128,7 +128,7 @@
        </div>
 </xsl:template>
 
-<xsl:template match="datatable">
+<xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
        <script type="text/javascript">
        <![CDATA[
        function checkAll(myclass)
@@ -209,7 +209,7 @@
 </xsl:template>
 
 
-<xsl:template name="datasource-definition">
+<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
        <script>
                YAHOO.namespace('controller');
         

Copied: 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control_group.xsl
 (from rev 8797, 
trunk/controller/templates/base/add_component_to_control_group.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control_group.xsl
                            (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/add_component_to_control_group.xsl
    2012-02-07 07:35:50 UTC (rev 8798)
@@ -0,0 +1,248 @@
+<!-- $Id$ -->
+<func:function name="phpgw:conditional">
+       <xsl:param name="test"/>
+       <xsl:param name="true"/>
+       <xsl:param name="false"/>
+
+       <func:result>
+               <xsl:choose>
+                       <xsl:when test="$test">
+                               <xsl:value-of select="$true"/>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:value-of select="$false"/>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </func:result>
+</func:function>
+
+<xsl:template name="add_component_to_control_group" 
xmlns:php="http://php.net/xsl";>
+       <!-- IMPORTANT!!! Loads YUI javascript -->
+       <xsl:call-template name="common"/>
+
+       <div class="yui-content">
+               <div id="control_group_details">
+                       <xsl:call-template name="yui_booking_i18n"/>
+                       <xsl:apply-templates select="control_group_filters" />
+                       <xsl:apply-templates select="filter_form" />
+                       <xsl:apply-templates select="paging"/>
+                       <xsl:apply-templates select="datatable"/>
+                       <xsl:apply-templates select="form/list_actions"/>
+               </div>
+       </div>
+</xsl:template>
+
+<xsl:template match="control_group_filters" name="control_group_filters" 
xmlns:php="http://php.net/xsl";>
+       <div style="margin: 10px;padding: 10px; width: 25%;">
+               
+               <!-- When control area is chosen, an ajax request is executed. 
The operation fetches control groups from db and populates the control group 
list.
+                        The ajax opearation is handled in ajax.js --> 
+                <select style="float:left;" id="control_group_area_list" 
name="control_group_area_list">
+                       <xsl:for-each select="control_area_array">
+                               <xsl:variable 
name="control_area_id"><xsl:value-of select="id"/></xsl:variable>
+                               <option value="{$control_area_id}">
+                                       <xsl:value-of select="name"/>
+                               </option>                       
+                       </xsl:for-each>
+               </select>
+                
+                <form id="loc_form" action="" method="GET">
+                       <select id="control_group_id" name="control_group_id">
+                               <xsl:choose>
+                                       <xsl:when 
test="control_group_array/child::node()">
+                                               <xsl:for-each 
select="control_group_array">
+                                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="id"/></xsl:variable>
+                                                       <option 
value="{$control_group_id}">
+                                                               <xsl:value-of 
select="title"/>
+                                                       </option>               
                
+                                               </xsl:for-each>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <option>
+                                                       Ingen kontrollgrupper
+                                               </option>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </select>
+               </form>
+       </div>
+</xsl:template>
+
+<xsl:template match="filter_form" xmlns:php="http://php.net/xsl";>
+       <form id="queryForm">
+               <xsl:attribute name="method">
+                       <xsl:value-of select="phpgw:conditional(not(method), 
'GET', method)"/>
+               </xsl:attribute>
+
+               <xsl:attribute name="action">
+                       <xsl:value-of select="phpgw:conditional(not(action), 
'', action)"/>
+               </xsl:attribute>
+               <xsl:call-template name="filter_list"/>
+       </form>
+       
+       <form id="update_table_dummy" method='POST' action='' >
+       </form>
+
+</xsl:template>
+
+<xsl:template name="filter_list" xmlns:php="http://php.net/xsl";>
+       <div>
+         <ul id="filters">
+               <li>
+                 <select id="ifc" name="ifc">
+                       <option value="">
+                               <xsl:value-of select="php:function('lang', 
'Choose_component_category')"/>
+                       </option>
+                       <option value="0">
+                               <xsl:value-of select="php:function('lang', 
'component_category_internal')"/>
+                       </option>
+                       <option value="1">
+                               <xsl:value-of select="php:function('lang', 
'component_category_ifc')"/>
+                       </option>
+                 </select>
+               </li>
+               <li>
+                 <select id="bim_type_id" name="bim_type_id">
+                       <option value="">
+                               <xsl:value-of select="php:function('lang', 
'Choose_component_type')"/>
+                       </option>
+                       <xsl:for-each select="bim_types">
+                               <xsl:variable name="bim_type_id"><xsl:value-of 
select="id"/></xsl:variable>
+                               <option value="{$bim_type_id}">
+                                       <xsl:value-of select="name"/>
+                               </option>
+                       </xsl:for-each>
+                 </select>
+               </li>
+         </ul>
+         <ul id="search_list">
+                 <li>
+                       <input type="text" name="query" />
+                 </li>
+                 <li>
+                       <xsl:variable name="lang_search"><xsl:value-of 
select="php:function('lang', 'Search')" /></xsl:variable>
+                       <input type="submit" name="search" 
value="{$lang_search}" title = "{$lang_search}" />
+                 </li>                 
+         </ul>
+       
+       </div>
+</xsl:template>
+
+<xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
+       <script type="text/javascript">
+       <![CDATA[
+       function checkAll(myclass)
+       {
+               controls = YAHOO.util.Dom.getElementsByClassName(myclass);
+               for(i=0;i<controls.length;i++)
+               {
+                       //for class=mychecks, they have to be interchanged
+                       //checkbox is located within td->div->input. To get the 
input-object, use controls[i].children[0].children[0]
+                       if(myclass=='mychecks')
+                       {
+                               if(controls[i].children[0].children[0].checked)
+                               {
+                                       
controls[i].children[0].children[0].checked = false;
+                               }
+                               else
+                               {
+                                       
controls[i].children[0].children[0].checked = true;
+                               }
+                       }
+                       //for the rest, always id checked
+                       else
+                       {
+                               controls[i].children[0].children[0].checked = 
true;
+                       }
+               }
+       }
+       
+       function savecomponentToControl()
+       {
+               var divs = 
YAHOO.util.Dom.getElementsByClassName('component_submit');
+               var mydiv = divs[divs.length-1];
+
+               // styles for dont show
+               mydiv.style.display = "none";
+
+               valuesForPHP = 
YAHOO.util.Dom.getElementsByClassName('mychecks');
+               var values_return = ""; //new Array(); 
+               
+               for(i=0;i<valuesForPHP.length;i++)
+               {
+                       if(valuesForPHP[i].children[0].children[0].checked)
+                       {
+                               if(values_return != "")
+                                       values_return 
+="|"+valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
+                               else
+                                       values_return += 
valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
+                       }
+               }
+               
+               //alert(document.getElementById('control_id').value);
+               var control_group_id_value = 
document.getElementById('control_group_id').value;
+
+               var returnfield = document.createElement('input');
+               returnfield.setAttribute('name', 'values_assign');
+               returnfield.setAttribute('type', 'text');
+               returnfield.setAttribute('value', values_return);
+               mydiv.appendChild(returnfield);
+               
+               var control_group_id_field = document.createElement('input');
+               control_group_id_field.setAttribute('name', 'control_group_id');
+               control_group_id_field.setAttribute('type', 'text');
+               control_group_id_field.setAttribute('value', 
control_group_id_value);
+               mydiv.appendChild(control_group_id_field); 
+               
+       }
+       ]]>
+       </script>
+       <div id="data_paginator"/>
+       <div id="datatable-container"/>
+       <xsl:call-template name="datasource-definition" />
+       <xsl:variable name="label_submit"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
+       <xsl:variable name="label_checkAll"><xsl:value-of 
select="php:function('lang', 'invert_checkboxes')" /></xsl:variable>
+       <div><input type="button" id="select_all" value="{$label_checkAll}" 
onclick="checkAll('mychecks')"/></div>
+       <form action="#" name="component_form" id="component_form" 
method="post">
+               <div class="component_submit"><input type="submit" 
name="save_component" id="save_component" value="{$label_submit}" 
onclick="return savecomponentToControl()"/></div>
+       </form>
+</xsl:template>
+
+
+<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
+       <script>
+               YAHOO.namespace('controller');
+        
+               YAHOO.controller.columnDefs = [
+                               <xsl:for-each select="//datatable/field">
+                                       {
+                                               key: "<xsl:value-of 
select="key"/>",
+                                               <xsl:if test="label">
+                                               label: "<xsl:value-of 
select="label"/>",
+                                               </xsl:if>
+                                               sortable: <xsl:value-of 
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
+                                               <xsl:if test="hidden">
+                                               hidden: true,
+                                               </xsl:if>
+                                               <xsl:if test="formatter">
+                                               formatter: <xsl:value-of 
select="formatter"/>,
+                                               </xsl:if>
+                                               className: "<xsl:value-of 
select="className"/>"
+                                       }<xsl:value-of 
select="phpgw:conditional(not(position() = last()), ',', '')"/>
+                               </xsl:for-each>
+                       ];
+
+               var main_source = '<xsl:value-of select="source"/>';
+               var main_columnDefs = YAHOO.controller.columnDefs;
+               var main_form = 'queryForm';
+               var main_filters = ['bim_type_id'];
+               var main_container = 'datatable-container';
+               var main_table_id = 'datatable';
+               var main_pag = 'data_paginator';
+               var related_table = new Array('locations_table');
+       
+               setDataSource(main_source, main_columnDefs, main_form, 
main_filters, main_container, main_pag, main_table_id, related_table ); 
+               
+       </script>
+        
+</xsl:template>

Copied: 
branches/Version-1_0-branch/controller/templates/base/control_group_component_tabs.xsl
 (from rev 8797, 
trunk/controller/templates/base/control_group_component_tabs.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_group_component_tabs.xsl
                              (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_group_component_tabs.xsl
      2012-02-07 07:35:50 UTC (rev 8798)
@@ -0,0 +1,27 @@
+<!-- $Id: control_component_tabs.xsl 8267 2011-12-11 12:27:18Z sigurdne $ -->
+<!-- separate tabs and  inline tables-->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<div class="yui-navset yui-navset-top" id="control_group_component_tabview">
+       <xsl:choose>
+               <xsl:when test="view = 'view_component_for_control_group'">
+                       <div class="identifier-header">
+                               <h1><xsl:value-of select="php:function('lang', 
'component_for_control_group')"/></h1>
+                       </div>
+                       <!-- Prints tabs array -->
+                       <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
+                        
+                       <xsl:call-template 
name="view_component_for_control_group" />
+               </xsl:when>
+               <xsl:when test="view = 'add_component_to_control_group'">
+                       <div class="identifier-header">
+                               <h1><xsl:value-of select="php:function('lang', 
'Add_component_for_control_group')"/></h1>
+                       </div>
+                       <!-- Prints tabs array -->
+                       <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
+                       <xsl:call-template 
name="add_component_to_control_group" />
+               </xsl:when>
+       </xsl:choose>
+</div>
+       
+</xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
     2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
     2012-02-07 07:35:50 UTC (rev 8798)
@@ -16,7 +16,7 @@
        </func:result>
 </func:function>
 
-<xsl:template name="register_control_to_location">
+<xsl:template name="register_control_to_location" 
xmlns:php="http://php.net/xsl";>
        <!-- IMPORTANT!!! Loads YUI javascript -->
        <xsl:call-template name="common"/>
 
@@ -32,7 +32,7 @@
        </div>
 </xsl:template>
 
-<xsl:template match="control_filters" name="control_filters">
+<xsl:template match="control_filters" name="control_filters" 
xmlns:php="http://php.net/xsl";>
        <div style="margin: 10px;padding: 10px; width: 25%;">
                
                <!-- When control area is chosen, an ajax request is executed. 
The operation fetches controls from db and populates the control list.
@@ -68,7 +68,7 @@
        </div>
 </xsl:template>
 
-<xsl:template match="filter_form">
+<xsl:template match="filter_form" xmlns:php="http://php.net/xsl";>
        <form id="queryForm">
                <xsl:attribute name="method">
                        <xsl:value-of select="phpgw:conditional(not(method), 
'GET', method)"/>
@@ -154,14 +154,88 @@
        </div>
 </xsl:template>
 
-<xsl:template match="datatable">
+<xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
+       <script type="text/javascript">
+       <![CDATA[
+       function checkAll(myclass)
+       {
+               controls = YAHOO.util.Dom.getElementsByClassName(myclass);
+               for(i=0;i<controls.length;i++)
+               {
+                       //for class=mychecks, they have to be interchanged
+                       //checkbox is located within td->div->input. To get the 
input-object, use controls[i].children[0].children[0]
+                       if(myclass=='mychecks')
+                       {
+                               if(controls[i].children[0].children[0].checked)
+                               {
+                                       
controls[i].children[0].children[0].checked = false;
+                               }
+                               else
+                               {
+                                       
controls[i].children[0].children[0].checked = true;
+                               }
+                       }
+                       //for the rest, always id checked
+                       else
+                       {
+                               controls[i].children[0].children[0].checked = 
true;
+                       }
+               }
+       }
+       
+       function saveLocationToControl()
+       {
+               var divs = 
YAHOO.util.Dom.getElementsByClassName('location_submit');
+               var mydiv = divs[divs.length-1];
+
+               // styles for dont show
+               mydiv.style.display = "none";
+
+               valuesForPHP = 
YAHOO.util.Dom.getElementsByClassName('mychecks');
+               var values_return = ""; //new Array(); 
+               
+               for(i=0;i<valuesForPHP.length;i++)
+               {
+                       if(valuesForPHP[i].children[0].children[0].checked)
+                       {
+                               if(values_return != "")
+                                       values_return 
+="|"+valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
+                               else
+                                       values_return += 
valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
+                       }
+               }
+               
+               //alert(document.getElementById('control_id').value);
+               var control_id_value = 
document.getElementById('control_id').value;
+
+               var returnfield = document.createElement('input');
+               returnfield.setAttribute('name', 'values_assign');
+               returnfield.setAttribute('type', 'text');
+               returnfield.setAttribute('value', values_return);
+               mydiv.appendChild(returnfield);
+               
+               var control_id_field = document.createElement('input');
+               control_id_field.setAttribute('name', 'control_id');
+               control_id_field.setAttribute('type', 'text');
+               control_id_field.setAttribute('value', control_id_value);
+               mydiv.appendChild(control_id_field); 
+               
+       }
+       ]]>
+       </script>
        <div id="data_paginator"/>
        <div id="datatable-container"/>
        <xsl:call-template name="datasource-definition" />
+       <xsl:variable name="label_submit"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
+       <xsl:variable name="label_checkAll"><xsl:value-of 
select="php:function('lang', 'invert_checkboxes')" /></xsl:variable>
+       <div><input type="button" id="select_all" value="{$label_checkAll}" 
onclick="checkAll('mychecks')"/></div>
+       <form action="#" name="location_form" id="location_form" method="post">
+               <div class="location_submit"><input type="submit" 
name="save_location" id="save_location" value="{$label_submit}" onclick="return 
saveLocationToControl()"/></div>
+       </form>
 </xsl:template>
 
 
-<xsl:template name="datasource-definition">
+<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
        <script>
                YAHOO.namespace('controller');
         

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
       2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
       2012-02-07 07:35:50 UTC (rev 8798)
@@ -16,7 +16,7 @@
        </func:result>
 </func:function>
 
-<xsl:template name="view_locations_for_control">
+<xsl:template name="view_locations_for_control" xmlns:php="http://php.net/xsl";>
 
        <!-- IMPORTANT!!! Loads YUI javascript -->
        <xsl:call-template name="common"/>

Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css  
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css  
2012-02-07 07:35:50 UTC (rev 8798)
@@ -702,7 +702,7 @@
 }
 
 .check_list li.heading {
-    background: url("/pe/phpgwapi/js/yahoo/assets/skins/sam/sprite.png") 
repeat-x scroll 0 0 #D8D8D8;
+    background: 
url("../../../../phpgwapi/js/yahoo/assets/skins/sam/sprite.png") repeat-x 
scroll 0 0 #D8D8D8;
     height: 20px;
     padding-left: 25px;
 }
@@ -1278,4 +1278,9 @@
 
 input.focus, select.focus{
        border: 2px solid #dae6f4;
-}
\ No newline at end of file
+}
+
+div.controller_checklist {
+       padding: 20px;
+       border: 1px solid #ABABAB;
+}

Modified: 
branches/Version-1_0-branch/controller/templates/base/procedure/view_procedures_for_control.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/procedure/view_procedures_for_control.xsl
     2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/controller/templates/base/procedure/view_procedures_for_control.xsl
     2012-02-07 07:35:50 UTC (rev 8798)
@@ -22,8 +22,9 @@
                <h4 style="margin:5px 0;">Dokumenter</h4>
                <xsl:for-each select="control_procedure/documents">
                        <div style="margin-left:10px;">
-                               <span><xsl:value-of select="title"/></span>
-                               <span style="margin-left:10px;"><xsl:value-of 
select="description"/></span>
+                               <xsl:variable name="doc_link"><xsl:value-of 
select='document_link'/></xsl:variable>
+                               <span><a href="{$doc_link}"><xsl:value-of 
select="title"/></a></span>
+                               <span style="margin-left:10px;"><xsl:value-of 
select="description" disable-output-escaping="yes"/></span>
                        </div>  
                </xsl:for-each>
        </xsl:if>
@@ -56,8 +57,9 @@
                                <h4 style="margin:5px 0;">Dokumenter</h4>
                                        <xsl:for-each select="documents">
                                                <div style="margin-left:10px;">
-                                                       <span><xsl:value-of 
select="title"/></span>
-                                                       <span 
style="margin-left:10px;"><xsl:value-of select="description"/></span>
+                                                       <xsl:variable 
name="doc_link"><xsl:value-of select='document_link'/></xsl:variable>
+                                                       <span><a 
href="{$doc_link}"><xsl:value-of select="title"/></a></span>
+                                                       <span 
style="margin-left:10px;"><xsl:value-of select="description" 
disable-output-escaping="yes"/></span>
                                                </div>  
                                        </xsl:for-each>
                                </xsl:if>

Copied: 
branches/Version-1_0-branch/controller/templates/base/view_component_for_control_group.xsl
 (from rev 8797, 
trunk/controller/templates/base/view_component_for_control_group.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/view_component_for_control_group.xsl
                          (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/view_component_for_control_group.xsl
  2012-02-07 07:35:50 UTC (rev 8798)
@@ -0,0 +1,125 @@
+<!-- $Id$ -->
+<func:function name="phpgw:conditional">
+       <xsl:param name="test"/>
+       <xsl:param name="true"/>
+       <xsl:param name="false"/>
+
+       <func:result>
+               <xsl:choose>
+                       <xsl:when test="$test">
+                               <xsl:value-of select="$true"/>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:value-of select="$false"/>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </func:result>
+</func:function>
+
+<xsl:template name="view_component_for_control_group">
+       <!-- IMPORTANT!!! Loads YUI javascript -->
+       <xsl:call-template name="common"/>
+
+       <div class="yui-content">
+               <div id="control_details">
+                       <div style="margin: 10px;padding: 10px; width: 25%;">
+                               
+                               <!-- When control area is chosen, an ajax 
request is executed. 
+                                        The operation fetches controls groups 
from db and populates the control group list.
+                                        The ajax operation is handled in 
ajax.js 
+                                --> 
+                                <select style="float:left;" 
id="control_group_area_list" name="control_group_area_list">
+                                       <xsl:for-each 
select="control_area_array">
+                                               <xsl:variable 
name="control_area_id"><xsl:value-of select="id"/></xsl:variable>
+                                               <option 
value="{$control_area_id}">
+                                                       <xsl:value-of 
select="name"/>
+                                               </option>                       
+                                       </xsl:for-each>
+                                </select>
+                                
+                                <form id="loc_form" action="" method="GET">
+                       
+                                       <select id="control_group_id" 
name="control_group_id">
+                                       <xsl:choose>
+                                               <xsl:when 
test="control_group_array/child::node()">
+                                                       <xsl:for-each 
select="control_group_array">
+                                                               <xsl:variable 
name="control_group_id"><xsl:value-of select="id"/></xsl:variable>
+                                                               <option 
value="{$control_group_id}">
+                                                                       
<xsl:value-of select="group_name"/>
+                                                               </option>       
                        
+                                                       </xsl:for-each>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <option>
+                                                               Ingen 
kontrollgrupper
+                                                       </option>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                               
+                                       </select>
+                               </form>
+                       </div>
+                       
+                       <div id="addedProperties">
+                               <ul id="locations_for_control_group" 
name="locations_for_control_group">
+                                       <xsl:for-each 
select="locations_for_control">
+                                               <li>
+                                                       <div><xsl:value-of 
select="id"/></div>
+                                                       <div><xsl:value-of 
select="title"/></div>
+                                                       <div><xsl:value-of 
select="location_code"/></div>
+                                               </li>                   
+                                       </xsl:for-each>
+                               </ul>
+                       </div>
+                       
+                       <iframe id="yui-history-iframe" 
src="phpgwapi/js/yahoo/history/assets/blank.html" 
style="position:absolute;top:0; left:0;width:1px; 
height:1px;visibility:hidden;"></iframe>
+                       <input id="yui-history-field" type="hidden"/>
+                       
+                       <xsl:apply-templates select="locations_table"/>
+                       <xsl:call-template name="yui_booking_i18n"/>
+               </div>
+       </div>
+</xsl:template>
+
+<xsl:template match="locations_table" xmlns:php="http://php.net/xsl";>
+       
+       <div id="loc_paginator"/>
+       <div style="margin:20px;" id="locations-container"/>
+       <xsl:call-template name="locations-definition" />
+</xsl:template>
+
+<xsl:template name="locations-definition">
+       <script>
+        
+               YAHOO.controller.columnDefs = [
+                               <xsl:for-each select="//locations_table/field">
+                                       {
+                                               key: "<xsl:value-of 
select="key"/>",
+                                               <xsl:if test="label">
+                                               label: "<xsl:value-of 
select="label"/>",
+                                               </xsl:if>
+                                               sortable: <xsl:value-of 
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
+                                               <xsl:if test="hidden">
+                                               hidden: true,
+                                               </xsl:if>
+                                               <xsl:if test="formatter">
+                                               formatter: <xsl:value-of 
select="formatter"/>,
+                                               </xsl:if>
+                                               className: "<xsl:value-of 
select="className"/>"
+                                       }<xsl:value-of 
select="phpgw:conditional(not(position() = last()), ',', '')"/>
+                               </xsl:for-each>
+                       ];
+                       
+               var loc_source = '<xsl:value-of select="source"/>';
+               var loc_columnDefs = YAHOO.controller.columnDefs;
+               var loc_form = 'loc_form';
+               var loc_filters = ['control_id'];
+               var loc_container = 'locations-container';
+               var loc_table_id = 'locations_table';
+               var loc_data_table_pag = 'loc_paginator';
+       
+               setDataSource(loc_source, loc_columnDefs, loc_form, 
loc_filters, loc_container, loc_data_table_pag, loc_table_id, null, null, 
null); 
+               
+       </script>
+        
+</xsl:template>

Modified: branches/Version-1_0-branch/property/inc/class.soXport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2012-02-07 07:35:50 UTC (rev 8798)
@@ -749,11 +749,22 @@
                        $amount = $amount/100;
                        if(!$table)
                        {
-                               throw new Exception('ERROR: the order id seems 
to not correspond with any order type');
+                               $message = 
'property_soXport::correct_actual_cost() ERROR: the order id %1 seems to not 
correspond with any order type';
+                               $GLOBALS['phpgw']->log->error(array(
+                                               'text'  => $message,
+                                               'p1'    => $order_id,
+                                               'p2'    => '',
+                                               'line'  => __LINE__,
+                                               'file'  => __FILE__
+                                       ));
+
+                               echo $message . "\n";
                        }
-
-                       $sql="UPDATE {$table} SET 
{$actual_cost_field}={$actual_cost_field} {$operator} {$amount} {$update_paid} 
WHERE id='{$order_id}'";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       else
+                       {
+                               $sql="UPDATE {$table} SET 
{$actual_cost_field}={$actual_cost_field} {$operator} {$amount} {$update_paid} 
WHERE id='{$order_id}'";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
                }
 
                public function check_voucher_id($voucher_id)

Modified: branches/Version-1_0-branch/property/inc/class.sotts.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sotts.inc.php        
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/class.sotts.inc.php        
2012-02-07 07:35:50 UTC (rev 8798)
@@ -896,24 +896,25 @@
                        $this->db->query("select * from fm_tts_tickets where 
id='$id'",__LINE__,__FILE__);
                        $this->db->next_record();
 
-                       $location_code  = $this->db->f('location_code');
-                       $oldlocation_code       = $this->db->f('location_code');
-                       $oldfinnish_date        = $this->db->f('finnish_date');
-                       $oldfinnish_date2       = $this->db->f('finnish_date2');
-                       $oldassigned            = $this->db->f('assignedto');
-                       $oldgroup_id            = $this->db->f('group_id');
-                       $oldpriority            = $this->db->f('priority');
-                       $oldcat_id                      = 
$this->db->f('cat_id');
-                       $old_status             = $this->db->f('status');
-                       $old_budget             = $this->db->f('budget');
-                       $old_billable_hours     = 
$this->db->f('billable_hours');
-                       //      $old_billable_rate      = 
$this->db->f('billable_rate');
-                       $old_subject            = $this->db->f('subject');
-                       $old_contact_id         = $this->db->f('contact_id');
-                       $old_actual_cost        = $this->db->f('actual_cost');
-                       $old_order_cat_id       = $this->db->f('order_cat_id');
-                       $old_building_part      = 
$this->db->f('building_part',true);
-                       $old_order_dim1         = 
(int)$this->db->f('order_dim1');
+                       $location_code                  = 
$this->db->f('location_code');
+                       $oldlocation_code               = 
$this->db->f('location_code');
+                       $oldfinnish_date                = 
$this->db->f('finnish_date');
+                       $oldfinnish_date2               = 
$this->db->f('finnish_date2');
+                       $oldassigned                    = 
$this->db->f('assignedto');
+                       $oldgroup_id                    = 
$this->db->f('group_id');
+                       $oldpriority                    = 
$this->db->f('priority');
+                       $oldcat_id                              = 
$this->db->f('cat_id');
+                       $old_status                     = 
$this->db->f('status');
+                       $ticket['old_status']   = $old_status; // used for 
custom functions
+                       $old_budget                     = 
$this->db->f('budget');
+                       $old_billable_hours             = 
$this->db->f('billable_hours');
+               //      $old_billable_rate      = $this->db->f('billable_rate');
+                       $old_subject                    = 
$this->db->f('subject');
+                       $old_contact_id                 = 
$this->db->f('contact_id');
+                       $old_actual_cost                = 
$this->db->f('actual_cost');
+                       $old_order_cat_id               = 
$this->db->f('order_cat_id');
+                       $old_building_part              = 
$this->db->f('building_part',true);
+                       $old_order_dim1                 = 
(int)$this->db->f('order_dim1');
 
 
                        if($oldcat_id ==0){$oldcat_id ='';}
@@ -1104,9 +1105,9 @@
 
                        if($ticket['billable_hours'])
                        {
-                               $ticket['billable_hours'] = 
str_replace(',','.', $ticket['billable_hours']);
+                               $ticket['billable_hours'] = 
(float)str_replace(',','.', $ticket['billable_hours']);
                        }
-                       if ((float)$old_billable_hours != 
(float)$ticket['billable_hours'])
+                       if ((float)$old_billable_hours != 
$ticket['billable_hours'])
                        {
                                $this->db->query("UPDATE fm_tts_tickets SET 
billable_hours='{$ticket['billable_hours']}'"
                                        . " WHERE 
id='{$id}'",__LINE__,__FILE__);
@@ -1281,6 +1282,7 @@
                        {
                                $receipt['message'][]= array('msg' => 
lang('Ticket has been updated'));
 
+/*
                                $criteria = array
                                        (
                                                'appname'       => 'property',
@@ -1304,6 +1306,7 @@
                                                require_once $file;
                                        }
                                }
+*/
                        }
                        return $receipt;
                }

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-02-07 07:35:50 UTC (rev 8798)
@@ -894,7 +894,7 @@
                        $historylog     = 
CreateObject('property.historylog','workorder');
                        $workorder['descr'] = 
$this->db->db_addslashes($workorder['descr']);
                        $workorder['title'] = 
$this->db->db_addslashes($workorder['title']);
-                       $workorder['billable_hours'] = str_replace(',','.', 
$workorder['billable_hours']);
+                       $workorder['billable_hours'] = 
(float)str_replace(',','.', $workorder['billable_hours']);
 
                        $cols = array();
                        $vals = array();
@@ -1040,7 +1040,7 @@
                        $historylog     = 
CreateObject('property.historylog','workorder');
                        $workorder['descr'] = 
$this->db->db_addslashes($workorder['descr']);
                        $workorder['title'] = 
$this->db->db_addslashes($workorder['title']);
-                       $workorder['billable_hours'] = str_replace(',','.', 
$workorder['billable_hours']);
+                       $workorder['billable_hours'] = 
(float)str_replace(',','.', $workorder['billable_hours']);
 
                        $this->db->query("SELECT 
status,budget,calculation,billable_hours FROM fm_workorder WHERE id = 
{$workorder['id']}",__LINE__,__FILE__);
                        $this->db->next_record();

Modified: branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2012-02-07 07:35:50 UTC (rev 8798)
@@ -713,8 +713,8 @@
                        $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);
-                       
 
+
                        $uicols = array (
                                'input_type'    =>      array
                                                                        (
@@ -1351,7 +1351,7 @@
                                                        }
                                                        else
                                                        {
-                                                               
$json_row[$column['name']] = "<a target='".$column['target']."' 
href='".$column['link']."' >".$column['value']."</a>";                          
                        
+                                                               
$json_row[$column['name']] = "<a target='".$column['target']."' 
href='".$column['link']."' >".$column['value']."</a>";
                                                        }
                                                }
                                                else if($column['format']== 
"input")
@@ -1605,7 +1605,14 @@
 
                        if( phpgw::get_var('phpgw_return_as') == 'json' && 
is_array($values) && isset($values))
                        {
-                               $receipt = 
$this->bo->update_invoice_sub($values);
+                               if($this->get_approve_role())
+                               {
+                                       $receipt = 
$this->bo->update_invoice_sub($values);
+                               }
+                               else
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('you are not approved for this task'));
+                               }
                        }
 
                        if ($voucher_id)
@@ -1912,15 +1919,15 @@
                                                else if($i == 16)
                                                {
                                                        
$json_row[$uicols[$i]['col_name']]  = $invoices['counter'];
-                                               }                               
        
+                                               }
                                                else if($i == 17)
                                                {
                                                        
$json_row[$uicols[$i]['col_name']]  = $invoices['id'];
-                                               }                               
        
+                                               }
                                                else if($i == 18)
                                                {
                                                        
$json_row[$uicols[$i]['col_name']]  = $invoices['external_ref'];
-                                               }                               
        
+                                               }
                                        }
 
                                        if($invoices['workorder_id'])
@@ -2153,22 +2160,8 @@
                                'is_budget_responsible'         => lang('b - 
responsible')
                        );
 
-                       $roles  = $this->bo->check_role();
+                       $approve = $this->get_approve_role();
 
-                       $approve = array();
-                       foreach ($roles as $role => $role_value)
-                       {
-                               if ($role_value && isset($role_check[$role]))
-                               {
-                                       $approve[] = array
-                                       (
-                                               'id'            => $role,
-                                               'name'          => 
$role_check[$role],
-                                               'selected'      => 0
-                                       );
-                               }       
-                       }
-
                        $values = phpgw::get_var('values');
 
                        $receipt = array();
@@ -2182,7 +2175,7 @@
 
                                if(!$approve)
                                {
-                                       
$receipt['error'][]=array('msg'=>lang('you are not approved for this task'));   
                                
+                                       
$receipt['error'][]=array('msg'=>lang('you are not approved for this task'));
                                }
 
                                if(!isset($values['process_log']) || 
!$values['process_log'])
@@ -2196,7 +2189,7 @@
                                        $values['approved_amount']              
= str_replace(',','.',$values['approved_amount']);
                                        if( isset($values['order_id']) && 
$values['order_id'] && 
!execMethod('property.soXport.check_order',$values['order_id']) )
                                        {
-                                               
$receipt['error'][]=array('msg'=>lang('no such order: 
%1',$values['order_id']));                                
+                                               
$receipt['error'][]=array('msg'=>lang('no such order: %1',$values['order_id']));
                                        }
                                }
                                else
@@ -2228,7 +2221,7 @@
 //                     _debug_array($line);
 
                        $approved_list = array();
-                       
+
                        $approved_list[] = array
                        (
                                'role'          => $role_check['is_janitor'],
@@ -2338,13 +2331,13 @@
                        $paid   = phpgw::get_var('paid', 'bool');
 
                        $text = $this->bo->read_remark($id,$paid);
-                       
+
                        $html = '';
                        if(stripos($text, '<table') )
                        {
                                $html = 1;
                        }
-                       
+
                        $data = array
                        (
                                'remark' => $text,
@@ -3693,7 +3686,7 @@
                        if($values)
                        {
        //              _debug_array($values);die();
-                       
+
                                if(isset($values['export_reconciliation']) && 
$values['export_reconciliation'])
                                {
                                        if(!isset($values['periods']))
@@ -3704,7 +3697,7 @@
                                        else
                                        {
                                                
$this->bo->export_historical_transactions_at_periods($values['periods']);
-                                       
+
                                        }
                                }
                                else if(isset($values['export_deposition']) && 
$values['export_deposition'])
@@ -3768,22 +3761,8 @@
                                'is_budget_responsible'         => lang('b - 
responsible')
                        );
 
-                       $roles  = $this->bo->check_role();
+                       $approve = $this->get_approve_role();
 
-                       $approve = array();
-                       foreach ($roles as $role => $role_value)
-                       {
-                               if ($role_value && isset($role_check[$role]))
-                               {
-                                       $approve[] = array
-                                       (
-                                               'id'            => $role,
-                                               'name'          => 
$role_check[$role],
-                                               'selected'      => 0
-                                       );
-                               }       
-                       }
-
                        $values = phpgw::get_var('values');
 
                        $receipt = array();
@@ -3796,7 +3775,7 @@
 
                                if(!$approve)
                                {
-                                       
$receipt['error'][]=array('msg'=>lang('you are not approved for this task'));   
                                
+                                       
$receipt['error'][]=array('msg'=>lang('you are not approved for this task'));
                                }
 
                                if (!$receipt['error'])
@@ -3821,7 +3800,7 @@
                                        $_orders[] = $line['order_id'];
                                }
                        }
-                       
+
                        $_orders = array_unique($_orders);
 
                        foreach ($_orders as $_order)
@@ -3925,4 +3904,31 @@
                        $GLOBALS['phpgw']->xslttpl->add_file('invoice');
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('forward' => $data));
                }
+
+               function get_approve_role()
+               {
+                       $role_check = array
+                       (
+                               'is_janitor'                            => 
lang('janitor'),
+                               'is_supervisor'                         => 
lang('supervisor'),
+                               'is_budget_responsible'         => lang('b - 
responsible')
+                       );
+
+                       $roles  = $this->bo->check_role();
+
+                       $approve = array();
+                       foreach ($roles as $role => $role_value)
+                       {
+                               if ($role_value && isset($role_check[$role]))
+                               {
+                                       $approve[] = array
+                                       (
+                                               'id'            => $role,
+                                               'name'          => 
$role_check[$role],
+                                               'selected'      => 0
+                                       );
+                               }
+                       }
+                       return $approve;
+               }
        }

Modified: branches/Version-1_0-branch/property/inc/class.uitts.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uitts.inc.php        
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/class.uitts.inc.php        
2012-02-07 07:35:50 UTC (rev 8798)
@@ -897,6 +897,8 @@
 
                        $uicols['name'][] = 'priority';
                        $uicols['descr'][]      = lang('priority');
+                       $uicols['name'][] = 'hidden_id';
+                       $uicols['descr'][]      = 'hidden_id';
                        $uicols['name'][] = 'id';
                        $uicols['descr'][]      = lang('id');
                        $uicols['name'][] = 'bgcolor';
@@ -1036,6 +1038,7 @@
                                                );
                                }
 
+                               $view_action = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'  => 
'property.uitts.view','id'=> $ticket['id']));
                                foreach($ticket_list as $ticket)
                                {
                                        for ($k=0;$k<$count_uicols_name;$k++)
@@ -1053,15 +1056,17 @@
                                                if($uicols['name'][$k] == 'id' 
|| $uicols['name'][$k] == 'entry_date')
                                                {
                                                        
$datatable['rows']['row'][$j]['column'][$k]['format']   = 'link';
-                                                       
$datatable['rows']['row'][$j]['column'][$k]['link']             =       
$GLOBALS['phpgw']->link('/index.php',array
-                                                               (
-                                                                       
'menuaction'    => 'property.uitts.view',
-                                                                       'id'    
                => $ticket['id']
-                                                               ));
-                                                       
$datatable['rows']['row'][$j]['column'][$k]['value']    = 
$ticket[$uicols['name'][$k]] .  $ticket['new_ticket'];
+                                                       
$datatable['rows']['row'][$j]['column'][$k]['link']             = 
"{$view_action}&id={$ticket['id']}";
+                                                       
$datatable['rows']['row'][$j]['column'][$k]['value']    = 
$ticket[$uicols['name'][$k]] . $ticket['new_ticket'];
                                                        
$datatable['rows']['row'][$j]['column'][$k]['target']   = '_blank';
                                                }
 
+                                               if($uicols['name'][$k] == 
'hidden_id')//hidden
+                                               {
+                                                       
$datatable['rows']['row'][$j]['column'][$k]['value']    = $ticket['id'];
+                                               }
+
+
                                                $n = 0;
                                                foreach($uicols_related as 
$related)
                                                {
@@ -1077,7 +1082,6 @@
                                                        $n++;
                                                }
                                        }
-
                                        $j++;
                                }
                        }
@@ -1089,7 +1093,7 @@
                                                array
                                                (
                                                        'name'          => 'id',
-                                                       'source'        => 'id'
+                                                       'source'        => 
'hidden_id'
                                                ),
                                        )
                                );
@@ -1258,7 +1262,7 @@
                                                
$datatable['headers']['header'][$i]['sortable']         = true;
                                                
$datatable['headers']['header'][$i]['sort_field']   = $uicols['name'][$i];
                                        }
-                                       if($uicols['name'][$i]=='text_view' || 
$uicols['name'][$i]=='bgcolor' || $uicols['name'][$i]=='child_date' || 
$uicols['name'][$i]== 'link_view' || 
$uicols['name'][$i]=='lang_view_statustext')
+                                       if($uicols['name'][$i]=='text_view' || 
$uicols['name'][$i]=='bgcolor' || $uicols['name'][$i]=='child_date' || 
$uicols['name'][$i]== 'link_view' || 
$uicols['name'][$i]=='lang_view_statustext' || $uicols['name'][$i]=='hidden_id')
                                        {
                                                
$datatable['headers']['header'][$i]['visible']          = false;
                                                
$datatable['headers']['header'][$i]['format']           = 'hidden';

Modified: 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
===================================================================
--- 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
   2012-02-07 07:24:48 UTC (rev 8797)
+++ 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
   2012-02-07 07:35:50 UTC (rev 8798)
@@ -567,7 +567,7 @@
                        $toarray = array();
                        $order_id = (int) $order_id;
                        $sql = "SELECT 
fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb,
 fm_workorder.user_id"
-                       . " FROM fm_workorder {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = $order_id";
+                       . " FROM fm_workorder {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = {$order_id}";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
                        if ($this->db->f('location_code'))
@@ -581,18 +581,15 @@
                        $order_info['spbudact_code']            = 
$this->db->f('account_id');
                        $order_info['dimb']                                     
= $this->db->f('ecodimb');
 
-//                     $criteria_janitor                                       
= array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->bestiller ); 
//bestiller
-//                     $janitor_contact_id                                     
= $this->responsible->get_responsible($criteria_janitor);
-//                     $janitor_user_id                                        
= $this->responsible->get_contact_user_id($janitor_contact_id);
                        $janitor_user_id                                        
= $this->db->f('user_id');
                        $order_info['janitor']                          = 
$GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
-
+/*
                        $prefs = 
$this->bocommon->create_preferences('property', $janitor_user_id);
                        if($prefs['email'])
                        {
                                $toarray[] = $prefs['email'];
                        }
-
+*/
                        $criteria_supervisor                            = 
array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->attestant); // 
attestere
                        $supervisor_contact_id                          = 
$this->responsible->get_responsible($criteria_supervisor);
                        if($supervisor_contact_id)

Copied: 
branches/Version-1_0-branch/property/inc/custom/default/ticket_redirect_based_on_status.php
 (from rev 8797, 
trunk/property/inc/custom/default/ticket_redirect_based_on_status.php)
===================================================================
--- 
branches/Version-1_0-branch/property/inc/custom/default/ticket_redirect_based_on_status.php
                         (rev 0)
+++ 
branches/Version-1_0-branch/property/inc/custom/default/ticket_redirect_based_on_status.php
 2012-02-07 07:35:50 UTC (rev 8798)
@@ -0,0 +1,89 @@
+<?php
+
+       /*
+       * This class will enable status conditional redirect on tickets.
+       * A config section will be defined where conditions on status and 
target can be configured.
+       */
+       $ticket_redirect = new ticket_redirect_based_on_status();
+       $ticket_redirect->check_status($data);
+
+       class ticket_redirect_based_on_status extends property_botts
+       {
+               protected $db;
+               protected $config = array();
+               protected $status_text = array();
+               protected $custom_config;
+
+               function __construct()
+               {
+                       parent::__construct();
+                       $this->db               = & $GLOBALS['phpgw']->db;
+                       $custom_config  = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property', 
'.ticket'));
+                       $this->config = $custom_config->config_data;
+                       $this->status_text = parent::get_status_text();
+                       if($this->acl_location != '.ticket')
+                       {
+                               throw new Exception("'catch_ticket_export'  is 
intended for location = '.ticket'");
+                       }
+
+                       if(!isset($this->config['ticket_redirect']) || 
!$this->config['ticket_redirect'])
+                       {
+                               $this->custom_config = $custom_config;
+                               $this->initiate_config();
+                       }
+               }
+
+               protected function initiate_config()
+               {
+                       $receipt_section = 
$this->custom_config->add_section(array
+                               (
+                                       'name' => 'ticket_redirect',
+                                       'descr' => 'ticket redirect based on 
status'
+                               )
+                       );
+                       $receipt = $this->custom_config->add_attrib(array
+                               (
+                                       'section_id'    => 
$receipt_section['section_id'],
+                                       'input_type'    => 'text',
+                                       'name'                  => 'status',
+                                       'descr'                 => 
'commaseparated list of status that initiate redirect'
+                               )
+                       );
+                       $receipt = $this->custom_config->add_attrib(array
+                               (
+                                       'section_id'    => 
$receipt_section['section_id'],
+                                       'input_type'    => 'text',
+                                       'name'                  => 'target',
+                                       'descr'                 => 
'commaseparated list of target of redirect'
+                               )
+                       );
+                       $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'admin.uiconfig2.list_attrib', 'section_id' => 
$receipt_section['section_id'] , 'location_id' => 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket')) );
+               }
+
+               function check_status($data)
+               {
+                       $status_arr = explode(',', 
$this->config['ticket_redirect']['status']);
+                       $target_arr = explode(',', 
$this->config['ticket_redirect']['target']);
+
+                       foreach($status_arr as $key => $status_redirect)
+                       {
+                               if($data['status'] != $data['old_status'] && 
trim($data['status'],'C') == $status_redirect && isset($target_arr[$key]) && 
$target_arr[$key])
+                               {
+                                       $link_data = array
+                                       (
+                                               'menuaction'            => 
$target_arr[$key],
+                                               'bypass'                        
=> true,
+                                               'location_code'         => 
$data['location_code'],
+                                               'p_num'                         
=> $data['p_num'],
+                                               'p_entity_id'           => 
$data['p_entity_id'],
+                                               'p_cat_id'                      
=> $data['p_cat_id'],
+                                               'tenant_id'                     
=> $data['tenant_id'],
+                                               'origin'                        
=> '.ticket',
+                                               'origin_id'                     
=> $data['id']
+                                       );
+
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+                               }
+                       }
+               }
+       }

Modified: branches/Version-1_0-branch/property/inc/hook_home.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/hook_home.inc.php  2012-02-07 
07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/inc/hook_home.inc.php  2012-02-07 
07:35:50 UTC (rev 8798)
@@ -108,7 +108,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN ticket info 
-->'."\n".$portalbox->draw()."\n".'<!-- END ticket info -->'."\n";
+               echo "\n".'<!-- BEGIN ticket info -->'."\n<div 
class='property_tickets' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END ticket info -->'."\n";
 
                unset($tts);
                unset($portalbox);
@@ -189,7 +189,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN ticket info 
-->'."\n".$portalbox->draw()."\n".'<!-- END ticket info -->'."\n";
+               echo "\n".'<!-- BEGIN ticket info -->'."\n<div 
class='property_tickets' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END ticket info -->'."\n";
 
                unset($tts);
                unset($portalbox);
@@ -269,7 +269,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN ticket info 
-->'."\n".$portalbox->draw()."\n".'<!-- END ticket info -->'."\n";
+               echo "\n".'<!-- BEGIN ticket info -->'."\n<div 
class='property_tickets' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END ticket info -->'."\n";
 
                unset($tts);
                unset($portalbox);
@@ -361,7 +361,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN ticket info 
-->'."\n".$portalbox->draw()."\n".'<!-- END ticket info -->'."\n";
+               echo "\n".'<!-- BEGIN ticket info -->'."\n<div 
class='property_tickets' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END ticket info -->'."\n";
 
                unset($tts);
                unset($portalbox);
@@ -418,7 +418,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN project 1 info 
-->'."\n".$portalbox->draw()."\n".'<!-- END project 1 info -->'."\n";
+               echo "\n".'<!-- BEGIN project 1 info -->'."\n<div 
class='property_project' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END project 1 info -->'."\n";
 
                unset($obj);
                unset($portalbox);
@@ -474,7 +474,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN workorder 1 info 
-->'."\n".$portalbox->draw()."\n".'<!-- END workorder 1 info -->'."\n";
+               echo "\n".'<!-- BEGIN workorder 1 info -->'."\n<div 
class='property_workorder' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END workorder 1 info -->'."\n";
 
                unset($obj);
                unset($portalbox);
@@ -529,7 +529,7 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN workorder 2 info 
-->'."\n".$portalbox->draw()."\n".'<!-- END workorder 2 info -->'."\n";
+               echo "\n".'<!-- BEGIN workorder 2 info -->'."\n<div 
class='property_workorder' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END workorder 2 info -->'."\n";
 
                unset($obj);
                unset($portalbox);
@@ -653,7 +653,8 @@
                        );
                }
 
-               echo "\n".'<!-- BEGIN approval info 
-->'."\n".$portalbox->draw()."\n".'<!-- END approval info -->'."\n";
+               echo "\n".'<!-- BEGIN approval info -->'."\n<div 
class='property_approval' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END approval info -->'."\n";
+
                unset($portalbox);
                unset($obj);
                unset($pending_approvals);
@@ -781,7 +782,8 @@
                $portalbox->setvar('title', $title);
                $portalbox->start_template();
 
-               echo "\n".'<!-- BEGIN approval info 
-->'."\n".$portalbox->draw()."\n".'<!-- END approval info -->'."\n";
+               echo "\n".'<!-- BEGIN approval info -->'."\n<div 
class='property_approval' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END approval info -->'."\n";
+
                unset($portalbox);
                unset($pending_approvals);
        }
@@ -859,7 +861,8 @@
                $portalbox->setvar('title', $title);
                $portalbox->start_template();
 
-               echo "\n".'<!-- BEGIN reminder info 
-->'."\n".$portalbox->draw()."\n".'<!-- END reminder info -->'."\n";
+               echo "\n".'<!-- BEGIN reminder info -->'."\n<div 
class='property_reminder' style='padding-left: 
10px;'>".$portalbox->draw()."</div>\n".'<!-- END reminder info -->'."\n";
+
                unset($pending_reminder);
                unset($portalbox);
        }

Modified: branches/Version-1_0-branch/property/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/property/setup/phpgw_no.lang    2012-02-07 
07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/property/setup/phpgw_no.lang    2012-02-07 
07:35:50 UTC (rev 8798)
@@ -1885,6 +1885,7 @@
 write off period       property        no      avskrivningsperiode
 year   property        no      År
 yearly property        no      Årlig
+you are not approved for this task     property        no      Du mangler 
rettigheter for denne oppgaven
 you have entered an invalid end date ! property        no      Du har angitt 
en ugyldig slutt dato
 you have entered an invalid start date !       property        no      Du har 
angitt en ugyldig start dato
 you have no edit right for this project        property        no      Du har 
ikke editeringsrettigheter for dette prosjektet

Modified: branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.socontract.inc.php     
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/rental/inc/class.socontract.inc.php     
2012-02-07 07:35:50 UTC (rev 8798)
@@ -12,7 +12,9 @@
 {
        protected static $so;
        protected $fields_of_responsibility; // Used for caching the values
-       
+       protected $ordermethod;
+       protected $order_field;
+
        /**
         * Get a static reference to the storage object associated with this 
model object
         * 
@@ -20,12 +22,13 @@
         */
        public static function get_instance()
        {
-               if (self::$so == null) {
+               if (self::$so == null)
+               {
                        self::$so = CreateObject('rental.socontract');
                }
                return self::$so;
        }
-       
+
        /**
         * Filters:
         * Contracts with party as contract party
@@ -40,41 +43,62 @@
         * @see rental/inc/rental_socommon#get_query($sort_field, $ascending, 
$search_for, $search_type, $filters, $return_count)
         */
        protected function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean $return_count)
-       {       
+       {
                $clauses = array('1=1');
-               
+
                //Add columns to this array to include them in the query
                $columns = array();
-               
+
                $dir = $ascending ? 'ASC' : 'DESC';
                if($sort_field == null || $sort_field == '')
                {
                        $sort_field = 'contract.id';
                }
-               else if ($sort_field == 'party'){
+               else if ($sort_field == 'party')
+               {
                        $sort_field = "party.company_name {$dir}, 
party.last_name {$dir}, party.first_name";
+                       $this->order_field = 'party.company_name, 
party.last_name, party.first_name';
                }
-               else if ($sort_field == 'composite'){
+               else if ($sort_field == 'composite')
+               {
                        $sort_field = "composite.name";
+                       $this->order_field = $sort_field;
                }
-               else if ($sort_field == 'type'){
+               else if ($sort_field == 'type')
+               {
                        $sort_field = 'contract.location_id';
+                       $this->order_field = $sort_field;
                }
-               else if($sort_field == 'term_label'){
+               else if($sort_field == 'term_label')
+               {
                        $sort_field = 'contract.term_id';
+                       $this->order_field = $sort_field;
                }
-               
-               
+               else
+               {
+                       $this->order_field = $sort_field;
+               }
+
+
                //Contracts for billing should always be sorted on biling start
                if(isset($filters['contracts_for_billing']))
                {
-                       $order = "ORDER BY contract.billing_start ASC"; 
+                       $order = "ORDER BY contract.billing_start ASC";
+                       $this->order_field = 'billing_start';
                }
                else
                {
-                       $order = "ORDER BY {$sort_field} {$dir}";
+                       switch ($sort_field)
+                       {
+                               case 'contract_id':
+                                       $order = "ORDER BY contract.id {$dir}";
+                                       $this->order_field = '';
+                                       break;
+                               default:
+                                       $order = "ORDER BY {$sort_field} 
{$dir}";
+                       }
                }
-               
+
                // Search for based on search type
                if($search_for)
                {
@@ -82,7 +106,8 @@
                        $like_pattern = "'%".$search_for."%'";
                        $int_value_of_search = (int) $search_for;
                        $like_clauses = array();
-                       switch($search_type){
+                       switch($search_type)
+                       {
                                case "id":
                                        $like_clauses[] = 
"contract.old_contract_id $this->like $like_pattern";
                                        break;
@@ -101,7 +126,7 @@
                                        $like_clauses[] = "r_u.location_code 
like '{$search_for}%'";
                                        break;
                                case "all":
-                                       
+
                                        $like_clauses[] = 
"contract.old_contract_id $this->like $like_pattern";
                                        $like_clauses[] = "contract.comment 
$this->like $like_pattern";
                                        $like_clauses[] = "party.first_name 
$this->like $like_pattern";
@@ -111,7 +136,7 @@
                                        $like_clauses[] = "r_u.location_code 
$this->like $like_pattern";
                                        break;
                        }
-                       
+
                        if($composite_address)
                        {
                                $sql_composite_address = "select 
rental_composite.id as rc_id from rental_composite,rental_unit,fm_gab_location 
where rental_unit.composite_id=rental_composite.id and 
fm_gab_location.location_code=rental_unit.location_code and 
fm_gab_location.address like upper({$like_pattern})";
@@ -131,73 +156,77 @@
                                        $like_clauses[] = "composite.id in 
(-1)";
                                }
                        }
-                       
-                       
+
+
                        if(count($like_clauses))
                        {
                                $clauses[] = '(' . join(' OR ', $like_clauses) 
. ')';
                        }
-                       
-                       
                }
-               
+
                $filter_clauses = array();
-               
+
                // Contracts with party as contract party
-               if(isset($filters['party_id'])){
+               if(isset($filters['party_id']))
+               {
                        $party_id  =   
$this->marshal($filters['party_id'],'int');
                        $filter_clauses[] = "party.id = $party_id";
                }
-               
+
                // Contracts for this executive officer
-               if(isset($filters['executive_officer'])){
+               if(isset($filters['executive_officer']))
+               {
                        $account_id  =   
$this->marshal($filters['executive_officer'],'int');
                        $filter_clauses[] = "contract.executive_officer = 
$account_id";
                }
 
                // Contracts of type
-               if(isset($filters['contract_type']) && 
$filters['contract_type'] != 'all'){
+               if(isset($filters['contract_type']) && 
$filters['contract_type'] != 'all')
+               {
                        $type = 
$this->marshal($filters['contract_type'],'field');
                        $filter_clauses[] = "contract.location_id IN ($type)";
                }
-               
+
                // Contracts with this id (filter for retrieveing a single 
contract)
-               if(isset($filters[$this->get_id_field_name()])){
+               if(isset($filters[$this->get_id_field_name()]))
+               {
                        $id = 
$this->marshal($filters[$this->get_id_field_name()],'int');
                        $filter_clauses[] = "contract.id = {$id}";
                }
-               
+
                // All contracts with composite as contract composite
                if(isset($filters['composite_id']))
-               {       
+               {
                        $composite_id = 
$this->marshal($filters['composite_id'],'int');
                        $filter_clauses[] = "composite.id = {$composite_id}";
                }
-               
+
                // Affected contracts by regulation
                if(isset($filters['adjustment_interval']) && 
isset($filters['adjustment_year']))
                {
                        $adjustment_interval = 
$this->marshal($filters['adjustment_interval'],'int');
                        $adjustment_year = 
$this->marshal($filters['adjustment_year'],'int');
-                       
-                       if($filters['adjustment_is_executed']){
+
+                       if($filters['adjustment_is_executed'])
+                       {
                                $filter_clauses[] = "contract.adjustment_year = 
{$adjustment_year}";
                        }
-                       else{
+                       else
+                       {
                                $filter_clauses[] = "contract.adjustment_year + 
{$adjustment_interval} <= {$adjustment_year}";
                        }
-                       
+
                        $firstJanAdjYear = mktime(0,0,0,1,1,$adjustment_year);
-                       
+
                        //make sure the contracts are active
                        $filter_clauses[] = "(contract.date_end is null OR 
contract.date_end >= {$firstJanAdjYear})";
                        $filter_clauses[] = "contract.date_start is not null 
AND contract.date_start <= {$firstJanAdjYear}";
-                       
+
                        $filter_clauses[] = "contract.adjustable IS true";
                        $filter_clauses[] = "contract.adjustment_interval = 
{$adjustment_interval}";
-                       
+
                }
-               
+
                /* 
                 * Contract status is defined by the dates in each contract 
compared to the target date (default today):
                 * - contracts under planning: 
@@ -212,8 +241,9 @@
                 * - ended:
                 * the end date is smaller than the target date
                 */
-               if(isset($filters['contract_status']) && 
$filters['contract_status'] != 'all'){ 
-                       
+               if(isset($filters['contract_status']) && 
$filters['contract_status'] != 'all')
+               {
+
                        if(isset($filters['status_date_hidden']) && 
$filters['status_date_hidden'] != "")
                        {
                                $ts_query = 
strtotime($filters['status_date_hidden']); // target timestamp specified by user
@@ -222,7 +252,8 @@
                        {
                                $ts_query = strtotime(date('Y-m-d')); // 
timestamp for query (today)
                        }
-                       switch($filters['contract_status']){
+                       switch($filters['contract_status'])
+                       {
                                case 'under_planning':
                                        $filter_clauses[] = 
"contract.date_start > {$ts_query} OR contract.date_start IS NULL";
                                        break;
@@ -245,7 +276,7 @@
                                        break;
                        }
                }
-               
+
                /*
                 * Contracts for billing
                 */
@@ -274,27 +305,39 @@
                        }
                        $timestamp_end = strtotime('+1 month', $timestamp_end); 
// The first day in the month after the one to bill for
                        //$timestamp_start = strtotime("{$year}-{$month}-01");
-                       
+
                        $filter_clauses[] = "contract.term_id = 
{$billing_term_id}";
                        $filter_clauses[] = "contract.date_start < 
$timestamp_end";
                        $filter_clauses[] = "(contract.date_end IS NULL OR 
contract.date_end >= {$timestamp_start})";
                        $filter_clauses[] = "(contract.billing_start IS NULL OR 
contract.billing_start < {$timestamp_end})";
-                       
+
                        $specific_ordering = 'invoice.timestamp_end DESC, 
contract.billing_start DESC, contract.date_start DESC, contract.date_end DESC';
                        $order = $order ? $order.', '.$specific_ordering : 
"ORDER BY {$specific_ordering}";
                }
-               
+
                if(count($filter_clauses))
                {
                        $clauses[] = join(' AND ', $filter_clauses);
                }
-               
+
                $condition =  join(' AND ', $clauses);
-               
+
+               $tables = "rental_contract contract";
+               $join_contract_type =   $this->left_join.' 
rental_contract_responsibility type ON (type.location_id = 
contract.location_id)';
+               $join_parties = $this->left_join.' rental_contract_party c_t ON 
(contract.id = c_t.contract_id) LEFT JOIN rental_party party ON (c_t.party_id = 
party.id)';
+               $join_composites =              $this->left_join." 
rental_contract_composite c_c ON (contract.id = c_c.contract_id) 
{$this->left_join} rental_composite composite ON c_c.composite_id = 
composite.id";
+               $join_units = $this->left_join." rental_unit r_u ON 
(r_u.composite_id=composite.id)";
+               $join_last_edited = $this->left_join.' 
rental_contract_last_edited last_edited ON (contract.id = 
last_edited.contract_id)';
+               $join_last_billed = "{$this->left_join} rental_invoice invoice 
ON (contract.id = invoice.contract_id) {$this->left_join} rental_billing 
billing ON (invoice.billing_id = billing.id)";
+               $join_term_title = "{$this->left_join} rental_billing_term 
r_b_t ON (contract.term_id = r_b_t.id)";
+               $joins = $join_contract_type.' '.$join_parties.' 
'.$join_composites.' '.$join_units.' '.$join_last_edited.' 
'.$join_last_billed.' '.$join_term_title;
+
                if($return_count) // We should only return a count
                {
-                       $cols = 'COUNT(DISTINCT(contract.id)) AS count';
-                       $order = ''; // No ordering
+                       // Sigurd 4. feb 2012: The improved query is 50 % 
faster - might have the use the old one for non-postgresql-db
+                       // $cols = 'COUNT(DISTINCT(contract.id)) AS count';
+                       // return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition}";
+                       return "SELECT COUNT(id) AS count FROM (SELECT 
DISTINCT(contract.id)  as id FROM {$tables} {$joins} WHERE {$condition}) as t";
                }
                else
                {
@@ -303,31 +346,93 @@
                        $columns[] = 'contract.date_start, contract.date_end, 
contract.old_contract_id, contract.executive_officer, contract.last_updated, 
contract.location_id, contract.billing_start, contract.service_id, 
contract.responsibility_id, contract.reference, contract.invoice_header, 
contract.project_id, billing.deleted, contract.account_in, 
contract.account_out, contract.term_id, contract.security_type, 
contract.security_amount, contract.comment, contract.due_date, 
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,contract.publish_comment';
                        $columns[] = 'party.id AS party_id';
                        $columns[] = 'party.first_name, party.last_name, 
party.company_name';
-                       $columns[] = 'c_t.is_payer';            
+                       $columns[] = 'c_t.is_payer';
                        $columns[] = 'composite.id AS composite_id';
                        $columns[] = 'composite.name AS composite_name';
                        $columns[] = 'type.title, type.notify_before, 
type.notify_before_due_date, type.notify_after_termination_date';
                        $columns[] = 'last_edited.edited_on';
-                       $columns[] = 'invoice.timestamp_end';   
+                       $columns[] = 'invoice.timestamp_end';
                        $columns[] = 'r_b_t.title AS term_title';
                        $cols = implode(',',$columns);
+
+                       $this->ordermethod = $order;
+
+                       return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition}";
                }
-               
-               $tables = "rental_contract contract";
-               $join_contract_type =   $this->left_join.' 
rental_contract_responsibility type ON (type.location_id = 
contract.location_id)';
-               $join_parties = $this->left_join.' rental_contract_party c_t ON 
(contract.id = c_t.contract_id) LEFT JOIN rental_party party ON (c_t.party_id = 
party.id)';
-               $join_composites =              $this->left_join." 
rental_contract_composite c_c ON (contract.id = c_c.contract_id) 
{$this->left_join} rental_composite composite ON c_c.composite_id = 
composite.id";
-               $join_units = $this->left_join." rental_unit r_u ON 
(r_u.composite_id=composite.id)";
-               $join_last_edited = $this->left_join.' 
rental_contract_last_edited last_edited ON (contract.id = 
last_edited.contract_id)';
-               $join_last_billed = "{$this->left_join} rental_invoice invoice 
ON (contract.id = invoice.contract_id) {$this->left_join} rental_billing 
billing ON (invoice.billing_id = billing.id)";
-               $join_term_title = "{$this->left_join} rental_billing_term 
r_b_t ON (contract.term_id = r_b_t.id)";
-               $joins = $join_contract_type.' '.$join_parties.' 
'.$join_composites.' '.$join_units.' '.$join_last_edited.' 
'.$join_last_billed.' '.$join_term_title;
+       }
 
-               //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}");
-               
-               return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
+       /**
+        * Method for retreiving objects.
+        * 
+        * @param $start_index int with index of first object.
+        * @param $num_of_objects int with max number of objects to return.
+        * @param $sort_field string representing the object field to sort on.
+        * @param $ascending boolean true for ascending sort on sort field, 
false
+        * for descending.
+        * @param $search_for string with free text search query.
+        * @param $search_type string with the query type.
+        * @param $filters array with key => value of filters.
+        * @return array of objects. May return an empty
+        * array, never null. The array keys are the respective index numbers.
+        */
+       public function get(int $start_index, int $num_of_objects, string 
$sort_field, boolean $ascending, string $search_for, string $search_type, array 
$filters)
+       {
+               $results = array();                     // Array to store 
result objects
+
+               // Retrieve information about the table name and the name and 
alias of id column
+               //                                              for all the 
result objects are traversed
+               $id_field_name_info = $this->get_id_field_name(true);
+               if(is_array($id_field_name_info))
+               {
+                       $id_field_name = $id_field_name_info['translated'];
+               }
+               else
+               {
+                       $id_field_name = $id_field_name_info;
+               }
+
+               // Special case: Sort on id field. Always changed to the id 
field name.
+               //              results are reached and we are sure that the 
records are ordered by the id
+               if($sort_field == null || $sort_field == 'id' || $sort_field == 
'')
+               {
+                       $sort_field = $id_field_name;
+               }
+
+               // Only allow positive start index
+               if($start_index < 0)
+               {
+                       $start_index = 0;
+               }
+
+               $sql = $this->get_query($sort_field, $ascending, $search_for, 
$search_type, $filters, false);
+               $sql_parts = explode('1=1',$sql); // Split the query to insert 
extra condition on test for break
+
+               $sql_minimized = 'SELECT DISTINCT contract.id '  . 
substr($sql,strripos($sql,'FROM'));
+               $order_field = $this->order_field ? ", {$this->order_field}" : 
'';
+               $sql_end =   str_replace('SELECT DISTINCT contract.id',"SELECT 
DISTINCT contract.id {$order_field}", $sql_minimized) . " GROUP BY contract.id 
{$order_field} {$this->ordermethod}";
+       //_debug_array($sql_end);
+               $this->db->limit_query($sql_end,$start_index,__LINE__,__FILE__, 
$num_of_objects);
+
+               $records = array();
+               while ($this->db->next_record())
+               {
+                       $records[] =  (int)$this->db->f('id');
+               }
+
+               foreach ($records as $id)
+               {
+                       $this->db->query("{$sql_parts[0]} contract.id = 
{$id}",__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $result = &$results[$id];
+                               $results[$id] = $this->populate($id,$result);
+                       }
+               }
+
+               return $results;
        }
-       
+
+
        public function get_id_field_name($extended_info = false)
        {
                if(!$extended_info)
@@ -346,10 +451,10 @@
                return $ret;
        }
 
-       
+
        function populate(int $contract_id, &$contract)
        {
-               
+
                if($contract == null ) // new contract
                {
                        $contract_id = (int) $contract_id; 
@@ -390,23 +495,23 @@
                        
$contract->set_notify_before($this->unmarshal($this->db->f('notify_before'),'int'));
                        
$contract->set_notify_before_due_date($this->unmarshal($this->db->f('notify_before_due_date'),'int'));
                        
$contract->set_notify_after_termination_date($this->unmarshal($this->db->f('notify_after_termination_date'),'int'));
-                       
-                       
+
+
                }
-               
+
                $timestamp_end = 
$this->unmarshal($this->db->f('timestamp_end'),'int');
                $billing_deleted = 
$this->unmarshal($this->db->f('deleted'),'bool');
                if($timestamp_end && !$billing_deleted)
                {
                        $contract->add_bill_timestamp($timestamp_end);
                }
-               
+
                $total_price = 
$this->unmarshal($this->db->f('total_price'),'int');
                if($total_price)
                {
                        $contract->set_total_price($total_price);
                }
-               
+
                $party_id = $this->unmarshal($this->db->f('party_id', true), 
'int');
                if($party_id)
                {
@@ -421,7 +526,7 @@
                        }
                        $contract->add_party($party);
                }
-               
+
                $composite_id = $this->unmarshal($this->db->f('composite_id', 
true), 'int');
                if($composite_id)
                {
@@ -431,19 +536,21 @@
                }
                return $contract;
        }
-       
+
        /**
         * Get a key/value array of contract type titles keyed by their id
         * 
         * @return array
         */
-       function get_fields_of_responsibility(){
+       function get_fields_of_responsibility()
+       {
                if($this->fields_of_responsibility == null)
                {
                        $sql = "SELECT location_id,title FROM 
rental_contract_responsibility";
                        $this->db->query($sql, __LINE__, __FILE__);
                        $results = array();
-                       while($this->db->next_record()){
+                       while($this->db->next_record())
+                       {
                                $location_id = $this->db->f('location_id', 
true);
                                $results[$location_id] = $this->db->f('title', 
true);
                        }
@@ -451,8 +558,9 @@
                }
                return $this->fields_of_responsibility;
        }
-       
-       function get_default_account(int $location_id, bool $in){
+
+       function get_default_account(int $location_id, bool $in)
+       {
                if(isset($location_id) && $location_id > 0)
                {
                        if($in)
@@ -463,7 +571,7 @@
                        {
                                $col = 'account_out';
                        }
-                       
+
                        $sql = "SELECT {$col} FROM 
rental_contract_responsibility WHERE location_id = {$location_id}";
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
@@ -471,7 +579,7 @@
                }
                return '';
        }
-       
+
        function get_default_project_number(int $location_id)
        {
                if(isset($location_id) && $location_id > 0)
@@ -480,9 +588,9 @@
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        return $this->db->f('project_number',true);
-               }       
+               }
        }
-       
+
        function get_responsibility_title(int $location_id)
        {
                if(isset($location_id) && $location_id > 0)
@@ -491,9 +599,9 @@
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        return $this->db->f('title',true);
-               }       
+               }
        }
-       
+
        /**
         * Returns the range of year there are contracts. That is, the array
         * returned contains reversed chronologically all the years from the 
earliest start
@@ -523,10 +631,10 @@
                {
                        $year_range[] = $year;
                }
-               
+
                return $year_range;
        }
-       
+
        /**
         * Update the database values for an existing contract object.
         * 
@@ -536,7 +644,7 @@
        function update($contract)
        {
                $id = intval($contract->get_id());
-               
+
                $values = array();
 
                // Set all fields in form
@@ -544,18 +652,19 @@
                // FORM COLUMN 1
                $values[] = "contract_type_id = ".      
$this->marshal($contract->get_contract_type_id(), 'int');
                $values[] = "executive_officer = ". 
$this->marshal($contract->get_executive_officer_id(), 'int');
-               
-               if ($contract->get_contract_date()) {
+
+               if ($contract->get_contract_date())
+               {
                        $values[] = "date_start = " .   
$this->marshal($contract->get_contract_date()->get_start_date(), 'int');
                        $values[] = "date_end = " .             
$this->marshal($contract->get_contract_date()->get_end_date(), 'int');
                }
-               
+
                $values[] = "due_date = " .             
$this->marshal($contract->get_due_date(), 'int');
                $values[] = "invoice_header = ".        
$this->marshal($contract->get_invoice_header(),'string');
                $values[] = "term_id = " .                      
$this->marshal($contract->get_term_id(), 'int');
                $values[] = "billing_start = " .        
$this->marshal($contract->get_billing_start_date(), 'int');
                $values[] = "reference = ".             
$this->marshal($contract->get_reference(),'string');
-               
+
                // FORM COLUMN 2
                $values[] = "service_id = ".            
$this->marshal($contract->get_service_id(),'string');
                $values[] = "responsibility_id = ". 
$this->marshal($contract->get_responsibility_id(),'string');
@@ -569,25 +678,25 @@
                $values[] = "adjustment_interval = ".           
$this->marshal($contract->get_adjustment_interval(),'int');
                $values[] = "adjustment_share = ".              
$this->marshal($contract->get_adjustment_share(),'int');
                $values[] = "publish_comment = ".       
($contract->get_publish_comment() ? "true" : "false");
-               
+
                // FORM COLUMN 3
                $values[] = "comment = ".                       
$this->marshal($contract->get_comment(), 'string');
-               
-               
+
+
                // Set date last updated
                $values[] = "last_updated = ".          strtotime('now');
-               
+
                $result = $this->db->query('UPDATE rental_contract SET ' . 
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
-               
+
                if(isset($result))
                {
                        $this->last_edited_by($id);
                        return true;
                }
-                       
+
                return false;
        }
-       
+
        /**
         * This method marks the combination contract/user account with the 
current timestamp. It updates the record if the user has updated
         * this contract before; inserts a new record if the user has never 
updated this contract. 
@@ -595,13 +704,14 @@
         * @param $contract_id
         * @return true if the contract was marker, false otherwise
         */
-       public function last_edited_by($contract_id){
+       public function last_edited_by($contract_id)
+       {
                $account_id = $GLOBALS['phpgw_info']['user']['account_id']; // 
current user
                $ts_now = strtotime('now');
-               
+
                $sql_has_edited_before = "SELECT account_id FROM 
rental_contract_last_edited WHERE contract_id = $contract_id AND account_id = 
$account_id";
                $result = $this->db->query($sql_has_edited_before);
-               
+
                if(isset($result))
                {
                        if($this->db->next_record())
@@ -620,13 +730,13 @@
                }
                return false;
        }
-       
+
        public function remove_Last_edited_by_information()
        {
                $sql = "DELETE * FROM rental_contract_last_edited";
                $this->db->query($sql);
        }
-       
+
        public function get_last_edited_by($contract_id)
        {
                $sql = "SELECT account_id FROM rental_contract_last_edited 
where contract_id={$contract_id} ORDER by edited_on DESC";
@@ -641,14 +751,15 @@
                }
                return "";
        }
-       
+
        /**
         * This method markw the given contract with the current timestamp
         * 
         * @param $contract_id
         * @return true if the contract was marked, false otherwise
         */
-       public function last_updated($contract_id){
+       public function last_updated($contract_id)
+       {
                $ts_now = strtotime('now');
                $sql = "UPDATE rental_contract SET last_updated=$ts_now";
                $result = $this->db->query($sql);
@@ -661,7 +772,7 @@
                        return false;
                }
        }
-       
+
        /**
         * Add a new contract to the database.  Adds the new insert id to the 
object reference.
         * 
@@ -670,121 +781,128 @@
         */
        function add(&$contract)
        {
-        
-        $contract->set_id(self::get_new_id($contract->get_old_contract_id()));
 
-        // Contract has no old or new ID, get next ID available from DB
-        if($this->marshal($contract->get_id(), 'int') == 0) {
-            $new_id = $this->db->next_id('rental_contract');
-            $contract->set_id($new_id);
-        }
+               
$contract->set_id(self::get_new_id($contract->get_old_contract_id()));
 
+               // Contract has no old or new ID, get next ID available from DB
+               if($this->marshal($contract->get_id(), 'int') == 0)
+               {
+                       $new_id = $this->db->next_id('rental_contract');
+                       $contract->set_id($new_id);
+               }
+
                // These are the columns we know we have or that are nullable
                $cols = array('location_id', 'term_id');//
-               
+
                // Start making a db-formatted list of values of the columns we 
have to have
                $values = array(
                        $this->marshal($contract->get_location_id(), 'int'),
                        $this->marshal($contract->get_term_id(), 'int')
                );
 
-        // Set ID according to old contract id or generate a new one
-        $cols[] = 'id';
-        $values[] = $new_id ? $new_id : $this->marshal($contract->get_id(), 
'int');
+               // Set ID according to old contract id or generate a new one
+               $cols[] = 'id';
+               $values[] = $new_id ? $new_id : 
$this->marshal($contract->get_id(), 'int');
 
 
-               
+
                // Check values that can be null before trying to add them to 
the db-pretty list
-               if ($contract->get_billing_start_date()) {
+               if ($contract->get_billing_start_date())
+               {
                        $cols[] = 'billing_start';
                        $values[] = 
$this->marshal($contract->get_billing_start_date(), 'int');
                }
-               
-               if ($contract->get_contract_date()) {
+
+               if ($contract->get_contract_date())
+               {
                        $cols[] = 'date_start';
                        $cols[] = 'date_end';
                        $values[] = 
$this->marshal($contract->get_contract_date()->get_start_date(), 'int');
                        $values[] = 
$this->marshal($contract->get_contract_date()->get_end_date(), 'int');
                }
-               
-               if($contract->get_executive_officer_id()) {
+
+               if($contract->get_executive_officer_id())
+               {
                        $cols[] = 'executive_officer';
                        $values[] = 
$this->marshal($contract->get_executive_officer_id(), 'int');
                }
-               
+
                $cols[] = 'created';
                $cols[] = 'created_by';
                $values[] = strtotime('now');
                $values[] = $GLOBALS['phpgw_info']['user']['account_id'];
-               
-               
+
+
                $cols[] = 'service_id';
                $cols[] = 'responsibility_id';
                $values[] = 
$this->marshal($contract->get_service_id(),'string');
                $values[] = 
$this->marshal($contract->get_responsibility_id(),'string');
-               
+
                $cols[] = 'reference';
                $cols[] = 'invoice_header';
                $values[] = $this->marshal($contract->get_reference(),'string');
                $values[] = 
$this->marshal($contract->get_invoice_header(),'string');
-               
+
                $cols[] = 'account_in';
                $cols[] = 'account_out';
                $values[] = 
$this->marshal($contract->get_account_in(),'string');
                $values[] = 
$this->marshal($contract->get_account_out(),'string');
-               
+
                $cols[] = 'project_id';
                $values[] = 
$this->marshal($contract->get_project_id(),'string');
-               
+
                $cols[] = 'old_contract_id';
-        $values[] = $new_id ? 
$this->marshal(self::get_old_id($new_id),'string') : 
$this->marshal($contract->get_old_contract_id(),'string');
-               
-        $cols[] = 'rented_area';
-        $values[] =  $this->marshal($contract->get_rented_area(),'float');
-        
+               $values[] = $new_id ? 
$this->marshal(self::get_old_id($new_id),'string') : 
$this->marshal($contract->get_old_contract_id(),'string');
+
+               $cols[] = 'rented_area';
+               $values[] =  
$this->marshal($contract->get_rented_area(),'float');
+
                $cols[] = 'comment';
                $values[] = $this->marshal($contract->get_comment(),'string');
-               
+
                $cols[] = 'adjustment_interval';
                $values[] = 
$this->marshal($contract->get_adjustment_interval(),'int');
-               
+
                $cols[] = 'adjustment_share';
                $values[] = 
$this->marshal($contract->get_adjustment_share(),'int');
-               
+
                $cols[] = 'adjustable';
                $values[] = ($contract->get_adjustable() ? "true" : "false");
-               
+
                $cols[] = 'adjustment_year';
                $values[] = 
$this->marshal($contract->get_adjustment_year(),'int');
-               
+
                $cols[] = 'publish_comment';
                $values[] = ($contract->get_publish_comment() ? "true" : 
"false");
-               
-               
-               if ($contract->get_security_type()) {
+
+
+               if ($contract->get_security_type())
+               {
                        $cols[] = 'security_type';
                        $values[] = 
$this->marshal($contract->get_security_type(),'int');
                        $cols[] = 'security_amount';
                        $values[] = 
$this->marshal($contract->get_security_amount(),'string');
                }
-               
-               if ($contract->get_due_date()) {
+
+               if ($contract->get_due_date())
+               {
                        $cols[] = 'due_date';
                        $values[] = $this->marshal($contract->get_due_date(), 
'int');
                }
-               
-               if($contract->get_contract_type_id()) {
+
+               if($contract->get_contract_type_id())
+               {
                        $cols[] = 'contract_type_id';
                        $values[] = 
$this->marshal($contract->get_contract_type_id(), 'int');
                }
-               
+
                // Insert the new contract
                $q ="INSERT INTO rental_contract (" . join(',', $cols) . ") 
VALUES (" . join(',', $values) . ")";
                $result = $this->db->query($q);
-               
+
                return $contract;
        }
-       
+
        /**
         * This method adds a party to a contract. Updates last edited history.
         * 
@@ -804,7 +922,7 @@
                }
                return false;
        }
-       
+
        /**
         * This method removes a party from a contract. Updates last edited 
history.
         * 
@@ -824,7 +942,7 @@
                }
                return false;
        }
-       
+
        /**
         * This method adds a composite to a contract. Updates last edited 
history.
         * 
@@ -844,7 +962,7 @@
                }
                return false;
        }
-       
+
        /**
         * This method removes a composite from a contract. Updates last edited 
history.
         * 
@@ -864,9 +982,9 @@
                }
                return false;
        }
-       
-       
-       
+
+
+
        /**
         * This method sets a payer on a contract
         * 
@@ -897,171 +1015,194 @@
                return false;
        }
 
-    /**
-     * Convert old contract ID to new format
-     *
-     * @param $cid Old contract ID
-     * @return int New contract ID
-     */
-    public static function get_new_id($old) {
-        return (int) preg_replace('/[a-z]/i', '', $old);
-    }
+       /**
+        * Convert old contract ID to new format
+        *
+        * @param $cid Old contract ID
+        * @return int New contract ID
+        */
+       public static function get_new_id($old)
+       {
+               return (int) preg_replace('/[a-z]/i', '', $old);
+       }
 
-    /**
-     * Get new contract ID in "old" format
-     *
-     * @param $cid New contract ID
-     * @return string "Old" contract ID
-     */
-    public static function get_old_id($cid, $prefix = 'K', $digits = 8) {
-        $length = strlen(''.$cid);
+       /**
+        * Get new contract ID in "old" format
+        *
+        * @param $cid New contract ID
+        * @return string "Old" contract ID
+        */
+       public static function get_old_id($cid, $prefix = 'K', $digits = 8)
+       {
+               $length = strlen(''.$cid);
 
-        while($length != $digits) {
-            if($digits < $length) {
-                // If number of digits is lower that current length, this will 
loop forever, return null to stop it.
-                return null;
-            }
-            $cid = '0'.$cid;
-            $length = strlen(''.$cid);
-        }
+               while($length != $digits)
+               {
+                       if($digits < $length)
+                       {
+                               // If number of digits is lower that current 
length, this will loop forever, return null to stop it.
+                               return null;
+                       }
+                       $cid = '0'.$cid;
+                       $length = strlen(''.$cid);
+               }
 
-        return $prefix.$cid;
-    }
-    
-    public function get_contract_types($location_id){
-       $q1="SELECT rct.id, rct.label FROM rental_contract_types rct, 
rental_contract_responsibility rcr WHERE rcr.location_id={$location_id} AND 
rct.responsibility_id=rcr.id";
+               return $prefix.$cid;
+       }
+
+       public function get_contract_types($location_id)
+       {
+               $q1="SELECT rct.id, rct.label FROM rental_contract_types rct, 
rental_contract_responsibility rcr WHERE rcr.location_id={$location_id} AND 
rct.responsibility_id=rcr.id";
                $this->db->query($q1, __LINE__, __FILE__);
                $results = array();
-               while($this->db->next_record()){
+               while($this->db->next_record())
+               {
                        $results[$this->db->f('id')] = $this->db->f('label');
                }
-               
+
                return $results;
-    }
-    
-    public function get_contract_type_label($contract_type_id){
-       $result = "Ingen";
-       if(isset($contract_type_id)){
-               $q1="SELECT rct.label FROM rental_contract_types rct WHERE 
rct.id={$contract_type_id}";
+       }
+
+       public function get_contract_type_label($contract_type_id)
+       {
+               $result = "Ingen";
+               if(isset($contract_type_id))
+               {
+                       $q1="SELECT rct.label FROM rental_contract_types rct 
WHERE rct.id={$contract_type_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
-                       while($this->db->next_record()){
+                       while($this->db->next_record())
+                       {
                                $result = $this->db->f('label');
                        }
-       }
-               
+               }
+
                return $result;
-    }
-    
-    public function get_contract_type_account($contract_type_id)
-    {
-       $q1="SELECT rct.account FROM rental_contract_types rct WHERE 
rct.id={$contract_type_id}";
+       }
+
+       public function get_contract_type_account($contract_type_id)
+       {
+               $q1="SELECT rct.account FROM rental_contract_types rct WHERE 
rct.id={$contract_type_id}";
                $this->db->query($q1, __LINE__, __FILE__);
                $results = "";
-               while($this->db->next_record()){
+               while($this->db->next_record())
+               {
                        $result = $this->db->f('account');
                }
-               
+
                return $result;
-    }
-    
-    
-    public function get_term_label($billing_term_id){
-       $q1="SELECT rbt.title FROM rental_billing_term rbt WHERE 
rbt.id={$billing_term_id}";
+       }
+
+
+       public function get_term_label($billing_term_id)
+       {
+               $q1="SELECT rbt.title FROM rental_billing_term rbt WHERE 
rbt.id={$billing_term_id}";
                $this->db->query($q1, __LINE__, __FILE__);
                $results = "";
-               while($this->db->next_record()){
+               while($this->db->next_record())
+               {
                        $result = $this->db->f('title');
                }
-               
+
                return $result;
-    }
+       }
 
-    public function clear_last_edited_table() {
-        $q = "DELETE FROM rental_contract_last_edited";
-        $this->db->query($q, '', '', true);
-    }
-    public function copy_contract($contract_id, $old_contract_id){
-       //queries for selecting composites, parties and price items for the 
contract to be copied
-       $q_composites = "SELECT composite_id FROM rental_contract_composite 
WHERE contract_id={$old_contract_id}";
-       $q_parties = "SELECT party_id, is_payer FROM rental_contract_party 
WHERE contract_id={$old_contract_id}";
-       $q_price_items = "SELECT price_item_id, title, area, count, agresso_id, 
is_area, price, total_price, is_one_time FROM rental_contract_price_item WHERE 
contract_id={$old_contract_id}";
-       $success_composites = true;
-       $success_parties = true;
-       $success_price_items = true;
-       
-       //composites
-       $this->db->query($q_composites);
-       while($this->db->next_record()){
-               $composite_id = 
$this->unmarshal($this->db->f('composite_id'),'int');
-               $composite_id = $this->marshal($composite_id, 'int');
-               $sql = "INSERT INTO rental_contract_composite (contract_id, 
composite_id) VALUES ({$contract_id}, {$composite_id})";
-               $result_composites = $this->db->query($sql);
-               if($result_composites){
-                       //noop
-               }
-               else{
-                       $success_composites = false;
-               }
-       }
-       
-       //parties
-        $this->db->query($q_parties);
-       while($this->db->next_record()){
-               $party_id = $this->unmarshal($this->db->f('party_id'),'int');
-               $party_id = $this->marshal($party_id, 'int');
-               $is_payer = $this->unmarshal($this->db->f('is_payer'),'bool');
-               $is_payer = $this->marshal($is_payer ? 'true' : 'false','bool');
-               $sql = "INSERT INTO rental_contract_party (contract_id, 
party_id, is_payer) VALUES ({$contract_id}, {$party_id}, {$is_payer})";
-               $result_parties = $this->db->query($sql);
-               if($result_parties){
-                       //noop
-               }
-               else{
-                       $success_parties = false;
-               }
-       }
-       
-       //price items
-        $this->db->query($q_price_items);
-       while($this->db->next_record()){
-               $price_item_id = 
$this->unmarshal($this->db->f('price_item_id'),'int');
-               $price_item_id = $this->marshal($price_item_id, 'int');
-               $title = $this->unmarshal($this->db->f('title'),'string');
-               $title = $this->marshal($title, 'string');
-               $area = $this->unmarshal($this->db->f('area'),'float');
-               $area = $this->marshal($area, 'float');
-               $count = $this->unmarshal($this->db->f('count'),'int');
-               $count = $this->marshal($count, 'int');
-               $agresso_id = 
$this->unmarshal($this->db->f('agresso_id'),'string');
-               $agresso_id = $this->marshal($agresso_id, 'string');
-               $is_area = $this->unmarshal($this->db->f('is_area'),'bool');
-               $is_area = $this->marshal($is_area ? 'true' : 'false','bool');
-               $price = $this->unmarshal($this->db->f('price'),'float');
-               $price = $this->marshal($price, 'float');
-               $total_price = 
$this->unmarshal($this->db->f('total_price'),'float');
-               $total_price = $this->marshal($total_price, 'float');
-               $is_one_time = 
$this->unmarshal($this->db->f('is_one_time'),'bool');
-               $is_one_time = $this->marshal($is_one_time ? 'true' : 
'false','bool');
-               $sql = "INSERT INTO rental_contract_price_item (price_item_id, 
contract_id, title, area, count, agresso_id, is_area, price, total_price, 
is_one_time, date_start, date_end) VALUES ({$price_item_id}, {$contract_id}, 
{$title}, {$area}, {$count}, {$agresso_id}, {$is_area}, {$price}, 
{$total_price}, {$is_one_time}, null, null)";
-               $result_price_items = $this->db->query($sql);
-               if($result_price_items){
-                       //noop
-               }
-               else{
-                       $success_price_items = false;
-               }
-       }
-//     var_dump($success_composites.' '.$success_parties.' 
'.$success_price_items);
-       if($success_composites && $success_parties && $success_price_items){
-               return true;
-       }
-       else{
-               return false;
-       }
-    }
-    
-    public function get_months_in_term($term_id)
-    { 
+       public function clear_last_edited_table()
+       {
+               $q = "DELETE FROM rental_contract_last_edited";
+               $this->db->query($q, '', '', true);
+       }
+       public function copy_contract($contract_id, $old_contract_id)
+       {
+               //queries for selecting composites, parties and price items for 
the contract to be copied
+               $q_composites = "SELECT composite_id FROM 
rental_contract_composite WHERE contract_id={$old_contract_id}";
+               $q_parties = "SELECT party_id, is_payer FROM 
rental_contract_party WHERE contract_id={$old_contract_id}";
+               $q_price_items = "SELECT price_item_id, title, area, count, 
agresso_id, is_area, price, total_price, is_one_time FROM 
rental_contract_price_item WHERE contract_id={$old_contract_id}";
+               $success_composites = true;
+               $success_parties = true;
+               $success_price_items = true;
+
+               //composites
+               $this->db->query($q_composites);
+               while($this->db->next_record())
+               {
+                       $composite_id = 
$this->unmarshal($this->db->f('composite_id'),'int');
+                       $composite_id = $this->marshal($composite_id, 'int');
+                       $sql = "INSERT INTO rental_contract_composite 
(contract_id, composite_id) VALUES ({$contract_id}, {$composite_id})";
+                       $result_composites = $this->db->query($sql);
+                       if($result_composites)
+                       {
+                               //noop
+                       }
+                       else
+                       {
+                               $success_composites = false;
+                       }
+               }
+
+               //parties
+               $this->db->query($q_parties);
+               while($this->db->next_record())
+               {
+                       $party_id = 
$this->unmarshal($this->db->f('party_id'),'int');
+                       $party_id = $this->marshal($party_id, 'int');
+                       $is_payer = 
$this->unmarshal($this->db->f('is_payer'),'bool');
+                       $is_payer = $this->marshal($is_payer ? 'true' : 
'false','bool');
+                       $sql = "INSERT INTO rental_contract_party (contract_id, 
party_id, is_payer) VALUES ({$contract_id}, {$party_id}, {$is_payer})";
+                       $result_parties = $this->db->query($sql);
+                       if($result_parties)
+                       {
+                               //noop
+                       }
+                       else
+                       {
+                               $success_parties = false;
+                       }
+               }
+
+               //price items
+               $this->db->query($q_price_items);
+               while($this->db->next_record())
+               {
+                       $price_item_id = 
$this->unmarshal($this->db->f('price_item_id'),'int');
+                       $price_item_id = $this->marshal($price_item_id, 'int');
+                       $title = 
$this->unmarshal($this->db->f('title'),'string');
+                       $title = $this->marshal($title, 'string');
+                       $area = $this->unmarshal($this->db->f('area'),'float');
+                       $area = $this->marshal($area, 'float');
+                       $count = $this->unmarshal($this->db->f('count'),'int');
+                       $count = $this->marshal($count, 'int');
+                       $agresso_id = 
$this->unmarshal($this->db->f('agresso_id'),'string');
+                       $agresso_id = $this->marshal($agresso_id, 'string');
+                       $is_area = 
$this->unmarshal($this->db->f('is_area'),'bool');
+                       $is_area = $this->marshal($is_area ? 'true' : 
'false','bool');
+                       $price = 
$this->unmarshal($this->db->f('price'),'float');
+                       $price = $this->marshal($price, 'float');
+                       $total_price = 
$this->unmarshal($this->db->f('total_price'),'float');
+                       $total_price = $this->marshal($total_price, 'float');
+                       $is_one_time = 
$this->unmarshal($this->db->f('is_one_time'),'bool');
+                       $is_one_time = $this->marshal($is_one_time ? 'true' : 
'false','bool');
+                       $sql = "INSERT INTO rental_contract_price_item 
(price_item_id, contract_id, title, area, count, agresso_id, is_area, price, 
total_price, is_one_time, date_start, date_end) VALUES ({$price_item_id}, 
{$contract_id}, {$title}, {$area}, {$count}, {$agresso_id}, {$is_area}, 
{$price}, {$total_price}, {$is_one_time}, null, null)";
+                       $result_price_items = $this->db->query($sql);
+                       if($result_price_items)
+                       {
+                               //noop
+                       }
+                       else
+                       {
+                               $success_price_items = false;
+                       }
+               }
+//             var_dump($success_composites.' '.$success_parties.' 
'.$success_price_items);
+               if($success_composites && $success_parties && 
$success_price_items){
+                       return true;
+               }
+               else{
+                       return false;
+               }
+       }
+
+       public function get_months_in_term($term_id)
+       { 
                $sql = "SELECT months FROM rental_billing_term WHERE id = 
{$term_id}";
                $result = $this->db->query($sql);
                if(!$result)
@@ -1074,88 +1215,91 @@
                }
                $months = $this->unmarshal($this->db->f('months', true), 'int');
                return $months;
-    }
-    
-    public function update_price_items($contract_id, $rented_area){
-       $success_price_item = true;
-       $new_area = $rented_area;
-       $q_price_items = "SELECT id AS rpi_id, price as rpi_price FROM 
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area";
-       $res1 = $this->db->query($q_price_items, __LINE__, __FILE__,false,true);
-       while($this->db->next_record()){
-               $id = $this->db->f('rpi_id');
-               $price = $this->db->f('rpi_price');
-               $curr_total_price = ($new_area * $price);
-               $sql_pi = "UPDATE rental_contract_price_item SET 
area={$new_area}, total_price={$curr_total_price} WHERE id={$id}";
-               $result = $this->db->query($sql_pi, __LINE__, 
__FILE__,false,true);
-               if($result){
-                       //noop
-               }
-               else{
-                       $success_price_item = false;
-               }
-       }
-       if($success_price_item){
-               return true;
-       }
-       else{
-               return false;
-       }
-    }
-    
-    public function import_contract_reference($contract_id, $reference)
-    {
-       $reference = $this->marshal($reference,'string');
-       $sql = "UPDATE rental_contract SET reference={$reference} WHERE id = 
{$contract_id}";
-       $this->db->query($sql);
-    }
-    
-    public function update_adjustment_year_interval($contract_id, 
$adjusted_year, $adjustment_interval)
-    {
-       $new_adjusted_year = $this->marshal($adjusted_year, 'int');
-       $new_adjustment_interval = $this->marshal($adjustment_interval, 'int');
-       $sql = "UPDATE rental_contract SET adjustable=true, 
adjustment_interval={$new_adjustment_interval}, 
adjustment_year={$new_adjusted_year} WHERE id = {$contract_id} AND 
(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
-       $this->db->query($sql);
-       return $this->db->affected_rows() > 0 ? true : false;
-    }
-    
-    public function update_contract_end_date($contract_id, $date)
-    {
-       $cid = $this->marshal($contract_id, 'int');
-       $end_date = $this->marshal($date, 'int');
-       $sql = "UPDATE rental_contract SET date_end={$end_date} WHERE id = 
{$cid}";
-       $this->db->query($sql);
-    }
-    
+       }
+
+       public function update_price_items($contract_id, $rented_area){
+               $success_price_item = true;
+               $new_area = $rented_area;
+               $q_price_items = "SELECT id AS rpi_id, price as rpi_price FROM 
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area";
+               $res1 = $this->db->query($q_price_items, __LINE__, 
__FILE__,false,true);
+               while($this->db->next_record())
+               {
+                       $id = $this->db->f('rpi_id');
+                       $price = $this->db->f('rpi_price');
+                       $curr_total_price = ($new_area * $price);
+                       $sql_pi = "UPDATE rental_contract_price_item SET 
area={$new_area}, total_price={$curr_total_price} WHERE id={$id}";
+                       $result = $this->db->query($sql_pi, __LINE__, 
__FILE__,false,true);
+                       if($result)
+                       {
+                               //noop
+                       }
+                       else
+                       {
+                               $success_price_item = false;
+                       }
+               }
+               if($success_price_item)
+               {
+                       return true;
+               }
+               else
+               {
+                       return false;
+               }
+       }
+
+       public function import_contract_reference($contract_id, $reference)
+       {
+               $reference = $this->marshal($reference,'string');
+               $sql = "UPDATE rental_contract SET reference={$reference} WHERE 
id = {$contract_id}";
+               $this->db->query($sql);
+       }
+
+       public function update_adjustment_year_interval($contract_id, 
$adjusted_year, $adjustment_interval)
+       {
+               $new_adjusted_year = $this->marshal($adjusted_year, 'int');
+               $new_adjustment_interval = $this->marshal($adjustment_interval, 
'int');
+               $sql = "UPDATE rental_contract SET adjustable=true, 
adjustment_interval={$new_adjustment_interval}, 
adjustment_year={$new_adjusted_year} WHERE id = {$contract_id} AND 
(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
+               $this->db->query($sql);
+               return $this->db->affected_rows() > 0 ? true : false;
+       }
+
+       public function update_contract_end_date($contract_id, $date)
+       {
+               $cid = $this->marshal($contract_id, 'int');
+               $end_date = $this->marshal($date, 'int');
+               $sql = "UPDATE rental_contract SET date_end={$end_date} WHERE 
id = {$cid}";
+               $this->db->query($sql);
+       }
+
        public function update_adjustment_year($contract_id, $adjusted_year)
-    {
-       $new_adjusted_year = $this->marshal($adjusted_year, 'int');
-       $sql = "UPDATE rental_contract SET adjustment_year={$new_adjusted_year} 
WHERE id={$contract_id} AND(adjustment_year IS NULL OR 
adjustment_year<{$new_adjusted_year})";
-       $this->db->query($sql);
-       return $this->db->affected_rows() > 0 ? true : false;
-    }
-    
-    public function update_adjustment_share($contract_id, $adjustment_share)
-    {
-       $new_adjustment_share = $this->marshal($adjustment_share, 'int');
-       $sql = "UPDATE rental_contract SET 
adjustment_share={$new_adjustment_share} WHERE id = {$contract_id}";
-       $this->db->query($sql);
-    }
-    
-    public function get_default_price_items($location_id)
-    {
-       $price_items = array();
-       $loc_id = $this->marshal($location_id, 'int');
-       
-       //select all standard price_items for given location_id 
-       $sql = "SELECT id FROM rental_price_item WHERE 
responsibility_id={$loc_id} AND NOT is_inactive AND standard";
-       $this->db->query($sql);
-       while($this->db->next_record())
-       {
-               $price_item_id = $this->unmarshal($this->db->f('id'),'int');
-               $price_items[] = $price_item_id;
-       }
-       return $price_items;
-    }
+       {
+               $new_adjusted_year = $this->marshal($adjusted_year, 'int');
+               $sql = "UPDATE rental_contract SET 
adjustment_year={$new_adjusted_year} WHERE id={$contract_id} 
AND(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
+               $this->db->query($sql);
+               return $this->db->affected_rows() > 0 ? true : false;
+       }
 
+       public function update_adjustment_share($contract_id, $adjustment_share)
+       {
+               $new_adjustment_share = $this->marshal($adjustment_share, 
'int');
+               $sql = "UPDATE rental_contract SET 
adjustment_share={$new_adjustment_share} WHERE id = {$contract_id}";
+               $this->db->query($sql);
+       }
+
+       public function get_default_price_items($location_id)
+       {
+               $price_items = array();
+               $loc_id = $this->marshal($location_id, 'int');
+
+               //select all standard price_items for given location_id 
+               $sql = "SELECT id FROM rental_price_item WHERE 
responsibility_id={$loc_id} AND NOT is_inactive AND standard";
+               $this->db->query($sql);
+               while($this->db->next_record())
+               {
+                       $price_item_id = 
$this->unmarshal($this->db->f('id'),'int');
+                       $price_items[] = $price_item_id;
+               }
+               return $price_items;
+       }
 }
-?>

Modified: branches/Version-1_0-branch/rental/templates/base/contract_list.php
===================================================================
--- branches/Version-1_0-branch/rental/templates/base/contract_list.php 
2012-02-07 07:24:48 UTC (rev 8797)
+++ branches/Version-1_0-branch/rental/templates/base/contract_list.php 
2012-02-07 07:35:50 UTC (rev 8798)
@@ -58,9 +58,9 @@
 $editable = false;
 $extra_cols = array(
        array("key" => "type", "label" => lang('responsibility'), "index" => 3),
-       array("key" => "composite", "label" => lang('composite'), 
"sortable"=>'true', "index" => 4),
+       array("key" => "composite", "label" => lang('composite'), "sortable"=> 
false , "index" => 4),
        array("key" => "party", "label" => lang('party'), "sortable"=>'true', 
"index" => 5),
        array("key" => "contract_notification_status", "label" => 
lang('notification_status'), "sortable"=>false)
 );
 include('contract_list_partial.php');
-?>
\ No newline at end of file
+?>




reply via email to

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