Subversion Repositories SmartDukaan

Rev

Rev 35884 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
35806 amit 1
<div class="panel panel-default">
2
    <div class="panel-heading">
3
        <h4>Invoice #$invoice.getInvoiceNumber() - GRN Correction</h4>
4
    </div>
5
    <div class="panel-body">
6
 
7
        #if($hasPendingRequest)
8
        <div class="alert alert-warning">
9
            A pending correction request already exists for this invoice. Please wait for approval.
10
        </div>
11
        #end
12
 
13
        <h5>Items on Invoice</h5>
14
        <table class="table table-bordered table-condensed" id="correction-items-table">
15
            <thead>
16
                <tr>
17
                    <th>Item Id</th>
18
                    <th>Item</th>
19
                    <th>Invoice Qty</th>
20
                    <th>Current IMEIs / Serial Numbers</th>
21
                </tr>
22
            </thead>
23
            <tbody>
24
                #foreach($invoiceItem in $invoiceItems)
25
                <tr>
26
                    <td class="currentItemId">$invoiceItem.getItemId()</td>
27
                    <td>
28
                        #if($itemMap.get($invoiceItem.getItemId()))
29
                            $itemMap.get($invoiceItem.getItemId()).getModelName()
30
                            #if($itemMap.get($invoiceItem.getItemId()).getColor()) - $itemMap.get($invoiceItem.getItemId()).getColor()#end
31
                        #else
32
                            $invoiceItem.getItemId()
33
                        #end
34
                    </td>
35
                    <td>$invoiceItem.getQty()</td>
36
                    <td>
37
                        #if($inventoryByItem.get($invoiceItem.getItemId()))
38
                            #set($hasSerialized = false)
39
                            #foreach($inv in $inventoryByItem.get($invoiceItem.getItemId()))
40
                                #if($inv.getSerialNumber())
41
                                    #set($hasSerialized = true)
42
                                    <span class="label label-default imei-label"
43
                                          data-serial="$inv.getSerialNumber()"
44
                                          data-itemid="$invoiceItem.getItemId()"
45
                                          data-scantype="$inv.getLastScanType()">$inv.getSerialNumber()</span>
46
                                #end
47
                            #end
48
                            #if(!$hasSerialized)
49
                                (Non-serialized: qty $invoiceItem.getQty())
50
                            #end
51
                        #else
52
                            (Non-serialized: qty $invoiceItem.getQty())
53
                        #end
54
                    </td>
55
                </tr>
56
                #end
57
            </tbody>
58
        </table>
59
 
60
        <hr/>
61
 
62
        <h5>Serial Number Corrections</h5>
63
        <p class="text-muted">For serialized items: enter the wrong IMEI and the correct IMEI to replace it.</p>
64
        <table class="table table-bordered table-condensed" id="serial-corrections-table">
65
            <thead>
66
                <tr>
67
                    <th>Old Serial Number (wrong)</th>
68
                    <th>New Serial Number (correct)</th>
69
                    <th></th>
70
                </tr>
71
            </thead>
72
            <tbody>
73
                <tr class="serial-correction-row">
74
                    <td><input type="text" class="form-control old-serial" placeholder="Enter wrong IMEI/serial" /></td>
75
                    <td><input type="text" class="form-control new-serial" placeholder="Enter correct IMEI/serial" /></td>
76
                    <td><button class="btn btn-sm btn-danger removeSerialCorrectionRow">Remove</button></td>
77
                </tr>
78
            </tbody>
79
        </table>
80
        <button class="btn btn-sm btn-default addSerialCorrectionRow">+ Add Row</button>
81
 
82
        <hr/>
83
 
84
        <h5>Non-Serialized Quantity Corrections</h5>
85
        <p class="text-muted">For non-serialized items: move quantity from one item to another.</p>
86
        <table class="table table-bordered table-condensed" id="qty-corrections-table">
87
            <thead>
88
                <tr>
89
                    <th>From Item</th>
90
                    <th>To Item</th>
91
                    <th>Quantity</th>
92
                    <th></th>
