Bug Fixes 1 Leave module Leave Report & Permision date format : ps

This commit is contained in:
VE10-Sanjeev 2024-04-04 17:16:48 +05:30
parent 60147b10bb
commit 2336f25b8b
13 changed files with 240 additions and 149 deletions

View File

@ -49,6 +49,7 @@
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
// $route['default_controller'] = 'welcome';
$route['default_controller'] = 'Auth';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

View File

@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('email');
$autoload['libraries'] = array('session','database','email');
/*
| -------------------------------------------------------------------
@ -89,8 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url', 'mail');
$autoload['helper'] = array('url','custom','mail', 'data');
/*
| -------------------------------------------------------------------
| Auto-load Config files
@ -132,4 +131,4 @@
|
| $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array();
$autoload['model'] = array('auth/auth_model');

View File

@ -23,7 +23,9 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'https://localhost/CodeIgniter-HMVC';
$base = "http://".$_SERVER['HTTP_HOST'];
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $base;
/*
|--------------------------------------------------------------------------
@ -223,7 +225,7 @@
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;
$config['log_threshold'] = 4; // Logs all possible error levels
/*
|--------------------------------------------------------------------------

View File

@ -71,6 +71,7 @@
| the query builder class.
*/
$active_group = 'default';
$active_group = 'testingDB';
$query_builder = TRUE;
$db['default'] = array(
@ -94,3 +95,25 @@
'failover' => array(),
'save_queries' => TRUE
);
$db['testingDB'] = array(
'dsn' => '',
'hostname' => '119.18.54.85',
'username' => 'venbaehn_ams',
'password' => 'L;nD7Z@f)1ZT',
'database' => 'venbaehn_ams',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

View File

@ -49,6 +49,10 @@
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
// $route['default_controller'] = 'welcome';
// $route['default_controller'] = 'Auth';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['default_controller'] = 'Auth';
$route['logout'] = 'Auth/logout';
$route['login'] = 'Auth';

View File

@ -102,8 +102,7 @@
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = TRUE;
$config['enable_hooks'] = FALSE;
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
@ -225,7 +224,7 @@
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 4;
$config['log_threshold'] = 0;
/*
|--------------------------------------------------------------------------
@ -273,7 +272,7 @@
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'd-m-m H:i:s';
$config['log_date_format'] = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
@ -450,7 +449,7 @@
| 'csrf_regenerate' = Regenerate token on every submission
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
*/
$config['csrf_protection'] = TRUE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;

View File

@ -49,7 +49,8 @@
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'Backend';
// $route['default_controller'] = 'Backend';
$route['default_controller'] = 'Auth';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

View File

@ -5,104 +5,100 @@
if (!function_exists('send_emails')) {
function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null)
{
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);
log_message('error', 'Fns send_emails - helper_loaded');
log_message('error', 'Receiptent mail - ' . $to . ' - subject - ' . $subject . ' - body - ' . $body);
log_message('error', 'Sender mail ' . business()->sender_mail);
try {
$mailer = new PHPMailer(true);
log_message('info', 'phpmailer loaded');
try {
$mailer = new PHPMailer(true);
log_message('error', 'phpmailer loaded');
$mailer->isSMTP();
$mailer->CharSet = 'utf-8';
$mailer->Host= 'mail.venbait.in';
$mailer->SMTPSecure = 'ssl';
$mailer->SMTPAuth =true;
$mailer->SMTPDebug =false;
$mailer->Username='bbone@venbait.in';
$mailer->Password='xk!L(N_-R#};';
$mailer->Port=465;
$mailer->setFrom(business()->sender_mail, $aliasName);
$mailer->addAddress($to);
$mailer->isSMTP();
$mailer->CharSet = 'utf-8';
$mailer->Host = business()->mail_hostname;
$mailer->SMTPSecure = business()->mail_security;
$mailer->SMTPAuth = true;
$mailer->SMTPDebug = false;
$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 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);
// }
// }
// 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->Subject = $subject;
$mailer->isHTML(true);
$mailer->Body=$body;
$mailer->isHTML(true);
$mailer->Body = $body;
$attachmentPath = '/path/to/your/attachment/' . $receipt;
$attachmentPath = '/path/to/your/attachment/' . $receipt;
if (file_exists($attachmentPath)) {
$mailer->addAttachment($attachmentPath);
if (file_exists($attachmentPath)) {
$mailer->addAttachment($attachmentPath);
}
if ($mailer->send()) {
log_message('error', 'Email sent successfully');
} else {
throw new \Exception('Email sending failed.');
}
} catch (\Exception $e) {
log_message('error', 'Error mail noy send: ' . $mailer->ErrorInfo);
log_message('error', 'Email Error = ' . $e->getMessage());
}
$mailer->send();
log_message('info', 'success : mail sendsuccessfully');
return true;
} catch (Exception $e) {
log_message('info', 'Error mail noy send: '.$mailer->ErrorInfo);
return '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);
log_message('error', 'send_mail_helper_loadded');
log_message('error', 'Receiptent mail - ' . $to . ' - subject - ' . $subject . ' - body - ' . $body);
log_message('error', 'Sender mail ' . business()->sender_mail);
try {
$mailer = new PHPMailer(true);
log_message('info', 'phpmailer loaded');
log_message('error', '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->Host = business()->mail_hostname;
$mailer->SMTPSecure = business()->mail_security;
$mailer->SMTPAuth = true;
$mailer->SMTPDebug = false;
$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
@ -127,9 +123,9 @@ function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc
}
}
$mailer->Subject=$subject;
$mailer->Subject = $subject;
$mailer->isHTML(true);
$mailer->Body=$body;
$mailer->Body = $body;
$attachmentPath = '/path/to/your/attachment/' . $receipt;
@ -137,21 +133,20 @@ function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc
$mailer->addAttachment($attachmentPath);
}
$mailer->send();
if ($mailer->send()) {
log_message('error', 'Email sent successfully');
} else {
throw new \Exception('Email sending failed.');
}
return true;
log_message('info', 'success : mail sendsuccessfully');
} catch (Exception $e) {
return 'Error: ' . $mailer->ErrorInfo;
log_message('info', 'Error : '.$mailer->ErrorInfo);
// return true;
// log_message('error', 'success : mail send successfully');
} catch (\Exception $e) {
// return 'Error: ' . $mailer->Errorerror;
log_message('error', 'Error mail noy send: ' . $mailer->ErrorInfo);
log_message('error', 'Email Error = ' . $e->getMessage());
}
return true;
}
}
?>
}

