fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9579] Merge 9557:9578 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [9579] Merge 9557:9578 from trunk
Date: Wed, 13 Jun 2012 12:59:02 +0000

Revision: 9579
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9579
Author:   sigurdne
Date:     2012-06-13 12:59:02 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
Merge 9557:9578 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/controller/inc/class.menu.inc.php
    branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
    
branches/Version-1_0-branch/controller/inc/component/class.year_calendar.inc.php
    branches/Version-1_0-branch/controller/inc/hook_home.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/tables_current.inc.php
    
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_details.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
    branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.solocation.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php
    branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
    branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
    
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
    branches/Version-1_0-branch/property/setup/phpgw_no.lang
    branches/Version-1_0-branch/property/setup/setup.inc.php
    branches/Version-1_0-branch/property/setup/tables_current.inc.php
    branches/Version-1_0-branch/property/setup/tables_update.inc.php
    branches/Version-1_0-branch/property/templates/base/invoice2.xsl
    branches/Version-1_0-branch/property/templates/base/project.xsl

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,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556
   + 
/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,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578

Modified: branches/Version-1_0-branch/controller/inc/class.menu.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.menu.inc.php       
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.menu.inc.php       
2012-06-13 12:59:02 UTC (rev 9579)
@@ -64,12 +64,12 @@
                                                                                
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_location.index') ),
                                                                                
                'image' => array('property', 'location_1')
                                                                                
        ),
-/*                                                                             
        'component_for_check_list' => array
+                                                                               
        'component_for_check_list' => array
                                                                                
        (
                                                                                
                'text'  => lang('component'),
-                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicheck_list_for_component.index') ),
+                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 
'controller.uicontrol_location.register_control_to_component') ),
                                                                                
                'image' => array('property', 'entity_1')
-                                                                               
        )*/
