Sales_order_invoice_product

This commit is contained in:
heama 2024-04-05 17:43:06 +05:30
parent ad2a9b98e0
commit 34096b7a60
6 changed files with 81 additions and 18 deletions

2
.env
View File

@ -14,7 +14,7 @@
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
# CI_ENVIRONMENT = development
#--------------------------------------------------------------------
# APP

View File

@ -21,7 +21,7 @@ class Sales extends BaseController
{
$SalesOrderModel = new SalesOrderModel();
$sales=$SalesOrderModel->getSalesOrdersWithProducts();
$sales=$SalesOrderModel->getSalesOrdersWithProducts($this->session->get('logged_user_branch_id'));
$data['sales']=$sales;
// print_r($data);die;
return view('sales_list',$data);
@ -36,10 +36,14 @@ class Sales extends BaseController
$data['page_name']="Add Sale";
$data['sales'] = [];
$ClientModel = new ClientModel();
$client=$ClientModel->where('isactive',1)->findAll();
// print_r($client);die;
$client=$ClientModel
->where('isactive',1)
->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
// print_r($client);die;
$ProductModel = new ProductModel();
$product=$ProductModel->findAll();
$product=$ProductModel
->where('isactive',1)
->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['product']=$product;
$data['client']=$client;
} else if ($sales_order_id !== '0') {

View File

@ -5,7 +5,7 @@ class ProductModel extends Model
{
protected $table = 'products';
protected $primaryKey = 'product_id';
protected $allowedFields = ['product_id','product_name','search_tag','product_category','mfr_part_no','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
protected $allowedFields = ['product_id','product_name','branch_id','search_tag','product_category','mfr_part_no','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
public function getTax()

View File

@ -6,7 +6,7 @@ class SalesOrderModel extends Model
protected $table = 'sales_order';
protected $primaryKey = 'sales_order_id';
protected $allowedFields = ['sales_order_id','client_id','order_number','branch_id','status','mobile_no','billing_address','billing_city','billing_state','billing_country','billing_postal_code','total','tax','subtotal','discount','terms_condition','isactive'];
//
public function getSalesPdf($sales_order_id){
return $this->db->table('sales_order')
->where('sales_order_id', $sales_order_id)
@ -19,7 +19,7 @@ class SalesOrderModel extends Model
->getResult();
}
public function getSalesOrdersWithProducts()
public function getSalesOrdersWithProducts($logged_user_branch_id)
{
// Select required fields from both tables
$this->select('sales_order.*, COUNT(sales_order_product.sales_order_id) AS product_count,client.client_name');
@ -33,7 +33,8 @@ class SalesOrderModel extends Model
// Add condition to fetch only active sales orders
$this->where('sales_order_product.isactive', 1);
$this ->where('sales_order.branch_id',$logged_user_branch_id);
$this->orderBy('sales_order.sales_order_id','DESC');
// Get the results
return $this->findAll();
}

View File

@ -1,4 +1,14 @@
<?php include('layout/header.php'); ?>
<style>
.dataTables_wrapper button{
background: #f1f5f7;
color: #343a40;
border-width: 0;
}
.dataTables_wrapper .dt-buttons{
float:left;
}
</style>
<div class="container-fluid">
<div class="row">
<div class="col-12">
@ -24,7 +34,7 @@
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
<table id="datatable-buttons2" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
@ -79,4 +89,52 @@
</div> <!-- end col -->
</div>
<?php include('layout/footer.php'); ?>
<?php include('layout/footer.php'); ?>
<script>
$(document).ready(function() {
$('#datatable-buttons2').DataTable({
"order": [[2, 'desc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [ {
extend: 'pdfHtml5',
title: 'Transaction', // Set your custom PDF title here
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
// doc.content[1].table.body.forEach(function(row) {
// row.splice(0, 1); // Remove the first column (ID column)
// });
}
},
{
extend: 'print',
title: 'Transaction', // Set your custom print title here
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
// $(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'copy',
text: 'Copy', // Set the title for the Copy button
titleAttr: 'Copy', // Set the tooltip for the Copy button
exportOptions: {
// columns: ':not(:first-child)' // Exclude the first column (ID column)
}
},
{
extend: 'csv',
text: 'CSV', // Set the title for the CSV button
title: 'Transaction', // Set your custom print title here
exportOptions: {
// columns: ':not(:first-child)' // Exclude the first column (ID column)
}
}], // Enable export options
"language": {
"search": "Search: " // Customize search label
},
"ordering": false
});
});
</script>

View File

@ -39,7 +39,7 @@
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Status</label>
<select class="form-control status-select" name="status" required data-toggle="select2">
<option value="">Select a Status</option>
<!-- <option value="">Select a Status</option> -->
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
<option value="InvoiceGenerated" <?= isset($sales['status']) && $sales['status'] === 'InvoiceGenerated' ? 'selected' : '' ?>>Generate Invoice</option>
</select>
@ -50,7 +50,7 @@
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Billing Address</label>
<input type="text" class="form-control" name="billing_address" placeholder="Address"value="<?= isset($sales['billing_address']) ? $sales['billing_address'] : '' ?>" readonly>
<input type="text" class="form-control" name="billing_address" placeholder="Address"value="<?= isset($sales['billing_address']) ? $sales['billing_address'] : '' ?>" >
</div>
@ -58,23 +58,23 @@
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">City</label>
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($sales['billing_city']) ? $sales['billing_city'] : '' ?>" readonly>
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($sales['billing_city']) ? $sales['billing_city'] : '' ?>" >
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">State</label>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($sales['billing_state']) ? $sales['billing_state'] : '' ?>" readonly>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($sales['billing_state']) ? $sales['billing_state'] : '' ?>" >
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Postal Code</label>
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($sales['billing_postal_code']) ? $sales['billing_postal_code'] : '' ?>" readonly maxlength="6" minlength="6">
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($sales['billing_postal_code']) ? $sales['billing_postal_code'] : '' ?>" maxlength="6" minlength="6">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Country</label>
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($sales['billing_country']) ? $sales['billing_country'] : '' ?>" readonly>
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($sales['billing_country']) ? $sales['billing_country'] : '' ?>" >
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile_no" placeholder="Country"value="<?= isset($sales['billing_country']) ? $sales['billing_country'] : '' ?>" readonly>
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile"value="<?= isset($sales['mobile_no']) ? $sales['mobile_no'] : '' ?>" >
</div>
</div>