mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 12:18:43 +09:00
Unify public tickets with client tickets (#3799)
* Merge public ticket logic into regular client tickets * Unified email templates * Unified events and listeners * Remove passthrough service methods * Corrected phpDocs * Create a combined `author` array to replace `client`, `client_id`, `author_name`, `author_email` * Switch to using "Author" instead of "Requester" * Switch to using a single endpoint and single template for client and guest tickets Also left a redirect behind to make sure previously sent emails still have a working link * Add author_role parameter to onBeforeClientOpenTicket * Adjusted rate limit ordering * Update Twig templates and the update patcher * "Public ticket" -> "Guest ticket" * Addressed code review comments * Address code review comments * Also purge old pticket email templates * Fix email sending * Support: enforce auth, fix guest email links * Migrate mod_support config key name --------- Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
This commit is contained in:
1 parent
f39fd44f0f
commit
7ade5bbdf3
46 files changed
+880
-3081
No files matched your search
@@ -303,7 +303,7 @@ LOCK TABLES `setting` WRITE;
|
||||
|
||||
INSERT INTO `setting` (`id`, `param`, `value`, `public`, `category`, `hash`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1,'last_patch','72',0,NULL,NULL,'2024-12-30 12:00:00','2024-12-30 12:00:00'),
|
||||
(1,'last_patch','73',0,NULL,NULL,'2024-12-30 12:00:00','2024-12-30 12:00:00'),
|
||||
(2,'company_name','Company Name',0,NULL,NULL,'2022-12-01 12:00:00','2022-12-01 12:00:00'),
|
||||
(3,'company_email','support@yourcompany.com',0,NULL,NULL,'2022-12-01 12:00:00','2022-12-01 12:00:00'),
|
||||
(4,'company_signature','FOSSBilling.org - Client Management, Invoicing and Support Software',0,NULL,NULL,'2022-12-01 12:00:00','2022-12-01 12:00:00'),
|
||||
@@ -359,16 +359,6 @@ VALUES
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
# Dump of table support_p_ticket
|
||||
# ------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Dump of table support_p_ticket_message
|
||||
# ------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Dump of table support_pr
|
||||
# ------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1174,46 +1174,6 @@ CREATE TABLE `support_helpdesk` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `support_p_ticket`
|
||||
--
|
||||
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `support_p_ticket` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`hash` varchar(255) DEFAULT NULL,
|
||||
`author_name` varchar(255) DEFAULT NULL,
|
||||
`author_email` varchar(255) DEFAULT NULL,
|
||||
`subject` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(30) DEFAULT 'open',
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `support_p_ticket_message`
|
||||
--
|
||||
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `support_p_ticket_message` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`support_p_ticket_id` bigint(20) DEFAULT NULL,
|
||||
`admin_id` bigint(20) DEFAULT NULL COMMENT 'Filled when message author is admin',
|
||||
`content` text,
|
||||
`ip` varchar(45) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `support_p_ticket_id_idx` (`support_p_ticket_id`),
|
||||
KEY `admin_id_idx` (`admin_id`),
|
||||
FULLTEXT KEY `content_idx` (`content`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `support_pr`
|
||||
--
|
||||
@@ -1257,6 +1217,9 @@ CREATE TABLE `support_ticket` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`support_helpdesk_id` bigint(20) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`access_hash` varchar(255) DEFAULT NULL,
|
||||
`author_name` varchar(255) DEFAULT NULL,
|
||||
`author_email` varchar(255) DEFAULT NULL,
|
||||
`priority` int(11) DEFAULT '100',
|
||||
`subject` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(30) DEFAULT 'open' COMMENT 'open, closed, on_hold',
|
||||
@@ -1269,7 +1232,8 @@ CREATE TABLE `support_ticket` (
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `support_helpdesk_id_idx` (`support_helpdesk_id`),
|
||||
KEY `client_id_idx` (`client_id`)
|
||||
KEY `client_id_idx` (`client_id`),
|
||||
KEY `access_hash_idx` (`access_hash`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
@@ -272,6 +272,14 @@ class UpdatePatcher implements InjectionAwareInterface
|
||||
return in_array($column, $this->getTableColumns($table), true);
|
||||
}
|
||||
|
||||
private function tableExists(string $table): bool
|
||||
{
|
||||
return (bool) $this->fetchOne(
|
||||
'SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = :table LIMIT 1',
|
||||
['table' => $table],
|
||||
);
|
||||
}
|
||||
|
||||
private function getTableColumns(string $table): array
|
||||
{
|
||||
$columns = $this->fetchAll(sprintf('SHOW COLUMNS FROM `%s`', $this->quoteIdentifier($table)));
|
||||
@@ -459,6 +467,7 @@ class UpdatePatcher implements InjectionAwareInterface
|
||||
70 => 'patch70',
|
||||
71 => 'patch71',
|
||||
72 => 'patch72',
|
||||
73 => 'patch73',
|
||||
];
|
||||
ksort($patches, SORT_NATURAL);
|
||||
|
||||
@@ -1180,17 +1189,10 @@ class UpdatePatcher implements InjectionAwareInterface
|
||||
'mod_staff_client_signup' => ['13018c8f888668bbf731367ca3388a34f7170ff213bf1fa07771c375c4aae775', 'a573783ce28183abe13257c5b2663f750f8e37eb9056aad0c6abf203573d2f83'],
|
||||
'mod_staff_password_reset_approve' => ['f4e810c0a880b72dac35d7d7c1317fabdbc253c94b2c40387e72300fc502e75b', '8e3a3e5e4ffb9b393c08bcef9c07818a73c70d8c25a6cbed3f9ef339008e32bb'],
|
||||
'mod_staff_password_reset_request' => ['7afb81438ba5fe02b0cb1de5e2a0adafa1d54163fa6db3c594b052ae41d7a702', 'f6b1527a328af6b4e1c7a0f4d96d4cea7fa328a053508dc614385d39d78cc925'],
|
||||
'mod_staff_pticket_close' => ['649f36bc186928c2581f27e017dcad39ee38a01100bb38e0458e02cab1d06cb8', '49b9aced9a16bb81ce961a097c945a9c6dd828b3d8aab3b3c3557bb5d12ec85e'],
|
||||
'mod_staff_pticket_open' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', 'd30deb555b30c5a85f25b23bb4c83a76e49d8a8379ad09d4aff9968888e637ce'],
|
||||
'mod_staff_pticket_reply' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '22bbf90befc02e3da6211c7036362fb296a38eb4be686d18752552b3cc0ae63d'],
|
||||
'mod_staff_ticket_close' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', 'd54e0d97b88218404c731929eb2a39857ee422070e857802374626b72bf84b2f'],
|
||||
'mod_staff_ticket_open' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', 'dbe1dee98606a36285a79d019e6180e62ee04cc7e3c3f16d34045d6c70aaf78e'],
|
||||
'mod_staff_ticket_reply' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', '87238cbde59fd9faa31c8e0d6039924ad6068f1ca3858ad91b06cc4633243153'],
|
||||
'mod_support_helpdesk_ticket_open' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '709e2ff17c01e1056ef4824e507e4474a6eeb1e3f35d5acd1c646074d98cc5d6'],
|
||||
'mod_support_pticket_open' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', '9735ea9dfe213f0880f95fabf82cc0530bac78feeeab9b6ec21fee501c3e9e3f'],
|
||||
'mod_support_pticket_staff_close' => ['649f36bc186928c2581f27e017dcad39ee38a01100bb38e0458e02cab1d06cb8', '40a10a0a559dd5e3f69d8464df979db6bc5109696c4a1df6f60ea6802ca3376f'],
|
||||
'mod_support_pticket_staff_open' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '7dcba8e4fae63dd9ef4815a5db8cfb0cf6a510d48b947ec64f9e8163b8078e03'],
|
||||
'mod_support_pticket_staff_reply' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '4afbeb7038d64bd1a53277902139019fa219554cdb32fb1ec74b07e85b40e83d'],
|
||||
'mod_support_ticket_open' => ['5b80a40322052bccb1e00854c02fe4ad46be9dfbbdbf0b17a641af99175b72c5', '78fe28d46cba9f344b9a2045114b1a7d723dc8a62602690413ecac30287bcae2'],
|
||||
'mod_support_ticket_staff_close' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '965d0369564e2edc832db28564e414b960f9559213750d7f1f1baf0b1cceb2a7'],
|
||||
'mod_support_ticket_staff_open' => ['2fb0c49c240c05925211f0bd0e90b3de4ceab4287c1c89be6155f0a3d71d7811', '98ff5f36b64fb0f874048c7dd44310e98ecf2b08f49e8dab701d9d4bb5e81ba5'],
|
||||
@@ -1572,6 +1574,291 @@ class UpdatePatcher implements InjectionAwareInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function patch72(): void
|
||||
{
|
||||
$this->executeFileActions([
|
||||
Path::join(PATH_LIBRARY, 'Model', 'Product.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductCategory.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductCustom.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDomain.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDomainTable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDownloadable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductHosting.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductLicense.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductPayment.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductTable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'Promo.php') => 'unlink',
|
||||
Path::join(PATH_CACHE, 'classMap.php') => 'unlink',
|
||||
Path::join(PATH_CACHE, 'fallbackClassMap.php') => 'unlink',
|
||||
]);
|
||||
|
||||
$schemaManager = $this->di['dbal']->createSchemaManager();
|
||||
if (!$schemaManager->tablesExist(['promo_redemption'])) {
|
||||
$this->executeSql(
|
||||
"CREATE TABLE `promo_redemption` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`promo_id` bigint(20) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`client_order_id` bigint(20) DEFAULT NULL,
|
||||
`invoice_id` bigint(20) DEFAULT NULL,
|
||||
`phase` varchar(30) NOT NULL DEFAULT 'checkout',
|
||||
`status` varchar(30) NOT NULL DEFAULT 'reserved',
|
||||
`discount_amount` decimal(18,2) DEFAULT NULL,
|
||||
`currency` varchar(20) DEFAULT NULL,
|
||||
`committed_at` datetime DEFAULT NULL,
|
||||
`released_at` datetime DEFAULT NULL,
|
||||
`release_reason` varchar(100) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `promo_id_idx` (`promo_id`),
|
||||
KEY `client_id_idx` (`client_id`),
|
||||
KEY `client_order_id_idx` (`client_order_id`),
|
||||
KEY `invoice_id_idx` (`invoice_id`),
|
||||
KEY `phase_idx` (`phase`),
|
||||
KEY `status_idx` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
|
||||
);
|
||||
}
|
||||
|
||||
$table = $schemaManager->introspectTable('promo_redemption');
|
||||
$columns = [];
|
||||
|
||||
if (!$table->hasColumn('status')) {
|
||||
$columns[] = "ADD COLUMN `status` varchar(30) NOT NULL DEFAULT 'reserved' AFTER `phase`";
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('committed_at')) {
|
||||
$columns[] = 'ADD COLUMN `committed_at` datetime DEFAULT NULL AFTER `currency`';
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('released_at')) {
|
||||
$columns[] = 'ADD COLUMN `released_at` datetime DEFAULT NULL AFTER `committed_at`';
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('release_reason')) {
|
||||
$columns[] = 'ADD COLUMN `release_reason` varchar(100) DEFAULT NULL AFTER `released_at`';
|
||||
}
|
||||
|
||||
if ($columns !== []) {
|
||||
$this->executeSql('ALTER TABLE promo_redemption ' . implode(', ', $columns));
|
||||
}
|
||||
|
||||
$table = $schemaManager->introspectTable('promo_redemption');
|
||||
$expectedIndexes = [
|
||||
'promo_id_idx' => 'promo_id',
|
||||
'client_id_idx' => 'client_id',
|
||||
'client_order_id_idx' => 'client_order_id',
|
||||
'invoice_id_idx' => 'invoice_id',
|
||||
'phase_idx' => 'phase',
|
||||
'status_idx' => 'status',
|
||||
];
|
||||
|
||||
foreach ($expectedIndexes as $indexName => $columnName) {
|
||||
if (!$table->hasIndex($indexName)) {
|
||||
$this->executeSql(sprintf(
|
||||
'ALTER TABLE promo_redemption ADD INDEX `%s` (`%s`)',
|
||||
$indexName,
|
||||
$columnName
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$existingRedemptions = (int) $this->di['dbal']->executeQuery('SELECT COUNT(id) FROM promo_redemption')->fetchOne();
|
||||
if ($existingRedemptions === 0) {
|
||||
$orders = $this->di['dbal']->executeQuery(
|
||||
'SELECT id, promo_id, client_id, promo_used, discount, currency, created_at, updated_at
|
||||
FROM client_order
|
||||
WHERE promo_id IS NOT NULL'
|
||||
)->fetchAllAssociative();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$checkoutCreatedAt = $order['created_at'] ?? date('Y-m-d H:i:s');
|
||||
$renewalCreatedAt = $order['updated_at'] ?: $checkoutCreatedAt;
|
||||
$discountAmount = $order['discount'] !== null ? (float) $order['discount'] : null;
|
||||
|
||||
$this->di['dbal']->insert('promo_redemption', [
|
||||
'promo_id' => $order['promo_id'],
|
||||
'client_id' => $order['client_id'],
|
||||
'client_order_id' => $order['id'],
|
||||
'invoice_id' => null,
|
||||
'phase' => 'checkout',
|
||||
'status' => 'committed',
|
||||
'discount_amount' => $discountAmount,
|
||||
'currency' => $order['currency'],
|
||||
'committed_at' => $checkoutCreatedAt,
|
||||
'released_at' => null,
|
||||
'release_reason' => null,
|
||||
'created_at' => $checkoutCreatedAt,
|
||||
'updated_at' => $checkoutCreatedAt,
|
||||
]);
|
||||
|
||||
$renewalCount = max(0, ((int) ($order['promo_used'] ?? 1)) - 1);
|
||||
for ($i = 0; $i < $renewalCount; ++$i) {
|
||||
$this->di['dbal']->insert('promo_redemption', [
|
||||
'promo_id' => $order['promo_id'],
|
||||
'client_id' => $order['client_id'],
|
||||
'client_order_id' => $order['id'],
|
||||
'invoice_id' => null,
|
||||
'phase' => 'renewal',
|
||||
'status' => 'committed',
|
||||
'discount_amount' => $discountAmount,
|
||||
'currency' => $order['currency'],
|
||||
'committed_at' => $renewalCreatedAt,
|
||||
'released_at' => null,
|
||||
'release_reason' => null,
|
||||
'created_at' => $renewalCreatedAt,
|
||||
'updated_at' => $renewalCreatedAt,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize rows written by a previous partial migration run that pre-dated the
|
||||
// status column; those rows have a NULL/empty status. Legitimate 'reserved'
|
||||
// rows created by concurrent checkouts are left untouched so the payment flow
|
||||
// can commit or release them normally.
|
||||
$this->executeSql("
|
||||
UPDATE promo_redemption
|
||||
SET
|
||||
status = 'committed',
|
||||
committed_at = COALESCE(committed_at, created_at),
|
||||
release_reason = NULL
|
||||
WHERE status IS NULL OR status = ''
|
||||
");
|
||||
}
|
||||
|
||||
private function patch73(): void
|
||||
{
|
||||
// Merge guest/public support tickets into the regular support ticket tables.
|
||||
// See https://github.com/FOSSBilling/FOSSBilling/pull/3799
|
||||
if (!$this->tableHasColumn('support_ticket', 'access_hash')) {
|
||||
$this->executeSql('ALTER TABLE `support_ticket` ADD COLUMN `access_hash` VARCHAR(255) DEFAULT NULL AFTER `client_id`;');
|
||||
}
|
||||
|
||||
if (!$this->tableHasColumn('support_ticket', 'author_name')) {
|
||||
$this->executeSql('ALTER TABLE `support_ticket` ADD COLUMN `author_name` VARCHAR(255) DEFAULT NULL AFTER `access_hash`;');
|
||||
}
|
||||
|
||||
if (!$this->tableHasColumn('support_ticket', 'author_email')) {
|
||||
$this->executeSql('ALTER TABLE `support_ticket` ADD COLUMN `author_email` VARCHAR(255) DEFAULT NULL AFTER `author_name`;');
|
||||
}
|
||||
|
||||
if (!$this->tableHasIndex('support_ticket', 'access_hash_idx')) {
|
||||
$this->executeSql('ALTER TABLE `support_ticket` ADD INDEX `access_hash_idx` (`access_hash`);');
|
||||
}
|
||||
|
||||
$this->executeSql("
|
||||
DELETE FROM email_template
|
||||
WHERE action_code IN (
|
||||
'mod_staff_pticket_close',
|
||||
'mod_staff_pticket_open',
|
||||
'mod_staff_pticket_reply',
|
||||
'mod_support_pticket_open',
|
||||
'mod_support_pticket_staff_close',
|
||||
'mod_support_pticket_staff_open',
|
||||
'mod_support_pticket_staff_reply'
|
||||
)
|
||||
");
|
||||
|
||||
// Remove obsolete guest/public ticket email templates from extracted update archives.
|
||||
$this->executeFileActions([
|
||||
Path::join(PATH_MODS, 'Staff', 'templates', 'email', 'mod_staff_pticket_close.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Staff', 'templates', 'email', 'mod_staff_pticket_open.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Staff', 'templates', 'email', 'mod_staff_pticket_reply.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Support', 'templates', 'email', 'mod_support_pticket_open.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Support', 'templates', 'email', 'mod_support_pticket_staff_close.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Support', 'templates', 'email', 'mod_support_pticket_staff_open.html.twig') => 'unlink',
|
||||
Path::join(PATH_MODS, 'Support', 'templates', 'email', 'mod_support_pticket_staff_reply.html.twig') => 'unlink',
|
||||
]);
|
||||
|
||||
$row = $this->fetchOne(
|
||||
"SELECT meta_value FROM extension_meta WHERE extension = 'mod_support' AND meta_key = 'config'",
|
||||
);
|
||||
|
||||
if (is_string($row) && $row !== '') {
|
||||
$configJson = $this->di['crypt']->decrypt($row, Config::getProperty('info.salt'));
|
||||
if (is_string($configJson)) {
|
||||
$config = json_decode($configJson, true);
|
||||
if (is_array($config) && isset($config['disable_public_tickets']) && !isset($config['disable_guest_tickets'])) {
|
||||
$config['disable_guest_tickets'] = $config['disable_public_tickets'];
|
||||
unset($config['disable_public_tickets']);
|
||||
$encrypted = $this->di['crypt']->encrypt(json_encode($config, JSON_THROW_ON_ERROR), Config::getProperty('info.salt'));
|
||||
$this->executeSql(
|
||||
"UPDATE extension_meta SET meta_value = :config WHERE extension = 'mod_support' AND meta_key = 'config'",
|
||||
['config' => $encrypted],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->tableExists('support_p_ticket')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move legacy support_p_ticket rows into support_ticket, preserving guest access hashes.
|
||||
$defaultHelpdeskId = $this->fetchOne('SELECT id FROM support_helpdesk ORDER BY id ASC LIMIT 1');
|
||||
if (!$defaultHelpdeskId) {
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$this->executeSql(
|
||||
'INSERT INTO support_helpdesk (name, close_after, can_reopen, created_at, updated_at) VALUES (:name, :close_after, :can_reopen, :created_at, :updated_at)',
|
||||
[
|
||||
'name' => 'General',
|
||||
'close_after' => 24,
|
||||
'can_reopen' => 0,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
$defaultHelpdeskId = $this->fetchOne('SELECT id FROM support_helpdesk ORDER BY id ASC LIMIT 1');
|
||||
}
|
||||
|
||||
$publicTickets = $this->fetchAll('SELECT * FROM support_p_ticket ORDER BY id ASC');
|
||||
foreach ($publicTickets as $publicTicket) {
|
||||
$this->executeSql(
|
||||
'INSERT INTO support_ticket (support_helpdesk_id, client_id, access_hash, author_name, author_email, subject, status, created_at, updated_at)
|
||||
VALUES (:support_helpdesk_id, NULL, :access_hash, :author_name, :author_email, :subject, :status, :created_at, :updated_at)',
|
||||
[
|
||||
'support_helpdesk_id' => $defaultHelpdeskId,
|
||||
'access_hash' => $publicTicket['hash'],
|
||||
'author_name' => $publicTicket['author_name'],
|
||||
'author_email' => $publicTicket['author_email'],
|
||||
'subject' => $publicTicket['subject'],
|
||||
'status' => $publicTicket['status'],
|
||||
'created_at' => $publicTicket['created_at'],
|
||||
'updated_at' => $publicTicket['updated_at'],
|
||||
]
|
||||
);
|
||||
|
||||
$ticketId = (int) $this->getPdo()->lastInsertId();
|
||||
$messages = $this->tableExists('support_p_ticket_message')
|
||||
? $this->fetchAll('SELECT * FROM support_p_ticket_message WHERE support_p_ticket_id = :id ORDER BY id ASC', [
|
||||
'id' => $publicTicket['id'],
|
||||
]) : [];
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->executeSql(
|
||||
'INSERT INTO support_ticket_message (support_ticket_id, admin_id, content, ip, created_at, updated_at)
|
||||
VALUES (:support_ticket_id, :admin_id, :content, :ip, :created_at, :updated_at)',
|
||||
[
|
||||
'support_ticket_id' => $ticketId,
|
||||
'admin_id' => $message['admin_id'],
|
||||
'content' => $message['content'],
|
||||
'ip' => $message['ip'],
|
||||
'created_at' => $message['created_at'],
|
||||
'updated_at' => $message['updated_at'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->tableExists('support_p_ticket_message')) {
|
||||
$this->executeSql('DROP TABLE `support_p_ticket_message`;');
|
||||
}
|
||||
|
||||
$this->executeSql('DROP TABLE `support_p_ticket`;');
|
||||
}
|
||||
|
||||
private function generateDownloadableStoredFilename(): string
|
||||
{
|
||||
do {
|
||||
@@ -1759,158 +2046,4 @@ class UpdatePatcher implements InjectionAwareInterface
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function patch72(): void
|
||||
{
|
||||
$this->executeFileActions([
|
||||
Path::join(PATH_LIBRARY, 'Model', 'Product.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductCategory.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductCustom.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDomain.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDomainTable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductDownloadable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductHosting.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductLicense.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductPayment.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'ProductTable.php') => 'unlink',
|
||||
Path::join(PATH_LIBRARY, 'Model', 'Promo.php') => 'unlink',
|
||||
Path::join(PATH_CACHE, 'classMap.php') => 'unlink',
|
||||
Path::join(PATH_CACHE, 'fallbackClassMap.php') => 'unlink',
|
||||
]);
|
||||
|
||||
$schemaManager = $this->di['dbal']->createSchemaManager();
|
||||
if (!$schemaManager->tablesExist(['promo_redemption'])) {
|
||||
$this->executeSql(
|
||||
"CREATE TABLE `promo_redemption` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`promo_id` bigint(20) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`client_order_id` bigint(20) DEFAULT NULL,
|
||||
`invoice_id` bigint(20) DEFAULT NULL,
|
||||
`phase` varchar(30) NOT NULL DEFAULT 'checkout',
|
||||
`status` varchar(30) NOT NULL DEFAULT 'reserved',
|
||||
`discount_amount` decimal(18,2) DEFAULT NULL,
|
||||
`currency` varchar(20) DEFAULT NULL,
|
||||
`committed_at` datetime DEFAULT NULL,
|
||||
`released_at` datetime DEFAULT NULL,
|
||||
`release_reason` varchar(100) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `promo_id_idx` (`promo_id`),
|
||||
KEY `client_id_idx` (`client_id`),
|
||||
KEY `client_order_id_idx` (`client_order_id`),
|
||||
KEY `invoice_id_idx` (`invoice_id`),
|
||||
KEY `phase_idx` (`phase`),
|
||||
KEY `status_idx` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
|
||||
);
|
||||
}
|
||||
|
||||
$table = $schemaManager->introspectTable('promo_redemption');
|
||||
$columns = [];
|
||||
|
||||
if (!$table->hasColumn('status')) {
|
||||
$columns[] = "ADD COLUMN `status` varchar(30) NOT NULL DEFAULT 'reserved' AFTER `phase`";
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('committed_at')) {
|
||||
$columns[] = 'ADD COLUMN `committed_at` datetime DEFAULT NULL AFTER `currency`';
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('released_at')) {
|
||||
$columns[] = 'ADD COLUMN `released_at` datetime DEFAULT NULL AFTER `committed_at`';
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('release_reason')) {
|
||||
$columns[] = 'ADD COLUMN `release_reason` varchar(100) DEFAULT NULL AFTER `released_at`';
|
||||
}
|
||||
|
||||
if ($columns !== []) {
|
||||
$this->executeSql('ALTER TABLE promo_redemption ' . implode(', ', $columns));
|
||||
}
|
||||
|
||||
$table = $schemaManager->introspectTable('promo_redemption');
|
||||
$expectedIndexes = [
|
||||
'promo_id_idx' => 'promo_id',
|
||||
'client_id_idx' => 'client_id',
|
||||
'client_order_id_idx' => 'client_order_id',
|
||||
'invoice_id_idx' => 'invoice_id',
|
||||
'phase_idx' => 'phase',
|
||||
'status_idx' => 'status',
|
||||
];
|
||||
|
||||
foreach ($expectedIndexes as $indexName => $columnName) {
|
||||
if (!$table->hasIndex($indexName)) {
|
||||
$this->executeSql(sprintf(
|
||||
'ALTER TABLE promo_redemption ADD INDEX `%s` (`%s`)',
|
||||
$indexName,
|
||||
$columnName
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$existingRedemptions = (int) $this->di['dbal']->executeQuery('SELECT COUNT(id) FROM promo_redemption')->fetchOne();
|
||||
if ($existingRedemptions === 0) {
|
||||
$orders = $this->di['dbal']->executeQuery(
|
||||
'SELECT id, promo_id, client_id, promo_used, discount, currency, created_at, updated_at
|
||||
FROM client_order
|
||||
WHERE promo_id IS NOT NULL'
|
||||
)->fetchAllAssociative();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$checkoutCreatedAt = $order['created_at'] ?? date('Y-m-d H:i:s');
|
||||
$renewalCreatedAt = $order['updated_at'] ?: $checkoutCreatedAt;
|
||||
$discountAmount = $order['discount'] !== null ? (float) $order['discount'] : null;
|
||||
|
||||
$this->di['dbal']->insert('promo_redemption', [
|
||||
'promo_id' => $order['promo_id'],
|
||||
'client_id' => $order['client_id'],
|
||||
'client_order_id' => $order['id'],
|
||||
'invoice_id' => null,
|
||||
'phase' => 'checkout',
|
||||
'status' => 'committed',
|
||||
'discount_amount' => $discountAmount,
|
||||
'currency' => $order['currency'],
|
||||
'committed_at' => $checkoutCreatedAt,
|
||||
'released_at' => null,
|
||||
'release_reason' => null,
|
||||
'created_at' => $checkoutCreatedAt,
|
||||
'updated_at' => $checkoutCreatedAt,
|
||||
]);
|
||||
|
||||
$renewalCount = max(0, ((int) ($order['promo_used'] ?? 1)) - 1);
|
||||
for ($i = 0; $i < $renewalCount; ++$i) {
|
||||
$this->di['dbal']->insert('promo_redemption', [
|
||||
'promo_id' => $order['promo_id'],
|
||||
'client_id' => $order['client_id'],
|
||||
'client_order_id' => $order['id'],
|
||||
'invoice_id' => null,
|
||||
'phase' => 'renewal',
|
||||
'status' => 'committed',
|
||||
'discount_amount' => $discountAmount,
|
||||
'currency' => $order['currency'],
|
||||
'committed_at' => $renewalCreatedAt,
|
||||
'released_at' => null,
|
||||
'release_reason' => null,
|
||||
'created_at' => $renewalCreatedAt,
|
||||
'updated_at' => $renewalCreatedAt,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize rows written by a previous partial migration run that pre-dated the
|
||||
// status column; those rows have a NULL/empty status. Legitimate 'reserved'
|
||||
// rows created by concurrent checkouts are left untouched so the payment flow
|
||||
// can commit or release them normally.
|
||||
$this->executeSql("
|
||||
UPDATE promo_redemption
|
||||
SET
|
||||
status = 'committed',
|
||||
committed_at = COALESCE(committed_at, created_at),
|
||||
release_reason = NULL
|
||||
WHERE status IS NULL OR status = ''
|
||||
");
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Copyright 2022-2025 FOSSBilling
|
||||
* Copyright 2011-2021 BoxBilling, Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*
|
||||
* @copyright FOSSBilling (https://www.fossbilling.org)
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
|
||||
*/
|
||||
class Model_SupportPTicket extends RedBeanPHP\SimpleModel
|
||||
{
|
||||
final public const string OPENED = 'open';
|
||||
final public const string ONHOLD = 'on_hold';
|
||||
final public const string CLOSED = 'closed';
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Copyright 2022-2025 FOSSBilling
|
||||
* Copyright 2011-2021 BoxBilling, Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*
|
||||
* @copyright FOSSBilling (https://www.fossbilling.org)
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
|
||||
*/
|
||||
class Model_SupportPTicketMessage extends RedBeanPHP\SimpleModel
|
||||
{
|
||||
}
|
||||
@@ -65,8 +65,12 @@ class Service implements InjectionAwareInterface
|
||||
$antispamService->checkHoneypot($event);
|
||||
}
|
||||
|
||||
public static function onBeforeGuestPublicTicketOpen(\Box_Event $event): void
|
||||
public static function onBeforeClientOpenTicket(\Box_Event $event): void
|
||||
{
|
||||
if ($event->getParameters()['author_role'] !== 'guest') {
|
||||
return;
|
||||
}
|
||||
|
||||
$di = $event->getDi();
|
||||
$antispamService = $di['mod_service']('Antispam');
|
||||
$antispamService->isBlockedIp($event);
|
||||
|
||||
@@ -44,7 +44,7 @@ test('on before client sign up', function (): void {
|
||||
$service->onBeforeClientSignUp($boxEventMock);
|
||||
});
|
||||
|
||||
test('on before guest public ticket open', function (): void {
|
||||
test('on before client open ticket checks guest submissions', function (): void {
|
||||
$service = new Box\Mod\Antispam\Service();
|
||||
$spamCheckerService = Mockery::mock(Box\Mod\Antispam\Service::class);
|
||||
$spamCheckerService->shouldReceive('isBlockedIp')
|
||||
@@ -60,8 +60,28 @@ test('on before guest public ticket open', function (): void {
|
||||
$boxEventMock->shouldReceive('getDi')
|
||||
->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$boxEventMock->shouldReceive('getParameters')
|
||||
->atLeast()->once()
|
||||
->andReturn(['author_role' => 'guest', 'email' => 'guest@example.com']);
|
||||
|
||||
$service->onBeforeGuestPublicTicketOpen($boxEventMock);
|
||||
$service->onBeforeClientOpenTicket($boxEventMock);
|
||||
});
|
||||
|
||||
test('on before client open ticket skips client submissions', function (): void {
|
||||
$service = new Box\Mod\Antispam\Service();
|
||||
$spamCheckerService = Mockery::mock(Box\Mod\Antispam\Service::class);
|
||||
$spamCheckerService->shouldReceive('isBlockedIp')->never();
|
||||
$spamCheckerService->shouldReceive('isSpam')->never();
|
||||
$spamCheckerService->shouldReceive('isTemp')->never();
|
||||
|
||||
$di = container();
|
||||
$di['mod_service'] = $di->protect(fn (): Mockery\MockInterface => $spamCheckerService);
|
||||
$boxEventMock = Mockery::mock('\Box_Event');
|
||||
$boxEventMock->shouldReceive('getParameters')
|
||||
->atLeast()->once()
|
||||
->andReturn(['author_role' => 'client', 'client_id' => 1]);
|
||||
|
||||
$service->onBeforeClientOpenTicket($boxEventMock);
|
||||
});
|
||||
|
||||
test('is blocked ip ip not blocked', function (): void {
|
||||
|
||||
@@ -84,7 +84,6 @@ class Service
|
||||
$this->_exec($api, 'order_batch_suspend_expired');
|
||||
$this->_exec($api, 'order_batch_cancel_suspended');
|
||||
$this->_exec($api, 'support_batch_ticket_auto_close');
|
||||
$this->_exec($api, 'support_batch_public_ticket_auto_close');
|
||||
$this->_exec($api, 'client_batch_expire_password_reminders');
|
||||
$this->_exec($api, 'cart_batch_expire');
|
||||
$this->_exec($api, 'email_batch_sendmail');
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
<div class="embed-field">
|
||||
<label class="embed-label" for="embed-contact-message">{{ 'Message'|trans }}</label>
|
||||
<textarea id="embed-contact-message" class="embed-textarea" name="message" cols="5" rows="5" required="required">{{ request.message }}</textarea>
|
||||
<textarea id="embed-contact-message" class="embed-textarea" name="content" cols="5" rows="5" required="required">{{ request.content }}</textarea>
|
||||
</div>
|
||||
|
||||
{{ include('mod_antispam_recaptcha.html.twig') }}
|
||||
@@ -99,7 +99,7 @@
|
||||
if(json.error) {
|
||||
alert(json.error.message);
|
||||
} else {
|
||||
parent.window.location = "{{ 'support/contact-us/conversation'|url }}" + '/' + json.result;
|
||||
parent.window.location = "{{ 'support/ticket'|url }}" + '/' + json.result;
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
|
||||
@@ -38,7 +38,7 @@ class Client implements \FOSSBilling\InjectionAwareInterface
|
||||
$app->get('/service', 'get_orders', [], '\\' . \Box\Mod\Order\Controller\Client::class);
|
||||
$app->get('/service/manage/:id', 'get_order', ['id' => '[0-9]+'], '\\' . \Box\Mod\Order\Controller\Client::class);
|
||||
$app->get('/contact-us', 'get_contact_us', [], '\\' . \Box\Mod\Support\Controller\Client::class);
|
||||
$app->get('/contact-us/conversation/:hash', 'get_contact_us_conversation', ['hash' => '[a-z0-9]+'], '\\' . \Box\Mod\Support\Controller\Client::class);
|
||||
$app->get('/contact-us/conversation/:hash', 'get_ticket_redirect', ['hash' => '[a-z0-9]+'], '\\' . \Box\Mod\Support\Controller\Client::class);
|
||||
|
||||
$service = $this->di['mod_service']('redirect');
|
||||
$redirects = $service->getRedirects();
|
||||
|
||||
@@ -369,9 +369,9 @@ class Service implements InjectionAwareInterface
|
||||
$ticketModel = $supportTicketService->getTicketById((int) $params['id']);
|
||||
$ticket = $supportTicketService->toApiArray($ticketModel, true);
|
||||
|
||||
$helpdeskModel = $di['db']->load('SupportHelpdesk', $ticketModel->support_helpdesk_id);
|
||||
$helpdeskModel = isset($ticketModel->support_helpdesk_id) && $ticketModel->support_helpdesk_id ? $di['db']->load('SupportHelpdesk', $ticketModel->support_helpdesk_id) : null;
|
||||
$emailService = $di['mod_service']('email');
|
||||
if (!empty($helpdeskModel->email)) {
|
||||
if ($helpdeskModel instanceof \Model_SupportHelpdesk && !empty($helpdeskModel->email)) {
|
||||
$email = [];
|
||||
$email['to'] = $helpdeskModel->email;
|
||||
$email['code'] = 'mod_support_helpdesk_ticket_open';
|
||||
@@ -434,26 +434,6 @@ class Service implements InjectionAwareInterface
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterGuestPublicTicketOpen(\Box_Event $event): void
|
||||
{
|
||||
$params = $event->getParameters();
|
||||
$di = $event->getDi();
|
||||
|
||||
try {
|
||||
$supportTicketService = $di['mod_service']('support');
|
||||
$ticketModel = $supportTicketService->getPublicTicketById((int) $params['id']);
|
||||
$ticket = $supportTicketService->publicToApiArray($ticketModel, true);
|
||||
$email = [];
|
||||
$email['to_staff'] = true;
|
||||
$email['code'] = 'mod_staff_pticket_open';
|
||||
$email['ticket'] = $ticket;
|
||||
$emailService = $di['mod_service']('email');
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send staff public ticket notification email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterClientSignUp(\Box_Event $event): bool
|
||||
{
|
||||
$params = $event->getParameters();
|
||||
@@ -475,46 +455,6 @@ class Service implements InjectionAwareInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function onAfterGuestPublicTicketReply(\Box_Event $event): void
|
||||
{
|
||||
$params = $event->getParameters();
|
||||
$di = $event->getDi();
|
||||
|
||||
try {
|
||||
$supportTicketService = $di['mod_service']('support');
|
||||
$ticketModel = $supportTicketService->getPublicTicketById((int) $params['id']);
|
||||
$ticket = $supportTicketService->publicToApiArray($ticketModel, true);
|
||||
$email = [];
|
||||
$email['to_staff'] = true;
|
||||
$email['code'] = 'mod_staff_pticket_reply';
|
||||
$email['ticket'] = $ticket;
|
||||
$emailService = $di['mod_service']('email');
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send staff public ticket reply notification email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterGuestPublicTicketClose(\Box_Event $event): void
|
||||
{
|
||||
$params = $event->getParameters();
|
||||
$di = $event->getDi();
|
||||
|
||||
try {
|
||||
$supportService = $di['mod_service']('support');
|
||||
$publicTicket = $di['db']->load('SupportPTicket', $params['id']);
|
||||
$ticket = $supportService->publicToApiArray($publicTicket);
|
||||
$email = [];
|
||||
$email['to_staff'] = true;
|
||||
$email['code'] = 'mod_staff_pticket_close';
|
||||
$email['ticket'] = $ticket;
|
||||
$emailService = $di['mod_service']('email');
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send staff public ticket close notification email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getList($data)
|
||||
{
|
||||
$data['no_cron'] = true;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ticket.subject|default('')}} [closed]{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Ticket Closed</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
<p>Public ticket <a href='{{ "support/public-ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">ID {{ ticket.id|default('') }}</a> was closed by the client.</p>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': ticket.author_email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,49 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ ticket.subject|default('') }}{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Ticket Opened</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
<p>New public ticket received.</p>
|
||||
<a href='{{ "support/public-ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">Reply here.</a>
|
||||
<p>Track the conversation <a href='{{ "support/contact-us/conversation/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">here.</a></p>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': ticket.author_email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,49 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ticket.subject|default('')}}{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>New Ticket Reply</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
|
||||
<p>Public ticket {{ticket.id|default('')}} has a new reply.</p>
|
||||
<a href='{{ "support/public-ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">Reply here.</a></p>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': staff.email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -38,7 +38,7 @@
|
||||
<h1>Ticket Closed</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
|
||||
<p><strong>{{ ticket.client.first_name|default('') }} {{ ticket.client.last_name|default('') }}</strong> closed support ticket #{{ ticket.id|default('') }}</p>
|
||||
<p><strong>{{ ticket.author.name|default('') }}</strong> closed support ticket #{{ ticket.id|default('') }}</p>
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">Review the ticket</a>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': staff.email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<h1>Ticket Opened</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
|
||||
<p><strong>{{ ticket.client.first_name|default('') }} {{ ticket.client.last_name|default('') }}</strong> opened a new support ticket #{{ ticket.id|default('') }}</p>
|
||||
<p><strong>{{ ticket.author.name|default('') }}</strong> opened a new support ticket #{{ ticket.id|default('') }}</p>
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">Review the ticket</a>
|
||||
|
||||
<h2>Ticket contents</h2>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<h1>Ticket Reply</h1>
|
||||
<p>Hello {{ staff.name|default('') }},</p>
|
||||
|
||||
<p><strong>{{ ticket.client.first_name|default('') }} {{ ticket.client.last_name|default('') }}</strong> replied to support ticket #{{ ticket.id|default('') }}</p>
|
||||
<p><strong>{{ ticket.author.name|default('') }}</strong> replied to support ticket #{{ ticket.id|default('') }}</p>
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'admin') }}' target="_blank">Review the ticket</a>
|
||||
|
||||
<p>Ticket info</p>
|
||||
|
||||
@@ -311,7 +311,8 @@ test('onAfterClientReplyTicket sends email notification', function (): void {
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once();
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_staff_ticket_reply'));
|
||||
|
||||
$eventMock->shouldReceive('getparameters')->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
@@ -378,7 +379,8 @@ test('onAfterClientCloseTicket sends email notification', function (): void {
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once();
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_staff_ticket_close'));
|
||||
|
||||
$eventMock->shouldReceive('getparameters')->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
@@ -435,17 +437,18 @@ test('onAfterClientCloseTicket handles email exception', function (): void {
|
||||
$service->onAfterClientCloseTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterGuestPublicTicketOpen sends email notification', function (): void {
|
||||
test('onAfterClientOpenTicket sends guest email notification', function (): void {
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getPublicTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$supportServiceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$supportServiceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once();
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_staff_ticket_open'));
|
||||
|
||||
$eventMock->shouldReceive('getparameters')->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
@@ -465,16 +468,16 @@ test('onAfterGuestPublicTicketOpen sends email notification', function (): void
|
||||
$eventMock->shouldReceive('getDi')->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$service->setDi($di);
|
||||
$service->onAfterGuestPublicTicketOpen($eventMock);
|
||||
$service->onAfterClientOpenTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterGuestPublicTicketOpen handles email exception', function (): void {
|
||||
test('onAfterClientOpenTicket handles guest email exception', function (): void {
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getPublicTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$supportServiceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$supportServiceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
@@ -499,20 +502,21 @@ test('onAfterGuestPublicTicketOpen handles email exception', function (): void {
|
||||
$eventMock->shouldReceive('getDi')->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$service->setDi($di);
|
||||
$service->onAfterGuestPublicTicketOpen($eventMock);
|
||||
$service->onAfterClientOpenTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterGuestPublicTicketReply sends email notification', function (): void {
|
||||
test('onAfterClientReplyTicket sends guest email notification', function (): void {
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getPublicTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$supportServiceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$supportServiceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once();
|
||||
$emailServiceMock->shouldReceive('sendTemplate')->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_staff_ticket_reply'));
|
||||
|
||||
$eventMock->shouldReceive('getparameters')->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
@@ -532,16 +536,16 @@ test('onAfterGuestPublicTicketReply sends email notification', function (): void
|
||||
$eventMock->shouldReceive('getDi')->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$service->setDi($di);
|
||||
$service->onAfterGuestPublicTicketReply($eventMock);
|
||||
$service->onAfterClientReplyTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterGuestPublicTicketReply handles email exception', function (): void {
|
||||
test('onAfterClientReplyTicket handles guest email exception', function (): void {
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getPublicTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$supportServiceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$supportServiceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
@@ -566,7 +570,7 @@ test('onAfterGuestPublicTicketReply handles email exception', function (): void
|
||||
$eventMock->shouldReceive('getDi')->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$service->setDi($di);
|
||||
$service->onAfterGuestPublicTicketReply($eventMock);
|
||||
$service->onAfterClientReplyTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterClientSignUp sends email notification', function (): void {
|
||||
@@ -632,11 +636,13 @@ test('onAfterClientSignUp handles email exception', function (): void {
|
||||
$service->onAfterClientSignUp($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterGuestPublicTicketClose handles email exception', function (): void {
|
||||
test('onAfterClientCloseTicket handles guest email exception', function (): void {
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$supportServiceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$emailServiceMock = Mockery::mock(Box\Mod\Email\Service::class);
|
||||
@@ -646,10 +652,6 @@ test('onAfterGuestPublicTicketClose handles email exception', function (): void
|
||||
$eventMock->shouldReceive('getparameters')->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('load')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$service = new Service();
|
||||
|
||||
$di = container();
|
||||
@@ -661,12 +663,10 @@ test('onAfterGuestPublicTicketClose handles email exception', function (): void
|
||||
return $emailServiceMock;
|
||||
}
|
||||
});
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$eventMock->shouldReceive('getDi')->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$service->setDi($di);
|
||||
$service->onAfterGuestPublicTicketClose($eventMock);
|
||||
$service->onAfterClientCloseTicket($eventMock);
|
||||
});
|
||||
|
||||
test('onAfterClientOpenTicket sends mod_staff_ticket_open email', function (): void {
|
||||
@@ -674,6 +674,7 @@ test('onAfterClientOpenTicket sends mod_staff_ticket_open email', function (): v
|
||||
|
||||
$ticketModel = new Model_SupportTicket();
|
||||
$ticketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticketModel->support_helpdesk_id = 1;
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
@@ -728,6 +729,7 @@ test('onAfterClientOpenTicket sends mod_support_helpdesk_ticket_open email', fun
|
||||
|
||||
$ticketModel = new Model_SupportTicket();
|
||||
$ticketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticketModel->support_helpdesk_id = 1;
|
||||
|
||||
$supportServiceMock = Mockery::mock(Box\Mod\Support\Service::class);
|
||||
$supportServiceMock->shouldReceive('getTicketById')->atLeast()->once()
|
||||
|
||||
@@ -185,27 +185,6 @@ class Admin extends \FOSSBilling\Api\AbstractApi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to close all inquiries which have not received any replies for a
|
||||
* time defined in helpdesk.
|
||||
*
|
||||
* Run by cron job
|
||||
*/
|
||||
public function batch_public_ticket_auto_close($data): bool
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
// Auto close public tickets
|
||||
$expired = $this->getService()->publicGetExpired();
|
||||
foreach ($expired as $model) {
|
||||
if (!$this->getService()->publicAutoClose($model)) {
|
||||
$this->getDi()['logger']->info('Public Ticket %s was not closed', $model->id);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return tickets statuses with counter.
|
||||
*/
|
||||
@@ -220,134 +199,6 @@ class Admin extends \FOSSBilling\Api\AbstractApi
|
||||
return $this->getService()->counter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paginated list of inquiries.
|
||||
*/
|
||||
public function public_ticket_get_list(array $data): array
|
||||
{
|
||||
$this->checkPermissions('support', 'view');
|
||||
|
||||
[$sql, $bindings] = $this->getService()->publicGetSearchQuery($data);
|
||||
$pager = $this->getDi()['pager']->getPaginatedResultSet($sql, $bindings, PaginationOptions::fromArray($data));
|
||||
|
||||
foreach ($pager['list'] as $key => $ticketArr) {
|
||||
$ticket = $this->getDi()['db']->getExistingModelById('SupportPTicket', $ticketArr['id'], 'Ticket not found');
|
||||
$pager['list'][$key] = $this->getService()->publicToApiArray($ticket, true, $this->getIdentity());
|
||||
}
|
||||
|
||||
return $pager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new public inquiry.
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['name' => 'Name is required', 'email' => 'Email is required', 'subject' => 'Subject is required', 'message' => 'Message is required'])]
|
||||
public function public_ticket_create(array $data): int
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
$data['subject'] = \FOSSBilling\Tools::sanitizeContent($data['subject'], false);
|
||||
$data['message'] = \FOSSBilling\Tools::sanitizeContent($data['message'], true);
|
||||
|
||||
return $this->getService()->publicTicketCreate($data, $this->getIdentity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inquiry details.
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['id' => 'Ticket ID is missing'])]
|
||||
public function public_ticket_get(array $data): array
|
||||
{
|
||||
$this->checkPermissions('support', 'view');
|
||||
|
||||
$model = $this->getDi()['db']->getExistingModelById('SupportPTicket', $data['id'], 'Ticket not found');
|
||||
|
||||
return $this->getService()->publicToApiArray($model, true, $this->getIdentity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete inquiry.
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['id' => 'Ticket ID is missing'])]
|
||||
public function public_ticket_delete(array $data): bool
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
$model = $this->getDi()['db']->getExistingModelById('SupportPTicket', $data['id'], 'Ticket not found');
|
||||
|
||||
return $this->getService()->publicRm($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id status to closed.
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['id' => 'Ticket ID is missing'])]
|
||||
public function public_ticket_close(array $data): bool
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
$ticket = $this->getDi()['db']->getExistingModelById('SupportPTicket', $data['id'], 'Ticket not found');
|
||||
|
||||
return $this->getService()->publicCloseTicket($ticket, $this->getIdentity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update inquiry details.
|
||||
*
|
||||
* @optional string $subject - subject
|
||||
* @optional string $status - status
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['id' => 'Ticket ID is missing'])]
|
||||
public function public_ticket_update(array $data): bool
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
$model = $this->getDi()['db']->getExistingModelById('SupportPTicket', $data['id'], 'Ticket not found');
|
||||
|
||||
return $this->getService()->publicTicketUpdate($model, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post new reply to inquiry.
|
||||
*
|
||||
* @throws \FOSSBilling\Exception
|
||||
*/
|
||||
#[RequiredParams(['id' => 'Ticket ID is missing', 'content' => 'Ticket content required'])]
|
||||
public function public_ticket_reply(array $data): int
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
$data['content'] = \FOSSBilling\Tools::sanitizeContent($data['content'], true);
|
||||
|
||||
$ticket = $this->getDi()['db']->getExistingModelById('SupportPTicket', $data['id'], 'Ticket not found');
|
||||
|
||||
return $this->getService()->publicTicketReply($ticket, $this->getIdentity(), $data['content']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return tickets statuses with counter.
|
||||
*/
|
||||
public function public_ticket_get_statuses(array $data): array
|
||||
{
|
||||
$this->checkPermissions('support', 'view');
|
||||
|
||||
if (isset($data['titles'])) {
|
||||
return $this->getService()->publicGetStatuses();
|
||||
}
|
||||
|
||||
return $this->getService()->publicCounter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get helpdesk list.
|
||||
*/
|
||||
@@ -677,21 +528,6 @@ class Admin extends \FOSSBilling\Api\AbstractApi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes tickets with given IDs.
|
||||
*/
|
||||
#[RequiredParams(['ids' => 'IDs were not passed'])]
|
||||
public function batch_delete_public($data): bool
|
||||
{
|
||||
$this->checkPermissions('support', 'manage_tickets');
|
||||
|
||||
foreach ($data['ids'] as $id) {
|
||||
$this->public_ticket_delete(['id' => $id]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support Knowledge Base.
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ use FOSSBilling\Validation\Api\RequiredParams;
|
||||
class Client extends \FOSSBilling\Api\AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get client tickets list.
|
||||
* Get the list of tickets for the logged in client.
|
||||
*
|
||||
* @optional string status - filter tickets by status
|
||||
* @optional string date_from - show tickets created since this day. Can be any string parsable by strtotime()
|
||||
|
||||
@@ -10,10 +10,6 @@ declare(strict_types=1);
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Public tickets management.
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Support\Api;
|
||||
|
||||
use FOSSBilling\PaginationOptions;
|
||||
@@ -22,7 +18,7 @@ use FOSSBilling\Validation\Api\RequiredParams;
|
||||
class Guest extends \FOSSBilling\Api\AbstractApi
|
||||
{
|
||||
/**
|
||||
* Submit new public ticket.
|
||||
* Submit new ticket.
|
||||
*
|
||||
* @return string - ticket hash
|
||||
*/
|
||||
@@ -30,72 +26,88 @@ class Guest extends \FOSSBilling\Api\AbstractApi
|
||||
'name' => 'Please enter your name',
|
||||
'email' => 'Please enter your email address',
|
||||
'subject' => 'Please enter the subject',
|
||||
'message' => 'Please enter your message',
|
||||
])]
|
||||
public function ticket_create(array $data): string
|
||||
{
|
||||
$this->getDi()['rate_limiter']->consumeOrThrow('guest_ticket_create', (string) $this->getIp());
|
||||
|
||||
if (!is_string($data['message']) || strlen($data['message']) < 4) {
|
||||
// Deprecated 0.9.0 The 'message' parameter will be dropped. Update your themes to use 'content' instead.
|
||||
$content = $data['content'] ?? $data['message'] ?? null;
|
||||
if (!is_string($content) || strlen($content) < 4) {
|
||||
throw new \FOSSBilling\InformationException('Please enter your message');
|
||||
}
|
||||
|
||||
$data['email'] = $this->getDi()['tools']->validateAndSanitizeEmail($data['email']);
|
||||
$this->getDi()['rate_limiter']->consumeOrThrow('guest_ticket_create', (string) $this->getIp());
|
||||
|
||||
// Sanitize message to prevent XSS attacks
|
||||
$data['message'] = \FOSSBilling\Tools::sanitizeContent($data['message'], true);
|
||||
$data['content'] = \FOSSBilling\Tools::sanitizeContent($content, true);
|
||||
|
||||
return $this->getService()->ticketCreateForGuest($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public ticket.
|
||||
* Get ticket.
|
||||
*
|
||||
* @return array - ticket details
|
||||
*/
|
||||
#[RequiredParams(['hash' => 'Public ticket hash required'])]
|
||||
#[RequiredParams(['hash' => 'Ticket hash required'])]
|
||||
public function ticket_get(array $data): array
|
||||
{
|
||||
$publicTicket = $this->getService()->publicFindOneByHash($data['hash']);
|
||||
$guestTicket = $this->getService()->findOneByHash($data['hash']);
|
||||
|
||||
return $this->getService()->publicToApiArray($publicTicket);
|
||||
return $this->getService()->toApiArray($guestTicket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close public ticket.
|
||||
* Close ticket.
|
||||
*/
|
||||
#[RequiredParams(['hash' => 'Public ticket hash required'])]
|
||||
#[RequiredParams(['hash' => 'Ticket hash required'])]
|
||||
public function ticket_close(array $data): bool
|
||||
{
|
||||
$publicTicket = $this->getService()->publicFindOneByHash($data['hash']);
|
||||
$guestTicket = $this->getService()->findOneByHash($data['hash']);
|
||||
|
||||
return $this->getService()->publicCloseTicket($publicTicket, $this->getIdentity());
|
||||
return $this->getService()->closeTicket($guestTicket, $this->getIdentity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to public ticket.
|
||||
*
|
||||
* @return string - ticket hash
|
||||
* Reply to ticket.
|
||||
*/
|
||||
#[RequiredParams(['hash' => 'Public ticket hash required', 'message' => 'Message cannot be empty'])]
|
||||
public function ticket_reply(array $data): string
|
||||
#[RequiredParams(['hash' => 'Ticket hash required'])]
|
||||
public function ticket_reply(array $data): int
|
||||
{
|
||||
$publicTicket = $this->getService()->publicFindOneByHash($data['hash']);
|
||||
$guestTicket = $this->getService()->findOneByHash($data['hash']);
|
||||
// Deprecated 0.9.0 The 'message' parameter will be dropped. Update your themes to use 'content' instead.
|
||||
$message = $data['content'] ?? $data['message'] ?? null;
|
||||
|
||||
if (!is_string($data['message'])) {
|
||||
if (!is_string($message)) {
|
||||
throw new \FOSSBilling\InformationException('Message cannot be empty');
|
||||
}
|
||||
|
||||
// Sanitize message to prevent XSS attacks
|
||||
$data['message'] = \FOSSBilling\Tools::sanitizeContent($data['message'], true);
|
||||
$message = \FOSSBilling\Tools::sanitizeContent($message, true);
|
||||
|
||||
return $this->getService()->publicTicketReplyForGuest($publicTicket, $data['message']);
|
||||
return $this->getService()->ticketReply($guestTicket, new \Model_Guest(), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether public tickets are enabled for guests.
|
||||
* Get whether guest tickets are enabled.
|
||||
*/
|
||||
public function guest_tickets_enabled(): bool
|
||||
{
|
||||
return $this->getService()->guestTicketsEnabled();
|
||||
}
|
||||
|
||||
public function public_tickets_enabled(): bool
|
||||
{
|
||||
return $this->getService()->publicTicketsEnabled();
|
||||
// @deprecated 0.9.0 Use guest_tickets_enabled instead.
|
||||
return $this->guest_tickets_enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return pairs for support helpdesks. Can be used to populate the select box.
|
||||
*/
|
||||
public function helpdesk_get_pairs(): array
|
||||
{
|
||||
return $this->getService()->helpdeskGetPairs();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -38,18 +38,11 @@ class Admin implements \FOSSBilling\InjectionAwareInterface
|
||||
'subpages' => [
|
||||
[
|
||||
'location' => 'support',
|
||||
'label' => __trans('Client Tickets'),
|
||||
'label' => __trans('Support Tickets'),
|
||||
'uri' => $this->di['url']->adminLink('support', ['status' => 'open']),
|
||||
'index' => 100,
|
||||
'class' => '',
|
||||
],
|
||||
[
|
||||
'location' => 'support',
|
||||
'label' => __trans('Public Tickets'),
|
||||
'uri' => $this->di['url']->adminLink('support/public-tickets', ['status' => 'open']),
|
||||
'index' => 200,
|
||||
'class' => '',
|
||||
],
|
||||
[
|
||||
'location' => 'support',
|
||||
'label' => __trans('Canned Responses'),
|
||||
@@ -81,8 +74,6 @@ class Admin implements \FOSSBilling\InjectionAwareInterface
|
||||
$app->get('/support/index', 'get_index', [], static::class);
|
||||
$app->get('/support/ticket/:id', 'get_ticket', ['id' => '[0-9]+'], static::class);
|
||||
$app->get('/support/ticket/:id/message/:messageid', 'get_ticket', ['id' => '[0-9]+', 'messageid' => '[0-9]+'], static::class);
|
||||
$app->get('/support/public-tickets', 'get_public_tickets', [], static::class);
|
||||
$app->get('/support/public-ticket/:id', 'get_public_ticket', ['id' => '[0-9]+'], static::class);
|
||||
$app->get('/support/helpdesks', 'get_helpdesks', [], static::class);
|
||||
$app->get('/support/helpdesk/:id', 'get_helpdesk', ['id' => '[0-9]+'], static::class);
|
||||
$app->get('/support/canned-responses', 'get_canned_list', [], static::class);
|
||||
@@ -130,40 +121,6 @@ class Admin implements \FOSSBilling\InjectionAwareInterface
|
||||
return $app->render('mod_support_ticket', ['ticket' => $ticket, 'canned_delay_message' => $cdm, 'request_message' => $messageid]);
|
||||
}
|
||||
|
||||
public function get_public_tickets(\Box_App $app): string
|
||||
{
|
||||
$this->di['is_admin_logged'];
|
||||
|
||||
return $app->render('mod_support_public_tickets');
|
||||
}
|
||||
|
||||
public function get_public_ticket(\Box_App $app, $id): string
|
||||
{
|
||||
$api = $this->di['api_admin'];
|
||||
$ticket = $api->support_public_ticket_get(['id' => $id]);
|
||||
|
||||
$cdm = '';
|
||||
$mod = $this->di['mod']('support');
|
||||
$config = $mod->getConfig();
|
||||
|
||||
try {
|
||||
if (isset($config['delay_enable']) && $config['delay_enable'] && isset($config['delay_hours']) && $config['delay_hours'] >= 0) {
|
||||
$last_message = end($ticket['messages']);
|
||||
reset($ticket);
|
||||
|
||||
$hours_passed = (round((time() - strtotime((string) $last_message['created_at'])) / 3600) > $config['delay_hours']);
|
||||
if ($hours_passed) {
|
||||
$delay_canned = $api->support_canned_get(['id' => $config['delay_message_id']]);
|
||||
$cdm = $delay_canned['content'];
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->di['logger']->error($e->getMessage());
|
||||
}
|
||||
|
||||
return $app->render('mod_support_public_ticket', ['ticket' => $ticket, 'canned_delay_message' => $cdm]);
|
||||
}
|
||||
|
||||
public function get_helpdesk(\Box_App $app, $id): string
|
||||
{
|
||||
$api = $this->di['api_admin'];
|
||||
|
||||
@@ -31,7 +31,7 @@ class Client implements \FOSSBilling\InjectionAwareInterface
|
||||
$app->get('/support', 'get_tickets', [], static::class);
|
||||
$app->get('/support/ticket/:id', 'get_ticket', [], static::class);
|
||||
$app->get('/support/contact-us', 'get_contact_us', [], static::class);
|
||||
$app->get('/support/contact-us/conversation/:hash', 'get_contact_us_conversation', ['hash' => '[a-z0-9]+'], static::class);
|
||||
$app->get('/support/contact-us/conversation/:hash', 'get_ticket_redirect', ['hash' => '[a-z0-9]+'], static::class);
|
||||
|
||||
if ($this->di['mod']('support')->getService()->kbEnabled()) {
|
||||
$app->get('/support/kb', 'get_kb_index', [], static::class);
|
||||
@@ -49,8 +49,13 @@ class Client implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
public function get_ticket(\Box_App $app, $id): string
|
||||
{
|
||||
$api = $this->di['api_client'];
|
||||
$ticket = $api->support_ticket_get(['id' => $id]);
|
||||
$id = (string) $id;
|
||||
if (ctype_digit($id) && strlen($id) < 30) {
|
||||
$this->di['is_client_logged'];
|
||||
$ticket = $this->di['api_client']->support_ticket_get(['id' => $id]);
|
||||
} else {
|
||||
$ticket = $this->di['api_guest']->support_ticket_get(['hash' => $id]);
|
||||
}
|
||||
|
||||
return $app->render('mod_support_ticket', ['ticket' => $ticket]);
|
||||
}
|
||||
@@ -60,15 +65,14 @@ class Client implements \FOSSBilling\InjectionAwareInterface
|
||||
return $app->render('mod_support_contact_us');
|
||||
}
|
||||
|
||||
public function get_contact_us_conversation(\Box_App $app, $hash): string
|
||||
/**
|
||||
* A redirect to keep old guest ticket links working.
|
||||
*
|
||||
* /support/contact-us/conversation/:hash -> /support/ticket/:hash
|
||||
*/
|
||||
public function get_ticket_redirect(\Box_App $app, $hash): never
|
||||
{
|
||||
$api = $this->di['api_guest'];
|
||||
$data = [
|
||||
'hash' => $hash,
|
||||
];
|
||||
$array = $api->support_ticket_get($data);
|
||||
|
||||
return $app->render('mod_support_contact_us_conversation', ['ticket' => $array]);
|
||||
$app->redirect('support/ticket/' . $hash);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+188
-460
@@ -69,11 +69,17 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
try {
|
||||
$ticketObj = $supportService->getTicketById((int) $params['id']);
|
||||
$identity = $di['loggedin_client'];
|
||||
$isGuestTicket = $supportService->isGuestTicket($ticketObj);
|
||||
$identity = $isGuestTicket ? null : $di['loggedin_client'];
|
||||
$ticketArr = $supportService->toApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
if ($isGuestTicket) {
|
||||
$email['to'] = $ticketObj->author_email;
|
||||
$email['to_name'] = $ticketObj->author_name;
|
||||
} else {
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
}
|
||||
$email['code'] = 'mod_support_ticket_open';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
@@ -95,7 +101,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$ticketArr = $supportService->toApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
if ($supportService->isGuestTicket($ticketObj)) {
|
||||
$email['to'] = $ticketObj->author_email;
|
||||
$email['to_name'] = $ticketObj->author_name;
|
||||
} else {
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
}
|
||||
$email['code'] = 'mod_support_ticket_staff_open';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
@@ -117,7 +128,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$ticketArr = $supportService->toApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
if ($supportService->isGuestTicket($ticketObj)) {
|
||||
$email['to'] = $ticketObj->author_email;
|
||||
$email['to_name'] = $ticketObj->author_name;
|
||||
} else {
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
}
|
||||
$email['code'] = 'mod_support_ticket_staff_close';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
@@ -139,7 +155,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$ticketArr = $supportService->toApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
if ($supportService->isGuestTicket($ticketObj)) {
|
||||
$email['to'] = $ticketObj->author_email;
|
||||
$email['to_name'] = $ticketObj->author_name;
|
||||
} else {
|
||||
$email['to_client'] = $ticketObj->client_id;
|
||||
}
|
||||
$email['code'] = 'mod_support_ticket_staff_reply';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
@@ -148,105 +169,19 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterGuestPublicTicketOpen(\Box_Event $event): void
|
||||
{
|
||||
$di = $event->getDi();
|
||||
$supportService = $di['mod_service']('support');
|
||||
$emailService = $di['mod_service']('email');
|
||||
$params = $event->getParameters();
|
||||
|
||||
try {
|
||||
$ticketObj = $supportService->getPublicTicketById((int) $params['id']);
|
||||
$ticketArr = $supportService->publicToApiArray($ticketObj, true);
|
||||
|
||||
$email = [];
|
||||
$email['to'] = $ticketObj->author_email;
|
||||
$email['to_name'] = $ticketObj->author_name;
|
||||
$email['code'] = 'mod_support_pticket_open';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send public ticket open email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterAdminPublicTicketOpen(\Box_Event $event): void
|
||||
{
|
||||
$di = $event->getDi();
|
||||
$supportService = $di['mod_service']('support');
|
||||
$emailService = $di['mod_service']('email');
|
||||
$params = $event->getParameters();
|
||||
|
||||
try {
|
||||
$ticketObj = $supportService->getPublicTicketById((int) $params['id']);
|
||||
$identity = $di['loggedin_admin'];
|
||||
$ticketArr = $supportService->publicToApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to'] = $ticketArr['author_email'];
|
||||
$email['to_name'] = $ticketArr['author_name'];
|
||||
$email['code'] = 'mod_support_pticket_staff_open';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send admin public ticket open email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterAdminPublicTicketReply(\Box_Event $event): void
|
||||
{
|
||||
$di = $event->getDi();
|
||||
$supportService = $di['mod_service']('support');
|
||||
$emailService = $di['mod_service']('email');
|
||||
$params = $event->getParameters();
|
||||
|
||||
try {
|
||||
$ticketObj = $supportService->getPublicTicketById((int) $params['id']);
|
||||
$identity = $di['loggedin_admin'];
|
||||
$ticketArr = $supportService->publicToApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to'] = $ticketArr['author_email'];
|
||||
$email['to_name'] = $ticketArr['author_name'];
|
||||
$email['code'] = 'mod_support_pticket_staff_reply';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send admin public ticket reply email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterAdminPublicTicketClose(\Box_Event $event): void
|
||||
{
|
||||
$di = $event->getDi();
|
||||
$supportService = $di['mod_service']('support');
|
||||
$emailService = $di['mod_service']('email');
|
||||
$params = $event->getParameters();
|
||||
|
||||
try {
|
||||
$ticketObj = $supportService->getPublicTicketById((int) $params['id']);
|
||||
$identity = $di['loggedin_admin'];
|
||||
$ticketArr = $supportService->publicToApiArray($ticketObj, true, $identity);
|
||||
|
||||
$email = [];
|
||||
$email['to'] = $ticketArr['author_email'];
|
||||
$email['to_name'] = $ticketArr['author_name'];
|
||||
$email['code'] = 'mod_support_pticket_staff_close';
|
||||
$email['ticket'] = $ticketArr;
|
||||
$emailService->sendTemplate($email);
|
||||
} catch (\Exception $exc) {
|
||||
$di['logger']->setChannel('email')->error('Failed to send admin public ticket close email', ['exception' => $exc->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTicketById(int $id): \Model_SupportTicket
|
||||
{
|
||||
return $this->di['db']->getExistingModelById('SupportTicket', $id, 'Ticket not found');
|
||||
}
|
||||
|
||||
public function getPublicTicketById(int $id): \Model_SupportPTicket
|
||||
/**
|
||||
* Determine if the provided ticket is a guest ticket
|
||||
*
|
||||
* @todo Doctrine: Move this to the Entity when migrating to Doctrine
|
||||
*/
|
||||
public function isGuestTicket(\Model_SupportTicket $ticket): bool
|
||||
{
|
||||
return $this->di['db']->getExistingModelById('SupportPTicket', $id, 'Ticket not found');
|
||||
return empty($ticket->client_id) && !empty($ticket->access_hash);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,6 +235,9 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$date_from = $data['date_from'] ?? null;
|
||||
$date_to = $data['date_to'] ?? null;
|
||||
$priority = $data['priority'] ?? null;
|
||||
$auth = $data['auth'] ?? null;
|
||||
$name = $data['name'] ?? null;
|
||||
$email = $data['email'] ?? null;
|
||||
|
||||
$where = [];
|
||||
$bindings = [];
|
||||
@@ -331,6 +269,22 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$bindings[':client_id'] = $client_id;
|
||||
}
|
||||
|
||||
if ($auth === 'guest') {
|
||||
$where[] = 'st.client_id IS NULL AND st.access_hash IS NOT NULL';
|
||||
} elseif ($auth === 'client') {
|
||||
$where[] = 'st.client_id IS NOT NULL';
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
$where[] = 'st.author_name LIKE :filter_author_name';
|
||||
$bindings[':filter_author_name'] = '%' . $name . '%';
|
||||
}
|
||||
|
||||
if ($email) {
|
||||
$where[] = 'st.author_email LIKE :filter_author_email';
|
||||
$bindings[':filter_author_email'] = '%' . $email . '%';
|
||||
}
|
||||
|
||||
if ($content) {
|
||||
$where[] = 'stm.content LIKE :content';
|
||||
$bindings[':content'] = '%' . $content . '%';
|
||||
@@ -373,9 +327,11 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$bindings[':ticket_id'] = $search;
|
||||
} else {
|
||||
$search = '%' . $search . '%';
|
||||
$where[] = '(stm.content LIKE :content OR st.subject LIKE :subject)';
|
||||
$where[] = '(stm.content LIKE :content OR st.subject LIKE :subject OR st.author_name LIKE :author_name OR st.author_email LIKE :author_email)';
|
||||
$bindings[':content'] = $search;
|
||||
$bindings[':subject'] = $search;
|
||||
$bindings[':author_name'] = $search;
|
||||
$bindings[':author_email'] = $search;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,7 +428,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
return $ticket instanceof \Model_SupportTicket;
|
||||
}
|
||||
|
||||
public function closeTicket(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client $identity): bool
|
||||
public function closeTicket(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client|\Model_Guest $identity): bool
|
||||
{
|
||||
$ticket->status = \Model_SupportTicket::CLOSED;
|
||||
$ticket->updated_at = date('Y-m-d H:i:s');
|
||||
@@ -481,7 +437,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterAdminCloseTicket', 'params' => ['id' => $ticket->id]]);
|
||||
} elseif ($identity instanceof \Model_Client) {
|
||||
} else {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterClientCloseTicket', 'params' => ['id' => $ticket->id]]);
|
||||
}
|
||||
|
||||
@@ -574,12 +530,14 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
public function toApiArray(\Model_SupportTicket $model, bool $deep = true, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
{
|
||||
$firstSupportTicketMessage = $this->di['db']->findOne('SupportTicketMessage', 'support_ticket_id = :support_ticket_id ORDER by id ASC LIMIT 1', [':support_ticket_id' => $model->id]);
|
||||
$supportHelpdesk = $this->di['db']->load('SupportHelpdesk', $model->support_helpdesk_id);
|
||||
$supportHelpdesk = $model->support_helpdesk_id ? $this->di['db']->load('SupportHelpdesk', $model->support_helpdesk_id) : null;
|
||||
|
||||
$data = $this->ticketToApiArray($this->di['db']->toArray($model), $identity);
|
||||
$data['replies'] = $this->messageGetRepliesCount($model);
|
||||
$data['first'] = $firstSupportTicketMessage instanceof \Model_SupportTicketMessage ? $this->messageToApiArray($firstSupportTicketMessage, true, $identity) : null;
|
||||
$data['helpdesk'] = $this->helpdeskToApiArray($supportHelpdesk, $identity);
|
||||
$data['helpdesk'] = $supportHelpdesk instanceof \Model_SupportHelpdesk ? $this->helpdeskToApiArray($supportHelpdesk, $identity) : null;
|
||||
$data['author'] = $this->getTicketAuthor($model, $identity);
|
||||
// @deprecated 0.9.0 Use author instead.
|
||||
$data['client'] = $this->getClientApiArrayForTicket($model, $identity);
|
||||
|
||||
if ($deep) {
|
||||
@@ -605,14 +563,21 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
private function ticketToApiArray(array $data, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
{
|
||||
if (!empty($data['access_hash'])) {
|
||||
$data['hash'] = $data['access_hash'];
|
||||
}
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// @deprecated 0.9.0 Use author.id/name/email instead of client_id/author_name/author_email.
|
||||
|
||||
unset(
|
||||
$data['support_helpdesk_id'],
|
||||
$data['client_id'],
|
||||
$data['priority'],
|
||||
$data['access_hash'],
|
||||
$data['rel_type'],
|
||||
$data['rel_id'],
|
||||
$data['rel_task'],
|
||||
@@ -699,11 +664,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
}
|
||||
|
||||
$clients = [];
|
||||
$clientAuthors = [];
|
||||
if (!empty($clientIds)) {
|
||||
$placeholders = implode(',', array_fill(0, count($clientIds), '?'));
|
||||
$clientModels = $this->di['db']->find('Client', "id IN ($placeholders)", $clientIds);
|
||||
foreach ($clientModels as $client) {
|
||||
$clients[$client->id] = $this->clientToTicketApiArray($client, $identity);
|
||||
$clientAuthors[$client->id] = $this->clientToTicketAuthorArray($client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,10 +683,22 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$helpdesk = $helpdesks[$ticket['support_helpdesk_id']] ?? null;
|
||||
$data['helpdesk'] = $helpdesk ? $this->helpdeskToApiArray($helpdesk, $identity) : null;
|
||||
|
||||
if (!isset($clients[$ticket['client_id']])) {
|
||||
if (empty($ticket['client_id']) && !empty($ticket['access_hash'])) {
|
||||
$data['author'] = [
|
||||
'name' => $ticket['author_name'],
|
||||
'email' => $ticket['author_email'],
|
||||
'role' => 'guest',
|
||||
];
|
||||
// @deprecated 0.9.0 Use author instead.
|
||||
$data['client'] = [];
|
||||
} elseif (!isset($clients[$ticket['client_id']])) {
|
||||
$this->di['logger']->error('Missing client for ticket ' . $ticket['id']);
|
||||
$data['author'] = [];
|
||||
// @deprecated 0.9.0 Use author instead.
|
||||
$data['client'] = [];
|
||||
} else {
|
||||
$data['author'] = $clientAuthors[$ticket['client_id']];
|
||||
// @deprecated 0.9.0 Use author instead.
|
||||
$data['client'] = $clients[$ticket['client_id']];
|
||||
}
|
||||
|
||||
@@ -774,8 +753,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
return $ordered;
|
||||
}
|
||||
|
||||
public function getClientApiArrayForTicket(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
private function getClientApiArrayForTicket(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
{
|
||||
if ($this->isGuestTicket($ticket)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$client = $this->di['db']->load('Client', $ticket->client_id);
|
||||
|
||||
if ($client instanceof \Model_Client) {
|
||||
@@ -786,6 +769,43 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getTicketAuthor(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
{
|
||||
if ($this->isGuestTicket($ticket)) {
|
||||
$author = [
|
||||
'name' => $ticket->author_name,
|
||||
'role' => 'guest',
|
||||
];
|
||||
|
||||
if ($identity instanceof \Model_Admin || $identity === null) {
|
||||
$author['email'] = $ticket->author_email;
|
||||
}
|
||||
|
||||
return $author;
|
||||
}
|
||||
|
||||
$client = $this->di['db']->load('Client', $ticket->client_id);
|
||||
|
||||
if ($client instanceof \Model_Client) {
|
||||
return $this->clientToTicketAuthorArray($client);
|
||||
}
|
||||
$this->di['logger']->error('Missing client for ticket ' . $ticket->id);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function clientToTicketAuthorArray(\Model_Client $client): array
|
||||
{
|
||||
return [
|
||||
'id' => $client->id,
|
||||
'name' => $client->getFullName(),
|
||||
'first_name' => $client->first_name,
|
||||
'last_name' => $client->last_name,
|
||||
'email' => $client->email,
|
||||
'role' => 'client',
|
||||
];
|
||||
}
|
||||
|
||||
private function clientToTicketApiArray(\Model_Client $client, \Model_Admin|\Model_Client|null $identity = null): array
|
||||
{
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
@@ -910,9 +930,21 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
if ($model->admin_id) {
|
||||
$author = $this->di['db']->load('Admin', $model->admin_id);
|
||||
$role = 'admin';
|
||||
} else {
|
||||
} elseif ($model->client_id) {
|
||||
$author = $this->di['db']->load('Client', $model->client_id);
|
||||
$role = 'client';
|
||||
} else {
|
||||
$ticket = $this->di['db']->load('SupportTicket', $model->support_ticket_id);
|
||||
|
||||
if ($ticket instanceof \Model_SupportTicket && $this->isGuestTicket($ticket)) {
|
||||
return [
|
||||
'name' => $ticket->author_name,
|
||||
'email' => $ticket->author_email,
|
||||
'role' => 'guest',
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!$author) {
|
||||
@@ -978,7 +1010,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
/**
|
||||
* @param \Model_Admin $identity
|
||||
*/
|
||||
public function ticketReply(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client $identity, string $content): int
|
||||
public function ticketReply(\Model_SupportTicket $ticket, \Model_Admin|\Model_Client|\Model_Guest $identity, string $content): int
|
||||
{
|
||||
$msg = $this->di['db']->dispense('SupportTicketMessage');
|
||||
$msg->support_ticket_id = $ticket->id;
|
||||
@@ -995,7 +1027,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$ticket->status = \Model_SupportTicket::ONHOLD;
|
||||
} elseif ($identity instanceof \Model_Client) {
|
||||
} else {
|
||||
$ticket->status = \Model_SupportTicket::OPENED;
|
||||
}
|
||||
|
||||
@@ -1004,7 +1036,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterAdminReplyTicket', 'params' => ['id' => $ticket->id]]);
|
||||
} elseif ($identity instanceof \Model_Client) {
|
||||
} else {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterClientReplyTicket', 'params' => ['id' => $ticket->id]]);
|
||||
}
|
||||
|
||||
@@ -1046,28 +1078,35 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
|
||||
public function ticketCreateForGuest(array $data): string
|
||||
{
|
||||
if (!$this->publicTicketsEnabled()) {
|
||||
if (!$this->guestTicketsEnabled()) {
|
||||
throw new InformationException("We currently aren't accepting support tickets from unregistered users. Please use another contact method.");
|
||||
}
|
||||
|
||||
$data['email'] = $this->di['tools']->validateAndSanitizeEmail($data['email']);
|
||||
$data['content'] = $data['content'] ?? $data['message'] ?? null;
|
||||
|
||||
SupportTicketValidator::validateTicketCreation($data);
|
||||
|
||||
$event_params = $data;
|
||||
$event_params['author_role'] = 'guest';
|
||||
$event_params['ip'] = $this->di['request']->getClientIp();
|
||||
$altered = $this->di['events_manager']->fire(['event' => 'onBeforeGuestPublicTicketOpen', 'params' => $event_params]);
|
||||
$altered = $this->di['events_manager']->fire(['event' => 'onBeforeClientOpenTicket', 'params' => $event_params]);
|
||||
|
||||
$status = 'open';
|
||||
$subject = $data['subject'] ?? null;
|
||||
$message = $data['message'] ?? null;
|
||||
$message = $data['content'] ?? null;
|
||||
|
||||
if (is_array($altered)) {
|
||||
$status = $altered['status'] ?? null;
|
||||
$subject = $altered['subject'] ?? null;
|
||||
$message = $altered['message'] ?? null;
|
||||
$message = $altered['content'] ?? $altered['message'] ?? null;
|
||||
}
|
||||
|
||||
$ticket = $this->di['db']->dispense('SupportPTicket');
|
||||
$ticket->hash = bin2hex(random_bytes(random_int(15, 30)));
|
||||
$helpdesk = isset($data['support_helpdesk_id']) ? $this->di['db']->getExistingModelById('SupportHelpdesk', $data['support_helpdesk_id'], 'Helpdesk invalid') : $this->getDefaultHelpdesk();
|
||||
|
||||
$ticket = $this->di['db']->dispense('SupportTicket');
|
||||
$ticket->access_hash = bin2hex(random_bytes(random_int(15, 30)));
|
||||
$ticket->support_helpdesk_id = $helpdesk->id;
|
||||
$ticket->author_name = $data['name'];
|
||||
$ticket->author_email = $data['email'];
|
||||
$ticket->subject = $subject;
|
||||
@@ -1076,27 +1115,48 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
$ticket->updated_at = date('Y-m-d H:i:s');
|
||||
$ticketId = $this->di['db']->store($ticket);
|
||||
|
||||
$msg = $this->di['db']->dispense('SupportPTicketMessage');
|
||||
$msg->support_p_ticket_id = $ticket->id;
|
||||
$msg = $this->di['db']->dispense('SupportTicketMessage');
|
||||
$msg->support_ticket_id = $ticket->id;
|
||||
$msg->content = $message;
|
||||
$msg->ip = $this->di['request']->getClientIp();
|
||||
$msg->created_at = date('Y-m-d H:i:s');
|
||||
$msg->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($msg);
|
||||
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterGuestPublicTicketOpen', 'params' => ['id' => $ticketId]]);
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterClientOpenTicket', 'params' => ['id' => $ticketId]]);
|
||||
|
||||
$this->di['logger']->info('"%s" opened public ticket "%s"', $ticket->author_email, $ticketId);
|
||||
$this->di['logger']->info('"%s" opened guest ticket "%s"', $ticket->author_email, $ticketId);
|
||||
|
||||
return $ticket->hash;
|
||||
return $ticket->access_hash;
|
||||
}
|
||||
|
||||
public function publicTicketsEnabled(): bool
|
||||
private function getDefaultHelpdesk(): \Model_SupportHelpdesk
|
||||
{
|
||||
$helpdesk = $this->di['db']->findOne('SupportHelpdesk', 'ORDER BY id ASC LIMIT 1');
|
||||
if ($helpdesk instanceof \Model_SupportHelpdesk) {
|
||||
return $helpdesk;
|
||||
}
|
||||
|
||||
$helpdesk = $this->di['db']->dispense('SupportHelpdesk');
|
||||
$helpdesk->name = 'General';
|
||||
$helpdesk->close_after = 24;
|
||||
$helpdesk->can_reopen = 0;
|
||||
$helpdesk->created_at = date('Y-m-d H:i:s');
|
||||
$helpdesk->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($helpdesk);
|
||||
|
||||
return $helpdesk;
|
||||
}
|
||||
|
||||
public function guestTicketsEnabled(): bool
|
||||
{
|
||||
$extensionService = $this->di['mod_service']('extension');
|
||||
$config = $extensionService->getConfig('mod_support');
|
||||
|
||||
return !(isset($config['disable_public_tickets']) && $config['disable_public_tickets']);
|
||||
// @deprecated 0.9.0 Use disable_guest_tickets instead.
|
||||
$disableGuestTickets = $config['disable_guest_tickets'] ?? $config['disable_public_tickets'] ?? false;
|
||||
|
||||
return !$disableGuestTickets;
|
||||
}
|
||||
|
||||
public function canClientSubmitNewTicket(\Model_Client $client, array $config): bool
|
||||
@@ -1171,6 +1231,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
}
|
||||
|
||||
$event_params = $data;
|
||||
$event_params['author_role'] = 'client';
|
||||
$event_params['client_id'] = $client->id;
|
||||
$this->di['events_manager']->fire(['event' => 'onBeforeClientOpenTicket', 'params' => $event_params]);
|
||||
|
||||
@@ -1245,347 +1306,14 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
return $this->di['db']->store($msg);
|
||||
}
|
||||
|
||||
public function publicGetStatuses(): array
|
||||
public function findOneByHash(string $hash): \Model_SupportTicket
|
||||
{
|
||||
return [
|
||||
\Model_SupportPTicket::OPENED => 'Open',
|
||||
\Model_SupportPTicket::ONHOLD => 'On Hold',
|
||||
\Model_SupportPTicket::CLOSED => 'Closed',
|
||||
];
|
||||
}
|
||||
|
||||
public function publicFindOneByHash(string $hash): \Model_SupportPTicket
|
||||
{
|
||||
$bindings = [
|
||||
':hash' => $hash,
|
||||
];
|
||||
|
||||
$publicTicket = $this->di['db']->findOne('SupportPTicket', 'hash = :hash', $bindings);
|
||||
if (!$publicTicket instanceof \Model_SupportPTicket) {
|
||||
throw new \FOSSBilling\Exception('Public ticket not found');
|
||||
$guestTicket = $this->di['db']->findOne('SupportTicket', 'access_hash = :hash AND client_id IS NULL', [':hash' => $hash]);
|
||||
if (!$guestTicket instanceof \Model_SupportTicket) {
|
||||
throw new \FOSSBilling\Exception('Guest ticket not found');
|
||||
}
|
||||
|
||||
return $publicTicket;
|
||||
}
|
||||
|
||||
public function publicGetSearchQuery(array $data): array
|
||||
{
|
||||
$query = 'SELECT spt.* FROM support_p_ticket spt
|
||||
LEFT JOIN support_p_ticket_message sptm
|
||||
ON spt.id = sptm.support_p_ticket_id';
|
||||
|
||||
$search = $data['search'] ?? null;
|
||||
|
||||
$id = $data['id'] ?? null;
|
||||
$status = $data['status'] ?? null;
|
||||
$name = $data['name'] ?? null;
|
||||
$email = $data['email'] ?? null;
|
||||
$subject = $data['subject'] ?? null;
|
||||
$content = $data['content'] ?? null;
|
||||
|
||||
$where = [];
|
||||
$bindings = [];
|
||||
|
||||
if ($id) {
|
||||
$where[] = 'spt.id = :p_ticket_id';
|
||||
$bindings[':p_ticket_id'] = $id;
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$where[] = 'spt.status = :p_ticket_status';
|
||||
$bindings[':p_ticket_status'] = $status;
|
||||
}
|
||||
|
||||
if ($email) {
|
||||
$where[] = 'spt.author_email = :p_ticket_author_email';
|
||||
$bindings[':p_ticket_author_email'] = $email;
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
$where[] = 'spt.author_name = :p_ticket_author_name';
|
||||
$bindings[':p_ticket_author_name'] = $name;
|
||||
}
|
||||
|
||||
if ($content) {
|
||||
$where[] = 'spt.content LIKE :p_ticket_content';
|
||||
$bindings[':p_ticket_content'] = "%$content%";
|
||||
}
|
||||
|
||||
if ($subject) {
|
||||
$where[] = 'spt.subject LIKE :p_ticket_subject';
|
||||
$bindings[':p_ticket_subject'] = "%$subject%";
|
||||
}
|
||||
|
||||
// smartSearch
|
||||
if ($search) {
|
||||
if (is_numeric($search)) {
|
||||
$where[] = 'spt.id = :p_ticket_id';
|
||||
$bindings[':p_ticket_id'] = $search;
|
||||
} else {
|
||||
$search = '%' . $search . '%';
|
||||
$where[] = '(sptm.content LIKE :p_message_content OR spt.subject LIKE :p_ticket_subject)';
|
||||
$bindings[':p_message_content'] = $search;
|
||||
$bindings[':p_ticket_subject'] = $search;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($where)) {
|
||||
$query = $query . ' WHERE ' . implode(' AND ', $where);
|
||||
}
|
||||
|
||||
$query .= ' GROUP BY spt.id, sptm.id ORDER BY spt.id DESC, sptm.id ASC';
|
||||
|
||||
return [$query, $bindings];
|
||||
}
|
||||
|
||||
public function publicCounter(): array
|
||||
{
|
||||
$query = 'SELECT status, COUNT(id) as counter
|
||||
FROM support_p_ticket
|
||||
GROUP BY status';
|
||||
|
||||
$data = $this->di['db']->getAssoc($query);
|
||||
|
||||
return [
|
||||
'total' => array_sum($data),
|
||||
\Model_SupportPTicket::OPENED => $data[\Model_SupportPTicket::OPENED] ?? 0,
|
||||
\Model_SupportPTicket::CLOSED => $data[\Model_SupportPTicket::CLOSED] ?? 0,
|
||||
\Model_SupportPTicket::ONHOLD => $data[\Model_SupportPTicket::ONHOLD] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
public function publicGetLatest(): array
|
||||
{
|
||||
return $this->di['db']->find('SupportPTicket', 'ORDER BY id DESC Limit 10');
|
||||
}
|
||||
|
||||
public function publicCountByStatus(string $status): int
|
||||
{
|
||||
$query = 'SELECT COUNT(id) as counter
|
||||
FROM support_p_ticket
|
||||
WHERE status = :status
|
||||
GROUP BY status';
|
||||
|
||||
return (int) $this->di['db']->getCell($query, [':status' => $status]);
|
||||
}
|
||||
|
||||
public function publicGetExpired(): array
|
||||
{
|
||||
$bindings = [
|
||||
':status' => \Model_SupportPTicket::ONHOLD,
|
||||
];
|
||||
|
||||
return $this->di['db']->find('SupportPTicket', 'status = :status AND DATE_ADD(updated_at, INTERVAL 48 HOUR) < NOW() ORDER BY id ASC', $bindings);
|
||||
}
|
||||
|
||||
public function publicCloseTicket(\Model_SupportPTicket $model, \Model_Admin|\Model_Guest $identity): bool
|
||||
{
|
||||
$model->status = 'closed';
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
|
||||
$this->di['db']->store($model);
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterAdminPublicTicketClose', 'params' => ['id' => $model->id]]);
|
||||
$this->di['logger']->info('Public Ticket %s was closed', $model->id);
|
||||
} elseif ($identity instanceof \Model_Guest) {
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterGuestPublicTicketClose', 'params' => ['id' => $model->id]]);
|
||||
$this->di['logger']->info('"%s" closed public ticket "%s"', $model->author_email, $model->id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function publicAutoClose(\Model_SupportPTicket $model): bool
|
||||
{
|
||||
$model->status = 'closed';
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
|
||||
$this->di['db']->store($model);
|
||||
|
||||
$this->di['logger']->info('Public Ticket %s was closed', $model->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function publicRm(\Model_SupportPTicket $model): bool
|
||||
{
|
||||
$id = $model->id;
|
||||
$bindings = [
|
||||
':support_p_ticket_id' => $model->id,
|
||||
];
|
||||
$messages = $this->di['db']->find('SupportPTicketMessage', 'support_p_ticket_id = :support_p_ticket_id', $bindings);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->di['db']->trash($message);
|
||||
}
|
||||
|
||||
$this->di['db']->trash($model);
|
||||
|
||||
$this->di['logger']->info('Deleted public ticket #%s', $id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function publicToApiArray(\Model_SupportPTicket $model, bool $deep = true, $identity = null): array
|
||||
{
|
||||
$data = $this->di['db']->toArray($model);
|
||||
|
||||
if (!$identity instanceof \Model_Admin) {
|
||||
unset($data['author_email']);
|
||||
}
|
||||
|
||||
$messages = [];
|
||||
$messagesArr = $this->di['db']->find('SupportPTicketMessage', 'support_p_ticket_id = :support_p_ticket_id ORDER BY id', [':support_p_ticket_id' => $model->id]);
|
||||
foreach ($messagesArr as $msg) {
|
||||
$messages[] = $this->publicMessageToApiArray($msg, true, $identity);
|
||||
}
|
||||
|
||||
$first = reset($messagesArr);
|
||||
if ($first instanceof \Model_SupportPTicketMessage) {
|
||||
$data['author'] = $this->publicMessageGetAuthorDetails($first, $identity);
|
||||
} else {
|
||||
$data['author'] = [];
|
||||
}
|
||||
$data['messages'] = $messages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function publicMessageGetAuthorDetails(\Model_SupportPTicketMessage $model, $identity = null): array
|
||||
{
|
||||
if ($model->admin_id) {
|
||||
$author = $this->di['db']->getExistingModelById('Admin', $model->admin_id);
|
||||
|
||||
$result = [
|
||||
'name' => $author->getFullName(),
|
||||
];
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$result['email'] = $author->email;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$ticket = $this->di['db']->getExistingModelById('SupportPTicket', $model->support_p_ticket_id);
|
||||
|
||||
$result = [
|
||||
'name' => $ticket->author_name,
|
||||
];
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$result['email'] = $ticket->author_email;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function publicMessageToApiArray(\Model_SupportPTicketMessage $model, bool $deep = true, $identity = null): array
|
||||
{
|
||||
$data = [
|
||||
'id' => $model->id,
|
||||
'content' => $model->content,
|
||||
'created_at' => $model->created_at,
|
||||
'updated_at' => $model->updated_at,
|
||||
];
|
||||
|
||||
if ($identity instanceof \Model_Admin) {
|
||||
$data['support_p_ticket_id'] = $model->support_p_ticket_id;
|
||||
$data['admin_id'] = $model->admin_id;
|
||||
$data['ip'] = $model->ip;
|
||||
}
|
||||
|
||||
$data['author'] = $this->publicMessageGetAuthorDetails($model, $identity);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function publicTicketCreate(array $data, \Model_Admin $identity): int
|
||||
{
|
||||
$data['email'] = $this->di['tools']->validateAndSanitizeEmail($data['email']);
|
||||
|
||||
$this->di['events_manager']->fire(['event' => 'onBeforeAdminPublicTicketOpen', 'params' => $data]);
|
||||
|
||||
$ticket = $this->di['db']->dispense('SupportPTicket');
|
||||
$ticket->hash = bin2hex(random_bytes(random_int(15, 30)));
|
||||
$ticket->author_name = $data['name'];
|
||||
$ticket->author_email = $data['email'];
|
||||
$ticket->subject = $data['subject'];
|
||||
$ticket->status = 'open';
|
||||
$ticket->created_at = date('Y-m-d H:i:s');
|
||||
$ticket->updated_at = date('Y-m-d H:i:s');
|
||||
$ticketId = $this->di['db']->store($ticket);
|
||||
|
||||
$msg = $this->di['db']->dispense('SupportPTicketMessage');
|
||||
$msg->support_p_ticket_id = $ticketId;
|
||||
$msg->admin_id = $identity->id;
|
||||
$msg->content = $data['message'];
|
||||
$msg->ip = $this->di['request']->getClientIp();
|
||||
$msg->created_at = date('Y-m-d H:i:s');
|
||||
$msg->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($msg);
|
||||
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterAdminPublicTicketOpen', 'params' => ['id' => $ticketId]]);
|
||||
|
||||
$this->di['logger']->info('Opened public ticket for email "%s"', $ticket->author_email);
|
||||
|
||||
return $ticketId;
|
||||
}
|
||||
|
||||
public function publicTicketUpdate(\Model_SupportPTicket $model, $data): bool
|
||||
{
|
||||
$model->subject = $data['subject'] ?? $model->subject;
|
||||
$model->status = $data['status'] ?? $model->status;
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($model);
|
||||
|
||||
$this->di['logger']->info('Updated public ticket #%s', $model->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function publicTicketReply(\Model_SupportPTicket $ticket, \Model_Admin $identity, string $content): int
|
||||
{
|
||||
$msg = $this->di['db']->dispense('SupportPTicketMessage');
|
||||
$msg->support_p_ticket_id = $ticket->id;
|
||||
$msg->admin_id = $identity->id;
|
||||
$msg->content = $content;
|
||||
$msg->ip = $this->di['request']->getClientIp();
|
||||
$msg->created_at = date('Y-m-d H:i:s');
|
||||
$msg->updated_at = date('Y-m-d H:i:s');
|
||||
$messageId = $this->di['db']->store($msg);
|
||||
|
||||
$ticket->status = \Model_SupportPTicket::ONHOLD;
|
||||
$ticket->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($ticket);
|
||||
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterAdminPublicTicketReply', 'params' => ['id' => $ticket->id]]);
|
||||
|
||||
$this->di['logger']->info('Replied to public ticket "%s"', $ticket->id);
|
||||
|
||||
return $messageId;
|
||||
}
|
||||
|
||||
public function publicTicketReplyForGuest(\Model_SupportPTicket $ticket, string $message): string
|
||||
{
|
||||
$msg = $this->di['db']->dispense('SupportPTicketMessage');
|
||||
$msg->support_p_ticket_id = $ticket->id;
|
||||
$msg->content = $message;
|
||||
$msg->ip = $this->di['request']->getClientIp();
|
||||
$msg->created_at = date('Y-m-d H:i:s');
|
||||
$msg->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($msg);
|
||||
|
||||
$ticket->status = \Model_SupportPTicket::OPENED;
|
||||
$ticket->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($ticket);
|
||||
|
||||
$this->di['events_manager']->fire(['event' => 'onAfterGuestPublicTicketReply', 'params' => ['id' => $ticket->id]]);
|
||||
|
||||
$this->di['logger']->info('Client "%s" replied to public ticket "%s"', $ticket->author_email, $ticket->id);
|
||||
|
||||
return $ticket->hash;
|
||||
return $guestTicket;
|
||||
}
|
||||
|
||||
public function helpdeskUpdate(\Model_SupportHelpdesk $model, array $data): bool
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
{% extends request.ajax ? 'layout_blank.html.twig' : 'layout_default.html.twig' %}
|
||||
|
||||
{% import 'macro_functions.html.twig' as mf %}
|
||||
|
||||
{% block meta_title %}{{ ticket.subject }}{% endblock %}
|
||||
|
||||
{% set active_menu = 'support' %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ '/'|url }}">
|
||||
<svg class="icon">
|
||||
<use href="#home" />
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ 'support'|url }}">{{ 'Support'|trans }}</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ 'support/public-tickets'|url(query: { 'status': 'open' }) }}">{{ 'Public Tickets'|trans }}</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">#{{ ticket.id }} - {{ ticket.subject }}</li>
|
||||
</ol>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% embed 'partial_admin_detail_tabs.html.twig' with {
|
||||
title: ticket.subject,
|
||||
subtitle: 'Review public ticket details, adjust its status, and respond as staff.'|trans,
|
||||
outer_card_class: 'mb-3'
|
||||
} %}
|
||||
{% block detail_tabs %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" href="#tab-index" data-bs-toggle="tab" role="tab">{{ 'Ticket'|trans }}</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" href="#tab-manage" data-bs-toggle="tab" role="tab">{{ 'Manage'|trans }}</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block detail_tab_content %}
|
||||
{% import 'macro_functions.html.twig' as mf %}
|
||||
<div class="tab-pane fade show active" id="tab-index" role="tabpanel">
|
||||
<div class="p-3 d-flex flex-column gap-3">
|
||||
{% embed 'partial_admin_summary_card.html.twig' with {
|
||||
title: 'Public Ticket Summary'|trans,
|
||||
subtitle: 'Review the author details, current state, and message timing for this public ticket.'|trans,
|
||||
centered_actions: true,
|
||||
card_class: 'mb-0'
|
||||
} %}
|
||||
{% import 'macro_functions.html.twig' as mf %}
|
||||
{% block summary_content %}
|
||||
<div class="table-responsive">
|
||||
<table class="table card-table table-vcenter table-striped text-nowrap">
|
||||
<tbody>
|
||||
<tr><td class="w-50 text-end">{{ 'Ticket ID'|trans }}:</td><td>#{{ ticket.id }}</td></tr>
|
||||
<tr><td class="text-end">{{ 'Subject'|trans }}:</td><td>{{ ticket.subject }}</td></tr>
|
||||
<tr><td class="text-end">{{ 'Author'|trans }}:</td><td>{{ ticket.author_name }}</td></tr>
|
||||
<tr><td class="text-end">{{ 'Email'|trans }}:</td><td>{{ ticket.author_email }}</td></tr>
|
||||
<tr><td class="text-end">{{ 'Status'|trans }}:</td><td>{{ mf.status_badge(ticket.status, 'ticket') }}</td></tr>
|
||||
<tr><td class="text-end">{{ 'Time Opened'|trans }}:</td><td>{{ ticket.created_at|format_date }}</td></tr>
|
||||
{% if ticket.created_at != ticket.updated_at %}
|
||||
<tr><td class="text-end">{{ 'Last Updated'|trans }}:</td><td>{{ ticket.updated_at|timeago }} {{ 'ago'|trans }}</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block summary_actions %}
|
||||
{% if ticket.status != 'closed' %}
|
||||
<a class="btn btn-warning" href="{{ 'support/public_ticket_close'|api_url(query: { 'id': ticket.id }) }}"
|
||||
{{ fb_api_link({ redirect: 'support/public-tickets'|url }) }}>
|
||||
<svg class="icon"><use href="#x" /></svg>
|
||||
{{ 'Close'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-danger" href="{{ 'support/public_ticket_delete'|api_url(query: { 'id' : ticket.id }) }}"
|
||||
{{ fb_api_link({ message: 'Are you sure?'|trans, modal: {type: 'confirm', title: 'Are you sure?'|trans}, redirect: 'support/public-tickets'|url }) }}>
|
||||
<svg class="icon"><use href="#trash" /></svg>
|
||||
{{ 'Delete'|trans }}
|
||||
</a>
|
||||
<a class="btn btn-primary"
|
||||
href='{{ "support/contact-us/conversation/#{ticket.hash}"|url(area: 'client') }}'
|
||||
target="_blank">
|
||||
<svg class="icon"><use href="#eye" /></svg>
|
||||
{{ 'View as Author'|trans }}
|
||||
</a>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body pb-3">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-start gap-3">
|
||||
<div class="d-flex flex-column gap-1">
|
||||
<h5 class="card-title mb-0">{{ 'Conversation'|trans }}</h5>
|
||||
<p class="text-secondary mb-0">{{ 'Review the public message history and expand replies when needed.'|trans }}</p>
|
||||
</div>
|
||||
<a href="#" class="btn btn-secondary" id="toggleMessages">
|
||||
<svg class="icon">
|
||||
<use href="#eye" />
|
||||
</svg>
|
||||
{{ 'Show/Hide Messages'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="conversation">
|
||||
{% for i, message in ticket.messages %}
|
||||
<div class="card {% if loop.first %}mt-2 {% endif %}mb-3">
|
||||
<div class="card-header" style="cursor: pointer;">
|
||||
{{ avatar(message.author.email, 20, 'avatar avatar-xs me-2') }}
|
||||
{{ message.author.name }}
|
||||
<span class="ms-auto text-muted">{{ message.created_at|format_datetime }}</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{{ (message.content ?? '')|markdown_to_html }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-0" id="reply-box">
|
||||
<form method="post" action="{{ 'support/public_ticket_reply'|api_url }}"
|
||||
{{ fb_api_form({ redirect: 'support/public-tickets'|url(query: { 'status': 'open' }) }) }}>
|
||||
<div class="card-body">
|
||||
{% set public_ticket_recipient = ticket.author_name ? ticket.author_name : ticket.author_email %}
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4">
|
||||
<div class="d-flex flex-column gap-1">
|
||||
<h5 class="card-title mb-0">{{ 'Respond as'|trans }} {{ profile.name }}</h5>
|
||||
<p class="text-secondary mb-0">{{ 'Compose a staff reply and close the public ticket when appropriate.'|trans }}</p>
|
||||
</div>
|
||||
<div>{{ include('mod_support_canned_selector.html.twig') }}</div>
|
||||
</div>
|
||||
|
||||
<textarea name="content" rows="10" required class="editor-textarea" id="rt">{{ 'Hello'|trans }} {{ public_ticket_recipient }},
|
||||
{{ canned_delay_message }}
|
||||
|
||||
{{ profile.signature }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="card-footer d-flex flex-wrap align-items-center gap-2">
|
||||
<input type="hidden" name="id" value="{{ ticket.id }}">
|
||||
<input type="submit" value="{{ 'Post'|trans }}" class="btn btn-primary ms-auto">
|
||||
|
||||
{% if ticket.messages|length > 2 and ticket.status != 'closed' %}
|
||||
<a class="btn btn-warning" href="{{ 'support/public_ticket_close'|api_url(query: { 'id': ticket.id }) }}"
|
||||
{{ fb_api_link({ message: 'Are you sure?'|trans, modal: {type: 'confirm', title: 'Are you sure?'|trans}, redirect: 'support/public-tickets'|url(query: { 'status': 'open' }) }) }}>
|
||||
<svg class="icon">
|
||||
<use href="#check" />
|
||||
</svg>
|
||||
{{ 'Close Ticket'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-manage" role="tabpanel">
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ 'support/public_ticket_update'|api_url }}" {{ fb_api_form({ reload: true }) }}>
|
||||
{% embed 'partial_admin_form_card.html.twig' with {
|
||||
title: 'Public Ticket Settings'|trans,
|
||||
subtitle: 'Update the subject and current workflow status for this public ticket.'|trans
|
||||
} %}
|
||||
{% import 'macro_functions.html.twig' as mf %}
|
||||
{% block form_content %}
|
||||
<div class="row g-3">
|
||||
<div class="col-lg-8">
|
||||
<label class="form-label">{{ 'Subject'|trans }}</label>
|
||||
<input class="form-control" type="text" name="subject" value="{{ ticket.subject }}" required>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label class="form-label">{{ 'Status'|trans }}</label>
|
||||
{{ mf.selectbox('status', admin.support_ticket_get_statuses({ 'titles': 1 }), ticket.status, 1) }}
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="id" value="{{ ticket.id }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block form_actions %}
|
||||
<button class="btn btn-primary" type="submit">{{ 'Update'|trans }}</button>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
|
||||
{% set canned_response_selector %}
|
||||
<div class="canned_response">
|
||||
<select name="canned_response" class="canned">
|
||||
{% for response in admin.support_canned_get_list({ 'per_page': 90 }).list %}
|
||||
<option value="{{ response.id }}">{{ response.title }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% endset %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js%}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelector('#reply-box textarea').focus();
|
||||
|
||||
document.querySelectorAll('.conversation .card-header').forEach(function(header, event) {
|
||||
header.addEventListener('click', function() {
|
||||
const body = this.nextElementSibling;
|
||||
if (body && body.classList.contains('card-body')) {
|
||||
body.classList.toggle('hidden');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const toggleMessages = document.getElementById('toggleMessages');
|
||||
if (toggleMessages) {
|
||||
toggleMessages.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
document.querySelectorAll('.conversation .card-body').forEach(function(body) {
|
||||
body.classList.toggle('hidden');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}{{ wysiwyg('.editor-textarea') }}{% endblock %}
|
||||
@@ -1,299 +0,0 @@
|
||||
{% extends request.ajax ? 'layout_blank.html.twig' : 'layout_default.html.twig' %}
|
||||
|
||||
{% import 'macro_functions.html.twig' as mf %}
|
||||
|
||||
{% block meta_title %}{{ 'Public Tickets'|trans }}{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<ul class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ '/'|url }}">
|
||||
<svg class="icon">
|
||||
<use href="#home" />
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ 'support'|url }}">{{ 'Support'|trans }}</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ 'Public Tickets'|trans }}</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% set active_menu = 'support' %}
|
||||
{% set has_filter_panel = true %}
|
||||
{% set filter_panel_id = 'page-search-filters' %}
|
||||
{% set filter_panel_open = request_has_filters %}
|
||||
{% set public_ticket_toolbar_actions %}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#newPublicTicketModal">
|
||||
<svg class="icon">
|
||||
<use href="#plus" />
|
||||
</svg>
|
||||
{{ 'New Public Ticket'|trans }}
|
||||
</button>
|
||||
{% endset %}
|
||||
|
||||
{% block content %}
|
||||
{% if not filter_panel_open %}
|
||||
{% set statuses = admin.support_public_ticket_get_statuses %}
|
||||
<section class="row row-cards mb-3 filter-panel-summary">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<a class="card card-sm card-link" href="{{ 'support/public-tickets'|url(query: { 'status': 'open' }) }}">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<span class="bg-danger text-white avatar">{{ statuses.open }}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-weight-medium">{{ 'Client Reply'|trans }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<a class="card card-sm card-link" href="{{ 'support/public-tickets'|url(query: { 'status': 'on_hold' }) }}">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<span class="bg-warning text-white avatar">{{ statuses.on_hold }}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-weight-medium">{{ 'Staff Reply'|trans }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<a class="card card-sm card-link" href="{{ 'support/public-tickets'|url(query: { 'status': 'closed' }) }}">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<span class="bg-secondary text-white avatar">{{ statuses.closed }}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-weight-medium">{{ 'Solved'|trans }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<a class="card card-sm card-link" href="{{ 'support/public-tickets'|url }}">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<span class="bg-blue text-white avatar">{{ statuses.open + statuses.on_hold + statuses.closed }}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-weight-medium">{{ 'Total'|trans }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h3 class="card-title">{{ 'Public Tickets'|trans }}</h3>
|
||||
<p class="card-subtitle">{{ 'Review support tickets submitted without a client account and manage public conversations.'|trans }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ include('partial_search.html.twig', {
|
||||
search_body_class: filter_panel_open ? 'pb-2 border-bottom-0' : '',
|
||||
search_toolbar_actions: public_ticket_toolbar_actions
|
||||
}) }}
|
||||
<section id="{{ filter_panel_id }}" class="card-body pt-0 px-3 pb-3 border-bottom collapse{% if filter_panel_open %} show{% endif %}">
|
||||
<form method="get" class="border border-top-0 rounded-top-0 rounded-bottom-3 bg-body-tertiary p-3">
|
||||
{% if request.search %}
|
||||
<input type="hidden" name="search" value="{{ request.search }}">
|
||||
{% endif %}
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-public-ticket-id">{{ 'Ticket ID'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-public-ticket-id" name="id" value="{{ request.id }}" placeholder="{{ 'Ticket ID'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-public-ticket-name">{{ 'Name'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-public-ticket-name" name="name" value="{{ request.name }}" placeholder="{{ 'Author Name'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-public-ticket-email">{{ 'Email'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-public-ticket-email" name="email" value="{{ request.email }}" placeholder="{{ 'Author Email'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<label class="form-label text-muted small mb-1">{{ 'Status'|trans }}</label>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<input class="btn-check" id="publicTicketStatusAll" type="radio" name="status" value=""{% if not request.status %} checked{% endif %}>
|
||||
<label class="btn btn-outline-primary" for="publicTicketStatusAll">{{ 'All'|trans }}</label>
|
||||
|
||||
<input class="btn-check" id="publicTicketStatusOpen" type="radio" name="status" value="open"{% if request.status == 'open' %} checked{% endif %}>
|
||||
<label class="btn btn-outline-primary" for="publicTicketStatusOpen">{{ 'Open'|trans }}</label>
|
||||
|
||||
<input class="btn-check" id="publicTicketStatusHold" type="radio" name="status" value="on_hold"{% if request.status == 'on_hold' %} checked{% endif %}>
|
||||
<label class="btn btn-outline-primary" for="publicTicketStatusHold">{{ 'On Hold'|trans }}</label>
|
||||
|
||||
<input class="btn-check" id="publicTicketStatusClosed" type="radio" name="status" value="closed"{% if request.status == 'closed' %} checked{% endif %}>
|
||||
<label class="btn btn-outline-primary" for="publicTicketStatusClosed">{{ 'Closed'|trans }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-6">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-public-ticket-subject">{{ 'Subject'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-public-ticket-subject" name="subject" value="{{ request.subject }}" placeholder="{{ 'Ticket Subject'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-6">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-public-ticket-content">{{ 'Message Content'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-public-ticket-content" name="content" value="{{ request.content }}" placeholder="{{ 'Search Ticket Messages'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2 mt-3">
|
||||
<a class="btn btn-outline-secondary" href="{{ request_path|url }}">{{ 'Reset'|trans }}</a>
|
||||
<button class="btn btn-primary" type="submit">
|
||||
<svg class="icon">
|
||||
<use href="#filter" />
|
||||
</svg>
|
||||
{{ 'Apply Filters'|trans }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<div class="table-responsive">
|
||||
<table class="table card-table table-vcenter table-striped text-nowrap sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-1 no-sort">
|
||||
<input type="checkbox" class="form-check-input m-0 align-middle batch-delete-master-checkbox">
|
||||
</th>
|
||||
<th>{{ 'Subject'|trans }}</th>
|
||||
<th>{{ 'Email'|trans }}</th>
|
||||
<th>{{ 'Status'|trans }}</th>
|
||||
<th>{{ 'Date'|trans }}</th>
|
||||
<th class="w-1 no-sort"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set tickets = admin.support_public_ticket_get_list({ 'per_page': 25, 'page': request.page }|merge(request)) %}
|
||||
{% for i, ticket in tickets.list %}
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" class="form-check-input m-0 align-middle batch-delete-checkbox" data-item-id="{{ ticket.id }}">
|
||||
</td>
|
||||
<td>
|
||||
<a href='{{ "support/public-ticket/#{ticket.id}"|url }}'>#{{ ticket.id }} - {{ ticket.subject }} ({{ ticket.messages|length }})</a>
|
||||
</td>
|
||||
<td>{{ ticket.author_email }}</td>
|
||||
<td>{{ mf.status_badge(ticket.status, 'ticket') }}</td>
|
||||
<td>{{ ticket.updated_at|format_date }}</td>
|
||||
<td>
|
||||
<a class="btn btn-icon" href='{{ "support/public-ticket/#{ticket.id}"|url }}'>
|
||||
<svg class="icon">
|
||||
<use href="#edit" />
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td class="text-muted" colspan="5">{{ 'The list is empty'|trans }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card-footer d-flex align-items-center justify-content-between">
|
||||
{% include 'partial_batch_delete.html.twig' with { 'action': 'support/batch_delete_public' } %}
|
||||
{% include 'partial_pagination.html.twig' with { 'list': tickets, 'url': 'support/public-tickets' } %}
|
||||
</div>
|
||||
|
||||
<div class="modal modal-blur fade" id="newPublicTicketModal" tabindex="-1" aria-labelledby="newPublicTicketModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen-md-down modal-lg">
|
||||
<form class="modal-content fb-modal-form" method="post" action="{{ 'support/public_ticket_create'|api_url }}" {{ fb_api_form({ callback: 'onAfterPublicTicketCreate' }) }}>
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title" id="newPublicTicketModalLabel">{{ 'Open Public Ticket for Non-Client'|trans }}</h3>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ 'Close'|trans }}"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<section class="fb-modal-section">
|
||||
<div class="fb-modal-section-header">
|
||||
<div class="fb-modal-section-heading-row">
|
||||
<h4 class="fb-modal-section-title">{{ 'Ticket Details'|trans }}</h4>
|
||||
</div>
|
||||
<p class="fb-modal-section-description">{{ 'Capture the sender details and compose the opening public support message.'|trans }}</p>
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="new-public-ticket-name">{{ 'Receiver Name'|trans }}</label>
|
||||
<input class="form-control" type="text" id="new-public-ticket-name" name="name" required placeholder="{{ 'John Smith'|trans }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label" for="new-public-ticket-email">{{ 'Email'|trans }}</label>
|
||||
<input class="form-control" type="email" id="new-public-ticket-email" name="email" required placeholder="{{ 'user@domain.com'|trans }}">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="new-public-ticket-subject">{{ 'Subject'|trans }}</label>
|
||||
<input class="form-control" type="text" id="new-public-ticket-subject" name="subject" value="{{ request.subject|default('') }}" required placeholder="{{ 'Email Subject'|trans }}">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label" for="new-public-ticket-message">{{ 'Message'|trans }}</label>
|
||||
<textarea class="form-control editor-textarea" id="new-public-ticket-message" name="message" rows="10" required>{{ profile.signature }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ 'Cancel'|trans }}</button>
|
||||
<button type="submit" class="btn btn-primary">{{ 'Create'|trans }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const modalElement = document.getElementById('newPublicTicketModal');
|
||||
if (!modalElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(modalElement);
|
||||
if (window.location.hash === '#tab-new') {
|
||||
modal.show();
|
||||
}
|
||||
|
||||
modalElement.addEventListener('hidden.bs.modal', function () {
|
||||
if (window.location.hash !== '#tab-new') {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
url.hash = '';
|
||||
window.history.replaceState({}, '', url);
|
||||
});
|
||||
});
|
||||
|
||||
function onAfterPublicTicketCreate(result) {
|
||||
window.location = "{{ 'support/public-ticket'|url }}/" + result;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}{{ wysiwyg('.editor-textarea') }}{% endblock %}
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h3 class="card-title">{{ 'Support Settings'|trans }}</h3>
|
||||
<p class="card-subtitle">{{ 'Manage support automation, knowledge base availability, public tickets, and helpdesk configuration.'|trans }}</p>
|
||||
<p class="card-subtitle">{{ 'Manage support automation, knowledge base availability, guest tickets, and helpdesk configuration.'|trans }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-3 pb-0 px-0">
|
||||
@@ -108,11 +108,11 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="card-body border-top">
|
||||
<h4 class="card-title mb-2">{{ 'Public Tickets'|trans }}</h4>
|
||||
<p class="text-secondary mb-3">{{ 'Control whether non-client visitors may open public support tickets.'|trans }}</p>
|
||||
<h4 class="card-title mb-2">{{ 'Guest Tickets'|trans }}</h4>
|
||||
<p class="text-secondary mb-3">{{ 'Control whether non-client visitors may open support tickets.'|trans }}</p>
|
||||
<label class="form-check form-switch form-switch-2">
|
||||
<input class="form-check-input" name="disable_public_tickets" type="checkbox" {% if params.disable_public_tickets|default(false) %} checked="checked"{% endif %}>
|
||||
<span class="form-check-label">{{ 'Disable Public Tickets'|trans }}</span>
|
||||
<input class="form-check-input" name="disable_guest_tickets" type="checkbox" {% if params.disable_guest_tickets|default(false) %} checked="checked"{% endif %}>
|
||||
<span class="form-check-label">{{ 'Disable Guest Tickets'|trans }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="card-footer text-end">
|
||||
|
||||
@@ -41,9 +41,11 @@
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" href="#tab-notes" data-bs-toggle="tab" role="tab">{{ 'Notes'|trans }} {% if ticket.notes is defined and ticket.notes|length > 0 %}({{ ticket.notes|length }}){% endif %}</a>
|
||||
</li>
|
||||
{% if ticket.author.role == 'client' %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" href="#tab-support" data-bs-toggle="tab" role="tab">{{ 'Client Tickets'|trans }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block detail_tab_content %}
|
||||
@@ -63,7 +65,17 @@
|
||||
<table class="table card-table table-vcenter table-striped text-nowrap">
|
||||
<tbody>
|
||||
<tr><td class="w-25">{{ 'Ticket ID'|trans }}</td><td>#{{ ticket.id }}</td></tr>
|
||||
<tr><td>{{ 'Client'|trans }}</td><td><a href='{{ "client/manage/#{ticket.client.id }"|url }}'>{{ ticket.client.first_name }} {{ ticket.client.last_name }}</a> (#{{ ticket.client.id }})</td></tr>
|
||||
{% if ticket.author.role == 'client' %}
|
||||
<tr><td>{{ 'Client'|trans }}</td><td><a href='{{ "client/manage/#{ticket.author.id }"|url }}'>{{ ticket.author.name }}</a> (#{{ ticket.author.id }})</td></tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>{{ 'Author'|trans }}</td>
|
||||
<td>
|
||||
{{ ticket.author.name }} ({{ ticket.author.email }})
|
||||
<span class="badge bg-orange-lt ms-1">{{ 'Guest' |trans }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr><td>{{ 'Helpdesk'|trans }}</td><td>{{ admin.support_helpdesk_get_pairs[ticket.support_helpdesk_id]|trans }}</td></tr>
|
||||
<tr><td>{{ 'Status'|trans }}</td><td>{{ mf.status_badge(ticket.status, 'ticket') }}</td></tr>
|
||||
<tr><td>{{ 'Time Opened'|trans }}</td><td>{{ ticket.created_at|format_date }}</td></tr>
|
||||
@@ -94,6 +106,12 @@
|
||||
{{ 'Set Task Complete'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if ticket.author.role == 'guest' and ticket.hash is defined %}
|
||||
<a class="btn btn-secondary" href='{{ "support/ticket/#{ticket.hash}"|url(area: 'client') }}' target="_blank">
|
||||
<svg class="icon"><use href="#eye" /></svg>
|
||||
{{ 'View as Author'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
|
||||
@@ -146,11 +164,11 @@
|
||||
<div>{{ include('mod_support_canned_selector.html.twig') }}</div>
|
||||
</div>
|
||||
|
||||
<textarea class="editor-textarea" id="rt" name="content" rows="10" required>{{ 'Hello'|trans }} {{ ticket.client.first_name }},
|
||||
<textarea class="editor-textarea" id="rt" name="content" rows="10" required>{{ 'Hello'|trans }} {{ ticket.author.first_name|default(ticket.author.name) }},
|
||||
{{ canned_delay_message }}
|
||||
|
||||
{{ profile.signature }}
|
||||
{{ ticket.helpdesk.signature }}</textarea>
|
||||
{{ ticket.helpdesk.signature|default('') }}</textarea>
|
||||
</div>
|
||||
<div class="card-footer d-flex flex-wrap align-items-center gap-2">
|
||||
<input type="hidden" name="id" value="{{ ticket.id }}">
|
||||
@@ -263,6 +281,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if ticket.author.role == 'client' %}
|
||||
<div class="tab-pane fade" id="tab-support" role="tabpanel">
|
||||
{% embed 'partial_admin_related_section.html.twig' with {
|
||||
title: 'Client Tickets'|trans,
|
||||
@@ -270,7 +289,7 @@
|
||||
card_class: 'm-3'
|
||||
} %}
|
||||
{% block section_action %}
|
||||
<a href="{{ 'support'|url(query: { 'client_id': ticket.client.id}) }}#tab-new" class="btn btn-primary">
|
||||
<a href="{{ 'support'|url(query: { 'client_id': ticket.author.id}) }}#tab-new" class="btn btn-primary">
|
||||
<svg class="icon"><use href="#plus" /></svg>
|
||||
{{ 'New Support Ticket'|trans }}
|
||||
</a>
|
||||
@@ -290,7 +309,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set tickets = admin.support_ticket_get_list({ 'per_page': 20, 'client_id': ticket.client.id, 'deep': 0, 'include_first': 0 }) %}
|
||||
{% set tickets = admin.support_ticket_get_list({ 'per_page': 20, 'client_id': ticket.author.id, 'deep': 0, 'include_first': 0 }) %}
|
||||
{% for related_ticket in tickets.list %}
|
||||
<tr>
|
||||
<td>{{ related_ticket.id }}</td>
|
||||
@@ -312,6 +331,7 @@
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h3 class="card-title">{{ 'Support Tickets'|trans }}</h3>
|
||||
<p class="card-subtitle">{{ 'Manage client and public tickets, filter conversations, and open new support requests.'|trans }}</p>
|
||||
<p class="card-subtitle">{{ 'Manage client and guest tickets, filter conversations, and open new support requests.'|trans }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
@@ -116,6 +116,16 @@
|
||||
<input type="hidden" name="search" value="{{ request.search }}">
|
||||
{% endif %}
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-ticket-auth">{{ 'Author Type'|trans }}</label>
|
||||
<select class="form-select" id="filter-ticket-auth" name="auth">
|
||||
<option value="">{{ 'All Authors'|trans }}</option>
|
||||
<option value="client"{% if request.auth == 'client' %} selected{% endif %}>{{ 'Clients'|trans }}</option>
|
||||
<option value="guest"{% if request.auth == 'guest' %} selected{% endif %}>{{ 'Guests'|trans }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-ticket-client-id">{{ 'Client ID'|trans }}</label>
|
||||
@@ -134,6 +144,18 @@
|
||||
<input class="form-control" type="text" id="filter-ticket-subject" name="subject" value="{{ request.subject }}" placeholder="{{ 'Ticket Subject'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-ticket-name">{{ 'Guest Name'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-ticket-name" name="name" value="{{ request.name }}" placeholder="{{ 'Guest Name'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-ticket-email">{{ 'Guest Email'|trans }}</label>
|
||||
<input class="form-control" type="text" id="filter-ticket-email" name="email" value="{{ request.email }}" placeholder="{{ 'Guest Email'|trans }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3">
|
||||
<div>
|
||||
<label class="form-label text-muted small mb-1" for="filter-ticket-message">{{ 'Ticket Messages'|trans }}</label>
|
||||
@@ -204,7 +226,7 @@
|
||||
<th class="w-1 no-sort">
|
||||
<input class="form-check-input m-0 align-middle batch-delete-master-checkbox" type="checkbox">
|
||||
</th>
|
||||
<th>{{ 'Client'|trans }}</th>
|
||||
<th>{{ 'Author'|trans }}</th>
|
||||
<th>{{ 'Subject'|trans }}</th>
|
||||
<th>{{ 'Status'|trans }}</th>
|
||||
<th>{{ 'Helpdesk'|trans }}</th>
|
||||
@@ -214,22 +236,35 @@
|
||||
<tbody>
|
||||
{% set tickets = admin.support_ticket_get_list({ 'per_page': 25, 'page': request.page, 'deep': 0, 'include_first': 0 }|merge(request)) %}
|
||||
{% for i, ticket in tickets.list %}
|
||||
<tr class="priority_{{ ticket.priority }}">
|
||||
<tr class="priority_{{ ticket.priority|default(100) }}">
|
||||
<td>
|
||||
<input class="form-check-input m-0 align-middle batch-delete-checkbox" type="checkbox" data-item-id="{{ ticket.id }}">
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex py-1 align-items-center">
|
||||
<a href='{{ "client/manage/#{ticket.client_id}"|url }}'>
|
||||
{{ avatar(ticket.client.email, 40, 'avatar me-2') }}
|
||||
</a>
|
||||
<div class="flex-fill">
|
||||
<div class="font-weight-medium">
|
||||
<a href='{{ "client/manage/#{ticket.client_id}"|url }}'>{{ ticket.client.first_name }} {{ ticket.client.last_name }}</a>
|
||||
{% if ticket.author.role == 'client' %}
|
||||
<div class="d-flex py-1 align-items-center">
|
||||
<a href='{{ "client/manage/#{ticket.author.id}"|url }}'>
|
||||
{{ avatar(ticket.author.email, 40, 'avatar me-2') }}
|
||||
</a>
|
||||
<div class="flex-fill">
|
||||
<div class="font-weight-medium">
|
||||
<a href='{{ "client/manage/#{ticket.author.id}"|url }}'>{{ ticket.author.name }}</a>
|
||||
</div>
|
||||
<div class="text-muted">{{ ticket.author.email }}</div>
|
||||
</div>
|
||||
<div class="text-muted">{{ ticket.client.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="d-flex py-1 align-items-center">
|
||||
{{ avatar(ticket.author.email, 40, 'avatar me-2') }}
|
||||
<div class="flex-fill">
|
||||
<div class="font-weight-medium">
|
||||
{{ ticket.author.name }}
|
||||
<span class="badge bg-orange-lt ms-1">{{ 'Guest'|trans }}</span>
|
||||
</div>
|
||||
<div class="text-muted">{{ ticket.author.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
@@ -245,7 +280,7 @@
|
||||
<span class="text-muted">{{ ticket.updated_at|timeago }} {{ 'ago'|trans }}</span>
|
||||
</td>
|
||||
<td>{{ mf.status_badge(ticket.status, 'ticket') }}</td>
|
||||
<td>{{ ticket.helpdesk.name }}</td>
|
||||
<td>{{ ticket.helpdesk.name|default('-') }}</td>
|
||||
<td>
|
||||
<a class="btn btn-icon" href='{{ "support/ticket/#{ticket.id}"|url }}#reply-box'>
|
||||
<svg class="icon">
|
||||
|
||||
@@ -38,13 +38,17 @@
|
||||
<label class="form-label" for="email">{{ 'Email'|trans }}</label>
|
||||
<input class="form-control" type="email" name="email" value="{{ request.email }}" required="required" id="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="support-helpdesk-id" class="form-label">{{ 'Helpdesk'|trans }}</label>
|
||||
{{ mf.selectbox('support_helpdesk_id', guest.support_helpdesk_get_pairs, request.support_helpdesk_id, 1) }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="subject">{{ 'Subject'|trans }}</label>
|
||||
<input class="form-control" type="text" name="subject" value="{{ request.subject }}" required="required" id="subject">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="message">{{ 'Message'|trans }}</label>
|
||||
<textarea class="editor-textarea form-control" name="message" cols="5" rows="5" required="required" id="message">{{ request.message }}</textarea>
|
||||
<textarea class="editor-textarea form-control" name="content" cols="5" rows="5" required="required" id="message">{{ request.content }}</textarea>
|
||||
</div>
|
||||
|
||||
{{ mf.recaptcha }}
|
||||
@@ -92,7 +96,7 @@
|
||||
});
|
||||
|
||||
function onTicketCreate(result){
|
||||
window.location = "{{ 'support/contact-us/conversation'|url }}" + '/' + result;
|
||||
window.location = "{{ 'support/ticket'|url }}" + '/' + result;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,135 +0,0 @@
|
||||
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
|
||||
{% set active_menu = 'support' %}
|
||||
|
||||
{% import "macro_functions.html.twig" as mf %}
|
||||
|
||||
{% block meta_title %}{{ ticket.subject }}{% endblock %}
|
||||
|
||||
{% block body_class %}support-contact-us-conversation{% endblock %}
|
||||
{% block breadcrumb %}
|
||||
<li class="breadcrumb-item"><a href="{{ 'support/contact-us'|url }}">{{ 'Contact Us'|trans }}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ ticket.subject }}</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{{ wysiwyg('.editor-textarea') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="card ms-0 ms-md-3 w-100">
|
||||
<div class="card-header">
|
||||
<h2>{{ 'Ticket Information'|trans }}</h2>
|
||||
<table class="table table-striped table-bordered table-sm">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ 'Subject'|trans }}</td>
|
||||
<td><b>{{ ticket.subject }}</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ 'Author'|trans }}</td>
|
||||
<td>{{ ticket.author.name }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ 'Email'|trans }}</td>
|
||||
<td>{{ ticket.author.email }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ 'Status'|trans }}</td>
|
||||
<td>
|
||||
{{ mf.status_badge(ticket.status, 'ticket') }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ 'Time Opened'|trans }}</td>
|
||||
<td>{{ ticket.created_at|format_date }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<button type="button" class="btn btn-primary btn-small ms-2 w-25" id="new-ticket-button"
|
||||
{{ fb_api_link({ message: 'Are you sure?'|trans, modal: {type: 'confirm', title: 'Are you sure?'|trans}, redirect: 'support/contact-us'|url }) }}> {{ 'Close Ticket'|trans }}</button>
|
||||
<a class="btn btn-info btn-small ms-2 w-25" href="#reply-to">{{ 'Reply'|trans }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% for i, message in ticket.messages %}
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<span class="text-muted">
|
||||
{{ message.author.name }}
|
||||
</span>
|
||||
<br/>
|
||||
{{ avatar(message.author.email, 60, 'img-thumbnail d-none d-md-block', null, 'div') }}
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<header>#{{ i+1 }} | {{ message.created_at|format_date }}
|
||||
{% if ticket.status != 'closed' %}
|
||||
<div class="float-end">
|
||||
<a href="#" class="btn btn-dark reply-to-message" message-quote="{{ mf.markdown_quote(message.content) }}">{{ 'Reply'|trans }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</header>
|
||||
<section>
|
||||
<div class="well" id="message-{{message.id}}">{{ (message.content ?? '')|markdown_to_html }}</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="card-footer" id="reply-to">
|
||||
{% if ticket.status != 'closed' %}
|
||||
<form method="post" action="{{ 'support/ticket_reply'|api_url(role: 'guest') }}" {{ fb_api_form({ reload: true }) }}>
|
||||
<input type="hidden" name="hash" value="{{ ticket.hash }}" />
|
||||
|
||||
<textarea name="message" cols="5" rows="10" class="editor-textarea form-control" required="required" id="ticket-reply-text"></textarea>
|
||||
<button class="btn btn-primary btn-large mt-1" type="submit" id="submit-support-message" value="{{ 'Post'|trans }}" onclick="">{{ 'Post'|trans }}</button>
|
||||
</form>
|
||||
{% elseif ticket.status == 'closed' %}
|
||||
<div class="alert alert-white text-center">{{ 'Ticket was closed and cannot be reopened.'|trans }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.reply-to-message').forEach(button => {
|
||||
button.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const replyTextarea = document.getElementById('ticket-reply-text');
|
||||
|
||||
if (replyTextarea) {
|
||||
const quote = this.getAttribute('message-quote');
|
||||
if (replyTextarea.editor) {
|
||||
replyTextarea.editor.setData(quote);
|
||||
replyTextarea.editor.focus();
|
||||
} else {
|
||||
replyTextarea.value = quote;
|
||||
replyTextarea.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('new-ticket-button').addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
FOSSBilling.api.guest.post("support/ticket_close", { hash: '{{ ticket.hash }}' },
|
||||
() => {
|
||||
FOSSBilling.message("Ticket was closed");
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -2,6 +2,8 @@
|
||||
{% set active_menu = 'support' %}
|
||||
|
||||
{% import "macro_functions.html.twig" as mf %}
|
||||
{% set is_guest_ticket = ticket.author.role|default('') == 'guest' %}
|
||||
{% set can_reply = ticket.status != 'closed' or (not is_guest_ticket and ticket.helpdesk.can_reopen) %}
|
||||
|
||||
{% block meta_title %}{{ ticket.subject }}{% endblock %}
|
||||
|
||||
@@ -12,7 +14,11 @@
|
||||
|
||||
{% block body_class %}support-ticket{% endblock %}
|
||||
{% block breadcrumb %}
|
||||
<li class="breadcrumb-item"><a href="{{ 'support'|url }}">{{ 'Support Tickets'|trans }}</a></li>
|
||||
{% if is_guest_ticket %}
|
||||
<li class="breadcrumb-item"><a href="{{ 'support/contact-us'|url }}">{{ 'Contact Us'|trans }}</a></li>
|
||||
{% else %}
|
||||
<li class="breadcrumb-item"><a href="{{ 'support'|url }}">{{ 'Support Tickets'|trans }}</a></li>
|
||||
{% endif %}
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ ticket.subject }}</li>
|
||||
{% endblock %}
|
||||
|
||||
@@ -27,7 +33,7 @@
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="d-flex gap-2">
|
||||
{% if (ticket.status != 'closed') or (ticket.helpdesk.can_reopen) %}
|
||||
{% if can_reply %}
|
||||
<button class="btn btn-info btn-sm" id="reply-to-btn">{{ 'Reply'|trans }}</button>
|
||||
{% endif %}
|
||||
{% if ticket.status != 'closed' %}
|
||||
@@ -94,7 +100,7 @@
|
||||
</div>
|
||||
<span class="text-muted fs-7">on {{ message.created_at|format_date }}</span>
|
||||
</div>
|
||||
{% if (ticket.status != 'closed') or (ticket.helpdesk.can_reopen) %}
|
||||
{% if can_reply %}
|
||||
<div class="d-flex gap-3 align-items-center">
|
||||
<span class="text-muted fs-7">#{{ message.id }}</span>
|
||||
<button class="btn btn-outline-secondary btn-quote-reply"
|
||||
@@ -122,7 +128,7 @@
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% if ticket.status == 'closed' and not ticket.helpdesk.can_reopen %}
|
||||
{% if not can_reply %}
|
||||
<div class="mt-3 alert alert-secondary text-center">{{ 'Ticket was closed and cannot be reopened.'|trans }}</div>
|
||||
{% else %}
|
||||
{% if ticket.status == 'closed' %}
|
||||
@@ -131,7 +137,11 @@
|
||||
<div class="card mt-3" id="reply-to">
|
||||
<div class="card-body">
|
||||
<form id="ticket-reply-form">
|
||||
<input type="hidden" name="id" value="{{ ticket.id }}">
|
||||
{% if is_guest_ticket %}
|
||||
<input type="hidden" name="hash" value="{{ ticket.hash }}">
|
||||
{% else %}
|
||||
<input type="hidden" name="id" value="{{ ticket.id }}">
|
||||
{% endif %}
|
||||
<textarea name="content" cols="5" rows="10" class="editor-textarea form-control" required="required"
|
||||
id="ticket-reply-text"></textarea>
|
||||
<button class="mt-2 btn btn-primary" type="submit" id="post-reply-btn"
|
||||
@@ -155,10 +165,11 @@
|
||||
const postReplyBtn = document.getElementById('post-reply-btn');
|
||||
const replyToMessageBtn = document.querySelectorAll('.btn-quote-reply');
|
||||
const ticketReplyTextArea = document.getElementById('ticket-reply-text');
|
||||
const supportApi = FOSSBilling.api.{{ is_guest_ticket ? 'guest' : 'client' }};
|
||||
|
||||
ticketReplyForm?.addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
FOSSBilling.api.client.post('support/ticket_reply', FOSSBilling.tools.serializeFormDataToObject(new FormData(ticketReplyForm)),
|
||||
supportApi.post('support/ticket_reply', FOSSBilling.tools.serializeFormDataToObject(new FormData(ticketReplyForm)),
|
||||
() => {
|
||||
flashMessage({
|
||||
message: 'Posted reply',
|
||||
@@ -172,7 +183,7 @@
|
||||
closeTicketBtn?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
toggleLoader();
|
||||
FOSSBilling.api.client.post('support/ticket_close', FOSSBilling.tools.serializeFormDataToObject(new FormData(ticketReplyForm)),
|
||||
supportApi.post('support/ticket_close', FOSSBilling.tools.serializeFormDataToObject(new FormData(ticketReplyForm)),
|
||||
() => {
|
||||
flashMessage({
|
||||
message: 'Closed ticket #{{ ticket.id }}',
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ ticket.subject|default('') }}{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Public Ticket Opened</h1>
|
||||
|
||||
<p>Hi {{ ticket.author_name|default('') }},</p>
|
||||
|
||||
<p>Thank You for Your request. We will reply within 24 hours.</p>
|
||||
<p>You can track and respond to this conversation <a href='{{ "support/contact-us/conversation/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">here</a></p>
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': c.email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,51 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ticket.subject|default('')}} [closed]{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Public Ticket Opened</h1>
|
||||
|
||||
<p>Hi {{ ticket.author_name|default('') }},</p>
|
||||
|
||||
<p>This is a confirmation email to inform you that your ticket was closed.</p>
|
||||
<p>You can track conversation <a href='{{ "support/contact-us/conversation/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">here</a></p>
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
<p>You may <a href="{{ 'login'|url(query: { 'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,51 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ticket.subject|default('')}}{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Public Ticket Opened</h1>
|
||||
|
||||
<p>Hi {{ ticket.author_name|default('') }},</p>
|
||||
|
||||
<p>{{ticket.messages|default([])[0].content|default('')}}</p>
|
||||
|
||||
<p>You can track and respond to this conversation <a href='{{ "support/contact-us/conversation/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">here</a></p>
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
<p>You may <a href="{{ 'login'|url(query: { 'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -1,51 +0,0 @@
|
||||
{% block subject %}[{{ guest.system_company.name }}] {{ticket.subject|default('')}}{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #cccccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Public Ticket Reply</h1>
|
||||
|
||||
<p>Hi {{ ticket.author_name|default('') }},</p>
|
||||
|
||||
<p>A new reply was posted to ticket <strong>{{ticket.subject|default('')}}</strong></p>
|
||||
|
||||
<p>You can track and respond to this conversation <a href='{{ "support/contact-us/conversation/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">here</a></p>
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
<p>You may <a href="{{ 'login'|url(query: { 'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
@@ -35,8 +35,13 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% set is_guest_ticket = ticket.author.role|default('') == 'guest' %}
|
||||
<h1>Ticket Opened</h1>
|
||||
|
||||
{% if is_guest_ticket %}
|
||||
<p>Hello, {{ ticket.author.name|default('') }}.</p>
|
||||
{% endif %}
|
||||
|
||||
<p>Thank you for contacting our support team. A support ticket has now been opened for your request.</p>
|
||||
<p>You will be notified by email when your ticket receives a response. The details of your ticket are shown below.</p>
|
||||
|
||||
@@ -47,12 +52,14 @@
|
||||
<li><strong>Status:</strong> {{ticket.status|default('')|title}}</li>
|
||||
</ul>
|
||||
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% if is_guest_ticket %}
|
||||
<a href='{{ "support/ticket/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% else %}
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% endif %}
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
<p>You may <a href="{{ 'staff/login'|url(query: { 'email': c.email|default('') }, area: 'admin') }}" target="_blank">login</a> or <a href="{{ 'staff/profile'|url(area: 'admin') }}" target="_blank">edit your profile.</a>
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -35,9 +35,10 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% set is_guest_ticket = ticket.author.role|default('') == 'guest' %}
|
||||
<h1>Ticket Closed</h1>
|
||||
|
||||
<p>Hi {{ c.first_name|default('') }} {{ c.last_name|default('') }},</p>
|
||||
<p>Hello, {{ ticket.author.name|default('') }}.</p>
|
||||
|
||||
<p>This a notification message to inform you that ticket <strong>{{ticket.subject|default('')}}</strong> is now closed.</p>
|
||||
|
||||
@@ -48,11 +49,17 @@
|
||||
<li><strong>Status:</strong> {{ticket.status|default('')|title}}</li>
|
||||
</ul>
|
||||
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% if is_guest_ticket %}
|
||||
<a href='{{ "support/ticket/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% else %}
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% endif %}
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
{% if not is_guest_ticket %}
|
||||
<p>You may <a href="{{ 'login'|url(query: {'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
|
||||
@@ -35,9 +35,10 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% set is_guest_ticket = ticket.author.role|default('') == 'guest' %}
|
||||
<h1>Ticket Opened</h1>
|
||||
|
||||
<p>Hi {{ c.first_name|default('') }} {{ c.last_name|default('') }},</p>
|
||||
<p>Hi {{ ticket.author.name|default('') }},</p>
|
||||
|
||||
<p>{{ticket.messages|default([])[0].content|default('')}}</p>
|
||||
|
||||
@@ -48,11 +49,17 @@
|
||||
<li><strong>Status:</strong> {{ticket.status|default('')|title}}</li>
|
||||
</ul>
|
||||
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% if is_guest_ticket %}
|
||||
<a href='{{ "support/ticket/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% else %}
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% endif %}
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
{% if not is_guest_ticket %}
|
||||
<p>You may <a href="{{ 'login'|url(query: {'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
|
||||
@@ -35,9 +35,10 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% set is_guest_ticket = ticket.author.role|default('') == 'guest' %}
|
||||
<h1>Ticket Replied</h1>
|
||||
|
||||
<p>Hi {{ c.first_name|default('') }} {{ c.last_name|default('') }},</p>
|
||||
<p>Hello, {{ ticket.author.name|default('') }}.</p>
|
||||
|
||||
<p>A new reply was posted to ticket <strong>{{ticket.subject|default('')}}</strong></p>
|
||||
|
||||
@@ -48,11 +49,17 @@
|
||||
<li><strong>Status:</strong> {{ticket.status|default('')|title}}</li>
|
||||
</ul>
|
||||
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% if is_guest_ticket %}
|
||||
<a href='{{ "support/ticket/#{ticket.hash|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% else %}
|
||||
<a href='{{ "support/ticket/#{ticket.id|default('')}"|url(area: 'client') }}' target="_blank">Reply</a>
|
||||
{% endif %}
|
||||
|
||||
<p>Please do not reply to this email directly. Use the link provided above.</p>
|
||||
|
||||
{% if not is_guest_ticket %}
|
||||
<p>You may <a href="{{ 'login'|url(query: { 'email': c.email|default('') }, area: 'client') }}" target="_blank">login</a> or <a href="{{ 'client/profile'|url(area: 'client') }}" target="_blank">edit your profile.</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="signature">{{ guest.system_email.signature }}</div>
|
||||
</body>
|
||||
|
||||
@@ -53,7 +53,7 @@ test('creates ticket for guest', function (): void {
|
||||
'name' => $expectedName,
|
||||
'email' => $expectedEmail,
|
||||
'subject' => $expectedSubject,
|
||||
'message' => $expectedMessage,
|
||||
'content' => $expectedMessage,
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeTrue();
|
||||
@@ -68,17 +68,22 @@ test('creates ticket for guest', function (): void {
|
||||
|
||||
$ticketData = $ticketGetResult->getResult();
|
||||
expect($ticketData)->toBeArray()
|
||||
->toHaveKey('author_name')
|
||||
->toHaveKey('author')
|
||||
->toHaveKey('subject')
|
||||
->toHaveKey('messages')
|
||||
->and($ticketData['author_name'])->toBe($expectedName)
|
||||
->and($ticketData['subject'])->toBe($expectedSubject)
|
||||
->and($ticketData['messages'])->toBeArray()->not->toBeEmpty()
|
||||
->and($ticketData['messages'][0]['content'])->toBe($expectedMessage);
|
||||
|
||||
expect($ticketData['author'])->toMatchArray([
|
||||
'name' => $expectedName,
|
||||
'email' => $expectedEmail,
|
||||
'role' => 'guest',
|
||||
]);
|
||||
});
|
||||
|
||||
test('rejects guest ticket creation when public tickets are disabled', function (): void {
|
||||
$configResult = ApiClient::request('admin/extension/config_save', ['ext' => 'mod_support', 'disable_public_tickets' => true]);
|
||||
test('rejects guest ticket creation when guest tickets are disabled', function (): void {
|
||||
$configResult = ApiClient::request('admin/extension/config_save', ['ext' => 'mod_support', 'disable_guest_tickets' => true]);
|
||||
expect($configResult->wasSuccessful())->toBeTrue();
|
||||
|
||||
$configGetResult = ApiClient::request('admin/extension/config_get', ['ext' => 'mod_support']);
|
||||
@@ -86,14 +91,14 @@ test('rejects guest ticket creation when public tickets are disabled', function
|
||||
|
||||
$configData = $configGetResult->getResult();
|
||||
expect($configData)->toBeArray()
|
||||
->toHaveKey('disable_public_tickets')
|
||||
->and((bool) $configData['disable_public_tickets'])->toBeTrue();
|
||||
->toHaveKey('disable_guest_tickets')
|
||||
->and((bool) $configData['disable_guest_tickets'])->toBeTrue();
|
||||
|
||||
$result = ApiClient::request('guest/support/ticket_create', [
|
||||
'name' => 'Name',
|
||||
'email' => 'email2@example.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'message',
|
||||
'content' => 'message',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse();
|
||||
@@ -103,15 +108,15 @@ test('rejects guest ticket creation when public tickets are disabled', function
|
||||
->toContain('unregistered users');
|
||||
});
|
||||
|
||||
test('public tickets enabled reflects configuration', function (): void {
|
||||
$enabledResult = ApiClient::request('guest/support/public_tickets_enabled');
|
||||
test('guest tickets enabled reflects configuration', function (): void {
|
||||
$enabledResult = ApiClient::request('guest/support/guest_tickets_enabled');
|
||||
expect($enabledResult->wasSuccessful())->toBeTrue()
|
||||
->and($enabledResult->getResult())->toBeTrue();
|
||||
|
||||
$configResult = ApiClient::request('admin/extension/config_save', ['ext' => 'mod_support', 'disable_public_tickets' => true]);
|
||||
$configResult = ApiClient::request('admin/extension/config_save', ['ext' => 'mod_support', 'disable_guest_tickets' => true]);
|
||||
expect($configResult->wasSuccessful())->toBeTrue();
|
||||
|
||||
$disabledResult = ApiClient::request('guest/support/public_tickets_enabled');
|
||||
$disabledResult = ApiClient::request('guest/support/guest_tickets_enabled');
|
||||
expect($disabledResult->wasSuccessful())->toBeTrue()
|
||||
->and($disabledResult->getResult())->toBeFalse();
|
||||
});
|
||||
@@ -120,7 +125,7 @@ test('rejects guest ticket creation without name', function (): void {
|
||||
$result = ApiClient::request('guest/support/ticket_create', [
|
||||
'email' => 'email@example.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'message',
|
||||
'content' => 'message',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse()
|
||||
@@ -131,7 +136,7 @@ test('rejects guest ticket creation without email', function (): void {
|
||||
$result = ApiClient::request('guest/support/ticket_create', [
|
||||
'name' => 'Name',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'message',
|
||||
'content' => 'message',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse()
|
||||
@@ -143,7 +148,7 @@ test('rejects guest ticket creation with invalid email', function (): void {
|
||||
'name' => 'Name',
|
||||
'email' => 'not-an-email',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'message',
|
||||
'content' => 'message',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse()
|
||||
@@ -155,7 +160,7 @@ test('rejects guest ticket creation with empty subject', function (): void {
|
||||
'name' => 'Name',
|
||||
'email' => 'email@example.com',
|
||||
'subject' => '',
|
||||
'message' => 'message',
|
||||
'content' => 'message',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse()
|
||||
@@ -167,7 +172,7 @@ test('rejects guest ticket creation with empty message', function (): void {
|
||||
'name' => 'Name',
|
||||
'email' => 'email@example.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => '',
|
||||
'content' => '',
|
||||
]);
|
||||
|
||||
expect($result->wasSuccessful())->toBeFalse()
|
||||
|
||||
@@ -344,48 +344,12 @@ test('batch ticket auto close not closed', function (): void {
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('batch public ticket auto close', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicGetExpired')->atLeast()->once()
|
||||
->andReturn([new Model_SupportPTicket(), new Model_SupportPTicket()]);
|
||||
$serviceMock->shouldReceive('publicAutoClose')->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$result = $api->batch_public_ticket_auto_close([]);
|
||||
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('batch public ticket auto close not closed', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->id = 1;
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicGetExpired')->atLeast()->once()
|
||||
->andReturn([$ticket, $ticket]);
|
||||
$serviceMock->shouldReceive('publicAutoClose')->atLeast()->once()
|
||||
;
|
||||
|
||||
$api->setService($serviceMock);
|
||||
$di = container();
|
||||
$di['logger'] = $this->createStub('\Box_Log');
|
||||
$api->setDi($di);
|
||||
$result = $api->batch_public_ticket_auto_close([]);
|
||||
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('ticket get statuses', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$statuses = [
|
||||
Model_SupportPTicket::OPENED => 'Open',
|
||||
Model_SupportPTicket::ONHOLD => 'On hold',
|
||||
Model_SupportPTicket::CLOSED => 'Closed',
|
||||
Model_SupportTicket::OPENED => 'Open',
|
||||
Model_SupportTicket::ONHOLD => 'On hold',
|
||||
Model_SupportTicket::CLOSED => 'Closed',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('getStatuses')
|
||||
@@ -403,9 +367,9 @@ test('ticket get statuses', function (): void {
|
||||
test('ticket get statuses titles set', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$statuses = [
|
||||
Model_SupportPTicket::OPENED => 'Open',
|
||||
Model_SupportPTicket::ONHOLD => 'On hold',
|
||||
Model_SupportPTicket::CLOSED => 'Closed',
|
||||
Model_SupportTicket::OPENED => 'Open',
|
||||
Model_SupportTicket::ONHOLD => 'On hold',
|
||||
Model_SupportTicket::CLOSED => 'Closed',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('getStatuses')->atLeast()->once()
|
||||
@@ -423,251 +387,6 @@ test('ticket get statuses titles set', function (): void {
|
||||
expect($result)->toEqual($statuses);
|
||||
});
|
||||
|
||||
test('public ticket get list', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$resultSet = [
|
||||
'list' => [
|
||||
0 => ['id' => 1],
|
||||
],
|
||||
];
|
||||
$paginatorMock = Mockery::mock(FOSSBilling\Pagination::class)->makePartial();
|
||||
$paginatorMock
|
||||
->shouldReceive('getPaginatedResultSet')
|
||||
->atLeast()->once()
|
||||
->andReturn($resultSet);
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicGetSearchQuery')->atLeast()->once()
|
||||
->andReturn(['query', []]);
|
||||
$serviceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
->andReturn(['query', []]);
|
||||
|
||||
$model = new Model_SupportPTicket();
|
||||
$model->loadBean(new Tests\Helpers\DummyBean());
|
||||
$dbMock = Mockery::mock('\Box_DAtabase');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn($model);
|
||||
|
||||
$di = container();
|
||||
$di['pager'] = $paginatorMock;
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$data = [];
|
||||
$result = $api->public_ticket_get_list($data);
|
||||
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
test('public ticket create', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$randID = 1;
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicTicketCreate')->atLeast()->once()
|
||||
->andReturn($randID);
|
||||
|
||||
$di = container();
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
$api->setIdentity(new Model_Admin());
|
||||
|
||||
$data = [
|
||||
'name' => 'Name',
|
||||
'email' => 'email@example.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'Message',
|
||||
];
|
||||
|
||||
$result = $api->public_ticket_create($data);
|
||||
|
||||
expect($result)->toBeInt();
|
||||
expect($result)->toEqual($randID);
|
||||
});
|
||||
|
||||
test('public ticket get', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$randID = 1;
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
];
|
||||
$result = $api->public_ticket_get($data);
|
||||
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
test('public ticket delete', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicRm')->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
];
|
||||
$result = $api->public_ticket_delete($data);
|
||||
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('public ticket close', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicCloseTicket')->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
$api->setIdentity(new Model_Admin());
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
];
|
||||
$result = $api->public_ticket_close($data);
|
||||
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('public ticket update', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicTicketUpdate')->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
$api->setIdentity(new Model_Admin());
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
];
|
||||
$result = $api->public_ticket_update($data);
|
||||
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('public ticket reply', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock
|
||||
->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicTicketReply')->atLeast()->once()
|
||||
->andReturn(1);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$api->setDi($di);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
$api->setIdentity(new Model_Admin());
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
'content' => 'Content',
|
||||
];
|
||||
$result = $api->public_ticket_reply($data);
|
||||
|
||||
expect($result)->toBeInt();
|
||||
});
|
||||
|
||||
test('public ticket get statuses', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$statuses = [
|
||||
Model_SupportPTicket::OPENED => 'Open',
|
||||
Model_SupportPTicket::ONHOLD => 'On hold',
|
||||
Model_SupportPTicket::CLOSED => 'Closed',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicGetStatuses')
|
||||
->andReturn($statuses);
|
||||
$serviceMock->shouldReceive('publicCounter')->atLeast()->once()
|
||||
->andReturn($statuses);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$result = $api->public_ticket_get_statuses([]);
|
||||
|
||||
expect($result)->toEqual($statuses);
|
||||
});
|
||||
|
||||
test('public ticket get statuses titles set', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$statuses = [
|
||||
Model_SupportPTicket::OPENED => 'Open',
|
||||
Model_SupportPTicket::ONHOLD => 'On hold',
|
||||
Model_SupportPTicket::CLOSED => 'Closed',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicGetStatuses')->atLeast()->once()
|
||||
->andReturn($statuses);
|
||||
$serviceMock->shouldReceive('publicCounter')
|
||||
->andReturn($statuses);
|
||||
|
||||
$api->setService($serviceMock);
|
||||
|
||||
$data = [
|
||||
'titles' => true,
|
||||
];
|
||||
$result = $api->public_ticket_get_statuses($data);
|
||||
|
||||
expect($result)->toEqual($statuses);
|
||||
});
|
||||
|
||||
test('helpdesk get list', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$paginatorMock = Mockery::mock(FOSSBilling\Pagination::class)->makePartial();
|
||||
@@ -1193,18 +912,6 @@ test('batch delete', function (): void {
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('batch delete public', function (): void {
|
||||
$api = new Box\Mod\Support\Api\Admin();
|
||||
$activityMock = Mockery::mock(Box\Mod\Support\Api\Admin::class)->makePartial();
|
||||
$activityMock->shouldReceive('public_ticket_delete')->atLeast()->once()->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$activityMock->setDi($di);
|
||||
|
||||
$result = $activityMock->batch_delete_public(['ids' => [1, 2, 3]]);
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
/*
|
||||
* Knowledge Base Tests.
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ test('ticket create', function (): void {
|
||||
'name' => 'Name',
|
||||
'email' => 'email@wxample.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => 'Message',
|
||||
'content' => 'Message',
|
||||
];
|
||||
$result = $guestApi->ticket_create($data);
|
||||
|
||||
@@ -51,7 +51,7 @@ test('ticket create message too short exception', function (): void {
|
||||
'name' => 'Name',
|
||||
'email' => 'email@wxample.com',
|
||||
'subject' => 'Subject',
|
||||
'message' => '',
|
||||
'content' => '',
|
||||
];
|
||||
|
||||
expect(fn (): string => $guestApi->ticket_create($data))->toThrow(FOSSBilling\Exception::class);
|
||||
@@ -60,9 +60,9 @@ test('ticket create message too short exception', function (): void {
|
||||
test('ticket get', function (): void {
|
||||
$guestApi = new Box\Mod\Support\Api\Guest();
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicFindOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$serviceMock->shouldReceive('publicToApiArray')->atLeast()->once()
|
||||
$serviceMock->shouldReceive('findOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$serviceMock->shouldReceive('toApiArray')->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
@@ -81,9 +81,9 @@ test('ticket get', function (): void {
|
||||
test('ticket close', function (): void {
|
||||
$guestApi = new Box\Mod\Support\Api\Guest();
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicFindOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$serviceMock->shouldReceive('publicCloseTicket')->atLeast()->once()
|
||||
$serviceMock->shouldReceive('findOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$serviceMock->shouldReceive('closeTicket')->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -103,10 +103,10 @@ test('ticket close', function (): void {
|
||||
test('ticket reply', function (): void {
|
||||
$guestApi = new Box\Mod\Support\Api\Guest();
|
||||
$serviceMock = Mockery::mock(Box\Mod\Support\Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('publicFindOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
$serviceMock->shouldReceive('publicTicketReplyForGuest')->atLeast()->once()
|
||||
->andReturn(sha1(uniqid()));
|
||||
$serviceMock->shouldReceive('findOneByHash')->atLeast()->once()
|
||||
->andReturn(new Model_SupportTicket());
|
||||
$serviceMock->shouldReceive('ticketReply')->atLeast()->once()
|
||||
->andReturn(1);
|
||||
|
||||
$di = container();
|
||||
$guestApi->setDi($di);
|
||||
@@ -115,12 +115,11 @@ test('ticket reply', function (): void {
|
||||
|
||||
$data = [
|
||||
'hash' => sha1(uniqid()),
|
||||
'message' => 'Message',
|
||||
'content' => 'Message',
|
||||
];
|
||||
$result = $guestApi->ticket_reply($data);
|
||||
|
||||
expect($result)->toBeString();
|
||||
expect(strlen($result))->toEqual(40);
|
||||
expect($result)->toBeInt();
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,6 +24,7 @@ function supportClientFixture(): Model_Client
|
||||
$client->id = 1;
|
||||
$client->first_name = 'Client';
|
||||
$client->last_name = 'Name';
|
||||
$client->email = 'client@example.com';
|
||||
|
||||
return $client;
|
||||
}
|
||||
@@ -64,6 +65,7 @@ test('handles after client open ticket event', function (): void {
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_support_ticket_open'))
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -110,6 +112,7 @@ test('handles after admin open ticket event', function (): void {
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_support_ticket_staff_open'))
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -156,6 +159,7 @@ test('handles after admin close ticket event', function (): void {
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_support_ticket_staff_close'))
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -202,6 +206,7 @@ test('handles after admin reply ticket event', function (): void {
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_support_ticket_staff_reply'))
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -228,25 +233,30 @@ test('handles after admin reply ticket event', function (): void {
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('handles after guest public ticket open event', function (): void {
|
||||
test('handles guest ticket with regular client open event', function (): void {
|
||||
$service = new Service();
|
||||
$toApiArrayReturn = [
|
||||
'author_email' => 'email@example.com',
|
||||
'author_name' => 'Name',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial();
|
||||
$supportPTicketModel = new Model_SupportPTicket();
|
||||
$supportPTicketModel = new Model_SupportTicket();
|
||||
$supportPTicketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$serviceMock->shouldReceive('getPublicTicketById')
|
||||
$supportPTicketModel->client_id = null;
|
||||
$supportPTicketModel->access_hash = 'guest-ticket-hash';
|
||||
$supportPTicketModel->author_email = 'email@example.com';
|
||||
$supportPTicketModel->author_name = 'Name';
|
||||
$serviceMock->shouldReceive('getTicketById')
|
||||
->atLeast()->once()
|
||||
->andReturn($supportPTicketModel);
|
||||
$serviceMock->shouldReceive('publicToApiArray')
|
||||
$serviceMock->shouldReceive('toApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn($toApiArrayReturn);
|
||||
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->with(Mockery::on(fn ($email) => $email['code'] === 'mod_support_ticket_open' && $email['to'] === 'email@example.com'))
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
@@ -258,6 +268,9 @@ test('handles after guest public ticket open event', function (): void {
|
||||
return $serviceMock;
|
||||
}
|
||||
});
|
||||
$di['loggedin_client'] = static function (): void {
|
||||
throw new Exception('Client is not logged in');
|
||||
};
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
@@ -268,142 +281,7 @@ test('handles after guest public ticket open event', function (): void {
|
||||
->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
|
||||
$result = $serviceMock->onAfterGuestPublicTicketOpen($eventMock);
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('handles after admin public ticket open event', function (): void {
|
||||
$service = new Service();
|
||||
$toApiArrayReturn = [
|
||||
'author_email' => 'email@example.com',
|
||||
'author_name' => 'Name',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial();
|
||||
$supportPTicketModel = new Model_SupportPTicket();
|
||||
$supportPTicketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$serviceMock->shouldReceive('getPublicTicketById')
|
||||
->atLeast()->once()
|
||||
->andReturn($supportPTicketModel);
|
||||
$serviceMock->shouldReceive('publicToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn($toApiArrayReturn);
|
||||
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['mod_service'] = $di->protect(function ($serviceName) use ($emailServiceMock, $serviceMock) {
|
||||
if ($serviceName == 'email') {
|
||||
return $emailServiceMock;
|
||||
}
|
||||
if ($serviceName == 'support') {
|
||||
return $serviceMock;
|
||||
}
|
||||
});
|
||||
$di['loggedin_admin'] = new Model_Admin();
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
$eventMock->shouldReceive('getDi')
|
||||
->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$eventMock->shouldReceive('getParameters')
|
||||
->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
|
||||
$result = $serviceMock->onAfterAdminPublicTicketOpen($eventMock);
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('handles after admin public ticket reply event', function (): void {
|
||||
$service = new Service();
|
||||
$toApiArrayReturn = [
|
||||
'author_email' => 'email@example.com',
|
||||
'author_name' => 'Name',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial();
|
||||
$supportPTicketModel = new Model_SupportPTicket();
|
||||
$supportPTicketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$serviceMock->shouldReceive('getPublicTicketById')
|
||||
->atLeast()->once()
|
||||
->andReturn($supportPTicketModel);
|
||||
$serviceMock->shouldReceive('publicToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn($toApiArrayReturn);
|
||||
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['mod_service'] = $di->protect(function ($serviceName) use ($emailServiceMock, $serviceMock) {
|
||||
if ($serviceName == 'email') {
|
||||
return $emailServiceMock;
|
||||
}
|
||||
if ($serviceName == 'support') {
|
||||
return $serviceMock;
|
||||
}
|
||||
});
|
||||
$di['loggedin_admin'] = new Model_Admin();
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
$eventMock->shouldReceive('getDi')
|
||||
->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$eventMock->shouldReceive('getParameters')
|
||||
->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
|
||||
$result = $serviceMock->onAfterAdminPublicTicketReply($eventMock);
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('handles after admin public ticket close event', function (): void {
|
||||
$service = new Service();
|
||||
$toApiArrayReturn = [
|
||||
'author_email' => 'email@example.com',
|
||||
'author_name' => 'Name',
|
||||
];
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial();
|
||||
$supportPTicketModel = new Model_SupportPTicket();
|
||||
$supportPTicketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$serviceMock->shouldReceive('getPublicTicketById')
|
||||
->atLeast()->once()
|
||||
->andReturn($supportPTicketModel);
|
||||
$serviceMock->shouldReceive('publicToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn($toApiArrayReturn);
|
||||
|
||||
$emailServiceMock = Mockery::mock(EmailService::class);
|
||||
$emailServiceMock->shouldReceive('sendTemplate')
|
||||
->atLeast()->once()
|
||||
->andReturn(true);
|
||||
|
||||
$di = container();
|
||||
$di['mod_service'] = $di->protect(function ($serviceName) use ($emailServiceMock, $serviceMock) {
|
||||
if ($serviceName == 'email') {
|
||||
return $emailServiceMock;
|
||||
}
|
||||
if ($serviceName == 'support') {
|
||||
return $serviceMock;
|
||||
}
|
||||
});
|
||||
$di['loggedin_admin'] = new Model_Admin();
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_Event');
|
||||
$eventMock->shouldReceive('getDi')
|
||||
->atLeast()->once()
|
||||
->andReturn($di);
|
||||
$eventMock->shouldReceive('getParameters')
|
||||
->atLeast()->once()
|
||||
->andReturn(['id' => random_int(1, 100)]);
|
||||
|
||||
$result = $serviceMock->onAfterAdminPublicTicketClose($eventMock);
|
||||
$result = $serviceMock->onAfterClientOpenTicket($eventMock);
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
@@ -426,23 +304,6 @@ test('gets ticket by id', function (): void {
|
||||
expect($result)->toBeInstanceOf(Model_SupportTicket::class);
|
||||
});
|
||||
|
||||
test('gets public ticket by id', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$supportPTicketModel = new Model_SupportPTicket();
|
||||
$supportPTicketModel->loadBean(new Tests\Helpers\DummyBean());
|
||||
$dbMock->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn($supportPTicketModel);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->getPublicTicketById(1);
|
||||
expect($result)->toBeInstanceOf(Model_SupportPTicket::class);
|
||||
});
|
||||
|
||||
test('gets statuses', function (): void {
|
||||
$service = new Service();
|
||||
$result = $service->getStatuses();
|
||||
@@ -560,6 +421,7 @@ test('gets latest tickets', function (): void {
|
||||
$service = new Service();
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->support_helpdesk_id = 1;
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('find')
|
||||
->atLeast()->once()
|
||||
@@ -848,23 +710,33 @@ test('converts ticket to api array', function (): void {
|
||||
$serviceMock->shouldReceive('noteToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
$serviceMock->shouldReceive('getClientApiArrayForTicket')
|
||||
->atLeast()->once()
|
||||
$clientServiceMock = Mockery::mock(ClientService::class);
|
||||
$clientServiceMock->shouldReceive('toApiArray')
|
||||
->byDefault()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['mod_service'] = $di->protect(fn () => $clientServiceMock);
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->support_helpdesk_id = 1;
|
||||
|
||||
$result = $serviceMock->toApiArray($ticket, true, new Model_Admin());
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('replies');
|
||||
expect($result)->toHaveKey('helpdesk');
|
||||
expect($result)->toHaveKey('messages');
|
||||
expect($result['author'])->toMatchArray([
|
||||
'id' => 1,
|
||||
'name' => 'Client Name',
|
||||
'first_name' => 'Client',
|
||||
'last_name' => 'Name',
|
||||
'email' => 'client@example.com',
|
||||
'role' => 'client',
|
||||
]);
|
||||
expect(count($result['messages']))->toBe(count($ticketMessages));
|
||||
});
|
||||
|
||||
@@ -909,17 +781,19 @@ test('converts ticket to api array with rel details', function (): void {
|
||||
$serviceMock->shouldReceive('noteToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
$serviceMock->shouldReceive('getClientApiArrayForTicket')
|
||||
->atLeast()->once()
|
||||
$clientServiceMock = Mockery::mock(ClientService::class);
|
||||
$clientServiceMock->shouldReceive('toApiArray')
|
||||
->byDefault()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['mod_service'] = $di->protect(fn () => $clientServiceMock);
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->support_helpdesk_id = 1;
|
||||
$ticket->rel_id = 1;
|
||||
$ticket->rel_type = 'Type';
|
||||
|
||||
@@ -931,54 +805,6 @@ test('converts ticket to api array with rel details', function (): void {
|
||||
expect(count($result['messages']))->toBe(count($ticketMessages));
|
||||
});
|
||||
|
||||
test('gets client api array for ticket', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('load')
|
||||
->atLeast()->once()
|
||||
->andReturn(supportClientFixture());
|
||||
|
||||
$clientServiceMock = Mockery::mock(ClientService::class);
|
||||
$clientServiceMock->shouldReceive('toApiArray')
|
||||
->byDefault()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['mod_service'] = $di->protect(fn () => $clientServiceMock);
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->getClientApiArrayForTicket($ticket);
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
test('gets client api array for ticket when client not exists', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('load')
|
||||
->atLeast()->once()
|
||||
->andReturn(null);
|
||||
|
||||
$clientServiceMock = Mockery::mock(ClientService::class);
|
||||
$clientServiceMock->shouldReceive('toApiArray')->never();
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['mod_service'] = $di->protect(fn () => $clientServiceMock);
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->getClientApiArrayForTicket($ticket);
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
/*
|
||||
* Canned Response Tests
|
||||
*/
|
||||
@@ -1912,28 +1738,22 @@ test('kb find category by slug', function (): void {
|
||||
});
|
||||
|
||||
/*
|
||||
* Public Ticket Tests
|
||||
* Guest Ticket Tests
|
||||
*/
|
||||
|
||||
test('public get statuses', function (): void {
|
||||
$service = new Service();
|
||||
$result = $service->publicGetStatuses();
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
test('public find one by hash', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('findOne')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Model_SupportPTicket());
|
||||
->andReturn(new Model_SupportTicket());
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->publicFindOneByHash(sha1(uniqid()));
|
||||
expect($result)->toBeInstanceOf(Model_SupportPTicket::class);
|
||||
$result = $service->findOneByHash(sha1(uniqid()));
|
||||
expect($result)->toBeInstanceOf(Model_SupportTicket::class);
|
||||
});
|
||||
|
||||
test('public find one by hash not found exception', function (): void {
|
||||
@@ -1948,117 +1768,10 @@ test('public find one by hash not found exception', function (): void {
|
||||
$service->setDi($di);
|
||||
|
||||
$this->expectException(FOSSBilling\Exception::class);
|
||||
$service->publicFindOneByHash(sha1(uniqid()));
|
||||
$service->findOneByHash(sha1(uniqid()));
|
||||
});
|
||||
|
||||
dataset('publicGetSearchQueryProvider', fn (): array => [
|
||||
'with search string' => [
|
||||
[
|
||||
'search' => 'Query',
|
||||
'id' => 1,
|
||||
'status' => Model_SupportPTicket::OPENED,
|
||||
'name' => 'Name',
|
||||
'email' => 'email@example.com',
|
||||
'subject' => 'Subject',
|
||||
'content' => 'Content',
|
||||
],
|
||||
],
|
||||
'with search int' => [
|
||||
[
|
||||
'search' => 1,
|
||||
'id' => 1,
|
||||
'status' => Model_SupportPTicket::OPENED,
|
||||
'name' => 'Name',
|
||||
'email' => 'email@example.com',
|
||||
'subject' => 'Subject',
|
||||
'content' => 'Content',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
test('public get search query', function (array $data): void {
|
||||
$service = new Service();
|
||||
$di = container();
|
||||
$service->setDi($di);
|
||||
|
||||
[$query, $bindings] = $service->publicGetSearchQuery($data);
|
||||
expect($query)->toBeString();
|
||||
expect($bindings)->toBeArray();
|
||||
})->with('publicGetSearchQueryProvider');
|
||||
|
||||
test('public counter', function (): void {
|
||||
$service = new Service();
|
||||
$arr = [
|
||||
Model_SupportPTicket::OPENED => 1,
|
||||
Model_SupportPTicket::ONHOLD => 1,
|
||||
Model_SupportPTicket::CLOSED => 1,
|
||||
];
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('getAssoc')
|
||||
->atLeast()->once()
|
||||
->andReturn($arr);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->publicCounter();
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('total');
|
||||
expect($result['total'])->toEqual(array_sum($arr));
|
||||
});
|
||||
|
||||
test('public get latest', function (): void {
|
||||
$service = new Service();
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('find')
|
||||
->atLeast()->once()
|
||||
->andReturn([$ticket, $ticket]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->publicGetLatest();
|
||||
expect($result)->toBeArray();
|
||||
expect($result[0])->toBeInstanceOf(Model_SupportPTicket::class);
|
||||
});
|
||||
|
||||
test('public count by status', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('getCell')
|
||||
->atLeast()->once()
|
||||
->andReturn('1');
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->publicCountByStatus('open');
|
||||
expect($result)->toBeInt();
|
||||
});
|
||||
|
||||
test('public get expired', function (): void {
|
||||
$service = new Service();
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('find')
|
||||
->atLeast()->once()
|
||||
->andReturn([$ticket, $ticket]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->publicGetExpired();
|
||||
expect($result)->toBeArray();
|
||||
expect($result[0])->toBeInstanceOf(Model_SupportPTicket::class);
|
||||
});
|
||||
|
||||
dataset('publicCloseTicketProvider', fn (): array => [
|
||||
dataset('closeTicketProvider', fn (): array => [
|
||||
'with admin' => [new Model_Admin()],
|
||||
'with guest' => [new Model_Guest()],
|
||||
]);
|
||||
@@ -2080,329 +1793,62 @@ test('public close ticket', function (Model_Admin|Model_Guest $identity): void {
|
||||
$di['events_manager'] = $eventMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->access_hash = 'test-hash-123';
|
||||
|
||||
$result = $service->closeTicket($ticket, $identity);
|
||||
expect($result)->toBeTrue();
|
||||
})->with('closeTicketProvider');
|
||||
|
||||
test('public to api array delegates to ticket serialization', function (): void {
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial();
|
||||
$serviceMock->shouldReceive('toApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn(['hash' => 'test-hash-123']);
|
||||
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->publicCloseTicket($ticket, $identity);
|
||||
expect($result)->toBeTrue();
|
||||
})->with('publicCloseTicketProvider');
|
||||
$result = $serviceMock->toApiArray($ticket, true);
|
||||
expect($result)->toEqual(['hash' => 'test-hash-123']);
|
||||
});
|
||||
|
||||
test('public auto close', function (): void {
|
||||
test('guest ticket reply', function (): void {
|
||||
$service = new Service();
|
||||
$message = new Model_SupportTicketMessage();
|
||||
$message->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('dispense')
|
||||
->atLeast()->once()
|
||||
->andReturn($message);
|
||||
$dbMock->shouldReceive('store')
|
||||
->atLeast()->once()
|
||||
->andReturn(1);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->publicAutoClose($ticket);
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('public rm', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('trash')
|
||||
->atLeast()->once()
|
||||
->andReturn(null);
|
||||
$dbMock->shouldReceive('find')
|
||||
->atLeast()->once()
|
||||
->andReturn([new Model_SupportPTicketMessage()]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->publicRm($ticket);
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
dataset('publicToApiArrayProvider', fn (): array => [
|
||||
'with message' => [
|
||||
new Model_SupportPTicketMessage(),
|
||||
'atLeastOnce',
|
||||
],
|
||||
'without message' => [
|
||||
null,
|
||||
'never',
|
||||
],
|
||||
]);
|
||||
|
||||
test('public to api array', function (?Model_SupportPTicketMessage $findOne, string $publicMessageGetAuthorDetailsCalled): void {
|
||||
$service = new Service();
|
||||
$ticketMessages = [new Model_SupportPTicketMessage(), new Model_SupportPTicketMessage()];
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('findOne')
|
||||
->andReturn($findOne);
|
||||
$dbMock->shouldReceive('toArray')
|
||||
->byDefault()
|
||||
->andReturn([]);
|
||||
$dbMock->shouldReceive('find')
|
||||
->andReturn($ticketMessages);
|
||||
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial()->shouldAllowMockingProtectedMethods();
|
||||
$serviceMock->shouldReceive('publicMessageToApiArray')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
$serviceMock->shouldReceive('publicMessageGetAuthorDetails')
|
||||
->atLeast()->once()
|
||||
->andReturn(['name' => 'Name', 'email' => 'email#example.com']);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $serviceMock->publicToApiArray($ticket, true);
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('author');
|
||||
expect($result)->toHaveKey('messages');
|
||||
expect($result['messages'])->toHaveCount(count($ticketMessages));
|
||||
})->with('publicToApiArrayProvider');
|
||||
|
||||
test('public message get author details admin', function (): void {
|
||||
$service = new Service();
|
||||
$admin = new Model_Admin();
|
||||
$admin->loadBean(new Tests\Helpers\DummyBean());
|
||||
$admin->id = 1;
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn($admin);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$ticketMsg = new Model_SupportPTicketMessage();
|
||||
$ticketMsg->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticketMsg->admin_id = 1;
|
||||
|
||||
$result = $service->publicMessageGetAuthorDetails($ticketMsg);
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('name');
|
||||
});
|
||||
|
||||
test('public message get author details not admin', function (): void {
|
||||
$service = new Service();
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->author_name = 'Name';
|
||||
$ticket->author_email = 'Email@example.com';
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('getExistingModelById')
|
||||
->atLeast()->once()
|
||||
->andReturn($ticket);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$ticketMsg = new Model_SupportPTicketMessage();
|
||||
$ticketMsg->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticketMsg->admin_id = null;
|
||||
|
||||
$result = $service->publicMessageGetAuthorDetails($ticketMsg);
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('name');
|
||||
});
|
||||
|
||||
test('public message to api array', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('toArray')
|
||||
->byDefault()
|
||||
->andReturn([]);
|
||||
|
||||
$serviceMock = Mockery::mock(Service::class)->makePartial()->shouldAllowMockingProtectedMethods();
|
||||
$serviceMock->shouldReceive('publicMessageGetAuthorDetails')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$serviceMock->setDi($di);
|
||||
|
||||
$ticketMsg = new Model_SupportPTicketMessage();
|
||||
$ticketMsg->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticketMsg->id = 1;
|
||||
|
||||
$result = $serviceMock->publicMessageToApiArray($ticketMsg);
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->toHaveKey('author');
|
||||
});
|
||||
|
||||
test('public ticket create', function (): void {
|
||||
$service = new Service();
|
||||
$message = new Model_SupportTicketMessage();
|
||||
$message->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$randId = 1;
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('dispense')
|
||||
->atLeast()->once()
|
||||
->andReturn($message);
|
||||
$dbMock->shouldReceive('store')
|
||||
->atLeast()->once()
|
||||
->andReturn($randId);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_EventManager');
|
||||
$eventMock->shouldReceive('fire')
|
||||
->atLeast()->once();
|
||||
|
||||
$toolsMock = Mockery::mock(FOSSBilling\Tools::class);
|
||||
$toolsMock->shouldReceive('validateAndSanitizeEmail')
|
||||
->atLeast()->once();
|
||||
|
||||
$requestMock = Mockery::mock(FOSSBilling\Request::class);
|
||||
$requestMock->shouldReceive('getClientIp')
|
||||
->atLeast()->once()
|
||||
->andReturn('127.0.0.1');
|
||||
|
||||
$eventMock = Mockery::mock('\Box_EventManager');
|
||||
$eventMock->shouldReceive('fire')
|
||||
->atLeast()->once();
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['events_manager'] = $eventMock;
|
||||
$di['tools'] = $toolsMock;
|
||||
$di['request'] = $requestMock;
|
||||
$di['events_manager'] = $eventMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$admin = new Model_Admin();
|
||||
$admin->loadBean(new Tests\Helpers\DummyBean());
|
||||
$admin->id = 1;
|
||||
$ticket = new Model_SupportTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->access_hash = 'test-hash-123';
|
||||
|
||||
$data = [
|
||||
'email' => 'email@example.com',
|
||||
'name' => 'Name',
|
||||
'message' => 'Message',
|
||||
'request' => 'Request',
|
||||
'subject' => 'Subject',
|
||||
];
|
||||
|
||||
$result = $service->publicTicketCreate($data, $admin);
|
||||
$result = $service->ticketReply($ticket, new \Model_Guest(), 'Content');
|
||||
expect($result)->toBeInt();
|
||||
expect($result)->toEqual($randId);
|
||||
});
|
||||
|
||||
test('public ticket update', function (): void {
|
||||
$service = new Service();
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('store')
|
||||
->atLeast()->once()
|
||||
->andReturn(1);
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$data = [
|
||||
'support_helpdesk_id' => 1,
|
||||
'status' => Model_SupportTicket::OPENED,
|
||||
'subject' => 'Subject',
|
||||
'priority' => 1,
|
||||
];
|
||||
|
||||
$result = $service->publicTicketUpdate($ticket, $data);
|
||||
expect($result)->toBeTrue();
|
||||
});
|
||||
|
||||
test('public ticket reply', function (): void {
|
||||
$service = new Service();
|
||||
$message = new Model_SupportTicketMessage();
|
||||
$message->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$randId = 1;
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('dispense')
|
||||
->atLeast()->once()
|
||||
->andReturn($message);
|
||||
$dbMock->shouldReceive('store')
|
||||
->atLeast()->once()
|
||||
->andReturn($randId);
|
||||
|
||||
$eventMock = Mockery::mock('\Box_EventManager');
|
||||
$eventMock->shouldReceive('fire')
|
||||
->atLeast()->once();
|
||||
|
||||
$requestMock = Mockery::mock(FOSSBilling\Request::class);
|
||||
$requestMock->shouldReceive('getClientIp')
|
||||
->atLeast()->once()
|
||||
->andReturn('127.0.0.1');
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['events_manager'] = $eventMock;
|
||||
$di['request'] = $requestMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$admin = new Model_Admin();
|
||||
$admin->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$result = $service->publicTicketReply($ticket, $admin, 'Content');
|
||||
expect($result)->toBeInt();
|
||||
expect($result)->toEqual($randId);
|
||||
});
|
||||
|
||||
test('public ticket reply for guest', function (): void {
|
||||
$service = new Service();
|
||||
$message = new Model_SupportTicketMessage();
|
||||
$message->loadBean(new Tests\Helpers\DummyBean());
|
||||
|
||||
$dbMock = Mockery::mock('\Box_Database');
|
||||
$dbMock->shouldReceive('dispense')
|
||||
->atLeast()->once()
|
||||
->andReturn($message);
|
||||
$dbMock->shouldReceive('store')
|
||||
->atLeast()->once();
|
||||
|
||||
$requestMock = Mockery::mock(FOSSBilling\Request::class);
|
||||
$requestMock->shouldReceive('getClientIp')
|
||||
->atLeast()->once()
|
||||
->andReturn('127.0.0.1');
|
||||
|
||||
$eventMock = Mockery::mock('\Box_EventManager');
|
||||
$eventMock->shouldReceive('fire')
|
||||
->atLeast()->once();
|
||||
|
||||
$di = container();
|
||||
$di['db'] = $dbMock;
|
||||
$di['logger'] = new Tests\Helpers\TestLogger();
|
||||
$di['request'] = $requestMock;
|
||||
$di['events_manager'] = $eventMock;
|
||||
$service->setDi($di);
|
||||
|
||||
$ticket = new Model_SupportPTicket();
|
||||
$ticket->loadBean(new Tests\Helpers\DummyBean());
|
||||
$ticket->hash = 'test-hash-123';
|
||||
|
||||
$result = $service->publicTicketReplyForGuest($ticket, 'Content');
|
||||
expect($result)->toBeString();
|
||||
expect($result)->toEqual('test-hash-123');
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,9 +57,10 @@
|
||||
'/news',
|
||||
'/tos',
|
||||
'/privacy-policy'
|
||||
{% if guest.support_public_tickets_enabled() %}
|
||||
{% if guest.support_guest_tickets_enabled() %}
|
||||
,'/support/contact-us'
|
||||
,'/support/contact-us/conversation'
|
||||
,'/support/ticket'
|
||||
{% endif %}
|
||||
];
|
||||
const currentPath = window.location.pathname;
|
||||
@@ -76,7 +77,7 @@
|
||||
{% set profile = client.profile_get %}
|
||||
{% endif %}
|
||||
{% set company = guest.system_company %}
|
||||
{% set guest_support_url = guest.support_public_tickets_enabled() ? 'support/contact-us'|url : 'login'|url %}
|
||||
{% set guest_support_url = guest.support_guest_tickets_enabled() ? 'support/contact-us'|url : 'login'|url %}
|
||||
{% set support_url = client ? 'support'|url : guest_support_url %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
@@ -407,6 +407,7 @@ test('support admin ticket renders with no notes and no rel', function (): void
|
||||
'first' => null,
|
||||
'helpdesk' => ['id' => 1, 'name' => 'Helpdesk', 'can_reopen' => true, 'signature' => ''],
|
||||
'client' => ['id' => 1, 'first_name' => 'Test', 'last_name' => 'Client'],
|
||||
'author' => ['id' => 1, 'role' => 'client', 'name' => 'Test Client', 'first_name' => 'Test', 'last_name' => 'Client', 'email' => 'client@example.com'],
|
||||
],
|
||||
],
|
||||
);
|
||||
@@ -463,6 +464,7 @@ test('support admin ticket renders with a related order and a note', function ()
|
||||
'first' => null,
|
||||
'helpdesk' => ['id' => 1, 'name' => 'Helpdesk', 'can_reopen' => true, 'signature' => ''],
|
||||
'client' => ['id' => 1, 'first_name' => 'Test', 'last_name' => 'Client'],
|
||||
'author' => ['id' => 1, 'role' => 'client', 'name' => 'Test Client', 'first_name' => 'Test', 'last_name' => 'Client', 'email' => 'client@example.com'],
|
||||
],
|
||||
],
|
||||
);
|
||||
@@ -512,6 +514,7 @@ test('support admin ticket renders with a pending task (rel.status=pending)', fu
|
||||
'first' => null,
|
||||
'helpdesk' => ['id' => 1, 'name' => 'Helpdesk', 'can_reopen' => true, 'signature' => ''],
|
||||
'client' => ['id' => 1, 'first_name' => 'Test', 'last_name' => 'Client'],
|
||||
'author' => ['id' => 1, 'role' => 'client', 'name' => 'Test Client', 'first_name' => 'Test', 'last_name' => 'Client', 'email' => 'client@example.com'],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user