CHANGE_MANUFACTUTOR_MODUEL : AADHAVAN

This commit is contained in:
aadhavan valli 2024-04-17 09:09:02 +05:30
parent 5091538fc6
commit 5fe764cba7
18 changed files with 1229 additions and 135 deletions

View File

@ -14,6 +14,8 @@ $routes->set404Override();
$routes->get('/', 'Login::index');
$routes->get('log_out', 'Login::index');
$routes->post("authenticate", "Login::authenticate");
$routes->get("edit_account/(:any)", "Users::edit_account/$1");
$routes->post("add_account", "Users::add_account");
// $routes->get("new_user/(:any)", "Users::new_user/$1");
// $routes->get("delete_user/(:any)", "Users::delete_user/$1");
//end Login//
@ -34,6 +36,14 @@ $routes->get("new_business/(:any)", "Business::new_business/$1");
$routes->get("delete_business/(:any)", "Business::delete_business/$1");
// end business//
//Branch//
$routes->get('branch_index/(:any)', 'Branch::branch_index/$1');
$routes->post('add_branch/(:any)', 'Branch::new_branch/$1');
$routes->post('edit_branch/(:any)', 'Branch::edit_branch/$1');
$routes->get("get_branch/(:any)", "Branch::get_branch/$1");
$routes->get("delete_branch/(:any)", "Branch::delete_branch/$1");
// end Branch//
// Products//
$routes->get('product_index/', 'Products::product_index');
$routes->get('product_index/(:any)', 'Products::product_index/$1');
@ -58,6 +68,18 @@ $routes->post("save_vehicle", "Sales::save_vehicle");
$routes->post("getProducts", "Sales::getProducts");
//end salle order//
//Job Card //
$routes->get('job_card_index/', 'Jobcard::job_card_index');
$routes->post("add_jobs", "Jobcard::add_jobs");
$routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
// $routes->get("download_invoice/(:any)", "Jobcard::download_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
$routes->post("getServices", "Jobcard::getServices");
//End Job Card //
//Client//
$routes->get('client_index/', 'Client::client_index');
$routes->post("add_client", "Client::add_client");

