Subversion Repositories SmartDukaan

Rev

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