Subversion Repositories SmartDukaan

Rev

Rev 4687 | Rev 7410 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4687 Rev 4754
Line 1... Line 1...
1
$(function() {
1
$(function() {
2
    $('input#changeColor').live('click', function() {
2
    $('input#add-lineitem').live('click', function() {
3
        var oldItemId = $(this).parent().siblings('#itemId').html();
3
        addNewRowForLineItem($(this).parent().parent().children('table.lineitems'));
4
        var poId      = $('input#poId').val();
-
 
5
        $.ajax({
-
 
6
            type    : 'GET',
-
 
7
            url     : '/inventory/purchase-order!fetchSimilarItems?oldItemId=' + oldItemId + '&id=' + poId,
-
 
8
            success : function(response) {
-
 
9
                $('#form-' + oldItemId).html(response);
-
 
10
            }
-
 
11
        });
-
 
12
    });
4
    });
13
 
5
 
14
    $('input#cancel').live('click', function() {
6
    $('#remove-lineitem').live('click', function() {
-
 
7
        $(this).closest('tr').remove();
15
        document.location.href = '/inventory/purchase-order/' + $('input#poId').val();
8
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
16
    });
9
    });
17
 
10
 
-
 
11
    $('input[name$=itemId]').live('change', function() {
-
 
12
        updateModelNameXferPrice($(this).closest('tr'), $(this).val(), $(this).attr('supplierId'));
-
 
13
    });
-
 
14
 
-
 
15
    $('input[name$=unitPrice]').live('change', function() {
-
 
16
        var quantity = $(this).closest('tr').find('input[name$=quantity]');
-
 
17
        var price    = $(this).val();
-
 
18
        $(this).closest('tr').find('#amount').html(quantity * price);
-
 
19
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
-
 
20
    });
-
 
21
 
-
 
22
    $('input[name$=quantity]').live('change', function() {
-
 
23
        var price = $(this).closest('tr').find('input[name$=unitPrice]');
-
 
24
        var quantity    = $(this).val();
-
 
25
        $(this).closest('tr').find('#amount').html(quantity * price);
-
 
26
        updateTotalAmount($(this).closest('div.lineitems').attr('supplierId'));
-
 
27
    });
-
 
28
 
-
 
29
    $('form.create-purchase-order').live('submit', function() {
-
 
30
        submitPurchaseOrderForm($(this));
-
 
31
        return false;
-
 
32
    });
-
 
33
 
-
 
34
    $('#editAndResendPOButton').live('click', function() {
-
 
35
        $(this).siblings('input[name$=resendPO]').val(1);
-
 
36
        submitEditPurchaseOrderForm($(this).closest('form'), $(this).siblings('input[name$=id]').val());
-
 
37
    });
-
 
38
 
-
 
39
    $('#editPOButton').live('click', function() {
-
 
40
        $(this).siblings('input[name$=resendPO]').val(0);
-
 
41
        submitEditPurchaseOrderForm($(this).closest('form'), $(this).siblings('input[name$=id]').val());
-
 
42
    });
-
 
43
 
-
 
44
    $('.show-details').live('click', function() {
-
 
45
        $(this).closest('tr').siblings().removeClass('bold');
-
 
46
        $(this).closest('tr').addClass('bold');
-
 
47
        $('div.lineitems').hide();
-
 
48
        $('#lineitems-' + $(this).attr('supplierId')).show();
-
 
49
    });
18
    
50
    
-
 
51
    $('.lineitems #cancel').live('click', function() {
-
 
52
        $('div.lineitems').hide();
-
 
53
        $('#suppliers').find('tr').removeClass('bold');        
-
 
54
    });
-
 
55
 
-
 
56
    $('form.edit-purchase-order').live('submit', function() {
-
 
57
        return false;
-
 
58
    });
-
 
59
 
-
 
60
    $('#amendCancel').live('click', function() {
-
 
61
        document.location.href = '/inventory/purchase-order/' + $(this).attr('purchaseOrderId') + '/edit';
-
 
62
    });
19
});
63
});