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