Пример #1
0
    // change status
    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));
 /**
  * Method used to add a phone support entry using the user 
  * interface form available in the application.
  *
  * @access  public
  * @return  integer 1 if the insert worked, -1 or -2 otherwise
  */
 function insert()
 {
     global $HTTP_POST_VARS;
     $usr_id = Auth::getUserID();
     // format the date from the form
     $created_date = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $HTTP_POST_VARS["date"]["Year"], $HTTP_POST_VARS["date"]["Month"], $HTTP_POST_VARS["date"]["Day"], $HTTP_POST_VARS["date"]["Hour"], $HTTP_POST_VARS["date"]["Minute"], 0);
     // convert the date to GMT timezone
     $created_date = Date_API::getDateGMT($created_date);
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support\n                 (\n                    phs_iss_id,\n                    phs_usr_id,\n                    phs_phc_id,\n                    phs_created_date,\n                    phs_type,\n                    phs_phone_number,\n                    phs_description,\n                    phs_phone_type,\n                    phs_call_from_lname,\n                    phs_call_from_fname,\n                    phs_call_to_lname,\n                    phs_call_to_fname\n                 ) VALUES (\n                    " . Misc::escapeInteger($HTTP_POST_VARS["issue_id"]) . ",\n                    {$usr_id},\n                    " . Misc::escapeInteger($HTTP_POST_VARS["phone_category"]) . ",\n                    '" . Misc::escapeString($created_date) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["type"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["phone_number"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["description"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["phone_type"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["from_lname"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["from_fname"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["to_lname"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["to_fname"]) . "'\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         // enter the time tracking entry about this phone support entry
         $phs_id = $GLOBALS["db_api"]->get_last_insert_id();
         $HTTP_POST_VARS['category'] = Time_Tracking::getCategoryID('Telephone Discussion');
         $HTTP_POST_VARS['time_spent'] = $HTTP_POST_VARS['call_length'];
         $HTTP_POST_VARS['summary'] = 'Time entry inserted from phone call.';
         Time_Tracking::insertEntry();
         $stmt = "SELECT\n                        max(ttr_id)\n                     FROM\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking\n                     WHERE\n                        ttr_iss_id = " . Misc::escapeInteger($HTTP_POST_VARS["issue_id"]) . " AND\n                        ttr_usr_id = {$usr_id}";
         $ttr_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
         Issue::markAsUpdated($HTTP_POST_VARS['issue_id'], 'phone call');
         // need to save a history entry for this
         History::add($HTTP_POST_VARS['issue_id'], $usr_id, History::getTypeID('phone_entry_added'), 'Phone Support entry submitted by ' . User::getFullName($usr_id));
         // XXX: send notifications for the issue being updated (new notification type phone_support?)
         // update phone record with time tracking ID.
         if (!empty($phs_id) && !empty($ttr_id)) {
             $stmt = "UPDATE\n                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support\n                         SET\n                            phs_ttr_id = {$ttr_id}\n                         WHERE\n                            phs_id = " . Misc::escapeInteger($phs_id);
             $res = $GLOBALS["db_api"]->dbh->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
             }
         }
         return 1;
     }
 }