Edit Issues fixes

This commit is contained in:
VE10-Sanjeev 2025-01-20 06:31:09 +00:00
parent cf26a1d723
commit 7d22f3ebd3
9 changed files with 135 additions and 32 deletions

View File

@ -65,14 +65,16 @@ class Model extends BaseController
$make_id = $this->request->getPost('make_id');
$model_name = $this->request->getPost('modelname');
$BikemodelsModel = new BikemodelsModel();
//they check model name already exist or not here.
if ($make_id>0) {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])
$make = $BikemodelsModel->where(['model_name' => $model_name, 'isactive' => 1])
->where('make_id !=', $make_id)
->findAll();
} else {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])->findAll();
$make = $BikemodelsModel->where(['model_name' => $model_name, 'isactive' => 1])->findAll();
}
if (!empty($make)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
@ -85,9 +87,11 @@ class Model extends BaseController
];
// print_r($model_id);die;
//here model id they get from Param.
if (!$model_id) {
try {
$data['business_id'] = $this->session->get('logged_user_business_id');
$data['created_by'] = (int)$this->session->get('logged_user');
$inserted = $BikemodelsModel->insert($data);
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
@ -104,7 +108,7 @@ class Model extends BaseController
}
}
else{
$data['updated_by'] = (int)$this->session->get('logged_user');
$updated = $BikemodelsModel->update($model_id ,$data);
if ($updated) {
$result = $data;
@ -133,7 +137,7 @@ class Model extends BaseController
$data = [
'isactive' => $isactive
];
$data['updated_by'] = (int)$this->session->get('logged_user');
$updated = $BikemodelsModel->update($model_id, $data);
$model = $BikemodelsModel->where('model_id',$model_id)->first();

View File

@ -64,6 +64,7 @@ class Products extends BaseController
$data['products'] = $this->ProductModel->where('manufacturer_id',$manufacturer_id)->orderBy('product_name')->findAll();
$manufacturer = $this->ManufacturerModel->where('manufacturer_id',$manufacturer_id)->select('manufacturer_name')->first();
// print_r($manufacturer);die;
$data['manufacturer_id'] = $manufacturer_id;
$data['manufacturer_name'] = $manufacturer['manufacturer_name'];

View File

@ -126,16 +126,18 @@ class Service extends BaseController
public function add_service()
{
{
$tax= $this->request->getPost('tax')/2;
$final_price = ($this->request->getPost('productCost') ? $this->request->getPost('productCost') : 0) +
($this->request->getPost('serviceCost') ? $this->request->getPost('serviceCost') : 0) +
($this->request->getPost('labour_cost_With_Tax') ? $this->request->getPost('labour_cost_With_Tax') : 0);
// print $final_price;
// print_r($this->request->getPost());
$make_ids = $this->request->getPost('make');
$model_ids = $this->request->getPost('model');
$model_json = json_encode($model_ids);
$make_json = json_encode($make_ids);
$data = [
@ -148,15 +150,13 @@ class Service extends BaseController
'tax' => $this->request->getPost('tax'),
'labour_cost' => $this->request->getPost('labour_cost'),
'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
'price' => $this->request->getPost('price'),
'price' => $final_price,
'makes_id' => $make_json,
'models_id' => $model_json,
'description' => $this->request->getPost('description'),
'isactive' => 1 ,
];
$service_id = $this->request->getPost('service_id');
if (!empty($service_id))
{

View File

@ -172,6 +172,7 @@
$('#bike_model_login-modal').modal('hide');
$('#modelname').val('');
toastr.success(response.data, 'Success');
$(params).attr('disabled', false).text('Submit');
}
} else {
alert(response.data || "Unexpected error occurred!");

View File

@ -149,8 +149,8 @@
</div>
<div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger">*</span></label>
<select class="form-control status-select SelExample" name="productcategory" required data-toggle="select2">
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" style="font-size: 18px;" data-toggle="modal" id="addProductCategoryButton" data-target="#add_product_category" title="Add Product Category"></i>' ?>
<select class="form-control status-select SelExample" id="PCselect" name="productcategory" required data-toggle="select2">
<option value="">Select Category</option>
<?php
if (isset($products['product_id']) && $products['product_id']) {
@ -390,6 +390,32 @@
</div><!-- /.modal -->
<!-- End Bike Make Create Pop-UP -->
<!-- Start Product Category Add/edit Pop-UP -->
<div id="add_product_category" 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 id="form_add_edit">Add Product Category</h4>
</div>
<div class="form-group">
<label for="productcategoryname">Product Category Name </label>
<input type="text" id="product_category_id" hidden>
<input class="form-control" type="text" id="product_category_name" required="" placeholder="Product Category Name....">
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" id="pcBtn" onclick="submitproductcategory(this)">Save Product Category</button>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- End Product Category Add/edit Pop-UP -->
<script>
@ -1066,5 +1092,62 @@ function deleteProductName(data) {
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
function submitproductcategory(params) {
// Get the value of the Product Category Name input field
var productcategoryname = $('#product_category_name').val().trim();
const pcButton = $('#pcBtn');
pcButton.prop('disabled', true).text('Processing...');
if (productcategoryname === '') {
toastr.error('Please enter a Product Category Name.', 'Error');
pcButton.prop('disabled', false).text('Save Product Category');
return;
}
var formData = {
product_category_name: $('#product_category_name').val(),
product_category_id : 0
};
if (productcategoryname !== '') {
$.ajax({
type: 'POST',
url: 'create_product_category/0',
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
pcButton.prop('disabled', false).text('Save Product Category');
}else{
$('#product_category_name').val('');
toastr.success(response.data, 'Success');
$('#PCselect').empty();
response.product_category_list.forEach(function(PC) {
$('#PCselect').append($('<option>', {
value: PC.product_category_id,
text: PC.product_category_name
}));
});
$('#PCselect option').each(function() {
if ($(this).text() === productcategoryname) {
$(this).prop('selected', true);
}
});
$('#add_product_category').modal('hide');
}
pcButton.prop('disabled', false).text('Save Product Category');
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
pcButton.prop('disabled', false).text('Save Product Category');
}
});
}
}
</script>

View File

@ -73,6 +73,7 @@
<input class="form-control form-control-sm" type="text" id="searchRackNo" placeholder=" Rack No">
</td>
</tr>
<tr>
<th>SKU Id</th>
<th>Product Name</th>
@ -82,6 +83,7 @@
<th>Qty in Stock</th>
<th>Rack No</th>
<?php if(!$manufacturer_id) { ?><th>Actions</th><?php } ?>
</tr>
</thead>
@ -100,7 +102,7 @@
<?= $value['product_name']; ?>
</td>
<td><?= $value['manufacturer_name']; ?></td>
<td><?= isset($value['manufacturer_name']) ? $value['manufacturer_name'] : ''; ?></td>
<td><?= $value['product_category']; ?></td>
<td><?= number_format($value['unit_price']); ?></td>
<td><?= $value['qty_stock']; ?></td>

View File

@ -122,8 +122,10 @@
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="price" id="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" readonly>
<!-- <label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label> -->
<input type="hidden" class="form-control" name="price" id="price" placeholder="Price" value="<?= isset($services['price']) ? $services['price'] : 0 ?>">
<input type="hidden" class="form-control" name="productCost" id="productCost" placeholder="ProductCost" value="0">
<input type="hidden" class="form-control" name="serviceCost" id="serviceCost" placeholder="ServiceCost" value="0">
</div>
</div>
<br>
@ -274,6 +276,14 @@ $(document).ready(function() {
});
}
});
data = <?php echo json_encode($product) ?>;
servicedata = <?php echo json_encode($service) ?>;
var service_id = "<?php echo $service_id; ?>";
if (service_id != 0) {
$("#productSelect").trigger('change');
$('#serviceSelected').trigger('change');
}
});
@ -330,9 +340,8 @@ document.getElementById('category').addEventListener('change', function() {
}
});
</script>
<input id="productCost" value="0" hidden>
<script>
data = <?php echo json_encode($product) ?>;
$('#productSelect').change(function() {
console.log('this.value',this.value);
if(this.value != 0) {
@ -378,9 +387,7 @@ document.getElementById('category').addEventListener('change', function() {
}
</script>
<input id="serviceCost" value="0" hidden>
<script>
servicedata = <?php echo json_encode($service) ?>;
$('#serviceSelected').change(function() {
// console.log(this.value);
if(this.value != 0) {
@ -469,6 +476,9 @@ document.getElementById('category').addEventListener('change', function() {
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#serviceForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
var labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
var add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
$('#price').val(add);
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});

View File

@ -23,6 +23,7 @@
<thead>
<tr>
<th>Service Name</th>
<th>Labour Cost</th>
<th>Price</th>
<th>Tax</th>
<th>Description</th>
@ -38,6 +39,7 @@
}?>
<tr class="service_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
<td><?= $value['service_name']; ?></td>
<td><?= $value['labour_cost']; ?></td>
<td><?= $value['price']; ?></td>
<td><?= $value['cgst'] + $value['sgst']; ?></td>
<td><?= $value['description']; ?></td>

View File

@ -22,7 +22,7 @@
<form action="<?= base_url() . "add_user"; ?>" method="post">
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Business</label>
<label for="inputState" class="col-form-label">Business<span class="text-danger">*</span></label>
<select id="business" class="form-control" name="business" required>
<!-- <option value="">Select Business</option> -->
<?php foreach ($business as $busin): ?>
@ -31,7 +31,7 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Branch</label>
<label for="inputState" class="col-form-label">Branch<span class="text-danger">*</span></label>
<select id="branch" class="form-control" name="branch" required>
<!-- <option value="">Select Branch</option> -->
<?php if (isset($branch) && (is_array($branch) || is_object($branch))) {
@ -42,7 +42,7 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Role</label>
<label for="inputState" class="col-form-label">Role<span class="text-danger">*</span></label>
<select id="inputState" class="form-control" name="role" required>
<option value="">Select Role</option>
<?php foreach ($roles as $role): ?>
@ -56,19 +56,19 @@
<h5 class="text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Personal Info</h5>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Name</label>
<label for="inputEmail4" class="col-form-label">Name<span class="text-danger">*</span></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>
<label for="inputEmail4" class="col-form-label">Email<span class="text-danger">*</span></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>
<label for="inputPassword4" class="col-form-label">Password<span class="text-danger">*</span></label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<label for="inputAddress" class="col-form-label">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($users['mobile_no']) ? $users['mobile_no'] : '' ?>" maxlength="16" minlength="6"required>
</div>
</div>
@ -88,7 +88,7 @@
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="old_password">Old Password</label>
<label for="old_password">Old Password<span class="text-danger">*</span></label>
<div class="input-group">
<input type="password" class="form-control" id="old_password" required>
<div class="input-group-append">
@ -102,7 +102,7 @@
<div class="col-md-6">
<div class="form-group">
<label for="new_password">New Password</label>
<label for="new_password">New Password<span class="text-danger">*</span></label>
<div class="input-group">
<input type="password" class="form-control" id="new_password" required>
<div class="input-group-append">
@ -116,7 +116,7 @@
<div class="col-md-6">
<div class="form-group">
<label for="confirm_password">Confirm Password</label>
<label for="confirm_password">Confirm Password<span class="text-danger">*</span></label>
<div class="input-group">
<input type="password" class="form-control" id="confirm_password" required>
<div class="input-group-append">