function create_year_view(&$calendar) { $year = $calendar->view; $out = "<table class=\"steelgroup0\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; $out .= "<tr><td align=\"center\" width=\"10%\">\n"; $out .= '<a href="' . URLHelper::getLink('', array('', 'cmd' => 'showyear', 'atime' => $year->getStart() - 1)) . '">'; $out .= Icon::create('arr_1left', 'clickable', ['title' => _("zurück")])->asImg(). " </a></td>\n"; $out .= "<td class=\"calhead\" align=\"center\" width=\"80%\">\n"; $out .= "<font size=\"+2\"><b>" . $year->getYear() . "</b></font></td>\n"; $out .= '<td align="center" width="10%"><a href="' . URLHelper::getLink('', array('', 'cmd' => 'showyear', 'atime' => $year->getEnd() + 1)) . '">'; $out .= Icon::create('arr_1right', 'clickable', ['title' => _("vor")])->asImg() . ' </a></td>'; $out .= "</tr>\n"; $out .= "<tr><td colspan=\"3\" class=\"blank\">"; $out .= '<table class="steelgroup0" width="100%" border="0" '; $out .= "cellpadding=\"2\" cellspacing=\"1\">\n"; $days_per_month = array(31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (date('L', $year->getStart())) { $days_per_month[2]++; } $out .= '<tr>'; for ($i = 1; $i < 13; $i++) { $ts_month += ( $days_per_month[$i] - 1) * 86400; $out .= '<td align="center" width="8%">'; $out .= '<a class="calhead" href="' . URLHelper::getLink('', array('cmd' => 'showmonth', 'atime' => $year->getStart() + $ts_month)) . '">'; $out .= '<font size="-1"><b>'; $out .= htmlReady(strftime("%B", $ts_month)); $out .= "</b></font></a></td>\n"; } $out .= "</tr>\n"; $now = date('Ymd'); for ($i = 1; $i < 32; $i++) { $out .= '<tr>'; for ($month = 1; $month < 13; $month++) { $aday = mktime(12, 0, 0, $month, $i, $year->getYear()); if ($i <= $days_per_month[$month]) { $wday = date('w', $aday); // emphesize current day if (date('Ymd', $aday) == $now) $day_class = ' class="celltoday"'; else if ($wday == 0 || $wday == 6) $day_class = ' class="weekend"'; else $day_class = ' class="weekday"'; if ($month == 1) $out .= "<td$day_class height=\"25\">"; else $out .= "<td$day_class>"; $event_count_txt = javascript_hover_year($calendar, $aday); if ($event_count_txt != '') { $out .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; $out .= "<td$day_class>"; } $weekday = '<font size="2">' . wday($aday, 'SHORT') . '</font>'; $hday = holiday($aday); switch ($hday['col']) { case "1": if (date("w", $aday) == "0") { $out .= '<a style="font-weight:bold;" class="sday" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; $count++; } else { $out .= '<a style="font-weight:bold;" class="day" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; } break; case "2": case "3": if (date("w", $aday) == "0") { $out .= '<a style="font-weight:bold;" class="sday" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; $count++; } else { $out .= '<a style="font-weight:bold;" class="hday" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; } break; default: if (date("w", $aday) == "0") { $out .= '<a style="font-weight:bold;" class="sday" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; $count++; } else { $out .= '<a style="font-weight:bold;" class="day" href="' . URLHelper::getLink('', array('cmd' => 'showday', 'atime' => $aday)) . '">'; $out .= "$i</a> " . $weekday; } } if ($event_count_txt != '') { $out .= "</td><td$day_class align=\"right\">"; $out .= Icon::create('date', 'clickable', ['title' => $event_count_txt])->asImg(16, ["alt" => $event_count_txt]); $out .= "</td></tr></table>\n"; } $out .= '</td>'; } else $out .= '<td class="weekday"> </td>'; } $out .= "</tr>\n"; } $out .= '<tr>'; $ts_month = 0; for ($i = 1; $i < 13; $i++) { $ts_month += ( $days_per_month[$i] - 1) * 86400; $out .= "<td align=\"center\" width=\"8%%\">"; $out .= '<a class="calhead" href="' . URLHelper::getLink('', array('cmd' => 'showmonth', 'atime' => $year->getStart() + $ts_month)) . '">'; $out .= "<font size=\"-1\"><b>"; $out .= htmlReady(strftime("%B", $ts_month)); $out .= "</b></font></a></td>\n"; } $out .= "</tr></table>\n</td></tr></table>\n"; return $out; }
?> > <? endif; ?> <? $tooltip = $this->render_partial('calendar/group/_tooltip_year', array('aday' => $aday, 'calendars' => $calendars, 'count_lists' => $count_lists)) ?> <? if (trim($tooltip)) : ?> <table style="width: 100%;"> <tr> <td<?php echo $day_class; ?> > <? endif; ?> <? $weekday = strftime('%a', $aday); ?> <? $hday = holiday($aday); ?> <? if ($hday['col'] == '1') : ?> <? if (date('w', $aday) == '0') : ?> <a style="font-weight:bold;" class="sday" href="<?php echo $controller->url_for('calendar/group/day', array('atime' => $aday)); ?> "><?php echo $i; ?> </a> <?php echo $weekday; ?> <? $count++; ?> <? else : ?> <a style="font-weight:bold;" class="day" href="<?php echo $controller->url_for('calendar/group/day', array('atime' => $aday));
public function reports() { // Calculate the Holidays and update the database $clerks = $this->reports_model->get_clerks('clerk_id, start_date, end_date', 'clerk'); // we calculate the tax - holiday years $this_year = get_year(1); $last_year = get_year(0); foreach ($clerks as $clerk => $value) { $clerk_status[$value['clerk_id']] = $this->reports_model->get_status('clerks_list_rota.date, clerk_status.status, clerks_list_rota.status_id, clerk.clerk_name, clerk.secret_no', $this_year['start'], $this_year['end'], $value['clerk_id']); $clerk_status_last[$value['clerk_id']] = $this->reports_model->get_status('clerks_list_rota.date, clerk_status.status, clerks_list_rota.status_id, clerk.clerk_name, clerk.secret_no', $last_year['start'], $last_year['end'], $value['clerk_id']); } // we create 2 variables with the holiday calculations $holidays = holiday($clerks, $clerk_status, $this_year); $holidays_last = holiday($clerks, $clerk_status_last, $last_year); // we calculate the sick days $sick_days = sick($clerk_status); // we calculate the dayly overtimes $dayly_overtime = overtime($clerk_status); // query the database to get the data for the form $clerk = $this->load_file->get_data_extend('clerk', 'clerk_id, clerk_name'); $companies = $this->load_file->get_data_extend('companies', 'company'); $clerk_list[0] = 'Select Clerk'; // prepare the tables for the form foreach ($clerk as $row) { $clerk_list[$row['clerk_id']] = $row['clerk_name']; } foreach ($companies as $row) { $comp_list[] = $row['company']; } //check validation for user input in sign up form $this->form_validation->set_rules('rep_type', 'Report Type', 'required|xss_clean'); $this->form_validation->set_rules('date_from', 'Date From', 'trim|required|xss_clean'); $this->form_validation->set_rules('date_to', 'Date To', 'trim|xss_clean'); $this->form_validation->set_rules('comp', 'Company', 'trim|xss_clean'); $this->form_validation->set_rules('clerk', 'Clerk', 'trim|xss_clean'); // We get the POST data $post_data = array('rep_type' => $this->input->post('rep_type'), 'date_from' => $this->input->post('date_from'), 'date_to' => $this->input->post('date_to'), 'comp' => $this->input->post('comp'), 'clerk' => $this->input->post('clerk')); // Do a check on the dates submited $date_from = date('z', strtotime($post_data['date_from'])); $date_to = date('z', strtotime($post_data['date_to'])); if ($date_to == 0 && $date_from <= date('z')) { $post_data['date_to'] = date('Y-m-d'); $error = FALSE; $msg = ''; } elseif ($date_to < $date_from) { $error = TRUE; $msg = '<h4 class="error_msg">You canot have earlier date than the starting date!</h4>'; } else { $error = FALSE; $msg = ''; } // prepere the data to sent to the reports page $data = array('name' => 'Admin', 'message_display' => $msg, 'clerk_list' => $clerk_list, 'comp_list' => $comp_list); if ($this->form_validation->run() == FALSE || $error == TRUE) { // Load the view as a result and check if the user is logged in for resubmission if ($this->login_database->is_logged()) { $this->load->view('reports_view', $data); } else { $this->load->view('login_form', $data); } } else { // Validation successful and prepare the data for the result unset($clerk_list); // clear out this var, we need it later unset($clerks); if ($post_data['comp'] != 0) { $company = $post_data['comp']; } else { $company = FALSE; } if ($post_data['clerk'] != 0) { $clerk = $post_data['clerk']; } else { $clerk = FALSE; } // We query the database $clerk_data = $this->reports_model->get_weekly('clerks_check.clerk_id', $post_data['date_from'], $post_data['date_to'], $clerk, $company); if ($clerk_data != NULL) { foreach ($clerk_data as $key => $value) { $clerks[] = $clerk_data[$key]['clerk_id']; } $clerks = array_unique($clerks); foreach ($clerks as $clerk => $value) { $clerk_details[$value] = $this->reports_model->get_weekly('clerks_check.clerk_id, clerk.clerk_name, clerk.secret_no, clerks_check.status, clerks_check.date, clerks_check.time, clerks_check.sign_time, clerks_check.id, clerks_check.approval', $post_data['date_from'], $post_data['date_to'], $clerks[$clerk]); } switch ($post_data['rep_type']) { case 0: // Weekly report page $clerk_list = overtime_deductions($clerk_details, FALSE); // prepere the data to sent to the reports page $data = array('name' => 'Admin', 'message_display' => $msg, 'clerk_list' => $clerk_list, 'holidays' => $holidays, 'holidays_last' => $holidays_last, 'sick_days' => $sick_days, 'dayly_overtime' => $dayly_overtime); // Load the view as a result and check if the user is logged in if ($this->login_database->is_logged()) { $this->load->view('weekly', $data); } else { $this->load->view('login_form', $data); } break; case 1: // Monthly Simple report page $clerk_list = overtime_deductions($clerk_details, TRUE); // prepere the data to sent to the reports page $data = array('name' => 'Admin', 'message_display' => $msg, 'clerk_list' => $clerk_list, 'holidays' => $holidays, 'holidays_last' => $holidays_last, 'sick_days' => $sick_days, 'dayly_overtime' => $dayly_overtime); // Load the view as a result and check if the user is logged in if ($this->login_database->is_logged()) { $this->load->view('monthly_simple', $data); } else { $this->load->view('login_form', $data); } break; case 2: // Monthly Analitic report page $clerk_list = overtime_deductions($clerk_details, TRUE); // prepere the data to sent to the reports page $data = array('name' => 'Admin', 'message_display' => $msg, 'clerk_list' => $clerk_list, 'holidays' => $holidays, 'holidays_last' => $holidays_last, 'sick_days' => $sick_days, 'dayly_overtime' => $dayly_overtime); // Load the view as a result and check if the user is logged in if ($this->login_database->is_logged()) { $this->load->view('monthly', $data); } else { $this->load->view('login_form', $data); } break; default: break; } } else { // prepere the data to sent to the reports page $data['message_display'] = '<h4 class="error_msg">No Data Available!</h4>'; // Load the view as a result and check if the user is logged in if ($this->login_database->is_logged()) { $this->load->view('reports_view', $data); } else { $this->load->view('login_form', $data); } } } }
</tr> </thead> <tbody> <? for ($i = $first_day, $j = 0; $i <= $last_day; $i += 86400, $j++) : ?> <? $aday = date('j', $i); ?> <? $class_day = ''; if (($aday - $j - 1 > 0) || ($j - $aday > 6)) { $class_cell = 'lightmonth'; $class_day = 'light'; } elseif (date('Ymd', $i) == date('Ymd')) { $class_cell = 'celltoday'; } else { $class_cell = 'month'; } $hday = holiday($i); if ($j % 7 == 0) { ?><tr><? } ?> <td class="<?php echo $class_cell; ?> "> <? if (($j + 1) % 7 == 0) : ?> <a class="<?php echo $class_day . 'sday'; ?> " href="<?php echo $controller->url_for('calendar/single/day', array('atime' => $i));
function isHoliday() { foreach (HolidayData::GetAllHolidaysArray() as $val) { if ($val['beginn'] <= $this->date && $val['ende'] >= $this->end_time) { $name = $val['name']; } } if (!$name) { $holy_type = holiday($this->date); $name = $holy_type['name']; } if ($name) { return $name; } else { return false; } }
?> > <?php echo Icon::create('arr_1left', 'clickable')->asImg(16, ["style" => 'vertical-align: text-top;']); ?> <?php echo strftime(_('%x'), strtotime('-1 day', $calendar->getStart())); ?> </span> </a> </div> <div class="calhead" style="width: 50%; display: inline-block;"> <?php echo strftime('%A, %e. %B %Y', $atime); ?> <div style="text-align: center; font-size: 12pt; color: #bbb; height: auto; overflow: visible; font-weight: bold;"><? $hd = holiday($atime); echo $holiday['name']; ?></div> </div> <div style="text-align: right; width: 20%; display: inline-block; white-space: nowrap;"> <a href="<?php echo $controller->url_for('calendar/single/day', array('atime' => strtotime('+1 day', $atime))); ?> "> <span style="vertical-align: middle;" <?php echo tooltip(_('einen Tag vor')); ?> > <?php echo strftime(_('%x'), strtotime('+1 day', $calendar->getStart())); ?> <?php echo Icon::create('arr_1right', 'clickable')->asImg(16, ["style" => 'vertical-align: text-top;']);
/** * generate single date objects for one cycle and one semester, existing dates are merged in * * @param string cycle id * @param int timestamp of semester start * @param int timestamp of semester end * @param int alternative timestamp to start from * @param int correction calculation, if the semester does not start on monday (number of days?) * @return array returns an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates */ function getVirtualSingleDatesForSemester($metadate_id, $sem_begin, $sem_end, $startAfterTimeStamp, $corr) { $dates = array(); $dates_to_delete = array(); // loads the singledates of the by metadate_id denoted regular time-entry into the object $this->readSingleDates($metadate_id); // The currently existing singledates for the by metadate_id denoted regular time-entry $existingSingleDates =& $this->cycles[$metadate_id]->getSingleDates(); $start_woche = $this->cycles[$metadate_id]->week_offset; $end_woche = $this->cycles[$metadate_id]->end_offset; $turnus = $this->cycles[$metadate_id]->cycle; // HolidayData is used to decide wether a date is during a holiday an should be created as an ex_termin. // Additionally, it is used to show which type of holiday we've got. $holiday = new HolidayData(); // This variable is used to check if a given singledate shall be created in a bi-weekly seminar. if ($start_woche == -1) { $start_woche = 0; } $week = 0; // get the first presence date after sem_begin $day_of_week = date('l', strtotime('Sunday + ' . $this->cycles[$metadate_id]->day . ' days')); $stamp = strtotime('this ' . $day_of_week, $sem_begin); if ($end_woche) { $end_woche -= 1; if ($end_woche < 0) { $end_woche = 0; } $sem_end = strtotime(sprintf('+%u weeks %s', $end_woche, strftime('%d.%m.%Y', $stamp))); } $start_time = mktime((int) $this->cycles[$metadate_id]->start_stunde, (int) $this->cycles[$metadate_id]->start_minute, 0, date("n", $stamp), date("j", $stamp), date("Y", $stamp)); // Year $end_time = mktime((int) $this->cycles[$metadate_id]->end_stunde, (int) $this->cycles[$metadate_id]->end_minute, 0, date("n", $stamp), date("j", $stamp), date("Y", $stamp)); // Year // loop through all possible singledates for this regular time-entry do { // if dateExists is true, the singledate will not be created. Default is of course to create the singledate $dateExists = false; // do not create singledates, if they are earlier then the chosen start-week if ($start_woche > $week) { $dateExists = true; } // bi-weekly check if ($turnus > 0 && $week - $start_woche > 0 && ($week - $start_woche) % ($turnus + 1)) { $dateExists = true; } /* * We only create dates, which do not already exist, so we do not overwrite existing dates. * * Additionally, we delete singledates which are not needed any more (bi-weekly, changed start-week, etc.) */ foreach ($existingSingleDates as $key => $val) { // take only the singledate into account, that maps the current timepoint if ($start_time > $startAfterTimeStamp && $val->date == $start_time && $val->end_time == $end_time) { // bi-weekly check if ($turnus > 0 && $week - $start_woche > 0 && ($week - $start_woche) % ($turnus + 1)) { $dates_to_delete[$key] = $val; unset($existingSingleDates[$key]); } // delete singledates if they are earlier than the chosen start-week if ($start_woche > $week) { $dates_to_delete[$key] = $val; unset($existingSingleDates[$key]); } $dateExists = true; if (isset($existingSingleDates[$key])) { $dates[$key] = $val; } } } if ($start_time < $startAfterTimeStamp) { $dateExists = true; } if (!$dateExists) { $termin = new SingleDate(array('seminar_id' => $this->seminar_id)); $all_holiday = $holiday->getAllHolidays(); // fetch all Holidays foreach ($all_holiday as $val2) { if ($val2["beginn"] <= $start_time && $start_time <= $val2["ende"]) { $termin->setExTermin(true); } } //check for calculatable holidays if (!$termin->isExTermin()) { $holy_type = holiday($start_time); if ($holy_type["col"] == 3) { $termin->setExTermin(true); } } // fill the singleDate-Object with data $termin->setMetaDateID($metadate_id); $termin->setTime($start_time, $end_time); $termin->setDateType(1); //best guess $dates[$termin->getTerminID()] = $termin; } //inc the week, create timestamps for the next singledate $start_time = strtotime('+1 week', $start_time); $end_time = strtotime('+1 week', $end_time); $week++; } while ($end_time < $sem_end); foreach ($existingSingleDates as $id => $val) { foreach (array_keys($dates) as $date) { if ($date != $id) { $dates_to_delete[$id] = $val; unset($existingSingleDates[$id]); } } } return array('dates' => $dates, 'dates_to_delete' => $dates_to_delete); }
/** * Returns if a given date is a holiday. * * @param int $time Timestamp to check * @param bool $check_vacation_only Defines whether to check only vacation * times or against all holidays * @return mixed false if no holiday was found, an array with the name and * the "col" value of the holiday otherwise */ public static function isHoliday($time, $check_vacation_only = true) { // Check all defined vaciation times foreach (SemesterHoliday::getAll() as $val) { if ($val->beginn <= $time && $val->ende >= $time) { return array('name' => $val->name, 'col' => 3); } } // Check all other holidays if (!$check_vacation_only) { return holiday($time); $holiday_entry = holiday($time); } // Nothing found return false; }
<td bgcolor="#CCFFCC" height="20"><b><font color="#003300">S</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">M</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">Tu</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">W</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">Th</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">F</font></b></td> <td bgcolor="#CCFFCC" height="20"><b><font color="#003300">S</font></b></td> </tr> <?php for ($y = 0; $y < $line; $y++) { echo " <tr align=\"center\" bgcolor=\"#FFFFFF\">\n"; for ($x = 0; $x < 7; $x++) { $count = $y * 7 + $x; $day = $count - $w + 1; if ($day >= 1 && $day <= $t) { $h = holiday((int) $year, (int) $month, (int) $day); if ($h[0]) { $bg = "#FF0000"; } else { if ($x == 6) { $bg = blue; } else { $bg = "#666666"; } } // 기본배경색이다. $bc = "white"; $text = $h[1]; if ($text) { $bc = "#DADADA"; }
<?php use mole\helpers\Datetime; function holiday($year, array $include = [], array $exclude = []) { $stamp = strtotime(sprintf('%s-01-01', $year)); $result = []; do { if (date('w', $stamp) == 0 || date('w', $stamp) == 6) { $result[] = date('Y-m-d', $stamp); } $stamp = strtotime('+1 day', $stamp); if ((int) date('Y', $stamp) > 2016) { break; } } while (true); $result = array_merge($result, $include); $result = array_diff($result, $exclude); sort($result); return $result; } $I = new UnitTester($scenario); $I->wantTo('perform actions and see result'); $I->assertTrue(holiday('2016', ['2016-06-12'], ['2016-06-09', '2016-06-10']) == Datetime::holiday('2016', ['2016-06-12'], ['2016-06-09', '2016-06-10']));
</td> <? // weekday and date as title for each column ?> <? for ($i = 0; $i < $week_type; $i++) : ?> <td style="text-align:center; font-weight:bold;"<?php echo $tab_arr[$i]['max_cols'] > 0 ? ' colspan="' . ($tab_arr[$i]['max_cols'] + 1) . '"' : ''; ?> > <a class="calhead" href="<?php echo $controller->url_for('calendar/single/day', array('atime' => $calendars[$i]->getStart())); ?> "> <?php echo strftime('%a', $calendars[$i]->getStart()) . ' ' . date('d', $calendars[$i]->getStart()); ?> </a> <? if ($holiday = holiday($calendars[$i]->getStart())) : ?> <div style="font-size:9pt; color:#bbb; height:auto; overflow:visible; font-weight:bold;"><?php echo $holiday['name']; ?> </div> <? endif ?> </td> <? endfor ?> <td style="text-align: center; white-space: nowrap;" <?php echo $colspan_1; ?> > <? if ($start > 0) : ?> <a href="<?php echo $controller->url_for('calendar/single/week', array('atime' => mktime($start - 1, 0, 0, date('n', $calendars[0]->getStart()), date('j', $calendars[0]->getStart()), date('Y', $calendars[0]->getStart())))); ?>