fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9776]


From: Torstein
Subject: [Fmsystem-commits] [9776]
Date: Sat, 14 Jul 2012 18:37:39 +0000

Revision: 9776
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9776
Author:   vator
Date:     2012-07-14 18:37:38 +0000 (Sat, 14 Jul 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.socontrol_item.inc.php
    trunk/controller/inc/class.socontrol_item_option.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/class.uicontrol_item.inc.php

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-07-14 18:37:28 UTC 
(rev 9775)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-07-14 18:37:38 UTC 
(rev 9776)
@@ -52,9 +52,8 @@
                }
 
                /**
-                * Function for adding a new control to the database. Updates 
the control object.
-                *
-                * @param activitycalendar_activity $activity the party to be 
added
+                * Add a new control to database.
+                * @param $control control object
                 * @return bool true if successful, false otherwise
                 */
                function add(&$control)
@@ -79,9 +78,9 @@
                }
 
                /**
-                * Update the database values for an existing activity object.
+                * Update the database values for an existing control object.
                 *
-                * @param $activity the activity to be updated
+                * @param $control the control to be updated
                 * @return boolean true if successful, false otherwise
                 */
                function update($control)
@@ -110,6 +109,17 @@
                        }
                }
                
+               /**
+                * Get controls that should be carried out on a location within 
period
+                *
+                * @param $location_code the locaction code for the location 
the control should be carried out for   
+                * @param $from_date start date for period
+                * @param $to_date end date for period
+                * @param $repeat_type Dag, Uke, Måned, År 
+                * @param $return_type return data as objects or as arrays
+                * @param $role_id responsible role for carrying out the 
control  
+                * @return array with controls as objects or arrays
+                */
                public function get_controls_by_location($location_code, 
$from_date, $to_date, $repeat_type, $return_type = "return_object", $role_id = 
'')
                {
                        $controls_array = array();
@@ -160,6 +170,17 @@
                        }
                }
                
+               /**
+                * Get controls that should be carried out on components on a 
location within period
+                *
+                * @param $location_code the locaction code for the location 
the control should be carried out for   
+                * @param $from_date start date for period
+                * @param $to_date end date for period
+                * @param $repeat_type Dag, Uke, Måned, År 
+                * @param $return_type return data as objects or as arrays
+                * @param $role_id responsible role for carrying out the 
control  
+                * @return array with controls as objects or arrays
+                */
          public function 
get_controls_for_components_by_location($location_code, $from_date, $to_date, 
$repeat_type, $return_type = "return_object", $role_id = '')
                {
                        $controls_array = array();
@@ -210,6 +231,17 @@
                        }
                }
                
+               /**
+                * Get components and populates array of controls that should 
be carried out on the components on a location within period
+                *
+                * @param $location_code the locaction code for the location 
the control should be carried out for   
+                * @param $from_date start date for period
+                * @param $to_date end date for period
+                * @param $repeat_type Dag, Uke, Måned, År 
+                * @param $return_type return data as objects or as arrays
+                * @param $role_id responsible role for carrying out the 
control  
+                * @return array of components as objects or arrays
+                */
                public function get_controls_by_component($location_code, 
$from_date, $to_date, $repeat_type = '', $return_type = "return_object", 
$role_id = '')
                {
                        $controls_array = array();
@@ -323,6 +355,12 @@
                        }
                }
 
+               /**
+                * Get controls with a control area
+                *
+                * @param $control_area_id  
+                * @return array with controls as objects or arrays
+                */
                function get_controls_by_control_area($control_area_id)
                {
                        $control_area_id = (int) $control_area_id;
@@ -361,6 +399,12 @@
                        }
                }
 
+               /**
+                * Get locations that a control should be carried out for
+                *
+                * @param $control_id control id
+                * @return array with arrays of location info  
+                */
                function get_locations_for_control($control_id)
                {
                        $controls_array = array();
@@ -394,38 +438,42 @@
                        }
                }
                
