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

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js (-93 / +58 lines)
Lines 721-753 function fetchSortDropbox(f) { Link Here
721
721
722
for (i=1;i<=2;i++) {
722
for (i=1;i<=2;i++) {
723
723
724
    var sort_zone = document.getElementById('sort'+i+'_zone');
724
    var $sort_zone = jQuery('#sort'+i+'_zone');
725
    var url = '../acqui/fetch_sort_dropbox.pl?sort='+i+'&budget_id='+budgetId;
725
    var url = '../acqui/fetch_sort_dropbox.pl?sort='+i+'&budget_id='+budgetId;
726
726
727
    var xmlhttp = null;
727
    jQuery.ajax({
728
    xmlhttp = new XMLHttpRequest();
728
        url: url,
729
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
729
        mimeType: 'text/xml',
730
        xmlhttp.overrideMimeType('text/xml');
730
        success: function (data, textStatus, xmlhttp) {
731
    }
731
            // rc =  eval ( xmlhttp.responseText );
732
732
            var retRootType = jQuery(xmlhttp.responseXML).children().first().get(0).nodeName.toLowerCase();
733
    xmlhttp.open('GET', url, false);
733
            var hasInputs = $sort_zone.has('input').length > 0;
734
    xmlhttp.send(null);
734
            if (hasInputs && retRootType == 'input') {
735
735
                // when sort is already an input, do not override to preseve value
736
    xmlhttp.onreadystatechange = function() {
736
                return;
737
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
737
            }
738
    // stupid JS...
738
            $sort_zone.html(xmlhttp.responseText);
739
        } else {
740
    // wait for the call to complete
741
        }
739
        }
742
    };
740
    });
743
    // rc =  eval ( xmlhttp.responseText );
744
    var retRootType = xmlhttp.responseXML.firstChild.nodeName;
745
    var existingInputs = sort_zone.getElementsByTagName('input');
746
    if (existingInputs.length > 0 && retRootType == 'input') {
747
        // when sort is already an input, do not override to preseve value
748
        return;
749
    }
750
    sort_zone.innerHTML = xmlhttp.responseText;
751
}
741
}
752
}
742
}
753
743
Lines 760-788 for (i=1;i<=2;i++) { Link Here
760
//USED BY NEWORDEREMPTY.PL
750
//USED BY NEWORDEREMPTY.PL
761
function totalExceedsBudget(budgetId, total) {
751
function totalExceedsBudget(budgetId, total) {
762
752
763
    var xmlhttp = null;
764
    xmlhttp = new XMLHttpRequest();
765
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
766
        xmlhttp.overrideMimeType('text/xml');
767
    }
768
769
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
753
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
770
    xmlhttp.open('GET', url, false);
754
    var ret = undefined;
771
    xmlhttp.send(null);
755
    jQuery.ajax({
772
756
        url: url,
773
    xmlhttp.onreadystatechange = function() {
757
        mimeType: 'text/xml',
774
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
758
        async: false, // non-async because we need to return a value based on the result
775
759
        success: function(data, textStatus, xmlhttp) {
776
            actTotal = eval ( xmlhttp.responseText );
760
            actTotal = eval ( xmlhttp.responseText );
777
761
778
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
762
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
779
            // if budget is to low :(
763
            // if budget is to low :(
780
                return true ;
764
                ret = true ;
781
            } else {
765
            } else {
782
                return false;
766
                ret = false;
783
            }
767
            }
784
        }
768
        }
785
    }
769
    });
770
    return ret;
