public function query()
 {
     $entity_group_id = phpgw::get_var('entity_group_id', 'int');
     $location_id = phpgw::get_var('location_id', 'int');
     $control_area = phpgw::get_var('control_area', 'int');
     $user_id = phpgw::get_var('user_id', 'int');
     $district_id = phpgw::get_var('district_id', 'int');
     $query = phpgw::get_var('query', 'string');
     $year = phpgw::get_var('year', 'int');
     $all_items = phpgw::get_var('all_items', 'bool');
     $user_only = phpgw::get_var('user_only', 'bool');
     $filter_status = phpgw::get_var('status', 'string');
     $report_type = phpgw::get_var('report_type', 'string');
     if ($filter_component_str = phpgw::get_var('filter_component', 'string')) {
         $filter_component_arr = explode('_', $filter_component_str);
         $location_id = $filter_component_arr[0];
         $filter_component = $filter_component_arr[1];
     }
     if ($org_unit_id = phpgw::get_var('org_unit_id', 'int')) {
         $_subs = execMethod('property.sogeneric.read_tree', array('node_id' => $org_unit_id, 'type' => 'org_unit'));
         $this->org_units[] = $org_unit_id;
         foreach ($_subs as $entry) {
             $this->org_units[] = $entry['id'];
             if (isset($entry['children']) && $entry['children']) {
                 $this->_get_children($entry['children']);
             }
         }
         unset($entry);
         unset($_subs);
     }
     $so_control = CreateObject('controller.socontrol');
     $this->so = CreateObject('controller.socheck_list');
     // Validates year. If year is not set, current year is chosen
     $year = execMethod('controller.uicalendar.validate_year', $year);
     // Gets timestamp of first day in year
     $from_date_ts = execMethod('controller.uicalendar.get_start_date_year_ts', $year);
     // Gets timestamp of first day in next year
     $to_date_ts = execMethod('controller.uicalendar.get_end_date_year_ts', $year);
     $location_filter = $this->get_location_filter();
     foreach ($location_filter as $_location) {
         $location_type_name[$_location['id']] = $_location['name'];
     }
     //			_debug_array($location_type_name);
     $components = array();
     $keep_only_assigned_to = 0;
     //			$lookup_stray_items = false;
     $lookup_stray_items = !!$entity_group_id;
     if ($user_id < 0) {
         $user_id = $user_id * -1;
         $all_items = false;
         $user_only = true;
         //				$keep_only_assigned_to = $user_id;
         //				$assigned_components = $so_control->get_assigned_control_components($from_date_ts, $to_date_ts, $assigned_to = $user_id);
         //				foreach($assigned_components as $_location_id => $component_list)
         //				{
         //					$_components = execMethod('property.soentity.read',array(
         //						'filter_entity_group'		=> $entity_group_id,
         //						'location_id'				=> $_location_id,
         //						'district_id'				=> $district_id,
         //						'allrows'					=> true,
         //						'filter_item'				=> $component_list
         //						)
         //					);
         //					$components = array_merge($components, $_components);
         //				}
     }
     if (!$location_id) {
         //nothing
     } else {
         if ($location_id == -1 && !$entity_group_id) {
             //nothing
         } else {
             if (!$location_id && $entity_group_id) {
                 //still nothing
             } else {
                 $exclude_locations = array();
                 foreach ($location_filter as $_location_filter) {
                     if ($location_id > 0 && $_location_filter['id'] != $location_id) {
                         continue;
                     }
                     $_location_id = (int) $_location_filter['id'];
                     $exclude_locations[] = $_location_id;
                     $_components = execMethod('property.soentity.read', array('filter_entity_group' => $entity_group_id, 'location_id' => $_location_id, 'district_id' => $district_id, 'org_units' => $this->org_units, 'allrows' => true, 'control_registered' => !$all_items, 'check_for_control' => true, 'filter_item' => $filter_component ? array($filter_component) : array()));
                     $components = array_merge($components, $_components);
                 }
                 if ($lookup_stray_items) {
                     $_components = execMethod('property.soentity.read_entity_group', array('entity_group_id' => $entity_group_id, 'exclude_locations' => $exclude_locations, 'location_id' => $_location_id, 'district_id' => $district_id, 'org_units' => $this->org_units, 'allrows' => true, 'control_registered' => !$all_items, 'check_for_control' => true));
                     $components = array_merge($components, $_components);
                 }
             }
         }
     }
     $all_components = array();
     $components_with_calendar_array = array();
     //			_debug_array($components);
     foreach ($components as $_component) {
         $location_id = $_component['location_id'];
         $component_id = $_component['id'];
         $all_components["{$location_id}_{$component_id}"] = $_component;
         $short_description = $_component['short_description'];
         $short_description .= ' [' . $_component['location_name'] . ']';
         if ($all_items && !$_component['has_control']) {
             continue;
         }
         $controls_at_component = $so_control->get_controls_at_component2($_component);
         foreach ($controls_at_component as $component) {
             $_control_relation = $component->get_control_relation();
             if (!$_control_relation['serie_enabled']) {
                 //					continue;
             }
             $control_id = $_control_relation['control_id'];
             $control = $so_control->get_single($control_id);
             $repeat_type = $control->get_repeat_type();
             //FIXME: Not currently supported
             if ($repeat_type <= controller_control::REPEAT_TYPE_WEEK) {
                 $repeat_type = controller_control::REPEAT_TYPE_MONTH;
             }
             // LOCATIONS: Process aggregated values for controls with repeat type day or week
             if ($repeat_type <= controller_control::REPEAT_TYPE_WEEK) {
                 //FIXME: Not currently supported
                 $component->set_xml_short_desc(" {$location_type_name[$location_id]}</br>{$short_description}");
                 $component_with_check_lists = $this->so->get_check_lists_for_control_and_component($control_id, $component->get_location_id(), $component->get_id(), $from_date_ts, $to_date_ts, $repeat_type);
                 $cl_criteria = new controller_check_list();
                 $cl_criteria->set_control_id($control->get_id());
                 $cl_criteria->set_component_id($component->get_id());
                 $cl_criteria->set_location_id($component->get_location_id());
                 $from_month = $this->get_start_month_for_control($control);
                 $to_month = $this->get_end_month_for_control($control);
                 // Loops through controls in controls_for_location_array and populates aggregate open cases pr month array.
                 $agg_open_cases_pr_month_array = $this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, $to_month);
                 $year_calendar_agg = new year_calendar_agg($control, $year, $location_code, "VIEW_LOCATIONS_FOR_CONTROL");
                 $calendar_array = $year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
                 $components_with_calendar_array["{$location_id}_{$component_id}"][] = array("component" => $component->toArray(), "calendar_array" => $calendar_array);
             } else {
                 if ($repeat_type > controller_control::REPEAT_TYPE_WEEK) {
                     $component->set_xml_short_desc(" {$location_type_name[$location_id]}</br>{$short_description}");
                     $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);
                     // ,$user_id);
                     $check_lists_array = $component_with_check_lists["check_lists_array"];
                     /*
                      * start override control with data from serie
                      */
                     $control_relation = $component->get_control_relation();
                     if (isset($control_relation['start_date']) && $control_relation['start_date']) {
                         $control->set_start_date($control_relation['start_date']);
                     }
                     if (isset($control_relation['end_date']) && $control_relation['end_date']) {
                         $control->set_end_date($control_relation['end_date']);
                     }
                     if (isset($control_relation['repeat_type']) && $control_relation['repeat_type']) {
                         $control->set_repeat_type($control_relation['repeat_type']);
                     }
                     if (isset($control_relation['repeat_interval']) && $control_relation['repeat_interval']) {
                         $control->set_repeat_interval($control_relation['repeat_interval']);
                     }
                     $year_calendar = new year_calendar($control, $year, $component, null, "component", $control_relation);
                     $calendar_array = $year_calendar->build_calendar($check_lists_array);
                     if ($user_only && $user_id) {
                         $keep_only_assigned_to = $user_id;
                         $found_assigned_to = false;
                         if ($calendar_array) {
                             foreach ($calendar_array as $_month => $_month_info) {
                                 if (isset($_month_info['info']['assigned_to']) && $_month_info['info']['assigned_to'] == $user_id) {
                                     $found_assigned_to = true;
                                     break;
                                 }
                             }
                         }
                         if (!$found_assigned_to) {
                             unset($all_components["{$location_id}_{$component_id}"]);
                             continue;
                         }
                     }
                     $components_with_calendar_array["{$location_id}_{$component_id}"][] = array("component" => $component->toArray(), "calendar_array" => $calendar_array);
                 }
             }
         }
     }
     $total_records = count($all_components);
     //			_debug_array($components_with_calendar_array);
     unset($component_id);
     //			_debug_array($components_with_calendar_array[1]);
     //			_debug_array($components);
     //			_debug_array(array_keys($components_with_calendar_array));
     $repeat_type_array = array("0" => lang('day'), "1" => lang('week'), "2" => lang('month'), "3" => lang('year'));
     $values = array();
     foreach ($components_with_calendar_array as $dummy => $entry) {
         $location_id = $entry[0]['component']['location_id'];
         $component_id = $entry[0]['component']['id'];
         unset($all_components["{$location_id}_{$component_id}"]);
         $data = array();
         $component_link_data = array('menuaction' => 'property.uientity.edit', 'location_id' => $location_id, 'id' => $component_id, 'active_tab' => 'controller');
         $data['component_url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" target='_blank'>{$component_id}{$entry[0]['component']['xml_short_desc']}</a>";
         $data['component_id'] = $component_id;
         $data['location_id'] = $location_id;
         $max_interval_length = 0;
         //number of months
         $_data = array();
         foreach ($entry as $dataset) {
             $repeat_type = (int) $dataset['component']['control_relation']['repeat_type'];
             $repeat_interval = (int) $dataset['component']['control_relation']['repeat_interval'];
             /*
             						REPEAT_TYPE_DAY = 0;
             						REPEAT_TYPE_WEEK = 1;
             						REPEAT_TYPE_MONTH = 2;
             						REPEAT_TYPE_YEAR = 3;
             */
             switch ($repeat_type) {
                 case controller_control::REPEAT_TYPE_DAY:
                     $interval_length = ceil($repeat_interval / 30);
                     break;
                 case controller_control::REPEAT_TYPE_WEEK:
                     $interval_length = ceil($repeat_interval / 4);
                     break;
                 case controller_control::REPEAT_TYPE_MONTH:
                     $interval_length = $repeat_interval;
                     break;
                 case controller_control::REPEAT_TYPE_YEAR:
                     $interval_length = $repeat_interval * 12;
                     $interval_length = $interval_length > 12 ? 12 : $interval_length;
                     break;
                 default:
                     $interval_length = 0;
                     break;
             }
             $service_time = $dataset['component']['control_relation']['service_time'];
             $controle_time = $dataset['component']['control_relation']['controle_time'];
             if ($interval_length > $max_interval_length) {
                 $max_interval_length = $interval_length;
             }
             foreach ($dataset['calendar_array'] as $month => $calendar) {
                 if ($calendar) {
                     //							$repeat_type = $calendar['info']['repeat_type'] ? (int)$calendar['info']['repeat_type'] : $repeat_type;
                     $calendar['info']['service_time'] = $calendar['info']['service_time'] ? $calendar['info']['service_time'] : $service_time;
                     $calendar['info']['controle_time'] = $calendar['info']['controle_time'] ? $calendar['info']['controle_time'] : $controle_time;
                     $_data[$month][$interval_length] = $calendar;
                     $_data[$month][$interval_length]['repeat_type'] = $repeat_type;
                     $_data[$month][$interval_length]['repeat_interval'] = $repeat_interval;
                 }
             }
         }
         for ($_month = 1; $_month < 13; $_month++) {
             for ($i = $max_interval_length; $i > -1; $i--) {
                 if (isset($_data[$_month][$i])) {
                     $data[$_month] = $_data[$_month][$i];
                     $data[$_month]['repeat_type'] = "{$repeat_type_array[$_data[$_month][$i]['repeat_type']]}/{$_data[$_month][$i]['repeat_interval']}";
                     //FIXME
                     break 1;
                 } else {
                     $data[$_month] = array();
                 }
             }
         }
         $values[] = $data;
     }
     unset($entry);
     unset($component_id);
     unset($component);
     if ($report_type == 'summary') {
         return array('components' => null, 'summary' => $this->get_summary($values, $user_id), 'location_filter' => $location_filter);
     }
     $choose_master = false;
     if ($all_components && count($all_components)) {
         $choose_master = true;
         foreach ($all_components as $dummy => $component) {
             $data = array();
             $location_id = $component['location_id'];
             $component_id = $component['id'];
             $component_link_data = array('menuaction' => 'property.uientity.edit', 'location_id' => $location_id, 'id' => $component_id, 'active_tab' => 'controller');
             $short_description = $component['short_description'];
             $short_description .= "[ {$component['location_name']} ]";
             $data['component_url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" target='_blank'>{$component_id} {$location_type_name[$location_id]}</br>{$short_description}</a>";
             $data['component_id'] = $component_id;
             $data['location_id'] = $location_id;
             $data['missing_control'] = true;
             $values[] = $data;
         }
     }
     //_debug_array($values);
     $data_set = array();
     $total_time = array();
     foreach ($values as $entry) {
         $row = array();
         $row_sum = array();
         $row_sum_actual = array();
         //billable_hours
         $row['component_url'] = $entry['component_url'];
         $row['year'] = '';
         $row['descr'] = '';
         if (!isset($entry['missing_control'])) {
             if ($filter_component_str) {
                 $row['choose'] = '<input id="selected_component" type="checkbox" name="selected_component" checked = "checked" onclick="deselect_component();">';
             } else {
                 if ($choose_master) {
                     $row['choose'] = "<input id=\"master_component\" type=\"radio\" name=\"master_component\" value = \"{$entry['location_id']}_{$entry['component_id']}\" >";
                 }
             }
             $row['year'] = $year;
             $row['descr'] = "Frekvens<br/>Status<br/>Utførende<br/>Tidsbruk";
         } else {
             if ($choose_master) {
                 $row['choose'] = "<input id=\"selected_components\" class=\"mychecks\" type=\"checkbox\" name=\"selected_components[]\" value = \"{$entry['location_id']}_{$entry['component_id']}\">";
             }
         }
         $found_at_least_one = false;
         for ($_month = 1; $_month < 13; $_month++) {
             $row[$_month] = $this->translate_calendar_info($entry[$_month], $year, $_month, $filter_status, $found_at_least_one, $keep_only_assigned_to);
             if ($row[$_month] && (!$user_id || $entry[$_month]['info']['assigned_to'] == $user_id)) {
                 $row_sum[$_month] = $entry[$_month]['info']['service_time'] + $entry[$_month]['info']['controle_time'];
                 $row_sum_actual[$_month] = +$entry[$_month]['info']['billable_hours'];
             } else {
                 $row_sum[$_month] = 0;
                 $row_sum_actual[$_month] = 0;
             }
         }
         if (!$filter_status || $found_at_least_one) {
             $total_time[] = $row_sum;
             $total_time_actual[] = $row_sum_actual;
             $data_set[] = $row;
         }
     }
     $fields = $this->get_fields($filter_component_str);
     $class = '';
     $tbody = '';
     foreach ($data_set as $row_data) {
         $tbody .= "<tr {$class}>";
         foreach ($fields as $field) {
             $tbody .= '<td>';
             $tbody .= $row_data[$field['key']];
             $tbody .= '</td>';
         }
         $tbody .= '</tr>';
         $class = $class ? '' : 'class="alt"';
     }
     $result = array('tbody' => $tbody);
     unset($_month);
     $sum_year = 0;
     $sum_year_actual = 0;
     if (!$total_time) {
         for ($_month = 1; $_month < 13; $_month++) {
             $result['time_sum'][$_month] = 0;
         }
     } else {
         foreach ($total_time as $_row) {
             for ($_month = 1; $_month < 13; $_month++) {
                 $result['time_sum'][$_month] += $_row[$_month];
                 $sum_year += $_row[$_month];
             }
         }
         unset($_row);
     }
     $result['time_sum'][0] = $sum_year;
     if (!$total_time_actual) {
         for ($_month = 1; $_month < 13; $_month++) {
             $result['time_sum_actual'][$_month] = 0;
         }
     } else {
         foreach ($total_time_actual as $_row) {
             for ($_month = 1; $_month < 13; $_month++) {
                 $result['time_sum_actual'][$_month] += $_row[$_month];
                 $sum_year_actual += $_row[$_month];
             }
         }
     }
     $result['time_sum_actual'][0] = $sum_year_actual;
     $result['total_records'] = $total_records;
     $result['location_filter'] = $location_filter;
     if ($choose_master) {
         $lang_save = lang('add');
         $lang_select = lang('select');
         $result['checkall'] = "<input type=\"button\" value = '{$lang_save}' title = '{$lang_save}' onclick=\"add_from_master('mychecks');\">";
         $result['checkall'] .= '</br>';
         $result['checkall'] .= "<input type=\"checkbox\" title = '{$lang_select}' onclick=\"checkAll('mychecks');\">";
     } else {
         $result['checkall'] = '';
     }
     return array('components' => $result, 'summary' => null, 'location_filter' => $location_filter);
 }
 public function view_calendar_year_for_locations()
 {
     static $_location_name = array();
     $control_id = phpgw::get_var('control_id', 'int');
     $control = $this->so_control->get_single($control_id);
     $year = phpgw::get_var('year', 'int');
     $location_id = phpgw::get_var('location_id', 'int');
     $component_id = phpgw::get_var('component_id', 'int');
     $serie_id = phpgw::get_var('serie_id', 'int');
     $user_id = $GLOBALS['phpgw_info']['user']['account_id'];
     $bookmarks = phpgwapi_cache::user_get('controller', "location_bookmark", $user_id);
     if (is_array($bookmarks)) {
         $bookmark_locations = array_keys($bookmarks);
     }
     if ($location_code = phpgw::get_var('location_code')) {
         $bookmark_locations[] = $location_code;
     }
     $locations_list = array();
     if (is_numeric($control_id) & $control_id > 0) {
         $locations_for_control_array = $this->so_control->get_locations_for_control($control_id);
         $components_for_control_array = $this->so_control->get_components_for_control($control_id, $location_id, $component_id, $serie_id);
         foreach ($locations_for_control_array as $location) {
             $locations_list[] = array('id' => $location['location_code'], 'name' => $location['loc_name'], 'selected' => $location_code == $location['location_code'] ? 1 : 0);
         }
         reset($locations_for_control_array);
         unset($location);
     }
     // Validates year. If year is not set, current year is chosen
     $year = $this->validate_year($year);
     // Gets timestamp of first day in year
     $from_date_ts = $this->get_start_date_year_ts($year);
     // Gets timestamp of first day in next year
     $to_date_ts = $this->get_end_date_year_ts($year);
     $locations_with_calendar_array = array();
     // LOCATIONS: Process aggregated values for controls with repeat type day or week
     if ($control->get_repeat_type() <= controller_control::REPEAT_TYPE_WEEK) {
         foreach ($locations_for_control_array as $location) {
             $curr_location_code = $location['location_code'];
             if (!$bookmark_locations || !in_array($curr_location_code, $bookmark_locations)) {
                 continue;
             }
             $cl_criteria = new controller_check_list();
             $cl_criteria->set_control_id($control->get_id());
             $cl_criteria->set_location_code($curr_location_code);
             $from_month = $this->get_start_month_for_control($control);
             $to_month = $this->get_end_month_for_control($control);
             // Loops through controls in controls_for_location_array and populates aggregate open cases pr month array.
             $agg_open_cases_pr_month_array = $this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, $to_month);
             $year_calendar_agg = new year_calendar_agg($control, $year, $curr_location_code, "VIEW_LOCATIONS_FOR_CONTROL");
             $calendar_array = $year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
             $locations_with_calendar_array[] = array('location' => $location, 'calendar_array' => $calendar_array, 'selected' => $bookmarks && isset($bookmarks[$curr_location_code]));
         }
         // COMPONENTS: Process aggregated values for controls with repeat type day or week
         foreach ($components_for_control_array as $component) {
             $short_desc_arr = execMethod('property.soentity.get_short_description', array('location_id' => $component->get_location_id(), 'id' => $component->get_id()));
             if (!isset($_location_name[$component->get_location_code()])) {
                 $_location = execMethod('property.solocation.read_single', $component->get_location_code());
                 $location_arr = explode('-', $component->get_location_code());
                 $i = 1;
                 $name_arr = array();
                 foreach ($location_arr as $_dummy) {
                     $name_arr[] = $_location["loc{$i}_name"];
                     $i++;
                 }
                 $_location_name[$component->get_location_code()] = implode('::', $name_arr);
             }
             $short_desc_arr .= ' [' . $_location_name[$component->get_location_code()] . ']';
             $component->set_xml_short_desc($short_desc_arr);
             $repeat_type = $control->get_repeat_type();
             $component_with_check_lists = $this->so->get_check_lists_for_control_and_component($control_id, $component->get_location_id(), $component->get_id(), $from_date_ts, $to_date_ts, $repeat_type);
             $cl_criteria = new controller_check_list();
             $cl_criteria->set_control_id($control->get_id());
             $cl_criteria->set_component_id($component->get_id());
             $cl_criteria->set_location_id($component->get_location_id());
             $from_month = $this->get_start_month_for_control($control);
             $to_month = $this->get_end_month_for_control($control);
             // Loops through controls in controls_for_location_array and populates aggregate open cases pr month array.
             $agg_open_cases_pr_month_array = $this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, $to_month);
             $year_calendar_agg = new year_calendar_agg($control, $year, $location_code, "VIEW_LOCATIONS_FOR_CONTROL");
             $calendar_array = $year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
             $components_with_calendar_array[] = array("component" => $component->toArray(), "calendar_array" => $calendar_array);
         }
     } else {
         if ($control->get_repeat_type() > controller_control::REPEAT_TYPE_WEEK) {
             foreach ($locations_for_control_array as $location) {
                 $curr_location_code = $location['location_code'];
                 if (!$bookmark_locations || !in_array($curr_location_code, $bookmark_locations)) {
                     continue;
                 }
                 $repeat_type = $control->get_repeat_type();
                 $check_lists_array = $this->so->get_check_lists_for_control_and_location($control_id, $curr_location_code, $from_date_ts, $to_date_ts, $repeat_type);
                 $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, 'selected' => $bookmarks && isset($bookmarks[$curr_location_code]));
             }
             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()));
                 //FIXME - make generic
                 /* => */
                 if (!isset($_location_name[$component->get_location_code()])) {
                     $_location = execMethod('property.solocation.read_single', $component->get_location_code());
                     $location_arr = explode('-', $component->get_location_code());
                     $i = 1;
                     $name_arr = array();
                     foreach ($location_arr as $_dummy) {
                         $name_arr[] = $_location["loc{$i}_name"];
                         $i++;
                     }
                     $_location_name[$component->get_location_code()] = implode('::', $name_arr);
                 }
                 $short_desc_arr .= ' [' . $_location_name[$component->get_location_code()] . ']';
                 /* <= */
                 $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);
                 $check_lists_array = $component_with_check_lists["check_lists_array"];
                 /*
                  * start override control with data from serie
                  */
                 $control_relation = $component->get_control_relation();
                 if (isset($control_relation['start_date']) && $control_relation['start_date']) {
                     $control->set_start_date($control_relation['start_date']);
                 }
                 if (isset($control_relation['end_date']) && $control_relation['end_date']) {
                     $control->set_end_date($control_relation['end_date']);
                 }
                 if (isset($control_relation['repeat_type']) && $control_relation['repeat_type']) {
                     $control->set_repeat_type($control_relation['repeat_type']);
                 }
                 if (isset($control_relation['repeat_interval']) && $control_relation['repeat_interval']) {
                     $control->set_repeat_interval($control_relation['repeat_interval']);
                 }
                 /*
                  * End override control with data from serie
                  */
                 $year_calendar = new year_calendar($control, $year, $component, null, "component");
                 $calendar_array = $year_calendar->build_calendar($check_lists_array);
                 $components_with_calendar_array[] = array("component" => $component->toArray(), "calendar_array" => $calendar_array);
             }
         }
     }
     // Gets array of locations assigned to current user
     $my_locations = $this->get_my_assigned_locations($location_code);
     $heading_array = year_calendar::get_heading_array();
     $data = array('locations_list' => $locations_list, 'my_locations' => $my_locations, 'control' => $control->toArray(), 'heading_array' => $heading_array, 'locations_with_calendar_array' => $locations_with_calendar_array, 'components_with_calendar_array' => $components_with_calendar_array, 'current_year' => $year, 'location_code' => $location_code, 'serie_id' => $serie_id);
     self::render_template_xsl(array('calendar/view_calendar_year_for_locations', 'calendar/check_list_status_manager', 'calendar/icon_color_map', 'calendar/select_my_locations', 'calendar/nav_calendar_year'), $data);
     phpgwapi_jquery::load_widget('core');
     self::add_javascript('controller', 'controller', 'ajax.js');
 }