Esempio n. 1
0
    }
} 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);
Esempio n. 2
0
 /**
  * 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;
 }