209 lines
9.0 KiB
PHP
209 lines
9.0 KiB
PHP
<!-- ============================================================== -->
|
||
<!-- Start Page Content here -->
|
||
<!-- ============================================================== -->
|
||
|
||
<div class="content-page">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<h4 class="page-title">Service And Templates </h4>
|
||
<div class="page-title-right">
|
||
<a href="<?= base_url('template_create?service_id=').md5($serviceData->service_id); ?>" class="btn btn-primary waves-effect waves-light">
|
||
Create New
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
|
||
|
||
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
|
||
<h4 class="header-title">
|
||
<?= $serviceData->service_name; ?>
|
||
<a href="javascript:void(0);" data-toggle="modal" data-target="#con-close-modal" title="Edit" style="font-size: 22px;">
|
||
<i class='mdi mdi-square-edit-outline mr-1'></i>
|
||
</a>
|
||
</h4>
|
||
|
||
<p class="text-muted font-13 mb-4"> <?= $serviceData->notes; ?> </p>
|
||
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" >
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th>Template Name</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="font-14">
|
||
|
||
|
||
<?php foreach ($templateData as $key => $value) { ?>
|
||
|
||
<tr>
|
||
<td> <?php echo $value['template_name']; ?></td>
|
||
|
||
|
||
<!-- <td><a href="<?= base_url()."template_edit?template_id=".md5($value['template_id']); ?>" > <i class='mdi mdi-pencil-outline mr-1'></i>Edit</a></td> -->
|
||
<td>
|
||
<div class="btn-group dropdown">
|
||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<a class="dropdown-item" href="<?= base_url()."template_edit?template_id=".md5($value['template_id']); ?>"><i class="mdi mdi-pencil-outline mr-2 text-muted font-18 vertical-middle"></i> Edit </a>
|
||
<!-- <a class="dropdown-item" href="<?= base_url()."template_preview?template_id=".md5($value['template_id']); ?>"><i class="mdi mdi-eye-outline mr-2 text-muted font-18 vertical-middle"></i> Preview </a> -->
|
||
<a class="dropdown-item preview-button" href="#" data-template-id="<?= md5($value['template_id']); ?>">
|
||
<i class="mdi mdi-eye-outline mr-2 text-muted font-18 vertical-middle"></i> Preview
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<?php } ?>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
</div>
|
||
|
||
|
||
</div> <!-- container -->
|
||
|
||
</div> <!-- content -->
|
||
|
||
|
||
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title">Update Service</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<form id="save-service" enctype="multipart/form-data">
|
||
<div class="modal-body p-4">
|
||
<input type="hidden" name="id" value=" <?= $serviceData->service_id; ?> ">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="field-1" class="control-label">Service Name</label>
|
||
<input type="text" class="form-control" name="service_name" value=" <?= $serviceData->service_name; ?> ">
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="field-1" class="control-label">Notes</label>
|
||
<textarea class="form-control" name="notes"><?= $serviceData->notes; ?></textarea>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
|
||
<button type="submit" class="btn btn-info waves-effect waves-light">Save changes</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<button type="button" style="display:none;" class="btn btn-info" id="template_preview_button" data-toggle="modal" data-target="#bs-example-modal-lg">Large Modal</button>
|
||
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||
<div class="modal-dialog modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Preview</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" id="template_preview">
|
||
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<!-- ============================================================== -->
|
||
<!-- End Page content -->
|
||
<!-- ============================================================== -->
|
||
|
||
|
||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0/js/select2.min.js"></script>
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
$('#save-service').submit(function(e) {
|
||
e.preventDefault(); // Prevent the form from submitting normally
|
||
|
||
// Create a FormData object
|
||
var formData = new FormData(this);
|
||
|
||
|
||
console.log(formData);
|
||
// Make an AJAX POST request
|
||
$.ajax({
|
||
url: '<?= base_url()."service_edit"; ?>',
|
||
type: 'POST',
|
||
data: formData,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(response) {
|
||
if(response){
|
||
toastr.success('Data saved successfully ', 'Success');
|
||
window.location.reload();
|
||
}else{
|
||
toastr.warning('Something went wrong', 'Warning');
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle errors here
|
||
console.error(xhr.responseText);
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
$('.preview-button').on('click', function(e) {
|
||
e.preventDefault();
|
||
|
||
var templateId = $(this).data('template-id');
|
||
|
||
$.ajax({
|
||
url: '<?= base_url(); ?>template_preview?template_id='+templateId,
|
||
type: 'GET',
|
||
success: function(response) {
|
||
// Assuming you want to display the response in a modal
|
||
$('#template_preview').html(response);
|
||
$('#template_preview_button').click();
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error('Error fetching template preview:', error);
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
});
|
||
</script>
|