Unverified Commit d521efa1 authored by bitsoko's avatar bitsoko Committed by GitHub

Merge pull request #57 from bitsoko-services/master

Updates
parents bbc19b82 c71f1b73
This diff is collapsed.
...@@ -732,7 +732,10 @@ function userNamesInput() { ...@@ -732,7 +732,10 @@ function userNamesInput() {
for (var iii in e.users) { for (var iii in e.users) {
var nm = e.users[iii].name; var nm = e.users[iii].name;
var icn = e.users[iii].icon; var icn = e.users[iii].icon;
deliveryGuysNames.push(nm) deliveryGuysNames.push({
name: nm,
pic: icn
})
//var id = e.users[iii].id; //var id = e.users[iii].id;
dat[nm] = icn; dat[nm] = icn;
...@@ -744,69 +747,74 @@ function userNamesInput() { ...@@ -744,69 +747,74 @@ function userNamesInput() {
} }
function autocomplete(inp, arr) { function autocomplete(inp, arr) {
var currentFocus; var currentFocus;
inp.addEventListener("input", function(e) { inp.addEventListener("input", function(e) {
var a, b, i, val = this.value; var a, b, i, val = this.value;
closeAllLists(); closeAllLists();
if (!val) { return false;} if (!val) {
currentFocus = -1; return false;
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
this.parentNode.appendChild(a);
for (i = 0; i < arr.length; i++) {
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
b = document.createElement("DIV");
b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
b.innerHTML += arr[i].substr(val.length);
b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
closeAllLists();
});
a.appendChild(b);
} }
} currentFocus = -1;
}); a = document.createElement("DIV");
inp.addEventListener("keydown", function(e) { a.setAttribute("id", this.id + "autocomplete-list");
var x = document.getElementById(this.id + "autocomplete-list"); a.setAttribute("class", "autocomplete-items");
if (x) x = x.getElementsByTagName("div"); this.parentNode.appendChild(a);
if (e.keyCode == 40) { for (i = 0; i < arr.length; i++) {
currentFocus++; if (arr[i].name.substr(0, val.length).toUpperCase() == val.toUpperCase()) {
addActive(x); b = document.createElement("DIV");
} else if (e.keyCode == 38) { b.innerHTML = "<strong>" + arr[i].name.substr(0, val.length) + "</strong>";
currentFocus--; b.innerHTML += arr[i].name.substr(val.length);
addActive(x); b.innerHTML += "<input type='hidden' value='" + arr[i].name + "'><img src='" + arr[i].pic + "' style='width: 30px; height: 30px; float: right; margin-top: -3px; border-radius: 50%;'/>";
} else if (e.keyCode == 13) { b.addEventListener("click", function(e) {
e.preventDefault(); inp.value = this.getElementsByTagName("input")[0].value;
if (currentFocus > -1) { closeAllLists();
if (x) x[currentFocus].click(); });
a.appendChild(b);
}
} }
} });
}); inp.addEventListener("keydown", function(e) {
function addActive(x) { var x = document.getElementById(this.id + "autocomplete-list");
if (!x) return false; if (x) x = x.getElementsByTagName("div");
removeActive(x); if (e.keyCode == 40) {
if (currentFocus >= x.length) currentFocus = 0; currentFocus++;
if (currentFocus < 0) currentFocus = (x.length - 1); addActive(x);
x[currentFocus].classList.add("autocomplete-active"); } else if (e.keyCode == 38) {
} currentFocus--;
function removeActive(x) { addActive(x);
for (var i = 0; i < x.length; i++) { } else if (e.keyCode == 13) {
x[i].classList.remove("autocomplete-active"); e.preventDefault();
if (currentFocus > -1) {
if (x) x[currentFocus].click();
}
}
});
function addActive(x) {
if (!x) return false;
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
x[currentFocus].classList.add("autocomplete-active");
} }
}
function closeAllLists(elmnt) { function removeActive(x) {
var x = document.getElementsByClassName("autocomplete-items"); for (var i = 0; i < x.length; i++) {
for (var i = 0; i < x.length; i++) { x[i].classList.remove("autocomplete-active");
if (elmnt != x[i] && elmnt != inp) { }
x[i].parentNode.removeChild(x[i]);
}
} }
}
document.addEventListener("click", function (e) { function closeAllLists(elmnt) {
closeAllLists(e.target); var x = document.getElementsByClassName("autocomplete-items");
}); for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && elmnt != inp) {
x[i].parentNode.removeChild(x[i]);
}
}
}
document.addEventListener("click", function(e) {
closeAllLists(e.target);
});
} }
function persistentFunc() { function persistentFunc() {
...@@ -894,7 +902,7 @@ function insufficientOrder() { ...@@ -894,7 +902,7 @@ function insufficientOrder() {
if (e.status == "ok") { if (e.status == "ok") {
$("#insufficientOrderStatus").html('Transaction code confirmed successfully'); $("#insufficientOrderStatus").html('Transaction code confirmed successfully');
$("#insufficientOrderStatus").css("color", "green"); $("#insufficientOrderStatus").css("color", "green");
$("#buyStoreTokens").modal("close"); $("#buyStoreTokens").modal("close");
} else { } else {
$("#insufficientOrderStatus").html('Error! Enter transaction code again.'); $("#insufficientOrderStatus").html('Error! Enter transaction code again.');
$("#insufficientOrderStatus").css("color", "red"); $("#insufficientOrderStatus").css("color", "red");
......
...@@ -112,11 +112,18 @@ angular.module('sokoApp', []) ...@@ -112,11 +112,18 @@ angular.module('sokoApp', [])
switchTo(getBitsWinOpt('page')) switchTo(getBitsWinOpt('page'))
if (getBitsWinOpt('page') == 'packaging') { if (getBitsWinOpt('page') == 'packaging') {
showPackagingPage(); showPackagingPage();
wrappingBagModal('wrappingBagModal')
fetchPackagingOrders(); fetchPackagingOrders();
if(getBitsWinOpt('sel')=="wraps"){ if(getBitsWinOpt('sel')=="wraps"){
$('#wrappingBagModal').modal('open') $('#wrappingBagModal').modal('open')
} }
} }
if (getBitsWinOpt('page') == 'inventory') {
openInventoryPage();
if(getBitsWinOpt('sel')=="add"){
$('#spnsrdModal').modal('open');
}
}
} }
......
...@@ -13,6 +13,8 @@ function deliveryMbr() { ...@@ -13,6 +13,8 @@ function deliveryMbr() {
$("#ordMembersLst").html(""); $("#ordMembersLst").html("");
if (deliveryMemberLst.length == 0) { if (deliveryMemberLst.length == 0) {
$('#incompleteShopIcon').css('display', 'block'); $('#incompleteShopIcon').css('display', 'block');
$('.shareStoreBtn').css('display', 'none');
$('.walletBalDiv').css('display', 'none');
if ($('.addOperatorShopError').length >= 1) { if ($('.addOperatorShopError').length >= 1) {
//Do nothing //Do nothing
} else { } else {
...@@ -75,7 +77,9 @@ function deliveryMbr() { ...@@ -75,7 +77,9 @@ function deliveryMbr() {
$("#rangeOutputId").val(rateInput); $("#rangeOutputId").val(rateInput);
if (rateInput == 0 || rateInput == undefined || rateInput == '') { if (rateInput == 0 || rateInput == undefined || rateInput == '') {
$('#incompleteShopIcon').css('display', 'block') $('#incompleteShopIcon').css('display', 'block');
$('.shareStoreBtn').css('display', 'none');
$('.walletBalDiv').css('display', 'none');
$('#shopIncompleteLst').append("<li>Set shop's delivery rate</li>") $('#shopIncompleteLst').append("<li>Set shop's delivery rate</li>")
} }
} }
......
...@@ -15,24 +15,37 @@ function sponpProdNamesInput() { ...@@ -15,24 +15,37 @@ function sponpProdNamesInput() {
var inputVal = $("#check-prod-input").val(); var inputVal = $("#check-prod-input").val();
var fetchedData = doFetch({ var fetchedData = doFetch({
action: 'getAllProducts', action: 'getAllProducts',
data: inputVal, data: '',
filter: 'sponsored' filter: 'sponsored'
}).then(function(e) { }).then(function(e) {
var dat = {} var dat = {}
var itemDat = new Array(); var itemDat = new Array();
sponProds = e.products; sponProds = e.products;
for (var iii in e.products) { $('.inventoryItemsToAdd').html('');
var nm = e.products[iii].name + " - " + e.products[iii].price; for (var iii in sponProds) {
var icn = e.products[iii].icon; var itemName = sponProds[iii].name;
var itemName = e.products[iii].name var itemPrice = sponProds[iii].price;
//var id = e.users[iii].id; var itemId = sponProds[iii].id;
dat[nm] = icn; var itemIcon = sponProds[iii].icon;
itemDat.push(itemName) if (itemName.toLowerCase() == "eggs") {
$('.inventoryItemsToAdd').append('<form action="#" style="padding-right: 20px;"> <p> <label> <input class="inventoryItems" type="checkbox" pid="' + itemId + '" id="inventoryItem' + itemId + '"/> <span><img src="' + itemIcon + '" style=" width: 25px; height: 25px; object-fit: cover; border-radius: 50%; float: left; margin-right: 10px;">' + itemName + ' @ ' + itemPrice + ' per tray</span> </label> </p></form>');
}
if (itemName.toLowerCase() == "potatoes") {
$('.inventoryItemsToAdd').append('<form action="#" style="padding-right: 20px;"> <p> <label> <input class="inventoryItems" type="checkbox" pid="' + itemId + '" id="inventoryItem' + itemId + '"/> <span><img src="' + itemIcon + '" style=" width: 25px; height: 25px; object-fit: cover; border-radius: 50%; float: left; margin-right: 10px;">' + itemName + ' @ ' + itemPrice + ' per kg</span> </label> </p></form>');
}
if (invetoryItemsInStore.includes(itemId) == true) {
$('#inventoryItem' + itemId + '').attr('checked', true);
}
} }
autocomplete(document.getElementById("check-prod-input"), itemDat);
}); });
var remainingTime = 7 - moment().format("d");
if (remainingTime == 1) {
document.getElementById('invetoryEndDate').innerHTML = remainingTime + " day";
} else {
document.getElementById('invetoryEndDate').innerHTML = remainingTime + " days";
}
} }
//Process Inventory Order //Process Inventory Order
...@@ -62,3 +75,59 @@ function inventoryOrder(prid) { ...@@ -62,3 +75,59 @@ function inventoryOrder(prid) {
}) })
} }
} }
$(document).on('click touchstart', '.inventoryItems', function(e) {
var getId = $(this).attr('pid');
var isChecked = $('#inventoryItem' + getId).prop('checked');
if (isChecked == true) {
M.toast({
html: 'Adding item to inventory',
classes: 'spnsrdTst',
displayLength: 10000
})
doFetch({
action: 'addSponsoredProduct',
store: localStorage.getItem('soko-active-store'),
do: 'add',
id: getId
}).then(function(e) {
if (e.status == 'ok') {
$(".spnsrdTst").remove();
$('#spnsrdModal').modal('close');
M.toast({
html: 'Item added to inventory successfully',
displayLength: 3000
})
} else {}
});
} else {
$("#rmvSpnsrdProd").attr("sid", getId)
$("#rmvSpnsrdProd").css('display', 'block');
$('#inventoryItem' + getId).prop('checked', true);
$(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();
$('#inventoryItem15').prop('checked', false);
M.toast({
html: 'Inventory item removed successfully',
displayLength: 3000
})
} else {}
});
});
}
})
$(document).on('touchstart click', '#noSponsoredBtn', function(event) {
$("#rmvSpnsrdProd").hide();
});
...@@ -10,6 +10,7 @@ function packagingDataArray() { ...@@ -10,6 +10,7 @@ function packagingDataArray() {
promise1 = new Promise(function(resolve, reject) { promise1 = new Promise(function(resolve, reject) {
var packagingDataArray = {}; var packagingDataArray = {};
var wrappingBagDataArray = {}; var wrappingBagDataArray = {};
var nonSealableDataArray = {};
if (packagingType == "paperBag") { if (packagingType == "paperBag") {
if ($("#smallPaperbag").prop("disabled") == false) { if ($("#smallPaperbag").prop("disabled") == false) {
packagingDataArray["small"] = $("#smallPaperbag").val(); packagingDataArray["small"] = $("#smallPaperbag").val();
...@@ -27,6 +28,23 @@ function packagingDataArray() { ...@@ -27,6 +28,23 @@ function packagingDataArray() {
packagingDataArray["large"] = "0" packagingDataArray["large"] = "0"
} }
resolve(packagingDataArray); resolve(packagingDataArray);
} else if (packagingType == 'nonSealable') {
if ($("#nonSealableSmall-3").prop("disabled") == false) {
nonSealableDataArray["small"] = $("#nonSealableSmall-3").val();
} else {
nonSealableDataArray["small"] = "0"
}
if ($("#nonSealableMeduim-5").prop("disabled") == false) {
nonSealableDataArray["medium"] = $("#nonSealableMeduim-5").val();
} else {
nonSealableDataArray["medium"] = "0"
}
if ($("#nonSealableLarge-8").prop("disabled") == false) {
nonSealableDataArray["large"] = $("#nonSealableLarge-8").val();
} else {
nonSealableDataArray["large"] = "0"
}
resolve(nonSealableDataArray);
} else { } else {
if ($("#wrappingBagTiny").prop("checked") == true) { if ($("#wrappingBagTiny").prop("checked") == true) {
wrappingBagDataArray["tiny-1"] = $("#wrappingTiny-1").val() wrappingBagDataArray["tiny-1"] = $("#wrappingTiny-1").val()
...@@ -108,7 +126,7 @@ function packagingData() { ...@@ -108,7 +126,7 @@ function packagingData() {
}); });
} else { } else {
//creditTopup = $(".packPrice").html(); //creditTopup = $(".packPrice").html();
var totalInsufficient = JSON.stringify(parseInt(numberify($('.packPrice').html().replace(/[^0-9\.]+/g, ''))) + parseInt(numberify(delPrice))) var totalInsufficient = $('.packPrice').html().replace(/[^0-9\.]+/g, '')
getInsufficientFundsOrderbook(totalInsufficient).then(function(r) { getInsufficientFundsOrderbook(totalInsufficient).then(function(r) {
doFetch({ doFetch({
...@@ -146,7 +164,10 @@ function packagingTotalCost() { ...@@ -146,7 +164,10 @@ function packagingTotalCost() {
var smallWrappingBag = $("#wrappingSmall-3").val() * 3 var smallWrappingBag = $("#wrappingSmall-3").val() * 3
var meduiumWrappingBag = $("#wrappingMeduim-5").val() * 5 var meduiumWrappingBag = $("#wrappingMeduim-5").val() * 5
var largeWrappingBag = $("#wrappingLarge-8").val() * 7 var largeWrappingBag = $("#wrappingLarge-8").val() * 7
var exLargeWrappingBag = $("#wrappingLarge-8").val() * 9 var exLargeWrappingBag = $("#wrappingLarge-9").val() * 9
var smallNonSealable = $("#nonSealableSmall-3").val() * 1
var mediumNonSealable = $("#nonSealableMeduim-5").val() * 3
var largeNonSealable = $("#nonSealableLarge-8").val() * 5
if (packagingType == 'paperBag') { if (packagingType == 'paperBag') {
if ($("#smallPaperbag").prop("disabled") == true) { if ($("#smallPaperbag").prop("disabled") == true) {
...@@ -161,6 +182,19 @@ function packagingTotalCost() { ...@@ -161,6 +182,19 @@ function packagingTotalCost() {
var totalCost = smallPack + mediumPack + largePack var totalCost = smallPack + mediumPack + largePack
$(".packPrice").html(parseInt(totalCost) + parseInt(numberify(delPrice)) + " " + baseCd); $(".packPrice").html(parseInt(totalCost) + parseInt(numberify(delPrice)) + " " + baseCd);
$(".packPriceVal").html(totalCost + " " + baseCd); $(".packPriceVal").html(totalCost + " " + baseCd);
} else if (packagingType == 'nonSealable') {
if ($("#nonSealableSmall-3").prop("disabled") == true) {
smallNonSealable = 0
}
if ($("#nonSealableMeduim-5").prop("disabled") == true) {
mediumNonSealable = 0
}
if ($("#nonSealableLarge-8").prop("disabled") == true) {
largeNonSealable = 0
}
var totalCost = smallNonSealable + mediumNonSealable + largeNonSealable
$(".packPrice").html(parseInt(totalCost) + parseInt(numberify(delPrice)) + " " + baseCd);
$(".packPriceVal").html(totalCost + " " + baseCd);
} else { } else {
if ($("#wrappingBagTiny").prop("checked") == false) { if ($("#wrappingBagTiny").prop("checked") == false) {
tinyWrappingBag = 0 tinyWrappingBag = 0
...@@ -245,6 +279,7 @@ function fetchPackagingOrders() { ...@@ -245,6 +279,7 @@ function fetchPackagingOrders() {
if (e.data.length == 0) {} else { if (e.data.length == 0) {} else {
$('.packagingContainer').html(''); $('.packagingContainer').html('');
var orderData = e.data; var orderData = e.data;
console.log(orderData.length)
var allItems = 0 var allItems = 0
for (order in orderData) { for (order in orderData) {
if (orderData[order].type == "paperBag") { if (orderData[order].type == "paperBag") {
...@@ -260,7 +295,6 @@ function fetchPackagingOrders() { ...@@ -260,7 +295,6 @@ function fetchPackagingOrders() {
testArray.push(items[sizes]) testArray.push(items[sizes])
} }
packagingArrayItems(testArray, itemsSize) packagingArrayItems(testArray, itemsSize)
function packagingArrayItems(itm, size) { function packagingArrayItems(itm, size) {
var nums = itm var nums = itm
var sum = 0; var sum = 0;
...@@ -270,8 +304,6 @@ function fetchPackagingOrders() { ...@@ -270,8 +304,6 @@ function fetchPackagingOrders() {
sum += parseInt(nums[i]); sum += parseInt(nums[i]);
} }
console.log();
$('.packagingContainer').append('<div class="row" style="width: 100%; display: block; margin-left: auto; margin-right: auto;"><div class="col s12 m6"> <div class="card"> <span class="card-title" style="border-bottom: solid #cecbcb 1px; display: block; padding: 5px 10px; font-size: 1em; font-weight: bold;">' + orderData[order].type + '</span> <div class="card-content" style="padding: 10px;"><div class="packagingSizes"></div> <p style="font-weight: bold; color: #545252;">Status: <span style="font-weight: normal;">' + orderData[order].status + '</span></p><p style="font-weight: bold; color: #545252;">No. of Items: <span style="font-weight: normal;">' + sum + '</span></p><p style="font-weight: bold; color: #545252;">Total Price: <span style="font-weight: normal;">0 kes</span></p></div></div></div></div>'); $('.packagingContainer').append('<div class="row" style="width: 100%; display: block; margin-left: auto; margin-right: auto;"><div class="col s12 m6"> <div class="card"> <span class="card-title" style="border-bottom: solid #cecbcb 1px; display: block; padding: 5px 10px; font-size: 1em; font-weight: bold;">' + orderData[order].type + '</span> <div class="card-content" style="padding: 10px;"><div class="packagingSizes"></div> <p style="font-weight: bold; color: #545252;">Status: <span style="font-weight: normal;">' + orderData[order].status + '</span></p><p style="font-weight: bold; color: #545252;">No. of Items: <span style="font-weight: normal;">' + sum + '</span></p><p style="font-weight: bold; color: #545252;">Total Price: <span style="font-weight: normal;">0 kes</span></p></div></div></div></div>');
} }
......
This diff is collapsed.
...@@ -11,7 +11,7 @@ function refreshPromotions() { ...@@ -11,7 +11,7 @@ function refreshPromotions() {
var allPromo = promoSubsId[i].promoSubs; var allPromo = promoSubsId[i].promoSubs;
for (var s = 0; s < allPromo.length; s++) { for (var s = 0; s < allPromo.length; s++) {
console.log('[++++++++++++++]' + promoSubsId[i].id + allPromo[s].id) // console.log('[++++++++++++++]' + promoSubsId[i].id + allPromo[s].id)
} }
} }
if (e.status == 'ok') { if (e.status == 'ok') {
...@@ -270,17 +270,20 @@ function promoCreator(proId) { ...@@ -270,17 +270,20 @@ function promoCreator(proId) {
// $(".promo-add-new-promotion-" + proId).html(''); // $(".promo-add-new-promotion-" + proId).html('');
for (var i = 0, proId = proId; i < e.length; ++i) { for (var i = 0, proId = proId; i < e.length; ++i) {
try {
var itemsInPromo = JSON.parse(promoSubsId[i].promoItems) var itemsInPromo = JSON.parse(promoSubsId[i].promoItems)
$('.promoItems-' + promoSubsId[i].id).html('') $('.promoItems-' + promoSubsId[i].id).html('')
for (items in itemsInPromo) { for (items in itemsInPromo) {
for (var ii = 0; ii < getAllProducts.length; ii++) { for (var ii = 0; ii < getAllProducts.length; ii++) {
var prdId = getAllProducts[ii].id var prdId = getAllProducts[ii].id
var prodName = getAllProducts[ii].name var prodName = getAllProducts[ii].name
if (prdId == itemsInPromo[items]) { if (prdId == itemsInPromo[items]) {
$('.promoItems-' + promoSubsId[i].id).append('<li style="display: inline-block;"><div class="chip">' + prodName + '</div></li>') $('.promoItems-' + promoSubsId[i].id).append('<li style="display: inline-block;"><div class="chip">' + prodName + '</div></li>')
}
} }
} }
} catch (err) {
console.log(err)
} }
$("#prodEdit_" + e[i].id).change(function() { $("#prodEdit_" + e[i].id).change(function() {
......
...@@ -251,13 +251,19 @@ function editStoreContent() { ...@@ -251,13 +251,19 @@ function editStoreContent() {
document.querySelector('#colorChosen').value = xx.theme; document.querySelector('#colorChosen').value = xx.theme;
M.updateTextFields(); M.updateTextFields();
$('#shopIncompleteLst').html('')
if (xx.lonlat == '' || xx.lonlat == undefined || xx.lonlat == null) { if (xx.lonlat == '' || xx.lonlat == undefined || xx.lonlat == null) {
$('#incompleteShopIcon').css('display', 'block') $('#incompleteShopIcon').css('display', 'block');
$('.shareStoreBtn').css('display', 'none');
$('.walletBalDiv').css('display', 'none');
$('#shopIncompleteLst').append("<li>Add store location</li>") $('#shopIncompleteLst').append("<li>Add store location</li>")
} }
if (xx.phone == '' || xx.phone == undefined || xx.phone == null) { if (xx.phone == '' || xx.phone == undefined || xx.phone == null) {
$('#incompleteShopIcon').css('display', 'block') $('#incompleteShopIcon').css('display', 'block');
$('#shopIncompleteLst').append("<li>Add store phone number</li>") $('.shareStoreBtn').css('display', 'none');
$('.walletBalDiv').css('display', 'none');
$('#shopIncompleteLst').append("<li>Add store phone number</li>");
} }
} }
......
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