Fix for Bug 3659, Add place hold option from patron checkout tab
[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         //<![CDATA[
5         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
6         /* this function open a popup to search on z3950 server.  */
7         function PopupZ3950() {
8                 var strQuery = GetZ3950Terms();
9                 if(strQuery){
10                         window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
11                 } 
12         }
13
14         /* provide Z3950 search points */
15         function GetZ3950Terms(){
16                 var strQuery="&frameworkcode=";
17                 <!-- TMPL_LOOP NAME='z3950_search_params' -->
18                         strQuery += "&" + "<!-- TMPL_VAR NAME="name" -->" + "=" + "<!-- TMPL_VAR NAME="encvalue" -->";
19                 <!-- /TMPL_LOOP -->
20                 return strQuery;
21         }
22         <!-- /TMPL_IF -->
23         function addToCart() { addRecord('<!-- TMPL_VAR NAME="biblionumber" -->'); }
24         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');
25         }
26         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');
27         }
28 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
29 function confirm_deletion() {
30                 var count = <!-- TMPL_VAR NAME="count" -->;
31         var is_confirmed;
32         if (count>0){
33                     is_confirmed= alert(_('There are [ '+ count +' ] item(s) attached to this record \n You must delete all items before deleting this record.'));
34                     } else{
35                     is_confirmed= confirm(_('Are you sure you want to delete this record? '));
36         }
37
38      if (is_confirmed) {
39         if (count>0){
40         //      window.location="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
41                 } else {
42                         window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
43                 }
44         } else {
45                 return false;
46         }
47 }
48 <!-- /TMPL_IF -->
49 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
50 function confirm_items_deletion() {
51         var count = <!-- TMPL_VAR NAME="count" -->;
52         if(count > 0){
53             if(confirm(_('Are you sure you want to delete the ' + count + ' attached items? '))){
54                 window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
55             }else{
56                 return false;
57             }
58                 }
59 }
60 <!-- /TMPL_IF -->
61         // prepare DOM for YUI Toolbar
62
63          $(document).ready(function() {
64             <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->$("#edititems").parent().remove();
65                 $("#newitem").parent().remove();<!-- /TMPL_IF -->
66             <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->$("#duplicatebiblio").parent().remove();
67                 $("#deletebiblio").parent().remove();
68                 $("#z3950searchc").empty();<!-- /TMPL_IF -->
69                 <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->$("#newsub").parent().remove();<!-- /TMPL_IF -->
70             $("#newbiblio").parent().remove();
71                 $("#editbiblio").parent().remove();
72                 $("#addtoshelf").parent().remove();
73                 $("#printbiblio").parent().remove();
74                 $("#placehold").parent().remove();
75                 $("#export").remove();
76          });
77
78         YAHOO.util.Event.onContentReady("cattoolbar", function () {
79                 //      Menu for new record, new item, new subscription
80                 var newmenu = [
81                         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{text: _("New Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl" },<!-- /TMPL_IF -->
82                         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{text: _("New Item"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#additema" },<!-- /TMPL_IF -->
83                         <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->
84                         {text: _("New Subscription"), url: "/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=<!-- TMPL_VAR NAME="biblionumber" -->"},<!-- /TMPL_IF -->
85                 ];
86                 if(newmenu.length){
87                         new YAHOO.widget.Button({
88                                 type: "menu",
89                                 label: _("New"),
90                                 id: "newmenuc",
91                                 name: "newmenubutton",
92                                 menu: newmenu,
93                                 container: this
94                          });
95                  }
96             var editmenu = [
97                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },<!-- /TMPL_IF -->
98                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },<!-- /TMPL_IF -->
99                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },<!-- /TMPL_IF -->
100                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" },<!-- /TMPL_IF -->
101                         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Delete Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> },<!-- /TMPL_IF -->
102                 <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Delete all Items"), onclick: {fn: confirm_items_deletion } }<!-- /TMPL_IF -->
103             ];
104                 if(editmenu.length){
105                         new YAHOO.widget.Button({
106                                 type: "menu",
107                                 label: _("Edit"),
108                                 id: "editmenuc",
109                                 name: "editmenubutton",
110                                 menu: editmenu,
111                                 container: this
112                          });
113                 }
114                 var savemenu = [
115                         { text: _("MODS (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
116                         { text: _("Dublin Core (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=dc&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
117                         { text: _("MARCXML"), url: "/cgi-bin/koha/catalogue/export.pl?format=marcxml&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
118                         { text: _("MARC (non-Unicode/MARC-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=marc8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
119                         { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" }
120                 ];
121
122             new YAHOO.widget.Button({
123                 type: "menu",
124                 label: _("Save"),
125                 id: "savemenuc",
126                 name: "savemenubutton",
127                 menu: savemenu,
128                 container: this
129             });
130
131             var addtomenu = [
132                         { text: _("Cart"), onclick: { fn: addToCart } },
133                         { text: _("List"),  onclick: { fn: addToShelf } }
134                 ];
135
136                 new YAHOO.widget.Button({
137                 type: "menu",
138                 label: _("Add to"),
139                 name: "addtomenubutton",
140                 menu: addtomenu,
141                 container: this
142             });
143
144                 new YAHOO.widget.Button({
145                 id: "printbiblio",
146                 type: "button",
147                 label: _("Print"),
148                 container: this,
149                         onclick: {fn: printBiblio }
150                 });
151                 <!-- TMPL_IF NAME="CAN_user_reserveforothers" --><!-- TMPL_UNLESS NAME="norequests" -->
152                 <!-- TMPL_IF NAME="holdfor" -->
153                 //      Create an array of YAHOO.widget.MenuItem configuration properties
154                 var onButtonClick = function () { 
155                         location.href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
156                 }
157                 var HoldForButtonMenu = [
158                         { text: "Place hold", url: "/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
159                         { text: "Place hold for <!-- TMPL_VAR NAME="holdfor_firstname" --> <!-- TMPL_VAR NAME="holdfor_surname" --> (<!-- TMPL_VAR NAME="holdfor_cardnumber" -->)", url: "/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&findborrower=<!-- TMPL_VAR NAME="holdfor_cardnumber" -->" }
160                 ];
161
162                 //      Instantiate a Split Button using the array of YAHOO.widget.MenuItem 
163                 //      configuration properties as the value for the "menu" 
164                 //      configuration attribute.
165
166                 var HoldForButton = new YAHOO.widget.Button({
167                                 id: "holdfor",
168                                 type: "split",
169                                 label: "Place hold",
170                                 name: "holdfor",
171                                 menu: HoldForButtonMenu,
172                                 container: this,
173                                 onclick: { fn: onButtonClick }
174                 });
175             <!-- TMPL_ELSE -->
176             new YAHOO.widget.Button({
177                         id: "placehold",
178                         type: "link",
179                         label: _("Place hold"),
180                         container: this,
181                         href: "/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"
182              });
183             <!-- /TMPL_IF -->
184             <!-- /TMPL_IF --><!-- /TMPL_IF -->
185             <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
186                 new YAHOO.widget.Button({
187                         id: "z3950search",
188                         type: "button", 
189                         label: _("Z39.50 Search"),
190                         container: this,
191                         onclick: {fn:function(){PopupZ3950()}}
192                 });
193                 <!-- /TMPL_IF -->
194         });
195         //]]>
196         </script>
197         
198 <form method="post" name="f" id="f" action="/cgi-bin/koha/cataloguing/addbiblio.pl" onsubmit="return Check();">
199
200 <ul class="toolbar" id="cattoolbar">
201
202         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
203         <li><a id="newbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl">New Record</a></li>
204         <!-- /TMPL_IF -->
205         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
206         <li><a id="newitem" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">New Item</a></li>
207         <!-- /TMPL_IF -->
208         <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->
209         <li><a id="newsub" href="/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=<!-- TMPL_VAR NAME="biblionumber" -->">New Subscription</a></li>
210         <!-- /TMPL_IF -->
211
212         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
213         <li><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>
214         <!-- /TMPL_IF -->
215         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
216         <li><a id="edititems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Edit Items</a></li>
217         <!-- /TMPL_IF -->
218         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
219         <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>
220         <!-- /TMPL_IF -->
221         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
222         <li><a id="deletebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Delete</a></li>
223         <!-- /TMPL_IF -->       
224
225         <li><a id="addtoshelf" href="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add to shelf</a></li>
226         <li><a id="printbiblio" href="/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Print</a></li>
227         <!-- TMPL_IF NAME="CAN_user_reserveforothers" -->
228         <!-- 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 -->
229         <!-- /TMPL_IF -->
230         <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" --><li id="z3950searchc"><input type="button" id="z3950search" value="Z39.50 Search" onclick="PopupZ3950(); return false;" /></li><!-- /TMPL_IF -->
231     </ul>
232 </form>
233 </div>
234