+               /**
+                * Get arrays with component info that a control should be 
carried out on
+                *
+                * @param $control_id control id
+                * @return array with arrays of component info  
+                */
          function get_components_for_control($control_id)
                {
                        $controls_array = array();
 
-                       $sql =  "SELECT c.id, c.title, ccl.component_id, 
ccl.location_id, bim_type.description, bim.location_code ";
-      $sql .= "FROM controller_control c, controller_control_component_list 
ccl, fm_bim_item bim, fm_bim_type bim_type "; 
+                       $sql =  "SELECT ccl.control_id, ccl.component_id as 
component_id, ccl.location_id as location_id, bim_type.description, 
bim_item.location_code ";
+      $sql .= "FROM controller_control_component_list ccl, fm_bim_item 
bim_item, fm_bim_type bim_type "; 
                        $sql .= "WHERE ccl.control_id = $control_id ";
-      $sql .= "AND ccl.control_id = c.id ";
-                       $sql .= "AND bim.id = ccl.component_id ";
-                       $sql .= "AND bim_type.id = bim.type";
+                       $sql .= "AND ccl.component_id = bim_item.id ";
+                       $sql .= "AND ccl.location_id = bim_type.location_id ";
+                       $sql .= "AND bim_type.id = bim_item.type";
 
                        $this->db->query($sql);
 
                        while($this->db->next_record()) {
-                               $control_id = 
$this->unmarshal($this->db->f('id', true), 'int');
-                               $title = $this->unmarshal($this->db->f('title', 
true), 'string');
-                               $component_id = 
$this->unmarshal($this->db->f('component_id', true), 'int');
-                               $location_id = 
$this->unmarshal($this->db->f('location_id', true), 'int');
-                               $component_type = 
$this->unmarshal($this->db->f('description', true), 'string');
-                               $component_location_code = 
$this->unmarshal($this->db->f('location_code', true), 'string');
-                               //$component_guid = 
$this->unmarshal($this->db->f('guid', true), 'string');
-                               //$component_description = 
$this->getBimItemAttributeValue($component_guid, "beskrivelse");
-                               //$component_name = 
$this->getBimItemAttributeValue($component_guid, "betegnelse");
-                               //$component_author = 
$this->getBimItemAttributeValue($component_guid, "juridisk_person");
+                               $component = new controller_component();
+                               
$component->set_type($this->unmarshal($this->db->f('type', true), 'int'));
+                               
$component->set_id($this->unmarshal($this->db->f('component_id', true), 'int'));
+                               
$component->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
+                               
$component->set_guid($this->unmarshal($this->db->f('guid', true), 'string'));
+                               
$component->set_xml($this->unmarshal($this->db->f('xml', true), 'string'));
+                               
$component->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                               
$component->set_loc_1($this->unmarshal($this->db->f('loc_1', true), 'string'));
+                               
$component->set_address($this->unmarshal($this->db->f('address', true), 
'string'));
+                               
$component->set_type_str($this->unmarshal($this->db->f('description', true), 
'string'));
                                
-                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$component_location_code));
-                               
-                               $controls_array[] = array("id" => $control_id, 
"title" => $title, "component_id" => $component_id, "location_id" => 
$location_id, "component_description" => $component_type, "component_location" 
=> $location_array["loc1_name"]);
+                               $components_array[] = $component;
                        }
 
-                       if( count( $controls_array ) > 0 ){
-                               return $controls_array; 
+                       if( count( $components_array ) > 0 ){
+                               return $components_array; 
                        }
                        else
                        {
@@ -433,6 +481,13 @@
                        }
                }
 
+               /**
+                * Get arrays of control_location_list objects
+                *
+                * @param $control_id control id
+                * @param $location_code location code
+                * @return array with control_location_list objects  
+                */
                function get_control_location($control_id, $location_code)
                {
                        $control_id = (int)$control_id;
@@ -525,6 +580,14 @@
                        return $this->db->next_record();
                }
 
