-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from bbalet/dev
Dev
- Loading branch information
Showing
37 changed files
with
952 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,6 +430,41 @@ private function sendMailOnLeaveRequestCreation($id, $reminder=FALSE) { | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Send a notification to the manager of the connected employee when the | ||
* leave request has been canceled by its collaborator. | ||
* @param int $id Leave request identifier | ||
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
private function sendMailOnLeaveRequestCanceled($id) { | ||
$this->load->model('users_model'); | ||
$this->load->model('types_model'); | ||
$this->load->model('delegations_model'); | ||
//We load everything from DB as the LR can be edited from HR/Employees | ||
$leave = $this->leaves_model->getLeaves($id); | ||
$user = $this->users_model->getUsers($leave['employee']); | ||
$manager = $this->users_model->getUsers($user['manager']); | ||
if (empty($manager['email'])) { | ||
//TODO: create specific error message when the employee has no manager | ||
$this->session->set_flashdata('msg', lang('leaves_cancel_flash_msg_error')); | ||
} else { | ||
//Send an e-mail to the manager | ||
$this->load->library('email'); | ||
$this->load->library('polyglot'); | ||
$usr_lang = $this->polyglot->code2language($manager['language']); | ||
|
||
//We need to instance an different object as the languages of connected user may differ from the UI lang | ||
$lang_mail = new CI_Lang(); | ||
$lang_mail->load('email', $usr_lang); | ||
$lang_mail->load('global', $usr_lang); | ||
|
||
$this->sendGenericMail($leave, $user, $manager, $lang_mail, | ||
$lang_mail->line('email_leave_request_cancellation_title'), | ||
$lang_mail->line('email_leave_request_cancellation_subject'), | ||
'cancelled'); | ||
} | ||
} | ||
|
||
/** | ||
* Send a leave request cancellation email to the manager of the connected employee | ||
|
@@ -612,6 +647,38 @@ public function cancellation($id) { | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Allows the employee to cancel a requested leave request. | ||
* Only the connected user can reject its own requests. | ||
* Send a notification to the line manager. | ||
* Next status is 'Canceled' | ||
* @param int $id identifier of the leave request | ||
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
public function cancel($id) { | ||
//Test if the leave request exists | ||
$leave = $this->leaves_model->getLeaves($id); | ||
if (empty($leave)) { | ||
redirect('notfound'); | ||
} else { | ||
//Only the connected user can reject its own requests | ||
if ($this->user_id != $leave['employee']){ | ||
$this->session->set_flashdata('msg', lang('leaves_cancellation_flash_msg_error')); | ||
redirect('leaves'); | ||
} | ||
//We can cancel a leave request only with a status 'Requested' | ||
if ($leave['status'] == LMS_REQUESTED) { | ||
$this->leaves_model->switchStatus($id, LMS_CANCELED); | ||
$this->sendMailOnLeaveRequestCanceled($id); | ||
$this->session->set_flashdata('msg', lang('requests_cancellation_accept_flash_msg_success')); | ||
redirect('leaves'); | ||
} else { | ||
$this->session->set_flashdata('msg', lang('leaves_cancellation_flash_msg_error')); | ||
redirect('leaves'); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Export the list of all leaves into an Excel file | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Email template.You can change the content of this template | ||
* @copyright Copyright (c) 2014-2017 Benjamin BALET | ||
* @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0 | ||
* @link https://github.com/bbalet/jorani | ||
* @since 0.1.0 | ||
*/ | ||
?> | ||
<html lang="cs"> | ||
<head> | ||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | ||
<meta charset="UTF-8"> | ||
<style> | ||
table {width:50%;margin:5px;border-collapse:collapse;} | ||
table, th, td {border: 1px solid black;} | ||
th, td {padding: 20px;} | ||
h5 {color:red;} | ||
</style> | ||
</head> | ||
<body> | ||
<h3>{Title}</h3> | ||
{Firstname} {Lastname} cancelled a requested time off. See the <a href="{BaseUrl}leaves/leaves/{LeaveId}">details</a> below:<br /> | ||
<table border="0"> | ||
<tr> | ||
<td>From </td><td>{StartDate} ({StartDateType})</td> | ||
</tr> | ||
<tr> | ||
<td>To </td><td>{EndDate} ({EndDateType})</td> | ||
</tr> | ||
<tr> | ||
<td>Type </td><td>{Type}</td> | ||
</tr> | ||
<tr> | ||
<td>Duration </td><td>{Duration}</td> | ||
</tr> | ||
<tr> | ||
<td>Balance </td><td>{Balance}</td> | ||
</tr> | ||
<tr> | ||
<td>Reason </td><td>{Reason}</td> | ||
</tr> | ||
</table> | ||
<br /> | ||
You can check the <a href="{BaseUrl}hr/counters/collaborators/{UserId}">leave balance</a> before validating the leave request. | ||
<hr> | ||
<h5>*** This is an automatically generated message, please do not reply to this message ***</h5> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Email template.You can change the content of this template | ||
* @copyright Copyright (c) 2014-2017 Benjamin BALET | ||
* @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0 | ||
* @link https://github.com/bbalet/jorani | ||
* @since 0.1.0 | ||
*/ | ||
?> | ||
<html lang="de"> | ||
<head> | ||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | ||
<meta charset="UTF-8"> | ||
<style> | ||
table {width:50%;margin:5px;border-collapse:collapse;} | ||
table, th, td {border: 1px solid black;} | ||
th, td {padding: 20px;} | ||
h5 {color:red;} | ||
</style> | ||
</head> | ||
<body> | ||
<h3>{Title}</h3> | ||
{Firstname} {Lastname} cancelled a requested time off. See the <a href="{BaseUrl}leaves/leaves/{LeaveId}">details</a> below:<br /> | ||
<table border="0"> | ||
<tr> | ||
<td>From </td><td>{StartDate} ({StartDateType})</td> | ||
</tr> | ||
<tr> | ||
<td>To </td><td>{EndDate} ({EndDateType})</td> | ||
</tr> | ||
<tr> | ||
<td>Type </td><td>{Type}</td> | ||
</tr> | ||
<tr> | ||
<td>Duration </td><td>{Duration}</td> | ||
</tr> | ||
<tr> | ||
<td>Balance </td><td>{Balance}</td> | ||
</tr> | ||
<tr> | ||
<td>Reason </td><td>{Reason}</td> | ||
</tr> | ||
</table> | ||
<br /> | ||
You can check the <a href="{BaseUrl}hr/counters/collaborators/{UserId}">leave balance</a> before validating the leave request. | ||
<hr> | ||
<h5>*** This is an automatically generated message, please do not reply to this message ***</h5> | ||
</body> | ||
</html> |
Oops, something went wrong.