Product quantity Adjustment : GWM
This commit is contained in:
parent
3dfd9e5595
commit
c77c9ea534
@ -1062,10 +1062,10 @@ class Jobcard extends BaseController
|
||||
$product = $JobcardProductModel->find($product_id);
|
||||
$qty = isset($product['issued_qty']) ? $product['issued_qty'] : 0;
|
||||
if ($status == 'Issued') {
|
||||
// $this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
// $this->subractProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
}elseif ($status == 'Cancelled'){
|
||||
|
||||
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
$this->subractProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
$data['status'] = 0;
|
||||
// echo $product['job_card_product_id'];die;
|
||||
// $JobcardProductModel->where('job_card_product_id',$product['job_card_product_id'])->update($data);
|
||||
@ -1078,26 +1078,41 @@ class Jobcard extends BaseController
|
||||
{
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty + $sold_qty;
|
||||
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
|
||||
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
|
||||
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
private function subractProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty - $sold_qty;
|
||||
|
||||
$data['qty_stock'] = $product['qty_stock'] - $sold_qty;
|
||||
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
|
||||
public function delete_sales_product()
|
||||
|
||||
@ -326,19 +326,25 @@ class Purchase extends BaseController
|
||||
}
|
||||
|
||||
|
||||
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty + $sold_qty;
|
||||
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
}
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
|
||||
public function delete_purchase($purchase_order_id)
|
||||
{
|
||||
|
||||
@ -242,18 +242,24 @@ class ReturnOrder extends BaseController
|
||||
|
||||
|
||||
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
{
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty + $sold_qty;
|
||||
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
}
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
|
||||
public function delete_purchase($purchase_order_id)
|
||||
{
|
||||
|
||||
@ -145,6 +145,8 @@ class Sales extends BaseController
|
||||
$SalesOrderModel = new SalesOrderModel();
|
||||
$ProductModel = new ProductModel();
|
||||
$SalesOrderProductModel = new SalesOrderProductModel(); // Assuming you have a model for sales_order_product
|
||||
|
||||
|
||||
|
||||
// Prepare data for sales order
|
||||
$data = [
|
||||
@ -169,7 +171,6 @@ class Sales extends BaseController
|
||||
// Insert or update sales order
|
||||
$sales_order_id = $this->request->getPost('sales_order_id');
|
||||
if (!empty($sales_order_id)) {
|
||||
// print_r("hello");die;
|
||||
if ($this->request->getPost('status') === "Paid") {
|
||||
$data['mode_of_payment'] = $this->request->getPost('mode_of_payment');
|
||||
}
|
||||
@ -177,12 +178,13 @@ class Sales extends BaseController
|
||||
} else {
|
||||
$SalesOrderModel->insert($data);
|
||||
$sales_order_id = $SalesOrderModel->getInsertID(); // Get the last inserted ID
|
||||
|
||||
// Update sales order with generated order number
|
||||
$orderNumber = 'SO-' . date('md') . '-' . str_pad($sales_order_id, 5, '0', STR_PAD_LEFT);
|
||||
$SalesOrderModel->update($sales_order_id, ['order_number' => $orderNumber]);
|
||||
}
|
||||
|
||||
$orderNumber = 'SO-' . date('md') . '-' . str_pad($sales_order_id, 5, '0', STR_PAD_LEFT);
|
||||
|
||||
// Update sales order with generated order number
|
||||
$SalesOrderModel->update($sales_order_id, ['order_number' => $orderNumber]);
|
||||
|
||||
|
||||
// Prepare data for sales order product
|
||||
$product_ids = $this->request->getPost('item_details');
|
||||
@ -200,12 +202,8 @@ class Sales extends BaseController
|
||||
foreach ($product_ids as $key => $product_id) {
|
||||
$qty = isset($quantities[$key]) ? $quantities[$key] : 0;
|
||||
if ($status == 'Created') {
|
||||
// echo "hello";die;
|
||||
$this->updateProductQuantity($ProductModel, $product_id, $qty);
|
||||
$this->subractProductQuantity($ProductModel, $product_id, $qty);
|
||||
}elseif ($status == 'Cancelled'){
|
||||
// echo "cancel";die;
|
||||
|
||||
// echo"hello";die;
|
||||
$this->addBackProductQuantity($ProductModel, $product_id, $qty);
|
||||
}
|
||||
|
||||
@ -247,29 +245,43 @@ class Sales extends BaseController
|
||||
|
||||
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty + $sold_qty;
|
||||
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
|
||||
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
|
||||
private function subractProductQuantity($ProductModel, $product_id, $sold_qty)
|
||||
{
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
|
||||
// Fetch current product quantity
|
||||
$product = $ProductModel->find($product_id);
|
||||
$current_qty = $product['qty_stock'];
|
||||
|
||||
// Calculate updated quantity
|
||||
$new_qty = $current_qty - $sold_qty;
|
||||
|
||||
$data['qty_stock'] = $product['qty_stock'] - $sold_qty;
|
||||
|
||||
if($product['per'] == 'barrel')
|
||||
{
|
||||
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
|
||||
}
|
||||
else if($product['per'] == 'box')
|
||||
{
|
||||
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
|
||||
}
|
||||
|
||||
// Update quantity in Product table
|
||||
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
|
||||
$ProductModel->update($product_id, $data );
|
||||
}
|
||||
|
||||
public function delete_sales_product()
|
||||
|
||||
@ -1,5 +1,56 @@
|
||||
|
||||
|
||||
<!-- <div class="loader" style="display:none;">
|
||||
<div class="loader-inner" >
|
||||
<div class="gear">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<div class="gear gear-two">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<div class="gear gear-three">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div id="loader" style="display:none;">
|
||||
|
||||
<div class="gear">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<!-- <div class="gear gear-two">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<div class="gear gear-three">
|
||||
<div class="center"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Footer Start -->
|
||||
|
||||
@ -71,6 +71,135 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
.gear {
|
||||
position: absolute;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: auto;
|
||||
background: #198;
|
||||
border-radius: 50%;
|
||||
animation-name: spin;
|
||||
animation-duration:6s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-timing-function: linear;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
.gear .center {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
z-index: 10;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.bar {
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
left: 28px;
|
||||
z-index: 1;
|
||||
width: 22px;
|
||||
height: 100px;
|
||||
background: #198;
|
||||
}
|
||||
.bar:nth-child(2) {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.bar:nth-child(3) {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
.bar:nth-child(4) {
|
||||
transform: rotate(135deg);
|
||||
}
|
||||
|
||||
.gear-two {
|
||||
left: -90px;
|
||||
top: 68px;
|
||||
width: 55px;
|
||||
height: 55px;
|
||||
background: #f58bb6;
|
||||
animation-name: spin-reverse;
|
||||
}
|
||||
.gear-two .bar {
|
||||
background: #f58bb6;
|
||||
width: 14px;
|
||||
height: 70px;
|
||||
left: 20px;
|
||||
top: -8px;
|
||||
}
|
||||
.gear-two .center {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
left: 13px;
|
||||
top: 13px;
|
||||
}
|
||||
.gear-three {
|
||||
left: 90px;
|
||||
top: 68px;
|
||||
width: 55px;
|
||||
height: 55px;
|
||||
background: #576e81;
|
||||
animation-name: spin-reverse;
|
||||
}
|
||||
.gear-three .bar {
|
||||
background: #576e81;
|
||||
width: 14px;
|
||||
height: 70px;
|
||||
left: 20px;
|
||||
top: -8px;
|
||||
}
|
||||
.gear-three .center {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
left: 13px;
|
||||
top: 13px;
|
||||
}
|
||||
|
||||
@-webkit-keyframes spin {
|
||||
50% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
50% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes spin-reverse {
|
||||
50% {
|
||||
-webkit-transform: rotate(-360deg);
|
||||
transform: rotate(-360deg);
|
||||
}
|
||||
}
|
||||
@keyframes spin-reverse {
|
||||
50% {
|
||||
-webkit-transform: rotate(-360deg);
|
||||
transform: rotate(-360deg);
|
||||
}
|
||||
}
|
||||
|
||||
#loader {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgb(0 0 0 / 5%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999; /* Ensure it appears on top of other content */
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<script>
|
||||
toastr.options = {
|
||||
|
||||
@ -434,7 +434,7 @@ $(document).ready(function() {
|
||||
$('#makeSelectMessage').hide();
|
||||
|
||||
// AJAX request to get models based on the selected make ID
|
||||
// $('.loader-section').show();
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
@ -464,7 +464,7 @@ $(document).ready(function() {
|
||||
// Handle case when no models are found
|
||||
$('#model').empty().append('<option value="">No models found</option>');
|
||||
}
|
||||
// $('.loader-section').hide();
|
||||
$('#loader').hide();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
|
||||
Loading…
Reference in New Issue
Block a user