Exemple #1
0
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
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'] : 0;
     $id = $params['cid'] ? $params['cid'] : 0;
     if (isset($params['edit_submit'])) {
         $comp_id = $params['comp_id'];
         $input_arr = array('name' => $params['comp_name'], 'owner' => $params['comp_owner'], 'is_disabled' => $params['disable'], 'is_deleted' => $params['delete']);
         $ret = Bll_DdComponentBiz::get_instance()->modify_component($comp_id, $input_arr);
         $url = Admin_CompViewController::build_uri() . "?pro=" . $pro;
         $res->redirect($url);
     } else {
         if ($id != 0 && $pro != 0) {
             $depart = Bll_DdCommonBiz::get_instance()->get_name_by_id($pro);
             $component = Bll_DdComponentBiz::get_instance()->get_component_by_id($id);
         }
         $all_users = Bll_UserBiz::get_instance()->get_all_valid_users();
         $tmp_all = array();
         foreach ($all_users as $key => $value) {
             $tmp_all[$key] = $value->user_name;
         }
         $all_users = json_encode($tmp_all);
         $req->set_attribute('depart', $depart);
         $req->set_attribute('pro', $pro);
         $req->set_attribute('component', $component);
         $req->set_attribute('all_users', $all_users);
         return 'Admin_CompEdit';
     }
 }
Exemple #3
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' => $pro);
     $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;
         }
     }
     foreach ($groups as $value) {
         $group[$value->department][] = array('name' => $value->group_name, 'id' => $value->id);
     }
     $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);
     }
     $req->set_attribute('department_id', $department_id);
     return 'NewReport_UserOnlineBug';
 }
Exemple #4
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $all_users = Bll_UserBiz::get_instance()->get_all_valid_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $all_users = json_encode($tmp_all);
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $req->set_attribute('all_users', $all_users);
     $req->set_attribute('departments', $departments);
     //        var_dump($params['group_members']) ;
     if (isset($params['add_submit'])) {
         if (!empty($params['group_name']) && !empty($params['department']) && !empty($params['group_members'])) {
             $department = Bll_DdCommonBiz::get_instance()->get_department_value_by_id($params['department']);
             $input_arr = array('group_name' => $params['group_name'], 'department' => $department, 'group_members' => $params['group_members']);
             $ret = Bll_UserGroupCustomBiz::get_instance()->group_add($input_arr);
             if ($ret) {
                 $url = Admin_GroupViewController::build_uri();
                 $res->redirect($url);
             } else {
                 return 'Admin_GroupAdd';
             }
         } else {
             return 'Admin_GroupAdd';
         }
     } else {
         return 'Admin_GroupAdd';
     }
 }
Exemple #5
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     if (isset($params['add_submit'])) {
         $input_arr = array('name' => $params['reason_name'], 'is_disabled' => $params['disable'], 'is_deleted' => $params['delete']);
         $ret = Bll_DdCommonBiz::get_instance()->add_reason_by_admin($input_arr);
         $url = Admin_ReasonViewController::build_uri();
         $res->redirect($url);
     } else {
         return 'Admin_ReasonAdd';
     }
 }
Exemple #6
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     if ($params && $params['type'] && $params['name']) {
         $type = $params['type'];
         $name = $params['name'];
         $id = Bll_DdCommonBiz::get_instance()->add($type, $name);
         if ($id) {
             $req->set_attribute('suc', '增加成功!');
         } else {
             $req->set_attribute('suc', '增加失败!');
         }
     }
     return 'Ddcommon_Add';
 }
Exemple #7
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'] : 0;
     if (isset($params['add_submit'])) {
         $input_arr = array('department' => $params['department'], 'name' => $params['comp_name'], 'owner' => $params['comp_owner'], 'is_disabled' => $params['disable'], 'is_deleted' => $params['delete']);
         $ret = Bll_DdComponentBiz::get_instance()->add_by_admin($input_arr);
         $url = Admin_CompViewController::build_uri() . "?pro=" . $pro;
         $res->redirect($url);
     } else {
         $depart = Bll_DdCommonBiz::get_instance()->get_departments_new();
         $req->set_attribute('depart', $depart);
         $req->set_attribute('pro', $pro);
         return 'Admin_CompAdd';
     }
 }
Exemple #8
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $id = $params['pid'] ? $params['pid'] : 0;
     $all_users = Bll_UserBiz::get_instance()->get_all_valid_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $all_users = json_encode($tmp_all);
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     if ($id != 0) {
         $group = Bll_UserGroupCustomBiz::get_instance()->get_group_by_id($id);
         $group_members = explode(",", $group->group_members);
         $group_members = array_filter($group_members);
         $members = Bll_UserBiz::get_instance()->get_wholenames_by_ids($group_members);
         $group_members = implode(';', $members);
     }
     $req->set_attribute('all_users', $all_users);
     $req->set_attribute('departments', $departments);
     $req->set_attribute('group', $group);
     $req->set_attribute('group_members', $group_members);
     if (isset($params['edit_submit'])) {
         if (!empty($params['group_name']) && !empty($params['department']) && !empty($params['group_members'])) {
             $group_id = $params['group_id'];
             $department = Bll_DdCommonBiz::get_instance()->get_department_value_by_id($params['department']);
             $input_arr = array('group_name' => $params['group_name'], 'group_members' => $params['group_members'], 'department' => $department);
             $ret = Bll_UserGroupCustomBiz::get_instance()->group_edit($group_id, $input_arr);
             if ($ret) {
                 $url = Admin_GroupViewController::build_uri();
                 $res->redirect($url);
             } else {
                 return 'Admin_GroupEdit';
             }
         } else {
             return 'Admin_GroupEdit';
         }
     } else {
         return 'Admin_GroupEdit';
     }
 }
Exemple #9
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     if ($params['department'] && $params['name'] && $params['owner']) {
         $department = $params['department'];
         $name = $params['name'];
         $owner = $params['owner'];
         $int = Bll_DdComponentBiz::get_instance()->add($department, $name, $owner);
         if ($int) {
             $req->set_attribute('suc', '增加成功!');
         } else {
             $req->set_attribute('suc', '增加失败!');
         }
     }
     $departments = Bll_DdCommonBiz::get_instance()->get_departments();
     $req->set_attribute('departments', $departments);
     return 'Ddcomponent_Add';
 }
Exemple #10
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $id = $params['cid'] ? $params['cid'] : 0;
     if (isset($params['edit_submit'])) {
         $reason_id = $params['reason_id'];
         $input_arr = array('name' => $params['reason_name'], 'is_disabled' => $params['disable'], 'is_deleted' => $params['delete']);
         $ret = Bll_DdCommonBiz::get_instance()->modify_common($reason_id, $input_arr);
         $url = Admin_ReasonViewController::build_uri();
         $res->redirect($url);
     } else {
         if ($id != 0) {
             $reason = Bll_DdCommonBiz::get_instance()->get_common_by_id($id);
         }
         $req->set_attribute('reason', $reason);
         return 'Admin_ReasonEdit';
     }
 }
