diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 99e3a4c..d359936 100755 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -481,7 +481,8 @@ class Jobcard extends BaseController public function new_jobcard($job_card_id,$rework = null) { if ($job_card_id === '0') { - $data['page_name']="Create Job Card"; + + $data['page_name']="Create Job Card"; $data['jobs'] = []; $data['jobcardfiles'] = []; $ClientModel = new ClientModel(); @@ -684,13 +685,14 @@ class Jobcard extends BaseController $data['logged_user_role'] = $this->session->get('logged_user_role'); if($rework == 're-work') { $data['rework']= true; } - if($this->session->get('logged_user_role') == "Floor Manager") - { - $RoleModel = new RoleModel(); - $data['workers'] = $RoleModel->get_workers($this->session->get('logged_user_branch_id')); + - } + + } + + $RoleModel = new RoleModel(); + $data['workers'] = $RoleModel->get_workers($this->session->get('logged_user_branch_id')); $data['job_card_id'] = $job_card_id; $bikeMakeModel = new BikeMakeModel(); $data['makeData'] =$bikeMakeModel->findAll(); @@ -703,13 +705,8 @@ class Jobcard extends BaseController public function add_jobs() { - // echo $this->request->getPost('issued_items');die; - // echo $this->request->getPost('products');die; - // echo $this->request->getPost('delete_items');die; - // echo $this->request->getPost('issued_items');die; - // echo json_encode($this->request->getPost());die; - // echo "
";
- // print_r($this->request->getPost());die;
+
+ // dd($this->request->getPost());
$JobcardModel = new JobcardModel();
if($this->session->get('logged_user_role') == "Store Manager") {
$data['status'] = $this->request->getPost('status');
@@ -749,14 +746,14 @@ class Jobcard extends BaseController
'note'=> $this->request->getPost('note'),
'status'=> $this->request->getPost('status'),
'assigned_to'=> json_encode($this->request->getPost('assigned_to')),
- 'subtotal'=> $this->request->getPost('sub_total'), // (isset($rework) ? 0 : $this->request->getPost('sub_total') ),
- 'tax'=> $this->request->getPost('invoicetax'), //(isset($rework) ? 0 : $this->request->getPost('invoicetax') ),
- 'discount'=> $this->request->getPost('discount'), //($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
- 'total'=> $this->request->getPost('grand_total'), //(isset($rework) ? 0 : $this->request->getPost('grand_total') ),
+ 'trial_mechanic'=> $this->request->getPost('trial_mechanic'),
+ 'subtotal'=> $this->request->getPost('sub_total'),
+ 'tax'=> $this->request->getPost('invoicetax'),
+ 'discount'=> $this->request->getPost('discount'),
+ 'total'=> $this->request->getPost('grand_total'),
'isactive' => 1
];
- // echo "";
- // print_r($job_card_data);die;
+
$status = $this->request->getPost('status');
// Insert or update sales order
$job_card_id = $this->request->getPost('job_card_id');
@@ -784,17 +781,13 @@ class Jobcard extends BaseController
$orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
}
- // print_r($orderNumber);die;
- // Update sales order with generated order number
+
}
/********** INSERT SERVICE DATA ************/
$data = json_decode($_POST['products']);
$service_data = $data[0]->service;
- // echo "";
- // print_r($service_data);die;
-
foreach ($service_data as $item) {
// Insert into the service table
$service['job_card_id'] = $job_card_id;
@@ -1148,10 +1141,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);
@@ -1164,26 +1157,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()
diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php
index 9f583fc..ece7133 100755
--- a/app/Controllers/Products.php
+++ b/app/Controllers/Products.php
@@ -151,12 +151,15 @@ class Products extends BaseController
$ProductModel = new ProductModel();
$tax= $this->request->getPost('tax')/2;
- // print_r($this->request->getPost());die;
-
- if ($this->request->getPost('per') != 'ml') {
- $ml = 0;
- }else{
+ $ml = 0; $box = 0; $qty_per_box = 0; $barrel = 0; $ltr_per_barrel = 0;
+ if ($this->request->getPost('per') == 'ml') {
$ml = $this->request->getPost('ml');
+ }else if ($this->request->getPost('per') == 'box'){
+ $box = $this->request->getPost('box');
+ $qty_per_box = $this->request->getPost('qty_per_box');
+ }else if ($this->request->getPost('per') == 'barrel'){
+ $barrel = $this->request->getPost('barrel');
+ $ltr_per_barrel = $this->request->getPost('ltr_per_barrel');
}
$data = [
@@ -170,7 +173,6 @@ class Products extends BaseController
'cgst' => $tax,
'purchase_cost' => $this->request->getPost('purchase_cost'),
'qty_stock'=> $this->request->getPost('qty_in_stock'),
- 'qty_in_demand'=> $this->request->getPost('qty_in_demand'),
'description' => $this->request->getPost('description'),
'vendor' =>json_encode( $this->request->getPost('vendor')),
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
@@ -188,7 +190,11 @@ class Products extends BaseController
'total_amount' => $this->request->getPost('total_amount'),
'per' => $this->request->getPost('per'),
- 'ml' => $ml
+ 'ml' => $ml,
+ 'box' => $box,
+ 'qty_per_box' => $qty_per_box,
+ 'barrel' => $barrel,
+ 'ltr_per_barrel' => $ltr_per_barrel
];
$product_id = $this->request->getPost('product_id');
diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php
index d6d9445..a5c1b66 100755
--- a/app/Controllers/Purchase.php
+++ b/app/Controllers/Purchase.php
@@ -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)
{
diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php
index 70ba8fe..9584235 100755
--- a/app/Controllers/ReturnOrder.php
+++ b/app/Controllers/ReturnOrder.php
@@ -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)
{
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index 796aa3e..8b3f285 100755
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -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()
diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php
index 009a23a..25caa33 100755
--- a/app/Models/JobcardModel.php
+++ b/app/Models/JobcardModel.php
@@ -9,7 +9,7 @@ class JobcardModel extends Model
'order_number','client_mobile_no','client_name',
'billing_address','billing_city','billing_state','billing_country',
'billing_postal_code','fuel_qty', 'meter', 'delivery_date', 'note',
- 'status','assigned_to', 'is_rework','subtotal','tax', 'discount','total','isactive','mode_of_payment'];
+ 'status','assigned_to', 'is_rework','subtotal','tax', 'discount','total','isactive','mode_of_payment','trial_mechanic'];
diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php
index b903059..b8e6f6c 100755
--- a/app/Models/ProductModel.php
+++ b/app/Models/ProductModel.php
@@ -9,7 +9,7 @@ class ProductModel extends Model
'quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level',
'unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level',
'handler','qty_in_demand','product_image','description','specification','hsn_sac','isactive','total_amount',
- 'per','ml'];
+ 'per','ml','box','qty_per_box','barrel','ltr_per_barrel'];
public function getTax()
diff --git a/app/Models/RoleModel.php b/app/Models/RoleModel.php
index e300cb2..4bde616 100755
--- a/app/Models/RoleModel.php
+++ b/app/Models/RoleModel.php
@@ -21,7 +21,7 @@ class RoleModel extends Model
$this->join('users', 'users.role = roles.role_id');
$this->where('roles.isactive', 1);
$this->where('users.isactive', 1);
- $this->whereIn('roles.roles', ['Mechanic','Helper']);
+ $this->whereIn('roles.roles', ['Senior Mechanic','Mechanic','Helper']);
$this ->where('users.branch_id',$logged_user_branch_id);
return $this->findAll();
}
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 9623e56..c2ebe21 100755
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -22,17 +22,28 @@
top:4px;
}
- .select2-container .select2-selection--multiple{
- height: 36px;
- border:1px solid #ced4da;
- }
- .select2-container--default .select2-selection--multiple .select2-selection__rendered{
- line-height: 36px;
- }
- .select2-container--default .select2-selection--multiple .select2-selection__arrow{
- top:4px;
- }
+
+
@@ -153,20 +164,36 @@
-
+
+
-
+
+
+
+
+ = isset($jobs['trial_mechanic']) ? '' : '' ?>
+
+
+
+
+
+
+
+
@@ -2080,14 +2107,14 @@ $closestTR.remove();