Commit c0c728f1 authored by gaseema.n's avatar gaseema.n

inventory update

parent b1c583c7
......@@ -1515,11 +1515,10 @@
</div>
<div class="col s12">
<div class="row">
<div class="inventoryItemsToAdd">
<div class="inventoryItemsToAdd" style="padding: 10px 20px;">
</div>
</div>
<div class="row sprndProd"></div>
</div>
</div>
</div>
......
......@@ -26,7 +26,10 @@ function sponpProdNamesInput() {
var itemName = sponProds[iii].name;
var itemPrice = sponProds[iii].price;
var itemId = sponProds[iii].id;
$('.inventoryItemsToAdd').append('<form action="#"> <p> <label> <input class="inventoryItems" type="checkbox" pid="' + itemId + '" id="inventoryItem' + itemId + '"/> <span>' + itemName + '</span> </label> </p></form>');
$('.inventoryItemsToAdd').append('<form action="#" style="float: left; padding-right: 20px;"> <p> <label> <input class="inventoryItems" type="checkbox" pid="' + itemId + '" id="inventoryItem' + itemId + '"/> <span>' + itemName + '</span> </label> </p></form>');
if(invetoryItemsInStore.includes(itemId) == true){
$('#inventoryItem' + itemId + '').attr('checked', true);
}
}
});
......@@ -65,8 +68,6 @@ function inventoryOrder(prid) {
$(document).on('click touchstart', '.inventoryItems', function(e) {
var getId = $(this).attr('pid');
var isChecked = $('#inventoryItem' + getId).prop('checked');
console.log(getId)
console.log(isChecked)
if(isChecked == true){
M.toast({
html: 'Adding item to inventory',
......@@ -89,27 +90,31 @@ $(document).on('click touchstart', '.inventoryItems', function(e) {
} else {}
});
}else{
M.toast({
html: 'Removing item from inventory',
classes: 'spnsrdTst',
displayLength: 10000
})
doFetch({
action: 'addSponsoredProduct',
store: localStorage.getItem('soko-active-store'),
do: 'remove',
id: getId
}).then(function(e) {
if (e.status == 'ok') {
$(".spnsrdTst").remove();
$('#spnsrdModal').modal('close');
M.toast({
html: 'Item removed successfully',
displayLength: 3000
})
} else {}
$("#rmvSpnsrdProd").attr("sid", getId)
$("#rmvSpnsrdProd").css('display','block');
$(document).on('touchstart click', '#yesSponsoredBtn', function(event) {
var sponsoredID = $("#rmvSpnsrdProd").attr("sid");
$(this).unbind(event);
doFetch({
action: 'removeSponsoredProduct',
store: localStorage.getItem('soko-active-store'),
do: 'remove',
id: sponsoredID
}).then(function(e) {
if (e.status == 'ok') {
$("#rmvSpnsrdProd").hide();
document.getElementById(id).remove();
document.getElementById("sprdprod_" + id).remove();
M.toast({
html: 'Inventory item removed successfully',
displayLength: 3000
})
} else {}
});
});
}
})
$(document).on('touchstart click', '#noSponsoredBtn', function(event) {
$("#rmvSpnsrdProd").hide();
});
var getAllProducts;
var globalProductList = []
var globalProductList = [];
var invetoryItemsInStore = new Array();
function refreshProducts() {
doFetch({
......@@ -147,30 +148,6 @@ $(document).on('touchstart click', '.prodactsPage', function() {
$(".activePage").html("Products")
});
$(document).on('touchstart click', '#yesSponsoredBtn', function(event) {
var sponsoredID = $("#rmvSpnsrdProd").attr("sid");
$(this).unbind(event);
doFetch({
action: 'removeSponsoredProduct',
store: localStorage.getItem('soko-active-store'),
do: 'remove',
id: sponsoredID
}).then(function(e) {
if (e.status == 'ok') {
$("#rmvSpnsrdProd").hide();
document.getElementById(id).remove();
document.getElementById("sprdprod_" + id).remove();
M.toast({
html: 'Sponsored product removed successfully',
displayLength: 3000
})
} else {}
});
});
$(document).on('touchstart click', '#noSponsoredBtn', function(event) {
$("#rmvSpnsrdProd").hide();
});
var prodUID;
function productsUpdater() {
......@@ -204,12 +181,14 @@ function productsUpdater() {
$('#firstProdModal').modal('close');
}
globalProductList = []
invetoryItemsInStore = []
for (var i = 0; i < reqs.length; ++i) {
globalProductList.push(reqs[i])
prodUID = reqs
if (reqs[i].sponsored == "true") {
$('#inventoryEmpty').css('display', 'none');
var totalPrice = reqs[i].rstQuantity * reqs[i].price
var totalPrice = reqs[i].rstQuantity * reqs[i].price;
invetoryItemsInStore.push(reqs[i].id)
$(".sponsoredPrd-collapsible").append('<li class="prdList" prid="' + reqs[i].id + '" style="margin: 0px 0px 10px 0p !important; background: rgb(255, 255, 255);">' + '<div class="prodImgDskt" id="prodImg-holda-' + reqs[i].id + '" style="background-size: cover;background-repeat: no-repeat;background-position: center;background-image:url(' + reqs[i].imagePath.replace('.png', '-35.webp') + ');width: 70px;height: 70px;float: left; margin: 10px"></div><div class="collapsible-header" style="padding: 5px 10px;line-height: 0;width: calc(100% - 90px);display:inline-block;border-bottom:none;"><div class="row"><div class="col s10"><p style="margin:0px;line-height:1.8rem;font-weight:bold; white-space: nowrap; width: 85%; overflow: hidden; text-overflow: ellipsis;">' + reqs[i].name + ' <br><span style="font-weight:400;color:#7e7e7e;">' + reqs[i].description + '<br> Ksh. ' + reqs[i].price + '</span></p></div><div class="col s2"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;margin-top:10px;" xml:space="preserve"><path style="fill: rgba(29, 125, 116, 0.85);" d="M426.639,426.049l1.732-34.191c0.315-6.146,4.255-11.659,10.084-13.865l31.907-12.211 c13.944-5.278,24.58-16.544,29.07-30.647c4.648-14.102,2.679-29.306-5.514-41.754l-18.593-28.833c-3.467-5.2-3.466-11.818,0-17.017 l18.671-28.756c8.036-12.447,10.084-27.731,5.515-41.912c-4.648-14.102-15.127-25.21-29.149-30.566l-31.985-12.29 c-5.751-2.127-9.612-7.563-9.927-13.708l-1.891-34.192c0.079-0.71-0.078-1.339-0.157-2.049 c-1.182-14.102-8.509-26.786-19.932-35.214c-12.054-8.588-27.022-11.423-41.518-7.642l-33.167,8.902 c-5.908,1.654-12.211-0.393-16.071-5.2l-21.586-26.628C284.754,6.696,270.809,0,255.999,0c-14.811,0-28.756,6.696-38.051,18.198 l-21.664,26.707c-3.86,4.805-10.163,6.853-16.071,5.2l-33.167-8.902c-14.339-3.781-29.464-0.945-41.518,7.642 c-12.054,8.902-19.38,22.374-20.089,37.263l-1.891,34.191c-0.158,6.146-4.176,11.58-9.927,13.708l-31.986,12.29 c-13.865,5.357-24.501,16.465-29.149,30.567c-4.569,14.181-2.521,29.463,5.593,41.99l18.75,28.677 c3.309,5.2,3.309,11.818-0.078,17.095L18.08,293.382c-8.114,12.368-10.163,27.653-5.515,41.754 c4.491,14.102,15.205,25.447,29.07,30.647l32.064,12.211c5.672,2.206,9.612,7.721,9.927,13.865l1.734,34.192 c0,1.417,0.158,2.835,0.393,4.175c1.813,13.157,8.902,25.132,19.774,32.853c12.054,8.902,27.258,11.659,41.596,7.72l33.01-8.902 c5.988-1.575,12.29,0.472,16.229,5.357l21.586,26.628c9.217,11.58,23.162,18.119,38.13,18.119c14.811,0,28.755-6.539,38.13-18.119 l21.428-26.628c3.94-4.884,10.242-6.933,16.229-5.357l33.167,8.902c14.181,3.94,29.385,1.182,41.439-7.721 C418.525,454.488,425.851,441.017,426.639,426.049z"></path><path style="fill: #1d7d74;" d="M406.471,463.076c-12.054,8.902-27.258,11.659-41.439,7.721l-33.167-8.902 c-5.987-1.575-12.29,0.472-16.229,5.357l-21.428,26.628c-9.375,11.58-23.32,18.119-38.13,18.119 c-14.968,0-28.913-6.539-38.13-18.119l-21.586-26.628c-3.94-4.884-10.241-6.933-16.229-5.357l-33.01,8.902 c-14.338,3.94-29.542,1.182-41.596-7.72c-10.873-7.721-17.962-19.696-19.774-32.853L426.718,89.259l1.732,31.04 c0.315,6.144,4.176,11.58,9.927,13.708l31.985,12.29c14.022,5.357,24.501,16.465,29.149,30.566 c4.569,14.181,2.521,29.464-5.515,41.912l-18.671,28.756c-3.466,5.2-3.467,11.818,0,17.017l18.593,28.833 c8.193,12.448,10.163,27.653,5.514,41.754c-4.49,14.103-15.126,25.368-29.07,30.647l-31.907,12.211 c-5.83,2.206-9.769,7.721-10.084,13.865l-1.732,34.191C425.851,441.017,418.525,454.488,406.471,463.076z"></path><path style="fill: #ffab40;" d="M188.424,232.848c-18.431,0-33.424-14.993-33.424-33.424S169.993,166,188.424,166 s33.424,14.993,33.424,33.424S206.855,232.848,188.424,232.848z M188.424,199.445h0.109H188.424z M188.424,199.445h0.109H188.424z M188.424,199.431l0.109-0.001L188.424,199.431z M188.424,199.431l0.109-0.001L188.424,199.431z M188.424,199.431L188.424,199.431 L188.424,199.431z M188.424,199.431l0.109-0.001L188.424,199.431z M188.424,199.431l0.109-0.001L188.424,199.431z M188.424,199.431 l0.109-0.001L188.424,199.431z"></path><path style="fill:#F9A926;" d="M310.979,355.403c-18.431,0-33.424-14.993-33.424-33.424c0-18.431,14.993-33.424,33.424-33.424 s33.424,14.993,33.424,33.424C344.403,340.41,329.41,355.403,310.979,355.403z M310.979,322h0.109H310.979z M310.979,322h0.109 H310.979z M310.979,321.986l0.109-0.001L310.979,321.986z M310.979,321.986l0.109-0.001L310.979,321.986z M310.979,321.986 L310.979,321.986L310.979,321.986z M310.979,321.986l0.109-0.001L310.979,321.986z M310.979,321.986l0.109-0.001L310.979,321.986z M310.979,321.986l0.109-0.001L310.979,321.986z"></path><path style="fill:#FFC033;" d="M161.461,354.516c-6.524-6.524-6.528-17.106,0-23.634l157.562-157.562 c6.528-6.528,17.11-6.524,23.634,0c6.524,6.524,6.528,17.106,0,23.634L185.095,354.516 C178.568,361.043,167.985,361.04,161.461,354.516z"></path><path style="fill:#F9A926;" d="M185.095,354.516l157.562-157.562c6.528-6.528,6.524-17.11,0-23.634L161.461,354.516 C167.985,361.04,178.568,361.043,185.095,354.516z"></path></svg></div></div><div class="divider" style="background-color: #ffffff;"></div><span style="font-size:1em; font-weight:400; color:#616161;">' + '<i class="{{product.icon}}"></i><p style="margin:0px;display:none;">' + reqs[i].quantity + ' available</p><div class="divider" style="background-color: #ffffff;"></div></span></div><div class="collapsible-body" style="padding:0px;"><div style="width: 100%;text-align: center;margin: 20px 0px 0px;color: rgba(0,0,0,0.4);text-transform:uppercase;">sale information</div>' + '<form class="col s12" style="padding: 20px 30px;"><div class="row"><div class="input-field col s12">' + '<input disabled id="prodName-' + reqs[i].id + '" prnm="name" type="text" class="validate" prid="' + reqs[i].id + '" value="' + reqs[i].name + '"><label for="prodName-' + reqs[i].id + '" class="">Name</label></div></div>' + '<div class="row"><div class="input-field col s12"><input disabled prnm="description" placeholder="" value="' + reqs[i].description + '" id="prodDesc-' + reqs[i].id + '" type="text" class="validate" prid="' + reqs[i].id + '" min="0">' +
'<label for="description" class="">Description</label></div></div><div class="row">' +
'<div class="input-field col s6"><input disabled prnm="price" placeholder="" value="' + reqs[i].price + '" id="prodPrice-' + reqs[i].id + '" type="number" class="validate" prid="' + reqs[i].id + '" min="0">' +
......@@ -229,10 +208,6 @@ function productsUpdater() {
}
$(".sprndProd").empty().append($.parseHTML(sprndhtml));
$(document).on('touchstart click', '#sprdprod_' + reqs[i].id, function(event) {
$("#rmvSpnsrdProd").attr("sid", id)
$('#removeSprdProd').modal('open');
});
var modal = document.getElementById('rmvSpnsrdProd');
var btn = document.getElementById("sprdprod_" + reqs[i].id);
var id = reqs[i].id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment