Subversion Repositories SmartDukaan

Rev

Rev 36198 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36198 Rev 37037
Line 854... Line 854...
854
        return;
854
        return;
855
    }
855
    }
856
    window.location.href = `${context}/credit-note/download-all?yearMonth=${selectedDate}`;
856
    window.location.href = `${context}/credit-note/download-all?yearMonth=${selectedDate}`;
857
});
857
});
858
 
858
 
-
 
859
$(document).on('click', '.order-report', function () {
-
 
860
    doGetAjaxRequestHandler(context + "/orderReport",
-
 
861
        function (response) {
-
 
862
            $('#' + 'main-content').html(response);
-
 
863
        });
-
 
864
});
-
 
865
 
-
 
866
$(document).on('click', '.download-order-report', function () {
-
 
867
    var startDate = $("#startDate-order-report").val();
-
 
868
    var endDate = $("#endDate-order-report").val();
-
 
869
 
-
 
870
    if (startDate == "" || startDate == undefined) {
-
 
871
        alert("start date must not be empty!!");
-
 
872
        return;
-
 
873
    }
-
 
874
    if (endDate == "" || endDate == undefined) {
-
 
875
        alert("end date must not be empty!!");
-
 
876
        return;
-
 
877
    }
-
 
878
 
-
 
879
    var start = new Date(startDate);
-
 
880
    var end = new Date(endDate);
-
 
881
    if (end < start) {
-
 
882
        alert("End date cannot be before start date!!");
-
 
883
        return;
-
 
884
    }
-
 
885
 
-
 
886
    // Period not more than a month: end <= start + 1 calendar month
-
 
887
    var maxEnd = new Date(start);
-
 
888
    maxEnd.setMonth(maxEnd.getMonth() + 1);
-
 
889
    if (end > maxEnd) {
-
 
890
        alert("Please select a period of at most one month.");
-
 
891
        return;
-
 
892
    }
-
 
893
 
-
 
894
    var endPoint = `${context}/downloadOrderReport?startDate=${startDate}&endDate=${endDate}`;
-
 
895
    // Empty partner search => no fofoId => all partners (admin only; server ignores it for non-admins).
-
 
896
    if (typeof partnerId != "undefined" && partnerId !== null && partnerId !== "") {
-
 
897
        endPoint = `${endPoint}&fofoId=${partnerId}`;
-
 
898
    }
-
 
899
    window.location.href = endPoint;
-
 
900
});
-
 
901