View File

@ -65,6 +65,15 @@ public function leaveList()
}
public function leave_list_report()
{
$business_id = user()->business_id;
$leave_list = $this->Leave_model->get_all_leave_data($business_id);
$this->layout->set('leave_list', $leave_list);
$this->layout->buffer('main_content', 'Leave/leave_list_report');
$this->layout->render('Employee_Layout');
}
public function leave_list_report_exist()
{
$business_id = user()->business_id;
$leave_list = $this->Leave_model->get_all_leave(user()->business_id);
@ -87,6 +96,7 @@ public function leave_list_report()
}
}
$result = array_values($resultArray);
// echo json_encode( $result, JSON_PRETTY_PRINT);die;
$this->layout->set('leave_list', $result);
@ -187,8 +197,8 @@ public function createLeave()
$table="leave_list";
$perm_data['perm_date_new'] = date("Y-m-d", strtotime( $this->input->post('perm_date_new') ));
$create_permission = $this->MY_Model->insert($perm_data,$table);
$create_permission = $this->MY_Model->insert($perm_data,$table);
// $create_permission = 221;
//for notification
if($create_permission){
$code = 'LEAVE_PERMISSION';
@ -197,7 +207,8 @@ public function createLeave()
}
$this->session->set_flashdata('Success', '1');
redirect('Leave/LeaveHistory');
redirect('Leave/LeaveHistory');
}
//end of permission

View File

