From 54e76f485b9a61477f64878d11da6742620c4f81 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Jun 2024 14:35:57 +0530 Subject: [PATCH] CHANGE_STAFF_CREATE : AADHAVAN --- .env | 4 ++-- app/Controllers/StaffController.php | 8 +++++--- app/Views/staff_form.php | 13 +++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.env b/.env index b281b3e..4efe471 100644 --- a/.env +++ b/.env @@ -72,6 +72,6 @@ database.default.port = 3306 -WAAI_INSTANCE = '666FEE6738696' -WAAI_TOKEN = '666fd862df687' +WAAI_INSTANCE = '66712908EB75A' +WAAI_TOKEN = '667128c844c48' SEND_WAAI_URL = SEND_WAAI_URL \ No newline at end of file diff --git a/app/Controllers/StaffController.php b/app/Controllers/StaffController.php index a04dcdb..11045f3 100644 --- a/app/Controllers/StaffController.php +++ b/app/Controllers/StaffController.php @@ -120,7 +120,7 @@ class StaffController extends BaseController $staff = $this->StaffModel->where('email', $email)->first(); if($staff){ - return; + return json_encode('mail_exists'); }else{ $staffData = $this->request->getVar(); // print_r($staffData);die; @@ -129,7 +129,8 @@ class StaffController extends BaseController $insert = $this->StaffModel->save($staffData); if($insert) { - return redirect()->to(base_url()."staff_list"); + return json_encode('staff_created'); + // return redirect()->to(base_url()."staff_list"); } } @@ -155,7 +156,8 @@ class StaffController extends BaseController $staff_id = $this->request->getVar('id'); $this->StaffModel->where('staff_id', $staff_id )->set($staffData)->update(); - return redirect()->to(base_url()."staff_list"); + return json_encode('edit_success'); + // return redirect()->to(base_url()."staff_list"); }else{ $data['staffData'] = $this->StaffModel->where('md5(staff.staff_id)', $this->request->getVar('staff_id') )->get()->getRow(); diff --git a/app/Views/staff_form.php b/app/Views/staff_form.php index 3429e60..697f394 100644 --- a/app/Views/staff_form.php +++ b/app/Views/staff_form.php @@ -181,9 +181,8 @@ $(document).ready(function() { var formData = $(this).serialize(); // Serialize form data var staffData = ; - console.log(staffData); - var action = staffData ? '' : ''; + console.log(action); $.ajax({ type: 'POST', @@ -192,6 +191,12 @@ $(document).ready(function() { dataType: 'json', success: function(response) { console.log(response); + if(response === 'staff_created' || response == 'edit_success'){ + window.location.href = ''; + }else if(response == 'mail_exists'){ + toastr.warning('Mail Already Exists Please Choose Another Mail'); + } + // Handle success response }, error: function(error) { @@ -205,17 +210,17 @@ $(document).ready(function() { $('#staff_data_form_submit').click(function (event) { + console.log("come"); event.preventDefault(); if($('#business_id').val() == 0){ toastr.warning('Select Business'); return; } if($('#branch_id').val() == 0){ - console.log("branch"); toastr.warning('Select Branch'); return; } - // $('#staff_form').submit(); + $('#staff_form').submit(); }) $(document).ready(function() {