|
Line 0
Link Here
|
|
|
1 |
[% USE Asset %] |
| 2 |
[% USE AuthorisedValues %] |
| 3 |
[% SET footerjs = 1 %] |
| 4 |
[% INCLUDE 'doc-head-open.inc' %] |
| 5 |
<title>Koha › Administration › |
| 6 |
[% SWITCH op %] |
| 7 |
[% CASE 'add_form' %][% IF field %]Modify additional field '[% field.name %]'[% ELSE %]Add additional field[% END %] |
| 8 |
[% CASE %]Manage additional fields |
| 9 |
[% END %] |
| 10 |
</title> |
| 11 |
[% INCLUDE 'doc-head-close.inc' %] |
| 12 |
[% Asset.css('css/datatables.css') %] |
| 13 |
</head> |
| 14 |
|
| 15 |
<body id="ser_add_fields" class="ser"> |
| 16 |
[% INCLUDE 'header.inc' %] |
| 17 |
[% INCLUDE 'cat-search.inc' %] |
| 18 |
|
| 19 |
<div id="breadcrumbs"> |
| 20 |
<a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › |
| 21 |
[% SWITCH op %] |
| 22 |
[% CASE 'add_form' %]<a href="/cgi-bin/koha/admin/additional-fields.pl">Manage additional fields</a> › [% IF field %]Modify field '[% field.name %]'[% ELSE %]Add field[% END %] |
| 23 |
[% CASE 'list' %]<a href="/cgi-bin/koha/admin/additional-fields.pl">Manage additional fields</a> › Modify fields for '[% tablename %]' |
| 24 |
[% CASE %]Manage additional fields |
| 25 |
[% END %] |
| 26 |
</div> |
| 27 |
|
| 28 |
<div id="doc3" class="yui-t2"> |
| 29 |
<div id="bd"> |
| 30 |
<div id="yui-main"> |
| 31 |
<div class="yui-b"> |
| 32 |
[% IF op == 'list' %] |
| 33 |
<div id="toolbar" class="btn-toolbar"> |
| 34 |
<a class="btn btn-default btn-sm" id="newfields" href="?op=add_form&tablename=[% tablename %]"><i class="fa fa-plus"></i> Create field</a> |
| 35 |
</div> |
| 36 |
[% END %] |
| 37 |
|
| 38 |
[% IF messages %] |
| 39 |
[% FOR message IN messages %] |
| 40 |
[% IF message.code == 'insert' %] |
| 41 |
[% IF message.number > 0 %] |
| 42 |
<div class="dialog message">The field has been inserted</div> |
| 43 |
[% ELSE %] |
| 44 |
<div class="dialog alert">The field could not be inserted. Perhaps the name already exists?</div> |
| 45 |
[% END %] |
| 46 |
[% ELSIF message.code == 'update' %] |
| 47 |
[% IF message.number > 0 %] |
| 48 |
<div class="dialog message">The field has been updated</div> |
| 49 |
[% ELSE %] |
| 50 |
<div class="dialog alert">The field could not be updated. Perhaps the name already exists?</div> |
| 51 |
[% END %] |
| 52 |
[% ELSIF message.code == 'delete' %] |
| 53 |
[% IF message.number > 0 %] |
| 54 |
<div class="dialog message">The field has been deleted</div> |
| 55 |
[% ELSE %] |
| 56 |
<div class="dialog alert">The field could not be deleted. Check the log for errors.</div> |
| 57 |
[% END %] |
| 58 |
[% END %] |
| 59 |
[% END %] |
| 60 |
[% END %] |
| 61 |
|
| 62 |
[% IF op == 'list_tables' %] |
| 63 |
<h3>Additional fields</h3> |
| 64 |
<p>Select a table:</p> |
| 65 |
[% BLOCK table_option %] |
| 66 |
<li><a href="?tablename=[% value %]">[% content %] (<tt>[% value %]</tt>)</a></li> |
| 67 |
[% END %] |
| 68 |
<ul> |
| 69 |
[% WRAPPER table_option value="aqbasket" %]Order baskets[% END %] |
| 70 |
[% WRAPPER table_option value="subscription" %]Subscriptions[% END %] |
| 71 |
</ul> |
| 72 |
[% ELSIF op == 'list' %] |
| 73 |
<h3>Additional fields for '[% tablename %]'</h3> |
| 74 |
[% IF fields %] |
| 75 |
<table id="fieldst"> |
| 76 |
<thead> |
| 77 |
<tr> |
| 78 |
<th>Name</th> |
| 79 |
<th>Authorised value category</th> |
| 80 |
<th>MARC field</th> |
| 81 |
<th>Searchable</th> |
| 82 |
<th>Actions</th> |
| 83 |
</tr> |
| 84 |
</thead> |
| 85 |
<tbody> |
| 86 |
[% FOR field IN fields %] |
| 87 |
<tr> |
| 88 |
<td>[% field.name %]</td> |
| 89 |
<td>[% field.authorised_value_category %]</td> |
| 90 |
<td>[% field.marcfield %]</td> |
| 91 |
<td> |
| 92 |
[% IF field.searchable %]Yes[% ELSE %]No[% END %] |
| 93 |
</td> |
| 94 |
<td class="actions"> |
| 95 |
<a class="btn btn-default btn-xs" href="?op=add_form&field_id=[% field.id %]"><i class="fa fa-pencil"></i> Edit</a> |
| 96 |
<a class="confirmdelete btn btn-default btn-xs" href="?op=delete&field_id=[% field.id %]"><i class="fa fa-trash"></i> Delete</a> |
| 97 |
</td> |
| 98 |
</tr> |
| 99 |
[% END %] |
| 100 |
</tbody> |
| 101 |
</table> |
| 102 |
[% ELSE %] |
| 103 |
[% IF tablename %]There are no additional fields defined for this table.[% END %] |
| 104 |
[% END %] |
| 105 |
[% ELSIF op == 'add_form' %] |
| 106 |
[% IF field %] |
| 107 |
<h3>Modify field</h3> |
| 108 |
[% ELSE %] |
| 109 |
<h3>Add field</h3> |
| 110 |
[% END %] |
| 111 |
<form action="" name="add_form" id="add_field" method="post"> |
| 112 |
<fieldset class="rows"> |
| 113 |
<ol> |
| 114 |
<li> |
| 115 |
<label for="name" class="required">Name: </label> |
| 116 |
<input type="text" name="name" id="name" value="[% field.name | html %]" class="required" required="required" /> |
| 117 |
<span class="required">Required</span> |
| 118 |
</li> |
| 119 |
<li> |
| 120 |
<label for="av">Authorised value category: </label> |
| 121 |
<select name="authorised_value_category"> |
| 122 |
<option value="">None</option> |
| 123 |
[% PROCESS options_for_authorised_value_categories |
| 124 |
authorised_value_categories = AuthorisedValues.GetCategories({ |
| 125 |
selected => field.authorised_value_category |
| 126 |
}) |
| 127 |
%] |
| 128 |
</select> |
| 129 |
</li> |
| 130 |
<li> |
| 131 |
<label for="marcfield">MARC field: </label> |
| 132 |
<input type="text" name="marcfield" id="marcfield" value="[% field.marcfield %]" /> |
| 133 |
</li> |
| 134 |
<li> |
| 135 |
<label for="searchable">Searchable: </label> |
| 136 |
[% IF field.searchable %] |
| 137 |
<input type="checkbox" name="searchable" id="searchable" checked="checked" /> |
| 138 |
[% ELSE %] |
| 139 |
<input type="checkbox" name="searchable" id="searchable" /> |
| 140 |
[% END %] |
| 141 |
</li> |
| 142 |
</ol> |
| 143 |
</fieldset> |
| 144 |
<fieldset class="action"> |
| 145 |
[% IF field %] |
| 146 |
<input type="hidden" name="field_id" value="[% field.id %]" /> |
| 147 |
[% END %] |
| 148 |
<input type="hidden" name="tablename" value="[% tablename %]" /> |
| 149 |
<input type="hidden" name="op" value="add" /> |
| 150 |
<input type="submit" value="Save" /> |
| 151 |
<a href="?tablename=[% tablename %]" class="cancel">Cancel</a> |
| 152 |
</fieldset> |
| 153 |
</form> |
| 154 |
[% END %] |
| 155 |
|
| 156 |
</div> |
| 157 |
</div> |
| 158 |
|
| 159 |
<div class="yui-b"> |
| 160 |
[% INCLUDE 'admin-menu.inc' %] |
| 161 |
</div> |
| 162 |
</div> |
| 163 |
|
| 164 |
[% MACRO jsinclude BLOCK %] |
| 165 |
[% INCLUDE "datatables.inc" %] |
| 166 |
<script type="text/javascript"> |
| 167 |
$(document).ready(function(){ |
| 168 |
$('#selecttable').find(":submit").hide(); |
| 169 |
$('#selecttable select').change(function() { |
| 170 |
$('#selecttable').submit(); |
| 171 |
}); |
| 172 |
|
| 173 |
$("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, { |
| 174 |
'bAutoWidth': false, |
| 175 |
'sDom': 't<"bottom pager"ilpf>', |
| 176 |
'sPaginationType': 'four_button', |
| 177 |
'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]], |
| 178 |
'iDisplayLength': 20, |
| 179 |
'aaSorting': [[ 0, "asc" ]], |
| 180 |
})); |
| 181 |
|
| 182 |
$(".confirmdelete").click(function(){ |
| 183 |
return confirm(_("Are you sure you want to delete this field?")); |
| 184 |
}); |
| 185 |
|
| 186 |
$("#add_field").on('submit', function(){ |
| 187 |
if ( $("#marcfield").val().length > 0 |
| 188 |
&& $("select[name='authorised_value_category']" ).val().length > 0 ) { |
| 189 |
alert("You cannot select an authorised value category and a marcfield"); |
| 190 |
return false; |
| 191 |
} |
| 192 |
return true; |
| 193 |
}); |
| 194 |
}); |
| 195 |
</script> |
| 196 |
[% END %] |
| 197 |
|
| 198 |
[% INCLUDE 'intranet-bottom.inc' %] |