Subversion Repositories SmartDukaan

Rev

Rev 9829 | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {
        $(function() {
                transferLotTable = $('#transfer-lots-table').dataTable({
                        "sPaginationType": "full_numbers",
            "aaSorting" : [ [ 4, 'asc' ] ],
            "bAutoWidth": true,
            "iDisplayLength" : 50,
            "sDom" : 'T<"clear">lfrtip',
            "oTableTools" : {
                "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
            },
        });
        });
        
        /*$('#transfer-lot-receive-button').live('click', function() {
                var transferLotId = $(this).attr('transferLotId');
                $('#transfer-lot-updation-box').show();
                $('#update-transfer-lot').attr('transferLotId',transferLotId);
                $.colorbox({
                        inline : true,
                width : "325px",
                height : "125px",
                opacity : "0.30",
                overlayClose :  true,
                escKey :        true,
                href : "#transfer-lot-updation-box",
                onClosed : function() {
                    $("#transfer-lot-updation-box").hide();
                    $('#update-transfer-lot').removeAttr('transferLotId');
                }
                });
        });*/
        
        $("#transfer-lot-item-receive-button").live('click', function() {
                var transferLotId = $(this).attr('transferLotId');
                $("#optionMultipleSelect").find("option").remove();
                $('#optionMultipleSelect').multiselect( 'refresh' );
                $('#markReceiveTransferLotItem').attr('transferLotId',transferLotId);
                $('#transfer-lot-reference-number-item').val('');
                $.ajax({
                        type : "GET",
                        url : "/inventory/transfer-lot!getTransferLotItemsForMarkReceive",
                        data      : "id="+transferLotId,
                        dataType  : 'json',
                        success : function(reply) {
                                $.each(reply.TransferLotItemData, function(i,obj) {
                                        var status = obj.ItemStatus;
                                        if(status=="Disabled"){
                                                $('#optionMultipleSelect').append($("<option></option>").val(obj.ItemId).html(obj.ItemDetail).attr("disabled",true));
                                                //$('#optionMultipleSelect').multiselect( 'refresh' );
                                        }
                                        else{
                                                $('#optionMultipleSelect').append($("<option></option>").val(obj.ItemId).html(obj.ItemDetail).attr("disabled",false));
                                                //$('#optionMultipleSelect').multiselect( 'refresh' );
                                        }
                                });
                                $('#optionMultipleSelect').multiselect( 'refresh' );
                        },
                        error : function(response) {
                                alert("Error in fetching Transfer Lot Items");
                        }
                });
                $("div#transferLotItemsDataDiv").show();
                /*$.colorbox({
                        inline : true,
                width : "700px",
                height : "400px",
                overlayClose :  true,
                escKey :        true,
                href : "div#transferLotItemsDataDiv",
                onClosed : function() {
                        $("div#transferLotItemsDataDiv").hide();
                }
                });*/
                
        });
        
        $('#cancelReceiveTransferLotItem').live('click',function(){
                $("div#transferLotItemsDataDiv").hide();
        });     
        
        $('#markReceiveTransferLotItem').live('click', function () {
                var receiveType = $("#transferLotReceiveType").val();
                if(receiveType=="partial"){
                        var selectedLength = $('#optionMultipleSelect :selected').length;
                        
                        if(selectedLength==0){
                                alert("Please Select option(s) to Mark as Transfer Receive");
                                return false;
                        }
                }
                var refNumber = $('#transfer-lot-reference-number-item').val();
                if(refNumber=="" || refNumber.length ==0 ){
                        alert("Please Enter Transfer Lot Reference Number");
                        return false;
                }
                $.ajax({
                        type : "POST",
                        url : "/inventory/transfer-lot!markTransferLotAsReceivedPartial",
                        data : "id="+$(this).attr('transferLotId')+"&remoteTransferRefNumber="+$('#transfer-lot-reference-number-item').val()+"&inventoryItemsString="+$('#optionMultipleSelect').val()+"&inventoryItemsLength="+$('#optionMultipleSelect :selected').length+"&transferLotReceiveType="+$("#transferLotReceiveType").val(),
                        success : function(response) {
                                alert("Successfully marked Transfer Lot as Recieved");
                                $("div#transferLotItemsDataDiv").hide();
                                location.reload();
                        },
                        error : function(response) {
                                alert("Error in marking Transfer Lot as Recieved");
                        }
                        
                });
        });
        
        $("#transferLotReceiveType").change(function () {
                var receiveType = $("#transferLotReceiveType").val();
                if(receiveType=="partial"){
                        $("#optionMultipleSelect").multiselect("refresh");
                        $("#optionMultipleSelect").multiselect("uncheckAll");
                        $("#optionMultipleSelect").multiselect("enable");
                }
                else{
                        $("#optionMultipleSelect").multiselect("checkAll");
                        $("#optionMultipleSelect").multiselect("disable");
                }
        });
        
        $('#transfer-lot-receive-button').live('click', function() {
                var transferLotId = $(this).attr('transferLotId');
                $('#transfer-lot-updation-box').show();
                $('#update-transfer-lot').attr('transferLotId',transferLotId);
                $.colorbox({
                        inline : true,
                width : "325px",
                height : "125px",
                opacity : "0.30",
                overlayClose :  true,
                escKey :        true,
                href : "#transfer-lot-updation-box",
                onClosed : function() {
                    $("#transfer-lot-updation-box").hide();
                    $('#update-transfer-lot').removeAttr('transferLotId');
                }
                });
        });
        
        
        $('#update-transfer-lot').live('click', function () {
                $.ajax({
                        type : "POST",
                        url : "/inventory/transfer-lot!markTransferLotAsReceived",
                        data : "id="+$(this).attr('transferLotId')+"&remoteTransferRefNumber="+$('#transfer-lot-reference-number').val(),
                        success : function(response) {
                                alert("Successfully marked Transfer Lot as Recieved");
                        },
                        error : function(response) {
                                alert("Error in marking Transfer Lot as Recieved");
                        }
                        
                });
        });
        /*$.ajax({
                type : "POST",
        url : "/inventory/transfer-lot!markTransferred",
        param : "id="+id+"&remoteTransferRefNumber=dummy",
        success : function(response) {
                alert("Marked inventory lot as recieved");
        }
                error : function(response) {
                alert("Failed to mark inventory lot as received");
        } 
        });*/
        $('#show-transfer-lot-items').live('click', function() {
                $.ajax({
                        type : "GET",
                        url : "/inventory/transfer-lot!getTransferLotItems?id="+$(this).attr('transferLotId'),
                        success : function(response) {
                                $.colorbox({
                                        inline : true,
                                width : "400px",
                                height : "500px",
                                opacity : "0.30",
                                overlayClose :  true,
                                escKey :        true,
                                href : $(response),
                                onClosed : function() {
                                    //TODO
                                }
                                });
                        },
                        error : function(response) {
                                alert("Error in fetching Transfer Lot Items");
                        }
                });
        });
        $('#add-transfer-lineitem').live('click', function(){
                /*var transfer-lot-line-item = '<tr ><td ><input type="text" class="itemId" name="" onkeypress="return disableEnterKey(event)" /></td>'+
                        '<td ><input class="itemNumber" type="text" tabindex="$tabIndex" onkeypress="return disableEnterKey(event)"/></td>'+
            '<td ><input class="serialNumber" type="text" tabindex="$tabIndex" onkeypress="return disableEnterKey(event)"/></td>'+
            '<td ><input class="quantity" type="text" value="1" onkeypress="return disableEnterKey(event)"/></td></tr>';*/
//              $(transfer-lot-line-item).appendTo('#transfer-items-body')
                $('<tr ><td ><input type="text" class="itemId" name="" onkeypress="return disableEnterKey(event)" /></td>'+
                                '<td ><input class="itemNumber" type="text" tabindex="$tabIndex" onkeypress="return disableEnterKey(event)"/></td>'+
                    '<td ><input class="serialNumber" type="text" tabindex="$tabIndex" onkeypress="return disableEnterKey(event)"/></td>'+
                    '<td ><input class="quantity" type="text" value="1" onkeypress="return disableEnterKey(event)"/></td></tr>').appendTo('#transfer-items-body')
        });

        
});