Skip to content

Commit

Permalink
ER:ICS feeds (new variable in config.php).
Browse files Browse the repository at this point in the history
ER:Enter timezone of employees (new variable in config.php).
  • Loading branch information
bbalet committed Feb 16, 2015
1 parent 1869ea7 commit 7d037fe
Show file tree
Hide file tree
Showing 34 changed files with 639 additions and 46 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ Use bbalet / bbalet for login / password. Be nice and don't screw up the data of
## Contribute

* Suggest ideas, declare bugs with Github's issue tracking system.
* Translate the software in your language.
* Code enhancement requests declared in Github's issue tracking system.
* Help me to translate the software in your language https://www.transifex.com/projects/p/jorani

## Credits

Expand All @@ -75,7 +74,7 @@ We thank the following open source projects for the components used by Jorani:

#### Backend

* CodeIgniter MVC framework http://ellislab.com/codeigniter
* CodeIgniter MVC framework http://www.codeigniter.com/
* BCRYPT password hasher https://github.com/dwightwatson/codeigniter-bcrypt
* RSA Encryption in pure PHP https://github.com/phpseclib/phpseclib
* Excel import/export https://github.com/PHPOffice/PHPExcel
Expand All @@ -89,5 +88,6 @@ We thank the following open source projects for the components used by Jorani:
* Datatable https://datatables.net/
* RSA implementation https://github.com/travist/jsencrypt
* Moment (JS dates lib) http://momentjs.com/
* Selectize https://github.com/brianreavis/selectize.js

Background image of login page by Kevin Dooley - https://www.flickr.com/photos/pagedooley/ / License: Creative Commons (Attribution 3.0 Unported)
2 changes: 1 addition & 1 deletion application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
| $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array('url', 'tools');
$autoload['helper'] = array('url', 'tools', 'language');


/*
Expand Down
8 changes: 5 additions & 3 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,12 @@
$config['ldap_host'] = '127.0.0.1';
$config['ldap_port'] = 389;
$config['ldap_basedn'] = 'uid=%s,ou=people,dc=company,dc=com';
$config['ldap_basedn_db'] = FALSE;
$config['ldap_basedn_db'] = TRUE;

//Enable public ICS feeds
$config['ics_enabled'] = TRUE;
$config['default_timezone'] = 'Europe/Paris';

//Enable public ICS feeds - Will be added in v0.4.0 (need a db patch)
$config['ics_enabled'] = FALSE;

/* End of file config.php */
/* Location: ./application/config/config.php */
2 changes: 1 addition & 1 deletion application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@

//ICS Feeds
$route['ics/individual/(:num)'] = 'ics/individual/$1';
$route['ics/dayoffs/(:num)'] = 'ics/dayoffs/$1';
$route['ics/dayoffs/(:num)/(:num)'] = 'ics/dayoffs/$1/$2';
$route['ics/ical/(:num)'] = 'ics/ical/$1';

