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

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js (-24 / +14 lines)
Lines 776-805 for (i=1;i<=2;i++) { Link Here
776
776
777
//USED BY NEWORDEREMPTY.PL
777
//USED BY NEWORDEREMPTY.PL
778
function totalExceedsBudget(budgetId, total) {
778
function totalExceedsBudget(budgetId, total) {
779
779
    budgetTotal = 0;
780
    var xmlhttp = null;
780
    $.ajax({
781
    xmlhttp = new XMLHttpRequest();
781
        url: "../acqui/check_budget_total.pl",
782
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
782
        async:false,
783
        xmlhttp.overrideMimeType('text/xml');
783
        method: "post",
784
    }
784
        data: {budget_id : budgetId, total : total},
785
785
        success: function(actTotal) {
786
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
786
            actTotal = Math.abs(actTotal);
787
    xmlhttp.open('GET', url, false);
787
            exceeds = (actTotal < Math.abs(total));
788
    xmlhttp.send(null);
788
            if (exceeds)
789
789
                budgetTotal = actTotal;
790
    xmlhttp.onreadystatechange = function() {
790
         }
791
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
791
    });
792
792
    return budgetTotal;
793
            actTotal = eval ( xmlhttp.responseText );
794
795
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
796
            // if budget is to low :(
797
                return true ;
798
            } else {
799
                return false;
800
            }
801
        }
802
    }
803
}
793
}
804
794
805
795
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-7 / +8 lines)
Lines 56-67 function Check(ff) { Link Here
56
                    _alertString += "\n- " + _("Total must be a number");
56
                    _alertString += "\n- " + _("Total must be a number");
57
    }
57
    }
58
58
59
    if (totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
60
        ok=1;
61
        _alertString += "\n- " + _("Order total (") + ff.total.value +
62
            _(") exceeds budget available (") + actTotal+")";
63
    }
64
65
    if ( ff.field_value ) {
59
    if ( ff.field_value ) {
66
        var empty_item_mandatory = 0;
60
        var empty_item_mandatory = 0;
67
        for (i = 0; i < ff.field_value.length; i++) {
61
        for (i = 0; i < ff.field_value.length; i++) {
Lines 87-92 function Check(ff) { Link Here
87
        [% END %]
81
        [% END %]
88
        return false;
82
        return false;
89
    }
83
    }
84
    else {
85
        if (actTotal = totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
86
            stringWarning = _("Order total (") + ff.total.value +
87
                _(") exceeds budget available (") + actTotal+")\n";
88
            stringWarning += _("Are you sure you want do save this order?");
89
            return confirm(stringWarning);
90
        }
91
    }
90
92
91
    [% IF (AcqCreateItemOrdering) %]
93
    [% IF (AcqCreateItemOrdering) %]
92
        if(check_additem('[% UniqueItemFields %]') == false) {
94
        if(check_additem('[% UniqueItemFields %]') == false) {
93
- 

Return to bug 6832