Non-igr : GWM
This commit is contained in:
parent
5a97a6ebeb
commit
e6739be31c
@ -48,8 +48,17 @@ class Expense extends BaseController
|
||||
$this->loadViews("expense_list", $this->global, $data, NULL);
|
||||
}
|
||||
|
||||
private function generateSerialNumber($financialYear, $lastSerial)
|
||||
{
|
||||
// If no last serial number exists, start with 00001
|
||||
$lastNumber = $lastSerial ? (int)explode('/', $lastSerial)[1] : 0;
|
||||
$newNumber = str_pad($lastNumber + 1, 5, '0', STR_PAD_LEFT);
|
||||
return "$financialYear/$newNumber";
|
||||
}
|
||||
|
||||
public function addExpense()
|
||||
{
|
||||
try{
|
||||
$file = $this->request->getFile('transporterfile');
|
||||
$fileName = '';
|
||||
if ($file->isValid() && !$file->hasMoved()) {
|
||||
@ -59,6 +68,28 @@ class Expense extends BaseController
|
||||
|
||||
$status = $this->request->getPost('status');
|
||||
$paymentMethod = $status === 'Paid' ? $this->request->getPost('payment_method') : 0;
|
||||
|
||||
// Fetch the current month
|
||||
$currentMonth = date('n'); // 'n' gives the month without leading zeros (1-12)
|
||||
|
||||
// Calculate the current financial year
|
||||
if ($currentMonth >= 4) { // If it's April or later
|
||||
$startYear = date('Y'); // Current year
|
||||
$endYear = $startYear + 1; // Next year
|
||||
} else { // If it's January, February, or March
|
||||
$endYear = date('Y'); // Current year
|
||||
$startYear = $endYear - 1; // Previous year
|
||||
}
|
||||
|
||||
// Format the financial year as "yy-yy"
|
||||
$financialYear = substr($startYear, -2) . '-' . substr($endYear, -2);
|
||||
|
||||
// Fetch the last serial number for the financial year
|
||||
$lastSerial = $this->expense_model->getLastSerialNumber($financialYear);
|
||||
|
||||
// Generate the next serial number
|
||||
$newSerialNumber = $this->generateSerialNumber($financialYear, $lastSerial);
|
||||
|
||||
|
||||
$data = [
|
||||
'transporter_file' => $fileName,
|
||||
@ -70,14 +101,21 @@ class Expense extends BaseController
|
||||
'sgst' => $this->request->getPost('sgst'),
|
||||
'igst' => $this->request->getPost('igst'),
|
||||
'total' => $this->request->getPost('total'),
|
||||
'bill_no' => $this->request->getPost('bill_no'),
|
||||
'bill_date' => $this->request->getPost('bill_date'),
|
||||
'serial_number' => $newSerialNumber,
|
||||
];
|
||||
|
||||
|
||||
$insert_id = $this->expense_model->insertExpense($data);
|
||||
if ($insert_id) {
|
||||
return json_encode('true');
|
||||
} else {
|
||||
return json_encode('false');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Handle the exception
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getExpenseDetails()
|
||||
@ -117,6 +155,8 @@ class Expense extends BaseController
|
||||
'sgst' => $this->request->getPost('sgst'),
|
||||
'igst' => $this->request->getPost('igst'),
|
||||
'total' => $this->request->getPost('total'),
|
||||
'bill_no' => $this->request->getPost('bill_no'),
|
||||
'bill_date' => $this->request->getPost('bill_date'),
|
||||
];
|
||||
if(!empty($fileName)){
|
||||
$data['transporter_file'] = $fileName;
|
||||
|
||||
@ -9,9 +9,20 @@ class Expense_model extends Model
|
||||
protected $primaryKey = 'id'; // Primary key
|
||||
|
||||
protected $allowedFields = [
|
||||
'transporter_file', 'supplier_id', 'remarks', 'item_description', 'cost', 'cgst', 'sgst', 'igst', 'total',
|
||||
'serial_number' , 'transporter_file', 'supplier_id', 'remarks', 'item_description', 'cost', 'cgst', 'sgst', 'igst', 'total', 'bill_no' ,'bill_date'
|
||||
];
|
||||
|
||||
public function getLastSerialNumber($financialYear)
|
||||
{
|
||||
return $this->db->table('t_expense')
|
||||
->select('serial_number')
|
||||
->like('serial_number', "$financialYear/", 'after')
|
||||
->orderBy('serial_number', 'DESC')
|
||||
->limit(1)
|
||||
->get()
|
||||
->getRow('serial_number');
|
||||
}
|
||||
|
||||
// Retrieve all active expenses
|
||||
public function getAllExpense($fromDate,$toDate) {
|
||||
return $this->join('t_supplierdetailsn', 't_expense.supplier_id = t_supplierdetailsn.SupplierID')
|
||||
|
||||
@ -47,25 +47,7 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_length {
|
||||
/* float: left; */
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dt-buttons,
|
||||
.dataTables_wrapper .dataTables_filter {
|
||||
/* float: right; */
|
||||
/* margin-left: 10px; */
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dt-buttons {
|
||||
/* margin-top: 10px; */
|
||||
/* margin-bottom: 10px; */
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_filter {
|
||||
/* margin-top: 10px; */
|
||||
/* margin-bottom: 10px; */
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@ -267,7 +249,13 @@
|
||||
var table = $('#po_list').DataTable({
|
||||
dom: 'Blfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf'
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)' // Exclude the last column
|
||||
}
|
||||
}
|
||||
],
|
||||
pageLength: 10,
|
||||
lengthMenu: [
|
||||
|
||||
@ -55,6 +55,11 @@
|
||||
background-color: white;
|
||||
color: red;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
@ -108,8 +113,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left" style="width: 10%;">Created Date</th>
|
||||
<th align="left" style="width: 10%;">Non-IGRNO</th>
|
||||
<th align="left" style="width: 20%;">Supplier Name</th>
|
||||
<th align="left" style="width: 25%;">Item Description</th>
|
||||
<th align="left" style="width: 20%;">Bill No</th>
|
||||
<th align="left" style="width: 20%;">Bill Date</th>
|
||||
<th align="left" style="width: 7%;">Cost</th>
|
||||
<th align="left" style="width: 5%;">CGST</th>
|
||||
<th align="left" style="width: 5%;">SGST</th>
|
||||
@ -138,7 +146,7 @@
|
||||
}
|
||||
?>
|
||||
<td><?php echo $cdate; ?></td>
|
||||
<!-- <td><?php echo $record['id']; ?></td> -->
|
||||
<td><?php echo $record['serial_number']; ?></td>
|
||||
<td class="expandable-td">
|
||||
<div class="text-container" style="max-height: 20px; overflow: hidden;">
|
||||
<?php echo $record['SupplierName']; ?>
|
||||
@ -151,6 +159,13 @@
|
||||
<?php echo $record['item_description']; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php echo $record['bill_no']; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$date = new DateTime($record['bill_date']);
|
||||
echo $date->format('d-m-Y');
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $record['cost']; ?></td>
|
||||
<td><?php echo $record['cgst']; ?></td>
|
||||
<td><?php echo $record['sgst']; ?></td>
|
||||
@ -214,12 +229,29 @@
|
||||
<textarea name="item_description" id="item_description" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<label for="bill_no" class="col-form-label">Bill No</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" name="bill_no" id="bill_no" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<label for="bill_date" class="col-form-label">Bill Date</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="date" name="bill_date" id="bill_date" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<label for="cost" class="col-form-label">Cost</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" name="cost" id="cost" class="form-control" required onchange="totalCalculate()">
|
||||
<input type="text" name="cost" id="cost" class="form-control" required onchange="totalCalculate()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@ -227,7 +259,7 @@
|
||||
<label for="cost" class="col-form-label">CGST</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" name="cgst" id="cgst" class="form-control" onchange="totalCalculate()">
|
||||
<input type="text" name="cgst" id="cgst" class="form-control" onchange="totalCalculate()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@ -235,7 +267,7 @@
|
||||
<label for="cost" class="col-form-label">SGST</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" name="sgst" id="sgst" class="form-control" onchange="totalCalculate()">
|
||||
<input type="text" name="sgst" id="sgst" class="form-control" onchange="totalCalculate()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@ -243,7 +275,7 @@
|
||||
<label for="igst" class="col-form-label">IGST</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" name="igst" id="igst" class="form-control" onchange="totalCalculate()">
|
||||
<input type="text" name="igst" id="igst" class="form-control" onchange="totalCalculate()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@ -251,7 +283,7 @@
|
||||
<label for="cost" class="col-form-label">Total</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" name="total" id="total" class="form-control">
|
||||
<input type="text" name="total" id="total" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@ -287,6 +319,13 @@
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
const dateInput = document.getElementById('bill_date');
|
||||
dateInput.addEventListener('change', function () {
|
||||
const date = new Date(dateInput.value);
|
||||
const formattedDate = date.toLocaleDateString('en-GB').split('/').join('-');
|
||||
console.log('Formatted Date:', formattedDate);
|
||||
});
|
||||
|
||||
function downloadFile(fileId, fileName) {
|
||||
window.location.href = 'downloadFile/' + fileName;
|
||||
}
|
||||
@ -365,6 +404,8 @@
|
||||
$('#igst').val(expense.igst);
|
||||
$('#total').val(expense.total);
|
||||
$('#status_id').val(expense.status);
|
||||
$('#bill_no').val(expense.bill_no);
|
||||
$('#bill_date').val(expense.bill_date);
|
||||
|
||||
// Clear any existing file link and delete button
|
||||
$('#transporterfile').next('.download_button').remove();
|
||||
@ -470,7 +511,13 @@
|
||||
var table = $('#expense_list_table').DataTable({
|
||||
dom: 'Blfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf'
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)' // Exclude the last column
|
||||
}
|
||||
}
|
||||
],
|
||||
pageLength: 10,
|
||||
lengthMenu: [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user