279 lines
12 KiB
PHP
279 lines
12 KiB
PHP
<!-- ============================================================== -->
|
||
<!-- Start Page Content here -->
|
||
<!-- ============================================================== -->
|
||
<style>
|
||
.select2-container .select2-selection--single{
|
||
height: 36px;
|
||
border:1px solid #ced4da;
|
||
}
|
||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||
line-height: 36px;
|
||
}
|
||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||
top:4px;
|
||
}
|
||
</style>
|
||
<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">Docs Shared With <?= $clientdata->name; ?></h4>
|
||
|
||
<div class="page-title-right">
|
||
<button type="reset" onclick="window.history.back()" class="btn btn-secondary waves-effect"> Back </button>
|
||
<a href="javascript:void(0);" data-toggle="modal" data-target="#con-close-modal" class="btn btn-primary waves-effect waves-light">Share Docs </a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
|
||
|
||
|
||
|
||
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
|
||
|
||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100 display">
|
||
<thead>
|
||
<tr>
|
||
<th>Service</th>
|
||
<th>Doc Status</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
|
||
<tbody>
|
||
|
||
<?php foreach ($doc_list as $key => $value) { ?>
|
||
|
||
<tr>
|
||
<td> <?php echo $value['service_name']; ?></td>
|
||
|
||
<td>
|
||
<?php if ($value['is_active'] == 1){ ?>
|
||
<!-- <span style="color:green">Shared</span> -->
|
||
<?php if ($value['is_approved'] == 1): ?>
|
||
<span style="color:green">Approved</span>
|
||
<?php elseif ($value['is_approved'] == 0): ?>
|
||
<span style="color:orange">Pending Approval</span>
|
||
<?php elseif ($value['is_approved'] == 2): ?>
|
||
<span style="color:red">Rejected</span>
|
||
<?php endif; ?>
|
||
<?php }else if ($value['is_approved'] == 0){ ?>
|
||
<span style="color:red">Not Shared</span>
|
||
<?php } ?>
|
||
|
||
</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="<?php echo base_url().'client_docs_preview?doc_id='.$value['doc_id']; ?>" > <i class='mdi mdi-eye-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Preview</a>
|
||
|
||
<?php if($value['is_active'] == 1 && $value['is_approved'] == 0){ ?>
|
||
<a class="dropdown-item" data-id="<?php echo $value['doc_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Revert" onclick="statusChange(this)"><i class="mdi mdi-file-undo" style="margin-right: 16px !important;margin-left: 5px;"></i>Revert</a>
|
||
<?php } else if($value['is_active'] == 0 ) { ?>
|
||
<a class="dropdown-item" data-id="<?php echo $value['doc_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Share" onclick="statusChange(this)"><i class="mdi mdi-share-all-outline" style="margin-right: 16px !important;margin-left: 5px;"></i>Share</a>
|
||
<?php } ?>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</td>
|
||
|
||
</tr>
|
||
|
||
<?php } ?>
|
||
|
||
|
||
</tbody>
|
||
</table>
|
||
|
||
</div> <!-- end card body-->
|
||
</div> <!-- end card -->
|
||
</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">Create Docs for <?= $clientdata->name; ?></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<form id="share-docs" enctype="multipart/form-data">
|
||
<div class="modal-body p-4">
|
||
|
||
<div class="row">
|
||
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="field-2" class="control-label">Service</label>
|
||
<select class="select2-dropdown form-control" name="service_id" id="service_id" required>
|
||
<option value="">Select Service</option>
|
||
<?php foreach ($serviceData as $key => $Value) { ?>
|
||
<option value="<?php echo $Value['service_id']; ?>" ><?php echo $Value['service_name']; ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="field-1" class="control-label">Template</label>
|
||
<select class="select2-dropdown form-control" name="template_id" id="template_id" required>
|
||
<option value="">Select Template</option>
|
||
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<input type="hidden" name="client_id" value="<?= $clientdata->client_id; ?>">
|
||
<input type="hidden" name="is_active" value="0">
|
||
|
||
|
||
</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">Create</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</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() {
|
||
$('.select2-dropdown').select2({ });
|
||
|
||
$("#service_id").on("change", function()
|
||
{
|
||
var value = $(this).val();
|
||
$.ajax({
|
||
url: '<?= base_url("get_templates") ?>?service_id=' + value,
|
||
type: 'GET',
|
||
dataType: 'json', // Expect JSON response
|
||
success: function(response) {
|
||
if (response.count > 0) {
|
||
|
||
$('#template_id option:not(:first)').remove();
|
||
|
||
|
||
$.each(response.data, function(index, item) {
|
||
$('#template_id').append($('<option>', {
|
||
value: item.template_id,
|
||
text: item.template_name
|
||
}));
|
||
});
|
||
|
||
|
||
} else {
|
||
toastr.warning('Templates not found.', 'Warning');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle error
|
||
console.error(xhr.responseText);
|
||
toastr.error('Failed to fetch data.', 'Error');
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
|
||
});
|
||
|
||
|
||
$('#share-docs').submit(function(e) {
|
||
e.preventDefault(); // Prevent the form from submitting normally
|
||
|
||
// Create a FormData object
|
||
var formData = new FormData(this);
|
||
|
||
// Make an AJAX POST request
|
||
$.ajax({
|
||
url: '<?= base_url()."create_docs"; ?>',
|
||
type: 'POST',
|
||
data: formData,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(response) {
|
||
if(response){
|
||
toastr.success('Document created.', 'Success');
|
||
window.location.reload();
|
||
}else{
|
||
toastr.warning('Creation Failed.', 'Warning');
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle errors here
|
||
console.error(xhr.responseText);
|
||
}
|
||
});
|
||
});
|
||
|
||
function statusChange(params) {
|
||
console.log(params);
|
||
var status = params.getAttribute('data-isactive');
|
||
var doc_id = params.getAttribute('data-id');
|
||
if(status == 1){
|
||
var is_active= 0;
|
||
}else{
|
||
var is_active= 1;
|
||
}
|
||
|
||
var formData = {
|
||
doc_id: doc_id,
|
||
is_active: is_active
|
||
};
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: '<?php echo base_url()."change_doc_status"?>',
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
if (response.data) {
|
||
window.location.reload();
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle error response here
|
||
console.error(xhr.responseText);
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
</script>
|