CHANGE_PRODUCT_MAKE_MULTIPLE : AADHAVAN
This commit is contained in:
parent
7e309f9594
commit
9935089af0
@ -129,6 +129,7 @@ $routes->get('dashboard', 'Users::dashboard');
|
|||||||
// Make //
|
// Make //
|
||||||
$routes->get('make_index', 'Make::index');
|
$routes->get('make_index', 'Make::index');
|
||||||
$routes->post('create_make/(:any)', 'Make::create_make/$1');
|
$routes->post('create_make/(:any)', 'Make::create_make/$1');
|
||||||
|
$routes->post('status_make', 'Make::status_make');
|
||||||
// Make End's //
|
// Make End's //
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
use App\Models\BikemodelsModel;
|
||||||
use App\Models\BikemakeModel;
|
use App\Models\BikemakeModel;
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
@ -40,10 +41,18 @@ class Make extends BaseController
|
|||||||
'make' => $make_name
|
'make' => $make_name
|
||||||
];
|
];
|
||||||
if (!$make_id) {
|
if (!$make_id) {
|
||||||
|
try {
|
||||||
$inserted = $BikemakeModel->insert($data);
|
$inserted = $BikemakeModel->insert($data);
|
||||||
|
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $e->getMessage()],200);
|
||||||
|
}
|
||||||
|
|
||||||
if ($inserted) {
|
if ($inserted) {
|
||||||
$result = $data;
|
$result = $data;
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
$make_list = $BikemakeModel->orderBy('make','asc')->findAll();
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $result,'make_list'=>$make_list],200);
|
||||||
} else {
|
} else {
|
||||||
$result = "No Match's";
|
$result = "No Match's";
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
||||||
@ -63,4 +72,39 @@ class Make extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function status_make()
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
$make_id = $this->request->getPost('make_id');
|
||||||
|
$isactive = $this->request->getPost('isactive');
|
||||||
|
|
||||||
|
$BikemakeModel = new BikemakeModel();
|
||||||
|
$BikemodelsModel = new BikemodelsModel();
|
||||||
|
$data = [
|
||||||
|
'isactive' => $isactive
|
||||||
|
];
|
||||||
|
$updated = $BikemakeModel->update($make_id, $data);
|
||||||
|
$make_list = $BikemakeModel->orderBy('make','asc')->findAll();
|
||||||
|
$model_list = $BikemodelsModel->where('make_id',$make_id)->findAll();
|
||||||
|
|
||||||
|
foreach ($model_list as $model) {
|
||||||
|
$model_id= $model['model_id'];
|
||||||
|
$model_updated = $BikemodelsModel->update($model_id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($updated) {
|
||||||
|
$result = $data;
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $make_list],200);
|
||||||
|
} else {
|
||||||
|
$result = "No Match's";
|
||||||
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
||||||
|
}
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -54,10 +54,18 @@ class Model extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (!$model_id) {
|
if (!$model_id) {
|
||||||
|
|
||||||
|
try {
|
||||||
$inserted = $BikemodelsModel->insert($data);
|
$inserted = $BikemodelsModel->insert($data);
|
||||||
|
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $e->getMessage()],200);
|
||||||
|
}
|
||||||
if ($inserted) {
|
if ($inserted) {
|
||||||
$result = $data;
|
$result = $data;
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
$model_list = $BikemodelsModel->where('make_id',$make_id)->orderBy('make','asc')->findAll();
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $result,'model_list'=>$model_list],200);
|
||||||
} else {
|
} else {
|
||||||
$result = "No Match's";
|
$result = "No Match's";
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
||||||
@ -93,10 +101,13 @@ class Model extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
$updated = $BikemodelsModel->update($model_id, $data);
|
$updated = $BikemodelsModel->update($model_id, $data);
|
||||||
$model_list = $BikemodelsModel->findAll();
|
$model = $BikemodelsModel->where('model_id',$model_id)->first();
|
||||||
|
|
||||||
|
$models = $BikemodelsModel->where('make_id', $model['make_id'])->orderBy('model_name', 'asc')->findAll();
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$result = $data;
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $model_list],200);
|
// $result = $data;
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $models],200);
|
||||||
} else {
|
} else {
|
||||||
$result = "No Match's";
|
$result = "No Match's";
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
||||||
|
|||||||
@ -74,13 +74,25 @@ class Products extends BaseController
|
|||||||
$ProductModel = new ProductModel();
|
$ProductModel = new ProductModel();
|
||||||
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
$products=$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);
|
||||||
|
|
||||||
|
|
||||||
$data['products']=$products;
|
$data['products']=$products;
|
||||||
|
|
||||||
$BikemakeModel = new BikemakeModel();
|
$BikemakeModel = new BikemakeModel();
|
||||||
$data['make'] = $BikemakeModel->findAll();
|
$data['make'] = $BikemakeModel->findAll();
|
||||||
$BikemodelsModel = new BikemodelsModel();
|
$BikemodelsModel = new BikemodelsModel();
|
||||||
$make_id = $products['make_id'];
|
$make_id = $products['make_id'];
|
||||||
$data['models'] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
$BikemodelsModel = new BikemodelsModel();
|
||||||
|
|
||||||
|
$models = [];
|
||||||
|
if( $products['make_id'] != null) {
|
||||||
|
foreach ($products['make_id'] as $make_id) {
|
||||||
|
$models[] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['models'] = $models;
|
||||||
|
|
||||||
$tax=$ProductModel->getTax();
|
$tax=$ProductModel->getTax();
|
||||||
$data['tax']=$tax;
|
$data['tax']=$tax;
|
||||||
@ -89,6 +101,9 @@ class Products extends BaseController
|
|||||||
$ManufacturerModel = new ManufacturerModel();
|
$ManufacturerModel = new ManufacturerModel();
|
||||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||||
$vendorIds = json_decode($products['vendor'], true);
|
$vendorIds = json_decode($products['vendor'], true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$vendors = [];
|
$vendors = [];
|
||||||
$VendorModel = new VendorModel();
|
$VendorModel = new VendorModel();
|
||||||
foreach ($vendorIds as $vendorId) {
|
foreach ($vendorIds as $vendorId) {
|
||||||
@ -107,6 +122,9 @@ class Products extends BaseController
|
|||||||
}
|
}
|
||||||
$data['product_id'] = $product_id;
|
$data['product_id'] = $product_id;
|
||||||
|
|
||||||
|
// echo "<pre>";
|
||||||
|
// print_r($data);die;
|
||||||
|
|
||||||
echo view('product_form',$data);
|
echo view('product_form',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +153,7 @@ class Products extends BaseController
|
|||||||
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
||||||
'reorder_level' => $this->request->getPost('reorder_level'),
|
'reorder_level' => $this->request->getPost('reorder_level'),
|
||||||
'quality' => $this->request->getPost('quality'),
|
'quality' => $this->request->getPost('quality'),
|
||||||
'make_id' => $this->request->getPost('make'),
|
'make_id' => json_encode($this->request->getPost('make')),
|
||||||
'models_id' => json_encode($this->request->getPost('model')),
|
'models_id' => json_encode($this->request->getPost('model')),
|
||||||
'rack_number' => $this->request->getPost('rack_number'),
|
'rack_number' => $this->request->getPost('rack_number'),
|
||||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||||
@ -146,7 +164,6 @@ class Products extends BaseController
|
|||||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$product_id = $this->request->getPost('product_id');
|
$product_id = $this->request->getPost('product_id');
|
||||||
|
|
||||||
|
|
||||||
@ -246,13 +263,35 @@ class Products extends BaseController
|
|||||||
|
|
||||||
public function get_models()
|
public function get_models()
|
||||||
{
|
{
|
||||||
$make_id = $this->request->getPost('make_id'); // Assuming you are sending make_id via POST
|
$make_ids = $this->request->getPost('make_id'); // Assuming you are sending make_id via POST
|
||||||
|
|
||||||
// Fetch models based on the selected make ID
|
|
||||||
$BikemodelsModel = new BikemodelsModel(); // Adjust this according to your actual model name
|
$BikemodelsModel = new BikemodelsModel(); // Adjust this according to your actual model name
|
||||||
$models = $BikemodelsModel->where('make_id', $make_id)->findAll(); // Implement this method in your model
|
|
||||||
// Return the model data as JSON
|
|
||||||
return $this->response->setJSON($models);
|
|
||||||
|
$formatted_models = [];
|
||||||
|
|
||||||
|
// Iterate over each selected make ID
|
||||||
|
if ($make_ids) {
|
||||||
|
foreach ($make_ids as $make_id) {
|
||||||
|
// Fetch models based on the selected make ID
|
||||||
|
$models = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||||
|
|
||||||
|
// Iterate over each fetched model and format it as needed
|
||||||
|
foreach ($models as $model) {
|
||||||
|
// Create an associative array with 'model_id' and 'model_name' properties
|
||||||
|
$formatted_model = [
|
||||||
|
'make_id' => $model['make_id'],
|
||||||
|
'model_id' => $model['model_id'],
|
||||||
|
'model_name' => $model['model_name']
|
||||||
|
// Add other properties if needed
|
||||||
|
];
|
||||||
|
|
||||||
|
// Push the formatted model into the array
|
||||||
|
$formatted_models[] = $formatted_model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->response->setJSON($formatted_models);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,8 @@ class Sales extends BaseController
|
|||||||
$sales=$SalesOrderModel->getSalesOrdersWithProducts($this->session->get('logged_user_branch_id'));
|
$sales=$SalesOrderModel->getSalesOrdersWithProducts($this->session->get('logged_user_branch_id'));
|
||||||
$data['sales']=$sales;
|
$data['sales']=$sales;
|
||||||
|
|
||||||
|
// echo"<pre>";
|
||||||
|
// print_r($data);die;
|
||||||
return view('sales_list',$data);
|
return view('sales_list',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,13 +82,14 @@ class Sales extends BaseController
|
|||||||
$modelId = $vehicles['model'];
|
$modelId = $vehicles['model'];
|
||||||
|
|
||||||
// Encode the modelId before searching
|
// Encode the modelId before searching
|
||||||
|
$encodedMakeId = json_encode([$makeId]);
|
||||||
$encodedModelId = json_encode([$modelId]);
|
$encodedModelId = json_encode([$modelId]);
|
||||||
|
|
||||||
// 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
|
||||||
$product = $productModel->where('make_id', $makeId)
|
$product = $productModel->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||||
->findAll();
|
->findAll();
|
||||||
$data['product']=$product;
|
$data['product']=$product;
|
||||||
@ -426,16 +429,18 @@ public function getProducts()
|
|||||||
$modelId = $this->request->getPost('model_id');
|
$modelId = $this->request->getPost('model_id');
|
||||||
|
|
||||||
// Encode the modelId before searching
|
// Encode the modelId before searching
|
||||||
|
$encodedMakeId = json_encode([$makeId]);
|
||||||
$encodedModelId = json_encode([$modelId]);
|
$encodedModelId = json_encode([$modelId]);
|
||||||
|
|
||||||
// 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
|
||||||
$product = $productModel->where('make_id', $makeId)
|
$product = $productModel->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)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
// print_r($product);die;
|
||||||
|
|
||||||
$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;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class SalesOrderModel extends Model
|
|||||||
public function getSalesOrdersWithProducts($logged_user_branch_id)
|
public function getSalesOrdersWithProducts($logged_user_branch_id)
|
||||||
{
|
{
|
||||||
// Select required fields from both tables
|
// Select required fields from both tables
|
||||||
$this->select('sales_order.*, COUNT(sales_order_product.sales_order_id) AS product_count,vehicle.reg_no');
|
$this->select('sales_order.*, COUNT(sales_order_product.sales_order_id) AS product_count,vehicle.reg_no,SUM(sales_order_product.qty) AS product_qty ');
|
||||||
|
|
||||||
// Join the sales_order_product table based on sales_order_id
|
// Join the sales_order_product table based on sales_order_id
|
||||||
$this->join('sales_order_product', 'sales_order_product.sales_order_id = sales_order.sales_order_id');
|
$this->join('sales_order_product', 'sales_order_product.sales_order_id = sales_order.sales_order_id');
|
||||||
|
|||||||
@ -44,9 +44,9 @@
|
|||||||
<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="<?php echo $item['model_id']; ?>" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>
|
<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="<?php echo $item['model_id']; ?>" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>
|
||||||
|
|
||||||
<?php if($item['isactive'] == 1): ?>
|
<?php if($item['isactive'] == 1): ?>
|
||||||
<a style="color:red; margin-left:12px;" data-id="<?php echo $item['model_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Deactivate" onclick="statusChange(this)" class="fa fa-user-times"></a>
|
<a style="color:red; margin-left:12px;" data-id="<?php echo $item['model_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a style="color:green; margin-left:12px;" data-id="<?php echo $item['model_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Activate" onclick="statusChange(this)" class="fa fa-user"></a>
|
<a style="color:green; margin-left:12px;" data-id="<?php echo $item['model_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -115,10 +115,43 @@
|
|||||||
data: formData,
|
data: formData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
// Handle success response here
|
if (response.status == "failed") {
|
||||||
console.log(response);
|
toastr.warning(response.data, 'Warning');
|
||||||
|
}else{
|
||||||
$('#bike_model_login-modal_1').modal('hide');
|
$('#bike_model_login-modal_1').modal('hide');
|
||||||
|
$('#makename').val('');
|
||||||
$('#modelname').val('');
|
$('#modelname').val('');
|
||||||
|
toastr.success(response.data, 'Success');
|
||||||
|
|
||||||
|
$('tbody').html('');
|
||||||
|
|
||||||
|
$.each(response.model_list, function(index, item) {
|
||||||
|
var row = '<tr>' +
|
||||||
|
'<td class="model_name">' + item.model_name + '</td>' +
|
||||||
|
'<td>';
|
||||||
|
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<span style="color:green">Active</span>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<span style="color:red">Inactive</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td>';
|
||||||
|
|
||||||
|
row += '<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="' + item.model_id + '" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>';
|
||||||
|
// Check the isactive status and set the icon color accordingly
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<a style="color:red; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<a style="color:green; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td></td></tr>';
|
||||||
|
|
||||||
|
// Append the row to the tbody
|
||||||
|
$('tbody').append(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
// Handle error response here
|
// Handle error response here
|
||||||
@ -147,14 +180,13 @@
|
|||||||
data: formData,
|
data: formData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
|
||||||
|
|
||||||
if (response.status == "success") {
|
if (response.status == "success") {
|
||||||
$('tbody').html('');
|
$('tbody').html('');
|
||||||
|
|
||||||
$.each(response.data, function(index, item) {
|
$.each(response.data, function(index, item) {
|
||||||
var row = '<tr>' +
|
var row = '<tr>' +
|
||||||
'<td>' + item.model_name + '</td>' +
|
'<td class="model_name">' + item.model_name + '</td>' +
|
||||||
'<td>';
|
'<td>';
|
||||||
|
|
||||||
if (item.isactive == 1) {
|
if (item.isactive == 1) {
|
||||||
@ -165,11 +197,12 @@
|
|||||||
|
|
||||||
row += '</td><td>';
|
row += '</td><td>';
|
||||||
|
|
||||||
|
row += '<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="' + item.model_id + '" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>';
|
||||||
// Check the isactive status and set the icon color accordingly
|
// Check the isactive status and set the icon color accordingly
|
||||||
if (item.isactive == 1) {
|
if (item.isactive == 1) {
|
||||||
row += '<a style="color:red" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)" class="fa fa-user-times"></a>';
|
row += '<a style="color:red; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
|
||||||
} else if (item.isactive == 0) {
|
} else if (item.isactive == 0) {
|
||||||
row += '<a style="color:green" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)" class="fa fa-user"></a>';
|
row += '<a style="color:green; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
row += '</td><td></td></tr>';
|
row += '</td><td></td></tr>';
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Bike Make</th>
|
<th>Bike Make</th>
|
||||||
|
<th>Status</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -33,6 +34,13 @@
|
|||||||
<?php foreach ($make as $item): ?>
|
<?php foreach ($make as $item): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="make"><?php echo $item['make']; ?></td>
|
<td class="make"><?php echo $item['make']; ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if($item['isactive'] == 1): ?>
|
||||||
|
<span style="color:green">Active</span>
|
||||||
|
<?php else: ?>
|
||||||
|
<span style="color:red">Inactive</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="<?php echo $item['make_id']; ?>" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>
|
<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="<?php echo $item['make_id']; ?>" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>
|
||||||
|
|
||||||
@ -42,6 +50,11 @@
|
|||||||
<a href="<?= "bike_model_index/" . $item['make_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 12px;">
|
<a href="<?= "bike_model_index/" . $item['make_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 12px;">
|
||||||
<i class="ri-list-check-2 icon-large"></i>
|
<i class="ri-list-check-2 icon-large"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<?php if($item['isactive'] == 1): ?>
|
||||||
|
<a style="color:red; margin-left:12px;" data-id="<?php echo $item['make_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Deactivate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>
|
||||||
|
<?php else: ?>
|
||||||
|
<a style="color:green; margin-left:12px;" data-id="<?php echo $item['make_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Activate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i></a>
|
||||||
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -62,7 +75,7 @@
|
|||||||
<h4 id="form_add_edit">Add Bike Make</h4>
|
<h4 id="form_add_edit">Add Bike Make</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="model_form_data" class="px-3">
|
<!-- <form id="model_form_data" class="px-3"> -->
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="makename">Make Name </label>
|
<label for="makename">Make Name </label>
|
||||||
@ -74,7 +87,7 @@
|
|||||||
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitMake(this)">Submit</button>
|
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitMake(this)">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
<!-- </form> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
@ -91,7 +104,7 @@
|
|||||||
<h4>Add Models</h4>
|
<h4>Add Models</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="model_form_data" class="px-3">
|
<!-- <form id="model_form_data" class="px-3"> -->
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input class="form-control" type="text" id="make_id" required="" placeholder="Make Name...." style="display:none;">
|
<input class="form-control" type="text" id="make_id" required="" placeholder="Make Name...." style="display:none;">
|
||||||
@ -105,7 +118,7 @@
|
|||||||
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModel(this)">Submit</button>
|
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModel(this)">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
<!-- </form> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
@ -169,8 +182,48 @@
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
$('#bike_model_login-modal').modal('hide');
|
|
||||||
|
|
||||||
|
if (response.status == "failed") {
|
||||||
|
toastr.warning(response.data, 'Warning');
|
||||||
|
}else{
|
||||||
|
$('#bike_make_login-modal').modal('hide');
|
||||||
$('#bike_make_name').val('');
|
$('#bike_make_name').val('');
|
||||||
|
toastr.success(response.data, 'Success');
|
||||||
|
|
||||||
|
$('tbody').html('');
|
||||||
|
|
||||||
|
$.each(response.make_list, function(index, item) {
|
||||||
|
var row = '<tr>' +
|
||||||
|
'<td class="make">' + item.make + '</td>' +
|
||||||
|
'<td>';
|
||||||
|
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<span style="color:green">Active</span>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<span style="color:red">Inactive</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td>';
|
||||||
|
|
||||||
|
// Check the isactive status and set the icon color accordingly
|
||||||
|
row += '<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="'+ item.make_id +'" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>';
|
||||||
|
|
||||||
|
row +='<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="'+ item.make_id+'" data-value="' +item.make+'" onclick="setMakeName(this)"><i class="ri-add-line icon-large"></i></a>';
|
||||||
|
row +='<a href="bike_model_index/' +item.make_id+'" class="view-list-button" title="Model List" style="margin-left: 12px;"><i class="ri-list-check-2 icon-large"></i></a>';
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<a style="color:red; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<a style="color:green; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td></td></tr>';
|
||||||
|
|
||||||
|
// Append the row to the tbody
|
||||||
|
$('tbody').append(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
// Handle error response here
|
// Handle error response here
|
||||||
@ -186,7 +239,7 @@
|
|||||||
$('#form_add_edit').text('Edit Bike Make');
|
$('#form_add_edit').text('Edit Bike Make');
|
||||||
|
|
||||||
var full_div = $(params).parent().parent()[0];
|
var full_div = $(params).parent().parent()[0];
|
||||||
|
console.log($(full_div));
|
||||||
$('#bike_make_name').val($(full_div).find('.make').text());
|
$('#bike_make_name').val($(full_div).find('.make').text());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,4 +250,68 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function statusChange(params) {
|
||||||
|
var status = params.getAttribute('data-isactive');
|
||||||
|
var make_id = params.getAttribute('data-id');
|
||||||
|
if(status == 1){
|
||||||
|
var isactive= 0;
|
||||||
|
}else{
|
||||||
|
var isactive= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
make_id: make_id,
|
||||||
|
isactive: isactive
|
||||||
|
};
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '<?php echo base_url()."status_make"?>',
|
||||||
|
data: formData,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
|
if (response.status == "success") {
|
||||||
|
$('tbody').html('');
|
||||||
|
|
||||||
|
$.each(response.data, function(index, item) {
|
||||||
|
var row = '<tr>' +
|
||||||
|
'<td class="make">' + item.make + '</td>' +
|
||||||
|
'<td>';
|
||||||
|
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<span style="color:green">Active</span>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<span style="color:red">Inactive</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td>';
|
||||||
|
|
||||||
|
// Check the isactive status and set the icon color accordingly
|
||||||
|
row += '<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="'+ item.make_id +'" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>';
|
||||||
|
|
||||||
|
row +='<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="'+ item.make_id+'" data-value="' +item.make+'" onclick="setMakeName(this)"><i class="ri-add-line icon-large"></i></a>';
|
||||||
|
row +='<a href="bike_model_index/' +item.make_id+'" class="view-list-button" title="Model List" style="margin-left: 12px;"><i class="ri-list-check-2 icon-large"></i></a>';
|
||||||
|
if (item.isactive == 1) {
|
||||||
|
row += '<a style="color:red; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
|
||||||
|
} else if (item.isactive == 0) {
|
||||||
|
row += '<a style="color:green; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row += '</td><td></td></tr>';
|
||||||
|
|
||||||
|
// Append the row to the tbody
|
||||||
|
$('tbody').append(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Handle error response here
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -28,12 +28,12 @@
|
|||||||
|
|
||||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
<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 Client"></i>' ?>
|
<?= 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 Client"></i>' ?>
|
||||||
<select class="form-control SelExample" id="make" name="make" required>
|
<select class="form-control SelExample" id="make" name="make[]" required multiple>
|
||||||
<option value="">Select a Make</option>
|
<option value="">Select a Make</option>
|
||||||
|
|
||||||
<!-- Options for make -->
|
<!-- Options for make -->
|
||||||
<?php foreach ($make as $value): ?>
|
<?php foreach ($make as $value): ?>
|
||||||
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && $products['make_id'] == $value['make_id'] ? 'selected' : '' ?>>
|
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && in_array($value['make_id'], $products['make_id']) ? 'selected' : '' ?>>
|
||||||
<?= $value['make'] ?>
|
<?= $value['make'] ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -46,10 +46,10 @@
|
|||||||
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
||||||
<!-- Options for model will be populated dynamically via AJAX -->
|
<!-- Options for model will be populated dynamically via AJAX -->
|
||||||
<?php if(isset($models) && !empty($models)): ?>
|
<?php if(isset($models) && !empty($models)): ?>
|
||||||
<?php foreach($models as $model): ?>
|
<?php foreach ($models as $make_models): ?>
|
||||||
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], json_decode($products['models_id'], true)) ? 'selected' : '' ?>>
|
<?php foreach ($make_models as $model): ?>
|
||||||
<?= $model['model_name'] ?>
|
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], $products['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
|
||||||
</option>
|
<?php endforeach; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</select>
|
</select>
|
||||||
@ -359,6 +359,8 @@ $(document).ready(function() {
|
|||||||
$('#make').change(function() {
|
$('#make').change(function() {
|
||||||
var make_id = $(this).val(); // Get the selected make ID
|
var make_id = $(this).val(); // Get the selected make ID
|
||||||
make_value = $('option:selected', this).text();
|
make_value = $('option:selected', this).text();
|
||||||
|
var models_id = $('#model').val();
|
||||||
|
|
||||||
$('#makeSelect').empty();
|
$('#makeSelect').empty();
|
||||||
$('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
$('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
||||||
$('#makeSelectMessage').hide();
|
$('#makeSelectMessage').hide();
|
||||||
@ -374,10 +376,21 @@ $(document).ready(function() {
|
|||||||
if (response.length > 0) {
|
if (response.length > 0) {
|
||||||
// Clear existing options
|
// Clear existing options
|
||||||
$('#model').empty();
|
$('#model').empty();
|
||||||
// Append new options
|
// Iterate through response and models_id
|
||||||
$("#model").append('<option value=""> Select a Model </option>');
|
|
||||||
$.each(response, function(index, model) {
|
$.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>');
|
$('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle case when no models are found
|
// Handle case when no models are found
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
<th>Client Name</th>
|
<th>Client Name</th>
|
||||||
|
|
||||||
<th>Items</th>
|
<th>Items</th>
|
||||||
|
<th>Qty</th>
|
||||||
<th>Total</th>
|
<th>Total</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
@ -77,6 +77,7 @@
|
|||||||
<td><?= $value['client_name']; ?></td>
|
<td><?= $value['client_name']; ?></td>
|
||||||
|
|
||||||
<td><?= $value['product_count']; ?></td>
|
<td><?= $value['product_count']; ?></td>
|
||||||
|
<td><?= $value['product_qty']; ?></td>
|
||||||
|
|
||||||
<td><?= $value['total']; ?></td>
|
<td><?= $value['total']; ?></td>
|
||||||
<td class="<?php
|
<td class="<?php
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user