Bug 14667: UI/UX improvements for the Label creator
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / label-edit-batch.tt
index 5a6b09e..ed3f148 100644 (file)
@@ -1,8 +1,10 @@
-    <!-- PLEASE MAINTAIN PROPER INDENTATION!!!!  -->
+[% USE ItemTypes %]
     [% INCLUDE 'doc-head-open.inc' %]
-    <title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage Label Batches</title>
+    <title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage label batches</title>
     [% INCLUDE 'doc-head-close.inc' %]
     [% INCLUDE 'greybox.inc' %]
+    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+    [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">
     //<![CDATA[
         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
                 return true;    // ok
             };
         }
+            function Remove() {
+                items = new Array;
+                item_num = new Array;
+                if(document.items.action.length > 0) {
+                    for (var i=0; i < document.items.action.length; i++) {
+                        if (document.items.action[i].checked) {
+                            items.push("label_id=" +  document.items.action[i].value);
+                            item_num.push(i+1);
+                        }
+                    }
+                    if (items.length < 1) {
+                        alert(_("Please select at least one item to delete."));
+                        return;     // no item selected
+                    }
+                    getstr = items.join("&");
+                    item_msg = item_num.join(", ");
+                    var msg = "Are you sure you want to remove label number(s): " + item_msg + " from this batch?"
+                }
+                else {
+                    alert(_("Please select at least label to delete."));
+                    return;     // no item selected
+                }
+                var answer = confirm(msg);
+                if (answer) {
+                    window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
+                }
+                else {
+                    return; // abort delete
+                }
+            };
+            function Add() {
+                var number_list = document.getElementById("number_list");
+                if (number_list.value == '') {
+                    window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id %]&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
+                }
+                else {
+                    document.forms["add_by_number"].submit();
+                }
+            };
+
+            function add_item(item_number) {
+                $("#itemnum_enter").prop("checked",true);
+                $("#number_list").val($("#number_list").val()+item_number+"\r\n");
+            };
+
+            function DeDuplicate() {
+                window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
+            };
+            function Xport(mode) {
+                if (mode == 'label') {
+                    labels= new Array;
+                    if(document.items.action.length > 0) {
+                        for (var i=0; i < document.items.action.length; i++) {
+                            if (document.items.action[i].checked) {
+                                labels.push("label_id=" +  document.items.action[i].value);
+                            }
+                        }
+                        if (labels.length < 1) {
+                            alert(_("Please select at least one label to export."));
+                            return;     // no batch selected
+                        }
+                        getstr = labels.join("&");
+                    }
+                    else if (document.items.action.checked) {
+                        getstr = document.items.action.value;
+                    }
+                    else {
+                        alert(_("Please select at least one label to export."));
+                        return;     // no batch selected
+                    }
+                    return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
+                }
+                else if (mode == 'batch') {
+                    return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id %]", 700, 800);
+                }
+                else {
+                    // some pass-thru error trapping just in case...
+                }
+            };
+           function selected_layout() {
+                if (document.items.action.length) {
+                for (i=0;i<document.items.action.length;i++){
+                    if (document.items.action[i].checked==true){
+                        return(document.items.action[i].value);
+                    }
+                };
+                }
+                else {
+                    if (document.items.action.checked){
+                        return(document.items.action.value);
+                    }
+                };
+                alert(_("Please select at least one item."));
+                return (-1);
+            };
+
+         $(document).ready(function() {
+            $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
+                ],
+                "aaSorting": [[ 0, "asc" ]],
+                "sPaginationType": "four_button"
+            }));
+            $("#additems").click(function(){
+                Add();
+                return false;
+            });
+            $("#removeitems").click(function(){
+                Remove();
+                return false;
+            });
+            $("#deletebatch").click(function(){
+                DeleteConfirm();
+                return false;
+            });
+            $("#deduplicate").click(function(){
+                DeDuplicate();
+                return false;
+            });
+            $("#exportitems").click(function(){
+                Xport('label');
+                return false;
+            });
+            $("#exportbatch").click(function(){
+                Xport('batch');
+                return false;
+            });
+         });
     //]]>
     </script>
 </head>
