FIX_minor Bugs

This commit is contained in:
venba-Inspriron-3558 2025-11-13 17:54:23 +05:30
parent 78ba1fc582
commit 3a2456b629
6 changed files with 59 additions and 48 deletions

View File

@ -682,9 +682,10 @@ class Products extends BaseController
$purchase_order_level = floor($qty_in_stock / 2); // Calculate purchase reorder level (half of qty in stock)
$purchase_order_level = is_nan($purchase_order_level) ? '' : $purchase_order_level; // Safely assign values (handle invalid numbers)
$reorder_level = is_nan($qty_in_stock) ? '' : $qty_in_stock;
$ccIds = $this->request->getPost('cubic_centimeter_id');
$data = [
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
'cubic_centimeter_id' => !empty($ccIds) ? json_encode($ccIds) : null,
'product_name' => $this->request->getPost('product_name'),
'product_category' => $this->request->getPost('product_category'),
'total_amount' => $this->request->getPost('product_total_amount'),

View File

@ -99,6 +99,7 @@ class Service extends BaseController
$data['tax'] = $this->ServicesModel->getTax();
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
$data['product'] = [];
if ($service_id === '0') {
@ -107,7 +108,7 @@ class Service extends BaseController
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
$data['models'] = [];
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['product'] = [];
} else if ($service_id !== '0') {
@ -129,8 +130,17 @@ class Service extends BaseController
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$ccid = json_decode($services['cubic_capacity_id'], true);
$data['product'] = $this->get_product_by_cc($ccid);
// dd($data['service']);
if ($services['category'] == 0) {
$data['product'] = $this->ProductModel
->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
->where('products.isactive', 1)
->findAll();
} elseif ($services['category'] == 1) {
$data['product'] = $this->get_product_by_cc($ccid);
}
// dd($data);
}
$data['service_id'] = $service_id;
echo view('service_form',$data);
@ -153,11 +163,15 @@ class Service extends BaseController
// $model_json = json_encode($model_ids);
// $make_json = json_encode($make_ids);
$productIds = $this->request->getPost('product_id');
$subServiceIds = $this->request->getPost('sub_service_id');
$data = [
'service_name' => $this->request->getPost('servicename'),
'category' => $this->request->getPost('category'),
'product_id' => json_encode($this->request->getPost('product_id')),
'sub_service_id' => json_encode($this->request->getPost('sub_service_id')),
'product_id' => !empty($productIds) ? json_encode($productIds) : null,
'sub_service_id' => !empty($subServiceIds) ? json_encode($subServiceIds) : null,
'cgst' => $tax,
'sgst' => $tax,
'tax' => $this->request->getPost('tax'),

View File

@ -281,46 +281,41 @@ class Users extends BaseController
return view('user_form',$data);
}
public function edit_account($user_id)
{
$roleModel = new RoleModel();
$businessModel = new BusinessModel();
$usersModel = new UsersModel();
$uri = $this->request->getUri();
// Get the query parameters
$queryParams = $uri->getQuery();
if ($user_id === '0') {
$data = [];
// Fetch roles once (used in both cases)
$data['roles'] = $roleModel->getRoles();
$data['business'] = $businessModel->findAll();
if ($user_id === '0') { // New user
$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') {
$data['role_name'] = '';
} else { // Existing user
$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();
$users = $usersModel->getUserById($user_id);
$data['users'] = $users;
$role = $rolemodel->where('role_id',$users['role'])->first();
$roles =$rolemodel->getRoles();
$branchModel = new BranchModel();
$data['branches'] = $branchModel->where('business_id', $users['business_id'])->findAll();
$data['roles'] = $roles;
$data['role'] = $role;
$role = $roleModel->where('role_id', $users['role'])->first();
$data['role_name'] = $role['roles'] ?? '';
}
$data['user_id'] = $user_id;
return view('edit_account_form',$data);
}

View File

@ -15,7 +15,7 @@
<div class="card text-center">
<div class="card-body">
<h4 class="mt-3 mb-0"><?php echo $users['name']; ?></h4>
<p class="text-muted">@<?php echo $role['roles']; ?></p>
<p class="text-muted">@<?= $role_name ?></p>
<div class="text-left mt-3" style=" margin-bottom: 16px;">
<div class="table-responsive">
<table class="table table-borderless table-sm">

View File

@ -205,7 +205,7 @@
} else {
$value_ml = '';
}
?>
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>"
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
@ -746,18 +746,17 @@ $(document).ready(function() {
for (var i = 0; i < productarray.length; i++) {
var product = productarray[i];
// console.log("product",product);
var value_ml ='';
if (product.per == 'ml') {
value_ml = " ("+product.ml+product.per+")";
var value_ml = '';
if (product.per === 'ml') {
value_ml = " (" + product.ml + product.per + ")";
}
var product = productarray[i];
if(!selected_pr.includes(product.product_id))
{
newRow += '<option value="' + product.product_id + '" >' +
+ value_ml +
if (!selected_pr.includes(product.product_id)) {
newRow += '<option value="' + product.product_id + '">' +
product.product_name + value_ml +
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
'</option>';
'</option>';
}
}
newRow += '</select></td>' +
@ -1170,6 +1169,8 @@ $(document).on('click', '#selectClient', function() {
});
function fetchMakeAndModel(makeId, modelId) {
console.log("*************************");
// Make sure makeId and modelId are valid
if (makeId !== '' && modelId !== '') {
// Perform AJAX request to fetch product information

View File

@ -53,7 +53,7 @@
<?php if(isset($product)){ foreach ($product as $value) { ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($services['product_id']) && is_array(json_decode($services['product_id'])) && in_array($value['product_id'], json_decode($services['product_id'])) ? 'selected' : '' ?>>
<?= $value["product_name"] .' - '. $value['manufacturer_name']; ?>
<?= $value["product_name"].($value["manufacturer_name"] ? ' - '.$value["manufacturer_name"] : ''); ?>
</option>
<?php endif; ?>
<?php } }?>
@ -381,7 +381,7 @@ document.getElementById('category').addEventListener('change', function() {
// Append new options
$('#productSelect').append('<option value>Select Product</option>');
$.each(response, function(index, product) {
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - ' + product.manufacturer_name + '</option>');
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name + (product.manufacturer_name ? ' - ' + product.manufacturer_name : '') + '</option>');
});
} else {
// Handle case when no vendors are found for the selected model