/** * Get check list objects for a control on a location with set planned date * * @param $control_id control id * @param $location_code location code representing physical locations * @param $location_id location id representing logical system locations * @param $component_id component id: entity within logical location * @return array with check list objects */ function get_planned_check_lists_for_control($control_id, $location_code, $location_id, $component_id) { $control_id = (int) $control_id; $component_filter = ' AND component_id IS NULL '; if ($component_id) { $location_id = (int) $location_id; $component_id = (int) $component_id; $component_filter = " AND component_id = {$component_id} AND location_id = {$location_id} "; } $sql = "SELECT cl.id as cl_id, cl.status as cl_status, cl.comment as cl_comment, deadline, planned_date, assigned_to,"; $sql .= "completed_date, component_id, location_code, num_open_cases, num_pending_cases, cl.serie_id "; $sql .= "FROM controller_check_list cl "; $sql .= "WHERE cl.control_id = {$control_id} "; $sql .= "AND cl.location_code = '{$location_code}' "; $sql .= "AND NOT cl.planned_date IS NULL "; $sql .= "AND cl.completed_date IS NULL "; $sql .= $component_filter; $sql .= "ORDER BY cl.id;"; $this->db->query($sql); $check_list_id = 0; $check_list = null; while ($this->db->next_record()) { if ($this->db->f('cl_id') != $check_list_id) { if ($check_list_id) { $check_list_array[] = $check_list; } $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'), '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('component_id'), 'int')); $check_list->set_location_code($this->unmarshal($this->db->f('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_id = $check_list->get_id(); } if ($check_list != null) { $check_list_array[] = $check_list; return $check_list_array; } else { return null; } }