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 (-11 / +14 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 empty_item_mandatory = 0;
43
        var empty_item_mandatory = 0;
50
        for (i = 0; i < ff.field_value.length; i++) {
44
        for (i = 0; i < ff.field_value.length; i++) {
Lines 60-72 function Check(ff) { Link Here
60
        }
54
        }
61
    }
55
    }
62
56
63
if (ok) {
57
    if (ok) {
64
        alert(_alertString);
58
        alert(_alertString);
65
    return false;
59
        return false;
60
    }
61
    else {
62
        if (actTotal = totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
63
            stringWarning = _("Order total (") + ff.total.value +
64
                _(") exceeds budget available (") + actTotal+")\n";
65
            stringWarning += _("Are you sure you want do save this order?");
66
            var r=confirm(stringWarning);
67
            if (! r){
68
                return false;
69
            }
70
        }
66
    }
71
    }
67
72
68
ff.submit();
73
    ff.submit();
69
70
}
74
}
71
75
72
$(document).ready(function() 
76
$(document).ready(function() 
73
- 

Return to bug 6832