-<body onload="dofocus();">
+<body id="labels_label-edit-batch" class="tools labels" onload="dofocus();">
     [% INCLUDE 'header.inc' %]
     [% INCLUDE 'cat-search.inc' %]
     <div id="breadcrumbs">
         <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/labels/label-home.pl">Labels Home</a> &rsaquo;
-        <a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Mange Label Batches</a> &rsaquo;
-        Manage Batch Number [% batch_id %]
+        <a href="/cgi-bin/koha/labels/label-home.pl">Labels home</a> &rsaquo;
+        <a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Manage label batches</a> &rsaquo;
+        [% IF batch_id %]
+            Manage batch number [% batch_id %]
+        [% ELSE %]
+            Create new batch
+        [% END %]
     </div>
     <div id="doc3" class="yui-t2">
         <div id="bd">
             <div id="yui-main">
                 <div class="yui-b">
-                    [% INCLUDE 'labels-batches-toolbar.inc' %]
-                    <div class="yui-g">
-                        <div class="yui-u first" id="manage-label-batches">
-                            <div class="hint">Current Branch: [% LoginBranchname %]</div>
-                            <form name="add_by_barcode" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
+                        [% INCLUDE 'labels-toolbar.inc' %]
+                        [% IF ( err ) %]
+                            <div class="dialog alert">
+                                <strong>WARNING:</strong> An error was encountered and [% errstr %] Please have your system administrator check the error log for details.
+                            </div>
+                        [% ELSIF ( duplicate_message ) %]
+                            <div class="dialog message">
+                                <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
+                            </div>
+                        [% END %]
+
+                        <div id="manage-label-batches">
+                            <div class="hint">Current library: [% LoginBranchname %]</div>
+                            <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
                                 <div>
                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
                                     <ol><li>
-                                    <input type="hidden" name="op" value="add" \>
-                                    <input type="hidden" name="batch_id" value="[% batch_id %]" \>
-                                    <label for="barcode">Add by Barcode(s): 
-                                        <br \> <span class="hint">One barcode per line.</span>
-                                        <br \> <span class="hint">Leave empty to add via item search.</span>
-                                    </label>
-                                    <textarea rows="5" id="barcode" name="barcode" tabindex="1" class="focus"></textarea>
+                                        <input type="hidden" name="op" value="add" />
+                                        <input type="hidden" name="batch_id" value="[% batch_id %]" />
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="number_type" id="barcode_enter" value="barcode" checked />
+                                        <label for="barcode_enter">Enter by barcode</label><br/>
+                                        <input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" />
+                                        <label for="itemnum_enter">Enter by itemnumber</label>
+                                    </li>
+                                    <li>
+                                        <label for="number_list">Add by barcode(s) or itemnumbers(s):
+                                            <br /> <span class="hint">One number per line.</span>
+                                            <br /> <span class="hint">Leave empty to add via item search (itemnunber).</span>
+                                        </label>
+                                        <textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea>
                                     </li></ol>
                                     </fieldset>
                                 </div>
                             </form>
-                                [% IF ( table_loop ) %]
+                            <div id="batch-manage" class="btn-toolbar">
+                                <a class="btn btn-small" id="additems" href="#"><icon class="icon-plus"></icon> Add item(s)</a>[% IF ( table_loop ) %]
+                                <a class="btn btn-small" id="removeitems" href="#"><icon class="icon-trash"></icon> Remove selected items</a>
+                                <a class="btn btn-small" id="deduplicate" href="#"><icon class="icon-minus"></icon> Remove duplicates</a>
+                                <a class="btn btn-small" id="exportitems" href="#"><icon class="icon-share"></icon> Export selected items</a>
+                                <a class="btn btn-small" id="exportbatch" href="#"><icon class="icon-share"></icon> Export full batch</a>[% END %]
+                            </div>
+                            [% IF ( table_loop ) %]
                                 <form name="items" class="checkboxed">
                                     <h2>Items in batch number [% batch_id %]</h2>
