Collapse All | Expand All

 Lines 3122-3214 sub CalcDateDue { (-)a/C4/Circulation.pm (-87 lines) 3122 return \$datedue; 3122 return \$datedue; 3123 } 3123 } 3124 3124 3125 3126 =head2 CheckRepeatableHolidays 3127 3128 \$countrepeatable = CheckRepeatableHoliday(\$itemnumber,\$week_day,\$branchcode); 3129 3130 This function checks if the date due is a repeatable holiday 3131 3132 C<\$date_due> = returndate calculate with no day check 3133 C<\$itemnumber> = itemnumber 3134 C<\$branchcode> = localisation of issue 3135 3136 =cut 3137 3138 sub CheckRepeatableHolidays{ 3139 my(\$itemnumber,\$week_day,\$branchcode)=@_; 3140 my \$dbh = C4::Context->dbh; 3141 my \$query = qq|SELECT count(*) 3142 FROM repeatable_holidays 3143 WHERE branchcode=? 3144 AND weekday=?|; 3145 my \$sth = \$dbh->prepare(\$query); 3146 \$sth->execute(\$branchcode,\$week_day); 3147 my \$result=\$sth->fetchrow; 3148 return \$result; 3149 } 3150 3151 3152 =head2 CheckSpecialHolidays 3153 3154 \$countspecial = CheckSpecialHolidays(\$years,\$month,\$day,\$itemnumber,\$branchcode); 3155 3156 This function check if the date is a special holiday 3157 3158 C<\$years> = the years of datedue 3159 C<\$month> = the month of datedue 3160 C<\$day> = the day of datedue 3161 C<\$itemnumber> = itemnumber 3162 C<\$branchcode> = localisation of issue 3163 3164 =cut 3165 3166 sub CheckSpecialHolidays{ 3167 my (\$years,\$month,\$day,\$itemnumber,\$branchcode) = @_; 3168 my \$dbh = C4::Context->dbh; 3169 my \$query=qq|SELECT count(*) 3170 FROM `special_holidays` 3171 WHERE year=? 3172 AND month=? 3173 AND day=? 3174 AND branchcode=? 3175 |; 3176 my \$sth = \$dbh->prepare(\$query); 3177 \$sth->execute(\$years,\$month,\$day,\$branchcode); 3178 my \$countspecial=\$sth->fetchrow ; 3179 return \$countspecial; 3180 } 3181 3182 =head2 CheckRepeatableSpecialHolidays 3183 3184 \$countspecial = CheckRepeatableSpecialHolidays(\$month,\$day,\$itemnumber,\$branchcode); 3185 3186 This function check if the date is a repeatble special holidays 3187 3188 C<\$month> = the month of datedue 3189 C<\$day> = the day of datedue 3190 C<\$itemnumber> = itemnumber 3191 C<\$branchcode> = localisation of issue 3192 3193 =cut 3194 3195 sub CheckRepeatableSpecialHolidays{ 3196 my (\$month,\$day,\$itemnumber,\$branchcode) = @_; 3197 my \$dbh = C4::Context->dbh; 3198 my \$query=qq|SELECT count(*) 3199 FROM `repeatable_holidays` 3200 WHERE month=? 3201 AND day=? 3202 AND branchcode=? 3203 |; 3204 my \$sth = \$dbh->prepare(\$query); 3205 \$sth->execute(\$month,\$day,\$branchcode); 3206 my \$countspecial=\$sth->fetchrow ; 3207 return \$countspecial; 3208 } 3209 3210 3211 3212 sub CheckValidBarcode{ 3125 sub CheckValidBarcode{ 3213 my (\$barcode) = @_; 3126 my (\$barcode) = @_; 3214 my \$dbh = C4::Context->dbh; 3127 my \$dbh = C4::Context->dbh;
 Lines 699-704 our \$PERL_DEPS = { (-)a/C4/Installer/PerlDependencies.pm (+5 lines) 699 'required' => '0', 699 'required' => '0', 700 'min_ver' => '0.73', 700 'min_ver' => '0.73', 701 }, 701 }, 702 'Template::Plugin::JavaScript' => { 703 'usage' => 'Core', 704 'required' => '1', 705 'min_ver' => '0.02', 706 }, 702 }; 707 }; 703 708 704 1; 709 1;
 Lines 306-435 sub _get_chargeable_units { (-)a/C4/Overdues.pm (-124 lines) 306 } 306 } 307 307 308 308 309 =head2 GetSpecialHolidays 310 311 &GetSpecialHolidays(\$date_dues,\$itemnumber); 312 313 return number of special days between date of the day and date due 314 315 C<\$date_dues> is the envisaged date of book return. 316 317 C<\$itemnumber> is the book's item number. 318 319 =cut 320 321 sub GetSpecialHolidays { 322 my ( \$date_dues, \$itemnumber ) = @_; 323 324 # calcul the today date 325 my \$today = join "-", &Today(); 326 327 # return the holdingbranch 328 my \$iteminfo = GetIssuesIteminfo(\$itemnumber); 329 330 # use sql request to find all date between date_due and today 331 my \$dbh = C4::Context->dbh; 332 my \$query = 333 qq|SELECT DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') as date 334 FROM `special_holidays` 335 WHERE DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') >= ? 336 AND DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') <= ? 337 AND branchcode=? 338 |; 339 my @result = GetWdayFromItemnumber(\$itemnumber); 340 my @result_date; 341 my \$wday; 342 my \$dateinsec; 343 my \$sth = \$dbh->prepare(\$query); 344 \$sth->execute( \$date_dues, \$today, \$iteminfo->{'branchcode'} ) 345 ; # FIXME: just use NOW() in SQL instead of passing in \$today 346 347 while ( my \$special_date = \$sth->fetchrow_hashref ) { 348 push( @result_date, \$special_date ); 349 } 350 351 my \$specialdaycount = scalar(@result_date); 352 353 for ( my \$i = 0 ; \$i < scalar(@result_date) ; \$i++ ) { 354 \$dateinsec = UnixDate( \$result_date[\$i]->{'date'}, "%o" ); 355 ( undef, undef, undef, undef, undef, undef, \$wday, undef, undef ) = 356 localtime(\$dateinsec); 357 for ( my \$j = 0 ; \$j < scalar(@result) ; \$j++ ) { 358 if ( \$wday == ( \$result[\$j]->{'weekday'} ) ) { 359 \$specialdaycount--; 360 } 361 } 362 } 363 364 return \$specialdaycount; 365 } 366 367 =head2 GetRepeatableHolidays 368 369 &GetRepeatableHolidays(\$date_dues, \$itemnumber, \$difference,); 370 371 return number of day closed between date of the day and date due 372 373 C<\$date_dues> is the envisaged date of book return. 374 375 C<\$itemnumber> is item number. 376 377 C<\$difference> numbers of between day date of the day and date due 378 379 =cut 380 381 sub GetRepeatableHolidays { 382 my ( \$date_dues, \$itemnumber, \$difference ) = @_; 383 my \$dateinsec = UnixDate( \$date_dues, "%o" ); 384 my ( \$sec, \$min, \$hour, \$mday, \$mon, \$year, \$wday, \$yday, \$isdst ) = 385 localtime(\$dateinsec); 386 my @result = GetWdayFromItemnumber(\$itemnumber); 387 my @dayclosedcount; 388 my \$j; 389 390 for ( my \$i = 0 ; \$i < scalar(@result) ; \$i++ ) { 391 my \$k = \$wday; 392 393 for ( \$j = 0 ; \$j < \$difference ; \$j++ ) { 394 if ( \$result[\$i]->{'weekday'} == \$k ) { 395 push( @dayclosedcount, \$k ); 396 } 397 \$k++; 398 ( \$k = 0 ) if ( \$k eq 7 ); 399 } 400 } 401 return scalar(@dayclosedcount); 402 } 403 404 405 =head2 GetWayFromItemnumber 406 407 &Getwdayfromitemnumber(\$itemnumber); 408 409 return the different week day from repeatable_holidays table 410 411 C<\$itemnumber> is item number. 412 413 =cut 414 415 sub GetWdayFromItemnumber { 416 my (\$itemnumber) = @_; 417 my \$iteminfo = GetIssuesIteminfo(\$itemnumber); 418 my @result; 419 my \$query = qq|SELECT weekday 420 FROM repeatable_holidays 421 WHERE branchcode=? 422 |; 423 my \$sth = C4::Context->dbh->prepare(\$query); 424 425 \$sth->execute( \$iteminfo->{'branchcode'} ); 426 while ( my \$weekday = \$sth->fetchrow_hashref ) { 427 push( @result, \$weekday ); 428 } 429 return @result; 430 } 431 432 433 =head2 GetIssuesIteminfo 309 =head2 GetIssuesIteminfo 434 310 435 &GetIssuesIteminfo(\$itemnumber); 311 &GetIssuesIteminfo(\$itemnumber);
 Lines 339-356 Lines 468-479 sub clear_weekly_closed_days { In test mode changes the testing set of closed days to a new set with (-)a/Koha/Calendar.pm (-18 lines) 339 return; 339 return; 340 } 340 } 341 341 342 sub add_holiday { 343 my \$self = shift; 344 my \$new_dt = shift; 345 my @dt = \$self->single_holidays->as_list; 346 push @dt, \$new_dt; 347 \$self->{single_holidays} = 348 DateTime::Set->from_datetimes( dates => \@dt ); 349 \$single_holidays = \$self->{single_holidays}; 350 351 return; 352 } 353 354 1; 342 1; 355 __END__ 343 __END__ 356 344 468 no closed days. TODO passing an array of closed days to this would 456 no closed days. TODO passing an array of closed days to this would 469 allow testing of more configurations 457 allow testing of more configurations 470 458 471 =head2 add_holiday 472 473 Passed a datetime object this will add it to the calendar's list of 474 closed days. This is for testing so that we can alter the Calenfar object's 475 list of specified dates 476 477 =head1 DIAGNOSTICS 459 =head1 DIAGNOSTICS 478 460 479 Will croak if not passed a branchcode in new 461 Will croak if not passed a branchcode in new
 Lines 87-93 (-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (-1 / +1 lines) 87
87
88
88
89 [% IF ( CAN_user_tools_edit_calendar ) %] 89 [% IF ( CAN_user_tools_edit_calendar ) %] 90
• Calendar
• 90
• Calendar
• 91 [% END %] 91 [% END %] 92 [% IF ( CAN_user_tools_manage_csv_profiles ) %] 92 [% IF ( CAN_user_tools_manage_csv_profiles ) %] 93
• CSV profiles
• 93
• CSV profiles
 Line 0 (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/calendar.tt (+594 lines) 1 [% USE 'JavaScript' %] 2 [% USE 'KohaDates' %] 3 [% INCLUDE 'doc-head-open.inc' %] 4 Koha › Tools › [% branchname %] Calendar 5 [% INCLUDE 'doc-head-close.inc' %] 6 [% INCLUDE 'calendar.inc' %] 7 8 [% INCLUDE 'datatables.inc' %] 9 223 256 257 258 [% INCLUDE 'header.inc' %] 259 [% INCLUDE 'cat-search.inc' %] 260 261 262 263
264 265
266
267
268

[% branchname %] Calendar

269
270
271 272 281 282 283 284 285 286 287
288
289 290
291

Edit this event

292 293
294
1. 295 Library: 296 297
2. 298
3. 299 From Date: 300 , 301 302 [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] 303 304 305 306 307 308
4. 309
5. 310 To Date : 311 312
6. 313
7. 314 315 316
8. 317 323
9. 324 325 326 327 328
10. 329 [?] 330
This will delete this event rule. 331
11. . 332 [?] 333
This will delete the single events only. The repeatable events will not be deleted.
334
12. 335
13. . 336 [?] 337
This will delete the yearly repeated events only.
338
14. 339
15. 340 [?] 341
This will save changes to the event's title and description. If the information for a repeatable event is modified, it affects all of the dates on which the event is repeated.
16. 342
343
344 345 Cancel 346
347
348 349
350 351 352
353
354 355 356
357

358 359
360
1. 361 Library: 362 363 364
2. 365
3. 366 From date: 367 , 368 369 [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] 370 371 372 373 374 375
4. 376
5. 377 To date : 378 379
6. 380
7. 381 382 383
8. 384 390
9. 391
10. 392 393
11. 394
12. 395 . 396 [?] 397
Make a single event. For example, selecting August 1st, 2012 will not affect August 1st in other years.
398
13. 399
14. 400 . 401 [?] 402
Make this weekday an event, every week. For example, if your library is closed on Saturdays, use this option to make every Saturday a event.
403
15. 404
16. 405 . 406 [?] 407
Make this day of the year an event, every year. For example, selecting August 1st will set the hours for August 1st every year.
408
17. 409
18. 410 . 411 [?] 412
Make events for a range of days. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st event, but will not affect August 1-10 in other years.
413
19. 414
20. 415 . 416 [?] 417
Make a single event on a range repeated yearly. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st event, and will affect August 1-10 in other years.
418
21. 419
22. 420 421 . 422 [?] 423
If checked, this event will be copied to all libraries. If the event already exists for a library, no change is made.
424
425
426 427 Cancel 428
429
430 431
432 433 434 435 436 437 438 439 440

Calendar information

441
442 443
444
445 446 447 448 454 455 456
457 458
459
460
461

Hints

462
463
• Search in the calendar the day you want to set as event.
• 464
• Click the date to add or edit a event.
• 465
• Enter a title and description for the event.
• 466
• Specify how the event should repeat.
• 467
• Click Save to finish.
• 468
469

Key

470

471 Working day 472 Unique event 473 Event repeating weekly 474 Event repeating yearly 475

476
477
478 [% IF ( weekly_events ) %] 479

Weekly - Repeatable Events

480 481
Day of weekTitleDescriptionHours
482 483 484 485 486 487 488 489
493 496 [% event.title %][% event.description %] 500 [% IF event.closed %] 501 Closed 502 [% ELSIF event.close_hour == 24 %] 503 Open 504 [% ELSE %] 505 [% event.open_hour %]:[% event.open_minute > 10 ? event.open_minute : ( '0' _ event.open_minute) %] - 506 [% event.close_hour %]:[% event.close_minute > 10 ? event.close_minute : ( '0' _ event.close_minute) %] 507 [% END %] 508
490 [% FOREACH event IN weekly_events %] 491 492 497 498 499 509 510 [% END %] 511 512 513 [% END %] 514 515 [% IF ( yearly_events ) %] 516

Yearly - Repeatable Events

517 518
Day/MonthMonth/DayTitleDescriptionHours
519 520 [% IF ( dateformat == "metric" ) %] 521 522 [% ELSE %] 523 524 [% END %] 525 526 527 528 529 530
[% event.month_day_sort %][% event.title %][% event.description %] 537 [% IF event.closed %] 538 Closed 539 [% ELSIF event.close_hour == 24 %] 540 Open 541 [% ELSE %] 542 [% event.open_hour %]:[% event.open_minute > 10 ? event.open_minute : ( '0' _ event.open_minute) %] - 543 [% event.close_hour %]:[% event.close_minute > 10 ? event.close_minute : ( '0' _ event.close_minute) %] 544 [% END %] 545
531 [% FOREACH event IN yearly_events %] 532 533 534 535 536 546 547 [% END %] 548 549 550 [% END %] 551 552 [% IF ( single_events ) %] 553

Single Events

554 555
DateTitleDescriptionHours
556 557 558 559 560 561 562 563
[% event.event_date | \$KohaDates %][% event.title %][% event.description %] 570 [% IF event.closed %] 571 Closed 572 [% ELSIF event.close_hour == 24 %] 573 Open 574 [% ELSE %] 575 [% event.open_hour %]:[% event.open_minute > 10 ? event.open_minute : ( '0' _ event.open_minute) %] - 576 [% event.close_hour %]:[% event.close_minute > 10 ? event.close_minute : ( '0' _ event.close_minute) %] 577 [% END %] 578
564 [% FOREACH event IN single_events %] 565 566 567 568 569 579 580 [% END %] 581 582 583 [% END %] 584 585 586 587 588 589 590
591 [% INCLUDE 'tools-menu.inc' %] 592
593 594 [% INCLUDE 'intranet-bottom.inc' %]
 Lines 1-535 (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-535 lines) 1 [% INCLUDE 'doc-head-open.inc' %] 2 Koha › Tools › [% branchname %] Calendar 3 [% INCLUDE 'doc-head-close.inc' %] 4 [% INCLUDE 'calendar.inc' %] 5 6 [% INCLUDE 'datatables.inc' %] 7 194 213 214 215 [% INCLUDE 'header.inc' %] 216 [% INCLUDE 'cat-search.inc' %] 217 218 219 220
221 222
223
224
225

[% branchname %] Calendar

226
227
228 229 238 239 240 241 242 243 244
245
246 247
248

Edit this holiday

249 250
251
1. 252 Library: 253 254
2. 255
3. 256 From Date: 257 , 258 259 [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] 260 261 262 263 264 265 266
4. 267
5. 268 To Date : 269 270
6. 271
7. 272 273 274 275 276
8. 277 278 [?] 279
You can make an exception for this holiday rule. This means that you will be able to say that for a repeatable holiday there is one day which is going to be an exception.
280
9. 281
10. 282 283 [?] 284
You can make an exception on a range of dates repeated yearly.
285
11. 286
12. 287 [?] 288
This will delete this holiday rule. If it is a repeatable holiday, this option checks for possible exceptions. If an exception exists, this option will remove the exception and set the date to a regular holiday.
13. 289
14. . 290 [?] 291
This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.
292
15. 293
16. . 294 [?] 295
This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.
296
17. 297
18. . 298 [?] 299
This will delete the exceptions inside a given range. Be careful about your scope range if it is oversized you could slow down Koha.
300
19. 301
20. 302 [?] 303
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.
21. 304
305
306 307 Cancel 308
309
310 311
312 313 314
315
316 317
318

319
320
1. 321 Library: 322 323 324
2. 325
3. 326 From date: 327 , 328 329 [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] 330 331 332 333 334 335 336
4. 337
5. 338 To date : 339 340
6. 341
7. 342
8. 343 344
9. 345
10. 346 . 347 [?] 348
Make a single holiday. For example, selecting August 1st, 2012 will make it a holiday, but will not affect August 1st in other years.
349
11. 350
12. 351 . 352 [?] 353
Make this weekday a holiday, every week. For example, if your library is closed on Saturdays, use this option to make every Saturday a holiday.
354
13. 355
14. 356 . 357 [?] 358
This will take this day and month as a reference to make it a holiday. Through this option, you can repeat this rule for every year. For example, selecting August 1st will make August 1st a holiday every year.
359
15. 360
16. 361 . 362 [?] 363
Make a single holiday on a range. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st holiday, but will not affect August 1-10 in other years.
364
17. 365
18. 366 . 367 [?] 368
Make a single holiday on a range repeated yearly. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st holiday, and will affect August 1-10 in other years.
369
19. 370
20. 371 372 . 373 [?] 374
If checked, this holiday will be copied to all libraries. If the holiday already exists for a library, no change is made.
375
376
377 378 Cancel 379
380
381 382
383 384 385 386 387 388 389 390 391

Calendar information

392
393 394
395
396 397 398 404 405 406
407 408
409
410
411

Hints

412
413
• Search in the calendar the day you want to set as holiday.
• 414
• Click the date to add or edit a holiday.
• 415
• Enter a title and description for the holdiay.
• 416
• Specify how the holiday should repeat.
• 417
• Click Save to finish.
• 418
419

Key

420

421 Working day 422 Unique holiday 423 Holiday repeating weekly 424 Holiday repeating yearly 425 Holiday exception 426

427
428
429 430 431 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %] 432

Exceptions

433 434
DateTitleDescription
435 436 437 438 439 440
[% EXCEPTION_HOLIDAYS_LOO.DATE %][% EXCEPTION_HOLIDAYS_LOO.TITLE %][% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION %]
441 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %] 442 443 444 445 446 447 [% END %] 448 449 450 [% END %] 451 452 [% IF ( WEEK_DAYS_LOOP ) %] 453

