// | | // | Free Software Foundation, Inc. | // | 59 Temple Place - Suite 330 | // | Boston, MA 02111-1307, USA. | // +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ // // @(#) $Id$ // include_once "config.inc.php"; include_once APP_INC_PATH . "class.template.php"; include_once APP_INC_PATH . "class.auth.php"; include_once APP_INC_PATH . "class.time_tracking.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("add_time_tracking.tpl.html"); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $issue_id = @$HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : $HTTP_GET_VARS["iss_id"]; if (!Issue::canAccess($issue_id, Auth::getUserID())) { $tpl = new Template_API(); $tpl->setTemplate("permission_denied.tpl.html"); $tpl->displayTemplate(); exit; } if (@$HTTP_POST_VARS["cat"] == "add_time") { $res = Time_Tracking::insertEntry(); $tpl->assign("time_add_result", $res); } $tpl->assign(array("issue_id" => $issue_id, "time_categories" => Time_Tracking::getAssocCategories(), "current_user_prefs" => Prefs::get(Auth::getUserID()))); $tpl->displayTemplate();
function recordTimeWorked($p) { $email = XML_RPC_decode($p->getParam(0)); $password = XML_RPC_decode($p->getParam(1)); $auth = authenticate($email, $password); if (is_object($auth)) { return $auth; } $issue_id = XML_RPC_decode($p->getParam(2)); $cat_id = XML_RPC_decode($p->getParam(3)); $summary = XML_RPC_decode($p->getParam(4)); $time_spent = XML_RPC_decode($p->getParam(5)); $usr_id = User::getUserIDByEmail($email); $res = Time_Tracking::recordRemoteEntry($issue_id, $usr_id, $cat_id, $summary, $time_spent); if ($res == -1) { return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Could not record the time tracking entry"); } else { return new XML_RPC_Response(XML_RPC_Encode('OK')); } }
} elseif (@$HTTP_POST_VARS["cat"] == "save_draft") { $res = Draft::saveEmail($issue_id, $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $HTTP_POST_VARS["parent_id"]); $tpl->assign("draft_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_draft") { $res = Draft::update($issue_id, $HTTP_POST_VARS["draft_id"], $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $HTTP_POST_VARS["parent_id"]); $tpl->assign("draft_result", $res); } elseif (Auth::getCurrentRole() >= User::getRoleID('Developer')) { $res = Issue::addUserAssociation($usr_id, $issue_id, $usr_id); } // enter the time tracking entry about this new email if (@$HTTP_POST_VARS["cat"] == "save_draft" || @$HTTP_POST_VARS["cat"] == "update_draft") { if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['issue_id'] = $issue_id; $HTTP_POST_VARS['category'] = Time_Tracking::getCategoryID('Email Discussion'); $HTTP_POST_VARS['summary'] = 'Time entry inserted when saving an email draft.'; Time_Tracking::insertEntry(); } } if (@$HTTP_GET_VARS['cat'] == 'view_draft') { $draft = Draft::getDetails($HTTP_GET_VARS['id']); $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc'])); // try to guess the correct email account to be associated with this email if (!empty($draft['emd_sup_id'])) { $HTTP_GET_VARS['ema_id'] = Email_Account::getAccountByEmail($draft['emd_sup_id']); } else { // if we are not replying to an existing message, just get the first email account you can find... $HTTP_GET_VARS['ema_id'] = Email_Account::getEmailAccount(); } $tpl->bulkAssign(array("draft_id" => $HTTP_GET_VARS['id'], "email" => $email, "parent_email_id" => $draft['emd_sup_id'], "draft_status" => $draft['emd_status'])); if ($draft['emd_status'] != 'pending') { $tpl->assign("read_only", 1);
/** * Method used to add a new project to the system. * * @return integer 1 if the update worked, -1 or -2 otherwise */ public static function insert() { if (Validation::isWhitespace($_POST['title'])) { return -2; } $stmt = 'INSERT INTO {{%project}} ( prj_created_date, prj_title, prj_status, prj_lead_usr_id, prj_initial_sta_id, prj_outgoing_sender_name, prj_outgoing_sender_email, prj_mail_aliases, prj_remote_invocation, prj_customer_backend, prj_workflow_backend ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )'; try { DB_Helper::getInstance()->query($stmt, array(Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['status'], $_POST['lead_usr_id'], $_POST['initial_status'], $_POST['outgoing_sender_name'], $_POST['outgoing_sender_email'], $_POST['mail_aliases'], $_POST['remote_invocation'], $_POST['customer_backend'], $_POST['workflow_backend'])); } catch (DbException $e) { return -1; } $new_prj_id = DB_Helper::get_last_insert_id(); foreach ($_POST['users'] as $user) { if ($user == $_POST['lead_usr_id']) { $role_id = User::getRoleID('Manager'); } else { $role_id = User::getRoleID('Standard User'); } self::associateUser($new_prj_id, $user, $role_id); } foreach ($_POST['statuses'] as $sta_id) { Status::addProjectAssociation($sta_id, $new_prj_id); } Display_Column::setupNewProject($new_prj_id); // insert default timetracking categories Time_Tracking::addProjectDefaults($new_prj_id); return 1; }
/** * Method used to remove all issues associated with a specific list of * projects. * * XXX: this is dangerous, maybe remove such methods? * * @param array $ids The list of projects to look for * @return boolean */ public static function removeByProjects($ids) { $stmt = 'SELECT iss_id FROM {{%issue}} WHERE iss_prj_id IN (' . DB_Helper::buildList($ids) . ')'; try { $res = DB_Helper::getInstance()->getColumn($stmt, $ids); } catch (DbException $e) { return false; } if (count($res) > 0) { self::deleteAssociations($res); Attachment::removeByIssues($res); SCM::removeByIssues($res); Impact_Analysis::removeByIssues($res); self::deleteUserAssociations($res); Note::removeByIssues($res); Time_Tracking::removeTimeEntriesByIssues($res); Notification::removeByIssues($res); Custom_Field::removeByIssues($res); Phone_Support::removeByIssues($res); History::removeByIssues($res); // now really delete the issues $items = implode(', ', $res); $stmt = "DELETE FROM\n {{%issue}}\n WHERE\n iss_id IN ({$items})"; DB_Helper::getInstance()->query($stmt); } return true; }
/** * Returns the data used by the weekly report. * * @param string $usr_id The ID of the user this report is for. * @param int $prj_id The project id * @param string|DateTime $start The start date of this report. * @param string|DateTime $end The end date of this report. * @param array $options extra options for report: * - $separate_closed If closed issues should be separated from other issues. * - $ignore_statuses If issue status changes should be ignored in report. * - $separate_not_assigned_to_user Separate Issues Not Assigned to User * - $show_per_issue Add time spent on issue to issues * - $separate_no_time Separate No time spent issues * @return array An array of data containing all the elements of the weekly report. */ public static function getWeeklyReport($usr_id, $prj_id, $start, $end, $options = array()) { // figure out timezone $user_prefs = Prefs::get($usr_id); $tz = $user_prefs['timezone']; // if start or end is string, convert assume min and max date are specified if (!$start instanceof DateTime) { $start = Date_Helper::getDateTime($start, $tz)->setTime(0, 0, 0); } if (!$end instanceof DateTime) { $end = Date_Helper::getDateTime($end, $tz)->setTime(23, 59, 59); } $start_ts = Date_Helper::getSqlDateTime($start); $end_ts = Date_Helper::getSqlDateTime($end); $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $prj_id, $start_ts, $end_ts); // replace spaces in index with _ and calculate total time $total_time = 0; foreach ($time_tracking as $category => $data) { unset($time_tracking[$category]); $time_tracking[str_replace(' ', '_', $category)] = $data; $total_time += $data['total_time']; } // get count of issues assigned in week of report. $stmt = 'SELECT COUNT(*) FROM {{%issue}}, {{%issue_user}}, {{%status}} WHERE iss_id = isu_iss_id AND iss_sta_id = sta_id AND isu_usr_id = ? AND iss_prj_id = ? AND isu_assigned_date BETWEEN ? AND ?'; $params = array($usr_id, Auth::getCurrentProject(), $start_ts, $end_ts); try { $newly_assigned = DB_Helper::getInstance()->getOne($stmt, $params); } catch (DbException $e) { $newly_assigned = null; } $email_count = array('associated' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), 'other' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false)); $htt_exclude = array(); if (!empty($options['ignore_statuses'])) { $htt_exclude[] = 'status_changed'; $htt_exclude[] = 'status_auto_changed'; $htt_exclude[] = 'remote_status_change'; } $issue_list = History::getTouchedIssuesByUser($usr_id, $prj_id, $start_ts, $end_ts, $htt_exclude); $issues = array('no_time' => array(), 'not_mine' => array(), 'closed' => array(), 'other' => array()); // organize issues into categories if ($issue_list) { if (!empty($options['show_per_issue']) || !empty($options['separate_no_time'])) { Time_Tracking::fillTimeSpentByIssueAndTime($issue_list, $usr_id, $start_ts, $end_ts); } foreach ($issue_list as $row) { if (!empty($row['iss_customer_id']) && CRM::hasCustomerIntegration($row['iss_prj_id'])) { $row['customer_name'] = CRM::getCustomerName($row['iss_prj_id'], $row['iss_customer_id']); } else { $row['customer_name'] = null; } if (!empty($options['separate_closed']) && $row['sta_is_closed'] == 1) { $issues['closed'][] = $row; } elseif (!empty($options['separate_not_assigned_to_user']) && !Issue::isAssignedToUser($row['iss_id'], $usr_id)) { $issues['not_mine'][] = $row; } elseif (!empty($options['separate_no_time']) && empty($row['it_spent'])) { $issues['no_time'][] = $row; } else { $issues['other'][] = $row; } } $sort_function = function ($a, $b) { return strcasecmp($a['customer_name'], $b['customer_name']); }; usort($issues['closed'], $sort_function); usort($issues['other'], $sort_function); } return array('start' => $start_ts, 'end' => $end_ts, 'user' => User::getDetails($usr_id), 'group_name' => Group::getName(User::getGroupID($usr_id)), 'issues' => $issues, 'status_counts' => History::getTouchedIssueCountByStatus($usr_id, $prj_id, $start_ts, $end_ts), 'new_assigned_count' => $newly_assigned, 'time_tracking' => $time_tracking, 'email_count' => $email_count, 'phone_count' => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), 'note_count' => Note::getCountByUser($usr_id, $start_ts, $end_ts), 'total_time' => Misc::getFormattedTime($total_time, false)); }
/** * Returns the data used by the weekly report. * * @access public * @param string $usr_id The ID of the user this report is for. * @param string The start date of this report. * @param string The end date of this report. * @param boolean If closed issues should be separated from other issues. * @return array An array of data containing all the elements of the weekly report. */ function getWeeklyReport($usr_id, $start, $end, $separate_closed = false) { $usr_id = Misc::escapeInteger($usr_id); // figure out timezone $user_prefs = Prefs::get($usr_id); $tz = @$user_prefs["timezone"]; $start_dt = new Date(); $end_dt = new Date(); // set timezone to that of user. $start_dt->setTZById($tz); $end_dt->setTZById($tz); // set the dates in the users time zone $start_dt->setDate($start . " 00:00:00"); $end_dt->setDate($end . " 23:59:59"); // convert time to GMT $start_dt->toUTC(); $end_dt->toUTC(); $start_ts = $start_dt->getDate(); $end_ts = $end_dt->getDate(); $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $start_ts, $end_ts); // replace spaces in index with _ and calculate total time $total_time = 0; foreach ($time_tracking as $category => $data) { unset($time_tracking[$category]); $time_tracking[str_replace(" ", "_", $category)] = $data; $total_time += $data["total_time"]; } // get count of issues assigned in week of report. $stmt = "SELECT\n COUNT(*)\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n WHERE\n iss_id = isu_iss_id AND\n iss_sta_id = sta_id AND\n isu_usr_id = {$usr_id} AND\n isu_assigned_date BETWEEN '{$start_ts}' AND '{$end_ts}'"; $newly_assigned = $GLOBALS["db_api"]->dbh->getOne($stmt); if (PEAR::isError($newly_assigned)) { Error_Handler::logError(array($newly_assigned->getMessage(), $newly_assigned->getDebugInfo()), __FILE__, __LINE__); } $email_count = array("associated" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), "other" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false)); $data = array("start" => str_replace('-', '.', $start), "end" => str_replace('-', '.', $end), "user" => User::getDetails($usr_id), "group_name" => Group::getName(User::getGroupID($usr_id)), "issues" => History::getTouchedIssuesByUser($usr_id, $start_ts, $end_ts, $separate_closed), "status_counts" => History::getTouchedIssueCountByStatus($usr_id, $start_ts, $end_ts), "new_assigned_count" => $newly_assigned, "time_tracking" => $time_tracking, "email_count" => $email_count, "phone_count" => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), "note_count" => Note::getCountByUser($usr_id, $start_ts, $end_ts), "total_time" => Misc::getFormattedTime($total_time, false)); return $data; }
/** * @param int $issue_id * @param int $cat_id * @param string $summary * @param int $time_spent * @return string * @access protected * @since 3.0.2 checks access via Issue::canUpdate */ public function recordTimeWorked($issue_id, $cat_id, $summary, $time_spent) { $usr_id = Auth::getUserID(); if (!Issue::canUpdate($issue_id, $usr_id)) { throw new RemoteApiException("No access to issue #{$issue_id}"); } $res = Time_Tracking::recordRemoteTimeEntry($issue_id, $usr_id, $cat_id, $summary, $time_spent); if ($res == -1) { throw new RemoteApiException('Could not record the time tracking entry'); } return 'OK'; }
/** * Returns information from time tracking module, split by category * * @access private * @return array Array of counts. */ function getTimeTracking() { $time = array(); // get total stats $time[0] = $this->getIndividualTimeTracking(); $time[0]["name"] = "Total"; $this->time_tracking_categories[0] = "Total"; // get categories $categories = Time_Tracking::getAssocCategories(); foreach ($categories as $ttc_id => $category) { $individual = $this->getIndividualTimeTracking($ttc_id); if (count($individual) > 0) { $time[$ttc_id] = $individual; $time[$ttc_id]["name"] = $category; $this->time_tracking_categories[$ttc_id] = $category; } } return $time; }
$show_category = 0; } $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE); if (!empty($auto_switched_from)) { $tpl->assign(array("project_auto_switched" => 1, "old_project" => Project::getName($auto_switched_from))); } $setup = Setup::load(); $tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]); $tpl->assign(array('next_issue' => @$sides['next'], 'previous_issue' => @$sides['previous'], 'subscribers' => Notification::getSubscribers($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id), 'files' => Attachment::getList($issue_id), 'emails' => Support::getEmailsByIssue($issue_id), 'zones' => Date_API::getTimezoneList(), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'ema_id' => Email_Account::getEmailAccount(), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'show_releases' => $show_releases, 'show_category' => $show_category, 'categories' => Category::getAssocList($prj_id), 'quarantine' => Issue::getQuarantineInfo($issue_id))); if ($role_id != User::getRoleID('customer')) { if (@$_REQUEST['show_all_drafts'] == 1) { $show_all_drafts = true; } else { $show_all_drafts = false; } if (Workflow::hasWorkflowIntegration($prj_id)) { $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id); // if currently selected release is not on list, go ahead and add it. } else { $statuses = Status::getAssocStatusList($prj_id); } if (!empty($details['iss_sta_id']) && empty($statuses[$details['iss_sta_id']])) { $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']); } $time_entries = Time_Tracking::getListing($issue_id); $tpl->assign(array('notes' => Note::getListing($issue_id), 'is_user_assigned' => Issue::isAssignedToUser($issue_id, $usr_id), 'is_user_authorized' => Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id), 'phone_entries' => Phone_Support::getListing($issue_id), 'phone_categories' => Phone_Support::getCategoryAssocList($prj_id), 'checkins' => SCM::getCheckinList($issue_id), 'time_categories' => Time_Tracking::getAssocCategories(), 'time_entries' => $time_entries['list'], 'total_time_spent' => $time_entries['total_time_spent'], 'impacts' => Impact_Analysis::getListing($issue_id), 'statuses' => $statuses, 'drafts' => Draft::getList($issue_id, $show_all_drafts), 'groups' => Group::getAssocList($prj_id))); } } } } $tpl->displayTemplate();
/** * Method used to remove a specific phone support entry from the * application. * * @param integer $phone_id The phone support entry ID * @return integer 1 if the removal worked, -1 or -2 otherwise */ public static function remove($phone_id) { $stmt = 'SELECT phs_iss_id, phs_ttr_id, phs_usr_id FROM {{%phone_support}} WHERE phs_id=?'; $details = DB_Helper::getInstance()->getRow($stmt, array($phone_id)); if ($details['phs_usr_id'] != Auth::getUserID()) { return -2; } $stmt = 'DELETE FROM {{%phone_support}} WHERE phs_id=?'; try { DB_Helper::getInstance()->query($stmt, array($phone_id)); } catch (DbException $e) { return -1; } Issue::markAsUpdated($details['phs_iss_id']); $usr_id = Auth::getUserID(); History::add($details['phs_iss_id'], $usr_id, 'phone_entry_removed', 'Phone Support entry removed by {user}', array('user' => User::getFullName($usr_id))); if (!empty($details['phs_ttr_id'])) { $time_result = Time_Tracking::removeTimeEntry($details['phs_ttr_id'], $details['phs_usr_id']); if ($time_result == 1) { return 2; } return $time_result; } return 1; }
include_once APP_INC_PATH . "class.notification.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("close.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $prj_id = Auth::getCurrentProject(); $issue_id = @$HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : $HTTP_GET_VARS["id"]; $tpl->assign("extra_title", "Close Issue #{$issue_id}"); $notification_list = Notification::getSubscribers($issue_id, 'closed'); $tpl->assign("notification_list_all", $notification_list['all']); $notification_list_internal = Notification::getSubscribers($issue_id, 'closed', User::getRoleID("standard User")); $tpl->assign("notification_list_internal", $notification_list_internal['all']); if (@$HTTP_POST_VARS["cat"] == "close") { $res = Issue::close(Auth::getUserID(), $HTTP_POST_VARS["issue_id"], $HTTP_POST_VARS["send_notification"], $HTTP_POST_VARS["resolution"], $HTTP_POST_VARS["status"], $HTTP_POST_VARS["reason"], @$_REQUEST['notification_list']); if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['summary'] = 'Time entry inserted when closing issue.'; Time_Tracking::insertEntry(); } if (Customer::hasCustomerIntegration($prj_id) && Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($issue_id))) { Customer::updateRedeemedIncidents($prj_id, $issue_id, @$_REQUEST['redeem']); } $tpl->assign("close_result", $res); } $tpl->assign("statuses", Status::getClosedAssocList($prj_id)); $tpl->assign("resolutions", Resolution::getAssocList()); $tpl->assign("time_categories", Time_Tracking::getAssocCategories()); if (Customer::hasCustomerIntegration($prj_id) && Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($issue_id))) { $details = Issue::getDetails($issue_id); $tpl->assign(array('redeemed' => Customer::getRedeemedIncidentDetails($prj_id, $issue_id), 'incident_details' => $details['customer_info']['incident_details'])); } $tpl->displayTemplate();
/** * Method used to get the list of issues to be displayed in the grid layout. * * @access public * @param integer $prj_id The current project ID * @param array $options The search parameters * @param integer $current_row The current page number * @param integer $max The maximum number of rows per page * @return array The list of issues to be displayed */ function getListing($prj_id, $options, $current_row = 0, $max = 5, $get_reporter = FALSE) { if (strtoupper($max) == "ALL") { $max = 9999999; } $start = $current_row * $max; // get the current user's role $usr_id = Auth::getUserID(); $role_id = User::getRoleByUser($usr_id, $prj_id); // get any custom fields that should be displayed $custom_fields = Custom_Field::getFieldsToBeListed($prj_id); $stmt = "SELECT\n iss_id,\n iss_grp_id,\n iss_prj_id,\n iss_sta_id,\n iss_customer_id,\n iss_created_date,\n iss_updated_date,\n iss_last_response_date,\n iss_closed_date,\n iss_last_customer_action_date,\n iss_usr_id,\n iss_summary,\n pri_title,\n prc_title,\n sta_title,\n sta_color status_color,\n sta_id,\n iqu_status,\n grp_name `group`,\n pre_title,\n iss_last_public_action_date,\n iss_last_public_action_type,\n iss_last_internal_action_date,\n iss_last_internal_action_type,\n " . Issue::getLastActionFields() . ",\n IF(iss_last_internal_action_date > iss_last_public_action_date, 'internal', 'public') AS action_type,\n iss_private,\n CONCAT(en_firstname,' ', en_lastname) as usr_full_name,\n iss_percent_complete,\n iss_dev_time,\n iss_expected_resolution_date\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . ETEL_USER_TABLE_NOSUB . ""; // join custom fields if we are searching by custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) { continue; } if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeInteger($search_value); foreach ($search_value as $cfo_id) { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . '_' . $cfo_id . "\n"; } } else { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . "\n"; } } } $stmt .= ")"; // check for the custom fields we want to sort by if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_id = str_replace("custom_field_", '', $options['sort_by']); $stmt .= "\n LEFT JOIN \n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf_sort\n ON\n (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n"; } // START ETEL MODIFIED if (!empty($options["show_authorized_issues"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters($prj_id)) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier\n ON\n iur_iss_id=iss_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id"; } else { if (!empty($options["users"])) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id"; } } // END ETEL MODIFIED if (!empty($options["show_notification_list_issues"])) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription\n ON\n sub_iss_id=iss_id"; } $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`\n ON\n iss_grp_id=grp_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category\n ON\n iss_prc_id=prc_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release\n ON\n iss_pre_id = pre_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n ON\n iss_pri_id=pri_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n ON\n iss_id=iqu_iss_id AND\n (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n WHERE\n iss_prj_id= " . Misc::escapeInteger($prj_id); $stmt .= Issue::buildWhereClause($options); //echo $stmt; if (strstr($options["sort_by"], 'custom_field') !== false) { $sort_by = 'cf_sort.icf_value'; } else { $sort_by = Misc::escapeString($options["sort_by"]); } $stmt .= "\n GROUP BY\n iss_id\n ORDER BY\n " . $sort_by . " " . Misc::escapeString($options["sort_order"]) . ",\n iss_id DESC"; $total_rows = Pager::getTotalRows($stmt); if ($max > 100) { $max = 100; } $stmt .= "\n LIMIT\n " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max); $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); // echo $stmt; if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return array("list" => "", "info" => ""); } else { if (count($res) > 0) { if ($get_reporter) { Issue::getReportersByIssues($res); } Issue::getAssignedUsersByIssues($res); Time_Tracking::getTimeSpentByIssues($res); // need to get the customer titles for all of these issues... if (Customer::hasCustomerIntegration($prj_id)) { Customer::getCustomerTitlesByIssues($prj_id, $res); } Issue::formatLastActionDates($res); Issue::getLastStatusChangeDates($prj_id, $res); } elseif ($current_row > 0) { // if there are no results, and the page is not the first page reset page to one and reload results Auth::redirect(APP_RELATIVE_URL . "list.php?pagerRow=0&rows={$max}"); } $groups = Group::getAssocList($prj_id); $categories = Category::getAssocList($prj_id); $column_headings = Issue::getColumnHeadings($prj_id); if (count($custom_fields) > 0) { $column_headings = array_merge($column_headings, $custom_fields); } $csv[] = @implode("\t", $column_headings); for ($i = 0; $i < count($res); $i++) { $res[$i]["time_spent"] = Misc::getFormattedTime($res[$i]["time_spent"]); $res[$i]["iss_expected_resolution_date"] = Date_API::getSimpleDate($res[$i]["iss_expected_resolution_date"], false); $fields = array($res[$i]['pri_title'], $res[$i]['iss_id']); // hide the group column from the output if no // groups are available in the database if (count($groups) > 0) { $fields[] = $res[$i]['group']; } $fields[] = $res[$i]['assigned_users']; $fields[] = $res[$i]['time_spent']; // hide the category column from the output if no // categories are available in the database if (count($categories) > 0) { $fields[] = $res[$i]['prc_title']; } if (Customer::hasCustomerIntegration($prj_id)) { $fields[] = @$res[$i]['customer_title']; // check if current user is acustomer and has a per incident contract. // if so, check if issue is redeemed. if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) { if (Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) && Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])) { $res[$i]['redeemed'] = true; } } } $fields[] = $res[$i]['sta_title']; $fields[] = $res[$i]["status_change_date"]; $fields[] = $res[$i]["last_action_date"]; $fields[] = $res[$i]['iss_summary']; if (count($custom_fields) > 0) { $res[$i]['custom_field'] = array(); $custom_field_values = Custom_Field::getListByIssue($prj_id, $res[$i]['iss_id']); foreach ($custom_field_values as $this_field) { if (!empty($custom_fields[$this_field['fld_id']])) { $res[$i]['custom_field'][$this_field['fld_id']] = $this_field['icf_value']; $fields[] = $this_field['icf_value']; } } } $csv[] = @implode("\t", $fields); } $total_pages = ceil($total_rows / $max); $last_page = $total_pages - 1; return array("list" => $res, "info" => array("current_page" => $current_row, "start_offset" => $start, "end_offset" => $start + count($res), "total_rows" => $total_rows, "total_pages" => $total_pages, "previous_page" => $current_row == 0 ? "-1" : $current_row - 1, "next_page" => $current_row == $last_page ? "-1" : $current_row + 1, "last_page" => $last_page, "custom_fields" => $custom_fields), "csv" => @implode("\n", $csv)); } }
} } elseif ($cat == 'save_draft') { $res = Draft::saveEmail($issue_id, $_POST['to'], $_POST['cc'], $_POST['subject'], $_POST['message'], $_POST['parent_id']); $tpl->assign('draft_result', $res); } elseif ($cat == 'update_draft') { $res = Draft::update($issue_id, $_POST['draft_id'], $_POST['to'], $_POST['cc'], $_POST['subject'], $_POST['message'], $_POST['parent_id']); $tpl->assign('draft_result', $res); } // enter the time tracking entry about this new email if ($cat == 'save_draft' || $cat == 'update_draft') { if (!empty($_POST['time_spent'])) { $date = (array) $_POST['date']; $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Email Discussion'); $time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when saving an email draft.'; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } } if ($cat == 'view_draft') { $draft = Draft::getDetails($_GET['id']); $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc'])); // try to guess the correct email account to be associated with this email if (!empty($draft['emd_sup_id'])) { $_GET['ema_id'] = Email_Account::getAccountByEmail($draft['emd_sup_id']); } else { // if we are not replying to an existing message, just get the first email account you can find... $_GET['ema_id'] = Email_Account::getEmailAccount(); } $tpl->assign(array('draft_id' => $_GET['id'], 'email' => $email, 'parent_email_id' => $draft['emd_sup_id'], 'draft_status' => $draft['emd_status'])); if ($draft['emd_status'] != 'pending') { $tpl->assign('read_only', 1);
include_once APP_INC_PATH . "class.phone_support.php"; include_once APP_INC_PATH . "class.status.php"; include_once APP_INC_PATH . "class.history.php"; include_once APP_INC_PATH . "class.user.php"; include_once APP_INC_PATH . "class.authorized_replier.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("popup.tpl.html"); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $usr_id = Auth::getUserID(); $prj_id = Auth::getCurrentProject(); if (@$HTTP_GET_VARS["cat"] == "delete_note") { $res = Note::remove($HTTP_GET_VARS["id"]); $tpl->assign("note_delete_result", $res); } elseif (@$HTTP_GET_VARS["cat"] == "delete_time") { $res = Time_Tracking::removeEntry($HTTP_GET_VARS["id"], $usr_id); $tpl->assign("time_delete_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "bulk_update") { $res = Issue::bulkUpdate(); $tpl->assign("bulk_update_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "set_initial_impact") { $res = Issue::setImpactAnalysis($HTTP_POST_VARS["issue_id"]); $tpl->assign("set_initial_impact_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "add_requirement") { $res = Impact_Analysis::insert($HTTP_POST_VARS["issue_id"]); $tpl->assign("add_requirement_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "set_impact_requirement") { $res = Impact_Analysis::update($HTTP_POST_VARS["isr_id"]); $tpl->assign("set_impact_requirement_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "delete_requirement") { $res = Impact_Analysis::remove();
/** * Method used to get the list of issues to be displayed in the grid layout. * * @param integer $prj_id The current project ID * @param array $options The search parameters * @param integer $current_row The current page number * @param integer $max The maximum number of rows per page. 'ALL' for unlimited. * @return array The list of issues to be displayed */ public static function getListing($prj_id, $options, $current_row = 0, $max = 5) { if (strtoupper($max) == 'ALL') { $max = 9999999; } $start = $current_row * $max; // get the current user's role $usr_id = Auth::getUserID(); $role_id = User::getRoleByUser($usr_id, $prj_id); $usr_details = User::getDetails($usr_id); // get any custom fields that should be displayed $custom_fields = Custom_Field::getFieldsToBeListed($prj_id); $stmt = 'SELECT iss_id, iss_grp_id, iss_prj_id, iss_sta_id, iss_customer_id, iss_customer_contract_id, iss_created_date, iss_updated_date, iss_last_response_date, iss_closed_date, iss_last_customer_action_date, iss_usr_id, iss_summary, pri_title, prc_title, sta_title, sta_color status_color, sta_id, iqu_status, grp_name, pre_title, iss_last_public_action_date, iss_last_public_action_type, iss_last_internal_action_date, iss_last_internal_action_type, ' . Issue::getLastActionFields() . ",\n CASE WHEN iss_last_internal_action_date > iss_last_public_action_date THEN 'internal' ELSE 'public' END AS action_type,\n iss_private,\n usr_full_name,\n iss_percent_complete,\n iss_dev_time,\n iss_expected_resolution_date,\n sev_title\n FROM\n (\n {{%issue}},\n {{%user}}"; // join custom fields if we are searching by custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) { continue; } if ($field['fld_type'] == 'integer' && empty($search_value['value'])) { continue; } if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeString($search_value); foreach ($search_value as $cfo_id) { $stmt .= ",\n{{%issue_custom_field}} as cf" . $fld_id . '_' . $cfo_id . "\n"; } } else { $stmt .= ",\n{{%issue_custom_field}} as cf" . $fld_id . "\n"; } } } $stmt .= ')'; // check for the custom fields we want to sort by if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_id = str_replace('custom_field_', '', $options['sort_by']); $stmt .= "\n LEFT JOIN \n\n {{%issue_custom_field}} as cf_sort\n ON\n (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n"; } if (!empty($options['users']) || $options['sort_by'] === 'isu_usr_id') { $stmt .= ' LEFT JOIN {{%issue_user}} ON isu_iss_id=iss_id'; } if (!empty($usr_details['usr_par_code'])) { // restrict partners $stmt .= ' LEFT JOIN {{%issue_partner}} ON ipa_iss_id=iss_id'; } if (!empty($options['show_authorized_issues']) || $role_id == User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) { $stmt .= ' LEFT JOIN {{%issue_user_replier}} ON iur_iss_id=iss_id'; } if (!empty($options['show_notification_list_issues'])) { $stmt .= ' LEFT JOIN {{%subscription}} ON sub_iss_id=iss_id'; } if (!empty($options['product'])) { $stmt .= ' LEFT JOIN {{%issue_product_version}} ON ipv_iss_id=iss_id'; } $stmt .= "\n LEFT JOIN\n {{%group}}\n ON\n iss_grp_id=grp_id\n LEFT JOIN\n {{%project_category}}\n ON\n iss_prc_id=prc_id\n LEFT JOIN\n {{%project_release}}\n ON\n iss_pre_id = pre_id\n LEFT JOIN\n {{%status}}\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n {{%project_priority}}\n ON\n iss_pri_id=pri_id\n LEFT JOIN\n {{%project_severity}}\n ON\n iss_sev_id=sev_id\n LEFT JOIN\n {{%issue_quarantine}}\n ON\n iss_id=iqu_iss_id AND\n (iqu_expiration > '" . Date_Helper::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n WHERE\n iss_prj_id= " . Misc::escapeInteger($prj_id); $stmt .= self::buildWhereClause($options); if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_details = Custom_Field::getDetails($fld_id); $sort_by = 'cf_sort.' . Custom_Field::getDBValueFieldNameByType($fld_details['fld_type']); } else { $sort_by = Misc::escapeString($options['sort_by']); } $stmt .= ' GROUP BY iss_id ORDER BY ' . $sort_by . ' ' . Misc::escapeString($options['sort_order']) . ', iss_id DESC'; $total_rows = Pager::getTotalRows($stmt); $stmt .= ' LIMIT ' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start); try { $res = DB_Helper::getInstance()->getAll($stmt); } catch (DbException $e) { return array('list' => null, 'info' => null, 'csv' => null); } if (count($res) > 0) { Issue::getAssignedUsersByIssues($res); Time_Tracking::fillTimeSpentByIssues($res); // need to get the customer titles for all of these issues... if (CRM::hasCustomerIntegration($prj_id)) { $crm = CRM::getInstance($prj_id); $crm->processListIssuesResult($res); } Issue::formatLastActionDates($res); Issue::getLastStatusChangeDates($prj_id, $res); } elseif ($current_row > 0) { // if there are no results, and the page is not the first page reset page to one and reload results Auth::redirect("list.php?pagerRow=0&rows={$max}"); } $groups = Group::getAssocList($prj_id); $categories = Category::getAssocList($prj_id); $column_headings = array(); $columns_to_display = Display_Column::getColumnsToDisplay($prj_id, 'list_issues'); foreach ($columns_to_display as $col_key => $column) { if ($col_key == 'custom_fields' && count($custom_fields) > 0) { foreach ($custom_fields as $fld_id => $fld_title) { $column_headings['cstm_' . $fld_id] = $fld_title; } } else { $column_headings[$col_key] = $column['title']; } } $csv[] = @implode("\t", $column_headings); if (@$options['hide_excerpts'] != 1 && self::doesBackendSupportExcerpts() == true) { $excerpts = self::getFullTextExcerpts(); } foreach ($res as &$row) { $issue_id = $row['iss_id']; $row['time_spent'] = Misc::getFormattedTime($row['time_spent']); $row['iss_created_date'] = Date_Helper::getFormattedDate($row['iss_created_date']); $row['iss_expected_resolution_date'] = Date_Helper::getSimpleDate($row['iss_expected_resolution_date'], false); $row['excerpts'] = isset($excerpts[$issue_id]) ? $excerpts[$issue_id] : ''; $fields = array(); foreach (array_keys($columns_to_display) as $col_key) { switch ($col_key) { case 'pri_rank': $col_key = 'pri_title'; break; case 'assigned': $col_key = 'assigned_users'; break; case 'sta_rank': $col_key = 'sta_title'; break; case 'sta_change_date': $col_key = 'status_change_date'; break; case 'sev_rank': $col_key = 'sev_title'; break; } if ($col_key == 'custom_fields' && count($custom_fields) > 0) { $custom_field_values = Custom_Field::getListByIssue($prj_id, $row['iss_id']); foreach ($custom_field_values as $this_field) { if (!empty($custom_fields[$this_field['fld_id']])) { $row['custom_field'][$this_field['fld_id']] = $this_field['value']; $fields[] = $this_field['value']; } } } else { $fields[] = isset($row[$col_key]) ? $row[$col_key] : ''; } } if (CRM::hasCustomerIntegration($prj_id)) { // check if current user is a customer and has a per incident contract. // if so, check if issue is redeemed. if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) { // TODOCRM: Fix per incident usage // if ((Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) && // (Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])))) { // $res[$i]['redeemed'] = true; // } } } $csv[] = @implode("\t", $fields); } $total_pages = ceil($total_rows / $max); $last_page = $total_pages - 1; return array('list' => $res, 'info' => array('current_page' => $current_row, 'start_offset' => $start, 'end_offset' => $start + count($res), 'total_rows' => $total_rows, 'total_pages' => $total_pages, 'previous_page' => $current_row == 0 ? '-1' : $current_row - 1, 'next_page' => $current_row == $last_page ? '-1' : $current_row + 1, 'last_page' => $last_page, 'custom_fields' => $custom_fields), 'csv' => @implode("\n", $csv)); }
$time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when closing issue.'; Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary); } if (CRM::hasCustomerIntegration($prj_id) && isset($details['contract'])) { $crm = CRM::getInstance($prj_id); $contract = $details['contract']; if ($contract->hasPerIncident()) { $contract->updateRedeemedIncidents($issue_id, @$_REQUEST['redeem']); } } $tpl->assign('close_result', $res); if ($res == 1) { Misc::setMessage(ev_gettext('Thank you, the issue was closed successfully')); Misc::displayNotifiedUsers(Notification::getLastNotifiedAddresses($issue_id)); Auth::redirect(APP_RELATIVE_URL . 'view.php?id=' . $issue_id); } } $tpl->assign(array('statuses' => Status::getClosedAssocList($prj_id), 'resolutions' => Resolution::getAssocList(), 'time_categories' => Time_Tracking::getAssocCategories($prj_id), 'notify_list' => Notification::getLastNotifiedAddresses($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id, $usr_id, 'close_form'), 'issue_id' => $issue_id)); if (CRM::hasCustomerIntegration($prj_id) && isset($details['contract'])) { $crm = CRM::getInstance($prj_id); $contract = $details['contract']; if ($contract->hasPerIncident()) { $details = Issue::getDetails($issue_id); $tpl->assign(array('redeemed' => $contract->getRedeemedIncidentDetails($issue_id), 'incident_details' => $details['customer']['incident_details'])); } } $usr_id = Auth::getUserID(); $user_prefs = Prefs::get($usr_id); $tpl->assign('current_user_prefs', $user_prefs); $tpl->displayTemplate();
$tpl = new Template_Helper(); $tpl->setTemplate('popup.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $usr_id = Auth::getUserID(); $prj_id = Auth::getCurrentProject(); $iss_id = isset($_GET['iss_id']) ? (int) $_GET['iss_id'] : (isset($_POST['issue_id']) ? (int) $_POST['issue_id'] : null); $cat = isset($_GET['cat']) ? (string) $_GET['cat'] : (isset($_POST['cat']) ? (string) $_POST['cat'] : null); $id = isset($_GET['id']) ? (int) $_GET['id'] : null; $status_id = isset($_GET['new_sta_id']) ? (int) $_GET['new_sta_id'] : null; $isr_id = isset($_POST['isr_id']) ? (int) $_POST['isr_id'] : null; $items = isset($_POST['item']) ? (array) $_POST['item'] : null; if ($cat == 'delete_note') { $res = Note::remove($id); $tpl->assign('note_delete_result', $res); } elseif ($cat == 'delete_time') { $res = Time_Tracking::removeTimeEntry($id, $usr_id); $tpl->assign('time_delete_result', $res); } elseif ($cat == 'bulk_update') { $res = Issue::bulkUpdate(); $tpl->assign('bulk_update_result', $res); } elseif ($cat == 'set_initial_impact') { $res = Issue::setImpactAnalysis($iss_id); $tpl->assign('set_initial_impact_result', $res); } elseif ($cat == 'add_requirement') { $res = Impact_Analysis::insert($iss_id); $tpl->assign('add_requirement_result', $res); } elseif ($cat == 'set_impact_requirement') { $res = Impact_Analysis::update($isr_id); $tpl->assign('set_impact_requirement_result', $res); } elseif ($cat == 'delete_requirement') { $res = Impact_Analysis::remove();
// | | // | Free Software Foundation, Inc. | // | 51 Franklin Street, Suite 330 | // | Boston, MA 02110-1301, USA. | // +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // | Authors: Elan Ruusamäe <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('add_time_tracking.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); $issue_id = @$_POST['issue_id'] ? $_POST['issue_id'] : $_GET['iss_id']; if (!Issue::canAccess($issue_id, Auth::getUserID()) || Auth::getCurrentRole() <= User::getRoleID('Customer')) { $tpl = new Template_Helper(); $tpl->setTemplate('permission_denied.tpl.html'); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'add_time') { $date = (array) $_POST['date']; $ttc_id = (int) $_POST['category']; $iss_id = (int) $_POST['issue_id']; $time_spent = (int) $_POST['time_spent']; $summary = (string) $_POST['summary']; $res = Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary); $tpl->assign('time_add_result', $res); } $prj_id = Auth::getCurrentProject(); $tpl->assign(array('issue_id' => $issue_id, 'time_categories' => Time_Tracking::getAssocCategories($prj_id), 'current_user_prefs' => Prefs::get(Auth::getUserID()))); $tpl->displayTemplate();
if (!@empty($HTTP_POST_VARS['new_status'])) { $res = Issue::setStatus($issue_id, $HTTP_POST_VARS['new_status']); if ($res != -1) { $new_status = Status::getStatusTitle($HTTP_POST_VARS['new_status']); History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '{$new_status}' by " . User::getFullName($usr_id)); } } $res = Note::insert($usr_id, $issue_id); $tpl->assign("post_result", $res); // enter the time tracking entry about this phone support entry if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['issue_id'] = $issue_id; $HTTP_POST_VARS['category'] = $HTTP_POST_VARS['time_category']; $HTTP_POST_VARS['summary'] = 'Time entry inserted when sending an internal note.'; Time_Tracking::insertEntry(); } } elseif (@$HTTP_GET_VARS["cat"] == "reply") { if (!@empty($HTTP_GET_VARS["id"])) { $note = Note::getDetails($HTTP_GET_VARS["id"]); $date = Misc::formatReplyDate($note["timestamp"]); $header = "\n\n\nOn {$date}, " . $note["not_from"] . " wrote:\n>\n"; $note["not_body"] = $header . Misc::formatReply($note["not_note"]); $tpl->bulkAssign(array("note" => $note, "parent_note_id" => $HTTP_GET_VARS["id"])); $reply_subject = Mail_API::removeExcessRe($note['not_title']); } } if (empty($reply_subject)) { $reply_subject = 'Re: ' . $details['iss_summary']; } $tpl->assign(array('from' => User::getFromHeader($usr_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'current_user_prefs' => Prefs::get($usr_id), 'subscribers' => Notification::getSubscribers($issue_id, false, User::getRoleID("Standard User")), 'statuses' => Status::getAssocStatusList($prj_id, false), 'current_issue_status' => Issue::getStatusID($issue_id), 'time_categories' => Time_Tracking::getAssocCategories(), 'note_category_id' => Time_Tracking::getCategoryID('Note Discussion'), 'reply_subject' => $reply_subject)); $tpl->displayTemplate();
// include_once "../config.inc.php"; include_once APP_INC_PATH . "class.template.php"; include_once APP_INC_PATH . "class.auth.php"; include_once APP_INC_PATH . "class.user.php"; include_once APP_INC_PATH . "class.time_tracking.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("manage/index.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "time_tracking"); $role_id = Auth::getCurrentRole(); if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) { if ($role_id == User::getRoleID('administrator')) { $tpl->assign("show_setup_links", true); } if (@$HTTP_POST_VARS["cat"] == "new") { $tpl->assign("result", Time_Tracking::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Time_Tracking::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Time_Tracking::remove(); } if (@$HTTP_GET_VARS["cat"] == "edit") { $tpl->assign("info", Time_Tracking::getDetails($HTTP_GET_VARS["id"])); } $tpl->assign("list", Time_Tracking::getList()); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
$tpl = new Template_Helper(); $tpl->setTemplate('manage/time_tracking.tpl.html'); Auth::checkAuthentication(); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_MANAGER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } $prj_id = isset($_POST['prj_id']) ? (int) $_POST['prj_id'] : (int) $_GET['prj_id']; $cat = isset($_POST['cat']) ? (string) $_POST['cat'] : null; $tpl->assign('project', Project::getDetails($prj_id)); if ($cat == 'new') { $title = $_POST['title']; $res = Time_Tracking::insertCategory($prj_id, $title); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the time tracking category was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new time tracking category.'), Misc::MSG_INFO), -2 => array(ev_gettext('Please enter the title for this new time tracking category.'), Misc::MSG_ERROR))); } elseif ($cat == 'update') { $title = (string) $_POST['title']; $prj_id = (int) $_POST['prj_id']; $id = (int) $_POST['id']; $res = Time_Tracking::updateCategory($prj_id, $id, $title); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the time tracking category was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the time tracking category information.'), Misc::MSG_INFO), -2 => array(ev_gettext('Please enter the title for this time tracking category.'), Misc::MSG_ERROR))); } elseif ($cat == 'delete') { $items = (array) $_POST['items']; Time_Tracking::removeCategory($items); } if ($cat == 'edit') { $tpl->assign('info', Time_Tracking::getCategoryDetails($_GET['id'])); } $tpl->assign('list', Time_Tracking::getCategoryList($prj_id)); $tpl->displayTemplate();
/** * Method used to remove a specific phone support entry from the * application. * * @access public * @param integer $phone_id The phone support entry ID * @return integer 1 if the removal worked, -1 or -2 otherwise */ function remove($phone_id) { $phone_id = Misc::escapeInteger($phone_id); $stmt = "SELECT\n phs_iss_id,\n phs_ttr_id,\n phs_usr_id\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support\n WHERE\n phs_id={$phone_id}"; $details = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC); if ($details['phs_usr_id'] != Auth::getUserID()) { return -2; } $stmt = "DELETE FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support\n WHERE\n phs_id={$phone_id}"; $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { Issue::markAsUpdated($details["phs_iss_id"]); // need to save a history entry for this History::add($details["phs_iss_id"], Auth::getUserID(), History::getTypeID('phone_entry_removed'), 'Phone Support entry removed by ' . User::getFullName(Auth::getUserID())); if (!empty($details["phs_ttr_id"])) { $time_result = Time_Tracking::removeEntry($details["phs_ttr_id"], $details['phs_usr_id']); if ($time_result == 1) { return 2; } else { return $time_result; } } else { return 1; } } }