CREATE_NOTIFICATION_MODULE : RV

This commit is contained in:
VENKATESHWARAN 2024-01-02 11:37:55 +05:30
parent e2b789a599
commit fb64ceca08
49 changed files with 1655 additions and 190 deletions

View File

@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array();
$autoload['libraries'] = array('email');
/*
| -------------------------------------------------------------------
@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url');
$autoload['helper'] = array('url', 'mail');
/*
| -------------------------------------------------------------------

View File

@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array();
$autoload['libraries'] = array('email');
/*
| -------------------------------------------------------------------
@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url');
$autoload['helper'] = array('url', 'mail');
/*
| -------------------------------------------------------------------

View File

@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('session','database');
$autoload['libraries'] = array('session','database','email');
/*
| -------------------------------------------------------------------
@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url','custom');
$autoload['helper'] = array('url','custom','mail', 'data');
/*
| -------------------------------------------------------------------

View File

@ -102,7 +102,7 @@
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;
$config['enable_hooks'] = TRUE;
/*
|--------------------------------------------------------------------------

View File

@ -11,3 +11,11 @@
| https://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['pre_controller'] = array(
'class' => 'MyHooks',
'function' => 'initialize',
'filename' => 'MyHooks.php',
'filepath' => 'hooks',
);

View File

@ -50,6 +50,7 @@ public function __construct()
### Syntax : $this->load->module('module_name', $params, $object_name);
$this->load->module('Layout');
$this->load->module('Audit');
$this->load->module('Notification');
}
}

View File

@ -78,6 +78,22 @@ function user()
}
}
if (!function_exists('business'))
{
function business()
{
$ci =& get_instance();
$business = $ci->auth_model->get_logged_business(user()->business_id);
if (empty($business))
{
$ci->auth_model->logout();
} else {
return $business;
}
}
}
if (!function_exists('employee'))
{
function employee()

View File

@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if (!function_exists('collectLeaveData')) {
function collectLeaveData($id){
$ci =& get_instance();
return $ci->Notification_model->get_leave_data_using_leave_id($id);
}
}
if (!function_exists('collectDelegationData')) {
function collectDelegationData($id){
$ci =& get_instance();
return $ci->Notification_model->get_delegation_data_using_delegation_id($id);
}
}
if (!function_exists('collectExpenceData')) {
function collectExpenceData($id){
$ci =& get_instance();
return $ci->Notification_model->get_expence_data_using_expence_id($id);
}
}
if (!function_exists('getTempleteData')) {
function getTempleteData($code, $type){
$ci =& get_instance();
return $ci->Notification_model->get_template_data_using_code($code, $type);
}
}
if (!function_exists('replaceTemplateWithData')) {
function replaceTemplateWithData($originalTemplate, $placeholders) {
$notificationContent = $originalTemplate;
foreach ($placeholders as $value) {
$notificationContent = str_replace($value['placeholder'], $value['strval'], $notificationContent);
}
return $notificationContent;
}
}
?>

View File

@ -0,0 +1,156 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use PHPMailer\PHPMailer\PHPMailer;
if (!function_exists('send_emails')) {
function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null)
{
log_message('info', 'send_mail_helper_loadded');
log_message('info', 'Receiptent mail - '.$to.' - subject - '.$subject.' - body - '.$body);
log_message('info', 'Sender mail '.business()->sender_mail);
try {
$mailer = new PHPMailer(true);
log_message('info', 'phpmailer loaded');
$mailer->isSMTP();
$mailer->CharSet = 'utf-8';
$mailer->Host=business()->mail_hostname;
$mailer->SMTPSecure = business()->mail_security;
$mailer->SMTPAuth =true;
$mailer->SMTPDebug = 2;
$mailer->Username=business()->mail_username;
$mailer->Password=business()->mail_password;
$mailer->Port=business()->mail_port_no;
$mailer->setFrom(business()->sender_mail, $aliasName);
$mailer->addAddress($to);
// Add CC recipients
if ($cc !== null) {
if (is_array($cc)) {
foreach ($cc as $ccRecipient) {
$mailer->addCC($ccRecipient);
}
} else {
$mailer->addCC($cc);
}
}
// Add BCC recipients
if ($bcc !== null) {
if (is_array($bcc)) {
foreach ($bcc as $bccRecipient) {
$mailer->addBCC($bccRecipient);
}
} else {
$mailer->addBCC($bcc);
}
}
$mailer->Subject=$subject;
$mailer->isHTML(true);
$mailer->Body=$body;
$attachmentPath = '/path/to/your/attachment/' . $receipt;
if (file_exists($attachmentPath)) {
$mailer->addAttachment($attachmentPath);
}
$mailer->send();
return true;
log_message('info', 'success : mail sendsuccessfully');
} catch (Exception $e) {
return 'Error: ' . $mailer->ErrorInfo;
log_message('info', 'Error : '.$mailer->ErrorInfo);
}
}
}
if (!function_exists('send_emails_forgot_password')) {
function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null)
{
log_message('info', 'send_mail_helper_loadded');
log_message('info', 'Receiptent mail - '.$to.' - subject - '.$subject.' - body - '.$body);
log_message('info', 'Sender mail '.business()->sender_mail);
try {
$mailer = new PHPMailer(true);
log_message('info', 'phpmailer loaded');
$mailer->isSMTP();
$mailer->CharSet = 'utf-8';
$mailer->Host='smtp.sendgrid.net';
$mailer->SMTPSecure = 'tls';
$mailer->SMTPAuth =true;
$mailer->SMTPDebug = 2;
$mailer->Username='apikey';
$mailer->Password='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';
$mailer->Port='587';
$mailer->setFrom('no-reply@tripapprovaltool.com');
$mailer->addAddress($to);
// Add CC recipients
if ($cc !== null) {
if (is_array($cc)) {
foreach ($cc as $ccRecipient) {
$mailer->addCC($ccRecipient);
}
} else {
$mailer->addCC($cc);
}
}
// Add BCC recipients
if ($bcc !== null) {
if (is_array($bcc)) {
foreach ($bcc as $bccRecipient) {
$mailer->addBCC($bccRecipient);
}
} else {
$mailer->addBCC($bcc);
}
}
$mailer->Subject=$subject;
$mailer->isHTML(true);
$mailer->Body=$body;
$attachmentPath = '/path/to/your/attachment/' . $receipt;
if (file_exists($attachmentPath)) {
$mailer->addAttachment($attachmentPath);
}
$mailer->send();
return true;
log_message('info', 'success : mail sendsuccessfully');
} catch (Exception $e) {
return 'Error: ' . $mailer->ErrorInfo;
log_message('info', 'Error : '.$mailer->ErrorInfo);
}
}
}
?>

View File

@ -0,0 +1,15 @@
<?php
class MyHooks
{
public function initialize()
{
$CI =& get_instance();
$CI->load->database();
$sql = "UPDATE `delegation` SET is_active = 0 WHERE to_date < CURDATE(); ";
$data = $CI->db->query($sql);
}
}

View File

@ -166,6 +166,62 @@ public function sendMail(){
}
}
public function sendOTP(){
$mail = $this->input->get('email');
$otp = $this->input->get('otp');
$where = 'email';
$user = $this->auth_model->validateUserForOtp($mail, $where);
$id = $user->id;
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['id'] = $id;
$data['email'] = $mail;
$body =`
<body style="font-family: Arial, sans-serif;">
<div style="max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px;">
<h2 style="color: #333; text-align: center;">One-Time Password (OTP) Verification</h2>
<p>Hello,</p>
<p>Your One-Time Password (OTP) for verification is:</p>
<div style="text-align: center; background-color: #f5f5f5; padding: 10px; border-radius: 5px; font-size: 24px; margin-top: 15px;">
<strong>`. $otp .`</strong>
</div>
<p>This OTP is valid for a short period. Please do not share it with anyone.</p>
<p>If you did not request this OTP, please ignore this email.</p>
<p>Thank you!</p>
<hr style="border: 1px solid #ccc; margin-top: 20px; margin-bottom: 20px;">
<p style="text-align: center; color: #777;">&copy; 2023 </p>
</div>
</body>`;
$subject = 'Forgot Password OTP Send';
$result = send_emails_forgot_password($mail, $subject, $body);
if($result){
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "success";
$data['id'] = $id;
$data['email'] = $mail;
echo json_encode($data);
}else{
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "failed";
$data['id'] = $id;
$data['email'] = $mail;
$data['result'] = $result;
echo json_encode($data);
}
}
public function verify_otp(){
$id = $this->input->post('id');
@ -177,7 +233,7 @@ public function verify_otp(){
if ($user->otp == $user_entered_otp)
{
$data['generate_otp'] = $generate_otp;
$data['generate_otp'] = $user->otp;
$data['user_entered_otp'] = $user_entered_otp;
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "success";

View File

@ -34,6 +34,15 @@ public function get_logged_user()
}
}
public function get_logged_business( $id)
{
$this->db->select('B.*');
$this->db->from('business as B');
$this->db->where('B.uid', $id);
$query = $this->db->get();
return $query->row();
}
public function get_logged_employee()
{
if ($this->is_logged_in()) {

View File

@ -78,7 +78,7 @@
</div>
<div>
<button type="submit" id="submitButton" class="btn btn-primary">Submit</button>
<button type="button" id="sendotpbtn" class="btn btn-info" onclick="send_otp(); startTimer(10);" class="otp"> Send OTP </button><p id="timer">Time remaining: 90 seconds</p>
<button type="button" id="sendotpbtn" class="btn btn-info" onclick="send_otp(); startTimer(30);" class="otp"> Send OTP </button><p id="timer">Time remaining: 90 seconds</p>
</div>
<div class="clearfix"></div>
@ -124,7 +124,7 @@ function send_otp() {
$('input[name=csrf_test_name]').val(response.csrf_hash);
$('#span_msg').html('invalid username').css('color', 'red');
} else {
//for OTP Send success Lable
// for OTP Send success Lable
new PNotify({
title: 'OTP Send Successfully',
text: 'Check Your Mail',
@ -133,7 +133,6 @@ function send_otp() {
delay: 2000
});
//update the csrf to the form
$('input[name=csrf_test_name]').val(response.csrf_hash);
$('#hidden_otp').val(response.otp);
@ -141,6 +140,38 @@ function send_otp() {
$('#id').val(response.id);
$('#submitButton').show();
$('#email').prop('required', false);
$.ajax({
type: "get",
url: "<?php echo base_url();?>Auth/sendOTP",
data: {email : email, otp : response.otp},
json: true,
success: function(response) {
response = jQuery.parseJSON(response)
alert(response);
if (response.status == "failed") {
new PNotify({
title: 'OTP Send Failed',
text: response.result,
type: 'warning',
styling: 'bootstrap3',
delay: 2000
});
} else {
new PNotify({
title: 'OTP Send Sucessfully',
type: 'success',
styling: 'bootstrap3',
delay: 2000
});
}
},
error: function(jqXHR, textStatus, err) {
alert('text status ' + textStatus + ', err ' + err)
}
});
}
},
error: function(jqXHR, textStatus, err) {
@ -205,7 +236,6 @@ function startTimer(seconds) {
if (seconds <= 0) {
clearInterval(timer);
$('#timer').html('Did not Recive the OTP pleace click the Resend OTP Button');
// Enable the button after the timer reaches zero
$('#sendotpbtn').prop('disabled', false);
}
}, 1000);

View File

@ -148,16 +148,16 @@ public function create_business()
}
public function get_business($id, $uid)
public function get_business($id)
{
//select dropdown values
$this->layout->set('stateData', $this->MY_Model->select('state'));
// select business value by id
$table="business";
$businessData = $this->Business_model->get_business_by_md5_id($id);
$businessModuleData = $this->Business_model->get_business_modules($uid);
$businessModuleData = $this->Business_model->get_business_modules($id);
$this->layout->set('ModuleData', $this->MY_Model->select('modules'));
$this->layout->set('businessModuleData', $businessModuleData);
$this->layout->set('businessData', $businessData);

View File

@ -19,7 +19,7 @@ public function get_business_by_md5_id($id)
$this->db->from('business B');
$this->db->join('state', 'state.id = B.state', 'left');
$this->db->where('B.is_active', 1);
$this->db->where('md5(B.id)', $id);
$this->db->where('md5(B.uid)', $id);
$query = $this->db->get();
$query = $query->row();
return $query;
@ -37,7 +37,7 @@ public function get_business_modules($business_id)
$this->db->select('permit_modules.*,modules.modules');
$this->db->from('permit_modules');
$this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left');
$this->db->where('uid', $business_id);
$this->db->where('md5(uid)', $business_id);
$this->db->where('permit_modules.is_active', 1);
$query = $this->db->get();
return $query->result();

View File

@ -197,7 +197,7 @@ class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)">
</div>
<div class="x_title"> </div> <br />
<!-- <div class="x_title"> </div> <br /> --><br /><br />
<div class="item form-group">
@ -240,6 +240,57 @@ class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)">
</div>
</div>
<br /><br /><br />
<div class="x_title">
<div class="clearfix"></div>
<h6>Mail Configurations</h6>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">HostName</label>
<div class="col-md-5 col-sm-5 ">
<input id="address" name="mail_hostname" class="form-control" type="text">
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Port Number</label>
<div class="col-md-5 col-sm-5 ">
<input id="city" name="mail_port_no" class="form-control" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">UserName</label>
<div class="col-md-5 col-sm-5 ">
<input id="city" name="mail_username" class="form-control" type="text">
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Password</label>
<div class="col-md-5 col-sm-5 ">
<input id="country" name="mail_password" class="form-control" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Sender Mail</label>
<div class="col-md-5 col-sm-5">
<input id="pincode" name="sender_mail" class="form-control" type="text" >
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Security Type</label>
<div class="col-md-5 col-sm-5">
<input id="pincode" name="mail_security" class="form-control" type="text" placeholder="ssl or tsl">
</div>
</div>
<div class="ln_solid"></div>
<div class="item form-group">

View File

@ -77,7 +77,7 @@
</td>
<td style=" text-align: center; font-size: 16px;">
<?php if ($value->is_active == 1) { ?>
<a href="<?php echo base_url()?>Business/get_business/<?php echo md5($value->id);?>" ><i class="fa fa-pencil" title="Edit"></i></a>&nbsp;
<a href="<?php echo base_url()?>Business/get_business/<?php echo md5($value->uid);?>" ><i class="fa fa-pencil" title="Edit"></i></a>&nbsp;
<a href="<?php echo base_url()?>Business/delete_business/<?php echo $value->id;?>" ><i class="fa fa-times-circle-o" aria-hidden="true" style="font-size:20px;" title="deactivate"></i></a>&nbsp;
<?php } ?>
<?php if ($value->is_active == 0) { ?>

View File

@ -6,7 +6,7 @@
<div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Are you sure you want to delete</h6>
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
<!-- <button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> -->
</button>
</div>
</br>

View File

@ -178,7 +178,11 @@ class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)" /
</div>
</div>
<div class="item form-group">
<?php if(is_superadmin()) { ?>
<label class="control-label col-md-1 col-sm-1 " for="last-name">Select Modules</label>
<div class="col-md-5 col-sm-5 ">
<select id="people" name="module_id[]" class="form-control select2_multiple" multiple>
@ -202,6 +206,7 @@ class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)" /
<?php } ?>
</select>
</div>
<?php } ?>
<label class="control-label col-md-1 col-sm-1 " for="last-name">Select Logo</label>
@ -212,7 +217,7 @@ class="form-control" onkeyup="check_if_exists(this.id, this.value, this.name)" /
</div>
<br />
<div class="x_title"> </div> <br />
<!-- <div class="x_title"> </div> <br /> --><br /><br />
<div class="item form-group">
@ -257,6 +262,57 @@ class="form-control" type="text">
</div>
</div>
<br /><br /><br />
<div class="x_title">
<div class="clearfix"></div>
<h6>Mail Configurations</h6>
</div><br />
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">HostName</label>
<div class="col-md-5 col-sm-5 ">
<input id="address" name="mail_hostname" class="form-control" type="text" value="<?php echo $businessData->mail_hostname; ?>">
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Port Number</label>
<div class="col-md-5 col-sm-5 ">
<input id="city" name="mail_port_no" class="form-control" type="text" value="<?php echo $businessData->mail_port_no; ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">UserName</label>
<div class="col-md-5 col-sm-5 ">
<input id="city" name="mail_username" class="form-control" type="text" value="<?php echo $businessData->mail_username; ?>">
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Password</label>
<div class="col-md-5 col-sm-5 ">
<input id="country" name="mail_password" class="form-control" type="text" value="<?php echo $businessData->mail_password; ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Sender Mail</label>
<div class="col-md-5 col-sm-5">
<input id="pincode" name="sender_mail" class="form-control" type="text" value="<?php echo $businessData->sender_mail; ?>" >
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Security Type</label>
<div class="col-md-5 col-sm-5">
<input id="pincode" name="mail_security" class="form-control" type="text" placeholder="ssl or tsl" value="<?php echo $businessData->mail_security; ?>">
</div>
</div>
<div class="ln_solid"></div>
<div class="item form-group">
<div class="offset-md-8">

View File

@ -54,11 +54,19 @@ public function Assign_Delecation()
{
$data = $this->input->post();
$data['business_id'] = user()->business_id;
$data['delegated_at'] = date('d-m-Y H:i');
$data['is_active'] = 1;
$data['from_date'] = date('Y-m-d', strtotime($this->input->post('from_date')));
$data['to_date'] = date('Y-m-d', strtotime($this->input->post('to_date')));
$table="delegation";
$Delecation = $this->MY_Model->insert($data, $table);
$Delecation_id = $this->MY_Model->insert($data, $table);
if($Delecation_id){
$code = 'ASSIGN_DELEGATION';
$type = 'Email';
$this->notification->sendNotificationForDelegation($Delecation_id, $code, $type);
}
$this->session->set_flashdata('Success', 'Delegation Assigned Successfully');
@ -85,10 +93,10 @@ public function Edit_Create_Delecation()
$action = $this->input->post();
unset($action['id']);
$id = $this->input->post('id');
//var_dump($id); die();
$action['business_id'] = user()->business_id;
$action['updated_at'] = date('d-m-Y H:i a');
$action['is_active'] = 1;
$action['from_date'] = date('Y-m-d', strtotime($this->input->post('from_date')));
$action['to_date'] = date('Y-m-d', strtotime($this->input->post('to_date')));
$table="delegation";
$Delecation = $this->MY_Model->edit_option($action, $id, $table);
@ -119,7 +127,7 @@ public function checkUniqueValue()
$data = $this->input->get('emp_id');
$table = 'delegation';
$where = 'delegated_to';
$result = $this->MY_Model->checkUniqueValueInDataBase($table, $where, $data);
$result = $this->Delegation_model->checkUniqueValueInDataBase($table, $where, $data);
if(count($result)){
$this->output->set_output(true);
}else{

View File

@ -84,5 +84,15 @@ public function Expencecancle($id, $data)
return;
}
public function checkUniqueValueInDataBase($table, $where, $data){
$this->db->select('*');
$this->db->from($table);
$this->db->where($where, $data);
$this->db->where('is_active', 1);
return $this->db->get()->result_array();
}
}

View File

@ -1,12 +1,6 @@
<!-- bootstrap-daterangepicker -->
<script src="https://localhost/ams//assets/default/moment/min/moment.min.js"></script>
<script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap-datetimepicker -->
<script src="https://localhost/ams//assets/default/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<!-- Body page content -->
@ -108,28 +102,32 @@
<script>
// Initialize datepickers
var dateFormat = "dd-mm-yy";
var fromDateInput = $("#fromdate");
var toDateInput = $("#todate");
document.addEventListener("DOMContentLoaded", function () {
const fromDateInput = document.getElementById('fromdate');
const toDateInput = document.getElementById('todate');
fromDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
onSelect: function (dateText, inst) {
toDateInput.datepicker("option", "minDate", dateText);
validateDateRange();
}
});
flatpickr(fromDateInput, {
dateFormat: 'd-m-Y',
minDate: 'today',
maxDate: new Date().fp_incr(365 * 10),
allowInput: false,
autoclose: true,
onChange: function (selectedDates, dateStr) {
toDateInput._flatpickr.set('minDate', dateStr);
console.log('Selected from date: ', dateStr);
}
});
toDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
onSelect: function (dateText, inst) {
validateDateRange();
}
flatpickr(toDateInput, {
dateFormat: 'd-m-Y',
minDate: 'today',
maxDate: new Date().fp_incr(365 * 10),
allowInput: false,
autoclose: true,
onChange: function (selectedDates, dateStr) {
console.log('Selected to date: ', dateStr);
}
});
});
// Function to validate the date range

View File

@ -57,11 +57,11 @@
<table id="datatables" class="table table-striped table-bordered" width="100%">
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th class="column-title">Delegate Duration</th>
<th class="column-title">Delegated To </th>
<th class="column-title"> Delegation Date </th>
<th class="column-title" >Action </th>
<th style=" text-align: center;" hidden class="column-title">id</th>
<th style=" text-align: center;" class="column-title">Delegate Duration</th>
<th style=" text-align: center;" class="column-title">Delegated To </th>
<th style=" text-align: center;" class="column-title"> Delegation Date</th>
<th style=" text-align: center;" class="column-title" >Action </th>
</tr>
</thead>
<tbody>
@ -70,10 +70,10 @@
<?php if(user()->id == $value->emp_id) { ?>
<tr class="even pointer">
<td hidden > <?php echo $value->id;?> </td>
<td class=" "><?php echo $value->from_date;?> to <?php echo $value->to_date;?> </td>
<td class=" "><?php echo $value->name; ?> (<?php echo $value->delegated_to; ?>)</td>
<td class=" "> <?php echo $value->delegated_at;?> </td>
<td style=" text-align: center;" hidden > <?php echo $value->id;?> </td>
<td style=" text-align: center;" class=""><?php echo date('d-m-Y', strtotime($value->from_date));?> to <?php echo date('d-m-Y', strtotime($value->to_date));?> </td>
<td style=" text-align: center;" class=""><?php echo $value->name; ?></td>
<td style=" text-align: center;" class=""> <?php echo date('d-m-Y', strtotime($value->delegated_at));?> </td>
<td style=" text-align: center; font-size: 16px;">
<a href="<?php echo base_url('Delegation/Edit_Delegation')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-edit" aria-hidden="true"title="Edit"></i></a> &nbsp;

View File

@ -1,14 +1,6 @@
<!-- bootstrap-daterangepicker -->
<script src="https://localhost/ams//assets/default/moment/min/moment.min.js"></script>
<script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap-datetimepicker -->
<script src="https://localhost/ams//assets/default/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<!-- Body page content -->
<style>
@ -62,7 +54,7 @@
<label class="control-label col-md-2 col-sm-2 " for="first-name"> From Date<a style="color:red;">*</a> </label>
<div class="col-md-3 col-sm-3 ">
<div class='input-group date'>
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="fromdate" name="from_date" value="<?php echo $data->from_date ?>" required autocomplete="off"/>
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="fromdate" name="from_date" value="<?php echo date('d-m-Y', strtotime($data->from_date)) ?>" required autocomplete="off"/>
</div>
</div>
@ -70,7 +62,7 @@
<label class="control-label col-md-1 col-sm-1" for="last-name">To Date<a style="color:red;">*</a> </label>
<div class="col-md-3 col-sm-3 ">
<div class='input-group date' >
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="todate" name= "to_date" value="<?php echo $data->to_date ?>" required autocomplete="off"/>
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="todate" name= "to_date" value="<?php echo date('d-m-Y', strtotime($data->to_date))?>" required autocomplete="off"/>
</div>
</div>
@ -124,29 +116,39 @@
</div>
</div>
<script>
// Initialize datepickers
var dateFormat = "dd-mm-yy";
var fromDateInput = $("#fromdate");
var toDateInput = $("#todate");
fromDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
onSelect: function (dateText, inst) {
toDateInput.datepicker("option", "minDate", dateText);
validateDateRange();
document.addEventListener("DOMContentLoaded", function () {
const fromDateInput = document.getElementById('fromdate');
const toDateInput = document.getElementById('todate');
flatpickr(fromDateInput, {
dateFormat: 'd-m-Y',
minDate: 'today',
maxDate: new Date().fp_incr(365 * 10),
allowInput: false,
autoclose: true,
onChange: function (selectedDates, dateStr) {
toDateInput._flatpickr.set('minDate', dateStr);
console.log('Selected from date: ', dateStr);
}
});
toDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
onSelect: function (dateText, inst) {
validateDateRange();
flatpickr(toDateInput, {
dateFormat: 'd-m-Y',
minDate: 'today',
maxDate: new Date().fp_incr(365 * 10),
allowInput: false,
autoclose: true,
onChange: function (selectedDates, dateStr) {
console.log('Selected to date: ', dateStr);
}
});
});
// Function to validate the date range

View File

@ -35,6 +35,7 @@ public function __construct()
$this->load->model('Employee_model','Emp_model');
$this->load->model('Audit/Audit_model','audit_model');
$this->load->helper(array('form', 'url'));
$this->load->library('email');
}
@ -546,6 +547,40 @@ public function checkUniqueValue()
}
}
public function sendemail(){
$to = "suseendhiran13@gmail.com";
$cc = 'venkateshraman786@gmail.com';
$body = $body = "<html>
<style>
table,th,td{
border-collapse:collapse;
border:1px solid black;
}
</style>
<body>
<p>Someone has contacted you!</p>
<br><br>
<h3>Sender Details<h3><br>
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>Suseendhiran</td>
</tr>
</table>
</body>
</html>";
$subject ="test email";
$result = send_emails($to, $subject, $body);
if ($result === true) {
echo 'Email sent successfully';
} else {
echo 'Errors: ' . $result;
}
}
}

View File

@ -12,6 +12,7 @@
<h2>Employee Details </h2>
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Employee/addEmployee" class="btn btn-sm btn-primary">Add Employee</a>
<a href="<?php echo base_url();?>Employee/sendemail" class="btn btn-sm btn-primary">send</a>
</ul>
<div class="clearfix"></div>
</div>

View File

@ -294,6 +294,10 @@ public function expence_list_view($id)
{
$expence_list = $this->Expence_model->get_expense_child_data2($id);
$get_expense_name = $this->Expence_model->get_expense_data_not_md5($id);
$expence_list_with_delegation = $this->Expence_model->get_all_leave_request_by_manager_id_with_delegation(user()->business_id, user()->id);
if($expence_list_with_delegation == NULL){
$expence_list_with_delegation = [];
}
$this->layout->set('tableData', $expence_list);
$this->layout->set('expense_name', $get_expense_name);
$this->layout->buffer('main_content', 'Expence/expence_list_view');
@ -337,26 +341,32 @@ public function getDeleteConfirmationPopup()
public function Approve_Expence()
{
$id=$this->input->post('id');
$id=$this->input->post('id');
// echo $id; die;
$action['status'] = 'Approved';
$action['approved_by']= user()->name;
$action['approved_at'] = date('Y-m-d h:i:s');
$table = "expense";
$this->MY_Model->edit_option($action, $id, $table);
$expence_id = $this->MY_Model->edit_option($action, $id, $table);
$this->Expence_model->approve_child_expense($action, $id);
if($expence_id){
$code = 'APPROVE_EXPENCE';
$type = 'Email';
$this->notification->sendNotificationForExpense($id, $code, $type);
}
$this->session->set_flashdata('Create', '1');
redirect('Expence/expence_list');
}
public function Approve_Child_Expence()
{
if($this->input->get('reason'))
if($this->input->post('declinedata'))
{
$id=$this->input->get('id');
$expense_id=$this->input->get('expence_id');
$id=$this->input->post('id');
$expense_id=$this->input->post('expence_id');
$decline_action['status'] = 'Declined';
$decline_action['decline_by'] = user()->name;
$decline_action['decline_reason'] = $this->input->get('reason');
$decline_action['decline_reason'] = $this->input->post('declinedata');
$is_decline = $this->Expence_model->approve_child_expense_2($decline_action, $id);
if($is_decline == true)
@ -371,7 +381,12 @@ public function Approve_Child_Expence()
else if($count->approve_count >= 1 && $count->declined_count >= 1)
{
$status_update['status'] = 'Partially approved';
return $this->MY_Model->edit_option($status_update, $expense_id, $table);
$id_for_expence = $this->MY_Model->edit_option($status_update, $expense_id, $table);
if($id_for_expence){
$code = 'APPROVE_EXPENCE';
$type = 'Email';
$this->notification->sendNotificationForExpense($expense_id, $code, $type);
}
}
else if($count->declined_count >= 1 && $count->approve_count == 0 && $count->pending_count == 0)
{
@ -381,6 +396,8 @@ public function Approve_Child_Expence()
return $this->MY_Model->edit_option($status_update, $expense_id, $table);
}
}
redirect('Expence/expence_list_view/'.$this->input->post('expence_id'));
}
else
@ -403,7 +420,12 @@ public function Approve_Child_Expence()
else if($count->approve_count >= 1 && $count->declined_count >= 1)
{
$status_update['status'] = 'Partially approved';
$this->MY_Model->edit_option($status_update, $expense_id, $table);
$id_for_expence = $this->MY_Model->edit_option($status_update, $expense_id, $table);
if($id_for_expence){
$code = 'APPROVE_EXPENCE';
$type = 'Email';
$this->notification->sendNotificationForExpense($expense_id, $code, $type);
}
}
else if($count->approve_count >= 1 && $count->declined_count == 0 && $count->pending_count == 0)
{
@ -423,15 +445,28 @@ public function Approve_Child_Expence()
}
public function getDeclineConfirmationPopup()
{
$data = array();
$htmlPage = $this->load->view('confirmation_popup_2.php',$data,true);
echo json_encode($htmlPage);
}
public function Decline_expence()
{
$id=$this->input->get('id');
$id=$this->input->post('id');
// echo $id; die;
$data['status'] = 'Declined';
$data['decline_by'] = user()->name;
$data['decline_reason'] = $this->input->get('reason');
$this->Expence_model->ExpenceDecline($id, $data);
$data['decline_reason'] = $this->input->get('declinedata');
$expence_id = $this->Expence_model->ExpenceDecline($id, $data);
$this->Expence_model->Expence_Decline_Child($id, $data);
return true;
if($expence_id){
$code = 'DECLINE_EXPENCE';
$type = 'Email';
$this->notification->sendNotificationForExpense($id, $code, $type);
}
redirect('Expence/expence_list');
}
@ -476,8 +511,13 @@ public function submit()
$table1 = 'expense';
$data['status'] = "pending";
$data['updated_on'] = date('Y-m-d h:i:s');
$this->MY_Model->edit_option($data, $id, $table1);
$this->Expence_model->update_to_submit_all($id, $data);
$expence_id = $this->MY_Model->edit_option($data, $id, $table1);
$expence_child_id = $this->Expence_model->update_to_submit_all($id, $data);
if($expence_child_id){
$code = 'EXPENCE_CLAIM';
$type = 'Email';
$this->notification->sendNotificationForExpense($id, $code, $type);
}
redirect('Expence/emp_expence_list');
}

View File

@ -151,7 +151,7 @@ public function ExpenceDecline($id, $data)
$this->db->where('id',$id);
$this->db->where('status', 'pending');
$this->db->update('expense', $data);
return;
return true;
}
public function Expence_Decline_Child($id, $data)
@ -214,7 +214,7 @@ public function update_to_submit_all($id, $data)
$this->db->where('expense_id',$id);
$this->db->where('status', 'Draft');
$this->db->update('expense_child', $data);
return;
return true;
}
@ -241,4 +241,51 @@ public function get_status_update($id)
}
public function get_delegated_user_id($business_id, $user_id){
$this->db->select('emp_id');
$this->db->from('delegation');
$this->db->where('business_id', $business_id);
$this->db->where('delegated_to', $user_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$result_array = $query->result_array();
$emp_ids = array_column($result_array, 'emp_id');
return $emp_ids;
}
public function get_all_leave_request_by_manager_id_with_delegation($business_id, $loggeduserid)
{
$delegated_users_id_list = $this->get_delegated_user_id($business_id, $loggeduserid);
$count = count($delegated_users_id_list);
if($count > 0)
{
foreach ($delegated_users_id_list as $user_id) {
$this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby, E.manager as manager_id, LM.type as leave_type, D.from_date as delegate_f_date, D.to_date as delegate_t_date, D.delegated_to, D.emp_id');
$this->db->from('leave_list A');
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
$this->db->join('users U2', 'U2.id = A.approved_by', 'left');
$this->db->join('users U3', 'U3.id = A.declined_by', 'left');
$this->db->join('users U4', 'U4.id = A.risedby', 'left');
$this->db->join('employees E', 'E.user_id = A.emp_id', 'left');
$this->db->join('delegation D', 'D.business_id = A.business_id', 'left');
$this->db->join('leave_master LM', 'LM.id = A.type', 'left');
$this->db->where('A.business_id', $business_id);
$this->db->where('E.manager', $user_id); //User ID as Employee ID
// $this->db->where('D.emp_id', $user_id);
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
return $query;
}
}
}
}

View File

@ -0,0 +1,23 @@
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Decline Reason</h6>
<!-- <button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> -->
</div>
<center>
<form class="delete_url" method="post" action="" id="">
<input id="decline_reason" required name="declinedata" autocomplete="off" style="width:90%; height:45px;"><br>
<button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
<input type="hidden" class="delete_id" name="id" value="">
<input type="hidden" class="expence_id" name="expence_id" value="">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button>
</form>
</center>
</br>
</div>
</div>

View File

@ -453,8 +453,8 @@ function createAndAppendFormGroup() {
html1 += '<label class="control-label col-md-1 col-sm-1" for="last-name">Description</label>'
html1 += '<div class="col-md-5 col-sm-3"><textarea id="comments" name="description2[]" value="" class="form-control" style="height:50px !important;" type="text" ></textarea></div>'
html1 += '<label class="control-label col-md-1 col-sm-1" required for="first-name">Upload Bill </label>'
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill2[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" required></div>'
html1 += '<label class="control-label col-md-1 col-sm-1" required for="first-name">Receipt </label>'
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill2[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" ></div>'
html1 += '</div>'
html1 += '<div class="col-12"><button type="button" class="float-right btn btn-danger"" id="remove-button" onclick="removebutton('+i+')"><i class="fa fa-trash"></i></button></div><button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button></div>'

View File

@ -34,7 +34,7 @@
cursor: pointer;
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important; //search to up
margin-top: -30px !important;
}
.alert-success {

View File

@ -21,7 +21,7 @@
.modal-content_default {
background-color: #fefefe;
margin: 15% auto;s
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 380px;
@ -34,7 +34,8 @@
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important; //search to up
margin-top: -30px !important;
}
</style>
@ -199,11 +200,8 @@
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<!-- <a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id= "<?php echo $value->id; ?>"></i></a>&nbsp; -->
<?php } ?>
</td>
</tr>
@ -275,6 +273,21 @@
}
});
});
$('.test').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Expence/Decline_expence";
$.ajax({
url: "<?php echo base_url()?>Expence/getDeclineConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
}
});
});
</script>

View File

@ -21,7 +21,7 @@
.modal-content_default {
background-color: #fefefe;
margin: 15% auto;s
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 380px;
@ -34,7 +34,8 @@
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important; //search to up
margin-top: -30px !important;
}
</style>
@ -156,7 +157,6 @@
}
}
?>"
autocomplete='off' required />
</div>
</div>
@ -226,10 +226,8 @@
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<!-- <a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id= "<?php echo $value->id; ?>"></i></a>&nbsp; -->
<?php } ?>
</td>
@ -276,6 +274,23 @@
}
});
});
$('.test').click(function() {
var id = $(this).attr('id');
var expence_id = document.getElementById('expense_id').value;
var url = "<?php echo base_url()?>Expence/Approve_Child_Expence";
$.ajax({
url: "<?php echo base_url()?>Expence/getDeclineConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.expence_id').attr('value',expence_id);
$('.delete_url').attr('action',url);
}
});
});
</script>

View File

@ -78,7 +78,6 @@ public function applyLeave($update = null)
$this->session->set_flashdata('error', 0);
$this->layout->buffer('main_content', 'Leave/apply_leave');
$this->layout->render('Employee_Layout');
}
public function get_emp_leave_count()
@ -149,6 +148,14 @@ public function createLeave()
$perm_data['created_time'] = date('H:i A');
$table="leave_list";
$create_permission = $this->MY_Model->insert($perm_data,$table);
//for notification
if($create_permission){
$code = 'LEAVE_PERMISSION';
$type = 'Email';
$this->notification->sendNotification($create_permission, $code, $type);
}
$this->session->set_flashdata('Success', '1');
redirect('Leave/LeaveHistory');
}
@ -259,7 +266,12 @@ public function createLeave()
redirect('Leave/applyLeave/'.'update');
}
if($create_leave){
$code = 'APPLY_LEAVE';
$type = 'Email';
$this->notification->sendNotification($create_leave, $code, $type);
}
//audit
if($create_leave)
@ -431,6 +443,13 @@ public function getDeleteConfirmationPopup()
echo json_encode($htmlPage);
}
public function getDeclineConfirmationPopup()
{
$data = array();
$htmlPage = $this->load->view('confirmation_popup_2.php',$data,true);
echo json_encode($htmlPage);
}
public function ApproveLeave()
{
$id=$this->input->post('id');
@ -438,36 +457,34 @@ public function ApproveLeave()
$emp_id = $this->Leave_model->get_emp_id($id);
$no_of_days = $this->Leave_model->get_Leave_nodays($id,);
$leave_year = date('Y', strtotime($no_of_days->from_date));
//print_r($no_of_days); die('approveleave');
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
if($leave_type->leave_code !== 'permission')
{
$remaining_days = $this->Leave_model->remaining_days($emp_id, user()->business_id, $leave_year, $no_of_days->type);
//print_r($remaining_days); die();
$balance_days = $remaining_days[0]->remaining_days - $no_of_days->no_of_days;
if($remaining_days[0]->remaining_days <= 0){
$data['status'] = 'Declined';
$data['declined_by']= user()->id;
$data['declined_at'] = date('d-m-Y H:i:s');
$data['DReason'] = 'No sufficient leave balance';
$this->Leave_model->LeaveDecline($id, $data);
redirect('Leave/leaveList');
}
else
{
$data['leave_bal'] = $balance_days;
$days['remaining_days'] = $balance_days;
$this->Leave_model->emp_leave_days_update($emp_id, $days, $leave_year, $business_id, $no_of_days->type);
$data['leave_bal'] = $balance_days;
$days['remaining_days'] = $balance_days;
$this->Leave_model->emp_leave_days_update($emp_id, $days, $leave_year, $business_id, $no_of_days->type);
}
$data['status'] = 'Approved';
$data['approved_by']= user()->id;
$data['approved_at'] = date('d-m-Y H:i:s');
// print_r($data); die;
$this->Leave_model->LeaveApprove($id, $data);
$leave_approve = $this->Leave_model->LeaveApprove($id, $data);
if($leave_approve){
if($leave_type->leave_code === 'permission'){
$code = 'APPROVE_PERMISSION';
}
else{
$code = 'APPROVE_LEAVE';
}
$type = 'Email';
$this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/leaveList');
}
}
@ -484,6 +501,7 @@ public function ManagerLeaveApprove()
$emp_id = $this->Leave_model->get_emp_id($id);
$no_of_days = $this->Leave_model->get_Leave_nodays($id,);
$leave_year = date('Y', strtotime($no_of_days->from_date));
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
$remaining_days = $this->Leave_model->remaining_days($emp_id, user()->business_id, $leave_year, $no_of_days->type);
$balance_days = $remaining_days[0]->remaining_days - $no_of_days->no_of_days;
@ -496,21 +514,70 @@ public function ManagerLeaveApprove()
$data['status'] = 'Approved';
$data['approved_by']= user()->name;
$data['approved_at'] = date('d-m-Y H:i:s');
$this->Leave_model->LeaveApprove($id, $data);
$leave_approve = $this->Leave_model->LeaveApprove($id, $data);
if($leave_approve){
if($leave_type->leave_code === 'permission'){
$code = 'APPROVE_PERMISSION';
}
else{
$code = 'APPROVE_LEAVE';
}
$type = 'Email';
$this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/manager_approvel');
}
public function Decline()
{
$id=$this->input->get('id');
$id=$this->input->post('id');
$data['status'] = 'Declined';
$data['declined_by']= user()->name;
$data['declined_at'] = date('d-m-Y H:i:s');
$data['DReason'] = $this->input->get('reason');
$this->Leave_model->LeaveDecline($id, $data);
return true;
$data['DReason'] = $this->input->post('declinedata');
$leave_decline = $this->Leave_model->LeaveDecline($id, $data);
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
if($leave_decline){
if($leave_type->leave_code === 'permission'){
$code = 'DECLINE_PERMISSION';
}
else{
$code = 'DECLINE_LEAVE';
}
$type = 'Email';
$return = $this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/leaveList');
}
public function managerDecline()
{
$id=$this->input->post('id');
$data['status'] = 'Declined';
$data['declined_by']= user()->name;
$data['declined_at'] = date('d-m-Y H:i:s');
$data['DReason'] = $this->input->post('declinedata');
$leave_decline = $this->Leave_model->LeaveDecline($id, $data);
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
if($leave_decline){
if($leave_type->leave_code === 'permission'){
$code = 'DECLINE_PERMISSION';
}
else{
$code = 'DECLINE_LEAVE';
}
$type = 'Email';
$return = $this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/manager_approvel');
}
public function cancled()
{
$id=$this->input->get('id');
@ -553,4 +620,6 @@ public function manager_approvel()
$this->layout->render('Employee_Layout');
}
}

View File

@ -18,6 +18,43 @@ public function get_leave_with_emp_name($business_id)
}
public function get_leave_data_using_leave_id($leave_id)
{
$this->db->select('A.* ,U1.name as emp_name, U1.email as emp_email, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby, E.manager as ManagerId, LM.code as leave_code, LM.type as leave_type');
$this->db->from('leave_list A');
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
$this->db->join('users U2', 'U2.id = A.approved_by', 'left');
$this->db->join('users U3', 'U3.id = A.declined_by', 'left');
$this->db->join('users U4', 'U4.id = A.risedby', 'left');
$this->db->join('employees E', 'E.user_id = A.emp_id', 'left');
$this->db->join('leave_master LM', 'LM.id = A.type', 'left');
$this->db->where('A.id', $leave_id);
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $row = $query->row();
} else {
return false;
}
}
public function get_template_data_using_code($code, $type){
$this->db->select('*');
$this->db->from('templates');
$this->db->where('templet_code', $code);
$this->db->where('templet_type', $type);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
public function get_user_name($user_id){
$this->db->select('name');
@ -238,7 +275,7 @@ public function LeaveApprove($id, $data)
$this->db->where('id',$id);
$this->db->update('leave_list', $data);
return;
return true;
}
@ -247,7 +284,7 @@ public function LeaveDecline($id, $data)
$this->db->where('id',$id);
$this->db->where('status', 'pending');
$this->db->update('leave_list', $data);
return;
return true;
}
public function Leavecancle($id, $data)

View File

@ -302,7 +302,7 @@
$('#type').on('change',function() {
let id = $("#user_dropdown").val();
var type_id = $('option:selected', this).attr('id');
var type_id = $('option:selected', this).val();
var fromdate = document.getElementById("fromdate").value;

View File

@ -5,8 +5,8 @@
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Leave</h6>
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Action</h6>
<!-- <button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> -->
</button>
</div>
</br>

View File

@ -0,0 +1,27 @@
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Decline Reason</h6>
<!-- <button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> -->
</button>
</div>
</br>
<center>
<form class="delete_url" method="post" action="" id="">
<input list="browsers" onfocus id="decline_reason" required name="declinedata" autocomplete="off" style="width:90%; height: 45px;" />
<datalist id="browsers">
<?php foreach ($dropdown as $key => $value) { ?>
<option value="<?php echo $value->enum_value; ?>"><?php echo $value->enum_value; ?></option>
<?php } ?>
</datalist><br><br>
<input type="hidden" class="delete_id" name="id" value="">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button><button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
</form>
</center>
</br>
</div>
</div>

View File

@ -42,8 +42,7 @@
<div class="x_title">
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Leave/LeaveHistory" class="btn btn-sm btn-primary"
style="margin-top: 20px;">Back</a>
<a href="<?php echo base_url();?>Leave/LeaveHistory" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a>
</ul>
<h1>My Approvals</h1>
@ -107,7 +106,7 @@
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> By
<?php echo $value->DeclineBy; ?> <br>" <?php echo $value->DReason; ?> "</td>
<?php echo $value->declined_by; ?> <br>" <?php echo $value->DReason; ?> "</td>
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
@ -119,8 +118,8 @@
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveleave" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id="<?php echo $value->id; ?>"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<!-- <a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id="<?php echo $value->id; ?>"></i></a>&nbsp; -->
<?php } ?>
</td>
</tr>
@ -138,8 +137,7 @@
<span style="text-align: right;" onclick="$('#customPrompt').hide()"><i class="fa fa-times"
aria-hidden="true"></i></span>
<h3>Decline Reason</h3>
<input list="browsers" onfocus id="decline_reason" required name="myBrowser"
style="margin-top: 10%;padding: 10px;" />
<input list="browsers" onfocus id="decline_reason" required name="myBrowser" style="margin-top: 10%;padding: 10px;" />
<datalist id="browsers">
<?php foreach ($dropdown as $key => $value) { ?>
<option value="<?php echo $value->enum_value; ?>"><?php echo $value->enum_value; ?></option>
@ -176,6 +174,21 @@
});
});
$('.test').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/Decline";
$.ajax({
url: "<?php echo base_url()?>Leave/getDeclineConfirmationPopup",
type: "GET",
success: function(data) {
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value', id);
$('.delete_url').attr('action', url);
}
});
});
$(document).on('click', '.bi-card-list', function() {
var id = $(this).attr("id")
@ -216,8 +229,8 @@ function submitCustomPrompt() {
url: "<?php echo base_url('Leave/Decline');?>",
type: "get",
success: function(response) {
window.location = '<?php echo base_url('Leave/leaveList');?>';
console.log(response)
// window.location = '<?php echo base_url('Leave/sendDeclinemail/');?>'+id;
}

View File

@ -119,7 +119,7 @@
<td style=" text-align: center; font-size: 16px;">
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveleave" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" id= "<?php echo $value->id; ?>" onclick="showCustomPrompt()"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
@ -174,6 +174,21 @@
});
});
$('.test').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/managerDecline";
$.ajax({
url: "<?php echo base_url()?>Leave/getDeclineConfirmationPopup",
type: "GET",
success: function(data) {
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value', id);
$('.delete_url').attr('action', url);
}
});
});
$(document).on('click','.bi-card-list',function(){
var id = $(this).attr("id")

View File

@ -0,0 +1,428 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
date_default_timezone_set('Asia/Kolkata');
/**
* AMS
*
* @package HMVC
* @author Venba
* @copyright 2022 Venba
* @license https://venbainfotech.com/licenses/MIT MIT License
* @link <URI> (description)
* @version GIT: $Id$
* @since Version 0.0.1
* @filesource
*
*/
class Notification extends MX_Controller
{
/**
* [__construct description]
*
* @method __construct
*/
public function __construct()
{
// To inherit directly the attributes of the parent class.
parent::__construct();
### Syntax : $this->load->model('Model Path' , 'Alias name');
### The second parameter (optional) is used to call the method.
$this->load->model('MY_Model','MY_Model');
$this->load->model('Notification_model','Notification_model');
}
// Function for Mail Send
public function prepareNotificationData($body,$templateData,$Data,$type,$code){
$getBusinessData = $this->Notification_model->get_admin_and_hr_mail_id(user()->business_id);
$managerID = $Data->ManagerId;
$managerMail = $this->Notification_model->get_user_data($managerID);
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail, $Data->delegatePersonEmail];
if($Data->delegatePersonEmail == NULL)
{
if($Data->managerEmail == NULL){
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email];
}
else{
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail];
}
}
if($type === 'Email'){
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
$to = $getBusinessData->hr_email;
$cc = $cc_mail_data;
$subject = $templateData->subject;
$aliasName = $Data->emp_name;
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die;
return $result;
}
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
$to = $Data->emp_email;
$cc = $cc_mail_data;
$subject = $templateData->subject;
$aliasName = 'HR';
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die;
return $result;
}
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
$to = $Data->emp_email;
$cc = $cc_mail_data;
$subject = $templateData->subject;
$aliasName = 'HR';
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die;
return $result;
}
else{
$to = $Data->emp_email;
$cc = $cc_mail_data;
$subject = $templateData->subject;
$aliasName = 'HR';
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die;
return $result;
}
}
}
public function prepareNotificationDataForDelegation($body,$templateData,$Data,$type,$code){
$getBusinessData = $this->Notification_model->get_admin_and_hr_mail_id(user()->business_id);
if($type === 'Email'){
$to = $Data->delegatePersonEmail;
$cc = [$getBusinessData->admin_email, $getBusinessData->hr_email];
$subject = $templateData->subject;
$aliasName = $Data->emp_name;
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die;
return $result;
}
}
public function prepareNotificationDataForExpence($body,$templateData,$Data,$type,$code){
// echo $body; die;
$getBusinessData = $this->Notification_model->get_admin_and_hr_mail_id(user()->business_id);
if(!empty($Data->managerEmail)){
$mail = [$getBusinessData->admin_email, $Data->managerEmail];
}else{
$mail = $getBusinessData->admin_email;
}
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail, $Data->delegatePersonEmail];
if($Data->delegatePersonEmail == NULL)
{
if($Data->managerEmail == NULL){
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email];
}
else{
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail];
}
}
if($type === 'Email'){
if($code === 'EXPENCE_CLAIM'){
$to = $getBusinessData->hr_email;
$cc = $mail;
$subject = $templateData->subject;
$aliasName = $Data->emp_name;
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die('EXPENCE_CLAIM');
return $result;
}else if($code === 'APPROVE_EXPENCE' || ($code === 'DECLINE_EXPENCE')){
$to = $Data->emp_email;
$cc = $cc_mail_data;
$subject = $templateData->subject;
$aliasName = 'HR';
$result = send_emails($to, $subject, $body, $aliasName, $cc);
// echo $result; die('APPROVE_EXPENCE or DECLINE_EXPENCE');
return $result;
}
}
}
// end of Function for Mail Send
//Send Mail For Apply Leave and apply Permission also Approve and Decline
public function sendNotification($leave_id, $code, $type){
$leaveData = collectLeaveData($leave_id);
$templateData = getTempleteData($code, $type);
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
$FormettedTemplateData = $this->preprocessTemplateData($leaveData,$templateData);
}
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveApprove($leaveData,$templateData);
}
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveDecline($leaveData,$templateData);
}
return $this->prepareNotificationData($FormettedTemplateData,$templateData,$leaveData,$type, $code);
}
public function preprocessTemplateData($leaveData, $templateData){
$managerID = $leaveData->ManagerId;
$managerName = $this->Notification_model->get_user_data($managerID);
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
if($leaveData->leave_code === 'permission'){
if(empty($managerName->name)){
$values = ['Manager', $leaveData->emp_name, $leaveData->leave_type, $leaveData->perm_date, $leaveData->from_time, $leaveData->to_time, $leaveData->risedby, $leaveData->status, $leaveData->comments];
}
else{
$values = [$managerName->name, $leaveData->emp_name, $leaveData->leave_type, $leaveData->perm_date, $leaveData->from_time, $leaveData->to_time, $leaveData->risedby, $leaveData->status, $leaveData->comments];
}
}
else{
if(empty($managerName->name)){
$values = ['Manager', $leaveData->emp_name, $leaveData->no_of_days, $leaveData->leave_type, $leaveData->from_date, $leaveData->to_date, $leaveData->risedby, $leaveData->leave_bal, $leaveData->status, $leaveData->comments];
}
else{
$values = [$managerName->name, $leaveData->emp_name, $leaveData->no_of_days, $leaveData->leave_type, $leaveData->from_date, $leaveData->to_date, $leaveData->risedby, $leaveData->leave_bal, $leaveData->status, $leaveData->comments];
}
}
$result = [];
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
return $body = replaceTemplateWithData($templateData->content,$result);
}
public function preprocessTemplateDataForLeaveApprove($leaveData, $templateData){
$managerID = $leaveData->ManagerId;
$managerName = $this->Notification_model->get_user_data($managerID);
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
if($leaveData->leave_code === 'permission'){
$values = [$leaveData->emp_name, $leaveData->from_time, $leaveData->to_time, $leaveData->perm_date, $leaveData->ApproveBy, $leaveData->status];
}
else{
$values = [$leaveData->emp_name, $leaveData->from_date, $leaveData->to_date, $leaveData->no_of_days, $leaveData->ApproveBy, $leaveData->status];
}
$result = [];
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
return $body = replaceTemplateWithData($templateData->content,$result);
}
public function preprocessTemplateDataForLeaveDecline($leaveData, $templateData){
$managerID = $leaveData->ManagerId;
$managerName = $this->Notification_model->get_user_data($managerID);
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
if($leaveData->leave_code === 'permission'){
$values = [$leaveData->emp_name, $leaveData->from_time, $leaveData->to_time, $leaveData->perm_date, $leaveData->declined_by, $leaveData->status, $leaveData->DReason];
}
else{
$values = [$leaveData->emp_name, $leaveData->from_date, $leaveData->to_date, $leaveData->no_of_days, $leaveData->declined_by, $leaveData->status, $leaveData->DReason];
}
$result = [];
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
return $body = replaceTemplateWithData($templateData->content,$result);
}
// end of Send Mail For Apply Leave and apply Permission also Approve and Decline
// Send mail for Assign Delegation
public function sendNotificationForDelegation($Delecation_id, $code, $type){
$delegationData = collectDelegationData($Delecation_id);
$templateData = getTempleteData($code, $type);
$FormettedTemplateData = $this->preprocessTemplateDataForAssignDelegation($delegationData,$templateData);
return $this->prepareNotificationDataForDelegation($FormettedTemplateData,$templateData,$delegationData,$type, $code);
}
public function preprocessTemplateDataForAssignDelegation($Data, $templateData){
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
$values = [$Data->delegatePersonName, $Data->from_date, $Data->to_date, $Data->emp_name];
$result = [];
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
return $body = replaceTemplateWithData($templateData->content,$result);
}
// end of Send mail for Assign Delegation
// Send mail for Applay , Approve, Decline expence
public function sendNotificationForExpense($ecpence_id, $code, $type){
$expenceData = collectExpenceData($ecpence_id);
$expenceChildData = $this->Notification_model->get_expence_child_data_using_expence_id($ecpence_id);
// echo $ecpence_id;
// echo '--------------------------------------------------------------';
// echo '<pre>';
// print_r($expenceData);
// echo '--------------------------------------------------------------';
// print_r($expenceChildData); die;
$templateData = getTempleteData($code, $type);
if($code === 'EXPENCE_CLAIM'){
$FormettedTemplateData = $this->preprocessTemplateDataForExpense($expenceData,$templateData,$expenceChildData);
}else if($code === 'APPROVE_EXPENCE'){
$FormettedTemplateData = $this->preprocessTemplateDataForExpenseApprove($expenceData,$templateData,$expenceChildData);
}else if($code === 'DECLINE_EXPENCE'){
$FormettedTemplateData = $this->preprocessTemplateDataForExpenseDecline($expenceData,$templateData,$expenceChildData);
}
return $this->prepareNotificationDataForExpence($FormettedTemplateData,$templateData,$expenceData,$type, $code);
}
public function preprocessTemplateDataForExpense($Data, $templateData, $expenceChildData){
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
$tableRows = '';
foreach ($expenceChildData as $row) {
$tableRows .= '<tr>';
$tableRows .= '<td>' . $row['childExpenceDate'] . '</td>';
$tableRows .= '<td>' . $row['childAmount'] . '</td>';
$tableRows .= '<td>' . $row['childDescription'] . '</td>';
$tableRows .= '</tr>';
}
$values =[$Data->managerName, $Data->emp_name];
$emailTemplate = str_replace('[table_rows]', $tableRows, $templateData->content);
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
return $body = replaceTemplateWithData($emailTemplate,$result);
}
public function preprocessTemplateDataForExpenseApprove($Data, $templateData, $expenceChildData){
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
$tableRows = '';
foreach ($expenceChildData as $row) {
$tableRows .= '<tr>';
$tableRows .= '<td>' . $row['childExpenceDate'] . '</td>';
$tableRows .= '<td>' . $row['childAmount'] . '</td>';
$tableRows .= '<td>' . $row['childDescription'] . '</td>';
$tableRows .= '<td>' . $row['childStatus'] . '</td>';
$tableRows .= '</tr>';
}
$values =[$Data->managerName, $Data->emp_name, $Data->status];
$emailTemplate = str_replace('[table_rows]', $tableRows, $templateData->content);
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
$body = replaceTemplateWithData($emailTemplate,$result);
return $body;
}
public function preprocessTemplateDataForExpenseDecline($Data, $templateData, $expenceChildData){
$inputString = $templateData->placeholder;
$placeholders = explode(',', $inputString);
$tableRows = '';
foreach ($expenceChildData as $row) {
$tableRows .= '<tr>';
$tableRows .= '<td>' . $row['childExpenceDate'] . '</td>';
$tableRows .= '<td>' . $row['childAmount'] . '</td>';
$tableRows .= '<td>' . $row['childDescription'] . '</td>';
$tableRows .= '<td>' . $row['childStatus'] . '</td>';
$tableRows .= '</tr>';
}
$values =[$Data->managerName, $Data->emp_name, $Data->status];
$emailTemplate = str_replace('[table_rows]', $tableRows, $templateData->content);
foreach ($placeholders as $index => $placeholder) {
$result[] = ['placeholder' => '[' . trim($placeholder, '[]') . ']', 'strval' => $values[$index]];
}
// echo '<pre>';
// print_r($result); die;
return $body = replaceTemplateWithData($emailTemplate,$result);
}
// end of Send mail for Applay , Approve, Decline expence
}

