Subversion Repositories SmartDukaan

Rev

Rev 10864 | Rev 16411 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {
        $('#add-nonserialized-return').live('click', function(){
                $('<br/><label>ItemId : </label><input class = "return-itemId" name = "returnItemId" type = "textbox"/>'
                                +'<label>Quantity : </label><input class = "return-qty" name = "returnQty" type = "textbox"/>').appendTo('#nonserialized-items-container');
        });
        
        $('#add-serialized-return').live('click', function(){
                $('<br/><label>IMEI Number : </label><input class = "imei-number" name = "returnImeiNumber" type = "textbox"/>').appendTo('#serialized-items-container')
        });
        
        $('.settlePurchaseReturn').live('click', function(){
                purchaseReturnId = $(this).attr('id');
                $.ajax({
                type : "GET",
                url : "/inventory/purchase-return!markSettled?purchaseReturnId="+purchaseReturnId,
                success : function(response) {
                    alert("Purchase Return Settled");
                    document.location.reload(true);
                }
            });
        });
        
        $('.detailPurchaseReturn').live('click', function(){
                purchaseReturnId = $(this).attr('id');
                $.ajax({
                type : "GET",
                url : "/inventory/purchase-return!getItemDetailsForPurchaseReturn?purchaseReturnId="+purchaseReturnId,
                success : function(response) {
                        $.colorbox({
                                        inline : true,
                                width : "500px",
                                height : "500px",
                                opacity : "0.20",
                                overlayClose :  true,
                                escKey :        true,
                                href : $(response),
                                onClosed : function() {
                                    //TODO
                                }
                                });
                },
                error : function(response) {
                                alert("Error in fetching Purchase Return Items");
                        }                       
            });
        });
        
        $('#create-purchase-return').live('submit', function() {
                createPurchaseReturnJS($(this).serialize());
        return false;
        });
        
        $(function() {
                purchaseReturn = $('#purchase-return-table').dataTable({
                        "sPaginationType": "full_numbers",
            "aaSorting" : [ [ 1, 'desc' ] ],
            "bAutoWidth": true,
            "iDisplayLength" : 25,
            "sDom" : 'T<"clear">lfrtip',
            "oTableTools" : {
                "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
            },
        });
        });
});


function createPurchaseReturnJS(params){
        $.ajax({
        type : 'POST',
        url : '/inventory/purchase-return!createPurchaseReturn',
        data      : params,
        success : function(response) {
                alert(response);
                document.location.href = '/inventory/purchase-return' ;
        },
        error : function() {
                alert('Some Error occurred at Server End');
                document.location.href = '/inventory/purchase-return';
        }
    });
}