+               /**
+                * Register that a control should be carried out on a component
+                *
+                * @param $data['control_id'] control id
+                * @param $data['component_id'] component id
+                * @param $data['location_id'] component id
+                * @return true or false if the execution was successful  
+               */
                function register_control_to_component($data)
                {
 
@@ -591,7 +654,13 @@
                        return $this->db->transaction_commit();
                }
 
-
+               /**
+                * Register that a control should be carried out on a component
+                *
+                * @param $control_id control id
+                * @param $component_id component id
+                * @return void  
+                */
                function add_component_to_control($control_id, $component_id)
                {
                        $sql =  "INSERT INTO controller_control_component_list 
(control_id, component_id) values($control_id, $component_id)";
@@ -707,10 +776,8 @@
                                
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
                                
$control->set_responsibility_name($this->unmarshal($this->db->f('responsibility_name',
 true), 'string'));
                                
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
-                               
//$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
 true), 'string'));
                                $category = 
execMethod('phpgwapi.categories.return_single', 
$this->unmarshal($this->db->f('control_area_id', 'int')));
                                
$control->set_control_area_name($category[0]['name']);
-       //                      
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
                                
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
                                
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
                        }
@@ -722,22 +789,23 @@
                 * Get single control
                 * 
                 * @param       $id     id of the control to return
-                * @return a controller_control
+                * @return a controller_control object
                 */
                function get_single($id)
                {
                        $id = (int)$id;
 
-                       //$joins = " {$this->left_join} controller_control_area 
ON (c.control_area_id = controller_control_area.id)";
                        $joins .= " {$this->left_join} controller_procedure ON 
(c.procedure_id = controller_procedure.id)";
                        $joins .= " {$this->left_join} fm_responsibility_role 
ON (c.responsibility_id = fm_responsibility_role.id)";
 
-                       $sql = "SELECT c.*, controller_procedure.title AS 
procedure_name, fm_responsibility_role.name AS responsibility_name FROM 
controller_control c {$joins} WHERE c.id = " . $id;
+                       $sql  = "SELECT c.*, controller_procedure.title AS 
procedure_name, fm_responsibility_role.name AS responsibility_name "; 
+                       $sql .= "FROM controller_control c {$joins} "; 
+                       $sql .= "WHERE c.id = " . $id;
+                       
                        $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
                        $this->db->next_record();
-
+                       
                        $control = new controller_control((int) $id);
-
                        
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
                        
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
                        
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
@@ -749,7 +817,6 @@
                        
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
                        
$control->set_responsibility_name($this->unmarshal($this->db->f('responsibility_name',
 true), 'string'));
                        
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
-                       
//$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
 true), 'string'));
                        $category = 
execMethod('phpgwapi.categories.return_single', 
$this->unmarshal($this->db->f('control_area_id', 'int')));
                        $control->set_control_area_name($category[0]['name']);
                        
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
@@ -796,7 +863,8 @@
                        }
                        return $ret_array;
                }
