Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 75 lines (64 sloc) 2.604 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#!/usr/bin/perl

use strict;
use warnings;

use CGI;

use C4::Auth;
use C4::Output;


use C4::Calendar;

my $input = new CGI;
my $dbh = C4::Context->dbh();

my $branchcode = $input->param('showBranchName');
my $weekday = $input->param('showWeekday');
my $day = $input->param('showDay');
my $month = $input->param('showMonth');
my $year = $input->param('showYear');
my $title = $input->param('showTitle');
my $description = $input->param('showDescription');
my $holidaytype = $input->param('showHolidayType');

my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
my $isodate = C4::Dates->new($calendardate, 'iso');
$calendardate = $isodate->output('syspref');

my $calendar = C4::Calendar->new(branchcode => $branchcode);

$title || ($title = '');
if ($description) {
    $description =~ s/\r/\\r/g;
    $description =~ s/\n/\\n/g;
} else {
    $description = '';
}

if ($input->param('showOperation') eq 'exception') {
$calendar->insert_exception_holiday(day => $day,
month => $month,
year => $year,
title => $title,
description => $description);
} elsif ($input->param('showOperation') eq 'edit') {
    if($holidaytype eq 'weekday') {
      $calendar->ModWeekdayholiday(weekday => $weekday,
                                   title => $title,
                                   description => $description);
    } elsif ($holidaytype eq 'daymonth') {
      $calendar->ModDaymonthholiday(day => $day,
                                    month => $month,
                                    title => $title,
                                    description => $description);
    } elsif ($holidaytype eq 'ymd') {
      $calendar->ModSingleholiday(day => $day,
                                  month => $month,
                                  year => $year,
                                  title => $title,
                                  description => $description);
    } elsif ($holidaytype eq 'exception') {
      $calendar->ModExceptionholiday(day => $day,
                                  month => $month,
                                  year => $year,
                                  title => $title,
                                  description => $description);
    }
} elsif ($input->param('showOperation') eq 'delete') {
$calendar->delete_holiday(weekday => $weekday,
day => $day,
   month => $month,
year => $year);
}
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");
Something went wrong with that request. Please try again.