NEW_SALES_INVOICE_STYLE_ISSUES_SOLVE

This commit is contained in:
aadhavan valli 2024-08-19 08:55:13 +05:30
parent 42f07f95fe
commit 07c9912d44
3 changed files with 145 additions and 63 deletions

View File

@ -357,7 +357,7 @@ $routes->get('inprocess', 'Inprocess::index');
// Sales Invoice routes // Sales Invoice routes
$routes->get('invoicedetails/ViewInvoice', 'User::ViewInvoice'); $routes->get('invoicedetails/ViewInvoice', 'User::ViewInvoice');
$routes->get('getInvoiceAttachment', 'User::getInvoiceAttachment'); $routes->get('getInvoiceAttachments', 'User::getInvoiceAttachments');
$routes->get('deleteAttachment', 'User::deleteAttachment'); $routes->get('deleteAttachment', 'User::deleteAttachment');
$routes->post('saveAttachment', 'User::saveAttachment'); $routes->post('saveAttachment', 'User::saveAttachment');

View File

@ -1670,8 +1670,8 @@ class User extends BaseController
// Sales Invoice // Sales Invoice
function getInvoiceAttachment(){ function getInvoiceAttachments(){
$data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_number')); $data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_id'));
return json_encode($data); return json_encode($data);
} }

View File