Exemple #11
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     if (isset($params['sort_save'])) {
         $new_sort = $params['reason_sort'];
         $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
         foreach ($reasons as $key => $row) {
             if ($row->sort != $new_sort[$key]) {
                 $modify_id = $row->id;
                 $input_arr = array('sort' => $new_sort[$key]);
                 $res_id = Bll_DdCommonBiz::get_instance()->modify_common($modify_id, $input_arr);
             }
         }
         $url = Admin_ReasonViewController::build_uri();
         $res->redirect($url);
     } else {
         $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
         $req->set_attribute('reasons', $reasons);
         return 'Admin_ReasonView';
     }
 }
Exemple #12
0
 public function log_add($input_arr)
 {
     if ($input_arr['field'] == 'environment' || $input_arr['field'] == 'emergency' || $input_arr['field'] == 'reason' || $input_arr['field'] == 'deparment' || $input_arr['field'] == 'priority' || $input_arr['field'] == 'resolution') {
         //            var_dump($input_arr['oldvalue']);die;
         $input_arr['oldvalue'] = Bll_DdCommonBiz::get_instance()->get_name_by_id($input_arr['oldvalue']);
         $input_arr['newvalue'] = Bll_DdCommonBiz::get_instance()->get_name_by_id($input_arr['newvalue']);
         if (!$input_arr['oldvalue']) {
             $input_arr['oldvalue'] = 'null';
         }
         if (!$input_arr['newvalue']) {
             $input_arr['newvalue'] = 'null';
         }
     }
     $ticket_log = new Model_TicketLog();
     $ticket_log->ticket_id = $input_arr['ticket_id'];
     $ticket_log->created_at = $input_arr['created_at'];
     $ticket_log->created_by = $input_arr['created_by'];
     $ticket_log->field = $input_arr['field'];
     $ticket_log->oldvalue = $input_arr['oldvalue'];
     $ticket_log->newvalue = $input_arr['newvalue'];
     $ticket_log->rlog = $input_arr['rlog'];
     $ticket_log->save();
     return $ticket_log->id;
 }
Exemple #13
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $groups = Bll_UserGroupCustomBiz::get_instance()->get_all_groups();
     $groups_arr = array();
     $group_arr = array();
     foreach ($groups as $group) {
         $group_arr['id'] = $group->id;
         $group_arr['group_name'] = $group->group_name;
         $group_arr['department'] = Bll_DdCommonBiz::get_instance()->get_department_name_by_value($group->department)->name;
         $group_members = explode(",", $group->group_members);
         $group_members = array_filter($group_members);
         $members_arr = Bll_UserBiz::get_instance()->get_chinesenames_by_ids($group_members);
         $group_arr['group_members'] = implode(',', $members_arr);
         $groups_arr[] = $group_arr;
     }
     $req->set_attribute('groups_arr', $groups_arr);
     if (isset($params['id'])) {
         $ret = Bll_UserGroupCustomBiz::get_instance()->group_delete($params['id']);
     }
     return 'Admin_GroupView';
 }
Exemple #14
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'] : 2;
     $userid = $req->get_user_id();
     $role = Bll_RoleBiz::get_instance()->get_user_role($userid);
     if ($role != "admin" && $role != "root") {
         $status = "nopermit";
         $this->request->set_attribute('status', $status);
         return 'Admin_CompView';
     }
     if (isset($params['sort_save'])) {
         $new_sort = $params['comp_sort'];
         $components = Bll_DdComponentBiz::get_instance()->get_components($product);
         foreach ($components as $key => $row) {
             if ($row->sort != $new_sort[$key]) {
                 $modify_id = $row->int;
                 $input_arr = array('sort' => $new_sort[$key]);
                 $res_id = Bll_DdComponentBiz::get_instance()->modify_component($modify_id, $input_arr);
             }
         }
         $url = Admin_CompViewController::build_uri() . "?pro=" . $product;
         $res->redirect($url);
     } else {
         $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
         $depart_select = array();
         foreach ($departments as $row) {
             $depart_select[$row->id] = array('name' => $row->name, 'click' => false);
         }
         $depart_select[$product]['click'] = true;
         $components = Bll_DdComponentBiz::get_instance()->get_components($product, 1);
         $req->set_attribute('pro', $product);
         $req->set_attribute('depart_select', $depart_select);
         $req->set_attribute('components', $components);
         return 'Admin_CompView';
     }
     /*$user_id=$req->get_user_id();
       $params=$req->get_parameters();
       if($params['changerole_user_id']&&$params['new_role']){
           $changerole_user_id=$params['changerole_user_id'];$new_role=$params['new_role'];
           $suc=Bll_UserRoleBiz::get_instance()->change_role($changerole_user_id, $new_role);//old:dev new:qa
           if($suc){
               $req->set_attribute('suc', '修改成功!');
           }else{
               $req->set_attribute('suc', '修改失败!');
           }
       }
       $user_info=Bll_UserBiz::get_instance()->get_userinfo_by_user_id($user_id);
       $role_name=Bll_RoleBiz::get_instance()->get_user_role($user_id);
       if($role_name=='admin'){
           $dev_users=Bll_UserBiz::get_instance()->get_dev_users();//对象数组
           $qa_users=Bll_UserBiz::get_instance()->get_qa_users();//对象数组
           $req->set_attribute('admin', 'admin');
           $req->set_attribute('dev_users', $dev_users);//对象数组
           $req->set_attribute('qa_users', $qa_users);//对象数组
       }
       $req->set_attribute('user_info', $user_info);//一个对象
       return 'Admin_CompView';*/
 }
Exemple #15
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';
 }