-                                    <table>
+                                    <table id="batcht">
                                         [% 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>
-                                        [% 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>
-                                        [% ELSE %]
-                                            <td>[% text_field.field_value %]</td>
-                                        [% END %]
-                                        [% END %]
-                                        </tr>
-                                        [% END %]
+                                            [% IF ( table_loo.header_fields ) %]
+                                                <thead>
+                                                    <tr>
+                                                        [% FOREACH header_field IN table_loo.header_fields %]
+                                                            [% SWITCH header_field.field_label -%]
+                                                                [% CASE "Label Number" -%]
+                                                                    <th>Label number</th>
+                                                                [% CASE "Summary" -%]
+                                                                    <th class="anti-the">Summary</th>
+                                                                [% CASE "Item Type" %]
+                                                                    <th>Item type</th>
+                                                                [% CASE "Barcode" %]
+                                                                    <th>Barcode</th>
+                                                                [% CASE "Select" -%]
+                                                                    <th>Select</th>
+                                                                [% CASE %]
+                                                                    <th>[% header_field.field_label %]</th>
+                                                            [% END -%]
+                                                        [% END %]
+                                                    </tr>
+                                                </thead>
+                                                <tbody>
+                                            [% ELSE %]
+                                                    <tr>
+                                                        [% FOREACH text_field IN table_loo.text_fields %]
+                                                            [% IF ( text_field.select_field ) %]
+                                                                <td><a class="btn btn-mini" onclick="return confirm('Are you sure you want to delete this?');" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id |url %]&amp;label_id=[% text_field.field_value |url %]"><icon class="icon-trash"></icon> Delete</a> <a class="btn btn-mini" href="#" onclick="GB_showCenter('Export labels','/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id %]&amp;label_id=[% text_field.field_value |url %]')"><icon class="icon-share"></icon> Export</a></td>
+                                                                <td><center><input type="checkbox" name="action" value="[% text_field.field_value %]"></center></td>
+                                                            [% ELSE %]
+                                                                <td>
+                                                                    [% IF ( text_field.field_name == '_item_type_tbl' ) %]
+                                                                        [% ItemTypes.GetDescription( text_field.field_value ) %]
+                                                                    [% ELSE %]
+                                                                        [% text_field.field_value %]
+                                                                    [% END %]
+                                                                </td>
+                                                            [% END %]
+                                                        [% END %]
+                                                    </tr>
+                                            [% END %]
                                         [% END %]
+                                        </tbody>
                                     </table>
                                 </form>
                                 [% ELSE %]
                                 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
                                 <ol><li>
                                     <div class="dialog message">
-                                        <h4>There are no items in Batch [% batch_id %] yet</h4>
-                                        <p>Add items by barcode using the text area above or leave empty to add via item search.</p>
+                                        <h4>There are no items in this batch yet</h4>
+                                        <p>Add items by using the text area above or leave empty to add via item search.</p>
                                     </div>
                                 </li></ol>
                                 </fieldset>
                                 [% END %]
                             </div>
-                            [% IF ( err ) %]
-                            <div class="yui-u">
-                                <div class="dialog alert">
-                                    <strong>WARNING:</strong> An error was encountered and [% errstr %] Please have your system administrator check the error log for details.
-                                </div>
-                            </div>
-                            [% ELSIF ( duplicate_message ) %]
-                            <div class="yui-u">
-                                <div class="dialog message">
-                                    <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
-                                </div>
-                            </div>
-                            [% END %]
                         </div>
-                    </div>
                 </div>
                 <div class="yui-b">
                     [% INCLUDE 'labels-menu.inc' %]
                 </div>
             </div>
-        </div>
     [% INCLUDE 'intranet-bottom.inc' %]