CHANGE_FIRST_COMMIT_CLIENT_LOGIN_ACTIVE_DEACTIVE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-31 11:06:50 +05:30
parent b493a31463
commit 19b1d226a9
16 changed files with 576 additions and 52 deletions

2
.env
View File

@ -23,7 +23,7 @@ CI_ENVIRONMENT = development
#--------------------------------------------------------------------
# app.baseURL = 'https://localhost/docs/'
# app.baseURL = 'https://localhost/bb_sign/'
# If you have trouble with `.`, you could also use `_`.
# app_baseURL = ''
# app.forceGlobalSecureRequests = false

View File

@ -19,19 +19,20 @@ use CodeIgniter\Router\RouteCollection;
$routes->match(['get','post'],'/forgot_password','StaffController::forgot_password');
$routes->match(['get','post'],'/verify_otp','StaffController::verify_otp');
$routes->match(['get','post'],'/change_password','StaffController::change_password');
$routes->post('status_staff','StaffController::status_staff');
$routes->match(['get','post'],'/','ClientController::login');
$routes->get('/client_logout','ClientController::client_logout');
$routes->match(['get','post'],'/client_profile','ClientController::client_profile');
$routes->post("change_client_password/(:any)", "ClientController::change_client_password/$1");
$routes->post('generate_otp','ClientController::generate_otp');
$routes->post('verify_otp_client','ClientController::verify_otp');
$routes->get('client_home','ClientController::client_home');
$routes->post('status_client','ClientController::status_client');
$routes->match(['get','post'],'/service_list','MasterController::service_list');
$routes->match(['get','post'],'/service_create','MasterController::service_create');
$routes->match(['get','post'],'/service_edit','MasterController::service_edit');
@ -43,4 +44,9 @@ use CodeIgniter\Router\RouteCollection;
$routes->match(['get','post'],'/template_preview','MasterController::template_preview');
$routes->match(['get','post'],'/test','MasterController::test');

View File

@ -2,30 +2,35 @@
namespace App\Controllers;
use App\Models\ClientModel;
use App\Models\ClientDocsModel;
use CodeIgniter\API\ResponseTrait;
class ClientController extends BaseController
{
public $session;
protected $ClientModel;
protected $ClientDocsModel;
use ResponseTrait;
public function __construct()
{
$this->session = session();
$this->ClientModel = new ClientModel();
$this->ClientDocsModel = new ClientDocsModel();
}
public function login()
{
if($this->session->has('is_client_logged_in')){ return redirect()->to(base_url().'client_home'); }
if($this->request->getmethod() == 'POST')
{
$user_name = $this->request->getVar('user_name');
$password = $this->request->getVar('password');
$clientdata = $this->ClientModel->verifyUserName($user_name);
$pan_no = $this->request->getPost('pan_no');
$clientdata = $this->ClientModel->where('pan_no', $pan_no)->first();
if($clientdata)
{
@ -35,17 +40,12 @@ class ClientController extends BaseController
return redirect()->to(base_url());
}
if (password_verify($password, $clientdata['password']))
{
$this->session->set('is_client_logged_in',$clientdata['client_id']);
$this->session->set('logged_in_client_name',$clientdata['org_name']);
// $this->session->set('logged_in_client_name',$clientdata['org_name']);
return redirect()->to(base_url().'client_home');
}
else{
$this->session->setTempdata('error','Email or Password is invalid',3);
return redirect()->to(base_url());
}
}else{
$this->session->setTempdata('error','Email or Password is invalid',3);
@ -53,8 +53,6 @@ class ClientController extends BaseController
}
}
//get method
return view('client_login');
}
@ -67,7 +65,20 @@ class ClientController extends BaseController
}
public function client_home(){
$client_id =$this->session->get('is_client_logged_in');
$data['doc_list'] = $this->ClientDocsModel->getTemplate($client_id);
// print_r($data['doc_list']);die;
$clientdata = $this->ClientModel->where('client_id', $client_id)->get()->getRow();
if($clientdata){
echo view('layout/header', ['Data'=>$clientdata]);
echo view('client_home',$data);
echo view('layout/footer');
}
}
public function client_profile()
@ -131,16 +142,90 @@ class ClientController extends BaseController
}
public function generate_otp()
{
try {
$pan_no = $this->request->getPost('pan_no');
$client_data = $this->ClientModel->where('pan_no', $pan_no )->first();
if($client_data){
$id = $client_data['client_id'];
$data = [
'otp' => '123456'
];
$update = $this->ClientModel->update($id , $data);
if($update){
return json_encode(true);
}
} else {
return false;
}
} catch (\Exception $e) {
// Handle any exceptions that occur during execution
return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500);
}
}
public function verify_otp()
{
try {
$pan_no = $this->request->getPost('pan_no');
$otp = $this->request->getPost('otp');
$client_data = $this->ClientModel->where('pan_no', $pan_no )->where('otp', $otp)->first();
$data = ['otp' =>''];
if($client_data){
$id = $client_data['client_id'];
$update = $this->ClientModel->update($id , $data);
if($update){
return json_encode(true);
}
} else {
$client_data = $this->ClientModel->where('pan_no', $pan_no )->first();
$id = $client_data['client_id'];
$update = $this->ClientModel->update($id , $data);
return false;
}
} catch (\Exception $e) {
// Handle any exceptions that occur during execution
return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500);
}
}
public function status_client()
{
try {
$client_id = $this->request->getPost('client_id');
$is_active = $this->request->getPost('is_active');
$data = [
'is_active' => $is_active
];
$updated = $this->ClientModel->update($client_id, $data);
if ($updated) {
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
} else {
$result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
} catch (\Exception $exception) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
}
}