Weekly - Repeatable Holidays

454 455
Day of weekTitleDescription
456 457 458 459 460 461 462
466 469 [% WEEK_DAYS_LOO.TITLE %][% WEEK_DAYS_LOO.DESCRIPTION %]
463 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %] 464 465 470 471 472 473 [% END %] 474 475 476 [% END %] 477 478 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %] 479

Yearly - Repeatable Holidays

480 481
Day/MonthMonth/DayTitleDescription
482 483 [% IF ( dateformat == "metric" ) %] 484 485 [% ELSE %] 486 487 [% END %] 488 489 490 491 492
[% DAY_MONTH_HOLIDAYS_LOO.DATE %][% DAY_MONTH_HOLIDAYS_LOO.TITLE %][% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION %]
493 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %] 494 495 496 497 498 499 [% END %] 500 501 502 [% END %] 503 504 [% IF ( HOLIDAYS_LOOP ) %] 505

Unique Holidays

506 507
DateTitleDescription
508 509 510 511 512 513 514
[% HOLIDAYS_LOO.DATE %][% HOLIDAYS_LOO.TITLE %][% HOLIDAYS_LOO.DESCRIPTION %]
515 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %] 516 517 518 519 520 521 [% END %] 522 523 524 [% END %] 525 526 527 528 529 530 531
532 [% INCLUDE 'tools-menu.inc' %] 533
534 535 [% INCLUDE 'intranet-bottom.inc' %]
 Lines 73-79 (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-1 / +1 lines) 73

