FIX_minor issues

This commit is contained in:
VE10-Sanjeev 2025-01-04 03:07:18 +00:00
parent e591e1b4a9
commit 7ae211fcb5
24 changed files with 295 additions and 92 deletions

View File

@ -79,7 +79,7 @@ class Client extends BaseController
if (!empty($client_id)) {
$data['updated_by'] = (int)$this->session->get('logged_user');
$update= $ClientModel->update($client_id, $data);
if($update){
@ -91,6 +91,7 @@ class Client extends BaseController
$error = "Mobile number already exists";
return json_encode(false);
}else{
$data['created_by'] = (int)$this->session->get('logged_user');
$ClientModel->insert($data);
return json_encode(true);
}

View File

@ -29,6 +29,19 @@ class Complaint extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$name = $this->request->getPost('name');
$ComplaintModel = new ComplaintModel();
if ($complaint_id>0) {
$complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1])
->where('complaint_id !=', $complaint_id)
->findAll();
} else {
$complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1])->findAll();
}
if (!empty($complaint)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
"name" => $this->request->getPost('name'),

View File

@ -39,6 +39,20 @@ class Manufacturer extends BaseController
$manufacturer_name = $this->request->getPost('manufacturername');
$quality = $this->request->getPost('quality');
$ManufacturerModel = new ManufacturerModel();
if ($manufacturer_id>0) {
$manufacturer = $ManufacturerModel->where(['manufacturer_name' => $manufacturer_name, 'isactive' => 1])
->where('manufacturer_id !=', $manufacturer_id)
->findAll();
} else {
$manufacturer = $ManufacturerModel->where(['manufacturer_name' => $manufacturer_name, 'isactive' => 1])->findAll();
}
if (!empty($manufacturer)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
'manufacturer_name' => $manufacturer_name,
'quality' => $quality,

View File

@ -64,8 +64,21 @@ class Model extends BaseController
try {
$make_id = $this->request->getPost('make_id');
$model_name = $this->request->getPost('modelname');
$BikemodelsModel = new BikemodelsModel();
if ($make_id>0) {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])
->where('make_id !=', $make_id)
->findAll();
} else {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])->findAll();
}
if (!empty($make)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
'make_id' => $make_id,
'model_name' => $model_name

View File

@ -28,16 +28,30 @@ class Outsourcing extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$name = $this->request->getPost('name');
$id = $this->request->getPost('id');
$OutsourceModel = new OutsourceModel();
if ($id == '') {
$complaint = $OutsourceModel->where(['name' => $name, 'is_active' => 1])
->where('id !=', $id)
->findAll();
} else {
$complaint = $OutsourceModel->where(['name' => $name, 'is_active' => 1])->findAll();
}
if (!empty($complaint)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
"name" => $this->request->getPost('name'),
"name" => $name,
"labour_cost" => $this->request->getPost('labour_cost'),
"cost_with_tax" => $this->request->getPost('cost_with_tax'),
"tax" => $this->request->getPost('tax'),
"description" => $this->request->getPost('description'),
];
if ($this->request->getPost('id') == '') {
if ($id == '') {
$OutsourceModel = new OutsourceModel();
$data['business_id'] = $this->session->get('logged_user_business_id');
$inserted = $OutsourceModel->insert($data);

View File

@ -102,8 +102,10 @@ class Vehicle extends BaseController
$vehicle_id = $this->request->getPost('vehicle_id');
if (!empty($vehicle_id)) {
$data['updated_by'] = (int)$this->session->get('logged_user');
$VehicleModel->update($vehicle_id, $data);
} else {
$data['created_by'] = (int)$this->session->get('logged_user');
$VehicleModel->insert($data);
}
return redirect()->to('vehicle_index');

View File

@ -71,10 +71,25 @@ class Vendor extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$VendorModel = new VendorModel();
$vendor_name = $this->request->getPost('vendor_name');
$vendor_id = $this->request->getPost('vendor_id');
if ($vendor_id>0) {
$vendor = $VendorModel->where(['vendor_name' => $vendor_name, 'isactive' => 1])
->where('vendor_id !=', $vendor_id)
->findAll();
} else {
$vendor = $VendorModel->where(['vendor_name' => $vendor_name, 'isactive' => 1])->findAll();
}
if (!empty($vendor)) {
session()->setFlashdata('warning', 'Vendor Name Already Exist.');
$this->logger->info("Vendor: Name Already Exist ID = ".$vendor_id);
return redirect()->to('vendor_index');
}
$data = [
'vendor_name' => $this->request->getPost('vendor_name'),
'vendor_name' => $vendor_name,
'gstnumber' => $this->request->getPost('gstnumber'),
'vendor_email' => $this->request->getPost('email'),
'address' => $this->request->getPost('address'),

View File

@ -5,7 +5,7 @@ class ClientModel extends Model
{
protected $table = 'client';
protected $primaryKey = 'client_id';
protected $allowedFields = ['client_id','client_type','gstnumber','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id'];
protected $allowedFields = ['client_id','client_type','gstnumber','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id','updated_by','created_by'];
}

View File

@ -7,7 +7,7 @@ class VehicleModel extends Model
protected $table = 'vehicle';
protected $primaryKey = 'vehicle_id';
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive'];
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive','updated_by','created_by'];
public function getCustomerandVehicle($branch_id)
{

View File

@ -20,7 +20,7 @@
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Client Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="client_name" placeholder="Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" required>
<input type="text" class="form-control" name="client_name" id="client_name" placeholder="Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputAddress" class="col-form-label">Mobile<span class="text-danger">*</span></label>
@ -70,7 +70,7 @@
</div>
</div>
<button type="submit" id="client_form_submit" class="btn btn-primary">Submit</button>
<button type="submit" id="client_form_submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -92,6 +92,22 @@
// action="<?= base_url() . "add_client"; ?>"
var formData = $('#client_form').serialize();
const submitButton = $('#client_form_submit');
var mobile = $('#mobile').val();
var clientname = $('#client_name').val();
if (!clientname) {
toastr.warning("Client Name cannot be empty!");
$('#client_name').focus();
submitButton.prop('disabled', false).text('Submit');
return;
}
if (!mobile) {
toastr.warning("mobile Number cannot be empty!");
$('#mobile').focus();
submitButton.prop('disabled', false).text('Submit');
return;
}
submitButton.prop('disabled', true).text('Processing...');
$.ajax({
type: 'POST',
@ -102,12 +118,12 @@
console.log(response);
if(response == 'update'){
toastr.success('Client Updated Succssfully');
window.location.href = '<?= base_url() . "client_index"; ?>';
// submitButton.prop('disabled', false).text('Submit');
}else if(response){
toastr.success('Client Added Succssfully');
window.location.href = '<?= base_url() . "client_index"; ?>';
// submitButton.prop('disabled', false).text('Submit');
}else{
toastr.warning('Mobile number already exists');
$('#mobile_error').html('Mobile number already exists');
@ -115,8 +131,8 @@
$('#mobile').focus();
setTimeout(() => {
$('#mobile').css('border', '1px solid #ced4da');
}, 2000);
submitButton.prop('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {

View File

@ -19,9 +19,9 @@
<table id="datatable-complaint" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
<thead>
<tr>
<th> Complaint</th>
<th>Complaint</th>
<th>Unit Price (Including Tax)</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th hidden>Status</th>
<th>Actions</th>
@ -34,8 +34,8 @@
$color ='red';
}?>
<tr class="complaint_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" > <td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost_with_tax']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_charge']; ?></td>
<td hidden>
<?php if($value['isactive'] == 1): ?>
@ -80,8 +80,11 @@
<label for="name">Complaint </label>
<input class="form-control" type="text" id="complaint_id" hidden>
<input class="form-control" type="text" id="name" required="" placeholder="Complaint">
</div>
<div class="form-group">
<label for="labour_cost_with_tax">Unit Price (Including Tax)</label>
<input class="form-control" type="number" id="labour_cost_with_tax" name="labour_cost_with_tax" placeholder="Total Price" step="0.01" min="0" onkeyup="ReverseCalculation()" required>
</div>
<div class="form-group">
<label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
@ -90,10 +93,6 @@
<option value="28" >28%</option>
</select>
</div>
<div class="form-group">
<label for="labour_cost_with_tax">Labour Charge + Tax</label>
<input class="form-control" type="text" id="labour_cost_with_tax" placeholder="Labour Charge + Tax" onkeyup="ReverseCalculation()" required>
</div>
<div class="form-group">
<label for="labour_charge">Labour Charge </label>
<input class="form-control" type="text" id="labour_charge" placeholder="Labour Charge" required readonly>
@ -138,8 +137,7 @@
if (!complaint_id) {
complaint_id = 0;
}
$(params).attr('disabled', true);
$(params).attr('disabled', true).text('Processing...');
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_complaint/"?>' + complaint_id,
@ -147,12 +145,29 @@
dataType: 'json',
success: function(response) {
console.log(response);
// Reload the page after successful submission
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}

View File

@ -175,7 +175,7 @@
</div>
</div>
<?php if ($return_order['status'] !== 'Returned') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>

View File

@ -340,10 +340,10 @@
</div>
<?php if (!isset($jobs['status']) || $jobs['status'] !== 'Paid') : ?>
<button type="submit" id="submit-btn" class="btn btn-primary">Submit</button>
<button type="submit" id="submit-btn" class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
<?php if (isset($rework) && $rework = 'Paid') : ?>
<button type="submit" id="submit-btn" class="btn btn-primary">Submit</button>
<button type="submit" id="submit-btn" class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>
@ -1237,11 +1237,12 @@ $(document).ready(function() {
data_contruction_for_save();
$("#delete_items").val(JSON.stringify(delete_items_id));
$('#form-submit').submit();
$('#submit-btn').prop('disabled', true);
$('#submit-btn').prop('disabled', true).text('Processing...');
}else{
$('#submit-btn').prop('disabled', false).text('Submit');
}
});
});
// Event listener for product selection
$(document).on('change', 'select[name="item_details[]"]', function() {
var productId = $(this).val();

View File

@ -91,7 +91,7 @@
<!-- <a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Invoice</a> -->
<?php } ?>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" class="dropdown-item preview-jobcard" href="#" title="Preview Jobcard"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Jobcard</a>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" data-order_number="<?= $value['order_number']; ?>" class="dropdown-item download-files"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Preview Files</a>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" data-order_number="<?= $value['order_number']; ?>" class="dropdown-item download-files"><i class="ri-eye-fill mr-2 text-muted font-18 vertical-middle"></i>Preview Files</a>
<!-- <a href="<?= base_url() ."download_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item download-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Jobcard</a> -->
<?php if($value['status'] == 'Paid' && $admins && $value['is_rework'] == 0) { ?>

View File

@ -151,6 +151,7 @@
modelname: $('#modelname').val()
};
var model_id =0;
$(params).attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: 'create_model/'+model_id,
@ -158,6 +159,13 @@
dataType: 'json',
success: function(response) {
console.log(response);
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
@ -165,10 +173,22 @@
$('#modelname').val('');
toastr.success(response.data, 'Success');
}
} else {
alert(response.data || "Unexpected error occurred!");
toastr.success(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.success(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}
@ -190,25 +210,43 @@
if (!edit_make_id) {
edit_make_id =0;
}
$(params).attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: 'create_make/'+edit_make_id,
data: formData,
dataType: 'json',
success: function(response) {
if (response.status == "failed") {
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_make_login-modal').modal('hide');
$('#bike_make_name').val('');
toastr.success(response.data, 'Success');
window.location.reload();
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_model_login-modal').modal('hide');
$('#modelname').val('');
toastr.success(response.data, 'Success');
window.location.reload();
}
} else {
alert(response.data || "Unexpected error occurred!");
toastr.success(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
// console.error(xhr.responseText);
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.success(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}

View File

@ -123,7 +123,7 @@
if (!$('#manufacturer_name').val() || !$('#quality').val()) {
return false;
}
$('#manufacturer_submit').attr('disabled','true');
$('#manufacturer_submit').attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_manufacturer/"?>'+edit_manufacturer_id,
@ -131,13 +131,30 @@
dataType: 'json',
success: function(response) {
console.log(response);
$('#manufacturer_modal').modal('hide');
$('#bike_make_name').val('');
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
$('#manufacturer_modal').modal('hide');
$('#bike_make_name').val('');
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
}
});
}

View File

@ -20,8 +20,8 @@
<thead>
<tr>
<th>Out Sourcing</th>
<th>Unit Price (Including Tax)</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th>Description</th>
<th hidden>Status</th>
@ -36,8 +36,8 @@
}?>
<tr class="outsource_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
<td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['cost_with_tax']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost']; ?></td>
<td><?= $value['description']; ?></td>
<td hidden>
@ -85,6 +85,10 @@
<input class="form-control" type="text" id="name" required="" placeholder="Name">
</div>
<div class="form-group">
<label for="cost_with_tax">Unit Price (Including Tax)</label>
<input class="form-control" type="number" id="cost_with_tax" name="cost_with_tax" placeholder="Total Price" step="0.01" min="0" onkeyup="ReverseCalculation()" required >
</div>
<div class="form-group">
<label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
@ -93,10 +97,6 @@
<option value="28" >28%</option>
</select>
</div>
<div class="form-group">
<label for="cost_with_tax">Labour Charge + Tax</label>
<input class="form-control" type="text" id="cost_with_tax" name="cost_with_tax" placeholder="Labour Charge + Tax" onkeyup="ReverseCalculation()" required="">
</div>
<div class="form-group">
<label for="labour_cost">Labour Cost </label>
<input class="form-control" type="text" id="labour_cost" placeholder="Labour Charge" required readonly>
@ -134,6 +134,7 @@
function submitComplaint(params, event) {
$(params).attr('disabled', true).text('Processing...');
if (!$('#name').val() || !$('#labour_cost').val() ) {
return false;
}
@ -159,11 +160,32 @@
// $('#outsource_submit_button').removeAttr('disabled');
console.log(response);
// Reload the page after successful submission
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
return;
}
if (response.code === 200 || response.status === 'success') {
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
}
});
}

View File

@ -32,7 +32,7 @@
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_purchase"; ?>" method="post">
<form action="<?= base_url() . "add_purchase"; ?>" method="post" id="purchaseForm">
<input type="hidden" id="purchase_order_id" name="purchase_order_id" value="<?= isset($purchase['purchase_order_id']) ? $purchase['purchase_order_id'] : '' ?>"readonly>
<h4 class="header-title">Purchase Details :</h4><br>
<div class="form-row">
@ -226,7 +226,7 @@
</div>
</div> -->
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received' || isset($reorder)) : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>
@ -641,6 +641,12 @@ $('#editaddbutton').click(function(event) {
// 'background-color': '#ebebe0',
// });
});
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#purchaseForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});

View File

@ -156,7 +156,7 @@
</textarea>
</div>
</div>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>

View File

@ -199,7 +199,7 @@
</div>
</div>
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Released') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>

View File

@ -18,7 +18,7 @@
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_service"; ?>" method="post">
<form action="<?= base_url() . "add_service"; ?>" method="post" id="serviceForm">
<h4 class="header-title">Service Details :</h4>
<div class="form-row">
<div class="form-group col-md-3">
@ -88,25 +88,10 @@
<input type="hidden" id="service_id" name="service_id" value="<?= isset($services['service_id']) ? $services['service_id'] : '' ?>"><br>
<h4 class="header-title">Pricing Information :</h4>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" data-toggle="select2" required>
<?php
<?php
$cgst = isset($services['cgst']) ? $services['cgst'] : 0; // CGST value (half of the tax amount)
$sgst = isset($services['sgst']) ? $services['sgst'] : 0; // SGST value (half of the tax amount)
$tax = $cgst + $sgst; // Total tax (sum of CGST and SGST)
?>
<option value="" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Labour Cost + Tax<span class="text-danger">*</span></label>
<?php
if(isset($services['labour_cost'])){
$labour_cost = ($services['labour_cost'] / 100) * $tax;
$labour_cost = round($labour_cost + $services['labour_cost']);
@ -114,7 +99,18 @@
$labour_cost = '';
}
?>
<input type="text" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Labour Cost + Tax" value="<?= $labour_cost; ?>" required="">
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Total Price" step="0.01" min="0" value="<?= $labour_cost; ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax<span class="text-danger">*</span></label>
<select class="form-control status-select" name="tax" data-toggle="select2" required>
<option value="" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</div>
@ -141,7 +137,7 @@
<textarea class="form-control" name="description" placeholder="Description" ><?= isset($services['description']) ? $services['description'] : '' ?></textarea>
</div>
</div>
<button id="service_form_submit" type="submit" class="btn btn-primary">Submit</button>
<button id="service_form_submit" type="submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -470,6 +466,12 @@ 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"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
</script>

View File

@ -18,8 +18,7 @@
<div class="card">
<div class="card-body">
<form id="vehicle_add_form_id" action="<?= base_url() . "add_vehicle"; ?>" method="post" id="vehicleForm">
<form id="vehicle_add_form_id" action="<?= base_url() . "add_vehicle"; ?>" method="post">
<h4 class="header-title">Vehicle Details :</h4>
<div class="form-row">
<div class="form-group col-md-4">
@ -468,10 +467,13 @@ $('#saveModelBtn').click(function() {
var register_number = $('#regno').val();
var vehicle_id = $('#vehicle_id').val();
const submitButton = $('#form_submit_button');
submitButton.prop('disabled', true).text('Processing...');
if (!register_number) {
toastr.warning("Registration Number cannot be empty!");
$('#regno').focus(); // Set focus to the registration number input field
submitButton.prop('disabled', false).text('Submit');
return;
}
@ -483,9 +485,9 @@ $('#saveModelBtn').click(function() {
data: { register_number: register_number },
success: function (response) {
if (response) {
$('#regno').val('');
$('#regno').focus(); // Set focus to the registration number input field
$('#regno').val('').focus();
toastr.warning("Register Number Already Added!");
submitButton.prop('disabled', false).text('Submit');
} else {
// If the registration number is not a duplicate, submit the form
$('#vehicle_add_form_id')[0].submit();
@ -494,22 +496,19 @@ $('#saveModelBtn').click(function() {
error: function (xhr, status, error) {
console.error(error); // Log any errors to the console
toastr.error("An error occurred while checking the registration number.");
submitButton.prop('disabled', false).text('Submit');
}
});
} else {
$('#vehicle_add_form_id')[0].submit();
}
});
$('#vehicle_add_form_id').on('submit', function () {
const submitButton = $('#form_submit_button');
submitButton.prop('disabled', true).text('Processing...');
});
});
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#vehicleForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
</script>

View File

@ -167,7 +167,7 @@
</div>
</div>
<button type="submit" id="vendor_add_submit" class="btn btn-primary">Submit</button>
<button type="submit" id="vendor_add_submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -240,14 +240,14 @@ $(document).ready(function() {
});
$('#vendor_add_submit').click(function (event) {
var form = document.getElementById('vendor_form');
var form = document.getElementById('vendor_form');
if (form.checkValidity()) {
$(this).attr('disabled', true);
$(this).attr('disabled', true).text('Processing...');
$('#vendor_form').submit();
}else{
$(this).attr('disabled', false).text('Submit');
}
})
});
});
</script>
<style>

View File

@ -74,6 +74,21 @@
</div>
</div> <!-- end card -->
</div> <!-- end col -->
<?php if (session()->getFlashdata('warning')): ?>
<script>
$(document).ready(function() {
toastr.warning("<?= session()->getFlashdata('warning'); ?>", "Warning");
});
</script>
<?php endif; ?>
<?php if (session()->getFlashdata('success')): ?>
<script>
$(document).ready(function() {
toastr.success("<?= session()->getFlashdata('success'); ?>", "Success");
});
</script>
<?php endif; ?>
<?php include('layout/footer.php'); ?> </div>
<script>