Fixing and refining toolbars, including fixes for Bug 1509.
[wip/koha-chris_n.git] / koha-tmpl / intranet-tmpl / prog / en / includes / cat-toolbar.inc
1 <div id="toolbar">
2         
3         <script type="text/javascript">
4         
5         function addToShelf() { window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->','Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes');
6         }
7         function printBiblio() {window.open('/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->','Print_Biblio','width=700,height=500,toolbar=false,scrollbars=yes');
8         }
9 function confirm_deletion() {
10                 var count = <!-- TMPL_VAR NAME="count" -->;
11                 if(!count){ alert("no count!");
12                 return false; } else {
13                 alert(count);
14                 }
15         var is_confirmed;
16         if (count>0){
17                     is_confirmed= alert(_('There are [ '+ count +' ] item(s) attached to this record \n You must delete all items before deleting this record.'));
18                     } else{
19                     is_confirmed= confirm(_('Are you sure you want to delete this record? '));
20         }
21    
22      if (is_confirmed) {
23         if (count>0){
24 //      window.location="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
25         } else {
26         window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
27         }
28                 
29     }
30 }
31         //<![CDATA[
32
33         // prepare DOM for YUI Toolbar
34
35          $(document).ready(function() {
36             $("#edititems").parent().remove();
37             $("#duplicatebiblio").parent().remove();
38             $("#editmenuc").empty();
39                 $("#addtoshelfc").empty();
40                 $("#printbiblioc").empty();
41                 $("#deletebiblioc").empty();
42             yuiToolbar();
43          });
44
45         // YUI Toolbar Functions
46
47         function yuiToolbar() {
48             var editmenu = [
49                 { text: "Edit Record", url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },
50                 { text: "Edit Items", url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
51                 { text: "Edit as New (Duplicate)", url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" }
52             ];
53
54             new YAHOO.widget.Button({
55                 type: "menu",
56                 label: "Edit",
57                 name: "editmenubutton",
58                 menu: editmenu,
59                 container: "editmenuc"
60             });
61                 
62                 var deletebiblioButton = new YAHOO.widget.Button({
63                                             id: "deletebiblio", 
64                                             type: "button", 
65                                             label: "Delete", 
66                                             container: "deletebiblioc",
67                                                                                         onclick: {fn: confirm_deletion }
68                                         });
69                                                                                                 
70                 var addtoshelfButton = new YAHOO.widget.Button({
71                                             id: "addtoshelf", 
72                                             type: "button", 
73                                             label: "Add to Shelf", 
74                                             container: "addtoshelfc",
75                                                                                         onclick: {fn: addToShelf }
76                                         });
77                                                                                 
78                 var printbiblioButton = new YAHOO.widget.Button({
79                                             id: "printbiblio", 
80                                             type: "button", 
81                                             label: "Print", 
82                                             container: "printbiblioc",
83                                                                                         onclick: {fn: printBiblio }
84                                         });
85
86             var addbiblioButton = new YAHOO.widget.Button("addbiblio");
87             var placeholdButton = new YAHOO.widget.Button("placehold");
88                 
89         }
90
91         //]]>
92         </script>
93         
94 <ul class="toolbar">
95
96         <li><a id="addbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl">New</a></li>
97         <li id="editmenuc"><a id="editbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=<!--TMPL_VAR Name="current_framework" -->&amp;op=">Edit Record</a></li>
98         <li><a id="edititems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Edit Items</a></li>
99         <li><a id="duplicatebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=<!--TMPL_VAR Name="current_framework" -->&amp;op=duplicate">Duplicate Record</a></li>
100         <li id="deletebiblioc"><a id="deletebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Delete</a></li>
101         <li id="addtoshelfc"><a id="addtoshelf" href="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add to shelf</a></li>
102         <li id="printbiblioc"><a id="printbiblio" href="/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Print</a></li>
103         <!-- TMPL_UNLESS name="bi_notforloan" -->
104         <!-- TMPL_UNLESS NAME="norequests" --><li><a id="placehold" href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li><!-- /TMPL_UNLESS --><!-- TMPL_UNLESS -->
105 </ul></div>