NEW_SALES_INVOICE
This commit is contained in:
parent
a58927e217
commit
63c34ea6d6
@ -1339,6 +1339,8 @@ class User extends BaseController
|
|||||||
$invoice_date = $rs['date'];
|
$invoice_date = $rs['date'];
|
||||||
$status = $rs['status'];
|
$status = $rs['status'];
|
||||||
$due_date = $rs['due_date'];
|
$due_date = $rs['due_date'];
|
||||||
|
$invoice_url = $rs['invoice_url'];
|
||||||
|
$einvoice_number = $rs['einvoice_details']['inv_ref_num'];
|
||||||
|
|
||||||
$invoice_time=$rs['created_time'];
|
$invoice_time=$rs['created_time'];
|
||||||
$time_array = explode("T", $invoice_time);
|
$time_array = explode("T", $invoice_time);
|
||||||
@ -1382,6 +1384,9 @@ class User extends BaseController
|
|||||||
$ip_invoices['invoice_url_key'] = $url_key;
|
$ip_invoices['invoice_url_key'] = $url_key;
|
||||||
$ip_invoices['receivedstatus'] = 'ST066';
|
$ip_invoices['receivedstatus'] = 'ST066';
|
||||||
$ip_invoices['credit_status'] = 0;
|
$ip_invoices['credit_status'] = 0;
|
||||||
|
$ip_invoices['status'] = $status;
|
||||||
|
$ip_invoices['e_invoice_number'] = $einvoice_number;
|
||||||
|
$ip_invoices['invoice_url'] = $invoice_url;
|
||||||
$invoice_insert_id = $Zohobook_model->customInsert($ip_invoices,'ip_invoices');
|
$invoice_insert_id = $Zohobook_model->customInsert($ip_invoices,'ip_invoices');
|
||||||
if($invoice_insert_id)
|
if($invoice_insert_id)
|
||||||
{
|
{
|
||||||
@ -1590,8 +1595,8 @@ class User extends BaseController
|
|||||||
}
|
}
|
||||||
else // update invoice status, especially for cancelled invoices
|
else // update invoice status, especially for cancelled invoices
|
||||||
{
|
{
|
||||||
if($status == "void" || $status == "sent" || $status == "overdue")
|
// if($status == "void" || $status == "sent" || $status == "overdue")
|
||||||
{
|
// {
|
||||||
$sql_invoice_update = array();
|
$sql_invoice_update = array();
|
||||||
$sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5);
|
$sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5);
|
||||||
// echo 'script' . $invoice_number. $status;
|
// echo 'script' . $invoice_number. $status;
|
||||||
@ -1607,7 +1612,7 @@ class User extends BaseController
|
|||||||
log_message('error', 'Data update failed DB : ip_invoices ');
|
log_message('error', 'Data update failed DB : ip_invoices ');
|
||||||
}
|
}
|
||||||
$update_count = $update_count + 1;
|
$update_count = $update_count + 1;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
// echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count;
|
// echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count;
|
||||||
|
|
||||||
|
|||||||
@ -20,9 +20,11 @@ class Ipinvoice_model extends Model
|
|||||||
$builder = $this->db->table('ip_invoices')
|
$builder = $this->db->table('ip_invoices')
|
||||||
->select('ip_invoices.invoice_id, ip_invoices.user_id, ip_invoices.client_id,
|
->select('ip_invoices.invoice_id, ip_invoices.user_id, ip_invoices.client_id,
|
||||||
ip_invoices.invoice_group_id, ip_invoices.invoice_status_id, ip_invoices.invoice_date_due, ip_invoices.invoice_date_created,
|
ip_invoices.invoice_group_id, ip_invoices.invoice_status_id, ip_invoices.invoice_date_due, ip_invoices.invoice_date_created,
|
||||||
ip_invoices.invoice_number, ip_invoices.invoice_terms, ip_clients.client_name,
|
ip_invoices.invoice_number, ip_invoices.invoice_terms, ip_invoices.status, ip_invoices.e_invoice_number, ip_invoices.invoice_url, ip_clients.client_name,
|
||||||
ip_payment_methods.payment_method_name, ip_users.user_name, ip_products.product_name,
|
ip_payment_methods.payment_method_name, ip_users.user_name,
|
||||||
ip_invoice_amounts.invoice_total')
|
ip_products.product_name, ip_invoice_items.item_price, ip_products.cgst, ip_products.sgst,
|
||||||
|
ip_invoice_items.item_quantity, ip_invoice_items.item_price, ip_invoice_items.item_name, ip_invoice_items.item_quantity,
|
||||||
|
ip_invoice_amounts.invoice_total, ip_invoice_amounts.invoice_item_subtotal, ip_invoice_amounts.invoice_item_tax_total')
|
||||||
->join('ip_payment_methods', 'ip_invoices.payment_method = ip_payment_methods.payment_method_id', 'left')
|
->join('ip_payment_methods', 'ip_invoices.payment_method = ip_payment_methods.payment_method_id', 'left')
|
||||||
->join('ip_clients', 'ip_invoices.client_id = ip_clients.client_id', 'left')
|
->join('ip_clients', 'ip_invoices.client_id = ip_clients.client_id', 'left')
|
||||||
->join('ip_users', 'ip_invoices.user_id = ip_users.user_id', 'left')
|
->join('ip_users', 'ip_invoices.user_id = ip_users.user_id', 'left')
|
||||||
@ -33,13 +35,55 @@ class Ipinvoice_model extends Model
|
|||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
|
// $results = $query->getResultArray();
|
||||||
return $result;
|
return $result;
|
||||||
|
// $invoices = [];
|
||||||
|
|
||||||
|
// foreach ($results as $row) {
|
||||||
|
// $invoice_id = $row['invoice_id'];
|
||||||
|
|
||||||
|
// // If the invoice_id doesn't exist in the $invoices array, initialize it
|
||||||
|
// if (!isset($invoices[$invoice_id])) {
|
||||||
|
// $invoices[$invoice_id] = [
|
||||||
|
// 'invoice_id' => $row['invoice_id'],
|
||||||
|
// 'user_id' => $row['user_id'],
|
||||||
|
// 'client_id' => $row['client_id'],
|
||||||
|
// 'invoice_group_id' => $row['invoice_group_id'],
|
||||||
|
// 'invoice_status_id' => $row['invoice_status_id'],
|
||||||
|
// 'invoice_date_due' => $row['invoice_date_due'],
|
||||||
|
// 'invoice_date_created' => $row['invoice_date_created'],
|
||||||
|
// 'invoice_number' => $row['invoice_number'],
|
||||||
|
// 'invoice_terms' => $row['invoice_terms'],
|
||||||
|
// 'status' => $row['status'],
|
||||||
|
// 'e_invoice_number' => $row['e_invoice_number'],
|
||||||
|
// 'invoice_url' => $row['invoice_url'],
|
||||||
|
// 'client_name' => $row['client_name'],
|
||||||
|
// 'payment_method_name' => $row['payment_method_name'],
|
||||||
|
// 'user_name' => $row['user_name'],
|
||||||
|
// 'invoice_total' => $row['invoice_total'],
|
||||||
|
// 'invoice_item_subtotal' => $row['invoice_item_subtotal'],
|
||||||
|
// 'invoice_item_tax_total' => $row['invoice_item_tax_total'],
|
||||||
|
// 'products' => [] // Initialize the products array
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Add the product to the products array for the current invoice
|
||||||
|
// $invoices[$invoice_id]['products'][] = [
|
||||||
|
// 'product_name' => $row['product_name'],
|
||||||
|
// 'item_quantity' => $row['item_quantity'],
|
||||||
|
// 'item_price' => $row['item_price'],
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Return the grouped invoices
|
||||||
|
// return $invoices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to add new user to system
|
* This function is used to add new user to system
|
||||||
* @return number $insert_id : This is last inserted id
|
* @return number $insert_id : This is last inserted id
|
||||||
|
|||||||
@ -349,7 +349,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li class="treeview">
|
<li class="treeview">
|
||||||
<a id="salesDashboardLin" href="<?php echo base_url(); ?>sales_invoice">
|
<a id="salesDashboardLin" href="<?php echo base_url(); ?>sales_invoice">
|
||||||
<i class="fa fa-file-text-o"></i><span>Sales Invoice</span>
|
<i class="fa fa-file-text-o"></i><span>Sales</span>
|
||||||
</a>
|
</a>
|
||||||
</li><!--Dashboard active treeview -->
|
</li><!--Dashboard active treeview -->
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||||
|
<style>
|
||||||
|
.invoice-link {
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #007bff; /* Adjust color as needed */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<!-- Content Header (Page header) -->
|
<!-- Content Header (Page header) -->
|
||||||
<section class="content-header">
|
<section class="content-header">
|
||||||
@ -21,40 +26,60 @@
|
|||||||
|
|
||||||
</div><!-- /.box-header -->
|
</div><!-- /.box-header -->
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<table id="datatable_sales_invoice_list" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;text-align: right;" >
|
<table id="datatable_sales_invoice_list" class="table table-striped dt-responsive nowrap w-100" style="background-color:#fff;font-size:12px;text-align: right;" >
|
||||||
<thead style="background-color: #ddd;">
|
<thead style="background-color: #ddd;">
|
||||||
<tr >
|
<tr >
|
||||||
|
<th width="10%">Invoice Date</th>
|
||||||
<th width="10%">Invoice No</th>
|
<th width="10%">Invoice No</th>
|
||||||
<th width="10%">Invoice Date Created</th>
|
|
||||||
<th width="10%">Invoice Date Due</th>
|
|
||||||
<th width="10%">Client Name</th>
|
<th width="10%">Client Name</th>
|
||||||
<th width="10%">User Name</th>
|
<th width="10%">Product</th>
|
||||||
<th width="10%">Product Name</th>
|
<th width="10%">Rate</th>
|
||||||
<th width="10%" >Payment Method</th>
|
<th width="10%">Quantity</th>
|
||||||
<th width="10%">Invoice Total</th>
|
<th width="10%">Sub Total</th>
|
||||||
|
<th width="10%">GST</th>
|
||||||
|
<th width="10%">Total</th>
|
||||||
|
<th width="10%">Status</th>
|
||||||
|
<th width="10%" >E-Invoice Number</th>
|
||||||
|
<th width="5%">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<input type="text" id="invoice_id_set" name="invoice_id_set" hidden>
|
<input type="text" id="invoice_id_set" name="invoice_id_set" hidden>
|
||||||
<?php if(!empty($sales_invoice)){ foreach($sales_invoice as $invoice){ ?>
|
<?php if(!empty($sales_invoice)){ foreach($sales_invoice as $invoice){
|
||||||
<tr style="cursor: pointer;" onclick="openInvoiceModal('<?php echo $invoice->invoice_number; ?>')">
|
|
||||||
|
$subtotal = $invoice->item_price * $invoice->item_quantity;
|
||||||
|
// Calculate CGST and SGST
|
||||||
|
$cgst_amount = ($subtotal * $invoice->cgst) / 100;
|
||||||
|
$sgst_amount = ($subtotal * $invoice->sgst) / 100;
|
||||||
|
$total = $subtotal + $cgst_amount + $sgst_amount;?>
|
||||||
|
<!-- Main invoice row -->
|
||||||
|
<tr class="parent-row">
|
||||||
|
<td style="text-align: center;"><?php echo date('d-m-Y', strtotime($invoice->invoice_date_created)); ?></td>
|
||||||
<td style="text-align: left;">
|
<td style="text-align: left;">
|
||||||
|
<?php if(!empty($invoice->invoice_url)){ ?>
|
||||||
|
<a href="<?php echo $invoice->invoice_url; ?>" target="_blank" class="invoice-link">
|
||||||
|
<?php } ?>
|
||||||
<?php echo $invoice->invoice_number; ?>
|
<?php echo $invoice->invoice_number; ?>
|
||||||
</td>
|
<?php if(!empty($invoice->invoice_url)){ ?>
|
||||||
<td style="text-align: center;"><?php echo date('d/m/y', strtotime($invoice->invoice_date_created)); ?>
|
</a>
|
||||||
<td style="text-align: center;"><?php echo date('d/m/y', strtotime($invoice->invoice_date_due)); ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;"><?php echo $invoice->client_name ?></td>
|
<td style="text-align: center;"><?php echo $invoice->client_name ?></td>
|
||||||
<td style="text-align: center;"><?php echo $invoice->user_name ?></td>
|
<td style="text-align: center;"><?php echo $invoice->item_name ?></td>
|
||||||
<td style="text-align: center;"><?php echo $invoice->product_name ?></td>
|
<td style="text-align: center;"><?php echo $invoice->item_price ?></td>
|
||||||
<td style="text-align: center;"><?php echo $invoice->payment_method_name; ?></td>
|
<td style="text-align: center;"><?php echo number_format($invoice->item_quantity, 2 ,'.', ',' ) ?></td>
|
||||||
<td style="text-align: center;"><?php echo $invoice->invoice_total ?></td>
|
<td style="text-align: center;"><?php echo number_format($subtotal, 2, '.', ',') ?></td>
|
||||||
|
<td style="text-align: center;"><?php echo number_format($cgst_amount+$sgst_amount, 2, '.', ',') ?></td>
|
||||||
|
<td style="text-align: center;"><?php echo number_format($total, 2, '.', ',') ?></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;">
|
||||||
|
<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; ?>')">
|
||||||
|
<i class="fas fa-file-upload text-muted" style="font-size: 18px; vertical-align: middle;"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php } } ?>
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div><!-- /.box-body -->
|
</div><!-- /.box-body -->
|
||||||
@ -72,10 +97,12 @@
|
|||||||
<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>
|
<h3 class="modal-title" id="invoiceModalLabel">Invoice Files</h3>
|
||||||
<label for=""> Invoice Number :</label><span id="invoice_number_display_model"></span>
|
|
||||||
<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">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</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>
|
||||||
<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">
|
||||||
@ -123,12 +150,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(function () {
|
$(document).ready(function() {
|
||||||
|
var table = $('#datatable_sales_invoice_list').DataTable({
|
||||||
$('#datatable_sales_invoice_list').DataTable({
|
|
||||||
"paging": true,
|
"paging": true,
|
||||||
"lengthChange": true,
|
"lengthChange": true,
|
||||||
"searching": true,
|
"searching": true,
|
||||||
@ -138,14 +165,21 @@
|
|||||||
"type": "date-eu"
|
"type": "date-eu"
|
||||||
}],
|
}],
|
||||||
"aaSorting": [
|
"aaSorting": [
|
||||||
[1, "desc"]
|
[0, "desc"]
|
||||||
],
|
],
|
||||||
"info": true,
|
"info": true,
|
||||||
"autoWidth": true,
|
"autoWidth": true,
|
||||||
"pageLength": 10,
|
"pageLength": 10,
|
||||||
"lengthMenu": [10, 25, 50, 100],
|
"lengthMenu": [10, 25, 50, 100],
|
||||||
|
"rowCallback": function(row, data, index) {
|
||||||
|
// Ignore child rows
|
||||||
|
if ($(row).hasClass('child-row')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -191,8 +225,11 @@ function saveAttachment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openInvoiceModal(invoiceNumber) {
|
function openInvoiceModal(invoiceNumber, clientName, Date) {
|
||||||
$('#invoice_number_display_model').html(invoiceNumber);
|
$('#invoice_number_display_model').html(invoiceNumber);
|
||||||
|
$('#client_name_display_model').html(clientName);
|
||||||
|
$('#date_display_model').html(Date);
|
||||||
|
|
||||||
// document.getElementById('modalInvoiceNumber').innerText = invoiceNumber;
|
// document.getElementById('modalInvoiceNumber').innerText = invoiceNumber;
|
||||||
$('#day').show();
|
$('#day').show();
|
||||||
// $('#invoiceModal').modal('show');
|
// $('#invoiceModal').modal('show');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user