+                                                                               
        )
                                                                                
)
                                        ),
 /*                                     'location_for_check_list' => array

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-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php       
2012-06-13 12:59:02 UTC (rev 9579)
@@ -224,6 +224,8 @@
                $sql .= "FROM controller_check_list cl ";
                $sql .= "WHERE cl.control_id = $control_id ";
                $sql .= "AND cl.location_code = '{$location_code}' "; 
+               $sql .= "AND NOT cl.planned_date IS NULL ";
+               $sql .= "AND cl.completed_date IS NULL ";
                $sql .= "ORDER BY cl.id;";
                //var_dump($sql);
                $this->db->query($sql);
@@ -261,6 +263,51 @@
                }
        }
        
+       function get_unplanned_check_lists_for_control($control_id, 
$location_code){
+               $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, "; 
+               $sql .= "completed_date, component_id, location_code, 
num_open_cases, num_pending_cases ";
+               $sql .= "FROM controller_check_list cl ";
+               $sql .= "WHERE cl.control_id = $control_id ";
+               $sql .= "AND cl.location_code = '{$location_code}' "; 
+               $sql .= "AND cl.planned_date IS NULL ";
+               $sql .= "AND cl.completed_date IS NULL ";
+               $sql .= "ORDER BY cl.id;";
+
+               $this->db->query($sql);
+               
+               $check_list_id = 0;
+               $check_list = null;
+               while ($this->db->next_record()) {
+               
+                       if( $this->db->f('cl_id', true) != $check_list_id ){
+                               
+                               if($check_list_id != 0){
+                                       $check_list_array[] = $check_list;
+                               }
+                               
+                               $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+                               
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'int'));
+                               
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                               
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
+                               
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
+                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id', 
true), 'int'));
+                               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int')); 
+                               
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases',
 true), 'int'));
+                       }
+                       $check_list_id =  $check_list->get_id();
+               }
+               
+               if($check_list != null){
+                       $check_list_array[] = $check_list;
+               
+                       return $check_list_array;
+               }else {
+                       return null;
+               }
+       }
+       
        function get_agg_check_lists_for_location( $location_code, 
$from_date_ts, $to_date_ts, $control_id = 0 ){
                                
                $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(cl.num_open_cases) ";
@@ -319,11 +366,18 @@
                }       
        }
        
-       function get_num_open_cases_for_control( $control_id, $location_code, 
$from_date_ts, $to_date_ts ){
+       function get_num_open_cases_for_control( $control_id, $location_code, 
$from_date_ts, $to_date_ts, $component ){
                
                $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}' ";
+               if($component)
+               {
+                   $sql .= "WHERE cl.component_id = {$location_code} ";
+               }
+               else
+               {
+                   $sql .= "WHERE cl.location_code = '{$location_code}' ";
+               }
                $sql .= "AND c.id = $control_id ";
                $sql .= "AND cl.control_id = c.id ";
                $sql .= "AND cl.deadline >= $from_date_ts AND $to_date_ts > 
cl.deadline ";
@@ -506,6 +560,40 @@
                return array( "location_code" => $location_code, 
"check_lists_array" => $check_lists_array);
        }
        
+// Fetches check lists for component and control id
+       function get_check_lists_for_control_and_component( $control_id, 
$component_id, $from_date_ts, $to_date_ts, $repeat_type = null ){
+               $sql =  "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, completed_date, ";
+               $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases, num_pending_cases "; 
+               $sql .= "FROM controller_check_list cl ";
+               $sql .= "LEFT JOIN controller_control c on cl.control_id = c.id 
";
+               $sql .= "WHERE cl.control_id = {$control_id} ";
+               $sql .= "AND cl.component_id = {$component_id} ";
+               
+               if( $repeat_type != null )
+                       $sql .= "AND c.repeat_type = $repeat_type ";
+               
+               $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
+               
+               $this->db->query($sql);
+               
+               while ($this->db->next_record()) {
+                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'int'));
+                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
+                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
+                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                       
$check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id', 
true), 'int'));
+                       
$check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code',
 true), 'string'));
+                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int'));
+                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases',
 true), 'int'));
+                       
+                       $check_lists_array[] = $check_list;
+               }
+               
+               return array( "location_code" => $location_code, 
"check_lists_array" => $check_lists_array);
+       }
+       
        function get_check_list_for_date($control_id, $current_date){
                $sql =  "SELECT c.id as c_id, title, description, start_date, 
end_date, control_area_id, c.location_code as c_location_code, repeat_type, 
repeat_interval, ";
                $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";

Modified: branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-06-13 12:59:02 UTC (rev 9579)
@@ -113,6 +113,24 @@
                        //return isset($result);
                }
 
+               function get_controls_for_location($location_code, $from_date, 
$to_date, $repeat_type)
+               {
+                   $controls = array();
+                   $controls_loc = 
$this->get_controls_by_location($location_code, $from_date, $to_date, 
$repeat_type );
+                   $controls_comp = 
$this->get_controls_for_components_by_location($location_code, $from_date, 
$to_date, $repeat_type );
+                   
+                   foreach($controls_loc as $cl)
+                   {
+                       $controls[] = $cl;
+                   }
+                   foreach($controls_comp as $cc)
+                   {
+                       $controls[] = $cc;
+                   }
+                   
+                   return $controls;
+               }
+               
                public function get_controls_by_location($location_code, 
$from_date, $to_date, $repeat_type, $return_type = "return_object")
                {
                        $controls_array = array();
@@ -128,9 +146,112 @@
                        
                        $sql .= "AND (c.start_date <= $from_date AND c.end_date 
IS NULL ";
                        $sql .= "OR c.start_date > $from_date AND c.start_date 
< $to_date)";
+                       //var_dump($sql."<br/>");
+                       $this->db->query($sql);
+
+                       while($this->db->next_record()) {
+                               $control = new 
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
+                               
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+                               
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
+                               
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
+                               
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+                               
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
+                               
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
+                               
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
+                               
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
+                               
$control->set_responsibility_name($this->unmarshal($this->db->f('responsibility_name',
 true), 'string'));
+                               
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+                               
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                               
$control->set_repeat_type_label($this->unmarshal($this->db->f('repeat_type', 
true), 'int'));
+                               
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
+                               
+                               if($return_type == "return_object")
+                                       $controls_array[] = $control;
+                               else
+                                       $controls_array[] = $control->toArray();
+                       }
+
+                       if( count( $controls_array ) > 0 ){
+                               return $controls_array; 
+                       }
+                       else
+                       {
+                               return null;
+                       }
+               }
+               
+               public function get_controls_by_component($location_code, 
$from_date, $to_date, $repeat_type, $return_type = "return_object")
+               {
+                       $controls_array = array();
                        
+                       $sql   = "SELECT c.id as control_id, c.*, bim_item.id, 
xpath('/beskrivelse/text()', xml_representation), bim_item.location_code, 
bim_item.address ";
+                       $sql  .= "FROM controller_control_component_list cl ";
+                       $sql  .= "JOIN fm_bim_item bim_item on cl.component_id 
= bim_item.id ";
+                       $sql  .= "JOIN fm_bim_type bim_type on cl.location_id = 
bim_type.location_id ";
+                       $sql  .= "JOIN controller_control c on cl.control_id = 
c.id ";
+                       $sql  .= "AND bim_item.type = bim_type.id ";
+                       $sql  .= "AND bim_item.location_code LIKE 
'$location_code%'";
+                       
+                       if( is_numeric($repeat_type) )
+                               $sql .= "AND c.repeat_type = $repeat_type ";
+                       
+                       $sql .= "AND (c.start_date <= $from_date AND c.end_date 
IS NULL ";
+                       $sql .= "OR c.start_date > $from_date AND c.start_date 
< $to_date)";
+                       
+                       $sql .= "AND (c.start_date <= $from_date AND c.end_date 
IS NULL ";
+                       $sql .= "OR c.end_date > $from_date AND c.start_date < 
$to_date)";
+                       //var_dump($sql."<br/>");
                        $this->db->query($sql);
+                       
+                       while($this->db->next_record()) {
+                               $control = new 
controller_control($this->unmarshal($this->db->f('control_id', true), 'int'));
+                               
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+                               
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
+                               
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
+                               
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+                               
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
+                               
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
+                               
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
+                               
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
+                               
$control->set_responsibility_name($this->unmarshal($this->db->f('responsibility_name',
 true), 'string'));
+                               
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+                               
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                               
$control->set_repeat_type_label($this->unmarshal($this->db->f('repeat_type', 
true), 'int'));
+                               
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
+                               
+                               if($return_type == "return_object")
+                                       $controls_array[] = $control;
+                               else
+                                       $controls_array[] = $control->toArray();
+                       }
 
+                       if( count( $controls_array ) > 0 ){
+                               return $controls_array; 
+                       }
+                       else
+                       {
+                               return null;
+                       }
+               }
+               
+         public function 
get_controls_for_components_by_location($location_code, $from_date, $to_date, 
$repeat_type, $return_type = "return_object")
+         {
+                       $controls_array = array();
+                       
+                       $sql  = "SELECT distinct c.*, 
fm_responsibility_role.name AS responsibility_name FROM 
controller_control_component_list ccl "; 
+                       $sql .= "LEFT JOIN controller_control c on 
ccl.control_id=c.id ";
+                       $sql .= "LEFT JOIN fm_responsibility_role ON 
fm_responsibility_role.id = c.responsibility_id ";
+                       $sql .= "LEFT JOIN fm_bim_item ON fm_bim_item.id = 
ccl.component_id ";
+                       $sql .= "WHERE fm_bim_item.loc1 = '$location_code' ";
+                       
+                       if( is_numeric($repeat_type) )
+                               $sql .= "AND c.repeat_type = $repeat_type ";
+                       
+                       $sql .= "AND (c.start_date <= $from_date AND c.end_date 
IS NULL ";
+                       $sql .= "OR c.end_date > $from_date AND c.start_date < 
$to_date)";
+
+                       $this->db->query($sql);
+                       
                        while($this->db->next_record()) {
                                $control = new 
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
                                
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
@@ -212,7 +333,7 @@
                        while($this->db->next_record()) {
                                $control_id = 
$this->unmarshal($this->db->f('id', true), 'int');
                                $title = $this->unmarshal($this->db->f('title', 
true), 'string');
-                               $location_code = 
$this->unmarshal($this->db->f('location_code', true), 'strign');
+                               $location_code = 
$this->unmarshal($this->db->f('location_code', true), 'string');
 
                                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
 
@@ -227,7 +348,45 @@
                                return null;
                        }
                }
+               
+           function get_components_for_control($control_id)
+               {
+                       $controls_array = array();
 
+                       $sql =  "SELECT c.id, c.title, ccl.component_id, 
bim_type.description, bim.location_code ";
+            $sql .= "FROM controller_control c, 
controller_control_component_list ccl, fm_bim_item bim, fm_bim_type bim_type "; 
+                       $sql .= "WHERE ccl.control_id = $control_id ";
+            $sql .= "AND ccl.control_id = c.id ";
+                       $sql .= "AND bim.id = ccl.component_id ";
+                       $sql .= "AND bim_type.id = bim.type";
+
+                       $this->db->query($sql);
+
+                       while($this->db->next_record()) {
+                               $control_id = 
$this->unmarshal($this->db->f('id', true), 'int');
+                               $title = $this->unmarshal($this->db->f('title', 
true), 'string');
+                               $component_id = 
$this->unmarshal($this->db->f('component_id', true), 'int');
+                               $component_type = 
$this->unmarshal($this->db->f('description', true), 'string');
+                               $component_location_code = 
$this->unmarshal($this->db->f('location_code', true), 'string');
+                               //$component_guid = 
$this->unmarshal($this->db->f('guid', true), 'string');
+                               //$component_description = 
$this->getBimItemAttributeValue($component_guid, "beskrivelse");
+                               //$component_name = 
$this->getBimItemAttributeValue($component_guid, "betegnelse");
+                               //$component_author = 
$this->getBimItemAttributeValue($component_guid, "juridisk_person");
+                               
+                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$component_location_code));
+                               
+                               $controls_array[] = array("id" => $control_id, 
"title" => $title, "component_id" => $component_id, "component_description" => 
$component_type, "component_location" => $location_array["loc1_name"]);
+                       }
+
+                       if( count( $controls_array ) > 0 ){
+                               return $controls_array; 
+                       }
+                       else
+                       {
+                               return null;
+                       }
+               }
+
                function get_control_location($control_id, $location_code)
                {
                        $control_id = (int)$control_id;
@@ -523,8 +682,6 @@
                        
//$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
 true), 'string'));
                        $category = 
execMethod('phpgwapi.categories.return_single', 
$this->unmarshal($this->db->f('control_area_id', 'int')));
                        $control->set_control_area_name($category[0]['name']);
-                       
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
 true), 'int'));
-                       
$control->set_component_id($this->unmarshal($this->db->f('component_id', true), 
'int'));
                        
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
                        
$control->set_repeat_type_label($control->get_repeat_type());
                        
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
@@ -638,6 +795,7 @@
                {
                        $columnAlias = "attribute_values";
                        $sql = "select 
array_to_string(xpath('descendant-or-self::*[{$attribute}]/{$attribute}/text()',
 (select xml_representation from fm_bim_item where guid='{$bimItemGuid}')), 
',') as $columnAlias";
+                       //var_dump($sql);
                        $this->db->query($sql,__LINE__,__FILE__);
                        if($this->db->num_rows() > 0)
                        {

Modified: branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-06-13 12:59:02 UTC (rev 9579)
@@ -51,8 +51,8 @@
                                
                public $public_functions = array
                (
-                       'view_calendar_for_month'                       =>      
true,
-                       'view_calendar_for_year'                        =>      
true,
+                       'view_calendar_for_month'                             
=>        true,
+                       'view_calendar_for_year'                              
=>        true,
                        'view_calendar_year_for_locations'      =>  true,
                        'view_calendar_month_for_locations'     =>  true
                );
@@ -61,20 +61,20 @@
                {
                        parent::__construct();
                        
-                       $read    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_READ, 'controller');//1 
-                       $add     = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_ADD, 'controller');//2 
-                       $edit    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_EDIT, 'controller');//4 
-                       $delete  = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_DELETE, 'controller');//8 
+                       $read    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_READ, 'controller'); //1 
+                       $add     = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_ADD, 'controller'); //2 
+                       $edit    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_EDIT, 'controller'); //4 
+                       $delete  = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_DELETE, 'controller'); //8 
                        
-                       $manage  = $GLOBALS['phpgw']->acl->check('.control', 
16, 'controller');//16
+                       $manage  = $GLOBALS['phpgw']->acl->check('.control', 
16, 'controller'); //16
                        
-                       $this->so = CreateObject('controller.socheck_list');
-                       $this->so_control = 
CreateObject('controller.socontrol');
-                       $this->so_control_group = 
CreateObject('controller.socontrol_group');
-                       $this->so_control_group_list = 
CreateObject('controller.socontrol_group_list');
-                       $this->so_control_item = 
CreateObject('controller.socontrol_item');
-                       $this->so_check_list = 
CreateObject('controller.socheck_list');
-                       $this->so_check_item = 
CreateObject('controller.socheck_item');
+                       $this->so                                               
                                = CreateObject('controller.socheck_list');
+                       $this->so_control                                       
        = CreateObject('controller.socontrol');
+                       $this->so_control_group                         = 
CreateObject('controller.socontrol_group');
+                       $this->so_control_group_list    = 
CreateObject('controller.socontrol_group_list');
+                       $this->so_control_item                          = 
CreateObject('controller.socontrol_item');
+                       $this->so_check_list                                    
= CreateObject('controller.socheck_list');
+                       $this->so_check_item                                    
= CreateObject('controller.socheck_item');
                        
                        
self::set_active_menu('controller::location_check_list');
                }
@@ -85,49 +85,27 @@
                        $year = phpgw::get_var('year');
                        $month = phpgw::get_var('month');
                        
-                       $year = intval( $year );
-                       $from_month = intval( $month );
-                               
-                       $from_date_ts = 
month_calendar::get_start_month_date_ts($year, $month);
-                       $to_date_ts = 
month_calendar::get_end_month_date_ts($year, $month);
-                                                                               
                                        
-                       $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
-                               'type_id' => 1,
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
-                       );
-               
-                       $location_finder = new location_finder();
-                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
-
-                       if(empty($location_code)){
-                               $location_code = 
$my_locations[0]["location_code"];
-                       }
+                       // Validates year. If year is not set, current year is 
chosen
+                       $year = $this->validate_year($year);
                        
-                       $level = count(explode('-', $location_code));
+                       // Validates month. If year is not set, current month 
in current year is chosen
+                       $month = $this->validate_month($month);
                        
-                       // Property level
-                       if($level == 1){
-                               $property_location_code = $location_code;
-                       }
-                       // Building level
-                       else if($level > 1){
-                               $split_loc_code_array = explode('-', 
$location_code);
-                               $property_location_code = 
$split_loc_code_array[0];
-                       }
+                       // Gets timestamp value of first day in month
+                       $from_date_ts = 
month_calendar::get_start_month_date_ts($year, intval( $month ));
+
+                       // Gets timestamp value of first day in month
+                       $to_date_ts = 
month_calendar::get_end_month_date_ts($year, intval( $month ));
+
+                       // Validates location_code. If not set, first location 
among assigned locations
+                       $location_code = 
$this->validate_location_code($location_code);
                        
-                       if($manage){
-                               $criteria = array();
-                               $criteria['location_code'] = 
$property_location_code;
-                               $criteria['field_name'] = 'loc2_name';
-                               $criteria['child_level'] = '2';
-                               
-       $buildings_on_property = execMethod('property.solocation.get_children', 
$criteria);
-      }else{
-        $buildings_on_property = 
execMethod('property.solocation.get_children', $property_location_code);
-      }
+                       $level = $this->get_location_level($location_code);
+                                               
+      $user_role = true;
+
+      // Fetches buildings on property
+      $buildings_on_property = $this->get_buildings_on_property($user_role, 
$location_code, $level);
                        
                        // Fetches controls for location within specified time 
period
                        $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts);
@@ -149,14 +127,19 @@
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                
                        $property_array = 
execMethod('property.solocation.read', array('type_id' => 1, 'allrows' => 
true));
-                                               
+                       
+                       // Gets array of locations assigned to current user
+                       $my_locations = $this->get_my_assigned_locations();
+                       
+                       $heading_array = 
month_calendar::get_heading_array($year, $month);
+                       
                        $data = array
                        (               
                                'buildings_on_property'         => 
$buildings_on_property,
                                'my_locations'                          => 
$my_locations,
                                'property_array'                        => 
$property_array,
                                'current_location'                      => 
$location_array,
-                               'heading_array'                         => 
month_calendar::get_heading_array($year, $month),
+                               'heading_array'                         => 
$heading_array,
                                'controls_calendar_array' => 
$controls_calendar_array,
                                'date_format'                                   
=> $date_format,
                                'current_year'                                  
=> $year,
@@ -179,62 +162,34 @@
                        $location_code = phpgw::get_var('location_code');
                        $year = phpgw::get_var('year');
                        
-                       // Array that should conatain control and calendar 
objects that will be sent to view
-                       $controls_calendar_array = array();
+                       // Validates year. If year is not set, current year is 
chosen
+                       $year = $this->validate_year($year);
                        
-                       if(empty($year)){
-                               $year = date("Y");
-                       }
-                       
-                       $year = intval($year);
+                       // Gets timestamp of first day in year
+                       $from_date_ts = $this->get_start_date_year_ts($year);
 
-                       $from_date_ts = strtotime("01/01/$year");
-                       $to_year = $year + 1;
-                       $to_date_ts = strtotime("01/01/$to_year");
+                       // Gets timestamp of first day in next year
+                       $to_date_ts = $this->get_end_date_year_ts($year);
+
+                       // Array that will be populated with controls and 
calendar objects that will be sent to view
+                       $controls_calendar_array = array();
                                
-      $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
-                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
-                       );
-               
-                       $location_finder = new location_finder();
-                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
-            
-                       if(empty($location_code)){
-                               $location_code = 
$my_locations[0]["location_code"];
-                       }
+       // Validates location_code. If not set, first location among assigned 
locations
+                       $location_code = 
$this->validate_location_code($location_code);
                        
-                       $manage = true;
-       
-                       $level = count(explode('-', $location_code));
+                       $level = $this->get_location_level($location_code);
+                                               
+      $user_role = true;
+
+      // Fetches buildings on property
+      $buildings_on_property = $this->get_buildings_on_property($user_role, 
$location_code, $level);
                        
-                       // Property level
-                       if($level == 1){
-                               $property_location_code = $location_code;
-                       }
-                       // Building level
-                       else if($level > 1){
-                               $split_loc_code_array = explode('-', 
$location_code);
-                               $property_location_code = 
$split_loc_code_array[0];
-                       }
+                       // Fetches all controls for the location within time 
period
+                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type = null);
                        
-                       if($manage){
-                               $criteria = array();
-                               $criteria['location_code'] = 
$property_location_code;
-                               $criteria['field_name'] = 'loc2_name';
-                               $criteria['child_level'] = '2';
-                               
-       $buildings_on_property = execMethod('property.solocation.get_children', 
$criteria);
-      }else{
-        $buildings_on_property = 
execMethod('property.solocation.get_children', $property_location_code);
-      }
+                       // Fetches all controls for the components on location 
within time period
+                       $controls_for_component_array = 
$this->so_control->get_controls_by_component($location_code, $from_date_ts, 
$to_date_ts, $repeat_type = null);
                        
-                       // Fetches all controls for the location within time 
period
-                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts,  $repeat_type = null);
-                       
                        $controls_calendar_array = array();
                        
                        // Loops through controls with repeat type day or week 
in controls_for_location_array
@@ -246,7 +201,7 @@
                                        $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $location_code, $year);
                                        
                                        $year_calendar = new 
year_calendar($control, $year);
-                                       $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+                                       $calendar_array = 
$year_calendar->build_agg_month_calendar($agg_open_cases_pr_month_array);
                                                
                                        $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
                                }
@@ -278,12 +233,17 @@
                        
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
 
+                       // Gets array of locations assigned to current user
+                       $my_locations = $this->get_my_assigned_locations();
+                       
+                       $heading_array = year_calendar::get_heading_array();
+                       
                        $data = array
                        (
                                'buildings_on_property'         => 
$buildings_on_property,
                                'my_locations'                                  
        => $my_locations,
                                'current_location'              => 
$location_array,
-                               'heading_array'                         => 
year_calendar::get_heading_array(),
+                               'heading_array'                         => 
$heading_array,
                                'controls_calendar_array' => 
$controls_calendar_array,
                                'date_format'                                   
=> $date_format,
                                'current_year'                                  
=> $year,
@@ -309,15 +269,17 @@
                        if(is_numeric($control_id) & $control_id > 0)
                        {
                                $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
+                               $components_for_control_array = 
$this->so_control->get_components_for_control($control_id);
                        }
                        
-                       if(empty($year)){
-                               $year = intval( date("Y") );
-                       }
+                       // Validates year. If year is not set, current year is 
chosen
+                       $year = $this->validate_year($year);
                        
-                       $from_date_ts = strtotime("01/01/$year");
-                       $to_year = $year + 1;
-                       $to_date_ts = strtotime("01/01/$to_year");
+                       // Gets timestamp of first day in year
+                       $from_date_ts = $this->get_start_date_year_ts($year);
+
+                       // Gets timestamp of first day in next year
+                       $to_date_ts = $this->get_end_date_year_ts($year);
                        
                        $locations_with_calendar_array = array();
                        
@@ -329,9 +291,31 @@
                                        $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $curr_location_code, 
$year);
                                        
                                        $year_calendar = new 
year_calendar($control, $year);
-                                       $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+                                       $calendar_array = 
$year_calendar->build_agg_month_calendar($agg_open_cases_pr_month_array);
                                        $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
+                               
+                           foreach($components_for_control_array as 
$component){
+                                       $curr_component_id = 
$component['component_id'];
+                                       
+                                       // Loops through controls in 
controls_for_location_array and populates aggregate open cases pr month array.
+                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $curr_component_id, $year, 
true);
+                                       
+                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_array);
+                               }
+                               
+                           foreach($components_for_control_array as 
$component){
+                                       $curr_component_id = 
$component['component_id'];
+                                       
+                                       // Loops through controls in 
controls_for_location_array and populates aggregate open cases pr month array.
+                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $curr_component_id, $year, 
true);
+                                       
+                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
+                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_array);
+                               }
                        }else if($control->get_repeat_type() > 1){
                                foreach($locations_for_control_array as 
$location){
                                        $curr_location_code = 
$location['location_code'];
@@ -346,31 +330,40 @@
 
                                        $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
+                               
+                         foreach($components_for_control_array as $component){
+                                       $curr_component_id = 
$component['component_id'];
+                                       
+                                       $repeat_type = 
$control->get_repeat_type();
+                                       $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$curr_component_id, $from_date_ts, $to_date_ts, $repeat_type);  
+                                       
+                                       $check_lists_array = 
$component_with_check_lists["check_lists_array"];
+                                       
+                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $calendar_array = 
$year_calendar->build_calendar( $check_lists_array );
+
+                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_array);
+                               }
                        }
                        
-                       $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], //
-                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
-                       );
-               
-                       $location_finder = new location_finder();
-                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
+                       // Gets array of locations assigned to current user
+                       $my_locations = $this->get_my_assigned_locations();
                        
+                       $heading_array = year_calendar::get_heading_array();
+                       
                        $data = array
                        (
-                               'my_locations'                                  
                => $my_locations,
-                               'control'                                       
                                        => $control->toArray(),
-                               'heading_array'                                 
                => year_calendar::get_heading_array(),
-                               'locations_with_calendar_array' => 
$locations_with_calendar_array,
-                               'date_format'                                   
                        => $date_format,
-                               'current_year'                                  
        => $year,
+                               'my_locations'                                  
                        => $my_locations,
+                               'control'                                       
                                                => $control->toArray(),
+                               'heading_array'                                 
                        => $heading_array,
+                               'locations_with_calendar_array'         => 
$locations_with_calendar_array,
+                         'components_with_calendar_array'      => 
$components_with_calendar_array,
+                               'date_format'                                   
                                => $date_format,
+                               'current_year'                                  
                => $year,
                        );
                        
                        self::render_template_xsl( 
array('calendar/view_calendar_year_for_locations', 
'calendar/check_list_status_checker', 
-                                                                               
         'calendar/icon_color_map', 'calendar/select_my_locations'), $data);
+                                                                               
                                                                         
'calendar/icon_color_map', 'calendar/select_my_locations'), $data);
                        
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
@@ -386,18 +379,20 @@
                        if(is_numeric($control_id) & $control_id > 0)
                        {
                                $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
+                               $components_for_control_array = 
$this->so_control->get_components_for_control($control_id);
                        }
 
-                       if(empty($year)){
-                               $year = intval( date("Y") );
-                       }
+                       // Validates year. If year is not set, current year is 
chosen
+                       $year = $this->validate_year($year);
                        
-                       if(empty($month)){
-                               $month = date("n");
-                       }
+                       // Validates month. If year is not set, current month 
in current year is chosen
+                       $month = $this->validate_month($month);
                        
-                       $from_date_ts = 
month_calendar::get_start_month_date_ts($year, $month);
-                       $to_date_ts = 
month_calendar::get_end_month_date_ts($year, $month);
+                       // Gets timestamp value of first day in month
+                       $from_date_ts = 
month_calendar::get_start_month_date_ts($year, intval( $month ));
+
+                       // Gets timestamp value of first day in month
+                       $to_date_ts = 
month_calendar::get_end_month_date_ts($year, intval( $month ));
                        
                        $locations_with_calendar_array = array();
                        
@@ -415,28 +410,22 @@
                                $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                        }
                        
-                       $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
-                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
-                       );
-               
-                       $location_finder = new location_finder();
-                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
+                       // Gets array of locations assigned to current user
+                       $my_locations = $this->get_my_assigned_locations();
                        
+                       $heading_array = 
month_calendar::get_heading_array($year, $month);
+                       
                        $data = array
                        (               
-                               'control'                                       
        => $control->toArray(),
-                               'my_locations'                                  
=> $my_locations,
-                               'property_array'                                
=> $property_array,
-                               'location_array'                                
=> $location_array,
-                               'heading_array'                                 
=> month_calendar::get_heading_array($year, $month),
+                               'control'                                       
                                        => $control->toArray(),
+                               'my_locations'                                  
                => $my_locations,
+                               'property_array'                                
                => $property_array,
+                               'location_array'                                
                        => $location_array,
+                               'heading_array'                                 
                => $heading_array,
                                'locations_with_calendar_array' => 
$locations_with_calendar_array,
-                               'date_format'                                   
=> $date_format,
-                               'current_month_nr'                              
=> $month,
-                               'current_year'                                  
=> $year,
+                               'date_format'                                   
                        => $date_format,
+                               'current_month_nr'                              
                => $month,
+                               'current_year'                                  
                => $year,
                        );
                        
                        self::render_template_xsl( 
array('calendar/view_calendar_month_for_locations', 
'calendar/check_list_status_checker', 
@@ -462,7 +451,7 @@
                }
                
                // Generates array of aggregated number of open cases for each 
month in time period 
-               function build_agg_open_cases_pr_month_array($control, 
$location_code, $year){
+               function build_agg_open_cases_pr_month_array($control, 
$location_code, $year, $component=false ){
                                
                        // Checks if control starts in the year that is 
displayed 
                        if( date("Y", $control->get_start_date()) == $year ){
@@ -496,7 +485,7 @@
                                $num_open_cases_for_control_array = array();
                                
                                // Fetches aggregate value for open cases in a 
month from db    
-                               $num_open_cases_for_control_array = 
$this->so_check_list->get_num_open_cases_for_control( $control->get_id(), 
$location_code, $month_start_ts, $month_end_ts ); 
+                               $num_open_cases_for_control_array = 
$this->so_check_list->get_num_open_cases_for_control( $control->get_id(), 
$location_code, $month_start_ts, $month_end_ts, $component );     
                                
                                // If there is a aggregated value for the 
month, add aggregated status object to agg_open_cases_pr_month_array
                                if( !empty($num_open_cases_for_control_array) ){
@@ -510,6 +499,106 @@
                        return $agg_open_cases_pr_month_array;
                }
                
+               function get_buildings_on_property($user_role, $location_code, 
$level){
+                                       
+                       // Property level
+                       if($level == 1){
+                               $property_location_code = $location_code;
+                       }
+                       // Building level
+                       else if($level > 1){
+                               $split_loc_code_array = explode('-', 
$location_code);
+                               $property_location_code = 
$split_loc_code_array[0];
+                       }       
+               
+                 if($user_role){
+                               $criteria = array();
+                               $criteria['location_code'] = 
$property_location_code;
+                               $criteria['field_name'] = 'loc2_name';
+                               $criteria['child_level'] = '2';
+                               
+       $buildings_on_property = execMethod('property.solocation.get_children', 
$criteria);
+      }else{
+        $buildings_on_property = 
execMethod('property.solocation.get_children', $property_location_code);
+      }
+                       
+      return $buildings_on_property;
+               }
+               
+               function get_location_level($location_code){
+                       $level = count(explode('-', $location_code));
 
+                       return $level;
+               }       
+               
+               function validate_location_code($location_code){
+                       $criteria = array
+                       (
+                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
+                               'type_id' => 1,
+                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows' => false
+                       );
+               
+                       $location_finder = new location_finder();
+                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
+
+                       if(empty($location_code)){
+                               $location_code = 
$my_locations[0]["location_code"];
+                       }
+                       
+                       return $location_code;
+               }
+               
+               function get_my_assigned_locations($location_code){
+                       $criteria = array
+                       (
+                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
+                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
+                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows' => false
+                       );
+               
+                       $location_finder = new location_finder();
+                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
+                       
+                       return $my_locations;
+               }
+               
+               function get_start_date_year_ts($year){
+                       $start_date_year_ts = strtotime("01/01/$year");
+                       
+                       return $start_date_year_ts;
+               }
+               
+               function get_end_date_year_ts($year){
+                       $to_year = $year + 1;
+                       $end_date_year_ts = strtotime("01/01/$to_year");
+                       
+                       return $end_date_year_ts;
+               }
+               
+               function validate_year($validate_year){
+                       
+                       if( empty( $validate_year ) ){
+                               $validate_year = date("Y");
+                       }
+                       
+                       $validate_year = intval($validate_year);
+                       
+                       return $validate_year;
+               }
+               
+               function validate_month($month){
+                       
+                       if( empty( $month ) ){
+                               $month = date("n");
+                       }
+                       
+                       $month = intval($month);
+                       
+                       return $month;
+               }
+
                public function query(){}
        }
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php       
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php       
2012-06-13 12:59:02 UTC (rev 9579)
@@ -320,12 +320,6 @@
                        
self::render_template_xsl(array('check_list/check_list_tab_menu','check_list/edit_check_list'),
 $data);
                }
                
-               /**
-                * Public function for displaying the edit check list form
-                * 
-                * @param HTTP:: check list id
-                * @return data array
-               */
                function view_cases_for_check_list(){
                        $check_list_id = phpgw::get_var('check_list_id');
                        
@@ -339,8 +333,8 @@
                        
                        $data = array
                        (
-                               'control'                       => 
$control->toArray(),
-                               'check_list'            => 
$check_list->toArray(),
+                               'control'                               => 
$control->toArray(),
+                               'check_list'                    => 
$check_list->toArray(),
                                'location_array'        => $location_array,
                                'date_format'           => $date_format
                        );
@@ -355,14 +349,6 @@
                        
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'check_list/view_cases_for_check_list'), $data);
                }
                
