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