786
}
771
}
787
772
788
773
Lines 790-831 function totalExceedsBudget(budgetId, total) { Link Here
790
function budgetExceedsParent(budgetTotal, budgetId, newBudgetParent, periodID) {
775
function budgetExceedsParent(budgetTotal, budgetId, newBudgetParent, periodID) {
791
776
792
777
793
    var xmlhttp = null;
794
    xmlhttp = new XMLHttpRequest();
795
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
796
        xmlhttp.overrideMimeType('text/xml');
797
    }
798
799
// make the call... yawn
778
// make the call... yawn
800
//    var url = '../admin/check_parent_total.pl?budget_id=' + budgetId +   '&parent_id=' + newBudgetParent  + "&total=" + budgetTotal + "&period_id="+ periodID   ;
779
//    var url = '../admin/check_parent_total.pl?budget_id=' + budgetId +   '&parent_id=' + newBudgetParent  + "&total=" + budgetTotal + "&period_id="+ periodID   ;
801
780
802
781
803
    var url = '../admin/check_parent_total.pl?total=' + budgetTotal + "&period_id="+ periodID   ;
782
    var url = '../admin/check_parent_total.pl?total=' + budgetTotal + "&period_id="+ periodID   ;
804
805
if (budgetId ) { url +=  '&budget_id=' + budgetId };
783
if (budgetId ) { url +=  '&budget_id=' + budgetId };
806
if ( newBudgetParent  ) { url +=  '&parent_id=' + newBudgetParent};
784
if ( newBudgetParent  ) { url +=  '&parent_id=' + newBudgetParent};
807
785
    var ret = undefined;
808
786
    jQuery.ajax({
809
    xmlhttp.open('GET', url, false);
787
        url: url,
810
    xmlhttp.send(null);
788
        mimeType: 'text/xml',
811
789
        async: false, // non-async because we need to return a value based on the result
812
    xmlhttp.onreadystatechange = function() {
790
        success: function(data, textStatus, xmlhttp) {
813
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
791
            var result = eval ( xmlhttp.responseText );
814
    // stupid JS...
792
815
        } else {
793
            if (result == '1') {
816
    // wait for the call to complete
794
                    ret = _("- Budget total exceeds parent allocation\n");
795
            } else if (result == '2') {
796
                    ret = _("- Budget total exceeds period allocation\n");
797
            } else  {
798
                    ret = false;
799
            }
817
        }
800
        }
818
    };
801
    });
819
802
    return ret;
820
    var result = eval ( xmlhttp.responseText );
821
822
    if (result == '1') {
823
            return _("- Budget total exceeds parent allocation\n");
824
    } else if (result == '2') {
825
            return _("- Budget total exceeds period allocation\n");
826
    } else  {
827
            return false;
828
    }
829
}
803
}
830
804
831
805
Lines 833-865 if ( newBudgetParent ) { url += '&parent_id=' + newBudgetParent}; Link Here
833
807
834
//USED BY AQBUDGETS.TMPL
808
//USED BY AQBUDGETS.TMPL
835
function checkBudgetParent(budgetId, newBudgetParent) {
809
function checkBudgetParent(budgetId, newBudgetParent) {
836
    var xmlhttp = null;
837
    xmlhttp = new XMLHttpRequest();
838
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
839
        xmlhttp.overrideMimeType('text/xml');
840
    }
841
842
    var url = '../admin/check_budget_parent.pl?budget_id=' + budgetId + '&new_parent=' + newBudgetParent;
810
    var url = '../admin/check_budget_parent.pl?budget_id=' + budgetId + '&new_parent=' + newBudgetParent;
843
    xmlhttp.open('GET', url, false);
811
    var ret = undefined;
844
    xmlhttp.send(null);
812
    jQuery.ajax({
845
813
        url: url,
846
    xmlhttp.onreadystatechange = function() {
814
        mimeType: 'text/xml',
847
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
815
        async: false, // non-async because we need to return a value based on the result
848
    // do something with the results
816
        success: function(data, textStatus, xmlhttp) {
849
        } else {
817
            var result = eval ( xmlhttp.responseText );
850
    // wait for the call to complete
818
819
            if (result == '1') {
820
                    return _("- New budget-parent is beneath budget\n");
821
//            } else if (result == '2') {
822
//                    return "- New budget-parent has insufficent funds\n";
823
//            } else  {
824
//                    return false;
825
            }
851
        }
826
        }
852
    };
827
    });
853
828
    return ret;
854
    var result = eval ( xmlhttp.responseText );
855
856
    if (result == '1') {
857
            return _("- New budget-parent is beneath budget\n");
858
//     } else if (result == '2') {
859
//            return "- New budget-parent has insufficent funds\n";
860
//     } else  {
861
//              return false;
862
    }
863
}
829
}
864
830
865
831
866
- 

Return to bug 4437