Exemple #16
0
 public function handle_request_internal()
 {
     $user = array();
     $display = array();
     $depart = 12;
     //12=>用户事业部
     //前端:508 后台:599,600 602 移动:601,根据hroa的api
     //product = 50=>网站端,51=>mobile
     $type_key = array("mobile" => array('product' => '51', 'user' => array(508, 602, 601)), "pc" => array('product' => '50', 'user' => array(508, 599, 600, 602)));
     $tab_info = array('pc' => array('name' => 'Pc', 'click' => false), 'mobile' => array('name' => 'Mobile', 'click' => false));
     $req = APF::get_instance()->get_request();
     // $res = APF::get_instance()->get_response();
     $params = $req->get_parameters();
     $pro = $params['pro'] ? $params['pro'] : 'pc';
     $time_type = $params['time'] ? $params['time'] : 'week';
     $report_type = $params['report'] ? $params['report'] : 'week';
     $tab_info[$pro]['click'] = true;
     $display['pro'] = $pro;
     $display['report_type'] = $report_type;
     /*获取开始时间,结束时间*/
     $time_arr = $this->get_time_type($time_type);
     $from = $time_arr['begin'];
     $to = $time_arr['end'];
     $display['input_from'] = date("Y-m-d", strtotime($from));
     $display['input_to'] = date("Y-m-d", strtotime($to));
     /* 获取组信息*/
     $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' => $pro . '_project');
     $page_bind_groups = Bll_ReportGroupSelectedBiz::get_instance()->get_group_ids_arr($input_arr);
     /*获取用户端的所有组*/
     $groups_user = Bll_UserGroupCustomBiz::get_instance()->get_groups_by_department(10);
     //10=>用户端
     foreach ($departments as $value) {
         if (intval($value->value) < 17 || intval($value->value) > 26) {
             $department[$value->value] = $value->name;
         }
     }
     foreach ($groups as $value) {
         $group[$value->department][] = array('name' => $value->group_name, 'id' => $value->id);
     }
     $req->set_attribute('department', $department);
     if ($group != null) {
         $req->set_attribute('group', $group);
     }
     if (!empty($page_bind_groups) || strlen($page_bind_groups[0]) > 0) {
         $req->set_attribute('page_bind_groups', $page_bind_groups);
     }
     /*获取项目延期信息*/
     $begin = strtotime($from);
     $end = strtotime($to);
     $ss = new APi_DeployInfoController();
     $delay_projects_all = $ss->get_deply_project($begin, $end);
     foreach ($delay_projects_all as $project) {
         //            if($project->type != 4){
         //                $delay_projects[] = $project;
         //            }
         if ($project->type == 1) {
             $delay_projects['pc'][] = $project;
         } elseif ($project->type == 2 || $project->type == 3) {
             $delay_projects['mobile'][] = $project;
         }
     }
     /* 获取组信息*/
     $product_line = $type_key[$pro]['product'];
     $result_arr = $this->get_time_type('month');
     $dev_summary = Bll_ReportMonthDevBiz::get_instance()->get_data_by_product_and_months($result_arr['nine_months'], 51, 'product_line', $pro);
     //获取前6个月的bug总览
     $dev_bug_summary = array();
     foreach ($dev_summary as $summary) {
         $dev_bug_summary['month'][] = $summary->month;
         $dev_bug_summary['workload'][] = $summary->dev_workload;
         $dev_bug_summary['bugs'][] = $summary->count;
         $dev_bug_summary['bug_workload'][] = $summary->dev_workload == 0 ? 0 : round($summary->count / $summary->dev_workload, 2);
     }
     /*获取user信息,通过hroa api*/
     for ($c = 0; $c < count($type_key[$pro]['user']); $c++) {
         $user[] = $this->get_user_by_department($type_key[$pro]['user'][$c]);
     }
     $user = $this->merge_array($user);
     $projects = Bll_PMTProjectBiz::get_instance()->get_project_by_user_and_time($depart, $product_line, $from, $to);
     if (empty($projects)) {
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('display', $display);
         $req->set_attribute('table_project', array());
         $req->set_attribute('project_tested', array());
         $req->set_attribute('dev_bug_workload_rate', array());
         $req->set_attribute('dev_bug_summary', array());
         $req->set_attribute('top_three_projects', array());
         //top 3项目
         $req->set_attribute('delay_projects', array());
         //延期项目
         return 'NewReport_ProjectQuality';
     }
     $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))) {
                 //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))) {
                 //4=>测试
                 $tasks_pmtid[$task['project_id']]['test'][] = $task;
                 $tasks_pmtid_person[$task['project_id']]['test'][$task['chinese_name']][] = $task['workload'];
             }
         }
     }
     $pmt_ids = array();
     $pmt_no_test_ids = array();
     //项目无测试人员
     foreach ($pmt_ids_init as $pmt_id) {
         if (!empty($tasks_pmtid[$pmt_id]['dev'])) {
             //task为开发的不为空则存pmt_id
             $pmt_ids[] = $pmt_id;
             if (empty($tasks_pmtid[$pmt_id]['test'])) {
                 //开发不为空并且qa为空的为notesting项目;
                 $pmt_no_test_ids[] = $pmt_id;
             }
         } else {
             //$pmt_ids[] = '';
         }
     }
     if (empty($pmt_ids)) {
         $req->set_attribute('tab_info', $tab_info);
         $req->set_attribute('table_project', array());
         $req->set_attribute('display', $display);
         $req->set_attribute('project_tested', array());
         $req->set_attribute('dev_bug_workload_rate', array());
         $req->set_attribute('dev_bug_summary', array());
         //项目bug总览
         $req->set_attribute('top_three_projects', array());
         //top 3项目
         $req->set_attribute('delay_projects', array());
         //延期项目
         return 'NewReport_ProjectQuality';
     }
     $project_tested = array();
     $count_all_project = isset($pmt_ids) ? count($pmt_ids) : 0;
     $count_notest_project = isset($pmt_no_test_ids) ? count($pmt_no_test_ids) : 0;
     $project_tested['all'] = $count_all_project;
     $project_tested['tested'] = $count_all_project - $count_notest_project;
     //有测试人员的项目数
     $project_tested['notest'] = $count_notest_project;
     //no testing项目数
     $bug_detail = Bll_TicketBiz::get_instance()->get_bugs_detail_by_pmtids($pmt_ids);
     //根据pmt_id获取bug数目
     $bugs_pmtid = array();
     foreach ($bug_detail as $bug) {
         $bugs_pmtid[$bug->pmt_id][] = $bug;
         //每个pmt项目获取的bug
     }
     $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();
     $dev_bug_workload_rate = array();
     foreach ($pmt_ids as $pmt_id) {
         $dev_p = array();
         //开发者
         $dev_t = array();
         //开发工时
         $test_p = array();
         $test_t = array();
         $dev_bug = array();
         //开发bug
         $test_bug = array();
         //测试bug
         $dev_bug_workload = array();
         $test_bug_workload = array();
         $table_work_person[$pmt_id]['php_bug'] = 0;
         $table_work_person[$pmt_id]['js_bug'] = 0;
         //前端bug
         $table_work_person[$pmt_id]['qa_bug'] = 0;
         //qa bug
         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);
         }
         foreach ($dev_t as $dev_key => $dev_value) {
             if (in_array($dev_key, $user)) {
                 if (isset($dev_bug_workload_rate[$dev_key])) {
                     $dev_bug_workload_rate[$dev_key][0] += $dev_bug[$dev_key];
                     $dev_bug_workload_rate[$dev_key][1] += $dev_value;
                 } else {
                     $dev_bug_workload_rate[$dev_key][0] = $dev_bug[$dev_key];
                     $dev_bug_workload_rate[$dev_key][1] = $dev_value;
                 }
             }
         }
         //508=>前端,后台:599,600 602 移动:601 QA:603
         foreach ($dev_p as $key => $value) {
             if (in_array($value, $this->get_user_by_department(508))) {
                 $table_work_person[$pmt_id]['js_bug'] += $dev_bug[$key];
                 //判断是否是前端bug和PHP bug
             } else {
                 $table_work_person[$pmt_id]['php_bug'] += $dev_bug[$key];
             }
         }
         $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);
         //开发bug
         $table_work_person[$pmt_id]['test_bug'] = implode("<br />", $test_bug);
         //测试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);
     }
     $dev_bug_workload_rate = $this->process_rate($dev_bug_workload_rate);
     if ($params['ajax'] == 1) {
         if ($params['div'] == "#best_dev_group") {
             $group_rate = $this->process_group_info($params['group_id'], $dev_bug_workload_rate);
             $best = $this->get_best_group($group_rate);
             echo $best;
             return 0;
         }
     }
     //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;
             $tasks_pmtid[$pmt_id]['groups'] = '';
             $temp_group_selected = array();
             foreach ($tasks_pmtid[$pmt_id]['dev'] as $row) {
                 $person[] = $row['chinese_name'];
                 $data = Bll_UserBiz::get_instance()->get_user_id_by_chinese_name($row['chinese_name']);
                 foreach ($groups_user as $group) {
                     $group_members = explode(',', $group->group_members);
                     $group_members = array_filter($group_members);
                     if (in_array($data->user_id, $group_members)) {
                         $temp_group_selected[] = $group->group_name;
                     }
                 }
                 $temp_group_selected = array_unique($temp_group_selected);
                 $tasks_pmtid[$pmt_id]['groups'] = implode(',', $temp_group_selected);
                 // 项目与组之间关系
                 $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();
             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]['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]['bugs_count'] = isset($bugs_pmtid[$pmt_id]) ? count($bugs_pmtid[$pmt_id]) : 0;
         $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'];
         //开发bug
         $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'];
         //测试发现的bug
         $table_project[$pmt_id]['dev_workload_all'] = $table_workload[$pmt_id]['dev_workload'];
         //总开发工时
         $table_project[$pmt_id]['test_workload_all'] = $table_workload[$pmt_id]['test_workload'];
         //总测试工时
         $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]['php_bug'] = $table_work_person[$pmt_id]['php_bug'];
         $table_project[$pmt_id]['js_bug'] = $table_work_person[$pmt_id]['js_bug'];
         $table_project[$pmt_id]['others_bug'] = $table_project[$pmt_id]['bugs_count'] - ($table_work_person[$pmt_id]['js_bug'] + $table_work_person[$pmt_id]['php_bug']);
         //总bug数目-(php+js) bug
         $table_project[$pmt_id]['groups'] = $tasks_pmtid[$pmt_id]['groups'];
     }
     if ($params['ajax'] == 1) {
         if ($params['div'] == "#contrast_dev_group") {
             echo $this->group_quality($table_project, $params['group_id'], $from, $to, count($pmt_ids), $delay_projects[$display['pro']]);
             return 0;
         }
     }
     $dev_bug_workload_rate = array_values($dev_bug_workload_rate);
     $top_three_projects = array();
     usort($table_project, "self::my_sort");
     $top_three_projects['first'] = $table_project[0];
     $top_three_projects['second'] = $table_project[1];
     $top_three_projects['third'] = $table_project[2];
     //top3项目
     $req->set_attribute('tab_info', $tab_info);
     $req->set_attribute('table_project', $table_project);
     $req->set_attribute('dev_bug_workload_rate', $dev_bug_workload_rate);
     $req->set_attribute('project_tested', $project_tested);
     $req->set_attribute('display', $display);
     $req->set_attribute('dev_bug_summary', $dev_bug_summary);
     //项目bug总览
     $req->set_attribute('top_three_projects', $top_three_projects);
     //top3项目
     $req->set_attribute('delay_projects', $delay_projects);
     //延期项目
     return 'NewReport_ProjectQuality';
 }
