Purchase Changes support

This commit is contained in:
VE10-Sanjeev 2025-01-06 05:49:27 +00:00
parent 692b6ff9b8
commit fb0a825faf
9 changed files with 82 additions and 36 deletions

View File

@ -43,6 +43,14 @@ class Products extends BaseController
$ProductCategoryModel = new ProductCategoryModel();
$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;
return view('product_categories',$data);
}

View File

@ -206,6 +206,12 @@ class Purchase extends BaseController
$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;

View File

@ -10,11 +10,11 @@ class PurchaseOrderModel extends Model
public function getPurchaseOrdersWithProducts($logged_user_branch_id)
{
// 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
$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
$this->groupBy('purchase_order.purchase_order_id');

View File

@ -36,7 +36,7 @@ class SalesOrderModel extends Model
// Add condition to fetch only active sales orders
$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
return $this->findAll();
}

View File

@ -44,15 +44,12 @@
<div class="card-body">
<!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-jobcard" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
<tr>
<th>Job Card</th>
<th>Order Number</th>
<th>Vehicle No</th>
<th>Client</th>
@ -67,6 +64,7 @@
<tbody>
<?php foreach ($jobs as $index => $value) : if ($value['isactive'] == 1) : ?>
<tr class="job_tr_<?php echo $index+1; ?>">
<td><?= $value['job_card_id']; ?></td>
<td><?= $value['order_number']; ?></td>
<td><?= $value['reg_no']; ?></td>
<td><?= $value['client_name']; ?><br><?= $value['client_mobile_no']; ?></td>
@ -182,6 +180,13 @@
"language": {
"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)
}
]
});

View File

@ -25,6 +25,7 @@
<thead>
<tr>
<th>Product Category</th>
<th>Total Product</th>
<th>Status</th>
<th>Products</th>
</tr>
@ -33,6 +34,7 @@
<?php foreach ($productcategory as $index => $item): ?>
<tr class="productcategory_tr_<?php echo $index+1; ?>">
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
<td><?php echo $item['total_product']; ?></td>
<td>
<?php if($item['isactive'] == 1): ?>
<span style="color:green">Active</span>

View File

@ -149,11 +149,14 @@
<thead>
<tr>
<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>Amount</th>
<?php endif; ?>
<?php }else{ ?>
<th>Qty</th>
<?php } ?>
<th hidden></th>
<th></th>
</tr>
@ -184,8 +187,13 @@
<?php endforeach; ?>
</select>
</td>
<?php if(!isset($reorder)) { ?>
<td style="width:2%;">
<?php echo $purchasechild['qty']; ?>
</td>
<?php }?>
<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>
<?php if(!isset($reorder)) { ?>
<td style="width:2%;">

View File

@ -49,31 +49,34 @@
<thead>
<tr>
<th>PO Id</th>
<th>Order Number</th>
<th>Vendor Name</th>
<th>Order Date</th>
<th>Contact Details</th>
<!-- <th>Contact Person Mobile</th> -->
<th>Items</th>
<th>Qty</th>
<th>Received Items</th>
<th>Items Details</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($purchase as $index => $value) :
if ($value['isactive'] == 1) : ?>
<tr class="purchase_tr_<?php echo $index+1;?>">
<td><?= $value['purchase_order_id']; ?></td>
<td><?= $value['order_number']; ?></td>
<td><?= $value['vendor_name']; ?></td>
<td><?= date('j F Y', strtotime($value['order_date'])); ?></td>
<td><?= $value['contact_person_name']; ?><br>
<?= $value['contact_person_mobile']; ?>
<td><?= $value['product_count']; ?></td>
<td><?= $value['purchase_qty'] ?></td>
<td><?= $value['selected_product_count']; ?></td>
<?= $value['contact_person_mobile']; ?>
</td>
<td><?= "Product : <b>".$value['product_count']." </b>"; ?><br>
<?= "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
if ($value['status'] == 'Cancel') {
echo 'cancelled-status';
@ -130,7 +133,13 @@
{extend: 'csv',text: 'CSV', title: 'Products', }],
"language": {
"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)
}
]
});

View File

@ -41,15 +41,11 @@
<div class="card">
<div class="card-body">
<!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-sales-order" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
<tr>
<th>Sales Order Id</th>
<th>Order Number</th>
<th>Reg No</th>
<th>Client Name</th>
@ -69,6 +65,7 @@
foreach ($sales as $index => $value) :
if ($value['isactive'] == 1) : ?>
<tr class="sale_tr_<?php echo $index+1; ?>">
<td><?= $value['sales_order_id']; ?></td>
<td><?= $value['order_number']; ?></td>
<td><?= $value['reg_no']; ?></td>
<td><?= $value['client_name']; ?></td>
@ -125,17 +122,28 @@
var datatable_sales_order ='';
$(document).ready(function() {
datatable_sales_order = $('#datatable-sales-order').DataTable({
"order": [[0, 'desc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
{extend: 'print',title: 'Products',text: 'Print',},
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
{extend: 'csv',text: 'CSV', title: 'Products', }],
"language": {
"search": "Search: " // Customize search label
},
});
datatable_sales_order = $('#datatable-sales-order').DataTable({
"order": [[0, 'desc']], // Sort by Sales Order Id (hidden column)
"dom": 'Bfrtip', // Show export buttons
"buttons": [
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
{extend: 'print', title: 'Products', text: 'Print'},
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
{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