fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10725] Merge 10707:10724 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [10725] Merge 10707:10724 from trunk
Date: Tue, 29 Jan 2013 12:22:51 +0000

Revision: 10725
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10725
Author:   sigurdne
Date:     2013-01-29 12:22:51 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
Merge 10707:10724 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
    
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
    
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    branches/Version-1_0-branch/logistic/inc/class.sorequirement.inc.php
    branches/Version-1_0-branch/logistic/inc/class.uiactivity.inc.php
    branches/Version-1_0-branch/logistic/inc/class.uirequirement.inc.php
    
branches/Version-1_0-branch/logistic/inc/class.uirequirement_resource_allocation.inc.php
    branches/Version-1_0-branch/logistic/inc/model/class.requirement.inc.php
    branches/Version-1_0-branch/logistic/js/logistic/resource_allocation.js
    
branches/Version-1_0-branch/logistic/templates/base/allocation/book_resources.xsl
    branches/Version-1_0-branch/property/inc/class.boproject.inc.php
    branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
    branches/Version-1_0-branch/property/inc/class.soentity.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.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/Import_fra_BKK_csv
    branches/Version-1_0-branch/property/js/yahoo/project.bulk_update_status.js
    branches/Version-1_0-branch/property/js/yahoo/workorder.index.js
    branches/Version-1_0-branch/property/setup/phpgw_no.lang
    branches/Version-1_0-branch/property/templates/base/project.xsl
    branches/Version-1_0-branch/property/templates/base/workorder.xsl

Added Paths:
-----------
    
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_month_no_loc.xsl
    
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_year_no_loc.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,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706
   + 
/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,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706,10708-10724

Modified: branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2013-01-29 12:22:51 UTC (rev 10725)
@@ -1,41 +1,41 @@
 <?php
-/**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erik Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare is free software; you can redistribute it and/or modify
-       * it under the terms of the GNU General Public License as published by
-       * the Free Software Foundation; either version 2 of the License, or
-       * (at your option) any later version.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
-       * @package property
-       * @subpackage controller
-       * @version $Id$
-       */      
 
        /**
-       * Import the jQuery class
-       */
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erik Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
+       /**
+        * Import the jQuery class
+        */
        phpgw::import_class('phpgwapi.jquery');
 
        phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('controller.socheck_list');
-       
+
        include_class('controller', 'check_list', 'inc/model/');
        include_class('controller', 'check_item', 'inc/model/');
        include_class('controller', 'component', 'inc/model/');
@@ -45,9 +45,10 @@
        include_class('controller', 'year_calendar', 'inc/component/');
        include_class('controller', 'year_calendar_agg', 'inc/component/');
        include_class('controller', 'month_calendar', 'inc/component/');
-               
+
        class controller_uicalendar extends phpgwapi_uicommon
        {
+
                private $so;
                private $so_control;
                private $so_control_group;
@@ -55,37 +56,36 @@
                private $so_control_item;
                private $so_check_list;
                private $so_check_item;
-                               
                public $public_functions = array
-               (
-                       'view_calendar_for_month'                             
=>        true,
-                       'view_calendar_for_year'                              
=>        true,
-                       'view_calendar_year_for_locations'      =>  true,
-                       'view_calendar_month_for_locations'     =>  true
+                       (
+                       'view_calendar_for_month' => true,
+                       'view_calendar_for_year' => true,
+                       'view_calendar_year_for_locations' => true,
+                       'view_calendar_month_for_locations' => 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 
-                       
-                       $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');
-                       
+
+                       $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
+
+                       $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');
                }
-               
+
                public function view_calendar_for_month()
                {
                        $location_code = phpgw::get_var('location_code');
@@ -93,156 +93,170 @@
                        $month = phpgw::get_var('month');
                        $role = phpgw::get_var('role');
                        $repeat_type = phpgw::get_var('repeat_type');
-                       
+
                        // Validates year. If year is not set, current year is 
chosen
                        $year = $this->validate_year($year);
-                       
+
                        // Validates month. If year is not set, current month 
in current year is chosen
                        $month = $this->validate_month($month);
-                       
-                       // Validates year. 
+
+                       // Validates year.
                        $repeat_type = 
$this->validate_repeat_type($repeat_type);
-                       
-                       // Validates role. 
+
+                       // Validates role.
                        $role = $this->validate_role($role);
-                       
+
                        // Gets timestamp value of first day in month
-                       $from_date_ts = 
month_calendar::get_start_date_month_ts($year, intval( $month ));
+                       $from_date_ts = 
month_calendar::get_start_date_month_ts($year, intval($month));
 
                        // Gets timestamp value of first day in month
-                       $to_date_ts = 
month_calendar::get_next_start_date_month_ts($year, intval( $month ));
+                       $to_date_ts = 
month_calendar::get_next_start_date_month_ts($year, intval($month));
 
                        // Validates location_code. If not set, first location 
among assigned locations
                        $location_code = 
$this->validate_location_code($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, $repeat_type, "return_object", $role );
-
-                       if($level == 1){
-                               // Fetches all controls for the components for 
a location within time period
-                               $filter = "bim_item.location_code = 
'$location_code' ";
-                               $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);      
-                       }else
+                       if ($location_code != null && $location_code = "")
                        {
-                               // Fetches all controls for the components for 
a location within time period
-                               $filter = "bim_item.location_code LIKE 
'$location_code%' ";
-                               $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);      
-                       }
-                       
-                       // Fetches all control ids with check lists for 
specified time period
-                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location($location_code, $from_date_ts, 
$to_date_ts);
-                       
-                       // Loops through all controls for location and 
populates controls with check lists
-                       $controls_with_check_list_array = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
-                       
-                       $controls_calendar_array = array();
-                       foreach($controls_with_check_list_array as $control)
-                       {
-                               $month_calendar = new month_calendar($control, 
$year, $month, null, $location_code, "location");
-                               $calendar_array = 
$month_calendar->build_calendar( $control->get_check_lists_array() );
+                               $level = 
$this->get_location_level($location_code);
 
-                               $controls_calendar_array[] = array("control" => 
$control->toArray(), "calendar_array" => $calendar_array);
-                       }
-                       
-                       // COMPONENTS
-                       foreach($components_with_controls_array as $component)
-                       {
-                               $location_id = $component->get_location_id();
-                               $component_id = $component->get_id();
-      
-               $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
-               $component->set_xml_short_desc( $short_desc );
-                               
-                               $controls_for_component_array = 
$component->get_controls_array();
-                               $controls_components_calendar_array = array();
-                                                               
-                         foreach($controls_for_component_array as $control)
-                         {
-                           // Fetches control ids with check lists for 
specified time period
-                                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_component($component->get_location_id(), 
$component->get_id(), $from_date_ts, $to_date_ts, $repeat_type = ">=0");
+                               $user_role = true;
 
-                                       // Loops through all controls for 
location and populates controls with check lists
-                                       $controls_for_component_array = 
$this->populate_controls_with_check_lists($controls_for_component_array, 
$control_id_with_check_list_array);
-                                                                        
-                                       $month_calendar = new month_calendar( 
$control, $year, $month, $component, null, "component" );
-                                       $calendar_array = 
$month_calendar->build_calendar( $control->get_check_lists_array() );
-                                                                               
                                
-                                       $controls_components_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
-                         }
-                         
-                         $components_calendar_array[] = array("component" => 
$component->toArray(), "controls_calendar" => 
$controls_components_calendar_array);
-                       }
-                                               
-                       $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($location_code);
-                       
-                       $heading_array = 
month_calendar::get_heading_array($year, $month);
-                       
-                       $roles_array = $this->so_control->get_roles();
-                       
-                       $repeat_type_array = array(
-                                                                       
array('id'      => "0", 'value' => "Dag"),
-                                                                       
array('id'      => "1", 'value' => "Uke"),
-                                                                       
array('id'      => "2", 'value' => "Måned"),
-                                                                       
array('id'      => "3", 'value' => "År")
-                                                               );
-                       
-                       $data = array
-                       (               
-                               'buildings_on_property'                 => 
$buildings_on_property,
-                               'my_locations'                                  
=> $my_locations,
-                               'property_array'                                
=> $property_array,
-                               'current_location'                              
=> $location_array,
-                               'heading_array'                                 
=> $heading_array,
-                               'controls_calendar_array'       => 
$controls_calendar_array,
-                               'components_calendar_array'     => 
$components_calendar_array,
-                               'location_level'                                
        => $level,
-                               'roles_array'                                   
                => $roles_array,
-                               'repeat_type_array'                             
=> $repeat_type_array,
-                               'current_year'                                  
        => $year,
-                               'current_month_nr'                              
=> $month,
-                               'current_role'                                  
                => $role,
-                               'current_repeat_type'                   => 
$repeat_type
-                       );
-                       
+                               // Fetches buildings on property
+                               $buildings_on_property = 
$this->get_buildings_on_property($user_role, $location_code, $level);
 
-                       phpgwapi_jquery::load_widget('autocomplete');
+                               // 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, $repeat_type, "return_object", $role);
 
-                       self::add_javascript('controller', 'controller', 
'ajax.js');
-                       
-                       
self::render_template_xsl(array('calendar/view_calendar_month', 
'calendar/check_list_status_manager', 
-                                                                               
                                                                        
'calendar/icon_color_map', 'calendar/select_my_locations', 
+                               if ($level == 1)
+                               {
+                                       // Fetches all controls for the 
components for a location within time period
+                                       $filter = "bim_item.location_code = 
'$location_code' ";
+                                       $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);
+                               }
+                               else
+                               {
+                                       // Fetches all controls for the 
components for a location within time period
+                                       $filter = "bim_item.location_code LIKE 
'$location_code%' ";
+                                       $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);
+                               }
+
+                               // Fetches all control ids with check lists for 
specified time period
+                               $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location($location_code, $from_date_ts, 
$to_date_ts);
+
+                               // Loops through all controls for location and 
populates controls with check lists
+                               $controls_with_check_list_array = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
+
+                               $controls_calendar_array = array();
+                               foreach ($controls_with_check_list_array as 
$control)
+                               {
+                                       $month_calendar = new 
month_calendar($control, $year, $month, null, $location_code, "location");
+                                       $calendar_array = 
$month_calendar->build_calendar($control->get_check_lists_array());
+
+                                       $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+                               }
+
+                               // COMPONENTS
+                               foreach ($components_with_controls_array as 
$component)
+                               {
+                                       $location_id = 
$component->get_location_id();
+                                       $component_id = $component->get_id();
+
+                                       $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
+                                       
$component->set_xml_short_desc($short_desc);
+
+                                       $controls_for_component_array = 
$component->get_controls_array();
+                                       $controls_components_calendar_array = 
array();
+
+                                       foreach ($controls_for_component_array 
as $control)
+                                       {
+                                               // Fetches control ids with 
check lists for specified time period
+                                               
$control_id_with_check_list_array = 
$this->so->get_check_lists_for_component($component->get_location_id(), 
$component->get_id(), $from_date_ts, $to_date_ts, $repeat_type = ">=0");
+
+                                               // Loops through all controls 
for location and populates controls with check lists
+                                               $controls_for_component_array = 
$this->populate_controls_with_check_lists($controls_for_component_array, 
$control_id_with_check_list_array);
+
+                                               $month_calendar = new 
month_calendar($control, $year, $month, $component, null, "component");
+                                               $calendar_array = 
$month_calendar->build_calendar($control->get_check_lists_array());
+
+                                               
$controls_components_calendar_array[] = array("control" => $control->toArray(), 
"calendar_array" => $calendar_array);
+                                       }
+
+                                       $components_calendar_array[] = 
array("component" => $component->toArray(), "controls_calendar" => 
$controls_components_calendar_array);
+                               }
+
+                               $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($location_code);
+
+                               $heading_array = 
month_calendar::get_heading_array($year, $month);
+
+                               $roles_array = $this->so_control->get_roles();
+
+                               $repeat_type_array = array(
+                                       array('id' => "0", 'value' => "Dag"),
+                                       array('id' => "1", 'value' => "Uke"),
+                                       array('id' => "2", 'value' => "Måned"),
+                                       array('id' => "3", 'value' => "År")
+                               );
+
+                               $data = array
+                                       (
+                                       'buildings_on_property' => 
$buildings_on_property,
+                                       'my_locations' => $my_locations,
+                                       'property_array' => $property_array,
+                                       'current_location' => $location_array,
+                                       'heading_array' => $heading_array,
+                                       'controls_calendar_array' => 
$controls_calendar_array,
+                                       'components_calendar_array' => 
$components_calendar_array,
+                                       'location_level' => $level,
+                                       'roles_array' => $roles_array,
+                                       'repeat_type_array' => 
$repeat_type_array,
+                                       'current_year' => $year,
+                                       'current_month_nr' => $month,
+                                       'current_role' => $role,
+                                       'current_repeat_type' => $repeat_type
+                               );
+
+                               phpgwapi_jquery::load_widget('autocomplete');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+                               
self::render_template_xsl(array('calendar/view_calendar_month', 
'calendar/check_list_status_manager',
+                                                                               
                                                                        
'calendar/icon_color_map', 'calendar/select_my_locations',
                                                                                
                                                                        
'calendar/select_buildings_on_property', 'calendar/nav_calendar_month',
                                                                                
                                                                        
'calendar/calendar_filters'), $data);
+                       }
+                       else
+                       {
+                               $data = array(
+                                       'current_year' => $year,
+                                       'current_month_nr' => $month
+                               );
+
+                               phpgwapi_jquery::load_widget('autocomplete');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+
+                               
self::render_template_xsl('calendar/calendar_month_no_loc', $data);
+                       }
                }
-               
+
                public function view_calendar_for_year()
                {
                        $location_code = phpgw::get_var('location_code');
                        $year = phpgw::get_var('year');
                        $role = phpgw::get_var('role');
                        $repeat_type = phpgw::get_var('repeat_type');
-               
+
                        // Validates year. If year is not set, current year is 
chosen
                        $year = $this->validate_year($year);
 
-                       // Validates repeat type. 
+                       // Validates repeat type.
                        $repeat_type = 
$this->validate_repeat_type($repeat_type);
-                       
-                       // Validates role. 
+
+                       // Validates role.
                        $role = $this->validate_role($role);
-                       
+
                        // Gets timestamp of first day in year
                        $from_date_ts = $this->get_start_date_year_ts($year);
 
@@ -251,162 +265,177 @@
 
                        // Array that will be populated with controls and 
calendar objects that will be sent to view
                        $controls_calendar_array = array();
-                               
-       // Validates location_code. If not set, first location among assigned 
locations
+
+                       // Validates location_code. If not set, first location 
among assigned locations
                        $location_code = 
$this->validate_location_code($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 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, "return_object", $role);
-                       
-                       if($level == 1){
-                               // Fetches all controls for the components for 
a location within time period
-                               $filter = "bim_item.location_code = 
'$location_code' ";
-                               $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);      
-                       }else
+                       if ($location_code != null && $location_code != "")
                        {
-                               // Fetches all controls for the components for 
a location within time period
-                               $filter = "bim_item.location_code LIKE 
'$location_code%' ";
-                               $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);      
-                       }
-                       
-                       // Loops through controls with repeat type day or week
-                       // and populates array that contains aggregated open 
cases pr month.
-                       foreach($controls_for_location_array as $control)
-                       {
-                               if($control->get_repeat_type() == 
controller_control::REPEAT_TYPE_DAY | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_WEEK)
+                               $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 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, "return_object", $role);
+
+                               if ($level == 1)
                                {
-                                       $cl_criteria = new 
controller_check_list();
-                                       
$cl_criteria->set_control_id($control->get_id());
-                                       
$cl_criteria->set_location_code($location_code);
-                                       
-                                       $from_month = 
$this->get_start_month_for_control($control);
-                                       $to_month = 
$this->get_end_month_for_control($control);
-                                       
-                                       // Loops through controls and populates 
aggregate open cases pr month array.
-                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, 
$to_month);
-                                       
-                                       $year_calendar_agg = new 
year_calendar_agg($control, $year, $location_code, 
"VIEW_CONTROLS_FOR_LOCATION");
-                                       $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
-                                               
-                                       $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+                                       // Fetches all controls for the 
components for a location within time period
+                                       $filter = "bim_item.location_code = 
'$location_code' ";
+                                       $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);
                                }
-                       }
-                       
-                       $repeat_type_expr = ">=2";
-                       // Fetches control ids with check lists for specified 
time period
-                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type_expr);
-                       
-                       // Loops through all controls for location and 
populates controls with check lists
-                       $controls_for_location_array = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
-                       
-                       foreach($controls_for_location_array as $control)
-                       {
-                               if($control->get_repeat_type() == 
controller_control::REPEAT_TYPE_MONTH | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_YEAR)
+                               else
                                {
-                                       $year_calendar = new 
year_calendar($control, $year, null, $location_code, "location" );
-                                       $calendar_array = 
$year_calendar->build_calendar( $control->get_check_lists_array() );
-                                                                               
        
-                                       $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+                                       // Fetches all controls for the 
components for a location within time period
+                                       $filter = "bim_item.location_code LIKE 
'$location_code%' ";
+                                       $components_with_controls_array = 
$this->so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_object", $role, $filter);
                                }
-                       }
-                       
-                       // COMPONENTS
-                       foreach($components_with_controls_array as $component)
-                       {
-                               $location_id = $component->get_location_id();
-                               $id = $component->get_id();
-      
-               $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $id));
-               $component->set_xml_short_desc( $short_desc_arr );
-                               
-                               $controls_for_component_array = 
$component->get_controls_array();
-                               $controls_components_calendar_array = array();
 