View File

@ -7,6 +7,8 @@ use App\Models\ClientModel;
use App\Models\ServiceModel;
use App\Models\TemplateModel;
use CodeIgniter\API\ResponseTrait;
class StaffController extends BaseController
{
@ -15,6 +17,9 @@ class StaffController extends BaseController
protected $ClientModel;
protected $ServiceModel;
protected $TemplateModel;
use ResponseTrait;
public function __construct()
{
$this->session = session();
@ -30,7 +35,8 @@ class StaffController extends BaseController
public function login()
{
if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_home'); }
// if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_home'); }
if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_list'); }
if($this->request->getmethod() == 'POST')
{
$email = $this->request->getVar('email');
@ -338,12 +344,26 @@ class StaffController extends BaseController
}
}
public function status_staff()
{
try {
$staff_id = $this->request->getPost('staff_id');
$is_active = $this->request->getPost('is_active');
$data = [
'is_active' => $is_active
];
$updated = $this->StaffModel->update($staff_id, $data);
if ($updated) {
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
} else {
$result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
} catch (\Exception $exception) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
}
}
}

View File

@ -0,0 +1,25 @@
<?php namespace App\Models;
use CodeIgniter\Model;
class ClientDocsModel extends Model
{
protected $table = 'client_docs';
protected $primaryKey = 'id';
protected $allowedFields = ['client_id','template_id','is_active' ,'created_by','updated_by'];
public function getTemplate($client_id){
$this->select('template.*,client_docs.is_approved');
$this->join('template', 'template.template_id = client_docs.template_id');
$this->where('client_docs.is_active', 1);
$this->where('client_docs.client_id', $client_id);
return $this->findAll();
}
}

95
app/Views/client_home.php Normal file
View File

@ -0,0 +1,95 @@
<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<div class="content-page">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Shared Docs</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100 display">
<thead>
<tr>
<th>Template</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($doc_list as $key => $value) { ?>
<tr>
<td> <?php echo $value['template_name']; ?></td>
<td>
<?php if ($value['is_approved'] == 1): ?>
<span style="color:green">Approved</span>
<?php elseif ($value['is_approved'] == 0): ?>
<span style="color:orange">Pending Approval</span>
<?php elseif ($value['is_approved'] == 2): ?>
<span style="color:red">Rejected</span>
<?php endif; ?>
</td>
<td><a href="#"><i class='mdi mdi-eye-outline mr-1'></i>Preview</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div> <!-- container -->
</div> <!-- content -->
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
<script>
$(document).ready(function() {
$('#datatable-buttons').DataTable({
"ordering": false,
"paging": false,
"info": false,
"searching": true,
"lengthChange": false,
"dom": 'Bfrtip',
});
});
</script>

View File

@ -35,6 +35,7 @@
<th>PAN</th>
<th>Mobile</th>
<th>Email</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
@ -49,8 +50,27 @@
<td> <?php echo $value['pan_no']; ?></td>
<td><?php echo $value['mobile_no']; ?></td>
<td><?php echo $value['email']; ?></td>
<td><a href="<?= base_url()."client_edit?client_id=".md5($value['client_id']); ?>" > <i class='mdi mdi-pencil-outline mr-1'></i>Edit</a></td>
<td>
<?php if($value['is_active'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url()."client_edit?client_id=".md5($value['client_id']); ?>" > <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['client_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['client_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
@ -87,4 +107,39 @@
"ordering": false
});
});
function statusChange(params) {
console.log(params);
var status = params.getAttribute('data-isactive');
var client_id = params.getAttribute('data-id');
if(status == 1){
var is_active= 0;
}else{
var is_active= 1;
}
var formData = {
client_id: client_id,
is_active: is_active
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_client"?>',
data: formData,
dataType: 'json',
success: function(response) {
if (response.data) {
window.location.reload();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -19,7 +19,19 @@
<!-- icons -->
<link href="<?= base_url()."public"; ?>/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css" rel="stylesheet">
<style>
.toast-warning {
color: black !important;
background-color: #edd179 !important; /* Set background color to a solid color */
opacity: 1 !important; /* Set opacity to 1 to remove transparency */
}
.toast-success {
color: black !important;
background-color: #2aa762 !important; /* Set background color to a solid color */
opacity: 1 !important; /* Set opacity to 1 to remove transparency */
}
.otp-input {
text-align: center;
letter-spacing: 0.5rem;
@ -65,7 +77,7 @@
<!-- form -->
<form action="<?= base_url(); ?>" method="post">
<form id="client_login_form" action="<?= base_url(); ?>" method="post">
<?php if(session()->getTempdata('error')):?>
<div class="alert alert-danger" >
@ -74,13 +86,20 @@
<?php endif;?>
<div class="form-group">
<div id="pan_error" style="margin-bottom: 4px;"></div>
<div id="otp_sent_success" style="margin-bottom: 4px;"></div>
<label for="pan_no">PAN Number</label>
<input class="form-control" type="text" id="pan_no" name="pan_no" required placeholder="Enter your PAN">
</div>
<div class="form-group">
<!-- Preloader -->
<div class="loader-mask" style="display:none;">
<div class="loader" style="display:none;">
Please Wait <img src="<?= base_url() . "public" ?>/assets/images/simple_loader.gif" height="30" width="30" alt="Loading...">
</div>
</div>
<div class="form-group" id="otp_hide" style="display:none;">
<label for="otp">OTP</label>
<input type="text" name="otp" id="otp" class="form-control otp-input" maxlength="6" pattern="\d{6}" required>
<input type="text" name="otp" id="otp" class="form-control otp-input" maxlength="6" pattern="\d{6}">
</div>
<div class="form-group mb-3">
@ -90,9 +109,16 @@
</div> -->
</div>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary btn-block" type="submit">Log In </button>
<button class="btn btn-primary btn-block" id="generate_otp_id" type="button">Generate OTP </button>
</div>
<div class="form-group mb-0 text-center" id="verify_otp_hide" style="display:none;">
<button class="btn btn-primary btn-block" id="verify_otp_id" type="button">Verify OTP</button>
</div>
<div class="form-group mb-0 text-center" id="resend_reenter_otp_hide" style="margin-top: 10px;display:none;">
<a href="#" id="reenter_pan">Re-Enter PAN</a> |
<a href="#" id="resend_otp">Resend OTP</a>
</div>
</form>
<!-- end form-->
@ -115,5 +141,121 @@
<!-- App js -->
<script src="<?= base_url()."public"; ?>/assets/js/app.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$('#generate_otp_id').click(function (params) {
event.preventDefault(); // Prevent form submission
var pan_error = $('#pan_error')
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?php echo base_url()."generate_otp"?>',
method: 'POST',
data: {
pan_no : $('#pan_no').val()
},
success: function(response) {
if(response){
pan_error.html('');
$('#generate_otp_id').hide();
$('#otp_hide').show();
$('#verify_otp_hide').show();
$('#pan_no').attr('readonly', true);
}else{
pan_error.html('PAN number mismatch. Please try again.');
pan_error.css('color','red');
}
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
},
error: function(xhr, status, error) {
// Handle any errors
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
console.error('Error generating OTP: ' + error);
}
});
})
$('#verify_otp_id').click(function (params) {
// console.log("verify_otp_id clicked");
$.ajax({
url: '<?php echo base_url()."verify_otp_client"?>',
method: 'POST',
data: {
pan_no : $('#pan_no').val(),
otp : $('#otp').val()
},
success: function(response) {
if(response){
$('#client_login_form').submit();
}else{
$('#resend_reenter_otp_hide').show();
$('#pan_error').html('OTP Mismatch. Please try again.').css('color','red');
$('#otp').val('');
}
},
error: function(xhr, status, error) {
// Handle any errors
console.error('Error generating OTP: ' + error);
}
});
})
$('#reenter_pan').click(function (params) {
window.location.reload();
})
$('#resend_otp').click(function (params) {
event.preventDefault(); // Prevent form submission
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?php echo base_url()."generate_otp"?>',
method: 'POST',
data: {
pan_no : $('#pan_no').val()
},
success: function(response) {
if(response){
$('#pan_error').html('');
$('#generate_otp_id').hide();
$('#otp_hide').show();
$('#verify_otp_hide').show();
$('#otp_sent_success').html('OTP Sent Successfully').css('color','green');
}else{
}
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
},
error: function(xhr, status, error) {
// Handle any errors
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
console.error('Error generating OTP: ' + error);
}
});
})
</script>
</body>
</html>

