Subversion Repositories SmartDukaan

Rev

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