Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / virtualshelves / shelves.tt
index 95fa4b9..0c7ee12 100644 (file)
+[% USE raw %]
+[% USE Asset %]
+[% USE Koha %]
+[% USE KohaDates %]
+[% SET PRIVATE = 1 %]
+[% SET PUBLIC = 2 %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; [% IF ( viewshelf ) %]Lists &rsaquo; Contents of [% shelfname | html %][% ELSE %]Lists[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list [% shelfname | html %][% END %]</title>
+<title>Koha &rsaquo; [% IF op == 'view' %]Lists &rsaquo; Contents of [% shelf.shelfname | html %][% ELSE %]Lists[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list [% shelf.shelfname | html %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% IF ( viewshelf ) %]
-    <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-    <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
-[% END %]
-<script type="text/javascript">
-//<![CDATA[ 
-
-var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
-var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these records from the shelf?");
-var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
-[% IF ( viewshelf ) %]
-$(document).ready(function(){
-    [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
-    $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\">"+_("Clear all")+"<\/a>");
-    $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\">"+_("Select all")+"<\/a>");
-    $("#CheckAll").click(function(){
-        $(".checkboxed").checkCheckboxes();
-        return false;
-    });
-    $("#CheckNone").click(function(){
-        $(".checkboxed").unCheckCheckboxes();
-        return false;
-    });
-    $(".placehold").on("click",function(e){
-        placeHold();
-        e.preventDefault();
-    });
-    $(".addtocart").show();
-    var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
-    [% IF ( intranetbookbag ) %]
-         param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
-    [% END %]
-    [% IF ( virtualshelves ) %]
-        [% IF ( addbarshelves ) %]
-            param1 += "<optgroup label=\""+_("Your lists:")+"\">";
-            [% FOREACH addbarshelvesloo IN addbarshelvesloop %]
-                [% IF ( shelfnumber != addbarshelvesloo.shelfnumber ) %]
-                    param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";
-                [% END %]
-            [% END %]
-            param1 += "<\/optgroup>";
-        [% END %]
-        [% IF ( addpubshelves ) %]
-            param1 += "<optgroup label=\""+_("Public lists:")+"\">";
-            [% FOREACH addpubshelvesloo IN addpubshelvesloop %]
-                [% IF ( shelfnumber != addpubshelvesloo.shelfnumber ) %]
-                    param1 += "<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>";
-                [% END %]
+[% Asset.css("css/datatables.css") | $raw %]
+<style type="text/css">textarea { width: 100%; }</style>
+
+[% BLOCK list_permissions %]
+    <li>
+        <label for="allow_changes_from">Allow changes to contents from: </label>
+        <select name="allow_changes_from" id="allow_changes_from" onchange="AdjustRemark()">
+
+            [% IF shelf.allow_change_from_owner %]<option value="0">Nobody</option>[% ELSE %]<option value="0" selected="selected">Nobody</option>[% END %]
+
+            [% IF shelf.allow_change_from_owner && (( !shelf.is_public && !shelf.is_shared ) || !shelf.allow_change_from_others ) %]
+                <option value="1" selected="selected">Owner only</option>
+            [% ELSE %]
+                <option value="1">Owner only</option>
             [% END %]
-            param1 += "<\/optgroup>";
-        [% END %]
-        [% IF ( ( addbarshelvesloop && addbarshelvesloop.size > 9 ) || (addpubshelvesloop && addpubshelvesloop.size > 9 )) %]
-            param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
-        [% END %]
-        param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
-    [% END %]
-    param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-mini\">"+_("Save")+"</button>";
-    $("span.addto").html(param1);
-    $("#cartsubmit").on("click",function(e){
-        cartList();
-        e.preventDefault();
-    });
-    $("#addto").change(function(){
-        cartList();
-    });
-    $(".addto").find("input:submit").click(function(e){
-        e.preventDefault();
-        cartList();
-    });
-    $("#selection_ops").show();
-    $(".merge-items").on("click",function(e){
-        e.preventDefault();
-        MergeItems();
-    });
-    $("#listform").on("submit",function(e){
-
-    });
-    $(".list-remove").on("click",function(e){
-        if($(".selection").filter(":checked").length > 0){
-            return confirm(MSG_REMOVE_FROM_LIST);
-        } else {
-            alert(MSG_NO_ITEM_SELECTED);
-            e.preventDefault();
-        }
-    });
-});
-[% END %]
 
-       function confirmDelete(message){
-               if (window.confirm(message)) {
-                   location.href="/cgi-bin/koha/virtualshelves/shelves.pl?[% IF ( showprivateshelves ) %]display=privateshelves&[% END %]shelves=1&DEL-[% shelfnumber %]=1&shelfoff=[% shelfoff %]";
-               } else { 
-                       return false;
-               }
-       }
-
-    /**
-     * This function checks if the adequate number of records are checked for merging
-     */
-    function MergeItems() {
-       var checkboxes = $("input:checkbox:checked");
-        var nbCheckbox = checkboxes.length;
-       if (nbCheckbox != 2) {
-           alert(_("Two records must be selected for merging."));
-       } else {
-           location.href='/cgi-bin/koha/cataloguing/merge.pl?biblionumber=' + checkboxes[0].value + '&amp;biblionumber=' + checkboxes[1].value;
-       }
-       return false;
-    }
-
-    /**
-     * This function checks all checkboxes if all are empty,
-     * or unchecks all if any already checked.
-     */
-    function CheckAll(){
-        var checkboxes = document.getElementsByTagName('input');
-        var nbCheckbox = checkboxes.length;
-        var check = areAllChecked();
-        for(var i=0;i<nbCheckbox;i++){
-            if(checkboxes[i].getAttribute('type') == "checkbox" ){
-                checkboxes[i].checked = (check) ? 0 : 1;
-            }
-        }
-    }
-    /**
-     * This function returns true if ALL checkboxes are checked
-     */
-    function areAllChecked(){
-        var checkboxes = document.getElementsByTagName('input');
-        var nbCheckbox = checkboxes.length;
-        for(var i=0;i<nbCheckbox;i++){
-            if(checkboxes[i].getAttribute('type') == "checkbox" ){
-                if(checkboxes[i].checked == 0){
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-function placeHold () {
-    var checkedItems = $(".selection:checked");
-    if ($(checkedItems).size() == 0) {
-        alert(MSG_NO_ITEM_SELECTED);
-        return false;
-    }
-    var bibs = "";
-    $(checkedItems).each(function() {
-        bibs += $(this).val() + "/";
-    });
-    $("#hold_form_biblios").val(bibs);
-    $("#hold_form").submit();
-    return false;
-}
-    /**
-     * This function checks to make sure a list title is assigned
-     */
-      function Check(f) {
-               var _alertString="";
-               var alertString2;
-
-           if($("#shelfname").val() == ""){
-            _alertString += "- "+_("You must enter a List Name") + "\n";
-               }
-
-               if (_alertString.length==0) {
-            f.submit();
-               } else {
-                       alertString2 = _("Form not submitted because of the following problem(s)");
-                       alertString2 += "\n------------------------------------------------------------------------------------\n\n";
-                       alertString2 += _alertString;
-                       alert(alertString2);
-               }
-       }
-    function cartList(){
-        var checkboxes = $("#searchresults").find(":checkbox");
-        var vshelf = vShelfAdd(checkboxes);
-        if($("#addto").find("option:selected").attr("value") == "addtolist"){
-            var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
-            if (vshelf) {
-                 openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
-            }
-            return false;
-        } else if($("#addto").find("option:selected").attr("value") == "newlist"){
-            if (vshelf) {
-                openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
-            }
-            return false;
-        } else if($("#addto").find("option:selected").attr("value") == "morelists"){
-            if (vshelf) {
-                openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
-            }
-            return false;
-        }
-        if($("#addto").find("option:selected").attr("value") == "addtocart"){
-            addMultiple(checkboxes);
-            return false;
-        }
-    }
-//]]>
-</script>
+            [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Anyone seeing this list</option>[% ELSE %]<option value="2">Anyone seeing this list</option>[% END %]
+
+        </select>
+        &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
+    </li>
+[% END %]
 </head>
+
 <body id="lists_shelves" class="lists">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-[% BLOCK list_permissions %]
-    <li>
-        <label for="permissions">Permissions: </label>
-        <select name="allow_add" id="allow_add">
-            [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
-            [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
-        </select>
-        &nbsp;<span>anyone else to add entries.</span>
-    </li>
-    <li>
-        <label>&nbsp;</label>
-        <select name="allow_delete_own" id="allow_delete_own">
-            [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
-            [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
-        </select>
-        &nbsp;<span>anyone to remove his own contributed entries.</span>
-    </li>
-    <li>
-        <label>&nbsp;</label>
-        <select name="allow_delete_other" id="allow_delete_other">
-            [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
-            [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
-        </select>
-        &nbsp;<span>anyone to remove other contributed entries.</span>
-    </li>
-[% END %]
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a> [% IF ( category1 ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( category2 ) %] &rsaquo; [% IF ( viewshelf ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% ELSIF ( showprivateshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( showpublicshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% END %]
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
+    [% IF op != 'list' %]
+        <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
+    [% ELSE %]
+        Lists
+    [% END %]
+    [% IF shelf AND shelf.is_private %] &rsaquo;
+        [% IF op == 'view' OR op == 'edit_form' %]
+            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE | html %]">Your lists</a>
+        [% ELSE %]
+            Your lists
+        [% END %]
+    [% ELSIF shelf AND shelf.is_public %] &rsaquo;
+        [% IF op == 'view' %]
+            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | html %]">Public lists</a>
+        [% ELSE %]
+            Public lists
+        [% END %]
+    [% END %]
 
-[% IF ( viewshelf ) %]&rsaquo; Contents of <i>[% shelfname | html %]</i>[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list <i>[% shelfname | html %]</i>[% END %]</div>
+[% IF op == 'view' %]&rsaquo; Contents of <i>[% shelf.shelfname | html %]</i>[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list <i>[% shelf.shelfname | html %]</i>[% END %]</div>
+
+<div id="doc3" class="yui-t2">
+<div id="bd">
+<div id="yui-main">
+<div class="yui-b">
 
-<div id="doc2" class="yui-t7">
- <div id="bd">
-  <div id="yui-main">
    <div class="yui-g">[% INCLUDE 'virtualshelves-toolbar.inc' %]
    </div>
-[% IF ( paramsloop ) %]
-[% FOREACH paramsloo IN paramsloop %]
-<div class="yui-ge">
-    <div class="yui-u first">
-        [% IF ( paramsloo.already ) %]<div class="dialog alert">A List named [% paramsloo.already %] already exists!</div>[% END %]
-               [% IF ( paramsloo.status ) %]<div class="dialog alert">[% paramsloo.string %]</div>[% END %]
-               [% IF ( paramsloo.nobarcode ) %]<div class="dialog alert">ERROR: No barcode given.</div>[% END %] 
-               [% IF ( paramsloo.noshelfnumber ) %]<div class="dialog alert">ERROR: No shelfnumber given.</div>[% END %] 
-               [% IF ( paramsloo.need_confirm ) %]
-               <div class="dialog alert">The list <i>[% paramsloo.need_confirm %]</i> is not empty.
-                       <br />It has <b>[% paramsloo.count %]</b> entries.
-                       <br />Use the "Confirm" button below to confirm deletion.
-               </div>
-               [% END %]
-               [% IF ( paramsloo.nopermission ) %]
-               <div class="dialog alert">ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission %].</div>
-               [% END %]
-               [% IF ( paramsloo.failgetitem ) %]
-               <div class="dialog alert">ERROR: No item found with barcode [% paramsloo.failgetitem %].</div>
-               [% END %] 
-               [% IF ( paramsloo.duplicatebiblio ) %]
-               <div class="dialog alert">A record matching barcode <b>[% paramsloo.duplicatebiblio %]</b> has already been added.</div>
-               [% END %]
-                [% IF ( paramsloo.nothingdeleted) %]
-                      <div class="dialog message">Warning: You could not delete any selected items from this shelf.</div>
-                [% END %]
-                [% IF ( paramsloo.somedeleted) %]
-                      <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div>
-                [% END %]
-                [% IF ( paramsloo.modifyfailure) %]
-                      <div class="dialog message">ERROR: List could not be modified.</div>
-                [% END %]
-       </div>
-</div>
+
+[% FOR m IN messages %]
+    <div class="dialog [% m.type | html %]">
+        [% SWITCH m.code %]
+        [% CASE 'error_on_update' %]
+            <span>An error occurred when updating this list.</span>
+        [% CASE 'error_on_insert' %]
+            <span>An error occurred when creating this list.</span>
+        [% CASE 'error_on_delete' %]
+            <span>An error occurred when deleting this list.</span>
+        [% CASE 'error_on_add_biblio' %]
+            [% IF m.item_barcode %]
+               <span>The item ([% m.item_barcode | html %]) has not been added to the list. Please verify it is not already in the list.</span>
+            [% ELSE %]
+                <span>The record ([% m.bibnum | html %]) has not been added to the list. Please verify it is not already in the list.</span>
+            [% END %]
+        [% CASE 'success_on_update' %]
+            <span>List updated.</span>
+        [% CASE 'success_on_insert' %]
+            <span>List created.</span>
+        [% CASE 'success_on_delete' %]
+            <span>List deleted.</span>
+        [% CASE 'success_on_add_biblio' %]
+            [% IF m.item_barcode %]
+                <span>The item ([% m.item_barcode | html %]) has been added to the list.</span>
+            [% ELSE %]
+                <span>The record ([% m.bibnum | html %]) has been added to the list.</span>
+            [% END %]
+        [% CASE 'success_on_remove_biblios' %]
+            <span>The item has been removed from the list.</span>
+        [% CASE 'does_not_exist' %]
+            <span>This list does not exist.</span>
+        [% CASE 'item_does_not_exist' %]
+            [% IF m.item_barcode %]
+                <span>The item ([% m.item_barcode | html %]) does not exist.</span>
+            [% ELSE %]
+                <span>The record ([% m.bibnum | html %]) does not exist.</span>
+            [% END %]
+        [% CASE 'unauthorized_on_view' %]
+            <span>You do not have permission to view this list.</span>
+        [% CASE 'unauthorized_on_update' %]
+            <span>You do not have permission to update this list.</span>
+        [% CASE 'unauthorized_on_delete' %]
+           <span>You do not have permission to delete this list.</span>
+        [% CASE 'unauthorized_on_add_biblio' %]
+            <span>You do not have permission to add a record to this list.</span>
+        [% CASE 'no_biblio_removed' %]
+            <span>No record was removed.</span>
+        [% CASE 'Koha::Exceptions::Virtualshelves::DuplicateObject' %]
+            <span>An error occurred when creating this list. The name [% shelfname | html %] already exists.</span>
+        [% CASE 'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' %]
+            <span>List could not be created. (Do not use the database administrator account.)</span>
+        [% CASE 'DBIx::Class::Exception' %]
+            [% m.msg | html %]
+        [% CASE %]
+            [% m.code | html %] [% m.msg | html %]
+        [% END %]
+    </div>
 [% END %]
-[% END %] 
 
-[% IF ( viewshelf ) %]
+[% IF op == 'view' %]
    <div class="yui-g">
-    [% IF ( itemsloop ) %]
+    [% IF itemsloop %]
 
-    <h3>Contents of <i>[% shelfname | html %]</i></h3>
-    <div class="pages">[% pagination_bar %]</div>
+    <h3>Contents of <i>[% shelf.shelfname | html %]</i></h3>
+    <div class="pages">[% pagination_bar | $raw %]</div>
     <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post" class="checkboxed">
-        <input type="hidden" name="viewshelf" value="[% shelfnumber %]" />
-        <input type="hidden" name="modifyshelfcontents" value="1" />
+        <input type="hidden" name="op" value="remove_biblios" />
+        <input type="hidden" name="referer" value="view" />
+        <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 
 [% IF direction == 'asc' %]
     [% SET new_direction = 'desc' %]
@@ -296,20 +144,20 @@ function placeHold () {
     [% SET new_direction = 'asc' %]
 [% END %]
 
-<div id="searchheader">
-    [% IF ( itemsloop ) %]
+<div id="searchheader" class="noprint">
+    [% IF itemsloop %]
         <div id="selection_ops"><span class="checkall"></span> |
         <span class="clearall"></span>
 
         <span class="addto">| </span>
         &nbsp;
-        [% IF ( CAN_user_reserveforothers && DisplayMultiPlaceHold ) %]
-            <div class="btn-group"><button class="btn btn-mini placehold"><i class="icon-hold"></i> Place hold</button></div>
+        [% IF CAN_user_reserveforothers && Koha.Preference('DisplayMultiPlaceHold') %]
+            <div class="btn-group"><button class="btn btn-default btn-xs placehold"><i class="fa fa-sticky-note-o"></i> Place hold</button></div>
         [% END %]
-        [% IF ( allowremovingitems ) %]
-            <div class="btn-group"><button type="submit" class="btn btn-mini list-remove"><i class="icon-remove-sign"></i> Remove selected</button></div>
+        [% IF can_remove_biblios %]
+            <div class="btn-group"><button type="submit" class="btn btn-default btn-xs list-remove"><i class="fa fa-trash"></i> Remove selected</button></div>
         [% END %]
-        [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]<div class="btn-group"><button type="submit" class="btn btn-mini merge-items"><i class="icon-merge"></i> Merge selected</button></div>[% END %]
+        [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]<div class="btn-group"><button type="submit" class="btn btn-default btn-xs merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>[% END %]
         </div>
     [% END %]
 </div>
@@ -320,84 +168,75 @@ function placeHold () {
 
                 [% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=title&amp;direction=[% IF sort != 'title' %]asc[% ELSE %][% new_direction %][% END %]">Title</a>
-                    [% IF sort == 'title' %]
-                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]&amp;sortfield=title&amp;direction=[% IF sortfield != 'title' %]asc[% ELSE %][% new_direction | html %][% END %]">Title</a>
+                    [% IF sortfield == 'title' %]
+                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
                     [% ELSE %]
-                        <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
+                        <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
                     [% END %]
                 </th>
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=author&amp;direction=[% IF sort != 'author' %]asc[% ELSE %][% new_direction %][% END %]">Author</a>
-                   [% IF sort == 'author' %]
-                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]&amp;sortfield=author&amp;direction=[% IF sortfield != 'author' %]asc[% ELSE %][% new_direction | html %][% END %]">Author</a>
+                   [% IF sortfield == 'author' %]
+                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
                    [% ELSE %]
-                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
+                       <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
                    [% END %]
                  </th>
                 <th>Date added</th>
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=itemcallnumber&amp;direction=[% IF sort != 'itemcallnumber' %]asc[% ELSE %][% new_direction %][% END %]">Call number</a>
-                   [% IF sort == 'itemcallnumber' %]
-                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]&amp;sortfield=itemcallnumber&amp;direction=[% IF sortfield != 'itemcallnumber' %]asc[% ELSE %][% new_direction | html %][% END %]">Call number</a>
+                   [% IF sortfield == 'itemcallnumber' %]
+                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
                    [% ELSE %]
-                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
+                       <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
                    [% END %]
                  </th>
             </tr>
-               [% FOREACH itemsloo IN itemsloop %]
-                       [% UNLESS ( loop.odd ) %]
-                       <tr class="highlight">
-                       [% ELSE %]
-                       <tr>
-                       [% END %]
-                       [% IF ( itemsloop ) %]
-                       <td>
-                               [% IF ( itemsloo.confirm ) %]
-                               <input type="hidden"   name="CONFIRM-[% itemsloo.confirm %]" />
-                               <input type="checkbox" class="selection" value="[% itemsloo.biblionumber %]" name="REM-[% itemsloo.biblionumber %]" checked />
-                               [% ELSE %]
-                               <input type="checkbox" class="selection" value="[% itemsloo.biblionumber %]" name="REM-[% itemsloo.biblionumber %]" />
-                               [% END %]
-                       </td>
-                       [% END %]
+        [% FOREACH itemsloo IN itemsloop %]
+                <tr>
+            [% IF itemsloop %]
+                <td>
+                    <input type="checkbox" class="selection" value="[% itemsloo.biblionumber | html %]" name="biblionumber" />
+                </td>
+            [% END %]
                        [% UNLESS ( item_level_itypes ) %]<td>
-                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl %]" alt="[% itemsloo.description %]" title="[% itemsloo.description %]" />[% END %][% itemsloo.description %]
+                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />[% END %][% itemsloo.description | html %]
                        </td>[% END %]
                        <td>
                 [% IF ( itemsloo.XSLTBloc ) %]
-                    [% itemsloo.XSLTBloc %]
+                    [% itemsloo.XSLTBloc | $raw %]
                 [% ELSE %]
                     [% INCLUDE 'biblio-default-view.inc' biblionumber = itemsloo.biblionumber %]
-                    [% itemsloo.title |html %][% FOREACH subtitl IN itemsloo.subtitle %] [% subtitl.subfield %][% END %]</a>
+                    [% itemsloo.title | html %][% FOREACH subtitl IN itemsloo.subtitle %] [% subtitl.subfield | html %][% END %]</a>
                 [% END %]
                     <p class="hold">
                         [% IF ( itemsloo.notforloan ) %]
                             <span class="noholdstext">No holds allowed</span>
                         [% ELSE %]
                             [% IF ( itemsloo.ITEM_RESULTS.size ) %]
-                                <a id="reserve_[% itemsloo.biblionumber %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber %]">Holds</a>
-                                [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber %]&amp;findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></span>[% END %]
+                                <a id="reserve_[% itemsloo.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]">Holds</a>
+                                [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]&amp;findborrower=[% holdfor_cardnumber | html %]">Place hold for [% holdfor_firstname | html %] [% holdfor_surname | html %] ([% holdfor_cardnumber | html %])</a></span>[% END %]
                             [% ELSE %]
                                 <span class="noholdstext">No holds allowed</span>
                             [% END %]
                         [% END %]
                         [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
-                            | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber %]">Edit record</a>
+                            | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber | html %]">Edit record</a>
                         [% END %]
                         [% IF ( CAN_user_editcatalogue_edit_items ) %]
-                            | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber %]">Edit items</a>
+                            | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber | html %]">Edit items</a>
                         [% END %]
                     </p>
-                       </td>
-                       <td>[% itemsloo.author %]</td>
-                       <td>[% itemsloo.dateadded %]</td>
-                       <td>
+            </td>
+            <td>[% itemsloo.author | html %]</td>
+            <td>[% itemsloo.dateadded | $KohaDates%]</td>
+            <td>
                 <ul>
                 [% FOREACH result IN itemsloo.ITEM_RESULTS %]
-                    <li>[% result.holdingbranch %] [% IF ( result.location_intranet ) %] ([% result.location_intranet %]) [% END %]
+                    <li>[% result.holdingbranch | html %] [% IF ( result.location_intranet ) %] ([% result.location_intranet | html %]) [% END %]
                         [% IF ( result.itemcallnumber ) %]
-                            [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=[% result.itemcallnumber |url %]">[% result.itemcallnumber %]</a>]
+                            [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=%22[% result.itemcallnumber |uri %]%22">[% result.itemcallnumber | html %]</a>]
                         [% END %]
                     </li>
                 [% END %]
@@ -406,239 +245,134 @@ function placeHold () {
                        </tr>
                [% END %]<!-- /itemsloop -->
     </table>
-    <div class="pages">[% pagination_bar %]</div>
+    <div class="pages">[% pagination_bar | $raw %]</div>
 </form>
 
        [% END %]
    </div>
-[% END %]<!-- /viewshelf -->
-
-[% IF ( allowaddingitem ) %]
-<div class="yui-g">
-<form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
- <fieldset class="brief">
-    <legend>Add an item to <i>[% shelfname | html %]</i></legend>
-        <ol>
-            <li>
-                <label for="addbarcode">Barcode:</label>
-                <input name="addbarcode" type="text" id="addbarcode" size="14" />
-                <input type="hidden" name="viewshelf" value="[% shelfnumber %]" />
-                <input type="hidden" name="modifyshelfcontents" value="1" />
-                <input type="submit" value="Add" />
-            </li>
-        </ol>
- </fieldset>
-</form>
-</div>
-[% END %]<!-- /allowaddingitem -->
-
-[% IF ( debug ) %]
-  [% IF ( edit ) %]<div>Edit is on ([% shelfname | html %])</div>[% END %]
-  [% IF ( seflag ) %]<div>seflag is on ([% seflag %])</div>[% END %]
 [% END %]
 
-[% IF ( seflag ) %]
+[% IF op == 'add_form' OR op == 'edit_form' %]
 <div class="yui-ge">
     <div class="yui-u first">
-    <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl">
+    <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
         <fieldset class="rows">
 
-    [% IF ( shelves ) %]
-        <input type="hidden" name="shelves" value="1" />
-        <legend>Create a new list</legend>
+        [% IF op == 'add_form' %]
+            <legend>Create a new list</legend>
+            <input type="hidden" name="op" value="add" />
+        [% ELSE %]
+            <legend>Edit list <i>[% shelf.shelfname | html %]</i></legend>
+            <input type="hidden" name="op" value="edit" />
+        [% END %]
+        <input type="hidden" name="referer" value="[% referer | html %]" />
+        <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
         <ol>
-        <li><label class="required" for="addshelf">List name:</label><input id="addshelf" type="text" name="addshelf" size="25" /></li>
-        <li><span class="label">Owner: </span><input type="hidden" name="owner" id="owner" value="[% loggedinuser %]" />[% loggedinusername %]</li>
-        <li><label for="sortfield" >Sort this list by: </label>
-        <select name="sortfield" id="sortfield">
-            <option value="title">Title</option>
-            <option value="author">Author</option>
-            <option value="copyrightdate">Copyrightdate</option>
-            <option value="itemcallnumber">Call number</option>
-        </select></li>
-        <li><label for="category">Category: </label>
-            <select name="category" id="category">
-                  <option value="1">Private</option>
-                  <option value="2">Public</option>
-                     </select></li>
-            [% INCLUDE list_permissions %]
-        </ol>
-    [% END %]
+            <li>
+                <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname | html %]" required="required" class="required" />
+            <span class="required">Required</span>
+            </li>
+            <li>
+                <span class="label">Owner: </span>
+                [% IF op == 'add_form' %]
+                    <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% loggedinusername | html %]</li>
+                [% ELSE %]
+                    [% IF owner %]
+                        <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
+                    [% ELSE %]
+                        <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% loggedinusername | html %]
+                    [% END %]
+                [% END %]
+            </li>
+            <li><label for="sortfield" >Sort this list by: </label>
+            <select name="sortfield">
+            [% IF shelf.sortfield == "title" %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
+            [% IF shelf.sortfield == "author" %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
+            [% IF shelf.sortfield == "copyrightdate" %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
+            [% IF shelf.sortfield == "itemcallnumber" %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
+            </select></li>
+            <li><label for="category">Category: </label>
+                <select id="category" name="category" onchange="AdjustRemark()">
+                [% IF shelf.is_private %]
+                    <option value="1" selected="selected">Private</option>
+                [% ELSE %]
+                    <option value="1">Private</option>
+                [% END %]
+                [% IF shelf.is_public %]
+                    <option value="2" selected="selected">Public</option>
+                [% ELSE %]
+                    <option value="2">Public</option>
+                [% END %]
+                           </select></li>
 
-    [% IF ( edit ) %]
-               <input type="hidden" name="op" value="modifsave" />
-        <input type="hidden" name="display" value="[% display %]" />
-        [% IF ( showprivateshelves ) %]<input type="hidden" name="display" value="privateshelves" />[% END %]
-               <input type="hidden" name="shelfnumber" value="[% shelfnumber %]" />
-        <legend>Edit list <i>[% shelfname | html %]</i></legend>
-               <ol>
-               <li><label for="shelfname">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelfname |html %]" /></li>
-               <li><label for="owner">Owner: </label><input type="hidden" id="owner" name="owner" value="[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]" />[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]</li>
-               <li><label for="sortfield" >Sort this list by: </label>
-               <select name="sortfield">
-        [% IF ( sortfield == "title" ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
-        [% IF ( sortfield == "author" ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
-        [% IF ( sortfield == "copyrightdate" ) %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
-        [% IF ( sortfield == "itemcallnumber" ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
-               </select></li>
-               <li><label for="category">Category: </label>
-                       <select id="category" name="category">
-                       [% IF ( category1 ) %]
-                               <option value="1" selected="selected">Private</option>
-                       [% ELSE %]
-                               <option value="1">Private</option>
-                       [% END %]
-                       [% IF ( category2 ) %]
-                               <option value="2" selected="selected">Public</option>
-                       [% ELSE %]
-                               <option value="2">Public</option>
-                       [% END %]
-                       </select></li>
             [% INCLUDE list_permissions %]
-            </ol>
-       [% END %]
 
-               </fieldset>
-               <fieldset class="action"><input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" />
-        [% IF ( showprivateshelves ) %]
-            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves" class="cancel">Cancel</a>
-        [% ELSE %]
-            [% IF ( display == "viewshelf" ) %]
-               <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]" class="cancel">Cancel</a>
+        </ol>
+    </fieldset>
+
+    <fieldset class="action">
+        <input type="submit" value="Save" class="submit" />
+        [% IF referer == 'view' %]
+           <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]" class="cancel">Cancel</a>
+       [% ELSE %]
+            [% IF category == PUBLIC %]
+                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | html %]" class="cancel">Cancel</a>
             [% ELSE %]
-                <a href="/cgi-bin/koha/virtualshelves/shelves.pl" class="cancel">Cancel</a>
+                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE | html %]" class="cancel">Cancel</a>
             [% END %]
         [% END %]
     </fieldset>
     </form>
     </div>
-    <div class="yui-u">
-        <div class="help"><ul>
-            <li>A <b>Private</b> list is managed by you and can be seen only by you.</li>
-            <li> A <b>Public</b> list can be seen by everybody, but managed only by you.</li>
-            <br/>
-            <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li>
-        </ul>
-        </div>
-    </div>
 </div>
-[% END %]<!-- /seflag -->
+[% END %]
 
-[% UNLESS ( vseflag ) %]
-        <h2>Lists</h2>
-        <div class="statictabs">
+[% IF op == 'list' %]
+    <h2>Lists</h2>
+    <div id="tabs" class="toptabs">
         <ul>
-        [% IF ( showprivateshelves ) %]
-            <li id="privateshelves_tab" class="active"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a></li>
-        [% ELSE %]
-            <li id="privateshelves_tab" class=""><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a></li>
-        [% END %]
-        [% IF ( showpublicshelves ) %]
-            <li id="publicshelves_tab" class="active"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a></li>
-        [% ELSE %]
-            <li id="publicshelves_tab" class=""><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a></li>
-        [% END %]
+            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
+            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
         </ul>
-        [% IF ( showprivateshelves ) %]
-        <div id="privateshelves" class="tabs-container" style="display:block;">
-               [% ELSE %]
-        <div id="privateshelves" class="tabs-container" style="display:none;">
-               [% END %]
-            [% IF ( shelveslooppriv ) %]
-                       <div class="pages">[% pagination_bar %]</div>
-                       <table>
-                       <tr><th>List Name</th><th>Contents</th><th>Sort by</th><th>Type</th><th>Options</th></tr>
-                [% FOREACH shelveslooppri IN shelveslooppriv %]
-                    [% IF ( shelveslooppri.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
-        <td><a href="shelves.pl?[% IF ( shelveslooppri.showprivateshelves ) %]display=privateshelves&amp;[% END %]viewshelf=[% shelveslooppri.shelf %]&amp;shelfoff=[% shelfoff %]">[% shelveslooppri.shelfname |html %]</a></td>
-        <td>[% shelveslooppri.count %] item(s)</td>
-        <td>[% IF ( shelveslooppri.sortfield == "author" ) %]Author[% ELSIF ( shelveslooppri.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelveslooppri.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
-        <td>[% IF ( shelveslooppri.viewcategory1 ) %]Private[% END %]
-                       [% IF ( shelveslooppri.viewcategory2 ) %]Public[% END %]
-               </td>
-        <td>
-            [% IF ( shelveslooppri.mine ) %]
-                               <form action="merge.pl" method="get">
-                                       <input type="hidden" name="shelf" value="[% shelveslooppri.shelf %]" />
-                               </form>
-                               <form action="shelves.pl" method="get">
-                                       <input type="hidden" name="shelfnumber" value="[% shelveslooppri.shelf %]" />
-                                       <input type="hidden" name="op" value="modif" />
-                    <input type="hidden" name="display" value="privateshelves" />
-                                       <input type="submit" class="editshelf" value="Edit" />
-                               </form>
-                               <form action="shelves.pl" method="post">
-                                   <input type="hidden" name="shelfoff" value="[% shelfoff %]" />
-                                       <input type="hidden" name="shelves" value="1" />
-                    <input type="hidden" name="display" value="privateshelves" />
-                                       <input type="hidden" name="DEL-[% shelveslooppri.shelf %]" value="1" />
-                                       [% IF ( shelveslooppri.confirm ) %]
-                                       <input type="hidden" name="CONFIRM-[% shelveslooppri.confirm %]" value="1" />
-                                       <input type="submit" class="approve" value="Confirm" />
-                                       [% ELSE %]
-                    <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
-                                       [% END %]
-                               </form>
-                       [% ELSE %]
-                               None
-                       [% END %]
-               </td>
-               </tr>
-                [% END %]
-        </table>
-            [% ELSE %]
-            <p>No private lists.</p>
-            [% END %]<!-- /shelveslooppriv -->
-               </div><!-- /privateshelves -->
-
-        [% IF ( showpublicshelves ) %]
-        <div id="publicshelves" class="tabs-container" style="display:block;">
-               [% ELSE %]
-        <div id="publicshelves" class="tabs-container" style="display:none;">
-               [% END %]
-        [% IF ( shelvesloop ) %]
-               <div class="pages">[% pagination_bar %]</div>
-        <table>
-        <tr><th>List Name</th><th>Created by</th><th>Contents</th><th>Sort By</th><th>Type</th><th>Options</th></tr>
-            [% FOREACH shelvesloo IN shelvesloop %]
-                [% IF ( shelvesloo.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
-               <td><a href="shelves.pl?viewshelf=[% shelvesloo.shelf %]">[% shelvesloo.shelfname |html %]</a></td>
-        <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% shelvesloo.owner %]">[% shelvesloo.ownername %]</td>
-               <td>[% shelvesloo.count %] item(s)</td>
-        <td>[% IF ( shelvesloo.sortfield == "author" ) %]Author[% ELSIF ( shelvesloo.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelvesloo.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
-        <td>[% IF ( shelvesloo.viewcategory1 ) %]Private[% END %]
-                       [% IF ( shelvesloo.viewcategory2 ) %]Public[% END %]
-               </td>
-        <td>
-            [% IF ( shelvesloo.manageshelf ) %]
-                               <form action="shelves.pl" method="get">
-                                       <input type="hidden" name="shelfnumber" value="[% shelvesloo.shelf %]" />
-                                       <input type="hidden" name="op" value="modif" />
-                                       <input type="submit" class="editshelf" value="Edit" />
-                               </form>
-                               <form action="shelves.pl" method="post">
-                                       <input type="hidden" name="shelfoff" value="[% shelfoff %]" />
-                                       <input type="hidden" name="shelves" value="1" />
-                                       <input type="hidden" name="DEL-[% shelvesloo.shelf %]" value="1" />
-                                       [% IF ( shelvesloo.confirm ) %]
-                                       <input type="hidden" name="CONFIRM-[% shelvesloo.confirm %]" value="1" />
-                                       <input type="submit" class="approve" value="Confirm" />
-                                       [% ELSE %]
-                    <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
-                                       [% END %]
-                               </form>
-                       [% ELSE %]
-                               None
-                       [% END %]
-               </td>
-               </tr>
-            [% END %]
-        </table>
-        [% ELSE %]
-            [% IF ( showpublicshelves ) %]<p>No public lists.</p>[% END %]
-        [% END %]<!-- /shelvesloop -->
-        </div><!-- /publicshelves -->
-               </div>
+
+        <div id="tab_content">
+            <table id="listresultst">
+                <thead>
+                    <tr>
+                        <th class="NoVisible">Type</th>
+                        <th>List name</th>
+                        <th>Contents</th>
+                        <th>Type</th>
+                        <th>Owner</th>
+                        <th>Sort by</th>
+                        <th>Creation date</th>
+                        <th>Modification date</th>
+                        <th>Actions</th>
+                    </tr>
+                    <tr class="filters_row">
+                        <th></th>
+                        <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th>
+                        <th></th>
+                        <th></th>
+                        <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th>
+                        <th>
+                            <select class="filter text_filter" id="searchsortby_filter">
+                                <option value=""></option>
+                                <option value="title">Title</option>
+                                <option value="author">Author</option>
+                                <option value="copyrightdate">Copyrightdate</option>
+                                <option value="itemcallnumber">Call number</option>
+                            </select>
+                        </th>
+                        <th></th>
+                        <th></th>
+                        <th></th>
+                    </tr>
+                </thead>
+                <tbody></tbody>
+            </table>
+        </div>
+    </div>
 [% END %]
 
 <form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
@@ -649,4 +383,363 @@ function placeHold () {
 
 </div>
 </div>
+
+[% IF ( can_add_biblios ) %]
+<div class="yui-b">
+  <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
+    <fieldset class="brief noprint">
+      <h4>Add items</h4>
+      <ol>
+        <li>
+          <label for="barcodes">Barcodes:</label>
+          <textarea name="barcodes" id="barcodes" class="focus" autocomplete="off" rows="5"></textarea>
+          <input type="hidden" name="op" value="add_biblio" />
+          <input type="hidden" name="referer" value="view" />
+          <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
+        </li>
+        <li>
+          <label for="biblionumbers">Biblio numbers:</label>
+          <textarea name="biblionumbers" id="biblionumbers" class="focus" autocomplete="off" rows="5"></textarea>
+          <input type="hidden" name="op" value="add_biblio" />
+          <input type="hidden" name="referer" value="view" />
+          <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
+        </li>
+      </ol>
+      <fieldset class="action">
+        <input type="submit" value="Add" />
+      </fieldset>
+    </fieldset>
+  </form>
+</div>
+[% END %]
+
+</div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
+    [% IF print %]
+        <script type="text/javascript">
+            $( document ).ready(function() {
+                window.print();
+                setTimeout('window.close()', 1);
+            });
+        </script>
+    [% END %]
+
+    [% IF op == 'view' %]
+        [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
+        [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") | $raw %]
+    [% END %]
+    <script type="text/javascript">
+        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
+        var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
+        var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
+
+        [% IF op == 'list' %]
+            $(document).ready(function(){
+                [% IF category == PUBLIC %]
+                    var type = [% PUBLIC | html %];
+                [% ELSE %]
+                    var type = [% PRIVATE | html %];
+                [% END %]
+                var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
+
+                "aaSorting": [[ 5, "asc" ]],
+                    'bServerSide': true,
+                    'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
+                    'fnServerData': function(sSource, aoData, fnCallback) {
+                        aoData.push({
+                            'name': 'type',
+                            'value': type,
+                        },{
+                            'name': 'shelfname',
+                            'value': $("#searchshelfname_filter").val(),
+                        },{
+                            'name': 'owner',
+                            'value': $("#searchowner_filter").val(),
+                        },{
+                            'name': 'sortby',
+                            'value': $("#searchsortby_filter").val(),
+                        },{
+                            'name': 'template_path',
+                            'value': 'virtualshelves/tables/shelves_results.tt',
+                        });
+                        $.ajax({
+                            'dataType': 'json',
+                            'type': 'POST',
+                            'url': sSource,
+                            'data': aoData,
+                            'success': function(json){
+                                fnCallback(json);
+                            }
+                        });
+                    },
+                    'aoColumns':[
+                        { 'mDataProp': 'dt_type' },
+                        { 'mDataProp': 'dt_shelfname' },
+                        { 'mDataProp': 'dt_count' },
+                        { 'mDataProp': 'dt_is_shared' },
+                        { 'mDataProp': 'dt_owner' },
+                        { 'mDataProp': 'dt_sortby' },
+                        { 'mDataProp': 'dt_created_on' },
+                        { 'mDataProp': 'dt_modification_time' },
+                        { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
+                    ],
+                    "aoColumnDefs": [
+                        { "bVisible": false, "aTargets": [ 'NoVisible' ] }
+                    ],
+                    'bAutoWidth': false,
+                    'sPaginationType': 'full_numbers',
+                    'bFilter': false,
+                    "bProcessing": true,
+                    "bSortCellsTop": true
+                }));
+
+                dtListResults.fnAddFilters("filter", 750);
+
+                var tabs = $("#tabs").tabs({
+                    [% IF category == PUBLIC %]
+                        active: 1,
+                    [% ELSE %]
+                        active: 0,
+                    [% END %]
+                    activate: function(e, ui) {
+                        var active = tabs.tabs("option", "active" );
+                        if ( active == 0 ) {
+                            type = [% PRIVATE | html %];
+                            dtListResults.fnDraw();
+                        } else if ( active == 1 ) {
+                            type = [% PUBLIC | html %];
+                            dtListResults.fnDraw();
+                        }
+                    }
+                });
+                $("body").on("click", ".deleteshelf", function(){
+                    return confirmDelete(MSG_CONFIRM_DELETE_LIST);
+                });
+            });
+        [% END %]
+
+        [% IF shelf AND op == 'view' %]
+            $(document).ready(function(){
+                [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
+                $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-remove\"></i>"+_(" Clear all")+"<\/a>");
+                $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-check\"></i>"+_(" Select all")+"<\/a>");
+                $("#CheckAll").click(function(){
+                    $(".checkboxed").checkCheckboxes();
+                    return false;
+                });
+                $("#CheckNone").click(function(){
+                    $(".checkboxed").unCheckCheckboxes();
+                    return false;
+                });
+                $(".placehold").on("click",function(e){
+                    placeHold();
+                    e.preventDefault();
+                });
+                $(".addtocart").show();
+                var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
+                [% IF ( intranetbookbag ) %]
+                     param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
+                [% END %]
+                [% IF Koha.Preference('virtualshelves') %]
+                    [% IF add_to_some_private_shelves.count %]
+                        param1 += "<optgroup label=\""+_("Your lists:")+"\">";
+                        [% SET number_of_private_shelves = 0 %]
+                        [% FOREACH s IN add_to_some_private_shelves %]
+                            [% IF shelfnumber != s.shelfnumber %]
+                                param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
+                                [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+                                [% IF number_of_private_shelves == 10 %][% LAST | html %][% END %]
+                            [% END %]
+                        [% END %]
+                        param1 += "<\/optgroup>";
+                    [% END %]
+                    [% IF add_to_some_public_shelves.count %]
+                        param1 += "<optgroup label=\""+_("Public lists:")+"\">";
+                        [% SET number_of_public_shelves = 0 %]
+                        [% FOREACH s IN add_to_some_public_shelves %]
+                            [% IF shelfnumber != s.shelfnumber %]
+                                param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
+                                [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+                                [% IF number_of_public_shelves == 10 %][% LAST | html %][% END %]
+                            [% END %]
+                        [% END %]
+                        param1 += "<\/optgroup>";
+                    [% END %]
+                    [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
+                        param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
+                    [% END %]
+                    param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
+                [% END %]
+                param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-default btn-xs\">"+_("Save")+"</button>";
+                $("span.addto").html(param1);
+                $("#cartsubmit").on("click",function(e){
+                    cartList();
+                    e.preventDefault();
+                });
+                $("#addto").change(function(){
+                    cartList();
+                });
+                $(".addto").find("input:submit").click(function(e){
+                    e.preventDefault();
+                    cartList();
+                });
+                $("#selection_ops").show();
+                $(".merge-items").on("click",function(e){
+                    e.preventDefault();
+                    MergeItems();
+                });
+                $("#listform").on("submit",function(e){
+
+                });
+                $(".list-remove").on("click",function(e){
+                    if($(".selection").filter(":checked").length > 0){
+                        return confirm(MSG_REMOVE_FROM_LIST);
+                    } else {
+                        alert(MSG_NO_ITEM_SELECTED);
+                        e.preventDefault();
+                    }
+                });
+            });
+        [% END %]
+
+        [% IF shelf AND op == 'edit_form' %]
+            $(document).ready(function(){
+                AdjustRemark();
+            });
+        [% END %]
+
+        /**
+         * This function checks if the adequate number of records are checked for merging
+         */
+        function MergeItems() {
+            var checkboxes = $("input:checkbox:checked");
+            if (checkboxes.length < 2) {
+                alert(_("At least two records must be selected for merging."));
+            } else {
+                var params = [];
+                $(checkboxes).each(function() {
+                    params.push('biblionumber=' + $(this).val());
+                });
+                var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
+                location.href = url;
+            }
+            return false;
+        }
+
+        /**
+         * This function checks all checkboxes if all are empty,
+         * or unchecks all if any already checked.
+         */
+        function CheckAll(){
+            var checkboxes = document.getElementsByTagName('input');
+            var nbCheckbox = checkboxes.length;
+            var check = areAllChecked();
+            for(var i=0;i<nbCheckbox;i++){
+                if(checkboxes[i].getAttribute('type') == "checkbox" ){
+                    checkboxes[i].checked = (check) ? 0 : 1;
+                }
+            }
+        }
+        /**
+         * This function returns true if ALL checkboxes are checked
+         */
+        function areAllChecked(){
+            var checkboxes = document.getElementsByTagName('input');
+            var nbCheckbox = checkboxes.length;
+            for(var i=0;i<nbCheckbox;i++){
+                if(checkboxes[i].getAttribute('type') == "checkbox" ){
+                    if(checkboxes[i].checked == 0){
+                        return false;
+                    }
+                }
+            }
+            return true;
+        }
+
+        function placeHold () {
+            var checkedItems = $(".selection:checked");
+            if ($(checkedItems).size() == 0) {
+                alert(MSG_NO_ITEM_SELECTED);
+                return false;
+            }
+            var bibs = "";
+            $(checkedItems).each(function() {
+                bibs += $(this).val() + "/";
+            });
+            $("#hold_form_biblios").val(bibs);
+            $("#hold_form").submit();
+            return false;
+        }
+
+        function cartList(){
+            var checkboxes = $("#searchresults").find(":checkbox");
+            var vshelf = vShelfAdd(checkboxes);
+            if($("#addto").find("option:selected").attr("value") == "addtolist"){
+                var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
+                if (vshelf) {
+                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
+                }
+                return false;
+            } else if($("#addto").find("option:selected").attr("value") == "newlist"){
+                if (vshelf) {
+                    openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
+                }
+                return false;
+            } else if($("#addto").find("option:selected").attr("value") == "morelists"){
+                if (vshelf) {
+                    openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
+                }
+                return false;
+            }
+            if($("#addto").find("option:selected").attr("value") == "addtocart"){
+                addMultiple(checkboxes);
+                return false;
+            }
+        }
+
+        function AdjustRemark() {
+            var category = $("#category").val();
+            var perms = $("#allow_changes_from").val();
+
+            if( perms < 2 ) {
+                $("#anyone_remark").hide();
+            } else if( category==1 ) {
+                // If we move to Private (without shares), show Anyone remark
+                // Note: the number of shares is not tested real-time
+                [% IF !shelf.is_shared %]
+                    $("#anyone_remark").show();
+                [% ELSE %]
+                    $("#anyone_remark").hide();
+                [% END %]
+            } else { // category==2
+                $("#anyone_remark").hide();
+            }
+        }
+        [% IF op == 'view' %]
+
+            function sendList(){
+                open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
+             }
+
+             $(document).ready(function() {
+                $("#sendlist").click(function(){
+                    sendList();
+                    return false;
+                });
+                $("#deleteshelf").click(function(e){
+                    if(confirm(_("Are you sure you want to delete this list?"))){
+                        return true;
+                    } else {
+                        e.preventDefault();
+                    }
+                });
+             });
+
+        [% END %]
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]