fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8597]


From: Torstein
Subject: [Fmsystem-commits] [8597]
Date: Tue, 17 Jan 2012 13:20:45 +0000

Revision: 8597
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8597
Author:   vator
Date:     2012-01-17 13:20:45 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socase.inc.php
    trunk/controller/inc/class.socheck_item.inc.php
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.socontrol_item.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/class.uicase.inc.php
    trunk/controller/inc/class.uicheck_list.inc.php
    trunk/controller/inc/class.uicheck_list_for_location.inc.php
    trunk/controller/inc/component/class.calendar_builder.inc.php
    trunk/controller/inc/component/class.date_generator.inc.php
    trunk/controller/inc/helper/class.location_finder.inc.php
    trunk/controller/inc/helper/class.status_checker.inc.php
    trunk/controller/inc/model/class.check_list.inc.php
    trunk/controller/templates/base/calendar/view_calendar_year.xsl
    trunk/controller/templates/base/check_list/edit_check_list.xsl
    trunk/controller/templates/base/check_list/register_case.xsl
    trunk/controller/templates/base/check_list/view_measurements.xsl

Modified: trunk/controller/inc/class.socase.inc.php
===================================================================
--- trunk/controller/inc/class.socase.inc.php   2012-01-17 13:02:52 UTC (rev 
8596)
+++ trunk/controller/inc/class.socase.inc.php   2012-01-17 13:20:45 UTC (rev 
8597)
@@ -125,7 +125,7 @@
 
                        $values = array(
                                $this->marshal($case->get_check_item_id(), 
'int'),
-                               $this->marshal($case->get_status(), 'int'),
+                               $case->get_status(),
                                $this->marshal($case->get_location_id(), 'int'),
                                $this->marshal($case->get_location_item_id(), 
'int'),
                                $this->marshal($case->get_descr(), 'string'),
@@ -143,10 +143,10 @@
                function update($case)
                {
                        $id = $case->get_id();
-
+                       
                        $values = array(
                                'check_item_id = ' . 
$this->marshal($case->get_check_item_id(), 'int'),
-                               'status = ' . $case->get_status(),
+                               'status = ' . 
$this->marshal($case->get_status(), 'int'),
                                'location_id = ' . 
$this->marshal($case->get_location_id(), 'int'),
                                'location_item_id = ' . 
$this->marshal($case->get_location_item_id(), 'int'),
                                'descr = ' . $this->marshal($case->get_descr(), 
'string'),

Modified: trunk/controller/inc/class.socheck_item.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_item.inc.php     2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.socheck_item.inc.php     2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -135,7 +135,7 @@
                        }
                }
                
-               public function get_single_with_cases($check_item_id, 
$returnType = "return_object"){
+               public function get_single_with_cases($check_item_id, 
$return_type = "return_object"){
                        $sql  = "SELECT ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment, ci.measurement, check_list_id, ";
                        $sql .= "cic.id as cic_id, cic.status as cic_status, 
cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
@@ -167,7 +167,7 @@
                                        
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
                                
-                                       if($returnType == "return_array")
+                                       if($return_type == "return_array")
                                                
$check_item->set_control_item($control_item->toArray());
                                        else
                                                
$check_item->set_control_item($control_item);
@@ -188,7 +188,7 @@
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
                                
                                
-                                       if($returnType == "return_array")
+                                       if($return_type == "return_array")
                                                $cases_array[] = 
$case->toArray();
                                        else
                                                $cases_array[] = $case;
@@ -201,7 +201,7 @@
                        if($check_item != null){
                                $check_item->set_cases_array($cases_array);
                                
-                               if($returnType == "return_array")
+                               if($return_type == "return_array")
                                        return $check_item->toArray();
                                else
                                        return $check_item;
@@ -244,7 +244,7 @@
                        }
                }
                
-               public function get_check_items($check_list_id, $status, $type){
+               public function get_check_items($check_list_id, $status, $type, 
$return_type = "return_object"){
                        $sql  = "SELECT ci.id as ci_id, ci.status, 
control_item_id, ci.comment, ci.measurement, check_list_id, "; 
                        $sql .= "coi.id as coi_id, coi.title, coi.required, 
coi.what_to_do, coi.how_to_do, coi.control_group_id, coi.type "; 
                        $sql .= "FROM controller_check_item ci "; 
@@ -277,16 +277,22 @@
                                
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
                                $control_item->set_type($this->db->f('type', 
true), 'string');
                                
-                               
$check_item->set_control_item($control_item->toArray());
-                               
-                               $check_items_array[] = $check_item->toArray();
+                               if($return_type == "return_array"){
+                                       
$check_item->set_control_item($control_item->toArray());
+                                       $check_items_array[] = 
$check_item->toArray();
+                               }
+                               else{
+                                       
$check_item->set_control_item($control_item);
+                                       $check_items_array[] = $check_item;
+                               }
                        }
                        
                        return $check_items_array;
                }
                
-               public function get_check_items_with_cases($check_list_id, 
$status = "open", $messageStatus = null, $returnType = "return_object"){
-                       $sql  = "SELECT ci.id as ci_id, ci.status, 
control_item_id, ci.comment, ci.measurement, check_list_id, cic.id as cic_id, 
cic.*, ";
+               public function get_check_items_with_cases($check_list_id, 
$status = "open", $messageStatus = null, $return_type = "return_object"){
+                       $sql  = "SELECT ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment, ci.measurement, check_list_id, ";
+                       $sql .= "cic.id as cic_id, cic.status as cic_status, 
cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
                        $sql .= "FROM controller_check_item ci "; 
                        $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
@@ -314,7 +320,7 @@
                                        if($check_item_id != 0){
                                                
$check_item->set_cases_array($cases_array);
                                                
-                                               if($returnType == 
"return_array")
+                                               if($return_type == 
"return_array")
                                                        $check_items_array[] = 
$check_item->toArray();
                                                else
                                                        $check_items_array[] = 
$check_item;
@@ -322,7 +328,7 @@
                                
                                        $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
                                        
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
-                                       
$check_item->set_status($this->unmarshal($this->db->f('status', true), 'bool'));
+                                       
$check_item->set_status($this->db->f('ci_status', true), 'int');
                                        
$check_item->set_comment($this->unmarshal($this->db->f('comment', true), 
'string'));
                                        
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
                                        
$check_item->set_measurement($this->unmarshal($this->db->f('measurement', 
true), 'int'));
@@ -335,14 +341,18 @@
                                        
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
                                
-                                       
$check_item->set_control_item($control_item->toArray());
-                                                                       
+                                       if($return_type == "return_array")
+                                               
$check_item->set_control_item($control_item->toArray());
+                                       else
+                                               
$check_item->set_control_item($control_item);
+                                                       
                                        $cases_array = array();
                                }
                                
                                if($this->db->f('cic_id', true) != ''){
                                        $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id', true), 
'int'));
                                        
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id', true), 
'int'));
+                                       
$case->set_status($this->unmarshal($this->db->f('cic_status', true), 'int'));
                                        
$case->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
                                        
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id', 
true), 'int'));
                                        
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
@@ -352,19 +362,19 @@
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
                                
                                
-                                       if($returnType == "return_array")
+                                       if($return_type == "return_array")
                                                $cases_array[] = 
