forked from bbalet/jorani
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ER:ICS feeds (new variable in config.php).
ER:Enter timezone of employees (new variable in config.php).
- Loading branch information
Showing
34 changed files
with
639 additions
and
46 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
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 |
---|---|---|
|
@@ -31,26 +31,41 @@ class Ics extends CI_Controller { | |
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
$this->load->helper('language'); | ||
$this->lang->load('global', $this->config->item('language')); | ||
//$this->load->helper('language'); | ||
//$this->lang->load('global', $this->config->item('language')); | ||
$this->load->library('polyglot'); | ||
require_once(APPPATH . 'third_party/VObjects/vendor/autoload.php'); | ||
} | ||
|
||
/** | ||
* Get the list of dayoffs for a given contract identifier | ||
* @param int $id identifier of a contract | ||
* @param int $user identifier of the user wanting to view the list (mind timezone) | ||
* @param int $contract identifier of a contract | ||
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
public function dayoffs($id) { | ||
public function dayoffs($user, $contract) { | ||
expires_now(); | ||
if ($this->config->item('ics_enabled') == FALSE) { | ||
$this->output->set_header("HTTP/1.0 403 Forbidden"); | ||
} else { | ||
//Get timezone and language of the user | ||
$this->load->model('users_model'); | ||
$employee = $this->users_model->get_users($user); | ||
if (!is_null($employee['timezone'])) { | ||
$tzdef = $employee['timezone']; | ||
} else { | ||
$tzdef = $this->config->item('default_timezone'); | ||
if ($tzdef == FALSE) $tzdef = 'Europe/Paris'; | ||
} | ||
$this->lang->load('global', $this->polyglot->code2language($employee['language'])); | ||
//Load the list of day off associated to the contract | ||
$this->load->model('dayoffs_model'); | ||
$result = $this->dayoffs_model->get_all_dayoffs($id); | ||
$result = $this->dayoffs_model->get_all_dayoffs($contract); | ||
if (empty($result)) { | ||
echo ""; | ||
} else { | ||
$tzold = date_default_timezone_get(); | ||
date_default_timezone_set($tzdef); | ||
$vcalendar = new VObject\Component\VCalendar(); | ||
foreach ($result as $event) { | ||
$startdate = new \DateTime($event->date); | ||
|
@@ -77,6 +92,7 @@ public function dayoffs($id) { | |
]); | ||
} | ||
echo $vcalendar->serialize(); | ||
date_default_timezone_set($tzold); | ||
} | ||
} | ||
} | ||
|
@@ -96,6 +112,19 @@ public function individual($id) { | |
if (empty($result)) { | ||
echo ""; | ||
} else { | ||
//Get timezone and language of the user | ||
$this->load->model('users_model'); | ||
$employee = $this->users_model->get_users($id); | ||
if (!is_null($employee['timezone'])) { | ||
$tzdef = $employee['timezone']; | ||
} else { | ||
$tzdef = $this->config->item('default_timezone'); | ||
if ($tzdef == FALSE) $tzdef = 'Europe/Paris'; | ||
} | ||
$this->lang->load('global', $this->polyglot->code2language($employee['language'])); | ||
$tzold = date_default_timezone_get(); | ||
date_default_timezone_set($tzdef); | ||
|
||
$vcalendar = new VObject\Component\VCalendar(); | ||
foreach ($result as $event) { | ||
$startdate = new \DateTime($event['startdate']); | ||
|
@@ -115,6 +144,7 @@ public function individual($id) { | |
]); | ||
} | ||
echo $vcalendar->serialize(); | ||
date_default_timezone_set($tzold); | ||
} | ||
} | ||
} | ||
|
@@ -130,6 +160,19 @@ public function ical($id) { | |
header('Content-Disposition: attachment; filename=leave.ics'); | ||
$this->load->model('leaves_model'); | ||
$leave = $this->leaves_model->get_leaves($id); | ||
//Get timezone and language of the user | ||
$this->load->model('users_model'); | ||
$employee = $this->users_model->get_users($leave['employee']); | ||
if (!is_null($employee['timezone'])) { | ||
$tzdef = $employee['timezone']; | ||
} else { | ||
$tzdef = $this->config->item('default_timezone'); | ||
if ($tzdef == FALSE) $tzdef = 'Europe/Paris'; | ||
} | ||
$this->lang->load('global', $this->polyglot->code2language($employee['language'])); | ||
$tzold = date_default_timezone_get(); | ||
date_default_timezone_set($tzdef); | ||
|
||
$vcalendar = new VObject\Component\VCalendar(); | ||
|
||
$vcalendar->add('VEVENT', [ | ||
|
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 |
---|---|---|
|
@@ -39,7 +39,6 @@ public function __construct() { | |
$this->user_id = $this->session->userdata('id'); | ||
$this->language = $this->session->userdata('language'); | ||
$this->language_code = $this->session->userdata('language_code'); | ||
$this->load->helper('language'); | ||
$this->lang->load('users', $this->language); | ||
} | ||
|
||
|
@@ -171,6 +170,7 @@ public function edit($id) { | |
$this->form_validation->set_rules('datehired', lang('users_edit_field_hired'), 'xss_clean'); | ||
$this->form_validation->set_rules('identifier', lang('users_edit_field_identifier'), 'xss_clean'); | ||
$this->form_validation->set_rules('language', lang('users_edit_field_language'), 'xss_clean'); | ||
$this->form_validation->set_rules('timezone', lang('users_edit_field_timezone'), 'xss_clean'); | ||
if ($this->config->item('ldap_basedn_db')) $this->form_validation->set_rules('ldap_path', lang('users_edit_field_ldap_path'), 'xss_clean'); | ||
|
||
$data['users_item'] = $this->users_model->get_users($id); | ||
|
@@ -327,6 +327,7 @@ public function create() { | |
$this->form_validation->set_rules('datehired', lang('users_create_field_hired'), 'xss_clean'); | ||
$this->form_validation->set_rules('identifier', lang('users_create_field_identifier'), 'xss_clean'); | ||
$this->form_validation->set_rules('language', lang('users_create_field_language'), 'xss_clean'); | ||
$this->form_validation->set_rules('timezone', lang('users_create_field_timezone'), 'xss_clean'); | ||
if ($this->config->item('ldap_basedn_db')) $this->form_validation->set_rules('ldap_path', lang('users_create_field_ldap_path'), 'xss_clean'); | ||
|
||
if ($this->form_validation->run() === FALSE) { | ||
|
@@ -383,6 +384,7 @@ public function create() { | |
* Form validation callback : prevent from login duplication | ||
* @param type $login | ||
* @return boolean true if the field is valid, false otherwise | ||
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
public function login_check($login) { | ||
if (!$this->users_model->is_login_available($login)) { | ||
|
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 |
---|---|---|
|
@@ -186,9 +186,7 @@ public function adddayoff($contract, $timestamp, $type, $title) { | |
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
public function userDayoffs($user_id, $start = "", $end = "") { | ||
$this->load->helper('language'); | ||
$this->lang->load('calendar', $this->session->userdata('language')); | ||
|
||
$this->db->select('dayoffs.*'); | ||
$this->db->join('dayoffs', 'users.contract = dayoffs.contract'); | ||
$this->db->where('users.id', $user_id); | ||
|
@@ -241,7 +239,6 @@ public function userDayoffs($user_id, $start = "", $end = "") { | |
* @author Benjamin BALET <[email protected]> | ||
*/ | ||
public function allDayoffs($start, $end, $entity_id, $children) { | ||
$this->load->helper('language'); | ||
$this->lang->load('calendar', $this->session->userdata('language')); | ||
|
||
$this->db->select('dayoffs.*, contracts.name'); | ||
|
Oops, something went wrong.