FIX_Product CC Implement
This commit is contained in:
parent
c725f80529
commit
2c0ba2e438
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
/writable
|
||||
vendor/*
|
||||
vendor
|
||||
.env
|
||||
!vendor/.gitkeep
|
||||
composer.lock
|
||||
@ -460,7 +460,7 @@ class Jobcard extends BaseController
|
||||
$vehicle = $this->VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->where('products.branch_id',$this->session->get('logged_user_branch_id'))
|
||||
->findAll();
|
||||
@ -505,7 +505,7 @@ class Jobcard extends BaseController
|
||||
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
|
||||
@ -526,7 +526,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock,manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -540,7 +540,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -554,7 +554,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -595,20 +595,29 @@ class Jobcard extends BaseController
|
||||
$model_name = $this->BikemodelsModel->where('model_id',$modelId)->select('model_name')->first();
|
||||
$data['make_model'] = $make_name['make'].' ' . $model_name['model_name'];
|
||||
// Encode the modelId before searching
|
||||
$encodedModelId = json_encode([$makeId]);
|
||||
$encoded_make_id = json_encode(['0']);
|
||||
$product1 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('qty_stock >',0)
|
||||
->findAll();
|
||||
$product2 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false)
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('qty_stock >',0)
|
||||
->findAll();
|
||||
$product = array_merge($product1, $product2);
|
||||
// $encodedModelId = json_encode([$makeId]);
|
||||
// $encoded_make_id = json_encode(['0']);
|
||||
// $product1 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('qty_stock >',0)
|
||||
// ->findAll();
|
||||
// $product2 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
// ->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false)
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('qty_stock >',0)
|
||||
// ->findAll();
|
||||
// $product = array_merge($product1, $product2);
|
||||
// $data['product']=$product;
|
||||
$encodedCCId = json_encode([(string)$ccId]);
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('qty_stock >',0)
|
||||
->where('JSON_VALID(products.cubic_centimeter_id) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.cubic_centimeter_id, '{$encodedCCId}')", null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
|
||||
@ -9,6 +9,7 @@ use App\Models\BikemodelsModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
use App\Models\ProductCategoryModel;
|
||||
use App\Models\AdditionalProductNameModal;
|
||||
use App\Models\ComplaintModel;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
@ -22,6 +23,7 @@ class Products extends BaseController
|
||||
protected $VendorModel;
|
||||
protected $ManufacturerModel;
|
||||
protected $ProductCategoryModel;
|
||||
protected $ComplaintModel;
|
||||
|
||||
public $session;
|
||||
use ResponseTrait;
|
||||
@ -36,6 +38,7 @@ class Products extends BaseController
|
||||
$this->ManufacturerModel = new ManufacturerModel();
|
||||
$this->ProductCategoryModel = new ProductCategoryModel();
|
||||
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
||||
$this->ComplaintModel = new ComplaintModel();
|
||||
}
|
||||
|
||||
public function product_categories()
|
||||
@ -98,7 +101,7 @@ class Products extends BaseController
|
||||
$data['tax']=$tax;
|
||||
|
||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
|
||||
$data['capacity'] = $this->ComplaintModel->getCubicCapacityName();
|
||||
$data['vendors'] = $this->VendorModel->orderBy('vendor_name')->findAll();
|
||||
|
||||
|
||||
@ -129,40 +132,42 @@ class Products extends BaseController
|
||||
|
||||
$products = $this->ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||
|
||||
$products['make_id'] = json_decode($products['make_id'], true);
|
||||
$products['models_id'] = json_decode($products['models_id'], true);
|
||||
// $products['make_id'] = json_decode($products['make_id'], true);
|
||||
// $products['models_id'] = json_decode($products['models_id'], true);
|
||||
|
||||
$data['products'] = $products;
|
||||
|
||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
|
||||
$make_id = $products['make_id'];
|
||||
// $make_id = $products['make_id'];
|
||||
|
||||
|
||||
$models = [];
|
||||
if( $products['make_id'] != null) {
|
||||
foreach ($products['make_id'] as $make_id) {
|
||||
$models[] = $this->BikemodelsModel->where('make_id', $make_id)->orderBy('model_name')->findAll();
|
||||
}
|
||||
}
|
||||
$data['models'] = $models;
|
||||
// $models = [];
|
||||
// if( $products['make_id'] != null) {
|
||||
// foreach ($products['make_id'] as $make_id) {
|
||||
// $models[] = $this->BikemodelsModel->where('make_id', $make_id)->orderBy('model_name')->findAll();
|
||||
// }
|
||||
// }
|
||||
// $data['models'] = $models;
|
||||
|
||||
$tax = $this->ProductModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
$data['tax']=$tax;
|
||||
|
||||
$data['vendors'] = $this->VendorModel->orderBy('vendor_name')->findAll();
|
||||
|
||||
$data['manufacturers'] = $this->ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('manufacturer_name', 'ASC')->findAll();
|
||||
// dd($data['vendors']);
|
||||
|
||||
$vendorIds = json_decode($products['vendor'], true);
|
||||
|
||||
$vendors = [];
|
||||
if($vendorIds){
|
||||
foreach ($vendorIds as $vendorId) {
|
||||
$vendor = $this->VendorModel->find($vendorId);
|
||||
if ($vendor) {
|
||||
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
||||
}
|
||||
}
|
||||
}}
|
||||
$data['vendorsProduct'] = $vendors;
|
||||
|
||||
$preferredVendorId = $products['prefered_vendor'];
|
||||
@ -180,7 +185,8 @@ class Products extends BaseController
|
||||
->findAll();
|
||||
$data['productcategory'] = $productcategory;
|
||||
$data['additionalProdutName'] = $additionalProdutName;
|
||||
|
||||
$data['capacity'] = $this->ComplaintModel->getCubicCapacityName();
|
||||
|
||||
echo view('product_form',$data);
|
||||
}
|
||||
|
||||
@ -217,8 +223,8 @@ class Products extends BaseController
|
||||
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
||||
'reorder_level' => $this->request->getPost('reorder_level'),
|
||||
'quality' => $this->request->getPost('quality'),
|
||||
'make_id' => json_encode($this->request->getPost('make')),
|
||||
'models_id' => json_encode($this->request->getPost('model')),
|
||||
// 'make_id' => json_encode($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'),
|
||||
@ -233,12 +239,13 @@ class Products extends BaseController
|
||||
'box' => $box,
|
||||
'qty_per_box' => $qty_per_box,
|
||||
'barrel' => $barrel,
|
||||
'ltr_per_barrel' => $ltr_per_barrel
|
||||
'ltr_per_barrel' => $ltr_per_barrel,
|
||||
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
|
||||
];
|
||||
|
||||
$product_id = $this->request->getPost('product_id');
|
||||
$additional_product_name = $this->request->getPost('additional_product_name');
|
||||
$product_names_id = $this->request->getPost('product_names_id');
|
||||
// $additional_product_name = $this->request->getPost('additional_product_name');
|
||||
// $product_names_id = $this->request->getPost('product_names_id');
|
||||
$model_ids = $this->request->getPost('fk_model_id');
|
||||
|
||||
// print_r($data);die;
|
||||
@ -250,7 +257,7 @@ class Products extends BaseController
|
||||
}
|
||||
|
||||
//for insert or update Additional Product Names
|
||||
$this->insertOrUpdateAdditionalProductName($additional_product_name, $product_names_id, $model_ids, $product_id, $data['product_name']);
|
||||
// $this->insertOrUpdateAdditionalProductName($additional_product_name, $product_names_id, $model_ids, $product_id, $data['product_name']);
|
||||
|
||||
$orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT);
|
||||
|
||||
@ -488,7 +495,7 @@ class Products extends BaseController
|
||||
|
||||
// Assuming you have a model for products and one for manufacturers
|
||||
$products = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
@ -670,13 +677,19 @@ class Products extends BaseController
|
||||
$ltr_per_barrel = floatval($this->request->getPost('ltr_per_barrel') ?? 0);
|
||||
}
|
||||
|
||||
|
||||
$qty_in_stock = floatval($this->request->getPost('qty_stock') ?: 0); // Get qty_stock from POST
|
||||
$purchase_order_level = floor($qty_in_stock / 2); // Calculate purchase reorder level (half of qty in stock)
|
||||
$purchase_order_level = is_nan($purchase_order_level) ? '' : $purchase_order_level; // Safely assign values (handle invalid numbers)
|
||||
$reorder_level = is_nan($qty_in_stock) ? '' : $qty_in_stock;
|
||||
|
||||
$data = [
|
||||
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
|
||||
'product_name' => $this->request->getPost('productname'),
|
||||
'product_category' => $this->request->getPost('productcategory'),
|
||||
'total_amount' => $this->request->getPost('total_amount'),
|
||||
'unit_price' => $this->request->getPost('unit_price'),
|
||||
'qty_stock' => $this->request->getPost('qty_stock'),
|
||||
'qty_stock' => $qty_in_stock,
|
||||
'sgst' => $tax,
|
||||
'cgst' => $tax,
|
||||
'per' => $per,
|
||||
@ -687,6 +700,8 @@ class Products extends BaseController
|
||||
'ltr_per_barrel' => $ltr_per_barrel,
|
||||
'isactive' => 1,
|
||||
'branch_id' => $bid,
|
||||
'purchase_order_level'=> $purchase_order_level,
|
||||
'reorder_level' => $reorder_level,
|
||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||
];
|
||||
|
||||
|
||||
@ -107,13 +107,14 @@ class Purchase extends BaseController
|
||||
$encodedVendorId = json_encode([$vendorId]);
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $this->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;
|
||||
// $product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
// ->findAll();
|
||||
|
||||
$data['product']=$this->gatherVendorProducts($encodedVendorId);
|
||||
// echo "<pre>";
|
||||
// print_r($data['product']);die;
|
||||
|
||||
|
||||
|
||||
@ -123,7 +124,7 @@ class Purchase extends BaseController
|
||||
|
||||
}
|
||||
$productAll = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->findAll();
|
||||
$data['productAll']= json_encode($productAll);
|
||||
@ -188,7 +189,7 @@ class Purchase extends BaseController
|
||||
$business = $this->BusinessModel->where('business_id', $this->session->get('logged_user_business_id'))->get()->getRowArray();
|
||||
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->where('products.branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['product']=$product;
|
||||
@ -210,7 +211,7 @@ class Purchase extends BaseController
|
||||
$data['purchase_product'] = $purchase_product;
|
||||
|
||||
$productAll = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->findAll();
|
||||
$data['productAll']= json_encode($productAll);
|
||||
@ -413,21 +414,29 @@ public function getVendorProducts()
|
||||
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $this->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();
|
||||
|
||||
$product = $this->gatherVendorProducts($encodedVendorId);
|
||||
$CrossVerify = "";
|
||||
// $CrossVerify = $this->ProductModel->getLastQuery()->getQuery();
|
||||
// print_r($product);die;
|
||||
if($product){
|
||||
// Send JSON response
|
||||
return $this->response->setJSON(['product'=>$product , 'VendorData' => $VendorData] );
|
||||
} else {
|
||||
// If product is not found, return an empty response or appropriate message
|
||||
return $this->response->setJSON(['product'=>[] , 'VendorData' => $VendorData]);
|
||||
}
|
||||
return $this->response->setJSON([
|
||||
'product' => $product ?: [],
|
||||
'VendorData' => $VendorData ?: [],
|
||||
'CrossVerify' => $CrossVerify ?: ''
|
||||
]);
|
||||
}
|
||||
|
||||
public function gatherVendorProducts($encodedVendorId)
|
||||
{
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('JSON_VALID(products.vendor) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.vendor, '{$encodedVendorId}')", null, false)
|
||||
->findAll();
|
||||
return $product;
|
||||
}
|
||||
|
||||
public function delete_purchase_product()
|
||||
{
|
||||
$purchase_order_child_id = $this->request->getPost('purchase_order_child_id');
|
||||
|
||||
@ -65,7 +65,7 @@ class Reorderlevel extends BaseController
|
||||
$data['page_name']="Rise Order";
|
||||
$ProductModel = new ProductModel();
|
||||
$products=$ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('prefered_vendor', $prefered_vendor)
|
||||
->where('qty_stock <= purchase_order_level')
|
||||
->findAll();
|
||||
@ -76,7 +76,7 @@ class Reorderlevel extends BaseController
|
||||
$vendorid= $prefered_vendor;
|
||||
|
||||
$product_data = $ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('prefered_vendor', $vendorid)->findAll();
|
||||
// echo json_encode($product_data);die;
|
||||
$data['product_data'] = $product_data;
|
||||
|
||||
@ -86,7 +86,7 @@ class ReturnOrder extends BaseController
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
@ -308,7 +308,7 @@ class ReturnOrder extends BaseController
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
|
||||
@ -436,7 +436,7 @@ public function download_purchase_invoice($purchase_order_id)
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
@ -72,17 +72,14 @@ class Sales extends BaseController
|
||||
|
||||
$data['vehicle'] = $this->VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||
|
||||
|
||||
|
||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.branch_id', $this->session->get('logged_user_branch_id'))
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
|
||||
|
||||
} else if ($sales_order_id !== '0') {
|
||||
|
||||
|
||||
@ -97,46 +94,49 @@ class Sales extends BaseController
|
||||
$vehicles = $this->VehicleModel->where('isactive',1)->where('vehicle_id',$data['sales']['vehicle_id'])
|
||||
->where('branch_id',$this->session->get('logged_user_branch_id'))
|
||||
->first();
|
||||
$makeId = $vehicles['make'];
|
||||
$modelId = $vehicles['model'];
|
||||
// $makeId = $vehicles['make'];
|
||||
// $modelId = $vehicles['model'];
|
||||
|
||||
// Encode the modelId before searching
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
$encodedModelId = json_encode([$modelId]);
|
||||
// $encodedMakeId = json_encode([$makeId]);
|
||||
// $encodedModelId = json_encode([$modelId]);
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->where('qty_stock >',0)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
// $makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('products.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
$encodedMakeId = json_encode(['0']);
|
||||
$encodedModelId = json_encode(['0']);
|
||||
// $encodedMakeId = json_encode(['0']);
|
||||
// $encodedModelId = json_encode(['0']);
|
||||
|
||||
$common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->where('qty_stock >',0)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
// $common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('products.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
$product = array_merge($common_product, $makeproduct);
|
||||
// $product = array_merge($common_product, $makeproduct);
|
||||
|
||||
|
||||
$data['product']=$product;
|
||||
|
||||
// $data['product']=$product;
|
||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.branch_id', $this->session->get('logged_user_branch_id'))
|
||||
->findAll();
|
||||
|
||||
$sales_product = $this->SalesOrderProductModel->where('sales_order_id', $sales_order_id)->findAll();
|
||||
$data['sales_product']=$sales_product;
|
||||
|
||||
|
||||
|
||||
$data['vehicle'] = $this->VehicleModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
|
||||
@ -517,13 +517,19 @@ class Sales extends BaseController
|
||||
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
||||
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
||||
|
||||
$product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->whereIn('product_names.model_id',[$modelId, 0])
|
||||
->where('qty_stock >',0)
|
||||
->where('product_names.isactive', 1)
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
// $product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->whereIn('product_names.model_id',[$modelId, 0])
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('product_names.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
if($product){
|
||||
// Send JSON response
|
||||
|
||||
@ -91,11 +91,11 @@ 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['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->ServicesModel->getTax();
|
||||
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
|
||||
@ -107,6 +107,7 @@ class Service extends BaseController
|
||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
||||
$data['models'] = [];
|
||||
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['product'] = [];
|
||||
|
||||
} else if ($service_id !== '0') {
|
||||
|
||||
@ -126,10 +127,12 @@ class Service extends BaseController
|
||||
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
||||
$data['services'] = $services;
|
||||
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
$ccid = json_decode($services['cubic_capacity_id'], true);
|
||||
$data['product'] = $this->get_product_by_cc($ccid);
|
||||
// dd($data['service']);
|
||||
}
|
||||
$data['service_id'] = $service_id;
|
||||
|
||||
echo view('service_form',$data);
|
||||
|
||||
}
|
||||
@ -220,29 +223,56 @@ class Service extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function get_product_by_cc(){
|
||||
$cc_id = $this->request->getPost('cc_id');
|
||||
$products = [];
|
||||
$model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
|
||||
|
||||
$mid[] = 0; // default zero. because general..
|
||||
foreach($model_ids as $model){
|
||||
$mid[] = $model['model_id'];
|
||||
}
|
||||
$products = [];
|
||||
foreach ($mid as $id) {
|
||||
$sql = "SELECT products.*, manufacturer.manufacturer_name
|
||||
FROM products
|
||||
JOIN manufacturer ON manufacturer.manufacturer_id = products.manufacturer_id
|
||||
WHERE JSON_CONTAINS(products.models_id, ?)
|
||||
AND products.isactive = 1";
|
||||
|
||||
$result = $this->ProductModel->query($sql, ['"' . $id . '"'])->getResult();
|
||||
$products = array_merge($products, $result);
|
||||
}
|
||||
// be carefully we used in add-ajax call and edit - directphp array
|
||||
public function get_product_by_cc($id = null)
|
||||
{
|
||||
|
||||
return $this->response->setJSON($products);
|
||||
$cc_id = $this->request->isAJAX()
|
||||
? $this->request->getPost('cc_id')
|
||||
: $id;
|
||||
|
||||
// $encodedCCId = json_encode([$cc_id]);
|
||||
$encodedCCId = json_encode([(string)$cc_id]);
|
||||
// $encodedCCId = json_encode(["2"]);
|
||||
// echo $encodedCCId;die;
|
||||
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('JSON_VALID(products.cubic_centimeter_id) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.cubic_centimeter_id, '{$encodedCCId}')", null, false)
|
||||
->findAll();
|
||||
// $this->ProductModel->getLastQuery()->getQuery();
|
||||
return $this->request->isAJAX()
|
||||
? $this->response->setJSON($product)
|
||||
: $product;
|
||||
|
||||
}
|
||||
|
||||
// public function get_product_by_cc(){
|
||||
// $cc_id = $this->request->getPost('cc_id');
|
||||
// $products = [];
|
||||
// $model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
|
||||
|
||||
// $mid[] = 0; // default zero. because general..
|
||||
// foreach($model_ids as $model){
|
||||
// $mid[] = $model['model_id'];
|
||||
// }
|
||||
// $products = [];
|
||||
// foreach ($mid as $id) {
|
||||
// $sql = "SELECT products.*, manufacturer.manufacturer_name
|
||||
// FROM products
|
||||
// JOIN manufacturer ON manufacturer.manufacturer_id = products.manufacturer_id
|
||||
// WHERE JSON_CONTAINS(products.models_id, ?)
|
||||
// AND products.isactive = 1";
|
||||
|
||||
// $result = $this->ProductModel->query($sql, ['"' . $id . '"'])->getResult();
|
||||
// $products = array_merge($products, $result);
|
||||
// }
|
||||
|
||||
// return $this->response->setJSON($products);
|
||||
// }
|
||||
|
||||
// public function get_product_by_models(){
|
||||
// $make_id = $this->request->getPost('make_id');
|
||||
|
||||
@ -89,21 +89,21 @@
|
||||
$bp = trim($invoice[0]->billing_postal_code ?? '');
|
||||
if ($bp === '0' || $bp === 0) {$bp = '';}
|
||||
$address = '';
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp.";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs.";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp.";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp.";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc.";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs.";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp.";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp.";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs.";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp.";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp.";
|
||||
} elseif ($ba) { $address = "$ba.";
|
||||
} elseif ($bc) { $address = "$bc.";
|
||||
} elseif ($bs) { $address = "$bs.";
|
||||
} elseif ($bp) { $address = "$bp.";
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp,";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs,";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp,";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp,";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc,";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs,";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp,";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp,";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs,";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp,";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp,";
|
||||
} elseif ($ba) { $address = "$ba,";
|
||||
} elseif ($bc) { $address = "$bc,";
|
||||
} elseif ($bs) { $address = "$bs,";
|
||||
} elseif ($bp) { $address = "$bp,";
|
||||
} else { $address = '-';}
|
||||
echo $address;
|
||||
?>
|
||||
|
||||
@ -79,21 +79,21 @@
|
||||
$bp = trim($sales[0]->billing_postal_code ?? '');
|
||||
if ($bp === '0' || $bp === 0) {$bp = '';}
|
||||
$address = '';
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp.";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs.";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp.";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp.";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc.";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs.";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp.";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp.";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs.";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp.";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp.";
|
||||
} elseif ($ba) { $address = "$ba.";
|
||||
} elseif ($bc) { $address = "$bc.";
|
||||
} elseif ($bs) { $address = "$bs.";
|
||||
} elseif ($bp) { $address = "$bp.";
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp,";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs,";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp,";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp,";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc,";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs,";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp,";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp,";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs,";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp,";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp,";
|
||||
} elseif ($ba) { $address = "$ba,";
|
||||
} elseif ($bc) { $address = "$bc,";
|
||||
} elseif ($bs) { $address = "$bs,";
|
||||
} elseif ($bp) { $address = "$bp,";
|
||||
} else { $address = '';}
|
||||
echo $address;
|
||||
?>
|
||||
|
||||
@ -55,7 +55,33 @@
|
||||
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= date("d-m-Y", strtotime($job_card[0]['created_at'])); ?></td>
|
||||
</tr>
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 49.4096%; height: 18px; font-size: small;"><?= $job_card[0]['billing_address']; ?>,<?= $job_card[0]['billing_city']; ?>,<?= $job_card[0]['billing_state']; ?>-<?= $job_card[0]['billing_postal_code']; ?>,</td>
|
||||
<td style="width: 49.4096%; height: 18px; font-size: small;">
|
||||
<?php
|
||||
$ba = trim($job_card[0]['billing_address'] ?? '');
|
||||
$bc = trim($job_card[0]['billing_city'] ?? '');
|
||||
$bs = trim($job_card[0]['billing_state'] ?? '');
|
||||
$bp = trim($job_card[0]['billing_postal_code'] ?? '');
|
||||
if ($bp === '0' || $bp === 0) {$bp = '';}
|
||||
$address = '';
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp,";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs,";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp,";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp,";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc,";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs,";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp,";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp,";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs,";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp,";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp,";
|
||||
} elseif ($ba) { $address = "$ba,";
|
||||
} elseif ($bc) { $address = "$bc,";
|
||||
} elseif ($bs) { $address = "$bs,";
|
||||
} elseif ($bp) { $address = "$bp,";
|
||||
} else { $address = '-';}
|
||||
echo $address;
|
||||
?>
|
||||
</td>
|
||||
<td style="width: 1.9685%; height: 18px;"> </td>
|
||||
<td style="width: 30.3148%; height: 18px; text-align: right; font-size: small;">Payment Mode:</td>
|
||||
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= $job_card[0]['mode_of_payment']; ?></td>
|
||||
|
||||
@ -52,35 +52,24 @@
|
||||
<h4 class="header-title">Product Details :</h4><br>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Make"></i>' ?>
|
||||
<select class="form-control SelExample" id="make" name="make[]" required multiple>
|
||||
<option value="">Select a Make</option>
|
||||
<!-- Options for make -->
|
||||
<?php foreach ($make as $value): ?>
|
||||
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && in_array($value['make_id'], $products['make_id']) ? 'selected' : '' ?>>
|
||||
<?= $value['make'] ?>
|
||||
<div class="form-group col-md-8">
|
||||
<label for="cubic_centimeter_id" class="col-form-label">Capacity in Cubic Centimeter (C.C.)<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="CCselect" name="cubic_centimeter_id[]" required multiple>
|
||||
<!-- <option value="">Select a Capacity in Cubic Centimeter (C.C.)</option> -->
|
||||
<!-- Options for CC -->
|
||||
<?php $cubic_ids = isset($products['cubic_centimeter_id'])
|
||||
? json_decode($products['cubic_centimeter_id'], true)
|
||||
: [];
|
||||
?>
|
||||
<?php foreach ($capacity as $cc): ?>
|
||||
<option value="<?= $cc['id'] ?>"
|
||||
<?= in_array($cc['id'], (array)$cubic_ids) ? 'selected' : '' ?>>
|
||||
<?= $cc['value'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
|
||||
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Modal"></i>'; ?>
|
||||
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
||||
<!-- Options for model will be populated dynamically via AJAX -->
|
||||
<?php if(isset($models) && !empty($models)): ?>
|
||||
<?php foreach ($models as $make_models): ?>
|
||||
<?php foreach ($make_models as $model): ?>
|
||||
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], $products['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
|
||||
@ -124,9 +113,13 @@
|
||||
<select class="form-control SelExample" id="vendor" name="vendor[]" required multiple>
|
||||
<!-- Placeholder option -->
|
||||
<option value="">Select Vendor</option>
|
||||
|
||||
<?php $vendor_ids = isset($products['vendor'])
|
||||
? json_decode($products['vendor'], true)
|
||||
: [];
|
||||
?>
|
||||
<?php foreach ($vendors as $vendor): ?>
|
||||
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && in_array($vendor['vendor_id'], json_decode($products['vendor'], true)) ? 'selected' : '' ?>>
|
||||
<option value="<?= $vendor['vendor_id'] ?>"
|
||||
<?= in_array($vendor['vendor_id'], (array)$vendor_ids) ? 'selected' : '' ?>>
|
||||
<?= $vendor['vendor_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
@ -273,7 +266,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '0' ?>" required>
|
||||
</div>
|
||||
</div><br>
|
||||
<h4 class="header-title">Description Details :</h4><br>
|
||||
@ -553,95 +546,93 @@ $(document).ready(function(){
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
var makeData = <?php echo json_encode($make); ?>;
|
||||
$('#make').change(function() {
|
||||
var make_id = $(this).val(); // Get the selected make ID
|
||||
make_value = $('option:selected', this).text();
|
||||
var models_id = $('#model').val();
|
||||
if (make_id.includes('0')) {
|
||||
// $(document).ready(function() {
|
||||
// var makeData = <?php // echo json_encode($make); ?>;
|
||||
// $('#make').change(function() {
|
||||
// var make_id = $(this).val(); // Get the selected make ID
|
||||
// make_value = $('option:selected', this).text();
|
||||
// var models_id = $('#model').val();
|
||||
// if (make_id.includes('0')) {
|
||||
|
||||
$('#make').empty();
|
||||
$('#make').append('<option value="" disabled > Select a Make </option>')
|
||||
if (makeData.length > 0) {
|
||||
makeData.forEach(function(make) {
|
||||
if(make.make_id == 0){
|
||||
$('#make').append('<option value="' + make.make_id + '" selected >' + make.make + '</option>')
|
||||
}else{
|
||||
$('#make').append('<option value="' + make.make_id + '" disabled >' + make.make + '</option>');
|
||||
}
|
||||
});
|
||||
$('#model').trigger('change');
|
||||
}
|
||||
make_id = ['0'];
|
||||
} else {
|
||||
// Enable all options if 'General' is not selected
|
||||
$('#make option').each(function () {
|
||||
$(this).prop('disabled', false); // Enable the option
|
||||
});
|
||||
}
|
||||
$('#makeSelect').empty(); // Clear existing options
|
||||
console.log(make_id);
|
||||
// $('#make').empty();
|
||||
// $('#make').append('<option value="" disabled > Select a Make </option>')
|
||||
// if (makeData.length > 0) {
|
||||
// makeData.forEach(function(make) {
|
||||
// if(make.make_id == 0){
|
||||
// $('#make').append('<option value="' + make.make_id + '" selected >' + make.make + '</option>')
|
||||
// }else{
|
||||
// $('#make').append('<option value="' + make.make_id + '" disabled >' + make.make + '</option>');
|
||||
// }
|
||||
// });
|
||||
// $('#model').trigger('change');
|
||||
// }
|
||||
// make_id = ['0'];
|
||||
// } else {
|
||||
// // Enable all options if 'General' is not selected
|
||||
// $('#make option').each(function () {
|
||||
// $(this).prop('disabled', false); // Enable the option
|
||||
// });
|
||||
// }
|
||||
// $('#makeSelect').empty(); // Clear existing options
|
||||
// console.log(make_id);
|
||||
|
||||
// Assuming make is an array of objects
|
||||
var filteredMakes = makeData.filter(function(item) {
|
||||
return make_id.includes(String(item.make_id)); // Check if make_id matches in the array
|
||||
});
|
||||
// // Assuming make is an array of objects
|
||||
// var filteredMakes = makeData.filter(function(item) {
|
||||
// return make_id.includes(String(item.make_id)); // Check if make_id matches in the array
|
||||
// });
|
||||
|
||||
// Check if filteredMakes has any results
|
||||
if (filteredMakes.length > 0) {
|
||||
filteredMakes.forEach(function(make) {
|
||||
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
});
|
||||
} else {
|
||||
console.log('No matching makes found!');
|
||||
}
|
||||
// // Check if filteredMakes has any results
|
||||
// if (filteredMakes.length > 0) {
|
||||
// filteredMakes.forEach(function(make) {
|
||||
// $('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
// });
|
||||
// } else {
|
||||
// console.log('No matching makes found!');
|
||||
// }
|
||||
|
||||
// $('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
||||
$('#makeSelectMessage').hide();
|
||||
// // $('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
||||
// $('#makeSelectMessage').hide();
|
||||
|
||||
// AJAX request to get models based on the selected make ID
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { make_id: make_id }, // Send the selected make ID to the controller
|
||||
success: function(response) {
|
||||
// Update models dropdown based on the response
|
||||
if (response.length > 0) {
|
||||
// Clear existing options
|
||||
$('#model').empty();
|
||||
// Iterate through response and models_id
|
||||
$.each(response, function(index, model) {
|
||||
var count =0;
|
||||
$.each(models_id, function(index, model_id) {
|
||||
if (model.model_id == model_id) {
|
||||
// Append option for the model
|
||||
$('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>');
|
||||
count =1;
|
||||
}
|
||||
});
|
||||
if (count == 0) {
|
||||
$('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
}
|
||||
// // AJAX request to get models based on the selected make ID
|
||||
// $('#loader').show();
|
||||
// $.ajax({
|
||||
// url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
// type: 'POST',
|
||||
// dataType: 'json',
|
||||
// data: { make_id: make_id }, // Send the selected make ID to the controller
|
||||
// success: function(response) {
|
||||
// // Update models dropdown based on the response
|
||||
// if (response.length > 0) {
|
||||
// // Clear existing options
|
||||
// $('#model').empty();
|
||||
// // Iterate through response and models_id
|
||||
// $.each(response, function(index, model) {
|
||||
// var count =0;
|
||||
// $.each(models_id, function(index, model_id) {
|
||||
// if (model.model_id == model_id) {
|
||||
// // Append option for the model
|
||||
// $('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>');
|
||||
// count =1;
|
||||
// }
|
||||
// });
|
||||
// if (count == 0) {
|
||||
// $('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
// }
|
||||
|
||||
});
|
||||
} else {
|
||||
// Handle case when no models are found
|
||||
$('#model').empty().append('<option value="">No models found</option>');
|
||||
}
|
||||
$('#loader').hide();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
// });
|
||||
// } else {
|
||||
// // Handle case when no models are found
|
||||
// $('#model').empty().append('<option value="">No models found</option>');
|
||||
// }
|
||||
// $('#loader').hide();
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// // Handle error
|
||||
// console.error(xhr.responseText);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
</script>
|
||||
<script>
|
||||
$('#qty_in_stock').on('keyup change', function() {
|
||||
|
||||
@ -175,7 +175,10 @@
|
||||
<select class="form-control book-select SelExample purchase_order_product_edit" name="item_details[]" required data-toggle="select2" id="" style="width: 280px !important;" readonly>
|
||||
<option value="">Select a Product</option>
|
||||
<?php foreach ($product as $value) : ?>
|
||||
<?php if ($value['per'] == 'ml') {
|
||||
<?php
|
||||
$value_name = $value["product_name"];
|
||||
$value_manufacturer_name = (!empty($value["manufacturer_name"]) ? ' - ' . $value["manufacturer_name"] : '') ;
|
||||
if ($value['per'] == 'ml') {
|
||||
$value_ml = ' ('.$value['ml'].$value['per'].')';
|
||||
} else {
|
||||
$value_ml = '';
|
||||
@ -183,7 +186,7 @@
|
||||
?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
||||
<?= $value_name . $value_ml . $value_manufacturer_name ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
@ -504,7 +507,9 @@ $(document).ready(function() {
|
||||
}
|
||||
if (valuesArray.indexOf(product.product_id.toString()) === -1) {
|
||||
|
||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +" - " + product.manufacturer_name + '</option>';
|
||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
newRow += '</select></td>' +
|
||||
|
||||
@ -18,7 +18,23 @@
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 33.3333%; font-size: small;"><?= "Date ". date("d-m-Y", strtotime($purchase[0]->order_date)); ?></td>
|
||||
<td style="width: 4.98683%;"> </td>
|
||||
<td style="width: 61.6798%; text-align: right; font-size: small;"><?= $purchase[0]->company_city; ?>,<?= $purchase[0]->company_state; ?>-<?= $purchase[0]->company_postal_code; ?></td>
|
||||
<td style="width: 61.6798%; text-align: right; font-size: small;">
|
||||
<?php
|
||||
$c = trim($purchase[0]->company_city ?? '');
|
||||
$s = trim($purchase[0]->company_state ?? '');
|
||||
$p = trim($purchase[0]->company_postal_code ?? '');
|
||||
if ($p === '0' || $p === 0) { $p = ''; }
|
||||
$output = '';
|
||||
if ($c && $s && $p) { $output = "$c, $s - $p.";
|
||||
} elseif ($c && $s) { $output = "$c, $s.";
|
||||
} elseif ($c && $p) { $output = "$c - $p.";
|
||||
} elseif ($s && $p) { $output = "$s - $p.";
|
||||
} elseif ($c) { $output = "$c.";
|
||||
} elseif ($s) { $output = "$s.";
|
||||
} elseif ($p) { $output = "$p."; }
|
||||
echo $output;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="height: 18px;">
|
||||
|
||||
@ -166,6 +166,7 @@
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="itemTableContainer">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
@ -206,9 +207,9 @@
|
||||
}
|
||||
?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option data-id="<?= $value["product_names_id"] ?>" value="<?= $value["product_id"] ?>"
|
||||
<?= isset($salechild['product_id']) && $salechild['product_names_id'] == $value["product_names_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["additional_product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
||||
<option value="<?= $value["product_id"] ?>"
|
||||
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"].$value_ml.($value["manufacturer_name"] ? ' - '.$value["manufacturer_name"] : ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
@ -396,7 +397,7 @@
|
||||
<option value="">Select a Client</option>
|
||||
<?php foreach ($client as $value) : ?>
|
||||
<option value="<?= $value["client_id"] ?>">
|
||||
<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>
|
||||
<?= $value["client_name"]; ?> <!-- $value["mobile_no"] .' - '. $value["client_name"]; -->
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@ -456,7 +457,7 @@ $(document).ready(function() {
|
||||
var vehicleId = $(this).val();
|
||||
console.log("**");
|
||||
console.log(vehicleId);
|
||||
|
||||
$('input[id="makeAndModel"],input[name="client_id"], input[name="client_name"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected vehicle
|
||||
var selectedVehicle = vehicles.find(function(vehicle) {
|
||||
@ -752,8 +753,11 @@ $(document).ready(function() {
|
||||
var product = productarray[i];
|
||||
if(!selected_pr.includes(product.product_id))
|
||||
{
|
||||
newRow += '<option data-id="'+ product.product_names_id +'" value="' + product.product_id + '" >' + product.additional_product_name + value_ml + " - " + product.manufacturer_name+
|
||||
'</option>';
|
||||
newRow += '<option value="' + product.product_id + '" >' +
|
||||
+ value_ml +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>';
|
||||
|
||||
}
|
||||
}
|
||||
newRow += '</select></td>' +
|
||||
@ -831,12 +835,11 @@ $(document).ready(function() {
|
||||
var selectedClient = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
});
|
||||
|
||||
|
||||
console.log(":( ",selectedClient);// sad
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('textarea[name="billing_address"]').val(selectedClient.address);
|
||||
// $('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="country"]').val(selectedClient.country);
|
||||
@ -1129,34 +1132,40 @@ $(document).on('click', '#selectClient', function() {
|
||||
|
||||
|
||||
$(window).on('load', function() {
|
||||
// This code will execute after the page has been reloaded
|
||||
vehicle_id = localStorage.getItem('vehicle_id');
|
||||
localStorage.removeItem('vehicle_id');
|
||||
if(vehicle_id) {
|
||||
var vehicleId = vehicle_id;
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected client in the client data
|
||||
var selectedClient = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
});
|
||||
var makeId = selectedClient.make;
|
||||
var modelId = selectedClient.model;
|
||||
|
||||
var vehicle_id = localStorage.getItem('vehicle_id');
|
||||
|
||||
fetchMakeAndModel(makeId, modelId);
|
||||
console.log(selectedClient);
|
||||
if (vehicle_id) {
|
||||
|
||||
$('#vehicle_id').val(vehicle_id).trigger('change');
|
||||
localStorage.removeItem('vehicle_id');
|
||||
|
||||
$('input[id="makeAndModel"], input[name="client_id"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
|
||||
|
||||
// Find the selected vehicle details
|
||||
var selectedVehicle = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicle_id;
|
||||
});
|
||||
|
||||
if (selectedVehicle) {
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
var makeId = selectedVehicle.make;
|
||||
var modelId = selectedVehicle.model;
|
||||
fetchMakeAndModel(makeId, modelId);
|
||||
|
||||
// Fill client & vehicle info fields
|
||||
$('input[name="client_id"]').val(selectedVehicle.client_id);
|
||||
$('textarea[name="billing_address"]').val(selectedVehicle.address);
|
||||
// $('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="country"]').val(selectedClient.country);
|
||||
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
||||
$('input[name="postalcode"]').val(selectedClient.postal_code);
|
||||
$('input[name="city"]').val(selectedVehicle.city);
|
||||
$('input[name="state"]').val(selectedVehicle.state);
|
||||
$('input[name="country"]').val(selectedVehicle.country);
|
||||
$('input[name="mobile_no"]').val(selectedVehicle.mobile_no);
|
||||
$('input[name="email"]').val(selectedVehicle.email);
|
||||
$('input[name="postalcode"]').val(selectedVehicle.postal_code);
|
||||
} else {
|
||||
console.warn("⚠️ Vehicle not found in 'vehicles' list for ID:", vehicle_id);
|
||||
}
|
||||
|
||||
$('#vehicle_name').val(vehicle_id).trigger('change');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -1176,7 +1185,7 @@ $(document).on('click', '#selectClient', function() {
|
||||
success: function(response) {
|
||||
// console.log(response);
|
||||
// Populate make and model in the input field
|
||||
var makeAndModel = response.makeName + ' ' + response.modelName;
|
||||
var makeAndModel = response.makeName + ' - ' + response.modelName;
|
||||
$('#makeAndModel').val(makeAndModel);
|
||||
|
||||
if(response.product.length){
|
||||
@ -1202,8 +1211,9 @@ $(document).on('click', '#selectClient', function() {
|
||||
<script>
|
||||
|
||||
function addProductNamesId(selectElement) {
|
||||
var product_names_id = $(selectElement).find('option:selected').attr('data-id');
|
||||
$(selectElement).closest('tr').find('input[name="product_names_id[]"]').val(product_names_id);
|
||||
if (!selectElement) return; // safety
|
||||
// var product_names_id = $(selectElement).find('option:selected').attr('data-id');
|
||||
// $(selectElement).closest('tr').find('input[name="product_names_id[]"]').val(product_names_id);
|
||||
}
|
||||
|
||||
// Prevent multiple submissions by disabling the button on first click
|
||||
|
||||
@ -292,7 +292,10 @@ $(document).ready(function() {
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
$.each(response, function(index, product) {
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - '+ product.manufacturer_name + '</option>');
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' +
|
||||
product.product_name +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
|
||||
Loading…
Reference in New Issue
Block a user