Bug 11897: (QA follow-up) Fixes for JS12
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / stockrotation.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE KohaDates %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Stock rotation</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("css/datatables.css") | $raw %]
11 </head>
12
13 <body id="tools_stockrotation" class="tools">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'patron-search.inc' %]
16
17 <div id="breadcrumbs">
18     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19     &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
20
21 [% IF no_op_set %]
22     &rsaquo; Stock rotation
23 [% ELSE %]
24     &rsaquo; <a href="/cgi-bin/koha/tools/stockrotation.pl">Stock rotation</a>
25 [% END %]
26
27 [% IF (op == 'create_edit_rota' && rota.rota_id) %]
28     &rsaquo; Edit rota
29 [% ELSIF (op == 'create_edit_rota' && !rota.rota_id) %]
30     &rsaquo; Create rota
31 [% ELSIF (op == 'manage_stages') %]
32     &rsaquo; Manage stages
33 [% ELSIF (op == 'create_edit_stage' && stage.id) %]
34     <a href="?op=manage_stages&amp;rota_id=[% rota_id | uri %]">&rsaquo; Manage stages</a>
35     &rsaquo; Edit stage
36 [% ELSIF (op == 'create_edit_stage' && !stage.id) %]
37     <a href="?op=manage_stages&amp;rota_id=[% rota_id | uri %]">&rsaquo; Manage stages</a>
38     &rsaquo; Create stage
39 [% ELSIF (op == 'manage_items') %]
40     &rsaquo; Manage items
41 [% END %]
42
43 </div>
44
45 <div id="doc3" class="yui-t2">
46     <div id="bd">
47         <div id="yui-main">
48             <div id="stockrotation" class="yui-b">
49
50                 [% IF no_op_set %]
51
52                     [% INCLUDE 'stockrotation-toolbar.inc' %]
53
54                     <h2>Stock rotation</h2>
55
56                     [% IF existing_rotas.size > 0 %]
57                         <table class="rotas_table" role="grid">
58                             <thead>
59                                 <th>Name</th>
60                                 <th>Cyclical</th>
61                                 <th>Active</th>
62                                 <th>Description</th>
63                                 <th>Number of items</th>
64                                 <th>&nbsp;</th>
65                             </thead>
66                             <tbody>
67                                 [% FOREACH rota IN existing_rotas %]
68                                     <tr>
69                                         <td>[% rota.title | html %]</td>
70                                         <td>[% rota.cyclical ? 'Yes' : 'No' | html %]</td>
71                                         <td>[% rota.active ? 'Yes' : 'No' | html %]</td>
72                                         <td>[% rota.description | html %]</td>
73                                         <td>[% rota.stockrotationitems.count | html %]</td>
74                                         <td class="actions">
75                                             <a class="btn btn-default btn-xs" href="?op=create_edit_rota&amp;rota_id=[% rota.rota_id | uri %]">
76                                                 <i class="fa fa-pencil"></i>
77                                                 Edit
78                                             </a>
79                                             <div class="btn-group" role="group">
80                                                 <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
81                                                     Manage
82                                                     <i class="fa fa-caret-down"></i>
83                                                 </button>
84                                                 <ul class="dropdown-menu">
85                                                     <li><a href="?op=manage_stages&amp;rota_id=[% rota.rota_id | uri %]">Stages</a></li>
86                                                     [% IF CAN_user_stockrotation_manage_rota_items && rota.stockrotationstages.count > 0 %]
87                                                     <li><a href="?op=manage_items&amp;rota_id=[% rota.rota_id | uri %]">Items</a></li>
88                                                     [% END %]
89                                                 </ul>
90                                             </div>
91                                             <a class="btn btn-default btn-xs" href="?op=toggle_rota&amp;rota_id=[% rota.rota_id | uri %]">
92                                                 <i class="fa fa-power-off"></i>
93                                                 [% IF !rota.active %]
94                                                     Activate
95                                                 [% ELSE %]
96                                                     Deactivate
97                                                 [% END %]
98                                             </a>
99                                         </td>
100                                     </tr>
101                                 [% END %]
102                             </tbody>
103                         </table>
104                     [% END %]
105
106                 [% ELSIF (op == 'create_edit_rota') %]
107
108                     [% IF rota.rota_id %]
109                         <h2>Edit "[% rota.title | html %]"</h2>
110                     [% ELSE %]
111                         <h2>Create new rota</h2>
112                     [% END %]
113
114                     [% IF error == 'invalid_form' %]
115                     <div class="dialog alert">
116                         <h3>There was a problem with your form submission</h3>
117                     </div>
118                     [% END %]
119
120                     <form id="rota_form" method="post" enctype="multipart/form-data" class="validated">
121                         <fieldset class="rows">
122                             <ol>
123                                 <li>
124                                     <label class="required" for="title">Name:</label>
125                                     <input type="text" id="title" name="title" value="[% rota.title | html %]" required="required" placeholder="Rota name">
126                                     <span class="required">Required</span>
127                                 </li>
128                                 <li>
129                                     <label for="cyclical">Cyclical:</label>
130                                     <select name="cyclical" id="cyclical">
131                                         [% IF rota.cyclical %]
132                                             <option value="1" selected>Yes</option>
133                                             <option value="0">No</option>
134                                         [% ELSE %]
135                                             <option value="1">Yes</option>
136                                             <option value="0" selected>No</option>
137                                         [% END %]
138                                     </select>
139                                 </li>
140                                 <li>
141                                     <label for="description">Description:</label>
142                                     <textarea id="description" name="description" placeholder="Rota description">[% rota.description | html %]</textarea>
143                                 </li>
144                             </ol>
145                         </fieldset>
146                         <fieldset class="action">
147                             <input type="submit" value="Save">
148                             <a href="/cgi-bin/koha/tools/stockrotation.pl" class="cancel">Cancel</a>
149                         </fieldset>
150                         [% IF rota.rota_id %]
151                             <input type="hidden" name="id" value="[% rota.rota_id | html %]">
152                         [% END %]
153                         <input type="hidden" name="op" value="process_rota">
154                     </form>
155
156                 [% ELSIF (op == 'manage_stages') %]
157
158                     [% INCLUDE 'stockrotation-toolbar.inc' %]
159
160                     [% IF error == 'invalid_form' %]
161                     <div class="dialog alert">
162                         <h3>There was a problem with your form submission</h3>
163                     </div>
164                     [% END %]
165
166                     <h2>Manage [% rota.title | html %] stages</h2>
167                     <div id="ajax_status"
168                         data-saving-msg="Saving changes..."
169                         data-success-msg=""
170                         data-failed-msg="Error: ">
171                         <span id="ajax_saving_msg"></span>
172                         <i id="ajax_saving_icon" class="fa fa-spinner fa-spin"></i>
173                         <i id="ajax_success_icon" class="fa fa-check"></i>
174                         <i id="ajax_failed_icon" class="fa fa-times"></i>
175                         <span id="ajax_success_msg"></span>
176                         <span id="ajax_failed_msg"></span>
177                     </div>
178
179                     <form id="stage_form" method="post" enctype="multipart/form-data" class="validated">
180                         <fieldset class="rows">
181                             <legend>Add stage</legend>
182                             <ol>
183                                 <li>
184                                     <label class="required" for="branch">Library:</label>
185                                     <select name="branchcode" id="branch">
186                                         [% FOREACH branch IN branches %]
187                                             [% IF branch.branchcode == stage.branchcode_id %]
188                                                 <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName(branch.branchcode) | html %]</option>
189                                             [% ELSE %]
190                                                 <option value="[% branch.branchcode | html %]">[% Branches.GetName(branch.branchcode) | html %]</option>
191                                             [% END %]
192                                         [% END %]
193                                     </select>
194                                     <span class="required">Required</span>
195                                 </li>
196                                 <li>
197                                     <label class="required" for="duration">Duration:</label>
198                                     <input type="text" id="duration" name="duration" value="[% stage.duration | html %]" required="required" placeholder="Duration (days)">
199                                     <span class="required">Required</span>
200                                 </li>
201                             </ol>
202                         </fieldset>
203                         <fieldset class="action">
204                             <input type="submit" value="Submit">
205                         </fieldset>
206                         <input type="hidden" name="stage_id" value="[% stage.id | html %]">
207                         <input type="hidden" name="rota_id" value="[% rota_id | html %]">
208                         <input type="hidden" name="op" value="process_stage">
209                     </form>
210
211                     [% IF existing_stages.size > 0 %]
212                         <div id="manage_stages">
213                             <div id="manage_stages_help">
214                                 Stages can be re-ordered by using the <i class="drag_handle fa fa-lg fa-bars"></i>handle to drag and drop them to their new position
215                             </div>
216                             <div id="stage_list_headings">
217                                 <span class="stagename">Library</span>
218                                 <span class="stageduration">Duration (days)</span>
219                             </div>
220                             <ul id="sortable_stages" data-rota-id="[% rota.rota_id | html %]">
221                                 [% FOREACH stage IN existing_stages %]
222                                     <li id="stage_[% stage.stage_id | html %]">
223                                         <span data-toggle="tooltip" title="Drag and drop to move this stage to another position" data-placement="right" class="stagename">
224                                             [% IF existing_stages.size > 1 %]
225                                                 <i class="drag_handle fa fa-lg fa-bars"></i>
226                                             [% END %]
227                                             [% Branches.GetName(stage.branchcode_id) | html %]
228                                         </span>
229                                         <span class="stageduration">[% stage.duration | html %]</span>
230                                         <span class="stageactions">
231                                             <a class="btn btn-default btn-xs" href="?op=create_edit_stage&amp;stage_id=[% stage.stage_id | uri %]">
232                                                 <i class="fa fa-pencil"></i> Edit
233                                             </a>
234                                             <a class="btn btn-default btn-xs" href="?op=confirm_delete_stage&amp;stage_id=[% stage.stage_id | uri %]">
235                                                 <i class="fa fa-trash"></i> Delete
236                                             </a>
237                                         </span>
238                                     </li>
239                                 [% END %]
240                             </ul>
241                         </div>
242                     [% END %]
243
244                     <p><a href="stockrotation.pl">Return to rotas</a></p>
245
246                 [% ELSIF (op == 'create_edit_stage') %]
247
248                     [% IF stage.id %]
249                         <h2>Edit "[% Branches.GetName(stage.branchcode_id) | html %]"</h2>
250                     [% ELSE %]
251                         <h2>Create new stage</h2>
252                     [% END %]
253
254                     [% IF error == 'invalid_form' %]
255                     <div class="dialog alert">
256                         <h3>There was a problem with your form submission</h3>
257                     </div>
258                     [% END %]
259
260                     <form id="stage_form" method="post" enctype="multipart/form-data" class="validated">
261                         <fieldset class="rows">
262                             <ol>
263                                 <li>
264                                     <label class="required" for="branch">Library:</label>
265                                     <select name="branchcode" id="branch">
266                                         [% FOREACH branch IN branches %]
267                                             [% IF branch.branchcode == stage.branchcode_id %]
268                                                 <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName(branch.branchcode) | html %]</option>
269                                             [% ELSE %]
270                                                 <option value="[% branch.branchcode | html %]">[% Branches.GetName(branch.branchcode) | html %]</option>
271                                             [% END %]
272                                         [% END %]
273                                     </select>
274                                     <span class="required">Required</span>
275                                 </li>
276                                 <li>
277                                     <label class="required" for="duration">Duration:</label>
278                                     <input type="text" id="duration" name="duration" value="[% stage.duration | html %]" required="required" placeholder="Duration (days)">
279                                     <span class="required">Required</span>
280                                 </li>
281                             </ol>
282                         </fieldset>
283                         <fieldset class="action">
284                             <input type="submit" value="Save">
285                             <a href="/cgi-bin/koha/tools/stockrotation.pl?op=manage_stages&amp;rota_id=[% rota_id | uri %]" class="cancel">Cancel</a>
286                         </fieldset>
287                         <input type="hidden" name="stage_id" value="[% stage.id | html %]">
288                         <input type="hidden" name="rota_id" value="[% rota_id | html %]">
289                         <input type="hidden" name="op" value="process_stage">
290                     </form>
291                 [% ELSIF (op == 'confirm_remove_from_rota') %]
292
293                     <div class="dialog alert">
294                         <h3>Are you sure you wish to remove this item from it's rota</h3>
295                         <p>
296                             <a class="btn btn-default btn-xs approve" href="?op=remove_item_from_stage&amp;item_id=[% item_id | uri %]&amp;stage_id=[% stage_id | uri %]&amp;rota_id=[% rota_id | uri %]"><i class="fa fa-fw fa-check"></i>Yes</a>
297                             <a class="btn btn-default btn-xs deny" href="?op=manage_items&amp;rota_id=[% rota_id | uri %]"><i class="fa fa-fw fa-remove"></i>No</a>
298                         </p>
299                     </div>
300                 [% ELSIF (op == 'confirm_delete_stage') %]
301
302                     <div class="dialog alert">
303                         <h3>Are you sure you want to delete this stage?</h3>
304                         [% IF stage.stockrotationitems.count > 0 %]
305                             <p>This stage contains the following item(s):</p>
306                             <ul>
307                                 [% FOREACH item IN stage.stockrotationitems %]
308                                     <li>[% item.itemnumber.biblio.title | html %] (Barcode: [% item.itemnumber.barcode | html %])</li>
309                                 [% END %]
310                             </ul>
311                         [% END %]
312                         <p>
313                             <a class="btn btn-default btn-xs approve" href="?op=delete_stage&amp;stage_id=[% stage.stage_id | uri %]"><i class="fa fa-fw fa-check"></i>Yes</a>
314                             <a class="btn btn-default btn-xs deny" href="?op=manage_stages&amp;rota_id=[% stage.rota.rota_id | uri %]"><i class="fa fa-fw fa-remove"></i>No</a>
315                         </p>
316                     </div>
317                 [% ELSIF (op == 'manage_items') %]
318
319                     [% INCLUDE 'stockrotation-toolbar.inc' %]
320
321                     [% IF error %]
322                         <div class="dialog alert">
323                             [% IF error == "item_not_found" %]
324                                 <h3>The item was not found</h3>
325                             [% ELSIF error == "already_on_rota" %]
326                                 <h3>This item is already on this rota</h3>
327                             [% END %]
328                         </div>
329                     [% END %]
330
331                     <h2>Manage [% rota.title | html %] items</h2>
332
333                     <div>
334                         <form id="add_rota_item_form" method="post" enctype="multipart/form-data" class="validated">
335                             <fieldset class="rows">
336                                 <legend>Add item to &quot;[% rota.title | html %]&quot;</legend>
337                                 <ol>
338                                     <li>
339                                         <label for="barcode">Barcode:</label>
340                                         <input type="text" id="barcode" name="barcode" placeholder="Item barcode" autofocus>
341                                     </li>
342                                 </ol>
343                             </fieldset>
344                             <fieldset class="rows">
345                                 <legend>Use a barcode file</legend>
346                                 <ol>
347                                     <li>
348                                         <label for="barcodefile">Barcode file:</label>
349                                         <input type="file" id="barcodefile" name="barcodefile">
350                                     </li>
351                                 </ol>
352                             </fieldset>
353                             <fieldset class="action">
354                                 <input type="submit" value="Save">
355                             </fieldset>
356                             <input type="hidden" name="rota_id" value="[% rota.id | html %]">
357                             <input type="hidden" name="op" value="add_items_to_rota">
358                         </form>
359                     </div>
360
361                     [% IF items.count > 0 %]
362                         <h3>Manage items assigned to &quot;[% rota.title | html %]&quot;</h3>
363                         <table id="sr_manage_items" class="items_table" role="grid">
364                             <thead>
365                                 <th>Barcode</th>
366                                 <th>Title</th>
367                                 <th>Author</th>
368                                 <th>Callnumber</th>
369                                 <th class="NoSearch">In transit</th>
370                                 <th class="NoSort">Stages &amp; duration in days<br>(current stage highlighted)</th>
371                                 <th class="NoSort">&nbsp;</th>
372                             </thead>
373                             <tbody>
374                                 [% FOREACH item IN items %]
375                                     <tr>
376                                         <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% item.id | uri %]&amp;biblionumber=[% item.itemnumber.biblio.id | uri %]#item[% item.id | uri %]">[% item.itemnumber.barcode | html %]</a></td>
377                                         <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.itemnumber.biblio.id | uri %]">[% item.itemnumber.biblio.title | html %]</a></td>
378                                         <td>[% item.itemnumber.biblio.author | html %]</td>
379                                         <td>[% item.itemnumber.itemcallnumber | html %]</td>
380                                         <td>[% item.itemnumber.get_transfer ? 'Yes' : 'No' | html %]</td>
381                                         <td>
382                                             [% FOREACH this_stage IN stages %]
383                                                 [% IF this_stage.stage_id == item.stage.stage_id %]
384                                                     <span class="stage highlight_stage">
385                                                 [% ELSE %]
386                                                     <span class="stage">
387                                                 [% END %]
388                                                 [% Branches.GetName(this_stage.branchcode_id) | html %] ([% this_stage.duration | html %])
389                                                 </span>
390                                                 &raquo;
391                                             [% END %]
392                                             [% IF stages.size > 0 %]
393                                                 <span class="stage">[% rota.cyclical ? 'START' : 'END' | html %]</span>
394                                             [% END %]
395                                         </td>
396                                         <td class="actions">
397                                             [% in_transit = item.itemnumber.get_transfer %]
398                                             [% IF !in_transit && stages.size > 1 %]
399                                                 <a class="btn btn-default btn-xs" href="?op=move_to_next_stage&amp;rota_id=[% rota.id | uri %]&amp;item_id=[% item.id | uri %]&amp;stage_id=[% item.stage.stage_id | uri %]">
400                                             [% ELSE %]
401                                                 <a class="btn btn-default btn-xs" disabled>
402                                             [% END %]
403                                                 <i class="fa fa-arrow-right"></i>
404                                                 Move to next stage
405                                             </a>
406                                             [% IF !in_transit %]
407                                                 <a class="btn btn-default btn-xs" href="?op=toggle_in_demand&amp;stage_id=[% item.stage.stage_id | uri %]&amp;item_id=[% item.id | uri %]&amp;rota_id=[% rota.id | uri %]">
408                                             [% ELSE %]
409                                                 <a class="btn btn-default btn-xs" disabled>
410                                             [% END %]
411                                                 <i class="fa fa-fire"></i>
412                                                 [% item.indemand ? 'Remove &quot;In demand&quot;' : 'Add &quot;In demand&quot;' | html %]
413                                             </a>
414                                             [% IF !in_transit %]
415                                                 <a class="btn btn-default btn-xs" href="?op=confirm_remove_from_rota&amp;stage_id=[% item.stage.stage_id | uri %]&amp;item_id=[% item.id | uri %]&amp;rota_id=[% rota.id | uri %]">
416                                             [% ELSE %]
417                                                 <a class="btn btn-default btn-xs" disabled>
418                                             [% END %]
419                                                 <i class="fa fa-trash"></i>
420                                                 Remove from rota
421                                             </a>
422                                         </td>
423                                     </tr>
424                                 [% END %]
425                             </tbody>
426                         </table>
427                     [% END %]
428
429                     <p><a href="stockrotation.pl">Return to rotas</a></p>
430
431                 [% ELSIF op == 'add_items_to_rota' %]
432
433                     <div class="dialog message">
434                         <h3>Add items to rota report</h3>
435                     </div>
436
437                     <div>
438                         [% IF barcode_status.ok.size > 0 %]
439                             <h4>Items added to rota:</h4>
440                             <ul>
441                                 [% FOREACH item_ok IN barcode_status.ok %]
442                                     <li>[% item_ok.biblio.title | html %]</li>
443                                 [% END %]
444                             </ul>
445                         [% END %]
446                         [% IF barcode_status.on_this.size > 0 %]
447                             <h4>Items already on this rota:</h4>
448                             <ul>
449                                 [% FOREACH item_on_this IN barcode_status.on_this %]
450                                     <li>[% item_on_this.biblio.title | html %]</li>
451                                 [% END %]
452                             </ul>
453                         [% END %]
454                         [% IF barcode_status.not_found.size > 0 %]
455                             <h4>Barcodes not found:</h4>
456                             <ul>
457                                 [% FOREACH barcode_not_found IN barcode_status.not_found %]
458                                     <li>[% barcode_not_found | html %]</li>
459                                 [% END %]
460                             </ul>
461                         [% END %]
462                         [% IF barcode_status.on_other.size > 0 %]
463                             <h4>Items found on other rotas:</h4>
464                             <ul>
465                                 [% FOREACH item_on_other IN barcode_status.on_other %]
466                                     <li>[% item_on_other.biblio.title | html %]</li>
467                                 [% END %]
468                             </ul>
469                         [% END %]
470                     </div>
471                     [% IF barcode_status.on_other.size > 0 %]
472                         <form id="add_rota_item_form" method="post" enctype="multipart/form-data">
473                             <fieldset>
474                                 <legend>Select items to move to this rota:</legend>
475                                 [% FOREACH item_on_other IN barcode_status.on_other %]
476                                     <li><input type="checkbox" name="move_item" value="[% item_on_other.itemnumber | html %]"> [% item_on_other.biblio.title | html %] (Currently on &quot;[% item_on_other.stockrotationitem.stage.rota.title | html %]&quot;)</li>
477                                 [% END %]
478
479                             </fieldset>
480                             <fieldset class="action">
481                                 <input type="submit" value="Save">
482                             </fieldset>
483                             <input type="hidden" name="rota_id" value="[% rota_id | html %]">
484                             <input type="hidden" name="op" value="move_items_to_rota">
485                         </form>
486                     [% END %]
487                     <p><a href="?op=manage_items&amp;rota_id=[% rota_id | uri %]">Return to rota</a></p>
488
489                 [% END %]
490             </div>
491         </div>
492         <div class="yui-b">
493             [% INCLUDE 'tools-menu.inc' %]
494         </div>
495     </div>
496 </div>
497
498 [% MACRO jsinclude BLOCK %]
499     [% Asset.js("js/tools-menu.js") | $raw %]
500     [% INCLUDE 'datatables.inc' %]
501     [% Asset.js("js/pages/stockrotation.js") | $raw %]
502     <script type="text/javascript">
503     $(document).ready(function() {
504         $('#sr_manage_items').dataTable($.extend(true, {}, dataTablesDefaults, {
505             "autoWidth": false,
506             "aoColumnDefs": [
507                 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
508                 { "bSortable": true, "bSearchable": false, 'aTargets': [ 'NoSearch' ] }
509             ],
510             "sPaginationType": "four_button"
511         }));
512     });
513     </script>
514 [% END %]
515
516 [% INCLUDE 'intranet-bottom.inc' %]