merge : GWM

This commit is contained in:
bitbucket 2024-06-11 09:01:04 +05:30
parent 36f9736ade
commit f8c68bd241
4 changed files with 344 additions and 18 deletions

View File

@ -215,16 +215,7 @@ class MasterController extends BaseController
}
}
public function get_service_data()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$service_group_id = $this->request->getVar('service_group_id');
$result = $this->ServiceModel->where('service_group_id',$service_group_id)->findAll();
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
}
public function template_edit()
{
@ -267,18 +258,27 @@ class MasterController extends BaseController
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$client_id = $this->request->getVar('client_id');
$data['doc_list'] = $this->ClientDocsModel->getDocs($client_id);
$data['clientdata'] = $this->ClientModel->where('client_id', $client_id)->get()->getRow();
$data['serviceData'] = $this->ServiceModel->findAll();
$data['doc_list'] = $this->ClientDocsModel->getDocs();
$data['clientdata'] = $this->ClientModel->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('docs_shared_with_client',$data);
echo view('share_docs',$data);
echo view('layout/footer');
}
public function get_service_data()
{
$service_group_id = $this->request->getVar('service_group_id');
$result = $this->ServiceModel->where('service_group_id',$service_group_id)->findAll();
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
}
public function get_templates()
{
@ -288,6 +288,7 @@ class MasterController extends BaseController
}
public function create_docs()
{
$docData = $this->request->getVar();

View File

@ -23,13 +23,13 @@ class ClientDocsModel extends Model
}
public function getDocs($client_id){
public function getDocs(){
$this->select('template.template_name , template.template_id ,client_docs.is_approved ,client_docs.id as doc_id ,client_docs.is_active, services.service_name');
$this->join('template', 'template.template_id = client_docs.template_id');
$this->join('services', 'services.service_id = template.service_id');
$this->where('client_docs.client_id', $client_id);
return $this->findAll();
}

View File

@ -286,7 +286,7 @@
<?php if($_SESSION['logged_in_staff_role'] == 'Admin' ) { ?>
<li class="nav-item">
<a class="nav-link" href="<?= base_url()."service_list"; ?>">
<a class="nav-link" href="<?= base_url()."shared_docs_list"; ?>">
<i class="ri-share-line"></i> Share Docs </a>
</li>

325
app/Views/share_docs.php Normal file
View File

@ -0,0 +1,325 @@
<!-- ============================================================== -->
<!-- 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">Share Document</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 </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 Group</label>
<select class="select2-dropdown form-control" name="service_group_id" id="service_group_id" required>
<option value="">Select Service</option>
<?php foreach ($serviceGroupData as $key => $Value) { ?>
<option value="<?php echo $Value['service_group_id']; ?>" ><?php echo $Value['group_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service</label>
<select class="select2-dropdown form-control" name="service_id" id="service_id" required>
<option value="">Select Service</option>
</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="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_group_id").on("change", function()
{
var value = $(this).val();
$.ajax({
url: '<?= base_url("get_service_data") ?>?service_group_id=' + value,
type: 'GET',
dataType: 'json', // Expect JSON response
success: function(response) {
if (response.count > 0) {
$('#service_id option:not(:first)').remove();
$.each(response.data, function(index, item) {
$('#service_id').append($('<option>', {
value: item.service_id,
text: item.service_name
}));
});
} else {
toastr.warning('Service not found.', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
toastr.error('Failed to fetch data.', 'Error');
}
});
});
$("#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>