101
app/Controllers/Branch.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace App\Controllers;
use App\Models\BranchModel;
use App\Models\RoleModel;
use App\Models\BusinessModel;
class Branch extends BaseController
{
public function branch_index($business_id)
{
$BranchModel = new BranchModel();
$BusinessModel = new BusinessModel();
$business=$BusinessModel->where('business_id',$business_id)->first();
$branch=$BranchModel->where('business_id',$business_id)->findAll();
$data['branch']=$branch;
$data['business_name']=$business['business_name'];
$data['business_id']=$business['business_id'];
return view('branch_list',$data);
}
public function new_business($business_id)
{
if ($business_id === '0') {
$data['business'] = [];
$data['page_name']="Add Business";
} else if ($business_id !== '0') {
$BusinessModel = new BusinessModel();
$business=$BusinessModel->getBusinessById($business_id);
$data['business']=$business;
$data['page_name']="Edit Business" ;
}
$data['business_id'] = $business_id;
return view('business_form',$data);
}
public function new_branch($business_id)
{
if ($business_id) {
$data = $this->request->getPost();
$data['business_id'] = $business_id;
// print_r($data);die;
$BranchModel = new BranchModel();
$BranchModel->insert($data);
}
}
public function get_branch($branch_id)
{
if ($branch_id) {
$BranchModel = new BranchModel();
$branch =$BranchModel->where('branch_id',$branch_id)->first();
return json_encode($branch);
}
}
public function edit_branch($branch_id)
{
if ($branch_id) {
$data = $this->request->getPost();
$BranchModel = new BranchModel();
$BranchModel->update($branch_id,$data);
return json_encode(true);
}
}
public function delete_branch($branch_id)
{
$model = new BranchModel();
$where = ['branch_id' => $branch_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
$existingBranch = $model->where($where)->first();
if ($existingBranch) {
$data['isactive'] = 0;
if ($model->update($branch_id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Branch: has been Inactivated successfully. Inactivated ID = ".$branch_id);
}
}
return redirect()->to('branch_index/' . $existingBranch['business_id']);
}
}

View File

@ -77,7 +77,7 @@ class Business extends BaseController
'country' => $this->request->getPost('country'),
'isactive' => 1 // Assuming this is a default value or handled separately
];
// print_r($data);die;
// print_r($data);die;
$business_id = $this->request->getPost('business_id');

467
app/Controllers/Jobcard.php Normal file
View File

@ -0,0 +1,467 @@
<?php
namespace App\Controllers;
use App\Models\JobcardModel;
use App\Models\JobcardProductModel;
use App\Models\JobcardServiceModel;
use App\Models\ProductModel;
use App\Models\ServiceModel;
use App\Models\ClientModel;
use App\Models\BikemodelsModel;
use App\Models\BikemakeModel;
use App\Models\VehicleModel;
use Mpdf\Mpdf;
class Jobcard extends BaseController
{
public $session;
public function __construct()
{
$this->session = session();
$this->BikemodelsModel = new BikemodelsModel();
$this->BikemakeModel = new BikemakeModel();
}
public function job_card_index()
{
$JobcardModel = new JobcardModel();
$jobs=$JobcardModel->getJobCardsWithProductsAndService($this->session->get('logged_user_branch_id'));
$data['jobs']=$jobs;
// echo "<pre>";
// print_r($jobs);die;
return view('jobs_list',$data);
}
public function new_jobcard($job_card_id)
{
if ($job_card_id === '0') {
$data['page_name']="Create Job Card";
$data['jobs'] = [];
$ClientModel = new ClientModel();
$client=$ClientModel
->where('isactive',1)
->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$VehicleModel = new VehicleModel();
$vehicle = $VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
$ProductModel = new ProductModel();
$product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$ServiceModel = new ServiceModel();
$service=$ServiceModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['product_1']=$product;
$data['product']="";
$data['service_1']=$service;
$data['service']="";
$data['client']=$client;
$data['vehicle']=$vehicle;
} else if ($job_card_id !== '0')
{
$data['page_name']="Edit Job Card";
$ClientModel = new ClientModel();
$client=$ClientModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$JobcardModel = new JobcardModel();
$jobs=$JobcardModel->where('job_card_id', $job_card_id)->get()->getRowArray();
$data['jobs']=$jobs;
$VehicleModel = new VehicleModel();
$vehicles = $VehicleModel->where('isactive',1)->where('vehicle_id',$jobs['vehicle_id'])
->where('branch_id',$this->session->get('logged_user_branch_id'))
->first();
$makeId = $vehicles['make'];
$modelId = $vehicles['model'];
$BikemakeModel = new BikemakeModel();
$BikemodelsModel = new BikemodelsModel();
$make_name = $BikemakeModel->where('make_id',$makeId)->select('make')->first();
$model_name = $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([$modelId]);
// Load the ProductModel
$productModel = new ProductModel();
// Query the database to find the product based on make_id and model_id
$product = $productModel->where('make_id', $makeId)
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
->findAll();
$data['product']=$product;
// Load the ServiceModel
$ServiceModel = new ServiceModel();
$encodedMakeId = json_encode([$makeId]);
// Query the database to find the product based on make_id and model_id
// $service = $ServiceModel->where('JSON_CONTAINS(makes_id, \'' . $encodedMakeId . '\')', null, false)
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
// ->findAll();
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
->findAll();
$data['product']=$product;
$data['service']=$service;
$JobcardProductModel = new JobcardProductModel();
$jobs_product= $JobcardProductModel->where('job_card_id', $job_card_id)->findAll();
$data['jobs_product']=$jobs_product;
$JobcardServiceModel = new JobcardServiceModel();
$jobs_service= $JobcardServiceModel->where('job_card_id', $job_card_id)->findAll();
$data['jobs_service']=$jobs_service;
$data['client']=$client;
// print_r($jobs_product);die;
$VehicleModel = new VehicleModel();
$vehicle=$VehicleModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['vehicle']=$vehicle;
}
// print_r($data);die;
$data['job_card_id'] = $job_card_id;
$bikeMakeModel = new BikeMakeModel();
$data['makeData'] =$bikeMakeModel->findAll();
// echo "<pre>";
// print_r($data);die;
return view('job_card_form',$data);
}
public function add_jobs()
{
$JobcardModel = new JobcardModel();
$ProductModel = new ProductModel();
$JobcardProductModel = new JobcardProductModel(); // Assuming you have a model for sales_order_product
$JobcardServiceModel = new JobcardServiceModel();
// Prepare data for sales order
$data = [
'client_name' => $this->request->getPost('client_id'),
'vehicle_id'=>$this->request->getPost('vehicle_id'),
'billing_address' => $this->request->getPost('billing_address'),
'billing_city' => $this->request->getPost('city'),
'mobile_no' => $this->request->getPost('mobile_no'),
'billing_state' => $this->request->getPost('state'),
'billing_postal_code' => $this->request->getPost('postalcode'),
// 'billing_country' => $this->request->getPost('country'),
// 'terms_condition' => $this->request->getPost('terms_condition'),
// 'subtotal' => $this->request->getPost('sub_total'),
// 'tax' => $this->request->getPost('invoice_tax'),
'total'=> $this->request->getPost('grand_total'),
'status'=> $this->request->getPost('status'),
'isactive' => 1, // Assuming this is a default value or handled separately
'branch_id'=> $this->session->get('logged_user_branch_id'),
];
// print_r($data);die;
// Insert or update sales order
$job_card_id = $this->request->getPost('job_card_id');
if (!empty($job_card_id)) {
// print_r("hello");die;
$JobcardModel->update($job_card_id, $data);
} else {
$JobcardModel->insert($data);
$job_card_id = $JobcardModel->getInsertID(); // Get the last inserted ID
}
$orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
// print_r($orderNumber);die;
// Update sales order with generated order number
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
// Prepare data for sales order product
// echo "<pre>";
// print_r($this->request->getPost());die;
$product_ids = $this->request->getPost('item_details');
$quantities = $this->request->getPost('quantity');
$discounts = $this->request->getPost('discount_amount');
$discount_types = $this->request->getPost('discount_type');
$amounts = $this->request->getPost('amount');
$itemtax=$this->request->getPost('item-tax');
$unitprice=$this->request->getPost('unit-price');
$job_card_product_id = $this->request->getPost('job_card_product_id');
// print_r($product_ids);die;
// print_r($status);die;
$status = $this->request->getPost('status');
foreach ($product_ids as $key => $product_id) {
$qty = isset($quantities[$key]) ? $quantities[$key] : 0;
if ($status == 'Created') {
// echo "hello";die;
$this->updateProductQuantity($ProductModel, $product_id, $qty);
}elseif ($status == 'Cancelled'){
// echo "cancel";die;
// echo"hello";die;
$this->addBackProductQuantity($ProductModel, $product_id, $qty);
}
$discount = isset($discounts[$key]) ? $discounts[$key] : 0;
$discount_type = isset($discount_types[$key]) ? $discount_types[$key] : '';
$tax=isset($itemtax[$key]) ? $itemtax[$key] : 0;
$rate=isset($unitprice[$key]) ? $unitprice[$key] : 0;
$amount = isset($amounts[$key]) ? $amounts[$key] : 0;
// $new_qty = $this->calculateUpdatedQuantity($ProductModel, $product_id, $qty);
// print_r($discount_type);die;
$product_data = [
'job_card_id' => $job_card_id,
'product_id' => $product_id,
'qty' => $qty,
'discount' => $discount,
'discount_type' => $discount_type,
'net_price'=>$rate,
'tax'=>$tax,
'amount' => $amount,
'isactive'=>1,
];
// print_r($product_data);die;
if (!empty($job_card_product_id[$key])) {
$JobcardProductModel->update($job_card_product_id[$key], $product_data);
} else {
$JobcardProductModel->insert($product_data);
}
}
return redirect()->to('job_card_index');
}
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty + $sold_qty;
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
}
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty - $sold_qty;
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
}
public function delete_sales_product()
{
$sales_order_product_id = $this->request->getPost('sales_order_product_id');
if (!empty($sales_order_product_id)) {
$SalesOrderProductModel = new SalesOrderProductModel();
$data['isactive'] = 0;
if ($SalesOrderProductModel->update($sales_order_product_id, $data)) {
// Return success response
return $this->response->setJSON(['success' => true]);
}
}
// Return error response if deletion fails
return $this->response->setJSON(['success' => false]);
}
public function delete_jobcard($job_card_id)
{
$model = new JobcardModel();
$where = ['job_card_id' => $job_card_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
$existingProduct = $model->where($where)->first();
if ($existingProduct) {
$data['isactive'] = 0;
if ($model->update($job_card_id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Job Card: has been Inactivated successfully. Inactivated ID = ".$job_card_id);
}
}
return redirect()->to('job_card_index');
}
public function download_invoice($sales_order_id)
{
// echo "hello"; die;
// Fetch the invoice data based on $invoice_id
$model = new SalesOrderModel();
$data = $model->getSalesPdf($sales_order_id);
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
// print_r($items);die();
// print_r($invoiceItems);die();
// Create an mPDF object
$mpdf = new Mpdf([
'mode' => '',
'format' => 'A5',
'default_font_size' => 0,
'default_font' => '',
// 'margin_right' => 1,
'margin_top' => 6,
'margin_bottom' => 6,
'margin_header' => 6,
'margin_footer' =>-30,
'orientation' => 'P',
]);
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Invoice');
$mpdf->SetAuthor($data[0]->branch_name);
$mpdf->SetCreator('');
// Generate the PDF content (HTML)
if ($data[0]->status === 'Draft') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Draft');
$mpdf->showWatermarkText = true;
}
if ($data[0]->status === 'Cancelled') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Cancelled');
$mpdf->showWatermarkText = true;
}
if ($data[0]->status === 'Void') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Void');
$mpdf->showWatermarkText = true;
}
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items]);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
// Output the PDF to the browser for download
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
}
public function save_vehicle(){
// Load ClientModel
$VehicleModel = new VehicleModel();
if($this->request->getPost('formType') == 'create')
{
$ClientModel = new ClientModel();
$client['client_name'] = $this->request->getPost('createclientName');
$client['mobile_no'] = $this->request->getPost('createclientMobile');
$client['client_type'] = $this->request->getPost('createclientType');
$client['branch_id'] = $this->session->get('logged_user_branch_id');
$client_id = $ClientModel->insert($client);
if($client_id){
$data = [
'client_id' => $client_id,
'mobile_no' => $this->request->getPost('createclientMobile'),
'reg_no' => $this->request->getPost('reg_no'),
'model' => $this->request->getPost('model'),
'make' => $this->request->getPost('make'),
'branch_id'=> $this->session->get('logged_user_branch_id'),
'city'=>'Chennai',
'state'=>'Tamil Nadu',
'isactive' => 1
];
}
}else{
$data = [
'client_id' => $this->request->getPost('client_id'),
'mobile_no' => $this->request->getPost('mobile_no'),
'reg_no' => $this->request->getPost('reg_no'),
'model' => $this->request->getPost('model'),
'make' => $this->request->getPost('make'),
'branch_id'=> $this->session->get('logged_user_branch_id'),
'city'=>'Chennai',
'state'=>'Tamil Nadu',
'isactive' => 1
];
}
// Attempt to insert the client data
$id = $VehicleModel->insert($data);
if ($id) {
$vehicleData = $VehicleModel->where('vehicle_id',$id)->first();
// If insertion succeeds, return success response
return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.','vehicleData'=>$vehicleData]);
} else {
// If insertion fails, return error response
return $this->response->setJSON(['success' => false, 'message' => 'Failed to save client.']);
}
}
public function get_vehicle_products(){
}
public function getServices()
{
// Retrieve make_id and model_id from the request
$makeId = $this->request->getPost('make_id');
$modelId = $this->request->getPost('model_id');
// Encode the makeId before searching
$encodedMakeId = json_encode([$makeId]);
// Encode the modelId before searching
$encodedModelId = json_encode([$modelId]);
// Load the ProductModel
$ServiceModel = new ServiceModel();
// Query the database to find the service based on make_id and model_id
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
->findAll();
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
if($service){
// Send JSON response
return $this->response->setJSON(['service'=>$service , 'modelName'=>$modelName ,'makeName'=>$makeName] );
} else {
// If service is not found, return an empty response or appropriate message
return $this->response->setJSON(['service'=>[] , 'modelName'=>$modelName ,'makeName'=>$makeName]);
}
}
// Check if service exists
}

