]> git.koha-community.org Git - koha.git/blob - koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
Bug 27631: offline_circ, patroncards, plugins, pos, reserve, rotating_collections...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / edit-batch.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4     [% INCLUDE 'doc-head-open.inc' %]
5     <title>[% IF batch_id %]Edit ([% batch_id | html %])[% ELSE %]New[% END %] &rsaquo; Batches &rsaquo; Patron card creator &rsaquo; Tools &rsaquo; Koha</title>
6     [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="pcard_edit-batch" class="tools pcard">
10     [% INCLUDE 'header.inc' %]
11     [% INCLUDE 'cat-search.inc' %]
12
13     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
14         <ol>
15             <li>
16                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
17             </li>
18             <li>
19                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
20             </li>
21             <li>
22                 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a>
23             </li>
24             <li>
25                 <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a>
26             </li>
27             <li>
28                 <a href="#" aria-current="page">
29                     [% IF description %]
30                         Edit [% description | html %]
31                     [% ELSIF batch_id %]
32                         Edit ([% batch_id | html %])
33                     [% ELSE %]
34                         New
35                     [% END %]
36                 </a>
37             </li>
38         </ol>
39     </nav>
40
41     <div class="main container-fluid">
42         <div class="row">
43             <div class="col-sm-10 col-sm-push-2">
44                 <main>
45
46                     [% INCLUDE 'patroncards-toolbar.inc' %]
47
48                     <h1>[% IF description %]Edit [% ELSIF batch_id %]Edit [% ELSE %]New [% END %]patron card batches</h1>
49
50                 [% IF ( duplicate_message ) %]
51                     <div class="dialog message">
52                         <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
53                     </div>
54                 [% END %]
55
56                     [% INCLUDE 'patroncards-errors.inc' %]
57                     <div id="manage-patroncard-batches">
58                             <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
59                                 <div>
60                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
61                                     <ol><li id="description">
62                                         <input type="hidden" name="op" value="add" />
63                                         <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
64                                         <label for="description">Batch description: </label>
65                                         <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
66                                     </li><li>
67                                         <label for="bor_num_list">Add by borrowernumber(s):
68                                             <br /> <span class="hint">One borrowernumber per line.</span>
69                                         </label>
70                                         <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
71                                     </li></ol>
72                                     </fieldset>
73                                 </div>
74                             </form>
75                             <div id="batch-manage" class="action">
76                                 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
77                                 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
78                                 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
79                                 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
80                                 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
81                                 <a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
82                                 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
83                             </div>
84                             [% IF ( table_loop ) %]
85                             <form name="items">
86                                 <h2>Patrons in batch number [% batch_id | html %]</h2>
87                                 <table id="batcht">
88                                     [% FOREACH table_loo IN table_loop %]
89                                         [% IF ( table_loo.header_fields ) %]
90                                             <thead>
91                                                 <tr>
92                                                     [% FOREACH header_field IN table_loo.header_fields %]
93                                                         [% SWITCH header_field.field_label -%]
94                                                             [% CASE "Summary" -%]
95                                                                 <th>Borrower name</th>
96                                                             [% CASE "Borrower Number" %]
97                                                                 <th>Borrower number</th>
98                                                             [% CASE "Actions " %]
99                                                                 <th class="noExport">Actions</th>
100                                                             [% CASE "Select" -%]
101                                                                 <th>Select</th>
102                                                             [% CASE %]
103                                                                 <th>[% header_field.field_label | html %]</th>
104                                                         [% END -%]
105                                                     [% END %]
106                                                 </tr>
107                                             </thead>
108                                             <tbody>
109                                         [% ELSE %]
110                                             <tr>
111                                                 [% FOREACH text_field IN table_loo.text_fields %]
112                                                     [% IF ( text_field.select_field ) %]
113                                                         <td>
114                                                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;label_id=[% text_field.field_value | html %]"><i class="fa fa-trash"></i> Delete</a>
115                                                             <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa fa-share-square-o"></i> Export</a>
116                                                         </td>
117                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
118                                                     [% ELSE %]
119                                                         <td>[% text_field.field_value | html %]</td>
120                                                     [% END %]
121                                                 [% END %]
122                                             </tr>
123                                         [% END %]
124                                     [% END %]
125                                     </tbody>
126                                 </table>
127                             </form>
128                             [% ELSE %]
129                                 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
130                                 <ol><li>
131                                     <div class="dialog message">
132                                         <h4>There are no patrons in this batch yet</h4>
133                                         <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
134                                     </div>
135                                 </li></ol>
136                                 </fieldset>
137                             [% END %]
138                         </div>
139
140             </main>
141         </div> <!-- /.col-sm-10.col-sm-push-2 -->
142
143         <div class="col-sm-2 col-sm-pull-10">
144             <aside>
145                 [% INCLUDE 'tools-menu.inc' %]
146             </aside>
147         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
148      </div> <!-- /.row -->
149 [% MACRO jsinclude BLOCK %]
150     [% INCLUDE 'greybox.inc' %]
151     [% INCLUDE 'datatables.inc' %]
152     <script>
153         function DeleteConfirm() {
154             var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
155             var answer = confirm(msg);
156             if (answer) {
157                 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id | html %]";
158             } else {
159                 return; // abort delete
160             }
161         };
162         function Remove() {
163             items = new Array;
164
165             if(document.items.action.length > 0) {
166                 for (var i=0; i < document.items.action.length; i++) {
167                     if (document.items.action[i].checked) {
168                         items.push("label_id=" +  document.items.action[i].value);
169                     }
170                 }
171                 getstr = items.join("&");
172                 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
173             } else if (document.items.action.checked) {
174                 alert(_("Deletion of patron from a batch with only one patron will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
175                 return; // no deletion for single item batch
176             } else {
177                 alert(_("Please select at least one patron to delete."));
178                 return;     // no item selected
179             }
180             var answer = confirm(msg);
181             if (answer) {
182                 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;" + getstr;
183             } else {
184                 return; // abort delete
185             }
186         };
187         function Add() {
188             var bor_nums = document.getElementById("bor_num_list");
189             if (bor_nums.value == '') {
190                 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
191                'PatronPopup',
192                'width=1024,height=768,location=yes,toolbar=no,'
193                + 'scrollbars=yes,resize=yes');
194             } else {
195                 document.forms["add_by_bor_num"].submit();
196             }
197         };
198
199         function add_user(borrowernumber) {
200             $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
201         }
202
203         function DeDuplicate() {
204             window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id | html %]";
205         };
206         function Xport(mode) {
207             if (mode == 'label') {
208                 patroncards= new Array;
209                 if(document.items.action.length > 0) {
210                     for (var i=0; i < document.items.action.length; i++) {
211                         if (document.items.action[i].checked) {
212                             patroncards.push("label_id=" +  document.items.action[i].value);
213                         }
214                     }
215                     if (patroncards.length < 1) {
216                         alert(_("Please select at least one card to export."));
217                         return;     // no batch selected
218                     }
219                     getstr = patroncards.join("&");
220                 } else if (document.items.action.checked) {
221                     getstr = document.items.action.value;
222                 } else {
223                     alert(_("Please select at least one card to export."));
224                     return;     // no batch selected
225                 }
226                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
227             } else if (mode == 'batch') {
228                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
229             } else {
230                 // some pass-thru error trapping just in case...
231             }
232         };
233         function selected_layout() {
234             if (document.items.action.length) {
235             for (i=0;i<document.items.action.length;i++){
236                 if (document.items.action[i].checked==true){
237                     return(document.items.action[i].value);
238                 }
239             };
240             } else {
241                 if (document.items.action.checked){
242                     return(document.items.action.value);
243                 }
244             };
245             alert(_("Please select at least one item."));
246             return (-1);
247         };
248
249         $(document).ready(function() {
250             [% IF table_loop %]
251                 $("#description").show();
252             [% ELSE %]
253                 $("#description").hide();
254             [% END %]
255             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
256                 "aoColumnDefs": [
257                     { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
258                 ],
259                 "aaSorting": [[ 0, "asc" ]],
260                 "sPaginationType": "full",
261                 "autoWidth": false
262             }));
263             $("#additems").click(function(){
264                 Add();
265                 return false;
266             });
267             $("#removeitems").click(function(){
268                 Remove();
269                 return false;
270             });
271             $("#deletebatch").click(function(){
272                 DeleteConfirm();
273                 return false;
274             });
275             $("#deduplicate").click(function(){
276                 DeDuplicate();
277                 return false;
278             });
279             $("#exportitems").click(function(){
280                 Xport('label');
281                 return false;
282             });
283             $("#exportbatch").click(function(){
284                 Xport('batch');
285                 return false;
286             });
287             $(".delete").on("click", function(){
288                 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
289             });
290             $(".export").on("click", function(e){
291                 e.preventDefault();
292                 var label_id = $(this).data("label-id");
293                 var batch_id = $(this).data("batch-id");
294                 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
295             });
296             $("#savedesc").click(function(event){
297                 var newdescription = $(this).siblings('input[name="description"]').val();
298                 var batch_id = $(this).data('batch_id');
299                 var ajaxData = {
300                     'newdescription': newdescription,
301                     'batch_id': batch_id,
302                     'card_element': "batch",
303                     'creator': "patroncard",
304                 };
305
306                 $.ajax({
307                     url: '/cgi-bin/koha/svc/creator_batches',
308                     type: 'POST',
309                     dataType: 'json',
310                     data: ajaxData,
311                 })
312
313                 .done(function(data){
314                     if (data.status == 'success') {
315                         $("input[name='description']").text(data.newdesc);
316                         $("#change-status").text(_("Saved"));
317                     } else {
318                         $("#change-status").text(_("Unable to save description"));
319                     }
320                 });
321             });
322             $("#savedesc").click(function(event){
323                 var newdescription = $('input[name="description"]').val();
324                 var batch_id = $(this).data('batch_id');
325                 var ajaxData = {
326                     'newdescription': newdescription,
327                     'batch_id': batch_id,
328                     'card_element': "batch",
329                     'creator': "patroncard",
330                 };
331
332                 $.ajax({
333                     url: '/cgi-bin/koha/svc/creator_batches',
334                     type: 'POST',
335                     dataType: 'json',
336                     data: ajaxData,
337                 })
338
339                 .done(function(data){
340                     if (data.status == 'success') {
341                         $("input[name='description']").text(data.newdesc);
342                         $("#change-status").text(_("Saved"));
343                     } else {
344                         $("#change-status").text(_("Unable to save description"));
345                     }
346                 });
347             });
348         });
349     </script>
350 [% END %]
351
352 [% INCLUDE 'intranet-bottom.inc' %]