Subversion Repositories SmartDukaan

Rev

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

Rev 27755 Rev 33715
Line 54... Line 54...
54
 
54
 
55
		$(this).closest("tr").remove();
55
		$(this).closest("tr").remove();
56
 
56
 
57
	});
57
	});
58
 
58
 
59
	$(document).on("click", ".submit-item",
59
    $(document).on("click", ".submit-item", function (e) {
60
					function(e) {
-
 
61
						var seletedIds;
60
        var seletedIds;
62
						var seletedIdsJson = [];
61
        var seletedIdsJson = [];
63
 
62
 
64
						$('#select-item-table').find('tr').each(
63
        // Get the current total price from the header and convert it to a number
65
								function() {
-
 
66
									var row = $(this);
64
        var totalPoPrice = parseFloat($(".totalPoPrice").text().replace(/[^0-9.-]+/g, "")) || 0;
67
 
65
 
-
 
66
        $('#select-item-table').find('tr').each(function () {
68
									console.log(row);
67
            var row = $(this);
69
									if (row.find('input[type="checkbox"]').is(
68
            if (row.find('input[type="checkbox"]').is(':checked')) {
70
											':checked')) {
-
 
71
										var currentRow = $(this).closest("tr");
69
                var currentRow = $(this).closest("tr");
72
 
70
 
73
										var itemId = currentRow
-
 
74
												.find("td:eq(1)").html();
71
                var itemId = currentRow.find("td:eq(1)").html();
75
										var name = currentRow.find("td:eq(2)")
72
                var name = currentRow.find("td:eq(2)").html();
76
												.html();
-
 
77
										var quantity = currentRow.find(
73
                var quantity = currentRow.find("td:eq(3) input").val();
78
												"td:eq(3) input").val();
74
                var itemPrice = parseFloat(currentRow.find("td:eq(4)").html());
79
										console.log(quantity)
-
 
-
 
75
 
80
										if (quantity == "") {
76
                if (quantity == "") {
81
											alert("Select the Quantity");
77
                    alert("Select the Quantity");
82
											return false;
78
                    return false;
-
 
79
                }
83
 
80
 
-
 
81
                // Calculate total item price
-
 
82
                var totalItemPrice = itemPrice * quantity;
84
										}
83
 
-
 
84
                // Add to the total PO price
-
 
85
                totalPoPrice += totalItemPrice;
85
 
86
 
86
										seletedIds = {
87
                seletedIds = {
87
											"itemId" : itemId,
88
                    "itemId": itemId,
88
											"name" : name,
89
                    "name": name,
89
											"qty" : quantity
90
                    "qty": quantity,
-
 
91
                    "itemPrice": itemPrice
90
										}
92
                }
91
										seletedIdsJson.push(seletedIds)
93
                seletedIdsJson.push(seletedIds);
92
 
-
 
93
									}
94
            }
94
 
-
 
95
								});
95
        });
96
 
96
 
97
						console.log(seletedIdsJson);
97
        console.log(seletedIdsJson);
98
 
98
 
99
						for (let i = 0; i < seletedIdsJson.length; i++) {
99
        for (let i = 0; i < seletedIdsJson.length; i++) {
100
							console.log(seletedIdsJson[i].itemId)
-
 
101
 
-
 
102
							markup = "<tr><td>"
100
            let markup = "<tr><td>" +
103
									+ seletedIdsJson[i].itemId
101
                seletedIdsJson[i].itemId + "</td><td>" +
104
									+ "</td><td>"
-
 
105
									+ seletedIdsJson[i].name
102
                seletedIdsJson[i].name + "</td><td>" +
106
									+ "</td><td>"
103
                seletedIdsJson[i].qty + "</td><td>" +
107
									+ seletedIdsJson[i].qty
104
                seletedIdsJson[i].itemPrice + "</td><td>" +
108
									+ "</td><td><button type = 'button' class='btnDelete'>Delete</button></td></tr>";
105
                "<button type='button' class='btnDelete'>Delete</button></td></tr>";
109
							$('#po-table > tbody:last-child').append(markup);
106
            $('#po-table > tbody:last-child').append(markup);
-
 
107
        }
-
 
108
 
-
 
109
        // Update the total price in the header
-
 
110
        updateTotalPoPrice(totalPoPrice);
-
 
111
 
-
 
112
        $("#selectItem").modal("hide");
-
 
113
    });
-
 
114
 
-
 
115
// Function to update the total price in the header
-
 
116
    function updateTotalPoPrice(newPrice) {
-
 
117
        $('.totalPoPrice').text('Total Price: ' + newPrice.toFixed(2));
110
						}
118
    }
-
 
119
 
111
 
120
 
112
						$("#selectItem").modal("hide");
-
 
113
					});
-
 
114
 
121
 
115
	$(document).on('click', ".confirm_po",
122
	$(document).on('click', ".confirm_po",
116
			function() {
123
			function() {
117
				var jsonObject = {};
124
				var jsonObject = {};
118
				var poIdsJSon = [];
125
				var poIdsJSon = [];