@ -4,6 +4,37 @@
text-decoration: underline; text-decoration: underline;
color: #007bff; /* Adjust color as needed */ color: #007bff; /* Adjust color as needed */
} }
.custom-button {
display: inline-block;
padding: 6px 8px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
background-color: #007bff;
border: 1px solid transparent;
border-radius: 4px;
color: #fff;
text-decoration: none;
width: 72px;
margin-left: -12px;
margin-top: -3px;
height: 32px;
font-size: 12px;
}
.custom-button:hover {
color: #fff;
text-decoration: none;
/* color: #007bff !important; */
/* background-color: white; */
/* border: 1px solid; */
}
</style> </style>
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Content Header (Page header) --> <!-- Content Header (Page header) -->
@ -64,8 +95,8 @@
</a> </a>
<?php } ?> <?php } ?>
</td> </td>
<td style="text-align: center;"><?php echo $invoice->client_name ?></td> <td style="text-align: left;"><?php echo $invoice->client_name ?></td>
<td style="text-align: center;"><?php echo $invoice->item_name ?></td> <td style="text-align: left;"><?php echo $invoice->item_name ?></td>
<td style="text-align: center;"><?php echo $invoice->item_price ?></td> <td style="text-align: center;"><?php echo $invoice->item_price ?></td>
<td style="text-align: center;"><?php echo number_format($invoice->item_quantity, 2 ,'.', ',' ) ?></td> <td style="text-align: center;"><?php echo number_format($invoice->item_quantity, 2 ,'.', ',' ) ?></td>
<td style="text-align: center;"><?php echo number_format($subtotal, 2, '.', ',') ?></td> <td style="text-align: center;"><?php echo number_format($subtotal, 2, '.', ',') ?></td>
@ -74,7 +105,7 @@
<td style="text-align: center;"><?php echo $invoice->status ?></td> <td style="text-align: center;"><?php echo $invoice->status ?></td>
<td style="text-align: center;"><?php echo $invoice->e_invoice_number; ?></td> <td style="text-align: center;"><?php echo $invoice->e_invoice_number; ?></td>
<td style="text-align: center;"> <td style="text-align: center;">
<a class="edit-button" style="cursor: pointer; display: inline-block;" title="Files Upload" onclick="openInvoiceModal('<?php echo $invoice->invoice_number; ?>', '<?php echo $invoice->client_name; ?>', '<?php echo $invoice->invoice_date_created; ?>')"> <a class="edit-button" style="cursor: pointer; display: inline-block;" title="Files Upload" onclick="openInvoiceModal('<?php echo $invoice->invoice_number; ?>', '<?php echo $invoice->client_name; ?>', '<?php echo $invoice->invoice_date_created; ?>', '<?php echo $invoice->invoice_id; ?>')">
<i class="fas fa-file-upload text-muted" style="font-size: 18px; vertical-align: middle;"></i> <i class="fas fa-file-upload text-muted" style="font-size: 18px; vertical-align: middle;"></i>
</a> </a>
</td> </td>
@ -96,24 +127,25 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h3 class="modal-title" id="invoiceModalLabel">Invoice Files</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
<label for=""> Client Name :</label><span id="client_name_display_model"></span><br> <h3><span id="invoice_number_display_model"></span> - <span id="date_display_model"></span><br></h3>
<label for=""> Date :</label><span id="date_display_model"></span><br> <span id="client_name_display_model"></span>
<label for=""> Invoice Number :</label><span id="invoice_number_display_model"></span>
<div class="col-md-12"> <div class="col-md-12">
<div class="col-md-10"></div> <div class="col-md-10"></div>
<div class="col-md-2"> <div class="col-md-2">
<button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()" id="day" > <!-- <button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()" id="day" >
Add New File Add New File
</button> </button> -->
</div> </div>
</div> </div>
</div> </div>
<div class="modal-body" style="margin-top: 23px;"> <div class="modal-body" style="margin-top: 23px;">
<div id="filesContainer"> <div id="filesContainer">
<!-- Rows will be dynamically appended here --> <!-- Rows will be dynamically appended here -->
</div> </div>
@ -122,20 +154,21 @@
<div class="col-md-12 pad "> <div class="col-md-12 pad ">
<div class="col-md-6"> <div class="col-md-6">
<span>File Name</span> <span>File Name</span>
<input type="text" maxlength="255" class="form-control" <input type="text" maxlength="255" class="form-control file_name"
value="<?php echo $value['file_name']; ?>" readonly> value="<?php echo $value['file_name']; ?>" readonly>
<div class="error-message"></div>
</div> </div>
<div class="col-md-1" style="margin-top: 25px;"> <div class="col-md-1" style="margin-top: 25px;">
<a href="<?php echo base_url() . 'public/uploads/images/emp_files/' . $value['emp_file']; ?>"
<a class="custom-button" href="<?php echo base_url() . 'public/uploads/images/emp_files/' . $value['emp_file']; ?>"
download> download>
<i class="fa fa-download" aria-hidden="true" Download
style="font-size: 25px;"></i>
</a> </a>
</div> </div>
<div class="col-md-5" style="margin-top: 23px;"> <div class="col-md-5" style="margin-top: 23px;">
<button type="button" class="btn btn-danger btn-sm" <button type="button" class="btn btn-danger btn-sm"
id="<?= $value['id']; ?>" id="<?= $value['id']; ?>"
onclick="removeContact(this)">Delete</button> onclick="removeContact(this)" style="margin-left: 22px;">Delete </button>
</div> </div>
</div> </div>
@ -185,61 +218,92 @@
<script> <script>
function saveAttachment() { function saveAttachment() {
var formData = new FormData();
var invoiceId = $('#invoice_id_set').val();
formData.append('invoice_id', invoiceId);
// Append files var file_name_classes = $('.file_name');
$('input[name="emp_file[]"]').each(function(index, input) { var hasEmptyInput = false;
var files = $(input)[0].files;
if (files.length > 0) { file_name_classes.each(function() {
formData.append('emp_file[]', files[0]); if ($(this).val().trim() === '') {
hasEmptyInput = true;
$(this).focus(); // Focus on the empty input field
$(this).addClass('error'); // Add an error class to the empty input
$('.error-message').text('Please fill out this field.').show(); // Show the error message
return false; // Break the loop
} }
}); });
if (!hasEmptyInput) {
$('.error-message').hide();
console.log('All inputs are filled.');
var formData = new FormData();
var invoiceId = $('#invoice_id_set').val();
formData.append('invoice_id', invoiceId);
// Append other fields // Append files
$('input[name="file_name[]"]').each(function(index, input) { $('input[name="emp_file[]"]').each(function(index, input) {
formData.append('file_name[]', $(input).val()); var files = $(input)[0].files;
}); if (files.length > 0) {
formData.append('emp_file[]', files[0]);
// AJAX request using FormData
$.ajax({
url: '<?php echo base_url() ?>saveAttachment',
type: 'POST',
data: formData,
processData: false, // Prevent jQuery from converting the data
contentType: false, // Prevent jQuery from overriding the content type
success: function(response) {
console.log(response);
if (response.success) {
$('#invoiceModal').modal('hide');
// Handle success
} else {
alert(response.message);
} }
}, });
error: function() {
alert('An error occurred while saving the attachment.'); // Append other fields
} $('input[name="file_name[]"]').each(function(index, input) {
}); formData.append('file_name[]', $(input).val());
});
// AJAX request using FormData
$.ajax({
url: '<?php echo base_url() ?>saveAttachment',
type: 'POST',
data: formData,
processData: false, // Prevent jQuery from converting the data
contentType: false, // Prevent jQuery from overriding the content type
success: function(response) {
console.log(response);
if (response.success) {
$('#invoiceModal').modal('hide');
// Handle success
} else {
alert(response.message);
}
},
error: function() {
alert('An error occurred while saving the attachment.');
}
});
}
} }
function openInvoiceModal(invoiceNumber, clientName, Date) { function openInvoiceModal(invoiceNumber, clientName, invoiceDate, invoiceId) {
function formatDate(date) {
let d = new Date(date); // Ensure the date is a Date object
let day = String(d.getDate()).padStart(2, '0');
let month = String(d.getMonth() + 1).padStart(2, '0'); // Months are 0-based
let year = d.getFullYear();
return `${day}/${month}/${year}`;
}
let formattedDate = formatDate(invoiceDate);
$('#invoice_number_display_model').html(invoiceNumber); $('#invoice_number_display_model').html(invoiceNumber);
$('#client_name_display_model').html(clientName); $('#client_name_display_model').html(clientName);
$('#date_display_model').html(Date); $('#date_display_model').html(formattedDate);
// document.getElementById('modalInvoiceNumber').innerText = invoiceNumber; // document.getElementById('modalInvoiceNumber').innerText = invoiceNumber;
$('#day').show(); // $('#day').show();
// $('#invoiceModal').modal('show'); // $('#invoiceModal').modal('show');
url:"<?php echo base_url() ?>servicepurchaseorder/getPODetails", // url:"<?php echo base_url() ?>servicepurchaseorder/getPODetails",
$('#invoice_id_set').val(invoiceNumber); $('#invoice_id_set').val(invoiceId);
// console.log(invoiceId);
$.ajax({ $.ajax({
url: '<?php echo base_url() ?>getInvoiceAttachment', url: '<?php echo base_url() ?>getInvoiceAttachments',
type: 'GET', type: 'GET',
data: { invoice_number: invoiceNumber }, data: { invoice_id: invoiceId },
success: function(response) { success: function(response) {
console.log(response);
console.log(JSON.parse(response).invoiceAttachment); console.log(JSON.parse(response).invoiceAttachment);
var list = JSON.parse(response).invoiceAttachment; var list = JSON.parse(response).invoiceAttachment;
var attachmentsHtml = ''; var attachmentsHtml = '';
@ -252,22 +316,37 @@ function openInvoiceModal(invoiceNumber, clientName, Date) {
<div class="col-md-12 pad"> <div class="col-md-12 pad">
<div class="col-md-4"> <div class="col-md-4">
<span>File Name</span> <span>File Name</span>
<input type="text" maxlength="255" class="form-control" <input type="text" maxlength="255" class="form-control file_name"
value="${attachmentName}" readonly> value="${attachmentName}" readonly>
<div class="error-message"></div>
</div> </div>
<div class="col-md-1" style="margin-top: 25px;"> <div class="col-md-1" style="margin-top: 25px;">
<a href="<?php echo base_url() . 'public/uploads/images/invoice_files/' ?>${fileName}" download> <a class="custom-button" href="<?php echo base_url() . 'public/uploads/images/invoice_files/' ?>${fileName}" download>
<i class="fa fa-download" aria-hidden="true" Download
style="font-size: 25px;"></i>
</a> </a>
</div> </div>
<div class="col-md-5" style="margin-top: 23px;"> <div class="col-md-5" style="margin-top: 23px;">
<button type="button" class="btn btn-danger btn-sm" <button type="button" class="btn btn-danger btn-sm"
id="${element.invoice_attachment_id}" id="${element.invoice_attachment_id}"
onclick="removeContact(this)">Delete</button> onclick="removeContact(this)" style="margin-left: 22px;">Delete</button>
</div> </div>
</div>`; </div>`;
}); });
attachmentsHtml += `<div class="col-md-12 pad">
<div class="col-md-4">
<span for="file_name">File name</span>
<input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control file_name" value="">
<div class="error-message"></div>
</div>
<div class="col-md-4">
<span for="emp_file">File</span>
<input type="file" name="emp_file[]" class="form-control">
</div>
<div class="col-md-4" style="margin-top: 23px;">
<button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()">Add</button>
</div>
</div>`;
$('#filesContainer').html(attachmentsHtml); $('#filesContainer').html(attachmentsHtml);
$('#invoiceModal').modal('show'); $('#invoiceModal').modal('show');
}, },
@ -277,6 +356,8 @@ function openInvoiceModal(invoiceNumber, clientName, Date) {
$('#invoiceModal').modal('show'); $('#invoiceModal').modal('show');
} }
}); });
console.log("day trigger works");
} }
@ -285,7 +366,8 @@ function appendFilesFileds(data) {
<div class="col-md-12 pad"> <div class="col-md-12 pad">
<div class="col-md-4"> <div class="col-md-4">
<span for="file_name">File name</span> <span for="file_name">File name</span>
<input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.file_name : ''}"> <input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control file_name" value="${data != null && data != '' ? data.file_name : ''}">
<div class="error-message"></div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<span for="emp_file">File</span> <span for="emp_file">File</span>
@ -313,7 +395,7 @@ function removeContact(button) {
var len = $('#filesContainer .pad:last .a1') var len = $('#filesContainer .pad:last .a1')
var length = len.length; var length = len.length;
if (length == 0) { if (length == 0) {
$('#day').show() // $('#day').show()
} else { } else {
$('#day').hide() $('#day').hide()
} }