//Session management
Expand Down
1 change: 0 additions & 1 deletion application/controllers/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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('calendar', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/contracts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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('contract', $this->language);
$this->load->model('contracts_model');
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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('database', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/entitleddays.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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('entitleddays', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/extra.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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('extra', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/hr.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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('hr', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
53 changes: 48 additions & 5 deletions application/controllers/ics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -77,6 +92,7 @@ public function dayoffs($id) {
]);
}
echo $vcalendar->serialize();
date_default_timezone_set($tzold);
}
}
}
Expand All @@ -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']);
Expand All @@ -115,6 +144,7 @@ public function individual($id) {
]);
}
echo $vcalendar->serialize();
date_default_timezone_set($tzold);
}
}
}
Expand All @@ -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', [
Expand Down
1 change: 0 additions & 1 deletion application/controllers/leaves.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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('leaves', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/leavetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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('leavetypes', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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('organization', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/overtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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('overtime', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/positions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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('positions', $this->language);
}

Expand Down
1 change: 0 additions & 1 deletion application/controllers/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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('reports', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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('requests', $this->language);
$this->lang->load('global', $this->language);
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct() {
$this->session->set_userdata('language', $this->config->item('language'));
$this->session->set_userdata('language_code', $this->polyglot->language2code($this->config->item('language')));
}
$this->load->helper('language');
$this->lang->load('session', $this->session->userdata('language'));
}

Expand Down
4 changes: 3 additions & 1 deletion application/controllers/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions application/language/english/users_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
$lang['users_view_field_position'] = 'Position';
$lang['users_view_field_entity'] = 'Entity';
$lang['users_view_field_hired'] = 'Date hired/started';
$lang['users_view_field_timezone'] = 'Timezone';
$lang['users_view_field_ldap_path'] = 'LDAP Path';
$lang['users_view_field_identifier'] = 'Internal/Company Identifier';
$lang['users_view_field_language'] = 'Language';
$lang['users_view_button_edit'] = 'Edit';
Expand Down Expand Up @@ -89,6 +91,7 @@
$lang['users_edit_field_position'] = 'Position';
$lang['users_edit_field_entity'] = 'Entity';
$lang['users_edit_field_hired'] = 'Date hired/started';
$lang['users_edit_field_timezone'] = 'Timezone';
$lang['users_edit_field_ldap_path'] = 'LDAP Path';
$lang['users_edit_field_identifier'] = 'Internal/Company Identifier';
$lang['users_edit_field_language'] = 'Language';
Expand Down Expand Up @@ -123,6 +126,7 @@
$lang['users_create_field_position'] = 'Position';
$lang['users_create_field_entity'] = 'Entity';
$lang['users_create_field_hired'] = 'Date hired/started';
$lang['users_create_field_timezone'] = 'Timezone';
$lang['users_create_field_ldap_path'] = 'LDAP Path';
$lang['users_create_field_identifier'] = 'Internal/Company Identifier';
$lang['users_create_field_language'] = 'Language';
Expand Down
4 changes: 4 additions & 0 deletions application/language/french/users_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
$lang['users_view_field_position'] = 'Poste';
$lang['users_view_field_entity'] = 'Entité';
$lang['users_view_field_hired'] = 'Date d\'embauche/démarrage';
$lang['users_view_field_timezone'] = 'Fuseau horaire';
$lang['users_view_field_ldap_path'] = 'Chemin LDAP';
$lang['users_view_field_identifier'] = 'Identifiant interne';
$lang['users_view_field_language'] = 'Langage';
$lang['users_view_button_edit'] = 'Modifier';
Expand Down Expand Up @@ -88,6 +90,7 @@
$lang['users_edit_field_position'] = 'Poste';
$lang['users_edit_field_entity'] = 'Entité';
$lang['users_edit_field_hired'] = 'Date d\'embauche/démarrage';
$lang['users_edit_field_timezone'] = 'Fuseau horaire';
$lang['users_edit_field_ldap_path'] = 'Chemin LDAP';
$lang['users_edit_field_identifier'] = 'Identifiant interne';
$lang['users_edit_field_language'] = 'Langage';
Expand Down Expand Up @@ -123,6 +126,7 @@
$lang['users_create_field_position'] = 'Poste';
$lang['users_create_field_entity'] = 'Entité';
$lang['users_create_field_hired'] = 'Date d\'embauche/démarrage';
$lang['users_create_field_timezone'] = 'Fuseau horaire';
$lang['users_create_field_ldap_path'] = 'Chemin LDAP';
$lang['users_create_field_identifier'] = 'Identifiant interne';
$lang['users_create_field_language'] = 'Langage';
Expand Down
4 changes: 4 additions & 0 deletions application/language/khmer/users_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
$lang['users_view_field_position'] = 'តំណែង';
$lang['users_view_field_entity'] = 'អង្គភាព';
$lang['users_view_field_hired'] = 'កាលបរិច្ឆេទជួល / បានចាប់ផ្តើ';
$lang['users_view_field_timezone'] = 'Timezone';
$lang['users_view_field_ldap_path'] = 'LDAP Path';
$lang['users_view_field_identifier'] = 'អ្នកកំណត់អត្តសញ្ញាណ';
$lang['users_view_field_language'] = 'ភាសា';
$lang['users_view_button_edit'] = 'កែសម្រួល';
Expand Down Expand Up @@ -89,6 +91,7 @@
$lang['users_edit_field_position'] = 'តំណែង';
$lang['users_edit_field_entity'] = 'អង្គភាព';
$lang['users_edit_field_hired'] = 'កាលបរិច្ឆេទជួល / បានចាប់ផ្តើ';
$lang['users_edit_field_timezone'] = 'Timezone';
$lang['users_edit_field_ldap_path'] = 'LDAP Path';
$lang['users_edit_field_identifier'] = 'អ្នកកំណត់អត្តសញ្ញាណ';
$lang['users_edit_field_language'] = 'ភាសា';
Expand Down Expand Up @@ -123,6 +126,7 @@
$lang['users_create_field_position'] = 'តំណែង';
$lang['users_create_field_entity'] = 'អង្គភាព';
$lang['users_create_field_hired'] = 'កាលបរិច្ឆេទជួល / បានចាប់ផ្តើ';
$lang['users_create_field_timezone'] = 'Timezone';
$lang['users_create_field_ldap_path'] = 'LDAP Path';
$lang['users_create_field_identifier'] = 'អ្នកកំណត់អត្តសញ្ញាណ';
$lang['users_create_field_language'] = 'ភាសា';
Expand Down
3 changes: 0 additions & 3 deletions application/models/dayoffs_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 7d037fe

Please sign in to comment.