Bug 19641: (follow-up) Move patron templates to the footer
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / manage.tt
index 0f85229..3585ea0 100644 (file)
@@ -1,27 +1,63 @@
+[% USE CGI %]
+[% BLOCK translate_card_element %]
+[%-  SWITCH element -%]
+[%-  CASE 'layout'    -%]layout
+[%-  CASE 'Layouts'   -%]Layouts
+[%-  CASE 'template'  -%]template
+[%-  CASE 'Templates' -%]Templates
+[%-  CASE 'profile'   -%]profile
+[%-  CASE 'Profiles'  -%]Profiles
+[%-  CASE 'batch'     -%]batch
+[%-  CASE 'Batches'   -%]Batches
+[%-  CASE 'Actions'   -%]Actions
+[%-  END -%]
+[% END %]
+[% BLOCK translate_card_elements %]
+[%-  SWITCH element -%]
+[%-  CASE 'layout'    -%]layouts
+[%-  CASE 'template'  -%]templates
+[%-  CASE 'profile'   -%]profiles
+[%-  CASE 'batch'     -%]batches
+[%-  END -%]
+[% END %]
+
     [% INCLUDE 'doc-head-open.inc' %]
-    <title>Koha &rsaquo; Tools &rsaquo; Patron cards &rsaquo; Manage patron card elements</title>
+    <title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; [% PROCESS translate_card_element element=card_element_title %]</title>
     [% INCLUDE 'doc-head-close.inc' %]
     [% INCLUDE 'greybox.inc' %]
     <script type="text/javascript">
         //<![CDATA[
             function DeleteConfirm() {
-                var element_id = selected_layout("delete");
-                if (element_id>-1) {
-                    var msg = _("Are you sure you want to delete") + " [% card_element %] " + element_id + "?"
-                    var answer = confirm(msg);
-                    if (answer) {
-                        window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=" + element_id;
-                    }
-                    else {
-                        return; // abort delete
+                var element_ids = selected_layouts("delete");
+
+                var msg;
+                if (element_ids.length > 1) {
+                    msg = _("Are you sure you want to delete %s %s?").format(element_ids.length, "[% PROCESS translate_card_elements element=card_element %]");
+                } else if (element_ids.length == 1) {
+                    msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]);
+                }
+
+                if (msg && confirm(msg)) {
+                    var elements = "";
+                    for (var i = 0; i < element_ids.length; i++) {
+                        if (element_ids[i] > -1) {
+                            elements += element_ids[i] + ","
+                        }
+                        else {
+                            return;     // no layout selected
+                        }
                     }
+
+                    window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=" + elements;
                 }
                 else {
-                    return;     // no layout selected
-                };
+                    return; // abort delete
+                }
+
             };
+
             function Edit() {
-                var element_id = selected_layout("edit");
+                var element_id = selected_layouts("edit");
                 if (element_id>-1) {
                     window.location = "/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=" + element_id;
                 }
                     alert(_("Please select at least one batch to export."));
                     return;     // no batch selected
                 }
