diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 8d6d34a..5a267c5 100755 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -11,7 +11,7 @@ use App\Models\JobcardServiceModel; use App\Models\JobcardProductModel; use App\Models\JobcardSubServiceModel; use App\Models\ProductModel; -use App\Models\ServiceModel; +use App\Models\ServicesModel; use App\Models\ClientModel; use App\Models\ComplaintModel; use App\Models\OutsourceModel; @@ -71,7 +71,7 @@ class Jobcard extends BaseController $this->JobcardProductModel = new JobcardProductModel(); $this->JobcardSubServiceModel = new JobcardSubServiceModel(); $this->ProductModel = new ProductModel(); - $this->ServiceModel = new ServiceModel(); + $this->ServiceModel = new ServicesModel(); $this->ClientModel = new ClientModel(); $this->ComplaintModel = new ComplaintModel(); $this->OutsourceModel = new OutsourceModel(); @@ -492,7 +492,9 @@ class Jobcard extends BaseController - + $type = $this->JobcardModel->select('job_card.type') + ->where('job_card.job_card_id', $job_card_id) + ->get()->getRow()->type; /*** SERVICE DATA ***/ $servicedata = $this->JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id')); // Using '&' to reference the original array element @@ -616,14 +618,32 @@ class Jobcard extends BaseController $encodedMakeId1 = 0; $encodedModelId1 = 0; - - $services2 = $this->ServiceModel->where('cubic_capacity_id', $ccId) - ->findAll(); - // $service = array_merge($common_services, $service1); + $selectServiceString = ($type == "With General") ? "services.wg_price,services.wg_labour_cost as labour_cost" : "services.wog_price,services.wog_labour_cost as labour_cost"; + + // Query the database to find the service - cubic_capacity_id .. category 1 na standlone and ccId must + $service1 = $this->ServiceModel->select('services.service_id,services.branch_id,services.cubic_capacity_id,services.service_name,services.category,services.tax,services.cgst,services.sgst,services.description, services.product_id,services.sub_service_id,services.created_at,services.created_by,services.updated_at,services.updated_by,services.isactive,cubic_capacity.value') + ->select($selectServiceString) + ->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left') + ->where('cubic_capacity_id', $ccId) + ->where('category',1) + ->where('services.isactive' ,1) + ->findAll(); + + + // Query the database to find the service - default values .. category 0 na common and ccId no need + $service2 = $this->ServiceModel->select('services.service_id,services.branch_id,services.cubic_capacity_id,services.service_name,services.category,services.tax,services.cgst,services.sgst,services.description, services.product_id,services.sub_service_id,services.created_at,services.created_by,services.updated_at,services.updated_by,services.isactive,cubic_capacity.value') + ->select($selectServiceString) + ->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left') + ->where('category',0) + ->where('services.isactive' ,1) + ->findAll(); + + // final service + $service = array_merge($service1, $service2); $data['product']=$product; - $data['service']=$services2; + $data['service_1']=$service; // echo "
";
// print_r($service);die;
$jobs_product= $this->JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
@@ -640,7 +660,7 @@ class Jobcard extends BaseController
-
+
}
@@ -680,6 +700,7 @@ class Jobcard extends BaseController
$job_card_data = [
'client_name' => $this->request->getPost('client_id'),
'client_mobile_no' => $this->request->getPost('mobile_no'),
+ 'type' => $this->request->getPost('type'),
'vehicle_id'=>$this->request->getPost('vehicle_id'),
'branch_id'=> $this->session->get('logged_user_branch_id'),
'billing_address' => $this->request->getPost('billing_address'),
@@ -1232,7 +1253,10 @@ class Jobcard extends BaseController
$ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
- $complaint = $this->ComplaintModel->where('cubic_capacity_id',$ccId)->where('isactive',1)->findAll();
+ // $complaint = $this->ComplaintModel->where('cubic_capacity_id',$ccId)
+ $complaint = $this->ComplaintModel->select('complaints.*,cubic_capacity.value')
+ ->join('cubic_capacity', 'cubic_capacity.id = complaints.cubic_capacity_id','left')
+ ->where('complaints.isactive',1)->findAll();
if($complaint){
// Send JSON response
@@ -1248,19 +1272,28 @@ class Jobcard extends BaseController
// Retrieve make_id and model_id from the request
$makeId = $this->request->getPost('make_id');
$modelId = $this->request->getPost('model_id');
+ $type = $this->request->getPost('type');
+ $selectServiceString = ($type == "With General") ? "services.wg_price,services.wg_labour_cost as labour_cost" : "services.wog_price,services.wog_labour_cost as labour_cost";
$ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
- // Query the database to find the service - cubic_capacity_id
- $service1 = $this->ServiceModel->where('cubic_capacity_id', $ccId)
+ // Query the database to find the service - cubic_capacity_id .. category 1 na standlone and ccId must
+ $service1 = $this->ServiceModel->select('services.service_id,services.branch_id,services.cubic_capacity_id,services.service_name,services.category,services.tax,services.cgst,services.sgst,services.description, services.product_id,services.sub_service_id,services.created_at,services.created_by,services.updated_at,services.updated_by,services.isactive,cubic_capacity.value')
+ ->select($selectServiceString)
+ ->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left')
+ ->where('cubic_capacity_id', $ccId)
->where('category',1)
- ->where('isactive' ,1)
+ ->where('services.isactive' ,1)
->findAll();
- // Query the database to find the service - default values
- $service2 = $this->ServiceModel->where('category',0)
- ->where('isactive' ,1)
- ->findAll();
+
+ // Query the database to find the service - default values .. category 0 na common and ccId no need
+ $service2 = $this->ServiceModel->select('services.service_id,services.branch_id,services.cubic_capacity_id,services.service_name,services.category,services.tax,services.cgst,services.sgst,services.description, services.product_id,services.sub_service_id,services.created_at,services.created_by,services.updated_at,services.updated_by,services.isactive,cubic_capacity.value')
+ ->select($selectServiceString)
+ ->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left')
+ ->where('category',0)
+ ->where('services.isactive' ,1)
+ ->findAll();
// final service
$service = array_merge($service1, $service2);
diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php
index cb34a95..9f859fb 100755
--- a/app/Controllers/Service.php
+++ b/app/Controllers/Service.php
@@ -2,7 +2,7 @@
namespace App\Controllers;
-use App\Models\ServiceModel;
+use App\Models\ServicesModel;
use App\Models\BikemakeModel;
use App\Models\VendorModel;
use App\Models\BikemodelsModel;
@@ -16,7 +16,7 @@ class Service extends BaseController
public $session;
protected $additionalProductNameModal;
- protected $ServiceModel;
+ protected $ServicesModel;
protected $BikemakeModel;
protected $vendorModel;
protected $BikemodelsModel;
@@ -29,7 +29,7 @@ class Service extends BaseController
$this->session = session();
$this->additionalProductNameModal = new AdditionalProductNameModal();
- $this->ServiceModel = new ServiceModel();
+ $this->ServicesModel = new ServicesModel();
$this->BikemakeModel = new BikemakeModel();
$this->vendorModel = new VendorModel();
$this->BikemodelsModel = new BikemodelsModel();
@@ -40,7 +40,7 @@ class Service extends BaseController
public function service_index()
{
- $services = $this->ServiceModel->select('services.*,cubic_capacity.value')
+ $services = $this->ServicesModel->select('services.*,cubic_capacity.value')
->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left')
->where('services.branch_id',$this->session->get('logged_user_branch_id'))
->orderBy('services.service_name','ASC')->findAll();
@@ -91,14 +91,13 @@ class Service extends BaseController
public function new_service($service_id)
{
-
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
->where('products.isactive', 1)
->findAll();
- $data['tax'] = $this->ServiceModel->getTax();
+ $data['tax'] = $this->ServicesModel->getTax();
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
if ($service_id === '0') {
@@ -107,12 +106,12 @@ class Service extends BaseController
$data['services'] = [];
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
$data['models'] = [];
- $data['service'] = $this->ServiceModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
+ $data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
} else if ($service_id !== '0') {
$data['page_name'] = "Edit Service";
- $services = $this->ServiceModel->where('service_id', $service_id)->get()->getRowArray();
+ $services = $this->ServicesModel->where('service_id', $service_id)->get()->getRowArray();
// $services['models_id'] = json_decode($services['models_id'], true);
// $services['makes_id'] = json_decode($services['makes_id'], true);
@@ -126,8 +125,8 @@ class Service extends BaseController
// $data['models'] = $models;
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
$data['services'] = $services;
- $data['service'] = $this->ServiceModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
-
+ $data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
+ // dd($data['service']);
}
$data['service_id'] = $service_id;
@@ -139,9 +138,9 @@ class Service extends BaseController
public function add_service()
{
$tax= $this->request->getPost('tax')/2;
- $final_price = ($this->request->getPost('productCost') ? $this->request->getPost('productCost') : 0) +
- ($this->request->getPost('serviceCost') ? $this->request->getPost('serviceCost') : 0) +
- ($this->request->getPost('labour_cost_With_Tax') ? $this->request->getPost('labour_cost_With_Tax') : 0);
+ // $final_price = ($this->request->getPost('productCost') ? $this->request->getPost('productCost') : 0) +
+ // ($this->request->getPost('serviceCost') ? $this->request->getPost('serviceCost') : 0) +
+ // ($this->request->getPost('labour_cost_With_Tax') ? $this->request->getPost('labour_cost_With_Tax') : 0);
// print $final_price;
// print_r($this->request->getPost());
@@ -159,9 +158,11 @@ class Service extends BaseController
'cgst' => $tax,
'sgst' => $tax,
'tax' => $this->request->getPost('tax'),
- 'labour_cost' => $this->request->getPost('labour_cost'),
- 'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
- 'price' => $final_price,
+ 'wg_labour_cost' => $this->request->getPost('wg_labour_cost'),
+ 'wog_labour_cost' => $this->request->getPost('wog_labour_cost'),
+ 'wg_price' => $this->request->getPost('wg_price_withtax'),
+ 'wog_price' => $this->request->getPost('wog_price_withtax'),
+ // 'price' => $final_price,
// 'makes_id' => $make_json,
// 'models_id' => $model_json,
'description' => $this->request->getPost('description'),
@@ -172,10 +173,10 @@ class Service extends BaseController
if (!empty($service_id))
{
- $this->ServiceModel->update($service_id, $data);
+ $this->ServicesModel->update($service_id, $data);
} else {
$data['branch_id'] = $this->session->get('logged_user_branch_id');
- $this->ServiceModel->insert($data);
+ $this->ServicesModel->insert($data);
}
@@ -186,12 +187,12 @@ class Service extends BaseController
{
$where = ['service_id' => $service_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
- $existingService = $this->ServiceModel->where($where)->first();
+ $existingService = $this->ServicesModel->where($where)->first();
if ($existingService) {
$data['isactive'] = 0;
- if ($this->ServiceModel->update($service_id, $data)) {
+ if ($this->ServicesModel->update($service_id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$service_id);
}
@@ -309,7 +310,7 @@ class Service extends BaseController
$data = [
'isactive' => $isactive
];
- $updated = $this->ServiceModel->update($service_id, $data);
+ $updated = $this->ServicesModel->update($service_id, $data);
if ($updated) {
$result = $data;
diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php
index 607b366..d40d6e4 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','trial_mechanic'];
+ 'status','assigned_to', 'is_rework','subtotal','tax', 'discount','total','isactive','mode_of_payment','trial_mechanic','type'];
diff --git a/app/Models/ServiceModel.php b/app/Models/ServiceModel.php
deleted file mode 100755
index fcdc13a..0000000
--- a/app/Models/ServiceModel.php
+++ /dev/null
@@ -1,28 +0,0 @@
-table('tax')->get();
-
- // Check if query returned results
- if ($query->resultID->num_rows > 0) {
- return $query->getResultArray();
- } else {
- return []; // Return an empty array if no tax data found
- }
- }
-
-}
-?>
\ No newline at end of file
diff --git a/app/Models/ServicesModel.php b/app/Models/ServicesModel.php
index 0c8febd..8e999aa 100755
--- a/app/Models/ServicesModel.php
+++ b/app/Models/ServicesModel.php
@@ -5,7 +5,23 @@ class ServicesModel extends Model
{
protected $table = 'services';
protected $primaryKey = 'service_id';
- protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive','cubic_capacity_id'];
+ protected $allowedFields = ['service_id','branch_id','category','service_name','wg_labour_cost','cgst','sgst','wg_price','wog_price','tax','wog_labour_cost','description','makes_id','models_id','product_id','sub_service_id','isactive','cubic_capacity_id'];
+
+ public function getTax()
+ {
+ // Get a database instance
+ $db = \Config\Database::connect();
+
+ // Query the tax table
+ $query = $db->table('tax')->get();
+
+ // Check if query returned results
+ if ($query->resultID->num_rows > 0) {
+ return $query->getResultArray();
+ } else {
+ return []; // Return an empty array if no tax data found
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 3340ec0..a9fba7f 100755
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -85,6 +85,19 @@
+
+
+
+
+
+
+
+
+
@@ -110,7 +123,7 @@
-
+
@@ -196,7 +209,7 @@
-