-                               // AGGREGATED VALUES PR MONTH: Puts aggregated 
number of open cases for days and weeks in calendar array
-                         foreach($controls_for_component_array as $control)
-                         {
-                                 if($control->get_repeat_type() == 
controller_control::REPEAT_TYPE_DAY | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_WEEK)
-                                 {
-                                       $cl_criteria = new 
controller_check_list();
-                                               $cl_criteria->set_control_id( 
$control->get_id() );
-                                               $cl_criteria->set_component_id( 
$component->get_id() );
-                                       $cl_criteria->set_location_id( 
$component->get_location_id() );
-                                       
-                                       $from_month = 
$this->get_start_month_for_control($control);
+                               // Loops through controls with repeat type day 
or week
+                               // and populates array that contains aggregated 
open cases pr month.
+                               foreach ($controls_for_location_array as 
$control)
+                               {
+                                       if ($control->get_repeat_type() == 
controller_control::REPEAT_TYPE_DAY | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_WEEK)
+                                       {
+                                               $cl_criteria = new 
controller_check_list();
+                                               
$cl_criteria->set_control_id($control->get_id());
+                                               
$cl_criteria->set_location_code($location_code);
+
+                                               $from_month = 
$this->get_start_month_for_control($control);
                                                $to_month = 
$this->get_end_month_for_control($control);
-                                                                               
-                                         $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, 
$to_month);
-                                       
-                                         $year_calendar_agg = new 
year_calendar_agg( $control, $year, $location_code, 
"VIEW_CONTROLS_FOR_LOCATION");
-                                         $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
 
-                                         $controls_components_calendar_array[] 
= array("control" => $control->toArray(), "calendar_array" => $calendar_array);
-                                 }
-                                 else 
-                                 {
-                                   // Fetches control ids with check lists for 
specified time period
-                                               
$control_id_with_check_list_array = 
$this->so->get_check_lists_for_component($component->get_location_id(), 
$component->get_id(), $from_date_ts, $to_date_ts, $repeat_type = ">=2");
+                                               // Loops through controls and 
populates aggregate open cases pr month array.
+                                               $agg_open_cases_pr_month_array 
= $this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, 
$to_month);
 
-                                               // Loops through all controls 
for location and populates controls with check lists
-                                               $controls_for_component_array = 
$this->populate_controls_with_check_lists($controls_for_component_array, 
$control_id_with_check_list_array);
+                                               $year_calendar_agg = new 
year_calendar_agg($control, $year, $location_code, 
"VIEW_CONTROLS_FOR_LOCATION");
+                                               $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
 
-                                               $year_calendar = new 
year_calendar( $control, $year, $component, null, "component" );
-                                               $calendar_array = 
$year_calendar->build_calendar( $control->get_check_lists_array() );
-                                                                               
                                
-                                               
$controls_components_calendar_array[] = array("control" => $control->toArray(), 
"calendar_array" => $calendar_array);
-                               }
-                         }
-                         
-                         $components_calendar_array[] = array("component" => 
$component->toArray(), "controls_calendar" => 
$controls_components_calendar_array);
+                                               $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+                                       }
+                               }
+
+                               $repeat_type_expr = ">=2";
+                               // Fetches control ids with check lists for 
specified time period
+                               $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type_expr);
+
+                               // Loops through all controls for location and 
populates controls with check lists
+                               $controls_for_location_array = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
+
+                               foreach ($controls_for_location_array as 
$control)
+                               {
+                                       if ($control->get_repeat_type() == 
controller_control::REPEAT_TYPE_MONTH | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_YEAR)
+                                       {
+                                               $year_calendar = new 
year_calendar($control, $year, null, $location_code, "location");
+                                               $calendar_array = 
$year_calendar->build_calendar($control->get_check_lists_array());
+
+                                               $controls_calendar_array[] = 
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+                                       }
+                               }
+
+                               // COMPONENTS
+                               foreach ($components_with_controls_array as 
$component)
+                               {
+                                       $location_id = 
$component->get_location_id();
+                                       $id = $component->get_id();
+
+                                       $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $id));
+                                       
$component->set_xml_short_desc($short_desc_arr);
+
+                                       $controls_for_component_array = 
$component->get_controls_array();
+                                       $controls_components_calendar_array = 
array();
+
+                                       // AGGREGATED VALUES PR MONTH: Puts 
aggregated number of open cases for days and weeks in calendar array
+                                       foreach ($controls_for_component_array 
as $control)
+                                       {
+                                               if ($control->get_repeat_type() 
== controller_control::REPEAT_TYPE_DAY | $control->get_repeat_type() == 
controller_control::REPEAT_TYPE_WEEK)
+                                               {
+                                                       $cl_criteria = new 
controller_check_list();
+                                                       
$cl_criteria->set_control_id($control->get_id());
+                                                       
$cl_criteria->set_component_id($component->get_id());
+                                                       
$cl_criteria->set_location_id($component->get_location_id());
+
+                                                       $from_month = 
$this->get_start_month_for_control($control);
+                                                       $to_month = 
$this->get_end_month_for_control($control);
+
+                                                       
$agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, 
$to_month);
+
+                                                       $year_calendar_agg = 
new year_calendar_agg($control, $year, $location_code, 
"VIEW_CONTROLS_FOR_LOCATION");
+                                                       $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
+
+                                                       
$controls_components_calendar_array[] = array("control" => $control->toArray(), 
"calendar_array" => $calendar_array);
+                                               }
+                                               else
+                                               {
+                                                       // Fetches control ids 
with check lists for specified time period
+                                                       
$control_id_with_check_list_array = 
$this->so->get_check_lists_for_component($component->get_location_id(), 
$component->get_id(), $from_date_ts, $to_date_ts, $repeat_type = ">=2");
+
+                                                       // Loops through all 
controls for location and populates controls with check lists
+                                                       
$controls_for_component_array = 
$this->populate_controls_with_check_lists($controls_for_component_array, 
$control_id_with_check_list_array);
+
+                                                       $year_calendar = new 
year_calendar($control, $year, $component, null, "component");
+                                                       $calendar_array = 
$year_calendar->build_calendar($control->get_check_lists_array());
+
+                                                       
$controls_components_calendar_array[] = array("control" => $control->toArray(), 
"calendar_array" => $calendar_array);
+                                               }
+                                       }
+
+                                       $components_calendar_array[] = 
array("component" => $component->toArray(), "controls_calendar" => 
$controls_components_calendar_array);
+                               }
+
+                               $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($location_code);
+
+                               $heading_array = 
year_calendar::get_heading_array();
+
+                               $roles_array = $this->so_control->get_roles();
+
+                               $repeat_type_array = array(
+                                       array('id' => "0", 'value' => "Dag"),
+                                       array('id' => "1", 'value' => "Uke"),
+                                       array('id' => "2", 'value' => "Måned"),
+                                       array('id' => "3", 'value' => "År")
+                               );
+
+                               $data = array
+                                       (
+                                       'buildings_on_property' => 
$buildings_on_property,
+                                       'my_locations' => $my_locations,
+                                       'current_location' => $location_array,
+                                       'heading_array' => $heading_array,
+                                       'controls_calendar_array' => 
$controls_calendar_array,
+                                       'components_calendar_array' => 
$components_calendar_array,
+                                       'location_level' => $level,
+                                       'roles_array' => $roles_array,
+                                       'repeat_type_array' => 
$repeat_type_array,
+                                       'current_year' => $year,
+                                       'current_role' => $role,
+                                       'current_repeat_type' => $repeat_type
+                               );
+
+                               phpgwapi_jquery::load_widget('autocomplete');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+
+                               
self::render_template_xsl(array('calendar/view_calendar_year', 
'calendar/check_list_status_manager',
+                                       'calendar/icon_color_map', 
'calendar/select_my_locations',
+                                       
'calendar/select_buildings_on_property', 'calendar/nav_calendar_year',
+                                       'calendar/calendar_filters'), $data);
                        }
-               
-                       $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+                       else
+                       {
+                               $data = array(
+                                       'current_year' => $year
+                               );
 
-                       // Gets array of locations assigned to current user
-                       $my_locations = 
$this->get_my_assigned_locations($location_code);
-                       
-                       $heading_array = year_calendar::get_heading_array();
-                       
-                       $roles_array = $this->so_control->get_roles();
-                       
-                       $repeat_type_array = array(
-                                                                       
array('id'      => "0", 'value' => "Dag"),
-                                                                       
array('id'      => "1", 'value' => "Uke"),
-                                                                       
array('id'      => "2", 'value' => "Måned"),
-                                                                       
array('id'      => "3", 'value' => "År")
-                                                               );
-                                                               
-                       $data = array
-                       (
-                               'buildings_on_property'                 => 
$buildings_on_property,
-                               'my_locations'                                  
                => $my_locations,
-                               'current_location'                      => 
$location_array,
-                               'heading_array'                                 
=> $heading_array,
-                               'controls_calendar_array'       => 
$controls_calendar_array,
-                               'components_calendar_array'     => 
$components_calendar_array,
-                               'location_level'                                
        => $level,
-                               'roles_array'                                   
                => $roles_array,
-                               'repeat_type_array'                             
=> $repeat_type_array,
-                               'current_year'                                  
        => $year,
-                               'current_role'                                  
                => $role,
-                               'current_repeat_type'                   => 
$repeat_type
-                       );
-                       
-                       
self::render_template_xsl(array('calendar/view_calendar_year', 
'calendar/check_list_status_manager', 
-                                                                               
                                                                        
'calendar/icon_color_map', 'calendar/select_my_locations', 
-                                                                               
                                                                        
'calendar/select_buildings_on_property', 'calendar/nav_calendar_year',
-                                                                               
                                                                        
'calendar/calendar_filters'), $data);
-                       
-                       phpgwapi_jquery::load_widget('autocomplete');
+                               phpgwapi_jquery::load_widget('autocomplete');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
 
-                       self::add_javascript('controller', 'controller', 
'ajax.js');
+                               
self::render_template_xsl('calendar/calendar_year_no_loc', $data);
+                       }
                }
 
                public function view_calendar_year_for_locations()
@@ -414,136 +443,136 @@
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
                        $year = phpgw::get_var('year');
-                       
-                       if(is_numeric($control_id) & $control_id > 0)
+
+                       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);
                        }
-                       
+
                        // Validates year. If year is not set, current year is 
chosen
                        $year = $this->validate_year($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();
-                       
-                       // LOCATIONS: Process aggregated values for controls 
with repeat type day or week 
-                       if( $control->get_repeat_type() <= 
controller_control::REPEAT_TYPE_WEEK  )
+
+                       // LOCATIONS: Process aggregated values for controls 
with repeat type day or week
+                       if ($control->get_repeat_type() <= 
controller_control::REPEAT_TYPE_WEEK)
                        {
-                               foreach($locations_for_control_array as 
$location)
+                               foreach ($locations_for_control_array as 
$location)
                                {
                                        $curr_location_code = 
$location['location_code'];
-                                       
+
                                        $cl_criteria = new 
controller_check_list();
-                                       $cl_criteria->set_control_id( 
$control->get_id() );
-                                       $cl_criteria->set_location_code( 
$curr_location_code );
-                                       
+                                       
$cl_criteria->set_control_id($control->get_id());
+                                       
$cl_criteria->set_location_code($curr_location_code);
+
                                        $from_month = 
$this->get_start_month_for_control($control);
                                        $to_month = 
$this->get_end_month_for_control($control);
-                                       
+
                                        // 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($cl_criteria, $year, $from_month, 
$to_month);
-                                       
+
                                        $year_calendar_agg = new 
year_calendar_agg($control, $year, $curr_location_code, 
"VIEW_LOCATIONS_FOR_CONTROL");
                                        $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
-                                       $locations_with_calendar_array[] = 
array( "location" => $location, "calendar_array" => $calendar_array );
+                                       $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
 
                                // COMPONENTS: Process aggregated values for 
controls with repeat type day or week
-                         foreach( $components_for_control_array as $component )
-                         {
-                               $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component->get_location_id(), 'id' => $component->get_id()));
-                       $component->set_xml_short_desc( $short_desc_arr );
-                                       
+                               foreach ($components_for_control_array as 
$component)
+                               {
+                                       $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component->get_location_id(), 'id' => $component->get_id()));
+                                       
$component->set_xml_short_desc($short_desc_arr);
+
                                        $repeat_type = 
$control->get_repeat_type();
                                        $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$component->get_location_id(), $component->get_id(), $from_date_ts, 
$to_date_ts, $repeat_type);
-                                                               
+
                                        $cl_criteria = new 
controller_check_list();
-                                       $cl_criteria->set_control_id( 
$control->get_id() );
-                                       $cl_criteria->set_component_id( 
$component->get_id());
-                                 $cl_criteria->set_location_id( 
$component->get_location_id() );
-                                       
-                                 $from_month = 
$this->get_start_month_for_control($control);
+                                       
$cl_criteria->set_control_id($control->get_id());
+                                       
$cl_criteria->set_component_id($component->get_id());
+                                       
$cl_criteria->set_location_id($component->get_location_id());
+
+                                       $from_month = 
$this->get_start_month_for_control($control);
                                        $to_month = 
$this->get_end_month_for_control($control);
-                               
+
                                        // 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($cl_criteria, $year, $from_month, 
$to_month);
-                                       
-                                       $year_calendar_agg = new 
year_calendar_agg( $control, $year, $location_code, 
"VIEW_LOCATIONS_FOR_CONTROL" );
+
+                                       $year_calendar_agg = new 
year_calendar_agg($control, $year, $location_code, 
"VIEW_LOCATIONS_FOR_CONTROL");
                                        $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
                                        $components_with_calendar_array[] = 
array("component" => $component->toArray(), "calendar_array" => 
$calendar_array);
                                }
                        }
                        // Process values for controls with repeat type month 
or year
-                       else if( $control->get_repeat_type() > 
controller_control::REPEAT_TYPE_WEEK )
+                       else if ($control->get_repeat_type() > 
controller_control::REPEAT_TYPE_WEEK)
                        {
-                               foreach( $locations_for_control_array as 
$location )
+                               foreach ($locations_for_control_array as 
$location)
                                {
                                        $curr_location_code = 
$location['location_code'];
-                                       
+
                                        $repeat_type = 
$control->get_repeat_type();
-                                       $location_with_check_lists = 
$this->so->get_check_lists_for_control_and_location($control_id, 
$curr_location_code, $from_date_ts, $to_date_ts, $repeat_type);   
-                                       
+                                       $location_with_check_lists = 
$this->so->get_check_lists_for_control_and_location($control_id, 
$curr_location_code, $from_date_ts, $to_date_ts, $repeat_type);
+
                                        $check_lists_array = 
$location_with_check_lists["check_lists_array"];
-                                       
+
                                        $year_calendar = new 
year_calendar($control, $year, null, $curr_location_code, "location");
-                                       $calendar_array = 
$year_calendar->build_calendar( $check_lists_array );
+                                       $calendar_array = 
$year_calendar->build_calendar($check_lists_array);
 
                                        $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                                }
-                               
-                         foreach( $components_for_control_array as $component )
-                         {
+
+                               foreach ($components_for_control_array as 
$component)
+                               {
                                        $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component->get_location_id(), 'id' => $component->get_id()));
-                       $component->set_xml_short_desc( $short_desc_arr );
-                                       
+                                       
$component->set_xml_short_desc($short_desc_arr);
+
                                        $repeat_type = 
$control->get_repeat_type();
-                                       $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$component->get_location_id(), $component->get_id(), $from_date_ts, 
$to_date_ts, $repeat_type); 
-                                       
+                                       $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$component->get_location_id(), $component->get_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, $component, null, "component" );
-                                       $calendar_array = 
$year_calendar->build_calendar( $check_lists_array );
 
+                                       $year_calendar = new 
year_calendar($control, $year, $component, null, "component");
+                                       $calendar_array = 
$year_calendar->build_calendar($check_lists_array);
+
                                        $components_with_calendar_array[] = 
array("component" => $component->toArray(), "calendar_array" => 
$calendar_array);
                                }
                        }
-                       
+
                        // Gets array of locations assigned to current user
                        $my_locations = 
$this->get_my_assigned_locations($location_code);
-                       
+
                        $heading_array = year_calendar::get_heading_array();
-                       
+
                        $data = array
-                       (
-                               '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,
-                               '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,
+                               'current_year' => $year,
                        );
-                       
-                       self::render_template_xsl( 
array('calendar/view_calendar_year_for_locations', 
'calendar/check_list_status_manager', 
-                                                                               
                                                                         
'calendar/icon_color_map', 'calendar/select_my_locations', 
'calendar/nav_calendar_year'), $data);
-                       
+
+                       
self::render_template_xsl(array('calendar/view_calendar_year_for_locations', 
'calendar/check_list_status_manager',
+                               'calendar/icon_color_map', 
'calendar/select_my_locations', 'calendar/nav_calendar_year'), $data);
+
                        phpgwapi_jquery::load_widget('core');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                }
-               
+
                public function view_calendar_month_for_locations()
                {
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so_control->get_single($control_id);
-                       $year = intval( phpgw::get_var('year') );
-                       $month = intval( phpgw::get_var('month') );
-                       
-                       if(is_numeric($control_id) & $control_id > 0)
+                       $year = intval(phpgw::get_var('year'));
+                       $month = intval(phpgw::get_var('month'));
+
+                       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);
@@ -551,176 +580,176 @@
 
                        // Validates year. If year is not set, current year is 
