FEAT_ADDITIONAL_PRODUCT_NAME : RV
This commit is contained in:
parent
d5c20cd5ce
commit
67ac9d4ff3
@ -3,25 +3,27 @@
|
|||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Models\ProductModel;
|
use App\Models\ProductModel;
|
||||||
use App\Models\BikemakeModel;
|
use App\Models\BikemakeModel;
|
||||||
use App\Models\VendorModel;
|
use App\Models\VendorModel;
|
||||||
use App\Models\BikemodelsModel;
|
use App\Models\BikemodelsModel;
|
||||||
use App\Models\ManufacturerModel;
|
use App\Models\ManufacturerModel;
|
||||||
use App\Models\ProductCategoryModel;
|
use App\Models\ProductCategoryModel;
|
||||||
|
use App\Models\AdditionalProductNameModal;
|
||||||
|
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
class Products extends BaseController
|
class Products extends BaseController
|
||||||
{
|
{
|
||||||
|
protected $additionalProductNameModal;
|
||||||
|
|
||||||
public $session;
|
public $session;
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
|
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function product_index($manufacturer_id = null)
|
public function product_index($manufacturer_id = null)
|
||||||
@ -53,11 +55,6 @@ class Products extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function new_product($product_id)
|
public function new_product($product_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -80,7 +77,9 @@ class Products extends BaseController
|
|||||||
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
||||||
$data['productcategory']=$productcategory;
|
$data['productcategory']=$productcategory;
|
||||||
$data['vendorsProduct'] =[];
|
$data['vendorsProduct'] =[];
|
||||||
|
|
||||||
} else if ($product_id !== '0') {
|
} else if ($product_id !== '0') {
|
||||||
|
|
||||||
$data['page_name']="Edit Product";
|
$data['page_name']="Edit Product";
|
||||||
$ProductModel = new ProductModel();
|
$ProductModel = new ProductModel();
|
||||||
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||||
@ -118,35 +117,43 @@ class Products extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
$vendors = [];
|
$vendors = [];
|
||||||
$VendorModel = new VendorModel();
|
|
||||||
foreach ($vendorIds as $vendorId) {
|
|
||||||
$vendor = $VendorModel->find($vendorId);
|
|
||||||
if ($vendor) {
|
|
||||||
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$data['vendorsProduct'] = $vendors;
|
|
||||||
// print_r($data['vendors']);die;
|
|
||||||
|
|
||||||
$preferredVendorId = $products['prefered_vendor'];
|
|
||||||
// Pass the preferred vendor ID to the view
|
$VendorModel = new VendorModel();
|
||||||
$data['preferredVendorId'] = $preferredVendorId; // print_r($data);die;
|
foreach ($vendorIds as $vendorId) {
|
||||||
// print_r($data);die;
|
$vendor = $VendorModel->find($vendorId);
|
||||||
|
if ($vendor) {
|
||||||
|
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['vendorsProduct'] = $vendors;
|
||||||
|
// print_r($data['vendors']);die;
|
||||||
|
|
||||||
|
$preferredVendorId = $products['prefered_vendor'];
|
||||||
|
// Pass the preferred vendor ID to the view
|
||||||
|
$data['preferredVendorId'] = $preferredVendorId; // print_r($data);die;
|
||||||
|
// print_r($data);die;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['product_id'] = $product_id;
|
$data['product_id'] = $product_id;
|
||||||
$ProductCategoryModel = new ProductCategoryModel();
|
$ProductCategoryModel = new ProductCategoryModel();
|
||||||
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
|
||||||
|
$additionalProdutName = $this->additionalProductNameModal->where('product_id', $product_id)->orderBy('product_names_id')->findAll();
|
||||||
$data['productcategory']=$productcategory;
|
$data['productcategory']=$productcategory;
|
||||||
// print_r($data);die;
|
$data['additionalProdutName']=$additionalProdutName;
|
||||||
|
|
||||||
|
// dd($data);
|
||||||
|
// print_r($data);die;
|
||||||
// echo "<pre>";
|
// echo "<pre>";
|
||||||
// print_r($data['manufacturers']);die;
|
// print_r($data['manufacturers']);die;
|
||||||
|
|
||||||
echo view('product_form',$data);
|
echo view('product_form',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add_product()
|
public function add_product()
|
||||||
{
|
{
|
||||||
|
// dd($this->request->getPost());
|
||||||
|
|
||||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||||
$ProductModel = new ProductModel();
|
$ProductModel = new ProductModel();
|
||||||
|
|
||||||
@ -198,17 +205,20 @@ class Products extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
$product_id = $this->request->getPost('product_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');
|
||||||
|
|
||||||
// print_r($data);die;
|
// print_r($data);die;
|
||||||
if (!empty($product_id)) {
|
if (!empty($product_id)) {
|
||||||
|
|
||||||
$ProductModel->update($product_id, $data);
|
$ProductModel->update($product_id, $data);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$ProductModel->insert($data);
|
$ProductModel->insert($data);
|
||||||
$product_id = $ProductModel->getInsertID();
|
$product_id = $ProductModel->getInsertID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for insert or update Additional Product Names
|
||||||
|
$this->insertOrUpdateAdditionalProductName($additional_product_name, $product_names_id, $product_id, $data['product_name']);
|
||||||
|
|
||||||
$orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT);
|
$orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
// Update sales order with generated order number
|
// Update sales order with generated order number
|
||||||
@ -236,64 +246,60 @@ class Products extends BaseController
|
|||||||
return redirect()->to('product_index');
|
return redirect()->to('product_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the make_id from the AJAX request
|
// Retrieve the make_id from the AJAX request
|
||||||
public function get_vendors_by_model()
|
public function get_vendors_by_model()
|
||||||
{
|
{
|
||||||
|
|
||||||
$model_ids = $this->request->getPost('model_ids');
|
$model_ids = $this->request->getPost('model_ids');
|
||||||
$make_id = $this->request->getPost('make_id');
|
$make_id = $this->request->getPost('make_id');
|
||||||
$vendorModel = new VendorModel();
|
$vendorModel = new VendorModel();
|
||||||
$Vendors = $vendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
$Vendors = $vendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||||
if($Vendors){
|
if($Vendors){
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach ($model_ids as $modelKey => $modelValue)
|
foreach ($model_ids as $modelKey => $modelValue)
|
||||||
|
{
|
||||||
|
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
||||||
{
|
{
|
||||||
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
print_r($vendorsValue);die;
|
||||||
|
$modelsArray = json_decode($vendorsValue['model'], true);
|
||||||
|
if (is_array($modelsArray))
|
||||||
{
|
{
|
||||||
print_r($vendorsValue);die;
|
$findIfModelExist = array_search($modelValue, $modelsArray);
|
||||||
$modelsArray = json_decode($vendorsValue['model'], true);
|
if ($findIfModelExist !== false)
|
||||||
if (is_array($modelsArray))
|
|
||||||
{
|
{
|
||||||
$findIfModelExist = array_search($modelValue, $modelsArray);
|
array_push($data,$vendorsValue);
|
||||||
if ($findIfModelExist !== false)
|
|
||||||
{
|
|
||||||
array_push($data,$vendorsValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($data)) {
|
|
||||||
|
|
||||||
$arrayOfArrays = array_map(function($obj) {
|
|
||||||
return (array) $obj;
|
|
||||||
}, $data);
|
|
||||||
|
|
||||||
// Remove duplicates based on string representation of each object
|
|
||||||
$uniqueArray = array_map('unserialize', array_unique(array_map('serialize', $arrayOfArrays)));
|
|
||||||
|
|
||||||
// Convert the unique array of associative arrays back to an array of objects
|
|
||||||
$uniqueObjectsArray = array_map(function($arr) {
|
|
||||||
return (object) $arr;
|
|
||||||
}, $uniqueArray);
|
|
||||||
|
|
||||||
return $this->response->setJSON($uniqueArray);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return $this->response->setJSON([]);
|
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
|
if (count($data)) {
|
||||||
|
|
||||||
|
$arrayOfArrays = array_map(function($obj) {
|
||||||
|
return (array) $obj;
|
||||||
|
}, $data);
|
||||||
|
|
||||||
|
// Remove duplicates based on string representation of each object
|
||||||
|
$uniqueArray = array_map('unserialize', array_unique(array_map('serialize', $arrayOfArrays)));
|
||||||
|
|
||||||
|
// Convert the unique array of associative arrays back to an array of objects
|
||||||
|
$uniqueObjectsArray = array_map(function($arr) {
|
||||||
|
return (object) $arr;
|
||||||
|
}, $uniqueArray);
|
||||||
|
|
||||||
|
return $this->response->setJSON($uniqueArray);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
return $this->response->setJSON([]);
|
return $this->response->setJSON([]);
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
|
||||||
|
return $this->response->setJSON([]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function get_models()
|
public function get_models()
|
||||||
{
|
{
|
||||||
@ -328,10 +334,8 @@ class Products extends BaseController
|
|||||||
return $this->response->setJSON($formatted_models);
|
return $this->response->setJSON($formatted_models);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save_make()
|
||||||
|
{
|
||||||
|
|
||||||
public function save_make() {
|
|
||||||
$response = []; // Initialize an empty array to hold the response data
|
$response = []; // Initialize an empty array to hold the response data
|
||||||
|
|
||||||
// Assuming BikemakeModel and BikemodelsModel are properly defined
|
// Assuming BikemakeModel and BikemodelsModel are properly defined
|
||||||
@ -372,13 +376,16 @@ class Products extends BaseController
|
|||||||
// Send JSON response back to the client
|
// Send JSON response back to the client
|
||||||
return $this->response->setJSON($response);
|
return $this->response->setJSON($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_makes()
|
public function get_makes()
|
||||||
{
|
{
|
||||||
$BikeMakeModel = new BikeMakeModel(); // Adjust this according to your actual model name
|
$BikeMakeModel = new BikeMakeModel(); // Adjust this according to your actual model name
|
||||||
$makes = $BikeMakeModel->findAll();
|
$makes = $BikeMakeModel->findAll();
|
||||||
return $this->response->setJSON($makes);
|
return $this->response->setJSON($makes);
|
||||||
}
|
}
|
||||||
public function save_model() {
|
|
||||||
|
public function save_model()
|
||||||
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
$BikemodelsModel = new BikemodelsModel();
|
$BikemodelsModel = new BikemodelsModel();
|
||||||
|
|
||||||
@ -409,9 +416,8 @@ class Products extends BaseController
|
|||||||
return $this->response->setJSON($response);
|
return $this->response->setJSON($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save_manufacturer()
|
||||||
|
{
|
||||||
public function save_manufacturer(){
|
|
||||||
$response = [];
|
$response = [];
|
||||||
$ManufacturerModel = new ManufacturerModel();
|
$ManufacturerModel = new ManufacturerModel();
|
||||||
|
|
||||||
@ -443,7 +449,8 @@ class Products extends BaseController
|
|||||||
return $this->response->setJSON($response);
|
return $this->response->setJSON($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function product_list_for_service(){
|
public function product_list_for_service()
|
||||||
|
{
|
||||||
$ProductModel = new ProductModel();
|
$ProductModel = new ProductModel();
|
||||||
// Assuming you have a model for products and one for manufacturers
|
// Assuming you have a model for products and one for manufacturers
|
||||||
$products = $ProductModel
|
$products = $ProductModel
|
||||||
@ -455,7 +462,6 @@ class Products extends BaseController
|
|||||||
return $this->response->setJSON($products);
|
return $this->response->setJSON($products);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function status_product()
|
public function status_product()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -481,4 +487,44 @@ class Products extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----VENKAT------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function insertOrUpdateAdditionalProductName($product_names, $product_name_id, $product_id, $first_product_name)
|
||||||
|
{
|
||||||
|
$firstProductNameData = [
|
||||||
|
'product_id' => $product_id,
|
||||||
|
'additional_product_name' => $first_product_name,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Delete existing records for the given product ID
|
||||||
|
$this->additionalProductNameModal->where('product_id', $product_id)->delete();
|
||||||
|
|
||||||
|
// Insert the first product name (if any)
|
||||||
|
$this->additionalProductNameModal->insert($firstProductNameData);
|
||||||
|
|
||||||
|
$productNameData = [];
|
||||||
|
|
||||||
|
// If there are additional product names, loop through and prepare them
|
||||||
|
if (!empty($product_names) && count($product_names) > 0) {
|
||||||
|
|
||||||
|
foreach ($product_names as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
$productNameData[] = [
|
||||||
|
'product_id' => $product_id,
|
||||||
|
'additional_product_name' => $name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert additional product names in batch if there are valid entries
|
||||||
|
if (!empty($productNameData) && count($product_names) > 0) {
|
||||||
|
$this->additionalProductNameModal->insertBatch($productNameData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -11,22 +11,27 @@ use App\Models\BikemakeModel;
|
|||||||
use App\Models\VehicleModel;
|
use App\Models\VehicleModel;
|
||||||
use App\Models\BusinessModel;
|
use App\Models\BusinessModel;
|
||||||
use App\Models\BranchModel;
|
use App\Models\BranchModel;
|
||||||
|
use App\Models\AdditionalProductNameModal;
|
||||||
|
|
||||||
|
|
||||||
use Mpdf\Mpdf;
|
use Mpdf\Mpdf;
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
use App\Helpers\InvNoHelper;
|
use App\Helpers\InvNoHelper;
|
||||||
|
|
||||||
class Sales extends BaseController
|
class Sales extends BaseController
|
||||||
{
|
{
|
||||||
public $session;
|
public $session;
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
protected $BikemodelsModel;
|
protected $BikemodelsModel;
|
||||||
protected $BikemakeModel;
|
protected $BikemakeModel;
|
||||||
|
protected $additionalProductNameModal;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
$this->BikemodelsModel = new BikemodelsModel();
|
$this->BikemodelsModel = new BikemodelsModel();
|
||||||
$this->BikemakeModel = new BikemakeModel();
|
$this->BikemakeModel = new BikemakeModel();
|
||||||
|
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sales_order_index()
|
public function sales_order_index()
|
||||||
@ -41,7 +46,6 @@ class Sales extends BaseController
|
|||||||
return view('sales_list',$data);
|
return view('sales_list',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function new_sale($sales_order_id)
|
public function new_sale($sales_order_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -71,8 +75,7 @@ class Sales extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else if ($sales_order_id !== '0')
|
} else if ($sales_order_id !== '0') {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
$data['page_name']="Edit Sale Order";
|
$data['page_name']="Edit Sale Order";
|
||||||
@ -98,27 +101,33 @@ class Sales extends BaseController
|
|||||||
// Load the ProductModel
|
// Load the ProductModel
|
||||||
$productModel = new ProductModel();
|
$productModel = new ProductModel();
|
||||||
|
|
||||||
// Query the database to find the product based on make_id and model_id
|
// Query the database to find the product based on make_id and model_id
|
||||||
$makemodelproduct = $productModel->select('products.*, manufacturer.manufacturer_name')
|
$makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, 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']);
|
||||||
|
|
||||||
|
$common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.additional_product_name')
|
||||||
|
->join('products', 'products.product_id = product_names.product_id')
|
||||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||||
|
->where('qty_stock >',0)
|
||||||
|
->where('products.isactive', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$encodedMakeId1 = json_encode(['0']);
|
$product = array_merge($common_product, $makeproduct);
|
||||||
$encodedModelId1 = json_encode(['0']);
|
|
||||||
|
|
||||||
$common_product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
|
||||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
|
||||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId1 . '\')', null, false)
|
|
||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId1 . '\')', null, false)
|
|
||||||
->where('qty_stock >',0)
|
|
||||||
->where('products.isactive',1)
|
|
||||||
->findAll();
|
|
||||||
$product = array_merge($common_product, $makemodelproduct);
|
|
||||||
|
|
||||||
|
|
||||||
$data['product']=$product;
|
$data['product']=$product;
|
||||||
|
|
||||||
$SalesProductOrderModel = new SalesOrderProductModel();
|
$SalesProductOrderModel = new SalesOrderProductModel();
|
||||||
$sales_product=$SalesProductOrderModel->where('sales_order_id', $sales_order_id)->findAll();
|
$sales_product=$SalesProductOrderModel->where('sales_order_id', $sales_order_id)->findAll();
|
||||||
$data['sales_product']=$sales_product;
|
$data['sales_product']=$sales_product;
|
||||||
@ -139,7 +148,6 @@ class Sales extends BaseController
|
|||||||
return view('sales_order_form',$data);
|
return view('sales_order_form',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add_sales()
|
public function add_sales()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||||
@ -518,7 +526,8 @@ class Sales extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
// Query the database to find the product based on make_id and model_id
|
// Query the database to find the product based on make_id and model_id
|
||||||
$makeproduct = $productModel->select('products.*, manufacturer.manufacturer_name')
|
$makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.additional_product_name')
|
||||||
|
->join('products', 'products.product_id = product_names.product_id')
|
||||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||||
@ -529,15 +538,18 @@ class Sales extends BaseController
|
|||||||
$encodedMakeId = json_encode(['0']);
|
$encodedMakeId = json_encode(['0']);
|
||||||
$encodedModelId = json_encode(['0']);
|
$encodedModelId = json_encode(['0']);
|
||||||
|
|
||||||
$common_product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
$common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.additional_product_name')
|
||||||
|
->join('products', 'products.product_id = product_names.product_id')
|
||||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||||
->where('qty_stock >',0)
|
->where('qty_stock >',0)
|
||||||
->where('products.isactive', 1)
|
->where('products.isactive', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$product = array_merge($common_product, $makeproduct);
|
$product = array_merge($common_product, $makeproduct);
|
||||||
|
|
||||||
|
|
||||||
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
||||||
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
||||||
if($product){
|
if($product){
|
||||||
|
|||||||
25
app/Models/AdditionalProductNameModal.php
Normal file
25
app/Models/AdditionalProductNameModal.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class AdditionalProductNameModal extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'product_names';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $useAutoIncrement = true;
|
||||||
|
protected $returnType = 'array';
|
||||||
|
protected $useSoftDeletes = false;
|
||||||
|
protected $protectFields = true;
|
||||||
|
protected $allowedFields = [
|
||||||
|
'product_names_id',
|
||||||
|
'product_id',
|
||||||
|
'additional_product_name',
|
||||||
|
'isactive',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -232,7 +232,9 @@
|
|||||||
<label for="description" class="col-form-label">Description</label>
|
<label for="description" class="col-form-label">Description</label>
|
||||||
<textarea class="form-control" name="description" placeholder="Description"value="<?= isset($products['description']) ? $products['description'] : '' ?>" ></textarea>
|
<textarea class="form-control" name="description" placeholder="Description"value="<?= isset($products['description']) ? $products['description'] : '' ?>" ></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div><br>
|
||||||
|
<h4 class="header-title">Additional Product Names :</h4><br>
|
||||||
|
<div id="dynamic-form-container"></div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -364,6 +366,32 @@ $(document).ready(function() {
|
|||||||
$("input[name='hiddenproductcategory']").val($(this).val());
|
$("input[name='hiddenproductcategory']").val($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//---------VENKAT-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// for Additional Product Name Edit Purpose
|
||||||
|
var additionalProductName = <?= json_encode($additionalProdutName) ?>;
|
||||||
|
|
||||||
|
// console.log(additionalProductName);
|
||||||
|
// console.log(additionalProductName.length);
|
||||||
|
|
||||||
|
if (Array.isArray(additionalProductName) && additionalProductName.length > 0) {
|
||||||
|
|
||||||
|
var firstProductName = '<?= isset($products['product_name']) ? $products['product_name'] : '' ?>';
|
||||||
|
console.log('firstProductName', firstProductName);
|
||||||
|
additionalProductName.forEach(function(item) {
|
||||||
|
if (firstProductName !== item.additional_product_name) {
|
||||||
|
addHTMLInput(item); // for if edit
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(additionalProductName.length == 1){
|
||||||
|
addHTMLInput()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addHTMLInput(); // for else add
|
||||||
|
}
|
||||||
|
// end of Additional Product Name Edit Purpose
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -864,3 +892,39 @@ $('#saveMakeBtn').click(function() {
|
|||||||
top:4px;
|
top:4px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Script for add multiple product name -->
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function addHTMLInput(data = null)
|
||||||
|
{
|
||||||
|
const container = document.getElementById('dynamic-form-container');
|
||||||
|
const newRow = document.createElement('div');
|
||||||
|
newRow.className = 'form-row dynamic-form-row';
|
||||||
|
newRow.innerHTML = `
|
||||||
|
<input value="${data != null && data.product_names_id != null ? data.product_names_id : ''}" type="hidden" name="product_names_id[]" >
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<input value="${data != null && data.additional_product_name != null ? data.additional_product_name : ''}" type="text" class="form-control" id="additional_product_name" name="additional_product_name[]" placeholder="Enter Additional Product name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||||
|
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
container.appendChild(newRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeHTMLInput(element)
|
||||||
|
{
|
||||||
|
const container = document.getElementById('dynamic-form-container');
|
||||||
|
const rows = container.querySelectorAll('.dynamic-form-row');
|
||||||
|
|
||||||
|
if (rows.length > 1) {
|
||||||
|
const row = element.closest('.dynamic-form-row');
|
||||||
|
row.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@ -196,7 +196,7 @@
|
|||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
<option value="<?= $value["product_id"] ?>"
|
<option value="<?= $value["product_id"] ?>"
|
||||||
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||||
<?= $value["product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
<?= $value["additional_product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -721,7 +721,7 @@ $(document).ready(function() {
|
|||||||
var product = productarray[i];
|
var product = productarray[i];
|
||||||
if(!selected_pr.includes(product.product_id))
|
if(!selected_pr.includes(product.product_id))
|
||||||
{
|
{
|
||||||
newRow += '<option value="' + product.product_id + '" >' + product.product_name + value_ml + " - " + product.manufacturer_name+
|
newRow += '<option value="' + product.product_id + '" >' + product.additional_product_name + value_ml + " - " + product.manufacturer_name+
|
||||||
'</option>';
|
'</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user