Subversion Repositories SmartDukaan

Rev

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

$(function() {
    $('input#add-item').live('click', function() {
        addNewRowForItem();
    });

    $('a#remove-item').live('click', function() {
        $(this).closest('tr').remove();
        updateTotalAmount();
    });

    $('#bulk-order').live('submit', function() {
        submitBulkOrderForm();
        return false;
    });
    
    $('#orderType').live('change', function() {
        hideShowTin();
        return false;
    });

    $('input[name$=unit_price]').live('change', function() {
        var quantity = $(this).closest('tr').find('input[name$=quantity]');
        var price    = $(this).val();
        $(this).closest('tr').find('#item-amount').html(quantity * price);
        updateTotalAmount();
    });

    $('input[name$=quantity]').live('change', function() {
        var price = $(this).closest('tr').find('input[name$=unit_price]');
        var quantity    = $(this).val();
        $(this).closest('tr').find('#item-amount').html(quantity * price);
        updateTotalAmount();
    });

    $('input[name$=item_id]').live('change', function() {
        var count=0;
        var that = this;
        $(this).closest('table').find('tr').each(function(el){
                if($(this).find('input[name=item_id]').val()==$(that).val()) {
                        count += 1;
                }
        });
        if(count==2) {
                alert("item should not be repeated twice");
                return;
        }
        updateModelName($(this).closest('tr'), $(this).val());
        updateModelPrice($(this).closest('tr'), $(this).val());
    });
    
    $('#walletFlag').live('change', function(){
        $('.rtgsgroup').toggle();
        $('.rtgsgroup input').attr('disabled', function(i, v) { return !v; });
    });
});