chosen
                        $year = $this->validate_year($year);
-                       
+
                        // Validates month. If year is not set, current month 
in current year is chosen
                        $month = $this->validate_month($month);
-                       
+
                        // Gets timestamp value of first day in month
-                       $from_date_ts = 
month_calendar::get_start_date_month_ts($year, intval( $month ));
+                       $from_date_ts = 
month_calendar::get_start_date_month_ts($year, intval($month));
 
                        // Gets timestamp value of first day in month
-                       $to_date_ts = 
month_calendar::get_next_start_date_month_ts($year, intval( $month ));
-                       
+                       $to_date_ts = 
month_calendar::get_next_start_date_month_ts($year, intval($month));
+
                        $locations_with_calendar_array = array();
-                       
-                       foreach($locations_for_control_array as $location)
+
+                       foreach ($locations_for_control_array as $location)
                        {
                                $curr_location_code = 
$location['location_code'];
-                                       
+
                                $repeat_type = $control->get_repeat_type();
-                               $location_with_check_lists = 
$this->so->get_check_lists_for_control_and_location($control_id, 
$curr_location_code, $from_date_ts, $to_date_ts, $control->get_repeat_type());  
  
-                                       
+                               $location_with_check_lists = 
$this->so->get_check_lists_for_control_and_location($control_id, 
$curr_location_code, $from_date_ts, $to_date_ts, $control->get_repeat_type());
+
                                $check_lists_array = 
$location_with_check_lists["check_lists_array"];
 
 
                                $month_calendar = new month_calendar($control, 
$year, $month, null, $curr_location_code, "location");
-                               $calendar_array = 
$month_calendar->build_calendar( $check_lists_array );
+                               $calendar_array = 
$month_calendar->build_calendar($check_lists_array);
 
                                $locations_with_calendar_array[] = 
array("location" => $location, "calendar_array" => $calendar_array);
                        }
 
-                       foreach( $components_for_control_array as $component )
+                       foreach ($components_for_control_array as $component)
                        {
                                $short_desc_arr = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component->get_location_id(), 'id' => $component->get_id()));
-               $component->set_xml_short_desc( $short_desc_arr );
-                                       
+                               $component->set_xml_short_desc($short_desc_arr);
+
                                $repeat_type = $control->get_repeat_type();
-                               $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$component->get_location_id(), $component->get_id(), $from_date_ts, 
$to_date_ts, $control->get_repeat_type());  
-                                       
+                               $component_with_check_lists = 
$this->so->get_check_lists_for_control_and_component($control_id, 
$component->get_location_id(), $component->get_id(), $from_date_ts, 
$to_date_ts, $control->get_repeat_type());
+
                                $check_lists_array = 
$component_with_check_lists["check_lists_array"];
-                                       
-                               $month_calendar = new month_calendar( $control, 
$year, $month, $component, null, "component" );
-                               $calendar_array = 
$month_calendar->build_calendar( $check_lists_array );
-                               
+
+                               $month_calendar = new month_calendar($control, 
$year, $month, $component, null, "component");
+                               $calendar_array = 
$month_calendar->build_calendar($check_lists_array);
+
                                $components_with_calendar_array[] = 
array("component" => $component->toArray(), "calendar_array" => 
$calendar_array);
                        }
-                       
+
                        // Gets array of locations assigned to current user
                        $my_locations = 
$this->get_my_assigned_locations($location_code);
-                       
+
                        $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'                                 
                        => $heading_array,
-                               'locations_with_calendar_array'         => 
$locations_with_calendar_array,
-                               'components_with_calendar_array'        => 
$components_with_calendar_array,
-                               'current_year'                                  
                                => $year,
-                               'current_month_nr'                              
                        => $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,
+                               'components_with_calendar_array' => 
$components_with_calendar_array,
+                               'current_year' => $year,
+                               'current_month_nr' => $month,
                        );
-                       
-                       self::render_template_xsl( 
array('calendar/view_calendar_month_for_locations', 
'calendar/check_list_status_manager', 
-                                                                               
                                                                         
'calendar/icon_color_map', 'calendar/select_my_locations', 
'calendar/nav_calendar_month'), $data);
-                       
+
+                       
self::render_template_xsl(array('calendar/view_calendar_month_for_locations', 
'calendar/check_list_status_manager',
+                               'calendar/icon_color_map', 
'calendar/select_my_locations', 'calendar/nav_calendar_month'), $data);
+
                        phpgwapi_jquery::load_widget('core');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                }
-               
+
                public function 
populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array)
                {
                        $controls_with_check_list = array();
-                       
-                       foreach($controls_for_location_array as $control)
+
+                       foreach ($controls_for_location_array as $control)
                        {
-                               foreach($control_id_with_check_list_array as 
$control_id)
+                               foreach ($control_id_with_check_list_array as 
$control_id)
                                {
-                                       if($control->get_id() == 
$control_id->get_id())
+                                       if ($control->get_id() == 
$control_id->get_id())
                                        {
                                                
$control->set_check_lists_array($control_id->get_check_lists_array());
-                                       }                                       
        
+                                       }
                                }
-                                       
+
                                $controls_with_check_list[] = $control;
                        }
-                       
+
                        return $controls_with_check_list;
                }
-               
-               // Generates array of aggregated number of open cases for each 
month in time period 
-               function build_agg_open_cases_pr_month_array( $cl_criteria, 
$year, $from_month, $to_month )
+
+               // Generates array of aggregated number of open cases for each 
month in time period
+               function build_agg_open_cases_pr_month_array($cl_criteria, 
$year, $from_month, $to_month)
                {
-                                       
+
                        $agg_open_cases_pr_month_array = array();
-                       
+
                        // Fetches aggregate value for open cases in each month 
in time period
-                       for($from_month; $from_month <= $to_month; 
$from_month++)
+                       for ($from_month; $from_month <= $to_month; 
$from_month++)
                        {
                                $month_start_ts = 
$this->get_month_start_ts($year, $from_month);
-                               $month_end_ts   = 
$this->get_month_start_ts($year, $from_month+1);
-                               
+                               $month_end_ts = 
$this->get_month_start_ts($year, $from_month + 1);
+
                                $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( $cl_criteria, 
$month_start_ts, $month_end_ts );       
-                               
+
+                               // 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($cl_criteria, 
$month_start_ts, $month_end_ts);
+
                                // 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) )
+                               if (!empty($num_open_cases_for_control_array))
                                {
                                        $status_agg_month_info = new 
status_agg_month_info();
                                        
$status_agg_month_info->set_month_nr($from_month);
-                                       
$status_agg_month_info->set_agg_open_cases( 
$num_open_cases_for_control_array["count"] );
+                                       
$status_agg_month_info->set_agg_open_cases($num_open_cases_for_control_array["count"]);
                                        $agg_open_cases_pr_month_array[] = 
$status_agg_month_info;
-                               } 
+                               }
                        }
-                                               
+
                        return $agg_open_cases_pr_month_array;
                }
-               
+
                function get_buildings_on_property($user_role, $location_code, 
$level)
                {
-                                       
+
                        // Property level
-                       if($level == 1)
+                       if ($level == 1)
                        {
                                $property_location_code = $location_code;
                        }
                        // Building level
-                       else if($level > 1)
+                       else if ($level > 1)
                        {
                                $split_loc_code_array = explode('-', 
$location_code);
                                $property_location_code = 
$split_loc_code_array[0];
-                       }       
-               
-                 if($user_role)
-                 {
+                       }
+
+                       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;
+
+                               $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_start_month_for_control($control)
                {
-                 // Checks if control starts in the year that is displayed 
-                       if( date("Y", $control->get_start_date()) == $year )
+                       // Checks if control starts in the year that is 
displayed
+                       if (date("Y", $control->get_start_date()) == $year)
                        {
-                               $from_month = date("n", 
$control->get_start_date());    
+                               $from_month = date("n", 
$control->get_start_date());
                        }
                        else
                        {
                                $from_month = 1;
                        }
-                       
+
                        return $from_month;
                }
-               
+
                function get_end_month_for_control($control)
-               {       
+               {
                        // Checks if control ends in the year that is displayed
-                       if( date("Y", $control->get_end_date()) == $year )
+                       if (date("Y", $control->get_end_date()) == $year)
                        {
                                $to_month = date("n", $control->get_end_date());
                        }
@@ -728,129 +757,136 @@
                        {
                                $to_month = 12;
                        }
-                       
+
                        return $to_month;
-         }
-                       
+               }
+
                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 );
+                       $my_locations = 
$location_finder->get_responsibilities($criteria);
 
-                       if(empty($location_code)){
+                       if (empty($location_code))
+                       {
                                $location_code = 
$my_locations[0]["location_code"];
                        }
-                       
+
                        return $location_code;
                }
-               
+
                function get_my_assigned_locations($current_location_code)
                {
                        $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
+                               (
+                               '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 );
-                       
+                       $my_locations = 
$location_finder->get_responsibilities($criteria);
+
                        $my_washed_locations = array();
-                       
-                       foreach($my_locations as $location)
+
+                       foreach ($my_locations as $location)
                        {
-                               if($location['location_code'] != 
$current_location_code)
+                               if ($location['location_code'] != 
$current_location_code)
                                {
                                        $my_washed_locations[] = $location;
                                }
                        }
-                       
+
                        return $my_washed_locations;
                }
-               
+
                function get_month_start_ts($year, $month)
                {
-                 if($month > 12)
-                 {
-                         $year = $year + 1;
-                         $month = $month % 12;
+                       if ($month > 12)
+                       {
+                               $year = $year + 1;
+                               $month = $month % 12;
                        }
-                       
+
                        return strtotime("$month/01/$year");
                }
-               
+
                function get_start_date_year_ts($year)
                {
                        return strtotime("01/01/$year");
                }
-               
+
                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 ) )
+                       if (empty($validate_year))
                        {
                                $validate_year = date("Y");
                        }
-                       
+
                        $validate_year = intval($validate_year);
-                       
+
                        return $validate_year;
                }
-               
+
                function validate_repeat_type($validate_repeat_type)
                {
-                       if( $validate_repeat_type != 0 & (empty( 
$validate_repeat_type ) | ($validate_repeat_type > 3)) )
+                       if ($validate_repeat_type != 0 & 
(empty($validate_repeat_type) | ($validate_repeat_type > 3)))
                        {
                                $validate_repeat_type = '';
                        }
-                       
+
                        return $validate_repeat_type;
                }
-               
-         function validate_role($validate_role)
+
+               function validate_role($validate_role)
                {
-                       if( empty( $validate_role ) | 
(!is_numeric($validate_role)) | ($validate_role < 1) )
+                       if (empty($validate_role) | 
(!is_numeric($validate_role)) | ($validate_role < 1))
                        {
                                $validate_role = '';
                        }
-                       
+
                        return $validate_role;
                }
-               
+
                function validate_month($month)
                {
-                       if( empty( $month ) ){
+                       if (empty($month))
+                       {
                                $month = date("n");
                        }
-                       
+
                        $month = intval($month);
-                       
+
                        return $month;
                }
-               
-               public function query(){}
+
+               public function query()
+               {
+
+               }
+
        }
