Bug 14610 - Add and update scripts
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / includes / cat-toolbar.inc
1         <script type="text/javascript">
2         //<![CDATA[
3         [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
4         /* this function open a popup to search on z3950 server.  */
5         function PopupZ3950() {
6                 var strQuery = GetZ3950Terms();
7                 if(strQuery){
8                         window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=[% biblionumber %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
9                 } 
10         }
11     function PopupZ3950Confirmed() {
12         if (confirm(_("Please note that this external search could replace the current record."))){
13             PopupZ3950();
14         }
15     }
16
17         /* provide Z3950 search points */
18         function GetZ3950Terms(){
19                 var strQuery="&frameworkcode=";
20                 [% FOREACH z3950_search_param IN z3950_search_params %]
21             strQuery += "&" + "[% z3950_search_param.name |uri %]" + "=" + "[% z3950_search_param.value |uri %]";
22                 [% END %]
23                 return strQuery;
24         }
25         [% END %]
26         function addToCart() { addRecord('[% biblionumber %]'); }
27         function addToShelf() { window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=[% biblionumber %]','Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes');
28         }
29     function printBiblio() {window.print(); }
30 [% IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
31     function confirm_deletion() {
32         var count = [% count %];
33         var holdcount = [% holdcount %];
34         var countorders = [% countorders %];
35         var countdeletedorders = [% countdeletedorders %];
36         var is_confirmed;
37         if (count > 0){
38             is_confirmed = alert( _("%s item(s) are attached to this record. You must delete all items before deleting this record.").format(count) );
39          }
40         else if (countorders > 0){
41             [% IF ( CAN_user_acquisition_order_manage ) %]
42                 is_confirmed = confirm( _("Warning: This record is used in %s order(s). Deleting it could cause serious issues on acquisition module. Are you sure you want to delete this record?").format(countorders) );
43             [% ELSE %]
44                 is_confirmed = alert( _("%s order(s) are using this record. You need order managing permissions to delete this record.").format(countorders) );
45             [% END %]
46         }
47         else if (countdeletedorders > 0){
48              [% IF ( CAN_user_acquisition_order_manage ) %]
49                  is_confirmed = confirm( _("%s deleted order(s) are using this record. Are you sure you want to delete this record?").format(countdeletedorders) );
50              [% ELSE %]
51                  is_confirmed = alert( _("%s deleted order(s) are using this record. You need order managing permissions to delete this record.").format(countdeletedorders) );
52              [% END %]
53         }
54         else if ( holdcount > 0 ) {
55             is_confirmed = confirm( _("%s holds(s) for this record. Are you sure you want to delete this record?").format(holdcount) );
56         } else {
57             is_confirmed = confirm(_("Are you sure you want to delete this record?"));
58         }
59         if (is_confirmed) {
60                 window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=[% biblionumber %]";
61         } else {
62             return false;
63         }
64     }
65 [% END %]
66
67 [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
68     function confirm_items_deletion() {
69         var count = [% count %];
70         var holdcount = [% holdcount %];
71
72         if ( holdcount > 0 ) {
73             alert( _("%s hold(s) on this record. You must delete all holds before deleting all items.").format(holdcount) );
74         } else if ( count > 0 ) {
75             if( confirm( _("Are you sure you want to delete the %s attached items?").format(count) ) ) {
76                 window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=[% biblionumber %]";
77             } else {
78                 return false;
79             }
80         } else {
81             alertNoItems();
82             return false;
83         }
84     }
85     function alertNoItems(){
86         alert(_("This record has no items."));
87     }
88 [% END %]
89          $(document).ready(function() {
90         $("#z3950copy").click(function(){
91             PopupZ3950();
92             return false;
93         });
94         $("#deletebiblio").click(function(){
95             confirm_deletion();
96             return false;
97         });
98         $("#deleteallitems").click(function(){
99             confirm_items_deletion();
100             return false;
101         });
102         $("#printbiblio").click(function(){
103             printBiblio();
104             return false;
105         });
106         $("#addtocart").click(function(){
107             addToCart();
108             $(".btn-group").removeClass("open");
109             return false;
110         });
111         $("#addtoshelf").click(function(){
112             addToShelf();
113             $(".btn-group").removeClass("open");
114             return false;
115         });
116         $("#export").remove(); // Hide embedded export form if JS menus available
117         $("#deletebiblio").tooltip();
118         $("#batchedit-disabled,#batchdelete-disabled,#deleteallitems-disabled")
119             .on("click",function(e){
120                 e.preventDefault();
121                 alertNoItems();
122             })
123             .tooltip();
124          });
125         //]]>
126         </script>
127
128 <div id="toolbar" class="btn-toolbar">
129
130 [% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items ||
131 CAN_user_serials_create_subscription ) %]
132     <div class="btn-group">
133     <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
134         <ul class="dropdown-menu">
135             [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
136              <li><a id="newbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl">New record</a></li>
137             [% END %]
138
139             [% IF ( CAN_user_editcatalogue_edit_items ) %]
140              <li><a id="newitem" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]#additema">New item</a></li>
141             [% END %]
142             [% IF ( CAN_user_serials_create_subscription ) %]
143              <li><a id="newsub" href="/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=[% biblionumber %]">New subscription</a></li>
144             [% END %]
145
146             [% IF ( EasyAnalyticalRecords && CAN_user_editcatalogue_edit_catalogue ) %]
147                 <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&amp;analyze=1">Analyze items</a></li>
148             [% END %]
149             [% IF CAN_user_editcatalogue_edit_catalogue && ! EasyAnalyticalRecords %]
150                 <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?parentbiblionumber=[% biblionumber %]">New child record</a></li>
151             [% END %]
152     </ul>
153     </div>
154 [% END %]
155
156 [% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
157     <div class="btn-group">
158     <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button>
159         <ul class="dropdown-menu">
160             [% IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
161             <li><a id="editbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">Edit record</a></li>
162             [% END %]
163
164             [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
165             <li><a id="edititems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Edit items</a></li>
166             [% END %]
167
168             [% IF ( CAN_user_tools_items_batchmod ) %]
169                 [% IF ( count ) %]
170                     <li><a id="batchedit" href="/cgi-bin/koha/tools/batchMod.pl?op=show&amp;biblionumber=[% biblionumber %]&amp;src=CATALOGUING">Edit items in batch</a></li>
171                 [% ELSE %]
172                     <li class="disabled"><a id="batchedit-disabled" href="#" data-toggle="tooltip" data-placement="left" title="This record has no items">Edit items in batch</a></li>
173                 [% END %]
174             [% END %]
175
176             [% IF ( CAN_user_tools_items_batchdel ) %]
177                 [% IF ( count ) %]
178                     <li><a id="batchdelete" href="/cgi-bin/koha/tools/batchMod.pl?del=1&amp;op=show&amp;biblionumber=[% biblionumber %]&amp;src=CATALOGUING">Delete items in a batch</a></li>
179                 [% ELSE %]
180                     <li class="disabled"><a id="batchdelete-disabled" href="#" data-toggle="tooltip" data-placement="left" title="This record has no items">Delete items in a batch</a></li>
181                 [% END %]
182             [% END %]
183
184             [% IF ( CAN_user_editcatalogue_edit_items ) %]<li><a href="/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=[% biblionumber %]">Attach item</a></li>[% END %]
185
186             [% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_items ) %]<li><a href="/cgi-bin/koha/cataloguing/linkitem.pl?biblionumber=[% biblionumber %]">Link to host item</a>[% END %][% END %]
187             [% IF ( LocalCoverImages || OPACLocalCoverImages) %][% IF ( CAN_user_tools_upload_local_cover_images ) %]<li><a href="/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&amp;filetype=image">Upload image</a>[% END %][% END %]
188
189             [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
190                 <li><a id="duplicatebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&amp;op=duplicate">Edit as new (duplicate)</a></li>
191                 <li><a href="#" id="z3950copy">Replace record via Z39.50/SRU</a></li>
192             [% END %]
193
194             [% IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
195                 [% IF ( count ) %]
196                     <li class="disabled"><a id="deletebiblio" data-toggle="tooltip" data-placement="left" title="[% count %] item(s) are attached to this record. You must delete all items before deleting this record." href="#">Delete record</a></li>
197                 [% ELSE %]
198                     <li><a id="deletebiblio" href="#">Delete record</a></li>
199                 [% END %]
200             [% END %]
201
202             [% IF CAN_user_editcatalogue_delete_all_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
203                 [% IF ( count ) %]
204                     <li><a href="#" id="deleteallitems">Delete all items</a></li>
205                 [% ELSE %]
206                     <li class="disabled"><a href="#" id="deleteallitems-disabled" data-toggle="tooltip" data-placement="left" title="This record has no items">Delete all items</a></li>
207                 [% END %]
208             [% END %]
209
210     </ul>
211     </div>
212 [% END %]
213
214     <div class="btn-group">
215     <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-download"></i> Save <span class="caret"></span></button>
216     <ul class="dropdown-menu">
217         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=bibtex&amp;op=export&amp;bib=[% biblionumber %]">BIBTEX</a></li>
218         <li><a href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
219         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcxml&amp;op=export&amp;bib=[% biblionumber %]">MARCXML</a></li>
220         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marc8&amp;op=export&amp;bib=[% biblionumber %]">MARC (non-Unicode/MARC-8)</a></li>
221         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=utf8&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8)</a></li>
222         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8, Standard)</a></li>
223         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber %]">MODS (XML)</a></li>
224         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber %]">RIS</a></li>
225     </ul>
226     </div>
227
228 [% IF ( virtualshelves && intranetbookbag ) %]
229     <div class="btn-group">
230     <button class="btn btn-small dropdown-toggle" data-toggle="dropdown">Add to <span class="caret"></span></button>
231     <ul class="dropdown-menu">
232         <li><a href="#" id="addtocart">Cart</a></li>
233         <li><a href="#" id="addtoshelf">List</a></li>
234     </ul>
235     </div>
236 [% ELSIF ( virtualshelves ) %]
237     <div class="btn-group"><a id="addtoshelf" class="btn btn-small"><i class="fa fa-list"></i> Add to list</a> </div>
238 [% ELSIF ( intranetbookbag ) %]
239     <div class="btn-group"><a id="addtocart" class="btn btn-small"><i class="fa fa-shopping-cart"></i> Add to cart</a> </div>
240 [% END %]
241
242     <div class="btn-group"><a id="printbiblio" class="btn btn-small"><i class="fa fa-print"></i> Print</a></div>
243
244 [% IF ( CAN_user_reserveforothers ) %]
245     [% UNLESS ( norequests ) %]
246         [% IF ( holdfor ) %]
247             <div class="btn-group">
248                 <button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
249                     <i class="fa fa-sticky-note-o"></i>
250                     Place hold
251                     <span class="caret"></span>
252                 </button>
253                 <ul class="dropdown-menu">
254                     <li><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">Place hold</a></li>
255                     <li><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]&amp;findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></li>
256                 </ul>
257             </div>
258         [% ELSE %]
259             <div class="btn-group"><a id="placehold" class="btn btn-small" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]"><i class="fa fa-sticky-note-o"></i> Place hold</a></div>
260         [% END %]
261     [% END %]
262 [% END %]
263
264 [% IF Koha.Preference('ArticleRequests') %]
265     <div class="btn-group"><a id="placehold" class="btn btn-small" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber %]"><i class="fa fa-file-text-o"></i> Request article</a></div>
266 [% END %]
267
268 </div>
269
270     <!--Modal for Dublin Core-->
271     <div class="modal hide" id="exportModal_" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_" aria-hidden="true">
272         <div class="modal-header">
273             <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">&times;</button>
274             <h3 id="exportLabelexportModal_">Exporting to Dublin Core...</h3>
275         </div>
276         <form method="get" action="/cgi-bin/koha/catalogue/export.pl">
277         <div class="modal-body">
278             <fieldset>
279                 <input id="input-simple" type="radio" name="format" value="rdfdc">
280                 <label for="input-simple">Simple DC-RDF</label>
281                 <br>
282                 <input id="input-oai" type="radio" name="format" value="oaidc" checked>
283                 <label for="input-oai">OAI-DC</label>
284                 <br>
285                 <input id="input-srw" type="radio" name="format" value="srwdc">
286                 <label for="input-srw">SRW-DC</label>
287                 <br>
288             </fieldset>
289         </div>
290         <div class="modal-footer">
291             <button type="submit" class="btn">Export</button>
292             <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
293         </div>
294         <input type="hidden" name="op" value="export" />
295         <input type="hidden" name="bib" value="[% biblionumber %]" />
296         </form>
297     </div>