Bugzilla – Attachment 53618 Details for
Bug 11844
Additional fields for order lines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11844: (followup) use new unified additional field screen
Bug-11844-followup-use-new-unified-additional-fiel.patch (text/plain), 12.94 KB, created by
Jesse Weaver
on 2016-07-21 20:50:51 UTC
(
hide
)
Description:
Bug 11844: (followup) use new unified additional field screen
Filename:
MIME Type:
Creator:
Jesse Weaver
Created:
2016-07-21 20:50:51 UTC
Size:
12.94 KB
patch
obsolete
>From a140409ed77a06745d888147e841cf03de28b717 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <jweaver@bywatersolutions.com> >Date: Thu, 21 Jul 2016 14:48:57 -0600 >Subject: [PATCH] Bug 11844: (followup) use new unified additional field screen > >--- > acqui/add_order_fields.pl | 123 --------------- > acqui/neworderempty.pl | 35 +++-- > .../prog/en/modules/acqui/add_order_fields.tt | 165 --------------------- > .../prog/en/modules/admin/additional-fields.tt | 1 + > 4 files changed, 20 insertions(+), 304 deletions(-) > delete mode 100755 acqui/add_order_fields.pl > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_order_fields.tt > >diff --git a/acqui/add_order_fields.pl b/acqui/add_order_fields.pl >deleted file mode 100755 >index ef77af6..0000000 >--- a/acqui/add_order_fields.pl >+++ /dev/null >@@ -1,123 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Copyright 2014 BibLibre >-# >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 3 of the License, or (at your option) any later >-# version. >-# >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >-use CGI; >-use C4::Auth; >-use C4::Koha; >-use C4::Output; >-use Koha::AdditionalField; >- >-my $input = new CGI; >- >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >- { >- template_name => "acqui/add_order_fields.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { acquisition => '*' }, >- debug => 1, >- } >-); >- >-my $op = $input->param('op') // 'list'; >-my $field_id = $input->param('field_id'); >-my @messages; >- >-if ( $op eq 'add' ) { >- my $name = $input->param('name') // q{}; >- my $authorised_value_category = $input->param('authorised_value_category') // q{}; >- my $marcfield = $input->param('marcfield') // q{}; >- if ( $field_id and $name ) { >- my $updated = 0; >- eval { >- my $af = Koha::AdditionalField->new({ >- id => $field_id, >- name => $name, >- authorised_value_category => $authorised_value_category, >- marcfield => $marcfield, >- }); >- $updated = $af->update; >- }; >- push @messages, { >- code => 'update', >- number => $updated, >- }; >- } elsif ( $name ) { >- my $inserted = 0; >- eval { >- my $af = Koha::AdditionalField->new({ >- tablename => 'aqorders', >- name => $name, >- authorised_value_category => $authorised_value_category, >- marcfield => $marcfield, >- }); >- $inserted = $af->insert; >- }; >- push @messages, { >- code => 'insert', >- number => $inserted, >- }; >- } else { >- push @messages, { >- code => 'insert', >- number => 0, >- }; >- } >- $op = 'list'; >-} >- >-if ( $op eq 'delete' ) { >- my $deleted = 0; >- eval { >- my $af = Koha::AdditionalField->new( { id => $field_id } ); >- $deleted = $af->delete; >- $deleted = 0 if $deleted eq '0E0'; >- }; >- push @messages, { >- code => 'delete', >- number => $deleted, >- }; >- $op = 'list'; >-} >- >-if ( $op eq 'add_form' ) { >- my $categories = C4::Koha::GetAuthorisedValueCategories(); >- my $field; >- if ( $field_id ) { >- $field = Koha::AdditionalField->new( { id => $field_id } )->fetch; >- } >- >- $template->param( >- field => $field, >- categories => $categories, >- ); >-} >- >-if ( $op eq 'list' ) { >- my $fields = Koha::AdditionalField->all( { tablename => 'aqorders' } ); >- $template->param( fields => $fields ); >-} >- >-$template->param( >- op => $op, >- messages => \@messages, >-); >- >-output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index e4aa0b4..9c21d49 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -301,25 +301,28 @@ my (undef, $barcode_subfield) = GetMarcFromKohaField('items.barcode', ''); > > # Get additional fields > my $record; >-my $additional_fields = Koha::AdditionalField->all({tablename => 'aqorders'}); >-foreach my $af (@$additional_fields) { >- if (!$af->{authorised_value_category} && $af->{marcfield}) { >- # Try to retrieve authorised values category from MARC framework >- my ($field, $subfield) = split /\$/, $af->{marcfield}; >- my $category = C4::Koha::GetAuthValCodeFromField($field, $subfield); >- if ($category) { >- $af->{authorised_value_category} = $category; >+my $available_additional_fields = Koha::AdditionalField->all( { tablename => 'aqorders' } ); >+my $additional_field_values = {}; >+ >+if ( $ordernumber ) { >+ $additional_field_values = Koha::AdditionalField->fetch_all_values( { >+ tablename => 'aqorders', >+ record_id => $ordernumber, >+ } )->{$ordernumber}; >+} elsif ( $biblionumber ) { >+ foreach my $af (@$additional_fields) { >+ if ($af->{marcfield}) { >+ $record //= GetMarcBiblio($biblionumber); >+ my ($field, $subfield) = split /\$/, $af->{marcfield}; >+ $additional_field_values->{ $af->{name} } = $record->subfield($field, $subfield); > } > } >- if ($ordernumber) { >- $af->fetch_values({record_id => $ordernumber}); >- } elsif ($biblionumber && $af->{marcfield}) { >- $record //= GetMarcBiblio($biblionumber); >- my ($field, $subfield) = split /\$/, $af->{marcfield}; >- $af->{values}->{'new'} = $record->subfield($field, $subfield); >- } > } >-$template->param(additional_fields => $additional_fields); >+ >+$template->param( >+ available_additional_fields => $available_additional_fields, >+ additional_field_values => $additional_field_values >+); > > # fill template > $template->param( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_order_fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_order_fields.tt >deleted file mode 100644 >index 4fab644..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_order_fields.tt >+++ /dev/null >@@ -1,165 +0,0 @@ >-[% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Acquisitions › Manage new fields for order lines >- [% IF op == "list" %] › List of fields >- [% ELSIF op == "add_form" %] >- [% IF field %] › Modify field >- [% ELSE %] › Add field >- [% END %] >- [% END %] >-</title> >-[% INCLUDE 'doc-head-close.inc' %] >-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >-[% INCLUDE "datatables.inc" %] >-<script type="text/javascript"> >-//<![CDATA[ >- $(document).ready(function(){ >- >- $("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, { >- 'bAutoWidth': false, >- 'sDom': 't<"bottom pager"ilpf>', >- 'sPaginationType': 'four_button', >- 'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]], >- 'iDisplayLength': 20, >- 'aaSorting': [[ 0, "asc" ]], >- })); >- >- $(".confirmdelete").click(function(){ >- return confirm(_("Are you sure you want to delete this field?")); >- }); >- >- $("#add_field").on('submit', function(){ >- if ( $("#marcfield").val().length > 0 >- && $("select[name='authorised_value_category']" ).val().length > 0 ) { >- alert("You cannot select an authorised value category and a marcfield"); >- return false; >- } >- return true; >- }); >- }); >-//]]> >-</script> >-</head> >- >-<body id="acq_add_fields" class="acq"> >- [% INCLUDE 'header.inc' %] >- [% INCLUDE 'acquisitions-search.inc' %] >- >- <div id="breadcrumbs"> >- <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> › Manage new fields for order lines >- </div> >- >- <div id="doc3" class="yui-t2"> >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >- [% IF op == 'list' %] >- <div id="toolbar" class="btn-toolbar"> >- <a class="btn btn-small" id="newfields" href="/cgi-bin/koha/acqui/add_order_fields.pl?op=add_form"><i class="icon-plus"></i> New field</a> >- </div> >- [% END %] >- >- [% IF messages %] >- [% FOR message IN messages %] >- [% IF message.code == 'insert' %] >- [% IF message.number > 0 %] >- <div class="dialog message">The field has been inserted</div> >- [% ELSE %] >- <div class="dialog alert">The field has not been inserted (name still exist?)</div> >- [% END %] >- [% ELSIF message.code == 'update' %] >- [% IF message.number > 0 %] >- <div class="dialog message">The field has been updated</div> >- [% ELSE %] >- <div class="dialog alert">The field has not been updated (name still exist?)</div> >- [% END %] >- [% ELSIF message.code == 'delete' %] >- [% IF message.number > 0 %] >- <div class="dialog message">The field has been deleted</div> >- [% ELSE %] >- <div class="dialog alert">The field has not been deleted</div> >- [% END %] >- [% END %] >- [% END %] >- [% END %] >- >- [% IF op == 'list' %] >- <h3>Additional fields for order lines</h3> >- [% IF fields %] >- <table id="fieldst"> >- <thead> >- <tr> >- <th>Name</th> >- <th>Authorised value category</th> >- <th>MARC field</th> >- <th>Actions</th> >- </tr> >- </thead> >- <tbody> >- [% FOR field IN fields %] >- <tr> >- <td>[% field.name %]</td> >- <td>[% field.authorised_value_category %]</td> >- <td>[% field.marcfield %]</td> >- <td> >- <a href="/cgi-bin/koha/acqui/add_order_fields.pl?op=add_form&field_id=[% field.id %]" title="Edit this field">Edit</a> >- <a class="confirmdelete" href="/cgi-bin/koha/acqui/add_order_fields.pl?op=delete&field_id=[% field.id %]" title="Delete this field">Delete</a> >- </td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% ELSE %] >- There is no field defined. >- [% END %] >- [% ELSIF op == 'add_form' %] >- [% IF field %] >- <h3>Modify field</h3> >- [% ELSE %] >- <h3>Add field</h3> >- [% END %] >- <form action="/cgi-bin/koha/acqui/add_order_fields.pl" name="add_form" id="add_field" method="post"> >- <fieldset class="rows"> >- <ol> >- <li> >- <label for="name" class="required">Name: </label> >- <input type="text" name="name" id="name" value="[% field.name | html %]" /> >- </li> >- <li> >- <label for="av">Authorised value category: </label> >- <select name="authorised_value_category"> >- <option value="">None</option> >- [% FOR category IN categories %] >- [% IF field.authorised_value_category == category %] >- <option value="[% category %]" selected="selected">[% category %]</option> >- [% ELSE %] >- <option value="[% category %]">[% category %]</option> >- [% END %] >- [% END %] >- </select> >- </li> >- <li> >- <label for="marcfield">MARC field: </label> >- <input type="text" name="marcfield" id="marcfield" value="[% field.marcfield| html %]" /> >- <span class="hint">Use this syntax: XXX$y</span> >- </li> >- </ol> >- </fieldset> >- <fieldset class="action"> >- [% IF field %] >- <input type="hidden" name="field_id" value="[% field.id %]" /> >- [% END %] >- <input type="hidden" name="op" value="add" /> >- <input type="submit" value="Save" /> >- <a href="/cgi-bin/koha/acqui/add_order_fields.pl" class="cancel">Cancel</a> >- </fieldset> >- </form> >- [% END %] >- >- </div> >- </div> >- >-<div class="yui-b"> >-[% INCLUDE 'acquisitions-menu.inc' %] >-</div> >-</div> >-[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >index 5166e4e..735fca5 100755 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >@@ -97,6 +97,7 @@ > [% END %] > <ul> > [% WRAPPER table_option value="aqbasket" %]Order baskets[% END %] >+ [% WRAPPER table_option value="aqorders" %]Order lines[% END %] > [% WRAPPER table_option value="subscription" %]Subscriptions[% END %] > </ul> > [% ELSIF op == 'list' %] >-- >2.8.1
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 11844
:
25632
|
25638
|
41859
|
41860
|
45674
|
45675
|
45676
|
45758
|
45915
|
45916
|
45917
|
53614
|
53615
|
53616
|
53618
|
53619
|
55529
|
75332
|
75362
|
141116
|
145517
|
145535
|
145536
|
145540
|
146497
|
146500
|
146501
|
146502
|
146503
|
146504
|
146505
|
146506
|
148889
|
148895
|
148897
|
149081
|
149082
|
149083
|
149084
|
149085
|
149086
|
149087
|
149088
|
149089
|
149090
|
149091
|
149682
|
149683
|
149684
|
149685
|
149686
|
149687
|
149688
|
149689
|
149690
|
149691
|
149692
|
150537
|
150538
|
150539
|
150540
|
150541
|
150542
|
150543
|
150544
|
150545
|
150546
|
150547
|
150548
|
151220
|
151221
|
151222
|
151223
|
151224
|
151225
|
151226
|
151227
|
151228
|
151229
|
151230
|
151366