-
+               
+/*
                public function getAllBimItems($noOfObjects = null, $bim_type = 
null) {
                        $filters = array();
                        if($noOfObjects != null && is_numeric($noOfObjects))
@@ -827,7 +895,7 @@
 
                        return $bimItemArray;
                }
-
+*/
                public function get_control_component($noOfObjects = null, 
$bim_type = null)
                {
                        $filters = array();
@@ -866,7 +934,7 @@
                {
                        $columnAlias = "attribute_values";
                        $sql = "select 
array_to_string(xpath('descendant-or-self::*[{$attribute}]/{$attribute}/text()',
 (select xml_representation from fm_bim_item where guid='{$bimItemGuid}')), 
',') as $columnAlias";
-                       //var_dump($sql);
+                       
                        $this->db->query($sql,__LINE__,__FILE__);
                        if($this->db->num_rows() > 0)
                        {
@@ -876,8 +944,6 @@
                        }
                }
                
-               
-               
                public function getLocationCodeFromControl($control_id)
                {
                        $sql = "select location_code from 
controller_control_location_list where control_id={$control_id}";

Modified: trunk/controller/inc/class.socontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item.inc.php   2012-07-14 18:37:28 UTC 
(rev 9775)
+++ trunk/controller/inc/class.socontrol_item.inc.php   2012-07-14 18:37:38 UTC 
(rev 9776)
@@ -39,7 +39,7 @@
                /**
                 * Get a static reference to the storage object associated with 
this model object
                 *
-                * @return controller_soparty the storage object
+                * @return controller_socontrol_item the storage object
                 */
                public static function get_instance()
                {
@@ -50,9 +50,9 @@
                }
 
                /**
-                * Function for adding a new activity to the database. Updates 
the activity object.
+                * Add a new control item to database.
                 *
-                * @param activitycalendar_activity $activity the party to be 
added
+                * @param control_item object to be added
                 * @return bool true if successful, false otherwise
                 */
                function add(&$control_item)
@@ -78,7 +78,6 @@
                        );
 
                        $result = $this->db->query('INSERT INTO 
controller_control_item (' . join(',', $cols) . ') VALUES (' . join(',', 
$values) . ')', __LINE__,__FILE__);
-                       //$result = $this->db->query($sql, __LINE__,__FILE__);
 
                        if(isset($result)) {
                                // return the new control item ID
@@ -91,9 +90,9 @@
                }
 
                /**
-                * Update the database values for an existing activity object.
+                * Update the database values for an existing control item 
object.
                 *
-                * @param $activity the activity to be updated
+                * @param $control item object to be updated
                 * @return boolean true if successful, false otherwise
                 */
 
@@ -128,7 +127,7 @@
                 * Get single control item
                 * 
                 * @param       $id     id of the control_item to return
-                * @return a controller_control_item
+                * @return control item object
                 */
                function get_single($id)
                {
@@ -153,6 +152,13 @@
                        return $control_item;
                }
                
+               /**
+                * Get single control item with options  
+                * 
+                * @param       $id     id of the control_item to return
+                * @param $return_type return data as objects or as arrays
+                * @return control item object
+               */
                public function get_single_with_options($id, $return_type = 
"return_object"){
                        $sql  = "SELECT ci.id as ci_id, ci.*, cio.id as cio_id, 
cio.*, cg.group_name ";
                        $sql .= "FROM controller_control_item ci "; 
@@ -213,6 +219,12 @@
                        }
                }
                
+               /**
+                * Delete control item from database  
+                * 
+                * @param       $control_item_id id of control_item to be 
deleted
+                * @return void
+               */
                function delete_option_values($control_item_id)
                {
                        $sql  = "delete from controller_control_item_option 
where control_item_id=$control_item_id";
@@ -386,6 +398,13 @@
                        return true;
                }
                
+               /**
+                * Get control items for a control within control group  
+                * 
+                * @param       $control_id control id
+                * @param       $control_group_id control group id
+                * @return void
+               */
                function get_items_for_control_group($control_id, 
$control_group_id)
                {
                        $results = array();

Modified: trunk/controller/inc/class.socontrol_item_option.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item_option.inc.php    2012-07-14 
18:37:28 UTC (rev 9775)
+++ trunk/controller/inc/class.socontrol_item_option.inc.php    2012-07-14 
18:37:38 UTC (rev 9776)
@@ -44,6 +44,12 @@
                        return self::$so;
                }
 
+               /**
+                * Inserts a new control item option in database  
+                * 
+                * @param       $control_item_option object to be inserted
+                * @return true if task was successful, false otherwise  
+               */
                function add(&$control_item_option)
                {
                        $cols = array(
@@ -67,7 +73,13 @@
                                return 0;
                        }
                }
