Example #1
0
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 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';
 }
Example #3
0
$priority_id_value = array();
foreach ($prioritys as $priority) {
    $priority_id_value[$priority->id] = $priority->value;
}
//tickets group by pmtid
$tickets_type = Bll_TicketBiz::get_instance()->get_count_pmt_type();
$tickets_type_pmtid = array();
foreach ($tickets_type as $tickets_type_row) {
    if ($tickets_type_row->pmt_id && $tickets_type_row->pmt_id != 0) {
        $tickets_type_pmtid[$tickets_type_row->pmt_id][] = $tickets_type_row;
    }
}
foreach ($tickets_type_pmtid as $key_pmtid => $tickets_type_pmtid_rows) {
    //priority counts
    $tickets_type_pmtid_priority = array();
    $tickets_type_pmtid_status = array();
    foreach ($tickets_type_pmtid_rows as $tickets_type_pmtid_row) {
        $tickets_type_pmtid_priority[$priority_id_value[$tickets_type_pmtid_row->priority]][] = $tickets_type_pmtid_row;
        $tickets_type_pmtid_status[$tickets_type_pmtid_row->status][] = $tickets_type_pmtid_row;
    }
    foreach ($tickets_type_pmtid_priority as $key_priority => $tickets_row) {
        $input_arr = array('day' => $day, 'pmt_id' => $key_pmtid, 'type_key' => 'priority', 'type_value' => $key_priority, 'count' => count($tickets_row), 'created_at' => $current_time);
        $count_id = Bll_ReportDayPmtBiz::get_instance()->insert_count_data($input_arr);
    }
    //status counts
    foreach ($tickets_type_pmtid_status as $key_status => $tickets_row) {
        $input_arr = array('day' => $day, 'pmt_id' => $key_pmtid, 'type_key' => 'status', 'type_value' => $key_status, 'count' => count($tickets_row), 'created_at' => $current_time);
        $count_id = Bll_ReportDayPmtBiz::get_instance()->insert_count_data($input_arr);
    }
}
echo date('c ') . " Count day pmt bugs ok \n";