@ -19,14 +19,57 @@ public function get_all_leave($business_id)
}
public function get_all_leave_data($business_id) {
$this->db->select("
A.id, A.emp_id, A.approved_by, A.business_id, A.is_active, A.from_date_new, A.to_date_new,
A.perm_date_new, A.from_time, A.to_time, U1.name as emp_name, U2.name as approve_by_name, l.type as leave_type, l.code as leave_code,
IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new) AS final_date,
MONTH(IF(A.from_date_new IS NOT NULL, A.from_date_new, A.perm_date_new)) AS final_date_month,
YEAR(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new)) as final_date_year,
GROUP_CONCAT(
CASE
WHEN A.from_date_new IS NOT NULL THEN CONCAT(' (',A.from_date_new, ' to ', A.to_date_new,') ')
ELSE ''
END
) AS date_range,
SUM(A.no_of_days) AS total_no_of_days,
GROUP_CONCAT(
CASE
WHEN A.perm_date_new IS NOT NULL AND UPPER(l.code) = 'PERMISSION' THEN CONCAT(
DATE_FORMAT(A.perm_date_new, '%d-%m-%Y'),
' ',
A.from_time,
' - ',
A.to_time)
ELSE ''
END
) AS permission_range
");
$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('leave_master l', 'l.id = A.type', 'LEFT');
$this->db->where('A.business_id', $business_id);
$this->db->where('A.is_active', 1);
$this->db->where('A.approved_by !=', '');
$this->db->group_by('A.emp_id, A.type, MONTH(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new)), YEAR(IF(A.from_date_new is not null, A.from_date_new ,A.perm_date_new))');
$this->db->order_by('A.id', 'DESC');
$query = $this->db->get();
return $query->result();
// print_r($this->db->last_query());die;
}
public function get_leave_with_emp_name($business_id)
{
$this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby');
$this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby,l.type as leave_type,l.code as leave_code');
$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('leave_master l', 'l.id = A.type', 'LEFT');
$this->db->where('A.business_id', $business_id);
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);

View File

@ -69,27 +69,40 @@
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<?php foreach ($leave_type as $leave => $type) { ?>
<?php if($type->id === $value->type ) { ?>
<tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<td class=" "><?php echo dateFormat('d-m-Y',$value->created_date_new); ?><br><?php echo $value->created_time; ?>
</td>
<td class=" "><?php echo $value->emp_name; ?></td>
<td class=" "><?php echo $value->comments; ?></td>
<?php if($value->from_date_new == "" && $value->to_date_new == "") { ?>
<td class="">
<?php echo dateFormat('d-m-Y',$value->perm_date_new);?><br>
<?php echo timeFormat('h:i a', $value->from_time); ?> to
<?php echo timeFormat('h:i a', $value->to_time);?>
</td>
<?php } else { ?>
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date_new); echo ' to ';?>
<?php echo dateFormat('d-m-Y',$value->to_date_new);?> </td>
<?php if(strtoupper($value->leave_code) != "PERMISSION"){ ?>
<?php if($value->from_date_new != '' && $value->to_date_new != ''){ ?>
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date_new); echo ' to ';?>
<?php echo dateFormat('d-m-Y',$value->to_date_new);?> </td>
<?php }else{ " - Invaild date - "; } ?>
<?php }else{ ?>
<td class="">
<?php if($value->perm_date_new != null && $value->perm_date_new != ''){ ?>
<?php echo dateFormat('d-m-Y',$value->perm_date_new);?><br>
<?php echo timeFormat('h:i a', $value->from_time); ?> to
<?php echo timeFormat('h:i a', $value->to_time);?>
<?php }else{ " - Invaild date - "; } ?>
</td>
<?php } ?>
<td class=" "><?php echo $value->leave_type; ?></td>
<!-- <?php // if($value->from_date_new == "" && $value->to_date_new == "") { ?>
<td class="">
<?php // echo dateFormat('d-m-Y',$value->perm_date_new);?><br>
<?php // echo timeFormat('h:i a', $value->from_time); ?> to
<?php // echo timeFormat('h:i a', $value->to_time);?>
</td>
<?php // } else { ?>
<td class=" "><?php echo $type->type; ?></td>
<td class=" "> <?php // echo dateFormat('d-m-Y',$value->from_date_new); echo ' to ';?>
<?php // echo dateFormat('d-m-Y',$value->to_date_new);?> </td>
<?php // } ?>
<td class=" "><?php // echo $type->type; ?></td> -->
<td class=" "><?php if($value->Risedby == ''){echo 'self'; }else{echo $value->Risedby; }; ?></td>
<?php if($value->no_of_days == 0){ ?>
@ -141,7 +154,8 @@
<?php } ?>
</td>
</tr>
<?php } } } ?>
<?php } ?>
</tbody>
</table>
</div>

