events();
foreach ($events as $event) {
$event_date = substr($event['DTSTART'], 0, 8);
$event_month = substr($event['DTSTART'], 0, 6);
if ($event_month >= $this_month) {
$values['description'] = @$event['SUMMARY'];
$values['date'] = $event_date;
$date = date ('Y-m-d', strtotime($event_date));
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter ('date', 'talert_special_days', $filter);
if ($date_check == $date) {
if ($overwrite) {
$id_special_day = db_get_value_filter ('id', 'talert_special_days', $filter);
alerts_update_alert_special_day ($id_special_day, $values);
}
else {
if ($skipped_dates == '') {
$skipped_dates = __('Skipped dates: ');
}
$skipped_dates .= $date . " ";
}
}
else {
alerts_create_alert_special_day ($date, $same_day, $values);
}
}
}
$result = true;
}
else {
$result = false;
}
if ($result) {
db_pandora_audit ("Special days list", "Upload iCalendar " . $_FILES['ical_file']['name']);
}
ui_print_result_message ($result, __('Success to upload iCalendar') . "
" . $skipped_dates, __('Fail to upload iCalendar'));
}
if ($create_special_day) {
$date = (string) get_parameter ('date');
$same_day = (string) get_parameter ('same_day');
$values = array();
$values['id_group'] = (string) get_parameter ('id_group');
$values['description'] = (string) get_parameter ('description');
list($year, $month, $day) = explode("-", $date);
if ($year == '*') {
# '0001' means every year.
$year = '0001';
$date = $year . '-' . $month . '-' . $day;
}
if (!checkdate ($month, $day, $year)) {
$result = '';
}
else {
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter ('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
}
else {
$result = alerts_create_alert_special_day ($date, $same_day, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $values['description'];
}
}
if ($result) {
db_pandora_audit("Command management", "Create special day " . $result, false, false, $info);
}
else {
db_pandora_audit("Command management", "Fail try to create special day", false, false);
}
ui_print_result_message ($result,
__('Successfully created'),
__('Could not be created'));
}
if ($update_special_day) {
$id = (int) get_parameter ('id');
$alert = alerts_get_alert_special_day ($id);
$date = (string) get_parameter ('date');
$date_orig = (string) get_parameter ('date_orig');
$same_day = (string) get_parameter ('same_day');
$description = (string) get_parameter ('description');
$id_group = (string) get_parameter ('id_group');
$id_group_orig = (string) get_parameter ('id_group_orig');
list($year, $month, $day) = explode("-", $date);
if ($year == '*') {
# '0001' means every year.
$year = '0001';
$date = $year . '-' . $month . '-' . $day;
}
$values = array ();
$values['date'] = $date;
$values['id_group'] = $id_group;
$values['same_day'] = $same_day;
$values['description'] = $description;
if (!checkdate ($month, $day, $year)) {
$result = '';
}
else {
if ($id_group != $id_group_orig || $date != $date_orig) {
$date_check = '';
$filter['id_group'] = $id_group;
$filter['date'] = $date;
$date_check = db_get_value_filter ('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
}
else {
$result = alerts_update_alert_special_day ($id, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description;
}
}
else {
$result = alerts_update_alert_special_day ($id, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description;
}
}
if ($result) {
db_pandora_audit("Command management", "Update special day " . $id, false, false, $info);
}
else {
db_pandora_audit("Command management", "Fail to update special day " . $id, false, false);
}
ui_print_result_message ($result,
__('Successfully updated'),
__('Could not be updated'));
}
if ($delete_special_day) {
$id = (int) get_parameter ('id');
$result = alerts_delete_alert_special_day ($id);
if ($result) {
db_pandora_audit("Command management", "Delete special day " . $id);
}
else {
db_pandora_audit("Command management", "Fail to delete special day " . $id);
}
ui_print_result_message ($result,
__('Successfully deleted'),
__('Could not be deleted'));
}
echo "
" . __('Display range: '); if ($display_range) { $html .= '[' . __('Default') . '] '; if ($display_range > 1970) { $html .= '<< '; } $html .= '[' . $display_range . ']'; $html .= ' >>'; } else { $html .= '[' . __('Default') . '] '; $html .= '<< '; $html .= '['; $html .= $this_year; $html .= ']'; $html .= ' >>'; } $html .= " |