public function change_status($status, $input_arr) { $new_reporter = APF::get_instance()->get_request()->get_username(); $new_ticket = array('priority' => $this->ticket->priority, 'reporter' => $new_reporter, 'owner' => $this->ticket->owner, 'assigned_qa' => $this->ticket->assigned_qa, 'status' => 'opened', 'summary' => $this->ticket->summary, 'pmt_id' => $this->ticket->pmt_id, 'environment' => $this->ticket->environment, 'department' => $this->ticket->department, 'component' => $this->ticket->component, 'version' => $this->ticket->version, 'is_regression' => $this->ticket->is_regression, 'description' => $this->ticket->description, 'resolution' => '', 'reason' => '', 'reason_detail' => ''); $new_ticket_id = Bll_TicketBiz::get_instance()->ticket_add($new_ticket); if ($input_arr['comments']) { $current_time = date("Y-m-d H:i:s"); $log_id_comment = Bll_TicketLogBiz::get_instance()->comment_add($new_ticket_id, $input_arr['comments'], $new_reporter, $current_time); } $parent_ticket_id = $this->ticket->id; $relation = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($parent_ticket_id); if ($relation) { $root_ticket_id = $relation->root_ticket_id; } else { $root_ticket_id = $parent_ticket_id; } $new_relation = array(); $new_relation['ticket_id'] = $new_ticket_id; $new_relation['parent_ticket_id'] = $parent_ticket_id; $new_relation['root_ticket_id'] = $root_ticket_id; $success = Bll_TicketRelationBiz::get_instance()->relation_add($new_relation); //return $success; if ($success) { //reopen log add $current_time = date("Y-m-d H:i:s"); $input_arr_log = array('ticket_id' => $new_ticket_id, 'created_by' => $new_reporter, 'field' => 'ticket', 'oldvalue' => 'null', 'newvalue' => $new_ticket['description'], 'created_at' => $current_time); $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr_log); $location = Ticket_DetailController::build_uri() . "?ticket_id=" . $new_ticket_id; APF::get_instance()->get_response()->redirect($location); } }
public static function &get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
foreach ($_ticket_ccs as $_ticket_cc) { $ticket_ccs[$_ticket_cc->ticket_id][] = $_ticket_cc->cc_to; } } foreach ($tickets as $ticket_id => $ticket) { if (empty($ticket)) { try { $solr->deleteById($ticket_id); echo date('c ') . " Delete ok {$ticket_id}\n"; } catch (Exception $e) { echo date('c ') . " Delete failed {$ticket_id}\n"; } continue; } $reopento = 0; $relation = Bll_TicketRelationBiz::get_instance()->find_son_bugs_of_parent($ticket->id); if ($relation) { $reopento = 1; } $reject = Bll_TicketLogBiz::get_instance()->get_log($ticket->id); $ifreject = 0; if ($reject) { foreach ($reject as $value) { if ($value->rlog === 'Ticket_ActionReject') { $ifreject = 1; } } } $ticket = Ibug_GlobalFunc::objToArray($ticket); #var_dump($ticket['component'],$ticket['department']); $_ticket = array("id" => $ticket["id"], "created_at" => intval(strtotime($ticket["created_at"])), "updated_at" => intval(strtotime($ticket["updated_at"])), "closed_at" => intval(strtotime($ticket["closed_at"])), "priority" => $ticket["priority"], "reporter" => $ticket["reporter"], "owner" => $ticket["owner"], "assigned_qa" => $ticket["assigned_qa"], "status" => $ticket["status"], "summary" => $ticket["summary"], "pmt_id" => $ticket["pmt_id"], "environment" => $ticket["environment"], "department" => $ticket["department"], "component" => $ticket["component"], "resolution" => $ticket["resolution"], "is_regression" => intval($ticket["is_regression"]), "is_occasional" => intval($ticket["is_occasional"]), "person_liable" => $ticket["person_liable"], "reason" => $ticket["reason"], "version" => $ticket["version"], "reason_detail" => $ticket["reason_detail"], "description" => $ticket["description"], 'cc' => empty($ticket_ccs[$ticket['id']]) ? null : $ticket_ccs[$ticket['id']], 'reject' => $ifreject, 'reopen' => $reopento);
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'; }
/** * 处理ticket数据 */ public function deal_ticket_data($results) { $docs = $results['docs']; $ids = array(); foreach ($docs as $doc) { $ids[] = $doc['fields']['id']; $tickets = Bll_TicketBiz::get_instance()->get_tickets_by_id_arr($ids); $tickets = $this->process_tickets($tickets, $results['docs']); $historys = Bll_TicketStatusHistoryBiz::get_instance()->get_history_by_ids($ids); $his_pro = array(); foreach ($historys as $row) { if ($row->status == 'accepted') { if (isset($his_pro[$row->ticket_id][$row->status]) && strtotime($row->created_at) < strtotime($his_pro[$row->ticket_id][$row->status]) || !isset($his_pro[$row->ticket_id][$row->status])) { $his_pro[$row->ticket_id][$row->status] = $row->created_at; } } else { if (isset($his_pro[$row->ticket_id][$row->status]) && strtotime($row->created_at) > strtotime($his_pro[$row->ticket_id][$row->status]) || !isset($his_pro[$row->ticket_id][$row->status])) { $his_pro[$row->ticket_id][$row->status] = $row->created_at; } } } foreach ($tickets as $key => $ticket) { foreach ($tickets[$key] as $k => $v) { $tickets[$key][$k]->additional = Bll_TicketColumnDetailBiz::get_instance()->get_all_custom($v->id); //QA时间 if (isset($his_pro[$v->id]['accepted'])) { $tickets[$key][$k]->qa_at = $his_pro[$v->id]['accepted']; $tickets[$key][$k]->qa_time = $this->format_time_v1($this->convert_time($v->created_at, $tickets[$key][$k]->qa_at)); } else { $tickets[$key][$k]->qa_at = '0'; $tickets[$key][$k]->qa_time = '-'; } //开发时间 if (isset($his_pro[$v->id]['verified']) && !in_array($v->status, array('opened', 'accepted'))) { $tickets[$key][$k]->dev_at = $his_pro[$v->id]['verified']; $tickets[$key][$k]->dev_time = $this->format_time($this->convert_time($v->created_at, $tickets[$key][$k]->dev_at)); } else { $tickets[$key][$k]->dev_at = '0'; $tickets[$key][$k]->dev_time = '-'; } //完整处理时间 if (isset($his_pro[$v->id]['closed'])) { $tickets[$key][$k]->all_at = $his_pro[$v->id]['closed']; $tickets[$key][$k]->all_time = $this->format_time($this->convert_time($v->created_at, $tickets[$key][$k]->all_at)); $tickets[$key][$k]->all_time_2 = $this->format_time_v2($this->convert_time($v->created_at, $tickets[$key][$k]->all_at)); } else { $tickets[$key][$k]->all_at = '0'; $tickets[$key][$k]->all_time = '-'; } //reopened $parent = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($v->id); if ($parent) { $tickets[$key][$k]->pid = $parent->parent_ticket_id; } else { $tickets[$key][$k]->pid = ''; } if (isset($v->description)) { $tickets[$key][$k]->description = preg_replace('/<img.*>/siU', '', $v->description); } } } } return $tickets; }
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'; }
foreach ($row_first as $r_enviro => $row_second) { $input_arr = array(); $input_arr['day'] = $day; $input_arr['pmt_id'] = $p_pmtid; $input_arr['environment'] = $r_enviro; $input_arr['created_at'] = $current_time; $input_arr['total'] = count($row_second); $new = 0; $reopen = 0; $fixed = 0; $close = 0; $reject = 0; foreach ($row_second as $ticket_row) { if ($ticket_row->created_at >= $begin && $ticket_row->created_at <= $end) { $new++; $is_reopen = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($ticket_row->id); if (!empty($is_reopen)) { $reopen++; } } $is_fixed = Bll_TicketStatusHistoryBiz::get_instance()->check_status_history($ticket_row->id, 'verified', $begin, $end); if (!empty($is_fixed)) { $fixed++; } if ($ticket_row->closed_at && $ticket_row->closed_at >= $begin && $ticket_row->closed_at <= $end) { $close++; } $is_reject = Bll_TicketCounterBiz::get_instance()->get_reject_counter($ticket_row->id); if (!empty($is_reject)) { if ($is_reject[0]->updated_at >= $begin && $is_reject[0]->updated_at <= $end) { $reject++;