-       
-               
-               /**
-                * Public function for displaying the create message form
-                * 
-                * @param HTTP:: check list id 
-                * @return data array
-               */
                function create_case_message(){
                        $check_list_id = phpgw::get_var('check_list_id');
                                                
@@ -379,10 +365,10 @@
                        
                        $data = array
                        (
-                               'location_array'                => 
$location_array,
-                               'control_array'                 => 
$control->toArray(),
+                               'location_array'        => $location_array,
+                               'control_array'         => $control->toArray(),
                                'check_list'                    => 
$check_list_with_check_items,
-                               'date_format'                   => $date_format
+                               'date_format'           => $date_format
                        );
                        
                        self::add_javascript('controller', 'controller', 
'jquery.js');
@@ -395,59 +381,6 @@
                        self::render_template_xsl('create_case_messsage', 
$data);
                }
                
-               /**
-                * Public function for displaying the create message form
-                * 
-                * @param HTTP:: check list id 
-                * @return data array
-               */
-               public function view_control_info(){
-                       $check_list_id = phpgw::get_var('check_list_id');
-                       
-                       $check_list = $this->so->get_single($check_list_id);
-                       $control = 
$this->so_control->get_single($check_list->get_control_id());
-                       
-                       $cats = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
-                       
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => 
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
-                       array_unshift($control_areas['cat_list'],array 
('cat_id'=>'','name'=> lang('select value')));
-                       $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'],
-                               );              
-                       }
-
-                       // Fetches prosedures that are related to first control 
area in list
-                       $control_area_id = $control_areas_array2[1]['id'];
-                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area($control_area_id);
-                       $role_array = $this->so_control->get_roles();
-                       
-                       $location_code = $check_list->get_location_code();  
-                       $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-                       
-                       $data = array
-                       (
-                               'location_array'                => 
$location_array,
-                               'control'                               => 
$control->toArray(),
-                               'check_list'                    => 
$check_list->toArray(),
-                               'date_format'                   => $date_format,
-                               'control_areas_array2'  => array('options' => 
$control_areas_array2),
-                               'procedures_array'              => 
$procedures_array,
-                               'role_array'                    => $role_array
-                       );
-
-                       self::add_javascript('controller', 'controller', 
'jquery.js');
-                       self::add_javascript('controller', 'controller', 
'jquery-ui.custom.min.js');
-                       
-                       
self::render_template_xsl(array('check_list/check_list_tab_menu','check_list/view_control_info'),
 $data);
