FIX_Preview Modals
This commit is contained in:
parent
378dcbba0b
commit
e591e1b4a9
@ -98,6 +98,7 @@ $routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
|
|||||||
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_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_invoice/(:any)", "Jobcard::preview_jobcard_invoice/$1");
|
||||||
$routes->get("preview_jobcard/(:any)", "Jobcard::preview_jobcard/$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->post("delete_sales_product", "Jobcard::delete_sales_product");
|
||||||
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
|
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
|
||||||
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
|
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
|
||||||
|
|||||||
@ -25,6 +25,7 @@ use Mpdf\Mpdf;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
use App\Helpers\InvNoHelper;
|
use App\Helpers\InvNoHelper;
|
||||||
|
use App\Helpers\ClientDetailsUpdate;
|
||||||
|
|
||||||
class Jobcard extends BaseController
|
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)
|
public function download_jobcard($job_card_id)
|
||||||
{
|
{
|
||||||
$data = $this->getJobCardData($job_card_id);
|
$data = $this->getJobCardData($job_card_id);
|
||||||
@ -643,7 +657,6 @@ class Jobcard extends BaseController
|
|||||||
public function add_jobs()
|
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');
|
$data['status'] = $this->request->getPost('status');
|
||||||
$job_card_id = $this->request->getPost('job_card_id');
|
$job_card_id = $this->request->getPost('job_card_id');
|
||||||
@ -685,7 +698,11 @@ class Jobcard extends BaseController
|
|||||||
'total'=> $this->request->getPost('grand_total'),
|
'total'=> $this->request->getPost('grand_total'),
|
||||||
'isactive' => 1
|
'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');
|
$status = $this->request->getPost('status');
|
||||||
// Insert or update sales order
|
// Insert or update sales order
|
||||||
$job_card_id = $this->request->getPost('job_card_id');
|
$job_card_id = $this->request->getPost('job_card_id');
|
||||||
|
|||||||
@ -6,6 +6,19 @@
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
cursor: not-allowed;
|
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>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -131,6 +144,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<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-row">
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Fuel Qty<span class="text-danger"></span></label>
|
<label for="inputPassword4" class="col-form-label">Fuel Qty<span class="text-danger"></span></label>
|
||||||
@ -219,19 +240,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="files">
|
<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>
|
||||||
|
<hr>
|
||||||
|
<div class="files" style="display: none;">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-12" style="text-align: right;">
|
<div class="form-group col-md-12" style="text-align: right;">
|
||||||
<button type="button" class="btn btn-primary waves-effect btn-sm a1"
|
<button type="button" class="btn btn-primary waves-effect btn-sm a1" onclick="appendFilesFileds()" id="filebtn">
|
||||||
onclick="appendFilesFileds()" id="filebtn">
|
|
||||||
Add File
|
Add File
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
<div id="existingContainer"></div>
|
<div id="existingContainer"></div>
|
||||||
<div id="filesContainer"></div>
|
<div id="filesContainer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row" id="itemTableContainer">
|
<div class="form-row" id="itemTableContainer">
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<h4>Item Details</h4>
|
<h4>Item Details</h4>
|
||||||
@ -2307,7 +2336,7 @@ $(document).ready(function() {
|
|||||||
var fileId = data != null && data != '' ? data.file_id : '';
|
var fileId = data != null && data != '' ? data.file_id : '';
|
||||||
var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
|
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">
|
<div class="form-group col-md-4">
|
||||||
<label class="col-form-label">File name</label>
|
<label class="col-form-label">File name</label>
|
||||||
<input type="text" maxlength="255" class="form-control" value="${fileName}" readonly>
|
<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) {
|
function appendFilesFileds(data) {
|
||||||
var newRowHtml = `
|
var newRowHtml = `
|
||||||
<div class="form-row pad">
|
<div class="file-append-row form-row pad mb-2">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label class="col-form-label">File name</label>
|
<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 : ''}">
|
<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>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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> -->
|
<!-- <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 } ?>
|
<?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']; ?>" 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> -->
|
<!-- <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) { ?>
|
<?php if($value['status'] == 'Paid' && $admins && $value['is_rework'] == 0) { ?>
|
||||||
@ -150,6 +151,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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">×</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'); ?>
|
<?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() {
|
$(document).on('click', '#printInvoiceButton', function() {
|
||||||
var jobCardId = $(this).data('id');
|
var jobCardId = $(this).data('id');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user