diff --git a/app/Controllers/Client.php b/app/Controllers/Client.php index 04734b8..d502070 100755 --- a/app/Controllers/Client.php +++ b/app/Controllers/Client.php @@ -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); } diff --git a/app/Controllers/Complaint.php b/app/Controllers/Complaint.php index e12b1fd..cf206fc 100755 --- a/app/Controllers/Complaint.php +++ b/app/Controllers/Complaint.php @@ -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'), diff --git a/app/Controllers/Manufacturer.php b/app/Controllers/Manufacturer.php index b255a74..daa809f 100755 --- a/app/Controllers/Manufacturer.php +++ b/app/Controllers/Manufacturer.php @@ -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, diff --git a/app/Controllers/Model.php b/app/Controllers/Model.php index 6f7b03f..0b9d59b 100755 --- a/app/Controllers/Model.php +++ b/app/Controllers/Model.php @@ -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 diff --git a/app/Controllers/Outsourcing.php b/app/Controllers/Outsourcing.php index ac2116f..5b43dc9 100755 --- a/app/Controllers/Outsourcing.php +++ b/app/Controllers/Outsourcing.php @@ -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); diff --git a/app/Controllers/Vehicle.php b/app/Controllers/Vehicle.php index d7ab1e6..f0e7942 100755 --- a/app/Controllers/Vehicle.php +++ b/app/Controllers/Vehicle.php @@ -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'); diff --git a/app/Controllers/Vendor.php b/app/Controllers/Vendor.php index b5891da..9744196 100755 --- a/app/Controllers/Vendor.php +++ b/app/Controllers/Vendor.php @@ -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'), diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index 5bf42a6..8143a86 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -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']; } \ No newline at end of file diff --git a/app/Models/VehicleModel.php b/app/Models/VehicleModel.php index 81bf969..0f42b8b 100755 --- a/app/Models/VehicleModel.php +++ b/app/Models/VehicleModel.php @@ -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) { diff --git a/app/Views/client_form.php b/app/Views/client_form.php index 949d146..22601e5 100755 --- a/app/Views/client_form.php +++ b/app/Views/client_form.php @@ -20,7 +20,7 @@
| Complaint | +Complaint | +Unit Price (Including Tax) | Tax | -Labour Charge With Tax | Labour Charge | Status | Actions | @@ -34,8 +34,8 @@ $color ='red'; }?>||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| = $value['name']; ?> | -= $value['tax']; ?> | = $value['labour_cost_with_tax']; ?> | += $value['tax']; ?> | = $value['labour_charge']; ?> |
@@ -80,8 +80,11 @@
+
+
+
+
-
-
-
-
@@ -138,8 +137,7 @@
if (!complaint_id) {
complaint_id = 0;
}
- $(params).attr('disabled', true);
-
+ $(params).attr('disabled', true).text('Processing...');
$.ajax({
type: 'POST',
url: '' + 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');
}
});
}
diff --git a/app/Views/edit_return_order.php b/app/Views/edit_return_order.php
index 633d53d..9ce2d75 100755
--- a/app/Views/edit_return_order.php
+++ b/app/Views/edit_return_order.php
@@ -175,7 +175,7 @@
-
+
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 25de47e..0ce1660 100755
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -340,10 +340,10 @@
-
+
-
+
@@ -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();
diff --git a/app/Views/jobs_list.php b/app/Views/jobs_list.php
index 28471ca..d91f31e 100755
--- a/app/Views/jobs_list.php
+++ b/app/Views/jobs_list.php
@@ -91,7 +91,7 @@
Preview Jobcard
- Preview Files
+ Preview Files
diff --git a/app/Views/make_list.php b/app/Views/make_list.php
index c7bf1c3..2984f87 100755
--- a/app/Views/make_list.php
+++ b/app/Views/make_list.php
@@ -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');
}
});
}
diff --git a/app/Views/manufacturer_list.php b/app/Views/manufacturer_list.php
index 8665821..5326e65 100755
--- a/app/Views/manufacturer_list.php
+++ b/app/Views/manufacturer_list.php
@@ -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: ''+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');
}
});
}
diff --git a/app/Views/outsourcing_list.php b/app/Views/outsourcing_list.php
index e67ea2d..16cec2e 100755
--- a/app/Views/outsourcing_list.php
+++ b/app/Views/outsourcing_list.php
@@ -20,8 +20,8 @@
Out Sourcing |
+ Unit Price (Including Tax) |
Tax |
- Labour Charge With Tax |
Labour Charge |
Description |
Status |
@@ -36,8 +36,8 @@
}?>
= $value['name']; ?> |
- = $value['tax']; ?> |
= $value['cost_with_tax']; ?> |
+ = $value['tax']; ?> |
= $value['labour_cost']; ?> |
= $value['description']; ?> |
@@ -85,6 +85,10 @@
+ |
+
+
+
-
-
-
@@ -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();
}
});
}
diff --git a/app/Views/purchase_form.php b/app/Views/purchase_form.php
index 8cad833..736c4fb 100755
--- a/app/Views/purchase_form.php
+++ b/app/Views/purchase_form.php
@@ -32,7 +32,7 @@
-
+
diff --git a/app/Views/return_order_form.php b/app/Views/return_order_form.php
index b5aa80f..fea982d 100755
--- a/app/Views/return_order_form.php
+++ b/app/Views/return_order_form.php
@@ -199,7 +199,7 @@
-
+
diff --git a/app/Views/service_form.php b/app/Views/service_form.php
index 0242aeb..84ee714 100755
--- a/app/Views/service_form.php
+++ b/app/Views/service_form.php
@@ -18,7 +18,7 @@
- -->
-
+
- |