-               }
-               
                // Saves a check list that already exists. Returns status for 
update as a JSON array with values update/not updated  
                public function update_check_list(){
                        $check_list_id = phpgw::get_var('check_list_id');
@@ -512,42 +445,42 @@
                        
self::render_template_xsl('check_list/print_check_list', $data);
                }
                
+               public function view_control_info(){
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       
+                       $check_list = $this->so->get_single($check_list_id);
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
+                       
+                       $location_code = $check_list->get_location_code();  
+                       $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+                       
+                       $data = array
+                       (
+                               'location_array'                                
=> $location_array,
+                               'control'                                       
                        => $control->toArray(),
+                               'check_list'                                    
        => $check_list->toArray(),
+                       );
+
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('controller', 'controller', 
'jquery-ui.custom.min.js');
+                       
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu','check_list/view_control_info'),
 $data);
+               }
+               
                function view_control_details(){
                        $control_id = phpgw::get_var('control_id');
                        
                        $control = $this->so_control->get_single($control_id);
                        
-                       // 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' => 
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
-                       array_unshift($control_areas['cat_list'],array 
('cat_id'=>'','name'=> lang('select value')));
-                       $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
-                       $control_area_id = $control_areas_array2[1]['id'];
-                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area($control_area_id);
-                       $role_array = $this->so_control->get_roles();
-                       
                        $data = array
                        (
-                               'control'       => $control->toArray(),
-                               'procedures_array'                      => 
$procedures_array,
-                               'role_array'                            => 
$role_array
+                               'control'                                       
        => $control->toArray(),
                        );
                        
                        
self::render_template_xsl('check_list/view_control_details', $data);
                }
                                                
-               // Function that displays control groups and control items for 
a check list
+               // Displays control groups and control items for a check list
                function register_case(){
                        $check_list_id = phpgw::get_var('check_list_id');
                        
@@ -704,6 +637,7 @@
                        return json_encode( $check_list );
                }
                
+               // Returns open cases for a check list as JSON 
                public function get_cases_for_check_list()
                {
                        $check_list_id = phpgw::get_var('check_list_id');

Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2012-06-13 12:59:02 UTC (rev 9579)
@@ -60,29 +60,29 @@
 
     public $public_functions = array
     (
-                       'index'                                                 
                                                                =>      true,
-                       'control_list'                                          
                                        =>      true,
-                       'view'                                                  
                                                                =>      true,
-                       'view_control_details'                                  
                =>      true,
-                       'save_control_details'                                  
                =>      true,
-                       'view_control_groups'                                   
                        =>      true,
-                       'save_control_groups'                                   
                        =>      true,
-                       'view_control_items'                                    
                        =>      true,
-                       'save_control_items'                                    
                        =>      true,
-                       'view_check_list'                                       
                                        =>      true,
-                       'get_controls_by_control_area'          =>      true,
+                       'index'                                                 
                                                =>      true,
+                       'control_list'                                          
                        =>      true,
+                       'view'                                                  
                                                =>      true,
+                       'view_control_details'                                  
=>      true,
+                       'save_control_details'                                  
=>      true,
+                       'view_control_groups'                                   
        =>      true,
+                       'save_control_groups'                                   
        =>      true,
+                       'view_control_items'                                    
        =>      true,
+                       'save_control_items'                                    
        =>      true,
+                       'view_check_list'                                       
                        =>      true,
+                       'get_controls_by_control_area'  =>      true,
                );
 
                public function __construct()
                {
                        parent::__construct();
 
-                       $read        = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
-                       $add         = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
-                       $edit         = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
-                       $delete     = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_DELETE, 'controller');//8 
+                       $read    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_READ, 'controller');//1 
+                       $add     = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_ADD, 'controller');//2 
+                       $edit    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_EDIT, 'controller');//4 
+                       $delete  = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_DELETE, 'controller');//8 
                        
-                       $manage     = $GLOBALS['phpgw']->acl->check('.control', 
16, 'controller');//16
+                       $manage  = $GLOBALS['phpgw']->acl->check('.control', 
16, 'controller');//16
 
                        //if(!$manage)
                        
@@ -256,7 +256,6 @@
                        
                        $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
                        $control_areas_array = $control_areas['cat_list'];