73

74
74
75 [% IF ( CAN_user_tools_edit_calendar ) %] 75 [% IF ( CAN_user_tools_edit_calendar ) %] 76
Calendar
76
Calendar
77
Define days when the library is closed
77
Define days when the library is closed
78 [% END %] 78 [% END %] 79 79
 Lines 40-48 Lines 172-181 use Date::Calc qw/Date_to_Days/; for ( my \$i = 0 ; \$i < scalar(@\$data) ; \$i++ ) { (-)a/misc/cronjobs/staticfines.pl (-3 / +8 lines) 40 use C4::Context; 40 use C4::Context; 41 use C4::Circulation; 41 use C4::Circulation; 42 use C4::Overdues; 42 use C4::Overdues; 43 use C4::Calendar qw(); # don't need any exports from Calendar 44 use C4::Biblio; 43 use C4::Biblio; 45 use C4::Debug; # supplying \$debug and \$cgi_debug 44 use C4::Debug; # supplying \$debug and \$cgi_debug 45 use Koha::Calendar; 46 46 use Getopt::Long; 47 use Getopt::Long; 47 use List::MoreUtils qw/none/; 48 use List::MoreUtils qw/none/; 48 use Koha::DateUtils; 49 use Koha::DateUtils; 172 173 173 my \$calendar; 174 my \$calendar; 174 unless ( defined( \$calendars{\$branchcode} ) ) { 175 unless ( defined( \$calendars{\$branchcode} ) ) { 175 \$calendars{\$branchcode} = C4::Calendar->new( branchcode => \$branchcode ); 176 \$calendars{\$branchcode} = Koha::Calendar->new( branchcode => \$branchcode ); 176 } 177 } 177 \$calendar = \$calendars{\$branchcode}; 178 \$calendar = \$calendars{\$branchcode}; 178 my \$isHoliday = \$calendar->isHoliday( \$tday, \$tmonth, \$tyear ); 179 my \$isHoliday = \$calendar->is_holiday( DateTime->new( 180 year => \$tyear, 181 month => \$tmonth, 182 day => \$tday 183 ) ); 179 184 180 # Reassing datedue_days if -delay specified in commandline 185 # Reassing datedue_days if -delay specified in commandline 181 \$bigdebug and warn "Using commandline supplied delay : \$delay" if (\$delay); 186 \$bigdebug and warn "Using commandline supplied delay : \$delay" if (\$delay);
 Lines 37-43 Lines 311-333 use C4::Items; sub GetWaitingHolds { (-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (-18 / +13 lines) 37 use C4::Letters; 37 use C4::Letters; 38 use C4::Overdues; 38 use C4::Overdues; 39 use C4::Dates; 39 use C4::Dates; 40 use C4::Calendar; 40 use Koha::Calendar; 41 41 42 sub usage { 42 sub usage { 43 pod2usage( -verbose => 2 ); 43 pod2usage( -verbose => 2 ); 311 sprintf( "%04d-%02d-%02d", \$date_due[0], \$date_due[1], \$date_due[2] ); 311 sprintf( "%04d-%02d-%02d", \$date_due[0], \$date_due[1], \$date_due[2] ); 312 \$issue->{'level'} = 1; # only one level for Hold Waiting notifications 312 \$issue->{'level'} = 1; # only one level for Hold Waiting notifications 313 313 314 my \$days_to_subtract = 0; 314 my \$calendar = Koha::Calendar->new( branchcode => \$issue->{'site'} ); 315 my \$calendar = C4::Calendar->new( branchcode => \$issue->{'site'} ); 315 \$issue->{'days_since_waiting'} = \$calendar->days_between( 316 while ( 316 DateTime->new( 317 \$calendar->isHoliday( 317 year => \$waitingdate[0], 318 reverse( 318 month => \$waitingdate[1], 319 Add_Delta_Days( 319 day => \$waitingdate[2], 320 \$waitingdate[0], \$waitingdate[1], 320 time_zone => C4::Context->tz, 321 \$waitingdate[2], \$days_to_subtract 321 ), 322 ) 322 DateTime->now( 323 ) 323 time_zone => C4::Context->tz, 324 ) 324 ), 325 ) 325 ); 326 { 327 \$days_to_subtract++; 328 } 329 \$issue->{'days_since_waiting'} = 330 \$issue->{'days_since_waiting'} - \$days_to_subtract; 331 326 332 if ( 327 if ( 333 ( 328 (
 Lines 4-20 use strict; (-)a/t/Calendar.t (-5 / +1 lines) 4 use warnings; 4 use warnings; 5 use DateTime; 5 use DateTime; 6 use DateTime::Duration; 6 use DateTime::Duration; 7 use Test::More tests => 35; 7 use Test::More tests => 34; 8 use Test::MockModule; 8 use Test::MockModule; 9 use DBD::Mock; 9 use DBD::Mock; 10 use Koha::DateUtils; 10 use Koha::DateUtils; 11 11 12 BEGIN { 12 BEGIN { 13 use_ok('Koha::Calendar'); 13 use_ok('Koha::Calendar'); 14 15 # This was the only test C4 had 16 # Remove when no longer used 17 use_ok('C4::Calendar'); 18 } 14 } 19 15 20 my \$module_context = new Test::MockModule('C4::Context'); 16 my \$module_context = new Test::MockModule('C4::Context');
 Line 0 (-)a/t/db_dependent/Calendar.t (+77 lines) 1 use Modern::Perl; 2 3 use Test::More tests => 14; 4 5 use C4::Calendar; 6 7 my \$new_holiday = { open_hour => 0, 8 open_minute => 0, 9 close_hour => 0, 10 close_minute => 0, 11 title => 'example week_day_holiday', 12 description => 'This is an example week_day_holiday used for testing' }; 13 14 # Weekly events 15 ModRepeatingEvent( 'UPL', 1, undef, undef, \$new_holiday ); 16 17 my \$weekly_events = GetWeeklyEvents( 'UPL' ); 18 is( \$weekly_events->[0]->{'title'}, \$new_holiday->{'title'}, 'weekly title' ); 19 is( \$weekly_events->[0]->{'description'}, \$new_holiday->{'description'}, 'weekly description' ); 20 21 \$new_holiday->{close_hour} = 24; 22 23 ModRepeatingEvent( 'UPL', 1, undef, undef, \$new_holiday ); 24 \$weekly_events = GetWeeklyEvents( 'UPL' ); 25 is( scalar @\$weekly_events, 0, 'weekly modification, not insertion' ); 26 27 \$new_holiday->{close_hour} = 0; 28 ModRepeatingEvent( 'UPL', 1, undef, undef, \$new_holiday ); 29 30 # Yearly events 31 32 ModRepeatingEvent( 'UPL', undef, 6, 26, \$new_holiday ); 33 34 my \$yearly_events = GetYearlyEvents( 'UPL' ); 35 is( \$yearly_events->[0]->{'title'}, \$new_holiday->{'title'}, 'yearly title' ); 36 is( \$yearly_events->[0]->{'description'}, \$new_holiday->{'description'}, 'yearly description' ); 37 38 \$new_holiday->{close_hour} = 24; 39 40 ModRepeatingEvent( 'UPL', undef, 6, 26, \$new_holiday ); 41 \$yearly_events = GetYearlyEvents( 'UPL' ); 42 is( scalar @\$yearly_events, 0, 'yearly modification, not insertion' ); 43 44 \$new_holiday->{close_hour} = 0; 45 ModRepeatingEvent( 'UPL', undef, 6, 26, \$new_holiday ); 46 47 # Single events 48 49 ModSingleEvent( 'UPL', '2013-03-17', \$new_holiday ); 50 51 my \$single_events = GetSingleEvents( 'UPL' ); 52 is( \$single_events->[0]->{'title'}, \$new_holiday->{'title'}, 'single title' ); 53 is( \$single_events->[0]->{'description'}, \$new_holiday->{'description'}, 'single description' ); 54 is( \$single_events->[0]->{'closed'}, 1, 'single closed' ); 55 56 \$new_holiday->{close_hour} = 24; 57 58 ModSingleEvent( 'UPL', '2013-03-17', \$new_holiday ); 59 \$single_events = GetSingleEvents( 'UPL' ); 60 is( scalar @\$single_events, 1, 'single modification, not insertion' ); 61 is( \$single_events->[0]->{'closed'}, 0, 'single closed' ); 62 63 64 # delete 65 66 DelRepeatingEvent( 'UPL', 1, undef, undef ); 67 \$weekly_events = GetWeeklyEvents( 'UPL' ); 68 is( scalar @\$weekly_events, 0, 'weekly deleted' ); 69 70 DelRepeatingEvent( 'UPL', undef, 6, 26 ); 71 \$yearly_events = GetYearlyEvents( 'UPL' ); 72 is( scalar @\$yearly_events, 0, 'yearly deleted' ); 73 74 DelSingleEvent( 'UPL', '2013-03-17' ); 75 76 \$single_events = GetSingleEvents( 'UPL' ); 77 is( scalar @\$single_events, 0, 'single deleted' );
 Lines 5-22 Lines 43-55 use DateTime; is( \$koha_calendar->is_holiday(\$sunday), 1, 'Sunday is a closed day' ); (-)a/t/db_dependent/Holidays.t (-14 / +1 lines) 5 use DateTime::TimeZone; 5 use DateTime::TimeZone; 6 6 7 use C4::Context; 7 use C4::Context; 8 use Test::More tests => 10; 8 use Test::More tests => 6; 9 9 10 BEGIN { use_ok('Koha::Calendar'); } 10 BEGIN { use_ok('Koha::Calendar'); } 11 BEGIN { use_ok('C4::Calendar'); } 12 11 13 my \$branchcode = 'MPL'; 12 my \$branchcode = 'MPL'; 14 13 15 my \$koha_calendar = Koha::Calendar->new( branchcode => \$branchcode ); 14 my \$koha_calendar = Koha::Calendar->new( branchcode => \$branchcode ); 16 my \$c4_calendar = C4::Calendar->new( branchcode => \$branchcode ); 17 15 18 isa_ok( \$koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' ); 16 isa_ok( \$koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' ); 19 isa_ok( \$c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' ); 20 17 21 my \$sunday = DateTime->new( 18 my \$sunday = DateTime->new( 22 year => 2011, 19 year => 2011, 43 is( \$koha_calendar->is_holiday(\$monday), 0, 'Monday is not a closed day' ); 40 is( \$koha_calendar->is_holiday(\$monday), 0, 'Monday is not a closed day' ); 44 is( \$koha_calendar->is_holiday(\$christmas), 1, 'Christmas is a closed day' ); 41 is( \$koha_calendar->is_holiday(\$christmas), 1, 'Christmas is a closed day' ); 45 is( \$koha_calendar->is_holiday(\$newyear), 1, 'New Years day is a closed day' ); 42 is( \$koha_calendar->is_holiday(\$newyear), 1, 'New Years day is a closed day' ); 46 47 my \$custom_holiday = DateTime->new( 48 year => 2013, 49 month => 11, 50 day => 12, 51 ); 52 is( \$koha_calendar->is_holiday(\$custom_holiday), 0, '2013-11-10 does not start off as a holiday' ); 53 \$koha_calendar->add_holiday(\$custom_holiday); 54 is( \$koha_calendar->is_holiday(\$custom_holiday), 1, 'able to add holiday for testing' ); 55