From 7ae211fcb5bb6209592f1ed667025067ef4f016c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 4 Jan 2025 03:07:18 +0000 Subject: [PATCH] FIX_minor issues --- app/Controllers/Client.php | 3 +- app/Controllers/Complaint.php | 13 ++++++++ app/Controllers/Manufacturer.php | 14 +++++++++ app/Controllers/Model.php | 15 ++++++++- app/Controllers/Outsourcing.php | 18 +++++++++-- app/Controllers/Vehicle.php | 2 ++ app/Controllers/Vendor.php | 19 ++++++++++-- app/Models/ClientModel.php | 2 +- app/Models/VehicleModel.php | 2 +- app/Views/client_form.php | 26 +++++++++++++--- app/Views/complaint_list.php | 41 +++++++++++++++++-------- app/Views/edit_return_order.php | 2 +- app/Views/job_card_form.php | 9 +++--- app/Views/jobs_list.php | 2 +- app/Views/make_list.php | 52 +++++++++++++++++++++++++++----- app/Views/manufacturer_list.php | 27 ++++++++++++++--- app/Views/outsourcing_list.php | 36 +++++++++++++++++----- app/Views/purchase_form.php | 10 ++++-- app/Views/reorder_level_form.php | 2 +- app/Views/return_order_form.php | 2 +- app/Views/service_form.php | 40 ++++++++++++------------ app/Views/vehicle_form.php | 23 +++++++------- app/Views/vendor_form.php | 12 ++++---- app/Views/vendor_list.php | 15 +++++++++ 24 files changed, 295 insertions(+), 92 deletions(-) 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 @@
- +
@@ -70,7 +70,7 @@
- + @@ -92,6 +92,22 @@ // action="" 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 = ''; + // submitButton.prop('disabled', false).text('Submit'); }else if(response){ toastr.success('Client Added Succssfully'); - window.location.href = ''; + // 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) { diff --git a/app/Views/complaint_list.php b/app/Views/complaint_list.php index 38d74f6..9d7020a 100755 --- a/app/Views/complaint_list.php +++ b/app/Views/complaint_list.php @@ -19,9 +19,9 @@ - + + - @@ -34,8 +34,8 @@ $color ='red'; }?> - + + - @@ -36,8 +36,8 @@ }?> - +
ComplaintComplaintUnit Price (Including Tax) TaxLabour Charge With Tax Labour Charge Actions
Out SourcingUnit Price (Including Tax) TaxLabour Charge With Tax Labour Charge Description