Bugzilla – Attachment 35677 Details for
Bug 10877
Add "Order Record" processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10877 - Add "Order Record" processing
Bug-10877---Add-Order-Record-processing.patch (text/plain), 20.19 KB, created by
Kyle M Hall
on 2015-02-05 18:09:38 UTC
(
hide
)
Description:
Bug 10877 - Add "Order Record" processing
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2015-02-05 18:09:38 UTC
Size:
20.19 KB
patch
obsolete
>From 80241102fb8380540bf7879e04d5317945e92660 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 11 Sep 2013 13:04:22 -0400 >Subject: [PATCH] Bug 10877 - Add "Order Record" processing > >Order Record Processing will allow a library to stage an "order record" >file which is a standard marc file with some additional information in >it about how to create items automatically ( quantity, itemtype, etc ). >The location of these fields is defined in the system preference >MarcFieldsToOrder from bug 7180. > >The workflow is thus: >1) A librarian uploads an "order record" file, and marks the batch as an >order file during the staging process. >2) The librarian selects an acquisitions basket and chooses "from a >staged order file" >3) From here, the librarian can view all the records that will be >created, along with quantity and other data ( from bug 7180 ). The >librarian will *not* see the item fields, as those are automatically >created using the minimum data needed ( branches, itype ). >4) The librarian hits "save" and the items are automatically generated >on order. > >Later ( using features not directly tied to this feature ), the >librarian will receive a new marc batch file with items attached >( including itemnumbers ). The vendor will have this information >because it was sent via EDI ( bug 7736 ). The librarian will then use >the marc record staging feature to overlay those bare bones item records >with the full data ( via bug 7131 ). > >Signed-off-by: Aaron Sakovich <asakovich@hmcpl.org> >--- > C4/ImportBatch.pm | 25 +++++++--- > acqui/addorderiso2709.pl | 53 +++++++++++++++++-- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++ > .../en/includes/acquisitions-add-to-basket.inc | 1 + > .../prog/en/modules/acqui/addorderiso2709.tt | 32 +++++++++--- > .../prog/en/modules/tools/stage-marc-import.tt | 4 ++ > misc/stage_file.pl | 5 ++- > tools/stage-marc-import.pl | 5 +- > 9 files changed, 109 insertions(+), 24 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 08304d7..f50048d 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -207,7 +207,8 @@ sub AddImportBatch { > my (@fields, @vals); > foreach (qw( matcher_id template_id branchcode > overlay_action nomatch_action item_action >- import_status batch_type file_name comments record_type )) { >+ import_status batch_type file_name comments >+ record_type is_order )) { > if (exists $params->{$_}) { > push @fields, $_; > push @vals, $params->{$_}; >@@ -320,7 +321,7 @@ sub ModAuthInBatch { > ($batch_id, $num_records, $num_items, @invalid_records) = > BatchStageMarcRecords($encoding, $marc_records, $file_name, $marc_modification_template, > $comments, $branch_code, $parse_items, >- $leave_as_staging, >+ $leave_as_staging, is_order, > $progress_interval, $progress_callback); > > =cut >@@ -335,6 +336,7 @@ sub BatchStageMarcRecords { > my $branch_code = shift; > my $parse_items = shift; > my $leave_as_staging = shift; >+ my $is_order = shift; > > # optional callback to monitor status > # of job >@@ -354,6 +356,7 @@ sub BatchStageMarcRecords { > file_name => $file_name, > comments => $comments, > record_type => $record_type, >+ is_order => $is_order, > } ); > if ($parse_items) { > SetImportBatchItemAction($batch_id, 'always_add'); >@@ -954,21 +957,29 @@ sub GetStagedWebserviceBatches { > > =head2 GetImportBatchRangeDesc > >- my $results = GetImportBatchRangeDesc($offset, $results_per_group); >+ my $results = GetImportBatchRangeDesc($offset, $results_per_group, $is_order); > > Returns a reference to an array of hash references corresponding to > import_batches rows (sorted in descending order by import_batch_id) > start at the given offset. > >+Pass in $is_order = 1 to get only batches marked as order records >+ > =cut > > sub GetImportBatchRangeDesc { >- my ($offset, $results_per_group) = @_; >+ my ($offset, $results_per_group,$is_order) = @_; >+ >+ my $is_order_limit = $is_order ? "AND is_order = 1" : q{}; > > my $dbh = C4::Context->dbh; >- my $query = "SELECT * FROM import_batches >- WHERE batch_type IN ('batch', 'webservice') >- ORDER BY import_batch_id DESC"; >+ my $query = " >+ SELECT * FROM import_batches >+ WHERE batch_type IN ('batch', 'webservice') >+ $is_order_limit >+ ORDER BY import_batch_id DESC >+ "; >+ > my @params; > if ($results_per_group){ > $query .= " LIMIT ?"; >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index b4aa4d9..8d94d42 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -61,11 +61,13 @@ my $cgiparams = $input->Vars; > my $op = $cgiparams->{'op'} || ''; > my $booksellerid = $input->param('booksellerid'); > my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); >+my $is_order = $input->param('is_order'); > my $data; > > $template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl", > booksellerid => $booksellerid, > booksellername => $bookseller->{name}, >+ is_order => $is_order, > ); > > if ($cgiparams->{'import_batch_id'} && $op eq ""){ >@@ -83,7 +85,7 @@ if (! $cgiparams->{'basketno'}){ > if ($op eq ""){ > $template->param("basketno" => $cgiparams->{'basketno'}); > #display batches >- import_batches_list($template); >+ import_batches_list( $template, $is_order ); > # > # 2nd step = display the content of the choosen file > # >@@ -269,6 +271,34 @@ if ($op eq ""){ > my @serials = $input->param('serial'); > my @ind_tag = $input->param('ind_tag'); > my @indicator = $input->param('indicator'); >+ >+ if ($is_order) { >+ my ( $notforloan_field, $notforloan_subfield ) = >+ GetMarcFromKohaField('items.notforloan'); >+ push( @tags, $notforloan_field ); >+ push( @subfields, $notforloan_subfield ); >+ push( @field_values, '-1' ); >+ >+ my ( $homebranch_field, $homebranch_subfield ) = >+ GetMarcFromKohaField('items.homebranch'); >+ push( @tags, $homebranch_field ); >+ push( @subfields, $homebranch_subfield ); >+ push( @field_values, C4::Context->userenv->{'branch'} ); >+ >+ my ( $holdingbranch_field, $holdingbranch_subfield ) = >+ GetMarcFromKohaField('items.holdingbranch'); >+ push( @tags, $holdingbranch_field ); >+ push( @subfields, $holdingbranch_subfield ); >+ push( @field_values, C4::Context->userenv->{'branch'} ); >+ >+ my $infos = get_infos_syspref($marcrecord, ['itype']); >+ my ( $itype_field, $itype_subfield ) = >+ GetMarcFromKohaField('items.itype'); >+ push( @tags, $itype_field ); >+ push( @subfields, $itype_subfield ); >+ push( @field_values, $infos->{itype} ); >+ } >+ > my $item; > push @{ $item->{tags} }, $tags[0]; > push @{ $item->{subfields} }, $subfields[0]; >@@ -324,8 +354,8 @@ output_html_with_http_headers $input, $cookie, $template->output; > > > sub import_batches_list { >- my ($template) = @_; >- my $batches = GetImportBatchRangeDesc(); >+ my ($template, $is_order) = @_; >+ my $batches = GetImportBatchRangeDesc(undef,undef,$is_order); > > my @list = (); > foreach my $batch (@$batches) { >@@ -420,6 +450,8 @@ sub import_biblios_list { > item_action => $item_action > ); > batch_info($template, $batch); >+ >+ return \@list; > } > > sub batch_info { >@@ -463,8 +495,7 @@ sub add_matcher_list { > $template->param(available_matchers => \@matchers); > } > >-sub get_infos_syspref { >- my ($record, $field_list) = @_; >+sub GetMarcFieldsToOrderAsYAML { > my $syspref = C4::Context->preference('MarcFieldsToOrder'); > $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt > my $yaml = eval { >@@ -472,8 +503,18 @@ sub get_infos_syspref { > }; > if ( $@ ) { > warn "Unable to parse MarcFieldsToOrder syspref : $@"; >- return (); >+ return; >+ } else { >+ return $yaml; > } >+} >+ >+sub get_infos_syspref { >+ my ($record, $field_list) = @_; >+ >+ my $yaml = GetMarcFieldsToOrderAsYAML; >+ return unless $yaml; >+ > my $r; > for my $field_name ( @$field_list ) { > next unless exists $yaml->{$field_name}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 82868e7..795ac09 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1030,6 +1030,7 @@ CREATE TABLE `import_batches` ( -- information about batches of marc records tha > `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio', -- type of record in the batch > `file_name` varchar(100), -- the name of the file uploaded > `comments` mediumtext, -- any comments added when the file was uploaded >+ `is_order` tinyint(1) NOT NULL DEFAULT '0', -- defines if this is an Order Record for processing > PRIMARY KEY (`import_batch_id`), > KEY `branchcode` (`branchcode`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 891ee25..cc2633d 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9691,6 +9691,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.18.00.XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("ALTER TABLE import_batches ADD is_order BOOLEAN NOT NULL DEFAULT '0' AFTER comments"); >+ print "Upgrade to $DBversion done (Bug 10877 - Add 'Order Record' processing)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc >index 8e2961b..cf52dca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc >@@ -17,6 +17,7 @@ > <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">From a new (empty) record</a></li> > <li><a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">From an external source</a></li> > <li><a href="/cgi-bin/koha/acqui/addorderiso2709.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]"> From a staged file</a></li> >+ <li><a href="/cgi-bin/koha/acqui/addorderiso2709.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]&is_order=1"> From a staged order file</a></li> > [% IF ( CAN_user_circulate ) %]<li><a href="/cgi-bin/koha/circ/reserveratios.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">From titles with highest hold ratios</a></li>[% END %] > </ul> > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >index cf03b7c..7b1aca2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >@@ -138,7 +138,12 @@ > > return disableUnchecked($(this)); > }); >+ > $('#tabs').tabs(); >+ >+ [% IF is_order %] >+ $("#checkAll").click(); >+ [% END %] > }); > > function disableUnchecked(form){ >@@ -166,7 +171,9 @@ > <div id="tabs" class="toptabs"> > <ul> > <li><a href="#records_to_import">Select to import</a></li> >- <li><a href="#items_info" class="items_info">Item information</a></li> >+ [% UNLESS is_order %] >+ <li><a href="#items_info" class="items_info">Item information</a></li> >+ [% END %] > <li><a href="#accounting_details">Default accounting details</a></li> > </ul> > >@@ -185,6 +192,12 @@ > <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" /> > [% END %] > >+ [% IF is_order %] >+ <p> >+ <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a> >+ </p> >+ [% END %] >+ > [% FOREACH biblio IN biblio_list %] > <fieldset class="biblio unselected rows" style="float:none;"> > <legend> >@@ -261,11 +274,11 @@ > </fieldset> > [% END %] > </div> >+ [% IF ( items && !is_order ) %] > <div id="items_info"> > <h2>Item information</h2> > <p>Import all the checked items in the basket with the following parameters:</p> > >- [% IF ( items ) %] > <fieldset class="rows" style="float:none;"> > <legend>Item</legend> > [% IF ( NoACQframework ) %] >@@ -309,8 +322,8 @@ > </div> > [% END %] <!-- /items --> > </fieldset> >- [% END %] <!-- items --> > </div> >+ [% END %] <!-- items tab --> > <div id="accounting_details"> > <p>Import all the checked items in the basket with the following accounting details (used only if no information is filled for the item):</p> > <fieldset class="rows" style="float:none;"> >@@ -360,6 +373,7 @@ > <label for="all_order_vendornote">Vendor note: </label> > <textarea id="all_order_vendornote" cols="30" rows="3" name="all_order_vendornote"></textarea> > </li> >+ [% UNLESS is_order %] > <li> > <div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div> > <label for="all_sort1">Statistic 1: </label> >@@ -369,14 +383,16 @@ > <label for="all_sort2">Statistic 2: </label> > <input type="text" id="all_sort2" size="20" name="all_sort2" value="" /> > </li> >+ [% END %] > </ol> > </fieldset> > </div> > </div> > >- <fieldset class="action"> >- <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a> >- </fieldset> >+ <fieldset class="action"> >+ <input type="hidden" name="is_order" value="[% is_order %]" /> >+ <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a> >+ </fieldset> > </form> > [% ELSE %] > <div> >@@ -415,8 +431,8 @@ > [% END %] > </td> > <td><span title="[% batch_lis.staged_date %]">[% batch_lis.staged_date | $KohaDates with_hours => 1 %]</span></td> >- <td>[% batch_lis.num_records %]</td> >- <td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&basketno=[% basketno %]&booksellerid=[% booksellerid %]">Add orders</a></td> >+ <td>[% batch_lis.num_biblios %]</td> >+ <td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&basketno=[% basketno %]&booksellerid=[% booksellerid %]&is_order=[% is_order %]">Add orders</a></td> > </tr> > [% END %] > </tbody> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >index b9b17f5..aaebbd1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >@@ -112,6 +112,10 @@ function CheckForm(f) { > <option value='auth'>Authority</option> > </select> > </li> >+ <li> >+ <input type="checkbox" name="is_order" id="is_order" /> >+ <label for="is_order">Is an order file:</label> >+ </li> > <li> > <label for="encoding">Character encoding: </label> > <select name="encoding" id="encoding"><option value="utf8" selected="selected">UTF-8 (Default)</option><option value="MARC-8">MARC 8</option><option value="ISO_5426">ISO 5426</option><option value="ISO_6937">ISO 6937</option><option value=ISO_8859-1">ISO 8859-1</option><option value="EUC-KR">EUC-KR</option></select> >diff --git a/misc/stage_file.pl b/misc/stage_file.pl >index 2e15466..a74428c 100755 >--- a/misc/stage_file.pl >+++ b/misc/stage_file.pl >@@ -45,6 +45,7 @@ my $input_file = ""; > my $batch_comment = ""; > my $want_help = 0; > my $no_replace ; >+my $is_order = 0; > my $item_action = 'always_add'; > > my $result = GetOptions( >@@ -56,6 +57,7 @@ my $result = GetOptions( > 'no-replace' => \$no_replace, > 'comment:s' => \$batch_comment, > 'authorities' => \$authorities, >+ 'is-order' => \$is_order, > 'h|help' => \$want_help > ); > >@@ -101,7 +103,7 @@ sub process_batch { > > print "... staging MARC records -- please wait\n"; > my ($batch_id, $num_valid_records, $num_items, @import_errors) = >- BatchStageMarcRecords($record_type, $encoding, $marc_records, $input_file, undef, $batch_comment, '', $add_items, 0, >+ BatchStageMarcRecords($record_type, $encoding, $marc_records, $input_file, undef, $batch_comment, '', $add_items, 0, $is_order, > 100, \&print_progress_and_commit); > print "... finished staging MARC records\n"; > >@@ -198,6 +200,7 @@ Parameters: > the record batch; if the comment > has spaces in it, surround the > comment with quotation marks. >+ --is-order this file is a bibliographic order file > --help or -h show this message. > _USAGE_ > } >diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl >index 500e6cd..50065d0 100755 >--- a/tools/stage-marc-import.pl >+++ b/tools/stage-marc-import.pl >@@ -55,6 +55,7 @@ my $parse_items = $input->param('parse_items'); > my $item_action = $input->param('item_action'); > my $comments = $input->param('comments'); > my $record_type = $input->param('record_type'); >+my $is_order = $input->param('is_order') eq 'on'; > my $encoding = $input->param('encoding'); > my $marc_modification_template = $input->param('marc_modification_template_id'); > >@@ -132,8 +133,8 @@ if ($completedJobID) { > $marcrecord, $filename, > $marc_modification_template, $comments, > '', $parse_items, >- 0, 50, >- staging_progress_callback( $job, $dbh ) >+ 0, $is_order, >+ 50, staging_progress_callback( $job, $dbh ) > ); > > my $num_with_matches = 0; >-- >1.7.2.5
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 10877
:
20994
|
21006
|
21429
|
24466
|
24467
|
24468
|
29405
|
29406
|
29759
|
29760
|
31338
|
35677
|
38849
|
38850