public static function &get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public function change_status($status, $input_arr) { $current_time = date("Y-m-d H:i:s"); if ($status != 'Verified') { $history_arr = array('ticket_id' => $this->ticket->id, 'status' => strtolower($status), 'created_at' => $current_time, 'created_by' => $this->user); $history_id = Bll_TicketStatusHistoryBiz::get_instance()->insert_status_history($history_arr); } if ($status == 'Opened') { $input_log_open = array('ticket_id' => $this->ticket->id, 'created_by' => $input_arr['owner'], 'field' => 'resolution', 'oldvalue' => $this->ticket->resolution, 'newvalue' => 'null', 'created_at' => $current_time, 'rlog' => $input_arr['rlog']); $log_id_open = Bll_TicketLogBiz::get_instance()->log_add($input_log_open); $reject_counter = Bll_TicketCounterBiz::get_instance()->insert_reject_counter($this->ticket->id); $this->ticket->status = 'opened'; $this->ticket->resolution = ''; } else { if ($status == 'Closed') { $this->ticket->status = 'closed'; $this->ticket->closed_at = $current_time; } else { if ($status == 'Released') { $this->ticket->status = 'released'; } } } $this->ticket->updated_at = $current_time; $success = $this->ticket->save(); return $this->ticket->status; }
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'; }
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++; } } } $input_arr['new'] = $new; $input_arr['reopen'] = $reopen; $input_arr['fixed'] = $fixed; $input_arr['close'] = $close; $input_arr['reject'] = $reject; if ($new + $reopen + $fixed + $close + $reject != 0) { $pro_id = Bll_ReportProgessPmtBiz::get_instance()->insert_count_data($input_arr); } }