Exemple #17
0
 protected function get_results()
 {
     $q = $this->request->get_parameter('q');
     $sort_by = @$this->request->get_parameter('sort_by');
     $sort_by = empty($sort_by) ? 'id' : $sort_by;
     $this->sort = $sort_by;
     $sort_order = @$this->request->get_parameter('sort_order');
     $sort_order = empty($sort_order) ? 'desc' : $sort_order;
     $this->group_order = $sort_order;
     $sort_c = @$this->request->get_parameter('sort_c');
     $sort_c = empty($sort_c) ? 'id' : $sort_c;
     $this->sort_c = $sort_c;
     $sort_o = @$this->request->get_parameter('sort_o');
     $sort_o = empty($sort_o) ? 'desc' : $sort_o;
     $this->sort_o = $sort_o;
     if ($sort_by != 'id') {
         if (!empty($sort_c)) {
             $sort = "{$sort_by} {$sort_order}, {$sort_c} {$sort_o}";
         } else {
             $sort = "{$sort_by} {$sort_order}, id desc";
         }
     } else {
         $sort = "{$sort_c} {$sort_o}";
     }
     $rows = @intval($this->request->get_parameter('rows'));
     $rows = empty($rows) ? 100 : $rows;
     $current = $this->page_current;
     $start = @intval($rows * ($current - 1));
     $params = $this->request->get_parameters();
     $user_querys = array();
     $fields = array_keys($this->fields);
     $user_inputs = array();
     foreach ($fields as $field) {
         if (empty($params[$field])) {
             continue;
         }
         if (empty($params[$field]['v'])) {
             continue;
         }
         if ($field != 'component' && $field != 'created_at' && $field != 'closed_at' && $field != 'updated_at' && $params[$field]['v'][0] == '') {
             $user_inputs[$field]['t'] = $this->fields[$field]['type'];
             $user_inputs[$field]['o'] = $params[$field]['o'];
             $user_inputs[$field]['v'] = array('');
             continue;
         }
         $user_inputs[$field]['t'] = $this->fields[$field]['type'];
         $user_inputs[$field]['o'] = $params[$field]['o'];
         $user_inputs[$field]['v'] = array();
         $sub_querys = array();
         foreach ($params[$field]['v'] as $v) {
             if (!is_array($v)) {
                 $v = trim($v);
             }
             if ($v === '') {
                 continue;
             }
             if ($this->fields[$field]['type'] == 'dateinput') {
                 $v['b'] = trim($v['b']);
                 $v['e'] = trim($v['e']);
                 $_user_input = array();
                 $date_begin = '*';
                 $date_end = '*';
                 if ($v['b']) {
                     $date_begin = strtotime($v['b']);
                     if ($date_begin <= 0) {
                         $date_begin = '*';
                     }
                     $_user_input['b'] = $v['b'];
                 }
                 if ($v['e']) {
                     $date_end = strtotime($v['e'] . ' 23:59:59');
                     if ($date_end <= 0) {
                         $date_end = '*';
                     }
                     $_user_input['e'] = $v['e'];
                 }
                 if ($date_begin == '*' && $date_end == '*') {
                     continue;
                 }
                 $sub_querys[] = "{$field}:[{$date_begin} TO {$date_end}]";
                 $user_inputs[$field]['v'][] = $_user_input;
             } else {
                 $user_inputs[$field]['v'][] = $v;
                 if ($field == 'owner' || $field == 'assigned_qa' || $field == 'reporter') {
                     $v_tmp = $v;
                     $v = Bll_UserBiz::get_instance()->get_username_by_wholename($v);
                     if (!$v) {
                         $v = $v_tmp;
                     }
                 } else {
                     if ($field == 'priority' || $field == 'environment' || $field == 'department' || $field == 'resolution' || $field == 'reason') {
                         $v_tmp = $v;
                         if ($v_tmp == '0') {
                             $v = "";
                         } else {
                             $v = Bll_DdCommonBiz::get_instance()->get_name_by_id($v_tmp);
                         }
                     } else {
                         if ($field == 'component') {
                             $v1 = Bll_DdComponentBiz::get_instance()->get_name_by_id($v['c']);
                             $v2 = Bll_DdCommonBiz::get_instance()->get_name_by_id($v['d']);
                             $sub_querys[] = "(department:\"{$v2}\" AND component:\"{$v1}\")";
                             continue;
                         } else {
                             if ($field == 'keyword') {
                                 if ($user_inputs[$field]['o'] == 'ticket title') {
                                     $sub_querys[] = "summary:({$v})";
                                 }
                                 if ($user_inputs[$field]['o'] == 'ticket description') {
                                     $sub_querys[] = "description:({$v})";
                                 }
                                 continue;
                             }
                         }
                     }
                 }
                 $sub_querys[] = "{$field}:\"{$v}\"";
             }
         }
         if (empty($sub_querys)) {
             continue;
         }
         $sub_querys_str = "(" . join(' OR ', $sub_querys) . ")";
         if ($params[$field]['o'] == 'is not') {
             $sub_querys_str = '-' . $sub_querys_str;
         }
         $user_querys[] = $sub_querys_str;
     }
     $q = join(" AND ", $user_querys);
     try {
         $solr = Util_SolrFactory::get_instance()->get_solr();
         $results = $solr->search($q, array('wt' => 'json', 'sort' => $sort), $start, $rows);
         //处理新字段
         if ($results) {
             $results['csv'] = $solr->search($q, array('wt' => 'json', 'sort' => $sort), 0, $results['numFound']);
         }
     } catch (Exception $e) {
         $this->page_status = 'solrexception';
         $this->request->set_attribute('solrexception', $e->getMessage());
     }
     $this->request->set_attribute('user_inputs', $user_inputs);
     $this->request->set_attribute('sort_by', $sort_by);
     $this->request->set_attribute('sort_order', $sort_order);
     $this->request->set_attribute('sort_c', $sort_c);
     $this->request->set_attribute('sort_o', $sort_o);
     return $results;
 }
