service and jobcard
This commit is contained in:
parent
18cb4b3a95
commit
f2f818a62b
@ -11,7 +11,7 @@ use App\Models\JobcardServiceModel;
|
|||||||
use App\Models\JobcardProductModel;
|
use App\Models\JobcardProductModel;
|
||||||
use App\Models\JobcardSubServiceModel;
|
use App\Models\JobcardSubServiceModel;
|
||||||
use App\Models\ProductModel;
|
use App\Models\ProductModel;
|
||||||
use App\Models\ServiceModel;
|
use App\Models\ServicesModel;
|
||||||
use App\Models\ClientModel;
|
use App\Models\ClientModel;
|
||||||
use App\Models\ComplaintModel;
|
use App\Models\ComplaintModel;
|
||||||
use App\Models\OutsourceModel;
|
use App\Models\OutsourceModel;
|
||||||
@ -71,7 +71,7 @@ class Jobcard extends BaseController
|
|||||||
$this->JobcardProductModel = new JobcardProductModel();
|
$this->JobcardProductModel = new JobcardProductModel();
|
||||||
$this->JobcardSubServiceModel = new JobcardSubServiceModel();
|
$this->JobcardSubServiceModel = new JobcardSubServiceModel();
|
||||||
$this->ProductModel = new ProductModel();
|
$this->ProductModel = new ProductModel();
|
||||||
$this->ServiceModel = new ServiceModel();
|
$this->ServiceModel = new ServicesModel();
|
||||||
$this->ClientModel = new ClientModel();
|
$this->ClientModel = new ClientModel();
|
||||||
$this->ComplaintModel = new ComplaintModel();
|
$this->ComplaintModel = new ComplaintModel();
|
||||||
$this->OutsourceModel = new OutsourceModel();
|
$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 ***/
|
/*** SERVICE DATA ***/
|
||||||
$servicedata = $this->JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
$servicedata = $this->JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||||
// Using '&' to reference the original array element
|
// Using '&' to reference the original array element
|
||||||
@ -617,13 +619,31 @@ class Jobcard extends BaseController
|
|||||||
$encodedMakeId1 = 0;
|
$encodedMakeId1 = 0;
|
||||||
$encodedModelId1 = 0;
|
$encodedModelId1 = 0;
|
||||||
|
|
||||||
$services2 = $this->ServiceModel->where('cubic_capacity_id', $ccId)
|
$selectServiceString = ($type == "With General") ? "services.wg_price,services.wg_labour_cost as labour_cost" : "services.wog_price,services.wog_labour_cost as labour_cost";
|
||||||
->findAll();
|
|
||||||
// $service = array_merge($common_services, $service1);
|
|
||||||
|
|
||||||
|
// 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['product']=$product;
|
||||||
$data['service']=$services2;
|
$data['service_1']=$service;
|
||||||
// echo "<pre>";
|
// echo "<pre>";
|
||||||
// print_r($service);die;
|
// print_r($service);die;
|
||||||
$jobs_product= $this->JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
|
$jobs_product= $this->JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
|
||||||
@ -680,6 +700,7 @@ class Jobcard extends BaseController
|
|||||||
$job_card_data = [
|
$job_card_data = [
|
||||||
'client_name' => $this->request->getPost('client_id'),
|
'client_name' => $this->request->getPost('client_id'),
|
||||||
'client_mobile_no' => $this->request->getPost('mobile_no'),
|
'client_mobile_no' => $this->request->getPost('mobile_no'),
|
||||||
|
'type' => $this->request->getPost('type'),
|
||||||
'vehicle_id'=>$this->request->getPost('vehicle_id'),
|
'vehicle_id'=>$this->request->getPost('vehicle_id'),
|
||||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||||
'billing_address' => $this->request->getPost('billing_address'),
|
'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;
|
$ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
|
||||||
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
$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){
|
if($complaint){
|
||||||
// Send JSON response
|
// Send JSON response
|
||||||
@ -1248,18 +1272,27 @@ class Jobcard extends BaseController
|
|||||||
// Retrieve make_id and model_id from the request
|
// Retrieve make_id and model_id from the request
|
||||||
$makeId = $this->request->getPost('make_id');
|
$makeId = $this->request->getPost('make_id');
|
||||||
$modelId = $this->request->getPost('model_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;
|
$ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
|
||||||
|
|
||||||
// Query the database to find the service - cubic_capacity_id
|
// Query the database to find the service - cubic_capacity_id .. category 1 na standlone and ccId must
|
||||||
$service1 = $this->ServiceModel->where('cubic_capacity_id', $ccId)
|
$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('category',1)
|
||||||
->where('isactive' ,1)
|
->where('services.isactive' ,1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
// Query the database to find the service - default values
|
|
||||||
$service2 = $this->ServiceModel->where('category',0)
|
// Query the database to find the service - default values .. category 0 na common and ccId no need
|
||||||
->where('isactive' ,1)
|
$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();
|
->findAll();
|
||||||
|
|
||||||
// final service
|
// final service
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Models\ServiceModel;
|
use App\Models\ServicesModel;
|
||||||
use App\Models\BikemakeModel;
|
use App\Models\BikemakeModel;
|
||||||
use App\Models\VendorModel;
|
use App\Models\VendorModel;
|
||||||
use App\Models\BikemodelsModel;
|
use App\Models\BikemodelsModel;
|
||||||
@ -16,7 +16,7 @@ class Service extends BaseController
|
|||||||
|
|
||||||
public $session;
|
public $session;
|
||||||
protected $additionalProductNameModal;
|
protected $additionalProductNameModal;
|
||||||
protected $ServiceModel;
|
protected $ServicesModel;
|
||||||
protected $BikemakeModel;
|
protected $BikemakeModel;
|
||||||
protected $vendorModel;
|
protected $vendorModel;
|
||||||
protected $BikemodelsModel;
|
protected $BikemodelsModel;
|
||||||
@ -29,7 +29,7 @@ class Service extends BaseController
|
|||||||
|
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
||||||
$this->ServiceModel = new ServiceModel();
|
$this->ServicesModel = new ServicesModel();
|
||||||
$this->BikemakeModel = new BikemakeModel();
|
$this->BikemakeModel = new BikemakeModel();
|
||||||
$this->vendorModel = new VendorModel();
|
$this->vendorModel = new VendorModel();
|
||||||
$this->BikemodelsModel = new BikemodelsModel();
|
$this->BikemodelsModel = new BikemodelsModel();
|
||||||
@ -40,7 +40,7 @@ class Service extends BaseController
|
|||||||
public function service_index()
|
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')
|
->join('cubic_capacity', 'cubic_capacity.id = services.cubic_capacity_id','left')
|
||||||
->where('services.branch_id',$this->session->get('logged_user_branch_id'))
|
->where('services.branch_id',$this->session->get('logged_user_branch_id'))
|
||||||
->orderBy('services.service_name','ASC')->findAll();
|
->orderBy('services.service_name','ASC')->findAll();
|
||||||
@ -91,14 +91,13 @@ class Service extends BaseController
|
|||||||
|
|
||||||
public function new_service($service_id)
|
public function new_service($service_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||||
->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
|
->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
|
||||||
->where('products.isactive', 1)
|
->where('products.isactive', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$data['tax'] = $this->ServiceModel->getTax();
|
$data['tax'] = $this->ServicesModel->getTax();
|
||||||
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
|
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
|
||||||
|
|
||||||
if ($service_id === '0') {
|
if ($service_id === '0') {
|
||||||
@ -107,12 +106,12 @@ class Service extends BaseController
|
|||||||
$data['services'] = [];
|
$data['services'] = [];
|
||||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
||||||
$data['models'] = [];
|
$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') {
|
} else if ($service_id !== '0') {
|
||||||
|
|
||||||
$data['page_name'] = "Edit Service";
|
$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['models_id'] = json_decode($services['models_id'], true);
|
||||||
// $services['makes_id'] = json_decode($services['makes_id'], true);
|
// $services['makes_id'] = json_decode($services['makes_id'], true);
|
||||||
|
|
||||||
@ -126,8 +125,8 @@ class Service extends BaseController
|
|||||||
// $data['models'] = $models;
|
// $data['models'] = $models;
|
||||||
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
||||||
$data['services'] = $services;
|
$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;
|
$data['service_id'] = $service_id;
|
||||||
|
|
||||||
@ -139,9 +138,9 @@ class Service extends BaseController
|
|||||||
public function add_service()
|
public function add_service()
|
||||||
{
|
{
|
||||||
$tax= $this->request->getPost('tax')/2;
|
$tax= $this->request->getPost('tax')/2;
|
||||||
$final_price = ($this->request->getPost('productCost') ? $this->request->getPost('productCost') : 0) +
|
// $final_price = ($this->request->getPost('productCost') ? $this->request->getPost('productCost') : 0) +
|
||||||
($this->request->getPost('serviceCost') ? $this->request->getPost('serviceCost') : 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);
|
// ($this->request->getPost('labour_cost_With_Tax') ? $this->request->getPost('labour_cost_With_Tax') : 0);
|
||||||
|
|
||||||
// print $final_price;
|
// print $final_price;
|
||||||
// print_r($this->request->getPost());
|
// print_r($this->request->getPost());
|
||||||
@ -159,9 +158,11 @@ class Service extends BaseController
|
|||||||
'cgst' => $tax,
|
'cgst' => $tax,
|
||||||
'sgst' => $tax,
|
'sgst' => $tax,
|
||||||
'tax' => $this->request->getPost('tax'),
|
'tax' => $this->request->getPost('tax'),
|
||||||
'labour_cost' => $this->request->getPost('labour_cost'),
|
'wg_labour_cost' => $this->request->getPost('wg_labour_cost'),
|
||||||
'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
|
'wog_labour_cost' => $this->request->getPost('wog_labour_cost'),
|
||||||
'price' => $final_price,
|
'wg_price' => $this->request->getPost('wg_price_withtax'),
|
||||||
|
'wog_price' => $this->request->getPost('wog_price_withtax'),
|
||||||
|
// 'price' => $final_price,
|
||||||
// 'makes_id' => $make_json,
|
// 'makes_id' => $make_json,
|
||||||
// 'models_id' => $model_json,
|
// 'models_id' => $model_json,
|
||||||
'description' => $this->request->getPost('description'),
|
'description' => $this->request->getPost('description'),
|
||||||
@ -172,10 +173,10 @@ class Service extends BaseController
|
|||||||
|
|
||||||
if (!empty($service_id))
|
if (!empty($service_id))
|
||||||
{
|
{
|
||||||
$this->ServiceModel->update($service_id, $data);
|
$this->ServicesModel->update($service_id, $data);
|
||||||
} else {
|
} else {
|
||||||
$data['branch_id'] = $this->session->get('logged_user_branch_id');
|
$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
|
$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) {
|
if ($existingService) {
|
||||||
$data['isactive'] = 0;
|
$data['isactive'] = 0;
|
||||||
|
|
||||||
if ($this->ServiceModel->update($service_id, $data)) {
|
if ($this->ServicesModel->update($service_id, $data)) {
|
||||||
session()->setFlashdata('success', 'Deleted successfully.');
|
session()->setFlashdata('success', 'Deleted successfully.');
|
||||||
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$service_id);
|
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$service_id);
|
||||||
}
|
}
|
||||||
@ -309,7 +310,7 @@ class Service extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'isactive' => $isactive
|
'isactive' => $isactive
|
||||||
];
|
];
|
||||||
$updated = $this->ServiceModel->update($service_id, $data);
|
$updated = $this->ServicesModel->update($service_id, $data);
|
||||||
|
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$result = $data;
|
$result = $data;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class JobcardModel extends Model
|
|||||||
'order_number','client_mobile_no','client_name',
|
'order_number','client_mobile_no','client_name',
|
||||||
'billing_address','billing_city','billing_state','billing_country',
|
'billing_address','billing_city','billing_state','billing_country',
|
||||||
'billing_postal_code','fuel_qty', 'meter', 'delivery_date', 'note',
|
'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'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Models;
|
|
||||||
use CodeIgniter\Model;
|
|
||||||
class ServiceModel extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'services';
|
|
||||||
protected $primaryKey = 'service_id';
|
|
||||||
protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','labour_cost_with_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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@ -5,7 +5,23 @@ class ServicesModel extends Model
|
|||||||
{
|
{
|
||||||
protected $table = 'services';
|
protected $table = 'services';
|
||||||
protected $primaryKey = 'service_id';
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,6 +85,19 @@
|
|||||||
<input type="hidden" id="issued_items" name="issued_items" value="">
|
<input type="hidden" id="issued_items" name="issued_items" value="">
|
||||||
<!-- <h4 class="header-title">Sales Order Details :</h4><br> -->
|
<!-- <h4 class="header-title">Sales Order Details :</h4><br> -->
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="inputEmail4" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||||
|
<select class="form-control type-select SelExample" name="type" id="type" data-toggle="select2" required>
|
||||||
|
<option value="" <?= (isset($jobs['type']) && $jobs['type'] == '') ? 'selected' : '' ?>>Select Type</option>
|
||||||
|
<option value="With General" <?= (isset($jobs['type']) && $jobs['type'] == "With General") ?'selected' : '' ?>>With General</option>
|
||||||
|
<option value="Without General" <?= (isset($jobs['type']) && $jobs['type'] == "Without General") ? 'selected' : '' ?>>Without General</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
|
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
|
||||||
@ -110,7 +123,7 @@
|
|||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Client Name<span class="text-danger"></span></label>
|
<label for="inputPassword4" class="col-form-label">Client Name<span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" name="client_id" placeholder="Client"value="<?= isset($jobs['client_name']) ? $jobs['client_name'] : '' ?>" readonly>
|
<input type="text" class="form-control" name="client_id" placeholder="Client" value="<?= isset($jobs['client_name']) ? $jobs['client_name'] : '' ?>" readonly>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Mobile No<span class="text-danger">*</span></label>
|
<label for="inputPassword4" class="col-form-label">Mobile No<span class="text-danger">*</span></label>
|
||||||
@ -196,7 +209,7 @@
|
|||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Assign To</label>
|
<label for="inputPassword4" class="col-form-label">Assign To</label>
|
||||||
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" data-toggle="select2" multiple>
|
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" placeholder="Assign To" data-toggle="select2" multiple>
|
||||||
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Mechanic</option>' ?>
|
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Mechanic</option>' ?>
|
||||||
<?php foreach ($workers as $value) : ?>
|
<?php foreach ($workers as $value) : ?>
|
||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
@ -815,6 +828,31 @@ $(document).ready(function() {
|
|||||||
productarray = [];
|
productarray = [];
|
||||||
servicearray = [];
|
servicearray = [];
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
|
||||||
|
var jc_id = "<?php echo $jobs['job_card_id'] ?? 0 ?>";
|
||||||
|
console.log("Job Card ID:", jc_id);
|
||||||
|
|
||||||
|
if(jc_id == 0) {
|
||||||
|
$('.type-select').prop('disabled', false);
|
||||||
|
} else {
|
||||||
|
$('.type-select').prop('disabled', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.type-select').change(function() {
|
||||||
|
$('#productItemTable tbody').empty();
|
||||||
|
$('.vehicle-select').val('').select2();
|
||||||
|
$('#makeAndModel').val('');
|
||||||
|
$('input[name="client_id"]').val('');
|
||||||
|
$('input[name="mobile_no"]').val('');
|
||||||
|
$('input[name="billing_address"]').val('');
|
||||||
|
$('input[name="city"]').val('');
|
||||||
|
$('input[name="state"]').val('');
|
||||||
|
$('input[name="country"]').val('');
|
||||||
|
$('input[name="mobile_no"]').val('');
|
||||||
|
$('input[name="postalcode"]').val('');
|
||||||
|
});
|
||||||
|
|
||||||
// Event listener for vehicle selection change
|
// Event listener for vehicle selection change
|
||||||
$('.vehicle-select').change(function() {
|
$('.vehicle-select').change(function() {
|
||||||
$('#productItemTable tbody').empty();
|
$('#productItemTable tbody').empty();
|
||||||
@ -837,6 +875,11 @@ $(document).ready(function() {
|
|||||||
// Extract makeId from the selected vehicle
|
// Extract makeId from the selected vehicle
|
||||||
var makeId = selectedVehicle.make;
|
var makeId = selectedVehicle.make;
|
||||||
var modelId = selectedVehicle.model;
|
var modelId = selectedVehicle.model;
|
||||||
|
var type = $('#type').val();
|
||||||
|
if(type == ""){
|
||||||
|
alert("Please Select the Type");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// console.log(modelId);
|
// console.log(modelId);
|
||||||
|
|
||||||
// Make sure makeId exists
|
// Make sure makeId exists
|
||||||
@ -870,7 +913,8 @@ $(document).ready(function() {
|
|||||||
data: {
|
data: {
|
||||||
make_id: makeId,
|
make_id: makeId,
|
||||||
model_id:modelId,
|
model_id:modelId,
|
||||||
vehicle_id: vehicleId
|
vehicle_id: vehicleId,
|
||||||
|
type : type
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
@ -910,7 +954,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
$product_json = isset($product_1) ? json_encode($product_1) : json_encode($product);
|
$product_json = isset($product_1) ? json_encode($product_1) : json_encode($product);
|
||||||
$service_json = isset($service_1) ? json_encode($service_1) : json_encode($service);
|
// $service_json = isset($service_1) ? json_encode($service_1) : json_encode($service);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
@ -1105,7 +1149,8 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var products = <?php echo $product_json; ?>;
|
var products = <?php echo $product_json; ?>;
|
||||||
var services = <?php echo $service_json; ?>;
|
// var services = <?php // echo $service_json; ?>;
|
||||||
|
|
||||||
var mapTable;
|
var mapTable;
|
||||||
function data_contruction_for_save() {
|
function data_contruction_for_save() {
|
||||||
|
|
||||||
@ -1309,7 +1354,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
if(className.includes("service")) {
|
if(className.includes("service")) {
|
||||||
// Find product details from JSON
|
// Find product details from JSON
|
||||||
var service_data = services.find(function(item) {
|
var service_data = servicearray.find(function(item) {
|
||||||
return item.service_id == productId;
|
return item.service_id == productId;
|
||||||
});
|
});
|
||||||
// Access unit price from product and set it as rate
|
// Access unit price from product and set it as rate
|
||||||
@ -1413,6 +1458,7 @@ $(document).ready(function() {
|
|||||||
return item.product_id == productId;
|
return item.product_id == productId;
|
||||||
});
|
});
|
||||||
console.log(product);
|
console.log(product);
|
||||||
|
if (product !== undefined) {
|
||||||
var cgst = parseFloat(product.cgst);
|
var cgst = parseFloat(product.cgst);
|
||||||
var sgst = parseFloat(product.sgst);
|
var sgst = parseFloat(product.sgst);
|
||||||
|
|
||||||
@ -1425,6 +1471,13 @@ $(document).ready(function() {
|
|||||||
rate = Number(product.total_amount);
|
rate = Number(product.total_amount);
|
||||||
var amount = rate * quantity;
|
var amount = rate * quantity;
|
||||||
total_tax_amt = amount - finrate;
|
total_tax_amt = amount - finrate;
|
||||||
|
}else{
|
||||||
|
tax1 = $(row).find('.item-tax').val();
|
||||||
|
rate1 = $(row).find('.rate-d-only').val();
|
||||||
|
var amount = rate1 * quantity;
|
||||||
|
total_tax_amt = amount;
|
||||||
|
}
|
||||||
|
|
||||||
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
|
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
|
||||||
$(row).find('.item-amount').val(amount.toFixed(2));
|
$(row).find('.item-amount').val(amount.toFixed(2));
|
||||||
}
|
}
|
||||||
@ -2467,11 +2520,4 @@ $(document).ready(function() {
|
|||||||
button.innerHTML = '<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
|
button.innerHTML = '<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +21,10 @@
|
|||||||
<form action="<?= base_url() . "add_service"; ?>" method="post" id="serviceForm">
|
<form action="<?= base_url() . "add_service"; ?>" method="post" id="serviceForm">
|
||||||
<h4 class="header-title">Service Details :</h4>
|
<h4 class="header-title">Service Details :</h4>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-3">
|
||||||
|
<label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="servicename" style="height:32px" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required>
|
||||||
|
</div>
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputEmail4" class="col-form-label">Type<span class="text-danger">*</span></label>
|
<label for="inputEmail4" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||||
<select class="form-control" id="category" name="category" style="height:32px" required>
|
<select class="form-control" id="category" name="category" style="height:32px" required>
|
||||||
@ -38,10 +42,6 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-3">
|
|
||||||
<label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label>
|
|
||||||
<input type="text" class="form-control" name="servicename" style="height:32px" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div><br>
|
</div><br>
|
||||||
<h4 class="header-title">Select Items :</h4>
|
<h4 class="header-title">Select Items :</h4>
|
||||||
@ -80,38 +80,45 @@
|
|||||||
$cgst = isset($services['cgst']) ? $services['cgst'] : 0; // CGST value (half of the tax amount)
|
$cgst = isset($services['cgst']) ? $services['cgst'] : 0; // CGST value (half of the tax amount)
|
||||||
$sgst = isset($services['sgst']) ? $services['sgst'] : 0; // SGST value (half of the tax amount)
|
$sgst = isset($services['sgst']) ? $services['sgst'] : 0; // SGST value (half of the tax amount)
|
||||||
$tax = $cgst + $sgst; // Total tax (sum of CGST and SGST)
|
$tax = $cgst + $sgst; // Total tax (sum of CGST and SGST)
|
||||||
if(isset($services['labour_cost'])){
|
|
||||||
$labour_cost = ($services['labour_cost'] / 100) * $tax;
|
|
||||||
$labour_cost = round($labour_cost + $services['labour_cost']);
|
|
||||||
}else{
|
|
||||||
$labour_cost = '';
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
|
|
||||||
<input type="number" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Total Price" step="0.01" min="0" value="<?= $labour_cost; ?>" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Tax<span class="text-danger">*</span></label>
|
<label for="inputPassword4" class="col-form-label">Tax<span class="text-danger">*</span></label>
|
||||||
<select class="form-control status-select" name="tax" data-toggle="select2" required>
|
<select class="form-control status-select" name="tax" data-toggle="select2" required>
|
||||||
<option value="" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
|
<option value="0" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
|
||||||
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
|
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
|
||||||
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
|
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-md-4"></div>
|
||||||
|
<div class="form-group col-md-4"></div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
|
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) with General<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['labour_cost']) ? $services['labour_cost'] : '' ?>" required readonly>
|
<input type="number" class="form-control" name="wg_price_withtax" id="PriceWithTaxAndGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wg_price']) ? $services['wg_price'] : '' ; ?>" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="inputEmail4" class="col-form-label">Labour Cost with General <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="wg_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wg_labour_cost']) ? $services['wg_labour_cost'] : '' ?>" required readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4"></div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) without General<span class="text-danger">*</span></label>
|
||||||
|
<input type="number" class="form-control" name="wog_price_withtax" id="PriceWithOutTaxWithGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wog_price']) ? $services['wog_price'] : ''; ?>" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="inputEmail4" class="col-form-label">Labour Cost without General <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="wog_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wog_labour_cost']) ? $services['wog_labour_cost'] : '' ?>" required readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4"></div>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<!-- <label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label> -->
|
<!-- <label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label> -->
|
||||||
<input type="hidden" class="form-control" name="price" id="price" placeholder="Price" value="<?= isset($services['price']) ? $services['price'] : 0 ?>">
|
<!-- <input type="hidden" class="form-control" name="price" id="price" placeholder="Price" value="<?= isset($services['price']) ? $services['price'] : 0 ?>"> -->
|
||||||
<input type="hidden" class="form-control" name="productCost" id="productCost" placeholder="ProductCost" value="0">
|
<input type="hidden" class="form-control" name="productCost" id="productCost" placeholder="ProductCost" value="0">
|
||||||
<input type="hidden" class="form-control" name="serviceCost" id="serviceCost" placeholder="ServiceCost" value="0">
|
<input type="hidden" class="form-control" name="serviceCost" id="serviceCost" placeholder="ServiceCost" value="0">
|
||||||
</div>
|
</div>
|
||||||
@ -301,10 +308,18 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
data = <?php echo json_encode($product) ?>;
|
data = <?php echo json_encode($product) ?>;
|
||||||
servicedata = <?php echo json_encode($service) ?>;
|
servicedata = <?php echo json_encode($service) ?>;
|
||||||
var service_id = "<?php echo $service_id; ?>";
|
|
||||||
if (service_id != 0) {
|
if (service_id != 0) {
|
||||||
$("#productSelect").trigger('change');
|
|
||||||
$('#serviceSelected').trigger('change');
|
var category = <?php echo isset($services['category']) ? json_encode($services['category']) : 'null'; ?>;
|
||||||
|
if (category == 1) {
|
||||||
|
$('#cc_hide').css('display', 'block');
|
||||||
|
$('#service_hide').css('display' ,'block');
|
||||||
|
$('#cubiccapacity').attr('required', false).attr('readonly', true);
|
||||||
|
} else {
|
||||||
|
$('#cc_hide').css('display', 'none');
|
||||||
|
$('#service_hide').css('display' ,'none');
|
||||||
|
$('#cubiccapacity').attr('required', true).attr('readonly', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -374,92 +389,90 @@ document.getElementById('category').addEventListener('change', function() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#productSelect').change(function() {
|
// $('#productSelect').change(function() {
|
||||||
console.log('this.value',this.value);
|
// console.log('this.value',this.value);
|
||||||
if(this.value != 0) {
|
// if(this.value != 0) {
|
||||||
// Get the selected options
|
// // Get the selected options
|
||||||
var selectedOptions = this.selectedOptions;
|
// var selectedOptions = this.selectedOptions;
|
||||||
|
|
||||||
// Initialize sum
|
// // Initialize sum
|
||||||
var sum = 0;
|
// var sum = 0;
|
||||||
|
|
||||||
for (var i = 0; i < selectedOptions.length; i++) {
|
// for (var i = 0; i < selectedOptions.length; i++) {
|
||||||
var productId = selectedOptions[i].value;
|
// var productId = selectedOptions[i].value;
|
||||||
var price = getPriceForProductId(productId);
|
// var price = getPriceForProductId(productId);
|
||||||
sum += parseInt(price);
|
// sum += parseInt(price);
|
||||||
}
|
// }
|
||||||
$('#productCost').val(parseInt(sum));
|
// $('#productCost').val(parseInt(sum));
|
||||||
// console.log(sum);
|
// // console.log(sum);
|
||||||
|
|
||||||
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
|
||||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
|
|
||||||
console.log("New value of #serviceCost:", add);
|
|
||||||
|
|
||||||
$('#price').val(add);
|
|
||||||
}
|
|
||||||
else if(this.value == '' ) {
|
|
||||||
$('#productCost').val(0);
|
|
||||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||||
labour_cost = ($('#LabourCostWithTax').val() == '') ? 0 : parseInt($('#LabourCostWithTax').val());
|
// add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
|
||||||
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) + labour_cost;
|
// console.log("New value of #serviceCost:", add);
|
||||||
console.log("New value of #serviceCost:", add);
|
|
||||||
|
|
||||||
$('#price').val(add);
|
// $('#price').val(add);
|
||||||
}
|
// }
|
||||||
});
|
// else if(this.value == '' ) {
|
||||||
|
// $('#productCost').val(0);
|
||||||
|
// // labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||||
|
// labour_cost = ($('#PriceWithTaxAndGeneral').val() == '') ? 0 : parseInt($('#PriceWithTaxAndGeneral').val());
|
||||||
|
// add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) + labour_cost;
|
||||||
|
// console.log("New value of #serviceCost:", add);
|
||||||
|
|
||||||
|
// $('#price').val(add);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
// Function to fetch the price for a product
|
// Function to fetch the price for a product
|
||||||
function getPriceForProductId(productId) {
|
// function getPriceForProductId(productId) {
|
||||||
for (var i = 0; i < data.length; i++) {
|
// for (var i = 0; i < data.length; i++) {
|
||||||
if (data[i].product_id === productId) {
|
// if (data[i].product_id === productId) {
|
||||||
// Return the purchase_cost if the product_id matches
|
// // Return the purchase_cost if the product_id matches
|
||||||
return data[i].unit_price;
|
// return data[i].unit_price;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
// $('#serviceSelected').change(function() {
|
||||||
$('#serviceSelected').change(function() {
|
// // console.log(this.value);
|
||||||
// console.log(this.value);
|
// if(this.value != 0) {
|
||||||
if(this.value != 0) {
|
// // Get the selected options
|
||||||
// Get the selected options
|
// var selectedOptions = this.selectedOptions;
|
||||||
var selectedOptions = this.selectedOptions;
|
// // Initialize sum
|
||||||
// Initialize sum
|
// var ssum = 0;
|
||||||
var ssum = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < selectedOptions.length; i++) {
|
// for (var i = 0; i < selectedOptions.length; i++) {
|
||||||
var serviceId = selectedOptions[i].value;
|
// var serviceId = selectedOptions[i].value;
|
||||||
var sprice = getPriceForServiceId(serviceId);
|
// var sprice = getPriceForServiceId(serviceId);
|
||||||
ssum += parseInt(sprice);
|
// ssum += parseInt(sprice);
|
||||||
}
|
// }
|
||||||
$('#serviceCost').val(parseInt(ssum));
|
// $('#serviceCost').val(parseInt(ssum));
|
||||||
// console.log(ssum);
|
// // console.log(ssum);
|
||||||
|
|
||||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
|
// // labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
|
||||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
|
// add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
|
||||||
// console.log("New value of #serviceCost:", add);
|
// // console.log("New value of #serviceCost:", add);
|
||||||
$('#price').val(add);
|
// $('#price').val(add);
|
||||||
}
|
// }
|
||||||
else if(this.value == '') {
|
// else if(this.value == '') {
|
||||||
$('#serviceCost').val(0);
|
// $('#serviceCost').val(0);
|
||||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
|
// // labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
|
||||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
|
// add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
|
||||||
// console.log("New value of #serviceCost:", add);
|
// // console.log("New value of #serviceCost:", add);
|
||||||
$('#price').val(add);
|
// $('#price').val(add);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Function to fetch the price for a product
|
// Function to fetch the price for a product
|
||||||
function getPriceForServiceId(serviceId) {
|
// function getPriceForServiceId(serviceId) {
|
||||||
// console.log(serviceId);
|
// // console.log(serviceId);
|
||||||
for (var i = 0; i < servicedata.length; i++) {
|
// for (var i = 0; i < servicedata.length; i++) {
|
||||||
if (servicedata[i].service_id === serviceId) {
|
// if (servicedata[i].service_id === serviceId) {
|
||||||
// Return the purchase_cost if the product_id matches
|
// // Return the purchase_cost if the product_id matches
|
||||||
return servicedata[i].price;
|
// return servicedata[i].price;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -471,34 +484,44 @@ document.getElementById('category').addEventListener('change', function() {
|
|||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
function unitPriceReverseCalculation() {
|
function unitPriceWithGeneralReverseCalculation() {
|
||||||
var tax = parseFloat($("select[name='tax']").val());
|
var tax = parseFloat($("select[name='tax']").val());
|
||||||
if(tax == ''){
|
if(tax == ''){
|
||||||
toastr.warning('Please select Tax', 'Warning');
|
toastr.warning('Please select Tax', 'Warning');
|
||||||
}else{
|
}else{
|
||||||
var labour_cost_With_Tax = parseFloat($("input[name='labour_cost_With_Tax']").val());
|
var wg_price_withtax = parseFloat($("input[name='wg_price_withtax']").val());
|
||||||
var labour_cost = labour_cost_With_Tax / parseFloat((tax / 100) + 1);
|
var wg_labour_cost = wg_price_withtax / parseFloat((tax / 100) + 1);
|
||||||
$("input[name='labour_cost']").val(labour_cost.toFixed(2));
|
if (!isNaN(wg_labour_cost)) {
|
||||||
|
$("input[name='wg_labour_cost']").val(wg_labour_cost.toFixed(2));
|
||||||
// add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(labour_cost.toFixed(2));
|
}
|
||||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(labour_cost_With_Tax);
|
}
|
||||||
// console.log("add");
|
|
||||||
// console.log(add);
|
|
||||||
$('#price').val(add);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unitPriceWithoutGeneralReverseCalculation() {
|
||||||
|
var tax = parseFloat($("select[name='tax']").val());
|
||||||
|
if(tax == ''){
|
||||||
|
toastr.warning('Please select Tax', 'Warning');
|
||||||
|
}else{
|
||||||
|
var wog_price_withtax = parseFloat($("input[name='wog_price_withtax']").val());
|
||||||
|
var wog_labour_cost = wog_price_withtax / parseFloat((tax / 100) + 1);
|
||||||
|
if (!isNaN(wog_labour_cost)) {
|
||||||
|
$("input[name='wog_labour_cost']").val(wog_labour_cost.toFixed(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("input[name='labour_cost_With_Tax'], select[name='tax']").change(function() {
|
$("input[name='wg_price_withtax'], select[name='tax']").change(function() {
|
||||||
unitPriceReverseCalculation();
|
unitPriceWithGeneralReverseCalculation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("input[name='wog_price_withtax'], select[name='tax']").change(function() {
|
||||||
|
unitPriceWithoutGeneralReverseCalculation();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#service_form_submit').click(function (event) {
|
$('#service_form_submit').click(function (event) {
|
||||||
|
|
||||||
// if(!$('#LabourCostWithTax').val()){
|
// if(!$('#PriceWithTaxAndGeneral').val()){
|
||||||
// // event.preventDefault();
|
// // event.preventDefault();
|
||||||
|
|
||||||
// $('form').serialize();
|
// $('form').serialize();
|
||||||
|
|||||||
@ -23,8 +23,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Service Name</th>
|
<th>Service Name</th>
|
||||||
<th>Labour Cost</th>
|
<th>Price With General</th>
|
||||||
<th>Price</th>
|
<th>Price WithOut General</th>
|
||||||
<th>Tax</th>
|
<th>Tax</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
@ -41,8 +41,8 @@
|
|||||||
?>
|
?>
|
||||||
<tr class="service_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
|
<tr class="service_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
|
||||||
<td><?= $value['service_name'].$name ; ?></td>
|
<td><?= $value['service_name'].$name ; ?></td>
|
||||||
<td><?= $value['labour_cost']; ?></td>
|
<td><?= $value['wg_price']; ?></td>
|
||||||
<td><?= $value['price']; ?></td>
|
<td><?= $value['wog_price']; ?></td>
|
||||||
<td><?= $value['cgst'] + $value['sgst']; ?></td>
|
<td><?= $value['cgst'] + $value['sgst']; ?></td>
|
||||||
<td><?= $value['description']; ?></td>
|
<td><?= $value['description']; ?></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user