function dbtime($var=null){ global $cfg; if(is_null($var) || !$var) $time=Misc::gmtime(); //gm time. else{ //user time to GM. $time=is_int($var)?$var:strtotime($var); $offset=$_SESSION['TZ_OFFSET']+($_SESSION['daylight']?date('I',$time):0); $time=$time-($offset*3600); } //gm to db time return $time+($cfg->getMysqlTZoffset()*3600); }
function dbtime($var = null) { global $cfg; if (is_null($var) || !$var) { $time = Misc::gmtime(); } else { //user time to GM. $time = is_int($var) ? $var : strtotime($var); $offset = $_SESSION['TZ_OFFSET'] + ($_SESSION['TZ_DST'] ? date('I', $time) : 0); $time = $time - $offset * 3600; } //gm to db time return $time + $cfg->getDBTZoffset() * 3600; }
function cacheable($etag, $modified, $ttl = 3600) { // Thanks, http://stackoverflow.com/a/1583753/1025836 // Timezone doesn't matter here — but the time needs to be // consistent round trip to the browser and back. $last_modified = strtotime($modified . " GMT"); header("Last-Modified: " . date('D, d M Y H:i:s', $last_modified) . " GMT", false); header('ETag: "' . $etag . '"'); header("Cache-Control: private, max-age={$ttl}"); header('Expires: ' . gmdate('D, d M Y H:i:s', Misc::gmtime() + $ttl) . " GMT"); header('Pragma: private'); if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified || @trim($_SERVER['HTTP_IF_NONE_MATCH'], '"') == $etag) { header("HTTP/1.1 304 Not Modified"); exit; } }
function Header() { global $cfg; //Common header $logo = $this->getLogoFile(); $this->Image($logo, null, $this->tMargin, 0, 20); if (strpos($logo, INCLUDE_DIR) === false) { unlink($logo); } $this->SetFont('Times', 'B', 16); $this->SetY($this->tMargin + 20); $this->SetX($this->lMargin); $this->Cell(0, 0, '', "B", 2, 'L'); $this->Ln(1); $this->SetFont('Arial', 'B', 10); $this->Cell(0, 5, $cfg->getTitle(), 0, 0, 'L'); $this->SetFont('Arial', 'I', 10); $this->Cell(0, 5, Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), $_SESSION['TZ_OFFSET'], $_SESSION['TZ_DST']) . ' GMT ' . $_SESSION['TZ_OFFSET'], 0, 1, 'R'); $this->Ln(5); }
function Header() { global $cfg; //Common header $this->Ln(2); $this->SetFont('Times', 'B', 16); $this->Image(FPDF_DIR . 'print-logo.png', null, 10, 0, 20); $this->SetX(200, 15); $this->Cell(0, 15, "Support Ticket System", 0, 1, 'R', 0); //$this->SetY(40); $this->SetXY(60, 25); $this->SetFont('Arial', 'B', 16); $this->Cell(0, 3, 'Ticket #' . $this->getTicket()->getExtId(), 0, 2, 'L'); $this->SetX($this->lMargin); $this->Cell(0, 3, '', "B", 2, 'L'); $this->SetFont('Arial', 'I', 10); $this->Cell(0, 5, 'Generated on ' . Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), $_SESSION['TZ_OFFSET'], $_SESSION['TZ_DST']), 0, 0, 'L'); $this->Cell(0, 5, 'Date & Time based on GMT ' . $_SESSION['TZ_OFFSET'], 0, 1, 'R'); $this->Ln(10); }
$warn = array(); if ($config['allow_attachments'] && !$config['upload_dir']) { $errors['allow_attachments'] = 'You need to setup upload dir.'; } else { if (!$config['allow_attachments'] && $config['allow_email_attachments']) { $warn['allow_email_attachments'] = '*Attachments Disabled.'; } if (!$config['allow_attachments'] && ($config['allow_online_attachments'] or $config['allow_online_attachments_onlogin'])) { $warn['allow_online_attachments'] = '<br>*Attachments Disabled.'; } } //Not showing err on post to avoid alarming the user...after an update. if (!$errors['err'] && !$msg && $warn) { $errors['err'] = 'Possible errors detected, please check the warnings below'; } $gmtime = Misc::gmtime(); $depts = db_query('SELECT dept_id,dept_name FROM ' . DEPT_TABLE . ' WHERE ispublic=1'); $templates = db_query('SELECT tpl_id,name FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE tpl_id=1 AND cfg_id=' . db_input($cfg->getId())); ?> <div class="msg">System Preferences and Settings (v<?php echo $config['ostversion']; ?> )</div> <table width="98%" border="0" cellspacing=0 cellpadding=0> <form action="admin.php?t=pref" method="post"> <input type="hidden" name="t" value="pref"> <tr><td> <table width="100%" border="0" cellspacing=0 cellpadding=2 class="tform"> <tr class="header" ><td colspan=2>General Settings</td></tr> <tr class="subheader"> <td colspan=2">Offline mode will disable client interface and <b>only</b> allow <b>super admin</b> to login to Staff Control Panel</td>
function download($disposition = false, $expires = false) { $disposition = $disposition ?: 'inline'; $bk = $this->open(); if ($bk->sendRedirectUrl($disposition)) { return; } $ttl = $expires ? $expires - Misc::gmtime() : false; $this->makeCacheable($ttl); Http::download($this->getName(), $this->getType() ?: 'application/octet-stream', null, $disposition); header('Content-Length: ' . $this->getSize()); $this->sendData(false); exit; }
?> </span> </td> </tr> <tr> <td width="180"> Daylight Saving: </td> <td> <input type="checkbox" name="daylight_saving" value="1" <?php echo $info['daylight_saving'] ? 'checked="checked"' : ''; ?> > Observe daylight saving <em>(Current Time: <strong><?php echo Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), $info['tz_offset'], $info['daylight_saving']); ?> </strong>)</em> </td> </tr> <tr> <td width="180">Maximum Page size:</td> <td> <select name="max_page_size"> <option value="0">— system default —</option> <?php $pagelimit = $info['max_page_size'] ? $info['max_page_size'] : $cfg->getPageSize(); for ($i = 5; $i <= 50; $i += 5) { $sel = $pagelimit == $i ? 'selected="selected"' : ''; echo sprintf('<option value="%d" %s>show %s records</option>', $i, $sel, $i); }
} ?> </select> </td> </tr> <tr> <td>Daylight Savings:</td> <td> <input type="checkbox" name="daylight_saving" <?php echo $rep['daylight_saving'] ? 'checked' : ''; ?> >Observe daylight saving </td> </tr> <tr><td>Current Time:</td> <td><b><i><?php echo Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), $rep['timezone_offset'], $rep['daylight_saving']); ?> </i></b></td> </tr> <tr> <td> </td> <td><br> <input class="button" type="submit" name="submit" value="Submit"> <input class="button" type="reset" name="reset" value="Reset"> <input class="button" type="button" name="cancel" value="Cancel" onClick='window.location.href="profile.php"'> </td> </tr> </form> </table>
: </td> <td> <input type="checkbox" name="dst" value="1" <?php echo $info['dst'] ? 'checked="checked"' : ''; ?> > <?php echo __('Observe daylight saving'); ?> <em>(<?php __('Current Time'); ?> : <strong><?php echo Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), $info['tz_offset'], $info['dst']); ?> </strong>)</em> </td> </tr> <tr> <td width="180"> <?php echo __('Preferred Language'); ?> : </td> <td> <?php $langs = Internationalization::availableLanguages(); ?>
function update($vars, &$errors) { global $cfg, $thisstaff; if (!$cfg || !$thisstaff || !$thisstaff->canEditTickets()) { return false; } $fields = array(); $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => __('Help topic selection is required')); $fields['slaId'] = array('type' => 'int', 'required' => 0, 'error' => __('Select a valid SLA')); $fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => __('Invalid date format - must be MM/DD/YY')); $fields['note'] = array('type' => 'text', 'required' => 1, 'error' => __('A reason for the update is required')); $fields['user_id'] = array('type' => 'int', 'required' => 0, 'error' => __('Invalid user-id')); if (!Validator::process($fields, $vars, $errors) && !$errors['err']) { $errors['err'] = __('Missing or invalid data - check the errors and try again'); } if ($vars['duedate']) { if ($this->isClosed()) { $errors['duedate'] = __('Due date can NOT be set on a closed ticket'); } elseif (!$vars['time'] || strpos($vars['time'], ':') === false) { $errors['time'] = __('Select a time from the list'); } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) === false) { $errors['duedate'] = __('Invalid due date'); } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) <= time()) { $errors['duedate'] = __('Due date must be in the future'); } } // Validate dynamic meta-data $forms = DynamicFormEntry::forTicket($this->getId()); foreach ($forms as $form) { // Don't validate deleted forms if (!in_array($form->getId(), $vars['forms'])) { continue; } $form->setSource($_POST); if (!$form->isValid()) { $errors = array_merge($errors, $form->errors()); } } if ($errors) { return false; } $sql = 'UPDATE ' . TICKET_TABLE . ' SET updated=NOW() ' . ' ,topic_id=' . db_input($vars['topicId']) . ' ,sla_id=' . db_input($vars['slaId']) . ' ,source=' . db_input($vars['source']) . ' ,duedate=' . ($vars['duedate'] ? db_input(date('Y-m-d G:i', Misc::dbtime($vars['duedate'] . ' ' . $vars['time']))) : 'NULL'); if ($vars['user_id']) { $sql .= ', user_id=' . db_input($vars['user_id']); } if ($vars['duedate']) { //We are setting new duedate... $sql .= ' ,isoverdue=0'; } $sql .= ' WHERE ticket_id=' . db_input($this->getId()); if (!db_query($sql) || !db_affected_rows()) { return false; } if (!$vars['note']) { $vars['note'] = sprintf(_S('Ticket details updated by %s'), $thisstaff->getName()); } $this->logNote(_S('Ticket Updated'), $vars['note'], $thisstaff); // Decide if we need to keep the just selected SLA $keepSLA = $this->getSLAId() != $vars['slaId']; // Update dynamic meta-data foreach ($forms as $f) { // Drop deleted forms $idx = array_search($f->getId(), $vars['forms']); if ($idx === false) { $f->delete(); } else { $f->set('sort', $idx); $f->save(); } } // Reload the ticket so we can do further checking $this->reload(); // Reselect SLA if transient if (!$keepSLA && (!$this->getSLA() || $this->getSLA()->isTransient())) { $this->selectSLAId(); } // Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue. if ($this->isOverdue() && (!$this->getEstDueDate() || Misc::db2gmtime($this->getEstDueDate()) > Misc::gmtime())) { $this->clearOverdue(); } Signal::send('model.updated', $this); return true; }
function update($vars, &$errors) { global $cfg, $thisstaff; if (!$cfg || !$thisstaff || !$thisstaff->canEditTickets()) { return false; } $fields = array(); $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Help topic required'); $fields['slaId'] = array('type' => 'int', 'required' => 0, 'error' => 'Select SLA'); $fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY'); $fields['note'] = array('type' => 'text', 'required' => 1, 'error' => 'Reason for the update required'); $fields['user_id'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid user-id'); if (!Validator::process($fields, $vars, $errors) && !$errors['err']) { $errors['err'] = 'Missing or invalid data - check the errors and try again'; } if ($vars['duedate']) { if ($this->isClosed()) { $errors['duedate'] = 'Due date can NOT be set on a closed ticket'; } elseif (!$vars['time'] || strpos($vars['time'], ':') === false) { $errors['time'] = 'Select time'; } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) === false) { $errors['duedate'] = 'Invalid due date'; } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) <= time()) { $errors['duedate'] = 'Due date must be in the future'; } } if ($errors) { return false; } $sql = 'UPDATE ' . TICKET_TABLE . ' SET updated=NOW() ' . ' ,topic_id=' . db_input($vars['topicId']) . ' ,sla_id=' . db_input($vars['slaId']) . ' ,source=' . db_input($vars['source']) . ' ,duedate=' . ($vars['duedate'] ? db_input(date('Y-m-d G:i', Misc::dbtime($vars['duedate'] . ' ' . $vars['time']))) : 'NULL'); if ($vars['user_id']) { $sql .= ', user_id=' . db_input($vars['user_id']); } if ($vars['duedate']) { //We are setting new duedate... $sql .= ' ,isoverdue=0'; } $sql .= ' WHERE ticket_id=' . db_input($this->getId()); if (!db_query($sql) || !db_affected_rows()) { return false; } if (!$vars['note']) { $vars['note'] = sprintf('Ticket Updated by %s', $thisstaff->getName()); } $this->logNote('Ticket Updated', $vars['note'], $thisstaff); // Decide if we need to keep the just selected SLA $keepSLA = $this->getSLAId() != $vars['slaId']; // Reload the ticket so we can do further checking $this->reload(); // Reselect SLA if transient if (!$keepSLA && (!$this->getSLA() || $this->getSLA()->isTransient())) { $this->selectSLAId(); } // Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue. if ($this->isOverdue() && (!$this->getEstDueDate() || Misc::db2gmtime($this->getEstDueDate()) > Misc::gmtime())) { $this->clearOverdue(); } return true; }
</tr></table> </htmlpageheader> <htmlpagefooter name="def" style="display:none"> <div class="hr"> </div> <table width="100%"><tr><td class="flush-left"> Ticket #<?php echo $ticket->getNumber(); ?> printed by <?php echo $thisclient->getName()->getFirst(); ?> on <?php echo Format::daydatetime(Misc::gmtime()); ?> </td> <td class="flush-right"> Page {PAGENO} </td> </tr></table> </htmlpagefooter> <!-- Ticket metadata --> <h1>Ticket #<?php echo $ticket->getNumber(); ?> </h1> <table class="meta-data" cellpadding="0" cellspacing="0"> <tbody>
$selected = ($info['lang'] == $l['code']) ? 'selected="selected"' : ''; ?> <option value="<?php echo $l['code']; ?>" <?php echo $selected; ?>><?php echo Internationalization::getLanguageDescription($l['code']); ?></option> <?php } ?> </select> <span class="error"> <?php echo $errors['lang']; ?></span> </td> </tr> <tr> <td width="180"> <?php echo __('Daylight Saving');?>: </td> <td> <input type="checkbox" name="daylight_saving" value="1" <?php echo $info['daylight_saving']?'checked="checked"':''; ?>> <?php echo __('Observe daylight saving');?> <em>(<?php echo __('Current Time');?>: <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['daylight_saving']); ?></strong>)</em> </td> </tr> <tr> <td width="180"><?php echo __('Maximum Page size');?>:</td> <td> <select name="max_page_size"> <option value="0">— <?php echo __('system default');?> —</option> <?php $pagelimit=$info['max_page_size']?$info['max_page_size']:$cfg->getPageSize(); for ($i = 5; $i <= 50; $i += 5) { $sel=($pagelimit==$i)?'selected="selected"':''; echo sprintf('<option value="%d" %s>'.__('show %s records').'</option>',$i,$sel,$i); } ?> </select> <?php echo __('per page.');?> </td>
function update($vars, &$errors) { global $cfg, $thisstaff; if (!$cfg || !$thisstaff || !$thisstaff->canEditTickets()) { return false; } $fields = array(); $fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required'); $fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required'); $fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required'); $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Help topic required'); $fields['priorityId'] = array('type' => 'int', 'required' => 1, 'error' => 'Priority required'); $fields['slaId'] = array('type' => 'int', 'required' => 0, 'error' => 'Select SLA'); $fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Valid phone # required'); $fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY'); $fields['note'] = array('type' => 'text', 'required' => 1, 'error' => 'Reason for the update required'); if (!Validator::process($fields, $vars, $errors) && !$errors['err']) { $errors['err'] = 'Missing or invalid data - check the errors and try again'; } if ($vars['duedate']) { if ($this->isClosed()) { $errors['duedate'] = 'Due date can NOT be set on a closed ticket'; } elseif (!$vars['time'] || strpos($vars['time'], ':') === false) { $errors['time'] = 'Select time'; } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) === false) { $errors['duedate'] = 'Invalid due date'; } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) <= time()) { $errors['duedate'] = 'Due date must be in the future'; } } //Make sure phone extension is valid if ($vars['phone_ext']) { if (!is_numeric($vars['phone_ext']) && !$errors['phone']) { $errors['phone'] = 'Invalid phone ext.'; } elseif (!$vars['phone']) { //make sure they just didn't enter ext without phone # $errors['phone'] = 'Phone number required'; } } if ($errors) { return false; } $sql = 'UPDATE ' . TICKET_TABLE . ' SET updated=NOW() ' . ' ,email=' . db_input($vars['email']) . ' ,name=' . db_input(Format::striptags($vars['name'])) . ' ,subject=' . db_input(Format::striptags($vars['subject'])) . ' ,phone="' . db_input($vars['phone'], false) . '"' . ' ,phone_ext=' . db_input($vars['phone_ext'] ? $vars['phone_ext'] : NULL) . ' ,priority_id=' . db_input($vars['priorityId']) . ' ,topic_id=' . db_input($vars['topicId']) . ' ,sla_id=' . db_input($vars['slaId']) . ' ,source=' . db_input($vars['source']) . ' ,duedate=' . ($vars['duedate'] ? db_input(date('Y-m-d G:i', Misc::dbtime($vars['duedate'] . ' ' . $vars['time']))) : 'NULL'); if ($vars['duedate']) { //We are setting new duedate... $sql .= ' ,isoverdue=0'; } $sql .= ' WHERE ticket_id=' . db_input($this->getId()); if (!db_query($sql) || !db_affected_rows()) { return false; } if (!$vars['note']) { $vars['note'] = sprintf('Ticket Updated by %s', $thisstaff->getName()); } $this->logNote('Ticket Updated', $vars['note'], $thisstaff); $this->reload(); // Reselect SLA if transient if (!$this->getSLAId() || $this->getSLA()->isTransient()) { $this->selectSLAId(); } //Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue. if ($this->isOverdue() && (!$this->getEstDueDate() || Misc::db2gmtime($this->getEstDueDate()) > Misc::gmtime())) { $this->clearOverdue(); } return true; }