Subversion Repositories SmartDukaan

Rev

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

$(function() {
    $('input#add-lineitem').live('click', function() {
        addNewRowForLineItem($(this).parent().parent().children('table.lineitems'));
    });

    $('#remove-lineitem').live('click', function() {
        $(this).closest('tr').remove();
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
    });

    $('input[name$=itemId]').live('change', function() {
        updateModelNameXferPrice($(this).closest('tr'), $(this).val(), $(this).attr('supplierId'));
    });

    $('input[name$=unitPrice]').live('change', function() {
        var quantity = $(this).closest('tr').find('input[name$=quantity]');
        var price    = $(this).val();
        $(this).closest('tr').find('#amount').html(quantity * price);
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
    });

    $('input[name$=quantity]').live('change', function() {
        var price = $(this).closest('tr').find('input[name$=unitPrice]');
        var quantity    = $(this).val();
        $(this).closest('tr').find('#amount').html(quantity * price);
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
    });

    $('form.create-purchase-order').live('submit', function() {
        submitPurchaseOrderForm($(this));
        return false;
    });

    $('#editAndResendPOButton').live('click', function() {
        $(this).siblings('input[name$=resendPO]').val(1);
        submitEditPurchaseOrderForm($(this).closest('form'), $(this).siblings('input[name$=id]').val());
    });

    $('#editPOButton').live('click', function() {
        $(this).siblings('input[name$=resendPO]').val(0);
        submitEditPurchaseOrderForm($(this).closest('form'), $(this).siblings('input[name$=id]').val());
    });

    $('.show-details').live('click', function() {
        $(this).closest('tr').siblings().removeClass('bold');
        $(this).closest('tr').addClass('bold');
        $('div.lineitems').hide();
        $('#lineitems-' + $(this).attr('supplierId')).show();
    });
    
    $('.lineitems #cancel').live('click', function() {
        $('div.lineitems').hide();
        $('#suppliers').find('tr').removeClass('bold');        
    });

    $('form.edit-purchase-order').live('submit', function() {
        return false;
    });

    $('#amendCancel').live('click', function() {
        document.location.href = '/inventory/purchase-order/' + $(this).attr('purchaseOrderId') + '/edit';
    });
    
    $('#close-po').live('click', function() {
        closePO($(this).attr('poId'));
    });
    
    $('#open-po-button').live('click', function() {
        openPO($(this).attr('poId'));
    });
    
    $('.change-po-warehouse').live('click', function() {
        $(this).hide();
        $(this).siblings('.change-po-warehouse-form').show();
    });

    $('.cancel-change-po-warehouse').live('click', function() {
        $(this).parent().siblings('.change-po-warehouse').show();
        $(this).parent().hide();
    });
    
    $('.cForm-class').change(function() {
        if ($(this).is(':checked')) {
                $(".cstCostTypeDiv-class").show();
                $('.cstCostType-class').val('ours');
                $('.extraCstInputs-class').hide();
        }
        else{
                $(".cstCostTypeDiv-class").hide();
                $('.cstCostType-class').val('ours');
                $('.extraCstInputs-class').hide();
        }
    });
    
    $('.cstCostType-class').change(function() {
        var cstCostType = $(this).val();
        if(cstCostType=="custom"){
                $('.extraCstInputs-class').show();
                $('.cstBorneByUs-class').val('0.00');
        }
        else{
                $('.extraCstInputs-class').hide();
                $('.cstBorneByUs-class').val('0.00');
        }
    });
});