Skip to content

Commit

Permalink
Merge pull request #219 from bbalet/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bbalet authored Aug 8, 2017
2 parents c501e80 + e634769 commit eba6295
Show file tree
Hide file tree
Showing 37 changed files with 952 additions and 8 deletions.
1 change: 1 addition & 0 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
$route['leaves/create'] = 'leaves/create';
$route['leaves/edit/(:num)'] = 'leaves/edit/$1';
$route['leaves/request/(:num)'] = 'leaves/requestLeave/$1';
$route['leaves/cancel/(:num)'] = 'leaves/cancel/$1';
$route['leaves/update'] = 'leaves/update';
$route['leaves/delete/(:num)'] = 'leaves/delete/$1';
$route['leaves/(:num)/history'] = 'leaves/history/$1';
Expand Down
67 changes: 67 additions & 0 deletions application/controllers/Leaves.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <benjamin.balet@gmail.com>
*/
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
Expand Down Expand Up @@ -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 <benjamin.balet@gmail.com>
*/
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
Expand Down
2 changes: 2 additions & 0 deletions application/language/chinese/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = '拿取';
$lang['leaves_summary_thead_entitled'] = '可享有權利';
$lang['leaves_summary_thead_description'] = '描述';
$lang['leaves_summary_thead_actual'] = '实际';
$lang['leaves_summary_thead_simulated'] = '模拟';
$lang['leaves_summary_tbody_empty'] = '此時段無可休假天數,請聯繫HR部門/管理者';
$lang['leaves_summary_flash_msg_error'] = '你無類別.請連繫HR部門/管理者';
$lang['leaves_summary_date_field'] = '報告建立日期';
Expand Down
2 changes: 2 additions & 0 deletions application/language/czech/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Vybráno';
$lang['leaves_summary_thead_entitled'] = 'Nárokováno';
$lang['leaves_summary_thead_description'] = 'Popis';
$lang['leaves_summary_thead_actual'] = 'aktuální';
$lang['leaves_summary_thead_simulated'] = 'Simulované';
$lang['leaves_summary_tbody_empty'] = 'Nemáte nárok na dovolenou pro toto období. Kontaktujte prosím personální oddělení, nebo nadřízeného.';
$lang['leaves_summary_flash_msg_error'] = 'Zdá se že nemáte smlouvu. Prosím kontaktujte vaše HR / Manažera.';
$lang['leaves_summary_date_field'] = 'Datum reportu';
Expand Down
2 changes: 2 additions & 0 deletions application/language/dutch/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Opgenomen';
$lang['leaves_summary_thead_entitled'] = 'Recht op';
$lang['leaves_summary_thead_description'] = 'Omschrijving';
$lang['leaves_summary_thead_actual'] = 'werkelijk';
$lang['leaves_summary_thead_simulated'] = 'nagebootst';
$lang['leaves_summary_tbody_empty'] = 'Geen beschikbare of opgenomen dagen voor deze periode. Neem aub contact op met uw HR Officer/Manager.';
$lang['leaves_summary_flash_msg_error'] = 'Geen contract gegevens gevonden. Neem contact op met uw HR Officer / manager.';
$lang['leaves_summary_date_field'] = 'Datum rapport';
Expand Down
2 changes: 2 additions & 0 deletions application/language/english/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
$lang['leaves_summary_thead_taken'] = 'Taken';
$lang['leaves_summary_thead_entitled'] = 'Entitled';
$lang['leaves_summary_thead_description'] = 'Description';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'No entitled or taken days for this period. Please contact your HR Officer / Manager.';
$lang['leaves_summary_flash_msg_error'] = 'It appears that you have no contract. Please contact your HR Officer / Manager.';
$lang['leaves_summary_date_field'] = 'Date of report';
Expand Down
2 changes: 2 additions & 0 deletions application/language/english_gb/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
$lang['leaves_summary_thead_taken'] = 'Taken';
$lang['leaves_summary_thead_entitled'] = 'Entitled';
$lang['leaves_summary_thead_description'] = 'Description';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'No entitled or taken days for this period. Please contact your HR Officer / Manager.';
$lang['leaves_summary_flash_msg_error'] = 'It appears that you have no contract. Please contact your HR Officer / Manager.';
$lang['leaves_summary_date_field'] = 'Date of report';
Expand Down
2 changes: 2 additions & 0 deletions application/language/french/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
$lang['leaves_summary_thead_taken'] = 'Pris';
$lang['leaves_summary_thead_entitled'] = 'Acquis';
$lang['leaves_summary_thead_description'] = 'Description';
$lang['leaves_summary_thead_actual'] = 'réel';
$lang['leaves_summary_thead_simulated'] = 'simulé';
$lang['leaves_summary_tbody_empty'] = 'Aucun jour pris ou disponible. Veuillez contacter un responsable des ressources humaines.';
$lang['leaves_summary_flash_msg_error'] = 'Il semble que vous n\'ayez pas de contrat. Veuillez contacter un responsable des ressources humaines.';
$lang['leaves_summary_date_field'] = 'Date du rapport';
Expand Down
2 changes: 2 additions & 0 deletions application/language/german/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Belegt';
$lang['leaves_summary_thead_entitled'] = 'Bezugsberechtigt';
$lang['leaves_summary_thead_description'] = 'Beschreibung';
$lang['leaves_summary_thead_actual'] = 'tatsächlich';
$lang['leaves_summary_thead_simulated'] = 'simuliert';
$lang['leaves_summary_tbody_empty'] = 'Keine bezugsberechtigten oder bezogenen Urlaubstage für diesen Zeitraum gefunden. Bitte wenden Sie sich an Ihre Personalabteilung oder Ihren Vorgesetzten.';
$lang['leaves_summary_flash_msg_error'] = 'Es scheint als hätten Sie keinen Vertrag. Bitte kontaktieren Sie Ihre Personalabteilung oder Ihren Vorgesetzten.';
$lang['leaves_summary_date_field'] = 'Datum des Reports';
Expand Down
2 changes: 2 additions & 0 deletions application/language/greek/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Έλαβα';
$lang['leaves_summary_thead_entitled'] = 'Δικαιοδοσία';
$lang['leaves_summary_thead_description'] = 'Περιγραφή';
$lang['leaves_summary_thead_actual'] = 'πραγματικός';
$lang['leaves_summary_thead_simulated'] = 'Προσομοίωση';
$lang['leaves_summary_tbody_empty'] = 'Δεν δικαιούται ή έλαβε ημέρες για αυτή την περίοδο. Επικοινωνήστε με τον υπεύθυνο / διευθυντή HR σας.';
$lang['leaves_summary_flash_msg_error'] = 'Φαίνεται ότι δεν έχετε συμβόλαιο. Επικοινωνήστε με τον υπεύθυνο / διευθυντή HR.';
$lang['leaves_summary_date_field'] = 'Ημερομηνία της αναφοράς';
Expand Down
2 changes: 2 additions & 0 deletions application/language/italian/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Occupato';
$lang['leaves_summary_thead_entitled'] = 'Spettante';
$lang['leaves_summary_thead_description'] = 'Descrizione';
$lang['leaves_summary_thead_actual'] = 'effettivo';
$lang['leaves_summary_thead_simulated'] = 'simulata';
$lang['leaves_summary_tbody_empty'] = 'Nessun giorno spettante o preso per questo periodo. Sei pregato di contattare il tuo responsabile delle Risorse Umane / Manager';
$lang['leaves_summary_flash_msg_error'] = 'Sembra che tu non abbia un contratto. Sei pregato di contattare il tuo responsabile delle Risorse Umane / Manager';
$lang['leaves_summary_date_field'] = 'Data del report';
Expand Down
2 changes: 2 additions & 0 deletions application/language/khmer/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'ថ្ងៃដែលបានឈប់សម្រាក';
$lang['leaves_summary_thead_entitled'] = 'ថ្ងៃដែលអនុញ្ញាតឱ្យឈប់សម្រាក';
$lang['leaves_summary_thead_description'] = 'បរិយាយ';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'ពុំមានថ្ងៃដែលត្រូវអនុញ្ញាតឱ្យឈប់ ឬថ្ងៃត្រូវឈប់សម្រាកក្នុងកំឡុងពេលនេះទេ។ សូមទំនាក់ទំនងទៅកាន់មន្ត្រីធនធានមនុស្យ ឬអ្នកគ្រប់គ្រងរបស់អ្នក។';
$lang['leaves_summary_flash_msg_error'] = 'ំនងជាអ្នកមិនមនាកិច្ចសន្យាទេ។ សូមទំនាក់ទំនងមន្ត្រីធនធានមនុស្យ / អ្នកគ្រប់គ្រងរបស់អ្នក។';
$lang['leaves_summary_date_field'] = 'កាលបរិច្ឆេទនៃរបាយការណ៍';
Expand Down
2 changes: 2 additions & 0 deletions application/language/persian/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'گرفته شده';
$lang['leaves_summary_thead_entitled'] = 'موجه';
$lang['leaves_summary_thead_description'] = 'توضیحات';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'هیچ روز استحقاقی و یا روز گرفته شده در این بازه وجود ندارد. لطفاً با مدیر منابع انسانی یا مدیر عمومی تان تماس بگیرید.';
$lang['leaves_summary_flash_msg_error'] = 'It appears that you have no contract. Please contact your HR Officer / Manager.';
$lang['leaves_summary_date_field'] = 'تاریخ گزارش';
Expand Down
2 changes: 2 additions & 0 deletions application/language/russian/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Использовано';
$lang['leaves_summary_thead_entitled'] = 'Предоставляемые дни';
$lang['leaves_summary_thead_description'] = 'Описание';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'Нет предоставленных или использованных дней для этого периода. Обратитесь к своему руководителю.';
$lang['leaves_summary_flash_msg_error'] = 'Похоже вы не имеете контракта. Обратитесь к своему руководителю.';
$lang['leaves_summary_date_field'] = 'Дата отчёта';
Expand Down
2 changes: 2 additions & 0 deletions application/language/spanish/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Recibido';
$lang['leaves_summary_thead_entitled'] = 'Asociado';
$lang['leaves_summary_thead_description'] = 'Descripción';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'No hay día asociado o recibido para este período. Por favor, póngase en contacto con el administrador.';
$lang['leaves_summary_flash_msg_error'] = 'Parece que no tiene contrato. Pongase en contacto con el administrador.';
$lang['leaves_summary_date_field'] = 'Fecha del informe';
Expand Down
2 changes: 2 additions & 0 deletions application/language/turkish/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Alınmış';
$lang['leaves_summary_thead_entitled'] = 'Hak edilmiş';
$lang['leaves_summary_thead_description'] = 'Açıklama';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'Bu dönem içinde hiçbir hak kazanılmış veya kullanılmış izin günü bulunmuyor. Lütfen İK Sorumlusu / Yöneticisi ile irtibata geçiniz.';
$lang['leaves_summary_flash_msg_error'] = 'Hiçbir sözleşmeniz yok gibi görünüyor. Lütfen İK Sorumlusu / Yöneticisi ile irtibata geçiniz.';
$lang['leaves_summary_date_field'] = 'Rapor tarihi';
Expand Down
2 changes: 2 additions & 0 deletions application/language/ukrainian/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Використано';
$lang['leaves_summary_thead_entitled'] = 'Надано';
$lang['leaves_summary_thead_description'] = 'Опис';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'Немає наданих або використаних днів за цей період. Зверніться до свого керівника.';
$lang['leaves_summary_flash_msg_error'] = 'Схоже не те, що у вас немає контракту. Зверніться до свого керівника.';
$lang['leaves_summary_date_field'] = 'Дата звіту';
Expand Down
2 changes: 2 additions & 0 deletions application/language/vietnamese/leaves_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
$lang['leaves_summary_thead_taken'] = 'Được dùng';
$lang['leaves_summary_thead_entitled'] = 'Được phép';
$lang['leaves_summary_thead_description'] = 'Miêu tả';
$lang['leaves_summary_thead_actual'] = 'actual';
$lang['leaves_summary_thead_simulated'] = 'simulated';
$lang['leaves_summary_tbody_empty'] = 'Không có số ngày được phép hay được dùng trong khoảng thời gian này. Vui lòng liên hệ Trưởng bộ phận nhân sự của bạn.';
$lang['leaves_summary_flash_msg_error'] = 'Hiển thị bạn không có hợp đồng. Vui lòng liên hệ Trưởng bộ phận nhân sự của bạn.';
$lang['leaves_summary_date_field'] = 'Ngày báo cáo';
Expand Down
49 changes: 49 additions & 0 deletions application/views/emails/cs/cancelled.php
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 &nbsp;</td><td>{StartDate}&nbsp;({StartDateType})</td>
</tr>
<tr>
<td>To &nbsp;</td><td>{EndDate}&nbsp;({EndDateType})</td>
</tr>
<tr>
<td>Type &nbsp;</td><td>{Type}</td>
</tr>
<tr>
<td>Duration &nbsp;</td><td>{Duration}</td>
</tr>
<tr>
<td>Balance &nbsp;</td><td>{Balance}</td>
</tr>
<tr>
<td>Reason &nbsp;</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>
49 changes: 49 additions & 0 deletions application/views/emails/de/cancelled.php
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 &nbsp;</td><td>{StartDate}&nbsp;({StartDateType})</td>
</tr>
<tr>
<td>To &nbsp;</td><td>{EndDate}&nbsp;({EndDateType})</td>
</tr>
<tr>
<td>Type &nbsp;</td><td>{Type}</td>
</tr>
<tr>
<td>Duration &nbsp;</td><td>{Duration}</td>
</tr>
<tr>
<td>Balance &nbsp;</td><td>{Balance}</td>
</tr>
<tr>
<td>Reason &nbsp;</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>
Loading

0 comments on commit eba6295

Please sign in to comment.