1 /* global KOHA searchid biblionumber frameworkcode popup op LABEL_EDIT_ITEM LABEL_DELETE_ITEM MSG_FORM_NOT_SUBMITTED MSG_MANDATORY_FIELDS_EMPTY MSG_ADD_MULTIPLE_ITEMS MSG_ENTER_NUM_ITEMS MSG_CONFIRM_DELETE_ITEM MSG_CONFIRM_ADD_ITEM columns_settings CheckMandatorySubfields CheckMultipleAdd */
3 var browser = KOHA.browser(searchid, parseInt(biblionumber, 10));
6 $(document).ready(function(){
8 // Remove the onclick event defined in browser.js,
9 // otherwise the deletion confirmation will not work correctly
10 $('a[href*="biblionumber="]').off('click');
12 if( popup && op != 'saveitem' ){
16 $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
17 /* Inline edit/delete links */
18 var biblionumber = $("input[name='biblionumber']").attr("value");
19 $("tr.editable").each(function(){
20 $(this).find("td:not(:first)").on('click', function(){
21 var rowid = $(this).parent().attr("id");
22 var num_rowid = rowid.replace("row","");
23 $(".linktools").remove();
24 var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '#edititem"></a>');
25 $(edit_link).text( LABEL_EDIT_ITEM );
26 var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '"></a>');
27 $(delete_link).text( LABEL_DELETE_ITEM );
28 $(delete_link).on('click', function() {
29 return confirm_deletion();
31 var tools_node = $('<span class="linktools"></span>');
32 $(tools_node).append(edit_link);
33 $(tools_node).append(delete_link);
34 $(this).append(tools_node);
38 $("#addnewitem").click(function(){
39 if ( confirm( MSG_CONFIRM_ADD_ITEM ) ){
40 window.location.href = "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=" + biblionumber;
44 // Skip the first column
45 columns_settings.unshift( { cannot_be_toggled: "1" } );
47 var itemst = KohaTable("itemst", {
51 "bKohaColumnsUseNames": true
54 var multiCopyControl = $("#add_multiple_copies_span");
55 var addMultipleBlock = $("#addmultiple");
56 var addSingleBlock = $("#addsingle");
57 multiCopyControl.hide();
58 $("#add_multiple_copies").on("click",function(e){
60 addMultipleBlock.toggle();
61 addSingleBlock.toggle();
62 multiCopyControl.toggle();
63 $('body,html').animate({ scrollTop: $('body').height() }, 100);
65 $("#cancel_add_multiple").on("click",function(e){
67 addMultipleBlock.toggle();
68 addSingleBlock.toggle();
69 multiCopyControl.toggle();
75 var total_mandatory = CheckMandatorySubfields(f);
76 var total_important = CheckImportantSubfields(f);
78 if (total_mandatory==0) {
79 // Explanation about this line:
80 // In case of limited edition permission, we have to prevent user from modifying some fields.
81 // But there is no such thing as readonly attribute for select elements.
82 // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
83 // So we "un-disable" the elements just before submitting.
84 // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
85 $("select[name=field_value]").prop('disabled', false);
87 alertString2 = MSG_FORM_NOT_SUBMITTED;
88 alertString2 += "\n------------------------------------------------------------------------------------\n";
89 alertString2 += "\n- " + "%s " + MSG_MANDATORY_FIELDS_EMPTY.format(total_mandatory);
91 if(total_important > 0){
95 alertString2 += "\n\n " + MSG_IMPORTANT_FIELDS_EMPTY.format(total_important);
96 alertString2 += "\n\n " + MSG_CONFIRM_SAVE;
102 var a = confirm(alertString2);
112 function CheckMultipleAdd(f) {
114 if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
115 alert( MSG_ENTER_NUM_ITEMS );
118 // Add a soft-limit of 99 with a reminder about potential data entry error
120 return confirm( MSG_ADD_MULTIPLE_ITEMS.format(f));
124 function Dopop(link,i) {
125 var defaultvalue=document.forms[0].field_value[i].value;
126 var newin=window.open(link+"&result=" + defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
129 function confirm_deletion() {
130 return confirm( MSG_CONFIRM_DELETE_ITEM );