Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_extend_due_dates.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% USE Branches %]
5 [% USE Categories %]
6 [% USE KohaDates %]
7 [% USE ItemTypes %]
8 [% PROCESS 'html_helpers.inc' %]
9
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Batch extend due dates &rsaquo; Tools &rsaquo; Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 [% Asset.css("css/humanmsg.css") | $raw %]
14 </head>
15
16 <body id="tools_batch_extend_due_dates" class="tools">
17     [% WRAPPER 'header.inc' %]
18     [% INCLUDE 'cat-search.inc' %]
19 [% END %]
20
21     [% WRAPPER 'sub-header.inc' %]
22     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
23         <ol>
24             <li>
25                 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
26             </li>
27             <li>
28                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
29             </li>
30             <li>
31                 <a href="#" aria-current="page">Batch extend due dates</a>
32             </li>
33         </ol>
34     </nav>
35     [% END %]
36
37     <div class="main container-fluid">
38         <div class="row">
39             <div class="col-sm-10 col-sm-push-2">
40                 <main>
41
42                     <h1>Batch extend due dates</h1>
43
44                     [% IF ( messages ) %]
45                         <div class="dialog message">
46
47                             [% FOREACH message IN messages %]
48                                 [% IF message.type == 'success' %]
49                                     <div><i class="fa fa-check success"></i>
50                                 [% ELSIF message.type == 'warning' %]
51                                     <div><i class="fa fa-warning warn"></i>
52                                 [% ELSIF message.type == 'error' %]
53                                     <div><i class="fa fa-exclamation error"></i>
54                                 [% END %]
55                                 [% IF message.error %]
56                                     <span>(The error was: [% message.error | html %]. See the Koha logfile for more information).</span>
57                                 [% END %]
58                                 </div>
59                             [% END %]
60
61                         </div> <!-- .dialog.message -->
62                     [% END %]
63
64                     [% IF view == 'form' %]
65                         <form method="post" action="/cgi-bin/koha/tools/batch_extend_due_dates.pl" id="extend_due_dates_form">
66                             <fieldset class="rows">
67                                 <legend>Checkout criteria:</legend>
68                                 <ol>
69                                     <li>
70                                         <label for="categorycodes">Patrons' categories: </label>
71                                         [% SET categories = Categories.all() %]
72                                         <select id="categorycodes" name="categorycodes" multiple="multiple">
73                                             [% FOREACH cat IN categories %]
74                                                 <option value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
75                                             [% END %]
76                                         </select>
77                                     </li>
78
79                                     <li>
80                                         <label for="branchcodes">Libraries: </label>
81                                         <select name="branchcodes" id="branchcodes" multiple="multiple">
82                                             [% PROCESS options_for_libraries libraries => Branches.all() %]
83                                         </select>
84                                     </li>
85
86                                     <li>
87                                         <label for="from_due_date">Due date from: </label>
88                                         <input type="text" size="10" id="from" name="from_due_date" class="flatpickr" data-date_to="to" />
89                                     </li>
90
91                                     <li>
92                                         <label for="to_due_date">Due date to:</label>
93                                         <input type="text" size="10" id="to" name="to_due_date" class="flatpickr" />
94                                     </li>
95                                 </ol>
96                             </fieldset>
97                             <fieldset class="rows">
98                                 <legend>New due date:</legend>
99                                 <ol>
100                                     <li>
101                                         <label for="new_hard_due_date">Hard due date: </label>
102                                         <input type="text" size="10" id="new_hard_due_date" name="new_hard_due_date" class="flatpickr" />
103                                     </li>
104
105                                     <li>
106                                         <label for="due_date_days">Or add number of days:</label>
107                                         <input type="text" size="10" id="due_date_days" name="due_date_days"/>
108                                     </li>
109                                 </ol>
110                             </fieldset>
111                             <fieldset class="rows">
112                                 <legend>Options:</legend>
113                                 <ol>
114                                     <li>
115                                         <label for="preview_results">Preview results:</label>
116                                         <input type="checkbox" name="preview_results" id="preview_results" checked />
117                                         <span class="hint">This is not recommended when changing very large numbers of due dates.</span>
118                                     </li>
119                                 </ol>
120                             </fieldset>
121                             <fieldset class="action">
122                                 <input type="hidden" name="op" value="list" />
123                                 <input type="submit" value="Continue" class="button" />
124                                 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
125                             </fieldset>
126                         </form> <!-- /#extend_due_dates_form -->
127                     [% ELSIF view == 'list' %]
128                         [% IF checkouts.count %]
129                             <form action="/cgi-bin/koha/tools/batch_extend_due_dates.pl" method="post" id="process">
130                                 <div id="toolbar">
131                                     <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
132                                     | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
133                                 </div>
134                                 <table id="checkouts">
135                                     <thead>
136                                         <tr>
137                                             <th>&nbsp;</th>
138                                             <th>Due date</th>
139                                             <th>Title</th>
140                                             <th>Item type</th>
141                                             <th>Home library</th>
142                                             <th>Checked out on</th>
143                                             <th>Checked out from</th>
144                                             <th>New due date</th>
145                                         </tr>
146                                     </thead>
147                                     <tbody>
148                                         [% FOR checkout IN checkouts %]
149                                             <tr>
150                                                 <td><input type="checkbox" name="issue_id" value="[% checkout.issue_id | html %]" /></td>
151                                                 <td>[% checkout.date_due | $KohaDates as_due_date => 1 %]</td>
152                                                 <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% checkout.item.biblio.biblionumber | uri %]">[% checkout.item.biblio.title | html %]</a></td>
153                                                 <td>[% ItemTypes.GetDescription( checkout.item.effective_itemtype ) | html %]</td>
154                                                 <td>[% checkout.item.home_branch.branchname | html %]</td>
155                                                 <td>[% checkout.issuedate | $KohaDates %]</td>
156                                                 <td>[% Branches.GetName( checkout.branchcode ) | html %]</td>
157                                                 <td>
158                                                     [% new_due_dates.shift | $KohaDates as_due_date => 1 %]
159                                                 </td>
160                                             </tr>
161                                         [% END %]
162                                     </tbody>
163                                 </table> <!-- /#checkouts -->
164                                 <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected checkouts!</div>
165                                 <fieldset class="action">
166                                     <input type="hidden" name="op" value="modify" />
167                                     <input type="hidden" name="new_hard_due_date" value="[% new_hard_due_date | $KohaDates dateformat => 'iso' %]" />
168                                     <input type="hidden" name="due_date_days" value="[% due_date_days | html %]" />
169                                     <input type="submit" value="Modify selected checkouts" class="button" />
170                                     <a class="cancel" href="/cgi-bin/koha/tools/batch_extend_due_dates.pl">Cancel</a>
171                                 </fieldset>
172                             </form> <!-- /#process -->
173                         [% ELSE %]
174                             <div class="dialog message">
175                                 No checkouts for the selected filters.
176                             </div>
177                         [% END %]
178                     [% ELSIF view == 'report' %]
179                         <div class="dialog message">
180                             Due dates have been modified!
181                         </div>
182
183                         <table id="checkouts_result">
184                             <thead>
185                                 <tr>
186                                     <th>Due date</th>
187                                     <th>Title</th>
188                                     <th>Item type</th>
189                                     <th>Home library</th>
190                                     <th>Checked out on</th>
191                                     <th>Checked out from</th>
192                                 </tr>
193                             </thead>
194                             <tbody>
195                                 [% FOR checkout IN checkouts %]
196                                     <tr>
197                                         <td>[% checkout.date_due | $KohaDates as_due_date => 1 %]</td>
198                                         <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% checkout.item.biblio.biblionumber | uri %]">[% checkout.item.biblio.title | html %]</a></td>
199                                         <td>[% ItemTypes.GetDescription( checkout.item.effective_itemtype ) | html %]</td>
200                                         <td>[% checkout.item.home_branch.branchname | html %]</td>
201                                         <td>[% checkout.issuedate | $KohaDates %]</td>
202                                         <td>[% Branches.GetName( checkout.branchcode ) | html %]</td>
203                                     </tr>
204                                 [% END %]
205                             </tbody>
206                         </table> <!-- /#checkouts_result -->
207                     [% END %]
208                 </main>
209             </div> <!-- /.col-sm-10.col-sm-push-2 -->
210
211             <div class="col-sm-2 col-sm-pull-10">
212                 <aside>
213                     [% INCLUDE 'tools-menu.inc' %]
214                 </aside>
215             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
216         </div> <!-- /.row -->
217
218 [% MACRO jsinclude BLOCK %]
219     [% Asset.js("js/tools-menu.js") | $raw %]
220     [% INCLUDE 'calendar.inc' %]
221     [% INCLUDE 'datatables.inc' %]
222     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
223     <script>
224         $(document).ready(function() {
225
226             $("#selectall").click(function(e){
227                 e.preventDefault();
228                 $("#checkouts input[type='checkbox']").each(function(){
229                     $(this).prop("checked", true);
230                 });
231             });
232
233             $("#clearall").click(function(e){
234                 e.preventDefault();
235                 $("#checkouts input[type='checkbox']").each(function(){
236                     $(this).prop("checked", false);
237                 });
238             });
239
240             $("#selectall").click();
241
242             $("#checkouts").dataTable($.extend(true, {}, dataTablesDefaults, {
243                 "aoColumnDefs": [
244                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
245                     { "aTargets": [1], "sType": "num-html" }
246                 ],
247                 "sDom": 't',
248                 "aaSorting": [],
249                 "bPaginate": false
250             }));
251
252             $("#checkouts_result").dataTable($.extend(true, {}, dataTablesDefaults, {
253                 "aoColumnDefs": [
254                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
255                     { "aTargets": [1], "sType": "num-html" }
256                 ],
257                 "sDom": 't',
258                 "aaSorting": [],
259                 "bPaginate": false
260             }));
261
262             $("#extend_due_dates_form").on('submit', function(e) {
263                 var new_hard_due_date = $("#new_hard_due_date").val();
264                 var due_date_days = $("#due_date_days").val();
265                 if (new_hard_due_date && due_date_days ) {
266                     e.preventDefault();
267                     alert(_("You must fill only one of the two due date options"));
268                     return false;
269                 } else if ( !new_hard_due_date && !due_date_days ) {
270                     e.preventDefault();
271                     alert(_("You must fill at least one of the two due date options"));
272                     return false;
273                 }
274
275                 return true;
276             });
277
278             $("#process").on('submit', function(e) {
279                 if ($("input[type=checkbox][name='issue_id']:checked").length == 0) {
280                     e.preventDefault();
281                     alert(_("Please select at least one checkout to process"));
282                     return false;
283                 }
284                 return true;
285             });
286
287         });
288     </script>
289 [% END %]
290
291 [% INCLUDE 'intranet-bottom.inc' %]