Beispiel #1
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $username = isset($params['user']) ? $params['user'] : '';
     $pmtid = isset($params['pmt']) ? $params['pmt'] : 0;
     $status = isset($params['status']) ? $params['status'] : '';
     $env = isset($params['env']) ? $params['env'] : '';
     /*
       1 => prod
       2 => dev
       3 => test
       4 => pre
     */
     $env_arr = array('1' => '19', '2' => '16', '3' => '17', '4' => '18');
     if ($env) {
         $env = $env_arr[$env];
     }
     if ($username != '' || $pmtid != '') {
         $bugs = Bll_TicketBiz::get_instance()->get_buglist_by_api($username, $pmtid, $status, $env);
         if (!empty($bugs)) {
             $ids = array();
             foreach ($bugs as $bug) {
                 $ids[] = $bug->id;
             }
             $return = array('status' => 'ok', 'result' => array('count' => count($ids), 'data' => $ids));
         } else {
             $return = array('status' => 'ok', 'result' => array('count' => 0, 'data' => array()));
         }
     } else {
         $return = array('status' => 'error', 'result' => array('code' => 101, 'message' => 'empty parameter'));
     }
     $return = json_encode($return);
     echo $return;
 }
Beispiel #2
0
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Beispiel #3
0
 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 function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $product = isset($params['pro']) ? $params['pro'] : '4';
     $from = $params['from'] ? date("Y-m-d 00:00:00", strtotime($params['from'])) : date("Y-m-01 00:00:00");
     $to = $params['to'] ? date("Y-m-d 23:59:59", strtotime($params['to'])) : date("Y-m-t 23:59:59");
     if ($product != '' || $from != '' || $to != '') {
         $ticketsx = Bll_TicketBiz::get_instance()->get_ticket_list_by_month($from, $to, $product);
         $tickets = array();
         foreach ($ticketsx as $row) {
             if ($row->environment == 'Production') {
                 $tickets[] = $row;
             }
         }
         if (empty($tickets)) {
             $datas = array();
         } else {
             $datas = array();
             foreach ($tickets as $ticket) {
                 $datas[$ticket->id]['bug_id'] = $ticket->id;
                 $datas[$ticket->id]['summary'] = $ticket->summary;
                 $datas[$ticket->id]['owner'] = $ticket->owner;
                 $datas[$ticket->id]['priority'] = $ticket->priority;
                 $datas[$ticket->id]['component'] = $ticket->component;
                 $datas[$ticket->id]['pmt_id'] = $ticket->pmt_id;
                 $datas[$ticket->id]['created_time'] = $ticket->created_at;
                 $datas[$ticket->id]['last_updated'] = $ticket->updated_at;
                 if ($ticket->closed_at) {
                     $sec = strtotime($ticket->closed_at) - strtotime($ticket->created_at);
                     $days = floor($sec / (24 * 3600));
                     $sec = $sec % (24 * 3600);
                     $hours = floor($sec / 3600);
                     $remainSeconds = $sec % 3600;
                     $minutes = floor($remainSeconds / 60);
                     $seconds = intval($sec - $hours * 3600 - $minutes * 60);
                     $datas[$ticket->id]['processing_time'] = $days . 'd' . $hours . 'h' . $minutes . 'm' . $seconds . 's';
                 } else {
                     $datas[$ticket->id]['processing_time'] = 0;
                 }
                 $datas[$ticket->id]['remark_classification'] = $ticket->description;
                 $datas[$ticket->id]['reason_description'] = $ticket->reason_detail;
             }
             if (!empty($datas)) {
                 $return = array('status' => 'ok', 'result' => array('count' => count($datas), 'data' => $datas));
             } else {
                 $return = array('status' => 'ok', 'result' => array('count' => 0, 'data' => array()));
             }
         }
     } else {
         $return = array('status' => 'error', 'result' => array('code' => 101, 'message' => 'empty parameter'));
     }
     $return = json_encode($return);
     echo $return;
 }
Beispiel #5
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $product = $params['pro'] ? $params['pro'] : 1;
     $tab_info = array(1 => array('name' => 'Anjuke', 'click' => false, 'id' => 2), 2 => array('name' => 'Aifang', 'click' => false, 'id' => 3), 3 => array('name' => 'Haozu', 'click' => false, 'id' => 4), 4 => array('name' => 'Jinpu', 'click' => false, 'id' => 5), 5 => array('name' => 'Mobile', 'click' => false, 'id' => 6), 6 => array('name' => 'Inc', 'click' => false, 'id' => 1));
     $tab_info[$product]['click'] = true;
     $depart = $tab_info[$product]['id'];
     $month_query = $params['form_month'] ? $params['form_month'] : date("Y-m", strtotime('now'));
     $begin = date("Y-m-01 00:00:00", strtotime($month_query));
     $end = date("Y-m-t 23:59:59", strtotime($month_query));
     $bugs_online = Bll_TicketBiz::get_instance()->get_count_online_by_month($begin, $end, 'all');
     $online_sec = array();
     foreach ($bugs_online as $row) {
         $online_sec[$row->owner][$row->priority][] = $row;
     }
     $persons = Bll_UserBiz::get_instance()->get_dev_staffs($depart);
     $table_all_on = array('P1' => 0, 'P2' => 0, 'P3' => 0, 'P4' => 0, 'P5' => 0, 'all' => 0);
     $table_on_tmp = array();
     $online_p_c = array();
     foreach ($persons as $row) {
         $tmp_on = array();
         if (!empty($online_sec[$row->user_name])) {
             $tmp_on['person'] = $row->chinese_name;
             $tmp_on['P1'] = isset($online_sec[$row->user_name]['7']) ? count($online_sec[$row->user_name]['7']) : 0;
             $tmp_on['P2'] = isset($online_sec[$row->user_name]['8']) ? count($online_sec[$row->user_name]['8']) : 0;
             $tmp_on['P3'] = isset($online_sec[$row->user_name]['6']) ? count($online_sec[$row->user_name]['6']) : 0;
             $tmp_on['P4'] = isset($online_sec[$row->user_name]['9']) ? count($online_sec[$row->user_name]['9']) : 0;
             $tmp_on['P5'] = isset($online_sec[$row->user_name]['10']) ? count($online_sec[$row->user_name]['10']) : 0;
             $tmp_on['all'] = $tmp_on['P1'] + $tmp_on['P2'] + $tmp_on['P3'] + $tmp_on['P4'] + $tmp_on['P5'];
             $table_on_tmp[$row->user_name] = $tmp_on;
             $table_all_on['P1'] += $tmp_on['P1'];
             $table_all_on['P2'] += $tmp_on['P2'];
             $table_all_on['P3'] += $tmp_on['P3'];
             $table_all_on['P4'] += $tmp_on['P4'];
             $table_all_on['P5'] += $tmp_on['P5'];
             $table_all_on['all'] += $tmp_on['all'];
             $online_p_c[$row->user_name] = $tmp_on['all'];
         }
     }
     arsort($online_p_c);
     $table_on = array();
     foreach ($online_p_c as $key => $row) {
         $table_on[] = $table_on_tmp[$key];
     }
     $req->set_attribute('month_query', $month_query);
     $req->set_attribute('table_on', $table_on);
     $req->set_attribute('table_all_on', $table_all_on);
     $req->set_attribute('tab_info', $tab_info);
     return 'Report_DevStatis';
 }
Beispiel #6
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $pro = $params['pro'] ? $params['pro'] : 1;
     $tab_info = array(1 => array('name' => 'DB-RT', 'click' => false), 2 => array('name' => 'SA-RT', 'click' => false));
     $tab_info[$pro]['click'] = true;
     $depart_value_id = array('1' => '47', '2' => '48');
     $pro_id = $depart_value_id[$pro];
     $components = Bll_DdComponentBiz::get_instance()->get_components($pro_id);
     $time_arr = array();
     for ($i = 5; $i >= 0; $i--) {
         if ($i == 0) {
             $time = strtotime('now');
         } else {
             $time = strtotime('-' . $i . ' month');
         }
         $begin = date('Y-m-01 00:00:00', $time);
         $end = date('Y-m-t 23:59:59', $time);
         $month = date('Y-m', $time);
         $time_arr[$month] = array('begin' => $begin, 'end' => $end);
     }
     $data_init = array();
     foreach ($time_arr as $key => $row) {
         $tickets = Bll_TicketBiz::get_instance()->get_ticket_list_by_month($row['begin'], $row['end'], $pro_id);
         foreach ($tickets as $t_row) {
             $data_init[$t_row->component][$key][] = $t_row;
         }
     }
     $data_sec = array();
     foreach ($time_arr as $time_key => $row) {
         $data_sec[$time_key]['month'] = $time_key;
         foreach ($components as $comp) {
             $data_sec[$time_key][$comp->name] = isset($data_init[$comp->name][$time_key]) ? count($data_init[$comp->name][$time_key]) : 0;
         }
     }
     $data = array();
     foreach ($data_sec as $row) {
         $data[] = $row;
     }
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('data', $data);
     return 'Report_RtReport';
 }
Beispiel #7
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $ticket_id = $req->get_parameter('ticket_id');
     $ticket = Bll_TicketBiz::get_instance()->get_detail($ticket_id);
     if (empty($ticket)) {
         $location = Home_IndexController::build_uri();
         $res->redirect($location);
     }
     $updated_at = $ticket->updated_at;
     $diff = strtotime(date('Y-m-d H:i:s')) - strtotime($updated_at);
     if ($diff < 5) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #8
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     /*$conditions = array(
           '1' => 'Online Bugs',
           '2' => 'Reopen Bugs',
           '3' => 'Prd Bugs',
           '4' => 'Anjuke Online Bugs',
           '5' => 'Haozu Online Bugs',
           '6' => 'Aifang Online Bugs',
           '7' => 'Jinpu Online Bugs',
           '8' => 'Mobile Online Bugs',
           '9' => 'Recent P1/P2 Bugs'
       );*/
     //条件数组
     $conditions = array('1' => 'Online Bugs', '2' => 'Reopen Bugs', '3' => 'Prd Bugs', '4' => '用户端 Online Bugs', '5' => '开发商 Online Bugs', '6' => 'CRM Online Bugs', '7' => '客户端 Online Bugs', '8' => '移动 Online Bugs', '9' => 'Recent P1/P2 Bugs');
     $tickets = array();
     $tickets['1'] = Bll_TicketBiz::get_instance()->get_online_tickets();
     $tickets['2'] = Bll_TicketBiz::get_instance()->get_p_reopen_bugs();
     $tickets['3'] = Bll_TicketBiz::get_instance()->get_prd_bugs();
     // FIXME: query once
     $tickets['4'] = Bll_TicketBiz::get_instance()->get_online_tickets(51);
     $tickets['5'] = Bll_TicketBiz::get_instance()->get_online_tickets(53);
     $tickets['6'] = Bll_TicketBiz::get_instance()->get_online_tickets(54);
     $tickets['7'] = Bll_TicketBiz::get_instance()->get_online_tickets(52);
     $tickets['8'] = Bll_TicketBiz::get_instance()->get_online_tickets_mobile(56, 60, 57, 58, 61);
     /*$tickets['9'] = Bll_TicketBiz::get_instance()->get_online_tickets(60);
       $tickets['10'] = Bll_TicketBiz::get_instance()->get_online_tickets(57);
       $tickets['11'] = Bll_TicketBiz::get_instance()->get_online_tickets(58);
       $tickets['12'] = Bll_TicketBiz::get_instance()->get_online_tickets(61);*/
     $tickets['9'] = Bll_TicketBiz::get_instance()->get_recent_major_tickets();
     $counts = array();
     foreach ($tickets as $key => $ticket) {
         $counts[$key] = 0;
         foreach ($ticket as $key_row => $ticket_row) {
             if ($ticket_row->status != 'closed') {
                 $counts[$key] += 1;
             }
         }
     }
     $req->set_attribute('conditions', $conditions);
     $req->set_attribute('counts', $counts);
     return 'Ticket_OftenQuery';
 }
Beispiel #9
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $ids_str = isset($params['id']) ? $params['id'] : '';
     if ($ids_str != '') {
         $ids_arr = json_decode($ids_str);
         //var_dump($ids_arr);die();
         if (!empty($ids_arr)) {
             $bugs = Bll_TicketBiz::get_instance()->get_buginfo_by_api($ids_arr);
             if (!empty($bugs)) {
                 $return = array('status' => 'ok', 'result' => array('count' => count($bugs), 'data' => $bugs));
             } else {
                 $return = array('status' => 'ok', 'result' => array('count' => 0, 'data' => array()));
             }
         } else {
             $return = array('status' => 'error', 'result' => array('code' => 102, 'message' => 'invalid parameter'));
         }
     } else {
         $return = array('status' => 'error', 'result' => array('code' => 101, 'message' => 'empty parameter'));
     }
     $return = json_encode($return);
     echo $return;
 }
