+
+[% MACRO jsinclude BLOCK %]
+ [% Asset.js("js/acquisitions-menu.js") | $raw %]
+ [% INCLUDE 'datatables.inc' %]
+ [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") | $raw %]
+ <script>
+ function updateColumnsVisibility(visible) {
+ if ( visible ) {
+ $("table .tax_excluded, .tax_included").show();
+ } else {
+ [% IF ( listincgst ) %]
+ $("table .tax_excluded").hide();
+ [% ELSE %]
+ $("table .tax_included").hide();
+ [% END %]
+ }
+ }
+
+ $(document).ready(function() {
+ if ( $('#toolbar').length ) {$('#toolbar').fixFloat();}
+ $("#show_all_details").click(function(){
+ updateColumnsVisibility($(this).is(":checked"));
+ });
+
+ $("#show_all_details").prop('checked', false);
+ updateColumnsVisibility(false);
+ [% UNLESS ( closedate ) %]
+ $('#addtoBasket').on('show', function () {
+ $(this).find(".modal-body").html($(".acqui_basket_add")[0].outerHTML);
+ });
+ [% END %]
+
+ $("body").on("click", ".del_user", function(e){
+ e.preventDefault();
+ del_user( $(this).data("borrowernumber") );
+ });
+
+ $("#add_user").on("click",function(e){
+ e.preventDefault();
+ UserSearchPopup();
+ });
+
+ $(".transfer_order").on("click",function(e){
+ e.preventDefault();
+ transfer_order_popup( $(this).data("ordernumber"));
+ });
+
+ $(".edit_note").on("click", function(e) {
+ e.preventDefault();
+ var ordernumber = $(this).data("ordernumber");
+ var note_type = $(this).data("note_type");
+ var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
+ var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
+ $("#noteEditor .modal-title").text(modalTitle);
+ $("#ordernumber").val( ordernumber );
+ $("#ordernotes").html( note_text );
+ $("#type").val( note_type );
+ $("#noteEditor").modal("show");
+ $("#ordernotes").focus();
+ });
+
+ $("#noteEditor").on('hidden.bs.modal', function (e) {
+ $("#noteEditorLabel").html("");
+ $("#noteEditor .modal-title").text("");
+ $("#ordernotes").html( "" );
+ $("#ordernumber").val("");
+ $("#type").val("");
+ });
+
+ $("#set_managing_library").on("click", function(e){
+ e.preventDefault();
+ $(this).hide();
+ $("#managing_library_entry").show();
+ });
+
+ $("#library_entry_cancel").on("click", function(e){
+ e.preventDefault();
+ $("#managing_library_entry").hide();
+ $("#set_managing_library").show();
+ });
+
+ $("#set_basket_group").on("click", function(e){
+ e.preventDefault();
+ $(this).hide();
+ $("#basket_grouping").show();
+ });
+
+ $("#basket_group_cancel").on("click", function(e){
+ e.preventDefault();
+ $("#basket_grouping").hide();
+ $("#set_basket_group").show();
+ });
+
+ });
+ </script>
+
+ [% UNLESS ( closedate ) %]
+ <script>
+ function transfer_order_popup(ordernumber) {
+ var url = "/cgi-bin/koha/acqui/transferorder.pl?"
+ + "ordernumber=" + ordernumber
+ window.open(url, 'TransferOrder','width=600,height=400,toolbar=false,scrollbars=yes');
+ }
+
+ function confirm_ediorder() {
+ var is_confirmed = confirm(_("Are you sure you want to close this basket and generate an EDIFACT order?"));
+ if (is_confirmed) {
+ window.location = "/cgi-bin/koha/acqui/basket.pl?op=edi_confirm&basketno=[% basketno | html %]";
+ }
+ }
+ </script>
+ [% ELSE %]
+ <script>
+ $(document).ready(function(){
+ $("#basketgroupid").change(function(){
+ if($(this).val() == "new"){
+ location.href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid | html %]";
+ } else {
+ $(this).parent().submit();
+ }
+ });
+ });
+ </script>
+ [% UNLESS ( grouped ) %]
+ <script>
+ function confirm_reopen() {
+ var skip = [% IF ( skip_confirm_reopen ) %] 1 [% ELSE %] 0 [% END %];
+ var is_confirmed = skip || confirm(_("Are you sure you want to reopen this basket?"));
+ if (is_confirmed) {
+ window.location = "/cgi-bin/koha/acqui/basket.pl?op=reopen&basketno=[% basketno | html %]";
+ }
+ }
+ </script>
+ [% END %]
+ [% END %]
+ <script>
+ $(document).ready(function() {
+ var orderst = $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "sPaginationType": "four_button",
+ [% IF ( active ) %]
+ "aoColumnDefs": [
+ [% UNLESS ( closedate ) %]
+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
+ [% END %]
+ { "sType": "anti-the", "aTargets": [ "anti-the" ] }
+ ],
+ [% END %]
+ } ) );
+ var cancelledorderst = $("#cancelledorderst").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "sPaginationType": "four_button"
+ } ) );
+ $("#reopenbutton").on("click",function(e){
+ e.preventDefault();
+ confirm_reopen();
+ });
+ // Generates a dynamic link for exporting the selections data as CSV
+ $("#exportbutton, #export-csv-menu a").click(function() {
+ // Building the url from currently checked boxes
+ var url = '/cgi-bin/koha/acqui/basket.pl';
+ url += $('#exportbutton').attr('href');
+ if($(this).attr("data-value")) {
+ url += '&csv_profile=' + $(this).attr("data-value");
+ }
+ // And redirecting to the CSV page
+ location.href = url;
+ return false;
+ });
+ $("#select_managing_library").on("change", function(){
+ $(this).parent().submit();
+ });
+ });
+
+ function UserSearchPopup(f) {
+ window.open(
+ "/cgi-bin/koha/acqui/add_user_search.pl",
+ 'UserSearchPopup',
+ 'width=840, height=500, scrollbars=yes, toolbar=no,'
+ );
+ }
+
+ function add_user(borrowernumber, borrowername) {
+ var ids = $("#users_ids").val();
+ if(ids.length > 0) {
+ ids = ids.split(':');
+ } else {
+ ids = new Array;
+ }
+ if (ids.indexOf(borrowernumber.toString()) < 0) {
+ ids.push(borrowernumber);
+ $("#users_ids").val(ids.join(':'));
+ var li = '<li id="user_'+borrowernumber+'">'+borrowername
+ + ' <a href="#" data-borrowernumber="'+borrowernumber+'" class="del_user"><i class="fa fa-trash"></i> '
+ + _("Delete user") + '</a></li>';
+ $("#users_names").prepend(li);
+ $("#add_user_submit").show();
+ return 0;
+ }
+ return -1;
+ }
+
+ function del_user(borrowernumber) {
+ $("#user_"+borrowernumber).remove();
+ var ids = $("#users_ids").val().split(':');
+ ids.splice(ids.indexOf(borrowernumber.toString()), 1);
+ $("#users_ids").val(ids.join(':'));
+ $("#add_user_submit").show();
+ }
+ </script>
+[% END %]
+