-                       
                        // END as categories
                
                        if($control != 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-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php 
2012-06-13 12:59:02 UTC (rev 9579)
@@ -563,6 +563,7 @@
 
                function register_control_to_component()
                {
+                   
self::set_active_menu('controller::control::component_for_check_list');
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
                        $receipt = array();
 
@@ -634,7 +635,7 @@
 
                        $tabs = array
                        ( 
-                               array
+/*                             array
                                (
                                        'label' => 
lang('View_locations_for_control'),
                                        'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
@@ -643,7 +644,7 @@
                                (
                                        'label' => 
lang('Add_locations_for_control'),
                                        'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
-                               ),
+                               ),*/
                                array
                                (
                                        'label' => lang('add components for 
control')

Modified: 
branches/Version-1_0-branch/controller/inc/component/class.year_calendar.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/component/class.year_calendar.inc.php
    2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/controller/inc/component/class.year_calendar.inc.php
    2012-06-13 12:59:02 UTC (rev 9579)
@@ -6,46 +6,43 @@
        
 
 class year_calendar {
-       
-       private $period_start_date_ts;
-    private $period_end_date_ts;
+  private $period_start_date_ts;
+  private $period_end_date_ts;
        private $year;
        private $control;
        private $calendar_array = array();
        
-       public function __construct($control, $year){
-        $this->year = $year;
-        $this->control = $control;
+  public function __construct($control, $year){
+    $this->year = $year;
+    $this->control = $control;
         
-        $this->period_start_date_ts = strtotime("01/01/$year");
-               $to_year = $year + 1;
-               $this->period_end_date_ts = strtotime("01/01/$to_year");
+    $this->period_start_date_ts = strtotime("01/01/$year");
+    $to_year = $year + 1;
+    $this->period_end_date_ts = strtotime("01/01/$to_year");
         
-        $this->init_calendar();
-       }
+    $this->init_calendar();
+  }
                
        function init_calendar(){
-
-               for($i = 1;$i <= 12;$i++){
-                       $this->calendar_array[$i] = null;
-               }
+    for($i = 1;$i <= 12;$i++){
+                 $this->calendar_array[$i] = null;
+    }
                
-               $date_generator = new 
date_generator($this->control->get_start_date(), 
$this->control->get_end_date(), $this->period_start_date_ts, 
$this->period_end_date_ts, $this->control->get_repeat_type(), 
$this->control->get_repeat_interval());
-               $dates_array = $date_generator->get_dates();
+    $date_generator = new date_generator($this->control->get_start_date(), 
$this->control->get_end_date(), $this->period_start_date_ts, 
$this->period_end_date_ts, $this->control->get_repeat_type(), 
$this->control->get_repeat_interval());
+    $dates_array = $date_generator->get_dates();
                
-               // Inserts dates 
-               foreach($dates_array as $date){
+    // Inserts dates 
+    foreach($dates_array as $date){
+      $todays_date = mktime(0,0,0,date("m"), date("d"), date("Y"));
                        
-                       $todays_date = mktime(0,0,0,date("m"), date("d"), 
date("Y"));
+      if($date < $todays_date){
+        $status = "CONTROL_NOT_DONE";
+      }else{
+        $status = "CONTROL_REGISTERED";
+      }
                        
-                       if($date < $todays_date){
-                               $status = "CONTROL_NOT_DONE";
-                       }else{
-                               $status = "CONTROL_REGISTERED";
-                       }
-                       
-                       $this->calendar_array[ date("n", $date) ]["status"]  = 
$status;
-                       $this->calendar_array[ date("n", $date) ]["info"]  = 
array("date" => $date, "control_id" => $this->control->get_id());
+      $this->calendar_array[ date("n", $date) ]["status"]  = $status;
+      $this->calendar_array[ date("n", $date) ]["info"]  = array("date" => 
$date, "control_id" => $this->control->get_id());
                }
        }
        
@@ -63,7 +60,7 @@
                return $this->calendar_array;
        }
        
-       public function build_agg_calendar( $agg_open_cases_pr_month_array ){
+       public function build_agg_month_calendar( 
$agg_open_cases_pr_month_array ){
                
                foreach($agg_open_cases_pr_month_array as 
$status_agg_month_info)
                {

Modified: branches/Version-1_0-branch/controller/inc/hook_home.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/hook_home.inc.php        
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/inc/hook_home.inc.php        
2012-06-13 12:59:02 UTC (rev 9579)
@@ -67,14 +67,22 @@
 
        $location_finder = new location_finder();
        $my_locations = $location_finder->get_responsibilities( $criteria );
-       
+       $unique_locations = array();
+       foreach($my_locations as $loc)
+       {
+           if(!in_array($loc["location_code"],$unique_locations))
+           {
+               $unique_locations[] = $loc["location_code"];
+           }
+       }
+
        $repeat_type = null;
        $controls_for_location_array = array();
-       foreach($my_locations as $location)
+       foreach($unique_locations as $location)
        {
-               $controls_for_location_array[] = 
array($location["location_code"], 
$so_control->get_controls_by_location($location["location_code"], 
$from_date_ts, $to_date_ts, $repeat_type ));
+           $controls_for_location_array[] = array($location, 
$so_control->get_controls_for_location($location, $from_date_ts, $to_date_ts, 
$repeat_type ));
        }
-       
+
        $controls_array = array();
        $control_dates = array();
        foreach($controls_for_location_array as $control_arr){
@@ -86,7 +94,7 @@
                        $controls_array[] = array($current_location, $control, 
$date_generator->get_dates());
                }
        }
-       
+
        $portalbox1 = CreateObject('phpgwapi.listbox', array
        (
                'title'         => "Mine planlagte kontroller",
@@ -130,7 +138,6 @@
                $curr_location = $control_instance[0];
                $current_control = $control_instance[1];
                $check_lists = 
$so->get_planned_check_lists_for_control($current_control->get_id(), 
$curr_location);
-               //_debug_array($check_lists);
                $location_array = execMethod('property.bolocation.read_single', 
array('location_code' => $curr_location));
                $location_name = $location_array["loc1_name"];
                foreach($control_areas['cat_list'] as $area)
@@ -203,7 +210,8 @@
        {
                $curr_location = $control_instance[0];
                $current_control = $control_instance[1];
-               $check_lists = 
$so->get_planned_check_lists_for_control($current_control->get_id(), 
$curr_location);
+               unset($check_lists);
+               $check_lists = 
$so->get_unplanned_check_lists_for_control($current_control->get_id(), 
$curr_location);
                //$control_location = 
$so_control->getLocationCodeFromControl($current_control->get_id());
                $location_array = execMethod('property.bolocation.read_single', 
array('location_code' => $curr_location));
                $location_name = $location_array["loc1_name"];
@@ -214,11 +222,7 @@
                                $control_area_name = $area['name'];
                        }
                }
-               $planned_lists = array();
-               foreach($check_lists as $check_list)
-               {
-                       $planned_lists = $check_list->get_deadline();
-               }
+
                $current_dates = $control_instance[2];
                
                foreach($current_dates as $current_date)
@@ -227,7 +231,7 @@
                        {
                                foreach($check_lists as $check_list)
                                {
-                                       if($current_date != 
$check_list->get_deadline())
+                                       if(intval($current_date) > 
intval($check_list->get_deadline()) && intval($current_date) != 
intval($check_list->get_deadline()))
                                        {
                                                $next_date = "Fristdato: " . 
date('d/m/Y', $current_date);
                                                $portalbox2_data[] = array
@@ -237,6 +241,16 @@
                                                        'link' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'date' => $current_date, 'control_id' 
=> $current_control->get_id(), 'location_code' => $curr_location))
                                                ));
                                        }
+                                       else
+                                       {
+                                               $next_date = "Fristdato: " . 
date('d/m/Y', $check_list->get_deadline());
+                                               $portalbox2_data[] = array
+                                               ($current_date, array
+                                               (
+                                                       'text' => 
"{$location_name} - {$control_area_name} - {$current_control->get_title()} :: 
{$next_date}",
+                                                       'link' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => 
$check_list->get_id()))
+                                               ));                             
            
+                                       }
                                }
                        }
                        else
@@ -254,6 +268,7 @@
        //sort data by due date for check list
        sort($portalbox2_data);
        //$limit = 20;
+       //$limit_no_of_assigned = 50;
        $tmp = 0;
        foreach($portalbox2_data as $check_list_dates)
        {

Modified: branches/Version-1_0-branch/controller/js/controller/ajax.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-06-13 12:59:02 UTC (rev 9579)
@@ -563,7 +563,7 @@
                                                          
                                                  // Changes text on save 
button back to original
                                                  window.setTimeout(function() {
-                                                               
$(submitBnt).val('Lagre sjekkpunkt');
+                                                               
$(submitBnt).val('Lagre detaljer');
                                                                
$(submitBnt).addClass("not_active");
                                                  }, 1000);
                                                  }

Modified: branches/Version-1_0-branch/controller/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2012-06-13 
12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2012-06-13 
12:59:02 UTC (rev 9579)
@@ -343,4 +343,8 @@
 repeat_type_day        controller      no      Dag
 repeat_type_week       controller      no      Uke
 repeat_type_month      controller      no      Måned
-repeat_type_year       controller      no      År
\ No newline at end of file
+repeat_type_year       controller      no      År
+components for control controller      no      Komponenter tilknyttet kontroll
+add components for control     controller      no      Legg til knytning 
mellom kontroll og komponent(er)
+location category      controller      no      Lokaliseringskategori
+select delete  controller      no      slett
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-06-13 12:59:02 UTC (rev 9579)
@@ -149,10 +149,10 @@
                ),
                'controller_control_component_list' => array(
                                'fd' => array(
-                                       'id' => array('type' => 'auto', 
'nullable' => false),
-                                       'control_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
-                                       'location_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
-                                       'component_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
+                                       'id'                                    
        => array('type' => 'auto', 'nullable' => false),
+                                       'control_id'            => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
+                                       'location_id'   => array('type' => 
'int', 'precision' => '4', 'nullable' => false),
+                                       'component_id'  => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
                                ),
                        'pk' => array('id'),
                        'fk' => array(),
@@ -161,9 +161,9 @@
                ),
                '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)
+                                       '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(),
@@ -172,7 +172,7 @@
                ),
                'controller_document_types' => array(
                        'fd' => array(
-                               'id' => array('type' => 'auto', 'nullable' => 
false),
+                               'id'            => array('type' => 'auto', 
'nullable' => false),
                                'title' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false)
                        ),
                        'pk' => array('id'),
@@ -184,7 +184,7 @@
                        'fd' => array(
                                'id'            => array('type' => 'auto', 
'nullable' => false),
                                'name'          => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false),
-                               'procedure_id'   => array('type' => 'int', 
'precision' => '4', 'nullable' => true),
+                               'procedure_id'  => array('type' => 'int', 
'precision' => '4', 'nullable' => true),
                                'title'         => array('type' => 'varchar', 
'precision' => '255', 'nullable' => true),
                                'description'   => array('type' => 'text', 
'nullable' => true),
                                'type_id'       => array('type' => 'int', 
'precision' => '4', 'nullable' => false)
@@ -199,17 +199,17 @@
                ),
                'controller_check_item_case' => array(
                        'fd' => array(
-                               'id'                    => array('type' => 
'auto', 'nullable' => false),
-                               'check_item_id'         => array('type' => 
'int', 'precision' => '4', 'nullable' => false),
-                               'status'                        => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
-                               'measurement'       => array('type' => 
'varchar', 'precision' => '50', 'nullable' => True),
-                               'location_id'           => array('type' => 
'int', 'precision' => '4', 'nullable' => true), // representer 
meldingsfregisteret
+                               'id'                            => array('type' 
=> 'auto', 'nullable' => false),
+                               'check_item_id'                 => array('type' 
=> 'int', 'precision' => '4', 'nullable' => false),
+                               'status'                                        
        => array('type' => 'int', 'precision' => '4', 'nullable' => false),
+                               'measurement'           => array('type' => 
'varchar', 'precision' => '50', 'nullable' => True),
+                               'location_id'                   => array('type' 
=> 'int', 'precision' => '4', 'nullable' => true), // representer 
meldingsfregisteret
         'location_item_id'     => array('type' => 'int', 'precision' => '8', 
'nullable' => true), //meldings id
-        'descr'                        => array('type' => 'text','nullable' => 
true),
-        'user_id'                      => array('type' => 'int','precision' => 
'4','nullable' => true),
-        'entry_date'           => array('type' => 'int', 'precision' => 
8,'nullable' => false),
-        'modified_date'                => array('type' => 'int', 'precision' 
=> 8,'nullable' => True),
-        'modified_by'          => array('type' => 'int', 'precision' => 
4,'nullable' => True),
+        'descr'                                                => array('type' 
=> 'text','nullable' => true),
+        'user_id'                                      => array('type' => 
'int','precision' => '4','nullable' => true),
+        'entry_date'                           => array('type' => 'int', 
'precision' => 8,'nullable' => false),
+        'modified_date'                        => array('type' => 'int', 
'precision' => 8,'nullable' => True),
+        'modified_by'                  => array('type' => 'int', 'precision' 
=> 4,'nullable' => True),
       ),
       'pk' => array('id'),
       'fk' => array('controller_check_item' => array('check_item_id' => 'id')),

Modified: 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
 2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
 2012-06-13 12:59:02 UTC (rev 9579)
@@ -83,6 +83,70 @@
                </xsl:choose>
        </table>
        </div>
+               <div id="cal_wrp">
+                       <table id="calendar" class="year">
+                               <tr>
+                                       <th>
+                                               <span 
class="location_code">Lokasjon</span>
+                                       </th>
+                                       <th>
+                                               <span 
class="location_name">Komponenttype</span>
+                                       </th>
+                                       <xsl:for-each select="heading_array">
+                                               <th>
+                                                       <a>
+                                                               <xsl:attribute 
name="href">
+                                                                       
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_month_for_locations</xsl:text>
+                                                                       
<xsl:text>&amp;year=</xsl:text>
+                                                                       
<xsl:value-of select="current_year"/>
+                                                                       
<xsl:text>&amp;month=</xsl:text>
+                                                                       
<xsl:number/>
+                                                                       
<xsl:text>&amp;control_id=</xsl:text>
+                                                                       
<xsl:value-of select="//control/id"/>
+                                                               </xsl:attribute>
+                                                               
+                                                               <xsl:variable 
name="month_str">short_month <xsl:value-of select="."/> 
capitalized</xsl:variable>
+                                                               <xsl:value-of 
select="php:function('lang', $month_str)" />
+                                                       </a>                    
        
+                                               </th>
+                                       </xsl:for-each>
+                               </tr>
+                       
+                       <xsl:choose>
+                               <xsl:when 
test="components_with_calendar_array/child::node()">
+                               
+                               <xsl:for-each 
select="components_with_calendar_array">
+                                       <tr>                            
+                                               <xsl:choose>
+                                               <xsl:when test="(position() mod 
2) != 1">
+                                                   <xsl:attribute 
name="class">odd</xsl:attribute>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                   <xsl:attribute 
name="class">even</xsl:attribute>
+                                               </xsl:otherwise>
+                                           </xsl:choose>
+                                   
+                                               <td>
+                                                       <xsl:value-of 
select="component/component_location"/>
+                                               </td>
+                                               <td class="location_name">
+                                                       <xsl:value-of 
select="component/component_description"/>
+                                               </td>
+                                                       
+                                               <xsl:for-each 
select="calendar_array">
+                                                       <xsl:call-template 
name="check_list_status_checker" >
+                                                               <xsl:with-param 
name="location_code"><xsl:value-of select="//location"/></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:for-each>
+                                       </tr>   
+                               </xsl:for-each> 
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <tr class="cal_info_msg"><td colspan="3">Ingen 
sjekklister for komponent i angitt periode</td></tr>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </table>
+       </div>
 </div>
 </div>
 </xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
      2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
      2012-06-13 12:59:02 UTC (rev 9579)