+

Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2013-01-29 12:22:51 UTC (rev 10725)
@@ -210,7 +210,8 @@
                                                array(
                                                        'key'   =>      'title',
                                                        'label' =>      
lang('Control title'),
-                                                       'sortable'      =>      
false
+                                                       'sortable'      =>      
false,
+              'formatter' => 'YAHOO.portico.formatLink'
                                                ),
                                                array(
                                                        'key' => 'description',

Copied: 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_month_no_loc.xsl
 (from rev 10724, 
trunk/controller/templates/base/calendar/calendar_month_no_loc.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_month_no_loc.xsl
                            (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_month_no_loc.xsl
    2013-01-29 12:22:51 UTC (rev 10725)
@@ -0,0 +1,96 @@
+<!-- $Id$ -->
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<xsl:variable name="date_format"><xsl:value-of 
select="php:function('get_phpgw_info', 'user|preferences|common|dateformat')" 
/></xsl:variable>
+<xsl:variable name="month_str">month <xsl:value-of select="current_month_nr"/> 
capitalized</xsl:variable>
+<xsl:variable name="session_url">&amp;<xsl:value-of 
select="php:function('get_phpgw_session_url')" /></xsl:variable>
+
+<script>
+<xsl:text>
+
+$(document).ready(function(){
+
+       var oArgs = {menuaction:'property.bolocation.get_locations_by_name'};
+       var baseUrl = phpGWLink('index.php', oArgs, false);
+
+       var location_type = $("#loc_type").val();
+
+       $("#search-location-name").autocomplete({
+               source: function( request, response ) {
+                       location_type = $("#loc_type").val();
+
+                       $.ajax({
+                               url: baseUrl,
+                               dataType: "json",
+                               data: {
+                                       location_name: request.term,
+                                       level: location_type,
+                                       phpgw_return_as: "json"
+                               },
+                               success: function( data ) {
+                                       response( $.map( data, function( item ) 
{
+                                               return {
+                                                       label: item.name,
+                                                       value: 
item.location_code
+                                               }
+                                       }));
+                               }
+                       });
+               },
+               focus: function (event, ui) {
+                       $(event.target).val(ui.item.label);
+                       return false;
+               },
+               minLength: 1,
+               select: function( event, ui ) {
+                 chooseLocation( ui.item.label, ui.item.value);
+               }
+       });
+});
+
+function chooseLocation( label, value ){
+       var currentYear = $("#currentYear").val();
+       var currentMonth = $("#currentMonth").val();
+
+       var oArgs = 
{menuaction:'controller.uicalendar.view_calendar_for_month'};
+       var baseUrl = phpGWLink('index.php', oArgs, false);
+       var requestUrl = baseUrl +  "&amp;location_code=" + value + 
"&amp;year=" + currentYear + "&amp;month=" + currentMonth;
+
+       window.location.replace(requestUrl);
+}
+
+</xsl:text>
+
+</script>
+
+<div id="main_content">
+       <div id="control_plan" class="month_view">
+               <div id="no-loc" class="top">
+      <h1>Eiendom/bygg ikke valgt</h1>
+                       <h3>Månedsoversikt</h3>
+
+                       <!-- =====================  SEARCH FOR LOCATION  
================= -->
+                       <div id="search-location" class="select-box">
+                               <div id="choose-loc">
+                           <input id="loc_type" type="hidden" name="loc_type" 
value="2" />
+                                       <input type="hidden" id="currentYear">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="current_year"/>
+                                       </xsl:attribute>
+                               </input>
+                               <input type="hidden" id="currentMonth">
+                                 <xsl:attribute name="value">
+                                               <xsl:value-of 
select="current_month_nr"/>
+                                       </xsl:attribute>
+                               </input>
+                                       <label>Søk etter</label>
+                                       <span>
+                                               <a href="loc_type_2" class="btn 
first active">Bygg</a>
+                                               <a href="loc_type_1" 
class="btn">Eiendom</a>
+                                       </span>
+                               </div>
+                               <input type="text" value="" 
id="search-location-name" />
+                       </div>
+               </div>
+       </div>
+</div>
+</xsl:template>

Copied: 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_year_no_loc.xsl
 (from rev 10724, 
trunk/controller/templates/base/calendar/calendar_year_no_loc.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_year_no_loc.xsl
                             (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/calendar_year_no_loc.xsl
     2013-01-29 12:22:51 UTC (rev 10725)
@@ -0,0 +1,96 @@
+<!-- $Id$ -->
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<xsl:variable name="date_format"><xsl:value-of 
select="php:function('get_phpgw_info', 'user|preferences|common|dateformat')" 
/></xsl:variable>
+<xsl:variable name="month_str">month <xsl:value-of select="current_month_nr"/> 
capitalized</xsl:variable>
+<xsl:variable name="session_url">&amp;<xsl:value-of 
select="php:function('get_phpgw_session_url')" /></xsl:variable>
+
+<script>
+<xsl:text>
+
+$(document).ready(function(){
+
+       var oArgs = {menuaction:'property.bolocation.get_locations_by_name'};
+       var baseUrl = phpGWLink('index.php', oArgs, false);
+
+       var location_type = $("#loc_type").val();
+
+       $("#search-location-name").autocomplete({
+               source: function( request, response ) {
+                       location_type = $("#loc_type").val();
+
+                       $.ajax({
+                               url: baseUrl,
+                               dataType: "json",
+                               data: {
+                                       location_name: request.term,
+                                       level: location_type,
+                                       phpgw_return_as: "json"
+                               },
+                               success: function( data ) {
+                                       response( $.map( data, function( item ) 
{
+                                               return {
+                                                       label: item.name,
+                                                       value: 
item.location_code
+                                               }
+                                       }));
+                               }
+                       });
+               },
+               focus: function (event, ui) {
+                       $(event.target).val(ui.item.label);
+                       return false;
+               },
+               minLength: 1,
+               select: function( event, ui ) {
+                 chooseLocation( ui.item.label, ui.item.value);
+               }
+       });
+});
+
+function chooseLocation( label, value ){
+       var currentYear = $("#currentYear").val();
+       var currentMonth = $("#currentMonth").val();
+
+       var oArgs = {menuaction:'controller.uicalendar.view_calendar_for_year'};
+       var baseUrl = phpGWLink('index.php', oArgs, false);
+       var requestUrl = baseUrl +  "&amp;location_code=" + value + 
"&amp;year=" + currentYear + "&amp;month=" + currentMonth;
+
+       window.location.replace(requestUrl);
+}
+
+</xsl:text>
+</script>
+
+<div id="main_content">
+       <div id="control_plan" class="month_view">
+               <div id="no-loc" class="top">
+      
+      <h1>Eiendom/bygg ikke valgt</h1>  
+                       <h3>Årsoversikt</h3>
+
+                       <!-- =====================  SEARCH FOR LOCATION  
================= -->
+                       <div id="search-location" class="select-box">
+                               <div id="choose-loc">
+                           <input id="loc_type" type="hidden" name="loc_type" 
value="2" />
+                                       <input type="hidden" id="currentYear">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="current_year"/>
+                                       </xsl:attribute>
+                               </input>
+                               <input type="hidden" id="currentMonth">
+                                 <xsl:attribute name="value">
+                                               <xsl:value-of 
select="current_month_nr"/>
+                                       </xsl:attribute>
+                               </input>
+                                       <label>Søk etter</label>
+                                       <span>
+                                               <a href="loc_type_2" class="btn 
first active">Bygg</a>
+                                               <a href="loc_type_1" 
class="btn">Eiendom</a>
+                                       </span>
+                               </div>
+                               <input type="text" value="" 
id="search-location-name" />
+                       </div>
+               </div>
+       </div>
+</div>
+</xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
      2013-01-29 12:19:59 UTC (rev 10724)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
      2013-01-29 12:22:51 UTC (rev 10725)
@@ -1,10 +1,9 @@
-<!-- $Id$ -->
 <xsl:template match="data" xmlns:php="http://php.net/xsl";>
 <xsl:variable name="date_format"><xsl:value-of 
select="php:function('get_phpgw_info', 'user|preferences|common|dateformat')" 
/></xsl:variable>
 <xsl:variable name="month_str">month <xsl:value-of select="current_month_nr"/> 
capitalized</xsl:variable>
 <xsl:variable name="session_url">&amp;<xsl:value-of 
select="php:function('get_phpgw_session_url')" /></xsl:variable>
 
-<script>
+       <script>
 <xsl:text>
 
 $(document).ready(function(){
@@ -51,7 +50,7 @@
        var currentYear = $("#currentYear").val();
        var currentMonth = $("#currentMonth").val();
        
-       var oArgs = {menuaction:'controller.uicalendar.view_calendar_for_year'};
+       var oArgs = 
{menuaction:'controller.uicalendar.view_calendar_for_month'};
        var baseUrl = phpGWLink('index.php', oArgs, false);
        var requestUrl = baseUrl +  "&amp;location_code=" + value + 
"&amp;year=" + currentYear + "&amp;month=" + currentMonth;
        
@@ -62,284 +61,347 @@
 
 </script>
 
-<div id="main_content">
-       <div id="control_plan" class="month_view">
-               <div class="top">
-                       <xsl:choose>
-                               <xsl:when test="location_level = 1">
-                                       <h1>Kontrollplan for eiendom: 
<xsl:value-of select="current_location/loc1_name"/></h1>
-                               </xsl:when>
-                               <xsl:otherwise>
-                                               <h1>Kontrollplan for bygg: 
<xsl:value-of select="current_location/loc2_name"/></h1>
-                               </xsl:otherwise>
-                       </xsl:choose>
-                       <h3>Kalenderoversikt for <span 
class="month"><xsl:value-of select="php:function('lang', $month_str)" 
/></span><span class="year"><xsl:value-of select="current_year"/></span></h3>
-               
-                       <!-- =====================  SEARCH FOR LOCATION  
================= -->
-                       <div id="search-location" class="select-box">
-                               <div id="choose-loc">
-                           <input id="loc_type" type="hidden" name="loc_type" 
value="2" />
-                                       <input type="hidden" id="currentYear">
-                                       <xsl:attribute name="value">
+       <div id="main_content">
+               <div id="control_plan" class="month_view">
+                       <div class="top">
+
+                               <xsl:choose>
+                                       <xsl:when test="location_level = 1">
+                                               <h1>Kontrollplan for eiendom:
+                                                       <xsl:value-of 
select="current_location/loc1_name"/>
+                                               </h1>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <h1>Kontrollplan for bygg:
+                                                       <xsl:value-of 
select="current_location/loc2_name"/>
+                                               </h1>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+
+                               <h3>Kalenderoversikt for
+                                       <span class="month">
+                                               <xsl:value-of 
select="php:function('lang', $month_str)" />
+                                       </span>
+                                       <span class="year">
                                                <xsl:value-of 
select="current_year"/>
-                                       </xsl:attribute>
-                               </input>
-                               <input type="hidden" id="currentMonth">
-                                 <xsl:attribute name="value">
-                                               <xsl:value-of 
select="current_month_nr"/>
-                                       </xsl:attribute>
-                               </input>
-                                       <label>Søk etter</label>
-                                       <span>
-                                               <a href="loc_type_2" class="btn 
first active">Bygg</a>
-                                               <a href="loc_type_1" 
class="btn">Eiendom</a>
                                        </span>
+                               </h3>
+
+                               <!-- =====================  SEARCH FOR LOCATION 
 ================= -->
+                               <div id="search-location" class="select-box">
+                                       <div id="choose-loc">
+                                               <input id="loc_type" 
type="hidden" name="loc_type" value="2" />
+                                               <input type="hidden" 
id="currentYear">
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="current_year"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                               <input type="hidden" 
id="currentMonth">
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="current_month_nr"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                               <label>Søk etter</label>
+                                               <span>
+                                                       <a href="loc_type_2" 
class="btn first active">Bygg</a>
+                                                       <a href="loc_type_1" 
class="btn">Eiendom</a>
+                                               </span>
+                                       </div>
+                                       <input type="text" value="" 
id="search-location-name" />
                                </div>
-                               <input type="text" value="" 
id="search-location-name" />
-                       </div>
-               
-                       <!-- =====================  SELECT LIST FOR MY ASSIGNED 
LOCATIONS  ================= -->
-                       <div id="choose-my-location" class="select-box">
-                               <label>Velg et annet bygg/eiendom du har ansvar 
for</label>
-                               
-                               <form action="#">
-                                       <input type="hidden" name="period_type" 
value="view_month" />
-                                       <input type="hidden" name="year">
-                                     <xsl:attribute name="value">
-                                       <xsl:value-of select="current_year"/>
-                                     </xsl:attribute>
-                                       </input>
-                                       <input type="hidden" name="month">
-                                     <xsl:attribute name="value">
-                                       <xsl:value-of 
select="current_month_nr"/>
-                                     </xsl:attribute>
-                                       </input>
-                                                               
-                                       <select id="choose_my_location" 
class="selectLocation">
-                                               <option>Velg bygg</option>
-                                               <xsl:for-each 
select="my_locations">
+
+                               <!-- =====================  SELECT LIST FOR MY 
ASSIGNED LOCATIONS  ================= -->
+                               <div id="choose-my-location" class="select-box">
+                                       <label>Velg et annet bygg/eiendom du 
har ansvar for</label>
+
+                                       <form action="#">
+                                               <input type="hidden" 
name="period_type" value="view_month" />
+                                               <input type="hidden" 
name="year">
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="current_year"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                               <input type="hidden" 
name="month">
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="current_month_nr"/>
+                                                       </xsl:attribute>
+                                               </input>
+
+                                               <select id="choose_my_location" 
class="selectLocation">
+                                                       <option>Velg 
bygg</option>
+                                                       <xsl:for-each 
select="my_locations">
                                                                <xsl:choose>
                                                                        
<xsl:when test="location_code = //current_location/location_code">
                                                                                
<option selected="SELECTED">
-                                                                               
        <xsl:attribute name="value"><xsl:value-of disable-output-escaping="yes" 
select="location_code"/></xsl:attribute>        
+                                                                               
        <xsl:attribute name="value">
+                                                                               
                <xsl:value-of disable-output-escaping="yes" 
select="location_code"/>
+                                                                               
        </xsl:attribute>
                                                                                
        <xsl:value-of disable-output-escaping="yes" select="loc1_name"/>
                                                                                
</option>
                                                                        
</xsl:when>
                                                                        
<xsl:otherwise>
                                                                                
<option>
-                                                                               
        <xsl:attribute name="value"><xsl:value-of disable-output-escaping="yes" 
select="location_code"/></xsl:attribute>        
+                                                                               
        <xsl:attribute name="value">
+                                                                               
                <xsl:value-of disable-output-escaping="yes" 
select="location_code"/>
+                                                                               
        </xsl:attribute>
                                                                                
        <xsl:value-of disable-output-escaping="yes" select="loc1_name"/>
                                                                                
</option>
                                                                        
</xsl:otherwise>
                                                                </xsl:choose>
-                                               </xsl:for-each>
-                                       </select>                               
        
-                               </form>
+                                                       </xsl:for-each>
+                                               </select>
+                                       </form>
+                               </div>
                        </div>
-               </div>
-               <div class="middle">
-               
-               <!-- =====================  SHOW CALENDAR FOR YEAR  
================= -->
-               <a id="showYear">
-                       <xsl:attribute name="href">
-                               
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
-                               <xsl:text>&amp;year=</xsl:text>
-                               <xsl:value-of select="current_year"/>
-                               <xsl:text>&amp;location_code=</xsl:text>
-                               <xsl:value-of 
select="current_location/location_code"/>
-                               <xsl:value-of select="$session_url"/>
-                       </xsl:attribute>
-                       <img height="20" 
src="controller/images/left_arrow_simple_light_blue.png" />Årsoversikt
-               </a>
-               
-               <!-- =====================  CHOOSE ANOTHER BUILDING ON PROPERTY 
 ================= -->
-                       <div id="choose-building" class="select-box">
-                               <xsl:if test="location_level > 1">
-                                       <a>
-                                               <xsl:attribute name="href">
-                                                       
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
-                                                       
<xsl:text>&amp;year=</xsl:text>
-                                                       <xsl:value-of 
select="current_year"/>
-                                                       
<xsl:text>&amp;location_code=</xsl:text>
-                                                       <xsl:value-of 
select="current_location/loc1"/>
-                                                       <xsl:value-of 
select="$session_url"/>
-                                               </xsl:attribute>
-                                               Vis kontrollplan for eiendom
-                                       </a> 
-                               </xsl:if>
+                       <div class="middle">
 
-                               <label>Velg et annet bygg på eiendommen</label>
-                               <xsl:call-template 
name="select_buildings_on_property" />
+                               <!-- =====================  SHOW CALENDAR FOR 
YEAR  ================= -->
+                               <a id="showYear">
+                                       <xsl:attribute name="href">
+                                               
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
+                                               <xsl:text>&amp;year=</xsl:text>
+                                               <xsl:value-of 
select="current_year"/>
+                                               
<xsl:text>&amp;location_code=</xsl:text>
+                                               <xsl:value-of 
select="current_location/location_code"/>
+                                               <xsl:value-of 
select="$session_url"/>
+                                       </xsl:attribute>
+                                       <img height="20" 
src="controller/images/left_arrow_simple_light_blue.png" />Årsoversikt
+                               </a>
+
+                               <!-- =====================  CHOOSE ANOTHER 
BUILDING ON PROPERTY  ================= -->
+                               <div id="choose-building" class="select-box">
+                                       <xsl:if test="location_level > 1">
+                                               <a>
+                                                       <xsl:attribute 
name="href">
+                                                               
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
+                                                               
<xsl:text>&amp;year=</xsl:text>
+                                                               <xsl:value-of 
select="current_year"/>
+                                                               
<xsl:text>&amp;location_code=</xsl:text>
+                                                               <xsl:value-of 
select="current_location/loc1"/>
+                                                               <xsl:value-of 
select="$session_url"/>
+                                                       </xsl:attribute>
+                                                       Vis kontrollplan for 
eiendom
+                                               </a>
+                                       </xsl:if>
+
+                                       <label>Velg et annet bygg på 
eiendommen</label>
+                                       <xsl:call-template 
name="select_buildings_on_property" />
+                               </div>
+
+                               <!-- =====================  COLOR ICON MAP  
================= -->
+                               <xsl:call-template name="icon_color_map" />
+
+                               <!-- =====================  FILTERS  
================= -->
+                               <xsl:call-template name="calendar_filters" >
+                                       <xsl:with-param 
name="view_period">month</xsl:with-param>
+                               </xsl:call-template>
+
+                               <!-- =====================  CALENDAR NAVIGATION 
 ================= -->
+                               <xsl:call-template name="nav_calendar_month">
+                                       <xsl:with-param 
name="view">VIEW_CONTROLS_FOR_LOCATION</xsl:with-param>
+                               </xsl:call-template>
                        </div>
-                       
-                       <!-- =====================  COLOR ICON MAP  
================= -->
-                       <xsl:call-template name="icon_color_map" />
-               
-                       <!-- =====================  FILTERS  ================= 
-->
-                       <xsl:call-template name="calendar_filters" >
-                               <xsl:with-param 
name="view_period">month</xsl:with-param>
-                       </xsl:call-template>
-                               
-                       <!-- =====================  CALENDAR NAVIGATION  
================= -->
-                       <xsl:call-template name="nav_calendar_month">
-               <xsl:with-param 
name="view">VIEW_CONTROLS_FOR_LOCATION</xsl:with-param>
-               </xsl:call-template>
-               </div>
-                       
-               <div id="cal_wrp">
-                       <!-- ================================  BUILDINGS TABLE  
====================================  -->
-                       <h2>Bygg/eiendom</h2>
-                       <table id="calendar" class="month">
-                               <tr class="heading">
-                                       <th 
class="title"><span>Tittel</span></th>
-                                       <th 
class="assigned"><span>Tildelt</span></th>
-                                       <th 
class="frequency"><span>Frekvens</span></th>
-                                       <xsl:for-each select="heading_array">
-                                               <th><span><xsl:value-of 
select="."/></span></th>
-                                       </xsl:for-each>
-                               </tr>
-                               <xsl:choose>    
-                                       <xsl:when 
test="controls_calendar_array/child::node()">
-                                       <xsl:for-each 
select="controls_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 
class="title">
-                                               <a class="show-control-details">
-                                                                               
<xsl:attribute name="href">
-                                                                               
        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
-                                                                               
        <xsl:text>&amp;control_id=</xsl:text>
-                                                                               
        <xsl:value-of select="control/id"/>
-                                                                               
        <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-                                                                               
        <xsl:value-of select="$session_url"/>
-                                                                               
</xsl:attribute>
-                                                                               
<xsl:value-of select="control/title"/>
-                                                                       </a> 
-                                                               </td>
-                                                               <td 
class="assigned">
-                                               <span><xsl:value-of 
select="control/responsibility_name"/></span>
-                                                               </td>
-                                                               <td 
class="frequency">
-                                                               <span>
-                                                                       
<xsl:choose>
-                                                                               
<xsl:when test="control/repeat_interval = 1">
-                                                                               
        <span class="pre">Hver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval = 2">
-                                                                               
        <span class="pre">Annenhver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval > 2">
-                                                                               
        <span class="pre">Hver</span><span><xsl:value-of 
select="control/repeat_interval"/>.</span>
-                                                                               
</xsl:when>
-                                                                       
</xsl:choose>
-                                                                       
-                                                                       <span 
class="val"><xsl:value-of select="control/repeat_type_label"/></span>
-                                                               </span>
-                                                               </td>
-                                               
-                                                       <xsl:for-each 
select="calendar_array">
-                                                               <td>
-                                                                       
<xsl:call-template name="check_list_status_manager" >
-                                                                               
<xsl:with-param name="location_code"><xsl:value-of 
select="//current_location/location_code"/></xsl:with-param>
-                                                                       
</xsl:call-template>
-                                                               </td>
-                                                       </xsl:for-each>
-                                               </tr>
-                                       </xsl:for-each>
-                               </xsl:when>
-                               <xsl:otherwise>
-                                       <tr class="cal_info_msg"><td 
colspan="3"><xsl:value-of select="php:function('lang', 
'error_msg_no_controls_in_period')" /></td></tr>
-                               </xsl:otherwise>
-                       </xsl:choose>
-                       </table>
-               
-               <!-- ================================  COMPONENTS TABLE  
====================================  -->
-               <h2 class="components">Komponenter</h2>
-               <xsl:choose>
-                               <xsl:when 
test="components_calendar_array/child::node()">
-               <xsl:for-each select="components_calendar_array">
-                 <h3><xsl:value-of select="component/xml_short_desc"/></h3>
-                 
-                       <table id="calendar" class="month">
+
+                       <div id="cal_wrp">
+                               <!-- ================================  
BUILDINGS TABLE  ====================================  -->
+                               <h2>Bygg/eiendom</h2>
+                               <table id="calendar" class="month">
                                        <tr class="heading">
-                                                       <th 
class="title"><span>Tittel</span></th>
-                                                       <th 
class="assigned"><span>Tildelt</span></th>
-                                                       <th 
class="frequency"><span>Frekvens</span></th>
-                                       <xsl:for-each select="//heading_array">
-                                               <th><span><xsl:value-of 
select="."/></span></th>
-                                       </xsl:for-each>
+                                               <th class="title">
+                                                       <span>Tittel</span>
+                                               </th>
+                                               <th class="assigned">
+                                                       <span>Tildelt</span>
+                                               </th>
+                                               <th class="frequency">
+                                                       <span>Frekvens</span>
+                                               </th>
+                                               <xsl:for-each 
select="heading_array">
+                                                       <th>
+                                                               <span>
+                                                                       
<xsl:value-of select="."/>
+                                                               </span>
+                                                       </th>
+                                               </xsl:for-each>
                                        </tr>
-                       
-                               <xsl:for-each select="controls_calendar">
-                                               <xsl:variable 
name="control_id"><xsl:value-of select="control/id"/></xsl:variable>
-                                               <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 
class="title">
-                                               <a id="showControlDetails">
-                                                                               
<xsl:attribute name="href">
-                                                                               
        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
-                                                                               
        <xsl:text>&amp;control_id=</xsl:text>
-                                                                               
        <xsl:value-of select="control/id"/>
-                                                                               
        <xsl:value-of select="$session_url"/>
-                                                                               
</xsl:attribute>
-                                                                               
<xsl:value-of select="control/title"/>
-                                                                       </a> 
+                                       <xsl:choose>
+                                               <xsl:when 
test="controls_calendar_array/child::node()">
+                                                       <xsl:for-each 
select="controls_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 
class="title">
+                                                                               
<a class="show-control-details">
+                                                                               
        <xsl:attribute name="href">
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+                                                                               
                <xsl:text>&amp;control_id=</xsl:text>
+                                                                               
                <xsl:value-of select="control/id"/>
+                                                                               
                <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
+                                                                               
                <xsl:value-of select="$session_url"/>
+                                                                               
        </xsl:attribute>
+                                                                               
        <xsl:value-of select="control/title"/>
+                                                                               
</a>
+                                                                       </td>
+                                                                       <td 
class="assigned">
+                                                                               
<span>
+                                                                               
        <xsl:value-of select="control/responsibility_name"/>
+                                                                               
</span>
+                                                                       </td>
+                                                                       <td 
class="frequency">
+                                                                               
<span>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="control/repeat_interval = 1">
+                                                                               
                        <span class="pre">Hver</span>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="control/repeat_interval = 2">
+                                                                               
                        <span class="pre">Annenhver</span>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="control/repeat_interval > 2">
+                                                                               
                        <span class="pre">Hver</span>
+                                                                               
                        <span>
+                                                                               
                                <xsl:value-of 
select="control/repeat_interval"/>.
+                                                                               
                        </span>
+                                                                               
                </xsl:when>
+                                                                               
        </xsl:choose>
+
+                                                                               
        <span class="val">
+                                                                               
                <xsl:value-of select="control/repeat_type_label"/>
+                                                                               
        </span>
+                                                                               
</span>
+                                                                       </td>
+
+                                                                       
<xsl:for-each select="calendar_array">
+                                                                               
<td>
+                                                                               
        <xsl:call-template name="check_list_status_manager" >
+                                                                               
                <xsl:with-param name="location_code">
+                                                                               
                        <xsl:value-of 
select="//current_location/location_code"/>
+                                                                               
                </xsl:with-param>
+                                                                               
        </xsl:call-template>
+                                                                               
</td>
+                                                                       
</xsl:for-each>
+                                                               </tr>
+                                                       </xsl:for-each>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <tr 
class="cal_info_msg">
+                                                               <td colspan="3">
+                                                                       
<xsl:value-of select="php:function('lang', 'error_msg_no_controls_in_period')" 
/>
                                                                </td>
-                                                               <td 
class="assigned">
-                                                               
<span><xsl:value-of select="control/responsibility_name"/></span>
-                                                               </td>
-                                                               <td 
class="frequency">
-                                                               <span>
-                                                                       
<xsl:choose>
-                                                                               
<xsl:when test="control/repeat_interval = 1 and control/repeat_type &lt; 3">
-                                                                               
        <span class="pre">Hver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval = 1 and control/repeat_type = 3">
-                                                                               
        <span class="pre">Hvert</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval = 2">
-                                                                               
        <span class="pre">Annenhver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval > 2">
-                                                                               
        <span class="pre">Hver</span><span><xsl:value-of 
select="control/repeat_interval"/>.</span>
-                                                                               
</xsl:when>
-                                                                       
</xsl:choose>
-                                                                       
-                                                                       <span 
class="val"><xsl:value-of select="control/repeat_type_label"/></span>
-                                                               </span>
-                                                               </td>
-                                                               <xsl:for-each 
select="calendar_array">
-                                                                       <td>
-                                                                               
<xsl:call-template name="check_list_status_manager" >
-                                                                               
        <xsl:with-param name="location_code"><xsl:value-of 
select="//current_location/location_code"/></xsl:with-param>
-                                                                               
</xsl:call-template>
-                                                                       </td>
+                                                       </tr>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </table>
+
+                               <!-- ================================  
COMPONENTS TABLE  ====================================  -->
+                               <h2 class="components">Komponenter</h2>
+                               <xsl:choose>
+                                       <xsl:when 
test="components_calendar_array/child::node()">
+                                               <xsl:for-each 
select="components_calendar_array">
+                                                       <h3>
+                                                               <xsl:value-of 
select="component/xml_short_desc"/>
+                                                       </h3>
+
+                                                       <table id="calendar" 
class="month">
+                                                               <tr 
class="heading">
+                                                                       <th 
class="title">
+                                                                               
<span>Tittel</span>
+                                                                       </th>
+                                                                       <th 
class="assigned">
+                                                                               
<span>Tildelt</span>
+                                                                       </th>
+                                                                       <th 
class="frequency">
+                                                                               
<span>Frekvens</span>
+                                                                       </th>
+                                                                       
<xsl:for-each select="//heading_array">
+                                                                               
<th>
+                                                                               
        <span>
+                                                                               
                <xsl:value-of select="."/>
+                                                                               
        </span>
+                                                                               
</th>
+                                                                       
</xsl:for-each>
+                                                               </tr>
+
+                                                               <xsl:for-each 
select="controls_calendar">
+                                                                       
<xsl:variable name="control_id">
+                                                                               
<xsl:value-of select="control/id"/>
+                                                                       
</xsl:variable>
+                                                                       <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 class="title">
+                                                                               
        <a id="showControlDetails">
+                                                                               
                <xsl:attribute name="href">
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+                                                                               
                        <xsl:text>&amp;control_id=</xsl:text>
+                                                                               
                        <xsl:value-of select="control/id"/>
+                                                                               
                        <xsl:value-of select="$session_url"/>
+                                                                               
                </xsl:attribute>
+                                                                               
                <xsl:value-of select="control/title"/>
+                                                                               
        </a>
+                                                                               
</td>
+                                                                               
<td class="assigned">
+                                                                               
        <span>
+                                                                               
                <xsl:value-of select="control/responsibility_name"/>
+                                                                               
        </span>
+                                                                               
</td>
+                                                                               
<td class="frequency">
+                                                                               
        <span>
+                                                                               
                <xsl:choose>
+                                                                               
                        <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type &lt; 3">
+                                                                               
                                <span class="pre">Hver</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type = 3">
+                                                                               
                                <span class="pre">Hvert</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval = 2">
+                                                                               
                                <span class="pre">Annenhver</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval > 2">
+                                                                               
                                <span class="pre">Hver</span>
+                                                                               
                                <span>
+                                                                               
                                        <xsl:value-of 
select="control/repeat_interval"/>.
+                                                                               
                                </span>
+                                                                               
                        </xsl:when>
+                                                                               
                </xsl:choose>
+
+                                                                               
                <span class="val">
+                                                                               
                        <xsl:value-of select="control/repeat_type_label"/>
+                                                                               
                </span>
+                                                                               
        </span>
+                                                                               
</td>
+                                                                               
<xsl:for-each select="calendar_array">
+                                                                               
        <td>
+                                                                               
                <xsl:call-template name="check_list_status_manager" >
+                                                                               
                        <xsl:with-param name="location_code">
+                                                                               
                                <xsl:value-of 
select="//current_location/location_code"/>
+                                                                               
                        </xsl:with-param>
+                                                                               
                </xsl:call-template>
+                                                                               
        </td>
+                                                                               
</xsl:for-each>
+                                                                       </tr>
                                                                </xsl:for-each>
-                                               </tr>   
-                                       </xsl:for-each>
-                               </table>        
-               </xsl:for-each>
-               </xsl:when>
-                       <xsl:otherwise>
-                               <div id="calendar">
-                                       <p class="no-comp-msg">Ingen 
komponenter tilknyttet kontroll</p>
-                               </div>
-                       </xsl:otherwise>
-                       </xsl:choose>
+                                                       </table>
+                                               </xsl:for-each>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <div id="calendar">
+                                                       <p 
class="no-comp-msg">Ingen komponenter tilknyttet kontroll</p>
+                                               </div>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </div>
                </div>
        </div>
-</div>
-</xsl:template>
+</xsl:template>
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
       2013-01-29 12:19:59 UTC (rev 10724)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
       2013-01-29 12:22:51 UTC (rev 10725)
@@ -1,8 +1,7 @@
-<!-- $Id$ -->
 <xsl:template match="data"  xmlns:php="http://php.net/xsl";>
 <xsl:variable name="session_url">&amp;<xsl:value-of 
select="php:function('get_phpgw_session_url')" /></xsl:variable>
-       
-<script>
+
+       <script>
 <xsl:text>
 
 $(document).ready(function(){
@@ -59,186 +58,105 @@
 
 </script>
 
-<div id="main_content">
-       <div id="control_plan">
-               <div class="top">
-                       <xsl:choose>
-                               <xsl:when test="location_level = 1">
-                                       <h1>Kontrollplan for eiendom: 
<xsl:value-of select="current_location/loc1_name"/></h1>
-                               </xsl:when>
-                               <xsl:otherwise>
-                                               <h1>Kontrollplan for bygg: 
<xsl:value-of select="current_location/loc2_name"/></h1>
-                               </xsl:otherwise>
-                       </xsl:choose>
-                       
-                       <h3>Kalenderoversikt for <span 
class="year"><xsl:value-of select="current_year"/></span></h3>
-                       
-                       <!-- =====================  SEARCH FOR LOCATION  
================= -->
-                       <div id="search-location" class="select-box">
-                               <div id="choose-loc">
-                                       <input id="loc_type" type="hidden" 
name="loc_type" value="2" />
-                                       <input type="hidden" id="currentYear">
-                                         <xsl:attribute name="value">
-                                                 <xsl:value-of 
select="current_year"/>
-                                         </xsl:attribute>
-                                 </input>
-                                       <label>Søk etter</label>
-                                       <span>
-                                               <a href="loc_type_2" class="btn 
first active">Bygg</a>
-                                               <a href="loc_type_1" 
class="btn">Eiendom</a>
+       <div id="main_content">
+               <div id="control_plan">
+                       <div class="top">
+
+                               <xsl:choose>
+                                       <xsl:when test="location_level = 1">
+                                               <h1>Kontrollplan for eiendom:
+                                                       <xsl:value-of 
select="current_location/loc1_name"/>
+                                               </h1>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <h1>Kontrollplan for bygg:
+                                                       <xsl:value-of 
select="current_location/loc2_name"/>
+                                               </h1>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+
+                               <h3>Kalenderoversikt for
+                                       <span class="year">
+                                               <xsl:value-of 
select="current_year"/>
                                        </span>
+                               </h3>
+
+                               <!-- =====================  SEARCH FOR LOCATION 
 ================= -->
+                               <div id="search-location" class="select-box">
+                                       <div id="choose-loc">
+                                               <input id="loc_type" 
type="hidden" name="loc_type" value="2" />
+                                               <input type="hidden" 
id="currentYear">
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="current_year"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                               <label>Søk etter</label>
+                                               <span>
+                                                       <a href="loc_type_2" 
class="btn first active">Bygg</a>
+                                                       <a href="loc_type_1" 
class="btn">Eiendom</a>
+                                               </span>
+                                       </div>
+                                       <input type="text" value="" 
id="search-location-name" />
                                </div>
-                               <input type="text" value="" 
id="search-location-name" />
+
+                               <!-- =====================  SELECT LIST FOR MY 
LOCATIONS  ================= -->
+                               <div id="choose-my-location" class="select-box">
+                                       <label>Velg et annet bygg/eiendom du 
har ansvar for</label>
+                                       <xsl:call-template 
name="select_my_locations" />
+                               </div>
                        </div>
-                       
-                       <!-- =====================  SELECT LIST FOR MY 
LOCATIONS  ================= -->
-                       <div id="choose-my-location" class="select-box">
-                               <label>Velg et annet bygg/eiendom du har ansvar 
for</label>
-                               <xsl:call-template name="select_my_locations" />
+
+                       <div class="middle">
+
+                               <!-- =====================  CHOOSE ANOTHER 
BUILDING ON PROPERTY  ================= -->
+                               <div id="choose-building" class="select-box">
+                                       <xsl:if test="location_level > 1">
+                                               <a>
+                                                       <xsl:attribute 
name="href">
+                                                               
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
+                                                               
<xsl:text>&amp;year=</xsl:text>
+                                                               <xsl:value-of 
select="current_year"/>
+                                                               
<xsl:text>&amp;location_code=</xsl:text>
+                                                               <xsl:value-of 
select="current_location/loc1"/>
+                                                               <xsl:value-of 
select="$session_url"/>
+                                                       </xsl:attribute>
+                                                       Vis kontrollplan for 
eiendom
+                                               </a>
+                                       </xsl:if>
+
+                                       <label>Velg et annet bygg på 
eiendommen</label>
+                                       <xsl:call-template 
name="select_buildings_on_property" />
+                               </div>
+
+
+                               <!-- =====================  COLOR ICON MAP  
================= -->
+                               <xsl:call-template name="icon_color_map" />
+
+                               <!-- =====================  FILTERS  
================= -->
+                               <xsl:call-template name="calendar_filters" >
+                                       <xsl:with-param 
name="view_period">year</xsl:with-param>
+                               </xsl:call-template>
+
+                               <!-- =====================  CALENDAR NAVIGATION 
 ================= -->
+                               <xsl:call-template name="nav_calendar_year">
+                                       <xsl:with-param 
name="view">VIEW_CONTROLS_FOR_LOCATION</xsl:with-param>
+                               </xsl:call-template>
                        </div>
-               </div>
-               
-               <div class="middle">
-               
-                       <!-- =====================  CHOOSE ANOTHER BUILDING ON 
PROPERTY  ================= -->
-                       <div id="choose-building" class="select-box">
-                               <xsl:if test="location_level > 1">
-                                       <a>
-                                               <xsl:attribute name="href">
-                                                       
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_year</xsl:text>
-                                                       
<xsl:text>&amp;year=</xsl:text>
-                                                       <xsl:value-of 
select="current_year"/>
-                                                       
<xsl:text>&amp;location_code=</xsl:text>
-                                                       <xsl:value-of 
select="current_location/loc1"/>
-                                                       <xsl:value-of 
select="$session_url"/>
-                                               </xsl:attribute>
-                                               Vis kontrollplan for eiendom
-                                       </a> 
-                               </xsl:if>
 
-                               <label>Velg et annet bygg på eiendommen</label>
-                               <xsl:call-template 
name="select_buildings_on_property" />
-                       </div>
-                       
-                       
-                       <!-- =====================  COLOR ICON MAP  
================= -->
-                       <xsl:call-template name="icon_color_map" />
-                                       
-                       <!-- =====================  FILTERS  ================= 
-->
-                       <xsl:call-template name="calendar_filters" >
-                               <xsl:with-param 
name="view_period">year</xsl:with-param>
-                       </xsl:call-template>
-                       
-                       <!-- =====================  CALENDAR NAVIGATION  
================= -->
-                       <xsl:call-template name="nav_calendar_year">
-               <xsl:with-param 
name="view">VIEW_CONTROLS_FOR_LOCATION</xsl:with-param>
-               </xsl:call-template>
-               </div>
-                
-               <div id="cal_wrp">
-               <h2>Bygg/eiendom</h2>
-               <table id="calendar" class="year">
-                               <tr class="heading">
-                                               <th 
class="title"><span>Tittel</span></th>
-                                               <th 
class="assigned"><span>Tildelt</span></th>
-                                               <th 
class="frequency"><span>Frekvens</span></th>
-                                       <xsl:for-each select="heading_array">
-                                               <th>
-                                                       <a>
-                                                               <xsl:attribute 
name="href">
-                                                                       
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_month</xsl:text>
-                                                                       
<xsl:text>&amp;year=</xsl:text>
-                                                                       
<xsl:value-of select="//current_year"/>
-                                                                       
<xsl:text>&amp;location_code=</xsl:text>
-                                                                       
<xsl:value-of select="//current_location/location_code"/>
-                                                                       
<xsl:text>&amp;month=</xsl:text>
-                                                                       
<xsl:number/>
-                                                                       
<xsl:value-of select="$session_url"/>
-                                                               </xsl:attribute>
-                                                               
-                                                               <xsl:variable 
name="month_str">short_month <xsl:number/> capitalized</xsl:variable>
-                                                               <xsl:value-of 
select="php:function('lang', $month_str)" />
-                                                       </a>                    
        
+                       <div id="cal_wrp">
+                               <h2>Bygg/eiendom</h2>
+                               <table id="calendar" class="year">
+                                       <tr class="heading">
+                                               <th class="title">
+                                                       <span>Tittel</span>
                                                </th>
-                                       </xsl:for-each>
-                               </tr>
-                       
-                       <xsl:choose>
-                               <xsl:when 
test="controls_calendar_array/child::node()">
-                               <xsl:for-each select="controls_calendar_array">
-                                       <xsl:variable 
name="control_id"><xsl:value-of select="control/id"/></xsl:variable>
-                                       <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 class="title">
-                                               <a class="show-control-details">
-                                                                               
<xsl:attribute name="href">
-                                                                               
        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
-                                                                               
        <xsl:text>&amp;control_id=</xsl:text>
-                                                                               
        <xsl:value-of select="control/id"/>
-                                                                               
        <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-                                                                               
        <xsl:value-of select="$session_url"/>
-                                                                               
</xsl:attribute>
-                                                                               
<xsl:value-of select="control/title"/>
-                                                                       </a> 
-                                                               </td>
-                                                       <td class="assigned">
-                                                       <span><xsl:value-of 
select="control/responsibility_name"/></span>
-                                                       </td>
-                                                       <td class="frequency">
-                                       <span>
-                                               <xsl:choose>
-                                                       <xsl:when 
test="control/repeat_interval = 1 and control/repeat_type &lt; 3">
-                                                               <span 
class="pre">Hver</span>
-                                                       </xsl:when>
-                                                       <xsl:when 
test="control/repeat_interval = 1 and control/repeat_type = 3">
-                                                               <span 
class="pre">Hvert</span>
-                                                       </xsl:when>
-                                                       <xsl:when 
test="control/repeat_interval = 2">
-                                                               <span 
class="pre">Annenhver</span>
-                                                       </xsl:when>
-                                                       <xsl:when 
test="control/repeat_interval > 2">
-                                                               <span 
class="pre">Hver</span><span><xsl:value-of 
select="control/repeat_interval"/>.</span>
-                                                       </xsl:when>
-                                               </xsl:choose>
-                                               
-                                               <span class="val"><xsl:value-of 
select="control/repeat_type_label"/></span>
-                                       </span>
-                                                       </td>
-                                                       <xsl:for-each 
select="calendar_array">
-                                                               <td>
-                                                                       
<xsl:call-template name="check_list_status_manager" >
-                                                                               
<xsl:with-param name="location_code"><xsl:value-of 
select="//current_location/location_code"/></xsl:with-param>
-                                                                       
</xsl:call-template>
-                                                               </td>
-                                                       </xsl:for-each>
-                                               </tr>   
-                               </xsl:for-each> 
-                       </xsl:when>
-                       <xsl:otherwise>
-                               <tr class="cal_info_msg"><td 
colspan="3"><xsl:value-of select="php:function('lang', 
'error_msg_no_controls_in_period')" /></td></tr>
-                       </xsl:otherwise>
-               </xsl:choose>
-               </table>
-               
-               <h2 class="components">Komponenter</h2>
-               <xsl:choose>
-                       <xsl:when 
test="components_calendar_array/child::node()">
-                       <xsl:for-each select="components_calendar_array">
-                 <h3><xsl:value-of select="component/xml_short_desc"/></h3>
-                 
-                       <table id="calendar" class="year">
-                                       <tr class="heading">
-                                                       <th 
class="title"><span>Tittel</span></th>
-                                                       <th 
class="assigned"><span>Tildelt</span></th>
-                                                       <th 
class="frequency"><span>Frekvens</span></th>
-                                               <xsl:for-each 
select="//heading_array">
+                                               <th class="assigned">
+                                                       <span>Tildelt</span>
+                                               </th>
+                                               <th class="frequency">
+                                                       <span>Frekvens</span>
+                                               </th>
+                                               <xsl:for-each 
select="heading_array">
                                                        <th>
                                                                <a>
                                                                        
<xsl:attribute name="href">
@@ -251,80 +169,212 @@
                                                                                
<xsl:number/>
                                                                                
<xsl:value-of select="$session_url"/>
                                                                        
</xsl:attribute>
-                                                                       
+
                                                                        
<xsl:variable name="month_str">short_month <xsl:number/> 
capitalized</xsl:variable>
-                                                                       
<xsl:value-of select="php:function('lang', $month_str)" />
-                                                               </a>            
                
+                                                               <xsl:value-of 
select="php:function('lang', $month_str)" />
+                                                               </a>
                                                        </th>
                                                </xsl:for-each>
                                        </tr>
-                       
-                               <xsl:for-each select="controls_calendar">
-                                               <xsl:variable 
name="control_id"><xsl:value-of select="control/id"/></xsl:variable>
-                                       
-                                               <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 
class="title">
-                                               <a class="show-control-details">
-                                                                               
<xsl:attribute name="href">
-                                                                               
        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
-                                                                               
        <xsl:text>&amp;control_id=</xsl:text>
-                                                                               
        <xsl:value-of select="control/id"/>
-                                                                               
        <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-                                                                               
        <xsl:value-of select="$session_url"/>
-                                                                               
</xsl:attribute>
-                                                                               
<xsl:value-of select="control/title"/>
-                                                                       </a> 
+
+                                       <xsl:choose>
+                                               <xsl:when 
test="controls_calendar_array/child::node()">
+                                                       <xsl:for-each 
select="controls_calendar_array">
+                                                               <xsl:variable 
name="control_id">
+                                                                       
<xsl:value-of select="control/id"/>
+                                                               </xsl:variable>
+                                                               <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 
class="title">
+                                                                               
<a class="show-control-details">
+                                                                               
        <xsl:attribute name="href">
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+                                                                               
                <xsl:text>&amp;control_id=</xsl:text>
+                                                                               
                <xsl:value-of select="control/id"/>
+                                                                               
                <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
+                                                                               
                <xsl:value-of select="$session_url"/>
+                                                                               
        </xsl:attribute>
+                                                                               
        <xsl:value-of select="control/title"/>
+                                                                               
</a>
+                                                                       </td>
+                                                                       <td 
class="assigned">
+                                                                               
<span>
+                                                                               
        <xsl:value-of select="control/responsibility_name"/>
+                                                                               
</span>
+                                                                       </td>
+                                                                       <td 
class="frequency">
+                                                                               
<span>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type &lt; 3">
+                                                                               
                        <span class="pre">Hver</span>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type = 3">
+                                                                               
                        <span class="pre">Hvert</span>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="control/repeat_interval = 2">
+                                                                               
                        <span class="pre">Annenhver</span>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="control/repeat_interval > 2">
+                                                                               
                        <span class="pre">Hver</span>
+                                                                               
                        <span>
+                                                                               
                                <xsl:value-of 
select="control/repeat_interval"/>.
+                                                                               
                        </span>
+                                                                               
                </xsl:when>
+                                                                               
        </xsl:choose>
+
+                                                                               
        <span class="val">
+                                                                               
                <xsl:value-of select="control/repeat_type_label"/>
+                                                                               
        </span>
+                                                                               
</span>
+                                                                       </td>
+                                                                       
<xsl:for-each select="calendar_array">
+                                                                               
<td>
+                                                                               
        <xsl:call-template name="check_list_status_manager" >
+                                                                               
                <xsl:with-param name="location_code">
+                                                                               
                        <xsl:value-of 
select="//current_location/location_code"/>
+                                                                               
                </xsl:with-param>
+                                                                               
        </xsl:call-template>
+                                                                               
</td>
+                                                                       
</xsl:for-each>
+                                                               </tr>
+                                                       </xsl:for-each>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <tr 
class="cal_info_msg">
+                                                               <td colspan="3">
+                                                                       
<xsl:value-of select="php:function('lang', 'error_msg_no_controls_in_period')" 
/>
                                                                </td>
-                                                               <td 
class="assigned">
-                                                               
<span><xsl:value-of select="control/responsibility_name"/></span>
-                                                               </td>
-                                                               <td 
class="frequency">
-                                                               <span>
-                                                                       
<xsl:choose>
-                                                                               
<xsl:when test="control/repeat_interval = 1 and control/repeat_type &lt; 3">
-                                                                               
        <span class="pre">Hver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval = 1 and control/repeat_type = 3">
-                                                                               
        <span class="pre">Hvert</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval = 2">
-                                                                               
        <span class="pre">Annenhver</span>
-                                                                               
</xsl:when>
-                                                                               
<xsl:when test="control/repeat_interval > 2">
-                                                                               
        <span class="pre">Hver</span><span><xsl:value-of 
select="control/repeat_interval"/>.</span>
-                                                                               
</xsl:when>
-                                                                       
</xsl:choose>
-                                                                       
-                                                                       <span 
class="val"><xsl:value-of select="control/repeat_type_label"/></span>
-                                                               </span>
-                                                               </td>
-                                                               <xsl:for-each 
select="calendar_array">
-                                                                       <td>
-                                                                               
<xsl:call-template name="check_list_status_manager" >
-                                                                               
        <xsl:with-param name="location_code"><xsl:value-of 
select="//current_location/location_code"/></xsl:with-param>
-                                                                               
</xsl:call-template>
-                                                                       </td>
+                                                       </tr>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </table>
+
+                               <h2 class="components">Komponenter</h2>
+                               <xsl:choose>
+                                       <xsl:when 
test="components_calendar_array/child::node()">
+                                               <xsl:for-each 
select="components_calendar_array">
+                                                       <h3>
+                                                               <xsl:value-of 
select="component/xml_short_desc"/>
+                                                       </h3>
+
+                                                       <table id="calendar" 
class="year">
+                                                               <tr 
class="heading">
+                                                                       <th 
class="title">
+                                                                               
<span>Tittel</span>
+                                                                       </th>
+                                                                       <th 
class="assigned">
+                                                                               
<span>Tildelt</span>
+                                                                       </th>
+                                                                       <th 
class="frequency">
+                                                                               
<span>Frekvens</span>
+                                                                       </th>
+                                                                       
<xsl:for-each select="//heading_array">
+                                                                               
<th>
+                                                                               
        <a>
+                                                                               
                <xsl:attribute name="href">
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_month</xsl:text>
+                                                                               
                        <xsl:text>&amp;year=</xsl:text>
+                                                                               
                        <xsl:value-of select="//current_year"/>
+                                                                               
                        <xsl:text>&amp;location_code=</xsl:text>
+                                                                               
                        <xsl:value-of 
select="//current_location/location_code"/>
+                                                                               
                        <xsl:text>&amp;month=</xsl:text>
+                                                                               
                        <xsl:number/>
+                                                                               
                        <xsl:value-of select="$session_url"/>
+                                                                               
                </xsl:attribute>
+
+                                                                               
                <xsl:variable name="month_str">short_month
+                                                                               
                        <xsl:number/> capitalized
+                                                                               
                </xsl:variable>
+                                                                               
                <xsl:value-of select="php:function('lang', $month_str)" />
+                                                                               
        </a>
+                                                                               
</th>
+                                                                       
</xsl:for-each>
+                                                               </tr>
+
+                                                               <xsl:for-each 
select="controls_calendar">
+                                                                       
<xsl:variable name="control_id">
+                                                                               
<xsl:value-of select="control/id"/>
+                                                                       
</xsl:variable>
+
+                                                                       <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 class="title">
+                                                                               
        <a class="show-control-details">
+                                                                               
                <xsl:attribute name="href">
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+                                                                               
                        <xsl:text>&amp;control_id=</xsl:text>
+                                                                               
                        <xsl:value-of select="control/id"/>
+                                                                               
                        <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
+                                                                               
                        <xsl:value-of select="$session_url"/>
+                                                                               
                </xsl:attribute>
+                                                                               
                <xsl:value-of select="control/title"/>
+                                                                               
        </a>
+                                                                               
</td>
+                                                                               
<td class="assigned">
+                                                                               
        <span>
+                                                                               
                <xsl:value-of select="control/responsibility_name"/>
+                                                                               
        </span>
+                                                                               
</td>
+                                                                               
<td class="frequency">
+                                                                               
        <span>
+                                                                               
                <xsl:choose>
+                                                                               
                        <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type &lt; 3">
+                                                                               
                                <span class="pre">Hver</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval = 1 and 
control/repeat_type = 3">
+                                                                               
                                <span class="pre">Hvert</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval = 2">
+                                                                               
                                <span class="pre">Annenhver</span>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:when test="control/repeat_interval > 2">
+                                                                               
                                <span class="pre">Hver</span>
+                                                                               
                                <span>
+                                                                               
                                        <xsl:value-of 
select="control/repeat_interval"/>.
+                                                                               
                                </span>
+                                                                               
                        </xsl:when>
+                                                                               
                </xsl:choose>
+
+                                                                               
                <span class="val">
+                                                                               
                        <xsl:value-of select="control/repeat_type_label"/>
+                                                                               
                </span>
+                                                                               
        </span>
+                                                                               
</td>
+                                                                               
<xsl:for-each select="calendar_array">
+                                                                               
        <td>
+                                                                               
                <xsl:call-template name="check_list_status_manager" >
+                                                                               
                        <xsl:with-param name="location_code">
+                                                                               
                                <xsl:value-of 
select="//current_location/location_code"/>
+                                                                               
                        </xsl:with-param>
+                                                                               
                </xsl:call-template>
+                                                                               
        </td>
+                                                                               
</xsl:for-each>
+                                                                       </tr>
                                                                </xsl:for-each>
-                                               </tr>   
-                                       </xsl:for-each>
-                               </table>        
-               </xsl:for-each>
-               </xsl:when>
-                       <xsl:otherwise>
-                               <div id="calendar">
-                                       <p class="no-comp-msg">Ingen 
komponenter tilknyttet kontroll</p>
-                               </div>
-                       </xsl:otherwise>
-                       </xsl:choose>
+                                                       </table>
+                                               </xsl:for-each>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <div id="calendar">
+                                                       <p 
class="no-comp-msg">Ingen komponenter tilknyttet kontroll</p>
+                                               </div>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </div>
+               </div>
        </div>
-</div>
-</div>
 </xsl:template>

Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css  
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css  
2013-01-29 12:22:51 UTC (rev 10725)
@@ -393,6 +393,11 @@
   padding: 5px 20px;
 }
 
+#innertoolbar-button, input[type="button"], #innertoolbar-button, 
input[type="submit"] {
+  margin-right: 3px;
+  padding: 3px 20px;
+}
+
 #innertoolbar-button {
   font-size: 1em;
   line-height: 1.2em;
@@ -516,7 +521,7 @@
 }
 
 #control_item_details .styleWrp {
-  background: none repeat scroll 0 0 #F2F8FF;
+  background: none repeat scroll 0 0 #FFFFFF;
   border: 1px solid #DBE5EF;
   border-radius: 4px;
   padding: 10px;
@@ -661,6 +666,7 @@
   padding: 0;
   position: relative;
 }
+
 ul.items li.list_item{
   position:relative;
   z-index: 1;
@@ -674,18 +680,24 @@
   padding: 5px;
 }
 
-#control_items form{
-  margin-bottom: 20px;
+#control_items form {
+  margin-bottom: 25px;
 }
 
+#control_items ul{
+  margin-bottom: 10px;
+}
+
 /* =======================================  DRAG LIST  
========================================= */
 
 .drag_group{
   margin-bottom: 10px;
 }
+
 .drag_group a:hover{
   cursor: move;
 }
+
 .drag_elem{
   z-index: 100;
   position:absolute;
@@ -704,6 +716,7 @@
   margin-bottom: 6px;
   margin-top: 0;
 }
+
 ul.expand_list h4 img {
   height: 12px;
 }
@@ -722,6 +735,7 @@
   padding-left: 5px;
   vertical-align: middle;
 }
+
 ul.expand_list .expand_item {
   display: none;
 }
@@ -739,10 +753,12 @@
   margin: 10px 0 15px 0;
   width: 120px;
 }
