CHANGE_STAFF_CREATE : AADHAVAN

This commit is contained in:
unknown 2024-06-18 14:35:57 +05:30
parent 5bb3ef7735
commit 54e76f485b
3 changed files with 16 additions and 9 deletions

4
.env
View File

@ -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

View File

@ -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();

View File

@ -181,9 +181,8 @@ $(document).ready(function() {
var formData = $(this).serialize(); // Serialize form data
var staffData = <?php echo isset($staffData) ? json_encode($staffData) : '0'; ?>;
console.log(staffData);
var action = staffData ? '<?php echo base_url("staff_edit"); ?>' : '<?php echo base_url("staff_create"); ?>';
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 = '<?php echo base_url("staff_list"); ?>';
}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() {