sanjeev
This commit is contained in:
parent
66a9163422
commit
1eacb69177
@ -45,12 +45,6 @@ class Notifications extends BaseController
|
||||
public function send_whatsapp_message() {
|
||||
helper('apiIntegration');
|
||||
$params = (object) Null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$this->logger->info("Whatsapp : sending message instance id = ".$this->instance_id);
|
||||
$params->number = 916369084112;
|
||||
|
||||
@ -67,10 +67,11 @@ class Users extends BaseController
|
||||
## For inserting/updating details of user
|
||||
public function insert_users()
|
||||
{
|
||||
// print_r($this->request->getPost());die();
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_bid = get_business_id();
|
||||
|
||||
try {
|
||||
// print_r($_FILES);die();
|
||||
$validationRule = [
|
||||
'userfile' => [
|
||||
@ -85,10 +86,9 @@ class Users extends BaseController
|
||||
];
|
||||
|
||||
if (!$this->validate($validationRule) && $this->request->getPost('profile_picture') === '') {
|
||||
$data = ['errors' => $this->validator->getErrors()];
|
||||
print_r($data);
|
||||
return 'hello';
|
||||
}
|
||||
$error = $this->validator->getErrors();
|
||||
throw new \Exception((string)$error);
|
||||
}
|
||||
$img = $this->request->getFile('profile_picture');
|
||||
$user_id = $this->request->getPost('user_id');
|
||||
$business_id = $this->request->getPost('business_id');
|
||||
@ -104,11 +104,11 @@ class Users extends BaseController
|
||||
if ($user_id) {
|
||||
$previousFileName = $this->request->getPost('previous_ufile');
|
||||
if ($previousFileName && is_file('public/uploads/' . $previousFileName)) {
|
||||
link('public/uploads/' . $previousFileName);
|
||||
link('public/uploads/'.$previousFileName,'');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fileName = $this->request->getPost('previous_ufile', ''); // Use the previous filename if no new image is provided
|
||||
$fileName = $this->request->getPost('previous_ufile')?$this->request->getPost('previous_ufile'):""; // Use the previous filename if no new image is provided
|
||||
}
|
||||
|
||||
|
||||
@ -141,34 +141,45 @@ class Users extends BaseController
|
||||
$data['password'] = $hash_password;
|
||||
$data['created_by'] = $session_uid;
|
||||
//print_r($data);die;
|
||||
$UsersModel->insert($data);
|
||||
($UsersModel->insert($data)) ? session()->setFlashdata('success', 'User has been added successfully.')
|
||||
: session()->setFlashdata('error', 'User could not be added. Please try again.');
|
||||
} else {
|
||||
// It's an update operation
|
||||
$isactive = $this->request->getPost('isactive');
|
||||
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
|
||||
$data['updated_by'] = $session_uid;
|
||||
$UsersModel->update($user_id, $data);
|
||||
// $UsersModel->update($user_id, $data);
|
||||
($UsersModel->update($user_id, $data)) ? session()->setFlashdata('success', 'User has been updated successfully.')
|
||||
: session()->setFlashdata('error', 'User update failed. Please try again.');
|
||||
|
||||
}
|
||||
}catch(\Exception $e) {
|
||||
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
|
||||
}
|
||||
return redirect()->route('user_list');
|
||||
}
|
||||
|
||||
## For delete the user details (Which means inactive the details)
|
||||
public function delete_user($id)
|
||||
{
|
||||
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
|
||||
$model = new UsersModel();
|
||||
|
||||
$existingBook = $model->find($id);
|
||||
if (!$existingBook) {
|
||||
return redirect()->route('user_list');
|
||||
try {
|
||||
$model = new UsersModel();
|
||||
$existingBook = $model->find($id);
|
||||
if ($existingBook) {
|
||||
// $data=[];
|
||||
$data['isactive'] = 0;
|
||||
$data['updated_by'] = $session_uid;
|
||||
($model->update($id, $data)) ? session()->setFlashdata('success', 'Deleted successfully.')
|
||||
: throw new \Exception("Data Not able to Deleted");
|
||||
}
|
||||
else{
|
||||
throw new \Exception("Data Not Available");
|
||||
}
|
||||
}catch(\Exception $e) {
|
||||
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
|
||||
}
|
||||
|
||||
$data['isactive'] = 0;
|
||||
$data['updated_by'] = $session_uid;
|
||||
$model->update($id, $data);
|
||||
return redirect()->route('user_list');
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,14 +38,22 @@
|
||||
<div id="textDiv">
|
||||
<span class="widget-simple text-center">
|
||||
<div class="media-body align-self-center font-24 avatar-title">
|
||||
<?php if (isset($validationErrors)) { ?>
|
||||
<p style="color: #f1556c!important;" class="mt-0" style><?= $validationErrors; ?></p>
|
||||
<?php if (isset($validationErrors)) { ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= $validationErrors ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php } elseif (isset($successMessage)) { ?>
|
||||
<p style="color: #0aef14!important;" class="mt-0" style><?= $successMessage; ?></p>
|
||||
<?php } else { ?>
|
||||
<p style="color: #0a0a0a!important;" class="mt-0" style><?= "Please Choose Your Choice....."; ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= $successMessage ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<p style="color: #0a0a0a!important;" class="mt-0" style><?= "Please Choose Your Choice....."; ?></p>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -473,6 +473,13 @@
|
||||
<!-- Init js -->
|
||||
<script src="<?= base_url()."public/assets/js/pages/form-summernote.init.js" ?>"></script>
|
||||
|
||||
|
||||
<script>
|
||||
// Automatically close both success and error messages after 5 seconds (5000 milliseconds)
|
||||
setTimeout(function () {
|
||||
document.querySelectorAll('.alert').forEach(function (alert) {
|
||||
alert.classList.add('d-none');
|
||||
});
|
||||
}, 5000); // Adjust the time (in milliseconds) as needed
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -7,9 +7,25 @@
|
||||
</div><!-- end col-->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success')): ?>
|
||||
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<!-- <table id="datatable-buttons" class="table dt-responsive w-100"> -->
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 139 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 139 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 256 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 256 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 366 KiB |
Loading…
Reference in New Issue
Block a user