+
 .delete {
   cursor: pointer;
   margin-left: 5px;
 }
+
 .yui-navset .yui-content.tab_content {
   padding: 20px;
 }
@@ -1146,6 +1162,12 @@
   margin-bottom: 10px;
 }
 
+#no-loc #search-location {
+    clear: both;
+    float: left;
+    margin-bottom: 10px;
+}
+
 #search-location-name {
   margin: 2px 0 0;
   width: 16em;

Modified: branches/Version-1_0-branch/logistic/inc/class.sorequirement.inc.php
===================================================================
--- branches/Version-1_0-branch/logistic/inc/class.sorequirement.inc.php        
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/logistic/inc/class.sorequirement.inc.php        
2013-01-29 12:22:51 UTC (rev 10725)
@@ -191,4 +191,4 @@
                        }
                        return self::$so;
                }
-       }
\ No newline at end of file
+       }

Modified: branches/Version-1_0-branch/logistic/inc/class.uiactivity.inc.php
===================================================================
--- branches/Version-1_0-branch/logistic/inc/class.uiactivity.inc.php   
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/logistic/inc/class.uiactivity.inc.php   
2013-01-29 12:22:51 UTC (rev 10725)
@@ -444,7 +444,7 @@
 
                        $accounts = 
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_READ, 'run', 'logistic');
 
