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 783-812 for (i=1;i<=2;i++) { Link Here
783
783
784
//USED BY NEWORDEREMPTY.PL
784
//USED BY NEWORDEREMPTY.PL
785
function totalExceedsBudget(budgetId, total) {
785
function totalExceedsBudget(budgetId, total) {
786
786
    budgetTotal = 0;
787
    var xmlhttp = null;
787
    $.ajax({
788
    xmlhttp = new XMLHttpRequest();
788
        url: "../acqui/check_budget_total.pl",
789
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
789
        async:false,
790
        xmlhttp.overrideMimeType('text/xml');
790
        method: "post",
791
    }
791
        data: {budget_id : budgetId, total : total},
792
792
        success: function(actTotal) {
793
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
793
            actTotal = Math.abs(actTotal);
794
    xmlhttp.open('GET', url, false);
794
            exceeds = (actTotal < Math.abs(total));
795
    xmlhttp.send(null);
795
            if (exceeds)
796
796
                budgetTotal = actTotal;
797
    xmlhttp.onreadystatechange = function() {
797
         }
798
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
798
    });
799
799
    return budgetTotal;
800
            actTotal = eval ( xmlhttp.responseText );
801
802
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
803
            // if budget is to low :(
804
                return true ;
805
            } else {
806
                return false;
807
            }
808
        }
809
    }
810
}
800
}
811
801
812
802
(-)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