Subversion Repositories SmartDukaan

Rev

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

Rev 34437 Rev 34449
Line 61... Line 61...
61
		const item = cart[id];
61
		const item = cart[id];
62
		const itemTotal = item.qty * item.price;
62
		const itemTotal = item.qty * item.price;
63
 
63
 
64
		cartHtml += `
64
		cartHtml += `
65
			<li style="display: flex; align-items: center; justify-content: space-between; padding: 5px 0;">
65
			<li style="display: flex; align-items: center; justify-content: space-between; padding: 5px 0;">
66
				<div style="flex: 1; min-width: 200px;">${item.model}</div>
66
				<div style="flex: 1; min-width: 200px;">${item.model} <br> <span style="color: gray;">- ${item.color}</div>
67
				<div style="display: flex; align-items: center; gap: 5px;">
67
				<div style="display: flex; align-items: center; gap: 5px;">
68
					<button class="dec-btn" data-id="${id}">-</button>
68
					<button class="dec-btn" data-id="${id}">-</button>
69
					<span class="cart-qty">${item.qty}</span>
69
					<span class="cart-qty">${item.qty}</span>
70
					<button class="inc-btn" data-id="${id}">+</button>
70
					<button class="inc-btn" data-id="${id}">+</button>
71
					<button class="remove-btn btn btn-xs btn-danger" data-id="${id}">x</button>
71
					<button class="remove-btn btn btn-xs btn-danger" data-id="${id}">x</button>
Line 75... Line 75...
75
	}
75
	}
76
 
76
 
77
	$('#custom-cart-section').html(cartHtml);
77
	$('#custom-cart-section').html(cartHtml);
78
}
78
}
79
 
79
 
-
 
80
$(document).on('click', '.po-radio-button', function () {
-
 
81
	const selectedRadio = $(this).find('input[type="radio"]');
80
 
82
 
81
$(document).on('click', '.add-to-cart-btn', function () {
83
	const itemId = selectedRadio.data('itemid');
82
	const catalogId = $(this).data('catalogid');
84
	const model = selectedRadio.data('modelnumber');
83
	const model = $(this).data('model');
85
	const color = selectedRadio.data('color');
84
	const price = parseFloat($(this).data('price')) || 0;
86
	const price = parseFloat(selectedRadio.data('price')) || 0;
-
 
87
 
-
 
88
	const key = itemId;
85
 
89
 
86
	if (cart[catalogId]) {
90
	if (cart[key]) {
87
		cart[catalogId].qty += 1;
91
		cart[key].qty += 1;
88
	} else {
92
	} else {
89
		cart[catalogId] = {model, qty: 1, price};
93
		cart[key] = {model, color, qty: 1, price};
90
	}
94
	}
91
 
95
 
92
	renderCart();
96
	renderCart();
93
});
97
});
94
 
98
 
Line 113... Line 117...
113
	const id = $(this).data('id');
117
	const id = $(this).data('id');
114
	delete cart[id];
118
	delete cart[id];
115
	renderCart();
119
	renderCart();
116
});
120
});
117
 
121
 
-
 
122
$(document).on('click', '.add-to-cart-btn', function () {
-
 
123
	var price = $(this).data('price');
-
 
124
	var catalogId = $(this).data('catalogid');
-
 
125
	console.log('price ', price)
-
 
126
 
-
 
127
	doGetAjaxRequestHandler(context + "/getPoCatalogsItems?price=" + price + "&catalogId=" + catalogId, function (response) {
-
 
128
 
-
 
129
		$('#poItemsDetail .modal-content').html(response);
-
 
130
 
-
 
131
	});
-
 
132
});
-
 
133
 
118
$(document).on('click', '#save-po-btn', function () {
134
$(document).on('click', '#save-po-btn', function () {
119
	console.log("Save PO button clicked!");
135
	console.log("Save PO button clicked!");
120
	const fofoId = parseInt($('#fofo-id').val());
136
	const fofoId = parseInt($('#fofo-id').val());
121
	console.log('fofoId:', fofoId);
137
	console.log('fofoId:', fofoId);
122
	saveSuggestedPo(fofoId);
138
	saveSuggestedPo(fofoId);
Line 127... Line 143...
127
	var jsonObject = {};
143
	var jsonObject = {};
128
	jsonObject.poIds = [];
144
	jsonObject.poIds = [];
129
 
145
 
130
	// Select <li> directly, not from inside <ul>
146
	// Select <li> directly, not from inside <ul>
131
	$("#custom-cart-section li").each(function () {
147
	$("#custom-cart-section li").each(function () {
132
		const catalogId = $(this).find(".dec-btn").data("id");
148
		const itemId = $(this).find(".dec-btn").data("id");
133
		const qty = parseInt($(this).find(".cart-qty").text().trim());
149
		const qty = parseInt($(this).find(".cart-qty").text().trim());
134
 
150
 
135
		if (!isNaN(catalogId) && qty > 0) {
151
		if (!isNaN(itemId) && qty > 0) {
136
			const item = {
152
			const item = {
137
				catalogId: catalogId,
153
				itemId: itemId,
138
				qty: qty
154
				qty: qty
139
			};
155
			};
140
			jsonObject.poIds.push(item);
156
			jsonObject.poIds.push(item);
141
		}
157
		}
142
	});
158
	});