function init_calendar() { $ctr_start_date_ts = $this->control->get_start_date(); $ctr_end_date_ts = $this->control->get_end_date(); $period_start_date_ts = $this->get_start_date_month_ts($this->year, $this->month); $period_end_date_ts = $this->get_next_start_date_month_ts($this->year, $this->month); $repeat_type = $this->control->get_repeat_type(); $repeat_interval = $this->control->get_repeat_interval(); $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year); for ($i = 1; $i <= $num_days_in_month; $i++) { $this->calendar_array[$i] = null; } $date_generator = new date_generator($ctr_start_date_ts, $ctr_end_date_ts, $period_start_date_ts, $period_end_date_ts, $repeat_type, $repeat_interval); $dates_array = $date_generator->get_dates(); // Set status for control on each date to NOT DONE or REGISTERED foreach ($dates_array as $date_ts) { $check_list = new controller_check_list(); $check_list->set_deadline($date_ts); $check_list->set_control_id($this->control->get_id()); if ($this->type == "component") { $check_list->set_component_id($this->component->get_id()); $check_list->set_location_id($this->component->get_location_id()); $check_list_status_manager = new check_list_status_manager($check_list, "component"); } else { $check_list->set_location_code($this->location_code); $check_list_status_manager = new check_list_status_manager($check_list, "location"); } $check_list_status_info = $check_list_status_manager->get_status_for_check_list(); $this->calendar_array[date("j", $date_ts)]["status"] = $check_list_status_info->get_status(); $this->calendar_array[date("j", $date_ts)]["info"] = $check_list_status_info->serialize(); } }
function init_calendar() { // Sets null values for twelve months in calendar array for ($i = 1; $i <= 12; $i++) { $this->calendar_array[$i] = null; } if ($this->control_relation && !$this->control_relation['serie_enabled']) { return; } $ctr_start_date_ts = $this->control->get_start_date(); $ctr_end_date_ts = $this->control->get_end_date(); $period_start_date_ts = $this->get_start_date_year_ts($this->year); $period_end_date_ts = $this->get_start_date_year_ts($this->year + 1); $repeat_type = $this->control->get_repeat_type(); $repeat_interval = $this->control->get_repeat_interval(); // Generates dates for time period with specified interval $date_generator = new date_generator($ctr_start_date_ts, $ctr_end_date_ts, $period_start_date_ts, $period_end_date_ts, $repeat_type, $repeat_interval); $dates_array = $date_generator->get_dates(); // Set status for control on each date to NOT DONE or REGISTERED foreach ($dates_array as $date_ts) { $check_list = new controller_check_list(); $check_list->set_deadline($date_ts); $check_list->set_control_id($this->control->get_id()); $check_list->set_assigned_to($this->control_relation['assigned_to']); if ($this->type == "component") { $check_list->set_component_id($this->component->get_id()); $check_list->set_location_id($this->component->get_location_id()); $check_list_status_manager = new check_list_status_manager($check_list, "component"); } else { $check_list->set_location_code($this->location_code); $check_list_status_manager = new check_list_status_manager($check_list, "location"); } $check_list_status_info = $check_list_status_manager->get_status_for_check_list(); $month_nr = date("n", $date_ts); $this->calendar_array[$month_nr]["status"] = $check_list_status_info->get_status(); $this->calendar_array[$month_nr]["info"] = $check_list_status_info->serialize(); if (!$this->calendar_array[$month_nr]["info"]['serie_id']) { $this->calendar_array[$month_nr]["info"]['serie_id'] = $this->control_relation['serie_id']; } $this->calendar_array[$month_nr]["info"]['service_time'] = $this->control_relation['service_time']; $this->calendar_array[$month_nr]["info"]['controle_time'] = $this->control_relation['controle_time']; } }
/** * Show info for homepage * * @return void */ public function home() { $app_id = $GLOBALS['phpgw']->applications->name2id('controller'); if (!isset($GLOBALS['portal_order']) || !in_array($app_id, $GLOBALS['portal_order'])) { $GLOBALS['portal_order'][] = $app_id; } $location_array = array(); $component_short_desc = array(); $component_short_desc[0][0] = ''; $so_check_list = CreateObject('controller.socheck_list'); $so_control = CreateObject('controller.socontrol'); $config = CreateObject('phpgwapi.config', 'controller'); $config->read(); $limit_no_of_planned = isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls']) ? $GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls'] : (isset($config->config_data['no_of_planned_controls']) && $config->config_data['no_of_planned_controls'] > 0 ? $config->config_data['no_of_planned_controls'] : 5); $limit_no_of_assigned = isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls']) ? $GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls'] : (isset($config->config_data['no_of_assigned_controls']) && $config->config_data['no_of_assigned_controls'] > 0 ? $config->config_data['no_of_assigned_controls'] : 10); $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; $styling = "\n" . '<!-- BEGIN checklist info -->' . "\n "; $styling .= "<style>"; $styling .= " .home-box { background: none repeat scroll 0 0 #EDF5FF; border-color: #DBE5EF; border-radius: 4px; margin: 5px 20px 20px;}"; $styling .= " .home-box .home_portal { margin: 0;border: 1px solid #EBF3FC;}"; $styling .= " .home_portal { margin:20px 20px 0 10px; }"; $styling .= " .home_portal a { color:#0066CC;text-decoration: none;text-transform: uppercase; clear:both;display:block;}"; $styling .= " .home_portal h2 { overflow:hidden;clear:left;font-size: 13px;font-weight: bold;text-transform:uppercase; background: #D0DEF4; margin: 0; padding: 2px 10px; color: #1C3C6F;}"; $styling .= " .home_portal h2 div{ display:block;float:left;cursor: pointer;vertical-align: middle;}"; $styling .= " .home_portal .title { width:300px;margin:0 20px 0 0;}"; $styling .= " .home_portal .control-area { width:200px;}"; $styling .= " .home_portal .control { width:300px;}"; $styling .= " .home_portal .date { margin-left: 20px;width:130px;}"; $styling .= " .home_portal li { overflow: hidden;margin: 10px;}"; $styling .= " .home_portal li div { display: block;float:left;cursor: pointer;vertical-align: middle;}"; $styling .= " .home_portal_content ul li { clear: both; overflow: hidden;}"; $styling .= " .home_portal_content { padding:5px 10px;}"; $styling .= " .property_tickets .home_portal_title h2 { font-size: 20px; padding: 5px 10px;}"; $styling .= " h2.heading { font-size: 22px; font-weight: normal;margin: 0 0 0 20px;}"; $styling .= " th.heading { font-size: 22px; font-weight: normal;margin: 0 0 0 20px;}"; $styling .= " tr.off {background: #DEEAF8 }"; $styling .= " h4.expand_trigger { clear:both;overflow:hidden;font-size: 12px;color:#031647;background: #DEEAF8;padding:2px 4px;margin:0; }"; $styling .= " h4.expand_trigger img { float:left;vertical-align:middle;margin-right:3px; }"; $styling .= " h4.expand_trigger span { float:left;display:block;vertical-align:middle; }"; $styling .= " h4.expand_trigger span.deadline { margin-right: 10px; }"; $styling .= " h4.expand_trigger span.num_check_lists { width:200px; }"; $styling .= " .expand_list{ display:none; overflow:hidden; }"; $styling .= " .expand_list li{ clear:both;overflow:hidden;margin:5px 0; }"; $styling .= "</style>"; $styling .= "\n" . '<!-- END checklist info -->' . "\n"; echo $styling; //Loaded from home.php $script = "<script>"; $script .= "\$(document).ready(function(){"; $script .= " \$('.expand_trigger').on('click', function() {"; $script .= " var liTag = \$(this).closest('li'); "; $script .= " var expandList = \$(liTag).find('.expand_list'); "; $script .= " if( !\$(expandList).hasClass('active') ){ \$(expandList).show(); \$(expandList).addClass('active'); "; $script .= " \$(liTag).find('img').attr('src', 'controller/images/arrow_down.png');} "; $script .= " else{ \$(expandList).hide(); \$(expandList).removeClass('active'); "; $script .= " \$(liTag).find('img').attr('src', 'controller/images/arrow_right.png');} "; $script .= " return false; "; $script .= " })"; $script .= " })"; $script .= "</script>"; echo $script; // Fetches my properties $criteria = array('user_id' => $GLOBALS['phpgw_info']['user']['account_id'], 'type_id' => 1, 'role_id' => 0, 'allrows' => false); $location_finder = new location_finder(); $my_properties = $location_finder->get_responsibilities($criteria); // Fetches my buildings $criteria = array('user_id' => $GLOBALS['phpgw_info']['user']['account_id'], 'type_id' => 2, 'role_id' => 0, 'allrows' => false); $location_finder = new location_finder(); $my_buildings = $location_finder->get_responsibilities($criteria); $my_locations = array_merge($my_properties, $my_buildings); /* ======================================= PLANNED CONTROLS FOR CURRENT USER ================================= */ $my_planned_controls_HTML = <<<HTML \t\t\t\t<div class='home_portal'> \t\t\t\t\t<table> \t\t\t\t\t<tr> \t\t\t\t\t\t<th class='date heading'>Planlagt dato</th> \t\t\t\t\t\t<th class='date heading'>Fristdato</th> \t\t\t\t\t\t<th class='control heading'>Tittel på kontroll</th> \t\t\t\t\t\t<th class='title heading'>Lokasjonsnavn</th> \t\t\t\t\t\t<th class='control-area heading'>Kontrollområde</th> \t\t\t\t\t</tr> HTML; // Todays date $from_date_ts = mktime(0, 0, 0, date("n"), date("j"), date("Y")); // One month ahead in time $to_date_ts = mktime(0, 0, 0, date("n") + 1, date("j"), date("Y")); // fetch all repeat types $repeat_type = null; // Fetches controls current user is responsible for 1 month ahead $my_controls = array(); // $my_controls = $this->get_my_controls($my_locations, $from_date_ts, $to_date_ts, $repeat_type); $my_check_lists = $this->get_my_assigned_check_list($from_date_ts, $to_date_ts, $repeat_type); $_assigned_list = array(); foreach ($my_check_lists as $_key => $my_check_list) { $_assigned_list[$my_check_list['location_code']][$_key] = $my_check_list; } foreach ($_assigned_list as $location_code => $controls_at_location) { $my_controls[] = array($location_code, 'assigned', $controls_at_location); } $my_planned_controls = array(); // Generates an array with planned controls foreach ($my_controls as $container_arr) { $location_code = $container_arr[0]; $control_type = $container_arr[1]; $controls = $container_arr[2]; foreach ($controls as $my_control) { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_DAY) { // Daily control: To_date assigned to one week ahead in time if repeat type is daily $to_date_ts = mktime(0, 0, 0, date("n"), date("j") + 7, date("Y")); } else { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_WEEK | $my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH | $my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR) { // Daily, monthly yearly control: to_date in one month $to_date_ts = mktime(0, 0, 0, date("n") + 1, date("j"), date("Y")); } } if ($control_type == "location") { $check_list_array = $so_check_list->get_check_lists_for_control_and_location($my_control['id'], $location_code, $from_date_ts, $to_date_ts, $repeat_type = null, $filter_assigned_to = true); foreach ($check_list_array as $check_list) { $planned_date_for_check_list = $check_list->get_planned_date(); if ($planned_date_for_check_list > 0) { $my_planned_controls[$planned_date_for_check_list][] = array($check_list->get_deadline(), $my_control, $check_list->get_id(), "location", $location_code); } } } else { if ($control_type == "component") { $component = $container_arr[3]; $check_lists_for_control_and_component = $so_check_list->get_check_lists_for_control_and_component($my_control['id'], $component['location_id'], $component['id'], $from_date_ts, $to_date_ts, $repeat_type = null); foreach ($check_lists_for_control_and_component['check_lists_array'] as $check_list) { $planned_date_for_check_list = $check_list->get_planned_date(); if ($planned_date_for_check_list > 0) { $my_planned_controls[$planned_date_for_check_list][] = array($check_list->get_deadline(), $my_control, $check_list->get_id(), "component", $component['location_id'], $component['id']); } } } else { if ($control_type == "assigned") { $check_list_array = $container_arr[2]; foreach ($check_list_array as $check_list) { $planned_date_for_check_list = $check_list['planned_date']; if ($planned_date_for_check_list > 0) { $my_planned_controls[$planned_date_for_check_list][] = array($check_list['deadline'], $my_control, $check_list['id'], "location", $location_code); } } } } } } } // $my_planned_controls_HTML .= "<ul style='overflow:hidden;'>"; foreach ($my_planned_controls as $planned_date_ts => $planned_controls_on_date) { foreach ($planned_controls_on_date as $my_planned_control) { switch ($_row_class) { case 'on': $_row_class = 'off'; break; case 'off': $_row_class = 'on'; break; default: $_row_class = 'on'; } $my_planned_controls_HTML .= "<tr class = '{$_row_class}'>"; $deadline_ts = $my_planned_control[0]; $my_control = $my_planned_control[1]; $location_id = isset($my_control['location_id']) && $my_control['location_id'] ? $my_control['location_id'] : 0; $component_id = isset($my_control['component_id']) && $my_control['component_id'] ? $my_control['component_id'] : 0; $control_area_name = $this->get_control_area_name($my_control["control_area_id"]); $deadline_formatted = date($dateformat, $deadline_ts); $planned_formatted = date($dateformat, $planned_date_ts); $check_list_id = $my_planned_control[2]; $location_code = $my_planned_control[4]; $location_name = $this->get_location_name($location_code); if ($component_id) { $short_descr = $this->get_short_description($location_id, $component_id); $location_name .= "::{$short_descr}"; } $link = ""; // $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicase.add_case', 'check_list_id' => $check_list_id)); // $my_planned_controls_HTML .= "<li><a href='$link'><div class='date'>{$planned_formatted}</div><div class='date'>{$deadline_formatted}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; $my_planned_controls_HTML .= "<td><a href='{$link}'><div class='date'>{$planned_formatted}</div></a></td>"; $my_planned_controls_HTML .= "<td><a href='{$link}'><div class='date'>{$deadline_formatted}</div></a></td>"; $my_planned_controls_HTML .= "<td><a href='{$link}'><div class='control'>{$my_control['title']}</div></a></td>"; $my_planned_controls_HTML .= "<td><a href='{$link}'><div class='title'>{$location_name}</div></a></td>"; $my_planned_controls_HTML .= "<td><a href='{$link}'><div class='control-area'>{$control_area_name}</div></a></td>"; $my_planned_controls_HTML .= "</tr>"; } } if (count($planned_controls_on_date) > 1) { // $my_planned_controls_HTML .= "</li></ul>"; } $my_planned_controls_HTML .= "</table></div>"; // home_portal echo "\n" . '<!-- BEGIN checklist info -->' . "\n <h2 class='heading'>Mine planlagte kontroller</h2><div class='home-box'>" . $my_planned_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n"; /* ======================================= UNDONE ASSIGNED CONTROLS FOR CURRENT USER ================================= */ // from date is set to 3 months back in time $from_date_ts = mktime(0, 0, 0, date("n") - 3, date("j"), date("Y")); $to_date_ts = mktime(0, 0, 0, date("n"), date("j"), date("Y")); // fetch all repeat types $repeat_type = null; // Fetches controls current user is responsible for 3 months back in time $my_controls = $this->get_my_controls($my_locations, $from_date_ts, $to_date_ts, $repeat_type); $my_undone_controls = array(); // Generates an array containing undone controls foreach ($my_controls as $container_arr) { $location_code = $container_arr[0]; $control_type = $container_arr[1]; $controls = $container_arr[2]; foreach ($controls as $my_control) { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_DAY) { // DAILY CONTROLS: Fetch undone controls one week back in time $from_date_ts = mktime(0, 0, 0, date("n"), date("j") - 7, date("Y")); } else { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_WEEK) { // WEEKLY CONTROLS: Fetch undone controls one month back in time $from_date_ts = mktime(0, 0, 0, date("n") - 1, date("j"), date("Y")); } else { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH) { // MONTHLY CONTROLS: Fetch undone controls three months back in time $from_date_ts = mktime(0, 0, 0, date("n") - 3, date("j"), date("Y")); } else { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR) { // YEARLY CONTROLS: Fetch undone controls one year back in time $from_date_ts = mktime(0, 0, 0, date("n"), date("j"), date("Y") - 1); } } } } $date_generator = new date_generator($my_control["start_date"], $my_control["end_date"], $from_date_ts, $to_date_ts, $my_control["repeat_type"], $my_control["repeat_interval"]); $deadline_dates_for_control = $date_generator->get_dates(); $check_list_array = array(); foreach ($deadline_dates_for_control as $deadline_ts) { $check_list = null; if ($control_type == "location") { $check_list = $so_check_list->get_check_list_for_control_by_date($my_control['id'], $deadline_ts, null, $location_code, null, null, "location"); } else { if ($control_type == "component") { $component = $container_arr[3]; $check_list = $so_check_list->get_check_list_for_control_by_date($my_control['id'], $deadline_ts, null, null, $component['location_id'], $component['id'], "component"); } } $control_id = $my_control['id']; if ($check_list == null & $control_type == "location") { $my_undone_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, "location", $location_code); } else { if ($check_list == null & $control_type == "component") { $component = $container_arr[3]; $my_undone_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, "component", $component['location_id'], $component['id']); } else { if ($check_list->get_status() == controller_check_list::STATUS_NOT_DONE || $check_list->get_status() == controller_check_list::STATUS_CANCELED) { $my_undone_controls[$deadline_ts][] = array("edit", $deadline_ts, $my_control, $check_list->get_id(), $location_code); } } } } } } //Add assigned $my_check_lists = $this->get_my_assigned_check_list($from_date_ts, $to_date_ts, $repeat_type, true); /*?? $_assigned_list = array(); foreach ($my_check_lists as $_key => $my_check_list) { $_assigned_list[$my_check_list['location_code']][$_key] = $my_check_list; } */ foreach ($my_check_lists as $_key => $my_check_list) { $my_undone_controls[$my_check_list['deadline']][] = array("edit", $my_check_list['deadline'], $my_check_list, $_key, $my_check_list['location_code']); } //_debug_array($my_undone_controls); ksort($my_undone_controls); $my_undone_controls_HTML = <<<HTML \t\t\t <div class='home_portal'> \t\t\t \t<h2> \t\t\t \t\t<div class='date heading'>Fristdato</div> \t\t\t \t\t<div class='control heading'>Tittel på kontroll</div> \t\t\t \t\t<div class='title heading'>Lokasjonsnavn</div> \t\t\t \t\t<div class='control-area heading'>Kontrollområde</div> \t\t\t \t</h2> HTML; // Sorts my_undone_controls by deadline date ksort($my_undone_controls); $my_undone_controls_HTML .= "<ul>"; $lang_planned_date = lang('planned date'); foreach ($my_undone_controls as $date_ts => $controls_on_date) { // If number of controls on a date exceeds 1 it will be put in expand list if (count($controls_on_date) > 1) { $my_undone_controls_HTML .= "<li>"; $my_undone_controls_HTML .= "<a href='#'><h4 class='expand_trigger'><img height='12' src='controller/images/arrow_right.png' /><span class='deadline'>" . date($dateformat, $date_ts) . "</span><span class='num_check_lists'>(" . count($controls_on_date) . " kontroller)</span></h4></a>"; $my_undone_controls_HTML .= "<ul class='expand_list'>"; } foreach ($controls_on_date as $my_undone_control) { $check_list_status = $my_undone_control[0]; $deadline_ts = $my_undone_control[1]; $my_control = $my_undone_control[2]; $control_area_name = $this->get_control_area_name($my_control["control_area_id"]); $date_str = date($dateformat, $deadline_ts); if ($my_control['planned_date']) { $date_str_planned = $lang_planned_date . ': ' . date($dateformat, $my_control['planned_date']); } if ($check_list_status == "add") { $check_list_type = $my_undone_control[3]; if ($check_list_type == "location") { $location_code = $my_undone_control[4]; $location_name = $this->get_location_name($location_code); if (count($controls_on_date) > 1) { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => $my_control['id'], 'location_code' => $location_code, 'deadline_ts' => $deadline_ts)); $my_undone_controls_HTML .= "<li><a href='{$link}' title = '{$date_str_planned}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } else { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => $my_control['id'], 'location_code' => $location_code, 'deadline_ts' => $deadline_ts)); $my_undone_controls_HTML .= "<a href='{$link} title = '{$date_str_planned}''><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a>"; } } else { if ($check_list_type == "component") { $location_id = $my_undone_control[4]; $component_id = $my_undone_control[5]; $short_descr = $this->get_short_description($location_id, $component_id); if (count($controls_on_date) > 1) { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' => $my_control['id'], 'location_id' => $location_id, 'component_id' => $component_id, 'deadline_ts' => $deadline_ts)); $my_undone_controls_HTML .= "<li><a href='{$link}' title = '{$date_str_planned}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$short_descr}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } else { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' => $my_control['id'], 'location_id' => $location_id, 'component_id' => $component_id, 'deadline_ts' => $deadline_ts)); $my_undone_controls_HTML .= "<a href='{$link}' title = '{$date_str_planned}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$short_descr}</div><div class='control-area'>{$control_area_name}</div></a>"; } } } } else { if ($check_list_status == "edit") { $location_id = isset($my_control['location_id']) && $my_control['location_id'] ? $my_control['location_id'] : 0; $component_id = isset($my_control['component_id']) && $my_control['component_id'] ? $my_control['component_id'] : 0; $check_list_id = $my_undone_control[3]; $location_code = $my_undone_control[4]; $location_name = $this->get_location_name($location_code); if ($component_id) { $short_descr = $this->get_short_description($location_id, $component_id); $location_name .= "::{$short_descr}"; } if (count($controls_on_date) > 1) { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); $my_undone_controls_HTML .= "<li><a href='{$link}' title = '{$date_str_planned}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } else { $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); $my_undone_controls_HTML .= "<li><a href='{$link}' title = '{$date_str_planned}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } } } } if (count($controls_on_date) > 1) { $my_undone_controls_HTML .= "</ul>"; $my_undone_controls_HTML .= "</li>"; } } $my_undone_controls_HTML .= "</ul>"; $my_undone_controls_HTML .= "</div>"; // home_portal echo "\n" . '<!-- BEGIN checklist info -->' . "\n <h2 class='heading'>Mine ugjorte kontroller</h2><div class='home-box'>" . $my_undone_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n"; /* ================================ CONTROLS ASSIGNED TO CURRENT USER ================================= */ $my_assigned_controls_HTML = <<<HTML \t\t\t\t<div class='home_portal'> \t\t\t\t\t<h2> \t\t\t\t\t\t<div class='date heading'>Fristdato</div> \t\t\t\t\t\t<div class='control heading'>Tittel på kontroll</div> \t\t\t\t\t\t<div class='title heading'>Lokasjonsnavn</div> \t\t\t\t\t\t<div class='control-area heading'>Kontrollområde</div> \t\t\t\t\t</h2> HTML; $from_date_ts = strtotime("now"); $to_date_ts = mktime(0, 0, 0, date("n") + 1, date("j"), date("Y")); // fetch all repeat types $repeat_type = null; // Fetches controls current user is responsible for 1 month ahead in time $my_controls = array(); $my_controls = $this->get_my_controls($my_locations, $from_date_ts, $to_date_ts, $repeat_type); $my_assigned_controls = array(); $from_date_ts = mktime(0, 0, 0, date("n"), date("j"), date("Y")); // Generates an array with undone controls foreach ($my_controls as $container_arr) { $location_code = $container_arr[0]; $control_type = $container_arr[1]; $controls = $container_arr[2]; foreach ($controls as $my_control) { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_DAY) { // Daily control: Todate in one week $to_date_ts = mktime(0, 0, 0, date("n"), date("j") + 7, date("Y")); } else { if ($my_control["repeat_type"] == controller_control::REPEAT_TYPE_WEEK | $my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH | $my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR) { // Daily, monthly yearly control: to_date in one month $to_date_ts = mktime(0, 0, 0, date("n") + 1, date("j"), date("Y")); } } $date_generator = new date_generator($my_control["start_date"], $my_control["end_date"], $from_date_ts, $to_date_ts, $my_control["repeat_type"], $my_control["repeat_interval"]); $deadline_dates_for_control = $date_generator->get_dates(); $check_list_array = array(); foreach ($deadline_dates_for_control as $deadline_ts) { $check_list = null; if ($control_type == "location") { // Gets checklist for control with current date as deadline if there exists one $check_list = $so_check_list->get_check_list_for_control_by_date($my_control['id'], $deadline_ts, null, $location_code, null, null, "location"); } else { if ($control_type == "component") { $component = $container_arr[3]; // Gets checklist for control with current date as deadline if there exists one $check_list = $so_check_list->get_check_list_for_control_by_date($my_control['id'], $deadline_ts, null, null, $component['location_id'], $component['id'], "component"); } } // Check if there is a checklist on the deadline if ($check_list == null) { if ($control_type == "location") { $my_assigned_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, "location", $location_code); } else { if ($control_type == "component") { $component = $container_arr[3]; $my_assigned_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, "component", $component['location_id'], $component['id']); } } } else { if (($check_list->get_planned_date() == '' || $check_list->get_planned_date() == 0) && ($check_list->get_status() == controller_check_list::STATUS_NOT_DONE || $check_list->get_status() == controller_check_list::STATUS_CANCELED)) { $my_assigned_controls[$deadline_ts][] = array("edit", $deadline_ts, $my_control, $check_list->get_id(), $location_code); } } } } } // Sorts my_undone_controls by deadline date $cats = CreateObject('phpgwapi.categories', -1, 'controller', '.control'); $cats->supress_info = true; $control_areas = $cats->formatted_xslt_list(array('format' => 'filter', 'selected' => '', 'globals' => true, 'use_acl' => $this->_category_acl)); $my_assigned_controls_HTML .= "<ul>"; foreach ($my_assigned_controls as $date_ts => $assigned_controls_on_date) { if (count($assigned_controls_on_date) > 1) { $my_assigned_controls_HTML .= "<li>"; $my_assigned_controls_HTML .= "<a href='#'><h4 class='expand_trigger'><img height='12' src='controller/images/arrow_right.png' /><span class='deadline'>" . date($dateformat, $date_ts) . "</span><span class='num_controls'>(" . count($assigned_controls_on_date) . " kontroller)</span></h4></a>"; $my_assigned_controls_HTML .= "<ul class='expand_list'>"; } foreach ($assigned_controls_on_date as $my_assigned_control) { $check_list_status = $my_assigned_control[0]; $deadline_ts = $my_assigned_control[1]; $my_control = $my_assigned_control[2]; reset($control_areas['cat_list']); foreach ($control_areas['cat_list'] as $area) { if ($area['cat_id'] == $my_control["control_area_id"]) { $control_area_name = $area['name']; } } $date_str = date($dateformat, $deadline_ts); if ($check_list_status == "add") { $check_list_type = $my_assigned_control[3]; if ($check_list_type == "location") { $location_code = $my_assigned_control[4]; $location_name = $this->get_location_name($location_code); $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => $my_control['id'], 'location_code' => $location_code, 'deadline_ts' => $deadline_ts)); $my_assigned_controls_HTML .= "<li><a href='{$link}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } else { if ($check_list_type == "component") { $location_id = $my_assigned_control[4]; $component_id = $my_assigned_control[5]; $short_descr = $this->get_short_description($location_id, $component_id); $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' => $my_control['id'], 'location_id' => $location_id, 'component_id' => $component_id, 'deadline_ts' => $deadline_ts)); $my_assigned_controls_HTML .= "<li><a href='{$link}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$short_descr}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } } } else { if ($check_list_status == "edit") { $check_list_id = $my_assigned_control[3]; $location_code = $my_assigned_control[4]; $location_name = $this->get_location_name($location_code); $link = ""; $link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); $my_assigned_controls_HTML .= "<li><a href='{$link}'><div class='date'>{$date_str}</div><div class='control'>{$my_control['title']}</div><div class='title'>{$location_name}</div><div class='control-area'>{$control_area_name}</div></a></li>"; } } } if (count($assigned_controls_on_date) > 1) { $my_assigned_controls_HTML .= "</li>"; $my_assigned_controls_HTML .= "</ul>"; } } $my_assigned_controls_HTML .= "</ul>"; $my_assigned_controls_HTML .= "</div>"; // home_portal echo "\n" . '<!-- BEGIN checklist info -->' . "\n <h2 class='heading'>Mine tildelte kontroller</h2><div class='home-box'>" . $my_assigned_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n"; }