$case->toArray();
                                        else
                                                $cases_array[] = $case;
                                }
                                
-                               $check_item_id =  $check_item->get_id();
+                               $check_item_id = $check_item->get_id();
                        }
                        
                        if($check_item != null){
                                $check_item->set_cases_array($cases_array);
                                
-                               if($returnType == "return_array")
+                               if($return_type == "return_array")
                                        $check_items_array[] = 
$check_item->toArray();
                                else
                                        $check_items_array[] = $check_item;
@@ -375,7 +385,7 @@
                        }
                }
                
-               public function 
get_check_items_with_cases_by_message($message_ticket_id, $returnType = 
"return_object"){
+               public function 
get_check_items_with_cases_by_message($message_ticket_id, $return_type = 
"return_object"){
                        $sql  = "SELECT ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment, ci.measurement, "; 
                        $sql .= "check_list_id, cic.id as cic_id, cic.status as 
cic_status, cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
@@ -395,7 +405,7 @@
                                        if($check_item_id != 0){
                                                
$check_item->set_cases_array($cases_array);
                                                
-                                               if($returnType == 
"return_array")
+                                               if($return_type == 
"return_array")
                                                        $check_items_array[] = 
$check_item->toArray();
                                                else
                                                        $check_items_array[] = 
$check_item;
@@ -416,7 +426,7 @@
                                        
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
                                
-                                       if($returnType == "return_array")
+                                       if($return_type == "return_array")
                                                
$check_item->set_control_item($control_item->toArray());
                                        else
                                                
$check_item->set_control_item($control_item);
@@ -437,7 +447,7 @@
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
                                
                                
-                                       if($returnType == "return_array")
+                                       if($return_type == "return_array")
                                                $cases_array[] = 
$case->toArray();
                                        else
                                                $cases_array[] = $case;
@@ -449,7 +459,7 @@
                        if($check_item != null){
                                $check_item->set_cases_array($cases_array);
                                
-                               if($returnType == "return_array")
+                               if($return_type == "return_array")
                                        $check_items_array[] = 
$check_item->toArray();
                                else
                                        $check_items_array[] = $check_item;
@@ -460,7 +470,7 @@
                        }
                }
                
-               public function get_check_items_by_message($message_ticket_id, 
$returnType = "return_array" ){
+               public function get_check_items_by_message($message_ticket_id, 
$return_type = "return_array" ){
                        $sql  = "SELECT ci.* "; 
                        $sql .= "FROM controller_check_item ci "; 
                        $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
@@ -476,7 +486,7 @@
                                
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
                                
$check_item->set_measurement($this->unmarshal($this->db->f('measurement', 
true), 'int'));
                                
-                               if($returnType == "return_array")
+                               if($return_type == "return_array")
                                        $check_items_array[] = 
$check_item->toArray();
                                else
                                        $check_items_array[] = $check_item;

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.socheck_list.inc.php     2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -27,6 +27,7 @@
        * @subpackage controller
        * @version $Id$
        */
+
 phpgw::import_class('controller.socommon');
 
 include_class('controller', 'check_list', 'inc/model/');
@@ -52,7 +53,7 @@
        
        public function get_single($check_list_id){
                $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.control_id, cl.comment as cl_comment, deadline, planned_date, "; 
-               $sql .= "completed_date, location_code, ci.id as ci_id, 
ci.status as ci_status, control_item_id, "; 
+               $sql .= "completed_date, location_code, component_id, 
num_open_cases, ci.id as ci_id, ci.status as ci_status, control_item_id, "; 
                $sql .= "ci.comment as ci_comment, check_list_id "; 
                $sql .= "FROM controller_check_list cl ";
                $sql .= "LEFT JOIN controller_check_item as ci ON cl.id = 
ci.check_list_id ";
@@ -72,7 +73,9 @@
                                
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
                                
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
                                
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int'));
-                               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));   
+                               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+                               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id', 
true), 'int'));
+                               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int')); 
                        }
                        
                        $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
@@ -257,7 +260,7 @@
                }
        }
        
-       function get_agg_check_lists_for_location( $location_code, $from_date, 
$to_date ){
+       function get_agg_check_lists_for_location( $location_code, 
$from_date_ts, $to_date_ts ){
                
                $sql =  "SELECT c.id as c_id, title, start_date, end_date, 
cl.id as cl_id, c.repeat_type, c.repeat_interval, cl.deadline, count(ci.id) ";
                $sql .= "FROM controller_check_list cl, controller_control c, 
controller_check_item ci ";
@@ -266,7 +269,7 @@
                $sql .= "AND cl.control_id = c.id ";
                $sql .= "AND cl.id = ci.check_list_id ";
                $sql .= "AND ci.status = 0 ";
-               $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
+               $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "GROUP BY c.id, title, start_date, end_date, cl.id, 
cl.deadline, c.repeat_type, c.repeat_interval ";
                $sql .= "ORDER BY c.id";
 
@@ -311,7 +314,32 @@
                }       
        }
        
-       function get_check_lists_for_location( $location_code, $from_date, 
$to_date, $repeat_type ){
+       function get_num_open_cases_for_control( $control_id, $location_code, 
$from_date_ts, $to_date_ts ){
+               
+               $sql =  "SELECT c.id as c_id, sum(cl.num_open_cases) as count ";
+               $sql .= "FROM controller_check_list cl, controller_control c ";
+               $sql .= "WHERE cl.location_code = $location_code ";
+               $sql .= "AND c.id = $control_id ";
+               $sql .= "AND c.repeat_type < 2 ";
+               $sql .= "AND cl.control_id = c.id ";
+               $sql .= "AND cl.deadline >= $from_date_ts AND $to_date_ts > 
cl.deadline ";
+               $sql .= "GROUP BY c.id";
+                       
+               $this->db->query($sql);
+               
+               if ($this->db->next_record() & $this->db->f('count', true) > 0) 
{
+
+                       $control_array = array(
+                                                                       "id"    
=> $this->unmarshal($this->db->f('c_id', true), 'int'),
+                                                                       "count" 
=> $this->db->f('count', true)
+                                                               );
+               }
+               
+               
+               return $control_array;
+       }
+       
+       function get_check_lists_for_location( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type ){
                $sql =  "SELECT c.id as c_id, title, description, start_date, 
end_date, control_area_id, c.location_code as c_location_code, repeat_type, 
repeat_interval, ";
                $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";
                $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
@@ -319,7 +347,7 @@
                $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
                $sql .= "WHERE cl.location_code = $location_code ";
                $sql .= "AND c.repeat_type = $repeat_type ";
-               $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
+               $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "ORDER BY c.id;";
 
                $this->db->query($sql);
@@ -372,7 +400,7 @@
                return $controls_array;
        }
        
-       function get_check_lists_for_location_2( $location_code, $from_date, 
$to_date, $repeat_type ){
+       function get_check_lists_for_location_2( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type ){
                $sql =  "SELECT c.id as c_id, ";
                $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";
                $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
@@ -380,7 +408,7 @@
                $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
                $sql .= "WHERE cl.location_code = $location_code ";
                $sql .= "AND c.repeat_type = $repeat_type ";
-               $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
+               $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "ORDER BY c.id;";
 
                $this->db->query($sql);
@@ -531,17 +559,20 @@
                                'planned_date',
                                'completed_date',
                                'location_code',
+                               'component_id',
+                               'num_open_cases'
                );
                
                $values = array(
                        $this->marshal($check_list->get_control_id(), 'int'),
-                       $this->marshal($check_list->get_status(), 'bool'),
+                       $this->marshal($check_list->get_status(), 'int'),
                        $this->marshal($check_list->get_comment(), 'string'),
                        $this->marshal($check_list->get_deadline(), 'int'),
                        $this->marshal($check_list->get_planned_date(), 'int'),
                        $this->marshal($check_list->get_completed_date(), 
'int'),
                        $this->marshal($check_list->get_location_code(), 'int'),
-//                     $this->marshal($check_list->get_equipment_id(), 'int')
+                       $this->marshal($check_list->get_component_id(), 'int'),
+                       $this->marshal($check_list->get_num_open_cases(), 'int')
                );
                
                $result = $this->db->query('INSERT INTO controller_check_list 
(' . join(',', $cols) . ') VALUES (' . join(',', $values) . ')', 
__LINE__,__FILE__);
@@ -562,6 +593,7 @@
                        'completed_date = ' . 
$this->marshal($check_list->get_completed_date(), 'int'),
                        'location_code = ' . 
$this->marshal($check_list->get_location_code(), 'int'),
                        'component_id = ' . 
$this->marshal($check_list->get_component_id(), 'int'),
+                       'num_open_cases = ' . 
$this->marshal($check_list->get_num_open_cases(), 'int')
                );
 
                $result = $this->db->query('UPDATE controller_check_list SET ' 
. join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -119,7 +119,10 @@
                        $sql  = "SELECT distinct c.* FROM 
controller_control_location_list cll "; 
                        $sql .= "LEFT JOIN controller_control c on 
cll.control_id=c.id ";
                        $sql .= "WHERE cll.location_code = $location_code ";
-                       $sql .= "AND c.repeat_type = $repeat_type ";
+                       
+                       if( is_numeric($repeat_type) )
+                               $sql .= "AND c.repeat_type = $repeat_type ";
+                       
                        $sql .= "AND (c.start_date <= $from_date AND c.end_date 
IS NULL ";
                        $sql .= "OR c.start_date > $from_date AND c.start_date 
< $to_date)";
                        

Modified: trunk/controller/inc/class.socontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item.inc.php   2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.socontrol_item.inc.php   2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -309,12 +309,14 @@
                        return $results;
                }
 
-               function get_control_items_by_control($control_id, $returnType 
= "object")
+               function get_control_items_by_control($control_id, $returnType 
= "return_object")
                {
                        $results = array();
 
-                       $sql  = "SELECT ci.* FROM controller_control_item ci, 
controller_control_item_list cl ";
-                       $sql .= "WHERE cl.control_id=$control_id AND 
cl.control_item_id=ci.id";
+                       $sql  = "SELECT ci.* ";
+                       $sql .= "FROM controller_control_item ci, 
controller_control_item_list cl ";
+                       $sql .= "WHERE cl.control_id=$control_id AND 
cl.control_item_id = ci.id ";
+                                                                       
                        $this->db->query($sql);
 
                        while ($this->db->next_record()) {
@@ -326,7 +328,7 @@
                                
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
                                
$control_item->set_type($this->unmarshal($this->db->f('type', true), 'string'));
 
-                               if($returnType == "array")
+                               if($returnType == "return_array")
                                        $results[] = $control_item->toArray();
                                else
                                        $results[] = $control_item;

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -85,15 +85,22 @@
                        $year = intval( $year );
                        $from_month = intval( $month );
                                
-                       $from_date = strtotime("$from_month/01/$year");
-                       $to_month = $from_month + 1;
-                       $to_date = strtotime("$to_month/01/$year+1");
-                                                                       
+                       $from_date_ts = strtotime("$from_month/01/$year");
+                       
+                       if(($from_month + 1) > 12){
+                               $to_month = 1;
+                               $year++;
+                       }else{
+                               $to_month = $from_month + 1;
+                       }
+                       
+                       $to_date_ts = strtotime("$to_month/01/$year");
+                                                                               
                
                        if(empty($location_code)){
                                $location_code = "1101";        
                        }
                        
-                       $this->calendar_builder = new 
calendar_builder($from_date, $to_date);
+                       $this->calendar_builder = new 
calendar_builder($from_date_ts, $to_date_ts);
                        
                        $repeat_type = 0;
 
@@ -107,14 +114,14 @@
                
                        $location_finder = new location_finder();
                        $locations = $location_finder->get_responsibilities( 
$criteria );
-                                       
-                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date, 
$to_date, $repeat_type);
+                       
+                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type);
                