View File

@ -40,6 +40,55 @@
<style>
.loader-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #00000069;
z-index: 99999;
}
.loader {
position: absolute;
left: 50%;
top: 50%;
width: 50px;
height: 50px;
font-size: 0;
color: #00c9d0;
display: inline-block;
margin: -25px 0 0 -25px;
text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.lead {
font-size: 13px;
}
.loader div {
background-color: #6ad9cf;
display: inline-block;
float: none;
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
opacity: .5;
border-radius: 50%;
-webkit-animation: ballPulseDouble 2s ease-in-out infinite;
animation: ballPulseDouble 2s ease-in-out infinite;
}
.loader div:last-child {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
.dropdown-item:focus, .dropdown-item:hover{
background-color: #7ce4dd;
}
@ -94,7 +143,7 @@
<?php if(isset($_SESSION['is_staff_logged_in']) && $_SESSION['is_staff_logged_in']) { ?>
<?= $Data->name; ?>
<?php }else if(isset($_SESSION['is_client_logged_in']) && $_SESSION['is_client_logged_in']){ ?>
<?= $Data->org_name; ?>
<?= $Data->name; ?>
<?php } ?>
<i class="mdi mdi-chevron-down"></i>
</span>
@ -252,10 +301,10 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="<?= base_url()."client_home"; ?>" id="topnav-my-visa" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-pages-line mr-1"></i> My Visa Request <div class="arrow-down"></div>
<i class="ri-pages-line mr-1"></i> My Documents <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-my-visa">
<a href="<?= base_url()."client_home"; ?>" class="dropdown-item">Visa Request List</a>
<a href="<?= base_url()."client_home"; ?>" class="dropdown-item">Document List</a>
</div>
</li>

View File

@ -35,6 +35,7 @@
<th>Email</th>
<th>Mobile</th>
<th>Role</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
@ -49,8 +50,26 @@
<td><?php echo $value['email']; ?></td>
<td><?php echo $value['mobile_no']; ?></td>
<td><?php echo $value['role']; ?></td>
<td><a href="<?= base_url()."staff_edit?staff_id=".md5($value['staff_id']); ?>" ><i class='mdi mdi-pencil-outline mr-1'></i>Edit</a></td>
<td>
<?php if($value['is_active'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url()."staff_edit?staff_id=".md5($value['staff_id']); ?>" ><i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['staff_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['staff_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
@ -87,4 +106,37 @@
"ordering": false
});
});
function statusChange(params) {
var status = params.getAttribute('data-isactive');
var staff_id = params.getAttribute('data-id');
if(status == 1){
var is_active= 0;
}else{
var is_active= 1;
}
var formData = {
staff_id: staff_id,
is_active: is_active
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_staff"?>',
data: formData,
dataType: 'json',
success: function(response) {
if (response.data) {
window.location.reload();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long