Beispiel #10
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     if ($params['delete']) {
         $suc = Bll_BookmarkBiz::get_instance()->delete_bookmark_by_id($params['delete']);
         $location = Home_PersonalQueryController::build_uri();
         $res->redirect($location);
     }
     if ($params['type'] && ($params['id'] || $params['owner'])) {
         $tickets_opened = array();
         $i = 0;
         $tickets_accepted = array();
         $j = 0;
         $tickets_verified = array();
         $k = 0;
         $tickets_released = array();
         $m = 0;
         $tickets_closed = array();
         $n = 0;
         $type = $params['type'];
         if ($type == 'pmtid') {
             $pmt_id = trim($params['id']);
             $name = 'Tickets of pmt id is ' . $pmt_id;
             if (preg_match('/^\\d*$/', $pmt_id)) {
                 $pmt_tickets = Bll_TicketBiz::get_instance()->get_tickets_by_pmtid($pmt_id);
                 foreach ($pmt_tickets as $ticket) {
                     if ($ticket->status == 'opened') {
                         $tickets_opened[$i] = $ticket;
                         $i = $i + 1;
                     } elseif ($ticket->status == 'accepted') {
                         $tickets_accepted[$j] = $ticket;
                         $j = $j + 1;
                     } elseif ($ticket->status == 'verified') {
                         $tickets_verified[$k] = $ticket;
                         $k = $k + 1;
                     } elseif ($ticket->status == 'released') {
                         $tickets_released[$m] = $ticket;
                         $m = $m + 1;
                     } elseif ($ticket->status == 'closed') {
                         $tickets_closed[$n] = $ticket;
                         $n = $n + 1;
                     }
                 }
             } else {
                 $tickets_opened = array();
                 $tickets_accepted = array();
                 $tickets_verified = array();
                 $tickets_released = array();
                 $tickets_closed = array();
             }
             if ($params['bc'] == 'yes') {
                 $input_arr = array();
                 $input_arr['user'] = $req->get_username();
                 $input_arr['name'] = $params['name'];
                 $input_arr['type'] = "1";
                 $input_arr['value'] = "type=" . $type . '&id=' . $pmt_id;
                 $id = Bll_BookmarkBiz::get_instance()->insert_condition($input_arr);
                 $url_again = Home_PersonalQueryController::build_uri() . '?' . $bookmark_value . '&bced=yes';
                 $res->redirect($url_again);
             } else {
                 if ($params['bced'] == 'yes') {
                 } else {
                     $value = "type=" . $type . '&id=' . $pmt_id;
                 }
             }
         } else {
             if ($type == 'owner') {
                 $owner = $params['owner'];
                 $tmp_owner = explode(';', $owner);
                 $owner_whole = $tmp_owner[0];
                 $owner_user = Bll_UserBiz::get_instance()->get_username_by_wholename($owner_whole);
                 if (!$owner_user) {
                     $owner_user = $owner_whole;
                 }
                 $name = 'Tickets of owner is ' . $owner_whole;
                 //if($params['time_begin']&&$params['time_end']){  2012-1-1
                 if ($params['time_begin'] && preg_match('/^\\d{4}\\-\\d{1,2}\\-\\d{1,2}$/', $params['time_begin'])) {
                     $time_begin = $params['time_begin'];
                 }
                 if ($params['time_end'] && preg_match('/^\\d{4}\\-\\d{1,2}\\-\\d{1,2}$/', $params['time_end'])) {
                     $time_end = $params['time_end'] . ' 23:59:59';
                 }
                 $owner_tickets = Bll_TicketBiz::get_instance()->get_tickets_by_query_owner($owner_user, $time_begin, $time_end);
                 foreach ($owner_tickets as $ticket) {
                     if ($ticket->status == 'opened') {
                         $tickets_opened[$i] = $ticket;
                         $i = $i + 1;
                     } else {
                         if ($ticket->status == 'accepted') {
                             $tickets_accepted[$j] = $ticket;
                             $j = $j + 1;
                         } else {
                             if ($ticket->status == 'verified') {
                                 $tickets_verified[$k] = $ticket;
                                 $k = $k + 1;
                             } else {
                                 if ($ticket->status == 'released') {
                                     $tickets_released[$m] = $ticket;
                                     $m = $m + 1;
                                 } else {
                                     if ($ticket->status == 'closed') {
                                         $tickets_closed[$n] = $ticket;
                                         $n = $n + 1;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($params['bc'] == 'yes') {
                     $input_arr = array();
                     $input_arr['user'] = $req->get_username();
                     $input_arr['name'] = $params['name'];
                     $input_arr['type'] = "1";
                     $input_arr['value'] = "type=" . $type . "&owner=" . $owner_user;
                     $id = Bll_BookmarkBiz::get_instance()->insert_condition($input_arr);
                     $url_again = Home_PersonalQueryController::build_uri() . '?' . $bookmark_value . '&bced=yes';
                     $res->redirect($url_again);
                 } else {
                     if ($params['bced'] == 'yes') {
                     } else {
                         $value = 'type=' . $type . '&owner=' . $owner_user;
                     }
                 }
             }
         }
         $tickets = array();
         $tickets['opened'] = $tickets_opened;
         $tickets['accepted'] = $tickets_accepted;
         $tickets['verified'] = $tickets_verified;
         $tickets['released'] = $tickets_released;
         $tickets['closed'] = $tickets_closed;
         $req->set_attribute('name', $name);
         $req->set_attribute('tickets', $tickets);
         $req->set_attribute('value', $value);
         return 'Home_IndexAllMyQ';
     }
     $personal_conditions = Bll_BookmarkBiz::get_instance()->get_personal_conditions($req->get_username());
     $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);
     $req->set_attribute('all_users', $all_users);
     $req->set_attribute('personal_conditions', $personal_conditions);
     return 'Home_PersonalQuery';
 }
     $count_created = count($tickets_all_created);
 } else {
     $count_created = 0;
 }
 $input_arr = array('week' => $week, 'department' => $depart->value, 'type_key' => 'created', 'type_value' => '0', 'count' => $count_created, 'updated_time' => $current_time);
 $insert_id = Bll_ReportWeekOnlineNewBiz::get_instance()->insert_count_data($input_arr);
 if (!$insert_id) {
     echo " insert type created all data error ";
 }
 //created tickets devide into component; attention: created and online bug
 $count_component = Bll_ReportWeekOnlineNewBiz::get_instance()->insert_online_count_for_alltype($time_arr, 'component', $tickets_all_created, $comp_id_value, $depart);
 if (!$count_component) {
     echo "insert count_component data error";
 }
 //get all  closed test and production counts about the department for a week
 $tickets_all_closed = Bll_TicketBiz::get_instance()->get_count_online_by_week($begin, $end, 'all', $depart->id);
 if ($tickets_all_closed) {
     $count = count($tickets_all_closed);
 } else {
     $count = 0;
 }
 $input_arr = array('week' => $week, 'department' => $depart->value, 'type_key' => 'closed', 'type_value' => '0', 'count' => $count, 'updated_time' => $current_time);
 $insert_id = Bll_ReportWeekOnlineNewBiz::get_instance()->insert_count_data($input_arr);
 if (!$insert_id) {
     echo " insert type-all data error ";
 }
 // closed and online(test and production) bug , devide into reason
 $count_resolution = Bll_ReportWeekOnlineNewBiz::get_instance()->insert_online_count_for_alltype($time_arr, 'reason', $tickets_all_closed, $reason_ids, $depart);
 if (!$count_resolution) {
     echo "insert count_resolution data error";
 }
Beispiel #12
0
 /**
  *	处理ticket数据
  */
 public function deal_ticket_data($results)
 {
     $docs = $results['docs'];
     $ids = array();
     $pie = array();
     $length = count($this->pie_type);
     foreach ($docs as $doc) {
         $ids[0] = $doc['fields']['id'];
         $tickets[$ids[0]] = Bll_TicketBiz::get_instance()->get_tickets_by_id_arr($ids);
     }
     foreach ($tickets as $key => $value) {
         for ($i = 0; $i < $length; $i++) {
             $type = $this->pie_type[$i];
             $type_value = $value[$key]->{$type};
             if ($type_value == null || $type_value == "") {
                 if (isset($pie[$type]["空"])) {
                     $pie[$type]["空"]++;
                 } else {
                     $pie[$type]["空"] = 1;
                 }
             } else {
                 if (isset($pie[$type][$type_value])) {
                     $pie[$type][$type_value]++;
                 } else {
                     $pie[$type][$type_value] = 1;
                 }
             }
         }
     }
     return $pie;
 }
Beispiel #13
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $query_num = $req->get_parameter('num');
     $tickets = array();
     if ($query_num == '1') {
         $tickets = Bll_TicketBiz::get_instance()->get_online_tickets();
         $depart = 'yes';
         $name = 'Online Bugs';
         $table_status = '1';
     } else {
         if ($query_num == '2') {
             $tickets = Bll_TicketBiz::get_instance()->get_p_reopen_bugs();
             $depart = 'no';
             $name = "Reopen Bugs";
             $table_status = '2';
         } else {
             if ($query_num == '3') {
                 $tickets = Bll_TicketBiz::get_instance()->get_prd_bugs();
                 $depart = 'no';
                 $name = "Prd Bugs";
                 $table_status = '2';
             } else {
                 if ($query_num == '4') {
                     $tickets = Bll_TicketBiz::get_instance()->get_online_tickets(51);
                     $depart = 'no';
                     $name = "用户端  Online Bugs";
                     $table_status = '1';
                 } else {
                     if ($query_num == '5') {
                         $tickets = Bll_TicketBiz::get_instance()->get_online_tickets(53);
                         $depart = 'no';
                         $name = "开发商 Online Bugs";
                         $table_status = '1';
                     } else {
                         if ($query_num == '6') {
                             $tickets = Bll_TicketBiz::get_instance()->get_online_tickets(54);
                             $depart = 'no';
                             $name = "CRM Online Bugs";
                             $table_status = '1';
                         } else {
                             if ($query_num == '7') {
                                 $tickets = Bll_TicketBiz::get_instance()->get_online_tickets(52);
                                 $depart = 'no';
                                 $name = "客户端 Online Bugs";
                                 $table_status = '1';
                             } else {
                                 if ($query_num == '8') {
                                     $tickets = Bll_TicketBiz::get_instance()->get_online_tickets_mobile(56, 60, 57, 58, 61);
                                     $depart = 'no';
                                     $name = "移动 Online Bugs";
                                     $table_status = '1';
                                 } else {
                                     if ($query_num == '9') {
                                         $tickets = Bll_TicketBiz::get_instance()->get_recent_major_tickets();
                                         $depart = 'yes';
                                         $name = "Recent P1/P2 Bugs";
                                         $table_status = '1';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $tickets_status = array();
     foreach ($tickets as $ticket) {
         $tickets_status[$ticket->status][] = $ticket;
     }
     $time_status = array();
     foreach ($tickets_status as $key => $ticket_r) {
         foreach ($ticket_r as $k => $r) {
             $time_status[$key][$k]['create'] = Bll_TicketBiz::get_instance()->process_time_field($r->created_at);
             $time_status[$key][$k]['update'] = Bll_TicketBiz::get_instance()->process_time_field($r->updated_at);
         }
     }
     if ($depart == 'yes') {
         $tickets_dpt = array();
         foreach ($tickets as $ticket) {
             $tickets_dpt[$ticket->department][] = $ticket;
         }
         $time_dpt = array();
         foreach ($tickets_dpt as $key => $ticket_r) {
             foreach ($ticket_r as $k => $r) {
                 $time_dpt[$key][$k]['create'] = Bll_TicketBiz::get_instance()->process_time_field($r->created_at);
                 $time_dpt[$key][$k]['update'] = Bll_TicketBiz::get_instance()->process_time_field($r->updated_at);
             }
         }
     }
     $req->set_attribute('name', $name);
     $req->set_attribute('depart', $depart);
     $req->set_attribute('table_status', $table_status);
     $req->set_attribute('tickets_status', $tickets_status);
     $req->set_attribute('time_status', $time_status);
     if ($depart == 'yes') {
         $req->set_attribute('tickets_dpt', $tickets_dpt);
         $req->set_attribute('time_dpt', $time_dpt);
     }
     return 'Ticket_List';
 }
Beispiel #14
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $product_array = array(12, 12, 13, 14, 7, 6, 4);
     //12=>用户事业部,13=>经纪人事业部,14=>开发商事业部,7=>CRM,6=>移动,4=>anjuke inc
     $pro_v = $params['pro'] ? $params['pro'] : 1;
     $tab_info = array(1 => array('name' => '用户端', 'click' => false), 2 => array('name' => '客户端', 'click' => false), 3 => array('name' => '开发商', 'click' => false), 4 => array('name' => 'CRM', 'click' => false), 5 => array('name' => '移动', 'click' => false), 6 => array('name' => 'Inc.', 'click' => false));
     $tab_info[$pro_v]['click'] = true;
     $product = $product_array[$pro_v];
     $from = $params['from'] ? date("Y-m-d 00:00:00", strtotime($params['from'])) : date("Y-m-01 00:00:00");
     $to = $params['to'] ? date("Y-m-d 23:59:59", strtotime($params['to'])) : date("Y-m-t 23:59:59");
     $input_from = date("Y-m-d", strtotime($from));
     $input_to = date("Y-m-d", strtotime($to));
     $projects = Bll_PMTProjectBiz::get_instance()->get_project_detail_by_release_date_new($product, $from, $to);
     if (empty($projects)) {
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('input_from', $input_from);
         $req->set_attribute('input_to', $input_to);
         $req->set_attribute('table_project', array());
         return 'NewReport_ProjectBug';
     }
     $pmt_ids_init = array();
     $projects_pmtid = array();
     foreach ($projects as $project) {
         $projects_pmtid[$project['id']] = $project;
         $pmt_ids_init[] = $project['id'];
     }
     $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids($pmt_ids_init);
     $tasks_pmtid = array();
     foreach ($tasks as $task) {
         if (in_array($task['task_type_id'], array(2, 3, 33))) {
             //2=>前端开发, 3=>后端开发,33=>开发
             $tasks_pmtid[$task['project_id']]['dev'][] = $task;
         } elseif (in_array($task['task_type_id'], array(4))) {
             //4=>测试
             $tasks_pmtid[$task['project_id']]['test'][] = $task;
         }
     }
     $pmt_ids = array();
     foreach ($pmt_ids_init as $pmt_id) {
         if (!empty($tasks_pmtid[$pmt_id]['dev']) && !empty($tasks_pmtid[$pmt_id]['test'])) {
             $pmt_ids[] = $pmt_id;
         } else {
             $pmt_ids[] = '';
         }
     }
     $rates = Bll_ReportPmtInfoBiz::get_instance()->get_through_rate_by_pmtids($pmt_ids);
     $rates_pmtid = array();
     foreach ($rates as $rate) {
         $rates_pmtid[$rate->project_id][$rate->chinese_name] = $rate->rate;
     }
     $delay_infos = Bll_ReportPmtInfoBiz::get_instance()->get_project_delay_info_by_pmtids($pmt_ids);
     //延期信息
     $delay_infos_pmtid = array();
     foreach ($delay_infos as $delay_info) {
         $delay_infos_pmtid[$delay_info->project_id] = $delay_info;
     }
     //stage: 5-dev 6-test
     $table_workload = array();
     $table_through = array();
     foreach ($pmt_ids as $pmt_id) {
         if (empty($tasks_pmtid[$pmt_id]['dev'])) {
             $table_workload[$pmt_id]['dev_person'] = '';
             $table_workload[$pmt_id]['dev_workload'] = 0;
         } else {
             $person = array();
             $time = 0;
             foreach ($tasks_pmtid[$pmt_id]['dev'] as $row) {
                 $person[] = $row['chinese_name'];
                 $time += intval($row['workload']);
             }
             $person = array_unique($person);
             $person_str = implode("/", $person);
             $table_workload[$pmt_id]['dev_person'] = $person_str;
             $table_workload[$pmt_id]['dev_workload'] = $time;
             $through_arr = array();
             $through_str = "";
             foreach ($person as $person_row) {
                 $str = isset($rates_pmtid[$pmt_id][$person_row]) ? $rates_pmtid[$pmt_id][$person_row] : "-";
                 if ($str == "-") {
                     $through_arr[] = $person_row . ": " . $str;
                 } else {
                     if ($str < 100) {
                         $through_arr[] = '<span style="color:red;">' . $person_row . ": " . $str . '%</span>';
                     } else {
                         $through_arr[] = $person_row . ": " . $str . '%';
                     }
                 }
             }
             $str = isset($rates_pmtid[$pmt_id]['all']) ? $rates_pmtid[$pmt_id]['all'] : "-";
             if ($str == "-") {
                 $through_arr[] = '整个项目' . ": " . $str;
             } else {
                 if ($str < 100) {
                     $through_arr[] = '<span style="color:red;">' . '整个项目' . ": " . $str . '%</span>';
                 } else {
                     $through_arr[] = '整个项目' . ": " . $str . '%';
                 }
             }
             $through_str = implode("<br />", $through_arr);
             $table_through[$pmt_id] = $through_str;
         }
         if (empty($tasks_pmtid[$pmt_id]['test'])) {
             $table_workload[$pmt_id]['test_person'] = '';
             $table_workload[$pmt_id]['test_workload'] = 0;
         } else {
             $person = array();
             $time = 0;
             foreach ($tasks_pmtid[$pmt_id]['test'] as $row) {
                 $person[] = $row['chinese_name'];
                 $time += intval($row['workload']);
             }
             $person = array_unique($person);
             $person_str = implode("/", $person);
             $table_workload[$pmt_id]['test_person'] = $person_str;
             $table_workload[$pmt_id]['test_workload'] = $time;
         }
     }
     $bugs = Bll_TicketBiz::get_instance()->get_bugs_detail_by_pmtids($pmt_ids);
     //bug数
     $bugs_pmtid = array();
     foreach ($bugs as $bug) {
         $bugs_pmtid[$bug->pmt_id][] = $bug;
     }
     //environment id-value array
     $environments = Bll_DdCommonBiz::get_instance()->get_environments();
     $envi_names = array();
     foreach ($environments as $environment) {
         $envi_names[$environment->sort] = $environment->name;
     }
     ksort($envi_names);
     //priority id-value array
     $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $priority_names = array();
     foreach ($prioritys as $priority) {
         if ($priority->value == 6) {
             continue;
         }
         $priority_names[$priority->sort] = $priority->name;
     }
     ksort($priority_names);
     $table_bugs = array();
     foreach ($pmt_ids as $pmt_id) {
         foreach ($envi_names as $envi) {
             $table_bugs[$pmt_id][$envi] = 0;
         }
         foreach ($priority_names as $prior) {
             $table_bugs[$pmt_id][$prior] = 0;
         }
         if (isset($bugs_pmtid[$pmt_id])) {
             foreach ($bugs_pmtid[$pmt_id] as $bug) {
                 foreach ($envi_names as $envi) {
                     if ($bug->environment == $envi) {
                         $table_bugs[$pmt_id][$envi] += 1;
                     }
                 }
                 foreach ($priority_names as $prior) {
                     if ($bug->priority == $prior) {
                         $table_bugs[$pmt_id][$prior] += 1;
                     }
                 }
             }
         }
     }
     $table_project = array();
     foreach ($pmt_ids as $pmt_id) {
         $table_project[$pmt_id]['pmt_id'] = $pmt_id;
         $table_project[$pmt_id]['summary'] = $projects_pmtid[$pmt_id]['summary'];
         $table_project[$pmt_id]['release_date'] = date("Y-m-d", strtotime($projects_pmtid[$pmt_id]['date_release']));
         $table_project[$pmt_id]['pro_set'] = empty($projects_pmtid[$pmt_id]['set_id']) ? '' : $projects_pmtid[$pmt_id]['set_id'] . ". " . $projects_pmtid[$pmt_id]['set_name'];
         $table_project[$pmt_id]['owner'] = $projects_pmtid[$pmt_id]['chinese_name'];
         $table_project[$pmt_id]['dev_person'] = $table_workload[$pmt_id]['dev_person'];
         $table_project[$pmt_id]['test_person'] = $table_workload[$pmt_id]['test_person'];
         $table_project[$pmt_id]['self_test'] = $table_through[$pmt_id];
         $table_project[$pmt_id]['bugs_count'] = isset($bugs_pmtid[$pmt_id]) ? count($bugs_pmtid[$pmt_id]) : 0;
         $table_project[$pmt_id]['Production'] = $table_bugs[$pmt_id]['Production'];
         $table_project[$pmt_id]['PreRelease'] = $table_bugs[$pmt_id]['PreRelease'];
         $table_project[$pmt_id]['Test'] = $table_bugs[$pmt_id]['Test'];
         $table_project[$pmt_id]['Dev'] = $table_bugs[$pmt_id]['Dev'];
         $table_project[$pmt_id]['P1'] = $table_bugs[$pmt_id]['P1-Blocker'];
         $table_project[$pmt_id]['P2'] = $table_bugs[$pmt_id]['P2-Critical'];
         $table_project[$pmt_id]['P3'] = $table_bugs[$pmt_id]['P3-Major'];
         $table_project[$pmt_id]['P4'] = $table_bugs[$pmt_id]['P4-Minor'];
         $table_project[$pmt_id]['P5'] = $table_bugs[$pmt_id]['P5-Trivial'];
         if (isset($delay_infos_pmtid[$pmt_id])) {
             $table_project[$pmt_id]['is_delay'] = $delay_infos_pmtid[$pmt_id]->self_test_delayed == 1 ? 'Yes' . '<br />' . '原因:' . $delay_infos_pmtid[$pmt_id]->delay_detail : 'No';
         } else {
             $table_project[$pmt_id]['is_delay'] = '-';
         }
     }
     unset($table_project[""]);
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('input_from', $input_from);
     $req->set_attribute('input_to', $input_to);
     $req->set_attribute('table_project', $table_project);
     return 'NewReport_ProjectBug';
 }
Beispiel #15
0
    $components = Bll_DdComponentBiz::get_instance()->get_components($depart->id);
    $comp_id_value = array();
    foreach ($components as $component) {
        $comp_id_value[$component->int] = $component->value;
    }
    $tickets_component = array();
    foreach ($tickets_all as $tickets_all_row) {
        if ($tickets_all_row->component) {
            $tickets_component[$comp_id_value[$tickets_all_row->component]][] = $tickets_all_row;
        }
    }
    foreach ($comp_id_value as $comp_v) {
        $count = isset($tickets_component[$comp_v]) ? count($tickets_component[$comp_v]) : 0;
        $input_arr = array('month' => $month, 'department' => $depart->value, 'type_key' => 'component', 'type_value' => $comp_v, 'count' => $count, 'created_at' => $current_time);
        $count_id = Bll_ReportMonthOnlineBiz::get_instance()->insert_count_data($input_arr);
    }
    //resolution counts
    $tickets_reso_all = Bll_TicketBiz::get_instance()->get_count_online_by_month($begin, $end, 'resolution', $depart->id);
    $tickets_resolution = array();
    foreach ($tickets_reso_all as $tickets_reso_all_row) {
        if ($tickets_reso_all_row->resolution) {
            $tickets_resolution[$reso_id_value[$tickets_reso_all_row->resolution]][] = $tickets_reso_all_row;
        }
    }
    foreach ($reso_id_value as $reso_v) {
        $count = isset($tickets_resolution[$reso_v]) ? count($tickets_resolution[$reso_v]) : 0;
        $input_arr = array('month' => $month, 'department' => $depart->value, 'type_key' => 'resolution', 'type_value' => $reso_v, 'count' => $count, 'created_at' => $current_time);
        $count_id = Bll_ReportMonthOnlineBiz::get_instance()->insert_count_data($input_arr);
    }
}
echo date('c ') . " Count month online bugs ok \n";
Beispiel #16
0
 /**
  *	处理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;
 }
Beispiel #17
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $sub = $params['form_sub'] ? trim($params['form_sub']) : 'Update';
     $product_array = array(0, 12, 13, 14, 7, 6, 4);
     $pro_v = $params['pro'] ? $params['pro'] : 0;
     $pmt_id_q = $params['pmt_id'] ? trim($params['pmt_id']) : 0;
     /*$tab_info = array(
       1 => array('name' => 'Anjuke', 'click' => false),
       2 => array('name' => 'Aifang', 'click' => false),
       3 => array('name' => 'Haozu', 'click' => false),
       4 => array('name' => 'Jinpu', 'click' => false),
       5 => array('name' => 'Mobile', 'click' => false),
       6 => array('name' => 'Inc', 'click' => false)
       );*/
     $tab_info = array(0 => array('name' => '全部', 'click' => false), 1 => array('name' => '用户端', 'click' => false), 2 => array('name' => '客户端', 'click' => false), 3 => array('name' => '开发商', 'click' => false), 4 => array('name' => 'CRM', 'click' => false), 5 => array('name' => '移动', 'click' => false), 6 => array('name' => 'Inc.', 'click' => false));
     $tab_info[$pro_v]['click'] = true;
     $product = $product_array[$pro_v];
     $from = $params['from'] ? date("Y-m-d 00:00:00", strtotime($params['from'])) : date("Y-m-01 00:00:00");
     $to = $params['to'] ? date("Y-m-d 23:59:59", strtotime($params['to'])) : date("Y-m-t 23:59:59");
     $input_from = date("Y-m-d", strtotime($from));
     $input_to = date("Y-m-d", strtotime($to));
     $mode = $params['select_mode'] ? $params['select_mode'] : '1';
     if ($sub == 'OK' && $pmt_id_q != 0) {
         $projects = Bll_PMTProjectBiz::get_instance()->get_project_detail_by_ids(array($pmt_id_q));
     } else {
         $projects = Bll_PMTProjectBiz::get_instance()->get_projects_by_release_date_new($product, $from, $to);
     }
     //shirlyhu
     $groups = Bll_UserGroupCustomBiz::get_instance()->get_all_groups();
     foreach ($groups as $value) {
         $group[$value->department][] = array('name' => $value->group_name, 'id' => $value->id);
     }
     if ($group != null) {
         $req->set_attribute('group', $group);
     }
     $groups_users = Bll_UserGroupCustomBiz::get_instance()->get_groups_by_department(10);
     //属于用户端的组
     $member_group = array();
     foreach ($groups as $groups_user) {
         $group_members = explode(',', $groups_user->group_members);
         $member_chinesename = Bll_UserBiz::get_instance()->get_chinesenames_by_ids($group_members);
         foreach ($member_chinesename as $group_member) {
             if ($group_member) {
                 $member_group[$group_member] .= $groups_user->id . ",";
             }
         }
     }
     //shirlyhu
     if (empty($projects)) {
         $req->set_attribute('product', $product);
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('table_person', array());
         $req->set_attribute('table_project', array());
         $req->set_attribute('input_from', $input_from);
         $req->set_attribute('input_to', $input_to);
         $req->set_attribute('mode', $mode);
         $req->set_attribute('pmt_id_q', $pmt_id_q);
         return 'NewReport_Workload';
     }
     $pmt_ids_init = array();
     $projects_pmtid = array();
     foreach ($projects as $project) {
         $projects_pmtid[$project['id']] = $project;
         $pmt_ids_init[] = $project['id'];
     }
     $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids($pmt_ids_init);
     $tasks_pmtid = array();
     $tasks_pmtid_person = array();
     if ($tasks) {
         foreach ($tasks as $task) {
             if (in_array($task['task_type_id'], array(2, 3, 33))) {
                 $tasks_pmtid[$task['project_id']]['dev'][] = $task;
                 $tasks_pmtid_person[$task['project_id']]['dev'][$task['chinese_name']][] = $task['workload'];
             } elseif (in_array($task['task_type_id'], array(4))) {
                 $tasks_pmtid[$task['project_id']]['test'][] = $task;
                 $tasks_pmtid_person[$task['project_id']]['test'][$task['chinese_name']][] = $task['workload'];
             }
         }
     }
     $pmt_ids = array();
     foreach ($pmt_ids_init as $pmt_id) {
         if (!empty($tasks_pmtid[$pmt_id]['dev']) && !empty($tasks_pmtid[$pmt_id]['test'])) {
             $pmt_ids[] = $pmt_id;
         }
     }
     if (empty($pmt_ids)) {
         $req->set_attribute('product', $product);
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('table_person', array());
         $req->set_attribute('table_project', array());
         $req->set_attribute('input_from', $input_from);
         $req->set_attribute('input_to', $input_to);
         $req->set_attribute('mode', $mode);
         $req->set_attribute('pmt_id_q', $pmt_id_q);
         return 'NewReport_Workload';
     }
     $tasks_person = array();
     $tasks_qa = array();
     $persons = array();
     $qa_users = array();
     foreach ($tasks as $task) {
         if (in_array($task['project_id'], $pmt_ids)) {
             if (in_array($task['task_type_id'], array(2, 3, 33))) {
                 $tasks_person[$task['chinese_name']][] = $task['workload'];
                 $persons[] = $task['chinese_name'];
             } elseif (in_array($task['task_type_id'], array(4))) {
                 $tasks_qa[$task['chinese_name']][] = $task['workload'];
                 $qa_users[] = $task['chinese_name'];
             }
         }
     }
     $persons_pro = array_unique($persons);
     $persons = array();
     foreach ($persons_pro as $row) {
         $persons[] = $row;
     }
     $qa_pro = array_unique($qa_users);
     $qa_users = array();
     foreach ($qa_pro as $row) {
         $qa_users[] = $row;
     }
     $rates = Bll_ReportPmtInfoBiz::get_instance()->get_through_rate_by_pmtids($pmt_ids);
     $rates_pmtid = array();
     foreach ($rates as $rate) {
         $rates_pmtid[$rate->project_id][$rate->chinese_name] = $rate->rate;
     }
     $delay_infos = Bll_ReportPmtInfoBiz::get_instance()->get_project_delay_info_by_pmtids($pmt_ids);
     $delay_infos_pmtid = array();
     foreach ($delay_infos as $delay_info) {
         $delay_infos_pmtid[$delay_info->project_id] = $delay_info;
     }
     $bugs = Bll_TicketBiz::get_instance()->get_bugs_by_pmtids($pmt_ids);
     $bugs_pmtid = array();
     foreach ($bugs as $bug) {
         $bugs_pmtid[$bug['pmt_id']] = $bug['BugCount'];
     }
     $bug_detail = Bll_TicketBiz::get_instance()->get_bugs_detail_by_pmtids($pmt_ids);
     $users = Bll_UserBiz::get_instance()->get_all_users();
     $user_wc = array();
     foreach ($users as $row) {
         $user_wc[$row->whole_name] = $row->chinese_name;
     }
     $bug_detail_dev = array();
     $bug_detail_qa = array();
     foreach ($bug_detail as $row) {
         $bug_detail_dev[$row->pmt_id][$user_wc[$row->owner]][] = $row;
         $bug_detail_qa[$row->pmt_id][$user_wc[$row->reporter]][] = $row;
     }
     $table_work_person = array();
     foreach ($pmt_ids as $pmt_id) {
         $dev_p = array();
         $dev_t = array();
         $test_p = array();
         $test_t = array();
         $dev_bug = array();
         $test_bug = array();
         $dev_bug_workload = array();
         $test_bug_workload = array();
         foreach ($tasks_pmtid_person[$pmt_id]['dev'] as $d_p => $task_dev) {
             $dev_p[$d_p] = $d_p;
             $dev_t[$d_p] = 0;
             $dev_bug[$d_p] = isset($bug_detail_dev[$pmt_id][$d_p]) ? count($bug_detail_dev[$pmt_id][$d_p]) : 0;
             foreach ($task_dev as $t) {
                 $dev_t[$d_p] += intval($t);
             }
             $dev_bug_workload[$d_p] = $dev_t[$d_p] == 0 ? 0 : round(intval($dev_bug[$d_p]) / $dev_t[$d_p], 2);
         }
         foreach ($tasks_pmtid_person[$pmt_id]['test'] as $t_p => $task_test) {
             $test_p[$t_p] = $t_p;
             $test_t[$t_p] = 0;
             $test_bug[$t_p] = isset($bug_detail_qa[$pmt_id][$t_p]) ? count($bug_detail_qa[$pmt_id][$t_p]) : 0;
             foreach ($task_test as $t) {
                 $test_t[$t_p] += intval($t);
             }
             $test_bug_workload[$t_p] = $test_t[$t_p] == 0 ? 0 : round(intval($test_bug[$t_p]) / $test_t[$t_p], 2);
         }
         $table_work_person[$pmt_id]['dev_p'] = implode("<br />", $dev_p);
         $table_work_person[$pmt_id]['dev_t'] = implode("<br />", $dev_t);
         $table_work_person[$pmt_id]['test_p'] = implode("<br />", $test_p);
         $table_work_person[$pmt_id]['test_t'] = implode("<br />", $test_t);
         $table_work_person[$pmt_id]['dev_bug'] = implode("<br />", $dev_bug);
         $table_work_person[$pmt_id]['test_bug'] = implode("<br />", $test_bug);
         $table_work_person[$pmt_id]['dev_bug_workload'] = implode("<br />", $dev_bug_workload);
         $table_work_person[$pmt_id]['test_bug_workload'] = implode("<br />", $test_bug_workload);
     }
     //stage: 5-dev 6-test
     $table_workload = array();
     $table_through = array();
     foreach ($pmt_ids as $pmt_id) {
         if (empty($tasks_pmtid[$pmt_id]['dev'])) {
             $table_workload[$pmt_id]['dev_person'] = '';
             $table_workload[$pmt_id]['dev_workload'] = 0;
         } else {
             $person = array();
             $time = 0;
             foreach ($tasks_pmtid[$pmt_id]['dev'] as $row) {
                 $person[] = $row['chinese_name'];
                 $time += intval($row['workload']);
             }
             $person = array_unique($person);
             $person_str = implode("/", $person);
             $table_workload[$pmt_id]['dev_person'] = $person_str;
             $table_workload[$pmt_id]['dev_workload'] = $time;
             $through_arr = array();
             $through_str = "";
             foreach ($person as $person_row) {
                 $str = isset($rates_pmtid[$pmt_id][$person_row]) ? $rates_pmtid[$pmt_id][$person_row] : "-";
                 if ($str == "-") {
                     $through_arr[] = $person_row . ": " . $str;
                 } else {
                     if ($str < 100) {
                         $through_arr[] = '<span style="color:red;">' . $person_row . ": " . $str . '%</span>';
                     } else {
                         $through_arr[] = $person_row . ": " . $str . '%';
                     }
                 }
             }
             $str = isset($rates_pmtid[$pmt_id]['all']) ? $rates_pmtid[$pmt_id]['all'] : "-";
             if ($str == "-") {
                 $through_arr[] = '整个项目' . ": " . $str;
             } else {
                 if ($str < 100) {
                     $through_arr[] = '<span style="color:red;">' . '整个项目' . ": " . $str . '%</span>';
                 } else {
                     $through_arr[] = '整个项目' . ": " . $str . '%';
                 }
             }
             $through_str = implode("<br />", $through_arr);
             $table_through[$pmt_id] = $through_str;
         }
         if (empty($tasks_pmtid[$pmt_id]['test'])) {
             $table_workload[$pmt_id]['test_person'] = '';
             $table_workload[$pmt_id]['test_workload'] = 0;
         } else {
             $person = array();
             $time = 0;
             foreach ($tasks_pmtid[$pmt_id]['test'] as $row) {
                 $person[] = $row['chinese_name'];
                 $time += intval($row['workload']);
             }
             $person = array_unique($person);
             $person_str = implode("/", $person);
             $table_workload[$pmt_id]['test_person'] = $person_str;
             $table_workload[$pmt_id]['test_workload'] = $time;
         }
     }
     $table_project = array();
     foreach ($pmt_ids as $pmt_id) {
         $table_project[$pmt_id]['release_date'] = date("Y-m-d", strtotime($projects_pmtid[$pmt_id]['date_release']));
         $table_project[$pmt_id]['pmt_id'] = $pmt_id;
         $table_project[$pmt_id]['summary'] = $projects_pmtid[$pmt_id]['summary'];
         $table_project[$pmt_id]['owner'] = $projects_pmtid[$pmt_id]['chinese_name'];
         //$table_project[$pmt_id]['dev_person'] = $table_workload[$pmt_id]['dev_person'];
         $table_project[$pmt_id]['dev_workload_all'] = $table_workload[$pmt_id]['dev_workload'];
         //$table_project[$pmt_id]['test_person'] = $table_workload[$pmt_id]['test_person'];
         $table_project[$pmt_id]['test_workload_all'] = $table_workload[$pmt_id]['test_workload'];
         $table_project[$pmt_id]['dev_person'] = $table_work_person[$pmt_id]['dev_p'];
         $table_project[$pmt_id]['dev_workload'] = $table_work_person[$pmt_id]['dev_t'];
         $table_project[$pmt_id]['dev_bug'] = $table_work_person[$pmt_id]['dev_bug'];
         $table_project[$pmt_id]['dev_bug_workload'] = $table_work_person[$pmt_id]['dev_bug_workload'];
         $table_project[$pmt_id]['test_person'] = $table_work_person[$pmt_id]['test_p'];
         $table_project[$pmt_id]['test_workload'] = $table_work_person[$pmt_id]['test_t'];
         $table_project[$pmt_id]['test_bug'] = $table_work_person[$pmt_id]['test_bug'];
         $table_project[$pmt_id]['test_bug_workload'] = $table_work_person[$pmt_id]['test_bug_workload'];
         $table_project[$pmt_id]['self_test'] = $table_through[$pmt_id];
         $table_project[$pmt_id]['bugs_count'] = isset($bugs_pmtid[$pmt_id]) ? $bugs_pmtid[$pmt_id] : 0;
         $table_project[$pmt_id]['bug_devload'] = $table_project[$pmt_id]['dev_workload_all'] == 0 ? 0 : round($table_project[$pmt_id]['bugs_count'] / $table_project[$pmt_id]['dev_workload_all'], 2);
         $table_project[$pmt_id]['bug_testload'] = $table_project[$pmt_id]['test_workload_all'] == 0 ? 0 : round($table_project[$pmt_id]['bugs_count'] / $table_project[$pmt_id]['test_workload_all'], 2);
         $table_project[$pmt_id]['devload_testload'] = $table_project[$pmt_id]['test_workload_all'] == 0 ? 0 : round($table_project[$pmt_id]['dev_workload_all'] / $table_project[$pmt_id]['test_workload_all'], 2);
         //shirlyhu
         //            $person_groups=explode("<br />",$table_project[$pmt_id]['dev_person']);
         //
         //            foreach($person_groups as $person_group){
         //               if($member_group[$person_group]){
         //                   $table_project[$pmt_id]['group_id'].=$member_group[$person_group].",";
         //               }
         //            }
         //shirlyhu
         if (isset($delay_infos_pmtid[$pmt_id])) {
             $table_project[$pmt_id]['is_delay'] = $delay_infos_pmtid[$pmt_id]->self_test_delayed == 1 ? 'Yes' . '<br />' . '原因:' . $delay_infos_pmtid[$pmt_id]->delay_detail : 'No';
         } else {
             $table_project[$pmt_id]['is_delay'] = '-';
         }
     }
     //by person
     $bugs = Bll_TicketBiz::get_instance()->get_bugs_by_persons($persons, $pmt_ids);
     $bugs_person = array();
     foreach ($bugs as $bug) {
         $bugs_person[$bug['chinese_name']] = $bug['BugCount'];
     }
     $bugs_qa_user = Bll_TicketBiz::get_instance()->get_bugs_by_qas($qa_users, $pmt_ids);
     $bugs_qa = array();
     foreach ($bugs_qa_user as $bug) {
         $bugs_qa[$bug['chinese_name']] = $bug['BugCount'];
     }
     $table_qa = array();
     $table_qa['total'] = array('person' => 'Total', 'bugs_count' => 0, 'workload' => 0, 'bugs_load' => 0);
     foreach ($qa_users as $qa) {
         $table_qa[$qa]['person'] = $qa;
         if ($member_group[$qa]) {
             $table_qa[$qa]['group_id'] = $member_group[$qa];
         }
         $table_qa[$qa]['bugs_count'] = isset($bugs_qa[$qa]) ? $bugs_qa[$qa] : 0;
         $table_qa[$qa]['workload'] = 0;
         foreach ($tasks_qa[$qa] as $row) {
             $table_qa[$qa]['workload'] += intval($row);
         }
         $table_qa[$qa]['bugs_load'] = $table_qa[$qa]['workload'] == 0 ? 0 : round($table_qa[$qa]['bugs_count'] / $table_qa[$qa]['workload'], 2);
         $table_qa['total']['bugs_count'] += $table_qa[$qa]['bugs_count'];
         $table_qa['total']['workload'] += $table_qa[$qa]['workload'];
     }
     $table_qa['total']['bugs_load'] = $table_qa['total']['workload'] == 0 ? 0 : round($table_qa['total']['bugs_count'] / $table_qa['total']['workload'], 2);
     $table_person = array();
     $table_person['total'] = array('person' => 'Total', 'bugs_count' => 0, 'workload' => 0, 'bugs_load' => 0);
     foreach ($persons as $person) {
         $table_person[$person]['person'] = $person;
         if ($member_group[$person]) {
             $table_person[$person]['group_id'] = $member_group[$person];
         }
         $table_person[$person]['bugs_count'] = isset($bugs_person[$person]) ? $bugs_person[$person] : 0;
         $table_person[$person]['workload'] = 0;
         foreach ($tasks_person[$person] as $row) {
             $table_person[$person]['workload'] += intval($row);
         }
         $table_person[$person]['bugs_load'] = $table_person[$person]['workload'] == 0 ? 0 : round($table_person[$person]['bugs_count'] / $table_person[$person]['workload'], 2);
         $table_person['total']['bugs_count'] += $table_person[$person]['bugs_count'];
         $table_person['total']['workload'] += $table_person[$person]['workload'];
     }
     $table_person['total']['bugs_load'] = $table_person['total']['workload'] == 0 ? 0 : round($table_person['total']['bugs_count'] / $table_person['total']['workload'], 2);
     $req->set_attribute('product', $product);
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('table_person', $table_person);
     $req->set_attribute('table_qa', $table_qa);
     $req->set_attribute('table_project', $table_project);
     $req->set_attribute('input_from', $input_from);
     $req->set_attribute('input_to', $input_to);
     $req->set_attribute('mode', $mode);
     $req->set_attribute('pmt_id_q', $pmt_id_q);
     return 'NewReport_Workload';
 }
Beispiel #18
0
 public function get_rank_bug_resolved_by_group($type, $group_id)
 {
     $count_by_group = array();
     $count_by_group['less_87'] = 0;
     $count_by_group['more_87'] = 0;
     $count_by_group['less_88'] = 0;
     $count_by_group['more_88'] = 0;
     $count_by_group['less_89'] = 0;
     $count_by_group['more_89'] = 0;
     $count_by_group['less_90'] = 0;
     $count_by_group['more_90'] = 0;
     $one_day = 86400;
     $result = $this->get_time($type);
     $emergency = Bll_DdCommonBiz::get_instance()->get_emergencies();
     $group = Bll_UserGroupCustomBiz::get_instance()->get_group_by_id($group_id);
     if ($group) {
         $user_id_arr = explode(',', $group->group_members);
         $user_id_arr = array_filter($user_id_arr);
         $depart_id = Bll_DdCommonBiz::get_instance()->get_department_id_by_value($group->department);
         $group_usernames = Bll_UserBiz::get_instance()->get_usernames_by_userids($user_id_arr);
         $tickets = Bll_TicketBiz::get_instance()->get_count_online_by_groups($result[0], $result[1], $group_usernames, $depart_id);
         $tickets = $this->distinct_emergency($tickets, $emergency);
         $count_by_group['group_name'] = $group->group_name;
         foreach ($emergency as $eme) {
             $id = $eme->id;
             $c = count($tickets[$id]);
             if ($c > 0) {
                 $t = count($tickets[$id]);
                 for ($i = 0; $i < $t; $i++) {
                     $created_time = strtotime($tickets[$id][$i]['created_at']);
                     $closed_time = strtotime($tickets[$id][$i]['closed_at']);
                     $created_time_date = strtotime(substr($tickets[$id][$i]['created_at'], 0, 10));
                     $closed_time_date = strtotime(substr($tickets[$id][$i]['closed_at'], 0, 10));
                     $gap = $this->get_work_days($created_time_date, $closed_time_date, $created_time, $closed_time);
                     if ($id == '87') {
                         if ($gap <= $one_day) {
                             $count_by_group['less_87']++;
                         } else {
                             $count_by_group['more_87']++;
                         }
                     } elseif ($id == '88') {
                         if ($gap <= $one_day * 2) {
                             $count_by_group['less_88']++;
                         } else {
                             $count_by_group['more_88']++;
                         }
                     } elseif ($id == '89') {
                         if ($gap <= $one_day * 3) {
                             $count_by_group['less_89']++;
                         } else {
                             $count_by_group['more_89']++;
                         }
                     } elseif ($id == '90') {
                         if ($gap <= $one_day * 22) {
                             $count_by_group['less_90']++;
                         } else {
                             $count_by_group['more_90']++;
                         }
                     }
                 }
             }
         }
     }
     $l = $count_by_group['less_87'] * 5 + $count_by_group['less_88'] * 3 + $count_by_group['less_89'] * 1 + $count_by_group['less_90'] * 0.5;
     $cou = ($count_by_group['less_87'] + $count_by_group['more_87']) * 5 + ($count_by_group['less_88'] + $count_by_group['more_88']) * 3 + ($count_by_group['less_89'] + $count_by_group['more_89']) * 1 + ($count_by_group['less_90'] + $count_by_group['more_90']) * 0.5;
     if ($l == 0 && $cou == 0) {
         $count_by_group['rate'] = 0;
     } else {
         $count_by_group['rate'] = $l / $cou;
     }
     return $count_by_group;
 }
Beispiel #19
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $pro = $params['pro'] ? $params['pro'] : 'all';
     $user_id = $req->get_user_id();
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_for_user_group();
     $groups = Bll_UserGroupCustomBiz::get_instance()->get_all_groups();
     $input_arr = array('type_key' => 'page', 'type_value' => 'onlinenew');
     $return = " ";
     if (isset($params['group_id']) && !empty($params['group_id'])) {
         $input_arr['groups'] = explode("|", $params['group_id']);
         array_pop($input_arr['groups']);
         $return = Bll_ReportGroupSelectedBiz::get_instance()->insert_selected_group($input_arr);
     }
     if ($return == null || $return == " ") {
         $page_bind_groups = "";
     } else {
         $page_bind_groups = Bll_ReportGroupSelectedBiz::get_instance()->get_group_ids_arr($input_arr);
     }
     foreach ($departments as $value) {
         if (intval($value->value) < 17 || intval($value->value) > 26) {
             $department[$value->value] = $value->name;
         }
     }
     $page_bind_groups_with_name = array();
     foreach ($groups as $value) {
         $group[$value->department][] = array('name' => $value->group_name, 'id' => $value->id);
         if (!empty($page_bind_groups) || strlen($page_bind_groups[0]) > 0) {
             foreach ($page_bind_groups as $p) {
                 if ($p == $value->id) {
                     $temp = array();
                     $temp['id'] = $p;
                     $temp['name'] = $value->group_name;
                     array_push($page_bind_groups_with_name, $temp);
                 }
             }
         }
     }
     $tab_info = array('all' => array('name' => 'ALL', 'click' => false), 'mobile' => array('name' => 'Mobile', 'click' => false), 'pc' => array('name' => 'Pc', 'click' => false));
     $tab_info[$pro]['click'] = true;
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('department', $department);
     if ($group != null) {
         $req->set_attribute('group', $group);
     }
     $req->set_attribute('user_id', $user_id);
     if (!empty($page_bind_groups) || strlen($page_bind_groups[0]) > 0) {
         $req->set_attribute('page_bind_groups', $page_bind_groups);
     }
     if (!empty($page_bind_groups_with_name) || strlen($page_bind_groups_with_name) > 0) {
         $req->set_attribute('page_bind_groups_with_name', $page_bind_groups_with_name);
     }
     $req->set_attribute('department_id', $department_id);
     $product = $params['pro'] ? $params['pro'] : 0;
     $tab_info = APF::get_instance()->get_config('department');
     /*$tab_info = array(
                     0 => array('name' => 'Overview', 'click' => false),
                     1 => array('name' => 'Anjuke', 'click' => false),
                     2 => array('name' => 'Aifang', 'click' => false),
                     3 => array('name' => 'Haozu', 'click' => false),
                     4 => array('name' => 'Jinpu', 'click' => false),
                     5 => array('name' => 'Mobile', 'click' => false),
                     6 => array('name' => 'Inc', 'click' => false)
     
             );*/
     $tab_info[$product]['click'] = true;
     $month_query = $params['form_month'] ? $params['form_month'] : date("Y-m", strtotime('now'));
     $depart_value_id = array('0' => '99', '10' => '51', '11' => '52', '12' => '53', '13' => '54', '20' => '52', '5' => '100', '15' => '56', '24' => '75');
     $pro_id = $depart_value_id[$product];
     $begin = date('Y-m-01', strtotime('now'));
     $end = date('Y-m-t', strtotime('now'));
     $detail_url = Ticket_CustomQueryController::build_uri() . "?act=query&page_current=1&created_at[v][1][b]=" . $begin . "&created_at[v][1][e]=" . $end . "&environment[v][]=19&department[v][]=" . $pro_id . "&sort_by=resolution&sort_order=desc&sort_c=&sort_o=desc";
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $department = array();
     foreach ($departments as $depart) {
         $department[$depart->value] = $depart->name;
     }
     //overview
     if ($product == 0) {
         $rows = 30 * count($department);
         $counts_all = Bll_ReportDayOnlineBiz::get_instance()->get_counts_by_date_all($rows, $product);
         //每个部门
         $counts_all = array_reverse($counts_all);
         $count_day_sec = array();
         $counts_all_temp = array();
         /*$count ="";
                     $day="";
                     foreach($counts_all as $row){
                         if (  in_array( $row->department,array('14','15','16','18','19') ) ){
                             $count = $count + $row->count;
                             $day =$row->day;
                         }else{
                             $counts_all_temp[] =$row;
                         }
                     }
                     $count_day_sec[$day]['移动']=$count."";
         
         
                     foreach ($counts_all_temp as $row) {
                         $count_day_sec[$row->day][$department[$row->department]] = $row->count;
                     }*/
         foreach ($counts_all as $row) {
             $count_day_sec[$row->day][$department[$row->department]] = $row->count;
         }
         foreach ($count_day_sec as $day => $ticketcnt) {
             $count = $ticketcnt['Mobile-broker'] + $ticketcnt['Mobile-jinpu'] + $ticketcnt['Mobile-xinfang'] + $ticketcnt['Mobile-haozu'] + $ticketcnt['Mobile-anjuke'];
             $count_day_sec[$day]['移动'] = $count;
             unset($count_day_sec[$day]['Mobile-broker']);
             unset($count_day_sec[$day]['Mobile-jinpu']);
             unset($count_day_sec[$day]['Mobile-xinfang']);
             unset($count_day_sec[$day]['Mobile-haozu']);
             unset($count_day_sec[$day]['Mobile-anjuke']);
         }
         $count_day_all = array();
         foreach ($count_day_sec as $key => $row) {
             $count_day_all[] = array_merge(array('date' => $key), $row);
         }
         //$count_day_all[] = array_merge($count_day_all,$temparray);
         //month_all
         //$rows_month = 12 * count($department);
         //array_pop($department);
         //array_pop($department);
         //month_all
         $rows_month = 12 * count($department);
         $last_twelve_month = array();
         for ($month = date('Y-m-d', strtotime('now')), $times = 12; $times > 0; $month = date('Y-m-d', strtotime('last month', strtotime($month))), --$times) {
             $last_twelve_month[] = date('Y-m', strtotime($month));
         }
         $last_twelve_month = array_reverse($last_twelve_month);
         foreach ($last_twelve_month as $month) {
             foreach ($department as $key => $value) {
                 $departc[] = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_month($month, 'all', $key);
             }
             $counts_month = $departc;
         }
         foreach ($counts_month as $value) {
             $temp[] = $value[0];
         }
         $counts_month = $temp;
         /*$count_month_temp = array();
           $count= 0;
           $month="";
           foreach($counts_month as $row){
               if (  in_array( $row->department,array('14','15','16','18','19') ) ){
                   $count = $count + $row->count;
                   $month =$row->month;
               }else{
                   $count_month_temp[] =$row;
               }
           }*/
         //$counts_month = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_type('all', $rows_month, $product, 1);
         $count_month_sec = array();
         foreach ($counts_month as $row) {
             $count_month_sec[$row->month][$department[$row->department]] = $row->count;
         }
         array_shift($count_month_sec);
         foreach ($count_month_sec as $month => $ticketcnt) {
             $count = $ticketcnt['Mobile-broker'] + $ticketcnt['Mobile-jinpu'] + $ticketcnt['Mobile-xinfang'] + $ticketcnt['Mobile-haozu'] + $ticketcnt['Mobile-anjuke'];
             $count_month_sec[$month]['移动'] = $count;
             unset($count_month_sec[$month]['Mobile-broker']);
             unset($count_month_sec[$month]['Mobile-jinpu']);
             unset($count_month_sec[$month]['Mobile-xinfang']);
             unset($count_month_sec[$month]['Mobile-haozu']);
             unset($count_month_sec[$month]['Mobile-anjuke']);
         }
         //$count_month_sec[$month]['移动']=$count."";
         $count_month_all = array();
         foreach ($count_month_sec as $key => $row) {
             $count = $row['用户端'] + $row['开发商'] + $row['CRM'] + $row['客户端'] + $row['移动'] + $row['Inc.'];
             $count_month_all[] = array_merge(array('date' => $key, 'count' => $count), $row);
         }
         /*$depart_staff = array(
           '1' => 'Inc',
           '2' => 'Anjuke',
           '3' => 'Aifang',
           '4' => 'Haozu',
           '5' => 'Jinpu',
           '6' => 'Mobile'
           );*/
         $m_begin = date('Y-m', strtotime('-7 month'));
         $m_end = date('Y-m', strtotime('now'));
         $tech_persons = Bll_ReportPersonCountBiz::get_instance()->get_counts_by_month($m_begin, $m_end);
         $tech_count = array();
         foreach ($tech_persons as $row) {
             $tech_count[$row->month][$row->department] = $row->person_count;
         }
         $count_month_table = $count_month_all;
         rsort($count_month_table);
         array_pop($count_month_table);
         $req->set_attribute('product', $product);
         $req->set_attribute('month_query', $month_query);
         $req->set_attribute('count_day_all', $count_day_all);
         $req->set_attribute('count_month_all', $count_month_all);
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('detail_url', '');
         $req->set_attribute('tech_count', $tech_count);
         $req->set_attribute('count_month_table', $count_month_table);
         return 'Newreport_OnlineNew';
     }
     if ($product == 5) {
         $owner = Bll_ReportDayOnlineOwnerBiz::get_instance()->get_owner();
         $rows = 30 * count($owner);
         $allowner = array();
         foreach ($owner as $own) {
             $allowner[] = $own->owner;
         }
         $counts_all = Bll_ReportDayOnlineOwnerBiz::get_instance()->get_30day($rows);
         //$counts_all = array_reverse($data);
         $count_day_sec = array();
         foreach ($counts_all as $row) {
             $count_day_sec[$row->day][$row->owner] = $row->count;
         }
         $count_day_all = array();
         foreach ($count_day_sec as $key => $row) {
             $count_day_all[] = array_merge(array('date' => $key), $row);
         }
         $count_day_all = array_reverse($count_day_all);
         $req->set_attribute('product', $product);
         $req->set_attribute('month_query', $month_query);
         $req->set_attribute('count_day_all', $count_day_all);
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('allowner', $allowner);
         return 'Newreport_OnlineNew';
     }
     if ($product == 15) {
         $rows = 30 * 5;
         $counts_all = Bll_ReportDayOnlineBiz::get_instance()->get_counts_mobile_by_date($rows, array(14, 15, 16, 18, 19));
         $counts_all = array_reverse($counts_all);
         $count_day_sec = array();
         $count_day_all = array();
         $count_day_all_temp = array();
         foreach ($counts_all as $row) {
             $count_day_sec[$row->day][$department[$row->department]] = $row->count;
         }
         foreach ($count_day_sec as $day => $ticketcnt) {
             $count_day_all[] = array('date' => $day, 'count' => array_sum($ticketcnt));
             //$count_day_all_temp[$day] =  array_sum($ticketcnt);
         }
         /* foreach($count_day_all_temp as $row){
                $count_day_all[] = array('date' => $row->day,
                                         'count' => $row->count);
            }*/
         //month_all
         $rows_month = 12 * count($department);
         $last_twelve_month = array();
         for ($month = date('Y-m-d', strtotime('now')), $times = 12; $times > 0; $month = date('Y-m-d', strtotime('last month', strtotime($month))), --$times) {
             $last_twelve_month[] = date('Y-m', strtotime($month));
         }
         $last_twelve_month = array_reverse($last_twelve_month);
         foreach ($last_twelve_month as $month) {
             foreach ($department as $key => $value) {
                 $departc[] = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_month($month, 'all', $key);
             }
             $counts_month = $departc;
         }
         foreach ($counts_month as $value) {
             $temp[] = $value[0];
         }
         $counts_month = $temp;
         //$counts_month = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_type('all', $rows_month, $product, 1);
         $count_month_sec = array();
         foreach ($counts_month as $row) {
             $count_month_sec[$row->month][$department[$row->department]] = $row->count;
         }
         array_shift($count_month_sec);
         foreach ($count_month_sec as $month => $ticketcnt) {
             $count = $ticketcnt['Mobile-broker'] + $ticketcnt['Mobile-jinpu'] + $ticketcnt['Mobile-xinfang'] + $ticketcnt['Mobile-haozu'] + $ticketcnt['Mobile-anjuke'];
             $count_month_sec[$month]['移动'] = $count;
             unset($count_month_sec[$month]['Mobile-broker']);
             unset($count_month_sec[$month]['Mobile-jinpu']);
             unset($count_month_sec[$month]['Mobile-xinfang']);
             unset($count_month_sec[$month]['Mobile-haozu']);
             unset($count_month_sec[$month]['Mobile-anjuke']);
         }
         /*foreach($counts_month as $row){
                         if (  in_array( $row->department,array('14','15','16','18','19') ) ){
                             $count = $count + $row->count;
                             $month =$row->month;
                         }else{
                             $count_month_temp[] =$row;
                         }
                     }
                     foreach ($count_month_temp as $row) {
                         $count_month_sec[$row->month][$department[$row->department]] = $row->count;
                     }
         
                     $m_begin = date('Y-m', strtotime('-7 month'));
                     $m_end = date('Y-m', strtotime('now'));
         
                     /*$rows_month = 12;
                     $counts_month = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_type('all', $rows_month, array(14,15,16,18,19));
                     $count_month_all = array();
                     $counts_month_sec=array();
                     foreach($counts_month as $temp){
                         $counts_month_sec[$temp['month']][$temp['department']] =$temp;
                     }
         */
         $count_month_all = array();
         $count_month_all_temp = array();
         foreach ($count_month_sec as $key => $value) {
             $count_month_all_temp[$key] = array_slice($value, -1, 1);
         }
         foreach ($count_month_all_temp as $key => $value) {
             $count_month_all[] = array('date' => $key, 'count' => $value['移动']);
         }
         //$count_month_all = array_reverse($count_month_all);
         $count_month_table = $count_month_all;
         rsort($count_month_table);
         //array_pop($count_month_table);
         //group by resolution
         $counts_resos = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_month_mobile($month_query, 'resolution', array(14, 15, 16, 18, 19));
         $counts_reso = array();
         foreach ($counts_resos as $row) {
             $counts_reso[$row->type_value] = $row->count;
         }
         $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions();
         $resolution = array();
         foreach ($resolutions as $resolu) {
             $resolution[$resolu->value] = $resolu->name;
         }
         $count_month_reso = array();
         foreach ($resolution as $r_value => $r_name) {
             $count_reso = isset($counts_reso[$r_value]) ? $counts_reso[$r_value] : 0;
             $count_month_reso[] = array('date' => $r_name, 'count' => $count_reso);
         }
         $req->set_attribute('product', $product);
         $req->set_attribute('month_query', $month_query);
         $req->set_attribute('count_day_all', $count_day_all);
         $req->set_attribute('count_month_all', $count_month_all);
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('detail_url', '');
         $req->set_attribute('tech_count', $tech_count);
         $req->set_attribute('count_month_table', $count_month_table);
         $req->set_attribute('count_month_reso', $count_month_reso);
         return 'Newreport_OnlineNew';
     }
     if ($page_bind_groups != "") {
         //day_all
         $department_id = intval(Bll_DdCommonBiz::get_instance()->get_department_id_by_value($product));
         $count_day_all = array();
         $days = $this->get_30Days();
         $interval = $this->get_the_day();
         $begin = $interval[0];
         $end = $interval[1];
         $tickets_all = Bll_TicketBiz::get_instance()->get_count_online_by_month($begin, $end, 'all', $department_id);
         for ($i = 29; $i >= 0; $i--) {
             $c = 0;
             foreach ($page_bind_groups as $group_id) {
                 $group_user_names = $this->get_group_member_name($group_id);
                 if (!empty($group_user_names)) {
                     foreach ($tickets_all as $value) {
                         if (in_array($value->owner, $group_user_names) && substr($value->created_at, 0, 10) == $days[$i]) {
                             $c++;
                         }
                     }
                 }
             }
             $count_day_all[] = array('date' => $days[$i], 'count' => $c);
         }
         //month_all
         $count_month_all = array();
         $count_month_comp = array();
         $count_month_reso = array();
         $counts_comp = array();
         $counts_reso = array();
         $flag = 0;
         $months = $this->get_12Months();
         for ($i = 11; $i >= 0; $i--) {
             $total = 0;
             $month_interval = $this->get_the_month($months[$i]);
             $begin = $month_interval[0];
             $end = $month_interval[1];
             $tickets_all = Bll_TicketBiz::get_instance()->get_count_online_by_month($begin, $end, 'all', $department_id);
             if ($month_query == $months[$i]) {
                 $flag = 1;
                 foreach ($page_bind_groups as $group_id) {
                     $group_user_names = $this->get_group_member_name($group_id);
                     if (!empty($group_user_names)) {
                         foreach ($tickets_all as $value) {
                             if (in_array($value->owner, $group_user_names)) {
                                 $total++;
                                 $counts_comp[$value->component] = isset($counts_comp[$value->component]) ? ++$counts_comp[$value->component] : 1;
                                 $counts_reso[$value->resolution] = isset($counts_reso[$value->resolution]) ? ++$counts_reso[$value->resolution] : 1;
                             }
                         }
                     }
                 }
             } else {
                 foreach ($page_bind_groups as $group_id) {
                     $group_user_names = $this->get_group_member_name($group_id);
                     if (!empty($group_user_names)) {
                         foreach ($tickets_all as $value) {
                             if (in_array($value->owner, $group_user_names)) {
                                 $total++;
                             }
                         }
                     }
                 }
             }
             $count_month_all[] = array('date' => $months[$i], 'count' => $total);
         }
         if ($flag == 0) {
             $month_interval = $this->get_the_month($months[$i]);
             $begin = $month_interval[0];
             $end = $month_interval[1];
             $tickets_all = Bll_TicketBiz::get_instance()->get_count_online_by_month($begin, $end, 'all', $department_id);
             foreach ($page_bind_groups as $group_id) {
                 $group_user_names = $this->get_group_member_name($group_id);
                 if (!empty($group_user_names)) {
                     foreach ($tickets_all as $value) {
                         if (in_array($value->owner, $group_user_names)) {
                             $counts_comp[$value->component] = isset($counts_comp[$value->component]) ? ++$counts_comp[$value->component] : 1;
                             $counts_reso[$value->resolution] = isset($counts_reso[$value->resolution]) ? ++$counts_reso[$value->resolution] : 1;
                         }
                     }
                 }
             }
         }
         $components = Bll_DdComponentBiz::get_instance()->get_components($pro_id);
         foreach ($components as $component) {
             $count_row = isset($counts_comp[$component->int]) ? $counts_comp[$component->int] : 0;
             $count_month_comp[] = array('date' => $component->name, 'count' => $count_row);
         }
         $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions();
         $resolution = array();
         foreach ($resolutions as $resolu) {
             $resolution[$resolu->id] = $resolu->name;
         }
         foreach ($resolution as $r_value => $r_name) {
             $count_reso = isset($counts_reso[$r_value]) ? $counts_reso[$r_value] : 0;
             $count_month_reso[] = array('date' => $r_name, 'count' => $count_reso);
         }
     } else {
         $rows = 30;
         $counts_all = Bll_ReportDayOnlineBiz::get_instance()->get_counts_by_date_all($rows, $product);
         $counts_all = array_reverse($counts_all);
         $count_day_all = array();
         foreach ($counts_all as $row) {
             $count_day_all[] = array('date' => $row->day, 'count' => $row->count);
         }
         //month_all
         $rows_month = 12;
         $counts_month = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_type('all', $rows_month, $product);
         $count_month_all = array();
         foreach ($counts_month as $row) {
             $count_month_all[] = array('date' => $row->month, 'count' => $row->count);
         }
         $count_month_all = array_reverse($count_month_all);
         //group by component
         $counts_comps = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_month($month_query, 'component', $product);
         $counts_comp = array();
         foreach ($counts_comps as $row) {
             $counts_comp[$row->type_value] = $row->count;
         }
         $components = Bll_DdComponentBiz::get_instance()->get_components($pro_id);
         $count_month_comp = array();
         foreach ($components as $component) {
             $count_row = isset($counts_comp[$component->value]) ? $counts_comp[$component->value] : 0;
             $count_month_comp[] = array('date' => $component->name, 'count' => $count_row);
         }
         //group by resolution
         $counts_resos = Bll_ReportMonthOnlineBiz::get_instance()->get_counts_by_month($month_query, 'resolution', $product);
         $counts_reso = array();
         foreach ($counts_resos as $row) {
             $counts_reso[$row->type_value] = $row->count;
         }
         $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions();
         $resolution = array();
         foreach ($resolutions as $resolu) {
             $resolution[$resolu->value] = $resolu->name;
         }
         $count_month_reso = array();
         foreach ($resolution as $r_value => $r_name) {
             $count_reso = isset($counts_reso[$r_value]) ? $counts_reso[$r_value] : 0;
             $count_month_reso[] = array('date' => $r_name, 'count' => $count_reso);
         }
     }
     $req->set_attribute('product', $product);
     $req->set_attribute('month_query', $month_query);
     $req->set_attribute('count_day_all', $count_day_all);
     $req->set_attribute('count_month_all', $count_month_all);
     $req->set_attribute('count_month_comp', $count_month_comp);
     $req->set_attribute('count_month_reso', $count_month_reso);
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('detail_url', $detail_url);
     return 'Newreport_OnlineNew';
 }
Beispiel #20
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $product = $params['pro'] ? $params['pro'] : 0;
     /*$tab_info = array(
               0 => array('name' => 'All', 'click' => false),
               1 => array('name' => 'Anjuke', 'click' => false),
               2 => array('name' => 'Aifang', 'click' => false),
               3 => array('name' => 'Haozu', 'click' => false),
               4 => array('name' => 'Jinpu', 'click' => false),
               5 => array('name' => 'Mobile', 'click' => false),
               6 => array('name' => 'Inc', 'click' => false)
       );*/
     $tab_info = array(0 => array('name' => 'All', 'click' => false), 1 => array('name' => '用户端', 'click' => false), 2 => array('name' => '客户端', 'click' => false), 3 => array('name' => '开发商', 'click' => false), 4 => array('name' => 'CRM', 'click' => false), 5 => array('name' => '移动', 'click' => false), 6 => array('name' => 'Inc.', 'click' => false));
     $tab_info[$product]['click'] = true;
     $from = $params['from'] ? date("Y-m-d 00:00:00", strtotime($params['from'])) : date("Y-m-01 00:00:00");
     $to = $params['to'] ? date("Y-m-d 23:59:59", strtotime($params['to'])) : date("Y-m-t 23:59:59");
     $input_from = date("Y-m-d", strtotime($from));
     $input_to = date("Y-m-d", strtotime($to));
     /*$depart_value_id = array(
       '0' => '0',
       '1' => '2',
       '2' => '4',
       '3' => '3',
       '4' => '5',
       '5' => '45',
       '6' => '46');*/
     $depart_value_id = array('0' => '0', '1' => '51', '2' => '52', '3' => '53', '4' => '54', '5' => '56', '6' => '75');
     $pro_id = $depart_value_id[$product];
     $bugs = Bll_TicketBiz::get_instance()->get_count_online_by_month_process($from, $to, 'all', $pro_id);
     $bug_ids = array();
     $bug_pro = array();
     foreach ($bugs as $row) {
         $bug_ids[] = $row->id;
         $bug_pro[$row->id] = $row;
     }
     if (!empty($bug_ids)) {
         $historys = Bll_TicketStatusHistoryBiz::get_instance()->get_history_by_ids($bug_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;
                 }
             }
         }
     }
     $table = array();
     foreach ($bug_ids as $id) {
         $table[$id]['id'] = $bug_pro[$id]->id;
         $table[$id]['summary'] = $bug_pro[$id]->summary;
         $table[$id]['owner'] = $bug_pro[$id]->owner;
         $table[$id]['priority'] = $bug_pro[$id]->priority;
         $table[$id]['component'] = $bug_pro[$id]->department . '-' . $bug_pro[$id]->component;
         $table[$id]['reporter'] = $bug_pro[$id]->reporter;
         $table[$id]['created_at'] = $bug_pro[$id]->created_at;
         $table[$id]['status'] = $bug_pro[$id]->status;
         if (isset($his_pro[$id]['accepted'])) {
             $table[$id]['qa_time'] = $this->convert_time($bug_pro[$id]->created_at, $his_pro[$id]['accepted']);
             $table[$id]['qa_time_format'] = $this->format_time($table[$id]['qa_time']);
         } else {
             $table[$id]['qa_time'] = '0';
             $table[$id]['qa_time_format'] = '-';
         }
         if (isset($his_pro[$id]['verified']) && !in_array($bug_pro[$id]->status, array('opened', 'accepted'))) {
             $table[$id]['dev_time'] = $this->convert_time($bug_pro[$id]->created_at, $his_pro[$id]['verified']);
             $table[$id]['dev_time_format'] = $this->format_time($table[$id]['dev_time']);
         } else {
             $table[$id]['dev_time'] = '0';
             $table[$id]['dev_time_format'] = '-';
         }
         if (isset($his_pro[$id]['closed'])) {
             $table[$id]['all_time'] = $this->convert_time($bug_pro[$id]->created_at, $his_pro[$id]['closed']);
             $table[$id]['all_time_format'] = $this->format_time($table[$id]['all_time']);
         } else {
             $table[$id]['all_time'] = '0';
             $table[$id]['all_time_format'] = '-';
         }
     }
     $req->set_attribute('product', $product);
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('input_from', $input_from);
     $req->set_attribute('input_to', $input_to);
     $req->set_attribute('table', $table);
     return 'Newreport_ProcessTime';
 }
Beispiel #21
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $from = $params['from'];
     $to = $params['to'];
     $person = $params['p'];
     $product = $params['pro'];
     $mode = $params['m'];
     $pmt_id_q = $params['pmt'] ? $params['pmt'] : 0;
     if ($pmt_id_q != 0) {
         $projects = Bll_PMTProjectBiz::get_instance()->get_project_detail_by_ids(array($pmt_id_q));
     } else {
         $projects = Bll_PMTProjectBiz::get_instance()->get_projects_by_release_date_new($product, $from, $to);
     }
     $pmt_ids_init = array();
     $projects_pmtid = array();
     foreach ($projects as $project) {
         $projects_pmtid[$project['id']] = $project;
         $pmt_ids_init[] = $project['id'];
     }
     $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids($pmt_ids_init);
     $tasks_pmtid = array();
     foreach ($tasks as $task) {
         if (in_array($task['task_type_id'], array(2, 3, 33))) {
             $tasks_pmtid[$task['project_id']]['dev'][$task['chinese_name']][] = $task['workload'];
         } elseif (in_array($task['task_type_id'], array(4))) {
             $tasks_pmtid[$task['project_id']]['test'][$task['chinese_name']][] = $task['workload'];
         }
     }
     $pmt_ids = array();
     foreach ($pmt_ids_init as $pmt_id) {
         if (!empty($tasks_pmtid[$pmt_id]['dev']) && !empty($tasks_pmtid[$pmt_id]['test'])) {
             $pmt_ids[] = $pmt_id;
         }
     }
     $rates = Bll_ReportPmtInfoBiz::get_instance()->get_through_rate_by_pmtids($pmt_ids);
     $rates_pmtid = array();
     foreach ($rates as $rate) {
         $rates_pmtid[$rate->project_id][$rate->chinese_name] = $rate->rate;
     }
     if ($mode == '1') {
         $bugs = Bll_TicketBiz::get_instance()->get_bugs_by_persons_sort_pmt($person, $pmt_ids);
     } elseif ($mode == '2') {
         $bugs = Bll_TicketBiz::get_instance()->get_bugs_by_qa_sort_pmt($person, $pmt_ids);
     }
     $bugs_pmtid = array();
     foreach ($bugs as $bug) {
         $bugs_pmtid[$bug['pmt_id']] = $bug['BugCount'];
     }
     $table = array();
     $m = $mode == '1' ? 'dev' : 'test';
     foreach ($pmt_ids as $pmt_id) {
         if (isset($bugs_pmtid[$pmt_id]) || !empty($tasks_pmtid[$pmt_id][$m][$person])) {
             $table[$pmt_id]['pmt_id'] = $pmt_id;
             $table[$pmt_id]['summary'] = $projects_pmtid[$pmt_id]['summary'];
             $table[$pmt_id]['person'] = $person;
             $table[$pmt_id]['test_through'] = isset($rates_pmtid[$pmt_id][$person]) ? $rates_pmtid[$pmt_id][$person] . "%" : "-";
             $time = 0;
             if (isset($tasks_pmtid[$pmt_id][$m][$person])) {
                 foreach ($tasks_pmtid[$pmt_id][$m][$person] as $time_row) {
                     $time += intval($time_row);
                 }
             }
             $table[$pmt_id]['workload'] = $time;
             $table[$pmt_id]['bugs_count'] = isset($bugs_pmtid[$pmt_id]) ? $bugs_pmtid[$pmt_id] : 0;
         }
     }
     $req->set_attribute('table', $table);
     $req->set_attribute('from', $from);
     $req->set_attribute('to', $to);
     $req->set_attribute('person', $person);
     $req->set_attribute('mode', $mode);
     return 'NewReport_PersonDetail';
 }
Beispiel #22
0
 public function handle_request_internal()
 {
     /*
      * owner is me
      * assign_qa is me
      * tickets which I create
      * tickets which are cc to me
      */
     $req = APF::get_instance()->get_request();
     $username = $req->get_username();
     $userid = $req->get_user_id();
     $params = $req->get_parameters();
     $wholename = Bll_UserBiz::get_instance()->get_wholename_by_username($username);
     if ($params['view'] == 'all') {
         $tickets_opened = array();
         $i = 0;
         $tickets_accepted = array();
         $j = 0;
         $tickets_verified = array();
         $k = 0;
         $tickets_released = array();
         $m = 0;
         $tickets_closed = array();
         $n = 0;
         $type = $params['type'];
         if ($type == 'ownerd') {
             $owner_tickets = Bll_TicketBiz::get_instance()->get_owner_tickets($username);
             foreach ($owner_tickets as $ticket) {
                 if ($ticket->status == 'opened') {
                     $tickets_opened[$i] = $ticket;
                     $i = $i + 1;
                 } else {
                     if ($ticket->status == 'accepted') {
                         $tickets_accepted[$j] = $ticket;
                         $j = $j + 1;
                     } else {
                         if ($ticket->status == 'verified') {
                             $tickets_verified[$k] = $ticket;
                             $k = $k + 1;
                         } else {
                             if ($ticket->status == 'released') {
                                 $tickets_released[$m] = $ticket;
                                 $m = $m + 1;
                             } else {
                                 if ($ticket->status == 'closed') {
                                     $tickets_closed[$n] = $ticket;
                                     $n = $n + 1;
                                 }
                             }
                         }
                     }
                 }
             }
             $name = "My tickets(ownerd)";
         } else {
             if ($type == 'assign') {
                 $assign_qa_tickets = Bll_TicketBiz::get_instance()->get_assign_qa_tickets($username);
                 foreach ($assign_qa_tickets as $ticket) {
                     if ($ticket->status == 'opened') {
                         $tickets_opened[$i] = $ticket;
                         $i = $i + 1;
                     } else {
                         if ($ticket->status == 'accepted') {
                             $tickets_accepted[$j] = $ticket;
                             $j = $j + 1;
                         } else {
                             if ($ticket->status == 'verified') {
                                 $tickets_verified[$k] = $ticket;
                                 $k = $k + 1;
                             } else {
                                 if ($ticket->status == 'released') {
                                     $tickets_released[$m] = $ticket;
                                     $m = $m + 1;
                                 } else {
                                     if ($ticket->status == 'closed') {
                                         $tickets_closed[$n] = $ticket;
                                         $n = $n + 1;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $name = "Assigned QA tickets";
             } else {
                 if ($type == 'create') {
                     $create_tickets = Bll_TicketBiz::get_instance()->get_create_tickets($username);
                     foreach ($create_tickets as $ticket) {
                         if ($ticket->status == 'opened') {
                             $tickets_opened[$i] = $ticket;
                             $i = $i + 1;
                         } else {
                             if ($ticket->status == 'accepted') {
                                 $tickets_accepted[$j] = $ticket;
                                 $j = $j + 1;
                             } else {
                                 if ($ticket->status == 'verified') {
                                     $tickets_verified[$k] = $ticket;
                                     $k = $k + 1;
                                 } else {
                                     if ($ticket->status == 'released') {
                                         $tickets_released[$m] = $ticket;
                                         $m = $m + 1;
                                     } else {
                                         if ($ticket->status == 'closed') {
                                             $tickets_closed[$n] = $ticket;
                                             $n = $n + 1;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $name = "My tickets(create by me)";
                 } else {
                     if ($type == 'cc') {
                         $cc_tickets = Bll_TicketBiz::get_instance()->get_cc_tickets($username);
                         foreach ($cc_tickets as $ticket) {
                             if ($ticket->status == 'opened') {
                                 $tickets_opened[$i] = $ticket;
                                 $i = $i + 1;
                             } else {
                                 if ($ticket->status == 'accepted') {
                                     $tickets_accepted[$j] = $ticket;
                                     $j = $j + 1;
                                 } else {
                                     if ($ticket->status == 'verified') {
                                         $tickets_verified[$k] = $ticket;
                                         $k = $k + 1;
                                     } else {
                                         if ($ticket->status == 'released') {
                                             $tickets_released[$m] = $ticket;
                                             $m = $m + 1;
                                         } else {
                                             if ($ticket->status == 'closed') {
                                                 $tickets_closed[$n] = $ticket;
                                                 $n = $n + 1;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         $name = "My tickets(cc to me)";
                     }
                 }
             }
         }
         $tickets = array();
         $tickets['opened'] = $tickets_opened;
         $tickets['accepted'] = $tickets_accepted;
         $tickets['verified'] = $tickets_verified;
         $tickets['released'] = $tickets_released;
         $tickets['closed'] = $tickets_closed;
         $req->set_attribute('tickets', $tickets);
         $req->set_attribute('name', $name);
         return 'Home_IndexAll';
     }
     $owner_tickets = Bll_TicketBiz::get_instance()->get_owner_tickets($username);
     $owner_tickets_opened = array();
     $i = 0;
     $owner_tickets_accepted = array();
     $j = 0;
     $owner_tickets_verified = array();
     $k = 0;
     $owner_tickets_released = array();
     $m = 0;
     $owner_tickets_closed = array();
     if ($owner_tickets) {
         foreach ($owner_tickets as $ticket) {
             if ($ticket->status == 'opened') {
                 $owner_tickets_opened[$i] = $ticket;
                 $i = $i + 1;
             } elseif ($ticket->status == 'accepted') {
                 $owner_tickets_accepted[$j] = $ticket;
                 $j = $j + 1;
             } elseif ($ticket->status == 'verified') {
                 $owner_tickets_verified[$k] = $ticket;
                 $k = $k + 1;
             } elseif ($ticket->status == 'released') {
                 $owner_tickets_released[$m] = $ticket;
                 $m = $m + 1;
             }
         }
     }
     $assign_qa_tickets = Bll_TicketBiz::get_instance()->get_assign_qa_tickets($username);
     $assign_qa_tickets_opened = array();
     $i = 0;
     $assign_qa_tickets_accepted = array();
     $j = 0;
     $assign_qa_tickets_verified = array();
     $k = 0;
     $assign_qa_tickets_released = array();
     $m = 0;
     $assign_qa_tickets_closed = array();
     if ($assign_qa_tickets) {
         foreach ($assign_qa_tickets as $ticket) {
             if ($ticket->status == 'opened') {
                 $assign_qa_tickets_opened[$i] = $ticket;
                 $i = $i + 1;
             } elseif ($ticket->status == 'accepted') {
                 $assign_qa_tickets_accepted[$j] = $ticket;
                 $j = $j + 1;
             } elseif ($ticket->status == 'verified') {
                 $assign_qa_tickets_verified[$k] = $ticket;
                 $k = $k + 1;
             } elseif ($ticket->status == 'released') {
                 $assign_qa_tickets_released[$m] = $ticket;
                 $m = $m + 1;
             }
         }
     }
     $create_tickets = Bll_TicketBiz::get_instance()->get_create_tickets($username);
     $create_tickets_opened = array();
     $i = 0;
     $create_tickets_accepted = array();
     $j = 0;
     $create_tickets_verified = array();
     $k = 0;
     $create_tickets_released = array();
     $m = 0;
     $create_tickets_closed = array();
     if ($create_tickets) {
         foreach ($create_tickets as $ticket) {
             if ($ticket->status == 'opened') {
                 $create_tickets_opened[$i] = $ticket;
                 $i = $i + 1;
             } elseif ($ticket->status == 'accepted') {
                 $create_tickets_accepted[$j] = $ticket;
                 $j = $j + 1;
             } elseif ($ticket->status == 'verified') {
                 $create_tickets_verified[$k] = $ticket;
                 $k = $k + 1;
             } elseif ($ticket->status == 'released') {
                 $create_tickets_released[$m] = $ticket;
                 $m = $m + 1;
             }
         }
     }
     $cc_tickets = Bll_TicketBiz::get_instance()->get_cc_tickets($username);
     $cc_tickets_opened = array();
     $i = 0;
     $cc_tickets_accepted = array();
     $j = 0;
     $cc_tickets_verified = array();
     $k = 0;
     $cc_tickets_released = array();
     $m = 0;
     $cc_tickets_closed = array();
     if ($cc_tickets) {
         foreach ($cc_tickets as $ticket) {
             if ($ticket->status == 'opened') {
                 $cc_tickets_opened[$i] = $ticket;
                 $i = $i + 1;
             } elseif ($ticket->status == 'accepted') {
                 $cc_tickets_accepted[$j] = $ticket;
                 $j = $j + 1;
             } elseif ($ticket->status == 'verified') {
                 $cc_tickets_verified[$m] = $ticket;
                 $m = $m + 1;
             } elseif ($ticket->status == 'released') {
                 $cc_tickets_released[$n] = $ticket;
                 $n = $n + 1;
             }
         }
     }
     $tickets = array();
     $tickets['ownerd']['opened'] = $owner_tickets_opened;
     $tickets['ownerd']['accepted'] = $owner_tickets_accepted;
     $tickets['ownerd']['verified'] = $owner_tickets_verified;
     $tickets['ownerd']['released'] = $owner_tickets_released;
     $tickets['ownerd']['closed'] = $owner_tickets_closed;
     $tickets['assign']['opened'] = $assign_qa_tickets_opened;
     $tickets['assign']['accepted'] = $assign_qa_tickets_accepted;
     $tickets['assign']['verified'] = $assign_qa_tickets_verified;
     $tickets['assign']['released'] = $assign_qa_tickets_released;
     $tickets['assign']['closed'] = $assign_qa_tickets_closed;
     $tickets['create']['opened'] = $create_tickets_opened;
     $tickets['create']['accepted'] = $create_tickets_accepted;
     $tickets['create']['verified'] = $create_tickets_verified;
     $tickets['create']['released'] = $create_tickets_released;
     $tickets['create']['closed'] = $create_tickets_closed;
     $tickets['cc']['opened'] = $cc_tickets_opened;
     $tickets['cc']['accepted'] = $cc_tickets_accepted;
     $tickets['cc']['verified'] = $cc_tickets_verified;
     $tickets['cc']['released'] = $cc_tickets_released;
     $tickets['cc']['closed'] = $cc_tickets_closed;
     $role = Bll_RoleBiz::get_instance()->get_user_role($userid);
     $counts = array();
     $counts['ownerd'] = count($tickets['ownerd']['opened']) + count($tickets['ownerd']['accepted']) + count($tickets['ownerd']['verified']) + count($tickets['ownerd']['released']);
     $counts['assign'] = count($tickets['assign']['opened']) + count($tickets['assign']['accepted']) + count($tickets['assign']['verified']) + count($tickets['assign']['released']);
     $counts['create'] = count($tickets['create']['opened']) + count($tickets['create']['accepted']) + count($tickets['create']['verified']) + count($tickets['create']['released']);
     $counts['cc'] = count($tickets['cc']['opened']) + count($tickets['cc']['accepted']) + count($tickets['cc']['verified']) + count($tickets['cc']['released']);
     foreach ($counts as $key => $count) {
         if ($count == 0) {
             $counts[$key] = '';
         }
     }
     foreach ($tickets as $key => $ticket) {
         foreach ($ticket as $key_row => $ticket_row) {
             if (empty($ticket_row)) {
                 unset($tickets[$key][$key_row]);
             }
         }
     }
     $tickets = array_filter($tickets);
     $time = array();
     foreach ($tickets as $key => $ticket) {
         foreach ($ticket as $key_row => $ticket_row) {
             foreach ($ticket_row as $k => $r) {
                 $time[$key][$key_row][$k]['create'] = Bll_TicketBiz::get_instance()->process_time_field($r->created_at);
                 $time[$key][$key_row][$k]['update'] = Bll_TicketBiz::get_instance()->process_time_field($r->updated_at);
             }
         }
     }
     $req->set_attribute('tickets', $tickets);
     $req->set_attribute('role', $role);
     $req->set_attribute('counts', $counts);
     $req->set_attribute('time', $time);
     $req->set_attribute('wholename', $wholename);
     return 'Home_Index';
 }
Beispiel #23
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';
 }
<?php

apf_require_class('Bll_TicketBiz');
apf_require_class('Bll_ReportDayOnlineOwnerBiz');
apf_require_class('Bll_DdCommonBiz');
apf_require_class('Bll_UserBiz');
$owner = Bll_DdComponentBiz::get_instance()->get_all_blong('blongto');
$oneday = 86400 * 0;
$whichday = strtotime('now') - $oneday;
$begin = date('Y-m-d 00:00:00', $whichday);
$end = date('Y-m-d 23:59:59', $whichday);
$day = date('Y-m-d', $whichday);
foreach ($owner as $key => $value) {
    $count = Bll_TicketBiz::get_instance()->get_count_by_function($begin, $end, $value);
    $owner[$key] = $count;
}
$user = array_keys($owner);
$userName = Bll_UserBiz::get_instance()->get_chinesenames_by_ids($user);
$input_arr = array();
foreach ($userName as $userid => $username) {
    $input_arr['day'] = $day;
    $input_arr['owner'] = $username;
    $input_arr['count'] = $owner[$userid] ? $owner[$userid] : 0;
    Bll_ReportDayOnlineOwnerBiz::get_instance()->insert_count_data($input_arr);
}
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $product = isset($params['pro']) ? $params['pro'] : '1';
     $from = $params['from'] ? date("Y-m-d 00:00:00", strtotime($params['from'])) : date("Y-m-01 00:00:00");
     $to = $params['to'] ? date("Y-m-d 23:59:59", strtotime($params['to'])) : date("Y-m-t 23:59:59");
     if ($product != '' || $from != '' || $to != '') {
         $projects = Bll_PMTProjectBiz::get_instance()->get_projects_by_release_date($product, $from, $to);
         if (empty($projects)) {
             $datas = array();
         } else {
             $datas = array();
             $pmt_ids = array();
             $projectsx = array();
             foreach ($projects as $project) {
                 $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids(array($project['id']));
                 $count_dev_task = 0;
                 $count_test_task = 0;
                 if ($tasks) {
                     foreach ($tasks as $task) {
                         if (in_array($task['task_type_id'], array(2, 3, 33))) {
                             $count_dev_task += 1;
                         } elseif (in_array($task['task_type_id'], array(4))) {
                             $count_test_task += 1;
                         }
                     }
                 }
                 if ($count_dev_task == 0 || $count_test_task == 0) {
                     continue;
                 }
                 $pmt_ids['id'][] = $project['id'];
                 $pmt_ids['summary'][$project['id']]['id'] = $project['id'];
                 $pmt_ids['summary'][$project['id']]['sum'] = $project['summary'];
             }
             $tasks = Bll_PMTProjectBiz::get_instance()->get_tasks_by_pmt_ids($pmt_ids['id']);
             $tasksx = array();
             foreach ($tasks as $task) {
                 if (in_array($task['task_type_id'], array(4))) {
                     $tasksx[] = $task;
                 }
             }
             foreach ($tasksx as $task) {
                 $datas[$task['chinese_name']]['test_person'] = $task['chinese_name'];
                 $bugs = Bll_TicketBiz::get_instance()->get_bugs_by_qas(array($task['chinese_name']), array($task['project_id']));
                 $projectsx[$task['chinese_name']][$task['project_id']]['bug_count'] = $bugs[0]['BugCount'] ? $bugs[0]['BugCount'] : '0';
                 $projectsx[$task['chinese_name']][$task['project_id']]['workload'] += $task['workload'];
             }
             foreach ($tasksx as $task) {
                 $bug_count = 0;
                 $workload = 0;
                 $datas[$task['chinese_name']]['projects'] = count($projectsx[$task['chinese_name']]);
                 foreach ($projectsx[$task['chinese_name']] as $project) {
                     $bug_count += $project['bug_count'];
                     $workload += $project['workload'];
                 }
                 $datas[$task['chinese_name']]['bugs_count'] = $bug_count;
                 $datas[$task['chinese_name']]['workload_all'] = $workload;
             }
             foreach ($tasksx as $task) {
                 $datas[$task['chinese_name']]['bug_workload_all'] = $datas[$task['chinese_name']]['workload_all'] == 0 ? 0 : round($datas[$task['chinese_name']]['bugs_count'] / $datas[$task['chinese_name']]['workload_all'], 2);
             }
             if (!empty($datas)) {
                 $return = array('status' => 'ok', 'result' => array('count' => count($datas), 'data' => $datas));
             } else {
                 $return = array('status' => 'ok', 'result' => array('count' => 0, 'data' => array()));
             }
         }
     } else {
         $return = array('status' => 'error', 'result' => array('code' => 101, 'message' => 'empty parameter'));
     }
     $return = json_encode($return);
     echo $return;
 }
Beispiel #26
0
 public function handle_request_internal()
 {
     //      var_dump(Bll_PMTProjectBiz::get_instance()->get_days(strtotime('2014-09-05'),strtotime('2014-09-09'),1));
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     $pmt_id = isset($params['pmt_id']) ? $params['pmt_id'] : '';
     $res = array();
     if ($pmt_id) {
         $max = 0;
         $current_time = date('Y-m-d H:i:s', time());
         $tickets = Bll_TicketBiz::get_instance()->get_bug_count_for_pmt_by_api($pmt_id);
         $c = count($tickets);
         $d = array();
         for ($j = 0; $j < $c; $j++) {
             if (intval(strtotime($tickets[$j]->closed_at)) > $max) {
                 $max = intval(strtotime($tickets[$j]->closed_at));
             }
         }
         $end = $max;
         $end_temp = intval(strtotime($tickets[$c - 1]->created_at));
         if ($end < $end_temp) {
             $end = intval(strtotime($current_time));
         }
         $start = intval(strtotime(substr($tickets[0]->created_at, 0, 10)));
         for ($i = $start; $i <= $end; $i += 86400) {
             array_push($d, date("Y-m-d", $i));
         }
         foreach ($tickets as $ticket) {
             $created_at = $ticket->created_at;
             $status = $ticket->status;
             $created_date = substr($created_at, 0, 10);
             if ($status == 'closed') {
                 $closed_at = $ticket->closed_at;
                 $closed_date = substr($closed_at, 0, 10);
                 foreach ($d as $value) {
                     if (strtotime($value) < strtotime($closed_date) && strtotime($value) >= strtotime($created_date)) {
                         $res[$value]['opened'] = empty($res[$value]['opened']) ? 1 : ++$res[$value]['opened'];
                     }
                     if (strtotime($value) >= strtotime($closed_date)) {
                         $res[$value]['closed'] = empty($res[$value]['closed']) ? 1 : ++$res[$value]['closed'];
                     }
                     if (strtotime($value) >= strtotime($created_date)) {
                         $res[$value]['total'] = empty($res[$value]['total']) ? 1 : ++$res[$value]['total'];
                     }
                     if (strtotime($value) < strtotime($closed_date) && strtotime($value) > strtotime($created_date)) {
                         $res[$value]['excess'] = empty($res[$value]['excess']) ? 1 : ++$res[$value]['excess'];
                     }
                 }
             } else {
                 $gap = $this->get_work_days(strtotime($created_date), strtotime(substr($current_time, 0, 10)), strtotime($created_at), strtotime($current_time));
                 foreach ($d as $value) {
                     if (strtotime($value) >= strtotime($created_date)) {
                         $res[$value]['opened'] = empty($res[$value]['opened']) ? 1 : ++$res[$value]['opened'];
                         $res[$value]['total'] = empty($res[$value]['total']) ? 1 : ++$res[$value]['total'];
                     }
                 }
                 if ($gap >= 86400) {
                     foreach ($d as $value) {
                         if (strtotime($value) <= strtotime($current_time) && strtotime($value) > strtotime($created_date)) {
                             $res[$value]['excess'] = empty($res[$value]['excess']) ? 1 : ++$res[$value]['excess'];
                         }
                     }
                 }
             }
         }
         foreach ($res as $date => $value) {
             if (!isset($value['opened'])) {
                 $res[$date]['opened'] = 0;
             }
             if (!isset($value['closed'])) {
                 $res[$date]['closed'] = 0;
             }
             if (!isset($value['total'])) {
                 $res[$date]['total'] = 0;
             }
             if (!isset($value['excess'])) {
                 $res[$date]['excess'] = 0;
             }
         }
         echo json_encode($res);
     } else {
         echo "参数错误,请传入pmt_id,eg. pmt_id=123!";
     }
 }
Beispiel #27
0
    $id = @intval(file_get_contents('/tmp/ibug_ticket_log_id'));
}
$logs = Bll_TicketLogBiz::get_instance()->get_ticket_ids_great_than_id($id, 500);
if (empty($logs)) {
    echo date('c ') . "No tickets to update\n";
    exit(0);
}
$ticket_ids = array();
foreach ($logs as $ticket_log) {
    $ticket_ids[] = $ticket_log->ticket_id;
}
$id = $ticket_log->id;
$dao = Model_Ticket::data_access();
$ticket_ids = array_unique($ticket_ids);
$tickets = $dao->find_by_pks($ticket_ids);
$tickets = Bll_TicketBiz::get_instance()->process_solr_field($tickets);
$_ticket_ccs = Bll_TicketCcBiz::get_instance()->get_ticket_cc_by_ticket_ids($ticket_ids);
$ticket_ccs = array();
if (!empty($_ticket_ccs)) {
    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";
        }
 public function insert_online_all_for_product_line($time_arr, $product_line, $type, $createdORclosed)
 {
     $tickets_line_arr = Bll_TicketBiz::get_instance()->get_count_online_by_product_line($time_arr['begin'], $time_arr['end'], $createdORclosed);
     if ($tickets_line_arr[$product_line]) {
         $count = count($tickets_line_arr[$product_line]);
     } else {
         $count = 0;
     }
     $input_arr = array('week' => $time_arr['week'], 'department' => 10, 'type_key' => $product_line . '_' . $type, 'type_value' => '0', 'count' => $count, 'updated_time' => $time_arr['current_time']);
     $insert_id = Bll_ReportWeekOnlineNewBiz::get_instance()->insert_count_data($input_arr);
     if (!$insert_id) {
         echo " insert_online_all_for_product_line data error ";
     }
     return $insert_id;
 }
Beispiel #29
0
<?php

apf_require_class('Bll_TicketBiz');
apf_require_class('Bll_ReportDayOnlineBiz');
apf_require_class('Bll_DdCommonBiz');
$departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
foreach ($departments as $depart) {
    $tickets = Bll_TicketBiz::get_instance()->get_count_online_bugs($depart->id);
    if ($tickets) {
        $count = count($tickets);
    } else {
        $count = 0;
    }
    $day = date("Y-m-d");
    $current_time = date("Y-m-d H:i:s");
    $input_arr = array('day' => $day, 'department' => $depart->value, 'type_key' => 'all', 'type_value' => '0', 'count' => $count, 'created_at' => $current_time);
    $count_id = Bll_ReportDayOnlineBiz::get_instance()->insert_count_data($input_arr);
}
echo date('c ') . " Count day online bugs ok \n";
Beispiel #30
0
 public function group_quality(array $table_project, $group_id, $begin, $end, $total_pmt, $delay_projects)
 {
     $res = array();
     $group_quality = array();
     $delay_pmt_ids = array();
     for ($v = 0; $v < count($delay_projects); $v++) {
         $delay_pmt_ids[] = $delay_projects[$v]->pmt_id;
     }
     $group_info = $this->get_group_info($group_id);
     foreach ($table_project as $pmt_id => $value) {
         $dev_persons = explode("<br />", $value['dev_person']);
         for ($i = 0; $i < count($dev_persons); $i++) {
             foreach ($group_info as $group_name => $members) {
                 foreach ($members[0] as $mem_id => $mem_name) {
                     if ($dev_persons[$i] == $mem_name) {
                         if (!isset($res[$group_name][1][$pmt_id]['bug_rate'])) {
                             $res[$group_name][1][$pmt_id]['bug_rate'] = $value['bug_devload'];
                             if (in_array($pmt_id, $delay_pmt_ids)) {
                                 $res[$group_name][1][$pmt_id]['delay'] = 1;
                             } else {
                                 $res[$group_name][1][$pmt_id]['delay'] = 0;
                             }
                         }
                     }
                 }
                 $res[$group_name][0]['members'] = $members[1];
             }
         }
     }
     foreach ($res as $group_name => $pmt_info) {
         $pmt_count = count($pmt_info);
         $less = 0;
         $delay = 0;
         $count_rate = 0;
         foreach ($pmt_info[1] as $value) {
             if ($value['bug_rate'] > 0.15) {
                 $less++;
             }
             if ($value['delay'] == 1) {
                 $delay++;
             }
             $count_rate += $value['bug_rate'];
         }
         $group_quality[$group_name]['less_rate'] = round($less / $pmt_count, 4) * 100;
         $group_quality[$group_name]['delay'] = $delay;
         $group_quality[$group_name]['pmt_count'] = $pmt_count;
         $group_quality[$group_name]['bug_rate'] = round($count_rate / $pmt_count, 2);
         $user_names = Bll_UserBiz::get_instance()->get_usernames_by_userids($pmt_info[0]['members']);
         $bugs = Bll_TicketBiz::get_instance()->get_count_production_by_groups($begin, $end, $user_names);
         $group_quality[$group_name]['bugs'] = count($bugs);
     }
     $return = '<table class="data_table" id="table_project_2_3_month">
                     <thead>
                     <tr>
                         <th class="table_sort" style="vertical-align:middle;"><span>开发组</span></th>
                         <th class="table_sort" style="vertical-align:middle;"><span>每工时Bug数量未达标项目比例</span></th>
                         <th class="table_sort" style="vertical-align:middle;"><span>线上Bug</span></th>
                         <th class="table_sort" style="vertical-align:middle;"><span>项目总数</span></th>
                         <th class="table_sort" style="vertical-align:middle;"><span>延期项目</span></th>
                         <th class="table_sort" style="vertical-align:middle;"><span>Bug工时比</span></th>
                     </tr>
                     </thead><tbody>';
     $total_bug = 0;
     if (count($group_quality) > 0) {
         foreach ($group_quality as $group_name => $value) {
             $total_bug += $value['bugs'];
             $return .= '<tr>' . '<td>' . $group_name . '</td>' . '<td>' . $value['less_rate'] . '%' . '</td>' . '<td>' . $value['bugs'] . '</td>' . '<td>' . $value['pmt_count'] . '</td>' . '<td>' . $value['delay'] . '</td>' . '<td>' . $value['bug_rate'] . '</td></tr>';
         }
         $return .= '<tr>' . '<td>' . "统计" . '</td>' . '<td>' . "" . '</td>' . '<td>' . $total_bug . '</td>' . '<td>' . $total_pmt . '</td>' . '<td>' . count($delay_pmt_ids) . '</td>' . '<td>' . "" . '</td></tr>';
         $return .= "</tbody></table>";
     }
     return $return;
 }