FIX_Preview Modals

This commit is contained in:
VE10-Sanjeev 2025-01-02 13:13:19 +00:00
parent 378dcbba0b
commit e591e1b4a9
4 changed files with 183 additions and 17 deletions

View File

@ -98,6 +98,7 @@ $routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
$routes->get("preview_jobcard_invoice/(:any)", "Jobcard::preview_jobcard_invoice/$1");
$routes->get("preview_jobcard/(:any)", "Jobcard::preview_jobcard/$1");
$routes->get("download_jobcard_files/(:any)", "Jobcard::download_jobcard_files/$1");
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");

View File

@ -25,6 +25,7 @@ use Mpdf\Mpdf;
use DateTime;
use CodeIgniter\API\ResponseTrait;
use App\Helpers\InvNoHelper;
use App\Helpers\ClientDetailsUpdate;
class Jobcard extends BaseController
{
@ -231,6 +232,19 @@ class Jobcard extends BaseController
}
}
public function download_jobcard_files($job_card_id)
{
try {
$data = $this->JobcardFileModel->where(['job_card_id'=>$job_card_id,'isactive'=>1])->findAll();
return $this->respond(['status' => 'success','code' => 200,'data' => $data],200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
}
}
public function download_jobcard($job_card_id)
{
$data = $this->getJobCardData($job_card_id);
@ -643,8 +657,7 @@ class Jobcard extends BaseController
public function add_jobs()
{
if($this->session->get('logged_user_role') == "Store Manager") {
if($this->session->get('logged_user_role') == "Store Manager") {
$data['status'] = $this->request->getPost('status');
$job_card_id = $this->request->getPost('job_card_id');
$this->JobcardModel->update($job_card_id, $data); // issued status update
@ -685,7 +698,11 @@ class Jobcard extends BaseController
'total'=> $this->request->getPost('grand_total'),
'isactive' => 1
];
$update_client_address = $this->request->getPost('update_client_address');
if(isset($update_client_address) && $update_client_address == 'on')
{
ClientDetailsUpdate::updateClientAddress($this->request->getPost('vehicle_id'),$job_card_data);
}
$status = $this->request->getPost('status');
// Insert or update sales order
$job_card_id = $this->request->getPost('job_card_id');

View File

@ -6,6 +6,19 @@
opacity: 0.5;
cursor: not-allowed;
}
hr{
margin-top:0 !important;
}
.file-append-row{
margin-bottom:-18px !important;
}
.file-append-row,.file-exist-row{
/* margin-bottom:-18px !important; */
margin-top:-35px !important;
}
</style>
<style>
@ -131,6 +144,14 @@
</div>
</div>
<br>
<div class="form-row">
<div class="form-group col-md-12" style="display: flex;align-items: center; gap: 8px;">
<input class="form-check-input" type="checkbox" name="update_client_address" style=" margin: 0;">
<label class="form-check-label" for="flexCheckDefault" style=" margin: 0;padding-left: 20px;">
Update client address
</label>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Fuel Qty<span class="text-danger"></span></label>
@ -219,19 +240,27 @@
</div>
<?php endif; ?>
</div>
<div class="files">
<div class="form-row">
<div class="form-group col-md-12" style="text-align: right;">
<button type="button" class="btn btn-primary waves-effect btn-sm a1"
onclick="appendFilesFileds()" id="filebtn">
Add File
</button>
<div style="display: flex; justify-content: space-between; align-items: center;">
<h4>File Details</h4>
<div>
<button type="button" class="btn" onclick="toggleFiles(this)">
<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>
</button>
</div>
</div>
<div id="existingContainer"></div>
<div id="filesContainer"></div>
</div>
<hr>
<div class="files" style="display: none;">
<div class="form-row">
<div class="form-group col-md-12" style="text-align: right;">
<button type="button" class="btn btn-primary waves-effect btn-sm a1" onclick="appendFilesFileds()" id="filebtn">
Add File
</button>
</div>
</div>
<br>
<div id="existingContainer"></div>
<div id="filesContainer"></div>
</div>
<div class="form-row" id="itemTableContainer">
<div class="form-group col-md-12">
<h4>Item Details</h4>
@ -2307,7 +2336,7 @@ $(document).ready(function() {
var fileId = data != null && data != '' ? data.file_id : '';
var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
var newRowHtml = `<div class="form-row pad mb-2">
var newRowHtml = `<div class="file-exist-row form-row pad mb-2">
<div class="form-group col-md-4">
<label class="col-form-label">File name</label>
<input type="text" maxlength="255" class="form-control" value="${fileName}" readonly>
@ -2325,12 +2354,12 @@ $(document).ready(function() {
`;
$('#existingContainer').append(newRowHtml);
$('#existingContainer').append(newRowHtml);existingContainer
}
function appendFilesFileds(data) {
var newRowHtml = `
<div class="form-row pad">
<div class="file-append-row form-row pad mb-2">
<div class="form-group col-md-4">
<label class="col-form-label">File name</label>
<input type="text" id="manual_file_name" name="manual_file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.manual_file_name : ''}">
@ -2392,6 +2421,27 @@ $(document).ready(function() {
}
</script>
<script>
// $(document).ready(function() {
// const button = $('.toggle-btn')[0]; // Select the button element
// toggleFiles(button); // Call toggleFiles on document ready
// });
function toggleFiles(button) {
const filesContainer = document.querySelector('.files');
// Check if the container is already maximized or minimized
if (filesContainer.style.display === "none") {
filesContainer.style.display = "block"; // Show and maximize the container
button.innerHTML = '<h4><i class="fa fa-minus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
} else {
filesContainer.style.display = "none"; // Minimize the container
button.innerHTML = '<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
}
}
</script>

View File

@ -91,6 +91,7 @@
<!-- <a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Invoice</a> -->
<?php } ?>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" class="dropdown-item preview-jobcard" href="#" title="Preview Jobcard"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Jobcard</a>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" data-order_number="<?= $value['order_number']; ?>" class="dropdown-item download-files"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Preview Files</a>
<!-- <a href="<?= base_url() ."download_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item download-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Jobcard</a> -->
<?php if($value['status'] == 'Paid' && $admins && $value['is_rework'] == 0) { ?>
@ -150,6 +151,20 @@
</div>
</div>
</div>
<div class="modal fade" id="FilesModal" tabindex="-1" role="dialog" aria-labelledby="FilesModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="width: 794px; height: 1123px;">
<div class="modal-header">
<h5 class="modal-title" id="FilesModalLabel"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" style="font-family: Times New Roman, Times, sans-serif !important; font-size: 12px !important;">
</div>
</div>
</div>
</div>
<?php include('layout/footer.php'); ?>
@ -288,6 +303,89 @@
});
});
$(document).on('click', '.download-files', function() {
var jobCardId = $(this).data('job-card-id');
var orderNumber = $(this).data('order_number');
$('#FilesModal .modal-body').empty();
$.ajax({
type: 'GET',
url: 'download_jobcard_files/'+jobCardId,
dataType: 'json',
success: function(response) {
if (response.status == "success") {
$('#FilesModal').modal('show');
$('#FilesModalLabel').text('Jobcard Files Modal ( '+orderNumber+' )');
// var filePath = response.data != null && response.data != '' ? response.data.file_name : '';
// console.log(filePath);
// var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
// var fileName = response.data != null && response.data != '' ? response.data.manual_file_name : '';
const base_url = '<?php echo base_url(); ?>';
if(response.data && response.data.length > 0){
var newRowHtml = `<div class="container-fluid">
<div class="row">`;
(response.data).forEach(function(row) {
var filePath = row != null && row != '' ?row.file_name : '';
var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
var fileName = row != null && row != '' ? row.manual_file_name : '';
var fileType = filePath.split('.').pop().toLowerCase();
var imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
newRowHtml += `<div class="col-md-6 col-xl-3">
<div class="card product-box">
<div class="product-img">
<div class="p-3">`;
if (imageExtensions.includes(fileType)) {
newRowHtml +=`<img src="`+downloadUrl+`" alt="Image Not Found" class="img-fluid" />`;
} else {
newRowHtml +=`<div text-align="center" >This is NOT an image file.`+`its a `+fileType+` type file</div>`;
}
newRowHtml +=`</div>
</div>
<div class="product-info border-top p-3">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h5 class="font-16 mt-0 mb-1">
<a href="#" class="text-dark">`+fileName+`</a>
</h5>
<a href="${downloadUrl}" download>
<i class="fa fa-download" aria-hidden="true" style="font-size: 25px;"></i>
</a>
</div>
</div>
</div>
</div>`;});
newRowHtml += `</div>
</div>`;
$('#FilesModal .modal-body').append(newRowHtml);
}else{
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
}
}else{
$('#FilesModal').modal('hide');
$('#FilesModalLabel').text('');
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
alert("Data Not Founded");
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
$('#FilesModal').modal('hide');
$('#FilesModalLabel').text('');
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
}
});
});
$(document).on('click', '#printInvoiceButton', function() {
var jobCardId = $(this).data('id');