-                       $activities = $this->so->get();
+                       $activities = $this->so->get(0, 0, 'name', true, null, 
null, null, true);
 
                        if($activity_id)
                        {
@@ -655,11 +655,16 @@
                                                        'sortable' => false
                                                ),
                                                array(
-                                                       'key' => 'location_id',
+                                                       'key' => 
'location_label',
                                                        'label' => 
lang('Resource type'),
                                                        'sortable' => false
                                                ),
                                                array(
+                                                       'key' => 'criterias',
+                                                       'label' => 
lang('Criterias'),
+                                                       'sortable' => false
+                                               ),
+                                               array(
                                                        'key' => 'link',
                                                        'hidden' => true
                                                ),

Modified: branches/Version-1_0-branch/logistic/inc/class.uirequirement.inc.php
===================================================================
--- branches/Version-1_0-branch/logistic/inc/class.uirequirement.inc.php        
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/logistic/inc/class.uirequirement.inc.php        
2013-01-29 12:22:51 UTC (rev 10725)
@@ -158,17 +158,56 @@
                                        $rows[] = $result->serialize();
                                }
                        }
+
+                       //Sigurd
+                       $custom = createObject('phpgwapi.custom_fields');
+
 //_debug_array($rows);
                        $line_id = 0; // optional preselect
                        foreach($rows as &$entry)
                        {
 
-//FIXME: hent verdier
-/*
+//-----------Sigurd
                                $_filters = array('requirement_id' => 
$entry['id']);
                                $requirement_values_array = 
$this->so_requirement_value->get(0, false, $sort_field, $sort_ascending, 
$search_for, $search_type, $_filters);
 
-*/
+                               $location_id = $entry['location_id'];
+                               $criterias = array();
+                               if( count( $requirement_values_array ) > 0 )
+                               {
+                                       foreach($requirement_values_array as 
$requirement_value)
+                                       {
+                                               $loc_arr = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+                                               $cust_attribute_id = 
$requirement_value->get_cust_attribute_id();
+
+                                               $attrib_data = 
$custom->get('property', $loc_arr['location'], $cust_attribute_id);
+
+                                               $_criterie = 
$attrib_data['input_text'];
+                                       
+                                               
if(isset($attrib_data['choice']))
+                                               {
+                                                       foreach 
($attrib_data['choice'] as $_choice)
+                                                       {
+                                                               
if($_choice['id'] == $requirement_value->get_value())
+                                                               {
+                                                                       
$_criterie .= "::{$_choice['value']}";
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                               else 
if($requirement_value->get_value())
+                                               {
+                                                       $_criterie .= 
"::{$requirement_value->get_value()}";                                    
+                                               }
+                                       
+                                               $criterias[] = $_criterie;
+
+//                                             $operator       = 
$requirement_value->get_operator();
+                                       }
+                               }
+                               $entry['criterias'] = implode(',',$criterias);
+
+//-------------
                                $_checked = '';
 
                                if($entry['id'] == $line_id)
@@ -288,7 +327,7 @@
                                                        'sortable' => false
                                                ),
                                                array(
-                                                       'key' => 'location_id',
+                                                       'key' => 
'location_label',
                                                        'label' => 
lang('Resource type'),
                                                        'sortable' => false
                                                ),

Modified: 
branches/Version-1_0-branch/logistic/inc/class.uirequirement_resource_allocation.inc.php
===================================================================
--- 
branches/Version-1_0-branch/logistic/inc/class.uirequirement_resource_allocation.inc.php
    2013-01-29 12:19:59 UTC (rev 10724)
+++ 
branches/Version-1_0-branch/logistic/inc/class.uirequirement_resource_allocation.inc.php
    2013-01-29 12:22:51 UTC (rev 10725)
@@ -301,9 +301,18 @@
 
                        if($requirement)
                        {
-                               $loc_arr = 
$GLOBALS['phpgw']->locations->get_name($requirement->get_location_id());
-                               $entity_arr = explode('.',$loc_arr['location']);
-
+// find allocated
+                               $allocated_objects = $this->so->get(null, null, 
null, null, null, null, array('requirement_id' => $requirement->get_id()));
+                               
+                               $allocated = array();
+                               if($allocated_objects)
+                               {
+                                       foreach ($allocated_objects as 
$allocated_object)
+                                       {
+                                               $allocated[] = 
$allocated_object->get_resource_id();
+                                       }
+                               }
+//
                                $requirement_values = 
$this->so_requirement_value->get(null, null, null, null, null, null, 
array('requirement_id' => $requirement->get_id()));
 
                                $criterias_array = array();
@@ -311,11 +320,7 @@
                                $location_id = $requirement->get_location_id();
 
                                $loc_arr = 
$GLOBALS['phpgw']->locations->get_name($location_id);
-                               $entity_arr = explode('.',$loc_arr['location']);
 
-                               $entity_id = $entity_arr[2];
-                               $cat_id = $entity_arr[3];
-
                                $criterias_array['location_id'] = $location_id;
                                $criterias_array['allrows'] = true;
 
@@ -341,26 +346,30 @@
                                                $operator_str = ">";
                                        }
 
-                                       $attrib_data = $custom->get('property', 
".entity.{$entity_id}.{$cat_id}", $cust_attribute_id);
+                                       $attrib_data = 
$custom->get($loc_arr['appname'], $loc_arr['location'], $cust_attribute_id);
 
                                        $view_criterias_array[] =  array(
-                                                       'operator'              
                                =>      $operator_str,
-                                                       'value'                 
                                        =>      $attrib_value,
-                                                       "cust_attribute_data" 
=> $attrib_data
+                                                       'operator'              
                                => $operator_str,
+                                                       'value'                 
                                => $attrib_value,
+                                                       'cust_attribute_data'   
                => $attrib_data
                                                );
 
                                        $condition = array(
                                                'operator'              => 
$operator_str,
-                                               'value'                         
=> $attrib_value,
-                                               'attribute_id' => 
$cust_attribute_id
+                                               'value'                 => 
$attrib_value,
+                                               'attribute_id'  => 
$cust_attribute_id
                                        );
 
                                        $criterias_array['conditions'][] = 
$condition;
                                }
                        }
                    
-                       $so_entity      = 
CreateObject('property.soentity',$entity_id,$cat_id);
-                       $allocation_suggestions = 
$so_entity->get_eav_list($criterias_array);
+                       $allocation_suggestions = 
execMethod('property.soentity.get_eav_list', $criterias_array);
+                       
+                       foreach ($allocation_suggestions as 
&$allocation_suggestion)
+                       {
+                               $allocation_suggestion['allocated'] = 
in_array($allocation_suggestion['id'],$allocated);
+                       }
 
                        $activity = $this->so_activity->get_single( 
$requirement->get_activity_id() );
 

Modified: 
branches/Version-1_0-branch/logistic/inc/model/class.requirement.inc.php
===================================================================
--- branches/Version-1_0-branch/logistic/inc/model/class.requirement.inc.php    
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/logistic/inc/model/class.requirement.inc.php    
2013-01-29 12:22:51 UTC (rev 10725)
@@ -156,7 +156,8 @@
                                'start_date' => $this->get_start_date() ? 
date($date_format, $this->get_start_date()): '',
                                'end_date' => $this->get_end_date() ? 
date($date_format, $this->get_end_date()): '',
                                'no_of_items' => $this->get_no_of_items(),
-                               'location_id' => $category_label,
+                               'location_id' => $this->get_location_id(),
+                               'location_label' => $category_label,
                        );
                }
                