-                return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
+                return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 400, 800);
+            };
+
+            function XportPatronlist() {
+                if ( patron_list_id.value.length < 1 ) {
+                    alert(_("Please select a patron list."));
+                    return;     // no patron list selected
+                }
+                getstr = 'patronlist_id='+patron_list_id.value;
+                return GB_showCenter(_("Export patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
             };
+
             function selected_layout(op) {
-                var selected = new Array;
                 if (document.layouts.action.length) {
+                    var selected = new Array();
                     for (i=0;i<document.layouts.action.length;i++){
                         if (document.layouts.action[i].checked){
                             selected.push(i);
                         }
                     };
-                    if (selected.length == 1) {
-                        return(document.layouts.action[selected[0]].value);
+                    if (selected.length == 1 || (op == "delete" && selected.length >= 1)) {
+                        if (op == "delete") {
+                            var selectedDelete = new Array;
+                            for (i = 0; i < selected.length; i++) {
+                                selectedDelete.push(document.layouts.action[selected[i]].value);
+                            }
+                            return(selectedDelete);
+                        } else {
+                            // op == 'edit' returns only the object and not list
+                            return(document.layouts.action[selected[0]].value);
+                        }
+                    }
+                    else if (selected.length < 1) {
+                        if (op == "edit") {
+                            alert(_("Please select one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
+                        } else {
+                            alert(_("Please select at least one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
+                        }
+                        return (-1);
                     }
                     else {
-                        alert(_("Please select only one ")+"[% card_element %]"+_(" to ") + op + ".");
+                        alert(_("Please select only one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
                         return (-1);
                     }
                 }
                 else {
                     if (document.layouts.action.checked){
-                        return(document.layouts.action.value);
+                        return([document.layouts.action.value]);
                     }
                 };
-                alert(_("Please select a ")+"[% card_element %].");
+                alert(_("Please select a %s.").format("[% PROCESS translate_card_element element=card_element %]"));
                 return (-1);
             };
 
                 Xport();
                 return false;
             });
+            $("#printlist").click(function(){
+                XportPatronlist();
+                return false;
+            });
+            $(".delete").on("click", function(){
+                return confirmDelete( _("Are you sure you want to delete this?") );
+            });
+            $(".export").on("click", function(e){
+                e.preventDefault();
+                var batch_id = $(this).data("batch-id");
+                GB_showCenter( _("Export single batch"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id, 400, 800);
+            });
          });
 //]]>
 </script>
         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
-        Manage card [% card_element_title %]
+        [% PROCESS translate_card_element element=card_element_title %]
     </div>
     <div id="doc3" class="yui-t2">
         <div id="bd">
             <div id="yui-main">
                 <div class="yui-b">
                     [% INCLUDE 'patroncards-toolbar.inc' %]
-                    [% INCLUDE 'error-messages.inc' %]
+                    [% INCLUDE 'patroncards-errors.inc' %]
                     <div class="yui-gc">
                         <div class="yui-u first" id="manage-patroncards-layouts">
                             <div class="hint">Current library: [% LoginBranchname %]</div>
                             [% IF ( table_loop ) %]
                             <form name="layouts" action="/cgi-bin/koha/manage.pl?card_element=[% card_element %]">
-                            <h2>Currently Available [% card_element_title %]</h2>
+                            <h2>Currently available [% PROCESS translate_card_element element=card_element_title FILTER lower %]</h2>
                             <table>
                                 [% FOREACH table_loo IN table_loop %]
                                 [% IF ( table_loo.header_fields ) %]
                                 <tr>
                                 [% FOREACH header_field IN table_loo.header_fields %]
-                                    <th>[% header_field.field_label %]</th>
+                                    [% SWITCH header_field.field_label -%]
+                                        [%-  CASE 'Layout ID'     -%]<th>Layout ID</th>
+                                        [%-  CASE 'Layout'        -%]<th>Layout</th>
+                                        [%-  CASE 'Action'        -%]<th>Action</th>
+                                        [%-  CASE 'Actions'       -%]<th>Actions</th>
+                                        [%-  CASE 'Select'        -%][% IF ( print ) %]<th>Select</th>[% END %]
+                                        [%-  CASE 'Template ID'   -%]<th>Template ID</th>
+                                        [%-  CASE 'Template Name' -%]<th>Template name</th>
+                                        [%-  CASE 'Description'   -%]<th>Description</th>
+                                        [%-  CASE 'Profile ID'    -%]<th>Profile ID</th>
+                                        [%-  CASE 'Printer Name'  -%]<th>Printer name</th>
+                                        [%-  CASE 'Paper Bin'     -%]<th>Paper bin</th>
+                                        [%-  CASE 'Batch ID'      -%]<th>Batch ID</th>
+                                        [%-  CASE 'Patron Count'  -%]<th>Patron count</th>
+                                        [%-  CASE                 -%]<th>[% header_field.field_label %]</th>
+                                    [% END -%]
                                 [% END %]
                                 </tr>
                                 [% ELSE %]
                                 <tr>
                                 [% FOREACH text_field IN table_loo.text_fields %]
                                 [% IF ( text_field.select_field ) %]
-                                    <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
+                                    <td>
+                                      <a class="btn btn-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=[% text_field.field_value %]"><i class="fa fa-edit"></i> Edit</a>
+                                      [% IF ( print ) %]<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa fa-share-square-o"></i> Export</a>[% END %]
+                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=[% text_field.field_value %]"><i class="fa fa-trash"></i> Delete</a>
+                                    </td>
+                                    [% IF ( print ) %]<td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>[% END %]
                                 [% ELSIF ( text_field.field_value ) %]
                                     <td>[% text_field.field_value %]</td>
                                 [% ELSE %]
                                 [% END %]
                             </table>
                             <fieldset class="action">
-                                <input type="button" id="edit" value="Edit" />
-                                <input type="button" id="delete" value="Delete" />
-                                [% IF ( print ) %]<input type="button" id="print" value="Export" />[% END %]
+                                [% IF ( print ) %]<input type="button" id="print" value="Export selected batches" />[% END %]
+                            </fieldset>
+                            [% IF patron_lists %]
+                            <fieldset class="rows">
+                                <legend>Or use a patron list</legend>
+                                <ol>
+                                    <li>
+                                        <label for="patron_list_id">Patron list: </label>
+                                        <select id="patron_list_id" name="patron_list_id">
+                                            <option value=""></option>
+                                            [% FOREACH pl IN patron_lists %]
+                                                <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
+                                            [% END %]
+                                        </select>
+                                    </li>
+                                </ol>
+                            </fieldset>
+                            <fieldset class="action">
+                                <input type="button" id="printlist" value="Export from patron list" />
                             </fieldset>
+                            [% END %]
                             </form>
+
                             [% ELSE %]
                         <div class="dialog message">
-                            <h4>There are no [% card_element_title %] currently available.</h4>
-                            <p>Use the toolbar above to create a new [% card_element %].</p></div>
+                            <h4>There are no [% PROCESS translate_card_element element=card_element_title %] currently available.</h4>
+                            <p>Use the toolbar above to create a new [% PROCESS translate_card_element element=card_element %].</p></div>
                             [% END %]
                         </div>
                     </div>
                 </div>
             </div>
             <div class="yui-b">
-                [% INCLUDE 'patroncards-menu.inc' %]
+              [% INCLUDE 'tools-menu.inc' %]
             </div>
         </div>
     [% INCLUDE 'intranet-bottom.inc' %]