/** * Method used to add a phone support entry using the user * interface form available in the application. * * @return integer 1 if the insert worked, -1 or -2 otherwise */ public static function insert() { $usr_id = Auth::getUserID(); $iss_id = (int) $_POST['issue_id']; $date = $_POST['date']; // format the date from the form $created_date = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $date['Year'], $date['Month'], $date['Day'], $date['Hour'], $date['Minute'], 0); // convert the date to GMT timezone $created_date = Date_Helper::convertDateGMT($created_date . ' ' . Date_Helper::getPreferredTimezone()); $stmt = 'INSERT INTO {{%phone_support}} ( phs_iss_id, phs_usr_id, phs_phc_id, phs_created_date, phs_type, phs_phone_number, phs_description, phs_phone_type, phs_call_from_lname, phs_call_from_fname, phs_call_to_lname, phs_call_to_fname ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )'; $params = array($iss_id, $usr_id, $_POST['phone_category'], $created_date, $_POST['type'], $_POST['phone_number'], $_POST['description'], $_POST['phone_type'], $_POST['from_lname'], $_POST['from_fname'], $_POST['to_lname'], $_POST['to_fname']); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return -1; } // enter the time tracking entry about this phone support entry $phs_id = DB_Helper::get_last_insert_id(); $prj_id = Auth::getCurrentProject(); $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Telephone Discussion'); $time_spent = (int) $_POST['call_length']; $summary = ev_gettext('Time entry inserted from phone call.'); Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary); $stmt = 'SELECT max(ttr_id) FROM {{%time_tracking}} WHERE ttr_iss_id = ? AND ttr_usr_id = ?'; $ttr_id = DB_Helper::getInstance()->getOne($stmt, array($iss_id, $usr_id)); Issue::markAsUpdated($iss_id, 'phone call'); // need to save a history entry for this History::add($iss_id, $usr_id, 'phone_entry_added', 'Phone Support entry submitted by {user}', array('user' => 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 {{%phone_support}} SET phs_ttr_id = ? WHERE phs_id = ?'; try { DB_Helper::getInstance()->query($stmt, array($ttr_id, $phs_id)); } catch (DbException $e) { return -1; } } return 1; }
$time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when sending outgoing email.'; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } } 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(); }
Misc::setMessage(ev_gettext('Thank you, the internal note was posted successfully.'), Misc::MSG_INFO); } $tpl->assign('post_result', $res); // enter the time tracking entry about this phone support entry if (!empty($_POST['time_spent'])) { if (isset($_POST['time_summary']) && !empty($_POST['time_summary'])) { $summary = (string) $_POST['time_summary']; } else { $summary = 'Time entry inserted when sending an internal note.'; } $date = (array) $_POST['date']; $ttc_id = (int) $_POST['time_category']; $time_spent = (int) $_POST['time_spent']; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } Auth::redirect("post_note.php?cat=post_result&issue_id={$issue_id}&post_result={$res}"); } elseif ($cat == 'reply') { if (!empty($_GET['id'])) { $note = Note::getDetails($_GET['id']); $header = Misc::formatReplyPreamble($note['timestamp'], $note['not_from']); $note['not_body'] = $header . Misc::formatReply($note['not_note']); $tpl->assign(array('note' => $note, 'parent_note_id' => $_GET['id'])); $reply_subject = Mail_Helper::removeExcessRe($note['not_title']); } } if (empty($reply_subject)) { // TRANSLATORS: %1 = issue summary $reply_subject = ev_gettext('Re: %1$s', $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($prj_id), 'note_category_id' => Time_Tracking::getCategoryId($prj_id, 'Note Discussion'), 'reply_subject' => $reply_subject, 'issue_fields' => Issue_Field::getDisplayData($issue_id, 'post_note'))); $tpl->displayTemplate();