Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_support/modules/ticket/controller/ |
Upload File : |
<?php
class helpdesk_Controller extends Controller {
private $model_ticket;
private $model_customer;
private $model_project;
private $model_status;
private $model_priority;
public function __construct() {
parent::__construct(dirname(__DIR__));
$this->model_ticket = $this->LoadModel('ticket_model');
$this->model_project = $this->LoadModel('project_model');
$this->model_ticket->Hostname($this->hostname())
->ModelProject($this->model_project);
$this->level = isset($_SESSION['current_user']) ? $_SESSION['current_user']['u_level'] : 0;
}
public function __Register() {
$this->RegisterView(__CLASS__ .'::index', ['tix_view' => ['tix_index']]);
$this->RegisterView(__CLASS__ .'::request', ['tix_view' => ['tix_request']]);
$this->RegisterView(__CLASS__ .'::success', ['tix_view' => ['tix_success']]);
$this->RegisterView(__CLASS__ .'::ticket', ['tix_view' => ['tix_detail']]);
}
/** everyone */
public function index() {
$result = $this->DefaultResult(__METHOD__);
$result['template'] = 'tix_index';
if ($this->level >= 9) {
$result['datatable_table_new'] = [
'columns' => [
['data' => 'ticket', 'width' => 70, 'render' => 'tix_request_ticket', 'className' => 'tix-priority'],
['data' => 'date', 'width' => 110],
['data' => 'client'],
['data' => 'subject', 'width' => 480],
['data' => 'status_desc'],
],
'order' => [ [ 0, 'desc' ]],
];
$result['datatable_table_open'] = [
'columns' => [
['data' => 'ticket', 'width' => 70, 'render' => 'tix_request_ticket', 'className' => 'tix-priority'],
['data' => 'date', 'width' => 110],
['data' => 'client'],
['data' => 'subject', 'width' => 480],
['data' => 'status_desc'],
],
'order' => [ [ 0, 'desc' ]],
];
} else {
$result['datatable_table_request'] = [
'columns' => [
['data' => 'date', 'width' => 110],
['data' => 'ticket', 'width' => 60, 'render' => 'tix_request_ticket'],
['data' => 'subject', 'width' => 500],
['data' => 'status_desc'],
],
'order' => [ [ 0, 'desc' ]],
];
}
return $result;
}
/** everyone */
public function request() {
$result = $this->DefaultResult(__METHOD__);
// if logged in, autofill name, email and maybe phone
$priority = $this->LoadModel('priority_model');
$result['fieldlist'] = $this->model_ticket->AssembleFieldlist(
$priority->asArray()
);
$result['template'] = 'tix_request';
return $result;
}
/** everyone */
public function request_POST() {
// if there is an error, return messages, then exit
$defs = $this->model_ticket->AssembleFieldlist();
$info = hook_execute('formedit.validate', [], $defs);
if (isset($info['field'])) { // validation errors
return $info;
}
$info = $info['data'];
// get/create user. Each unique company email address is a new user
$this->model_customer = $this->LoadModel('customer_model');
$this->model_ticket->ModelCustomer($this->model_customer);
$client_id = $this->model_ticket->createNewTicket(
$info['email'],
$info['name'],
$info['subject'],
$info['priority'],
$info['content'],
);
// generate and send email
// we have received your request - please check email
$result = $this->model_ticket->sendEmail_create($info['email']);
if (!isset($result['result'])) { // redirect to success page
$result = ['redirect' => '/helpdesk/success'];
}
return $result;
}
/** everyone */
public function success() {
$result = $this->DefaultResult(__METHOD__);
$result['template'] = 'tix_success';
return $result;
}
private function AsAttachmentList() {
// now redraw attachment area
$this->OutputFormat('json');
return [
'html' => [
'field' => 'attaches',
'template' => 'tix_filegroup',
'afterLoad' => 1,
],
'attachment' => $this->model_ticket->getAttachments(),
'number' => $this->model_ticket->TicketNumber(),
];
}
// must be logged in to view ticket
/** 1 */
public function ticket($ticketnumber = '', $action = '') {
$this->model_status = $this->LoadModel('status_model');
$this->model_priority = $this->LoadModel('priority_model');
$result = $this->DefaultResult(__METHOD__);
$result['template'] = 'tix_detail';
$this->model_ticket
->TicketNumber($ticketnumber)
->ModelStatus($this->model_status)
->ModelPriority($this->model_priority);
switch($action) {
case 'remove':
$hash = $this->param('hash', '');
if ($hash != '') {
$this->model_ticket->RemoveUpload($hash);
}
return $this->AsAttachmentList(); // now redraw attachment area
default:
$deets = $this->model_ticket->AsHandlebars();
break;
}
$deets = $this->model_ticket->AsHandlebars();
return array_merge($result, $deets);
}
/** 1 */
public function ticket_POST($ticketnumber = '', $action = '') {
$this->model_ticket
->TicketNumber($ticketnumber);
if ($action == '') $action = trim($this->post('action', 'comment'));
$message = trim($this->post('message', ''));
switch($action) {
case 'field':
$name = $this->post('field');
$value = $this->post('value');
header('content-type: text/plain');
die($this->model_ticket->SaveField($name, $value));
case 'attach':
header('content-type: text/plain');
if (!$_FILES['attach']['error']) {
$this->model_ticket->SaveUpload($_FILES['attach']);
return $this->AsAttachmentList(); // now redraw attachment area
}
break;
case 'comment':
case 'email':
case 'update':
$this->model_ticket->AddReply($action, $message);
header('Location: /helpdesk/ticket/' . $ticketnumber);
exit;
}
header('content-type: text/plain');
die('unable to post');
}
/** 1 */
public function _list($action = '') {
$this->model_status = $this->LoadModel('status_model');
$this->model_ticket
->ModelStatus($this->model_status);
return $this->model_ticket->datatableList($action);
}
}