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']; } }
function add_check_list($data = array()) { phpgw::import_class('controller.socheck_list'); include_class('controller', 'check_list', 'inc/model/'); $control_id = $data['control_id']; $type = 'component'; $comment = ''; $assigned_to = $data['assigned_to']; $billable_hours = phpgw::get_var('billable_hours', 'float'); $deadline_date_ts = $data['start_date']; $planned_date_ts = $deadline_date_ts; $completed_date_ts = 0; $check_list = new controller_check_list(); $check_list->set_control_id($control_id); $check_list->set_location_code($data['location_code']); $check_list->set_location_id($data['location_id']); $check_list->set_component_id($data['component_id']); $status = controller_check_list::STATUS_NOT_DONE; $check_list->set_status($status); $check_list->set_comment($comment); $check_list->set_deadline($deadline_date_ts); $check_list->set_planned_date($planned_date_ts); $check_list->set_completed_date($completed_date_ts); $check_list->set_assigned_to($assigned_to); $check_list->set_billable_hours($billable_hours); $socheck_list = CreateObject('controller.socheck_list'); if ($check_list->validate() && ($check_list_id = $socheck_list->store($check_list))) { return $check_list_id; } else { return false; } }
/** * Public function for saving a check list * * @param HTTP:: location code, control id, status etc.. (check list details) * @return data array */ function save_check_list() { $check_list_id = phpgw::get_var('check_list_id'); if (!$this->add && !$this->edit) { phpgwapi_cache::message_set('No access', 'error'); $this->redirect(array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); } $control_id = phpgw::get_var('control_id', 'int'); $serie_id = phpgw::get_var('serie_id', 'int'); $status = (int) phpgw::get_var('status'); $type = phpgw::get_var('type'); $deadline_date = phpgw::get_var('deadline_date', 'string'); $planned_date = phpgw::get_var('planned_date', 'string'); $completed_date = phpgw::get_var('completed_date', 'string'); $comment = phpgw::get_var('comment', 'string'); $assigned_to = phpgw::get_var('assigned_to', 'int'); $billable_hours = phpgw::get_var('billable_hours', 'float'); $deadline_date_ts = date_converter::date_to_timestamp($deadline_date); $error = false; if ($planned_date != '') { $planned_date_ts = date_converter::date_to_timestamp($planned_date); } else { $planned_date_ts = $deadline_date_ts; } if ($completed_date != '') { $completed_date_ts = phpgwapi_datetime::date_to_timestamp($completed_date); $status = controller_check_list::STATUS_DONE; } else { $completed_date_ts = 0; } if ($check_list_id > 0) { $check_list = $this->so->get_single($check_list_id); if ($status == controller_check_list::STATUS_DONE) { if (!$this->_check_for_required($check_list)) { $this->redirect(array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); } } } else { if ($status == controller_check_list::STATUS_DONE) { $status = controller_check_list::STATUS_NOT_DONE; $completed_date_ts = 0; $error_message = "Status kunne ikke settes til utført - prøv igjen"; $error = true; phpgwapi_cache::message_set($error_message, 'error'); } $check_list = new controller_check_list(); $check_list->set_control_id($control_id); $location_code = phpgw::get_var('location_code'); $check_list->set_location_code($location_code); $check_list->set_serie_id($serie_id); if ($type == "component") { $location_id = phpgw::get_var('location_id'); $component_id = phpgw::get_var('component_id'); $check_list->set_location_id($location_id); $check_list->set_component_id($component_id); } } $check_list->set_comment($comment); $check_list->set_deadline($deadline_date_ts); $check_list->set_planned_date($planned_date_ts); $check_list->set_completed_date($completed_date_ts); $orig_assigned_to = $check_list->get_assigned_to(); $check_list->set_assigned_to($assigned_to); $config = CreateObject('phpgwapi.config', 'controller'); $config->read(); $required_actual_hours = isset($config->config_data['required_actual_hours']) && $config->config_data['required_actual_hours'] ? $config->config_data['required_actual_hours'] : false; if ($status == controller_check_list::STATUS_DONE && $required_actual_hours && $check_list->get_billable_hours() == 0 && !$billable_hours) { phpgwapi_cache::message_set(lang("Please enter billable hours"), 'error'); $error = true; } else { $check_list->set_delta_billable_hours($billable_hours); } if ($status == controller_check_list::STATUS_DONE && $this->_check_for_required($check_list) && !$error) { $check_list->set_status($status); } else { if ($status == controller_check_list::STATUS_CANCELED && !$error) { $check_list->set_status($status); } } if (!$error && $check_list->validate()) { $check_list_id = $this->so->store($check_list); $serie = $this->so_control->get_serie($check_list->get_serie_id()); /** * Add an iCal-event if there is a serie - and the checklist is visited the first time - or assigned is changed */ if (phpgw::get_var('request_ical_event', 'bool') && $check_list_id && $serie) { $bocommon = CreateObject('property.bocommon'); $current_prefs_user = $bocommon->create_preferences('property', $GLOBALS['phpgw_info']['user']['account_id']); $from_address = "{$GLOBALS['phpgw_info']['user']['fullname']}<{$current_prefs_user['email']}>"; $from_name = $GLOBALS['phpgw_info']['user']['fullname']; $to_name = $GLOBALS['phpgw']->accounts->id2name($assigned_to); $prefs_target = $bocommon->create_preferences('property', $assigned_to); $to_address = $prefs_target['email']; if (!($start_date = $check_list->get_planned_date())) { $start_date = $check_list->get_deadline(); } $startTime = $start_date + 8 * 3600; $endTime = $startTime + (double) $serie['service_time'] * 3600 + (double) $serie['controle_time'] * 3600; if ($check_list->get_component_id() > 0) { $component_arr = execMethod('property.soentity.read_single_eav', array('location_id' => $check_list->get_location_id(), 'id' => $check_list->get_component_id())); $location_name = execMethod('property.bolocation.get_location_name', $component_arr['location_code']); $short_desc = $location_name . '::' . execMethod('property.soentity.get_short_description', array('location_id' => $check_list->get_location_id(), 'id' => $check_list->get_component_id())); $location = $location_name; } $repeat_type_array = array("0" => lang('day'), "1" => lang('week'), "2" => lang('month'), "3" => lang('year')); $subject = "{$repeat_type_array[$serie['repeat_type']]}/{$serie['repeat_interval']}"; $subject .= "::{$serie['title']}::{$short_desc}"; $link_backend = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'control_id' => $check_list->get_control_id(), 'location_id' => $check_list->get_location_id(), 'component_id' => $check_list->get_component_id(), 'serie_id' => $check_list->get_serie_id(), 'type' => 'component', 'assigned_to' => $check_list->get_assigned_to(), 'deadline_current' => true), false, true, true); $link_mobilefrontend = $GLOBALS['phpgw']->link('/mobilefrontend/index.php', array('menuaction' => 'controller.uicheck_list.add_check_list', 'control_id' => $check_list->get_control_id(), 'location_id' => $check_list->get_location_id(), 'component_id' => $check_list->get_component_id(), 'serie_id' => $check_list->get_serie_id(), 'type' => 'component', 'assigned_to' => $check_list->get_assigned_to(), 'deadline_current' => true), false, true, true); $html_description = "<a href ='{$link_mobilefrontend}'>Serie#" . $check_list->get_serie_id() . '::Mobilefrontend</a><br/><br/>'; $html_description .= "<a href ='{$link_backend}'>Serie#" . $check_list->get_serie_id() . '::Backend</a>'; $_serie_id = $check_list->get_serie_id(); $text_description = str_replace('&', '&', "Serie#{$_serie_id}::Mobilefrontend:\\n{$link_mobilefrontend}\\n\\nSerie#{$_serie_id}::Backend:\\n{$link_backend}"); if ($from_address && $to_address) { $this->sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $html_description, $text_description, $location); } else { phpgwapi_cache::message_set("Mangler epostadresse til avsender eller addresat - eller begge", 'error'); } } if ($check_list_id > 0) { $this->redirect(array('menuaction' => 'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id)); } else { $this->edit_check_list($check_list); } } else { if ($check_list->get_id() > 0) { $this->edit_check_list($check_list); } else { $this->redirect(array('menuaction' => 'controller.uicheck_list.add_check_list', 'control_id' => $control_id, 'location_id' => $location_id, 'component_id' => $component_id, 'serie_id' => $serie_id, 'deadline_ts' => $deadline_date_ts, 'type' => $type, 'assigned_to' => $assigned_to, 'status' => $status)); } } }
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'); }
/** * Get array with check lists for a control on a component within time period and for a specified repeat type * * @param $control_id control id * @param $location_code location code * @param $from_date_ts start time period * @param $to_date_ts end time period * @param $repeat_type_expr repeat type expression * @return array with check list objects */ function get_check_lists_for_control_and_component($control_id, $location_id, $component_id, $from_date_ts, $to_date_ts, $repeat_type = null, $user_id = 0) { $control_id = (int) $control_id; $location_id = (int) $location_id; $component_id = (int) $component_id; $user_id = (int) $user_id; $sql = "SELECT cl.id as cl_id, cl.status as cl_status, cl.comment as cl_comment, deadline, planned_date, completed_date, cl.assigned_to, "; $sql .= "cl.component_id as cl_component_id, cl.location_id as cl_location_id," . " cl.location_code as cl_location_code, num_open_cases, num_pending_cases ,cl.serie_id, cl.billable_hours, cs.repeat_type "; $sql .= "FROM controller_check_list cl "; $sql .= "LEFT JOIN controller_control c on cl.control_id = c.id "; $sql .= "LEFT JOIN controller_control_serie cs on cl.serie_id = cs.id "; $sql .= "WHERE cl.control_id = {$control_id} "; $sql .= "AND cl.component_id = {$component_id} "; $sql .= "AND cl.location_id = {$location_id} "; if ($repeat_type != null) { $sql .= "AND c.repeat_type = {$repeat_type} "; } // if($user_id) // { // $sql .= " AND assigned_to = {$user_id} "; // } $sql .= "AND deadline BETWEEN {$from_date_ts} AND {$to_date_ts} "; // _debug_array($sql); $this->db->query($sql); $check_lists_array = array(); while ($this->db->next_record()) { $check_list = new controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int')); $check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int')); $check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 'string')); $check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int')); $check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 'int')); $check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'), 'int')); $check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id'), 'int')); $check_list->set_location_id($this->unmarshal($this->db->f('cl_location_id'), 'int')); $check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code', true), 'string')); $check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'), 'int')); $check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'), 'int')); $check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 'int')); $check_list->set_serie_id($this->db->f('serie_id')); $check_list->set_repeat_type($this->db->f('repeat_type')); $check_list->set_billable_hours((double) $this->db->f('billable_hours')); $check_lists_array[] = $check_list; } return array("location_code" => $location_code, "check_lists_array" => $check_lists_array); }
/** * 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_assigned_check_list_by_component($from_date, $to_date, $repeat_type, $user_id, $completed = null, $return_type = "return_object") { $repeat_type = $repeat_type; $user_id = (int) $user_id; $sql = "SELECT DISTINCT controller_check_list.location_code, controller_check_list.control_id, controller_check_list.id AS check_list_id," . " controller_control.description, controller_control.start_date, end_date, deadline,planned_date, completed_date," . " control_area_id,controller_check_list.location_id,title,controller_check_list.component_id" . " FROM controller_check_list" . " {$this->join} controller_control ON controller_check_list.control_id = controller_control.id" . " {$this->join} controller_control_component_list " . " ON (controller_control_component_list.control_id = controller_check_list.control_id" . " AND controller_control_component_list.location_id = controller_check_list.location_id" . " AND controller_control_component_list.component_id = controller_check_list.component_id)" . " WHERE controller_check_list.assigned_to = {$user_id} AND status = 0"; if ($repeat_type) { // $sql .= "AND controller_control.repeat_type = $repeat_type "; } //FIXME if ($completed) { $sql .= " AND ( planned_date < {$to_date} AND controller_check_list.completed_date IS NULL) "; // $sql .= " AND ((deadline <= $to_date AND controller_control.end_date IS NULL) "; // $sql .= " OR (deadline <= $to_date AND deadline > $from_date ))"; // $sql .= " AND controller_check_list.completed_date IS NULL "; } else { $sql .= " AND (planned_date > {$from_date} AND planned_date <= {$to_date} AND controller_control.end_date IS NULL) "; } $this->db->query($sql); $check_list_array = array(); while ($this->db->next_record()) { $check_list = new controller_check_list($this->unmarshal($this->db->f('check_list_id'), 'int')); $check_list->set_control_id($this->unmarshal($this->db->f('control_id'), 'int')); $check_list->set_location_id($this->unmarshal($this->db->f('location_id'), 'int')); $check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 'int')); $check_list->set_title($this->unmarshal($this->db->f('title', true), 'string')); $check_list->set_description($this->unmarshal($this->db->f('description', true), 'string')); $check_list->set_start_date($this->unmarshal($this->db->f('start_date'), 'int')); $check_list->set_end_date($this->unmarshal($this->db->f('end_date'), 'int')); $check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int')); $check_list->set_control_area_id($this->unmarshal($this->db->f('control_area_id'), 'int')); $check_list->set_assigned_to($this->unmarshal($user_id, 'int')); $check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 'int')); $check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'), 'int')); $check_list->set_location_code($this->unmarshal($this->db->f('location_code', true), 'string')); if ($return_type == "return_object") { $check_list_array[] = $check_list; } else { $check_list_array[] = $check_list->toArray(); } } return $check_list_array; }