public static function &get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public function handle_request_internal() { $matches = $this->request->get_router_matches(); $userid = APF::get_instance()->get_request()->get_user_id(); $role = Bll_RoleBiz::get_instance()->get_user_role($userid); if ($role != "qa" && $role != "admin") { $status = "nopermit"; $this->request->set_attribute('status', $status); return 'NewReport_ProjectThroughRate'; } $project_id = intval($matches[1]); $this->project_id = $project_id; $tasks = Bll_PMTProjectBiz::get_instance()->get_dev_tasks_by_pmt_ids(array($project_id)); $project_infos = Bll_PMTProjectBiz::get_instance()->get_pmt_info_by_ids(array($project_id)); $rates = Bll_ReportPmtInfoBiz::get_instance()->get_through_rate_by_pmtids(array($project_id)); $delay_info = Bll_ReportPmtInfoBiz::get_instance()->get_project_delay_info_by_pmtids(array($project_id)); $rate_person = array(); foreach ($rates as $rate) { $rate_person[$rate->chinese_name] = $rate->rate; } $project_info = $project_infos[0]; $status = 'none'; $dev_users = array(); if (!empty($tasks)) { foreach ($tasks as $task) { $dev_users[$task['user']] = $task['chinese_name']; } } if ($this->request->get_parameter('act') == 'save') { $this->process_request(); $status = 'success'; } $this->request->set_attribute('status', $status); $this->request->set_attribute('project_info', $project_info); $this->request->set_attribute('dev_users', $dev_users); $this->request->set_attribute('rate_person', $rate_person); $this->request->set_attribute('delay_info', $delay_info); return 'NewReport_ProjectThroughRate'; }
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';*/ }
public function handle_request_internal() { /* * owner is me * assign_qa is me * tickets which I create * tickets which are cc to me */ $req = APF::get_instance()->get_request(); $username = $req->get_username(); $userid = $req->get_user_id(); $params = $req->get_parameters(); $wholename = Bll_UserBiz::get_instance()->get_wholename_by_username($username); if ($params['view'] == 'all') { $tickets_opened = array(); $i = 0; $tickets_accepted = array(); $j = 0; $tickets_verified = array(); $k = 0; $tickets_released = array(); $m = 0; $tickets_closed = array(); $n = 0; $type = $params['type']; if ($type == 'ownerd') { $owner_tickets = Bll_TicketBiz::get_instance()->get_owner_tickets($username); foreach ($owner_tickets as $ticket) { if ($ticket->status == 'opened') { $tickets_opened[$i] = $ticket; $i = $i + 1; } else { if ($ticket->status == 'accepted') { $tickets_accepted[$j] = $ticket; $j = $j + 1; } else { if ($ticket->status == 'verified') { $tickets_verified[$k] = $ticket; $k = $k + 1; } else { if ($ticket->status == 'released') { $tickets_released[$m] = $ticket; $m = $m + 1; } else { if ($ticket->status == 'closed') { $tickets_closed[$n] = $ticket; $n = $n + 1; } } } } } } $name = "My tickets(ownerd)"; } else { if ($type == 'assign') { $assign_qa_tickets = Bll_TicketBiz::get_instance()->get_assign_qa_tickets($username); foreach ($assign_qa_tickets as $ticket) { if ($ticket->status == 'opened') { $tickets_opened[$i] = $ticket; $i = $i + 1; } else { if ($ticket->status == 'accepted') { $tickets_accepted[$j] = $ticket; $j = $j + 1; } else { if ($ticket->status == 'verified') { $tickets_verified[$k] = $ticket; $k = $k + 1; } else { if ($ticket->status == 'released') { $tickets_released[$m] = $ticket; $m = $m + 1; } else { if ($ticket->status == 'closed') { $tickets_closed[$n] = $ticket; $n = $n + 1; } } } } } } $name = "Assigned QA tickets"; } else { if ($type == 'create') { $create_tickets = Bll_TicketBiz::get_instance()->get_create_tickets($username); foreach ($create_tickets as $ticket) { if ($ticket->status == 'opened') { $tickets_opened[$i] = $ticket; $i = $i + 1; } else { if ($ticket->status == 'accepted') { $tickets_accepted[$j] = $ticket; $j = $j + 1; } else { if ($ticket->status == 'verified') { $tickets_verified[$k] = $ticket; $k = $k + 1; } else { if ($ticket->status == 'released') { $tickets_released[$m] = $ticket; $m = $m + 1; } else { if ($ticket->status == 'closed') { $tickets_closed[$n] = $ticket; $n = $n + 1; } } } } } } $name = "My tickets(create by me)"; } else { if ($type == 'cc') { $cc_tickets = Bll_TicketBiz::get_instance()->get_cc_tickets($username); foreach ($cc_tickets as $ticket) { if ($ticket->status == 'opened') { $tickets_opened[$i] = $ticket; $i = $i + 1; } else { if ($ticket->status == 'accepted') { $tickets_accepted[$j] = $ticket; $j = $j + 1; } else { if ($ticket->status == 'verified') { $tickets_verified[$k] = $ticket; $k = $k + 1; } else { if ($ticket->status == 'released') { $tickets_released[$m] = $ticket; $m = $m + 1; } else { if ($ticket->status == 'closed') { $tickets_closed[$n] = $ticket; $n = $n + 1; } } } } } } $name = "My tickets(cc to me)"; } } } } $tickets = array(); $tickets['opened'] = $tickets_opened; $tickets['accepted'] = $tickets_accepted; $tickets['verified'] = $tickets_verified; $tickets['released'] = $tickets_released; $tickets['closed'] = $tickets_closed; $req->set_attribute('tickets', $tickets); $req->set_attribute('name', $name); return 'Home_IndexAll'; } $owner_tickets = Bll_TicketBiz::get_instance()->get_owner_tickets($username); $owner_tickets_opened = array(); $i = 0; $owner_tickets_accepted = array(); $j = 0; $owner_tickets_verified = array(); $k = 0; $owner_tickets_released = array(); $m = 0; $owner_tickets_closed = array(); if ($owner_tickets) { foreach ($owner_tickets as $ticket) { if ($ticket->status == 'opened') { $owner_tickets_opened[$i] = $ticket; $i = $i + 1; } elseif ($ticket->status == 'accepted') { $owner_tickets_accepted[$j] = $ticket; $j = $j + 1; } elseif ($ticket->status == 'verified') { $owner_tickets_verified[$k] = $ticket; $k = $k + 1; } elseif ($ticket->status == 'released') { $owner_tickets_released[$m] = $ticket; $m = $m + 1; } } } $assign_qa_tickets = Bll_TicketBiz::get_instance()->get_assign_qa_tickets($username); $assign_qa_tickets_opened = array(); $i = 0; $assign_qa_tickets_accepted = array(); $j = 0; $assign_qa_tickets_verified = array(); $k = 0; $assign_qa_tickets_released = array(); $m = 0; $assign_qa_tickets_closed = array(); if ($assign_qa_tickets) { foreach ($assign_qa_tickets as $ticket) { if ($ticket->status == 'opened') { $assign_qa_tickets_opened[$i] = $ticket; $i = $i + 1; } elseif ($ticket->status == 'accepted') { $assign_qa_tickets_accepted[$j] = $ticket; $j = $j + 1; } elseif ($ticket->status == 'verified') { $assign_qa_tickets_verified[$k] = $ticket; $k = $k + 1; } elseif ($ticket->status == 'released') { $assign_qa_tickets_released[$m] = $ticket; $m = $m + 1; } } } $create_tickets = Bll_TicketBiz::get_instance()->get_create_tickets($username); $create_tickets_opened = array(); $i = 0; $create_tickets_accepted = array(); $j = 0; $create_tickets_verified = array(); $k = 0; $create_tickets_released = array(); $m = 0; $create_tickets_closed = array(); if ($create_tickets) { foreach ($create_tickets as $ticket) { if ($ticket->status == 'opened') { $create_tickets_opened[$i] = $ticket; $i = $i + 1; } elseif ($ticket->status == 'accepted') { $create_tickets_accepted[$j] = $ticket; $j = $j + 1; } elseif ($ticket->status == 'verified') { $create_tickets_verified[$k] = $ticket; $k = $k + 1; } elseif ($ticket->status == 'released') { $create_tickets_released[$m] = $ticket; $m = $m + 1; } } } $cc_tickets = Bll_TicketBiz::get_instance()->get_cc_tickets($username); $cc_tickets_opened = array(); $i = 0; $cc_tickets_accepted = array(); $j = 0; $cc_tickets_verified = array(); $k = 0; $cc_tickets_released = array(); $m = 0; $cc_tickets_closed = array(); if ($cc_tickets) { foreach ($cc_tickets as $ticket) { if ($ticket->status == 'opened') { $cc_tickets_opened[$i] = $ticket; $i = $i + 1; } elseif ($ticket->status == 'accepted') { $cc_tickets_accepted[$j] = $ticket; $j = $j + 1; } elseif ($ticket->status == 'verified') { $cc_tickets_verified[$m] = $ticket; $m = $m + 1; } elseif ($ticket->status == 'released') { $cc_tickets_released[$n] = $ticket; $n = $n + 1; } } } $tickets = array(); $tickets['ownerd']['opened'] = $owner_tickets_opened; $tickets['ownerd']['accepted'] = $owner_tickets_accepted; $tickets['ownerd']['verified'] = $owner_tickets_verified; $tickets['ownerd']['released'] = $owner_tickets_released; $tickets['ownerd']['closed'] = $owner_tickets_closed; $tickets['assign']['opened'] = $assign_qa_tickets_opened; $tickets['assign']['accepted'] = $assign_qa_tickets_accepted; $tickets['assign']['verified'] = $assign_qa_tickets_verified; $tickets['assign']['released'] = $assign_qa_tickets_released; $tickets['assign']['closed'] = $assign_qa_tickets_closed; $tickets['create']['opened'] = $create_tickets_opened; $tickets['create']['accepted'] = $create_tickets_accepted; $tickets['create']['verified'] = $create_tickets_verified; $tickets['create']['released'] = $create_tickets_released; $tickets['create']['closed'] = $create_tickets_closed; $tickets['cc']['opened'] = $cc_tickets_opened; $tickets['cc']['accepted'] = $cc_tickets_accepted; $tickets['cc']['verified'] = $cc_tickets_verified; $tickets['cc']['released'] = $cc_tickets_released; $tickets['cc']['closed'] = $cc_tickets_closed; $role = Bll_RoleBiz::get_instance()->get_user_role($userid); $counts = array(); $counts['ownerd'] = count($tickets['ownerd']['opened']) + count($tickets['ownerd']['accepted']) + count($tickets['ownerd']['verified']) + count($tickets['ownerd']['released']); $counts['assign'] = count($tickets['assign']['opened']) + count($tickets['assign']['accepted']) + count($tickets['assign']['verified']) + count($tickets['assign']['released']); $counts['create'] = count($tickets['create']['opened']) + count($tickets['create']['accepted']) + count($tickets['create']['verified']) + count($tickets['create']['released']); $counts['cc'] = count($tickets['cc']['opened']) + count($tickets['cc']['accepted']) + count($tickets['cc']['verified']) + count($tickets['cc']['released']); foreach ($counts as $key => $count) { if ($count == 0) { $counts[$key] = ''; } } foreach ($tickets as $key => $ticket) { foreach ($ticket as $key_row => $ticket_row) { if (empty($ticket_row)) { unset($tickets[$key][$key_row]); } } } $tickets = array_filter($tickets); $time = array(); foreach ($tickets as $key => $ticket) { foreach ($ticket as $key_row => $ticket_row) { foreach ($ticket_row as $k => $r) { $time[$key][$key_row][$k]['create'] = Bll_TicketBiz::get_instance()->process_time_field($r->created_at); $time[$key][$key_row][$k]['update'] = Bll_TicketBiz::get_instance()->process_time_field($r->updated_at); } } } $req->set_attribute('tickets', $tickets); $req->set_attribute('role', $role); $req->set_attribute('counts', $counts); $req->set_attribute('time', $time); $req->set_attribute('wholename', $wholename); return 'Home_Index'; }
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'; }