diff --git a/.gitignore b/.gitignore index bb04af6..e8b17e5 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /writable -vendor/* +vendor .env !vendor/.gitkeep composer.lock \ No newline at end of file diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index bd22ac0..cebca91 100755 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -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]); diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 824fa21..cbf4a09 100755 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -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'), ]; diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php index 783d5c2..4b9bfe2 100755 --- a/app/Controllers/Purchase.php +++ b/app/Controllers/Purchase.php @@ -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 "
";
+ // 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');
diff --git a/app/Controllers/Reorderlevel.php b/app/Controllers/Reorderlevel.php
index 47070a4..d7d3edf 100755
--- a/app/Controllers/Reorderlevel.php
+++ b/app/Controllers/Reorderlevel.php
@@ -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;
diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php
index 9584235..29dc0be 100755
--- a/app/Controllers/ReturnOrder.php
+++ b/app/Controllers/ReturnOrder.php
@@ -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;
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index bb4d20f..77eec54 100755
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -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
diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php
index 5412a59..75a68f7 100755
--- a/app/Controllers/Service.php
+++ b/app/Controllers/Service.php
@@ -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');
diff --git a/app/Views/invoice_pdf_layout.php b/app/Views/invoice_pdf_layout.php
index 2ecfa25..788bf2c 100755
--- a/app/Views/invoice_pdf_layout.php
+++ b/app/Views/invoice_pdf_layout.php
@@ -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;
?>
diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php
index 63c7d85..08c3ab6 100755
--- a/app/Views/invoice_pdf_template.php
+++ b/app/Views/invoice_pdf_template.php
@@ -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;
?>
diff --git a/app/Views/invoice_pdf_template_jobcard.php b/app/Views/invoice_pdf_template_jobcard.php
index e4178a7..15c4411 100755
--- a/app/Views/invoice_pdf_template_jobcard.php
+++ b/app/Views/invoice_pdf_template_jobcard.php
@@ -55,7 +55,33 @@
= date("d-m-Y", strtotime($job_card[0]['created_at'])); ?>
- = $job_card[0]['billing_address']; ?>,= $job_card[0]['billing_city']; ?>,= $job_card[0]['billing_state']; ?>-= $job_card[0]['billing_postal_code']; ?>,
+
+
+
Payment Mode:
= $job_card[0]['mode_of_payment']; ?>
diff --git a/app/Views/product_form.php b/app/Views/product_form.php
index 50e6c93..86ba8fa 100755
--- a/app/Views/product_form.php
+++ b/app/Views/product_form.php
@@ -52,35 +52,24 @@
Product Details :
-
-
- = isset($products['product_id']) ? '' : '' ?>
-
Description Details :
@@ -553,95 +546,93 @@ $(document).ready(function(){
});