-                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location_2($location_code, $from_date, $to_date, 
$repeat_type);
+                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location_2($location_code, $from_date_ts, 
$to_date_ts, $repeat_type);
                        
                        $controls_with_check_list = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
                        
-                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $controls_with_check_list, null, 
31, "view_days" );
+                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $controls_with_check_list, 31, 
"view_days" );
 
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                        
@@ -160,25 +167,73 @@
                        $year = phpgw::get_var('year');
                        
                        $year = intval($year);
-                       
-                       $from_date = strtotime("01/01/$year");
+                                               
+                       $from_date_ts = strtotime("01/01/$year");
                        $to_year = $year + 1;
-                       $to_date = strtotime("01/01/$to_year"); 
+                       $to_date_ts = strtotime("01/01/$to_year");      
                                                
                        if(empty($location_code)){
                                $location_code = "1101";        
                        }
                        
-                       $this->calendar_builder = new 
calendar_builder($from_date, $to_date);
+                       $criteria = array
+                       (
+                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
+                               'type_id' => 2,
+                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows' => false
+                       );
+               
+                       $location_finder = new location_finder();
+                       $locations = $location_finder->get_responsibilities( 
$criteria );
+print_r($locations);
+                       $repeat_type = null;
+                       
+                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type );
 
-                       // Gets an array of controls that contains check_lists 
for the specified location
-                       $agg_check_list_array = 
$this->so->get_agg_check_lists_for_location( $location_code, $from_date, 
$to_date );
-                       $controls_calendar_array = 
$this->calendar_builder->build_agg_calendar_array( $agg_check_list_array );
+                       $this->calendar_builder = new 
calendar_builder($from_date_ts, $to_date_ts);
+
+                       foreach($controls_for_location_array as $control){
+                               
+                               if($control->get_repeat_type() == 0){
+
+                                       $twelve_month_array = array();
+                                       
+                                       $cal_to_year = $year;
+                                       
+                                       
for($from_month=1;$from_month<=12;$from_month++){
+
+                                               $from_date_ts = 
strtotime("$from_month/01/$cal_to_year");
+                                               
+                                               if(($from_month + 1) > 12)
+                                               {
+                                                       $to_month = 1;
+                                                       $cal_to_year = $year + 
1;
+                                               }
+                                               else
+                                               {
+                                                       $to_month = $from_month 
+ 1;
+                                               }
+                                               
+                                               $to_date_ts = 
strtotime("$to_month/01/$cal_to_year");
+                                               
+                                               
$num_open_cases_for_control_array = array();
+                                               
$num_open_cases_for_control_array = $this->so->get_num_open_cases_for_control( 
$control->get_id(), $location_code, $from_date_ts, $to_date_ts );        
+
+                                               
$twelve_month_array[$from_month-1] = $num_open_cases_for_control_array;
+                                       }
+                               
+                                       $days_controls_calendar_array = 
$this->calendar_builder->build_agg_calendar_array( $agg_check_list_array );
+                               }
+                       }
+
+                       $repeat_type = 2;
+                       $control_check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type );
                        
-                       $repeat_type = 2;
-                       $control_check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type );
-                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $control_check_list_array, 
$controls_calendar_array, 12, "view_months" );
+                       $month_controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $control_check_list_array, 12, 
"view_months" );
                                        
+                       $controls_calendar_array = 
array_merge($days_controls_calendar_array, $month_controls_calendar_array);
+                       
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                        
                        $heading_array = array("Jan", "Feb", "Mar", "Apr", 
"Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des");

Modified: trunk/controller/inc/class.uicase.inc.php
===================================================================
--- trunk/controller/inc/class.uicase.inc.php   2012-01-17 13:02:52 UTC (rev 
8596)
+++ trunk/controller/inc/class.uicase.inc.php   2012-01-17 13:20:45 UTC (rev 
8597)
@@ -36,6 +36,7 @@
        phpgw::import_class('controller.socontrol');
        
        include_class('controller', 'check_item_case', 'inc/model/');