@@ -50,7 +50,7 @@
                                  url: requestUrl,
                                  success: function(data) {
                                        $("#load_view_content").html(data);
-                                 }
+                                 },
                                  error: function(XMLHttpRequest, textStatus, 
errorThrown) {
                        if (XMLHttpRequest.status === 401) {
                        location.href = '/';

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_details.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_details.xsl
   2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_details.xsl
   2012-06-13 12:59:02 UTC (rev 9579)
@@ -8,11 +8,26 @@
        <fieldset id="control_details">
                <div class="row">
                        <label>Kontrollområde</label>
+                       
                        <xsl:choose>
                        <xsl:when test="editable">
                                <select id="control_area_id" 
name="control_area_id">
-                                       <xsl:apply-templates 
select="control_areas_array2/options"/>
-                               </select>
+                                               <option value="">Velg 
kontrollområde</option>
+                                                       <xsl:for-each 
select="control_areas_array">
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="cat_id = $control_area_id">
+                                                                               
<option value="{cat_id}" selected="selected">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:when>
+                                                                       
<xsl:otherwise>
+                                                                               
<option value="{cat_id}">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:otherwise>
+                                                               </xsl:choose>   
                                                        
+                                                       </xsl:for-each>
+                                               </select>
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:value-of 
select="control/control_area_name" />
@@ -89,7 +104,7 @@
                                        </select>
                                </xsl:when>
                                <xsl:otherwise>
-                                       <xsl:value-of 
select="control/role_name" />
+                                       <xsl:value-of 
select="control/responsibility_name" />
                                </xsl:otherwise>
                        </xsl:choose>
                </div>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
      2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
      2012-06-13 12:59:02 UTC (rev 9579)
@@ -5,6 +5,7 @@
 <div id="main_content" class="medium">
                
        <script>
+         
                $(document).ready(function() {
                        var requestUrl = 
$("#view_control_details").attr("href");
                        load_tab(requestUrl);

Modified: branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2012-06-13 12:59:02 UTC (rev 9579)
@@ -2331,6 +2331,11 @@
                                                $querymethod = " $where 
spbudact_code = '{$query}'";
                                                break;
 
+                                       case 'dimb':
+                                               $query = (int) $data['query'];
+                                               $querymethod = " $where dimb = 
{$query}";
+                                               break;
+
                                        default:
                                }
                                

Modified: branches/Version-1_0-branch/property/inc/class.solocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2012-06-13 12:59:02 UTC (rev 9579)
@@ -86,13 +86,26 @@
                                                        'entity_id'     => 
$this->db->f('entity_id'),
                                                        'cat_id'        => 
$this->db->f('id'),
                                                        'name'          => 
$this->db->f('name'),
-                                                       'descr'         => 
$this->db->f('descr')
+                                                       'descr'         => 
$this->db->f('descr'),
+                                                       'is_eav'        => 
$this->db->f('is_eav')
                                                );
                                }
 
                                foreach($category as $entry)
                                {
-                                       $sql = "SELECT count(*) as hits FROM 
fm_{$type}_{$entry['entity_id']}_{$entry['cat_id']} WHERE location_code 
$this->like '$location_code%'";
+                                       if($entry['is_eav'])
+                                       {
+                                               $location_id = 
$GLOBALS['phpgw']->locations->get_id($app, 
".{$type}.{$entry['entity_id']}.{$entry['cat_id']}"); 
+                                               $this->db->query("SELECT id as 
bim_type FROM fm_bim_type WHERE location_id = 
{$location_id}",__LINE__,__FILE__);
+                                               $this->db->next_record();
+                                               $bim_type = 
(int)$this->db->f('bim_type');
+                                               $sql = "SELECT count(*) as hits 
FROM fm_bim_item WHERE location_code {$this->like} '$location_code%' AND type = 
{$bim_type}";                                   
+                                       }
+                                       else
+                                       {
+                                               $sql = "SELECT count(*) as hits 
FROM fm_{$type}_{$entry['entity_id']}_{$entry['cat_id']} WHERE location_code 
{$this->like} '$location_code%'";
+                                       }
+
                                        
$this->db->query($sql,__LINE__,__FILE__);
                                        $this->db->next_record();
                                        if($this->db->f('hits'))
@@ -1203,18 +1216,19 @@
 //                     _debug_array($sql);
                        $cols_return    = $this->cols_return;
 
-                       $this->db->next_record();
-
-                       foreach ($cols_return as $col)
+                       if($this->db->next_record())
                        {
-                               $values[$col] = $this->db->f($col,true);
-                       }
+                               foreach ($cols_return as $col)
+                               {
+                                       $values[$col] = $this->db->f($col,true);
+                               }
 
-                       if ( isset($values['attributes']) && 
is_array($values['attributes']) )
-                       {
-                               foreach ( $values['attributes'] as &$attr )
+                               if ( isset($values['attributes']) && 
is_array($values['attributes']) )
                                {
-                                       $attr['value']  = 
$this->db->f($attr['column_name']);
+                                       foreach ( $values['attributes'] as 
&$attr )
+                                       {
+                                               $attr['value']  = 
$this->db->f($attr['column_name']);
+                                       }
                                }
                        }
 

Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2012-06-13 12:59:02 UTC (rev 9579)
@@ -808,6 +808,7 @@
                                                'ecodimb'                       
        => $this->db->f('ecodimb'),
                                                'b_account_id'                  
=> $this->db->f('account_group'),
                                                'contact_id'                    
=> $this->db->f('contact_id'),
+                                               'inherit_location'              
=>  $this->db->f('inherit_location')
                                        );
 
                                if ( isset($values['attributes']) && 
is_array($values['attributes']) )
@@ -993,13 +994,14 @@
                                        $this->account,
                                        $project['ecodimb'],
                                        $project['b_account_id'],
-                                       $project['contact_id']
+                                       $project['contact_id'],
+                                       $project['inherit_location']
                                );
 
                        $values = $this->bocommon->validate_db_insert($values);
 
                        $this->db->query("INSERT INTO fm_project 
(id,project_group,name,access,category,entry_date,start_date,end_date,coordinator,status,"
-                               . 
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id,ecodimb,account_group,contact_id
 $cols) "
+                               . 
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id,ecodimb,account_group,contact_id,inherit_location
 $cols) "
                                . "VALUES ($values $vals )",__LINE__,__FILE__);
 
                        if($project['budget'])
