NEW_SALES_INVOICE_STYLE_ISSUES_SOLVE
This commit is contained in:
parent
42f07f95fe
commit
07c9912d44
@ -357,7 +357,7 @@ $routes->get('inprocess', 'Inprocess::index');
|
||||
|
||||
// Sales Invoice routes
|
||||
$routes->get('invoicedetails/ViewInvoice', 'User::ViewInvoice');
|
||||
$routes->get('getInvoiceAttachment', 'User::getInvoiceAttachment');
|
||||
$routes->get('getInvoiceAttachments', 'User::getInvoiceAttachments');
|
||||
$routes->get('deleteAttachment', 'User::deleteAttachment');
|
||||
$routes->post('saveAttachment', 'User::saveAttachment');
|
||||
|
||||
|
||||
@ -1670,8 +1670,8 @@ class User extends BaseController
|
||||
|
||||
|
||||
// Sales Invoice
|
||||
function getInvoiceAttachment(){
|
||||
$data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_number'));
|
||||
function getInvoiceAttachments(){
|
||||
$data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_id'));
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
@ -4,6 +4,37 @@
|
||||
text-decoration: underline;
|
||||
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>
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
@ -64,8 +95,8 @@
|
||||
</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td style="text-align: center;"><?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->client_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 number_format($invoice->item_quantity, 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->e_invoice_number; ?></td>
|
||||
<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>
|
||||
</a>
|
||||
</td>
|
||||
@ -96,24 +127,25 @@
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title" id="invoiceModalLabel">Invoice Files</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<label for=""> Client Name :</label><span id="client_name_display_model"></span><br>
|
||||
<label for=""> Date :</label><span id="date_display_model"></span><br>
|
||||
<label for=""> Invoice Number :</label><span id="invoice_number_display_model"></span>
|
||||
<h3><span id="invoice_number_display_model"></span> - <span id="date_display_model"></span><br></h3>
|
||||
<span id="client_name_display_model"></span>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-10"></div>
|
||||
<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
|
||||
</button>
|
||||
</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body" style="margin-top: 23px;">
|
||||
<div id="filesContainer">
|
||||
|
||||
<!-- Rows will be dynamically appended here -->
|
||||
</div>
|
||||
|
||||
@ -122,20 +154,21 @@
|
||||
<div class="col-md-12 pad ">
|
||||
<div class="col-md-6">
|
||||
<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>
|
||||
<div class="error-message"></div>
|
||||
</div>
|
||||
<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>
|
||||
<i class="fa fa-download" aria-hidden="true"
|
||||
style="font-size: 25px;"></i>
|
||||
Download
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-5" style="margin-top: 23px;">
|
||||
<button type="button" class="btn btn-danger btn-sm"
|
||||
id="<?= $value['id']; ?>"
|
||||
onclick="removeContact(this)">Delete</button>
|
||||
onclick="removeContact(this)" style="margin-left: 22px;">Delete </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -185,61 +218,92 @@
|
||||
<script>
|
||||
|
||||
function saveAttachment() {
|
||||
var formData = new FormData();
|
||||
var invoiceId = $('#invoice_id_set').val();
|
||||
formData.append('invoice_id', invoiceId);
|
||||
|
||||
// Append files
|
||||
$('input[name="emp_file[]"]').each(function(index, input) {
|
||||
var files = $(input)[0].files;
|
||||
if (files.length > 0) {
|
||||
formData.append('emp_file[]', files[0]);
|
||||
var file_name_classes = $('.file_name');
|
||||
var hasEmptyInput = false;
|
||||
|
||||
file_name_classes.each(function() {
|
||||
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
|
||||
$('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);
|
||||
// Append files
|
||||
$('input[name="emp_file[]"]').each(function(index, input) {
|
||||
var files = $(input)[0].files;
|
||||
if (files.length > 0) {
|
||||
formData.append('emp_file[]', files[0]);
|
||||
}
|
||||
},
|
||||
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);
|
||||
$('#client_name_display_model').html(clientName);
|
||||
$('#date_display_model').html(Date);
|
||||
$('#date_display_model').html(formattedDate);
|
||||
|
||||
// document.getElementById('modalInvoiceNumber').innerText = invoiceNumber;
|
||||
$('#day').show();
|
||||
// $('#day').show();
|
||||
// $('#invoiceModal').modal('show');
|
||||
url:"<?php echo base_url() ?>servicepurchaseorder/getPODetails",
|
||||
$('#invoice_id_set').val(invoiceNumber);
|
||||
// url:"<?php echo base_url() ?>servicepurchaseorder/getPODetails",
|
||||
$('#invoice_id_set').val(invoiceId);
|
||||
// console.log(invoiceId);
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url() ?>getInvoiceAttachment',
|
||||
url: '<?php echo base_url() ?>getInvoiceAttachments',
|
||||
type: 'GET',
|
||||
data: { invoice_number: invoiceNumber },
|
||||
data: { invoice_id: invoiceId },
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
console.log(JSON.parse(response).invoiceAttachment);
|
||||
var list = JSON.parse(response).invoiceAttachment;
|
||||
var attachmentsHtml = '';
|
||||
@ -252,22 +316,37 @@ function openInvoiceModal(invoiceNumber, clientName, Date) {
|
||||
<div class="col-md-12 pad">
|
||||
<div class="col-md-4">
|
||||
<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>
|
||||
<div class="error-message"></div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-1" style="margin-top: 25px;">
|
||||
<a href="<?php echo base_url() . 'public/uploads/images/invoice_files/' ?>${fileName}" download>
|
||||
<i class="fa fa-download" aria-hidden="true"
|
||||
style="font-size: 25px;"></i>
|
||||
<a class="custom-button" href="<?php echo base_url() . 'public/uploads/images/invoice_files/' ?>${fileName}" download>
|
||||
Download
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-5" style="margin-top: 23px;">
|
||||
<button type="button" class="btn btn-danger btn-sm"
|
||||
id="${element.invoice_attachment_id}"
|
||||
onclick="removeContact(this)">Delete</button>
|
||||
onclick="removeContact(this)" style="margin-left: 22px;">Delete</button>
|
||||
</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);
|
||||
$('#invoiceModal').modal('show');
|
||||
},
|
||||
@ -277,6 +356,8 @@ function openInvoiceModal(invoiceNumber, clientName, Date) {
|
||||
$('#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-4">
|
||||
<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 class="col-md-4">
|
||||
<span for="emp_file">File</span>
|
||||
@ -313,7 +395,7 @@ function removeContact(button) {
|
||||
var len = $('#filesContainer .pad:last .a1')
|
||||
var length = len.length;
|
||||
if (length == 0) {
|
||||
$('#day').show()
|
||||
// $('#day').show()
|
||||
} else {
|
||||
$('#day').hide()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user