+       include_class('controller', 'status_checker', 'inc/helper/');
                        
        class controller_uicase extends controller_uicommon
        {
@@ -65,7 +66,7 @@
                        $check_list_id = phpgw::get_var('check_list_id');
                        $control_item_id = phpgw::get_var('control_item_id');
                        $case_descr = phpgw::get_var('case_descr');
-                                               
+                                                                               
        
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                                                
                        $control_id = $check_list->get_control_id();
@@ -76,11 +77,11 @@
                        $todays_date = mktime(0,0,0,date("m"), date("d"), 
date("Y"));
 
                        $user_id = $GLOBALS['phpgw_info']['user']['id'];
-                       $status = 0;
+                       $case_status = 0;
                        
                        $case = new controller_check_item_case();
                        $case->set_check_item_id( $check_item->get_id() );
-                       $case->set_status($status);
+                       $case->set_status($case_status);
                        $case->set_descr($case_descr);
                        $case->set_location_id($location_id);
                        $case->set_user_id($user_id);
@@ -90,8 +91,12 @@
                                
                        $case_id = $this->so->store($case);
                        
-                       if($case_id > 0)
+                       if($case_id > 0){
+                               $status_checker = new status_checker();
+                               $status_checker->update_check_list_status( 
$check_list_id );
+                                               
                                return json_encode( array( "saveStatus" => 
"saved" ) );
+                       }
                        else
                                return json_encode( array( "saveStatus" => 
"not_saved" ) );     
                        

Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php     2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/class.uicheck_list.inc.php     2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -33,6 +33,7 @@
 
        include_class('controller', 'check_list', 'inc/model/');
        include_class('controller', 'check_item', 'inc/model/');
+       include_class('controller', 'status_checker', 'inc/helper/');
 
        class controller_uicheck_list extends controller_uicommon
        {
@@ -86,15 +87,6 @@
 
                public function index()
                {
-/*                     $check_list_array = $this->so->get_check_list();
-
-                       $data = array
-                       (
-                               'check_list_array'      => $check_list_array
-                       );
-
-                       self::render_template_xsl('control_check_lists', $data);
-                       */
                        if(phpgw::get_var('phpgw_return_as') == 'json') {
                                return $this->query();
                        }
@@ -379,15 +371,29 @@
                        $location_code = $check_list->get_location_code();
                                
                        // Fetches all control items for check list
-                       $control_items_for_check_list = 
$this->so_control_item->get_control_items_by_control($check_list->get_control_id(),
 "array");
-               
+                       $control_items_for_check_list = array();
+                       
+                       $open_type_1_check_items = 
$this->so_check_item->get_check_items($check_list_id, null, 
"control_item_type_1", "return_object");                 
+                       
+                       foreach($open_type_1_check_items as $check_item){
+                               $control_items_for_check_list[] = 
$check_item->get_control_item()->toArray();
+                       }
+
+                       $open_type_2_check_items = 
$this->so_check_item->get_check_items($check_list_id, "open", 
"control_item_type_2", "return_object");
+                       foreach($open_type_2_check_items as $check_item){
+                               $control_items_for_check_list[] = 
$check_item->get_control_item()->toArray();
+                       }
+                       
                        $data = array
                        (
                                'control_items_for_check_list'  => 
$control_items_for_check_list,
-                               'check_list'    => $check_list->toArray()
+                               'check_list'                                    
=> $check_list->toArray()
                        );
                        
                        
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'check_list/register_case'), $data);
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('controller', 'controller', 
'custom_ui.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
                }
                
                function view_open_cases(){
@@ -428,12 +434,12 @@
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                                                
                        // Fetches check items that registeres measurement
-                       $measurement_check_items = 
$this->so_check_item->get_check_items($check_list_id, null, 
'control_item_type_2');
-                                               
+                       $measurement_check_items = 
$this->so_check_item->get_check_items($check_list_id, null, 
'control_item_type_2', "return_array");
+                       
                        $data = array
                        (
-                               'measurement_check_items'               => 
$measurement_check_items,
-                               'check_list'    => $check_list->toArray()
+                               'measurement_check_items'       => 
$measurement_check_items,
+                               'check_list'                            => 
$check_list->toArray()
                        );
                        
                        self::render_template_xsl( 
array('check_list/cases_tab_menu', 'check_list/view_measurements'), $data );
@@ -524,8 +530,12 @@
                        
                        $check_item_id = $this->so_check_item->store( 
$check_item );
 
-                       if($check_item_id > 0)
+                       if($check_item_id > 0){
+                               $status_checker = new status_checker();
+                               $status_checker->update_check_list_status( 
$check_item->get_check_list_id() );
+                               
                                return json_encode( array( "saveStatus" => 
"saved" ) );
+                       }
                        else
                                return json_encode( array( "status" => 
"not_saved" ) );
                }

Modified: trunk/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2012-01-17 13:20:45 UTC (rev 8597)
@@ -34,6 +34,7 @@
        
        include_class('controller', 'check_list', 'inc/model/');
        include_class('controller', 'date_generator', 'inc/component/');
+       include_class('controller', 'status_checker', 'inc/helper/');
                
        class controller_uicheck_list_for_location extends controller_uicommon
        {
@@ -362,7 +363,7 @@
                        
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
                        
-                       
self::render_template_xsl(array('add_check_list_for_location'), $data);
+                       
self::render_template_xsl('check_list/add_check_list_for_location', $data);
                }
                
                function edit_check_list(){
@@ -374,7 +375,7 @@
                        $location_code = $check_list->get_location_code();
        
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-                       
+                                               
                        $data = array
                        (
                                'check_list'                                    
=> $check_list->toArray(),

Modified: trunk/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-01-17 13:20:45 UTC (rev 8597)
@@ -12,40 +12,11 @@
         $this->period_end_date = $period_end_date;
        }
        
-       public function build_calendar_array( $control_array, 
$controls_calendar_array, $num, $period_type ){
+       public function build_calendar_array( $control_array, $num, 
$period_type ){
                
                foreach($control_array as $control){
-                                               
-                       // Initialises twelve_months_array
-                       for($i=1;$i<=$num;$i++){
-                               $calendar_array[$i] = null;
-                       }
 
-                       $date_generator = new 
date_generator($control->get_start_date(), $control->get_end_date(), 
$this->period_start_date, $this->period_end_date, $control->get_repeat_type(), 
$control->get_repeat_interval());
-                       $dates_array = $date_generator->get_dates();
-               
-                       // Inserts dates on behalf of repeat type and repeat 
interval
-                       foreach($dates_array as $date){
-                               
-                               $todays_date = mktime(0,0,0,date("m"), 
date("d"), date("Y"));
-                               
-                               if($date < $todays_date){
-                                       $status = "control_not_accomplished";
-                               }else{
-                                       $status = "control_registered";
-                               }
-                               
-                               if( $period_type == "view_months" )
-                               {
-                                       $calendar_array[ date("n", $date) 
]["status"]  = $status;
-                                       $calendar_array[ date("n", $date) 
]["info"]  = array("date" => $date, "control_id" => $control->get_id());
-                               }
-                               else if( $period_type == "view_days" )
-                               {
-                                       $calendar_array[ date("j", $date) 
]["status"]  = $status;
-                                       $calendar_array[ date("j", $date) 
]["info"]  = array("date" => $date, "control_id" => $control->get_id());      
-                               }
-                       }
+                       $calendar_array = $this->init_calendar( $control, 
$calendar_array, $num, $period_type );
                        
                        // Inserts check_list object on deadline month in 
twelve_months_array
                        foreach($control->get_check_lists_array() as 
$check_list){
@@ -68,15 +39,15 @@
                                {
                                        $status = "control_not_accomplished";
                                }
-                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() > $check_list->get_deadline() )
+                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() > $check_list->get_deadline() & 
$check_list->get_num_open_cases() == 0)
                                {
                                        $status = 
"control_accomplished_over_time_without_errors";
                                }
-                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() < $check_list->get_deadline() )
+                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() < $check_list->get_deadline() & 
$check_list->get_num_open_cases() == 0)
                                {
                                        $status = 
"control_accomplished_in_time_without_errors";
                                }
-                               else if( $check_list->get_status() == 2  ){
+                               else if( $check_list->get_status() == 1 & 
$check_list->get_num_open_cases() > 0){
                                        $status = 
"control_accomplished_with_errors";
                                        
$check_list_status_info->set_num_open_cases($check_list->get_num_open_cases());
                                }
@@ -135,4 +106,40 @@
 
                return $control_calendar_array;
        }
+       
+       function init_calendar( $control, $calendar_array, $num, $period_type ){
+               
+               // Initialises twelve_months_array
+               for($i=1;$i<=$num;$i++){
+                       $calendar_array[$i] = null;
+               }
+               
+               $date_generator = new 
date_generator($control->get_start_date(), $control->get_end_date(), 
$this->period_start_date, $this->period_end_date, $control->get_repeat_type(), 
$control->get_repeat_interval());
+               $dates_array = $date_generator->get_dates();
+       
+               // Inserts dates on behalf of repeat type and repeat interval
+               foreach($dates_array as $date){
+                       
+                       $todays_date = mktime(0,0,0,date("m"), date("d"), 
date("Y"));
+                       
+                       if($date < $todays_date){
+                               $status = "control_not_accomplished";
+                       }else{
+                               $status = "control_registered";
+                       }
+                       
+                       if( $period_type == "view_months" )
+                       {
+                               $calendar_array[ date("n", $date) ]["status"]  
= $status;
+                               $calendar_array[ date("n", $date) ]["info"]  = 
array("date" => $date, "control_id" => $control->get_id());
+                       }
+                       else if( $period_type == "view_days" )
+                       {
+                               $calendar_array[ date("j", $date) ]["status"]  
= $status;
+                               $calendar_array[ date("j", $date) ]["info"]  = 
array("date" => $date, "control_id" => $control->get_id());      
+                       }
+               }
+               
+               return $calendar_array;
+       } 
 }
\ No newline at end of file

Modified: trunk/controller/inc/component/class.date_generator.inc.php
===================================================================
--- trunk/controller/inc/component/class.date_generator.inc.php 2012-01-17 
13:02:52 UTC (rev 8596)
+++ trunk/controller/inc/component/class.date_generator.inc.php 2012-01-17 
13:20:45 UTC (rev 8597)
@@ -30,7 +30,7 @@
        
                $interval_date = $period_start_date;
                
-               while($interval_date <= $this->period_end_date){
+               while($interval_date < $this->period_end_date){
                        
                        $this->calendar_array[] = $interval_date; 
                                                

Modified: trunk/controller/inc/helper/class.location_finder.inc.php
===================================================================
--- trunk/controller/inc/helper/class.location_finder.inc.php   2012-01-17 
13:02:52 UTC (rev 8596)
+++ trunk/controller/inc/helper/class.location_finder.inc.php   2012-01-17 
13:20:45 UTC (rev 8597)
@@ -43,6 +43,7 @@
                {
                        $data['filter_role_on_contact'] = 
$GLOBALS['phpgw']->accounts->get($data['user_id'])->person_id;
                        $locations = $this->so->read($data);
+                       
                        $total_records = $this->so->total_records;
                        
                        return $locations;

Modified: trunk/controller/inc/helper/class.status_checker.inc.php
===================================================================
--- trunk/controller/inc/helper/class.status_checker.inc.php    2012-01-17 
13:02:52 UTC (rev 8596)
+++ trunk/controller/inc/helper/class.status_checker.inc.php    2012-01-17 
13:20:45 UTC (rev 8597)
@@ -1,138 +1,42 @@
 <?php
-
-include_class('controller', 'date_generator', 'inc/component/');
-
-class calendar_builder {
+       phpgw::import_class('controller.socheck_list');
+       phpgw::import_class('controller.socheck_item');
        
-       private $period_start_date;
-       private $period_end_date;
+       include_class('controller', 'check_list', 'inc/model/');
+       include_class('controller', 'check_item', 'inc/model/');
 
-       public function __construct($period_start_date, $period_end_date){
-        $this->period_start_date = $period_start_date;
-        $this->period_end_date = $period_end_date;
-       }
+       class status_checker {
        
-       public function build_calendar_array( $control_array, 
$controls_calendar_array, $num, $period_type ){
+       public function __construct()
+       {
+               $this->so_check_list = CreateObject('controller.socheck_list');
+               $this->so_check_item = CreateObject('controller.socheck_item');
+       }
                
-               foreach($control_array as $control){
-                                               
-                       // Initialises twelve_months_array
-                       for($i=1;$i<=$num;$i++){
-                               $calendar_array[$i] = null;
-                       }
+       public function update_check_list_status( $check_list_id )
+       {
+               $check_list = $this->so_check_list->get_single( $check_list_id 
);
 
-                       $date_generator = new 
date_generator($control->get_start_date(), $control->get_end_date(), 
$this->period_start_date, $this->period_end_date, $control->get_repeat_type(), 
$control->get_repeat_interval());
-                       $dates_array = $date_generator->get_dates();
+               $status = null;
+               $control_item_type = null;
+               $check_items = 
$this->so_check_item->get_check_items_with_cases($check_list_id, $status, 
$control_item_type, "return_object");
                
-                       // Inserts dates on behalf of repeat type and repeat 
interval
-                       foreach($dates_array as $date){
-                               
-                               $todays_date = mktime(0,0,0,date("m"), 
date("d"), date("Y"));
-                               
-                               if($date < $todays_date){
-                                       $status = "control_not_accomplished";
-                               }else{
-                                       $status = "control_registered";
-                               }
-                               
-                               if( $period_type == "view_months" )
-                               {
-                                       $calendar_array[ date("n", $date) 
]["status"]  = $status;
-                                       $calendar_array[ date("n", $date) 
]["info"]  = array("date" => $date, "control_id" => $control->get_id());
-                               }
-                               else if( $period_type == "view_days" )
-                               {
-                                       $calendar_array[ date("j", $date) 
]["status"]  = $status;
-                                       $calendar_array[ date("j", $date) 
]["info"]  = array("date" => $date, "control_id" => $control->get_id());      
-                               }
-                       }
-                       
-                       // Inserts check_list object on deadline month in 
twelve_months_array
-                       foreach($control->get_check_lists_array() as 
$check_list){
-                               
-                               $check_list_status_info = new 
check_list_status_info();
-                               $check_list_status_info->set_check_list_id( 
$check_list->get_id() );
+               $num_open_cases = 0;
                
-                               $todays_date = mktime(0,0,0,date("m"), 
date("d"), date("Y"));
-                               
-                               if( $check_list->get_status() == 0 & 
$check_list->get_planned_date() > 0 & $check_list->get_deadline() > 
$todays_date)
-                               {
-                                       $status = "control_planned";
-                                       
$check_list_status_info->set_info_text("Planlagt utført: " . 
$check_list->get_planned_date());
-                               }
-                               else if( $check_list->get_status() == 0 & 
$check_list->get_planned_date() > 0 & $check_list->get_deadline() < 
$todays_date)
-                               {
-                                       $status = 
"control_not_accomplished_with_info";
-                               }
-                               else if( $check_list->get_status() == 0 & 
$check_list->get_deadline() > $todays_date )
-                               {
-                                       $status = "control_not_accomplished";
-                               }
-                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() > $check_list->get_deadline() )
-                               {
-                                       $status = 
"control_accomplished_over_time_without_errors";
-                               }
-                               else if( $check_list->get_status() == 1 & 
$check_list->get_completed_date() < $check_list->get_deadline() )
-                               {
-                                       $status = 
"control_accomplished_in_time_without_errors";
-                               }
-                               else if( $check_list->get_status() == 2  ){
-                                       $status = 
"control_accomplished_with_errors";
-                                       
$check_list_status_info->set_num_open_cases($check_list->get_num_open_cases());
-                               }
-                               else if( $check_list->get_status() == 3 )
-                               {
-                                       $status = "control_canceled";
-                               }
-                               
-                               $check_list_status_info->set_deadline_date( 
date("d/m-Y", $check_list->get_deadline()) );
-                               
-                               if($period_type == "view_months")
-                               {
-                                       $calendar_array[ date("n", 
$check_list->get_deadline()) ]["status"] = $status;
-                                       $calendar_array[ date("n", 
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();  
     
-                               }
-                               else if( $period_type == "view_days" )
-                               {
-                                       $calendar_array[ date("j", 
$check_list->get_deadline()) ]["status"] = $status;
-                                       $calendar_array[ date("j", 
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();
-                               }
-                       }
+               foreach($check_items as $check_item){
                        
-                       $controls_calendar_array[] = array("control" => 
$control->toArray(), "calendar_array" => $calendar_array);
-               }
-
-               return $controls_calendar_array;
-       }
-       
-       // Function receives array with control objects that each contain 
check_lists for a certain period
-       public function build_agg_calendar_array( $controls_array ){
-                                       
-               $calendar_array = array();
-               
-               foreach($controls_array as $control_array){
-                       
-                       $control_info = $control_array['control'];
-                       $check_list_array = $control_array['check_list'];
-                       
-                       $control_id = $control_info['id'];
-                        
-                       // Initialises twelve_months_array
-                       for($i=0;$i<12;$i++){
-                               $calendar_array[$i] = null;
+                       if($check_item->get_control_item()->get_type() == 
"control_item_type_2" & $check_item->get_status() == 0){
+                               $num_open_cases++;
+                       }else{
+                               foreach($check_item->get_cases_array() as 
$case){
+                                       if($case->get_status() == 0){
+                                               $num_open_cases++;
+                                       }
+                               }       
                        }
-                       
-                       $status = "control_agg_accomplished_with_errors";
-                       
-                       // Inserts check_list object on deadline month in 
twelve_months_array
-                       foreach($check_list_array as $check_list){
-                               $calendar_array[ date("m", 
$check_list['deadline']) - 1 ] ["status"] = $status;
-                               $calendar_array[ date("m", 
$check_list['deadline']) - 1 ] ["info"] = $check_list['count']; 
-                       }
-                       
-                       $control_calendar_array[] = array("control" => 
$control_info, "calendar_array" => $calendar_array);
                }
-
-               return $control_calendar_array;
+               
+               $check_list->set_num_open_cases($num_open_cases);
+               $this->so_check_list->store($check_list);
        }
 }
\ No newline at end of file

Modified: trunk/controller/inc/model/class.check_list.inc.php
===================================================================
--- trunk/controller/inc/model/class.check_list.inc.php 2012-01-17 13:02:52 UTC 
(rev 8596)
+++ trunk/controller/inc/model/class.check_list.inc.php 2012-01-17 13:20:45 UTC 
(rev 8597)
@@ -153,7 +153,12 @@
                                'control_id' => $this->get_control_id(),
                                'status' => $this->get_status(),
                                'comment' => $this->get_comment(),
-                               'deadline' => $this->get_deadline()
-                               );
+                               'deadline' => $this->get_deadline(),
+                               'planned_date' => $this->get_planned_date(),
+                               'completed_date' => $this->get_completed_date(),
+                               'location_code' => $this->get_location_code(),
+                               'component_id' => $this->get_component_id(),
+                               'num_open_cases' => $this->get_num_open_cases()
+                       );
                }
        }

Modified: trunk/controller/templates/base/calendar/view_calendar_year.xsl
===================================================================
--- trunk/controller/templates/base/calendar/view_calendar_year.xsl     
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/templates/base/calendar/view_calendar_year.xsl     
2012-01-17 13:20:45 UTC (rev 8597)
@@ -140,7 +140,7 @@
                                                                                
<div id="info_box" style="position:absolute;display:none;"></div>
                                                                                
        <a class="view_check_list">
                                                                                
                <xsl:attribute name="href">
-                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                        <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                        <xsl:value-of select="info/check_list_id"/>
                                                                                
                </xsl:attribute>

Modified: trunk/controller/templates/base/check_list/edit_check_list.xsl
===================================================================
--- trunk/controller/templates/base/check_list/edit_check_list.xsl      
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/templates/base/check_list/edit_check_list.xsl      
2012-01-17 13:20:45 UTC (rev 8597)
@@ -62,6 +62,10 @@
                                </select>
                        </div>
                        <div>
+                               <label>Antall åpne avvik</label>
+                            <xsl:value-of select="check_list/num_open_cases"/>
+                   </div>
+                       <div>
                                <label>Skal utføres innen</label>
                                <input>
                              <xsl:attribute 
name="id">deadline_date</xsl:attribute>

Modified: trunk/controller/templates/base/check_list/register_case.xsl
===================================================================
--- trunk/controller/templates/base/check_list/register_case.xsl        
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/templates/base/check_list/register_case.xsl        
2012-01-17 13:20:45 UTC (rev 8597)
@@ -20,38 +20,40 @@
                                <ul id="control_items_list" class="check_items 
expand_list">
                                        <xsl:for-each 
select="control_items_for_check_list">
                                                <li>
-                                               <h4><img 
src="controller/images/arrow_right.png" width="14"/><span><xsl:value-of 
select="title"/></span></h4>                                           
-                                                       <form 
id="frm_register_case" 
action="index.php?menuaction=controller.uicase.register_case&amp;phpgw_return_as=json"
 method="post">
-                                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
-                                                               <input 
type="hidden" name="control_item_id" value="{$control_item_id}" /> 
-                                                               <input 
name="check_list_id" type="hidden">
-                                                             <xsl:attribute 
name="value">
-                                                               <xsl:value-of 
select="//check_list/id"/>
-                                                             </xsl:attribute>
-                                                           </input>
-                                                           <input 
name="status" type="hidden" value="0" />
-                                                             
+                                               <h4><img 
src="controller/images/arrow_right.png" width="14"/><span><xsl:value-of 
select="title"/></span></h4>   
                                                        <xsl:choose>
                                                                <xsl:when 
test="type = 'control_item_type_1'">
-                                                                       <input 
name="type" type="hidden" value="control_item_type_1" />
-                                                                   
-                                                                       <div 
class="check_item">
-                                                                      <div>
-                                                                               
 <label class="comment">Beskrivelse av sak</label>
-                                                                               
 <textarea name="case_descr">
-                                                                               
                <xsl:value-of select="comment"/>
-                                                                               
         </textarea>
-                                                                          
</div>
-                                                                      <div 
class="form-buttons">
-                                                                               
        <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
-                                                                               
        <input type="submit" name="save_control" value="{$lang_save}" 
class="not_active" title="{$lang_save}" />
+                                                                       <form 
id="frm_register_case" 
action="index.php?menuaction=controller.uicase.register_case&amp;phpgw_return_as=json"
 method="post">
+                                                                               
<xsl:variable name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                                                               
<input type="hidden" name="control_item_id" value="{$control_item_id}" /> 
+                                                                               
<input name="check_list_id" type="hidden"><xsl:attribute 
name="value"><xsl:value-of select="//check_list/id"/></xsl:attribute></input>
+                                                                           
<input name="status" type="hidden" value="0" />
+                                                                               
<input name="type" type="hidden" value="control_item_type_1" />
+                                                                               
    
+                                                                               
<div class="check_item">
+                                                                              
<div>
+                                                                               
         <label class="comment">Beskrivelse av sak</label>
+                                                                               
         <textarea name="case_descr">
+                                                                               
                        <xsl:value-of select="comment"/>
+                                                                               
                 </textarea>
+                                                                               
   </div>
+                                                                              
<div class="form-buttons">
+                                                                               
                <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
+                                                                               
                <input type="submit" name="save_control" value="{$lang_save}" 
class="not_active" title="{$lang_save}" />
+                                                                               
        </div>
                                                                                
</div>
-                                                                       </div>
+                                                                       </form>
                                                                </xsl:when>
                                                                <xsl:when 
test="type = 'control_item_type_2'">
+                                                               <form 
id="frm_save_check_item" 
action="index.php?menuaction=controller.uicheck_list.save_check_item&amp;phpgw_return_as=json"
 method="post">
+                                                                       
<xsl:variable name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                                                       <input 
type="hidden" name="control_item_id" value="{$control_item_id}" /> 
+                                                                       <input 
name="status" type="hidden" value="1" />
                                                                        <input 
name="type" type="hidden" value="control_item_type_2" />
+                                                                       <input 
name="check_list_id" type="hidden"><xsl:attribute name="value"><xsl:value-of 
select="//check_list/id"/></xsl:attribute></input>
+                                                               
                                                                        <div 
class="check_item">
-                                                                        <div>
+                                                                      <div>
                                                                         <label 
class="comment">Registrer målingsverdi</label>
                                                                           
<input>
                                                                                
      <xsl:attribute name="name">measurement</xsl:attribute>
@@ -72,10 +74,9 @@
                                                                                
        <input type="submit" name="save_control" value="Registrer sak" 
class="not_active" title="{$lang_save}" />
                                                                                
</div>
                                                                        </div>
+                                                                       </form>
                                                                </xsl:when>
                                                        </xsl:choose>           
                                                                                
                
-                                                               
-                                                       </form>
                                            </li>
                                        </xsl:for-each>
                                </ul>                   

Modified: trunk/controller/templates/base/check_list/view_measurements.xsl
===================================================================
--- trunk/controller/templates/base/check_list/view_measurements.xsl    
2012-01-17 13:02:52 UTC (rev 8596)
+++ trunk/controller/templates/base/check_list/view_measurements.xsl    
2012-01-17 13:20:45 UTC (rev 8597)
@@ -21,7 +21,7 @@
                                                                <form 
id="frm_save_check_item" 
action="index.php?menuaction=controller.uicheck_list.save_check_item" 
method="post">
                                                                        
<xsl:variable name="check_item_id"><xsl:value-of select="id"/></xsl:variable>
                                                                        <input 
type="hidden" name="check_item_id" value="{$check_item_id}" />
-                                                                       <input 
type="hidden" name="type" value="measurement" />
+                                                                       <input 
type="hidden" name="type" value="control_item_type_2" />
                                                                         
                                                                        <div 
class="check_item">
                                                                           <div>




reply via email to

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