diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index ae45b8f..c0c33c1 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -7,6 +7,7 @@ use App\Models\ProductModel; use App\Models\VendorModel; use App\Models\BikemodelsModel; use App\Models\ManufacturerModel; + class Products extends BaseController @@ -62,6 +63,10 @@ class Products extends BaseController $data['tax']=$tax; $BikemakeModel = new BikemakeModel(); $data['make'] = $BikemakeModel->findAll(); + $VendorModel = new VendorModel(); + $data['vendors']=$VendorModel->findAll(); + $ManufacturerModel = new ManufacturerModel(); + $data['manufacturers']=$ManufacturerModel->findAll(); $data['page_name']="Add Product"; } else if ($product_id !== '0') { $data['page_name']="Edit Product"; @@ -80,9 +85,12 @@ class Products extends BaseController $data['tax']=$tax; $VendorModel = new VendorModel(); $data['vendors']=$VendorModel->findAll(); - - - // print_r($data);die; + $ManufacturerModel = new ManufacturerModel(); + $data['manufacturers']=$ManufacturerModel->findAll(); + $preferredVendorId = $products['prefered_vendor']; + // Pass the preferred vendor ID to the view + $data['preferredVendorId'] = $preferredVendorId; // print_r($data);die; + // print_r($data);die; } $data['product_id'] = $product_id; @@ -101,7 +109,7 @@ class Products extends BaseController 'product_name' => $this->request->getPost('productname'), 'product_category' => $this->request->getPost('productcategory'), 'mfr_part_no' => $this->request->getPost('mfr_part_no'), - 'serial_no' => $this->request->getPost('serial_no'), + 'unit_price' => $this->request->getPost('unit_price'), 'commision_rate' => $this->request->getPost('commision_rate'), 'sgst' => $tax, @@ -110,16 +118,20 @@ class Products extends BaseController 'qty_stock'=> $this->request->getPost('qty_in_stock'), 'qty_in_demand'=> $this->request->getPost('qty_in_demand'), 'description' => $this->request->getPost('description'), - 'vendor' => $this->request->getPost('vendor'), + 'vendor' =>json_encode( $this->request->getPost('vendor')), 'purchase_order_level' => $this->request->getPost('purchase_order_level'), + 'reorder_level' => $this->request->getPost('reorder_level'), 'quality' => $this->request->getPost('quality'), 'make_id' => $this->request->getPost('make'), 'models_id' => json_encode($this->request->getPost('model')), + 'rack_number' => $this->request->getPost('rack_number'), + 'manufacturer_id' => $this->request->getPost('manufacturer'), + 'prefered_vendor' => $this->request->getPost('prefered_vendor'), 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id') ]; -// print_r($data);die; - + + // print_r($data);die; $product_id = $this->request->getPost('product_id'); @@ -129,9 +141,13 @@ class Products extends BaseController } else { $ProductModel->insert($data); + $product_id = $ProductModel->getInsertID(); } - + $orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT); +// print_r($orderNumber);die; + // Update sales order with generated order number + $ProductModel->update($product_id, ['sku_id' => $orderNumber]); return redirect()->to('product_index'); } diff --git a/app/Controllers/Vehicle.php b/app/Controllers/Vehicle.php index 7613135..67a5187 100644 --- a/app/Controllers/Vehicle.php +++ b/app/Controllers/Vehicle.php @@ -87,6 +87,7 @@ class Vehicle extends BaseController '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 ]; // print_r($data);die; diff --git a/app/Controllers/Vendor.php b/app/Controllers/Vendor.php index b3d490e..a59f33e 100644 --- a/app/Controllers/Vendor.php +++ b/app/Controllers/Vendor.php @@ -36,29 +36,14 @@ class Vendor extends BaseController if ($vendor_id === '0') { $data['vendor'] = []; $data['page_name'] = "Add Vendor"; - $BikemakeModel = new BikemakeModel(); - $data['make'] = $BikemakeModel->findAll(); - $data['models'] = []; // Initialize models array for the view } else { $VendorModel = new VendorModel(); $vendor = $VendorModel->where('vendor_id', $vendor_id)->get()->getRowArray(); - $vendor['model_ids'] = json_decode($vendor['model'], true); - $vendor['make_ids'] = json_decode($vendor['make'], true); $data['vendor'] = $vendor; $data['page_name'] = "Edit Vendor"; - // Load models based on the selected make IDs - $BikemodelModel = new BikemodelsModel(); - $models = []; - foreach ($vendor['make_ids'] as $make_id) { - $models[] = $BikemodelModel->where('make_id', $make_id)->findAll(); - } - $data['models'] = $models; // Pass models array to the view - - // Load make data - $BikemakeModel = new BikemakeModel(); - $data['make'] = $BikemakeModel->findAll(); + } $data['vendor_id'] = $vendor_id; @@ -71,30 +56,28 @@ class Vendor extends BaseController { $VendorModel = new VendorModel(); - // Retrieve the selected make IDs and model IDs from the form - $make_ids = $this->request->getPost('make'); - $model_ids = $this->request->getPost('model'); - - // Convert model IDs to JSON format - $model_json = json_encode($model_ids); - $make_json=json_encode($make_ids); + $data = [ 'vendor_name' => $this->request->getPost('vendor_name'), - 'contact_name' => $this->request->getPost('contact_name'), 'gstnumber' => $this->request->getPost('gstnumber'), 'vendor_email' => $this->request->getPost('email'), 'address' => $this->request->getPost('address'), - 'vendor_mobile' => $this->request->getPost('mobile'), 'city' => $this->request->getPost('city'), 'state' => $this->request->getPost('state'), 'postal_code' => $this->request->getPost('postalcode'), 'country' => $this->request->getPost('country'), 'category' => $this->request->getPost('category'), - 'website' => $this->request->getPost('website'), + 'contact_person_name1' => $this->request->getPost('contact_person_name1'), + 'contact_person_name2' => $this->request->getPost('contact_person_name2'), + 'contact_person_name3' => $this->request->getPost('contact_person_name3'), + 'contact_person_mobile1' => $this->request->getPost('contact_person_mobile1'), + 'contact_person_mobile2' => $this->request->getPost('contact_person_mobile2'), + 'contact_person_mobile3' => $this->request->getPost('contact_person_mobile3'), + 'contact_person_resignation1' => $this->request->getPost('contact_person_resignation1'), + 'contact_person_resignation2' => $this->request->getPost('contact_person_resignation2'), + 'contact_person_resignation3' => $this->request->getPost('contact_person_resignation3'), 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id'), - 'make' => $make_json, // Store the selected make IDs - 'model' => $model_json, // Store the selected model IDs in JSON format ]; $vendor_id = $this->request->getPost('vendor_id'); diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index d7f0ae2..2c7de1f 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -5,7 +5,7 @@ class ProductModel extends Model { protected $table = 'products'; protected $primaryKey = 'product_id'; - protected $allowedFields = ['sku_id','product_id','manufacturer_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive']; + protected $allowedFields = ['sku_id','product_id','rack_number','manufacturer_id','make_id','models_id','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','isactive']; public function getTax() diff --git a/app/Models/VehicleModel.php b/app/Models/VehicleModel.php index 9f6b2fd..2cff2fd 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','isactive']; + 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']; public function getCustomerandVehicle($branch_id) { diff --git a/app/Models/VendorModel.php b/app/Models/VendorModel.php index 547b2e1..853d9a0 100644 --- a/app/Models/VendorModel.php +++ b/app/Models/VendorModel.php @@ -5,7 +5,7 @@ class VendorModel extends Model { protected $table = 'vendor'; protected $primaryKey = 'vendor_id'; - protected $allowedFields = ['vendor_id','branch_id','vendor_name','vendor_email','vendor_mobile','contact_name','website','gstnumber','conatct_person','vendortype','make','model','category','address','state','postal_code','city','country','description','isactive']; + protected $allowedFields = ['vendor_id','branch_id','vendor_name','vendor_email','manufacturer_id','contact_person_name1','contact_person_name2','contact_person_name3','contact_person_mobile1','contact_person_mobile2','contact_person_mobile3','contact_person_designation1','contact_person_designation2','contact_person_designation3','gstnumber','conatct_person','vendortype','make','model','category','address','state','postal_code','city','country','description','isactive']; public function get_vendors_by_model($model_ids) { diff --git a/app/Views/product_form.php b/app/Views/product_form.php index ea54aee..62f3159 100644 --- a/app/Views/product_form.php +++ b/app/Views/product_form.php @@ -56,13 +56,35 @@