@@ -232,4 +233,4 @@
                                  
                  return $status;
                }
-       }
\ No newline at end of file
+       }

Modified: 
branches/Version-1_0-branch/logistic/js/logistic/resource_allocation.js
===================================================================
--- branches/Version-1_0-branch/logistic/js/logistic/resource_allocation.js     
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/logistic/js/logistic/resource_allocation.js     
2013-01-29 12:22:51 UTC (rev 10725)
@@ -20,7 +20,8 @@
                                  var obj = jQuery.parseJSON(data);
                          
                          if(obj.status == "deleted"){
-                                 $(thisRow).remove();
+                                       $(thisRow).remove();
+                                               
YAHOO.portico.updateinlineTableHelper('requirement-container');
                                  }
                          },
                          error: function(XMLHttpRequest, textStatus, 
errorThrown) {

Modified: 
branches/Version-1_0-branch/logistic/templates/base/allocation/book_resources.xsl
===================================================================
--- 
branches/Version-1_0-branch/logistic/templates/base/allocation/book_resources.xsl
   2013-01-29 12:19:59 UTC (rev 10724)
+++ 
branches/Version-1_0-branch/logistic/templates/base/allocation/book_resources.xsl
   2013-01-29 12:22:51 UTC (rev 10725)
@@ -76,7 +76,7 @@
                                        <div class="resource heading">
                                                        <span class="desc">Kort 
beskrivelse</span>
                                                        <span 
class="loc_id">Lokasjons id</span>
-                                                       <span 
class="type">Type</span>
+                                               <!--    <span 
class="type">Type</span> -->
                                                        <span 
class="loc_code">Lokasjons kode</span>
                                        </div>
                                        <xsl:for-each 
select="allocation_suggestions">
@@ -90,11 +90,15 @@
                                                        <xsl:attribute 
name="class">resource even</xsl:attribute>
                                                    </xsl:otherwise>
                                                  </xsl:choose>
-                                               
-                                                       <input type="checkbox" 
value="{id}" name="chosen_resources[]" />
+                                                       <input type="checkbox" 
value="{id}" name="chosen_resources[]" >
+                                                               <xsl:if 
test="allocated = 1">
+                                                               <xsl:attribute 
name="checked">checked</xsl:attribute>
+                                                               <xsl:attribute 
name="disabled">disabled</xsl:attribute>
+                                                               </xsl:if>
+                                                       </input>
                                                        <span 
class="desc"><xsl:value-of select="short_description" /></span>
                                                        <span 
class="loc_id"><xsl:value-of select="location_id" /></span>
-                                                       <span 
class="type"><xsl:value-of select="type_lokale" /></span>
+                                               <!--    <span 
class="type"><xsl:value-of select="type_lokale" /></span> -->
                                                        <span 
class="loc_code"><xsl:value-of select="location_code" /></span>
                                                </div>
                                        </xsl:for-each>
@@ -104,4 +108,4 @@
                        </form>
        </div>
 </div>
-</xsl:template>
\ No newline at end of file
+</xsl:template>

Modified: branches/Version-1_0-branch/property/inc/class.boproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boproject.inc.php    
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.boproject.inc.php    
2013-01-29 12:22:51 UTC (rev 10725)
@@ -834,7 +834,27 @@
                        return $record_history;
                }
 
+               public function get_files($id = 0)
+               {
+                       $vfs = CreateObject('phpgwapi.vfs');
+                       $vfs->override_acl = 1;
 
+                       $files = $vfs->ls(array(
+                               'string' => "/property/project/{$id}",
+                               'relatives' => array(RELATIVE_NONE)
+                       ));
+
+                       $vfs->override_acl = 0;
+
+                       $j      = count($files);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$files[$i]['file_name']=urlencode($files[$i]['name']);
+                       }
+                       return $files;
+               }
+
+
                function next_project_id()
                {
                        return $this->so->next_project_id();
@@ -884,9 +904,9 @@
                        $this->so->delete($project_id);
                }
 
-               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, 
$user_id,$ids,$paid,$closed_orders,$ecodimb,$transfer_budget)
+               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, 
$user_id,$ids,$paid,$closed_orders,$ecodimb,$transfer_budget,$new_budget)
                {
-                       return $this->so->bulk_update_status($start_date, 
$end_date, $status_filter, $status_new, $execute, $type, 
$user_id,$ids,$paid,$closed_orders,$ecodimb,$transfer_budget);
+                       return $this->so->bulk_update_status($start_date, 
$end_date, $status_filter, $status_new, $execute, $type, 
$user_id,$ids,$paid,$closed_orders,$ecodimb,$transfer_budget,$new_budget);
                }
 
                public function get_user_list($selected = 0)

Modified: branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2013-01-29 12:22:51 UTC (rev 10725)
@@ -39,6 +39,7 @@
                var $filter;
                var $sort;
                var $order;
+               var $filter_year;
                var $cat_id;
                var $order_sent_adress; // in case we want to resend the order 
as an reminder
                var $allrows;
@@ -69,11 +70,14 @@
                                $this->use_session = true;
                        }
 
+                       $default_filter_year    = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_project_filter_year'])
 && 
$GLOBALS['phpgw_info']['user']['preferences']['property']['default_project_filter_year']
 == 'current_year' ? date('Y') : 'all';
+
                        $start                          = 
phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $query                          = 
phpgw::get_var('query');
                        $sort                           = 
phpgw::get_var('sort');
                        $order                          = 
phpgw::get_var('order');
                        $filter                         = 
phpgw::get_var('filter', 'int');
+                       $filter_year            = phpgw::get_var('filter_year', 
'string', 'REQUEST', $default_filter_year);
                        $cat_id                         = 
phpgw::get_var('cat_id', 'int');
                        $status_id                      = 
phpgw::get_var('status_id');
                        $wo_hour_cat_id         = 
phpgw::get_var('wo_hour_cat_id', 'int');
@@ -89,6 +93,7 @@
                        $this->obligation       = $obligation;
 
                        $this->start            = $start ? $start : 0;
+                       $this->filter_year      = $filter_year;
 
                        if(array_key_exists('district_id',$_POST) || 
array_key_exists('district_id',$_GET) )
                        {
@@ -470,7 +475,7 @@
                                
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$data['allrows'],
                                
'b_group'=>$this->b_group,'ecodimb'=>$this->ecodimb, 
'paid'=>$this->paid,'b_account' => $this->b_account,
                                'district_id' => 
$this->district_id,'dry_run'=>$data['dry_run'], 'criteria' => 
$this->get_criteria($this->criteria_id),
-                               'obligation' => $this->obligation) );
+                               'obligation' => $this->obligation, 
'filter_year' => $this->filter_year) );
 
                        $this->total_records = $this->so->total_records;
 

Modified: branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-01-29 12:22:51 UTC (rev 10725)
@@ -563,13 +563,10 @@
                        $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
 
 
+                       $filtermethod = '';
+                       $filtermethod_order = " WHERE (fm_workorder_budget.year 
= $year OR fm_workorder_status.closed IS NULL)";
+                       $filtermethod_paid = " WHERE 
(fm_orders_paid_or_pending_view.periode > {$year}00 and 
fm_orders_paid_or_pending_view.periode < {$year}13)";
 
-                       $filtermethod .= " WHERE (fm_workorder.start_date >= 
$start_date AND fm_workorder.start_date <= $end_date";
-                       $filtermethod .= " OR fm_workorder_status.closed IS 
NULL AND fm_workorder.start_date < $start_date)";
-
-                       $filtermethod = " WHERE (fm_workorder_budget.year = 
$year OR fm_workorder_status.closed IS NULL)";
-
-
                        $where = 'AND';
 
                        $cat_ids = array();
@@ -654,23 +651,50 @@
                                $_taxcode[$this->db->f('id')] = 
$this->db->f('percent');
                        }
 
-                       $sql = "SELECT fm_workorder.id, 
fm_workorder_status.closed, sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
-                               . " fm_location1.mva,fm_workorder.start_date,"
-                               . " 
fm_orders_actual_cost_view.actual_cost,pending_cost, 
fm_b_account.{$b_account_field} as {$b_account_field}, district_id, 
fm_workorder.ecodimb"
+                       $sql = "SELECT fm_workorder.id AS id, 
sum(fm_orders_paid_or_pending_view.amount) AS actual_cost,fm_location1.mva,"
+                               . " fm_b_account.{$b_account_field} as 
{$b_account_field}, district_id, fm_workorder.ecodimb"
                                . " FROM fm_workorder"
                                . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
                                . " {$this->join} fm_workorder_budget ON 
(fm_workorder.id = fm_workorder_budget.order_id)"
                                . " {$this->join} fm_b_account ON 
fm_workorder.account_id = fm_b_account.id"
                                . " {$this->join} fm_project ON  
fm_workorder.project_id = fm_project.id"
-                               . " {$this->left_join} 
fm_orders_actual_cost_view ON  fm_workorder.id = 
fm_orders_actual_cost_view.order_id"
-                               . " {$this->left_join} 
fm_orders_pending_cost_view ON  fm_workorder.id = 
fm_orders_pending_cost_view.order_id"
+                               . " {$this->left_join} 
fm_orders_paid_or_pending_view ON fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id"
                                . " {$_join_district}"
                                . " {$this->join} fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
-                               . " {$filtermethod} {$querymethod} {$where} 
{$filtermethod_direction}"
-                               . " GROUP BY fm_workorder.id, 
fm_workorder_status.closed,fm_location1.mva,fm_workorder.start_date,fm_orders_actual_cost_view.actual_cost,pending_cost,
 fm_b_account.{$b_account_field}, district_id, fm_workorder.ecodimb";
+                               . " {$filtermethod_paid}{$filtermethod} 
{$querymethod} {$where} {$filtermethod_direction}"
+                               . " GROUP BY fm_workorder.id, fm_location1.mva,"
+                               . " fm_b_account.{$b_account_field}, 
district_id, fm_workorder.ecodimb";
 
-                       //_debug_array($sql);
+//                     _debug_array($sql);
                        //die();
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $_temp_paid_info = array();
+
+                       while ($this->db->next_record())
+                       {
+                               $_id = $this->db->f('id');
+                               $_temp_paid_info[$_id] = array
+                               (
+                                       'actual_cost'                   => 
$this->db->f('actual_cost'),
+                                       'mva'                                   
=> (int)$this->db->f('mva'),
+                                       'district_id'                   => 
(int)$this->db->f('district_id'),
+                                       'ecodimb'                               
=> (int)$this->db->f('ecodimb'),
+                                       $b_account_field                => 
$this->db->f($b_account_field),
+                               );
+                       }
+
+
+                       $sql = "SELECT fm_workorder.id, 
fm_workorder_status.closed, fm_workorder.budget, 
fm_workorder.combined_cost,fm_location1.mva,fm_workorder.start_date,"
+                               . " fm_b_account.{$b_account_field} as 
{$b_account_field}, district_id, fm_workorder.ecodimb"
+                               . " FROM fm_workorder"
+                               . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
+                               . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
+                               . " {$this->join} fm_b_account ON 
fm_workorder.account_id = fm_b_account.id"
+                               . " {$this->join} fm_project ON  
fm_workorder.project_id = fm_project.id"
+                               . " {$_join_district}"
+                               . " {$this->join} fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
+                               . " {$filtermethod_order}{$filtermethod} 
{$querymethod} {$where} {$filtermethod_direction}";
+
                        $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
 
                        $sum_actual_cost = 0;
