Bugzilla – Attachment 42299 Details for
Bug 10855
Custom fields for subscriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10855: interface configuration for adding new fields to subscriptions
Bug-10855-interface-configuration-for-adding-new-f.patch (text/plain), 11.48 KB, created by
Julian Maurice
on 2015-09-03 12:14:05 UTC
(
hide
)
Description:
Bug 10855: interface configuration for adding new fields to subscriptions
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2015-09-03 12:14:05 UTC
Size:
11.48 KB
patch
obsolete
>From 06a542b1646476a6a46c19ecbe32f7eef39dd6e1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 29 Aug 2013 13:32:30 +0200 >Subject: [PATCH] Bug 10855: interface configuration for adding new fields to > subscriptions > >This patch adds an interface configuration for adding fields to >subscriptions. > >Test plan: >- go to serials/serials-home.pl >- click on the "Add subscription fields" link on the left of the screen >- try to add/update/delete new fields >You are not abble to add a field with an authorised value category and a >marcfield. Columns are sortable >- for the rest, you should have, at least: > * a new field named af1, sortable, linked to a category > * a new field named af2, sortable, linked to a marcfield > * a new field named af3, not sortable > >Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> >--- > .../prog/en/modules/serials/add_fields.tt | 178 +++++++++++++++++++++ > serials/add_fields.pl | 126 +++++++++++++++ > 2 files changed, 304 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/add_fields.tt > create mode 100755 serials/add_fields.pl > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/add_fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/add_fields.tt >new file mode 100644 >index 0000000..6e1a290 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/add_fields.tt >@@ -0,0 +1,178 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Serials › Manage new fields for subscriptions >+ [% 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" /> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> >+<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="ser_add_fields" class="ser"> >+ [% INCLUDE 'header.inc' %] >+ [% INCLUDE 'serials-search.inc' %] >+ >+ <div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Manage new fields for subscriptions >+ </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/serials/add_fields.pl?op=add_form"><i class="icon-plus"></i> New fields</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 subscriptions</h3> >+ [% IF fields %] >+ <table id="fieldst"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Authorised value category</th> >+ <th>Marc field</th> >+ <th>Searchable</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> >+ [% IF field.searchable %]Yes[% ELSE %]No[% END %] >+ </td> >+ <td> >+ <a href="/cgi-bin/koha/serials/add_fields.pl?op=add_form&field_id=[% field.id %]" title="Edit this field">Edit</a> >+ <a class="confirmdelete" href="/cgi-bin/koha/serials/add_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/serials/add_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 %]" /> >+ </li> >+ <li> >+ <label for="searchable">Searchable: </label> >+ [% IF field.searchable %] >+ <input type="checkbox" name="searchable" id="searchable" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="searchable" id="searchable" /> >+ [% END %] >+ </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/serials/add_fields.pl" class="cancel">Cancel</a> >+ </fieldset> >+ </form> >+ [% END %] >+ >+ </div> >+ </div> >+ >+<div class="yui-b"> >+[% INCLUDE 'serials-menu.inc' %] >+</div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/serials/add_fields.pl b/serials/add_fields.pl >new file mode 100755 >index 0000000..9451a1b >--- /dev/null >+++ b/serials/add_fields.pl >@@ -0,0 +1,126 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2013 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 => "serials/add_fields.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { serials => '*' }, >+ 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{}; >+ my $searchable = $input->param('searchable') ? 1 : 0; >+ 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, >+ searchable => $searchable, >+ }); >+ $updated = $af->update; >+ }; >+ push @messages, { >+ code => 'update', >+ number => $updated, >+ }; >+ } elsif ( $name ) { >+ my $inserted = 0; >+ eval { >+ my $af = Koha::AdditionalField->new({ >+ tablename => 'subscription', >+ name => $name, >+ authorised_value_category => $authorised_value_category, >+ marcfield => $marcfield, >+ searchable => $searchable, >+ }); >+ $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 => 'subscription' } ); >+ $template->param( fields => $fields ); >+} >+ >+$template->param( >+ op => $op, >+ messages => \@messages, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >-- >1.9.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 10855
:
20937
|
20938
|
20939
|
20940
|
20941
|
20942
|
20943
|
20944
|
21184
|
21185
|
21186
|
21187
|
21188
|
21189
|
21190
|
21191
|
21663
|
22049
|
22050
|
22051
|
22052
|
22053
|
22054
|
22055
|
22056
|
22057
|
22359
|
22360
|
22600
|
22601
|
22602
|
22603
|
22604
|
22605
|
22606
|
22607
|
22608
|
22616
|
22698
|
22699
|
22700
|
22701
|
22702
|
22703
|
22722
|
22768
|
22769
|
22869
|
23052
|
23053
|
23142
|
23143
|
23301
|
23302
|
23594
|
23595
|
23596
|
23597
|
23598
|
23599
|
23600
|
23601
|
23602
|
23774
|
23775
|
23961
|
23962
|
23963
|
23964
|
24452
|
24453
|
24454
|
24455
|
24456
|
24457
|
24569
|
24570
|
26091
|
26092
|
26093
|
26094
|
26095
|
26096
|
26097
|
26254
|
26255
|
26256
|
26257
|
26258
|
26259
|
26260
|
26276
|
26651
|
26655
|
28929
|
28930
|
28931
|
28932
|
28933
|
28934
|
28935
|
28936
|
28937
|
28938
|
28939
|
28940
|
28941
|
29095
|
29161
|
35211
|
35212
|
35213
|
35214
|
35215
|
35216
|
35217
|
35218
|
35219
|
35220
|
35221
|
35309
|
35310
|
35369
|
35556
|
36359
|
36362
|
36363
|
36364
|
36365
|
36366
|
36367
|
36368
|
36369
|
36370
|
36371
|
36372
|
36373
|
36374
|
38549
|
38550
|
38551
|
38552
|
38553
|
38554
|
38555
|
38556
|
38557
|
38558
|
38559
|
38560
|
38561
|
42296
|
42297
|
42298
| 42299 |
42300
|
42301
|
42302
|
42303
|
42304
|
42305
|
42306
|
42307
|
42308
|
42309
|
42310
|
42332
|
42333
|
43076