Subversion Repositories SmartDukaan

Rev

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

Rev 32357 Rev 32358
Line 195... Line 195...
195
 
195
 
196
 
196
 
197
    $(document).on('click', ".addRowInPurchaseOrder", function () {
197
    $(document).on('click', ".addRowInPurchaseOrder", function () {
198
        var totalQty = 0;
198
        var totalQty = 0;
199
 
199
 
200
        /*$("table > tbody > tr").each(function () {
200
        $("table > tbody > tr").each(function () {
201
            var itemId = $(this).find(".transferPrice").data('itemid');
201
            var itemId = $(this).find(".transferPrice").data('itemid');
202
            var qty = $(this).find(".qty").val();
202
            var qty = $(this).find(".qty").val();
203
 
203
 
204
            console.log(qty);
204
            console.log(qty);
205
 
205
 
206
            if (qty !== undefined) {
206
            if (qty !== undefined) {
207
                totalQty += parseInt(qty);
207
                totalQty += parseInt(qty);
208
            }
208
            }
209
 
-
 
210
            console.log(totalQty);
209
            console.log(totalQty);
-
 
210
        });
211
 
211
 
212
 
-
 
213
            if (itemId !== undefined) {
-
 
214
                purchaseItemIds.push(itemId);
-
 
215
            }
-
 
216
        });*/
-
 
217
 
-
 
218
        var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td> <td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td><td>  <input type="number" class="form-control transferPrice"  disable placeholder="Transfer Price"/> </td>	<td>  <input type="number" class="form-control totalValue"  disable placeholder="Total Value"/> </td> <td> <input class="form-control btn btn-primary removeInPurchaseOrder" type="button" value="Remove"></td>  </tr> ');
212
        var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td> <td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td><td>  <input type="number" class="form-control transferPrice"  readonly tabindex="-1" placeholder="Transfer Price"/> </td>	<td>  <input type="number" class="form-control totalValue" tabindex="-1"  readonly placeholder="Total Value"/> </td> <td> <input class="form-control btn btn-primary removeInPurchaseOrder" tabindex="-1" type="button" value="Remove"></td>  </tr> ');
219
 
213
 
220
        var vendorId = $('#vendorId').val();
214
        var vendorId = $('#vendorId').val();
221
 
215
 
222
        $('tbody').append($html);
216
        $('tbody').append($html);
223
        getVendorItemAheadOptions($html.find('.typeaheaditem'), vendorId, function (
217
        getVendorItemAheadOptions($html.find('.typeaheaditem'), vendorId, function (
Line 247... Line 241...
247
        });
241
        });
248
 
242
 
249
    });
243
    });
250
 
244
 
251
    function addItem(container, itemId) {
245
    function addItem(container, itemId) {
252
        oldItem = container.find('.transferPrice').data(itemId);
246
        oldItem = container.find('.transferPrice').data('itemId');
253
        if (typeof (oldItem) === "undefined" || oldItem !== itemId) {
247
        if (typeof (oldItem) === "undefined" || oldItem !== itemId) {
254
            purchaseItemIds.push(itemId);
248
            purchaseItemIds.push(itemId);
255
            container.find('.transferPrice').data('itemId', itemId);
249
            container.find('.transferPrice').data('itemId', itemId);
-
 
250
            $('.addRowInPurchaseOrder').click();
256
        } else {
251
        } else {
257
            let oldIndex = purchaseItemIds.indexOf(oldItem);
252
            let oldIndex = purchaseItemIds.indexOf(oldItem);
258
            if (oldIndex > -1) {
253
            if (oldIndex > -1) {
259
                purchaseItemIds.splice(oldIndex, 1);
254
                purchaseItemIds.splice(oldIndex, 1);
-
 
255
            } else {
-
 
256
                alert("Item already added");
260
            }
257
            }
261
        }
258
        }
262
    }
259
    }
263
 
260
 
264
    $(document).on('click', '.createSendPurchaseOrder', function () {
261
    $(document).on('click', '.createSendPurchaseOrder', function () {
Line 289... Line 286...
289
        var purchaseOrderValue = 0;
286
        var purchaseOrderValue = 0;
290
 
287
 
291
        $("table > tbody > tr").each(function () {
288
        $("table > tbody > tr").each(function () {
292
 
289
 
293
            var totalValue = $(this).find(".totalValue").val();
290
            var totalValue = $(this).find(".totalValue").val();
294
            purchaseOrderValue += totalValue
291
            purchaseOrderValue += totalValue;
295
 
292
 
296
        });
293
        });
297
 
294
 
298
    });
295
    });
299
 
296
 
Line 405... Line 402...
405
            }
402
            }
406
        });
403
        });
407
 
404
 
408
        var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td>' +
405
        var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td>' +
409
            '<td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td>' +
406
            '<td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td>' +
410
            '<td>  <input type="number" class="form-control rate"  disable placeholder="Rate"/> </td>' +
407
            '<td>  <input type="number" class="form-control rate"  readonly placeholder="Rate"/> </td>' +
411
            '<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td>  </tr> ');
408
            '<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td>  </tr> ');
412
 
409
 
413
 
410
 
414
        getItemAheadOptions($html.find('.typeaheaditem'), true, function (
411
        getItemAheadOptions($html.find('.typeaheaditem'), true, function (
415
            selectedItem) {
412
            selectedItem) {