本文整理汇总了PHP中expires_now函数的典型用法代码示例。如果您正苦于以下问题:PHP expires_now函数的具体用法?PHP expires_now怎么用?PHP expires_now使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expires_now函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: counters
/**
* Display the details of leaves taken/entitled for a given employee
* This page can be displayed only if the connected user is the manager of the employee
* @param string $refTmp Timestamp (reference date)
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function counters($id, $refTmp = NULL)
{
$data = getUserContext($this);
$this->lang->load('datatable', $this->language);
$this->lang->load('entitleddays', $this->language);
$this->lang->load('hr', $this->language);
$this->load->model('users_model');
$employee = $this->users_model->get_users($id);
if ($this->user_id != $employee['manager'] && $this->is_hr == false) {
log_message('error', 'User #' . $this->user_id . ' illegally tried to access to leave counter of employee #' . $id);
$this->session->set_flashdata('msg', lang('requests_summary_flash_msg_forbidden'));
redirect('requests/collaborators');
} else {
$refDate = date("Y-m-d");
if ($refTmp != NULL) {
$refDate = date("Y-m-d", $refTmp);
$data['isDefault'] = 0;
} else {
$data['isDefault'] = 1;
}
$data['refDate'] = $refDate;
$data['summary'] = $this->leaves_model->get_user_leaves_summary($id, FALSE, $refDate);
if (!is_null($data['summary'])) {
$this->load->model('entitleddays_model');
$this->load->model('types_model');
$data['types'] = $this->types_model->get_types();
$this->load->model('users_model');
$data['employee_name'] = $this->users_model->get_label($id);
$user = $this->users_model->get_users($id);
$this->load->model('contracts_model');
$contract = $this->contracts_model->get_contracts($user['contract']);
$data['contract_name'] = $contract['name'];
$data['contract_start'] = $contract['startentdate'];
$data['contract_end'] = $contract['endentdate'];
$data['employee_id'] = $id;
$data['contract_id'] = $user['contract'];
$data['entitleddayscontract'] = $this->entitleddays_model->get_entitleddays_contract($user['contract']);
$data['entitleddaysemployee'] = $this->entitleddays_model->get_entitleddays_employee($id);
expires_now();
$data['title'] = lang('requests_summary_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_leave_balance_collaborators');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('requests/counters', $data);
$this->load->view('templates/footer');
} else {
$this->session->set_flashdata('msg', lang('requests_summary_flash_msg_error'));
redirect('requests/collaborators');
}
}
}
示例2: index
/**
* Display the list of all overtime requests submitted to you
* Status is submitted
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function index($filter = 'requested')
{
$this->auth->check_is_granted('list_overtime');
expires_now();
if ($filter == 'all') {
$showAll = true;
} else {
$showAll = false;
}
$data = getUserContext($this);
$data['filter'] = $filter;
$data['title'] = lang('overtime_index_title');
$data['requests'] = $this->overtime_model->requests($this->user_id, $showAll);
$this->load->model('status_model');
for ($i = 0; $i < count($data['requests']); ++$i) {
$data['requests'][$i]['status_label'] = $this->status_model->get_label($data['requests'][$i]['status']);
}
$data['flash_partial_view'] = $this->load->view('templates/flash', $data, true);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('overtime/index', $data);
$this->load->view('templates/footer');
}
示例3: setsupervisor
/**
* Select the supervisor of an entity of the organization
* takes parameters by GET
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function setsupervisor()
{
expires_now();
header("Content-Type: application/json");
if ($this->auth->is_granted('edit_organization') == FALSE) {
$this->output->set_header("HTTP/1.1 403 Forbidden");
} else {
if ($this->input->get('user', TRUE) == "") {
$id = NULL;
} else {
$id = $this->input->get('user', TRUE);
}
$entity = $this->input->get('entity', TRUE);
echo json_encode($this->organization_model->set_supervisor($id, $entity));
}
}
示例4: validate
/**
* Ajax endpoint. Result varies according to input :
* - difference between the entitled and the taken days
* - try to calculate the duration of the leave
* - try to detect overlapping leave requests
* If the user is linked to a contract, returns end date of the yearly leave period or NULL
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function validate()
{
expires_now();
header("Content-Type: application/json");
$id = $this->input->post('id', TRUE);
$type = $this->input->post('type', TRUE);
$startdate = $this->input->post('startdate', TRUE);
$enddate = $this->input->post('enddate', TRUE);
$startdatetype = $this->input->post('startdatetype', TRUE);
$enddatetype = $this->input->post('enddatetype', TRUE);
$leave_id = $this->input->post('leave_id', TRUE);
$leaveValidator = new stdClass();
if (isset($id) && isset($type)) {
if (isset($startdate) && $startdate !== "") {
$leaveValidator->credit = $this->leaves_model->get_user_leaves_credit($id, $type, $startdate);
} else {
$leaveValidator->credit = $this->leaves_model->get_user_leaves_credit($id, $type);
}
}
if (isset($id) && isset($startdate) && isset($enddate)) {
$leaveValidator->length = $this->leaves_model->length($id, $startdate, $enddate);
if (isset($startdatetype) && isset($enddatetype)) {
if (isset($leave_id)) {
$leaveValidator->overlap = $this->leaves_model->detect_overlapping_leaves($id, $startdate, $enddate, $startdatetype, $enddatetype, $leave_id);
} else {
$leaveValidator->overlap = $this->leaves_model->detect_overlapping_leaves($id, $startdate, $enddate, $startdatetype, $enddatetype);
}
}
}
//Returns end date of the yearly leave period or NULL if the user is not linked to a contract
$this->load->model('contracts_model');
$startentdate = NULL;
$endentdate = NULL;
$hasContract = $this->contracts_model->getBoundaries($id, $startentdate, $endentdate);
$leaveValidator->startentdate = $startentdate;
$leaveValidator->endentdate = $endentdate;
$leaveValidator->hasContract = $hasContract;
echo json_encode($leaveValidator);
}
示例5: export_presence
/**
* Action: export the presence details for a given employee
* @param string $source page calling the report (employees, collaborators)
* @param int $id employee id
* @param int $month Month number or 0 for last month (default)
* @param int $year Year number or 0 for current year (default)
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function export_presence($source, $id, $month = 0, $year = 0)
{
if ($source == 'collaborators') {
$this->auth->check_is_granted('list_collaborators');
}
if ($source == 'employees') {
$this->auth->check_is_granted('list_employees');
}
setUserContext($this);
expires_now();
$this->lang->load('calendar', $this->language);
$this->load->model('leaves_model');
$this->load->model('users_model');
$this->load->model('dayoffs_model');
$this->load->model('contracts_model');
$this->load->library('excel');
//Details about the employee
$employee = $this->users_model->get_users($id);
if ($this->user_id != $employee['manager'] && $this->is_hr === false) {
log_message('error', 'User #' . $this->user_id . ' illegally tried to access to hr/presence #' . $id);
$this->session->set_flashdata('msg', sprintf(lang('global_msg_error_forbidden'), 'hr/presence'));
redirect('leaves');
}
$employee_name = $employee['firstname'] . ' ' . $employee['lastname'];
$contract = $this->contracts_model->get_contracts($employee['contract']);
if (!empty($contract)) {
$contract_name = $contract['name'];
} else {
$contract_name = '';
}
//Compute facts about dates and the selected month
if ($month == 0) {
$month = date('m', strtotime('last month'));
}
if ($year == 0) {
$year = date('Y', strtotime('last month'));
}
$total_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$start = sprintf('%d-%02d-01', $year, $month);
$lastDay = date("t", strtotime($start));
//last day of selected month
$end = sprintf('%d-%02d-%02d', $year, $month, $lastDay);
//Number of non working days during the selected month
$non_working_days = $this->dayoffs_model->sumdayoffs($employee['contract'], $start, $end);
$opened_days = $total_days - $non_working_days;
$month_name = lang(date('F', strtotime($start)));
//tabular view of the leaves
$linear = $this->leaves_model->linear($id, $month, $year, FALSE, FALSE, TRUE, FALSE);
$leave_duration = $this->leaves_model->monthly_leaves_duration($linear);
$work_duration = $opened_days - $leave_duration;
$leaves_detail = $this->leaves_model->monthly_leaves_by_type($linear);
//Leave balance of the employee
$summary = $this->leaves_model->get_user_leaves_summary($id, FALSE, $end);
//Print the header with the facts of the presence report
$sheet = $this->excel->setActiveSheetIndex(0);
$sheet->setTitle(mb_strimwidth(lang('hr_presence_title'), 0, 28, "..."));
//Maximum 31 characters allowed in sheet title.
$sheet->setCellValue('A1', lang('hr_presence_employee'));
$sheet->setCellValue('A2', lang('hr_presence_month'));
$sheet->setCellValue('A3', lang('hr_presence_days'));
$sheet->setCellValue('A4', lang('hr_presence_contract'));
$sheet->setCellValue('A5', lang('hr_presence_working_days'));
$sheet->setCellValue('A6', lang('hr_presence_non_working_days'));
$sheet->setCellValue('A7', lang('hr_presence_work_duration'));
$sheet->setCellValue('A8', lang('hr_presence_leave_duration'));
$sheet->getStyle('A1:A8')->getFont()->setBold(true);
$sheet->setCellValue('B1', $employee_name);
$sheet->setCellValue('B2', $month_name);
$sheet->setCellValue('B3', $total_days);
$sheet->setCellValue('B4', $contract_name);
$sheet->setCellValue('B5', $opened_days);
$sheet->setCellValue('B6', $non_working_days);
$sheet->setCellValue('B7', $work_duration);
$sheet->setCellValue('B8', $leave_duration);
if (count($leaves_detail) > 0) {
$line = 9;
foreach ($leaves_detail as $leaves_type_name => $leaves_type_sum) {
$sheet->setCellValue('A' . $line, $leaves_type_name);
$sheet->setCellValue('B' . $line, $leaves_type_sum);
$sheet->getStyle('A' . $line)->getAlignment()->setIndent(2);
$line++;
}
}
//Print two lines : the short name of all days for the selected month (horizontally aligned)
$start = $year . '-' . $month . '-' . '1';
//first date of selected month
$lastDay = date("t", strtotime($start));
//last day of selected month
for ($ii = 1; $ii <= $lastDay; $ii++) {
$dayNum = date("N", strtotime($year . '-' . $month . '-' . $ii));
$col = $this->excel->column_name(3 + $ii);
//Print day number
//.........这里部分代码省略.........
示例6: year_export
/**
* Export the yearly calendar into Excel. The presentation differs a bit according to the limitation of Excel
* We'll get one line for the morning and one line for the afternoon
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function year_export($employee = 0, $year = 0)
{
setUserContext($this);
expires_now();
$this->lang->load('calendar', $this->language);
$this->auth->check_is_granted('organization_calendar');
if ($year == 0) {
$year = date("Y");
}
//Either self access, Manager or HR
if ($employee == 0) {
$employee = $this->user_id;
} else {
if (!$this->is_hr) {
if ($this->manager != $this->user_id) {
$employee = $this->user_id;
}
}
}
$this->load->model('users_model');
$employee_name = $this->users_model->get_label($employee);
//Load the leaves for all the months of the selected year
$this->load->model('leaves_model');
$months = array(lang('January') => $this->leaves_model->linear($employee, 1, $year, TRUE, TRUE, TRUE, TRUE), lang('February') => $this->leaves_model->linear($employee, 2, $year, TRUE, TRUE, TRUE, TRUE), lang('March') => $this->leaves_model->linear($employee, 3, $year, TRUE, TRUE, TRUE, TRUE), lang('April') => $this->leaves_model->linear($employee, 4, $year, TRUE, TRUE, TRUE, TRUE), lang('May') => $this->leaves_model->linear($employee, 5, $year, TRUE, TRUE, TRUE, TRUE), lang('June') => $this->leaves_model->linear($employee, 6, $year, TRUE, TRUE, TRUE, TRUE), lang('July') => $this->leaves_model->linear($employee, 7, $year, TRUE, TRUE, TRUE, TRUE), lang('August') => $this->leaves_model->linear($employee, 8, $year, TRUE, TRUE, TRUE, TRUE), lang('September') => $this->leaves_model->linear($employee, 9, $year, TRUE, TRUE, TRUE, TRUE), lang('October') => $this->leaves_model->linear($employee, 10, $year, TRUE, TRUE, TRUE, TRUE), lang('November') => $this->leaves_model->linear($employee, 11, $year, TRUE, TRUE, TRUE, TRUE), lang('December') => $this->leaves_model->linear($employee, 12, $year, TRUE, TRUE, TRUE, TRUE));
$this->load->library('excel');
$sheet = $this->excel->setActiveSheetIndex(0);
//Print the header with the values of the export parameters
$sheet->setTitle(mb_strimwidth(lang('calendar_year_title'), 0, 28, "..."));
//Maximum 31 characters allowed in sheet title.
$sheet->setCellValue('A1', lang('calendar_year_title') . ' ' . $year . ' (' . $employee_name . ') ');
$sheet->getStyle('A1')->getFont()->setBold(true);
$sheet->mergeCells('A1:C1');
//Print a line with all possible day numbers (1 to 31)
for ($ii = 1; $ii <= 31; $ii++) {
$col = $this->excel->column_name(3 + $ii);
$sheet->setCellValue($col . '3', $ii);
}
//Box around the lines for each employee
$styleBox = array('borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
//Box around a day
$dayBox = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'rgb' => '808080'), 'right' => array('style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'rgb' => '808080')));
//To fill at the left of months having less than 31 days
$styleMonthPad = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '00FFFF')));
//Background colors for the calendar according to the type of leave
$styleBgPlanned = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'DDD')));
$styleBgRequested = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F89406')));
$styleBgAccepted = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '468847')));
$styleBgRejected = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'FF0000')));
$styleBgDayOff = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '000000')));
$line = 4;
//Iterate on all employees of the selected entity
foreach ($months as $month_name => $month) {
//Merge the two line containing the name of the month and apply a border around it
$sheet->setCellValue('C' . $line, $month_name);
$sheet->mergeCells('C' . $line . ':C' . ($line + 1));
$col = $this->excel->column_name(34);
$sheet->getStyle('C' . $line . ':' . $col . ($line + 1))->applyFromArray($styleBox);
//Iterate on all days of the selected month
$dayNum = 0;
foreach ($month->days as $day) {
$dayNum++;
$col = $this->excel->column_name(3 + $dayNum);
$overlapping = FALSE;
if (strstr($day->display, ';')) {
//Two statuses in the cell
$periods = explode(";", $day->display);
$statuses = explode(";", $day->status);
$types = explode(";", $day->type);
//0 - Working day _
//1 - All day []
//2 - Morning |\
//3 - Afternoon /|
//4 - All Day Off []
//5 - Morning Day Off |\
//6 - Afternoon Day Off /|
$sheet->getComment($col . $line)->getText()->createTextRun($types[0]);
$sheet->getComment($col . ($line + 1))->getText()->createTextRun($types[1]);
switch (intval($statuses[0])) {
case 1:
$sheet->getStyle($col . $line)->applyFromArray($styleBgPlanned);
break;
// Planned
// Planned
case 2:
$sheet->getStyle($col . $line)->applyFromArray($styleBgRequested);
break;
// Requested
// Requested
case 3:
$sheet->getStyle($col . $line)->applyFromArray($styleBgAccepted);
break;
// Accepted
// Accepted
case 4:
$sheet->getStyle($col . $line)->applyFromArray($styleBgRejected);
//.........这里部分代码省略.........
示例7: export
/**
* Action: export the list of all users into an Excel file
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function export()
{
$this->auth->check_is_granted('export_user');
expires_now();
$this->load->library('excel');
$sheet = $this->excel->setActiveSheetIndex(0);
$sheet->setTitle(lang('users_export_title'));
$sheet->setCellValue('A1', lang('users_export_thead_id'));
$sheet->setCellValue('B1', lang('users_export_thead_firstname'));
$sheet->setCellValue('C1', lang('users_export_thead_lastname'));
$sheet->setCellValue('D1', lang('users_export_thead_email'));
$sheet->setCellValue('E1', lang('users_export_thead_manager'));
$sheet->getStyle('A1:E1')->getFont()->setBold(true);
$sheet->getStyle('A1:E1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$users = $this->users_model->get_users();
$line = 2;
foreach ($users as $user) {
$sheet->setCellValue('A' . $line, $user['id']);
$sheet->setCellValue('B' . $line, $user['firstname']);
$sheet->setCellValue('C' . $line, $user['lastname']);
$sheet->setCellValue('D' . $line, $user['email']);
$sheet->setCellValue('E' . $line, $user['manager']);
$line++;
}
//Autofit
foreach (range('A', 'E') as $colD) {
$sheet->getColumnDimension($colD)->setAutoSize(TRUE);
}
$filename = 'users.xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
示例8: export
/**
* Action: export the list of all extra times into an Excel file
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function export()
{
expires_now();
$this->load->library('excel');
$sheet = $this->excel->setActiveSheetIndex(0);
$sheet->setTitle(lang('extra_export_title'));
$sheet->setCellValue('A1', lang('extra_export_thead_id'));
$sheet->setCellValue('B1', lang('extra_export_thead_date'));
$sheet->setCellValue('C1', lang('extra_export_thead_duration'));
$sheet->setCellValue('D1', lang('extra_export_thead_cause'));
$sheet->setCellValue('E1', lang('extra_export_thead_status'));
$sheet->getStyle('A1:E1')->getFont()->setBold(true);
$sheet->getStyle('A1:E1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$extras = $this->overtime_model->get_user_extras($this->user_id);
$this->load->model('status_model');
$line = 2;
foreach ($extras as $extra) {
$date = new DateTime($extra['date']);
$startdate = $date->format(lang('global_date_format'));
$sheet->setCellValue('A' . $line, $extra['id']);
$sheet->setCellValue('B' . $line, $startdate);
$sheet->setCellValue('C' . $line, $extra['duration']);
$sheet->setCellValue('D' . $line, $extra['cause']);
$sheet->setCellValue('E' . $line, lang($this->status_model->get_label($extra['status'])));
$line++;
}
//Autofit
foreach (range('A', 'E') as $colD) {
$sheet->getColumnDimension($colD)->setAutoSize(TRUE);
}
$filename = 'extra.xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
示例9: forgetpassword
/**
* Send the password by e-mail to a user requesting it
*/
public function forgetpassword()
{
expires_now();
$this->output->set_content_type('text/plain');
$login = $this->input->post('login');
$this->load->model('users_model');
$user = $this->users_model->getUserByLogin($login);
if (is_null($user)) {
echo "UNKNOWN";
} else {
//Send an email to the user with its login information
$this->load->library('email');
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$usr_lang = $this->polyglot->code2language($user->language);
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
//Generate random password and store its hash into db
$password = $this->users_model->resetClearPassword($user->id);
//Send an e-mail to the user requesting a new password
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_password_forgotten_title'), 'BaseURL' => base_url(), 'Firstname' => $user->firstname, 'Lastname' => $user->lastname, 'Login' => $user->login, 'Password' => $password);
$message = $this->parser->parse('emails/' . $user->language . '/password_forgotten', $data, TRUE);
$this->email->set_encoding('quoted-printable');
if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
$this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
} else {
$this->email->from('do.not@reply.me', 'LMS');
}
$this->email->to($user->email);
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
$this->email->subject($subject . $lang_mail->line('email_password_forgotten_subject'));
$this->email->message($message);
$this->email->send();
echo "OK";
}
}
示例10: export
/**
* Action: export the list of all positions into an Excel file
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function export()
{
$this->auth->check_is_granted('export_positions');
expires_now();
$this->load->library('excel');
$sheet = $this->excel->setActiveSheetIndex(0);
$sheet->setTitle(mb_strimwidth(lang('positions_export_title'), 0, 28, "..."));
//Maximum 31 characters allowed in sheet title.
$sheet->setCellValue('A1', lang('positions_export_thead_id'));
$sheet->setCellValue('B1', lang('positions_export_thead_name'));
$sheet->setCellValue('C1', lang('positions_export_thead_description'));
$sheet->getStyle('A1:C1')->getFont()->setBold(true);
$sheet->getStyle('A1:C1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$types = $this->positions_model->get_positions();
$line = 2;
foreach ($types as $type) {
$sheet->setCellValue('A' . $line, $type['id']);
$sheet->setCellValue('B' . $line, $type['name']);
$sheet->setCellValue('C' . $line, $type['description']);
$line++;
}
//Autofit
foreach (range('A', 'C') as $colD) {
$sheet->getColumnDimension($colD)->setAutoSize(TRUE);
}
$filename = 'positions.xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
示例11: monthlypresence
/**
* Get the monthly presence stats for a given employee
* @param int $id Unique identifier of an employee
* @param int $month Month number [1-12]
* @param int $year Year number (XXXX)
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function monthlypresence($id, $month, $year)
{
if (!$this->server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
$this->server->getResponse()->send();
} else {
expires_now();
$this->load->model('users_model');
$employee = $this->users_model->get_users($id);
if (!isset($employee['contract'])) {
$this->output->set_header("HTTP/1.1 422 Unprocessable entity");
} else {
$this->load->model('leaves_model');
$this->load->model('dayoffs_model');
$start = sprintf('%d-%02d-01', $year, $month);
$lastDay = date("t", strtotime($start));
//last day of selected month
$end = sprintf('%d-%02d-%02d', $year, $month, $lastDay);
$result = new stdClass();
$linear = $this->leaves_model->linear($id, $month, $year, FALSE, FALSE, TRUE, FALSE);
$result->leaves = $this->leaves_model->monthly_leaves_duration($linear);
$result->dayoffs = $this->dayoffs_model->sumdayoffs($employee['contract'], $start, $end);
$result->total = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$result->start = $start;
$result->end = $end;
$result->open = $result->total - $result->dayoffs;
$result->work = $result->open - $result->leaves;
echo json_encode($result);
}
}
}
示例12: tabular_export
/**
* Export the tabular calendar into Excel. The presentation differs a bit according to the limitation of Excel
* We'll get one line for the morning and one line for the afternoon
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function tabular_export($id = -1, $month = 0, $year = 0, $children = TRUE)
{
expires_now();
//Load the language file (the loaded language depends if it was called from the public view)
if ($this->config->item('public_calendar') == TRUE && !$this->session->userdata('logged_in')) {
$this->load->library('polyglot');
$language = $this->config->item('language');
//$language_code = $this->polyglot->language2code($language);
} else {
setUserContext($this);
$language = $this->language;
}
$this->lang->load('calendar', $language);
$this->lang->load('global', $language);
$this->load->library('excel');
$sheet = $this->excel->setActiveSheetIndex(0);
//Print the header with the values of the export parameters
$sheet->setTitle(mb_strimwidth(lang('calendar_tabular_export_title'), 0, 28, "..."));
//Maximum 31 characters allowed in sheet title.
$sheet->setCellValue('A1', lang('calendar_tabular_export_param_entity'));
$sheet->setCellValue('A2', lang('calendar_tabular_export_param_month'));
$sheet->setCellValue('A3', lang('calendar_tabular_export_param_year'));
$sheet->setCellValue('A4', lang('calendar_tabular_export_param_children'));
$sheet->getStyle('A1:A4')->getFont()->setBold(true);
$this->load->model('organization_model');
$sheet->setCellValue('B1', $this->organization_model->get_label($id));
$sheet->setCellValue('B2', $month);
$sheet->setCellValue('B3', $year);
if ($children == TRUE) {
$sheet->setCellValue('B4', lang('global_true'));
} else {
$sheet->setCellValue('B4', lang('global_false'));
}
//Print two lines : the short name of all days for the selected month (horizontally aligned)
$start = $year . '-' . $month . '-' . '1';
//first date of selected month
$lastDay = date("t", strtotime($start));
//last day of selected month
for ($ii = 1; $ii <= $lastDay; $ii++) {
$dayNum = date("N", strtotime($year . '-' . $month . '-' . $ii));
$col = $this->excel->column_name(3 + $ii);
//Print day number
$sheet->setCellValue($col . '9', $ii);
//Print short name of the day
switch ($dayNum) {
case 1:
$sheet->setCellValue($col . '8', lang('calendar_monday_short'));
break;
case 2:
$sheet->setCellValue($col . '8', lang('calendar_tuesday_short'));
break;
case 3:
$sheet->setCellValue($col . '8', lang('calendar_wednesday_short'));
break;
case 4:
$sheet->setCellValue($col . '8', lang('calendar_thursday_short'));
break;
case 5:
$sheet->setCellValue($col . '8', lang('calendar_friday_short'));
break;
case 6:
$sheet->setCellValue($col . '8', lang('calendar_saturday_short'));
break;
case 7:
$sheet->setCellValue($col . '8', lang('calendar_sunday_short'));
break;
}
}
//Label for employee name
$sheet->setCellValue('C8', lang('calendar_tabular_export_thead_employee'));
$sheet->mergeCells('C8:C9');
//The header is horizontally aligned
$col = $this->excel->column_name(3 + $lastDay);
$sheet->getStyle('C8:' . $col . '9')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//Get the tabular data
$this->load->model('leaves_model');
$tabular = $this->leaves_model->tabular($id, $month, $year, $children);
//Box around the lines for each employee
$styleBox = array('borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
$dayBox = array('borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'rgb' => '808080'), 'right' => array('style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'rgb' => '808080')));
//Background colors for the calendar according to the type of leave
$styleBgPlanned = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'DDD')));
$styleBgRequested = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F89406')));
$styleBgAccepted = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '468847')));
$styleBgRejected = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'FF0000')));
$styleBgDayOff = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '000000')));
$line = 10;
//Iterate on all employees of the selected entity
foreach ($tabular as $employee) {
//Merge the two line containing the name of the employee and apply a border around it
$sheet->setCellValue('C' . $line, $employee->name);
$sheet->mergeCells('C' . $line . ':C' . ($line + 1));
$col = $this->excel->column_name($lastDay + 3);
$sheet->getStyle('C' . $line . ':' . $col . ($line + 1))->applyFromArray($styleBox);
//Iterate on all days of the selected month
//.........这里部分代码省略.........
示例13: ical
/**
* Action : download an iCal event corresponding to a leave request
* @param int leave request id
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function ical($id)
{
expires_now();
header('Content-type: text/calendar; charset=utf-8');
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']));
$vcalendar = new VObject\Component\VCalendar();
$vcalendar->add('VEVENT', array('SUMMARY' => lang('leave'), 'CATEGORIES' => lang('leave'), 'DESCRIPTION' => $leave['cause'], 'DTSTART' => new \DateTime($leave['startdate'], new \DateTimeZone($tzdef)), 'DTEND' => new \DateTime($leave['enddate'], new \DateTimeZone($tzdef)), 'URL' => base_url() . "leaves/" . $id));
echo $vcalendar->serialize();
}
示例14: createleave
/**
* Create a leave request in behalf of an employee
* @param int $id Identifier of the employee
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function createleave($id)
{
$this->auth->check_is_granted('list_employees');
expires_now();
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = lang('hr_leaves_create_title');
$data['form_action'] = 'hr/leaves/create/' . $id;
$data['source'] = 'hr/employees';
$data['employee'] = $id;
$this->form_validation->set_rules('startdate', lang('hr_leaves_create_field_start'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('startdatetype', 'Start Date type', 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('enddate', lang('hr_leaves_create_field_end'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('enddatetype', 'End Date type', 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('duration', lang('hr_leaves_create_field_duration'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('type', lang('hr_leaves_create_field_type'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('cause', lang('hr_leaves_create_field_cause'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('status', lang('hr_leaves_create_field_status'), 'required|xss_clean|strip_tags');
$data['credit'] = 0;
if ($this->form_validation->run() === FALSE) {
$this->load->model('types_model');
$data['types'] = $this->types_model->get_types();
foreach ($data['types'] as $type) {
if ($type['id'] == 0) {
$data['credit'] = $this->leaves_model->get_user_leaves_credit($id, $type['name']);
break;
}
}
$this->load->model('users_model');
$data['name'] = $this->users_model->get_label($id);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('hr/createleave');
$this->load->view('templates/footer');
} else {
$leave_id = $this->leaves_model->set_leaves($id);
$this->session->set_flashdata('msg', lang('hr_leaves_create_flash_msg_success'));
//No mail is sent, because the HR Officer would set the leave status to accepted
redirect('hr/employees');
}
}