-
+               
+               /**
+                * Updates an existing control item option in database  
+                * 
+                * @param       $control_item_option object to be updated
+                * @return true if task was successful, false otherwise  
+               */
                function update($control_item_option)
                {
                        $id = intval($control_item_option->get_id());
@@ -82,6 +94,12 @@
                        return isset($result);
                }
                
+               /**
+                * Get a single control item option from database  
+                * 
+                * @param       $id id of control item option to be fetched
+                * @return control item option object  
+               */
                function get_single($id)
                {
                        $id = (int)$id;

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-07-14 18:37:28 UTC 
(rev 9775)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-07-14 18:37:38 UTC 
(rev 9776)
@@ -33,6 +33,7 @@
        
        include_class('controller', 'check_list', 'inc/model/');
        include_class('controller', 'check_item', 'inc/model/');
+       include_class('controller', 'component', 'inc/model/');
        include_class('controller', 'check_list_status_info', 'inc/helper/');
        include_class('controller', 'status_agg_month_info', 'inc/helper/');
        include_class('controller', 'location_finder', 'inc/helper/');
@@ -323,7 +324,7 @@
                                                                                
                                          $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, 
$to_month);
                                        
-                                         $year_calendar = new 
year_calendar($control, $year);
+                                         $year_calendar = new year_calendar( 
$control, $year, $component, null, "component" );
                                          $calendar_array = 
$year_calendar->build_agg_month_calendar($agg_open_cases_pr_month_array);
 
                                          $controls_components_calendar_array[] 
= array("control" => $control->toArray(), "calendar_array" => $calendar_array);
@@ -414,7 +415,7 @@
                        $locations_with_calendar_array = array();
                        
                        // Process aggregated values for controls with repeat 
type day or week 
-                       if($control->get_repeat_type() <= 
controller_control::REPEAT_TYPE_WEEK )
+                       if( $control->get_repeat_type() <= 
controller_control::REPEAT_TYPE_WEEK  )
                        {
                                foreach($locations_for_control_array as 
$location)
                                {
@@ -430,20 +431,23 @@
                                        // 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 = new 
year_calendar($control, $year);
+                                       $year_calendar = new 
year_calendar($control, $year, null, $curr_location_code, "location");
                                        $calendar_array = 
$year_calendar->build_agg_month_calendar($agg_open_cases_pr_month_array);
                                        $locations_with_calendar_array[] = 
array( "location" => $location, "calendar_array" => $calendar_array );
                                }
                                
-                         foreach($components_for_control_array as $component)
+                         foreach( $components_for_control_array as $component )
                          {
-                                       $component_id = 
$component['component_id'];
-                                       $location_id = 
$component['location_id'];
+                               $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_id);
-                                 $cl_criteria->set_location_id( $location_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);
@@ -451,15 +455,15 @@
                                        // 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 = new 
year_calendar($control, $year);
+                                       $year_calendar = new year_calendar( 
$control, $year, $component, null, "component" );
                                        $calendar_array = 
$year_calendar->build_agg_calendar($agg_open_cases_pr_month_array);
-                                       $components_with_calendar_array[] = 
array("component" => $component, "calendar_array" => $calendar_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'];
                                        
@@ -468,26 +472,26 @@
                                        
                                        $check_lists_array = 
$location_with_check_lists["check_lists_array"];
                                        
-                                       $year_calendar = new 
year_calendar($control, $year);
+                                       $year_calendar = new 
year_calendar($control, $year, null, $curr_location_code, "location");
                                        $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 )
                          {
-                                       $curr_component_id = 
$component['component_id'];
-                                       $curr_location_id = 
$component['location_id'];
+                                       $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, 
$curr_location_id, $curr_component_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);
+                                       $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, "calendar_array" => $calendar_array);
+                                       $components_with_calendar_array[] = 
array("component" => $component->toArray(), "calendar_array" => 
$calendar_array);
                                }
                        }
                        
@@ -546,16 +550,32 @@
                                $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, $control->get_repeat_type());  
  
                                        
                                $check_lists_array = 