View File

@ -0,0 +1,135 @@
<?php
class Notification_model extends MY_Model {
public function get_leave_data_using_leave_id($leave_id)
{
$this->db->select('A.* ,U1.name as emp_name, U1.email as emp_email, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby, E.manager as ManagerId, LM.code as leave_code, LM.type as leave_type, U5.email as managerEmail, U6.email as delegatePersonEmail,');
$this->db->from('leave_list A');
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
$this->db->join('users U2', 'U2.id = A.approved_by', 'left');
$this->db->join('users U3', 'U3.id = A.declined_by', 'left');
$this->db->join('users U4', 'U4.id = A.risedby', 'left');
$this->db->join('employees E', 'E.user_id = A.emp_id', 'left');
$this->db->join('users U5', 'U5.id = E.manager', 'left');
$this->db->join('leave_master LM', 'LM.id = A.type', 'left');
$this->db->join('delegation D', 'D.emp_id = U5.id', 'left');
$this->db->join('users U6', 'U6.id = D. delegated_to', 'left');
$this->db->where('A.id', $leave_id);
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$row = $query->row();
// return $this->db->last_query();
return $row;
} else {
return false;
}
}
public function get_delegation_data_using_delegation_id($delegation_id)
{
$this->db->select('D.* ,U1.name as emp_name, U1.email as emp_email, U2.name as delegatePersonName, U2.email as delegatePersonEmail,');
$this->db->from('delegation D');
$this->db->join('users U1', 'U1.id = D.emp_id', 'left');
$this->db->join('employees E', 'E.user_id = D.emp_id', 'left');
$this->db->join('users U2', 'U2.id = D.delegated_to', 'left');
$this->db->join('users U3', 'U3.id = E.manager', 'left');
$this->db->where('D.id', $delegation_id);
$this->db->order_by('D.id','DESC');
$this->db->where('D.is_active', 1);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$row = $query->row();
// return $this->db->last_query();
return $row;
} else {
return false;
}
}
public function get_expence_data_using_expence_id($expence_id)
{
$this->db->select('A.*, u1.email as emp_email, u1.name as requested_name, u2.name as emp_name, u3.name as managerName, u3.email as managerEmail, u4.email as delegatePersonEmail');
$this->db->from('expense A');
$this->db->join('users u1', 'u1.id = A.requested_for', 'left');
$this->db->join('users u2', 'u2.id = A.created_by', 'left');
$this->db->join('employees E', 'E.user_id = u2.id', 'left');
$this->db->join('users u3', 'u3.id = E.manager', 'left');
$this->db->join('delegation D', 'D.emp_id = u3.id', 'left');
$this->db->join('users u4', 'u4.id = D. delegated_to', 'left');
$this->db->where('A.id', $expence_id);
$this->db->where('A.status !=', 'Draft');
$this->db->order_by('A.id', 'DESC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
$row = $query->row();
// return $this->db->last_query();
return $row;
} else {
return false;
}
}
public function get_expence_child_data_using_expence_id($expence_id)
{
$this->db->select('EC.date_of_expense as childExpenceDate, EC.amount as childAmount, EC.description as childDescription, EC.status as childStatus');
$this->db->from('expense_child EC');
$this->db->where('expense_id', $expence_id);
$this->db->order_by('id', 'DESC');
$query = $this->db->get();
$result_array = $query->result_array();
// $values_only = array_map('array_values', $result_array);
return $result_array;
}
public function get_template_data_using_code($code, $type){
$this->db->select('*');
$this->db->from('templates');
$this->db->where('templet_code', $code);
$this->db->where('templet_type', $type);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
public function get_user_data($user_id){
$this->db->select('*');
$this->db->from('users');
$this->db->where('id', $user_id);
$query = $this->db->get();
// $query = $query->result();
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
// return $query;
}
public function get_admin_and_hr_mail_id($id){
$this->db->select('*');
$this->db->from('business');
$this->db->where('uid', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
}

View File

@ -0,0 +1,26 @@
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Leave</h6>
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
</button>
</div>
</br>
<center>
<form class="delete_url" method="post" action="" id="">
<button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
&nbsp; &nbsp; &nbsp; &nbsp;
<input type="hidden" class="delete_id" name="id" value="">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button>
</form>
</center>
</br>
</div>
</div>

View File

@ -27,22 +27,7 @@
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<h2>Business Report
<!-- <small>Activity report</small> -->
</h2>
<!-- <ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Settings 1</a>
<a class="dropdown-item" href="#">Settings 2</a>
</div>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul> -->
<h2>Business Report</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
@ -80,7 +65,7 @@
</li>
</ul>
<a class="btn btn-success" href="<?php echo base_url()?>Business/get_business/<?php echo md5($businessData->id);?>"><i class="fa fa-edit m-right-xs"></i>Edit Business</a>
<a class="btn btn-success" href="<?php echo base_url()?>Business/get_business/<?php echo md5($businessData->uid);?>"><i class="fa fa-edit m-right-xs"></i>Edit Business</a>
<br />
</div>

View File

@ -14,7 +14,8 @@
"php": ">=5.3.7",
"filp/whoops": "^2.5",
"endroid/qr-code": "^4.6",
"chillerlan/php-qrcode": "^4.3"
"chillerlan/php-qrcode": "^4.3",
"phpmailer/phpmailer": "^6.9"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"

83
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4d49fa8b3c123439b594db07cd383c5f",
"content-hash": "6e6329bfc047a7f8fce3c9649bfe1b80",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -402,6 +402,87 @@
],
"time": "2023-11-03T12:00:00+00:00"
},
{
"name": "phpmailer/phpmailer",
"version": "v6.9.1",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/039de174cd9c17a8389754d3b877a2ed22743e18",
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",
"php": ">=5.5.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"doctrine/annotations": "^1.2.6 || ^1.13.3",
"php-parallel-lint/php-console-highlighter": "^1.0.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.7.2",
"yoast/phpunit-polyfills": "^1.0.4"
},
"suggest": {
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"psr/log": "For optional PSR-3 debug logging",
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPMailer\\PHPMailer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-only"
],
"authors": [
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
},
{
"name": "Brent R. Matzelle"
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"support": {
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.1"
},
"funding": [
{
"url": "https://github.com/Synchro",
"type": "github"
}
],
"time": "2023-11-25T22:23:28+00:00"
},
{
"name": "psr/log",
"version": "3.0.0",