@@ -688,19 +712,19 @@
                                        $_local_combined_cost[$_id] = 
round($this->db->f('combined_cost'));
                                        $_combined_cost = 
$_local_combined_cost[$_id];
                                }
-                               unset($_id);
-                               $_pending_cost = 
round($this->db->f('pending_cost'));
 
                                $_taxfactor = 1 + 
($_taxcode[(int)$this->db->f('mva')]/100);
-                               $_actual_cost = 
round($this->db->f('actual_cost')/$_taxfactor);
-               //              $_actual_cost = 
round($this->db->f('actual_cost'));
-                               $_obligation = $_combined_cost - $_actual_cost 
- $_pending_cost;
+                               $_actual_cost = 
isset($_temp_paid_info[$_id]['actual_cost']) && 
$_temp_paid_info[$_id]['actual_cost'] ? 
round($_temp_paid_info[$_id]['actual_cost']/$_taxfactor) : 0;
+               //              $_actual_cost = 
round($_temp_paid_info[$_id]['actual_cost']);
+                               $_obligation = $_combined_cost - $_actual_cost;
 
+                               unset($_temp_paid_info[$_id]);
+                               unset($_id);
 
                                // only the current year
                                if($this->db->f('start_date') < $start_date)
                                {
-                                       $_actual_cost = 0;
+//                                     $_actual_cost = 0;
                                }
 
                                $sum_hits += 1;
@@ -738,6 +762,20 @@
                        }
 
 
+//                     _debug_array($_temp_paid_info);
+                       
+                       foreach ($_temp_paid_info as $_id => $_paid)
+                       {
+                               $accout_info[$_paid[$b_account_field]] = true;
+                               $district[$_paid['district_id']] = true;
+                               $ecodimb[$_paid['ecodimb']] = true;
+
+                               $_taxfactor = 1 + 
($_taxcode[(int)$_paid['mva']]/100);
+                               $_actual_cost =  
round($_paid['actual_cost']/$_taxfactor);
+                               $sum_actual_cost += $_actual_cost;
+                               
$actual_cost[$_paid[$b_account_field]][(int)$_paid['district_id']][(int)$_paid['ecodimb']]
 += $_actual_cost;
+                       }
+
 //                     _debug_array($obligations);
 
                        //----------- ad hoc order

Modified: branches/Version-1_0-branch/property/inc/class.soentity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2013-01-29 12:22:51 UTC (rev 10725)
@@ -266,6 +266,7 @@
                                                {
                                                        case '=':
                                                        case 'equal':
+                                                       case 'eq':
                                                                
$_querymethod[]= "xmlexists('//{$attribute_name}[text() = 
''{$condition['value']}'']' PASSING BY REF xml_representation)";
                                                                break;
                                                        case 'gt':

Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2013-01-29 12:22:51 UTC (rev 10725)
@@ -738,7 +738,7 @@
                                                . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id)"// AND 
year = '{$filter_year}')"
 //                                             . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id )"
 //                                             . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id {$sql_filter_period})"
-                                               . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id AND( periode < {$filter_year}13 OR 
periode IS NULL))"
+                                               . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id AND( periode > {$filter_year}00 AND 
periode < {$filter_year}13 OR periode IS NULL))"
 //                                             . " WHERE project_id = 
'{$project['project_id']}' {$sql_workder_date_filter} OR (project_id = 
'{$project['project_id']}' AND fm_workorder_status.closed IS NULL)"
                                                . " WHERE (project_id = 
'{$project['project_id']}' AND fm_workorder_budget.year = {$filter_year} ) OR 
(project_id = '{$project['project_id']}' AND fm_workorder_status.closed IS 
NULL)"
                                                . " GROUP BY fm_workorder.id, 
billable_hours, closed";
@@ -2580,13 +2580,26 @@
                }
 
 
-               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, $user_id = 0,$ids,$paid = false, 
$closed_orders = false, $ecodimb = 0, $transfer_budget=0)
+               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, $user_id = 0,$ids,$paid = false, 
$closed_orders = false, $ecodimb = 0, $transfer_budget=0,$new_budget = array())
                {
 
-                       if($transfer_budget)
+                       if($transfer_budget && $execute)
                        {
                                echo "<H1> Overføre budsjett for valgte 
prosjekt/bestillinger til år {$transfer_budget} </H1>";
-                               _debug_array($ids);
+
+//_debug_array($new_budget);
+
+                               foreach($new_budget as $_id => $_budget)
+                               {
+                                       if((int)$_budget['latest_year'] >= 
(int)$transfer_budget)
+                                       {
+                                               continue;
+                                       }
+_debug_array($_id);
+_debug_array($_budget);
+
+                               }
+
                                die();
                        }
 
@@ -2620,13 +2633,13 @@
                                }
                        }
 
-                       $sql_budget = "SELECT DISTINCT year, active FROM 
fm_{$type}_budget WHERE ";
+                       $sql_budget = "SELECT DISTINCT year, active, 
sum(budget) as budget FROM fm_{$type}_budget WHERE ";
 
                        switch($type)
                        {
                                case 'project':
 
-                                       $sql_budget .= 'project_id = %d ORDER 
BY year';
+                                       $sql_budget .= 'project_id = %d GROUP 
BY year, active ORDER BY year';
 
                                        if($closed_orders)
                                        {
@@ -2637,17 +2650,17 @@
                                        $status_table = 'fm_project_status';
                                        $title_field = 'fm_project.name as 
title';
                                        $this->_update_status_project($execute, 
$status_new, $ids);
-                                       $sql = "SELECT DISTINCT {$table}.id, 
$status_table.descr as status 
,{$title_field},{$table}.start_date,{$table}.project_type_id, count(project_id) 
as num_open FROM {$table}"
+                                       $sql = "SELECT DISTINCT 
{$table}.id,{$status_table}.closed, {$status_table}.descr as status 
,{$title_field},{$table}.start_date,{$table}.project_type_id, count(project_id) 
as num_open FROM {$table}"
                                        . " {$this->join} {$status_table} ON  
{$table}.status = {$status_table}.id "
                                        . " {$this->left_join} 
fm_open_workorder_view ON {$table}.id = fm_open_workorder_view.project_id "
                                        . " WHERE ({$table}.start_date > 
{$start_date} AND {$table}.start_date < {$end_date} OR {$table}.start_date IS 
NULL)  {$filter}"
-                                       . " GROUP BY {$table}.id, 
$status_table.descr ,{$table}.name, {$table}.start_date,project_type_id"
+                                       . " GROUP BY {$table}.id, 
{$status_table}.closed, {$status_table}.descr ,{$table}.name, 
{$table}.start_date,project_type_id"
                                        . " ORDER BY {$table}.id DESC";
 
                                        break;
                                case 'workorder':
 
-                                       $sql_budget .= 'order_id = %d ORDER BY 
year';
+                                       $sql_budget .= 'order_id = %d GROUP BY 
year, active ORDER BY year';
 
                                        $table = 'fm_workorder';
                                        $status_table = 'fm_workorder_status';
@@ -2664,7 +2677,8 @@
                                        }
 
                                        
$this->_update_status_workorder($execute, $status_new, $ids);
-                                       $sql = "SELECT {$table}.id, project_id, 
$status_table.descr as status ,{$title_field},{$table}.start_date 
{$actual_cost},project_type_id"
+                                       $sql = "SELECT {$table}.id, 
project_id,{$status_table}.closed, {$status_table}.descr as status 
,{$title_field},{$table}.start_date {$actual_cost},"
+                                       . " project_type_id, continuous"
                                        . " FROM {$table} {$join_method}"
                                        . " WHERE ({$table}.start_date > 
{$start_date} AND {$table}.start_date < {$end_date} {$filter}) OR 
{$table}.start_date is NULL"
                                        . " ORDER BY {$table}.id DESC";
@@ -2690,11 +2704,14 @@
                                (
                                        'id'                            => 
$this->db->f('id'),
                                        'project_id'            => 
$this->db->f('project_id'),
+                                       'closed'                        => 
$this->db->f('closed'),
                                        'title'                         => 
htmlspecialchars_decode($this->db->f('title',true)),
                                        'status'                        => 
$this->db->f('status',true),
                                        'actual_cost'           => 
(float)$this->db->f('actual_cost'),
                                        'start_date'            => 
$GLOBALS['phpgw']->common->show_date($this->db->f('start_date'),$dateformat),
                                        'num_open'                      => 
(int)$this->db->f('num_open'),
+                                       'project_type_id'       => 
$this->db->f('project_type_id'),
+                                       'continuous'            => 
$this->db->f('continuous') ? X : '',
                                        'project_type'          => 
$project_types[$this->db->f('project_type_id')],
                                );
                        }
@@ -2705,12 +2722,17 @@
                                $this->db->query($sql,__LINE__,__FILE__);
 
                                $budget = array();
+                               $_year = 0;
 
                                while ($this->db->next_record())
                                {
-                                       $budget[] = $this->db->f('year') . '[' 
. $this->db->f('active') . ']';
+                                       $_year = $this->db->f('year');
+                                       $_active = $this->db->f('active') ? X : 
0;
+                                       $_budget = 
number_format((int)$this->db->f('budget'), 0, ',', '.');
+                                       $budget[] = $_year . " [{$_active}/ 
{$_budget}]";
                                }
-                               $entry['budget'] = implode(';', $budget);
+                               $entry['budget'] = implode(' ;', $budget);
+                               $entry['latest_year'] = $_year;
                        }
 
                        return $values;

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2013-01-29 12:22:51 UTC (rev 10725)
@@ -147,6 +147,7 @@
                        $district_id    = isset($data['district_id']) ? 
$data['district_id'] : '';
                        $dry_run                = isset($data['dry_run']) ? 
$data['dry_run'] : '';
                        $criteria               = isset($data['criteria']) && 
$data['criteria'] ? $data['criteria'] : array();
+                       $filter_year    = isset($data['filter_year']) ? 
$data['filter_year'] : '';
 
                        $GLOBALS['phpgw']->config->read();
                        $sql = 
$this->bocommon->fm_cache('sql_workorder'.!!$search_vendor . '_' . 
!!$wo_hour_cat_id . '_' . !!$b_group);
@@ -343,6 +344,8 @@
 
                                $joinmethod .= " {$this->left_join} fm_vendor 
ON (fm_workorder.vendor_id = fm_vendor.id))";
                                $paranthesis .='(';
+                               $joinmethod .= " {$this->left_join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id))";
+                               $paranthesis .='(';
 
                                //----- wo_hour_status
 
@@ -613,6 +616,13 @@
 
                        }
 
+                       if ($filter_year && $filter_year != 'all')
+                       {
+                               $filter_year = (int)$filter_year;
+                               $filtermethod .= " $where 
(fm_workorder_budget.year={$filter_year})";
+                               $where= 'AND';
+                       }
+
                        $querymethod = '';
                        if($query)
                        {
@@ -777,6 +787,12 @@
                                . " GROUP BY fm_workorder.id,closed, 
fm_location1.mva";
 
 
+                               $_paid_filter = '';
+                               if ($filter_year && $filter_year != 'all')
+                               {
+                                       $_paid_filter = " AND (periode > 
{$filter_year}00 AND periode < {$filter_year}13 OR periode IS NULL)";
+                               }
+
                                $_get_accounting = false;
                                if($_get_accounting)
                                {
@@ -793,7 +809,7 @@
                                        );
 
                                        $this->db2->query('SELECT 
sum(fm_orders_paid_or_pending_view.amount) as actual_cost'
-                                       . ' FROM fm_orders_paid_or_pending_view 
WHERE order_id = '. $this->db->f('order_id'),__LINE__,__FILE__);
+                                       . ' FROM fm_orders_paid_or_pending_view 
WHERE order_id = '. $this->db->f('order_id') . $_paid_filter,__LINE__,__FILE__);
                                        $this->db2->next_record();
                                        
$_actual_cost_arr[$this->db->f('order_id')]['actual_cost'] = 
$this->db2->f('actual_cost');
                                }
@@ -801,7 +817,6 @@
                                unset($_order_list);
                                }
 
-
                        }
 
                        $this->db->query('SELECT id, percent FROM 
fm_ecomva',__LINE__,__FILE__);

Modified: branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2013-01-29 12:19:59 UTC (rev 10724)
+++ branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2013-01-29 12:22:51 UTC (rev 10725)
@@ -67,6 +67,7 @@
                                'columns'                               => true,
                                'bulk_update_status'    => true,
                                'project_group'                 => true,
+                               'view_file'                             => true
                        );
 
                function property_uiproject()
@@ -132,6 +133,16 @@
                        
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
                }
 
+               function view_file()
+               {
+                       if(!$this->acl_read)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
+                       }
+                       $bofiles        = CreateObject('property.bofiles');
+                       $bofiles->view_file('project');
+               }
+
                function columns()
                {
                        $receipt = array();
@@ -1004,7 +1015,7 @@
                                }
                        }
 
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('project','attributes_form'));
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('project','files','attributes_form'));
                        $location_id    = 
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
                        $config                         = 
CreateObject('phpgwapi.config','property');
                        $config->read();
@@ -1279,6 +1290,44 @@
                                                        $id = $receipt['id'];
                                                }
 
+                                       //----------files
+                                               $bofiles        = 
CreateObject('property.bofiles');
+                                               
if(isset($values['file_action']) && is_array($values['file_action']))
+                                               {
+                                                       
$bofiles->delete_file("/project/{$id}/", $values);
+                                               }
+
+                                               $file_name = @str_replace(' 
','_',$_FILES['file']['name']);
+
+                                               if($file_name)
+                                               {
+                                                       $to_file = 
"{$bofiles->fakebase}/project/{$id}/{$file_name}";
+
+                                                       
if($bofiles->vfs->file_exists(array(
+                                                               'string' => 
$to_file,
+                                                               'relatives' => 
Array(RELATIVE_NONE)
+                                                       )))
+                                                       {
+                                                               
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+                                                       }
+                                                       else
+                                                       {
+                                                               
$bofiles->create_document_dir("project/$id");
+                                                               
$bofiles->vfs->override_acl = 1;
+       
+                                                               
if(!$bofiles->vfs->cp (array (
+                                                                       'from'  
=> $_FILES['file']['tmp_name'],
+                                                                       'to'    
=> $to_file,
+                                                                       
'relatives'     => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                                                               {
+                                                                       
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+                                                               }
+                                                               
$bofiles->vfs->override_acl = 0;
+                                                       }
+                                               }
+                                       //-----------
+
+
                                                if ( 
isset($GLOBALS['phpgw_info']['server']['smtp_server'])
                                                        && 
$GLOBALS['phpgw_info']['server']['smtp_server'] )
        //                                              && 
$config->config_data['project_approval'] )
@@ -1956,6 +2005,57 @@
 
 
 
+//--------------files
+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
'property.uiproject.view_file',
+                               'id'            => $id
+                       );
+
+                       $link_to_files 
=(isset($config->config_data['files_url'])?$config->config_data['files_url']:'');
+
+                       $link_view_file = 
$GLOBALS['phpgw']->link('/index.php',$link_file_data);
+
+                       $_files = $this->bo->get_files($id);
+                       
+                       $lang_view_file = lang('click to view file');
+                       $lang_delete_file = lang('Check to delete file');
+                       $z=0;
+                       $content_files = array();
+                       foreach( $_files as $_file )
+                       {
+                               if ($link_to_files)
+                               {
+                                       $content_files[$z]['file_name'] = "<a 
href='{$link_to_files}/{$_file['directory']}/{$_file['file_name']}' 
target=\"_blank\" title='{$lang_view_file}'>{$_file['name']}</a>";
+                               }
+                               else
+                               {
+                                       $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_name={$_file['file_name']}\" 
target=\"_blank\" title=\"{$lang_view_file}\">{$_file['name']}</a>";
+                               }
+                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['name']}\" 
title=\"{$lang_delete_file}\">";
+                               $z++;
+                       }                                                       
                
+
+                       $datavalues[5] = array
+                       (
+                               'name'                                  => "5",
+                               'values'                                => 
json_encode($content_files),
+                               'total_records'                 => 
count($content_files),
+                               'edit_action'                   => "''",
+                               'is_paginator'                  => 0,
+                               'footer'                                => 0
+                       );
+
+                       $myColumnDefs[5] = array
+                               (
+                                       'name'          => "5",
+                                       'values'        =>      
json_encode(array(      array('key' => 
'file_name','label'=>lang('Filename'),'sortable'=>false,'resizeable'=>true),
+                                       array('key' => 
'delete_file','label'=>lang('Delete 
file'),'sortable'=>false,'resizeable'=>true)))
+                               );
+
+//--------------files
+
+
 //     _debug_array($myButtons);die();
                        
//----------------------------------------------datatable settings--------
 
@@ -2005,7 +2105,7 @@
                                        'origin_id'             => $id
                                );
                        }
-
+                       $selected_tab = phpgw::get_var('tab', 'string', 
'REQUEST', 'general');

@@ Diff output truncated at 153600 characters. @@



reply via email to

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