Lines 10-34
use C4::Output;
Link Here
|
10 |
|
10 |
|
11 |
|
11 |
|
12 |
use C4::Calendar; |
12 |
use C4::Calendar; |
|
|
13 |
use DateTime; |
13 |
|
14 |
|
14 |
my $input = new CGI; |
15 |
my $input = new CGI; |
15 |
my $dbh = C4::Context->dbh(); |
16 |
my $dbh = C4::Context->dbh(); |
16 |
|
17 |
|
17 |
my $branchcode = $input->param('newBranchName'); |
18 |
my $branchcode = $input->param('newBranchName'); |
18 |
my $originalbranchcode = $branchcode; |
19 |
my $originalbranchcode = $branchcode; |
19 |
my $weekday = $input->param('newWeekday'); |
20 |
my $weekday = $input->param('newWeekday'); |
20 |
my $day = $input->param('newDay'); |
21 |
my $day = $input->param('newDay'); |
21 |
my $month = $input->param('newMonth'); |
22 |
my $month = $input->param('newMonth'); |
22 |
my $year = $input->param('newYear'); |
23 |
my $year = $input->param('newYear'); |
23 |
my $title = $input->param('newTitle'); |
24 |
my $day1; |
24 |
my $description = $input->param('newDescription'); |
25 |
my $month1; |
25 |
my $newoperation = $input->param('newOperation'); |
26 |
my $year1; |
26 |
my $allbranches = $input->param('allBranches'); |
27 |
my $dateofrange = $input->param('dateofrange'); |
|
|
28 |
my $title = $input->param('newTitle'); |
29 |
my $description = $input->param('newDescription'); |
30 |
my $newoperation = $input->param('newOperation'); |
31 |
my $allbranches = $input->param('allBranches'); |
27 |
|
32 |
|
28 |
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); |
33 |
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); |
29 |
my $isodate = C4::Dates->new($calendardate, 'iso'); |
34 |
my $isodate = C4::Dates->new($calendardate, 'iso'); |
30 |
$calendardate = $isodate->output('syspref'); |
35 |
$calendardate = $isodate->output('syspref'); |
31 |
|
36 |
|
|
|
37 |
my @dateend = split(/[\/-]/, $dateofrange); |
38 |
if (C4::Context->preference("dateformat") eq "metric") { |
39 |
$day1 = $dateend[0]; |
40 |
$month1 = $dateend[1]; |
41 |
$year1 = $dateend[2]; |
42 |
}elsif (C4::Context->preference("dateformat") eq "us") { |
43 |
$month1 = $dateend[0]; |
44 |
$day1 = $dateend[1]; |
45 |
$year1 = $dateend[2]; |
46 |
} else { |
47 |
$year1 = $dateend[0]; |
48 |
$month1 = $dateend[1]; |
49 |
$day1 = $dateend[2]; |
50 |
} |
32 |
$title || ($title = ''); |
51 |
$title || ($title = ''); |
33 |
if ($description) { |
52 |
if ($description) { |
34 |
$description =~ s/\r/\\r/g; |
53 |
$description =~ s/\r/\\r/g; |
Lines 80-84
sub add_holiday {
Link Here
|
80 |
description => $description); |
99 |
description => $description); |
81 |
} |
100 |
} |
82 |
|
101 |
|
83 |
} |
102 |
} elsif ( $newoperation eq 'holidayrange' ) { |
|
|
103 |
#Make an array with holiday's days |
104 |
my $first_dt = DateTime->new(year => $year, month => $month, day => $day); |
105 |
my $end_dt = DateTime->new(year => $year1, month => $month1, day => $day1); |
106 |
my @holiday_list = (); |
107 |
|
108 |
for (my $dt = $first_dt->clone(); |
109 |
$dt <= $end_dt; |
110 |
$dt->add(days => 1) ) |
111 |
{ |
112 |
push @holiday_list, $dt->clone(); |
113 |
} |
114 |
|
115 |
foreach my $date (@holiday_list){ |
116 |
unless ( $calendar->isHoliday( $date->{local_c}->{day}, $date->{local_c}->{month}, $date->{local_c}->{year} ) ) { |
117 |
$calendar->insert_single_holiday( |
118 |
day => $date->{local_c}->{day}, |
119 |
month => $date->{local_c}->{month}, |
120 |
year => $date->{local_c}->{year}, |
121 |
title => $title, |
122 |
description => $description |
123 |
); |
124 |
} |
125 |
} |
126 |
} elsif ( $newoperation eq 'holidayrangerepeat' ) { |
127 |
#Make an array with holiday's days |
128 |
my $first_dt = DateTime->new(year => $year, month => $month, day => $day); |
129 |
my $end_dt = DateTime->new(year => $year1, month => $month1, day => $day1); |
130 |
my @holiday_list = (); |
131 |
|
132 |
for (my $dt = $first_dt->clone(); |
133 |
$dt <= $end_dt; |
134 |
$dt->add(days => 1) ) |
135 |
{ |
136 |
push @holiday_list, $dt->clone(); |
137 |
} |
138 |
|
139 |
foreach my $date (@holiday_list){ |
140 |
unless ( $calendar->isHoliday( $date->{local_c}->{day}, $date->{local_c}->{month}, $date->{local_c}->{year} ) ) { |
141 |
$calendar->insert_day_month_holiday( |
142 |
day => $date->{local_c}->{day}, |
143 |
month => $date->{local_c}->{month}, |
144 |
title => $title, |
145 |
description => $description |
146 |
); |
147 |
} |
148 |
} |
149 |
} |
84 |
} |
150 |
} |
85 |
- |
|
|