From 5eac5a1cf0374c76e3c21e51e5dc6f124f8fe33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Tue, 10 Nov 2015 15:58:04 +0100 Subject: [PATCH] Bug 14946: (followup) Remove C4::Dates from files acqui... Followup for comment #12 --- acqui/finishreceive.pl | 1 + acqui/histsearch.pl | 4 ++-- acqui/invoice.pl | 19 +++++++++++++++---- acqui/invoices.pl | 14 +++++--------- acqui/orderreceive.pl | 5 +---- acqui/parcels.pl | 31 ++++--------------------------- 6 files changed, 28 insertions(+), 46 deletions(-) diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 165fc3a..c66090d 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -62,6 +62,7 @@ my $bookfund = $input->param("bookfund"); my $order = GetOrder($ordernumber); my $new_ordernumber = $ordernumber; +# Default $datereceived to today if empty or if invalid date given by user input my $datereceived_dt = eval { dt_from_string( $datereceived) }; $datereceived_dt = dt_from_string unless ( $datereceived_dt ); $datereceived = output_pref( { dt => $datereceived_dt , dateonly => 1, dateformat => 'iso' } ) ; diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 2dd38db..86fb540 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -126,8 +126,8 @@ if ($do_search) { ); } -my $from_date = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ); -my $to_date = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ); +my $from_date = output_pref( { dt => $from_placed_on, dateonly => 1 } ); +my $to_date = output_pref( { dt => $to_placed_on, dateonly => 1 } ); my $budgetperiods = C4::Budgets::GetBudgetPeriods; my $bp_loop = $budgetperiods; diff --git a/acqui/invoice.pl b/acqui/invoice.pl index fdd78c3..eda8df0 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -83,14 +83,25 @@ elsif ( $op && $op eq 'mod' ) { my $shipmentdate = ''; my $billingdate = ''; + # Set following dates to undef if date input is an invalid date, if ( $input->param('shipmentdate') ) { - $shipmentdate = eval { dt_from_string( $input->param('shipmentdate') ) }; - $shipmentdate = output_pref( { dt => $shipmentdate, dateformat => 'iso', dateonly => 1 } ) if ( $shipmentdate ); + my $shipmentdate_dt = eval { dt_from_string( $input->param('shipmentdate') ) }; + if ( $shipmentdate_dt ) { + $shipmentdate = output_pref( { dt => $shipmentdate_dt, dateformat => 'iso', dateonly => 1 } ) + } + else { + $shipmentdate = undef; + } } if ( $input->param('billingdate') ) { - $billingdate = eval { dt_from_string( $input->param('billingdate') ) }; - $billingdate = output_pref( { dt => $billingdate, dateformat => 'iso', dateonly => 1 } ) if ( $billingdate ); + my $billingdate_dt = eval { dt_from_string( $input->param('billingdate') ) }; + if ( $billingdate_dt ) { + $billingdate = output_pref( { dt => $billingdate_dt, dateformat => 'iso', dateonly => 1 } ); + } + else { + $billingdate = undef; + } } ModInvoice( diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 3ee725a..49ff72e 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -66,11 +66,7 @@ my $op = $input->param('op'); my $invoices = []; -my $shipmentdatefrom_iso = ''; -my $shipmentdateto_iso = ''; -my $billingdatefrom_iso = ''; -my $billingdateto_iso = ''; - +my ( $shipmentdatefrom_iso, $shipmentdateto_iso, $billingdatefrom_iso, $billingdateto_iso ); if ( $op and $op eq 'do_search' ) { @@ -160,10 +156,10 @@ $template->param( invoicenumber => $invoicenumber, booksellerid => $supplierid, suppliername => $suppliername, - shipmentdatefrom => $shipmentdatefrom_iso, - shipmentdateto => $shipmentdateto_iso, - billingdatefrom => $billingdatefrom_iso, - billingdateto => $billingdateto_iso, + shipmentdatefrom => $shipmentdatefrom, + shipmentdateto => $shipmentdateto, + billingdatefrom => $billingdatefrom, + billingdateto => $billingdateto, isbneanissn => $isbneanissn, title => $title, author => $author, diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index b9cd516..3543a0b 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -73,6 +73,7 @@ use C4::Branch; # GetBranches use C4::Items; use C4::Biblio; use C4::Suggestions; +use Koha::Acquisition::Bookseller; use Koha::DateUtils; @@ -193,9 +194,6 @@ my $budget = GetBudget( $order->{budget_id} ); my $datereceived = $order->{datereceived} ? dt_from_string( $order->{datereceived} ) : dt_from_string; -my $orderentrydate = eval{ dt_from_string( $order->{entrydate} ); }; -$orderentrydate = output_pref( { dt => $orderentrydate, dateonly => 1 } ) if ( $orderentrydate ); - $template->param( AcqCreateItem => $AcqCreateItem, count => 1, @@ -205,7 +203,6 @@ $template->param( booksellerid => $order->{'booksellerid'}, freight => $freight, name => $bookseller->{'name'}, - date => $orderentrydate, title => $order->{'title'}, author => $order->{'author'}, copyrightdate => $order->{'copyrightdate'}, diff --git a/acqui/parcels.pl b/acqui/parcels.pl index 39e686f..442db70 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -89,29 +89,6 @@ my $resultsperpage = $input->param('resultsperpage'); my $op = $input->param('op'); $resultsperpage ||= 20; -my $datefrom_iso = ''; -my $dateto_iso = ''; - -if ( $datefrom ) { - $datefrom_iso = eval { dt_from_string( $datefrom ) }; - if ($datefrom_iso ) { - $datefrom_iso = output_pref( { dt => $datefrom_iso, dateformat => 'iso', dateonly => 1 } ); - } - else { - $datefrom = ''; - } -} - -if ( $dateto ) { - $dateto_iso = eval { dt_from_string( $dateto ) }; - if ($dateto_iso ) { - $dateto_iso = output_pref( { dt => $dateto_iso, dateformat => 'iso', dateonly => 1 } ); - } - else { - $dateto = ''; - } -} - our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( { template_name => 'acqui/parcels.tt', query => $input, @@ -169,8 +146,8 @@ my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); my @parcels = GetInvoices( supplierid => $booksellerid, invoicenumber => $code, - shipmentdatefrom => $datefrom_iso, - shipmentdateto => $dateto_iso, + shipmentdatefrom => ( $datefrom ? ( shipmentdatefrom => output_pref( { dt => dt_from_string($datefrom), dateformat => 'iso' } ) ) : () ), + shipmentdateto => ( $dateto ? ( shipmentdateto => output_pref( { dt => dt_from_string($dateto), dateformat => 'iso' } ) ) : () ), order_by => $order ); my $count_parcels = @parcels; @@ -226,8 +203,8 @@ foreach my $r (@{$budgets}) { $template->param( orderby => $order, filter => $code, - datefrom => $datefrom, - dateto => $dateto, + ( $datefrom ? ( shipmentdatefrom => output_pref({ dt => dt_from_string($datefrom), dateformat => 'iso' }) ) : () ), + ( $dateto ? ( shipmentdateto => output_pref({ dt => dt_from_string($dateto), dateformat => 'iso' }) ) : () ), resultsperpage => $resultsperpage, name => $bookseller->{'name'}, shipmentdate_today => output_pref( { dt => dt_from_string, dateonly =>1 } ), -- 1.7.10.4