Bugzilla – Attachment 43315 Details for
Bug 14997
Remove C4::Dates from tools (import / export)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14997 - Remove C4::Dates from tools (import / export)
Bug-14997---Remove-C4Dates-from-tools-import--expo.patch (text/plain), 5.73 KB, created by
Marc Véron
on 2015-10-10 08:38:31 UTC
(
hide
)
Description:
Bug 14997 - Remove C4::Dates from tools (import / export)
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-10-10 08:38:31 UTC
Size:
5.73 KB
patch
obsolete
>From 1da0dcefe79400f0c0e9234b94799b97d52c0ff9 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Sat, 10 Oct 2015 10:03:51 +0200 >Subject: [PATCH] Bug 14997 - Remove C4::Dates from tools (import / export) > >This patch removes C4::Dates from: > >- tools/export.pl >- tools/import_borrowers.pl > >Note: For testing, both need preparation without patch, see below. > >To test export: >- Without patch applied, go to > Home > Tools > Export data > Export bibliographic records >- Define Start date / End date for Accession dates >- Export bibliographic records as 'without-patch.mrc' > >- Do the same with patch, export as 'with-patch.mrc >- Compare the files, they should be the same > >To test Import patrons: >- Without patch >- Go to Home > Tools > Import patrons >- Create a patron categorie like 'TEST' (usful for filtering...) >- Prepare a file with some patrons with category TEST to import. > Fill date of birth, enrolment date, expiry date with values > formatted in syspref format, in iso format and garbage >- Import >- Review the imported patrons (search for category TEST) > >- With patch: Change cardnumber and names in import file >- Import >- Review again and compare with results from previous import. >--- > tools/export.pl | 18 +++++++++++------- > tools/import_borrowers.pl | 11 ++++------- > 2 files changed, 15 insertions(+), 14 deletions(-) > >diff --git a/tools/export.pl b/tools/export.pl >index 80a15b4..a674248 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -29,6 +29,7 @@ use C4::Csv; > use C4::Koha; # GetItemTypes > use C4::Output; > use C4::Record; >+use Koha::DateUtils; > > my $query = new CGI; > >@@ -198,15 +199,18 @@ if ( $op eq "export" ) { > my $itemtype = $query->param("itemtype"); > my $start_callnumber = $query->param("start_callnumber"); > my $end_callnumber = $query->param("end_callnumber"); >- $timestamp = ($timestamp) ? C4::Dates->new($timestamp) : '' >- if ($commandline); >+ if ( $commandline ) { >+ $timestamp = eval { output_pref( { dt => dt_from_string( $timestamp ), dateonly => 1 }); }; >+ $timestamp = '' unless ( $timestamp ); >+ } >+ > my $start_accession = > ( $query->param("start_accession") ) >- ? C4::Dates->new( $query->param("start_accession") ) >+ ? eval { output_pref( { dt => dt_from_string( $query->param("start_accession") ), dateonly => 1, dateformat => 'iso' } ); } > : ''; > my $end_accession = > ( $query->param("end_accession") ) >- ? C4::Dates->new( $query->param("end_accession") ) >+ ? eval { output_pref( { dt => dt_from_string( $query->param("end_accession") ), dateonly => 1, dateformat => 'iso' } ); } > : ''; > $dont_export_items = $query->param("dont_export_item") > unless ($commandline); >@@ -565,7 +569,7 @@ sub construct_query { > WHERE $biblioitemstable.timestamp >= ? > OR deleteditems.timestamp >= ? > ) "; >- my $ts = $timestamp->output('iso'); >+ my $ts = eval { output_pref( { dt => dt_from_string( $timestamp ), dateonly => 1, dateformat => 'iso' }); }; > @sql_params = ( $ts, $ts, $ts, $ts ); > } > else { >@@ -618,12 +622,12 @@ sub construct_query { > } > if ($start_accession) { > $sql_query .= " AND dateaccessioned >= ? "; >- push @sql_params, $start_accession->output('iso'); >+ push @sql_params, $start_accession; > } > > if ($end_accession) { > $sql_query .= " AND dateaccessioned <= ? "; >- push @sql_params, $end_accession->output('iso'); >+ push @sql_params, $end_accession; > } > > if ($itemtype) { >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index 15053cc..4da0599 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -39,7 +39,6 @@ use warnings; > > use C4::Auth; > use C4::Output; >-use C4::Dates qw(format_date_in_iso); > use C4::Context; > use C4::Branch qw/GetBranchesLoop GetBranchName/; > use C4::Members; >@@ -49,6 +48,7 @@ use C4::Members::Messaging; > use C4::Reports::Guided; > use C4::Templates; > use Koha::Borrower::Debarments; >+use Koha::DateUtils; > > use Text::CSV; > # Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals: >@@ -141,11 +141,9 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > } > > push @feedback, {feedback=>1, name=>'headerrow', value=>join(', ', @csvcolumns)}; >- my $today_iso = C4::Dates->new()->output('iso'); >+ my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); > my @criticals = qw(surname branchcode categorycode); # there probably should be others > my @bad_dates; # I've had a few. >- my $date_re = C4::Dates->new->regexp('syspref'); >- my $iso_re = C4::Dates->new->regexp('iso'); > LINE: while ( my $borrowerline = <$handle> ) { > my %borrower; > my @missing_criticals; >@@ -211,9 +209,8 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > # Popular spreadsheet applications make it difficult to force date outputs to be zero-padded, but we require it. > foreach (qw(dateofbirth dateenrolled dateexpiry)) { > my $tempdate = $borrower{$_} or next; >- if ($tempdate =~ /$date_re/) { >- $borrower{$_} = format_date_in_iso($tempdate); >- } elsif ($tempdate =~ /$iso_re/) { >+ $tempdate = eval { output_pref( { dt => dt_from_string( $tempdate ), dateonly => 1, dateformat => 'iso' } ); }; >+ if ($tempdate) { > $borrower{$_} = $tempdate; > } else { > $borrower{$_} = ''; >-- >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 14997
:
43315
|
43856
|
43937