@@ -1166,7 +1168,8 @@
                                'address'                       => $address,
                                'ecodimb'                       => 
$project['ecodimb'],
                                'account_group'         => 
$project['b_account_id'],
-                               'contact_id'            => 
$project['contact_id']
+                               'contact_id'            => 
$project['contact_id'],
+                               'inherit_location'      => 
$project['inherit_location']
                        );
 
                        $data_attribute = 
$this->custom->prepare_for_db('fm_project', $values_attribute, $project['id']);

Modified: branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php   
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php   
2012-06-13 12:59:02 UTC (rev 9579)
@@ -379,6 +379,11 @@
                                        'id'    => 'b_account',
                                        'name'  => lang('budget account'),
                                ),
+                               array
+                               (
+                                       'id'    => 'dimb',
+                                       'name'  => lang('dimb'),
+                               ),
                        );
                        
                        $data = array

Modified: branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2012-06-13 12:59:02 UTC (rev 9579)
@@ -1865,6 +1865,7 @@
 
                        $data = array
                                (
+                                       'inherit_location'                      
                => $id ? $values['inherit_location'] : 1,
                                        'mode'                                  
                        => $mode,
                                        'suppressmeter'                         
                => isset($config->config_data['project_suppressmeter']) && 
$config->config_data['project_suppressmeter'] ? 1 : '',
                                        'suppresscoordination'                  
        => $suppresscoordination,

Modified: branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2012-06-13 12:59:02 UTC (rev 9579)
@@ -1373,7 +1373,7 @@
                                $location_types = 
$admin_location->select_location_type();
                                $max_level = count($location_types);
 
-                               $location_level = 
isset($project['location_data']['location_code']) ? 
count(explode('-',$project['location_data']['location_code'])) : 0 ;
+                               $location_level = 
isset($project['location_data']['location_code']) && 
$project['inherit_location'] ? 
count(explode('-',$project['location_data']['location_code'])) : 0 ;
                                $location_template_type = 'form';
                                $_location_data = array();
 
@@ -1396,7 +1396,7 @@
                                }
                                else
                                {
-                                       if(isset($project['location_data']) && 
$project['location_data'])
+                                       if(isset($project['location_data']) && 
$project['location_data'] && $project['inherit_location'])
                                        {
                                                $_location_data = 
$project['location_data'];
                                        }
@@ -1416,7 +1416,7 @@
                                        'lookup_type'           => 
$location_template_type,
                                        'lookup_entity'         => 
$this->bocommon->get_lookup_entity('project'),
                                        'entity_data'           => 
(isset($values['p'])?$values['p']:''),
-                                       'filter_location'       => 
$project['location_data']['location_code']
+                                       'filter_location'       => 
$project['inherit_location'] ? $project['location_data']['location_code'] : 
false
                                ));
                        }
                        else

Modified: 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
===================================================================
--- 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
        2012-06-13 12:18:31 UTC (rev 9578)
+++ 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
        2012-06-13 12:59:02 UTC (rev 9579)
@@ -94,29 +94,26 @@
                                $address        = 
$this->db->db_addslashes(implode(" ", $address));
                        }
 
+                       $loc3_data = explode('.',$data[3]);
+                       $loc3_data2 = explode('.........',$data[3]);
+                       $loc3_data3 = explode('.',$loc3_data2[1]);
 
-                       $loc3_data = explode('.........',$data[3]);
-
-                       $loc3_data2 = explode('.',$loc3_data[1] );
-
-                       if(ctype_digit($loc3_data2[0]))
+                       if(ctype_digit(rtrim($loc3_data[2],'00')))
                        {
-                               $location_code .= '-' . 
sprintf("%02s",$loc3_data2[0]);
+                               $location_code .= '-' . 
sprintf("%02s",rtrim($loc3_data[2],'00'));
                        }
+                       else if (ctype_digit($loc3_data3[0]))
+                       {
+                               $location_code .= '-' . 
sprintf("%02s",$loc3_data3[0]);
+                       }
 
-/*
-_debug_array($loc3_data2);
-_debug_array($location_code);
-die();
-*/
                        $_location_data = 
execMethod('property.solocation.read_single', $location_code );
-//_debug_array($data);
+
                        if(!$_location_data['loc1'])
                        {
                                $location_code = substr($byggid,0,4) . '-0' . 
substr($byggid,-1);
                        }
 
-
                        if(!$address)
                        {
                                $address = 
$this->db->db_addslashes($location_data['loc1_name']);
@@ -179,7 +176,7 @@
                                $ok = $this->_add_eav($id,$value_set);          
        
                        }
                        
-                       return $ok;
+                       return true;
 
                }
                
@@ -220,8 +217,6 @@
                                $doc->formatOutput = true;
                                $xml = $doc->saveXML();
 
