Subversion Repositories SmartDukaan

Rev

Rev 26518 | Rev 27755 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {

        $(".wallet-edit").live('click', function() {
                loadManualPayment("main-content");
        });

        $(".referenceSearch").live(
                        'click',
                        function() {
                                var reference = $('#reference_id').val();
                                var type = $('#reference-type option:selected').html();

                                if (type == "" || type == null || type == undefined) {
                                        alert("Please Choose Reference Type");
                                        return false;
                                }

                                doGetAjaxRequestHandler(context
                                                + "/getWalletHistory?reference=" + reference
                                                + "&referenceType=" + type, function(response) {
                                        
                                        
                                        doGetAjaxRequestHandler(context + "/getPartnerName?reference="
                                                        + reference + "&referenceType=" + type, function(
                                                        response) {
                                                response=JSON.parse(response);
                                                console.log(response.businessName+ "-" + response.address.city)
                           $("#FofoId").val(response.businessName+ "-" + response.address.city);
                                                currentFofoId=response.partnerId;
                                        });
                                        $('.wallet-history-container').html(response);
                                });

                                

                        });
        
        $(".fetchTransactions").live('click', function() {
                var type = $('#reference-type option:selected').html();
                if($('#reference-type option:selected').val()=="") {
                        type = "";
                }
                                doGetAjaxRequestHandler(context
                                                + "/getWalletHistoryByPartner?referenceType="+type+"&fofoId=" + currentFofoId, function(response) {
                        $('.wallet-history-container').html(response);
                        $("#wallet-form")[0].reset();
                });
        });

        $(".transactionSubmit").live(
                        'click',
                        function() {
                                var reference = $('#reference_id').val();
                                var typeValue = $('#reference-type option:selected').val();
                                var transactiontype = $('#transaction-type').val();
                                var amount = $('#amount').val();
                                var description = $('#description').val();
                                var retailerId = currentFofoId
                                console.log(currentFofoId)
                                console.log(typeValue);
                                if (typeValue == "") {
                                        alert("Please Choose Reference Type");
                                        return;
                                }
                                if(typeValue < 16){
                                        if(reference == ""){
                                                alert("Reference Id is required");
                                                return;
                                        }
                                }
                                
                                if (transactiontype == "") {
                                        alert("Please Choose Transaction Type");
                                        return;
                                }
                                if (amount == "") {
                                        alert("amount is required");
                                        return;
                                }

                                if (description == "") {
                                        alert("description is required");
                                        return;
                                }
                                if (retailerId == "") {
                                        alert("Partner name is required");
                                        return;
                                }
                                if (typeof startDate == "string") {
                                        if (confirm("Business Date is " + startDate.split("T")[0] + "?") == true) {
                                                if (confirm("Are you sure you want update wallet") == true) {
        
                                                        doPostAjaxRequestHandler(context
                                                                        + "/walletUpdate?reference=" + reference
                                                                        + "&referenceTypeValue=" + typeValue + "&transactiontype="
                                                                        + transactiontype + "&amount=" + amount
                                                                        + "&description=" + description + "&retailerId="
                                                                        + currentFofoId +"&businessTimestamp=" + startDate, function(response) {
                                                                if (response != 0) {
                                                                        alert("successfully submit");
                                                                        console.log(response)
                                                                        $("#reference_id").val(response);
                                                                //      $("button.referenceSearch").click();
                                                                        $("button.fetchTransactions").click();
                                                                }else{
                                                                        alert("failed transaction")
                                                                }
                                                                
                                                        });
                                                }
                                        }
                                } else {
                                        alert("Valid date is required");
                                }

                        });

});
function loadManualPayment(domId) {
        doGetAjaxRequestHandler(context + "/manualPayment", function(response) {
                $('#' + domId).html(response);
        });
}