View File

@ -21,7 +21,8 @@ class Purchase extends BaseController
{
$PurchaseOrderModel = new PurchaseOrderModel();
$purchase = $PurchaseOrderModel->select('purchase_order.*, vendor.vendor_name')
$purchase = $PurchaseOrderModel->where('purchase_order.branch_id', $this->session->get('logged_user_business_id'))
->select('purchase_order.*, vendor.vendor_name')
->join('vendor', 'vendor.vendor_id = purchase_order.vendor_id')
->findAll();
// echo "<pre>";
@ -41,7 +42,7 @@ class Purchase extends BaseController
$PurchaseOrderModel = new PurchaseOrderModel();
$VendorModel = new VendorModel();
$vendor = $VendorModel->select('vendor_id,vendor_name')->findAll();
$vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->select('vendor_id,vendor_name')->findAll();
$BranchModel = new BranchModel();
@ -63,7 +64,7 @@ class Purchase extends BaseController
$purchase=$PurchaseOrderModel->where('purchase_order_id', $purchase_order_id)->get()->getRowArray();
$VendorModel = new VendorModel();
$vendor = $VendorModel->select('vendor_id,vendor_name')->findAll();
$vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_business_id'))->select('vendor_id,vendor_name')->findAll();
$data['vendor']=$vendor;
$data['purchase'] = $purchase;
$data['vendor_id'] = $purchase['vendor_id'];

View File

@ -22,7 +22,7 @@ class Service extends BaseController
{
$ServiceModel = new ServiceModel();
$services = $ServiceModel->findAll();
$services = $ServiceModel->where('branch_id',$this->session->get('logged_user_business_id'))->findAll();
foreach ($services as &$service) {
// Convert JSON strings to arrays
@ -146,7 +146,7 @@ class Service extends BaseController
$ServiceModel->update($service_id, $data);
} else {
$data['branch_id'] = $this->session->get('logged_user_business_id');
$ServiceModel->insert($data);
}

View File

@ -44,6 +44,14 @@ class Users extends BaseController
public function new_user($user_id)
{
$uri = $this->request->getUri();
// Get the query parameters
$queryParams = $uri->getQuery();
// echo "<pre>";
// print_r($queryParams);
// die;
// echo $user_id;die;
if ($user_id === '0') {
@ -78,46 +86,124 @@ class Users extends BaseController
return view('user_form',$data);
}
public function edit_account($user_id)
{
$uri = $this->request->getUri();
// Get the query parameters
$queryParams = $uri->getQuery();
if ($user_id === '0') {
$data['users'] = [];
$BusinessModel=new BusinessModel();
$business=$BusinessModel->findAll();
// print_r($business);die;
$rolemodel = new RoleModel();
$roles =$rolemodel->getRoles();
$data['business'] = $business;
$data['roles'] = $roles;
} else if ($user_id !== '0') {
$UsersModel = new UsersModel();
$users=$UsersModel->getUserById($user_id);
$BusinessModel=new BusinessModel();
$business=$BusinessModel->findAll();
$BranchModel=new BranchModel();
$branch=$BranchModel->where("business_id",$users['business_id'])->findAll();
$data['users']=$users;
$data['business'] = $business;
$data['branches'] = $branch;
$rolemodel = new RoleModel();
$roles =$rolemodel->getRoles();
$data['roles'] = $roles;
}
$data['user_id'] = $user_id;
return view('edit_account_form',$data);
}
public function add_user()
{
// Load UsersModel
$UsersModel = new UsersModel();
{
// Load UsersModel
$UsersModel = new UsersModel();
// Get form data
$data = [
'name' => $this->request->getPost('name'),
'email' => $this->request->getPost('email'),
'mobile_no' => $this->request->getPost('mobile'),
'role' => $this->request->getPost('role'),
'business_id' => $this->request->getPost('business'),
'branch_id' => $this->request->getPost('branch'),
'isactive' => 1 // Assuming this is a default value or handled separately
];
// Get form data
$data = [
'name' => $this->request->getPost('name'),
'email' => $this->request->getPost('email'),
'mobile_no' => $this->request->getPost('mobile'),
'role' => $this->request->getPost('role'),
'business_id' => $this->request->getPost('business'),
'branch_id' => $this->request->getPost('branch'),
'isactive' => 1 // Assuming this is a default value or handled separately
];
// Hash the password
$password = $this->request->getPost('password');
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Use PASSWORD_DEFAULT for bcrypt hashing
// Hash the password
$password = $this->request->getPost('password');
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Use PASSWORD_DEFAULT for bcrypt hashing
// Add hashed password to the data array
$data['password'] = $hashedPassword;
// Add hashed password to the data array
$data['password'] = $hashedPassword;
// Get user_id from the form
$user_id = $this->request->getPost('user_id');
// Get user_id from the form
$user_id = $this->request->getPost('user_id');
// Check if user_id is provided
if (!empty($user_id)) {
// Update existing user
$UsersModel->update($user_id, $data);
} else {
// Insert new user
$UsersModel->insert($data);
// Check if user_id is provided
if (!empty($user_id)) {
// Update existing user
$UsersModel->update($user_id, $data);
} else {
// Insert new user
$UsersModel->insert($data);
}
// Redirect to user listing page or wherever appropriate
return redirect()->to('index'); // Change '/users' to your desired redirect URL
}
// Redirect to user listing page or wherever appropriate
return redirect()->to('index'); // Change '/users' to your desired redirect URL
}
public function add_account()
{
// Load UsersModel
$UsersModel = new UsersModel();
// Get form data
$data = [
'name' => $this->request->getPost('name'),
'email' => $this->request->getPost('email'),
'mobile_no' => $this->request->getPost('mobile'),
'role' => $this->request->getPost('role'),
'business_id' => $this->request->getPost('business'),
'branch_id' => $this->request->getPost('branch'),
'isactive' => 1 // Assuming this is a default value or handled separately
];
// Hash the password
$password = $this->request->getPost('password');
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Use PASSWORD_DEFAULT for bcrypt hashing
// Add hashed password to the data array
$data['password'] = $hashedPassword;
// Get user_id from the form
$user_id = $this->request->getPost('user_id');
// Check if user_id is provided
if (!empty($user_id)) {
// Update existing user
$UsersModel->update($user_id, $data);
} else {
// Insert new user
$UsersModel->insert($data);
}
// Redirect to user listing page or wherever appropriate
return redirect()->to('dashboard'); // Change '/users' to your desired redirect URL
}
public function delete_user($user_id)
{

View File

@ -5,7 +5,7 @@ class BranchModel extends Model
{
protected $table = 'branches';
protected $primaryKey = 'branch_id';
protected $allowedFields = ['business_id','branch_id','','branch_name','email','mobile','address','city','state','postal_code','country','isactive'];
protected $allowedFields = ['business_id','branch_id','','branch_name','email','mobile_no','address','city','state','postal_code','country','isactive'];
public function getBranchesByBusinessId($business_id)
{

View File

@ -5,7 +5,32 @@ class JobcardModel extends Model
{
protected $table = 'job_card';
protected $primaryKey = 'job_card_id';
protected $allowedFields = ['job_card_id','vehicle_id','sale_order','client_mobile_no','client_name','delivery_on','fuel','kilometer','materiality','customer_complaints','billing_address','billing_city','billing_state','billing_country','billing_postal_code','isactive'];
protected $allowedFields = ['job_card_id','vehicle_id','branch_id','order_number','sale_order','client_mobile_no','client_name','delivery_on','fuel','kilometer','materiality','customer_complaints','billing_address','billing_city','billing_state','billing_country','billing_postal_code','isactive','total','tax','subtotal','discount','status'];
public function getJobCardsWithProductsAndService($logged_user_branch_id)
{
// Select required fields from both tables
// $this->select('job_card.*, COUNT(sales_order_product.job_card_id) AS product_count,vehicle.reg_no');
// $this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count, COUNT(job_card_service.job_card_id) AS service_count,vehicle.reg_no');
$this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count, vehicle.reg_no');
// Join the sales_order_product table based on job_card_id
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id');
// $this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id');
// Group by job_card_id to get count of products per sales order
$this->groupBy('job_card.job_card_id');
// Add condition to fetch only active sales orders
$this->where('job_card_product.isactive', 1);
// $this->where('job_card_service.isactive', 1);
$this ->where('job_card.branch_id',$logged_user_branch_id);
$this->orderBy('job_card.job_card_id','DESC');
// Get the results
return $this->findAll();
}
}

View File

@ -5,7 +5,7 @@ class PurchaseOrderModel extends Model
{
protected $table = 'purchase_order';
protected $primaryKey = 'purchase_order_id';
protected $allowedFields = ['purchase_order_id','vendor_id','status','billing_address','billing_city','billing_state','billing_country','billing_postal_code','shipping_address','shipping_city','shipping_state','shipping_country','shipping_postal_code','terms_condition','isactive','order_date','contact_person_name','contact_person_mobile','description'];
protected $allowedFields = ['purchase_order_id','branch_id','vendor_id','status','billing_address','billing_city','billing_state','billing_country','billing_postal_code','shipping_address','shipping_city','shipping_state','shipping_country','shipping_postal_code','terms_condition','isactive','order_date','contact_person_name','contact_person_mobile','description'];
}

View File

@ -5,7 +5,7 @@ class ServiceModel extends Model
{
protected $table = 'services';
protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','service_name','price','cgst','igst','description','makes_id','models_id','isactive'];
protected $allowedFields = ['service_id','branch_id','service_name','price','cgst','igst','description','makes_id','models_id','isactive'];
public function getTax()

View File

@ -7,7 +7,7 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="">
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal_1" class="btn btn-primary waves-effect">
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal_1" class="btn btn-primary waves-effect" onclick="clearDetials(this)">
<i class="ri-add-line"></i>
</a>
</li>
@ -34,7 +34,7 @@
<tbody>
<?php foreach ($model as $item): ?>
<tr>
<td><?php echo $item['model_name']; ?></td>
<td class="model_name"><?php echo $item['model_name']; ?></td>
<td>
<?php if($item['isactive'] == 1): ?>
<span style="color:green">Active</span>
@ -43,10 +43,12 @@
<?php endif; ?>
</td>
<td>
<a data-toggle="modal" data-target="#bike_model_login-modal_1" value="<?php echo $item['model_id']; ?>" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>
<?php if($item['isactive'] == 1): ?>
<a style="color:red" 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)" class="fa fa-user-times"></a>
<?php else: ?>
<a style="color:green" 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)" class="fa fa-user"></a>
<?php endif; ?>
</td>
</tr>
@ -70,7 +72,7 @@
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4>Add Models</h4>
<h4 id="form_add_edit">Add Models</h4>
</div>
<form id="model_form_data" class="px-3">
@ -99,90 +101,105 @@
<script>
function submitModels(params) {
console.log( $('#modelname').val());
function submitModels(params) {
console.log( $('#modelname').val());
var formData = {
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_model"?>',
data: formData,
dataType: 'json',
success: function(response) {
// Handle success response here
console.log(response);
$('#bike_model_login-modal_1').modal('hide');
$('#modelname').val('');
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function statusChange(params) {
var status = params.getAttribute('data-isactive');
var model_id = params.getAttribute('data-id');
if(status == 1){
var isactive= 0;
}else{
var isactive= 1;
}
var formData = {
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
};
model_id: model_id,
isactive: isactive
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_model"?>',
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_model"?>',
data: formData,
dataType: 'json',
success: function(response) {
// Handle success response here
console.log(response);
$('#bike_model_login-modal_1').modal('hide');
$('#modelname').val('');
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
if (response.status == "success") {
$('tbody').html('');
$.each(response.data, function(index, item) {
var row = '<tr>' +
'<td>' + item.model_name + '</td>' +
'<td>';
function statusChange(params) {
var status = params.getAttribute('data-isactive');
var model_id = params.getAttribute('data-id');
if(status == 1){
var isactive= 0;
}else{
var isactive= 1;
}
if (item.isactive == 1) {
row += '<span style="color:green">Active</span>';
} else if (item.isactive == 0) {
row += '<span style="color:red">Inactive</span>';
}
var formData = {
model_id: model_id,
isactive: isactive
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_model"?>',
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>' + item.model_name + '</td>' +
'<td>';
row += '</td><td>';
// Check the isactive status and set the icon color accordingly
if (item.isactive == 1) {
row += '<span style="color:green">Active</span>';
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>';
} else if (item.isactive == 0) {
row += '<span style="color:red">Inactive</span>';
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 += '</td><td>';
row += '</td><td></td></tr>';
// Check the isactive status and set the icon color accordingly
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>';
} 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 += '</td><td></td></tr>';
// Append the row to the tbody
$('tbody').append(row);
});
// Append the row to the tbody
$('tbody').append(row);
});
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
});
}
}
function editModel(params) {
$('#form_add_edit').text('Edit Models');
var full_div = $(params).parent().parent()[0];
$('#modelname').val($(full_div).find('.model_name').text());
}
function clearDetials(params) {
$('#form_add_edit').text('Add Models');
$('#modelname').val('');
}
</script>

210
app/Views/branch_list.php Normal file
View File

@ -0,0 +1,210 @@
<?php include('layout/header.php'); ?>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Branch List - <?php echo $business_name;?></h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class=""> <a href="#" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
<i class="ri-add-line"></i>
</a>
</li>
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
<li class="breadcrumb-item active">Datatables</li> -->
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
<tr>
<th>Branch Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Postal Code</th>
<th>Mobile No</th>
<th>Active</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($branch as $value) :
?>
<tr>
<td><?= $value['branch_name']; ?></td>
<td><?= $value['address']; ?></td>
<td><?= $value['city']; ?></td>
<td><?= $value['state']; ?></td>
<td><?= $value['postal_code']; ?></td>
<td><?= $value['mobile_no']; ?></td>
<td>
<?php if ($value['isactive'] == 0): ?>
<span style="color: red;">Inactive</span>
<?php else: ?>
<span style="color: green;">Active</span>
<?php endif; ?>
</td>
<td>
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['branch_id']; ?>" onclick="editBranch(this)" class="edit-button"><i
class="ri-pencil-line"></i></a>
<a href="<?= base_url("delete_branch/".$value['branch_id']); ?>"
class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div> <!-- end card -->
</div> <!-- end col -->
<!-- Start Bike Make Create Pop-UP -->
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4>Add Branch - <?php echo $business_name;?></h4>
</div>
<form id="model_form_data" class="px-3">
<input type="text" id="business_id" value="<?php echo $business_id; ?>" hidden>
<input type="text" id="branch_id" hidden>
<div class="form-group">
<label for="branchname">Branch Name </label>
<input class="form-control" name="branch_name" type="text" id="branch_name" required="" placeholder="Branch Name....">
</div>
<div class="form-group">
<label for="address">Address </label>
<input class="form-control" name="address" type="text" id="address" required="" placeholder="Address....">
</div>
<div class="form-group">
<label for="city">City </label>
<input class="form-control" name="city" type="text" id="city" required="" placeholder="City....">
</div>
<div class="form-group">
<label for="state">State </label>
<input class="form-control" name="state" type="text" id="state" required="" placeholder="State....">
</div>
<div class="form-group">
<label for="pincode">Pin Code </label>
<input class="form-control" name="postal_code" type="text" id="postal_code" required="" placeholder="Pin Code....">
</div>
<div class="form-group">
<label for="mobilenumber">Mobile Number </label>
<input class="form-control" name="mobile_no" type="text" id="mobile_no" required="" placeholder="Mobile Number....">
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitBranch(this)">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- End Bike Make Create Pop-UP -->
</div>
<script>
function submitBranch(params) {
if ($('#branch_id').val()) {
var url = '<?= base_url("edit_branch/"); ?>'+$('#branch_id').val();
}else{
var url = '<?= base_url("add_branch/".$business_id); ?>';
}
var formData = {
branch_name: $('#branch_name').val(),
address: $('#address').val(),
city: $('#city').val(),
state: $('#state').val(),
postal_code: $('#postal_code').val(),
mobile_no: $('#mobile_no').val()
};
var form = $(params).parent().parent();
var isValid = true;
form[0].querySelectorAll('[required]').forEach(function(element) {
if (!element.value.trim()) {
isValid = false;
}
});
if (!isValid) {
return;
}
var business_id = $('#business_id').val();
// console.log(formData);
$.ajax({
type: 'POST',
url: url,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
$('#bike_model_login-modal').modal('hide');
$('#bike_make_name').val('');
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function editBranch(params) {
$.ajax({
type: 'GET',
url: '<?= base_url("get_branch/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
// console.log(response);
$('#branch_name').val(response.branch_name);
$('#address').val(response.address);
$('#branch_id').val(response.branch_id);
$('#city').val(response.city);
$('#mobile_no').val(response.mobile_no);
$('#postal_code').val(response.postal_code);
$('#state').val(response.state);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>
<?php include('layout/footer.php'); ?>

View File

@ -59,8 +59,8 @@
<td><?= $value['country']; ?></td>
<!-- Call the model method -->
<td>
<a href="<?= "new_branch/" . $value['business_id']; ?>" class=""><i
class="ri-add-circle-line"></i></a>
<a href="<?= "branch_index/" . $value['business_id']; ?>" class=""><i
class="ri-list-check-2"></i></a>
<a href="<?= "new_business/" . $value['business_id']; ?>" class="edit-button"><i
class="ri-pencil-line"></i></a>

View File

@ -0,0 +1,113 @@
<?php include('layout/header.php'); ?>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Add User</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
</li>
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
<li class="breadcrumb-item active">Datatables</li> -->
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<form action="<?= base_url() . "add_account"; ?>" method="post">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Name</label>
<input type="text" class="form-control" name="name" placeholder="Name" value="<?= isset($users['name']) ? $users['name'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Email</label>
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($users['email']) ? $users['email'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Password</label>
<input type="password" class="form-control" name="password" placeholder="Password" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($users['mobile_no']) ? $users['mobile_no'] : '' ?>" maxlength="10" minlength="10"required>
</div>
</div>
<input type="hidden" id="user_id" name="user_id" value="<?= isset($users['user_id']) ? $users['user_id'] : '' ?>">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Role</label>
<select id="inputState" class="form-control" name="role" required>
<option value="">Select Role</option>
<?php foreach ($roles as $role): ?>
<option value="<?= $role['role_id'] ?>" <?= isset($users['role']) && $users['role'] == $role['role_id'] ? 'selected' : '' ?>><?= $role['roles'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Business</label>
<select id="business" class="form-control" name="business" required>
<option value="">Select Business</option>
<?php foreach ($business as $busin): ?>
<option value="<?= $busin['business_id'] ?>" <?= isset($users['business_id']) && $users['business_id'] == $busin['business_id'] ? 'selected' : '' ?>><?= $busin['business_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Branch</label>
<select id="branch" class="form-control" name="branch" required>
<option value="">Select Branch</option>
<?php foreach ($branches as $branch): ?>
<option value="<?= $branch['branch_id'] ?>" <?= isset($users['branch_id']) && $users['branch_id'] == $branch['branch_id'] ? 'selected' : '' ?>><?= $branch['branch_name'] ?></option>
<?php endforeach; ?>
<!-- Branch options will be populated dynamically using JavaScript -->
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
<?php include('layout/footer.php'); ?>
<script>
$(document).ready(function() {
$('#business').change(function() {
var businessId = $(this).val();
if (businessId !== '') {
$.ajax({
url: '<?php echo base_url(),"get_branch"?>', // Update 'your_controller' with the actual controller name
type: 'post',
data: {business_id: businessId},
dataType: 'json',
success:function(response) {
var len = response.length;
$("#branch").empty();
$("#branch").append("<option value=''>Select Branch</option>");
for( var i = 0; i<len; i++) {
var branchId = response[i]['branch_id'];
var branchName = response[i]['branch_name'];
$("#branch").append("<option value='"+branchId+"'>"+branchName+"</option>");
}
}
});
} else {
$("#branch").empty();
$("#branch").append("<option value=''>Select Branch</option>");
}
});
});
</script>

View File

@ -89,7 +89,6 @@
<ul id="side-menu">
<li class="menu-title">Navigation</li>
@ -97,6 +96,7 @@
session()->get('logged_user_role') == 'Job Card Manager' ||
session()->get('logged_user_role') == 'Store Manager') {
?>
<li class="menu-title">Navigation</li>
<li>
<a href="#sidebarLayouts1" data-toggle="collapse">
@ -109,6 +109,9 @@
<li>
<a href="<?php echo base_url('sales_order_index') ?>">Sales Order</a>
</li>
<li>
<a href="<?php echo base_url('job_card_index') ?>">Job Card</a>
</li>
<li>
<a href="<?php echo base_url('vehicle_index') ?>">Vehicles</a>
</li>
@ -183,8 +186,7 @@
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
session()->get('logged_user_role') == 'Job Card Manager') { ?>
<?php if(session()->get('logged_user_role') == 'Floor Manager' ) { ?>
<li>
<a href="<?php echo base_url('index') ?>">
<i class="ri-message-2-line"></i>
@ -198,7 +200,28 @@
<?php if(session()->get('logged_user_role') == 'Administrator') { ?>
<li class="menu-title mt-2">Apps</li>
<li> <a href="<?php echo base_url('business_index') ?>"><i class="ri-layout-line"></i><span> Business </span></a></li>
<li>
<a href="<?php echo base_url('index') ?>">
<i class="fas fa-user"></i>
<span> Users</span>
</a>
</li>
<?php } ?>
<!-- <li class="menu-title">V Test </li>
<li>
<a href="<?php echo base_url('business_index') ?>">
<i class="fas fa-building"></i>
<span> Business</span>
</a>
</li>
<li>
<a href="<?php echo base_url('index') ?>">
<i class="fas fa-user"></i>
<span> Users</span>
</a>
</li> -->
</ul>
@ -249,10 +272,10 @@
<!-- item-->
<!-- <a href="<?= "new_user/" . session()->get("logged_user"); ?>" class="dropdown-item notify-item">
<a href="<?= base_url("edit_account/". session()->get("logged_user")); ?>" class="dropdown-item notify-item">
<i class="ri-account-circle-line"></i>
<span>My Account</span>
</a> -->
</a>
<div class="dropdown-divider"></div>

View File

@ -8,7 +8,7 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="">
<a href="#" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
<a href="#" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect" onclick="clearDetials(this)">
<i class="ri-add-line"></i>
</a>
</li>
@ -32,12 +32,14 @@
<tbody>
<?php foreach ($make as $item): ?>
<tr>
<td><?php echo $item['make']; ?></td>
<td class="make"><?php echo $item['make']; ?></td>
<td>
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" class="add-button" title="Add" data-id="<?php echo $item['make_id']; ?>" data-value="<?php echo $item['make']; ?>" onclick="setMakeName(this)">
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?php echo $item['make_id']; ?>" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="<?php echo $item['make_id']; ?>" data-value="<?php echo $item['make']; ?>" onclick="setMakeName(this)">
<i class="ri-add-line icon-large"></i>
</a>
<a href="<?= "bike_model_index/" . $item['make_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 16px;">
<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>
</td>
@ -57,7 +59,7 @@
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4>Add Bike Make</h4>
<h4 id="form_add_edit">Add Bike Make</h4>
</div>
<form id="model_form_data" class="px-3">
@ -148,9 +150,6 @@
});
}
function submitMake(params) {
var formData = {
makename: $('#bike_make_name').val()
@ -174,4 +173,19 @@
}
function editMake(params) {
$('#form_add_edit').text('Edit Bike Make');
var full_div = $(params).parent().parent()[0];
$('#bike_make_name').val($(full_div).find('.make').text());
}
function clearDetials(params) {
$('#form_add_edit').text('Add Bike Make');
$('#bike_make_name').val('');
}
</script>

View File

@ -8,7 +8,7 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="">
<a href="#" data-toggle="modal" data-target="#manufacturer_login-modal" class="btn btn-primary waves-effect">
<a href="#" data-toggle="modal" data-target="#manufacturer_login-modal" class="btn btn-primary waves-effect" onclick="clearDetials(this)">
<i class="ri-add-line"></i>
</a>
</li>
@ -33,9 +33,11 @@
<tbody>
<?php foreach ($manufacturer as $item): ?>
<tr>
<td><?php echo $item['manufacturer_name']; ?></td>
<td><?php echo $item['quality']; ?></td>
<td class="manufacturer_name"><?php echo $item['manufacturer_name']; ?></td>
<td class="quality"><?php echo $item['quality']; ?></td>
<td>
<a data-toggle="modal" data-target="#manufacturer_login-modal" value="<?php echo $item['manufacturer_id']; ?>" class="edit-button" onclick="editManufacturer(this)"><i class="ri-pencil-line"></i></a>
<a href="<?= "product_index/" . $item['manufacturer_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 16px;">
<i class="ri-list-check-2 icon-large"></i>
</a>
@ -56,7 +58,7 @@
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4>Add Manufacturer</h4>
<h4 id="form_add_edit">Add Manufacturer</h4>
</div>
<form id="model_form_data" class="px-3">
@ -118,5 +120,18 @@
});
}
function editManufacturer(params) {
$('#form_add_edit').text('Edit Manufacturer');
var full_div = $(params).parent().parent()[0];
$('#manufacturer_name').val($(full_div).find('.manufacturer_name').text());
$('#quality').val($(full_div).find('.quality').text());
}
function clearDetials(params) {
$('#form_add_edit').text('Add Manufacturer');
$('#manufacturer_name').val('');
$('#quality').val(0);
}
</script>