Exemple #18
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' => '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', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6');
     $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();
     $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();
         foreach ($counts_all as $row) {
             $count_day_sec[$row->day][$department[$row->department]] = $row->count;
         }
         $count_day_all = array();
         foreach ($count_day_sec as $key => $row) {
             $count_day_all[] = array_merge(array('date' => $key), $row);
         }
         //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;
         //$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;
         }
         $count_month_all = array();
         foreach ($count_month_sec as $key => $row) {
             $count = $row['Anjuke'] + $row['Aifang'] + $row['Haozu'] + $row['Jinpu'] + $row['Mobile'] + $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);
         $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 'Report_Online';
     }
     //day_all
     $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 'Report_Online';
 }
<?php

apf_require_class('Bll_TicketBiz');
apf_require_class('Bll_DdCommonBiz');
apf_require_class('Bll_ReportProgessPmtBiz');
apf_require_class('Bll_TicketRelationBiz');
apf_require_class('Bll_TicketCounterBiz');
apf_require_class('Bll_TicketStatusHistoryBiz');
$day = date("Y-m-d");
$begin = date("Y-m-d 00:00:00");
$end = date("Y-m-d 23:59:59");
$current_time = date("Y-m-d H:i:s");
//priority id-value array
$environments = Bll_DdCommonBiz::get_instance()->get_environments();
$envi_id_value = array();
foreach ($environments as $environment) {
    $envi_id_value[$environment->id] = $environment->value;
}
//all counts
$tickets_day = Bll_TicketBiz::get_instance()->get_all_progess();
$tickets_process = array();
foreach ($tickets_day as $day_row) {
    if ($day_row->pmt_id && $day_row->pmt_id != 0) {
        $tickets_process[$day_row->pmt_id][$envi_id_value[$day_row->environment]][] = $day_row;
    }
}
foreach ($tickets_process as $p_pmtid => $row_first) {
    foreach ($row_first as $r_enviro => $row_second) {
        $input_arr = array();
        $input_arr['day'] = $day;
        $input_arr['pmt_id'] = $p_pmtid;
Exemple #20
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';
 }
Exemple #21
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');
     $error = $req->get_parameter('error');
     $user_id = $req->get_user_id();
     $user_role = Bll_RoleBiz::get_instance()->get_user_role($user_id);
     $ticket = Bll_TicketBiz::get_instance()->get_detail($ticket_id);
     if (empty($ticket)) {
         $location = Home_IndexController::build_uri();
         $res->redirect($location);
     }
     //custom_detail
     $custom_detail = Bll_TicketColumnDetailBiz::get_instance()->get_ticket_custom($ticket_id);
     $custom_all = Bll_TicketColumnDetailBiz::get_instance()->get_all_custom($ticket_id);
     $ticket_before_md5 = md5(json_encode($ticket));
     $ticket->reporter = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->reporter);
     $ticket->owner = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->owner);
     $ticket->assigned_qa = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->assigned_qa);
     $ticket_log = Bll_TicketLogBiz::get_instance()->get_log($ticket_id);
     $ticket_cc_arr = Bll_TicketCcBiz::get_instance()->get_ticket_cc($ticket_id);
     $cc_tmp = array();
     foreach ($ticket_cc_arr as $key => $ticket_cc) {
         if (Util_StringUtils::is_email($ticket_cc->cc_to)) {
             $cc_tmp[] = $ticket_cc->cc_to;
         } else {
             $cc_tmp[] = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket_cc->cc_to);
         }
     }
     $ticket_cc_str = implode(";", $cc_tmp);
     $current_time = date("Y-m-d H:i:s");
     $ticket_log_process = array();
     foreach ($ticket_log as $key => $log) {
         if ($ticket_log[$key]->field == "component") {
             if (ctype_digit($ticket_log[$key]->oldvalue)) {
                 $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->oldvalue);
             }
             if (ctype_digit($ticket_log[$key]->newvalue)) {
                 $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->newvalue);
             }
         } else {
             if ($ticket_log[$key]->field == "department") {
                 if (ctype_digit($ticket_log[$key]->oldvalue)) {
                     $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->oldvalue);
                 }
                 if (ctype_digit($ticket_log[$key]->newvalue)) {
                     $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->newvalue);
                 }
             } else {
                 if ($ticket_log[$key]->field == "ticket" && $ticket_log[$key]->oldvalue == "null") {
                     $ticket_log[$key]->newvalue = "new";
                 }
             }
         }
         $ticket_log_process[$log->created_at][] = $log;
     }
     $log_time = array();
     foreach ($ticket_log_process as $key => $log) {
         /*
          * within 24h show xxx hours ago
          * mt 24h lt 7days show xx days ago
          * mt 7days lt 30days show xx weeks ago
          * mt 30days show xx months ago
          * floor((strtotime($current_time)-strtotime($log->created_at))/86400)
          */
         $second = floor(strtotime($current_time) - strtotime($key));
         $minute = floor((strtotime($current_time) - strtotime($key)) / 60);
         $hour = floor((strtotime($current_time) - strtotime($key)) / 3600);
         $day = floor((strtotime($current_time) - strtotime($key)) / 86400);
         $week = floor((strtotime($current_time) - strtotime($key)) / 604800);
         $month = floor((strtotime($current_time) - strtotime($key)) / 2592000);
         if ($second < 60) {
             $log_time[$key] = $second . ' seconds ago ';
         } else {
             if ($minute < 60) {
                 $log_time[$key] = $minute . ' minutes ago ';
             } else {
                 if ($hour < 24) {
                     $log_time[$key] = $hour . ' hours ago ';
                 } else {
                     if ($hour >= 24 && $hour < 168) {
                         $log_time[$key] = $day . ' days ago ';
                     } else {
                         if ($hour >= 168 && $hour < 720) {
                             $log_time[$key] = $week . ' weeks ago ';
                         } else {
                             if ($hour >= 720) {
                                 $log_time[$key] = $month . ' months ago ';
                             }
                         }
                     }
                 }
             }
         }
     }
     $parent = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($ticket_id);
     if ($parent) {
         $parent_id = $parent->parent_ticket_id;
     } else {
         $parent_id = "0";
     }
     $son = Bll_TicketRelationBiz::get_instance()->find_son_bugs_of_parent($ticket_id);
     if (empty($son)) {
         $son_id = "0";
     } else {
         $son_id = $son[0]->ticket_id;
     }
     $ticket_status = Ticket_Status::get_status($ticket);
     $actions = $ticket_status->get_available_actions($user_role, $ticket->environment);
     $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions();
     //start.....
     $all_users = Bll_UserBiz::get_instance()->get_all_valid_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $all_users = json_encode($tmp_all);
     $dev_users = Bll_UserBiz::get_instance()->get_dev_users();
     $tmp_dev = array();
     foreach ($dev_users as $key => $value) {
         $tmp_dev[$key] = $value->whole_name;
     }
     $dev_users = json_encode($tmp_dev);
     $qa_users = Bll_UserBiz::get_instance()->get_qa_users();
     $admin_users = Bll_UserBiz::get_instance()->get_admins();
     $qa_admin_users = array_merge($qa_users, $admin_users);
     $tmp_qa = array();
     foreach ($qa_admin_users as $key => $value) {
         $tmp_qa[$key] = $value->whole_name;
     }
     $qa_admin_users = json_encode($tmp_qa);
     //end.....
     $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
     $files = Bll_AttachmentBiz::get_instance()->get_file_by_ticket_id($ticket_id);
     if ($files) {
         foreach ($files as $file) {
             $file_link = Bll_AttachmentBiz::get_instance()->get_file_link_by_hash($file->fetch_hash);
             $file->fetch_hash = $file_link;
         }
     }
     $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $emergencies = Bll_DdCommonBiz::get_instance()->get_emergencies();
     $environments = Bll_DdCommonBiz::get_instance()->get_environments();
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $department_id = Bll_DdCommonBiz::get_instance()->get_department_id_by_name($ticket->department);
     $rel_components = Bll_DdComponentBiz::get_instance()->get_components($department_id->id);
     $req->set_attribute('user_id', $user_id);
     $req->set_attribute('files', $files);
     $req->set_attribute('prioritys', $prioritys);
     $req->set_attribute('emergencies', $emergencies);
     $req->set_attribute('departments', $departments);
     $req->set_attribute('rel_components', $rel_components);
     $req->set_attribute('environments', $environments);
     $req->set_attribute('reasons', $reasons);
     $req->set_attribute('resolutions', $resolutions);
     $req->set_attribute('ticket', $ticket);
     $req->set_attribute('ticket_cc_str', $ticket_cc_str);
     $req->set_attribute('ticket_logs', $ticket_log_process);
     $req->set_attribute('log_time', $log_time);
     $req->set_attribute('actions', $actions);
     $req->set_attribute('all_users', $all_users);
     $req->set_attribute('dev_users', $dev_users);
     $req->set_attribute('qa_admin_users', $qa_admin_users);
     $req->set_attribute('ticket_before_md5', $ticket_before_md5);
     $req->set_attribute('parent_id', $parent_id);
     $req->set_attribute('son_id', $son_id);
     $req->set_attribute('custom_detail', $custom_detail);
     $req->set_attribute('custom_all', $custom_all);
     if ($error) {
         $req->set_attribute('error', $error);
     }
     return 'Ticket_Detail';
 }