93
                </tr>
94
            </thead>
95
            <tbody>
96
                <tr class="qty-correction-row">
97
                    <td>
98
                        <input type="text" class="form-control typeaheaditem qty-old-item" autocomplete="off" placeholder="Search old item..." />
99
                        <input type="hidden" class="qty-old-itemid" />
100
                    </td>
101
                    <td>
102
                        <input type="text" class="form-control typeaheaditem qty-new-item" autocomplete="off" placeholder="Search new item..." />
103
                        <input type="hidden" class="qty-new-itemid" />
104
                    </td>
105
                    <td><input type="number" class="form-control qty-correction-val" placeholder="Qty" min="1" /></td>
106
                    <td><button class="btn btn-sm btn-danger removeQtyCorrectionRow">Remove</button></td>
107
                </tr>
108
            </tbody>
109
        </table>
110
        <button class="btn btn-sm btn-default addQtyCorrectionRow">+ Add Row</button>
111
 
112
        <hr/>
113
 
114
        <div class="form-group">
115
            <label>Remarks (reason for correction):</label>
116
            <textarea class="form-control" id="correctionRemarks" rows="3" placeholder="Describe why this correction is needed..."></textarea>
117
        </div>
118
 
119
        #if(!$hasPendingRequest)
120
        <button class="btn btn-primary submitGrnCorrection" data-invoiceid="$invoice.getId()">Submit Correction Request</button>
121
        #end
122
    </div>
123
</div>
124
 
125
<script>
126
$(function() {
127
    // Initialize typeahead for qty correction rows
128
    function initQtyTypeahead($row) {
129
        getItemAheadOptions($row.find('.qty-old-item'), true, function(selectedItem) {
130
            $row.find('.qty-old-itemid').val(selectedItem.itemId);
131
        });
132
        getItemAheadOptions($row.find('.qty-new-item'), true, function(selectedItem) {
133
            $row.find('.qty-new-itemid').val(selectedItem.itemId);
134
        });
135
    }
136
 
137
    // Init typeahead on existing rows
138
    $('#qty-corrections-table tbody tr').each(function() {
139
        initQtyTypeahead($(this));
140
    });
141
 
142
    // Add serial correction row
143
    $(document).on('click', '.addSerialCorrectionRow', function() {
144
        var $row = $('<tr class="serial-correction-row">' +
145
            '<td><input type="text" class="form-control old-serial" placeholder="Enter wrong IMEI/serial" /></td>' +
146
            '<td><input type="text" class="form-control new-serial" placeholder="Enter correct IMEI/serial" /></td>' +
147
            '<td><button class="btn btn-sm btn-danger removeSerialCorrectionRow">Remove</button></td>' +
148
            '</tr>');
149
        $('#serial-corrections-table tbody').append($row);
150
    });
151
 
152
    // Add qty correction row
153
    $(document).on('click', '.addQtyCorrectionRow', function() {
154
        var $row = $('<tr class="qty-correction-row">' +
155
            '<td><input type="text" class="form-control typeaheaditem qty-old-item" autocomplete="off" placeholder="Search old item..." /><input type="hidden" class="qty-old-itemid" /></td>' +
156
            '<td><input type="text" class="form-control typeaheaditem qty-new-item" autocomplete="off" placeholder="Search new item..." /><input type="hidden" class="qty-new-itemid" /></td>' +
157
            '<td><input type="number" class="form-control qty-correction-val" placeholder="Qty" min="1" /></td>' +
158
            '<td><button class="btn btn-sm btn-danger removeQtyCorrectionRow">Remove</button></td>' +
159
            '</tr>');
160
        $('#qty-corrections-table tbody').append($row);
161
        initQtyTypeahead($row);
162
    });
163
 
164
    // Remove rows
165
    $(document).on('click', '.removeSerialCorrectionRow', function() {
166
        $(this).closest('tr').remove();
167
    });
168
    $(document).on('click', '.removeQtyCorrectionRow', function() {
169
        $(this).closest('tr').remove();
170
    });
171
});
172
</script>