-//                             _debug_array($xml);
-
                                $value_set = array
                                (
                                        'xml_representation'    => 
$this->db->db_addslashes($xml),
@@ -234,7 +229,7 @@
 
                                $value_set      = 
$this->db->validate_update($value_set);
 
-                               return $this->db->query("UPDATE fm_bim_item SET 
$value_set WHERE id = $id AND type = {$type}",__LINE__,__FILE__);
+                               $sql = "UPDATE fm_bim_item SET $value_set WHERE 
id = $id AND type = {$type}";
                        }
                        else
                        {
@@ -259,8 +254,6 @@
                        
                                $xml = $doc->saveXML();
 
-                       //      _debug_array($xml);
-
                                if (function_exists('com_create_guid') === true)
                                {
                                        $guid = trim(com_create_guid(), '{}');
@@ -286,11 +279,31 @@
                                        'user_id'                               
=> $this->account
                                );
 
-                               return $this->db->query("INSERT INTO 
fm_bim_item (" . implode(',',array_keys($values_insert)) . ') VALUES ('
-                                . 
$this->db->validate_insert(array_values($values_insert)) . 
')',__LINE__,__FILE__);
+                               $sql = "INSERT INTO fm_bim_item (" . 
implode(',',array_keys($values_insert)) . ') VALUES ('
+                                . 
$this->db->validate_insert(array_values($values_insert)) . ')';
+                       }
 
+                       if($this->debug)
+                       {
+                               _debug_array($sql);
                        }
+                       else
+                       {
+                               $request_ok = 
$this->db->query($sql,__LINE__,__FILE__);
+                       }
 
+                       if(!$request_ok)
+                       {
+                               $this->messages[] = "Successfully imported 
location: Title ({$data['betegnelse']})";
+                               $ok = true;
+                       }
+                       else
+                       {
+                               $this->errors[] = "Error importing location: 
Title ({$data['betegnelse']})";
+                               $ok = false;
+                       }
+                       return $ok;
+
                }
 
                private function _add_sql()
@@ -326,12 +339,12 @@
 
                        if(!$request_ok)
                        {
-                               $this->messages[] = "Successfully imported 
location: Title ({$data[1]})";
+                               $this->messages[] = "Successfully imported 
location: Title ({$data['betegnelse']})";
                                $ok = true;
                        }
                        else
                        {
-                               $this->errors[] = "Error importing location: 
Title ({$data[1]})";
+                               $this->errors[] = "Error importing location: 
Title ({$data['betegnelse']})";
                                $ok = false;
                        }
                        return $ok;

Modified: branches/Version-1_0-branch/property/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/property/setup/phpgw_no.lang    2012-06-13 
12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/setup/phpgw_no.lang    2012-06-13 
12:59:02 UTC (rev 9579)
@@ -34,7 +34,7 @@
 actual cost - paid so far      property        no      Faktisk betalt - pr dd
 add a apartment        property        no      Legg til leilighet
 add a attrib   property        no      Legg til en attibutt
-add a budget account   property        no      Legg til en budsjettkonto
+add a budget account   property        no      Legg til en kostnadsart
 add a budget query     property        no      Legg til en budsjettspørring
 add a building property        no      legg til bygning
 add a category property        no      Legg til en kategori
@@ -80,7 +80,7 @@
 add attribute  property        no      legg til attribute
 add a workorder        property        no      legg til bestilling
 add a workorder to this project        property        no      legg til en 
bestilling til dette prosjektet
-add budget account     property        no      Legg til budsjettkonto
+add budget account     property        no      Legg til kostnadsart
 add building   property        no      legg til bygning
 add category   property        no      Legg til kategori
 add common     property        no      Legg til felles
@@ -207,7 +207,7 @@
 a unique code for this activity        property        no      En unik kode fo 
denne aktiviteten
 authorities demands    property        no      Myndighetskrav
 auto tax       property        no      Auto MVA
-b_account      property        no      Budsjett konto
+b_account      property        no      Kostnadsart
 back to admin  property        no      Tilbake til Admin
 back to calculation    property        no      Tilbake til kalkulasjon
 back to entity property        no      Returner til entitet
@@ -231,11 +231,11 @@
 b - responsible        property        no      Anviser
 bruks nr       property        no      bruks nr
 budget property        no      Budsjett
-budget account property        no      Budsjett konto
-budget account group   property        no      Konto gruppe
-budget account is missing:     property        no      Budsjett konto mangler
+budget account property        no      Kostnadsart
+budget account group   property        no      Kontogruppe
+budget account is missing:     property        no      Kostnadsart mangler
 budget changed property        no      Budsjett er endret
-budget code is missing from sub invoice in :   property        no      
Budsjett konto mangler fra underbilag i :
+budget code is missing from sub invoice in :   property        no      
Kostnadsart mangler fra underbilag i :
 budget cost    property        no      Budsjett-beløp
 budget_cost    property        no      Budsjett-beløp
 budget responsible     property        no      Anviser
@@ -316,7 +316,7 @@
 click this link to enter the list of sub-invoices      property        no      
klikk her for å entre liste over underbilag
 click this link to select      property        no      Klikk her for å velge
 click this link to select apartment    property        no      klikk her for å 
velge leilighet
-click this link to select budget account       property        no      klikk 
her for å velge budsjett konto
+click this link to select budget account       property        no      klikk 
her for å velge kostnadsart
 click this link to select building     property        no      klikk her for å 
velge bygning
 click this link to select customer     property        no      Klikk her for å 
velge kunde
 click this link to select entrance     property        no      klikk her for å 
velge inngang
@@ -427,7 +427,7 @@
 delete apartment       property        no      seltt leilighjet
 delete a single entry by passing the id.       property        no      slett 
en enkelt post ved å sende id
 delete async method    property        no      Slett async metode
-delete budget account  property        no      Slett budsjettkonto
+delete budget account  property        no      Slett kostnadsart
 delete building        property        no      slett bygning
 delete claim   property        no      Slett krav
 delete column  property        no      Slett kolonne
@@ -456,7 +456,7 @@
 delete the agreement   property        no      Slett avtale
 delete the apartment   property        no      slett leilighet
 delete the attrib      property        no      slett attributt
-delete the budget account      property        no      Slett budsjettkonto
+delete the budget account      property        no      Slett kostnadsart
 delete the building    property        no      slett bygning
 delete the category    property        no      Slett kategori
 delete the claim       property        no      Slett krav
@@ -560,7 +560,7 @@
 edit agreement group   property        no      Rette avtale gruppe
 edit apartment property        no      rette leilighet
 edit attribute property        no      endre attributt
-edit budget account    property        no      Rette budsjettkonto
+edit budget account    property        no      Rette kostnadsart
 edit building  property        no      rette bygning
 edit categories        property        no      Endre kategorier
 edit category  property        no      Rette kategori
@@ -598,7 +598,7 @@
 edit the alarm property        no      Rette alarm
 edit the apartment     property        no      rette leilighet
 edit the attrib        property        no      rette attributt
-edit the budget account        property        no      Rette budsjettkonto
+edit the budget account        property        no      Rette kostnadsart
 edit the building      property        no      rette bygning
 edit the category      property        no      Rette kategorien
 edit the claim property        no      Rette kravet
@@ -652,7 +652,7 @@
 enter a description of the standard    property        no      gi en 
beskrivelse av standarden
 enter a description of the status      property        no      Angi en 
beskrivelse av statusen
 enter a description the attribute      property        no      gi en 
beskrivelse av attributten
-enter a description the budget account property        no      Angi en 
beskrivelse av budsjettkontoen
+enter a description the budget account property        no      Angi en 
beskrivelse av kostnadsarten
 enter a description the category       property        no      Angi en 
beskrivelse av kategorien
 enter a description the method property        no      Angi en beskrivelse av 
metoden
 enter a description the standard       property        no      gi en 
beskrivelse av  standarden
@@ -698,7 +698,7 @@
 enter the attribute value for this entity      property        no      angi 
attributt verdi for denne posten
 enter the billable hour for the task   property        no      Angi egne timer 
for oppgaven
 enter the budget       property        no      Angi budsjett
-enter the budget account       property        no      Angi budsjettkonto
+enter the budget account       property        no      Angi kostnadsart
 enter the category id  property        no      Angi kategori ID
 enter the cost per unit        property        no      angi kostnad pr enhet
 enter the date for this reading        property        no      Angi dato for 
denne avlesningen
@@ -955,7 +955,7 @@
 list attribute property        no      List attributter
 listbox        property        no      ListBox
 list budget    property        no      Oversikt budsjett
-list budget account    property        no      list budsjett konto
+list budget account    property        no      list kostnadsart
 list building  property        no      list bygning
 list claim     property        no      Oversikt klage
 list config    property        no      List konfigurasjon
@@ -1223,7 +1223,7 @@
 please enter scale as integer !        property        no      Angi heltall 
for skalering
 please give som details !      property        no      Angi detaljer
 please select a branch !       property        no      Velg fag
-please select a budget account !       property        no      Velg en 
budsjettkonto
+please select a budget account !       property        no      Velg en 
kostnadsart
 please select a budget reponsible!     property        no      Velg en anviser
 please select a building id !  property        no      Velg bygnings ID
 please select a category !     property        no      velg kategori
@@ -1576,7 +1576,7 @@
 select the vendor the s_agreement belongs to.  property        no      Velg 
leverandør
 select the workorder hour category     property        no      Velg 
post-kategori
 select the year the selection belongs to       property        no      Velg år 
utvelgelsen gjelder
-select this budget account     property        no      velg budsjettkonto
+select this budget account     property        no      velg kostnadsart
 select this contact    property        no      Velg denne kontakten
 select this dates      property        no      Velg dato
 select this ns3420 - code      property        no      velg NS-kode
@@ -1834,7 +1834,7 @@
 view tender    property        no      Vis beskrivelse
 view the apartment     property        no      vis leilighet
 view the attrib        property        no      vis attributt
-view the budget account        property        no      Vis budsjettkonto
+view the budget account        property        no      Vis kostnadsart
 view the building      property        no      vis bygning
 view the category      property        no      Vis kategorien
 view the claim property        no      Vis kravet
@@ -1918,6 +1918,7 @@
 tenant common  no      Leietaker
 internal       common  no      Intern
 in progress date       property        no      Påbegynt dato
+inherit location       property        no      Arve lokalisering til bestilling
 delivered date property        no      Utført dato
 checklist      property        no      Sjekkliste
 closed date    property        no      Avsluttet dato

Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php    2012-06-13 
12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php    2012-06-13 
12:59:02 UTC (rev 9579)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.645';
+       $setup_info['property']['version']              = '0.9.17.646';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: branches/Version-1_0-branch/property/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2012-06-13 12:59:02 UTC (rev 9579)
@@ -1419,6 +1419,7 @@
                                'ecodimb' => array('type' => 'int','precision' 
=> 4,'nullable' => True),
                                'contact_id' => array('type' => 
'int','precision' => 4,'nullable' => True),
                                'account_group' => array('type' => 
'int','precision' => 4,'nullable' => True),
+                               'inherit_location' => array('type' => 
'int','precision' => 2,'nullable' => True,'default' => 1),
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2012-06-13 12:59:02 UTC (rev 9579)
@@ -6386,8 +6386,6 @@
                        $GLOBALS['phpgw_setup']->oProc->query("UPDATE 
fm_workorder SET actual_cost = '{$order['actual_cost']}' WHERE id = 
'{$order['order_id']}'",__LINE__,__FILE__);
                }
 
-               $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
-
                if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
                {
                        $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.645';
@@ -6395,3 +6393,30 @@
                }
        }
 
+       /**
+       * Update property version from 0.9.17.643 to 0.9.17.644
+       * Add optional inheritance of location from project to order
+       */
+       $test[] = '0.9.17.645';
+       function property_upgrade0_9_17_645()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+               $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM fm_cache");
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project','inherit_location',array(
+                       'type'          => 'int',
+                       'precision'     => 2,
+                       'nullable'      => true,
+                       'default'       => 1
+                       )
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->query("UPDATE fm_project SET 
inherit_location = 1",__LINE__,__FILE__);
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.646';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+

Modified: branches/Version-1_0-branch/property/templates/base/invoice2.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/invoice2.xsl    
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/templates/base/invoice2.xsl    
2012-06-13 12:59:02 UTC (rev 9579)
@@ -405,6 +405,24 @@
                </tr>
                <tr class ='row_off'>
                        <td>
+                               <xsl:value-of select="php:function('lang', 
'budget account')" />
+                       </td>
+                       <td>
+                               <input type="text" name="values[b_account_id]" 
id="b_account_id" value="{voucher_info/voucher/b_account_id}"/>
+                       </td>
+               </tr>
+               <tr class ='row_off'>
+                       <td>
+                               <xsl:value-of select="php:function('lang', 'dim 
b')" />
+                       </td>
+                       <td>
+                               <select id="dim_b" name="values[dim_b]">
+                                       <xsl:apply-templates 
select="voucher_info/generic/dimb_list/options"/>
+                               </select>
+                       </td>
+               </tr>
+               <tr class ='row_off'>
+                       <td>
                                <xsl:value-of select="php:function('lang', 
'invoice line text')" />
                        </td>
                        <td>
@@ -436,16 +454,6 @@
                </tr>
                <tr class ='row_off'>
                        <td>
-                               <xsl:value-of select="php:function('lang', 'dim 
b')" />
-                       </td>
-                       <td>
-                               <select id="dim_b" name="values[dim_b]">
-                                       <xsl:apply-templates 
select="voucher_info/generic/dimb_list/options"/>
-                               </select>
-                       </td>
-               </tr>
-               <tr class ='row_off'>
-                       <td>
                                        <xsl:value-of 
select="php:function('lang', 'dim a')" />
                        </td>
                        <td>
@@ -470,14 +478,6 @@
                                <input type="text" name="values[project_group]" 
id="project_group" value="{voucher_info/voucher/project_group}"/>
                        </td>
                </tr>
-               <tr class ='row_off'>
-                       <td>
-                               <xsl:value-of select="php:function('lang', 
'budget account')" />
-                       </td>
-                       <td>
-                               <input type="text" name="values[b_account_id]" 
id="b_account_id" value="{voucher_info/voucher/b_account_id}"/>
-                       </td>
-               </tr>
 </xsl:template>
 
 

Modified: branches/Version-1_0-branch/property/templates/base/project.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/project.xsl     
2012-06-13 12:18:31 UTC (rev 9578)
+++ branches/Version-1_0-branch/property/templates/base/project.xsl     
2012-06-13 12:59:02 UTC (rev 9579)
@@ -286,6 +286,22 @@
                                                <table cellpadding="2" 
cellspacing="2" width="80%" align="center">
                                                        <xsl:choose>
                                                                <xsl:when 
test="mode='edit'">
+
+                                                                       <tr>
+                                                                               
<td valign="top">
+                                                                               
        <xsl:value-of select="php:function('lang', 'inherit location')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <input type="checkbox" name="values[inherit_location]" value="1">
+                                                                               
                <xsl:if test="inherit_location = 1">
+                                                                               
                        <xsl:attribute name="checked" value="checked"/>
+                                                                               
                </xsl:if>
+                                                                               
                <xsl:attribute name="title">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'inherit 
location')"/>
+                                                                               
                </xsl:attribute>
+                                                                               
        </input>
+                                                                               
</td>
+                                                                       </tr>
                                                                        
<xsl:call-template name="location_form"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>




reply via email to

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