|
Line 0
Link Here
|
|
|
1 |
[% USE raw %] |
| 2 |
[% USE Asset %] |
| 3 |
[% PROCESS 'i18n.inc' %] |
| 4 |
[% SET footerjs = 1 %] |
| 5 |
[% INCLUDE 'doc-head-open.inc' %] |
| 6 |
<title>[% FILTER collapse %] |
| 7 |
[% IF ( op == 'edit_form' ) %] |
| 8 |
[% t("Rules") | html %] › |
| 9 |
[% END %] |
| 10 |
[% t("Automatic item modifications by event") | html %] › |
| 11 |
[% t("Cataloging") | html %] › |
| 12 |
[% t("Koha") | html %] |
| 13 |
[% END %]</title> |
| 14 |
[% INCLUDE 'doc-head-close.inc' %] |
| 15 |
</head> |
| 16 |
|
| 17 |
<body id="tools_automatic_item_modification_by_event" class="tools"> |
| 18 |
[% WRAPPER 'header.inc' %] |
| 19 |
[% INCLUDE 'cat-search.inc' %] |
| 20 |
[% END %] |
| 21 |
|
| 22 |
[% WRAPPER 'sub-header.inc' %] |
| 23 |
[% WRAPPER breadcrumbs %] |
| 24 |
[% WRAPPER breadcrumb_item %] |
| 25 |
<a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a> |
| 26 |
[% END %] |
| 27 |
|
| 28 |
[% IF ( op == 'edit_form' ) %] |
| 29 |
[% WRAPPER breadcrumb_item %] |
| 30 |
<a href="/cgi-bin/koha/tools/automatic_item_modification_by_event.pl">Automatic item modifications by event</a> |
| 31 |
[% END %] |
| 32 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
| 33 |
<span>Rules</span> |
| 34 |
[% END %] |
| 35 |
[% ELSE %] |
| 36 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
| 37 |
<span>Automatic item modifications by event</span> |
| 38 |
[% END %] |
| 39 |
[% END %] |
| 40 |
[% END #/ WRAPPER breadcrumbs %] |
| 41 |
[% END #/ WRAPPER sub-header.inc %] |
| 42 |
|
| 43 |
<div class="main container-fluid"> |
| 44 |
<div class="row"> |
| 45 |
<div class="col-md-10 order-md-2 order-sm-1"> |
| 46 |
<main> |
| 47 |
[% INCLUDE 'messages.inc' %] |
| 48 |
|
| 49 |
[% IF ( op == 'edit_form' ) %] |
| 50 |
<datalist id="substitution-fields"> |
| 51 |
[% FOREACH substitution_field IN substitution_fields %] |
| 52 |
<option value="$[% substitution_field | html %]">$[% substitution_field | html %]</option> |
| 53 |
[% END %] |
| 54 |
</datalist> |
| 55 |
|
| 56 |
<form method="post" id="rules_form" action="/cgi-bin/koha/tools/automatic_item_modification_by_event.pl"> |
| 57 |
[% INCLUDE 'csrf-token.inc' %] |
| 58 |
<h1>Rules for automatic item modifications by event</h1> |
| 59 |
<div id="toolbar" class="btn-toolbar"> |
| 60 |
<div class="btn-group"> |
| 61 |
<button class="btn btn-default add_rule"><i class="fa fa-plus"></i> Add rule</button> |
| 62 |
</div> |
| 63 |
<div class="btn-group"> |
| 64 |
<button type="submit" id="save_rules" class="btn btn-default"><i class="fa fa-save"></i> Save</button> |
| 65 |
</div> |
| 66 |
<div class="btn-group"> |
| 67 |
<a class="btn btn-default" href="/cgi-bin/koha/tools/automatic_item_modification_by_event.pl"><i class="fa fa-times"></i> Cancel</a> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
[% ELSE %] |
| 71 |
<h1>Automatic item modifications by event</h1> |
| 72 |
[% IF ( rules ) %] |
| 73 |
<div id="toolbar" class="btn-toolbar"> |
| 74 |
<a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/automatic_item_modification_by_event.pl?op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit rules</a> |
| 75 |
</div> |
| 76 |
[% ELSE %] |
| 77 |
<div id="toolbar" class="btn-toolbar"> |
| 78 |
<a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/automatic_item_modification_by_event.pl?op=edit_form"><i class="fa fa-plus"></i> Add rules</a> |
| 79 |
</div> |
| 80 |
[% END %] |
| 81 |
[% END %] |
| 82 |
|
| 83 |
[% FOR message IN messages %] |
| 84 |
[% IF message.type == "error" %] |
| 85 |
<div class="dialog alert"> |
| 86 |
[% END %] |
| 87 |
[% IF message.code == "unable_to_load_configuration" %] |
| 88 |
An error occurs: Unable to load the configuration. |
| 89 |
[% END %] |
| 90 |
</div> |
| 91 |
[% END %] |
| 92 |
|
| 93 |
[% IF op == 'edit_form' %] |
| 94 |
<div id="edit_rules"> |
| 95 |
<div id="rules"> |
| 96 |
[% FOR rule IN rules %] |
| 97 |
[% SET id = loop.count %] |
| 98 |
<fieldset class="rule"> |
| 99 |
<legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend> |
| 100 |
<input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled --> |
| 101 |
<div class="event"> |
| 102 |
<h5>Event</h5> |
| 103 |
<select class="event" type="text" name="event_[% id | html %]"> |
| 104 |
[% IF rule.event == "checkin" %] |
| 105 |
<option value="checkin" selected>Checkin</option> |
| 106 |
[% ELSE %] |
| 107 |
<option value="checkin">Checkin</option> |
| 108 |
[% END %] |
| 109 |
|
| 110 |
[% IF rule.event == "checkout" %] |
| 111 |
<option value="checkout" selected>Checkout</option> |
| 112 |
[% ELSE %] |
| 113 |
<option value="checkout">Checkout</option> |
| 114 |
[% END %] |
| 115 |
</select> |
| 116 |
</div> |
| 117 |
|
| 118 |
<div class="blocks"> |
| 119 |
<h5>Conditions</h5> |
| 120 |
[% FOR condition IN rule.conditions %] |
| 121 |
<div class="block"> |
| 122 |
<select name="condition_field_[% id | html %]"> |
| 123 |
<option value="">Choose a field name</option> |
| 124 |
[% FOR field IN condition_fields.sort %] |
| 125 |
[% IF condition.field == field %] |
| 126 |
<option value="[% field | html %]" selected="selected">[% field | html %]</option> |
| 127 |
[% ELSE %] |
| 128 |
<option value="[% field | html %]">[% field | html %]</option> |
| 129 |
[% END %] |
| 130 |
[% END %] |
| 131 |
</select> |
| 132 |
= |
| 133 |
<input type="text" value="[% condition.value | html %]" name="condition_value_[% id | html %]" /> |
| 134 |
<a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a> |
| 135 |
<a class="remove_block" href="#"><i class="fa fa-trash-can"></i> Remove condition</a> |
| 136 |
</div> |
| 137 |
[% END %] |
| 138 |
</div> |
| 139 |
<div class="blocks"> |
| 140 |
<h5>Substitutions</h5> |
| 141 |
[% FOR substitution IN rule.substitutions %] |
| 142 |
<div class="block"> |
| 143 |
<select class="required" required="required" name="substitution_field_[% id | html %]"> |
| 144 |
<option value="">Choose a field name</option> |
| 145 |
[% FOR field IN substitution_fields.sort %] |
| 146 |
[% IF substitution.field == field %] |
| 147 |
<option value="[% field | html %]" selected="selected">[% field | html %]</option> |
| 148 |
[% ELSE %] |
| 149 |
<option value="[% field | html %]">[% field | html %]</option> |
| 150 |
[% END %] |
| 151 |
[% END %] |
| 152 |
</select> |
| 153 |
= |
| 154 |
<input type="text" value="[% substitution.value | html %]" name="substitution_value_[% id | html %]" list="substitution-fields" autocomplete="off" /> |
| 155 |
<a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a> |
| 156 |
<a class="remove_block" href="#"><i class="fa fa-trash-can"></i> Remove substitution</a> |
| 157 |
<span class="required">A field name is required</span> |
| 158 |
</div> |
| 159 |
[% END %] |
| 160 |
</div> |
| 161 |
</fieldset> |
| 162 |
[% END %] |
| 163 |
</div> |
| 164 |
<input type="hidden" name="op" value="cud-update" /> |
| 165 |
</div> |
| 166 |
</form> |
| 167 |
|
| 168 |
<div id="norules" class="dialog message"> |
| 169 |
There are no rules defined. |
| 170 |
</div> |
| 171 |
|
| 172 |
<fieldset id="new_rule"> |
| 173 |
<legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend> |
| 174 |
<input type="hidden" name="unique_id" /> |
| 175 |
<div class="event"> |
| 176 |
<h5>Event</h5> |
| 177 |
<select class="event" type="text" name="event"> |
| 178 |
<option value="checkin">Checkin</option> |
| 179 |
<option value="checkout">Checkout</option> |
| 180 |
</select> |
| 181 |
</div> |
| 182 |
<div class="blocks"> |
| 183 |
<h5>Conditions</h5> |
| 184 |
<div class="block"> |
| 185 |
<select name="condition_field"> |
| 186 |
<option value="">Choose a field name</option> |
| 187 |
[% FOR field IN condition_fields.sort %] |
| 188 |
<option value="[% field | html %]">[% field | html %]</option> |
| 189 |
[% END %] |
| 190 |
</select> |
| 191 |
= |
| 192 |
<input type="text" value="" name="condition_value" /> |
| 193 |
<a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a> |
| 194 |
<a class="remove_block" href="#"><i class="fa fa-trash-can"></i> Remove condition</a> |
| 195 |
</div> |
| 196 |
</div> |
| 197 |
<div class="blocks"> |
| 198 |
<h5>Substitutions</h5> |
| 199 |
<div class="block"> |
| 200 |
<select required="required" class="required" name="substitution_field"> |
| 201 |
<option value="">Choose a field name</option> |
| 202 |
[% FOR field IN substitution_fields.sort %] |
| 203 |
<option value="[% field | html %]">[% field | html %]</option> |
| 204 |
[% END %] |
| 205 |
</select> |
| 206 |
= |
| 207 |
<input type="text" value="" name="substitution_value" list="substitution-fields" autocomplete="off"/> |
| 208 |
<a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a> |
| 209 |
<a class="remove_block" href="#"><i class="fa fa-trash-can"></i> Remove substitution</a> |
| 210 |
<span class="required">A field name is required</span> |
| 211 |
</div> |
| 212 |
</div> |
| 213 |
</fieldset> |
| 214 |
[% ELSIF rules %] |
| 215 |
<div> |
| 216 |
<h4>List of rules</h4> |
| 217 |
|
| 218 |
<div class="page-section"> |
| 219 |
<table id="rulest"> |
| 220 |
<thead> |
| 221 |
<tr> |
| 222 |
<th>Event</th> |
| 223 |
<th>Conditions</th> |
| 224 |
<th>Substitutions</th> |
| 225 |
</tr> |
| 226 |
</thead> |
| 227 |
<tbody> |
| 228 |
[% FOR rule IN rules %] |
| 229 |
<tr> |
| 230 |
<td>[% rule.event | html %]</td> |
| 231 |
<td> |
| 232 |
[% FOR condition IN rule.conditions %] |
| 233 |
[% IF condition.field %] |
| 234 |
<div class="block"> |
| 235 |
[% condition.field | html %] = [% condition.value | html %] |
| 236 |
</div> |
| 237 |
[% ELSE %] |
| 238 |
There is no condition for this rule. |
| 239 |
[% END %] |
| 240 |
[% END %] |
| 241 |
</td> |
| 242 |
<td> |
| 243 |
[% FOR substitution IN rule.substitutions %] |
| 244 |
<div class="block"> |
| 245 |
[% substitution.field | html %] = [% substitution.value | html %] |
| 246 |
</div> |
| 247 |
[% END %] |
| 248 |
</td> |
| 249 |
</tr> |
| 250 |
[% END %] |
| 251 |
</tbody> |
| 252 |
</table> |
| 253 |
</div> <!-- /.page-section --> |
| 254 |
</div> |
| 255 |
[% ELSE %] |
| 256 |
<div class="dialog message"> |
| 257 |
There are no rules defined. |
| 258 |
</div> |
| 259 |
[% END %] |
| 260 |
|
| 261 |
</main> |
| 262 |
</div> |
| 263 |
|
| 264 |
<div class="col-md-2 order-md-1 order-sm-2"> |
| 265 |
<aside> |
| 266 |
[% INCLUDE 'cat-menu.inc' %] |
| 267 |
</aside> |
| 268 |
</div> |
| 269 |
</div> <!-- /.row --> |
| 270 |
|
| 271 |
[% MACRO jsinclude BLOCK %] |
| 272 |
[% Asset.js("lib/hc-sticky/hc-sticky.js") | $raw %] |
| 273 |
[% Asset.js("js/automatic_item_modification_by_event.js") | $raw %] |
| 274 |
[% IF op == 'edit_form' %] |
| 275 |
<script> |
| 276 |
var Sticky; |
| 277 |
$(document).ready(function() { |
| 278 |
[% IF ( op == 'edit_form' ) %] |
| 279 |
Sticky = $("#toolbar"); |
| 280 |
Sticky.hcSticky({ |
| 281 |
stickTo: "main", |
| 282 |
stickyClass: "floating" |
| 283 |
}); |
| 284 |
[% END %] |
| 285 |
[% IF rules.size > 0 %] |
| 286 |
$("#norules").hide(); |
| 287 |
[% ELSE %] |
| 288 |
$("#rules").show(); |
| 289 |
[% END %] |
| 290 |
}); |
| 291 |
</script> |
| 292 |
[% END %] |
| 293 |
[% END %] |
| 294 |
|
| 295 |
[% INCLUDE 'intranet-bottom.inc' %] |