Exemple #22
0
 private function map_reason(array $type_value)
 {
     $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
     for ($i = 0; $i < count($type_value); $i++) {
         foreach ($reasons as $key => $value) {
             if ($type_value[$i] == $value->id) {
                 $type_value[$i] = $value->name;
             }
         }
     }
     return $type_value;
 }
Exemple #23
0
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     //var_dump($params);die();
     //var_dump($params['description']);die();
     if ($params && $params['summary'] && $params['editor1'] && $params['owner'] && $params['reporter']) {
         $input_arr = array('summary' => $params['summary'], 'reporter' => $params['reporter'], 'description' => Ticket_AttachAddController::convert_imageurl($params['editor1']), 'priority' => $params['priority'], 'emergency' => $params['emergency'], 'environment' => $params['environment'], 'department' => $params['department'], 'component' => $params['component'], 'owner' => $params['owner'], 'cc_user' => $params['cc_user'], 'assigned_qa' => $params['assigned_qa'], 'pmt_id' => $params['pmt_id'], 'version' => $params['version'], 'is_regression' => $params['is_regression'], 'status' => 'opened', 'version' => $params['version'], 'is_occasional' => $params['is_occasional'], 'person_liable' => $params['person_liable']);
         if (in_array($input_arr['department'], array('47', '48'))) {
             $input_arr['pmt_id'] = 0;
         }
         $input_arr['owner'] = strpos($input_arr['owner'], ";") ? substr($input_arr['owner'], 0, strpos($input_arr['owner'], ";")) : $input_arr['owner'];
         $input_arr['owner'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['owner']);
         $input_arr['assigned_qa'] = strpos($input_arr['assigned_qa'], ";") ? substr($input_arr['assigned_qa'], 0, strpos($input_arr['assigned_qa'], ";")) : $input_arr['assigned_qa'];
         $input_arr['assigned_qa'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['assigned_qa']);
         //$input_arr['person_liable'] = strpos($input_arr['person_liable'],";")?substr($input_arr['person_liable'], 0, strpos($input_arr['person_liable'],";")):$input_arr['person_liable'];
         //$input_arr['person_liable'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['person_liable']);
         $ticket_id = Bll_TicketBiz::get_instance()->ticket_add($input_arr);
         //request icase api
         if (isset($params['case_id'])) {
             $cycle = 3;
             $url = "http://icase.corp.anjuke.com/api/save/case2bug?";
             $p = array();
             $p['bug_id'] = $ticket_id;
             $p['case_id'] = $params['case_id'];
             $url = $url . "bug_id=" . $p['bug_id'] . "&case_id=" . $p['case_id'] . "&key=nmzszxsl";
             $culr = curl_init();
             curl_setopt($culr, CURLOPT_URL, $url);
             curl_setopt($culr, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($culr, CURLOPT_FOLLOWLOCATION, 1);
             $data = curl_exec($culr);
             $data = json_decode($data, true);
             while ($cycle > 0) {
                 if ($data['status'] == "ok") {
                     break;
                 }
                 $data = curl_exec($culr);
                 $cycle--;
             }
             curl_close($culr);
         }
         //request imonitor api
         if (isset($params['task_fail_id']) && $params['task_fail_id'] != "") {
             $cycle = 3;
             $url = "10.10.9.53:8888/api/ibug/";
             $p = array();
             $p['bug_id'] = $ticket_id;
             $p['task_fail_id'] = $params['task_fail_id'];
             $culr = curl_init();
             curl_setopt($culr, CURLOPT_URL, $url);
             curl_setopt($culr, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($culr, CURLOPT_HEADER, 0);
             curl_setopt($culr, CURLOPT_POST, 1);
             curl_setopt($culr, CURLOPT_POSTFIELDS, $p);
             $data = curl_exec($culr);
             while ($cycle > 0) {
                 if ($data == "ok") {
                     break;
                 }
                 $data = curl_exec($culr);
                 $cycle--;
             }
             curl_close($culr);
         }
         //custom column
         $custom_columns = Bll_TicketCustomColumnBiz::get_instance()->get_custom_columns();
         foreach ($custom_columns as $column) {
             if (!empty($params[$column->column_name])) {
                 $custom_arr[$column->column_name] = $params[$column->column_name];
             }
         }
         if (!empty($custom_arr)) {
             $res = Bll_TicketColumnDetailBiz::get_instance()->ticket_custom_add($ticket_id, $custom_arr);
         }
         //save files using curl
         $file_hidden = $params['file_hidden'];
         if (!empty($file_hidden)) {
             foreach ($file_hidden as $file_id) {
                 $file_info = Bll_AttachmentBiz::get_instance()->get_file_info_by_id($file_id);
                 $local_filepath = $file_info->local_filepath;
                 $finfo = finfo_open(FILEINFO_MIME_TYPE);
                 $file_type = finfo_file($finfo, $local_filepath);
                 $post_params = array("file" => "@" . $local_filepath . ";type=" . $file_type);
                 $request_url = APF::get_instance()->get_config('file_upload_url');
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $request_url);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $ret = curl_exec($ch);
                 $info = curl_getinfo($ch);
                 $ret_value = json_decode($ret);
                 if (!$ret_value->error) {
                     $fetch_hash = $ret_value->saved_file[0]->hash;
                 }
                 //更新数据库
                 $res = Bll_AttachmentBiz::get_instance()->modify_file_info($file_id, $ticket_id, $fetch_hash);
             }
         }
         $current_time = date("Y-m-d H:i:s");
         if ($ticket_id) {
             //mail add
             $id = Bll_MailBiz::get_instance()->mail_add($ticket_id, $current_time);
         }
         if ($ticket_id) {
             //new ticket log add
             $input_arr = array('ticket_id' => $ticket_id, 'created_by' => $req->get_username(), 'field' => 'ticket', 'oldvalue' => 'null', 'newvalue' => $input_arr['description'], 'created_at' => $current_time);
             $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr);
         }
         $location = Ticket_DetailController::build_uri() . '?ticket_id=' . $ticket_id;
         APF::get_instance()->get_response()->redirect($location);
     } else {
         if ($params['post'] == 'posted') {
             $req->set_attribute('error', '请检查,summary,description,owner为必填项!');
         }
     }
     $all_users = Bll_UserBiz::get_instance()->get_all_valid_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $all_users = json_encode($tmp_all);
     $dev_users = Bll_UserBiz::get_instance()->get_dev_users();
     $tmp_dev = array();
     foreach ($dev_users as $key => $value) {
         $tmp_dev[$key] = $value->whole_name;
     }
     $dev_users = json_encode($tmp_dev);
     $qa_users = Bll_UserBiz::get_instance()->get_qa_users();
     $admin_users = Bll_UserBiz::get_instance()->get_admins();
     $qa_admin_users = array_merge($qa_users, $admin_users);
     $tmp_qa = array();
     foreach ($qa_admin_users as $key => $value) {
         $tmp_qa[$key] = $value->whole_name;
     }
     $qa_admin_users = json_encode($tmp_qa);
     $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $emergencies = Bll_DdCommonBiz::get_instance()->get_emergencies();
     $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
     $environments = Bll_DdCommonBiz::get_instance()->get_environments();
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $custom_columns = Bll_TicketCustomColumnBiz::get_instance()->get_custom_columns();
     $req->set_attribute('prioritys', $prioritys);
     $req->set_attribute('emergencies', $emergencies);
     $req->set_attribute('reasons', $reasons);
     $req->set_attribute('environments', $environments);
     $req->set_attribute('departments', $departments);
     $req->set_attribute('reporter', $req->get_username());
     $req->set_attribute('all_users', $all_users);
     $req->set_attribute('dev_users', $dev_users);
     $req->set_attribute('qa_admin_users', $qa_admin_users);
     $req->set_attribute('custom_columns', $custom_columns);
     $req->set_attribute('paramas', $params);
     return 'Ticket_Add';
 }