$location_with_check_lists["check_lists_array"];
                                        
-                               $month_calendar = new month_calendar($control, 
$year, $month);
+                               $month_calendar = new month_calendar($control, 
$year, $month, null, $location_code, "location");
                                $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 )
+                       {
+                               $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, $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( $control->get_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);
                        
@@ -563,15 +583,16 @@
                        
                        $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,
-                               'date_format'                                   
                        => $date_format,
-                               'current_month_nr'                              
                => $month,
-                               'current_year'                                  
                => $year,
+                               '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,
+                               'date_format'                                   
                                => $date_format,
+                               'current_month_nr'                              
                        => $month,
+                               'current_year'                                  
                        => $year,
                        );
                        
                        self::render_template_xsl( 
array('calendar/view_calendar_month_for_locations', 
'calendar/check_list_status_checker', 

Modified: trunk/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item.inc.php   2012-07-14 18:37:28 UTC 
(rev 9775)
+++ trunk/controller/inc/class.uicontrol_item.inc.php   2012-07-14 18:37:38 UTC 
(rev 9776)
@@ -195,21 +195,28 @@
                        return status;
                }
 
-               public function edit()
+               public function edit( $control_item = null )
                {
-                       $control_item_id = phpgw::get_var('id');
-                       
-                       $control_item_array = array();
-                       if($control_item_id > 0)
+                       // NOT REDIRECT
+                       if($control_item == null)
                        {
-                               $control_item_array = 
$this->so->get_single_with_options( $control_item_id , "return_array"); 
+                               $control_item_id = phpgw::get_var('id');
+                       
+                               // Edit control item
+                               if($control_item_id > 0)
+                               {
+                                       $control_item = 
$this->so->get_single_with_options($control_item_id , "return_object"); 
+                               }
+                               // New control item
+                               else
+                               {
+                                       $control_item = new 
controller_control_item();
+                               }       
                        }
-                       else
-                       {
-                               $control_item = new controller_control_item();
-                         $control_item_array = $control_item->toArray();
-                       }
                        
+                       $control_item_array = array();
+                       $control_item_array = $control_item->toArray();
+                       
                        // Sigurd: START as categories
                        $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
                        $cats->supress_info     = true;
@@ -290,45 +297,10 @@
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_item.view', 'id' => 
$saved_control_item_id));
                        }else
                        {
-                               $this->redirect($control_item);
+                               $this->edit($control_item);
                        }
                }
 
-               public function redirect($control_item)
-               {               
-                       // Sigurd: START as categories
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
-                       
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
-                       $control_areas_array = $control_areas['cat_list'];
-
-                       $control_groups_array = 
$this->so_control_group->get_control_group_array();
-
-                       $control_item_array = $control_item->toArray();
-                       
-                       // Hack to fix display of &nbsp; char
-                       $control_item_array['what_to_do'] = 
str_replace("&nbsp;", " ",$control_item_array['what_to_do']);
-                       $control_item_array['how_to_do'] = 
str_replace('&nbsp;', ' ', $control_item_array['how_to_do']);
-
-                       print_r( $control_item_array );
-                       $data = array
-                       (
-                               'editable'                              => true,
-                               'control_item'          => $control_item_array,
-                               'control_areas'         => $control_areas_array,
-                               'control_groups'        => 
$control_groups_array,
-                       );
-               
-                       $this->use_yui_editor(array('what_to_do','how_to_do'));
-                       
-                       self::add_javascript('controller', 'controller', 
'jquery.js');
-                       self::add_javascript('controller', 'controller', 
'ajax.js');
-                       self::add_javascript('controller', 'controller', 
'jquery-ui.custom.min.js');
-
-                       self::render_template_xsl('control_item/control_item', 
$data);
-               }
-               
                /**
                 * Public method. Called when a user wants to view information 
about a control item.
                 * @param HTTP::id      the control_item ID




reply via email to

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