View File

@ -19,6 +19,7 @@
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th hidden class="column-title">Month Year</th>
<th class="column-title">Employee Id</th>
<th class="column-title">Employee Name </th>
<th class="column-title">Start - End (Date)</th>
@ -27,25 +28,20 @@
</tr>
</thead>
<tbody>
<?php foreach ($leave_list as $key => $value) { ?>
<?php
foreach ($leave_list as $key => $value) {
$year_month = !empty($value->final_date) ? date('Y-m', strtotime($value->final_date)) : "";
?>
<tr>
<td hidden><?php echo $value->id; ?></td>
<td hidden ><?php echo $year_month; ?></td>
<td><?php echo $value->emp_id; ?></td>
<td><?php echo $value->emp_name; ?></td>
<td>
<?php
if($value->leavetype == 'Permission')
{
echo dateFormat('d-m-Y',$value->perm_date_new).' - '.timeFormat('h:i a', $value->from_time). ' to ' .timeFormat('h:i a', $value->to_time);
}
else
{
echo $value->from_date_new;
}
?>
</td>
<td><?php echo $value->no_of_days; ?></td>
<td><?php echo $value->leavetype; ?></td>
<td><?php echo $value->from_date_new != '' ? $value->date_range : $value->permission_range; ?></td>
<td><?php echo $value->from_date_new != '' ? $value->total_no_of_days : '-'; ?></td>
<td><?php echo $value->leave_type; ?></td>
</tr>
<?php } ?>
</tbody>
@ -96,27 +92,28 @@
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
// Generate the past months of the current year
for (var month = currentMonth; month > 0; month--) {
dateList.push(currentYear + '-' + (month < 10 ? '0' + month : month));
dateListView.push(monthNames[month - 1] + ' ' + currentYear);
for (var i = 0; i < 6; i++) {
var monthIndex = currentMonth - i;
var yearOffset = 0;
if (monthIndex <= 0) {
monthIndex += 12;
yearOffset = 1;
}
dateList.push((currentYear - yearOffset) + '-' + (monthIndex < 10 ? '0' + monthIndex : monthIndex));
dateListView.push(monthNames[monthIndex - 1] + ' ' + (currentYear - yearOffset));
}
// Append the current month
dateList.push((currentMonth < 10 ? '0' + currentMonth : currentMonth)+ '-' +currentYear );
dateListView.push(monthNames[currentMonth - 1] + ' ' + currentYear);
console.log(dateList);
// Create dropdown list
var select = $('<select class="form-control form-control-sm" style="width: 20%;"><option value="">All</option></select>')
.appendTo($('#datatables_wrapper .dataTables_filter'))
.on('change', function() {
table.column(3).search($(this).val()).draw();
table.column(1).search($(this).val()).draw();
});
// Populate dropdown list options
$.each(dateList, function(index, value) {
if(index != 0)
select.append('<option value="' + value + '">' + dateListView[index] + '</option>');
});
// });

View File

@ -61,7 +61,7 @@
$domain = strtolower($_SERVER['HTTP_HOST']);
switch ($domain) {
case 'www.yoursite.tld':
case 'venbait.in/org-hub':
define('ENVIRONMENT', 'production');
break;
case 'localhost':
@ -108,7 +108,7 @@
break;
case 'production':
ini_set('display_errors', 0);
ini_set('display_errors', 1);
break;
default:
@ -116,7 +116,9 @@
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
// echo strtolower($_SERVER['HTTP_HOST']);
// echo ENVIRONMENT;
// echo PHP_VERSION;
/*
*---------------------------------------------------------------
* SYSTEM DIRECTORY NAME