Exemple #24
0
 protected function set_filter_fields()
 {
     $_rows = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $departments = array();
     foreach ($_rows as $_row) {
         $departments[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_environments();
     $environments = array();
     foreach ($_rows as $_row) {
         $environments[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_reasons();
     $reasons = array();
     foreach ($_rows as $_row) {
         $reasons[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_resolutions();
     $resolutions = array('0' => 'None');
     foreach ($_rows as $_row) {
         $resolutions[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $prioritys = array();
     foreach ($_rows as $_row) {
         $prioritys[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdComponentBiz::get_instance()->get_all_components();
     $components = array();
     foreach ($_rows as $_row) {
         $components[$_row->int] = $_row->name;
     }
     $_rows = Ticket_Status::get_all_status();
     $statuses = array();
     foreach ($_rows as $_row) {
         $statuses[$_row] = $_row;
     }
     $fields = array('assigned_qa' => array('type' => 'input', 'operates' => array('is', 'is not')), 'component' => array('type' => 'input', 'operates' => array('is', 'is not')), 'created_at' => array('type' => 'dateinput'), 'closed_at' => array('type' => 'dateinput'), 'department' => array('type' => 'checkbox', 'options' => $departments), 'environment' => array('type' => 'checkbox', 'options' => $environments), 'is_occasional' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'is_regression' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'keyword' => array('type' => 'input', 'operates' => array('ticket title', 'ticket description')), 'owner' => array('type' => 'input', 'operates' => array('is', 'is not')), 'person_liable' => array('type' => 'input', 'operates' => array('is', 'is not')), 'pmt_id' => array('type' => 'input', 'operates' => array('is', 'is not')), 'priority' => array('type' => 'checkbox', 'options' => $prioritys), 'reason' => array('type' => 'checkbox', 'options' => $reasons), 'reporter' => array('type' => 'input', 'operates' => array('is', 'is not')), 'resolution' => array('type' => 'checkbox', 'options' => $resolutions), 'status' => array('type' => 'checkbox', 'options' => $statuses), 'updated_at' => array('type' => 'dateinput'), 'reject' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'reopen' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')));
     $all_users = Bll_UserBiz::get_instance()->get_all_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $this->fields = $fields;
 }
Exemple #25
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';
 }
Exemple #26
0
$end = date("Y-m-d 23:59:59");
$current_time = date("Y-m-d H:i:s");
//all counts
$tickets_day = Bll_TicketBiz::get_instance()->get_count_pmt_day($begin, $end);
$ticket_pmt_all = array();
foreach ($tickets_day as $tickets_day_row) {
    if ($tickets_day_row->pmt_id && $tickets_day_row->pmt_id != 0) {
        $ticket_pmt_all[$tickets_day_row->pmt_id][] = $tickets_day_row;
    }
}
foreach ($ticket_pmt_all as $key => $ticket_pmt_all_row) {
    $input_arr = array('day' => $day, 'pmt_id' => $key, 'type_key' => 'all', 'type_value' => '0', 'count' => count($ticket_pmt_all_row), 'created_at' => $current_time);
    $count_id = Bll_ReportDayPmtBiz::get_instance()->insert_count_data($input_arr);
}
//priority id-value array
$prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys();
$priority_id_value = array();
foreach ($prioritys as $priority) {
    $priority_id_value[$priority->id] = $priority->value;
}
//tickets group by pmtid
$tickets_type = Bll_TicketBiz::get_instance()->get_count_pmt_type();
$tickets_type_pmtid = array();
foreach ($tickets_type as $tickets_type_row) {
    if ($tickets_type_row->pmt_id && $tickets_type_row->pmt_id != 0) {
        $tickets_type_pmtid[$tickets_type_row->pmt_id][] = $tickets_type_row;
    }
}
foreach ($tickets_type_pmtid as $key_pmtid => $tickets_type_pmtid_rows) {
    //priority counts
    $tickets_type_pmtid_priority = array();
Exemple #27
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;
 }
Exemple #28
0
 public function process_solr_field($tickets)
 {
     $common_ids = array();
     $component_ids = array();
     foreach ($tickets as $ticket) {
         $common_ids[] = $ticket->priority;
         $common_ids[] = $ticket->emergency;
         $common_ids[] = $ticket->environment;
         $common_ids[] = $ticket->department;
         $common_ids[] = $ticket->resolution;
         $common_ids[] = $ticket->reason;
         $component_ids[] = $ticket->component;
     }
     $common_names = Bll_DdCommonBiz::get_instance()->get_names_by_ids($common_ids);
     $component_names = Bll_DdComponentBiz::get_instance()->get_names_by_ids($component_ids);
     foreach ($tickets as $ticket) {
         $ticket->priority = $common_names[$ticket->priority];
         $ticket->emergency = $common_names[$ticket->emergency];
         $ticket->environment = $common_names[$ticket->environment];
         $ticket->department = $common_names[$ticket->department];
         $ticket->component = $component_names[$ticket->component];
         if ($ticket->resolution == 'Fixed') {
             $ticket->resolution = $ticket->resolution;
         } else {
             $ticket->resolution = $common_names[$ticket->resolution];
         }
         $ticket->reason = $common_names[$ticket->reason];
     }
     return $tickets;
 }
Exemple #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";
Exemple #30
0
 protected function set_filter_fields()
 {
     $_rows = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $departments = array();
     foreach ($_rows as $_row) {
         $departments[$_row->id] = $_row->name;
     }
     $this->request->set_attribute('departments', $departments);
     $_rows = Bll_DdCommonBiz::get_instance()->get_environments();
     $environments = array();
     foreach ($_rows as $_row) {
         $environments[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_reasons();
     $reasons = array();
     foreach ($_rows as $_row) {
         $reasons[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_resolutions();
     $resolutions = array('0' => 'None');
     foreach ($_rows as $_row) {
         $resolutions[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $prioritys = array();
     foreach ($_rows as $_row) {
         $prioritys[$_row->id] = $_row->name;
     }
     $_rows = Bll_DdComponentBiz::get_instance()->get_all_components();
     $components = array();
     foreach ($_rows as $_row) {
         $components[$_row->int] = $_row->name;
     }
     $_rows = Ticket_Status::get_all_status();
     $statuses = array();
     foreach ($_rows as $_row) {
         $statuses[$_row] = $_row;
     }
     $fields = array('assigned_qa' => array('type' => 'input', 'operates' => array('is', 'is not')), 'component' => array('type' => 'input', 'operates' => array('is', 'is not')), 'created_at' => array('type' => 'dateinput'), 'closed_at' => array('type' => 'dateinput'), 'department' => array('type' => 'checkbox', 'options' => $departments), 'environment' => array('type' => 'checkbox', 'options' => $environments), 'is_occasional' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'is_regression' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'keyword' => array('type' => 'input', 'operates' => array('ticket title', 'ticket description')), 'owner' => array('type' => 'input', 'operates' => array('is', 'is not')), 'person_liable' => array('type' => 'input', 'operates' => array('is', 'is not')), 'pmt_id' => array('type' => 'input', 'operates' => array('is', 'is not')), 'priority' => array('type' => 'checkbox', 'options' => $prioritys), 'reason' => array('type' => 'checkbox', 'options' => $reasons), 'reporter' => array('type' => 'input', 'operates' => array('is', 'is not')), 'resolution' => array('type' => 'checkbox', 'options' => $resolutions), 'status' => array('type' => 'checkbox', 'options' => $statuses), 'updated_at' => array('type' => 'dateinput'), 'reject' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')), 'reopen' => array('type' => 'checkbox', 'options' => array('1' => 'Yes', '0' => 'No')));
     $column = array('1' => array('id' => 'owner', 'value' => 'Owner', 'check' => '1'), '2' => array('id' => 'priority', 'value' => 'Priority', 'check' => '1'), '3' => array('id' => 'component', 'value' => 'Component', 'check' => '1'), '4' => array('id' => 'pmt_id', 'value' => 'PMT ID', 'check' => '1'), '5' => array('id' => 'environment', 'value' => 'Environment', 'check' => '1'), '6' => array('id' => 'created_at', 'value' => 'Created Time', 'check' => '1'), '7' => array('id' => 'updated_at', 'value' => 'Last Updated', 'check' => '1'), '8' => array('id' => 'status', 'value' => 'Status', 'check' => '1'), '9' => array('id' => 'assigned_qa', 'value' => 'Assigned QA', 'check' => '0'), '10' => array('id' => 'reporter', 'value' => 'Reporter', 'check' => '0'), '11' => array('id' => 'resolution', 'value' => 'Resolution', 'check' => '0'), '12' => array('id' => 'reason', 'value' => 'Reason', 'check' => '0'), '13' => array('id' => 'person_liable', 'value' => 'Person Liable', 'check' => '0'), '14' => array('id' => 'is_regression', 'value' => 'Is Regression', 'check' => '0'), '15' => array('id' => 'is_occasional', 'value' => 'Is Occasional', 'check' => '0'), '16' => array('id' => 'reason_detail', 'value' => 'Reason Detail', 'check' => '0'), '17' => array('id' => 'description', 'value' => 'Description', 'check' => '0'));
     $all_users = Bll_UserBiz::get_instance()->get_all_users();
     $tmp_all = array();
     foreach ($all_users as $key => $value) {
         $tmp_all[$key] = $value->whole_name;
     }
     $all_users = json_encode($tmp_all);
     $this->fields = $fields;
     $this->request->set_attribute('users', $all_users);
     $this->request->set_attribute('fields', $fields);
     $this->request->set_attribute('column', $column);
 }