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 15-20 my $input = new CGI; Link Here
15
my $dbh = C4::Context->dbh();
15
my $dbh = C4::Context->dbh();
16
16
17
my $branchcode = $input->param('showBranchName');
17
my $branchcode = $input->param('showBranchName');
18
my $originalbranchcode  = $branchcode;
18
my $weekday = $input->param('showWeekday');
19
my $weekday = $input->param('showWeekday');
19
my $day = $input->param('showDay');
20
my $day = $input->param('showDay');
20
my $month = $input->param('showMonth');
21
my $month = $input->param('showMonth');
Lines 24-31 my $description = $input->param('showDescription'); Link Here
24
my $holidaytype = $input->param('showHolidayType');
25
my $holidaytype = $input->param('showHolidayType');
25
my $datecancelrange_dt = eval { dt_from_string( scalar $input->param('datecancelrange') ) };
26
my $datecancelrange_dt = eval { dt_from_string( scalar $input->param('datecancelrange') ) };
26
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
27
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
27
28
my $showoperation = $input->param('showOperation');
28
my $calendar = C4::Calendar->new(branchcode => $branchcode);
29
my $allbranches = $input->param('allBranches');
29
30
30
$title || ($title = '');
31
$title || ($title = '');
31
if ($description) {
32
if ($description) {
Lines 47-123 if ($datecancelrange_dt){ Link Here
47
                push @holiday_list, $dt->clone();
48
                push @holiday_list, $dt->clone();
48
                }
49
                }
49
}
50
}
50
if ($input->param('showOperation') eq 'exception') {
51
51
	$calendar->insert_exception_holiday(day => $day,
52
if($allbranches) {
52
										month => $month,
53
    my $libraries = Koha::Libraries->search;
53
									    year => $year,
54
    while ( my $library = $libraries->next ) {
54
						                title => $title,
55
        edit_holiday($showoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype);
55
						                description => $description);
56
    }
56
} elsif ($input->param('showOperation') eq 'exceptionrange' ) {
57
} else {
57
        if (@holiday_list){
58
    edit_holiday($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype);
58
            foreach my $date (@holiday_list){
59
}
59
                $calendar->insert_exception_holiday(
60
60
                    day         => $date->{local_c}->{day},
61
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
61
                    month       => $date->{local_c}->{month},
62
62
                    year       => $date->{local_c}->{year},
63
sub edit_holiday {
63
                    title       => $title,
64
    ($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype) = @_;
64
                    description => $description
65
    my $calendar = C4::Calendar->new(branchcode => $branchcode);
65
                    );
66
67
    if ($showoperation eq 'exception') {
68
        $calendar->insert_exception_holiday(day => $day,
69
                                            month => $month,
70
                                            year => $year,
71
                                            title => $title,
72
                                            description => $description);
73
    } elsif ($showoperation eq 'exceptionrange' ) {
74
            if (@holiday_list){
75
                foreach my $date (@holiday_list){
76
                    $calendar->insert_exception_holiday(
77
                        day         => $date->{local_c}->{day},
78
                        month       => $date->{local_c}->{month},
79
                        year       => $date->{local_c}->{year},
80
                        title       => $title,
81
                        description => $description
82
                        );
83
                }
66
            }
84
            }
67
        }
85
    } elsif ($showoperation eq 'edit') {
68
} elsif ($input->param('showOperation') eq 'edit') {
86
        if($holidaytype eq 'weekday') {
69
    if($holidaytype eq 'weekday') {
87
        $calendar->ModWeekdayholiday(weekday => $weekday,
70
      $calendar->ModWeekdayholiday(weekday => $weekday,
88
                                    title => $title,
71
                                   title => $title,
89
                                    description => $description);
72
                                   description => $description);
90
        } elsif ($holidaytype eq 'daymonth') {
73
    } elsif ($holidaytype eq 'daymonth') {
91
        $calendar->ModDaymonthholiday(day => $day,
74
      $calendar->ModDaymonthholiday(day => $day,
92
                                        month => $month,
93
                                        title => $title,
94
                                        description => $description);
95
        } elsif ($holidaytype eq 'ymd') {
96
        $calendar->ModSingleholiday(day => $day,
75
                                    month => $month,
97
                                    month => $month,
98
                                    year => $year,
76
                                    title => $title,
99
                                    title => $title,
77
                                    description => $description);
100
                                    description => $description);
78
    } elsif ($holidaytype eq 'ymd') {
101
        } elsif ($holidaytype eq 'exception') {
79
      $calendar->ModSingleholiday(day => $day,
102
        $calendar->ModExceptionholiday(day => $day,
80
                                  month => $month,
103
                                    month => $month,
81
                                  year => $year,
104
                                    year => $year,
82
                                  title => $title,
105
                                    title => $title,
83
                                  description => $description);
106
                                    description => $description);
84
    } elsif ($holidaytype eq 'exception') {
107
        }
85
      $calendar->ModExceptionholiday(day => $day,
108
    } elsif ($showoperation eq 'delete') {
86
                                  month => $month,
109
        $calendar->delete_holiday(weekday => $weekday,
87
                                  year => $year,
110
                                day => $day,
88
                                  title => $title,
111
                                month => $month,
89
                                  description => $description);
112
                                year => $year);
90
    }
113
    }elsif ($showoperation eq 'deleterange') {
91
} elsif ($input->param('showOperation') eq 'delete') {
114
        if (@holiday_list){
92
	$calendar->delete_holiday(weekday => $weekday,
115
            foreach my $date (@holiday_list){
93
	                          day => $day,
116
                $calendar->delete_holiday_range(weekday => $weekday,
94
  	                          month => $month,
117
                                                day => $date->{local_c}->{day},
95
				              year => $year);
118
                                                month => $date->{local_c}->{month},
96
}elsif ($input->param('showOperation') eq 'deleterange') {
119
                                                year => $date->{local_c}->{year});
97
    if (@holiday_list){
120
                }
98
        foreach my $date (@holiday_list){
121
        }
99
            $calendar->delete_holiday_range(weekday => $weekday,
122
    }elsif ($showoperation eq 'deleterangerepeat') {
123
        if (@holiday_list){
124
            foreach my $date (@holiday_list){
125
            $calendar->delete_holiday_range_repeatable(weekday => $weekday,
126
                                            day => $date->{local_c}->{day},
127
                                            month => $date->{local_c}->{month});
128
            }
129
        }
130
    }elsif ($showoperation eq 'deleterangerepeatexcept') {
131
        if (@holiday_list){
132
            foreach my $date (@holiday_list){
133
            $calendar->delete_exception_holiday_range(weekday => $weekday,
100
                                            day => $date->{local_c}->{day},
134
                                            day => $date->{local_c}->{day},
101
                                            month => $date->{local_c}->{month},
135
                                            month => $date->{local_c}->{month},
102
                                            year => $date->{local_c}->{year});
136
                                            year => $date->{local_c}->{year});
103
            }
137
            }
104
    }
105
}elsif ($input->param('showOperation') eq 'deleterangerepeat') {
106
    if (@holiday_list){
107
        foreach my $date (@holiday_list){
108
           $calendar->delete_holiday_range_repeatable(weekday => $weekday,
109
                                         day => $date->{local_c}->{day},
110
                                         month => $date->{local_c}->{month});
111
        }
112
    }
113
}elsif ($input->param('showOperation') eq 'deleterangerepeatexcept') {
114
    if (@holiday_list){
115
        foreach my $date (@holiday_list){
116
           $calendar->delete_exception_holiday_range(weekday => $weekday,
117
                                         day => $date->{local_c}->{day},
118
                                         month => $date->{local_c}->{month},
119
                                         year => $date->{local_c}->{year});
120
        }
138
        }
121
    }
139
    }
122
}
140
}
123
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");
124
- 

Return to bug 4985