diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 4c9527d..e01ed45 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -524,6 +524,7 @@ class Jobcard extends BaseController $vehicles = $VehicleModel->where('isactive',1)->where('vehicle_id',$jobs['vehicle_id']) ->where('branch_id',$this->session->get('logged_user_branch_id')) ->first(); + // print_r($jobs['vehicle_id']);die; $makeId = $vehicles['make']; $modelId = $vehicles['model']; diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php index 6fc80f1..f20b3d0 100644 --- a/app/Controllers/Purchase.php +++ b/app/Controllers/Purchase.php @@ -45,6 +45,8 @@ class Purchase extends BaseController public function new_purchase($purchase_order_id) { if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } + $ProductModel = new ProductModel(); + if ($purchase_order_id === '0') { $data['purchase'] = []; @@ -62,7 +64,6 @@ class Purchase extends BaseController $BusinessModel = new BusinessModel(); $branch = $BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->get()->getRowArray(); $business = $BusinessModel->where('business_id', $this->session->get('logged_user_business_id'))->get()->getRowArray(); - $ProductModel = new ProductModel(); $product=$ProductModel->where('isactive',1) ->where('branch_id',$this->session->get('logged_user_branch_id')) ->findAll(); @@ -99,14 +100,14 @@ class Purchase extends BaseController // print_r($vendor);die; $vendorId=$purchase['vendor_id']; $encodedVendorId = json_encode([$vendorId]); - $productModel = new ProductModel(); // Query the database to find the product based on make_id and model_id - $product = $productModel->select('products.*, manufacturer.manufacturer_name') + $product = $ProductModel->select('products.*, manufacturer.manufacturer_name') ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) ->findAll(); $data['product']=$product; + // print_r($product);die; @@ -116,7 +117,11 @@ class Purchase extends BaseController $data['purchase_product']=$purchase_product; } - + $productAll= $ProductModel->select('products.*, manufacturer.manufacturer_name') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->where('products.isactive',1) + ->findAll(); + $data['productAll']= json_encode($productAll); echo view('purchase_form',$data); } @@ -388,6 +393,7 @@ public function getVendorProducts() $product = $productModel->select('products.*, manufacturer.manufacturer_name') ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) + ->where('products.isactive',1) ->findAll(); // print_r($product);die; diff --git a/app/Controllers/Vehicle.php b/app/Controllers/Vehicle.php index 1373240..4c16c34 100644 --- a/app/Controllers/Vehicle.php +++ b/app/Controllers/Vehicle.php @@ -74,40 +74,40 @@ class Vehicle extends BaseController { if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } $VehicleModel = new VehicleModel(); + $reg_no = $this->request->getPost('regno'); + $vehicle = $VehicleModel->where('reg_no',$reg_no)->first(); + // if(!$vehicle){ + $data = [ + 'client_id' => $this->request->getPost('client_name'), + 'email' => $this->request->getPost('email'), + 'gstnumber' => $this->request->getPost('gstnumber'), + 'address' => $this->request->getPost('address'), + 'mobile_no' => $this->request->getPost('mobile_no'), + 'city' => $this->request->getPost('city'), + 'state' => $this->request->getPost('state'), + 'postal_code' => $this->request->getPost('postalcode'), + 'make' => $this->request->getPost('make'), + 'model' => $this->request->getPost('model'), + 'reg_no' => $reg_no, + 'colour' => $this->request->getPost('colour'), + 'year_of_manufacturing' => $this->request->getPost('year_of_manufacturing'), + 'branch_id' => $this->session->get('logged_user_branch_id'), + 'specific' => $this->request->getPost('specific'), + 'isactive' => 1 // Assuming this is a default value or handled separately + ]; + $vehicle_id = $this->request->getPost('vehicle_id'); + if (!empty($vehicle_id)) { + $VehicleModel->update($vehicle_id, $data); + } else { + $VehicleModel->insert($data); + } + return redirect()->to('vehicle_index'); + // }else{ + // $this->session->setFlashdata('error', 'Vehicle with this registration number already exists.'); + // return redirect()->back()->withInput(); + // } - $data = [ - 'client_id' => $this->request->getPost('client_name'), - 'email' => $this->request->getPost('email'), - 'address' => $this->request->getPost('address'), - 'mobile_no' => $this->request->getPost('mobile_no'), - 'city' => $this->request->getPost('city'), - 'state' => $this->request->getPost('state'), - 'postal_code' => $this->request->getPost('postalcode'), - 'make' => $this->request->getPost('make'), - 'model' => $this->request->getPost('model'), - 'reg_no' => $this->request->getPost('regno'), - 'colour' => $this->request->getPost('colour'), - 'year_of_manufacturing' => $this->request->getPost('year_of_manufacturing'), - 'branch_id' => $this->session->get('logged_user_branch_id'), - 'specific' => $this->request->getPost('specific'), - 'isactive' => 1 // Assuming this is a default value or handled separately - ]; - - - $vehicle_id = $this->request->getPost('vehicle_id'); - - - if (!empty($vehicle_id)) { - - $VehicleModel->update($vehicle_id, $data); - } else { - - $VehicleModel->insert($data); - } - - - return redirect()->to('vehicle_index'); } public function delete_vehicle($vehicle_id) diff --git a/app/Models/VehicleModel.php b/app/Models/VehicleModel.php index 2cff2fd..f5c1455 100644 --- a/app/Models/VehicleModel.php +++ b/app/Models/VehicleModel.php @@ -7,7 +7,7 @@ class VehicleModel extends Model protected $table = 'vehicle'; protected $primaryKey = 'vehicle_id'; - protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','email','postal_code','mobile_no','specific','isactive']; + protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive']; public function getCustomerandVehicle($branch_id) { diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php index 672e630..a0dbb94 100644 --- a/app/Views/bike_model_list.php +++ b/app/Views/bike_model_list.php @@ -21,7 +21,7 @@