protected function set_filter_fields() { $_rows = Bll_DdCommonBiz::get_instance()->get_departments_new(); $departments = array(); foreach ($_rows as $_row) { $departments[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_environments(); $environments = array(); foreach ($_rows as $_row) { $environments[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_reasons(); $reasons = array(); foreach ($_rows as $_row) { $reasons[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_resolutions(); $resolutions = array('0' => 'None'); foreach ($_rows as $_row) { $resolutions[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_prioritys(); $prioritys = array(); foreach ($_rows as $_row) { $prioritys[$_row->id] = $_row->name; } $_rows = Bll_DdComponentBiz::get_instance()->get_all_components(); $components = array(); foreach ($_rows as $_row) { $components[$_row->int] = $_row->name; } $_rows = Ticket_Status::get_all_status(); $statuses = array(); foreach ($_rows as $_row) { $statuses[$_row] = $_row; } $fields = array('assigned_qa' => array('type' => 'input', 'operates' => array('is', 'is not')), 'component' => array('type' => 'input', 'operates' => array('is', 'is not')), 'created_at' => array('type' => 'dateinput'), 'closed_at' => array('type' => 'dateinput'), 'department' => array('type' => 'checkbox', 'options' => $departments), 'environment' => array('type' => 'checkbox', 'options' => $environments), 'is_occasional' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'is_regression' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'keyword' => array('type' => 'input', 'operates' => array('ticket title', 'ticket description')), 'owner' => array('type' => 'input', 'operates' => array('is', 'is not')), 'person_liable' => array('type' => 'input', 'operates' => array('is', 'is not')), 'pmt_id' => array('type' => 'input', 'operates' => array('is', 'is not')), 'priority' => array('type' => 'checkbox', 'options' => $prioritys), 'reason' => array('type' => 'checkbox', 'options' => $reasons), 'reporter' => array('type' => 'input', 'operates' => array('is', 'is not')), 'resolution' => array('type' => 'checkbox', 'options' => $resolutions), 'status' => array('type' => 'checkbox', 'options' => $statuses), 'updated_at' => array('type' => 'dateinput'), 'reject' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'reopen' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No'))); $all_users = Bll_UserBiz::get_instance()->get_all_users(); $tmp_all = array(); foreach ($all_users as $key => $value) { $tmp_all[$key] = $value->whole_name; } $this->fields = $fields; }
protected function set_filter_fields() { $_rows = Bll_DdCommonBiz::get_instance()->get_departments_new(); $departments = array(); foreach ($_rows as $_row) { $departments[$_row->id] = $_row->name; } $this->request->set_attribute('departments', $departments); $_rows = Bll_DdCommonBiz::get_instance()->get_environments(); $environments = array(); foreach ($_rows as $_row) { $environments[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_reasons(); $reasons = array(); foreach ($_rows as $_row) { $reasons[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_resolutions(); $resolutions = array('0' => 'None'); foreach ($_rows as $_row) { $resolutions[$_row->id] = $_row->name; } $_rows = Bll_DdCommonBiz::get_instance()->get_prioritys(); $prioritys = array(); foreach ($_rows as $_row) { $prioritys[$_row->id] = $_row->name; } $_rows = Bll_DdComponentBiz::get_instance()->get_all_components(); $components = array(); foreach ($_rows as $_row) { $components[$_row->int] = $_row->name; } $_rows = Ticket_Status::get_all_status(); $statuses = array(); foreach ($_rows as $_row) { $statuses[$_row] = $_row; } $fields = array('assigned_qa' => array('type' => 'input', 'operates' => array('is', 'is not')), 'component' => array('type' => 'input', 'operates' => array('is', 'is not')), 'created_at' => array('type' => 'dateinput'), 'closed_at' => array('type' => 'dateinput'), 'department' => array('type' => 'checkbox', 'options' => $departments), 'environment' => array('type' => 'checkbox', 'options' => $environments), 'is_occasional' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'is_regression' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'keyword' => array('type' => 'input', 'operates' => array('ticket title', 'ticket description')), 'owner' => array('type' => 'input', 'operates' => array('is', 'is not')), 'person_liable' => array('type' => 'input', 'operates' => array('is', 'is not')), 'pmt_id' => array('type' => 'input', 'operates' => array('is', 'is not')), 'priority' => array('type' => 'checkbox', 'options' => $prioritys), 'reason' => array('type' => 'checkbox', 'options' => $reasons), 'reporter' => array('type' => 'input', 'operates' => array('is', 'is not')), 'resolution' => array('type' => 'checkbox', 'options' => $resolutions), 'status' => array('type' => 'checkbox', 'options' => $statuses), 'updated_at' => array('type' => 'dateinput'), 'reject' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'reopen' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No'))); $column = array('1' => array('id' => 'owner', 'value' => 'Owner', 'check' => '1'), '2' => array('id' => 'priority', 'value' => 'Priority', 'check' => '1'), '3' => array('id' => 'component', 'value' => 'Component', 'check' => '1'), '4' => array('id' => 'pmt_id', 'value' => 'PMT ID', 'check' => '1'), '5' => array('id' => 'environment', 'value' => 'Environment', 'check' => '1'), '6' => array('id' => 'created_at', 'value' => 'Created Time', 'check' => '1'), '7' => array('id' => 'updated_at', 'value' => 'Last Updated', 'check' => '1'), '8' => array('id' => 'status', 'value' => 'Status', 'check' => '1'), '9' => array('id' => 'assigned_qa', 'value' => 'Assigned QA', 'check' => '0'), '10' => array('id' => 'reporter', 'value' => 'Reporter', 'check' => '0'), '11' => array('id' => 'resolution', 'value' => 'Resolution', 'check' => '0'), '12' => array('id' => 'reason', 'value' => 'Reason', 'check' => '0'), '13' => array('id' => 'person_liable', 'value' => 'Person Liable', 'check' => '0'), '14' => array('id' => 'is_regression', 'value' => 'Is Regression', 'check' => '0'), '15' => array('id' => 'is_occasional', 'value' => 'Is Occasional', 'check' => '0'), '16' => array('id' => 'reason_detail', 'value' => 'Reason Detail', 'check' => '0'), '17' => array('id' => 'description', 'value' => 'Description', 'check' => '0')); $all_users = Bll_UserBiz::get_instance()->get_all_users(); $tmp_all = array(); foreach ($all_users as $key => $value) { $tmp_all[$key] = $value->whole_name; } $all_users = json_encode($tmp_all); $this->fields = $fields; $this->request->set_attribute('users', $all_users); $this->request->set_attribute('fields', $fields); $this->request->set_attribute('column', $column); }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $params = $req->get_parameters(); $pmt_id = $params['form_pmt'] ? trim($params['form_pmt']) : 0; if ($pmt_id != 0) { //project detail table $project = Bll_PMTProjectBiz::get_instance()->get_project_detail_by_ids(array($pmt_id)); $table_project = array(); if (!empty($project)) { $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids(array($pmt_id)); $rates = Bll_ReportPmtInfoBiz::get_instance()->get_through_rate_by_pmtids(array($pmt_id)); $delay_info = Bll_ReportPmtInfoBiz::get_instance()->get_project_delay_info_by_pmtids(array($pmt_id)); $dev_person = array(); $test_person = array(); foreach ($tasks as $task) { if (in_array($task['task_type_id'], array(2, 3, 33))) { $dev_person[] = $task['chinese_name']; } else { if (in_array($task['task_type_id'], array(4))) { $test_person[] = $task['chinese_name']; } } } $dev_person = array_unique($dev_person); $test_person = array_unique($test_person); $table_project['dev_person'] = implode("/", $dev_person); $table_project['test_person'] = implode("/", $test_person); $rate_person = array(); foreach ($rates as $rate) { $rate_person[$rate->chinese_name] = $rate->rate; } $through_arr = array(); foreach ($dev_person as $person_row) { $str = isset($rate_person[$person_row]) ? $rate_person[$person_row] . "%" : "-"; $through_arr[] = $person_row . ": " . $str; } $str = isset($rate_person['all']) ? $rate_person['all'] . "%" : "-"; $through_arr[] = '整个项目' . ": " . $str; $through_str = implode(" ", $through_arr); $table_project['through_rate'] = $through_str; $table_project['pmt_id'] = $pmt_id; $table_project['summary'] = $project[0]['summary']; $table_project['release_date'] = date("Y-m-d", strtotime($project[0]['date_release'])); $table_project['pro_set'] = empty($project[0]['set_id']) ? '' : $project[0]['set_id'] . ". " . $project[0]['set_name']; $table_project['owner'] = $project[0]['chinese_name']; if (!empty($delay_info)) { $table_project['is_delay'] = $delay_info[0]->self_test_delayed == 1 ? 'Yes' . '<br />' . '原因:' . $delay_info[0]->delay_detail : 'No'; } else { $table_project['is_delay'] = '-'; } } //reopen & reject list $reopen_id = Bll_TicketRelationBiz::get_instance()->find_reopen_id_by_pmtid($pmt_id); $reopen = array(); if (!empty($reopen_id)) { foreach ($reopen_id as $row) { $reopen[] = $row['ticket_id']; } } $reject_id = Bll_TicketCounterBiz::get_instance()->get_reject_id_by_pmtid($pmt_id); $reject = array(); if (!empty($reject_id)) { foreach ($reject_id as $row) { $reject[] = $row["ticket_id"]; } } //prepare $day = date("Y-m-d"); $date_arr = array(); for ($i = 9; $i >= 1; $i--) { $t = "-{$i} day"; $date_arr[] = date("Y-m-d", strtotime($t)); } $date_arr[] = $day; $status = Ticket_Status::get_all_status(); $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys(); $priority = array(); $p_id_name = array(); foreach ($prioritys as $prioritys_row) { $priority[$prioritys_row->value] = $prioritys_row->name; $p_id_name[$prioritys_row->id] = $prioritys_row->name; } $environments = Bll_DdCommonBiz::get_instance()->get_environments(); $environment = array(); foreach ($environments as $environments_row) { $environment[$environments_row->value] = $environments_row->name; } //daily table $table_data = Bll_ReportProgessPmtBiz::get_instance()->get_counts_by_type_date($pmt_id, '2012-05-01', $day); foreach ($table_data as $key => $data_row) { $table_data[$key]->environment = $environment[$data_row->environment]; } //pmt_day $counts_day = Bll_ReportDayPmtBiz::get_instance()->get_counts_by_pmt_type($pmt_id, 'all'); $pmt_day = array(); if (!empty($counts_day)) { foreach ($counts_day as $key => $row) { $pmt_day[] = array('date' => $this->convert_date($row->day), 'count' => $row->count); } } else { $pmt_day[] = array('date' => $this->convert_date($day), 'count' => 0); } /*$day_pro = array(); foreach($counts_day as $row){ $day_pro[$row->day] = $row->count; } foreach($date_arr as $date_row){ $c = isset($day_pro[$date_row])? $day_pro[$date_row] : 0; $pmt_day[] = array('date' => $date_row, 'count' => $c); }*/ //pmt_priority $counts_prior = Bll_ReportDayPmtBiz::get_instance()->get_counts_by_pmt_type($pmt_id, 'priority'); $prior_pro = array(); foreach ($counts_prior as $row) { $prior_pro[$row->day][$row->type_value] = $row->count; } $pmt_priority = array(); if (!empty($prior_pro)) { foreach ($prior_pro as $key => $row) { $tmp = array(); $tmp['date'] = $this->convert_date($key); foreach ($priority as $p_value => $p_name) { $o = isset($row[$p_value]) ? $row[$p_value] : 0; $tmp[$p_name] = $o; } $pmt_priority[] = $tmp; } } /*else { $tmp = array(); $tmp['date'] = $this->convert_date($day); foreach($priority as $p_value => $p_name){ $tmp[$p_name] = 0; } $pmt_priority[] = $tmp; }*/ //pmt_status $counts_status = Bll_ReportDayPmtBiz::get_instance()->get_counts_by_pmt_type($pmt_id, 'status'); $status_pro = array(); foreach ($counts_status as $row) { $status_pro[$row->day][$row->type_value] = $row->count; } $pmt_status = array(); if (!empty($status_pro)) { foreach ($status_pro as $key => $row) { $tmp = array(); $tmp['date'] = $this->convert_date($key); foreach ($status as $status_row) { $s = isset($row[$status_row]) ? $row[$status_row] : 0; $tmp[$status_row] = $s; } $pmt_status[] = $tmp; } } /*else { $tmp = array(); $tmp['date'] = $this->convert_date($day); foreach($status as $status_row){ $tmp[$status_row] = 0; } $pmt_status[] = $tmp; }*/ //priority and status today $tickets_type = Bll_TicketBiz::get_instance()->get_count_pmt_type($pmt_id); $ticket_priority = array(); $ticket_status = array(); foreach ($tickets_type as $row) { $ticket_priority[$row->priority][] = $row; $ticket_status[$row->status][] = $row; } $tmp_p = array(); $tmp_p['date'] = $this->convert_date($day); foreach ($p_id_name as $id => $p_name) { $tmp_p[$p_name] = isset($ticket_priority[$id]) ? count($ticket_priority[$id]) : 0; } if (!isset($prior_pro[$day])) { $pmt_priority[] = $tmp_p; } $tmp_s = array(); $tmp_s['date'] = $this->convert_date($day); foreach ($status as $status_row) { $tmp_s[$status_row] = isset($ticket_status[$status_row]) ? count($ticket_status[$status_row]) : 0; } if (!isset($status_pro[$day])) { $pmt_status[] = $tmp_s; } $req->set_attribute('pmt_day', $pmt_day); $req->set_attribute('pmt_priority', $pmt_priority); $req->set_attribute('pmt_status', $pmt_status); $req->set_attribute('table_data', $table_data); $req->set_attribute('table_project', $table_project); $req->set_attribute('reopen', $reopen); $req->set_attribute('reject', $reject); } $req->set_attribute('pmt_id', $pmt_id); return 'NewReport_ProjectDaily'; }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $ticket_id = $req->get_parameter('ticket_id'); $error = $req->get_parameter('error'); $user_id = $req->get_user_id(); $user_role = Bll_RoleBiz::get_instance()->get_user_role($user_id); $ticket = Bll_TicketBiz::get_instance()->get_detail($ticket_id); if (empty($ticket)) { $location = Home_IndexController::build_uri(); $res->redirect($location); } //custom_detail $custom_detail = Bll_TicketColumnDetailBiz::get_instance()->get_ticket_custom($ticket_id); $custom_all = Bll_TicketColumnDetailBiz::get_instance()->get_all_custom($ticket_id); $ticket_before_md5 = md5(json_encode($ticket)); $ticket->reporter = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->reporter); $ticket->owner = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->owner); $ticket->assigned_qa = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->assigned_qa); $ticket_log = Bll_TicketLogBiz::get_instance()->get_log($ticket_id); $ticket_cc_arr = Bll_TicketCcBiz::get_instance()->get_ticket_cc($ticket_id); $cc_tmp = array(); foreach ($ticket_cc_arr as $key => $ticket_cc) { if (Util_StringUtils::is_email($ticket_cc->cc_to)) { $cc_tmp[] = $ticket_cc->cc_to; } else { $cc_tmp[] = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket_cc->cc_to); } } $ticket_cc_str = implode(";", $cc_tmp); $current_time = date("Y-m-d H:i:s"); $ticket_log_process = array(); foreach ($ticket_log as $key => $log) { if ($ticket_log[$key]->field == "component") { if (ctype_digit($ticket_log[$key]->oldvalue)) { $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->oldvalue); } if (ctype_digit($ticket_log[$key]->newvalue)) { $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->newvalue); } } else { if ($ticket_log[$key]->field == "department") { if (ctype_digit($ticket_log[$key]->oldvalue)) { $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->oldvalue); } if (ctype_digit($ticket_log[$key]->newvalue)) { $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->newvalue); } } else { if ($ticket_log[$key]->field == "ticket" && $ticket_log[$key]->oldvalue == "null") { $ticket_log[$key]->newvalue = "new"; } } } $ticket_log_process[$log->created_at][] = $log; } $log_time = array(); foreach ($ticket_log_process as $key => $log) { /* * within 24h show xxx hours ago * mt 24h lt 7days show xx days ago * mt 7days lt 30days show xx weeks ago * mt 30days show xx months ago * floor((strtotime($current_time)-strtotime($log->created_at))/86400) */ $second = floor(strtotime($current_time) - strtotime($key)); $minute = floor((strtotime($current_time) - strtotime($key)) / 60); $hour = floor((strtotime($current_time) - strtotime($key)) / 3600); $day = floor((strtotime($current_time) - strtotime($key)) / 86400); $week = floor((strtotime($current_time) - strtotime($key)) / 604800); $month = floor((strtotime($current_time) - strtotime($key)) / 2592000); if ($second < 60) { $log_time[$key] = $second . ' seconds ago '; } else { if ($minute < 60) { $log_time[$key] = $minute . ' minutes ago '; } else { if ($hour < 24) { $log_time[$key] = $hour . ' hours ago '; } else { if ($hour >= 24 && $hour < 168) { $log_time[$key] = $day . ' days ago '; } else { if ($hour >= 168 && $hour < 720) { $log_time[$key] = $week . ' weeks ago '; } else { if ($hour >= 720) { $log_time[$key] = $month . ' months ago '; } } } } } } } $parent = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($ticket_id); if ($parent) { $parent_id = $parent->parent_ticket_id; } else { $parent_id = "0"; } $son = Bll_TicketRelationBiz::get_instance()->find_son_bugs_of_parent($ticket_id); if (empty($son)) { $son_id = "0"; } else { $son_id = $son[0]->ticket_id; } $ticket_status = Ticket_Status::get_status($ticket); $actions = $ticket_status->get_available_actions($user_role, $ticket->environment); $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions(); //start..... $all_users = Bll_UserBiz::get_instance()->get_all_valid_users(); $tmp_all = array(); foreach ($all_users as $key => $value) { $tmp_all[$key] = $value->whole_name; } $all_users = json_encode($tmp_all); $dev_users = Bll_UserBiz::get_instance()->get_dev_users(); $tmp_dev = array(); foreach ($dev_users as $key => $value) { $tmp_dev[$key] = $value->whole_name; } $dev_users = json_encode($tmp_dev); $qa_users = Bll_UserBiz::get_instance()->get_qa_users(); $admin_users = Bll_UserBiz::get_instance()->get_admins(); $qa_admin_users = array_merge($qa_users, $admin_users); $tmp_qa = array(); foreach ($qa_admin_users as $key => $value) { $tmp_qa[$key] = $value->whole_name; } $qa_admin_users = json_encode($tmp_qa); //end..... $reasons = Bll_DdCommonBiz::get_instance()->get_reasons(); $files = Bll_AttachmentBiz::get_instance()->get_file_by_ticket_id($ticket_id); if ($files) { foreach ($files as $file) { $file_link = Bll_AttachmentBiz::get_instance()->get_file_link_by_hash($file->fetch_hash); $file->fetch_hash = $file_link; } } $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys(); $emergencies = Bll_DdCommonBiz::get_instance()->get_emergencies(); $environments = Bll_DdCommonBiz::get_instance()->get_environments(); $departments = Bll_DdCommonBiz::get_instance()->get_departments_new(); $department_id = Bll_DdCommonBiz::get_instance()->get_department_id_by_name($ticket->department); $rel_components = Bll_DdComponentBiz::get_instance()->get_components($department_id->id); $req->set_attribute('user_id', $user_id); $req->set_attribute('files', $files); $req->set_attribute('prioritys', $prioritys); $req->set_attribute('emergencies', $emergencies); $req->set_attribute('departments', $departments); $req->set_attribute('rel_components', $rel_components); $req->set_attribute('environments', $environments); $req->set_attribute('reasons', $reasons); $req->set_attribute('resolutions', $resolutions); $req->set_attribute('ticket', $ticket); $req->set_attribute('ticket_cc_str', $ticket_cc_str); $req->set_attribute('ticket_logs', $ticket_log_process); $req->set_attribute('log_time', $log_time); $req->set_attribute('actions', $actions); $req->set_attribute('all_users', $all_users); $req->set_attribute('dev_users', $dev_users); $req->set_attribute('qa_admin_users', $qa_admin_users); $req->set_attribute('ticket_before_md5', $ticket_before_md5); $req->set_attribute('parent_id', $parent_id); $req->set_attribute('son_id', $son_id); $req->set_attribute('custom_detail', $custom_detail); $req->set_attribute('custom_all', $custom_all); if ($error) { $req->set_attribute('error', $error); } return 'Ticket_Detail'; }