@@ -, +, @@ --- 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(-) --- a/acqui/finishreceive.pl +++ a/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' } ) ; --- a/acqui/histsearch.pl +++ a/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; --- a/acqui/invoice.pl +++ a/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( --- a/acqui/invoices.pl +++ a/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, --- a/acqui/orderreceive.pl +++ a/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'}, --- a/acqui/parcels.pl +++ a/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 } ), --