Purchase Changes support
This commit is contained in:
parent
692b6ff9b8
commit
fb0a825faf
@ -43,6 +43,14 @@ class Products extends BaseController
|
|||||||
|
|
||||||
$ProductCategoryModel = new ProductCategoryModel();
|
$ProductCategoryModel = new ProductCategoryModel();
|
||||||
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
||||||
|
// print_r($productcategory);
|
||||||
|
foreach ($productcategory as &$category) {
|
||||||
|
$sub_query_result = $this->ProductModel
|
||||||
|
->select('count(product_category) as total_product')
|
||||||
|
->where('product_category', $category['product_category_name'])
|
||||||
|
->first();
|
||||||
|
$category['total_product'] = $sub_query_result['total_product'] ?? 0;
|
||||||
|
}
|
||||||
$data['productcategory'] = $productcategory;
|
$data['productcategory'] = $productcategory;
|
||||||
return view('product_categories',$data);
|
return view('product_categories',$data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,6 +206,12 @@ class Purchase extends BaseController
|
|||||||
|
|
||||||
$data['purchase_product'] = $purchase_product;
|
$data['purchase_product'] = $purchase_product;
|
||||||
|
|
||||||
|
$productAll = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||||
|
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||||
|
->where('products.isactive',1)
|
||||||
|
->findAll();
|
||||||
|
$data['productAll']= json_encode($productAll);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data['purchase_order_id']= $purchase_order_id;
|
$data['purchase_order_id']= $purchase_order_id;
|
||||||
|
|||||||
@ -10,11 +10,11 @@ class PurchaseOrderModel extends Model
|
|||||||
public function getPurchaseOrdersWithProducts($logged_user_branch_id)
|
public function getPurchaseOrdersWithProducts($logged_user_branch_id)
|
||||||
{
|
{
|
||||||
// Select required fields from both tables
|
// Select required fields from both tables
|
||||||
$this->select('purchase_order.*, COUNT(purchase_order_child.purchase_order_id) AS product_count,vendor.vendor_name,SUM(purchase_order_child.qty) AS purchase_qty, purchase_order_child.received_qty');
|
$this->select('purchase_order.*, COUNT(purchase_order_child.purchase_order_id) AS product_count,vendor.vendor_name,SUM(purchase_order_child.qty) AS purchase_qty, SUM(purchase_order_child.received_qty) AS received_qty');
|
||||||
|
|
||||||
// Join the sales_order_product table based on sales_order_id
|
// Join the sales_order_product table based on sales_order_id
|
||||||
$this->join('purchase_order_child', 'purchase_order_child.purchase_order_id = purchase_order.purchase_order_id');
|
$this->join('purchase_order_child', 'purchase_order_child.purchase_order_id = purchase_order.purchase_order_id');
|
||||||
$this ->join('vendor', 'vendor.vendor_id = purchase_order.vendor_id');
|
$this->join('vendor', 'vendor.vendor_id = purchase_order.vendor_id');
|
||||||
// Group by sales_order_id to get count of products per sales order
|
// Group by sales_order_id to get count of products per sales order
|
||||||
$this->groupBy('purchase_order.purchase_order_id');
|
$this->groupBy('purchase_order.purchase_order_id');
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class SalesOrderModel extends Model
|
|||||||
|
|
||||||
// Add condition to fetch only active sales orders
|
// Add condition to fetch only active sales orders
|
||||||
$this ->where('sales_order.branch_id',$logged_user_branch_id);
|
$this ->where('sales_order.branch_id',$logged_user_branch_id);
|
||||||
$this->orderBy('sales_order.order_number','desc');
|
$this->orderBy('sales_order.sales_order_id','desc');
|
||||||
// Get the results
|
// Get the results
|
||||||
return $this->findAll();
|
return $this->findAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,15 +44,12 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- <h4 class="header-title">Business List</h4> -->
|
<!-- <h4 class="header-title">Business List</h4> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<table id="datatable-jobcard" class="table table-striped dt-responsive nowrap w-100"
|
<table id="datatable-jobcard" class="table table-striped dt-responsive nowrap w-100"
|
||||||
style="width:100% !important;">
|
style="width:100% !important;">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Job Card</th>
|
||||||
<th>Order Number</th>
|
<th>Order Number</th>
|
||||||
<th>Vehicle No</th>
|
<th>Vehicle No</th>
|
||||||
<th>Client</th>
|
<th>Client</th>
|
||||||
@ -67,6 +64,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($jobs as $index => $value) : if ($value['isactive'] == 1) : ?>
|
<?php foreach ($jobs as $index => $value) : if ($value['isactive'] == 1) : ?>
|
||||||
<tr class="job_tr_<?php echo $index+1; ?>">
|
<tr class="job_tr_<?php echo $index+1; ?>">
|
||||||
|
<td><?= $value['job_card_id']; ?></td>
|
||||||
<td><?= $value['order_number']; ?></td>
|
<td><?= $value['order_number']; ?></td>
|
||||||
<td><?= $value['reg_no']; ?></td>
|
<td><?= $value['reg_no']; ?></td>
|
||||||
<td><?= $value['client_name']; ?><br><?= $value['client_mobile_no']; ?></td>
|
<td><?= $value['client_name']; ?><br><?= $value['client_mobile_no']; ?></td>
|
||||||
@ -182,6 +180,13 @@
|
|||||||
"language": {
|
"language": {
|
||||||
"search": "Search: " // Customize search label
|
"search": "Search: " // Customize search label
|
||||||
},
|
},
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": [0], // Target the first column (JC Id)
|
||||||
|
"visible": false, // Hide the column
|
||||||
|
"searchable": false // Make it non-searchable (optional)
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Product Category</th>
|
<th>Product Category</th>
|
||||||
|
<th>Total Product</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Products</th>
|
<th>Products</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -33,6 +34,7 @@
|
|||||||
<?php foreach ($productcategory as $index => $item): ?>
|
<?php foreach ($productcategory as $index => $item): ?>
|
||||||
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
||||||
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
||||||
|
<td><?php echo $item['total_product']; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if($item['isactive'] == 1): ?>
|
<?php if($item['isactive'] == 1): ?>
|
||||||
<span style="color:green">Active</span>
|
<span style="color:green">Active</span>
|
||||||
|
|||||||
@ -149,11 +149,14 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Item Details</th>
|
<th>Item Details</th>
|
||||||
<th>Qty</th>
|
<?php if (!empty($purchase["status"]) && !isset($reorder)){ ?>
|
||||||
<?php if (!empty($purchase["status"]) && !isset($reorder)): ?>
|
<th>Original Qty</th>
|
||||||
|
<th>Rcvd Qty</th>
|
||||||
<th>Received</th>
|
<th>Received</th>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
<?php endif; ?>
|
<?php }else{ ?>
|
||||||
|
<th>Qty</th>
|
||||||
|
<?php } ?>
|
||||||
<th hidden></th>
|
<th hidden></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -184,8 +187,13 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
<?php if(!isset($reorder)) { ?>
|
||||||
|
<td style="width:2%;">
|
||||||
|
<?php echo $purchasechild['qty']; ?>
|
||||||
|
</td>
|
||||||
|
<?php }?>
|
||||||
<td style="width:5%;">
|
<td style="width:5%;">
|
||||||
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>">
|
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>" <?= (!isset($reorder) && $purchase['purchase_order_id'] > 0) ? 'max="' . $purchasechild['qty'] . '"' : '' ?> >
|
||||||
</td>
|
</td>
|
||||||
<?php if(!isset($reorder)) { ?>
|
<?php if(!isset($reorder)) { ?>
|
||||||
<td style="width:2%;">
|
<td style="width:2%;">
|
||||||
|
|||||||
@ -49,14 +49,13 @@
|
|||||||
<thead>
|
<thead>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>PO Id</th>
|
||||||
<th>Order Number</th>
|
<th>Order Number</th>
|
||||||
<th>Vendor Name</th>
|
<th>Vendor Name</th>
|
||||||
<th>Order Date</th>
|
<th>Order Date</th>
|
||||||
<th>Contact Details</th>
|
<th>Contact Details</th>
|
||||||
<!-- <th>Contact Person Mobile</th> -->
|
<!-- <th>Contact Person Mobile</th> -->
|
||||||
<th>Items</th>
|
<th>Items Details</th>
|
||||||
<th>Qty</th>
|
|
||||||
<th>Received Items</th>
|
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -64,16 +63,20 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<?php foreach ($purchase as $index => $value) :
|
<?php foreach ($purchase as $index => $value) :
|
||||||
|
|
||||||
if ($value['isactive'] == 1) : ?>
|
if ($value['isactive'] == 1) : ?>
|
||||||
<tr class="purchase_tr_<?php echo $index+1;?>">
|
<tr class="purchase_tr_<?php echo $index+1;?>">
|
||||||
|
<td><?= $value['purchase_order_id']; ?></td>
|
||||||
<td><?= $value['order_number']; ?></td>
|
<td><?= $value['order_number']; ?></td>
|
||||||
<td><?= $value['vendor_name']; ?></td>
|
<td><?= $value['vendor_name']; ?></td>
|
||||||
<td><?= date('j F Y', strtotime($value['order_date'])); ?></td>
|
<td><?= date('j F Y', strtotime($value['order_date'])); ?></td>
|
||||||
<td><?= $value['contact_person_name']; ?><br>
|
<td><?= $value['contact_person_name']; ?><br>
|
||||||
<?= $value['contact_person_mobile']; ?>
|
<?= $value['contact_person_mobile']; ?>
|
||||||
<td><?= $value['product_count']; ?></td>
|
</td>
|
||||||
<td><?= $value['purchase_qty'] ?></td>
|
<td><?= "Product : <b>".$value['product_count']." </b>"; ?><br>
|
||||||
<td><?= $value['selected_product_count']; ?></td>
|
<?= "Tot Qty : <b>".$value['purchase_qty']." </b>"; ?><br>
|
||||||
|
<?= (isset($value['received_qty']) && $value['received_qty'] != '')? "Rcvd Qty : <b>".$value['received_qty']." </b>" : "Rcvd Qty : <b>0 </b>"; ?>
|
||||||
|
</td>
|
||||||
<td class="<?php
|
<td class="<?php
|
||||||
if ($value['status'] == 'Cancel') {
|
if ($value['status'] == 'Cancel') {
|
||||||
echo 'cancelled-status';
|
echo 'cancelled-status';
|
||||||
@ -130,7 +133,13 @@
|
|||||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||||
"language": {
|
"language": {
|
||||||
"search": "Search: " // Customize search label
|
"search": "Search: " // Customize search label
|
||||||
},
|
}, "columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": [0], // Target the first column (PO Id)
|
||||||
|
"visible": false, // Hide the column
|
||||||
|
"searchable": false // Make it non-searchable (optional)
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,15 +41,11 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- <h4 class="header-title">Business List</h4> -->
|
<!-- <h4 class="header-title">Business List</h4> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<table id="datatable-sales-order" class="table table-striped dt-responsive nowrap w-100"
|
<table id="datatable-sales-order" class="table table-striped dt-responsive nowrap w-100"
|
||||||
style="width:100% !important;">
|
style="width:100% !important;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Sales Order Id</th>
|
||||||
<th>Order Number</th>
|
<th>Order Number</th>
|
||||||
<th>Reg No</th>
|
<th>Reg No</th>
|
||||||
<th>Client Name</th>
|
<th>Client Name</th>
|
||||||
@ -69,6 +65,7 @@
|
|||||||
foreach ($sales as $index => $value) :
|
foreach ($sales as $index => $value) :
|
||||||
if ($value['isactive'] == 1) : ?>
|
if ($value['isactive'] == 1) : ?>
|
||||||
<tr class="sale_tr_<?php echo $index+1; ?>">
|
<tr class="sale_tr_<?php echo $index+1; ?>">
|
||||||
|
<td><?= $value['sales_order_id']; ?></td>
|
||||||
<td><?= $value['order_number']; ?></td>
|
<td><?= $value['order_number']; ?></td>
|
||||||
<td><?= $value['reg_no']; ?></td>
|
<td><?= $value['reg_no']; ?></td>
|
||||||
<td><?= $value['client_name']; ?></td>
|
<td><?= $value['client_name']; ?></td>
|
||||||
@ -125,17 +122,28 @@
|
|||||||
var datatable_sales_order ='';
|
var datatable_sales_order ='';
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
datatable_sales_order = $('#datatable-sales-order').DataTable({
|
|
||||||
"order": [[0, 'desc']], // Set initial sorting to descending on the first column
|
datatable_sales_order = $('#datatable-sales-order').DataTable({
|
||||||
"dom": 'Bfrtip', // Show export buttons
|
"order": [[0, 'desc']], // Sort by Sales Order Id (hidden column)
|
||||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
"dom": 'Bfrtip', // Show export buttons
|
||||||
{extend: 'print',title: 'Products',text: 'Print',},
|
"buttons": [
|
||||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
|
||||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
{extend: 'print', title: 'Products', text: 'Print'},
|
||||||
"language": {
|
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
|
||||||
"search": "Search: " // Customize search label
|
{extend: 'csv', text: 'CSV', title: 'Products'}
|
||||||
},
|
],
|
||||||
});
|
"language": {
|
||||||
|
"search": "Search: " // Customize search label
|
||||||
|
},
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": [0], // Target the first column (Sales Order Id)
|
||||||
|
"visible": false, // Hide the column
|
||||||
|
"searchable": false // Make it non-searchable (optional)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Start DataTable Paging is session is set
|
//Start DataTable Paging is session is set
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user