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