From 48bf9b1d91dbbc336f859ac1a83d7d25b0e6a3c1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 11 Jul 2022 16:14:38 +0200 Subject: [PATCH] Bug 30718: Use flatpickr's altInput The idea rely on the KohaDates TT plugin for the date formatting. We should not have any output_pref calls in pl or pm (there are some exceptions, for ILSDI for instance). Also flatpickr will deal with the places where dates are inputed. We will pass the raw SQL value (what we call 'iso' in Koha::DateUtils), and the controller will receive the same value, no need to additional conversion. Note that DBIC has the capability to auto-deflate DateTime objects, which makes things way easier. We can either pass the value we receive from the controller, or pass a DT object to our methods. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- C4/Acquisition.pm | 13 ++---- C4/Barcodes/annual.pm | 1 + C4/Barcodes/hbyymmincr.pm | 1 + C4/Circulation.pm | 34 +++++++------- C4/ILSDI/Services.pm | 23 +++------- C4/Items.pm | 8 +--- C4/Letters.pm | 2 +- C4/Members.pm | 1 + C4/Overdues.pm | 6 +-- C4/Reports/Guided.pm | 3 +- C4/Reserves.pm | 15 ++----- C4/Search/History.pm | 1 + C4/Serials.pm | 45 ------------------- Koha/Hold.pm | 6 +-- Koha/Item.pm | 6 +-- Koha/Patrons/Import.pm | 1 + Koha/REST/V1/Clubs/Holds.pm | 6 --- Koha/REST/V1/Holds.pm | 34 ++++---------- Koha/Report.pm | 20 ++++----- acqui/duplicate_orders.pl | 8 ++-- acqui/histsearch.pl | 6 +-- acqui/invoice.pl | 4 +- acqui/invoices.pl | 15 +++---- acqui/lateorders.pl | 32 ++++--------- acqui/orderreceive.pl | 2 +- acqui/parcels.pl | 7 ++- admin/aqbudgetperiods.pl | 9 ++-- admin/aqcontract.pl | 20 +++------ admin/categories.pl | 11 ----- admin/smart-rules.pl | 5 --- cataloguing/additem.pl | 1 - cataloguing/value_builder/barcode.pl | 4 +- cataloguing/value_builder/barcode_manual.pl | 4 +- cataloguing/value_builder/dateaccessioned.pl | 3 +- circ/branchoverdues.pl | 4 +- circ/circulation.pl | 6 +-- circ/overdue.pl | 6 +-- circ/renew.pl | 17 ++++--- circ/reserveratios.pl | 9 ++-- circ/returns.pl | 40 ++++++++--------- circ/transferstoreceive.pl | 4 +- circ/waitingreserves.pl | 4 +- clubs/clubs-add-modify.pl | 6 +-- installer/onboarding.pl | 12 ----- .../prog/en/includes/calendar.inc | 7 ++- .../prog/en/includes/filter-orders.inc | 5 +-- .../prog/en/includes/holds_table.inc | 6 +-- .../prog/en/modules/acqui/invoice.tt | 4 +- .../prog/en/modules/acqui/invoices.tt | 8 ++-- .../prog/en/modules/acqui/orderreceive.tt | 2 +- .../prog/en/modules/acqui/parcels.tt | 2 +- .../prog/en/modules/admin/aqbudgetperiods.tt | 8 ++-- .../prog/en/modules/admin/aqcontract.tt | 4 +- .../prog/en/modules/admin/categories.tt | 2 +- .../prog/en/modules/circ/circulation.tt | 4 +- .../circ/circulation_batch_checkouts.tt | 2 +- .../prog/en/modules/circ/overdue.tt | 4 +- .../prog/en/modules/circ/pendingreserves.tt | 4 +- .../prog/en/modules/circ/renew.tt | 2 +- .../prog/en/modules/circ/reserveratios.tt | 4 +- .../prog/en/modules/circ/returns.tt | 4 +- .../prog/en/modules/clubs/clubs-add-modify.tt | 4 +- .../en/modules/reports/cash_register_stats.tt | 4 +- .../prog/en/modules/reserve/request.tt | 2 +- .../en/modules/serials/checkexpiration.tt | 2 +- .../prog/en/modules/serials/claims.tt | 8 ++-- .../prog/en/modules/serials/serials-search.tt | 4 +- .../en/modules/serials/subscription-add.tt | 8 ++-- .../modules/serials/subscription-history.tt | 4 +- .../prog/en/modules/suggestion/suggestion.tt | 6 +-- .../prog/en/modules/tags/review.tt | 4 +- .../en/modules/tools/additional-contents.tt | 4 +- .../prog/en/modules/tools/holidays.tt | 2 +- .../prog/en/modules/tools/inventory.tt | 4 +- koha-tmpl/intranet-tmpl/prog/js/members.js | 2 +- labels/label-item-search.pl | 17 ++----- members/housebound.pl | 5 +-- members/memberentry.pl | 26 ++--------- misc/cronjobs/fines.pl | 2 +- misc/cronjobs/serialsUpdate.pl | 4 +- misc/cronjobs/staticfines.pl | 4 +- opac/opac-memberentry.pl | 16 +------ opac/opac-reserve.pl | 1 - opac/opac-suggestions.pl | 3 +- pos/register.pl | 10 +++-- reports/acquisitions_stats.pl | 17 +------ reports/bor_issues_top.pl | 5 --- reports/borrowers_out.pl | 3 -- reports/borrowers_stats.pl | 12 ----- reports/cash_register_stats.pl | 10 ++--- reports/cat_issues_top.pl | 12 +---- reports/dictionary.pl | 9 ---- reports/guided_reports.pl | 20 --------- reports/issues_avg_stats.pl | 18 +------- reports/issues_stats.pl | 12 +---- reports/orders_by_fund.pl | 5 +-- reports/reserves_stats.pl | 11 +---- reserve/modrequest.pl | 5 +-- reserve/request.pl | 8 ++-- serials/serials-edit.pl | 16 ++----- serials/serials-search.pl | 7 ++- serials/showpredictionpattern.pl | 15 +++---- suggestion/suggestion.pl | 1 + t/db_dependent/Reserves.t | 12 ++--- t/db_dependent/Serials.t | 6 +-- tags/review.pl | 25 ++++------- tools/additional-contents.pl | 7 +-- tools/batchMod.pl | 1 - tools/batch_extend_due_dates.pl | 22 +++------ tools/cleanborrowers.pl | 37 +++------------ tools/holidays.pl | 1 + tools/inventory.pl | 4 +- tools/scheduler.pl | 8 +--- 113 files changed, 294 insertions(+), 698 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index cd2df080f3..51ece49e66 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -27,7 +27,7 @@ use C4::Biblio qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal use C4::Contract qw( GetContract ); use C4::Log qw( logaction ); use C4::Templates qw(gettemplate); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Baskets; use Koha::Acquisition::Booksellers; use Koha::Acquisition::Orders; @@ -1374,13 +1374,8 @@ sub ModReceiveOrder { my $received_items = $params->{received_items}; my $dbh = C4::Context->dbh; - $datereceived = output_pref( - { - dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string ), - dateformat => 'iso', - dateonly => 1, - } - ); + $datereceived = $datereceived ? dt_from_string( $datereceived ) : dt_from_string; + $datereceived = $datereceived->ymd; my $suggestionid = GetSuggestionFromBiblionumber( $biblionumber ); if ($suggestionid) { @@ -2728,7 +2723,7 @@ sub CloseInvoice { Reopen an invoice -Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string, dateonly=>1, otputpref=>'iso' })) +Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => $closedate ); =cut diff --git a/C4/Barcodes/annual.pm b/C4/Barcodes/annual.pm index 0d7e05ae00..215b3d840c 100644 --- a/C4/Barcodes/annual.pm +++ b/C4/Barcodes/annual.pm @@ -24,6 +24,7 @@ use Carp qw( carp ); use C4::Context; +# FIXME We should certainly remove output_pref from here use Koha::DateUtils qw( dt_from_string output_pref ); use vars qw(@ISA); diff --git a/C4/Barcodes/hbyymmincr.pm b/C4/Barcodes/hbyymmincr.pm index bd345a6d62..9b067864b6 100644 --- a/C4/Barcodes/hbyymmincr.pm +++ b/C4/Barcodes/hbyymmincr.pm @@ -23,6 +23,7 @@ use Carp qw( carp ); use C4::Context; +# FIXME We should certainly remove output_pref from here use Koha::DateUtils qw( dt_from_string output_pref ); use constant WIDTH => 4; # FIXME: too small for sizeable or multi-branch libraries? diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9cb56f79d3..65b8ddf256 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -24,7 +24,6 @@ use POSIX qw( floor ); use YAML::XS; use Encode; -use Koha::DateUtils qw( dt_from_string output_pref ); use C4::Context; use C4::Stats qw( UpdateStats ); use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest ItemsAnyAvailableAndNotRestricted ); @@ -43,7 +42,7 @@ use Koha::Account; use Koha::AuthorisedValues; use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; use Koha::Biblioitems; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Calendar; use Koha::Checkouts; use Koha::Illrequests; @@ -798,7 +797,7 @@ sub CanBookBeIssued { my $now = dt_from_string(); $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron_unblessed ); if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now - $needsconfirmation{INVALID_DATE} = output_pref($duedate); + $needsconfirmation{INVALID_DATE} = $duedate; } my $fees = Koha::Charges::Fees->new( @@ -1235,19 +1234,16 @@ sub CanBookBeIssued { my $check = checkHighHolds( $item_object, $patron ); if ( $check->{exceeded} ) { + my $highholds = { + num_holds => $check->{outstanding}, + duration => $check->{duration}, + returndate => $check->{due_date}, + }; if ($override_high_holds) { - $alerts{HIGHHOLDS} = { - num_holds => $check->{outstanding}, - duration => $check->{duration}, - returndate => output_pref( { dt => dt_from_string($check->{due_date}), dateformat => 'iso', timeformat => '24hr' }), - }; + $alerts{HIGHHOLDS} = $highholds; } else { - $needsconfirmation{HIGHHOLDS} = { - num_holds => $check->{outstanding}, - duration => $check->{duration}, - returndate => output_pref( { dt => dt_from_string($check->{due_date}), dateformat => 'iso', timeformat => '24hr' }), - }; + $needsconfirmation{HIGHHOLDS} = $highholds; } } } @@ -1462,8 +1458,8 @@ Calculated if empty. =item C<$cancelreserve> is 1 to override and cancel any pending reserves for the item (optional). -=item C<$issuedate> is the date to issue the item in iso (YYYY-MM-DD) format (optional). -Defaults to today. Unlike C<$datedue>, NOT a DateTime object, unfortunately. +=item C<$issuedate> is a DateTime object for the date to issue the item (optional). +Defaults to today. AddIssue does the following things : @@ -1635,8 +1631,8 @@ sub AddIssue { my $issue_attributes = { borrowernumber => $borrower->{'borrowernumber'}, - issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), - date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), + issuedate => $issuedate, + date_due => $datedue, branchcode => C4::Context->userenv->{'branch'}, onsite_checkout => $onsite_checkout, auto_renew => $auto_renew ? 1 : 0, @@ -4423,7 +4419,7 @@ sub _CalculateAndUpdateFine { itemnumber => $issue->itemnumber, borrowernumber => $issue->borrowernumber, amount => $amount, - due => output_pref($datedue), + due => $datedue, }); } elsif ($return_date) { @@ -4436,7 +4432,7 @@ sub _CalculateAndUpdateFine { itemnumber => $issue->itemnumber, borrowernumber => $issue->borrowernumber, amount => 0, - due => output_pref($datedue), + due => $datedue, }); } } diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 17f55cfe58..03ca66235a 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -694,6 +694,7 @@ sub RenewLoan { # Hashref building my $out; $out->{'renewals'} = $issue->renewals_count; + # FIXME Unusual date formatting $out->{date_due} = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M'); $out->{'success'} = $renewal[0]; $out->{'error'} = $renewal[1]; @@ -774,15 +775,8 @@ sub HoldTitle { return { code => 'libraryNotPickupLocation' } unless $destination->pickup_location; return { code => 'cannotBeTransferred' } unless $biblio->can_be_transferred({ to => $destination }); - my $resdate; - if ( $cgi->param('start_date') ) { - $resdate = $cgi->param('start_date'); - } - - my $expdate; - if ( $cgi->param('expiry_date') ) { - $expdate = $cgi->param('expiry_date'); - } + my $resdate = $cgi->param('start_date'); + my $expdate = $cgi->param('expiry_date'); # Add the reserve # $branch, $borrowernumber, $biblionumber, @@ -876,15 +870,8 @@ sub HoldItem { my $canitembereserved = C4::Reserves::CanItemBeReserved( $patron, $item, $branch )->{status}; return { code => $canitembereserved } unless $canitembereserved eq 'OK'; - my $resdate; - if ( $cgi->param('start_date') ) { - $resdate = $cgi->param('start_date'); - } - - my $expdate; - if ( $cgi->param('expiry_date') ) { - $expdate = $cgi->param('expiry_date'); - } + my $resdate = $cgi->param('start_date'); + my $expdate = $cgi->param('expiry_date'); # Add the reserve my $priority = C4::Reserves::CalculatePriority($biblionumber); diff --git a/C4/Items.pm b/C4/Items.pm index 443242be5d..fd69d008e2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -51,7 +51,6 @@ use Carp qw( croak ); use C4::Context; use C4::Koha; use C4::Biblio qw( GetMarcStructure TransformMarcToKoha ); -use Koha::DateUtils qw( dt_from_string output_pref ); use MARC::Record; use C4::ClassSource qw( GetClassSort GetClassSources GetClassSource ); use C4::Log qw( logaction ); @@ -60,7 +59,7 @@ use DateTime::Format::MySQL; # debugging; so please don't remove this use Koha::AuthorisedValues; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Database; use Koha::Biblios; @@ -403,10 +402,8 @@ The last optional parameter allows for passing skip_record_index through to the sub ModDateLastSeen { my ( $itemnumber, $leave_item_lost, $params ) = @_; - my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); - my $item = Koha::Items->find($itemnumber); - $item->datelastseen($today); + $item->datelastseen(dt_from_string); $item->itemlost(0) unless $leave_item_lost; $item->store({ log_action => 0, skip_record_index => $params->{skip_record_index}, skip_holds_queue => $params->{skip_holds_queue} }); } @@ -587,7 +584,6 @@ sub GetItemsForInventory { } if ($datelastseen) { - $datelastseen = output_pref({ str => $datelastseen, dateformat => 'iso', dateonly => 1 }); push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)'; push @bind_params, $datelastseen; } diff --git a/C4/Letters.pm b/C4/Letters.pm index 53cde01237..7c136f32f9 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -29,7 +29,6 @@ use C4::Members; use C4::Log qw( logaction ); use C4::SMS; use C4::Templates; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::SMS::Providers; use Koha::Email; @@ -788,6 +787,7 @@ sub _parseletter { # in callers ( by changing / formatting values ) my $values = $values_in ? { %$values_in } : {}; + # FIXME Dates formatting must be done in notice's templates if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){ $values->{'dateexpiry'} = output_pref({ dt => dt_from_string( $values->{'dateexpiry'} ), dateonly => 1 }); } diff --git a/C4/Members.pm b/C4/Members.pm index 5478e0de32..c17bbb2a32 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -596,6 +596,7 @@ sub IssueSlip { # FIXME We keep newdate and timestamp for backward compatibility (from GetNewsToDisplay) # But we should remove them and adjust the existing templates in a db rev + # FIXME This must be formatted in the notice template my $published_on_dt = output_pref({ dt => dt_from_string( $all->{published_on} ), dateonly => 1 }); $all->{newdate} = $published_on_dt; $all->{timestamp} = $published_on_dt; diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 1894731c06..56a0010f19 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -31,6 +31,7 @@ use C4::Accounts; use C4::Context; use Koha::Account::Lines; use Koha::Account::Offsets; +use Koha::DateUtils qw( output_pref ); use Koha::Libraries; use Koha::Recalls; use Koha::Logger; @@ -512,7 +513,7 @@ has the book on loan. C<$amount> is the current amount owed by the patron. -C<$due> is the due date formatted to the currently specified date format +C<$due> is the date C<&UpdateFine> looks up the amount currently owed on the given item and sets it to C<$amount>, creating, if necessary, a new entry in the @@ -552,7 +553,6 @@ sub UpdateFine { my $accountline; my $total_amount_other = 0.00; - my $due_qr = qr/$due/; # Cycle through the fines and # - find line that relates to the requested $itemnum # - accumulate fines for other items @@ -610,7 +610,7 @@ sub UpdateFine { items => $itemnum, }, ) }; - my $desc = $letter ? $letter->{content} : "Item $itemnum - due $due"; + my $desc = $letter ? $letter->{content} : sprintf("Item %s - due %s", $itemnum, output_pref($due) ); my $account = Koha::Account->new({ patron_id => $borrowernumber }); $accountline = $account->add_debit( diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index b6d58955c3..cbbc1a6f88 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -25,7 +25,7 @@ use JSON qw( from_json ); use C4::Context; use C4::Templates qw/themelanguage/; use C4::Koha qw( GetAuthorisedValues ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Patrons; use Koha::Reports; use C4::Output; @@ -753,7 +753,6 @@ sub get_saved_reports { my (@cond,@args); if ($filter) { if (my $date = $filter->{date}) { - $date = eval { output_pref( { dt => dt_from_string( $date ), dateonly => 1, dateformat => 'iso' }); }; push @cond, "DATE(last_modified) = ? OR DATE(last_run) = ?"; push @args, $date, $date; diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d5e01f283d..fa131cd5c3 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -38,7 +38,7 @@ use Koha::Biblios; use Koha::Calendar; use Koha::CirculationRules; use Koha::Database; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Hold; use Koha::Holds; use Koha::ItemTypes; @@ -194,10 +194,7 @@ sub AddReserve { my $itemtype = $params->{itemtype}; my $non_priority = $params->{non_priority}; - $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) - or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); - - $patron_expiration_date = output_pref({ str => $patron_expiration_date, dateonly => 1, dateformat => 'iso' }); + $resdate ||= dt_from_string; # if we have an item selectionned, and the pickup branch is the same as the holdingbranch # of the document, we force the value $priority and $found . @@ -1124,7 +1121,7 @@ sub ModReserve { if C4::Context->preference('HoldsLog'); # The only column that can be updated for a found hold is the expiration date - $hold->expirationdate(dt_from_string($date))->store(); + $hold->expirationdate($date)->store(); } elsif ($rank =~ /^\d+/ and $rank > 0) { logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) @@ -1148,7 +1145,6 @@ sub ModReserve { if ( defined( $suspend_until ) ) { if ( $suspend_until ) { - $suspend_until = eval { dt_from_string( $suspend_until ) }; $hold->suspend_hold( $suspend_until ); } else { # If the hold is suspended leave the hold suspended, but convert it to an indefinite hold. @@ -1523,8 +1519,6 @@ be cleared when it is unsuspended. sub ToggleSuspend { my ( $reserve_id, $suspend_until ) = @_; - $suspend_until = dt_from_string($suspend_until) if ($suspend_until); - my $hold = Koha::Holds->find( $reserve_id ); if ( $hold->is_suspended ) { @@ -1558,9 +1552,6 @@ sub SuspendAll { my $suspend_until = $params{'suspend_until'} || undef; my $suspend = defined( $params{'suspend'} ) ? $params{'suspend'} : 1; - $suspend_until = eval { dt_from_string($suspend_until) } - if ( defined($suspend_until) ); - return unless ( $borrowernumber || $biblionumber ); my $params; diff --git a/C4/Search/History.pm b/C4/Search/History.pm index fec4f004fd..c73df9834b 100644 --- a/C4/Search/History.pm +++ b/C4/Search/History.pm @@ -51,6 +51,7 @@ sub add_to_session { query_cgi => $query_cgi, total => "$total", type => $type, + # FIXME We shouldn't store the formatted date time => output_pref( { dt => $now, dateformat => 'iso', timeformat => '24hr' } ), id => $id, }; diff --git a/C4/Serials.pm b/C4/Serials.pm index 6a1274f20a..75c9d7f19f 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -38,7 +38,6 @@ use C4::Serials::Frequency qw( GetSubscriptionFrequency ); use C4::Serials::Numberpattern; use Koha::AdditionalFieldValues; use Koha::Biblios; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Serial; use Koha::Subscriptions; use Koha::Subscription::Histories; @@ -427,23 +426,11 @@ sub GetSubscriptionsFromBiblionumber { $sth->execute($biblionumber); my @res; while ( my $subs = $sth->fetchrow_hashref ) { - $subs->{startdate} = output_pref( { dt => dt_from_string( $subs->{startdate} ), dateonly => 1 } ); - $subs->{histstartdate} = output_pref( { dt => dt_from_string( $subs->{histstartdate} ), dateonly => 1 } ); - if ( defined $subs->{histenddate} ) { - $subs->{histenddate} = output_pref( { dt => dt_from_string( $subs->{histenddate} ), dateonly => 1 } ); - } else { - $subs->{histenddate} = ""; - } $subs->{opacnote} //= ""; $subs->{ "periodicity" . $subs->{periodicity} } = 1; $subs->{ "numberpattern" . $subs->{numberpattern} } = 1; $subs->{ "status" . $subs->{'status'} } = 1; - if (not defined $subs->{enddate} ) { - $subs->{enddate} = ''; - } else { - $subs->{enddate} = output_pref( { dt => dt_from_string( $subs->{enddate}), dateonly => 1 } ); - } $subs->{'abouttoexpire'} = abouttoexpire( $subs->{'subscriptionid'} ); $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} ); $subs->{cannotedit} = not can_edit_subscription( $subs ); @@ -677,13 +664,6 @@ sub GetSerials { while ( my $line = $sth->fetchrow_hashref ) { $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list - for my $datefield ( qw( planneddate publisheddate) ) { - if ($line->{$datefield} && $line->{$datefield}!~m/^00/) { - $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } ); - } else { - $line->{$datefield} = q{}; - } - } push @serials, $line; } @@ -700,13 +680,6 @@ sub GetSerials { while ( ( my $line = $sth->fetchrow_hashref ) && $counter < $count ) { $counter++; $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list - for my $datefield ( qw( planneddate publisheddate) ) { - if ($line->{$datefield} && $line->{$datefield}!~m/^00/) { - $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } ); - } else { - $line->{$datefield} = q{}; - } - } push @serials, $line; } @@ -751,15 +724,6 @@ sub GetSerials2 { while ( my $line = $sth->fetchrow_hashref ) { $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list - # Format dates for display - for my $datefield ( qw( planneddate publisheddate ) ) { - if (!defined($line->{$datefield}) || $line->{$datefield} =~m/^00/) { - $line->{$datefield} = q{}; - } - else { - $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } ); - } - } push @serials, $line; } return @serials; @@ -1900,15 +1864,6 @@ sub GetLateOrMissingIssues { $sth->execute( EXPECTED, LATE, CLAIMED ); my @issuelist; while ( my $line = $sth->fetchrow_hashref ) { - - if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) { - $line->{planneddateISO} = $line->{planneddate}; - $line->{planneddate} = output_pref( { dt => dt_from_string( $line->{"planneddate"} ), dateonly => 1 } ); - } - if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) { - $line->{claimdateISO} = $line->{claimdate}; - $line->{claimdate} = output_pref( { dt => dt_from_string( $line->{"claimdate"} ), dateonly => 1 } ); - } $line->{"status".$line->{status}} = 1; my $subscription_object = Koha::Subscriptions->find($line->{subscriptionid}); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 73eec43ccb..ca261086c7 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -85,14 +85,14 @@ sub age { =head3 suspend_hold -my $hold = $hold->suspend_hold( $suspend_until_dt ); +my $hold = $hold->suspend_hold( $suspend_until ); =cut sub suspend_hold { - my ( $self, $dt ) = @_; + my ( $self, $date ) = @_; - my $date = $dt ? $dt->clone()->truncate( to => 'day' )->datetime : undef; + $date &&= dt_from_string($date)->truncate( to => 'day' )->datetime; if ( $self->is_found ) { # We can't suspend found holds if ( $self->is_waiting ) { diff --git a/Koha/Item.pm b/Koha/Item.pm index 483c582446..f25ae42c57 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -166,11 +166,7 @@ sub store { && !$pre_mod_item->$field ) { my $field_on = "${field}_on"; - $self->$field_on( - DateTime::Format::MySQL->format_datetime( - dt_from_string() - ) - ); + $self->$field_on(dt_from_string); } } diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 96ab01e332..bb5f820400 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -57,6 +57,7 @@ Further pod documentation needed here. =cut has 'today_iso' => ( is => 'ro', lazy => 1, + # FIXME We shouldn't need to call output_pref here, passing a DateTime object should work default => sub { output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); }, ); has 'text_csv' => ( is => 'rw', lazy => 1, diff --git a/Koha/REST/V1/Clubs/Holds.pm b/Koha/REST/V1/Clubs/Holds.pm index 3333d75e7d..7af5602a81 100644 --- a/Koha/REST/V1/Clubs/Holds.pm +++ b/Koha/REST/V1/Clubs/Holds.pm @@ -26,7 +26,6 @@ use Koha::Patrons; use Koha::Holds; use Koha::Clubs; use Koha::Club::Hold; -use Koha::DateUtils qw( dt_from_string output_pref ); use Scalar::Util qw( blessed ); use Try::Tiny qw( catch try ); @@ -103,11 +102,6 @@ sub add { ); } - # AddReserve expects date to be in syspref format - if ($expiration_date) { - $expiration_date = output_pref( dt_from_string( $expiration_date, 'rfc3339' ) ); - } - my $club_hold = Koha::Club::Hold::add( { club_id => $club_id, diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index acd4b78e20..44188363a6 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -26,7 +26,7 @@ use C4::Reserves; use Koha::Items; use Koha::Patrons; use Koha::Holds; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use List::MoreUtils qw( any ); use Try::Tiny qw( catch try ); @@ -183,11 +183,6 @@ sub add { my $priority = C4::Reserves::CalculatePriority($biblio_id); - # AddReserve expects date to be in syspref format - if ($expiration_date) { - $expiration_date = output_pref( { dt => dt_from_string($expiration_date, 'iso'), dateformat => 'iso', dateonly => 1 } ); - } - my $hold_id = C4::Reserves::AddReserve( { branchcode => $pickup_library_id, @@ -280,19 +275,14 @@ sub edit { $pickup_library_id //= $hold->branchcode; my $priority = $body->{priority} // $hold->priority; # suspended_until can also be set to undef - my $suspended_until = - exists $body->{suspended_until} - ? dt_from_string( $body->{suspended_until}, 'rfc3339' ) - : $hold->suspend_until && dt_from_string( $hold->suspend_until, 'iso' ); + my $suspended_until = $body->{suspended_until} || $hold->suspend_until; my $params = { reserve_id => $hold_id, branchcode => $pickup_library_id, rank => $priority, - suspend_until => $suspended_until - ? output_pref({ dt => $suspended_until, dateformat => 'iso', dateonly => 1 }) - : '', - itemnumber => $hold->itemnumber + suspend_until => $suspended_until, + itemnumber => $hold->itemnumber, }; C4::Reserves::ModReserve($params); @@ -356,23 +346,15 @@ sub suspend { } return try { - my $date = ($end_date) ? dt_from_string( $end_date, 'iso' ) : undef; - $hold->suspend_hold($date); + $hold->suspend_hold($end_date); $hold->discard_changes; $c->res->headers->location( $c->req->url->to_string ); - my $suspend_end_date; - if ($hold->suspend_until) { - $suspend_end_date = output_pref({ - dt => dt_from_string( $hold->suspend_until, 'iso' ), - dateformat => 'iso', - dateonly => 1 - } - ); - } + + my $suspend_until = $end_date ? dt_from_string($hold->suspend_until)->ymd : undef; return $c->render( status => 201, openapi => { - end_date => $suspend_end_date + end_date => $suspend_until, } ); } diff --git a/Koha/Report.pm b/Koha/Report.pm index 35d46c4c21..937f10e917 100644 --- a/Koha/Report.pm +++ b/Koha/Report.pm @@ -20,7 +20,7 @@ use Modern::Perl; use Koha::Database; use Koha::Reports; -use Koha::DateUtils qw( dt_from_string output_pref ); +#use Koha::DateUtils qw( dt_from_string output_pref ); use base qw(Koha::Object); # @@ -159,15 +159,15 @@ sub prep_report { # if there are special regexp chars, we must \ them $split[ $i * 2 + 1 ] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; - if ( $split[ $i * 2 + 1 ] =~ /\|\s*date\s*$/ ) { - $quoted = output_pref( - { - dt => dt_from_string($quoted), - dateformat => 'iso', - dateonly => 1 - } - ) if $quoted; - } + #if ( $split[ $i * 2 + 1 ] =~ /\|\s*date\s*$/ ) { + # $quoted = output_pref( + # { + # dt => dt_from_string($quoted), + # dateformat => 'iso', + # dateonly => 1 + # } + # ) if $quoted; + #} unless ( $split[ $i * 2 + 1 ] =~ /\|\s*list\s*$/ && $quoted ) { $quoted = C4::Context->dbh->quote($quoted); } diff --git a/acqui/duplicate_orders.pl b/acqui/duplicate_orders.pl index 21e382e72f..c0b82f5431 100755 --- a/acqui/duplicate_orders.pl +++ b/acqui/duplicate_orders.pl @@ -28,7 +28,7 @@ use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget GetBudgetPerio use Koha::Acquisition::Baskets; use Koha::Acquisition::Currencies; use Koha::Acquisition::Orders; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my $basketno = $input->param('basketno'); @@ -76,10 +76,8 @@ unless ( $input->param('from') ) { # Fill the form with year-1 $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); } -$filters->{from_placed_on} = - output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ), - $filters->{to_placed_on} = - output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ), +$filters->{from_placed_on} = $from_placed_on; +$filters->{to_placed_on} = $to_placed_on; my ( @result_order_loop, @selected_order_loop ); my @ordernumbers = split ',', scalar $input->param('ordernumbers') || ''; diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index ff00c28442..e44c7db329 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -55,7 +55,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Acquisition qw( GetHistory ); use Koha::AdditionalFields; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my $do_search = $input->param('do_search') || 0; @@ -98,8 +98,8 @@ unless ( $input->param('from') ) { # Fill the form with year-1 $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); } -$filters->{from_placed_on} = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ); -$filters->{to_placed_on} = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ); +$filters->{from_placed_on} = $from_placed_on; +$filters->{to_placed_on} = $to_placed_on; my $additional_fields = Koha::AdditionalFields->search( { tablename => 'aqbasket', searchable => 1 } ); $template->param( available_additional_fields => $additional_fields ); my @additional_field_filters; diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 7240d9319f..f283f9721c 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -102,8 +102,8 @@ elsif ( $op && $op eq 'mod' ) { ModInvoice( invoiceid => $invoiceid, invoicenumber => $invoicenumber, - shipmentdate => scalar output_pref( { str => scalar $input->param('shipmentdate'), dateformat => 'iso', dateonly => 1 } ), - billingdate => scalar output_pref( { str => scalar $input->param('billingdate'), dateformat => 'iso', dateonly => 1 } ), + shipmentdate => scalar $input->param('shipmentdate'), + billingdate => scalar $input->param('billingdate'), shipmentcost => $shipmentcost, shipmentcost_budgetid => $shipment_budget_id ); diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 9720ead33e..0f6f666550 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -34,7 +34,7 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Acquisition qw( GetInvoices GetInvoice ); use C4::Budgets qw( GetBudget GetBudgets CanUserUseBudget ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Booksellers; my $input = CGI->new; @@ -62,20 +62,15 @@ my $branch = $input->param('branch'); my $message_id = $input->param('message_id'); my $op = $input->param('op'); -$shipmentdatefrom and $shipmentdatefrom = eval { dt_from_string( $shipmentdatefrom ) }; -$shipmentdateto and $shipmentdateto = eval { dt_from_string( $shipmentdateto ) }; -$billingdatefrom and $billingdatefrom = eval { dt_from_string( $billingdatefrom ) }; -$billingdateto and $billingdateto = eval { dt_from_string( $billingdateto ) }; - my $invoices = []; if ( $op and $op eq 'do_search' ) { @{$invoices} = GetInvoices( invoicenumber => $invoicenumber, supplierid => $supplierid, - shipmentdatefrom => $shipmentdatefrom ? output_pref( { str => $shipmentdatefrom, dateformat => 'iso' } ) : undef, - shipmentdateto => $shipmentdateto ? output_pref( { str => $shipmentdateto, dateformat => 'iso' } ) : undef, - billingdatefrom => $billingdatefrom ? output_pref( { str => $billingdatefrom, dateformat => 'iso' } ) : undef, - billingdateto => $billingdateto ? output_pref( { str => $billingdateto, dateformat => 'iso' } ) : undef, + shipmentdatefrom => $shipmentdatefrom, + shipmentdateto => $shipmentdateto, + billingdatefrom => $billingdatefrom, + billingdateto => $billingdateto, isbneanissn => $isbneanissn, title => $title, author => $author, diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index a47088c44e..639f4f4933 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -49,7 +49,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Context; use C4::Letters qw( SendAlerts GetLetters ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Orders qw( filter_by_lates ); use Koha::CsvProfiles; @@ -70,25 +70,11 @@ my $delay = $input->param('delay') // 0; my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom'); my $estimateddeliverydateto = $input->param('estimateddeliverydateto'); -my $estimateddeliverydatefrom_dt = - $estimateddeliverydatefrom - ? dt_from_string($estimateddeliverydatefrom) - : undef; - # Get the "date to" param. If it is not defined and $delay is not defined too, it is the today's date. -my $estimateddeliverydateto_dt = $estimateddeliverydateto - ? dt_from_string($estimateddeliverydateto) - : ( not defined $delay and not defined $estimateddeliverydatefrom) - ? dt_from_string() - : undef; - -# Format the output of "date from" and "date to" -if ($estimateddeliverydatefrom_dt) { - $estimateddeliverydatefrom = output_pref({dt => $estimateddeliverydatefrom_dt, dateonly => 1}); -} -if ($estimateddeliverydateto_dt) { - $estimateddeliverydateto = output_pref({dt => $estimateddeliverydateto_dt, dateonly => 1}); -} +$estimateddeliverydateto ||= + ( not defined $delay and not defined $estimateddeliverydatefrom ) + ? dt_from_string() + : undef; my $branch = $input->param('branch'); my $op = $input->param('op'); @@ -123,13 +109,13 @@ my @lateorders = Koha::Acquisition::Orders->filter_by_lates( { delay => $delay, ( - $estimateddeliverydatefrom_dt - ? ( estimated_from => $estimateddeliverydatefrom_dt ) + $estimateddeliverydatefrom + ? ( estimated_from => $estimateddeliverydatefrom ) : () ), ( - $estimateddeliverydateto_dt - ? ( estimated_to => $estimateddeliverydateto_dt ) + $estimateddeliverydateto + ? ( estimated_to => $estimateddeliverydateto ) : () ) }, diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index e1b76d3273..f380a675e5 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -119,7 +119,7 @@ my $creator = Koha::Patrons->find( $order->created_by ); my $budget = GetBudget( $order->budget_id ); -my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string; +my $datereceived = $order->datereceived || dt_from_string; # get option values for TaxRates syspref my @gst_values = map { diff --git a/acqui/parcels.pl b/acqui/parcels.pl index cd6e2562b1..9fa697a179 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -75,7 +75,7 @@ use C4::Acquisition qw( GetInvoices GetInvoice AddInvoice ); use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); use Koha::Acquisition::Booksellers; -use Koha::DateUtils qw( output_pref dt_from_string ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my $booksellerid = $input->param('booksellerid'); @@ -100,7 +100,6 @@ my $invoicenumber = $input->param('invoice'); my $shipmentcost = $input->param('shipmentcost'); my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid'); my $shipmentdate = $input->param('shipmentdate'); -$shipmentdate and $shipmentdate = output_pref({ str => $shipmentdate, dateformat => 'iso', dateonly => 1 }); if ( $op and $op eq 'new' ) { if ( C4::Context->preference('AcqWarnOnDuplicateInvoice') ) { @@ -140,8 +139,8 @@ my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); my @parcels = GetInvoices( supplierid => $booksellerid, invoicenumber => $code, - ( $datefrom ? ( shipmentdatefrom => output_pref({ dt => dt_from_string($datefrom), dateformat => 'iso' }) ) : () ), - ( $dateto ? ( shipmentdateto => output_pref({ dt => dt_from_string($dateto), dateformat => 'iso' }) ) : () ), + ( $datefrom ? ( shipmentdatefrom => $datefrom ) : () ), + ( $dateto ? ( shipmentdateto => $dateto ) : () ), order_by => $order ); my $count_parcels = @parcels; diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index efd174c167..861f303da3 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -47,7 +47,6 @@ script to administer the budget periods table use Modern::Perl; use CGI qw ( -utf8 ); -use Koha::DateUtils qw( dt_from_string ); use JSON qw( encode_json ); use Koha::Database; use C4::Koha; @@ -72,8 +71,8 @@ my $op = $input->param('op')||"else"; # get only the columns of aqbudgetperiods in budget_period_hashref my @columns = Koha::Database->new()->schema->source('Aqbudgetperiod')->columns; my $budget_period_hashref = { map { join(' ',@columns) =~ /$_/ ? ( $_ => scalar $input->param($_) ) : () } keys( %{$input->Vars()} ) } ; -$budget_period_hashref->{budget_period_startdate} = dt_from_string( scalar $input->param('budget_period_startdate') ); -$budget_period_hashref->{budget_period_enddate} = dt_from_string( scalar $input->param('budget_period_enddate') ); +$budget_period_hashref->{budget_period_startdate} = $input->param('budget_period_startdate'); +$budget_period_hashref->{budget_period_enddate} = $input->param('budget_period_enddate'); $searchfield =~ s/\,//g; @@ -190,8 +189,8 @@ elsif ( $op eq 'duplicate_form'){ elsif ( $op eq 'duplicate_budget' ){ die "please specify a budget period id\n" if( !defined $budget_period_id || $budget_period_id eq '' ); - my $budget_period_startdate = dt_from_string scalar $input->param('budget_period_startdate'); - my $budget_period_enddate = dt_from_string scalar $input->param('budget_period_enddate'); + my $budget_period_startdate = $input->param('budget_period_startdate'); + my $budget_period_enddate = $input->param('budget_period_enddate'); my $budget_period_description = $input->param('budget_period_description'); my $amount_change_percentage = $input->param('amount_change_percentage'); my $amount_change_round_increment = $input->param('amount_change_round_increment'); diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 83e99d7d0c..def0339d28 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -32,7 +32,7 @@ use C4::Contract qw( GetContracts ModContract ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Booksellers; @@ -96,8 +96,8 @@ elsif ( $op eq 'add_validate' ) { my $is_a_modif = $input->param("is_a_modif"); - my $contractstart_dt = eval { dt_from_string( scalar $input->param('contractstartdate') ); }; - my $contractend_dt = eval { dt_from_string( scalar $input->param('contractenddate') ); }; + my $contractstart_dt = $input->param('contractstartdate'); + my $contractend_dt = $input->param('contractenddate'); unless ( $contractstart_dt and $contractend_dt ) { my $today = dt_from_string; $contractstart_dt ||= $today; @@ -106,8 +106,8 @@ elsif ( $op eq 'add_validate' ) { if ( $is_a_modif ) { ModContract({ - contractstartdate => eval { output_pref({ dt => dt_from_string( $contractstart_dt ), dateformat => 'iso', dateonly => 1 } ); }, - contractenddate => eval { output_pref({ dt => dt_from_string( $contractend_dt ), dateformat => 'iso', dateonly => 1 } ); }, + contractstartdate => $contractstart_dt, + contractenddate => $contractend_dt, contractname => scalar $input->param('contractname'), contractdescription => scalar $input->param('contractdescription'), booksellerid => scalar $input->param('booksellerid'), @@ -118,8 +118,8 @@ elsif ( $op eq 'add_validate' ) { contractname => scalar $input->param('contractname'), contractdescription => scalar $input->param('contractdescription'), booksellerid => scalar $input->param('booksellerid'), - contractstartdate => eval { output_pref({ dt => dt_from_string( scalar $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 } ); }, - contractenddate => eval { output_pref({ dt => dt_from_string( scalar $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 } ); }, + contractstartdate => scalar $input->param('contractstartdate'), + contractenddate => scalar $input->param('contractenddate'), }); } @@ -165,12 +165,6 @@ if ( $op eq 'list' ) { # get contracts my @contracts = @{GetContracts( { booksellerid => $booksellerid } )}; - # format dates - for my $contract ( @contracts ) { - $contract->{contractstartdate} = output_pref({ dt => dt_from_string( $contract->{contractstartdate} ), dateonly => 1 }); - $contract->{contractenddate} = output_pref({ dt => dt_from_string( $contract->{contractenddate} ), dateonly => 1 }), - } - $template->param(loop => \@contracts); #---- END $OP eq DEFAULT diff --git a/admin/categories.pl b/admin/categories.pl index b30193deb9..53c4182b47 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -27,7 +27,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Form::MessagingPreferences; use Koha::Patrons; use Koha::Database; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patron::Categories; use Koha::Libraries; @@ -89,16 +88,6 @@ elsif ( $op eq 'add_validate' ) { my $is_a_modif = $input->param("is_a_modif"); - if ($enrolmentperioddate) { - $enrolmentperioddate = output_pref( - { - dt => dt_from_string($enrolmentperioddate), - dateformat => 'iso', - dateonly => 1, - } - ); - } - if ($is_a_modif) { my $category = Koha::Patron::Categories->find( $categorycode ); $category->categorycode($categorycode); diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 1d354aaf91..3583f59884 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -23,7 +23,6 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); use Koha::Exception; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Database; use Koha::Logger; use Koha::Libraries; @@ -272,8 +271,6 @@ elsif ($op eq 'add') { my $no_auto_renewal_after = $input->param('no_auto_renewal_after'); $no_auto_renewal_after = q{} if $no_auto_renewal_after =~ /^\s*$/; my $no_auto_renewal_after_hard_limit = $input->param('no_auto_renewal_after_hard_limit') || q{}; - $no_auto_renewal_after_hard_limit = eval { dt_from_string( scalar $no_auto_renewal_after_hard_limit ) } if ( $no_auto_renewal_after_hard_limit ); - $no_auto_renewal_after_hard_limit = output_pref( { dt => $no_auto_renewal_after_hard_limit, dateonly => 1, dateformat => 'iso' } ) if ( $no_auto_renewal_after_hard_limit ); my $reservesallowed = strip_non_numeric( scalar $input->param('reservesallowed') ); my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') ); my $holds_per_day = strip_non_numeric( scalar $input->param('holds_per_day') ); @@ -282,8 +279,6 @@ elsif ($op eq 'add') { my $daysmode = $input->param('daysmode'); my $lengthunit = $input->param('lengthunit'); my $hardduedate = $input->param('hardduedate') || q{}; - $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate ); - $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate ); my $hardduedatecompare = $input->param('hardduedatecompare'); my $rentaldiscount = $input->param('rentaldiscount') || 0; my $opacitemholds = $input->param('opacitemholds') || 0; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 49571e790d..bdd2061978 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -35,7 +35,6 @@ use C4::Context; use C4::Circulation qw( barcodedecode LostItem ); use C4::Barcodes; use C4::Barcodes::ValueBuilder; -use Koha::DateUtils qw( dt_from_string ); use Koha::Biblios; use Koha::Items; use Koha::ItemTypes; diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl index 8fcd45beae..e5a0966a63 100755 --- a/cataloguing/value_builder/barcode.pl +++ b/cataloguing/value_builder/barcode.pl @@ -25,7 +25,7 @@ use Modern::Perl; use C4::Context; use C4::Barcodes::ValueBuilder; use C4::Biblio qw( GetMarcFromKohaField ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Algorithm::CheckDigits qw( CheckDigits ); @@ -35,7 +35,7 @@ my $builder = sub { my %args; # find today's date - ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); + ($args{year}, $args{mon}, $args{day}) = split('-', dt_from_string()->ymd()); ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); my $nextnum; diff --git a/cataloguing/value_builder/barcode_manual.pl b/cataloguing/value_builder/barcode_manual.pl index d2b7f7a414..e809ca75f8 100755 --- a/cataloguing/value_builder/barcode_manual.pl +++ b/cataloguing/value_builder/barcode_manual.pl @@ -25,7 +25,7 @@ use Modern::Perl; use C4::Context; use C4::Barcodes::ValueBuilder; use C4::Biblio qw( GetMarcFromKohaField ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $builder = sub { my ( $params ) = @_; @@ -36,7 +36,7 @@ my $builder = sub { $args{dbh} = $dbh; # find today's date - ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); + ($args{year}, $args{mon}, $args{day}) = split('-', dt_from_string()->ymd()); ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); my $nextnum; diff --git a/cataloguing/value_builder/dateaccessioned.pl b/cataloguing/value_builder/dateaccessioned.pl index d1377a2bf6..f0d89b528f 100755 --- a/cataloguing/value_builder/dateaccessioned.pl +++ b/cataloguing/value_builder/dateaccessioned.pl @@ -21,13 +21,12 @@ # along with Koha; if not, see . use Modern::Perl; -use Koha::DateUtils qw( dt_from_string output_pref flatpickr_date_format ); +use Koha::DateUtils qw( flatpickr_date_format ); my $builder = sub { my ( $params ) = @_; my $function_name = $params->{id}; - my $date = output_pref({ dt => dt_from_string, dateonly => 1 }); my $dateformat = flatpickr_date_format(); my $res = <{$tag}->{$subfield}->{authorised_value}) { # now display infos foreach my $num (@getoverdues) { my %overdueforbranch; - my $dt = dt_from_string($num->{date_due}, 'sql'); - $overdueforbranch{'date_due'} = output_pref($dt); + $overdueforbranch{'date_due'} = $num->{date_due}; $overdueforbranch{'title'} = $num->{'title'}; $overdueforbranch{'subtitle'} = $num->{'subtitle'}; $overdueforbranch{'medium'} = $num->{'medium'}; diff --git a/circ/circulation.pl b/circ/circulation.pl index d4b5dcfe94..4648e97a04 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -45,7 +45,7 @@ use Koha::AuthorisedValues; use Koha::CsvProfiles; use Koha::Patrons; use Koha::Patron::Debarments qw( GetDebarments ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Plugins; use Koha::Database; use Koha::BiblioFrameworks; @@ -159,8 +159,6 @@ for my $barcode ( @$barcodes ) { my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate'); my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate'); -$duedatespec = eval { output_pref( { dt => dt_from_string( $duedatespec ), dateformat => 'iso' }); } - if ( $duedatespec ); my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec || $session->param('stickyduedate'); if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { undef $restoreduedatespec; @@ -628,7 +626,7 @@ $template->param( SpecifyDueDate => $duedatespec_allow, PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), debarments => scalar GetDebarments({ borrowernumber => $borrowernumber }), - todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ), + todaysdate => dt_from_string()->set(hour => 23)->set(minute => 59), has_modifications => $has_modifications, override_high_holds => $override_high_holds, nopermission => scalar $query->param('nopermission'), diff --git a/circ/overdue.pl b/circ/overdue.pl index 69750c6bcd..e2bb848d42 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -25,7 +25,7 @@ use C4::Output qw( output_html_with_http_headers ); use CGI qw(-oldstyle_urls -utf8); use C4::Auth qw( get_template_and_user ); use Text::CSV_XS; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Patron::Attribute::Types; use DateTime; use DateTime::Format::MySQL; @@ -337,7 +337,7 @@ if ($noreport) { branchcode => $data->{branchcode}, barcode => $data->{barcode}, itemnum => $data->{itemnumber}, - issuedate => output_pref({ dt => dt_from_string( $data->{issuedate} ), dateonly => 1 }), + issuedate => $data->{issuedate}, biblionumber => $data->{biblionumber}, title => $data->{title}, subtitle => $data->{subtitle}, @@ -374,7 +374,7 @@ if ($noreport) { $new_cgi->delete('op'); $template->param( - todaysdate => output_pref($today_dt), + todaysdate => $today_dt, overdueloop => \@overduedata, nnoverdue => scalar(@overduedata), noverdue_is_plural => scalar(@overduedata) != 1, diff --git a/circ/renew.pl b/circ/renew.pl index e7d49fd23a..f495a4061f 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -24,7 +24,7 @@ use C4::Context; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate AddRenewal ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Database; use Koha::BiblioFrameworks; @@ -92,13 +92,12 @@ if ($barcode) { } if ($can_renew) { my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; - my $date_due; - if ( $cgi->param('renewonholdduedate') ) { - $date_due = dt_from_string( scalar $cgi->param('renewonholdduedate')); - } - if ( C4::Context->preference('SpecifyDueDate') && $hard_due_date ) { - $date_due = dt_from_string( $hard_due_date ); - } + my $date_due = + ( C4::Context->preference('SpecifyDueDate') + && $hard_due_date ) + ? $hard_due_date + : $cgi->param('renewonholdduedate'); + $date_due = AddRenewal( undef, $item->itemnumber(), @@ -133,7 +132,7 @@ if ($barcode) { ); } -$template->param( hard_due_date => ($hard_due_date ? output_pref({ str => $hard_due_date, dateformat => 'iso' }) : undef) ); +$template->param( hard_due_date => $hard_due_date ); # Checking if there is a Fast Cataloging Framework $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl index 7311d1e8c9..51ee09647b 100755 --- a/circ/reserveratios.pl +++ b/circ/reserveratios.pl @@ -27,7 +27,7 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); use C4::Acquisition qw/GetOrdersByBiblionumber/; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Baskets; my $input = CGI->new; @@ -62,9 +62,6 @@ if ( $basketno ){ } } -$startdate = eval { dt_from_string( $startdate ) } if $startdate; -$enddate = eval { dt_from_string( $enddate ) } if $enddate; - my $todaysdate = dt_from_string; # A default of the prior years's holds is a reasonable way to pull holds @@ -85,9 +82,9 @@ my $sqldatewhere = ""; my @query_params = (); $sqldatewhere .= " AND reservedate >= ?"; -push @query_params, output_pref({ dt => $startdate, dateformat => 'iso' }) ; +push @query_params, $startdate; $sqldatewhere .= " AND reservedate <= ?"; -push @query_params, output_pref({ dt => $enddate, dateformat => 'iso' }); +push @query_params, $enddate; my $include_aqorders_qty = $effective_create_items eq 'receiving' diff --git a/circ/returns.pl b/circ/returns.pl index ac3260a5e9..97e0becff0 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -47,7 +47,7 @@ use Koha::AuthorisedValues; use Koha::BiblioFrameworks; use Koha::Calendar; use Koha::Checkouts; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Holds; use Koha::Items; use Koha::Item::Transfers; @@ -215,28 +215,21 @@ my $dest = $query->param('dest'); #dropbox: get last open day (today - 1) my $dropboxdate = Koha::Checkouts::calculate_dropbox_date(); -my $return_date_override = $query->param('return_date_override'); -my $return_date_override_dt; -my $return_date_override_remember = - $query->param('return_date_override_remember'); +my $return_date_override = $query->param('return_date_override') || q{}; if ($return_date_override) { if ( C4::Context->preference('SpecifyReturnDate') ) { - $return_date_override_dt = eval {dt_from_string( $return_date_override ) }; - if ( $return_date_override_dt ) { - # note that we've overriden the return date - $template->param( return_date_was_overriden => 1); - # Save the original format if we are remembering for this series - $template->param( - return_date_override => $return_date_override, - return_date_override_remember => 1 - ) if ($return_date_override_remember); - $return_date_override = - DateTime::Format::MySQL->format_datetime( $return_date_override_dt ); - } - } - else { - $return_date_override = q{}; + # note that we've overriden the return date + $template->param( return_date_was_overriden => 1 ); + + my $return_date_override_remember = + $query->param('return_date_override_remember'); + + # Save the original format if we are remembering for this series + $template->param( + return_date_override => $return_date_override, + return_date_override_remember => 1 + ) if ($return_date_override_remember); } } @@ -327,7 +320,10 @@ if ($barcode) { barcode => $barcode, ); - my $return_date = $dropboxmode ? $dropboxdate : $return_date_override_dt; + my $return_date = + $dropboxmode + ? $dropboxdate + : dt_from_string( $return_date_override ); # Block return if multi-part and confirm has not been received my $needs_confirm = @@ -762,7 +758,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { $ri{day} = $duedate->day(); $ri{hour} = $duedate->hour(); $ri{minute} = $duedate->minute(); - $ri{duedate} = output_pref($duedate); + $ri{duedate} = $duedate; my $patron = Koha::Patrons->find( $riborrowernumber{$_} ); unless ( $dropboxmode ) { $ri{return_overdue} = 1 if (DateTime->compare($duedate, dt_from_string()) == -1); diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index 939891211d..1fcab173bd 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -31,7 +31,7 @@ use C4::Reserves; use Koha::Items; use Koha::ItemTypes; use Koha::Libraries; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::BiblioFrameworks; use Koha::Patrons; @@ -129,7 +129,7 @@ while ( my $library = $libraries->next ) { $template->param( branchesloop => \@branchesloop, - show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), + show_date => dt_from_string, TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), latetransfers => $latetransfers ? 1 : 0, ); diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index fac7f02d98..2e56c5e86f 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -26,7 +26,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Items qw( ModItemTransfer ); use Date::Calc qw( Date_to_Days Today ); use C4::Reserves qw( ModReserve ModReserveCancelAll ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::BiblioFrameworks; use Koha::Items; use Koha::ItemTypes; @@ -127,7 +127,7 @@ $template->param( overcount => scalar @over_loop, cancel_reqs_count => $holds_with_cancellation_requests->count, cancel_reqs => $holds_with_cancellation_requests, - show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), + show_date => dt_from_string, tab => $tab, ); diff --git a/clubs/clubs-add-modify.pl b/clubs/clubs-add-modify.pl index 4a41f5c77a..3c5854376e 100755 --- a/clubs/clubs-add-modify.pl +++ b/clubs/clubs-add-modify.pl @@ -55,10 +55,8 @@ my $club_template_id = $cgi->param('club_template_id'); my $club_template = $club->club_template() || Koha::Club::Templates->find($club_template_id); $club_template_id ||= $club_template->id(); -my $date_start = $cgi->param('date_start'); -$date_start = $date_start ? dt_from_string($date_start) : undef; -my $date_end = $cgi->param('date_end'); -$date_end = $date_end ? dt_from_string($date_end) : undef; +my $date_start = $cgi->param('date_start') || undef; +my $date_end = $cgi->param('date_end') || undef; if ( $cgi->param('name') ) { # Update or create club $club->set( diff --git a/installer/onboarding.pl b/installer/onboarding.pl index 95e2b7b28e..68a1345df1 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -26,7 +26,6 @@ use C4::Members qw( checkcardnumber ); use Koha::Patrons; use Koha::Libraries; use Koha::Database; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patrons; use Koha::Patron::Categories; use Koha::ItemTypes; @@ -100,17 +99,6 @@ if ( $step == 2 ) { my $enrolmentperiod = $input->param('enrolmentperiod'); my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; - #Converts the string into a date format - if ($enrolmentperioddate) { - $enrolmentperioddate = output_pref( - { - dt => dt_from_string($enrolmentperioddate), - dateformat => 'DateTime', - dateonly => 1, - } - ); - } - #Adds a new patron category to the database $category = Koha::Patron::Category->new( { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 2432225d21..fee544a1dc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -35,7 +35,10 @@ flatpickr.l10ns.default.months = flatpickr_months; flatpickr.setDefaults({ allowInput: true, - dateFormat: flatpickr_dateformat_string, + dateFormat: "Y-m-d", + altInput: true, + altFormat: flatpickr_dateformat_string, + altInputClass: 'flatpickr-input', nextArrow: '', prevArrow: '', time_24hr: flatpickr_timeformat, @@ -46,7 +49,7 @@ }, onReady: function( selectedDates, dateStr, instance ){ /* When flatpickr instance is created, automatically append a "clear date" link */ - $(instance.input) + $(instance.input).siblings('input.flatpickr') /* Add a wrapper element so that we can prevent the clear button from wrapping */ .wrap("") .attr("autocomplete", "off") diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc index 84db77943d..e6451add24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc @@ -1,6 +1,5 @@ [% USE Koha %] [% USE Branches %] -[% USE KohaDates %] [% PROCESS 'html_helpers.inc' %]
  1. @@ -106,11 +105,11 @@
  2. - +
    [% INCLUDE 'date-format.inc' %]
  3. - +
    [% INCLUDE 'date-format.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 0eebedc585..536bd16484 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -117,13 +117,13 @@ [% hold.notes | html | html_line_break %] [% IF Koha.Preference('AllowHoldDateInFuture') %] - + [% ELSE %] [% hold.date | $KohaDates %] [% END %] - + [%- IF ( hold.found ) -%] @@ -224,7 +224,7 @@ [% IF Koha.Preference('AutoResumeSuspendedHolds') %] - + [%- ELSE -%] [%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index 27c57bf0e2..fbaa3fa439 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -69,7 +69,7 @@ [% IF readonly %] [% shipmentdate | $KohaDates %] [% ELSE %] - +
[% INCLUDE 'date-format.inc' %]
[% END %] @@ -79,7 +79,7 @@ [% IF readonly %] [% billingdate | $KohaDates %] [% ELSE %] - +
[% INCLUDE 'date-format.inc' %]
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt index b98c4d02b9..f8b9fc981f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -326,12 +326,12 @@
  1. - +
    [% INCLUDE 'date-format.inc' %]
  2. - +
    [% INCLUDE 'date-format.inc' %]
@@ -343,12 +343,12 @@
  1. - +
    [% INCLUDE 'date-format.inc' %]
  2. - +
    [% INCLUDE 'date-format.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 648a170c51..80a1d9da65 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -277,7 +277,7 @@
  1. - +
    [% INCLUDE 'date-format.inc' %]
  2. +
    [% INCLUDE 'date-format.inc' %]
  3. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index 2ec2e9e901..035ca0e49f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -189,14 +189,14 @@
  4. - + Required
    [% INCLUDE 'date-format.inc' %]
  5. - + Required
    [% INCLUDE 'date-format.inc' %]
  6. @@ -259,14 +259,14 @@
    1. - + Required
      [% INCLUDE 'date-format.inc' %]
    2. - + Required
      [% INCLUDE 'date-format.inc' %]
    3. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt index f97eac73ed..c6a6f0c667 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt @@ -132,12 +132,12 @@
    4.   - + Required
      [% INCLUDE 'date-format.inc' %]
    5.   - + Required
      [% INCLUDE 'date-format.inc' %]
    6. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 8f9a736e5e..11b87eb5d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -157,7 +157,7 @@
    7. - +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 992a1d2e7b..44614d73e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -420,7 +420,7 @@ [% END %] [% IF ( INVALID_DATE ) %] -
  7. The due date "[% INVALID_DATE | html %]" is invalid
  8. +
  9. The due date "[% INVALID_DATE | $KohaDates %]" is invalid
  10. [% END %] [% IF ( UNKNOWN_BARCODE ) %] @@ -680,7 +680,7 @@
    Specify due date [% INCLUDE 'date-format.inc' %]:
    [% IF ( duedatespec ) %] - + [% ELSE %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt index ef837f5b2f..b03cbd625c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt @@ -113,7 +113,7 @@
    Due date: - +
    [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt index bceb480a87..5c8bda4b73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt @@ -176,11 +176,11 @@
  11. - +
  12. - +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt index 61203de92e..b42661b803 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -271,12 +271,12 @@ - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index 913994d447..7c5a71883a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -223,7 +223,7 @@
    - +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt index 4f68aae453..1b71449b64 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt @@ -164,12 +164,12 @@
  • - +
  • - +
  • (inclusive) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index dd295153a3..ff5158e9e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -1203,9 +1203,9 @@ [% IF ( riloo.duedate ) %] [% IF ( riloo.return_overdue ) %] - [% riloo.duedate | html %] (overdue) + [% riloo.duedate | $KohaDates as_due_date => 1 %] (overdue) [% ELSE %] - [% riloo.duedate | html %] + [% riloo.duedate | $KohaDates as_due_date => 1 %] [% END %] [% ELSE %] Not checked out diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt index 0cd62451bf..ad8cc0301c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt @@ -75,12 +75,12 @@
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index 2e3bc98874..f0a12f2df2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -58,12 +58,12 @@
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 4003c1cb0b..eb37dbc00e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -793,7 +793,7 @@ [% IF ( itemloo.transfertwhen ) %] In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %], - to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %] + to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | $KohaDates %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt index 42f2f42626..fecdfd926f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt @@ -54,7 +54,7 @@ [% END %]
  • - + Required
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt index 7221556616..7806e4823f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt @@ -166,15 +166,15 @@ [% IF ( missingissue.status44 ) %]Missing (lost)[% END %] [% IF ( missingissue.status7 ) %]Claimed[% END %] - - [% missingissue.planneddate | html %] + + [% missingissue.planneddate | $KohaDates %] [% missingissue.publisheddate | $KohaDates %] [% missingissue.claims_count | html %] - - [% missingissue.claimdate | html %] + + [% missingissue.claimdate | $KohaDates %] [% FOR field IN additional_fields_for_subscription %] [% IF field.authorised_value_category %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt index fa5a68e8f2..8104c6d8a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt @@ -289,7 +289,7 @@
  • - +
  • [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %] @@ -404,7 +404,7 @@
  • - +
  • [% FOR field IN additional_fields_for_subscription %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 5c1e8ac1a9..e6406094fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -302,7 +302,7 @@ fieldset.rows table { clear: none; margin: 0; }
  • [% UNLESS (more_than_one_serial) %] - + [% ELSE %] [% firstacquidate | $KohaDates %] @@ -312,7 +312,7 @@ fieldset.rows table { clear: none; margin: 0; } [% IF (more_than_one_serial) %]
  • - +
  • [% END %]
  • @@ -366,11 +366,11 @@ fieldset.rows table { clear: none; margin: 0; }
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt index f8524e1a56..3c8067b349 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt @@ -41,14 +41,14 @@ Subscription start date - (start date of the 1st subscription) + (start date of the 1st subscription)
    [% INCLUDE 'date-format.inc' %]
    Subscription end date - (if empty, subscription is still active) + (if empty, subscription is still active)
    [% INCLUDE 'date-format.inc' %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 1e266d5855..09105f60eb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -500,7 +500,7 @@ - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %] @@ -517,7 +517,7 @@ - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %] @@ -547,7 +547,7 @@
  • - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt index abd19df0a8..a37d796740 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -64,9 +64,7 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% IF ( message_loop ) %]
    [% FOREACH message_loo IN message_loop %] - [% IF ( message_loo.date_from ) %]Error: "Date from" is not a legal value ("[% message_loo.date_from | html %]"). - [% ELSIF ( message_loo.date_to ) %]Error: "Date to" is not a legal value ("[% message_loo.date_to | html %]"). - [% ELSIF ( message_loo.failed_ok ) %]Error: Failed to approve term ([% message_loo.failed_ok | html %]). + [% IF ( message_loo.failed_ok ) %]Error: Failed to approve term ([% message_loo.failed_ok | html %]). [% ELSIF ( message_loo.failed_rej ) %]Error: Failed to reject term ([% message_loo.failed_rej | html %]). [% ELSIF ( message_loo.approver ) %]No match for user ([% message_loo.approver | html %]). FILTER REQUIRES BORROWERNUMBER (not name). [% ELSIF ( message_loo.approved_by ) %]Error: No match for borrowernumber ([% message_loo.approved_by | html %]). diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index e5e82bb2e6..d1a1e20ec3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -236,12 +236,12 @@ [% END %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %] [% IF category == 'news' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt index a35f8cbf15..5aeee985a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt @@ -484,7 +484,7 @@ function changeBranch () { var branch = $("#branch option:selected").val(); - location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]"; + location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | $KohaDates %]"; } /** diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 4f952b5452..d66d88c63e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -85,7 +85,7 @@
    Parameters
      -
    1. +
    2. @@ -185,7 +185,7 @@

    3. - + (Skip records marked as seen on or after this date.)
    4. diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 6f58302e9a..597bb5d141 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -128,7 +128,7 @@ function select_user(borrowernumber, borrower, relationship) { function CalculateAge(dateofbirth) { var today = new Date(); - var dob = Date_from_syspref(dateofbirth); + var dob = new Date(dateofbirth); var age = {}; age.year = today.getFullYear() - dob.getFullYear(); diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index d2f3ea113f..4dba30276d 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -30,7 +30,6 @@ use C4::Biblio qw( TransformMarcToKoha ); use C4::Creators::Lib qw( html_table ); use Koha::Logger; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Items; use Koha::ItemTypes; use Koha::SearchEngine::Search; @@ -67,21 +66,13 @@ if ( $op eq "do_search" ) { $dateto = $query->param('dateto'); if ($datefrom) { - $datefrom = eval { dt_from_string ( $datefrom ) }; - if ($datefrom) { - $datefrom = output_pref( { dt => $datefrom, dateonly => 1, dateformat => 'iso' } ); - $ccl_query .= ' AND ' if $ccl_textbox; - $ccl_query .= "acqdate,ge,st-date-normalized=" . $datefrom; - } + $ccl_query .= ' AND ' if $ccl_textbox; + $ccl_query .= "acqdate,ge,st-date-normalized=" . $datefrom; } if ($dateto) { - $dateto = eval { dt_from_string ( $dateto ) }; - if ($dateto) { - $dateto = output_pref( { dt => $dateto, dateonly => 1, dateformat => 'iso' } ); - $ccl_query .= ' AND ' if ( $ccl_textbox || $datefrom ); - $ccl_query .= "acqdate,le,st-date-normalized=" . $dateto; - } + $ccl_query .= ' AND ' if ( $ccl_textbox || $datefrom ); + $ccl_query .= "acqdate,le,st-date-normalized=" . $dateto; } my $offset = $startfrom > 1 ? $startfrom - 1 : 0; diff --git a/members/housebound.pl b/members/housebound.pl index c86fad8b33..27e69ef593 100755 --- a/members/housebound.pl +++ b/members/housebound.pl @@ -30,7 +30,6 @@ use C4::Auth qw( get_template_and_user ); use C4::Context; use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); use DateTime; -use Koha::DateUtils qw( dt_from_string ); use Koha::Libraries; use Koha::Patrons; use Koha::Patron::Categories; @@ -124,7 +123,7 @@ if ( $method eq 'updateconfirm' and $houseboundprofile ) { # simple display. $visit->set({ borrowernumber => scalar $input->param('borrowernumber') // q{}, - appointment_date => dt_from_string($input->param('date') // q{}), + appointment_date => scalar $input->param('date') // q{}, day_segment => scalar $input->param('segment') // q{}, chooser_brwnumber => scalar $input->param('chooser') // q{}, deliverer_brwnumber => scalar $input->param('deliverer') // q{}, @@ -138,7 +137,7 @@ if ( $method eq 'updateconfirm' and $houseboundprofile ) { # to simple display. my $visit = Koha::Patron::HouseboundVisit->new({ borrowernumber => scalar $input->param('borrowernumber') // q{}, - appointment_date => dt_from_string($input->param('date') // q{}), + appointment_date => scalar $input->param('date') // q{}, day_segment => scalar $input->param('segment') // q{}, chooser_brwnumber => scalar $input->param('chooser') // q{}, deliverer_brwnumber => scalar $input->param('deliverer') // q{}, diff --git a/members/memberentry.pl b/members/memberentry.pl index ee44ea6874..9921c409c6 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -37,7 +37,7 @@ use Koha::AuthorisedValues; use Koha::Email; use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments ); use Koha::Cities; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Libraries; use Koha::Patrons; use Koha::Patron::Attribute::Types; @@ -191,19 +191,6 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } } - foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) { - next unless exists $newdata{$_}; - my $userdate = $newdata{$_} or next; - - my $formatteddate = eval { output_pref({ dt => dt_from_string( $userdate ), dateformat => 'iso', dateonly => 1 } ); }; - if ( $formatteddate ) { - $newdata{$_} = $formatteddate; - } else { - $template->param( "ERROR_$_" => 1 ); - push(@errors,"ERROR_$_"); - } - } - # check permission to modify login info. if (ref($borrower_data) && ($category->category_type eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) { $NoUpdateLogin = 1; @@ -761,10 +748,10 @@ if ($nok) { #Formatting data for display if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){ - $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $data{'dateenrolled'} = dt_from_string; } if ( $op eq 'duplicate' ) { - $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + $data{'dateenrolled'} = dt_from_string; $data{dateexpiry} = $category->get_expiry_date( $data{dateenrolled} ); } if (C4::Context->preference('uppercasesurnames')) { @@ -772,13 +759,6 @@ if (C4::Context->preference('uppercasesurnames')) { $data{'contactname'} &&= uc( $data{'contactname'} ); } -foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) { - if ( $data{$_} ) { - $data{$_} = eval { output_pref({ dt => dt_from_string( $data{$_} ), dateonly => 1 } ); }; # back to syspref for display - } - $template->param( $_ => $data{$_}); -} - if ( C4::Context->preference('ExtendedPatronAttributes') ) { patron_attributes_form( $template, $extended_patron_attributes, $op ); } diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 3edf6ed736..e919d42a66 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -163,7 +163,7 @@ for my $overdue ( @{$overdues} ) { itemnumber => $overdue->{itemnumber}, borrowernumber => $overdue->{borrowernumber}, amount => $amount, - due => output_pref($datedue), + due => $datedue, } ); $updated++; diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index 26ebf25dde..ca6cb11d5b 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -25,7 +25,7 @@ use C4::Context; use C4::Serials qw( GetSubscription GetNextDate ModSerialStatus ); use C4::Serials::Frequency; use C4::Log qw( cronlogaction ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Date::Calc qw( check_date Date_to_Days ); use Getopt::Long qw( GetOptions ); @@ -113,7 +113,7 @@ while ( my $issue = $sth->fetchrow_hashref ) { if ( $subscription && $publisheddate ) { my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata ); - my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + my $today = dt_from_string->ymd; if ( $nextpublisheddate && $today ) { my ( $year, $month, $day ) = split( /-/, $nextpublisheddate ); diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl index d4141b25f3..36d5fb20b2 100755 --- a/misc/cronjobs/staticfines.pl +++ b/misc/cronjobs/staticfines.pl @@ -36,7 +36,7 @@ use C4::Calendar qw(); # don't need any exports from Calendar use C4::Log qw( cronlogaction ); use Getopt::Long qw( GetOptions ); use List::MoreUtils qw( none ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Patrons; my $help = 0; @@ -126,7 +126,7 @@ if (defined $borrowernumberlimit) { my $overdueItemsCounted = 0; my %calendars = (); $today = dt_from_string; -$today_iso = output_pref( { dt => $today, dateonly => 1, dateformat => 'iso' } ); +$today_iso = $today->ymd; my ($tyear, $tmonth, $tday) = split( /-/, $today_iso ); $today_days = Date_to_Days( $tyear, $tmonth, $tday ); diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index f456362c3a..427c99d53a 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -35,7 +35,7 @@ use Koha::Patron::Consent; use Koha::Patron::Modification; use Koha::Patron::Modifications; use C4::Scrubber; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Email; use Koha::Libraries; use Koha::Patron::Attribute::Types; @@ -545,20 +545,6 @@ sub ParseCgiForBorrower { } } - if ( defined $borrower{'dateofbirth'} ) { - my $dob_dt; - $dob_dt = eval { dt_from_string( $borrower{'dateofbirth'} ); } - if ( $borrower{'dateofbirth'} ); - - if ( $dob_dt ) { - $borrower{'dateofbirth'} = output_pref( { dt => $dob_dt, dateonly => 1, dateformat => 'iso' } ); - } - else { - # Trigger validation - $borrower{'dateofbirth'} = undef; - } - } - # Replace checkbox 'agreed' by datetime in gdpr_proc_consent $borrower{gdpr_proc_consent} = dt_from_string if $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed'; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index e32a41ea91..724a2ba354 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -34,7 +34,6 @@ use C4::Overdues; use Koha::AuthorisedValues; use Koha::Biblios; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::CirculationRules; use Koha::Items; use Koha::ItemTypes; diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index b2ab7609bc..ec3ced7f9f 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -37,7 +37,7 @@ use Koha::AuthorisedValues; use Koha::Libraries; use Koha::Patrons; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my $op = $input->param('op') || 'else'; @@ -151,7 +151,6 @@ my $patrons_total_suggestions_count = 0; if ( $borrowernumber ){ if ( C4::Context->preference("MaxTotalSuggestions") ne '' && C4::Context->preference("NumberOfSuggestionDays") ne '' ) { my $suggesteddate_from = dt_from_string()->subtract(days=>C4::Context->preference("NumberOfSuggestionDays")); - $suggesteddate_from = output_pref({ dt => $suggesteddate_from, dateformat => 'iso', dateonly => 1 }); $patrons_total_suggestions_count = Koha::Suggestions->search({ suggestedby => $borrowernumber, suggesteddate => { '>=' => $suggesteddate_from } })->count; } diff --git a/pos/register.pl b/pos/register.pl index b6f7cfbaef..8250b663a9 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -26,7 +26,7 @@ use C4::Context; use Koha::Account::Lines; use Koha::Cash::Registers; use Koha::Database; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new(); @@ -96,10 +96,12 @@ else { } } ); - $template->param( past_accountlines => $past_accountlines ); - $template->param( trange_f => output_pref({dt => $start, dateonly => 1})); + $template->param( + past_accountlines => $past_accountlines, + trange_f => $start, + ); } - $template->param( trange_t => output_pref({dt => $end, dateonly => 1})); + $template->param( trange_t => $end, ); my $op = $input->param('op') // ''; if ( $op eq 'cashup' ) { diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl index c804f72abe..63d0152846 100755 --- a/reports/acquisitions_stats.pl +++ b/reports/acquisitions_stats.pl @@ -27,7 +27,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Koha qw( GetAuthorisedValues ); use C4::Biblio qw( GetMarcSubfieldStructureFromKohaField ); use Koha::ItemTypes; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Libraries; =head1 NAME @@ -46,14 +45,6 @@ my $fullreportname = "reports/acquisitions_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->multi_param("Filter"); -$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[0] ); -$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[1] ); -$filters[2] = eval { output_pref( { dt => dt_from_string( $filters[2]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[2] ); -$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[3] ); my $podsp = $input->param("PlacedOnDisplay"); my $rodsp = $input->param("ReceivedOnDisplay"); my $calc = $input->param("Cellvalue"); @@ -235,13 +226,7 @@ sub calculate { if ( ( ( $i == 1 ) or ( $i == 3 ) ) and ( @$filters[ $i - 1 ] ) ) { $cell{err} = 1 if ( @$filters[$i] lt @$filters[ $i - 1 ] ); } - # format the dates filters, otherwise just fill as is - if ($i >= 4) { - $cell{filter} = @$filters[$i]; - } else { - $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } + $cell{filter} = @$filters[$i]; $cell{crit} = $i; push @loopfilter, \%cell; } diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl index 912798ea7b..e81615044f 100755 --- a/reports/bor_issues_top.pl +++ b/reports/bor_issues_top.pl @@ -25,7 +25,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Context; use C4::Reports qw( GetDelimiterChoices ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::ItemTypes; use Koha::Patron::Categories; @@ -43,9 +42,6 @@ my $do_it = $input->param('do_it'); my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->multi_param("Filter"); -foreach ( @filters[0..3] ) { - $_ and $_ = eval { output_pref( { dt => dt_from_string ( $_ ), dateonly => 1, dateformat => 'iso' }); }; -} my $output = $input->param("output"); my $basename = $input->param("basename"); my ($template, $borrowernumber, $cookie) @@ -143,7 +139,6 @@ sub calculate { if (($i==1) and (@$filters[$i-1])) { $cell{err} = 1 if (@$filters[$i]<@$filters[$i-1]) ; } - # format the dates filters, otherwise just fill as is $cell{filter} .= @$filters[$i]; defined ($cellmap[$i]) and $cell{crit} .= $cellmap[$i]; diff --git a/reports/borrowers_out.pl b/reports/borrowers_out.pl index 9d7fba6cac..bad3e76db3 100755 --- a/reports/borrowers_out.pl +++ b/reports/borrowers_out.pl @@ -25,7 +25,6 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Reports qw( GetDelimiterChoices ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patron::Categories; =head1 NAME @@ -44,8 +43,6 @@ my $fullreportname = "reports/borrowers_out.tt"; my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->multi_param("Filter"); -$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[1] ); my $output = $input->param("output"); my $basename = $input->param("basename"); diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index 7263c3b0dc..2989e33893 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -27,7 +27,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Reports qw( GetDelimiterChoices ); use Koha::AuthorisedValues; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Libraries; use Koha::Patron::Attribute::Types; use Koha::Patron::Categories; @@ -48,10 +47,6 @@ my $fullreportname = "reports/borrowers_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->multi_param("Filter"); -$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[3] ); -$filters[4] = eval { output_pref ({ dt => dt_from_string( $filters[4]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[4] ); my $digits = $input->param("digits"); our $period = $input->param("period"); my $borstat = $input->param("status"); @@ -190,13 +185,6 @@ sub calculate { foreach my $i (0 .. scalar @$filters) { my %cell; if ( @$filters[$i] ) { - if ($i == 3 or $i == 4) { - $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } else { - $cell{filter} = @$filters[$i]; - } - if ( $i == 0) { $cell{crit} = "Cat code"; } elsif ( $i == 1 ) { $cell{crit} = "ZIP/Postal code"; } elsif ( $i == 2 ) { $cell{crit} = "Branch code"; } diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index 871032941c..6bd869d34b 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -22,7 +22,7 @@ use C4::Context; use C4::Reports qw( GetDelimiterChoices ); use C4::Output qw( output_html_with_http_headers ); use DateTime; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Text::CSV::Encoded; use List::Util qw( any ); @@ -51,8 +51,8 @@ $template->param( ); #Initialize date pickers to today -my $fromDate = dt_from_string; -my $toDate = dt_from_string; +my $fromDate = $input->param("from") || dt_from_string; +my $toDate = $input->param("to") || dt_from_string; my @debit_types = Koha::Account::DebitTypes->search()->as_list; @@ -62,10 +62,6 @@ my $registerid; if ($do_it) { - $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string, - dateformat => 'sql', dateonly => 1 }); #for sql query - $toDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string, - dateformat => 'sql', dateonly => 1 }); #for sql query my $whereTType = q{}; my @extra_params; # if we add conditions to the select we need extra params diff --git a/reports/cat_issues_top.pl b/reports/cat_issues_top.pl index 23666f314c..87f1944311 100755 --- a/reports/cat_issues_top.pl +++ b/reports/cat_issues_top.pl @@ -25,7 +25,6 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Koha qw( GetAuthorisedValues ); use C4::Reports qw( GetDelimiterChoices ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::ItemTypes; =head1 NAME @@ -42,9 +41,6 @@ my $fullreportname = "reports/cat_issues_top.tt"; my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->multi_param("Filter"); -foreach ( @filters[0..3] ) { - $_ and $_ = eval { output_pref( { dt => dt_from_string ( $_ ), dateonly => 1, dateformat => 'iso' } ); }; -} my $output = $input->param("output"); my $basename = $input->param("basename"); @@ -165,13 +161,7 @@ sub calculate { if (($i==1) and (@$filters[$i-1])) { $cell{err} = 1 if (@$filters[$i]<@$filters[$i-1]) ; } - # format the dates filters, otherwise just fill as is - if ($i>=2) { - $cell{filter} .= @$filters[$i]; - } else { - $cell{filter} .= eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } + $cell{filter} .= @$filters[$i]; $cell{crit} .="Issue From" if ($i==0); $cell{crit} .="Issue To" if ($i==1); $cell{crit} .="Return From" if ($i==2); diff --git a/reports/dictionary.pl b/reports/dictionary.pl index ef95e7108d..5920e22ec1 100755 --- a/reports/dictionary.pl +++ b/reports/dictionary.pl @@ -137,9 +137,6 @@ elsif ( $phase eq 'New Term step 5' ) { $tmp_hash{'name'} = $crit; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - my $value_dt = eval { dt_from_string( $value ) }; - $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) - if ( $value_dt ); $query_criteria .= " AND $crit='$value'"; } @@ -151,9 +148,6 @@ elsif ( $phase eq 'New Term step 5' ) { $tmp_hash{'name'} = "$crit Start"; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - my $value_dt = eval { dt_from_string( $value ) }; - $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) - if ( $value_dt ); $query_criteria .= " AND $crit >= '$value'"; } @@ -163,9 +157,6 @@ elsif ( $phase eq 'New Term step 5' ) { $tmp_hash{'name'} = "$crit End"; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - my $value_dt = eval { dt_from_string( $value ) }; - $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) - if ( $value_dt ); $query_criteria .= " AND $crit <= '$value'"; } diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index c497dcc0a7..48647c3d90 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -30,7 +30,6 @@ use C4::Output qw( pagination_bar output_html_with_http_headers ); use C4::Context; use Koha::Caches; use C4::Log qw( logaction ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::AuthorisedValue; use Koha::AuthorisedValues; use Koha::BiblioFrameworks; @@ -401,32 +400,13 @@ elsif ( $phase eq 'Choose these criteria' ) { # If value is not defined, then it may be range values if (!defined $value) { - my $fromvalue = $input->param( "from_" . $crit . "_value" ); my $tovalue = $input->param( "to_" . $crit . "_value" ); - # If the range values are dates - my $fromvalue_dt; - $fromvalue_dt = eval { dt_from_string( $fromvalue ); } if ( $fromvalue ); - my $tovalue_dt; - $tovalue_dt = eval { dt_from_string( $tovalue ); } if ($tovalue); - if ( $fromvalue_dt && $tovalue_dt ) { - $fromvalue = output_pref( { dt => dt_from_string( $fromvalue_dt ), dateonly => 1, dateformat => 'iso' } ); - $tovalue = output_pref( { dt => dt_from_string( $tovalue_dt ), dateonly => 1, dateformat => 'iso' } ); - } - if ($fromvalue && $tovalue) { $query_criteria .= " AND $crit >= '$fromvalue' AND $crit <= '$tovalue'"; } - } else { - - # If value is a date - my $value_dt; - $value_dt = eval { dt_from_string( $value ); } if ( $value ); - if ( $value_dt ) { - $value = output_pref( { dt => dt_from_string( $value_dt ), dateonly => 1, dateformat => 'iso' } ); - } # don't escape runtime parameters, they'll be at runtime if ($value =~ /<<.*>>/) { $query_criteria .= " AND $crit=$value"; diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl index 7be36a54c2..ebba6994a4 100755 --- a/reports/issues_avg_stats.pl +++ b/reports/issues_avg_stats.pl @@ -24,7 +24,6 @@ use CGI qw ( -utf8 ); use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Reports qw( GetDelimiterChoices ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::ItemTypes; use Koha::Patron::Categories; use Date::Calc qw( Delta_Days ); @@ -43,15 +42,6 @@ my $fullreportname = "reports/issues_avg_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->multi_param("Filter"); -$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[0] ); -$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[1] ); -$filters[2] = eval { output_pref( { dt => dt_from_string( $filters[2]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[2] ); -$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[3] ); - my $podsp = $input->param("IssueDisplay"); my $rodsp = $input->param("ReturnDisplay"); @@ -186,13 +176,7 @@ sub calculate { if (($i==1) and (@$filters[$i-1])) { $cell{err} = 1 if (@$filters[$i]<@$filters[$i-1]) ; } - # format the dates filters, otherwise just fill as is - if ($i>=4) { - $cell{filter} .= @$filters[$i]; - } else { - $cell{filter} .= eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } + $cell{filter} .= @$filters[$i]; $cell{crit} .="Issue From" if ($i==0); $cell{crit} .="Issue To" if ($i==1); $cell{crit} .="Issue Month" if ($i==2); diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 6b541f7b28..e06bb5186b 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -28,7 +28,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Reports qw( GetDelimiterChoices ); use Koha::AuthorisedValues; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::ItemTypes; use Koha::Patron::Attribute::Types; @@ -48,10 +47,6 @@ my $do_it = $input->param('do_it'); my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->multi_param("Filter"); -$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[0] ); -$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[1] ); my $podsp = $input->param("DisplayBy"); my $type = $input->param("PeriodTypeSel"); my $daysel = $input->param("PeriodDaySel"); @@ -220,12 +215,7 @@ sub calculate { $cell{err} = 1 if ( @$filters[$i] < @$filters[ $i - 1 ] ); } # format the dates filters, otherwise just fill as is - if ($i>=2) { - $cell{filter} = @$filters[$i]; - } else { - $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } + $cell{filter} = @$filters[$i]; $cell{crit} = $i; push @loopfilter, \%cell; diff --git a/reports/orders_by_fund.pl b/reports/orders_by_fund.pl index a44ca3f864..b630350b28 100755 --- a/reports/orders_by_fund.pl +++ b/reports/orders_by_fund.pl @@ -33,7 +33,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Budgets qw( GetBudgetsReport GetBudgetHierarchy ); use C4::Acquisition qw( GetBasket get_rounded_price ); use Koha::Biblios; -use Koha::DateUtils qw( dt_from_string output_pref ); my $query = CGI->new; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -106,9 +105,7 @@ if ( $get_orders ) { $order->{'total_rrp'} = get_rounded_price($order->{'quantity'}) * $order->{'rrp'}; $order->{'total_ecost'} = get_rounded_price($order->{'quantity'}) * $order->{'ecost'}; - # Format the dates and currencies correctly - $order->{'datereceived'} = output_pref(dt_from_string($order->{'datereceived'})); - $order->{'entrydate'} = output_pref(dt_from_string($order->{'entrydate'})); + # Format the currencies correctly $total_quantity += $order->{'quantity'}; $total_rrp += $order->{'total_rrp'}; $total_ecost += $order->{'total_ecost'}; diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index 94bd5dad8b..f7db54d7bb 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -28,7 +28,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Reports qw( GetDelimiterChoices ); use C4::Members; use Koha::AuthorisedValues; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::ItemTypes; use Koha::Libraries; use Koha::Patron::Categories; @@ -170,21 +169,13 @@ sub calculate { my @loopfilter; foreach my $filter ( keys %$filters_hashref ) { $filters_hashref->{$filter} =~ s/\*/%/; - if ( $filter =~ /date/ ) { - $filters_hashref->{$filter} = - eval { output_pref( { dt => dt_from_string( $filters_hashref->{$filter} ), dateonly => 1, dateformat => 'iso' }); }; - } } #display @loopfilter = map { { crit => $_, - filter => ( - $_ =~ /date/ - ? eval { output_pref( { dt => dt_from_string( $filters_hashref->{$_} ), dateonly => 1 }); } - : $filters_hashref->{$_} - ) + filter => $filters_hashref->{$_}, } } sort keys %$filters_hashref; diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl index 8fa885dd23..ec78f683be 100755 --- a/reserve/modrequest.pl +++ b/reserve/modrequest.pl @@ -31,7 +31,6 @@ use Try::Tiny; use C4::Output; use C4::Reserves qw( ModReserve ModReserveCancelAll ); use C4::Auth qw( get_template_and_user ); -use Koha::DateUtils qw( dt_from_string ); use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; my $query = CGI->new; @@ -77,14 +76,14 @@ else { my $params = { rank => $rank[$i], reserve_id => $reserve_id[$i], - expirationdate => $expirationdates[$i] ? dt_from_string($expirationdates[$i]) : undef, + expirationdate => $expirationdates[$i] || undef, branchcode => $branch[$i], itemnumber => $itemnumber[$i], defined $suspend_until ? ( suspend_until => $suspend_until ) : (), cancellation_reason => $cancellation_reason, }; if (C4::Context->preference('AllowHoldDateInFuture')) { - $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef; + $params->{reservedate} = $reservedates[$i] || undef; } try { diff --git a/reserve/request.pl b/reserve/request.pl index 12c675240f..8c64f43160 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -38,11 +38,10 @@ use C4::Items qw( get_hostitemnumbers_of ); use C4::Koha qw( getitemtypeimagelocation ); use C4::Serials qw( CountSubscriptionFromBiblionumber ); use C4::Circulation qw( GetTransfers _GetCircControlBranch GetBranchItemRule ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use C4::Search qw( enabled_staff_search_views ); use Koha::Biblios; -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Checkouts; use Koha::Holds; use Koha::CirculationRules; @@ -90,7 +89,6 @@ my $messages; my $exceeded_maxreserves; my $exceeded_holds_per_record; -my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); my $action = $input->param('action'); $action ||= q{}; @@ -456,7 +454,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) GetTransfers($item_object->itemnumber); # FIXME replace with get_transfer if ( defined $transfertwhen && $transfertwhen ne '' ) { - $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 }); + $item->{transfertwhen} = $transfertwhen; $item->{transfertfrom} = $transfertfrom; $item->{transfertto} = $transfertto; $item->{nocancel} = 1; @@ -663,7 +661,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) $template->param( itemdata_enumchron => $itemdata_enumchron, itemdata_ccode => $itemdata_ccode, - date => $date, + date => dt_from_string, biblionumber => $biblionumber, findborrower => $findborrower, biblio => $biblio, diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 2b7f17103e..b80fa46f21 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -72,7 +72,7 @@ use C4::Context; use C4::Serials qw( GetSerials GetSerials2 GetSerialInformation HasSubscriptionExpired GetSubscription abouttoexpire NewIssue ModSerialStatus GetPreviousSerialid AddItem2Serial ); use C4::Search qw( enabled_staff_search_views ); -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Items; use Koha::Serial::Items; @@ -128,7 +128,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my @serialdatalist; my %processedserialid; -my $today = output_pref( { dt => dt_from_string, dateonly => 1 } ); +my $today = dt_from_string; foreach my $serialid (@serialids) { @@ -140,14 +140,6 @@ foreach my $serialid (@serialids) { { my $serinfo = GetSerialInformation($serialid); #TODO duplicates work done by GetSerials2 above - for my $d ( qw( publisheddate planneddate )){ - if ( $serinfo->{$d} =~m/^00/ ) { - $serinfo->{$d} = q{}; - } - else { - $serinfo->{$d} = output_pref( { dt => dt_from_string( $serinfo->{$d} ), dateonly => 1 } ); - } - } $serinfo->{arriveddate} = $today; $serinfo->{'editdisable'} = ( @@ -216,10 +208,10 @@ if ( $op and $op eq 'serialchangestatus' ) { my ($plan_date, $pub_date); if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') { - $plan_date = eval { output_pref( { dt => dt_from_string( $planneddates[$i] ), dateonly => 1, dateformat => 'iso' } ); }; + $plan_date = $planneddates[$i]; } if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') { - $pub_date = eval { output_pref( { dt => dt_from_string( $publisheddates[$i] ), dateonly => 1, dateformat => 'iso' } ); }; + $pub_date = $publisheddates[$i]; } if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) { diff --git a/serials/serials-search.pl b/serials/serials-search.pl index 52d9cdfabf..45b85817d1 100755 --- a/serials/serials-search.pl +++ b/serials/serials-search.pl @@ -88,7 +88,6 @@ for my $field ( @additional_fields ) { } } -my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef; my @subscriptions; my $mana_statuscode; if ($searched){ @@ -115,7 +114,7 @@ if ($searched){ branch => $branch, additional_fields => \@additional_field_filters, location => $location, - expiration_date => $expiration_date_dt, + expiration_date => $expiration_date, }); } } @@ -133,7 +132,7 @@ if ($mana) { bookseller_filter => $bookseller, branch_filter => $branch, location_filter => $location, - expiration_date_filter => $expiration_date_dt, + expiration_date_filter => $expiration_date, done_searched => $searched, routing => $routing, additional_field_filters => \@additional_field_filters, @@ -187,7 +186,7 @@ else bookseller_filter => $bookseller, branch_filter => $branch, location_filter => $location, - expiration_date_filter => $expiration_date_dt, + expiration_date_filter => $expiration_date, branches_loop => \@branches_loop, done_searched => $searched, routing => $routing, diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl index 6420e50ce1..e4fe56781a 100755 --- a/serials/showpredictionpattern.pl +++ b/serials/showpredictionpattern.pl @@ -36,7 +36,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq ); use C4::Serials::Frequency; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { @@ -90,16 +90,11 @@ my %pattern = ( every3 => scalar $input->param('every3') // '', ); -$firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); } - or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); +$firstacquidate = $firstacquidate ? dt_from_string($firstacquidate)->ymd : dt_from_string->ymd; -$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); }; +$enddate = dt_from_string($enddate)->ymd; -if($nextacquidate) { - $nextacquidate = eval { output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } ); }; -} else { - $nextacquidate = $firstacquidate; -} +$nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate; my $date = $nextacquidate; my %subscription = ( @@ -112,7 +107,7 @@ my %subscription = ( innerloop3 => scalar $input->param('innerloop3') // '', irregularity => '', countissuesperunit => 1, - firstacquidate => $firstacquidate, + firstacquidate => $firstacquidate->ymd, ); my $issuenumber; diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index e0c571b8aa..0e5ec8f80a 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -165,6 +165,7 @@ if ( $op =~ /save/i ) { else { for my $date_key ( qw( suggesteddate manageddate accepteddate rejecteddate ) ) { + # FIXME Do we need this? $suggestion_only->{$date_key} = dt_from_string( $suggestion_only->{$date_key} ) if $suggestion_only->{$date_key}; } diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 5adb5cebfd..6fb2c48019 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -356,7 +356,6 @@ $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); my $resdate= dt_from_string(); $resdate->add_duration(DateTime::Duration->new(days => 4)); -$resdate=output_pref($resdate); my $reserve_id = AddReserve( { branchcode => $branch_1, @@ -397,7 +396,7 @@ my $now_reserve_id = AddReserve( borrowernumber => $requesters{$branch_1}, biblionumber => $bibnum, priority => 2, - reservation_date => output_pref(dt_from_string()), + reservation_date => dt_from_string(), } ); my $which_highest; @@ -441,7 +440,6 @@ t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); $resdate= dt_from_string(); $resdate->add_duration(DateTime::Duration->new(days => 2)); -$resdate=output_pref($resdate); AddReserve( { branchcode => $branch_1, @@ -530,7 +528,7 @@ AddReserve( borrowernumber => $requesters{'CPL2'}, biblionumber => $bibnum, priority => $p, - reservation_date => output_pref($resdate), + reservation_date => $resdate, } ); $p = C4::Reserves::CalculatePriority($bibnum); @@ -564,14 +562,14 @@ AddReserve({ borrowernumber => $borrowernumber_tmp_1, biblionumber => $bibnum, priority => 3, - reservation_date => output_pref($date_in_future) + reservation_date => $date_in_future }); AddReserve({ branchcode => 'CPL', borrowernumber => $borrowernumber_tmp_2, biblionumber => $bibnum, priority => 4, - reservation_date => output_pref($date_in_future) + reservation_date => $date_in_future }); my @r1 = Koha::Holds->search({ borrowernumber => $borrowernumber_tmp_1 })->as_list; my @r2 = Koha::Holds->search({ borrowernumber => $borrowernumber_tmp_2 })->as_list; @@ -729,7 +727,6 @@ is( $status, '', 'MoveReserve filled waiting hold'); # hold from A pos 1, tomorrow, no fut holds: not filled $resdate= dt_from_string(); $resdate->add_duration(DateTime::Duration->new(days => 1)); -$resdate=output_pref($resdate); AddReserve( { branchcode => $branch_1, @@ -773,7 +770,6 @@ is( $status, '', 'MoveReserve filled future waiting hold now'); # hold from A pos 1, today+3, fut holds=2: MoveReserve should not fill it $resdate= dt_from_string(); $resdate->add_duration(DateTime::Duration->new(days => 3)); -$resdate=output_pref($resdate); AddReserve( { branchcode => $branch_1, diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 41e77bc40c..eb432dc914 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -306,17 +306,17 @@ subtest 'test_updateClaim' => sub { is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids'); my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serial1->serialid); - is($late_or_missing_issues_1_0[0]->{claimdate}, $today, 'Got the expected first different claim date from update claim'); + is(output_pref({str => $late_or_missing_issues_1_0[0]->{claimdate}, dateonly => 1}), $today, 'Got the expected first different claim date from update claim'); is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim'); is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim'); my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serial2->serialid); - is($late_or_missing_issues_1_1[0]->{claimdate}, $today, 'Got the expected second different claim date from update claim'); + is(output_pref({str => $late_or_missing_issues_1_1[0]->{claimdate}, dateonly => 1}), $today, 'Got the expected second different claim date from update claim'); is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim'); is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim'); my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, $serial3->serialid); - is($late_or_missing_issues_1_2[0]->{claimdate}, output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim'); + is(output_pref({str => $late_or_missing_issues_1_2[0]->{claimdate}, dateonly => 1}), output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim'); is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim'); is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); }; diff --git a/tags/review.pl b/tags/review.pl index 1393492567..c2c97c8117 100755 --- a/tags/review.pl +++ b/tags/review.pl @@ -26,7 +26,6 @@ use CGI::Cookie; # need to check cookies before having CGI parse the POST re use URI::Escape qw( uri_escape_utf8 ); use C4::Auth qw( check_cookie_auth get_template_and_user ); use C4::Context; -use Koha::DateUtils qw( dt_from_string output_pref ); use C4::Output qw( output_with_http_headers is_ajax pagination_bar output_html_with_http_headers ); use C4::Tags qw( approval_counts @@ -162,23 +161,15 @@ if ($filter = $input->param('tag')) { $template->param(filter_tag=>$filter); $filters{term} = $filter; } -if ($filter = $input->param('from')) { - $date_from = eval { output_pref( { dt => dt_from_string( $filter ), dateonly => 1, dateformat => 'iso' } ); }; - if ( $date_from ) { - $template->param(filter_date_approved_from=>$filter); - $filters{date_approved} = ">=$date_from"; - } else { - push @errors, {date_from=>$filter}; - } +if ( $filter = $input->param('from') ) { + $date_from = $filter; + $template->param( filter_date_approved_from => $filter ); + $filters{date_approved} = ">=$date_from"; } -if ($filter = $input->param('to')) { - $date_to = eval { output_pref( { dt => dt_from_string( $filter ), dateonly => 1, dateformat => 'iso' } ); }; - if ( $date_to ) { - $template->param(filter_date_approved_to=>$filter); - $filters{date_approved} = "<=$date_to"; - } else { - push @errors, {date_to=>$filter}; - } +if ( $filter = $input->param('to') ) { + $date_to = $filter; + $template->param( filter_date_approved_to => $filter ); + $filters{date_approved} = "<=$date_to"; } if ($filter = $input->param('approver')) { # name (or borrowernumber) from input box if ($filter =~ /^\d+$/ and $filter > 0) { diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl index de36d5d8e6..46f358f9d7 100755 --- a/tools/additional-contents.pl +++ b/tools/additional-contents.pl @@ -91,11 +91,8 @@ elsif ( $op eq 'add_validate' ) { my @lang = $cgi->multi_param('lang'); - my $expirationdate; - if ( $cgi->param('expirationdate') ) { - $expirationdate = dt_from_string( scalar $cgi->param('expirationdate') ); - } - my $published_on = dt_from_string( scalar $cgi->param('published_on') ); + my $expirationdate = $cgi->param('expirationdate'); + my $published_on = $cgi->param('published_on'); my $number = $cgi->param('number'); my $original_default = $idnew ? Koha::AdditionalContents->find($idnew) : undef; diff --git a/tools/batchMod.pl b/tools/batchMod.pl index a1e2bd476b..2d19a40bf2 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -31,7 +31,6 @@ use List::MoreUtils qw( uniq ); use Encode qw( encode_utf8 ); use Koha::Database; -use Koha::DateUtils qw( dt_from_string ); use Koha::Exception; use Koha::Biblios; use Koha::Items; diff --git a/tools/batch_extend_due_dates.pl b/tools/batch_extend_due_dates.pl index 1ce79eeb68..ea961691e9 100755 --- a/tools/batch_extend_due_dates.pl +++ b/tools/batch_extend_due_dates.pl @@ -25,7 +25,7 @@ use CGI; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use Koha::Checkouts; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); my $input = CGI->new; my $op = $input->param('op') // q|form|; @@ -107,19 +107,13 @@ elsif ( $op eq 'list' ) { if ($preview_results) { push( @new_due_dates, - output_pref( + calc_new_due_date( { - dt => calc_new_due_date( - { - due_date => - dt_from_string( $checkout->date_due ), - new_hard_due_date => $new_hard_due_date, - add_days => $due_date_days - } - ), - dateformat => 'iso' + due_date => dt_from_string( $checkout->date_due ), + new_hard_due_date => $new_hard_due_date, + add_days => $due_date_days } - ) + ), ); } else { push( @issue_ids, $checkout->id ); @@ -129,9 +123,7 @@ elsif ( $op eq 'list' ) { if ( $preview_results ) { $template->param( checkouts => $checkouts, - new_hard_due_date => $new_hard_due_date - ? dt_from_string($new_hard_due_date) - : undef, + new_hard_due_date => $new_hard_due_date, due_date_days => $due_date_days, new_due_dates => \@new_due_dates, view => 'list', diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index 42a79545e5..632ed5ccd6 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -37,7 +37,6 @@ use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Members qw( GetBorrowersToExpunge ); -use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Old::Checkouts; use Koha::Patron::Categories; use Koha::Patrons; @@ -53,22 +52,12 @@ my $params = $cgi->Vars; my $step = $params->{step} || 1; my $not_borrowed_since = # the date which filter on issue history. - $params->{not_borrowed_since} - ? dt_from_string $params->{not_borrowed_since} - : undef; + $params->{not_borrowed_since}; my $last_issue_date = # the date which filter on borrowers last issue. - $params->{last_issue_date} - ? dt_from_string $params->{last_issue_date} - : undef; -my $borrower_dateexpiry = - $params->{borrower_dateexpiry} - ? dt_from_string $params->{borrower_dateexpiry} - : undef; -my $borrower_lastseen = - $params->{borrower_lastseen} - ? dt_from_string $params->{borrower_lastseen} - : undef; + $params->{last_issue_date}; my $patron_list_id = $params->{patron_list_id}; +my $borrower_dateexpiry = $params->{borrower_dateexpiry}; +my $borrower_lastseen = $params->{borrower_lastseen}; my $borrower_categorycode = $params->{'borrower_categorycode'} || q{}; @@ -211,21 +200,9 @@ sub _get_selection_params { $borrower_categorycode, $patron_list_id, $branch) = @_; my $params = {}; - $params->{not_borrowed_since} = output_pref({ - dt => $not_borrowed_since, - dateformat => 'iso', - dateonly => 1 - }) if $not_borrowed_since; - $params->{expired_before} = output_pref({ - dt => $borrower_dateexpiry, - dateformat => 'iso', - dateonly => 1 - }) if $borrower_dateexpiry; - $params->{last_seen} = output_pref({ - dt => $borrower_lastseen, - dateformat => 'iso', - dateonly => 1 - }) if $borrower_lastseen; + $params->{not_borrowed_since} = $not_borrowed_since; + $params->{expired_before} = $borrower_dateexpiry; + $params->{last_seen} = $borrower_lastseen; $params->{category_code} = $borrower_categorycode if $borrower_categorycode; $params->{patron_list_id} = $patron_list_id if $patron_list_id; diff --git a/tools/holidays.pl b/tools/holidays.pl index ddf45db1dc..49bd19915f 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -39,6 +39,7 @@ my ($template, $loggedinuser, $cookie) # calendardate - date passed in url for human readability (syspref) # if the url has an invalid date default to 'now.' +# FIXME There is something to improve in the date handling here my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string; my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } ); diff --git a/tools/inventory.pl b/tools/inventory.pl index 6fe7e79014..ace4e7cb7b 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -36,7 +36,7 @@ use C4::Reports::Guided qw( ); use C4::Charset qw( NormalizeString ); use Koha::Biblios; -use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::DateUtils qw( dt_from_string ); use Koha::Database::Columns; use Koha::AuthorisedValues; use Koha::BiblioFrameworks; @@ -247,7 +247,7 @@ if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length } } } - $template->param( date => output_pref ( { str => $date, dateformat => 'iso' } ) ); + $template->param( date => $date ); $template->param( errorloop => \@errorloop ) if (@errorloop); } diff --git a/tools/scheduler.pl b/tools/scheduler.pl index 53d4b641c4..9f797ba34a 100755 --- a/tools/scheduler.pl +++ b/tools/scheduler.pl @@ -24,7 +24,7 @@ use C4::Reports::Guided qw( get_saved_reports ); use C4::Auth qw( get_template_and_user ); use CGI qw ( -utf8 ); use C4::Output qw( output_html_with_http_headers ); -use Koha::DateUtils qw( dt_from_string output_pref );; +use Koha::DateUtils qw( dt_from_string );; my $input = CGI->new; my $base; @@ -52,11 +52,7 @@ my $id = $input->param('id'); if ( $mode eq 'job_add' ) { - # Retrieving the date according to the dateformat syspref - my $c4date = output_pref({ dt => dt_from_string( scalar $input->param('startdate') ), dateformat => 'iso', dateonly => 1 }); - - # Formatting it for Schedule::At - my $startdate = join('', (split /-/, $c4date)); + my $startdate = dt_from_string( scalar $input->param('startdate') )->ymd; my $starttime = $input->param('starttime'); $starttime =~ s/\://g; -- 2.39.5