View | Details | Raw Unified | Return to bug 4985
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (+6 lines)
Lines 111-116 td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl Link Here
111
            <li class="radio"><input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
111
            <li class="radio"><input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
112
                <a href="#" class="helptext">[?]</a>
112
                <a href="#" class="helptext">[?]</a>
113
                <div class="hint">This will save changes to the holiday's title and description. If the information for a repeatable holiday is modified, it affects all of the dates on which the holiday is repeated.</div></li>
113
                <div class="hint">This will save changes to the holiday's title and description. If the information for a repeatable holiday is modified, it affects all of the dates on which the holiday is repeated.</div></li>
114
            <li class="checkbox">
115
                <input type="checkbox" name="allBranches" id="allBranches" />
116
                <label for="allBranches">Copy changes to all libraries</label>.
117
                <a href="#" class="helptext">[?]</a>
118
                <div class="hint">If checked, changes for this holiday will be copied to all libraries. If the holiday doesn't exists for a library, no change is made.</div>
119
            </li>
114
            </ol>
120
            </ol>
115
            <fieldset class="action">
121
            <fieldset class="action">
116
                <input type="submit" name="submit" value="Save" />
122
                <input type="submit" name="submit" value="Save" />
(-)a/tools/exceptionHolidays.pl (-66 / +82 lines)
Lines 18-23 checkauth($input, 0, {tools=> 'edit_calendar'}, 'intranet'); Link Here
18
18
19
19
20
my $branchcode = $input->param('showBranchName');
20
my $branchcode = $input->param('showBranchName');
21
my $originalbranchcode  = $branchcode;
21
my $weekday = $input->param('showWeekday');
22
my $weekday = $input->param('showWeekday');
22
my $day = $input->param('showDay');
23
my $day = $input->param('showDay');
23
my $month = $input->param('showMonth');
24
my $month = $input->param('showMonth');
Lines 27-34 my $description = $input->param('showDescription'); Link Here
27
my $holidaytype = $input->param('showHolidayType');
28
my $holidaytype = $input->param('showHolidayType');
28
my $datecancelrange_dt = eval { dt_from_string( scalar $input->param('datecancelrange') ) };
29
my $datecancelrange_dt = eval { dt_from_string( scalar $input->param('datecancelrange') ) };
29
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
30
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
30
31
my $showoperation = $input->param('showOperation');
31
my $calendar = C4::Calendar->new(branchcode => $branchcode);
32
my $allbranches = $input->param('allBranches');
32
33
33
$title || ($title = '');
34
$title || ($title = '');
34
if ($description) {
35
if ($description) {
Lines 50-126 if ($datecancelrange_dt){ Link Here
50
                push @holiday_list, $dt->clone();
51
                push @holiday_list, $dt->clone();
51
                }
52
                }
52
}
53
}
53
if ($input->param('showOperation') eq 'exception') {
54
54
	$calendar->insert_exception_holiday(day => $day,
55
if($allbranches) {
55
										month => $month,
56
    my $libraries = Koha::Libraries->search;
56
									    year => $year,
57
    while ( my $library = $libraries->next ) {
57
						                title => $title,
58
        edit_holiday($showoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype);
58
						                description => $description);
59
    }
59
} elsif ($input->param('showOperation') eq 'exceptionrange' ) {
60
} else {
60
        if (@holiday_list){
61
    edit_holiday($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype);
61
            foreach my $date (@holiday_list){
62
}
62
                $calendar->insert_exception_holiday(
63
63
                    day         => $date->{local_c}->{day},
64
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
64
                    month       => $date->{local_c}->{month},
65
65
                    year       => $date->{local_c}->{year},
66
sub edit_holiday {
66
                    title       => $title,
67
    ($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype) = @_;
67
                    description => $description
68
    my $calendar = C4::Calendar->new(branchcode => $branchcode);
68
                    );
69
70
    if ($showoperation eq 'exception') {
71
        $calendar->insert_exception_holiday(day => $day,
72
                                            month => $month,
73
                                            year => $year,
74
                                            title => $title,
75
                                            description => $description);
76
    } elsif ($showoperation eq 'exceptionrange' ) {
77
            if (@holiday_list){
78
                foreach my $date (@holiday_list){
79
                    $calendar->insert_exception_holiday(
80
                        day         => $date->{local_c}->{day},
81
                        month       => $date->{local_c}->{month},
82
                        year       => $date->{local_c}->{year},
83
                        title       => $title,
84
                        description => $description
85
                        );
86
                }
69
            }
87
            }
70
        }
88
    } elsif ($showoperation eq 'edit') {
71
} elsif ($input->param('showOperation') eq 'edit') {
89
        if($holidaytype eq 'weekday') {
72
    if($holidaytype eq 'weekday') {
90
        $calendar->ModWeekdayholiday(weekday => $weekday,
73
      $calendar->ModWeekdayholiday(weekday => $weekday,
91
                                    title => $title,
74
                                   title => $title,
92
                                    description => $description);
75
                                   description => $description);
93
        } elsif ($holidaytype eq 'daymonth') {
76
    } elsif ($holidaytype eq 'daymonth') {
94
        $calendar->ModDaymonthholiday(day => $day,
77
      $calendar->ModDaymonthholiday(day => $day,
95
                                        month => $month,
96
                                        title => $title,
97
                                        description => $description);
98
        } elsif ($holidaytype eq 'ymd') {
99
        $calendar->ModSingleholiday(day => $day,
78
                                    month => $month,
100
                                    month => $month,
101
                                    year => $year,
79
                                    title => $title,
102
                                    title => $title,
80
                                    description => $description);
103
                                    description => $description);
81
    } elsif ($holidaytype eq 'ymd') {
104
        } elsif ($holidaytype eq 'exception') {
82
      $calendar->ModSingleholiday(day => $day,
105
        $calendar->ModExceptionholiday(day => $day,
83
                                  month => $month,
106
                                    month => $month,
84
                                  year => $year,
107
                                    year => $year,
85
                                  title => $title,
108
                                    title => $title,
86
                                  description => $description);
109
                                    description => $description);
87
    } elsif ($holidaytype eq 'exception') {
110
        }
88
      $calendar->ModExceptionholiday(day => $day,
111
    } elsif ($showoperation eq 'delete') {
89
                                  month => $month,
112
        $calendar->delete_holiday(weekday => $weekday,
90
                                  year => $year,
113
                                day => $day,
91
                                  title => $title,
114
                                month => $month,
92
                                  description => $description);
115
                                year => $year);
93
    }
116
    }elsif ($showoperation eq 'deleterange') {
94
} elsif ($input->param('showOperation') eq 'delete') {
117
        if (@holiday_list){
95
	$calendar->delete_holiday(weekday => $weekday,
118
            foreach my $date (@holiday_list){
96
	                          day => $day,
119
                $calendar->delete_holiday_range(weekday => $weekday,
97
  	                          month => $month,
120
                                                day => $date->{local_c}->{day},
98
				              year => $year);
121
                                                month => $date->{local_c}->{month},
99
}elsif ($input->param('showOperation') eq 'deleterange') {
122
                                                year => $date->{local_c}->{year});
100
    if (@holiday_list){
123
                }
101
        foreach my $date (@holiday_list){
124
        }
102
            $calendar->delete_holiday_range(weekday => $weekday,
125
    }elsif ($showoperation eq 'deleterangerepeat') {
126
        if (@holiday_list){
127
            foreach my $date (@holiday_list){
128
            $calendar->delete_holiday_range_repeatable(weekday => $weekday,
129
                                            day => $date->{local_c}->{day},
130
                                            month => $date->{local_c}->{month});
131
            }
132
        }
133
    }elsif ($showoperation eq 'deleterangerepeatexcept') {
134
        if (@holiday_list){
135
            foreach my $date (@holiday_list){
136
            $calendar->delete_exception_holiday_range(weekday => $weekday,
103
                                            day => $date->{local_c}->{day},
137
                                            day => $date->{local_c}->{day},
104
                                            month => $date->{local_c}->{month},
138
                                            month => $date->{local_c}->{month},
105
                                            year => $date->{local_c}->{year});
139
                                            year => $date->{local_c}->{year});
106
            }
140
            }
107
    }
108
}elsif ($input->param('showOperation') eq 'deleterangerepeat') {
109
    if (@holiday_list){
110
        foreach my $date (@holiday_list){
111
           $calendar->delete_holiday_range_repeatable(weekday => $weekday,
112
                                         day => $date->{local_c}->{day},
113
                                         month => $date->{local_c}->{month});
114
        }
115
    }
116
}elsif ($input->param('showOperation') eq 'deleterangerepeatexcept') {
117
    if (@holiday_list){
118
        foreach my $date (@holiday_list){
119
           $calendar->delete_exception_holiday_range(weekday => $weekday,
120
                                         day => $date->{local_c}->{day},
121
                                         month => $date->{local_c}->{month},
122
                                         year => $date->{local_c}->{year});
123
        }
141
        }
124
    }
142
    }
125
}
143
}
126
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");
127
- 

Return to bug 4985