public static function get_selectable_projects($employee_id = 0, $date = '0000-00-00') { $project_array = array(); $role_array = role::get_selectable_roles($employee_id, $date); // Receive array of available roles if (tep_not_null($role_array)) { $database = $_SESSION['database']; $project_query = 'select projects_id, projects_name, projects_description, projects_customers_contact_name, projects_customers_reference, projects_start_date, projects_end_date, projects_calculated_hours, customers_id from ' . TABLE_PROJECTS . ' where projects_id in ('; // Walk through the array foreach ($role_array as $role) { if (substr($project_query, -1) != '(') { $project_query .= ','; } $project_query .= $role['projects_id']; } $project_query .= ') order by projects_name'; $project_query = $database->query($project_query); while ($project_result = $database->fetch_array($project_query)) { array_push($project_array, $project_result); } } return $project_array; }
} ?> </form> </td> </tr> <tr> <td class="item_entry"> <?php echo TEXT_ACTIVITY_ROLENAME; ?> </td> <td class="item_entry"> <?php echo tep_draw_form('role_selection', tep_href_link(FILENAME_TIMEREGISTRATION)) . tep_create_parameters(array('action' => 'enter_data'), array('mPath', 'period', 'sort_order', 'selected_date', 'projects_id', 'activity_id'), 'hidden_field'); if ($_POST['action'] == 'select_role' || $_POST['action'] == 'enter_data' || $_POST['action'] == 'save_data') { echo tep_html_select('roles_id', tep_get_partial_array(role::get_selectable_roles($_SESSION['employee']->id, tep_strftime('%Y-%m-%d', $_POST['selected_date']), $_POST['projects_id']), 'roles_id', 'roles_name'), TRUE, $_POST['roles_id']); } else { echo tep_html_select('roles_id', array(), FALSE); } ?> </form> </td> </tr> <?php if ($_POST['action'] == 'enter_data' || $_POST['action'] == 'save_data') { echo tep_draw_form('activity_entry', tep_href_link(FILENAME_TIMEREGISTRATION)) . tep_create_parameters(array('action' => 'save_data'), array('mPath', 'period', 'sort_order', 'selected_date', 'projects_id', 'roles_id', 'activity_id', 'error_level_history', 'previous_activity_amount', 'original_activity_amount'), 'hidden_field'); } ?> <tr> <td class="item_entry"> <?php