Finished migrating the last of the admin add modals to ajax-modal
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
<div class="card-header py-2">
|
<div class="card-header py-2">
|
||||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-file mr-2"></i>Document Templates</h3>
|
<h3 class="card-title mt-2"><i class="fa fa-fw fa-file mr-2"></i>Document Templates</h3>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addDocumentTemplateModal">
|
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/document_template/document_template_add.php" data-modal-size="xl">
|
||||||
<i class="fas fa-plus mr-2"></i>New Template
|
<i class="fas fa-plus mr-2"></i>New Template
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -121,38 +121,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php require_once "modals/document_template/document_template_add.php"; ?>
|
<?php require_once "../includes/footer.php";
|
||||||
<?php require_once "../includes/footer.php"; ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function(){
|
|
||||||
|
|
||||||
$('#generateAIContent').on('click', function(){
|
|
||||||
var prompt = $('#aiPrompt').val().trim();
|
|
||||||
if(prompt === '') {
|
|
||||||
alert('Please enter a prompt.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#generateAIContent').prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Generating...');
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: 'post.php?ai_create_document_template', // The PHP script that calls the OpenAI API
|
|
||||||
method: 'POST',
|
|
||||||
data: { prompt: prompt },
|
|
||||||
dataType: 'html',
|
|
||||||
success: function(response) {
|
|
||||||
// Assuming you have exactly one TinyMCE instance on the page
|
|
||||||
// and it's targeting the .tinymce textarea:
|
|
||||||
tinymce.activeEditor.setContent(response);
|
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
alert('Error generating content. Please try again.');
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
$('#generateAIContent').prop('disabled', false).html('<i class="fa fa-fw fa-magic mr-1"></i>Generate with AI');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
<div class="modal" id="addDocumentTemplateModal" tabindex="-1">
|
<?php
|
||||||
<div class="modal-dialog modal-xl">
|
|
||||||
<div class="modal-content">
|
require_once '../../../includes/modal_header.php';
|
||||||
<div class="modal-header bg-dark">
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header bg-dark">
|
||||||
<h5 class="modal-title"><i class="fa fa-fw fa-file-alt mr-2"></i>Creating Document Template</h5>
|
<h5 class="modal-title"><i class="fa fa-fw fa-file-alt mr-2"></i>Creating Document Template</h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -43,7 +48,40 @@
|
|||||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
<script>
|
||||||
</div>
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$('#generateAIContent').on('click', function(){
|
||||||
|
var prompt = $('#aiPrompt').val().trim();
|
||||||
|
if(prompt === '') {
|
||||||
|
alert('Please enter a prompt.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#generateAIContent').prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Generating...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/agent/ajax.php?ai_create_document_template', // The PHP script that calls the OpenAI API
|
||||||
|
method: 'POST',
|
||||||
|
data: { prompt: prompt },
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(response) {
|
||||||
|
// Assuming you have exactly one TinyMCE instance on the page
|
||||||
|
// and it's targeting the .tinymce textarea:
|
||||||
|
tinymce.activeEditor.setContent(response);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Error generating content. Please try again.');
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('#generateAIContent').prop('disabled', false).html('<i class="fa fa-fw fa-magic mr-1"></i>Generate with AI');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once '../../../includes/modal_footer.php';
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
<div class="modal" id="addSoftwareTemplateModal" tabindex="-1">
|
<?php
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
require_once '../../../includes/modal_header.php';
|
||||||
<div class="modal-header bg-dark">
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="modal-header bg-dark">
|
||||||
<h5 class="modal-title"><i class="fa fa-fw fa-cube mr-2"></i>New License Template</h5>
|
<h5 class="modal-title"><i class="fa fa-fw fa-cube mr-2"></i>New License Template</h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -77,7 +81,7 @@
|
|||||||
<button type="submit" name="add_software_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create</button>
|
<button type="submit" name="add_software_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create</button>
|
||||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
<?php
|
||||||
</div>
|
require_once '../../../includes/modal_footer.php';
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<div class="modal" id="addVendorTemplateModal" tabindex="-1">
|
<?php
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
require_once '../../../includes/modal_header.php';
|
||||||
<div class="modal-header bg-dark">
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header bg-dark">
|
||||||
<h5 class="modal-title"><i class="fas fa-fw fa-building mr-2"></i>New Vendor Template</h5>
|
<h5 class="modal-title"><i class="fas fa-fw fa-building mr-2"></i>New Vendor Template</h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
|
|
||||||
<input type="hidden" name="client_id" value="<?php if (isset($_GET['client_id'])) { echo $client_id; } else { echo 0; } ?>">
|
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
@@ -162,7 +165,7 @@
|
|||||||
<button type="submit" name="add_vendor_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create Template</button>
|
<button type="submit" name="add_vendor_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create Template</button>
|
||||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
<?php
|
||||||
</div>
|
require_once '../../../includes/modal_footer.php';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
<div class="card-header py-2">
|
<div class="card-header py-2">
|
||||||
<h3 class="card-title mt-2"><i class="fas fa-fw fa-cube mr-2"></i>License Templates</h3>
|
<h3 class="card-title mt-2"><i class="fas fa-fw fa-cube mr-2"></i>License Templates</h3>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addSoftwareTemplateModal"><i class="fas fa-plus mr-2"></i>New License Template</button>
|
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/software_template/software_template_add.php"><i class="fas fa-plus mr-2"></i>New License Template</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -127,5 +127,4 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "modals/software_template/software_template_add.php";
|
|
||||||
require_once "../includes/footer.php";
|
require_once "../includes/footer.php";
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="card card-dark">
|
<div class="card card-dark">
|
||||||
<div class="card-header py-2">
|
<div class="card-header py-2">
|
||||||
<h3 class="card-title mt-2">
|
<h3 class="card-title mt-2">
|
||||||
<i class="fas fa-fw fa-building mr-2"></i>Vendor Templates
|
<i class="fas fa-fw fa-building mr-2"></i>Vendor Templates
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addVendorTemplateModal">
|
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/vendor_template/vendor_template_add.php">
|
||||||
<i class="fas fa-plus mr-2"></i>New Vendor Template
|
<i class="fas fa-plus mr-2"></i>New Vendor Template
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -158,11 +158,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<?php require_once "../includes/filter_footer.php";
|
<?php require_once "../includes/filter_footer.php"; ?>
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "modals/vendor_template/vendor_template_add.php";
|
|
||||||
require_once "../includes/footer.php";
|
require_once "../includes/footer.php";
|
||||||
|
|||||||
Reference in New Issue
Block a user