Bugzilla – Attachment 43144 Details for
Bug 14946
Remove C4::Dates from files acqui/*.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14946 - Remove C4::Dates from files acqui/*.pl
Bug-14946---Remove-C4Dates-from-files-acquipl.patch (text/plain), 14.19 KB, created by
Marc Véron
on 2015-10-05 15:00:15 UTC
(
hide
)
Description:
Bug 14946 - Remove C4::Dates from files acqui/*.pl
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-10-05 15:00:15 UTC
Size:
14.19 KB
patch
obsolete
>From 472b977a0647c84fd4b740f45d9bf0acea44b990 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Fri, 2 Oct 2015 22:36:25 +0200 >Subject: [PATCH] Bug 14946 - Remove C4::Dates from files acqui/*.pl > >This patch removes C4::Dates from: >- acqui/histsearch.pl >- acqui/invoice.pl >- acqui/invoices.pl >- acqui/orderreceive.pl >- acqui/parcel.pl >- acqui/parcels.pl >- acqui/transferorder.pl > >To test: > >- Apply patch >- Go to Home > Acquisitions > Invoices >- Verify that Search filters work OK >- Edit an invoice >- Verify that Shipment date and Billing date display OK > and edit / save is OK >- Receive shipment for a vendor >- Verify that Shipment date behaves OK and that you > can filter list of shipents for this vendor >- Transfer an item from a basket to another vendor > >http://bugs.koha-community.org/show_bug.cgi?id=14926 >--- > acqui/histsearch.pl | 23 +++++++++++------------ > acqui/invoice.pl | 21 +++++++++++++++++---- > acqui/invoices.pl | 30 ++++++++++++++++++++++++++---- > acqui/orderreceive.pl | 14 ++++++++------ > acqui/parcel.pl | 11 +++++------ > acqui/parcels.pl | 11 ++++++----- > acqui/transferorder.pl | 1 - > 7 files changed, 73 insertions(+), 38 deletions(-) > >diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl >index 5add9e1..8650715 100755 >--- a/acqui/histsearch.pl >+++ b/acqui/histsearch.pl >@@ -55,10 +55,10 @@ use CGI qw ( -utf8 ); > use C4::Auth; # get_template_and_user > use C4::Output; > use C4::Acquisition; >-use C4::Dates; > use C4::Debug; > use C4::Branch; > use C4::Koha; >+use Koha::DateUtils; > > my $input = new CGI; > my $title = $input->param( 'title'); >@@ -67,11 +67,11 @@ my $isbn = $input->param('isbn'); > my $name = $input->param( 'name' ); > my $ean = $input->param('ean'); > my $basket = $input->param( 'basket' ); >-my $basketgroupname = $input->param('basketgroupname'); >+my $basketgroupname = $input->param('basketgroupname'); > my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' ); > my $do_search = $input->param('do_search') || 0; >-my $from_placed_on = C4::Dates->new($input->param('from')); >-my $to_placed_on = C4::Dates->new($input->param('to')); >+my $from_placed_on = eval { dt_from_string( $input->param('from') ) } || dt_from_string; >+my $to_placed_on = eval { dt_from_string( $input->param('to') ) } || dt_from_string; > my $budget = $input->param( 'budget' ); > my $orderstatus = $input->param( 'orderstatus' ); > my $ordernumber = $input->param( 'ordernumber' ); >@@ -79,9 +79,8 @@ my $search_children_too = $input->param( 'search_children_too' ); > my @created_by = $input->param('created_by'); > > if ( not $input->param('from') ) { >- # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ? >- # We would use a function like Add_Delta_YM(-1, 0, 0); >- $$from_placed_on{dmy_arrayref}[5] -= 1; >+ # Subtract one year if param was not defined >+ $from_placed_on->subtract(years => 1); > } > > my $dbh = C4::Context->dbh; >@@ -98,10 +97,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > my ( $from_iso, $to_iso, $d ); > if ( $d = $input->param('from') ) { >- $from_iso = C4::Dates->new($d)->output('iso'); >+ $from_iso = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ); > } >-if ( $d = $input->param('iso') ) { >- $to_iso = C4::Dates->new($d)->output('iso'); >+if ( $d = $input->param('to') ) { >+ $to_iso = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ); > } > > my $order_loop; >@@ -126,8 +125,8 @@ if ($do_search) { > ); > } > >-my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef; >-my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef; >+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 $budgetperiods = C4::Budgets::GetBudgetPeriods; > my $bp_loop = $budgetperiods; >diff --git a/acqui/invoice.pl b/acqui/invoice.pl >index 026fd13..fdd78c3 100755 >--- a/acqui/invoice.pl >+++ b/acqui/invoice.pl >@@ -37,6 +37,7 @@ use C4::Budgets; > > use Koha::Acquisition::Bookseller; > use Koha::Misc::Files; >+use Koha::DateUtils; > > my $input = new CGI; > my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( >@@ -76,14 +77,26 @@ elsif ( $op && $op eq 'reopen' ) { > } > } > elsif ( $op && $op eq 'mod' ) { >- my $shipmentdate = $input->param('shipmentdate'); >- my $billingdate = $input->param('billingdate'); >+ > my $shipmentcost = $input->param('shipmentcost'); > my $shipment_budget_id = $input->param('shipment_budget_id'); >+ my $shipmentdate = ''; >+ my $billingdate = ''; >+ >+ if ( $input->param('shipmentdate') ) { >+ $shipmentdate = eval { dt_from_string( $input->param('shipmentdate') ) }; >+ $shipmentdate = output_pref( { dt => $shipmentdate, dateformat => 'iso', dateonly => 1 } ) if ( $shipmentdate ); >+ } >+ >+ if ( $input->param('billingdate') ) { >+ $billingdate = eval { dt_from_string( $input->param('billingdate') ) }; >+ $billingdate = output_pref( { dt => $billingdate, dateformat => 'iso', dateonly => 1 } ) if ( $billingdate ); >+ } >+ > ModInvoice( > invoiceid => $invoiceid, >- shipmentdate => C4::Dates->new($shipmentdate)->output("iso"), >- billingdate => C4::Dates->new($billingdate)->output("iso"), >+ shipmentdate => $shipmentdate, >+ billingdate => $billingdate, > shipmentcost => $shipmentcost, > shipmentcost_budgetid => $shipment_budget_id > ); >diff --git a/acqui/invoices.pl b/acqui/invoices.pl >index 4909b78..872fbc6 100755 >--- a/acqui/invoices.pl >+++ b/acqui/invoices.pl >@@ -36,6 +36,7 @@ use C4::Output; > use C4::Acquisition qw/GetInvoices/; > use C4::Branch qw/GetBranches/; > use C4::Budgets; >+use Koha::DateUtils; > > my $input = CGI->new; > my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( >@@ -65,10 +66,31 @@ my $op = $input->param('op'); > > my $invoices = []; > if ( $op and $op eq 'do_search' ) { >- my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output('iso'); >- my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output('iso'); >- my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output('iso'); >- my $billingdateto_iso = C4::Dates->new($billingdateto)->output('iso'); >+ >+ my $shipmentdatefrom_iso = ''; >+ if ( $shipmentdatefrom ) { >+ $shipmentdatefrom_iso = eval { dt_from_string( $shipmentdatefrom ) }; >+ $shipmentdatefrom_iso = output_pref( { dt => $shipmentdatefrom_iso, dateformat => 'iso', dateonly => 1 } ) if ( $shipmentdatefrom_iso ); >+ } >+ >+ my $shipmentdateto_iso = ''; >+ if ( $shipmentdateto ) { >+ $shipmentdateto_iso = eval { dt_from_string( $shipmentdateto) }; >+ $shipmentdateto_iso = output_pref( { dt => $shipmentdateto_iso, dateformat => 'iso', dateonly => 1 } ) if ( $shipmentdateto_iso ); >+ } >+ >+ my $billingdatefrom_iso = ''; >+ if ( $billingdatefrom ) { >+ $billingdatefrom_iso = eval { dt_from_string( $billingdatefrom) }; >+ $billingdatefrom_iso = output_pref( { dt => $billingdatefrom_iso, dateformat => 'iso', dateonly => 1 } ) if ( $billingdatefrom_iso ); >+ } >+ >+ my $billingdateto_iso = ''; >+ if ( $billingdateto ) { >+ $billingdateto_iso = eval { dt_from_string( $billingdateto) }; >+ $billingdateto_iso = output_pref( { dt => $billingdateto_iso, dateformat => 'iso', dateonly => 1 } ) if ( $billingdateto_iso ); >+ } >+ > @{$invoices} = GetInvoices( > invoicenumber => $invoicenumber, > supplierid => $supplierid, >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 202e8ce..395adc6 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -67,7 +67,6 @@ use C4::Koha; # GetKohaAuthorisedValues GetItemTypes > use C4::Acquisition; > use C4::Auth; > use C4::Output; >-use C4::Dates qw/format_date/; > use C4::Budgets qw/ GetBudget GetBudgetHierarchy CanUserUseBudget GetBudgetPeriods /; > use C4::Members; > use C4::Branch; # GetBranches >@@ -76,7 +75,7 @@ use C4::Biblio; > use C4::Suggestions; > > use Koha::Acquisition::Bookseller; >- >+use Koha::DateUtils; > > my $input = new CGI; > >@@ -88,7 +87,7 @@ my $freight = $invoice->{shipmentcost}; > my $datereceived = $invoice->{shipmentdate}; > my $ordernumber = $input->param('ordernumber'); > >-$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new(); >+$datereceived = eval{ dt_from_string( $datereceived ); }; > > my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); > my $results; >@@ -196,6 +195,9 @@ my $member = GetMember( borrowernumber => $authorisedby ); > > my $budget = GetBudget( $order->{budget_id} ); > >+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 +207,7 @@ $template->param( > booksellerid => $order->{'booksellerid'}, > freight => $freight, > name => $bookseller->{'name'}, >- date => format_date($order->{entrydate}), >+ date => $orderentrydate, > title => $order->{'title'}, > author => $order->{'author'}, > copyrightdate => $order->{'copyrightdate'}, >@@ -221,8 +223,8 @@ $template->param( > membersurname => $member->{surname} || "", > invoiceid => $invoice->{invoiceid}, > invoice => $invoice->{invoicenumber}, >- datereceived => $datereceived->output(), >- datereceived_iso => $datereceived->output('iso'), >+ datereceived => output_pref( { dt => $datereceived, dateonly => 1 } ), >+ datereceived_iso => output_pref( { dt => $datereceived, dateonly => 1, dateformat => 'iso' } ), > order_internalnote => $order->{order_internalnote}, > order_vendornote => $order->{order_vendornote}, > suggestionid => $suggestion->{suggestionid}, >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index b66f609..f0223f8 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -64,10 +64,9 @@ use C4::Biblio; > use C4::Items; > use CGI qw ( -utf8 ); > use C4::Output; >-use C4::Dates qw/format_date format_date_in_iso/; > use C4::Suggestions; > use C4::Reserves qw/GetReservesFromBiblionumber/; >- >+use Koha::DateUtils; > use Koha::Acquisition::Bookseller; > > use JSON; >@@ -112,7 +111,7 @@ unless( $invoiceid and $invoice->{invoiceid} ) { > my $booksellerid = $invoice->{booksellerid}; > my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); > my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; >-my $datereceived = C4::Dates->new(); >+my $datereceived = dt_from_string; > > my @orders = @{ $invoice->{orders} }; > my $countlines = scalar @orders; >@@ -282,9 +281,9 @@ $template->param( > invoiceid => $invoice->{invoiceid}, > invoice => $invoice->{invoicenumber}, > invoiceclosedate => $invoice->{closedate}, >- datereceived => $datereceived->output('iso'), >- invoicedatereceived => $datereceived->output('iso'), >- formatteddatereceived => $datereceived->output(), >+ datereceived => eval { output_pref( { dt => $datereceived, dateonly => 1, dateformat =>'iso' } ) }, >+ invoicedatereceived => eval { output_pref( { dt => $datereceived, dateonly => 1, dateformat =>'iso' } ) }, >+ formatteddatereceived => eval { output_pref( { dt => $datereceived, dateonly => 1 } ) }, > name => $bookseller->{'name'}, > booksellerid => $bookseller->{id}, > loop_received => \@loop_received, >diff --git a/acqui/parcels.pl b/acqui/parcels.pl >index 0126fc0..5fad7b2 100755 >--- a/acqui/parcels.pl >+++ b/acqui/parcels.pl >@@ -103,8 +103,9 @@ my $invoicenumber = $input->param('invoice'); > my $shipmentdate = $input->param('shipmentdate'); > my $shipmentcost = $input->param('shipmentcost'); > my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid'); >-if($shipmentdate) { >- $shipmentdate = C4::Dates->new($shipmentdate)->output('iso'); >+if ( $shipmentdate ) { >+ $shipmentdate = eval { dt_from_string ( $shipmentdate ) }; >+ $shipmentdate = output_pref( { dt => $shipmentdate, dateonly => 1, dateformat => 'iso' } ) if ( $shipmentdate ); > } > > if ( $op and $op eq 'new' ) { >@@ -145,8 +146,8 @@ my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $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 ? ( eval { shipmentdatefrom => output_pref({ dt => dt_from_string($datefrom), dateformat => 'iso' }); } ) : () ), >+ ( $dateto ? ( eval { shipmentdateto => output_pref({ dt => dt_from_string($dateto), dateformat => 'iso' }); } ) : () ), > order_by => $order > ); > my $count_parcels = @parcels; >@@ -206,7 +207,7 @@ $template->param( > dateto => $dateto, > resultsperpage => $resultsperpage, > name => $bookseller->{'name'}, >- shipmentdate_today => C4::Dates->new()->output(), >+ shipmentdate_today => output_pref( { dt => dt_from_string, dateonly =>1 } ), > booksellerid => $booksellerid, > GST => C4::Context->preference('gist'), > budgets => $budget_loop, >diff --git a/acqui/transferorder.pl b/acqui/transferorder.pl >index 3e8bdc8..6d94625 100755 >--- a/acqui/transferorder.pl >+++ b/acqui/transferorder.pl >@@ -27,7 +27,6 @@ use C4::Output; > use C4::Context; > use C4::Acquisition; > use C4::Members; >-use C4::Dates qw/format_date_in_iso/; > use Date::Calc qw/Today/; > > my $input = new CGI; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14946
:
43078
|
43144
|
43954
|
44295
|
44596
|
44708
|
44717
|
44722
|
44933
|
44934
|
44936