View | Details | Raw Unified | Return to bug 6832
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js (-23 / +13 lines)
Lines 780-809 for (i=1;i<=2;i++) { Link Here
780
780
781
//USED BY NEWORDEREMPTY.PL
781
//USED BY NEWORDEREMPTY.PL
782
function totalExceedsBudget(budgetId, total) {
782
function totalExceedsBudget(budgetId, total) {
783
783
    budgetTotal = 0;
784
    var xmlhttp = null;
784
    $.ajax({
785
    xmlhttp = new XMLHttpRequest();
785
        url: "/cgi-bin/koha/acqui/check_budget_total.pl",
786
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
786
        async:false,
787
        xmlhttp.overrideMimeType('text/xml');
787
        method: "post",
788
    }
788
        data: {budget_id : budgetId, total : total},
789
789
        success: function(actTotal) {
790
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
790
            actTotal = Math.abs(actTotal);
791
    xmlhttp.open('GET', url, false);
791
            exceeds = (actTotal < Math.abs(total))
792
    xmlhttp.send(null);
792
            if (exceeds)
793
793
                budgetTotal = actTotal;
794
    xmlhttp.onreadystatechange = function() {
795
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
796
797
            actTotal = eval ( xmlhttp.responseText );
798
799
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
800
            // if budget is to low :(
801
                return true ;
802
            } else {
803
                return false;
804
            }
805
        }
794
        }
806
    }
795
    });
796
    return budgetTotal;
807
}
797
}
808
798
809
799
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-8 / +11 lines)
Lines 39-50 function Check(ff) { Link Here
39
                    _alertString += "\n- " + _("Total must be a number");
39
                    _alertString += "\n- " + _("Total must be a number");
40
    }
40
    }
41
41
42
    if (totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
43
        ok=1;
44
        _alertString += "\n- " + _("Order total (") + ff.total.value +
45
            _(") exceeds budget available (") + actTotal+")";
46
    }
47
48
    if ( ff.field_value ) {
42
    if ( ff.field_value ) {
49
        var barcodes = [];
43
        var barcodes = [];
50
        var empty_item_mandatory = 0;
44
        var empty_item_mandatory = 0;
Lines 106-114 function Check(ff) { Link Here
106
        alert(_alertString);
100
        alert(_alertString);
107
        return false;
101
        return false;
108
    }
102
    }
103
    else {
104
        if (actTotal = totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
105
            stringWarning = _("Order total (") + ff.total.value +
106
                _(") exceeds budget available (") + actTotal+")\n";
107
            stringWarning += _("Are you sure you want do save this order?");
108
            var r=confirm(stringWarning);
109
            if (! r){
110
                return false;
111
            }
112
        }
113
    }
109
114
110
    ff.submit();
115
    ff.submit();
111
112
}
116
}
113
117
114
$(document).ready(function() 
118
$(document).ready(function() 
115
- 

Return to bug 6832