Fix Ticket Summary move js inline with ticket.php as js files cant read php vars
This commit is contained in:
@@ -110,7 +110,7 @@ if (isset($_GET['ai_ticket_summary'])) {
|
|||||||
curl_setopt($ch, CURLOPT_POST, true);
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
'Authorization: Bearer ' . $config_ai_api_key,
|
'Authorization: Bearer ' . $config_ai_api_key
|
||||||
]);
|
]);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
|
||||||
|
|
||||||
@@ -126,4 +126,4 @@ if (isset($_GET['ai_ticket_summary'])) {
|
|||||||
|
|
||||||
// Print the summary
|
// Print the summary
|
||||||
echo nl2br(htmlentities($summary));
|
echo nl2br(htmlentities($summary));
|
||||||
}
|
}
|
||||||
21
ticket.php
21
ticket.php
@@ -379,9 +379,9 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<div class="card-tools d-print-none">
|
<div class="card-tools d-print-none">
|
||||||
<div class="btn-toolbar">
|
<div class="btn-toolbar">
|
||||||
|
|
||||||
<?php if($config_ai_enable == 1) { ?>
|
<?php if ($config_ai_enable == 1) { ?>
|
||||||
<button class="btn btn-info btn-sm ml-3" data-toggle="modal" data-target="#summaryModal">
|
<button class="btn btn-info btn-sm ml-3" data-toggle="modal" data-target="#summaryModal">
|
||||||
<i class="fas fa-fw fa-lightbulb mr-2"></i>Summarize
|
<i class="fas fa-fw fa-lightbulb mr-2"></i>Summary
|
||||||
</button>
|
</button>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
@@ -1217,4 +1217,19 @@ require_once "footer.php";
|
|||||||
|
|
||||||
<script src="js/pretty_content.js"></script>
|
<script src="js/pretty_content.js"></script>
|
||||||
|
|
||||||
<script src="js/ai_ticket_summary.js"></script>
|
<script>
|
||||||
|
$('#summaryModal').on('shown.bs.modal', function (e) {
|
||||||
|
// Perform AJAX request to get the summary
|
||||||
|
$.ajax({
|
||||||
|
url: 'post.php?ai_ticket_summary',
|
||||||
|
method: 'POST',
|
||||||
|
data: { ticket_id: <?php echo $ticket_id; ?> },
|
||||||
|
success: function(response) {
|
||||||
|
$('#summaryContent').html(response);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#summaryContent').html('Error generating summary.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user