initial: bootstrap from BukidBountyApp base

This commit is contained in:
Jonathan Sykes
2026-06-06 18:43:00 +08:00
commit eb4a5731fb
5674 changed files with 160857 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<div id="MainView">
<div class="row">
<div class="col-md" style="overflow:hidden;">
<a href="javascript:void(0);" onclick="">
<div class="card ListRowCard" id="ListRowCard-0" style="">
<div id="cardheader-ListRowCard-0" class="card-header ui-sortable-handle"
style="cursor: move;display:none;">
<h3 class="card-title" style="" id="card-title-ListRowCard-0"></h3>
<div class="card-tools" id="card-tools-ListRowCard-0">
</div>
</div>
<div class="card-body ListCardRow" id="card-body-ListRowCard-0">
<div style="text-align:center;" id="PhotosCard">
<img src="/assets/micons//image-alt.svg" style="max-width: 100%;
max-height: 100%; width: auto; height: 100%;">
</div>
<br>
<div class="row" style="">
<div class="col">
<h3 id="ProductNameMarketPlace"></h3>
</div>
<div class="col" id="ProductUnitMarketPlace"></div>
</div>
<ul class="mt-3 box-outstanding-service" id="ControlsAddCartBuy">
<li onclick="LoadDataPageFunc.AddToCart();return false;">
<div class="">
<img src="/assets/addtocart.png" style="width: 30; height: 30;" class="icon-user">
</div>Add To Cart
</li>
<li onclick="LoadDataPageFunc.Buy();return false;">
<div class="">
<img src="/assets/buy.png" style="width: 30; height: 30;" class="icon-user">
</div>Buy
</li>
</ul>
</div>
</div>
</div>
</a>
</div>
<div class="col-md" style="overflow:hidden;">
<a href="javascript:void(0);" onclick="">
<div class="card ListRowCard" id="ListRowCard-2" style="">
<div class="card-body ListCardRow" id="card-body-ListRowCard-2">
<div style="text-align:center;" id="ProductDescription">
</div>
<h5></h5>
</div>
</div>
</a>
</div>
<div class="col-md" style="overflow:hidden;display: none;" id="OutOfStockColumn">
<div class="card ListRowCard" id="ListRowCard-3" style="">
<div class="card-body ListCardRow" id="card-body-ListRowCard-3">
<div style="text-align:center;" id="OutOfStockMessage">
Out of Stock!
<button class="btn" onclick="ButtonGo('ListProductsMarket','');">Go to Market</button>
</div>
<h5></h5>
</div>
</div>
</div>
<div class="col-md" style="overflow:hidden;display: none;" id="ReviewsCard">
<UI type="card" id="ReviewsCard" title="Reviews" tools="no">
content
</UI>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Product Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Disabled = false;
LoadDataPageFunc.OutofStock = function () {
$('#OutOfStockColumn').show();
$('#ControlsAddCartBuy').hide()
ModalQuickDismiss(false, 'Product Out of Stock');
LoadDataPageFunc.Disabled = true;
};
LoadDataPageFunc.Buy = function () {
if (LoadDataPageFunc.Disabled) { return false; }
gotoPage('ConfirmBUYProductMarket', cartobj, nohistory = 0, redundantpage = 0);
};
LoadDataPageFunc.AddToCart = function () {
if (LoadDataPageFunc.Disabled) { return false; }
if (!currenttarget) { return false; }
let reqq = new RequestData(false);
reqq.fromVarCache(false).data(null).url(`/cart/add/one/${currenttarget}`).type('GET')
.success((response) => {
if (response === true) {
ModalQuickDismiss('', 'Added to Cart!', 'ModalAddedtoCartSuccessfully');
$('#modal-header-ModalAddedtoCartSuccessfully').hide();
} else {
ModalQuickDismiss('', 'Unable to Add to Cart!', 'ModalUnableAddtoCart');
$('#modal-header-ModalUnableAddtoCart').hide();
}
Preloaders.CartContents();
}).go();
};
LoadDataPageFunc.PopulateDetailsNow = function (name, description, price, unit, available) {
$('#ProductNameMarketPlace').html(name);
$('#ProductDescription').html(description);
$('#ProductUnitMarketPlace').html('P' + price + ' / ' + unit);
if (!available) { LoadDataPageFunc.OutofStock(); }
};
LoadDataPageFunc.Settings.Phototype = "ProductMarket";
LoadDataPageFunc.PopulateDetails = function () {
let description;
let photosarray;
const UpdateDetailsUI = function (response) {
const ErrorModal = function () {
ModalQuickDismiss(false, 'Product Not Available!', 'UnavailableProductModal');
};
if (!response) {
ErrorModal();
return false;
}
let ProductData = response.data || false;
if (!ProductData) { ErrorModal(); return false; }
LoadDataPageFunc.Details.photourl = ProductData.photourl;
LoadPhotosCard('PhotosCard', onclick = `ButtonGo('ViewAllPhotos','${currenttarget}');`, ProductData.photourl);
LoadDataPageFunc.PopulateDetailsNow(ProductData.name, ProductData.description, ProductData.price, ProductData.unitname, ProductData.available);
};
Preloaders.ViewProductinMarket(currenttarget, true, UpdateDetailsUI);
};
LoadDataPageFunc.Main = function () {
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,164 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<div id="MainView" style="padding-top: 5px;">
<div class="row" id="CartListRow" style="margin-top: 5px; margin-bottom: 5px;">
</div>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Cart';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.CartCurrentlyLoading = 0;
LoadDataPageFunc.SetQuantityUI = function (newquantity, rownum) {
if (typeof rownum !== 'number') { return false; }
if (typeof newquantity !== 'number') { return false; }
let controlid = "ProductCartMarket-" + rownum;
$('#' + controlid).html(newquantity);
const newvalue = $('#' + controlid).html();
if (newquantity !== newvalue) { return false; }
return true;
};
LoadDataPageFunc.FindRowNumByHash = function (hashkey) {
let element = $('[data-hash="' + hashkey + '"]');
if (element.length === 0) { return false; }
let nrownum = element.data('rownum');
return nrownum
};
LoadDataPageFunc.SetQuantitybyHash = function (newquantity, hashkey) {
if (!hashkey || typeof hashkey !== 'string') { return false; }
let rownum = '';
rownum = LoadDataPageFunc.FindRowNumByHash(hashkey);
if (rownum === false) { return false; }
const changequantity = LoadDataPageFunc.SetQuantityUI(newquantity, rownum);
if (!changequantity) { return false; }
return true;
};
LoadDataPageFunc.UpdateProductQuantityCart = function (response, producthash) {
LoadDataPageFunc.CartCurrentlyLoading--;
LoadDataPageFunc.PopulateDetails(false);
/* if (response === false) { return false; }
if (typeof response !== 'number') {
return false;
};
return LoadDataPageFunc.SetQuantitybyHash(response, producthash); */
};
LoadDataPageFunc.RequestData = new RequestData(false);
LoadDataPageFunc.RemoveFromCartOneProduct = function (producthash) {
if (LoadDataPageFunc.CartCurrentlyLoading) { return false; }
if (!producthash) { return false; }
LoadDataPageFunc.CartCurrentlyLoading++;
LoadDataPageFunc.RequestData
.url('/cart/remove/one/' + producthash)
.type('GET')
.fromVarCache(false)
.success((response) => {
const res = LoadDataPageFunc.UpdateProductQuantityCart(response, producthash);
})
.go();
}
LoadDataPageFunc.CheckOutAllCart = function () {
const cartobj = objectToUrlSafeBase64(LoadDataPageFunc.Details);
gotoPage('ConfirmBUYProductMarket', cartobj, nohistory = 0, redundantpage = 0);
};
LoadDataPageFunc.AddToCartOneProduct = function (producthash) {
if (LoadDataPageFunc.CartCurrentlyLoading > 0) { return false; }
if (!producthash) { return false; }
LoadDataPageFunc.CartCurrentlyLoading++;
LoadDataPageFunc.RequestData
.url('/cart/add/one/' + producthash)
.type('GET')
.fromVarCache(false)
.success((response) => {
const res = LoadDataPageFunc.UpdateProductQuantityCart(response, producthash);
})
.go();
};
LoadDataPageFunc.CartProductRow = MarketUI.CartProductRow;
LoadDataPageFunc.UpdateCartFull = function (response) {
LoadDataPageFunc.Details = response;
if (Array.isArray(response) && response.length === 0) {
let cardCARTempty = CreateCardSimple(false, '<div style="text-align:center;">No Items On Cart! Start Shopping<br>' + buttonGOTOPage('Go to Market', 'ListProductsMarket') + '</div>');
$('#CartListRow').html(cardCARTempty);
return null;
}
let htmllist = []; let finalhtml = '';
let rownum = 0;
if (!response) { return false; }
LoopArrayorObject(response, (item) => {
htmllist.push(LoadDataPageFunc.CartProductRow(item, rownum));
rownum++;
});
finalhtml = htmllist.join('');
finalhtml +=`<br><br>`+buttonprimary('Checkout All','','LoadDataPageFunc.CheckOutAllCart()');
$('#CartListRow').html(finalhtml);
LoopArrayorObject(response, (item) => {
LoadAndCreateURLfromFileHash(item.photourl).then(bloburl => {
$('#ProductCartMarketPlacePhoto--' + rownum).attr('src', bloburl);
});
});
};
LoadDataPageFunc.PopulateDetails = function (fromVarCacheN = true) {
Preloaders.CartContents(fromVarCacheN, (response) => { LoadDataPageFunc.UpdateCartFull(response); });
/* let reqq = new RequestData(true);
reqq.fromVarCache(fromVarCacheN).data().url('/User/My/Details/Cart/data').type('POST')
.success((response) => {
LoadDataPageFunc.UpdateCartFull(response);
}).go(); */
};
LoadDataPageFunc.Main = function () {
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,450 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
.pdbottom {
overflow: hidden;
padding-bottom: 5px;
text-align: center;
}
</style>
<div id="MainView">
<div class="row" id="MainRowContainer">
<center>
<h3>Loading...</h3>
</center>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Product Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.ProductNotAvailableModalDismissed = false;
LoadDataPageFunc.NewMainColumn = function (id, Cardtitle, CardContent, CardID) {
return `<div class="col-md-12 pdbottom" style="" id="${id}Container">
${CreateCardSimple(Cardtitle, CardContent, CardID,)}
</div>`;
};
LoadDataPageFunc.PopulateDetailsNow = function (obj) {
const details = obj.details || '';
const total = details.total || 'Unknown';
const containerID = 'CardCartContainer';
let cardhtmlArr = [];
iterateArray(obj.cart, (item, key) => {
cardhtmlArr.push(LoadDataPageFunc.CartProductRow(item, key, false) + '<br><br>');
});
const cardhtml = cardhtmlArr.join('');
const CardCartColumn = LoadDataPageFunc.NewMainColumn('CardCartContainer', 'Items', cardhtml, 'CardCart')
const TotalPricehtml = `
<h1>Total Price: <h1>
<h1 id="TotalPrice" style="text-align: center;color: red;">${formatCurrency(total)}</h1>`;
const TotalPriceColumn = LoadDataPageFunc.NewMainColumn('TotalPriceCardContainer', false, TotalPricehtml, 'TotalPriceCard');
const AddressHtml = `
`;
const AddressColumn = LoadDataPageFunc.NewMainColumn('AddressContainer', "Address", AddressHtml, 'AddressCard');
const PurchaseHtml = buttonprimary(imgiconuserdefault("/assets/plus-cart.png") + 'Proceed Purchase', '', 'LoadDataPageFunc.ConfirmPurchase();');
const ConfirmPurchaseColumn = LoadDataPageFunc.NewMainColumn('PurchaseContainer', false, PurchaseHtml, 'PurchaseCard');
const finalhtml = CardCartColumn + TotalPriceColumn + AddressColumn + ConfirmPurchaseColumn;
$('#MainRowContainer').html(finalhtml);
};
LoadDataPageFunc.Settings.Phototype = "ProductMarket";
LoadDataPageFunc.CartProductRow = MarketUI.CartProductRow;
LoadDataPageFunc.BuySuccess = function () {
ModalQuickDismiss(false, 'Successfully Bought Product!', 'ModalConfirmBuySuccess');
gotoPage('PendingBuysProductMarket');
return;
};
LoadDataPageFunc.BuyFailed = function (response) {
ModalQuickDismiss(false, 'Unable to Complete Purchase!<br>' + response, 'ModalConfirmBuyFailed');
return;
};
LoadDataPageFunc.ConfirmPurchase = function () {
if (!LoadDataPageFunc.CurrentSelectedAddress) {
ModalQuickDismiss(false, 'Please select an address to proceed with purchase.', 'ModalConfirmBuy');
return false;
}
let reqqpurchase = new RequestData(false);
reqqpurchase.fromVarCache(false).data({ targetproduct: currenttarget }).url('/Buy/Complete/Purchase')
.success((response) => {
if (response !== true) { LoadDataPageFunc.BuyFailed(response); return false; }
else { LoadDataPageFunc.BuySuccess(); return true; }
}).go();
};
LoadDataPageFunc.BuyDetails = {};
LoadDataPageFunc.AddressDetails = false;
LoadDataPageFunc.CurrentSelectedAddress = false;
LoadDataPageFunc.NewAddressValidate = function () {
const name = $('#NewAddressName').val();
const address = $('#NewAddress').val();
const contactname = $('#NewContactName').val();
const contactnumber = $('#NewContactNumber').val();
const defaultaddress = $('#NewDefaultAddress').is(':checked');
if (!name || !address || !contactname || !contactnumber) {
return false;
}
return { 'name': name, 'address': address, 'contactname': contactname, 'contactnumber': contactnumber, 'default': defaultaddress };
}
LoadDataPageFunc.SubmitNewAddress = function () {
const addressformdata = LoadDataPageFunc.NewAddressValidate();
if (!addressformdata) {
ModalQuickDismiss(false, 'Please fill in all fields!');
return false;
}
let submitReq = new RequestData(false);
submitReq.fromVarCache(false).type('POST').url('/User/My/Add/Address').data(addressformdata).success(
(response) => {
if (!response) {
ModalQuickDismiss(false, 'Unable to add address!<br>', 'ModalAddAddressSubmitFailed');
return false;
}
modaldestroy();
hideallmodals();
LoadDataPageFunc.fetchAddresses((response) => {
//modalhide('NewAddressModal');
if (addressformdata.default) {
LoadDataPageFunc.CurrentSelectedAddress = LoadDataPageFunc.FindDefaultAddressBasedonAddressDetails();
LoadDataPageFunc.UpdateAddressCard(response);
}
LoadDataPageFunc.ShowAddressesModal();
});
}
).go();
};
LoadDataPageFunc.NewAddressModal = function () {
const textbox = function (placeholder, label, idsuffix, required = false, datalist = '') {
return UIInputGroup(placeholder, 'text', 'New' + idsuffix, label, formclass = '', spanclass = '', imginsteadofspan = '', required, textvalue = '', datalist, imgwidth = '', imgheight = '');
};
const name = textbox('Address Name', 'Address Name', 'AddressName', true);
const address = textbox('Address', 'Address', 'Address', true);
const contactname = textbox('Recipient Name for the Address', 'Recipient Name', 'ContactName', true);
const contactnumber = textbox('Recipient Number for the Address', 'Recipient Number', 'ContactNumber', true);
const checkbox = `<input class="btn btn-primary" type="checkbox" id="NewDefaultAddress">Set As Default?`;
const finalform = name + address + contactname + contactnumber + checkbox;
const footerbuttons = buttonprimary('Submit Address', '', 'LoadDataPageFunc.SubmitNewAddress();');
CreateAndShowModal('NewAddressModal', 'New Address', finalform, footerbuttons, false);
};
LoadDataPageFunc.SelectCurrentAddress = function () {
const selectedaddress = LoadDataPageFunc.GetSelectAddressUIFields();
LoadDataPageFunc.CurrentSelectedAddress= selectedaddress;
LoadDataPageFunc.UpdateAddressCard([LoadDataPageFunc.CurrentSelectedAddress]);
hideallmodals();
modaldestroy();
//capture select control value and index and all textbox inside
//show confirm Address selection modal
//update LoadDataPageFunc.CurrentSelectedAddress
//Update Address Card
//close ShowAddressesModal and other Modals
};
LoadDataPageFunc.SelectedKey = false;
LoadDataPageFunc.SetAsDefault = function () {
const defaultkey = $('#InputSelectedAddress').val();
let addressui = LoadDataPageFunc.GetSelectAddressUIFields();
const datatosend = {
'name': addressui[1], 'address': addressui[0],
'contactname': addressui[2],
'contactnumber': addressui[3],
'key': defaultkey
};
let setasDefaultFetch = new RequestData(false);
setasDefaultFetch.url('/User/My/SetasDefault/Address/').type('POST').data(datatosend).fromVarCache(false)
.success((response) => {
if (!response) {
ModalQuickDismiss(false, 'Error Try Again Later');
return false;
}
ModalQuickDismiss(false, 'Success');
LoadDataPageFunc.fetchAddresses((response) => {
LoadDataPageFunc.AddressDetails = response;
LoadDataPageFunc.CurrentSelectedAddress = LoadDataPageFunc.FindDefaultAddressBasedonAddressDetails();
hideallmodals();
modaldestroy();
LoadDataPageFunc.ShowAddressesModal();
});
}).go();
};
LoadDataPageFunc.ShowAddressesModal = function () {
const title = 'Select Address';
let modalbody = '<div style="text-align:center;">No Address</div>';
const selectbutton = buttonprimary('Select Address', '', 'LoadDataPageFunc.SelectCurrentAddress();');
const Newbutton = buttonwarning('New Address', '', 'LoadDataPageFunc.NewAddressModal();');
const setasdefaultbutton = buttonprimary('Set As Default', '', 'LoadDataPageFunc.SetAsDefault();');
let footerbuttons = '';
let selectarray = [];
let selectedkey = -1;
const CurrentSelectedAddress = LoadDataPageFunc.CurrentSelectedAddressOBJ();
const selectedname = CurrentSelectedAddress['name'];
const selectedaddress = CurrentSelectedAddress['address'];
const selectedcontactname = CurrentSelectedAddress['contactname'];
const selectedcontactnumber = CurrentSelectedAddress['contactnumber'];
let UIAddressField = {};
UIAddressField.name = '';
UIAddressField.address = '';
UIAddressField.contactname = '';
UIAddressField.contactnumber = '';
if (!LoadDataPageFunc.AddressDetails) {
footerbuttons = Newbutton;
} else {
footerbuttons = selectbutton + setasdefaultbutton + Newbutton;
}
if (LoadDataPageFunc.AddressDetails) {
selectarray = [];
selectedkey = -1;
iterateArray(LoadDataPageFunc.AddressDetails, (item, key) => {
const name = item[1];
const address = item[0];
const contactname = item[2];
const contactnumber = item[3];
if (name === selectedname && address === selectedaddress && contactname === selectedcontactname && contactnumber === selectedcontactnumber) {
selectedkey = key;
} else {
}
selectarray.push([key, name]);
});
if (selectedkey > -1) {
LoadDataPageFunc.SelectedKey = selectedkey;
} else {
LoadDataPageFunc.SelectedKey = false;
}
const InputSelectHTML = UIInputGroupSelect('InputSelectedAddress', '', selectarray, '', '', selectedkey);
// UIArraytoOptionforSelect(selectarray,selectedkey);
//iterateArray() and
// if LoadDataPageFunc.CurrentSelectedAddress is present then find it in the obj and select it if not then show all addresses and default to obj.default
//Load SEleect Control
modalbody = InputSelectHTML + `
<h4 id="InputSelectContent-Name">${selectedname}</h4>
<h4 id="InputSelectContent-Address">${selectedaddress}</h4>
<h4 id="InputSelectContent-ContactName">${selectedcontactname}</h4>
<h4 id="InputSelectContent-ContactAddress">${selectedcontactnumber}</h4>
`;
footerbuttons = selectbutton + setasdefaultbutton + Newbutton;;
}
const finalmodal = CreateAndShowModal('ShowAddressesModal', 'Select Address', modalbody, footerbuttons, false);
if (!LoadDataPageFunc.SelectedKey) {
$('#InputSelectedAddress').val('');
}
const inputSelectedAddress = document.getElementById('InputSelectedAddress');
inputSelectedAddress.addEventListener('change', function (event) {
const value = event.target.value;
LoadDataPageFunc.UpdateSelectAddressUIFields();
});
};
LoadDataPageFunc.GetSelectAddressUIFields = function () {
return [
$('#InputSelectContent-Address').html(),
$('#InputSelectContent-Name').html(),
$('#InputSelectContent-ContactName').html(),
$('#InputSelectContent-ContactAddress').html()];
}
LoadDataPageFunc.UpdateSelectAddressUIFields = function () {
const currentselected = $('#InputSelectedAddress').val();
if (currentselected === false || currentselected === null) { return false; }
const SelectedData = LoadDataPageFunc.AddressDetails[currentselected];
const selectedname = SelectedData[1];
const selectedaddress = SelectedData[0];
const selectedcontactname = SelectedData[2];
const selectedcontactnumber = SelectedData[3];
$('#InputSelectContent-Name').html(selectedname);
$('#InputSelectContent-Address').html(selectedaddress);
$('#InputSelectContent-ContactName').html(selectedcontactname);
$('#InputSelectContent-ContactAddress').html(selectedcontactnumber);
}
LoadDataPageFunc.FindDefaultAddressBasedonAddressDetails = function () {
let foundIndex = -1;
let arrayofArrays = LoadDataPageFunc.AddressDetails;
arrayofArrays.forEach((innerArray, index) => {
if (innerArray.length >= 4) {
if (typeof innerArray[4] !== 'undefined') {
const fourthElement = innerArray[4];
if (fourthElement === true) {
foundIndex = index;
}
}
}
});
if (foundIndex > -1) { return arrayofArrays[foundIndex]; } else { return false; }
};
LoadDataPageFunc.CurrentSelectedAddressOBJ = function () {
if (Array.isArray(LoadDataPageFunc.CurrentSelectedAddress)) {
const name = LoadDataPageFunc.CurrentSelectedAddress[1];
const address = LoadDataPageFunc.CurrentSelectedAddress[0];
const contactname = LoadDataPageFunc.CurrentSelectedAddress[2];
const contactnumber = LoadDataPageFunc.CurrentSelectedAddress[3];
const defaultaddress = LoadDataPageFunc.CurrentSelectedAddress[4];
return { 'name': name, 'address': address, 'contactname': contactname, "contactnumber": contactnumber };
} else { return false; }
};
LoadDataPageFunc.UpdateAddressCard = function (objAdd) {
const btn = button('Select Address', '', 'LoadDataPageFunc.ShowAddressesModal();', '', 'btn');
if (!LoadDataPageFunc.CurrentSelectedAddress) {
LoadDataPageFunc.CurrentSelectedAddress = LoadDataPageFunc.FindDefaultAddressBasedonAddressDetails();
}
if (!objAdd || !LoadDataPageFunc.CurrentSelectedAddressOBJ()) {
$('#card-body-AddressCard').html(btn);
return false;
}
const AddressData = LoadDataPageFunc.CurrentSelectedAddressOBJ();
const SelectaddressHTML = `<h6>${AddressData.name}</h6>
<h6>${AddressData.address}</h6>
<h6>${AddressData.contactname}</h6>
<h6>${AddressData.contactnumber}</h6>`;
$('#card-body-AddressCard').html(SelectaddressHTML + btn);
//FInd Default Address based on LoadDataPageFunc.CurrentSelectedAddress if false find in obj
};
LoadDataPageFunc.fetchAddresses = function (sucessfunc = false) {
let fetchAddressesNow = new RequestData(false);
fetchAddressesNow.fromVarCache(false).data(null).url('/User/My/Get/Addresses/data').type('POST')
.success((response) => {
LoadDataPageFunc.AddressDetails = response;
if (typeof sucessfunc === 'function') {
sucessfunc(response);
}
}).go();
};
LoadDataPageFunc.PopulateDetails = function () {
let description;
let photosarray;
let reqqW = new RequestData(false);
reqqW.fromVarCache(false).data({ cart: currenttarget }).url(`/User/My/Cart/Compute/data/`).type('POST')
.success((response) => {
LoadDataPageFunc.BuyDetails = response;
LoadDataPageFunc.PopulateDetailsNow(response);
}).go();
LoadDataPageFunc.fetchAddresses((response) => { LoadDataPageFunc.UpdateAddressCard(response); });
};
LoadDataPageFunc.ProductNotAvailable = function () {
const modalfooter = `
<button class="btn" onclick="Backkey();">Back</button>
<button class="btn" onclick="ButtonGo('ListProductsMarket')">All Products</button>
`;
CreateAndShowModal('modal-buyconfirm-productunavailable', false, 'Product Not Available', modalfooter, false);
$('#modal-buyconfirm-productunavailable').on('hidden.bs.modal', function () {
LoadDataPageFunc.Settings.ProductNotAvailableModalDismissed = true;
ButtonGo('ListProductsMarket');
});
};
LoadDataPageFunc.Main = function () {
// if (!currenttarget || currenttarget==='0'){ LoadDataPageFunc.ProductNotAvailable();return false;}
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,325 @@
<style>
.ListRowCard {
margin-bottom: 20px;
}
</style>
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let name = objectdata.name;
let unit = objectdata.unit || '';
let price = objectdata.price;
let description = objectdata.description || '';
let imgurl = objectdata.photo
let imgwidthheight = 150;
let hashkey = objectdata.hashkey;
let ahreflink = "ButtonGo('BuyViewProductMarket','" + hashkey + "');";
const maxDescriptionChars=80;
//imgurl = LoadDataPageFunc.GetPhotoURL(imgurl, rownum);
const columnsize = '6';
let brdescbefore = '';
if (description) {
brdescbefore = '<br><br>';
}
if (description.length > maxDescriptionChars) {
description = description.substring(0, maxDescriptionChars) + '...';
}
imagehtml = `<img id="marketplacelistproductphoto-${rownum}" src="/RequestData/File/${imgurl}" loading="lazy" class="" style="width: 60%;height: 60%;object-fit: contain;">`;
const style = "width: 100%; height: 100%; object-fit: cover;";
return `<div class="col-${columnsize}" style="overflow:hidden; padding-bottom:10px;">
<a href="javascript:void(0);" onclick="${ahreflink}">
<div class="card ListRowCard" id="ListRowCard-${rownum}" style="${style}">
<div id="cardheader-ListRowCard-${rownum}" class="card-header ui-sortable-handle" style="cursor: move;display:none;">
<h3 class="card-title" style="" id="card-title-ListRowCard-${rownum}"></h3>
<div class="card-tools" id="card-tools-ListRowCard-${rownum}">
</div>
</div>
<div class="card-body ListCardRow" id="card-body-ListRowCard-${rownum}">
<div style="text-align:center;">
${imagehtml}
</div>
<br>
<div class="row" style=""><div class="col"><h3>${name}</h3></div><div class="col">P${price} / ${unit}</div></div>
${brdescbefore}
<h5>${description}</h5>
<br>
</div>
</div>
</a>
</div>`;
};
LoadDataPageFunc.InitializeDynamicVariables = function () {
LoadDataPageFunc.URLs.QueryListData = '/Market/Products/List';
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewLeadDetails', '${data}')`;
};
LoadDataPageFunc.Settings.CurrentTargetRequired = false;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.GetPhotoURL = function (imgurl, rownum) {
if (!imgurl || !(typeof imgurl === 'string' && imgurl.length < 72)) { return '/assets/noproductphoto.png'; }
imghash= imgurl.slice(-72);
// photoblob = fileBlobURLList[imgurl] || false;
photoblob = Preloaders.getfileBlobURL(imghash);
if (photoblob){
$('#marketplacelistproductphoto-' + rownum).attr('src', bloburl);
}else{$('#marketplacelistproductphoto-' + rownum).attr('src', imgurl);}
/* imgurl = '/RequestData/File/' + imgurl;
LoadAndCreateURLfromFileHash(imgurl).then(bloburl => {
if (!bloburl) {
bloburl = '/assets/noproductphoto.png';
imgurl = '/assets/noproductphoto.png';
}
$('#marketplacelistproductphoto-' + rownum).attr('src', bloburl);
}).catch((err) => {
imgurl = '/assets/noproductphoto.png';
}); */
return imgurl;
};
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.PageName = 'List';
LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage = 'No Data';
LoadDataPageFunc.Settings.DefaultRequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.MainContainer = 'ListMainContainer';
LoadDataPageFunc.ids.SearchInput = 'List_Search';
LoadDataPageFunc.ids.ListContainer = 'ListRowCard';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
LoadDataPageFunc.URLs = {};
$$$ = {};
$$$.UpdateMainContainer = function (html) {
$('#' + LoadDataPageFunc.ids.MainContainer).html(html);
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewDetails', '${data}')`;
};
LoadDataPageFunc.CheckCachefromURLandChangeURLToBlob = function (photourl) {
if (!photourl) { return ''; }
photoblob = reqcacheload(photourl);
if (photoblob) {
photourl = URL.createObjectURL(photoblob);
}
return photourl;
}
LoadDataPageFunc.ClearSearch = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).val('');
$('#' + LoadDataPageFunc.ids.SearchInput).trigger('keyup');
};
LoadDataPageFunc.GenerateListfromResponse = function (response) {
let newhtmlrows = ''; let htmlarrayrows = [];
const count = response.length;
let hashkey;
let colsize = '6';
htmlarrayrows.push('<div class="row">');
for (let i = 0; i < count; i++) {
htmlarrayrows.push(LoadDataPageFunc.NewRow(response[i], i));
}
htmlarrayrows.push('</div>');
newhtmlrows = htmlarrayrows.join('');
return newhtmlrows;
};
LoadDataPageFunc.MemoizeGenerateListResponse = memoize(LoadDataPageFunc.GenerateListfromResponse);
LoadDataPageFunc.CardResultInterSectionPreloadDetails = function () {
let hashkey = '';
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const cardId = $(entry.target).attr('id');
const variablePart = cardId.split('-')[1];
const hashKeyDivId = LoadDataPageFunc.ids.HashKeyContainer + '-' + variablePart;
hashkey = $('#' + hashKeyDivId).text();
if (hashkey) {
request.url('/ViewLead/Details/data').success((response) => {
}).data({ target: hashkey }).fromVarCache(true).type('POST').go();
}
hashkey = '';
}
});
}, { threshold: 0.1 });
$('#' + LoadDataPageFunc.ids.ListContainer + ' .card').each(function () {
observer.observe(this);
});
};
LoadDataPageFunc.populatelist = function () {
let request = new RequestData(true);
request
.url(LoadDataPageFunc.URLs.QueryListData)
.type(LoadDataPageFunc.Settings.DefaultRequestType)
.data(null)
.fromVarCache(true)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response;
//let newhtmlrows =LoadDataPageFunc.MemoizeGenerateListResponse(List);
newhtmlrows = LoadDataPageFunc.GenerateListfromResponse(List);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
iterateArray(List,(item,key)=>{
LoadDataPageFunc.GetPhotoURL(item['photourl'],key);
});
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
//Disabled IMG URL caching from varcache and BLob due to massive slowdown
//now Relying on service worker
//interceptImageSrcandChangetoBlob(fromvarcache = true, replacewithnologo = true);
})
.error((err) => {
console.error(err);
})
.go();
};
LoadDataPageFunc.SearchKeyUPListPage = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).on('keyup', function () {
let searchTerm = $(this).val().toLowerCase();
$('#' + LoadDataPageFunc.ids.ListContainer + ' .card').each(function () {
let title = $(this).find('.card-title').text().toLowerCase();
let cols = $(this).find('.col').text().toLowerCase();
let h4 = $(this).find('h4').text().toLowerCase();
let h3 = $(this).find('h3').text().toLowerCase();
let h2 = $(this).find('h2').text().toLowerCase();
let h1 = $(this).find('h1').text().toLowerCase();
let h5 = $(this).find('h5').text().toLowerCase();
let h6 = $(this).find('h6').text().toLowerCase();
if (title.includes(searchTerm) || cols.includes(searchTerm) ||
h1.includes(searchTerm) || h2.includes(searchTerm) || h3.includes(searchTerm)
|| h4.includes(searchTerm) || h5.includes(searchTerm) || h6.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
};
LoadDataPageFunc.main = function () {
if (LoadDataPageFunc.Settings.CurrentTargetRequired && (!currenttarget || currenttarget === '0')) {
$$$.UpdateMainContainer('<center>No Target<br><br>' + buttonprimary('View All Leads', '', "ButtonGo('ListLeads', '')") +
'<br><br>' + buttonprimary('Home', '', "ButtonGo('Home', '')") + '</center>'); return false;
}
const searchcard = UIInputGroup('Search', 'text', LoadDataPageFunc.ids.SearchInput, '', classs = '', span = '', '/assets/clear.png');
let LeadsListContainer = UICardSimple('', 'Loading Please Wait...', LoadDataPageFunc.ids.ListContainer);
LeadsListContainer = '<div id="' + LoadDataPageFunc.ids.ListContainer + '"><center>Loading Please Wait...</center></div>';
const FinalInnerHTML = searchcard + LeadsListContainer;
const MainCard = UICardSimple('', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
LoadDataPageFunc.LoadNow = function () {
LoadDataPageFunc.InitializeDynamicVariables();
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
LoadDataPageFunc.SearchKeyUPListPage();
changeTopbarTitle('Products');
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
};
LoadDataPageFunc.LoadNow();
</script>

View File

@@ -0,0 +1,325 @@
<style>
.ListRowCard {
margin-bottom: 20px;
}
</style>
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let name = objectdata.name;
let unit = objectdata.unit || '';
let price = objectdata.price;
let description = objectdata.description || '';
let imgurl = objectdata.photo
let imgwidthheight = 150;
let hashkey = objectdata.hashkey;
let ahreflink = "ButtonGo('BuyViewProductMarket','" + hashkey + "');";
const maxDescriptionChars=80;
//imgurl = LoadDataPageFunc.GetPhotoURL(imgurl, rownum);
const columnsize = '6';
let brdescbefore = '';
if (description) {
brdescbefore = '<br><br>';
}
if (description.length > maxDescriptionChars) {
description = description.substring(0, maxDescriptionChars) + '...';
}
imagehtml = `<img id="marketplacelistproductphoto-${rownum}" src="/RequestData/File/${imgurl}" loading="lazy" class="" style="width: 60%;height: 60%;object-fit: contain;">`;
const style = "width: 100%; height: 100%; object-fit: cover;";
return `<div class="col-${columnsize}" style="overflow:hidden; padding-bottom:10px;">
<a href="javascript:void(0);" onclick="${ahreflink}">
<div class="card ListRowCard" id="ListRowCard-${rownum}" style="${style}">
<div id="cardheader-ListRowCard-${rownum}" class="card-header ui-sortable-handle" style="cursor: move;display:none;">
<h3 class="card-title" style="" id="card-title-ListRowCard-${rownum}"></h3>
<div class="card-tools" id="card-tools-ListRowCard-${rownum}">
</div>
</div>
<div class="card-body ListCardRow" id="card-body-ListRowCard-${rownum}">
<div style="text-align:center;">
${imagehtml}
</div>
<br>
<div class="row" style=""><div class="col"><h3>${name}</h3></div><div class="col">P${price} / ${unit}</div></div>
${brdescbefore}
<h5>${description}</h5>
<br>
</div>
</div>
</a>
</div>`;
};
LoadDataPageFunc.InitializeDynamicVariables = function () {
LoadDataPageFunc.URLs.QueryListData = '/Market/Products/Wholesale/List';
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewLeadDetails', '${data}')`;
};
LoadDataPageFunc.Settings.CurrentTargetRequired = false;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.GetPhotoURL = function (imgurl, rownum) {
if (!imgurl || !(typeof imgurl === 'string' && imgurl.length < 72)) { return '/assets/noproductphoto.png'; }
imghash= imgurl.slice(-72);
// photoblob = fileBlobURLList[imgurl] || false;
photoblob = Preloaders.getfileBlobURL(imghash);
if (photoblob){
$('#marketplacelistproductphoto-' + rownum).attr('src', bloburl);
}else{$('#marketplacelistproductphoto-' + rownum).attr('src', imgurl);}
/* imgurl = '/RequestData/File/' + imgurl;
LoadAndCreateURLfromFileHash(imgurl).then(bloburl => {
if (!bloburl) {
bloburl = '/assets/noproductphoto.png';
imgurl = '/assets/noproductphoto.png';
}
$('#marketplacelistproductphoto-' + rownum).attr('src', bloburl);
}).catch((err) => {
imgurl = '/assets/noproductphoto.png';
}); */
return imgurl;
};
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.PageName = 'List';
LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage = 'No Data';
LoadDataPageFunc.Settings.DefaultRequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.MainContainer = 'ListMainContainer';
LoadDataPageFunc.ids.SearchInput = 'List_Search';
LoadDataPageFunc.ids.ListContainer = 'ListRowCard';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
LoadDataPageFunc.URLs = {};
$$$ = {};
$$$.UpdateMainContainer = function (html) {
$('#' + LoadDataPageFunc.ids.MainContainer).html(html);
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewDetails', '${data}')`;
};
LoadDataPageFunc.CheckCachefromURLandChangeURLToBlob = function (photourl) {
if (!photourl) { return ''; }
photoblob = reqcacheload(photourl);
if (photoblob) {
photourl = URL.createObjectURL(photoblob);
}
return photourl;
}
LoadDataPageFunc.ClearSearch = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).val('');
$('#' + LoadDataPageFunc.ids.SearchInput).trigger('keyup');
};
LoadDataPageFunc.GenerateListfromResponse = function (response) {
let newhtmlrows = ''; let htmlarrayrows = [];
const count = response.length;
let hashkey;
let colsize = '6';
htmlarrayrows.push('<div class="row">');
for (let i = 0; i < count; i++) {
htmlarrayrows.push(LoadDataPageFunc.NewRow(response[i], i));
}
htmlarrayrows.push('</div>');
newhtmlrows = htmlarrayrows.join('');
return newhtmlrows;
};
LoadDataPageFunc.MemoizeGenerateListResponse = memoize(LoadDataPageFunc.GenerateListfromResponse);
LoadDataPageFunc.CardResultInterSectionPreloadDetails = function () {
let hashkey = '';
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const cardId = $(entry.target).attr('id');
const variablePart = cardId.split('-')[1];
const hashKeyDivId = LoadDataPageFunc.ids.HashKeyContainer + '-' + variablePart;
hashkey = $('#' + hashKeyDivId).text();
if (hashkey) {
request.url('/ViewLead/Details/data').success((response) => {
}).data({ target: hashkey }).fromVarCache(true).type('POST').go();
}
hashkey = '';
}
});
}, { threshold: 0.1 });
$('#' + LoadDataPageFunc.ids.ListContainer + ' .card').each(function () {
observer.observe(this);
});
};
LoadDataPageFunc.populatelist = function () {
let request = new RequestData(true);
request
.url(LoadDataPageFunc.URLs.QueryListData)
.type(LoadDataPageFunc.Settings.DefaultRequestType)
.data(null)
.fromVarCache(true)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response;
//let newhtmlrows =LoadDataPageFunc.MemoizeGenerateListResponse(List);
newhtmlrows = LoadDataPageFunc.GenerateListfromResponse(List);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
iterateArray(List,(item,key)=>{
LoadDataPageFunc.GetPhotoURL(item['photourl'],key);
});
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
//Disabled IMG URL caching from varcache and BLob due to massive slowdown
//now Relying on service worker
//interceptImageSrcandChangetoBlob(fromvarcache = true, replacewithnologo = true);
})
.error((err) => {
console.error(err);
})
.go();
};
LoadDataPageFunc.SearchKeyUPListPage = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).on('keyup', function () {
let searchTerm = $(this).val().toLowerCase();
$('#' + LoadDataPageFunc.ids.ListContainer + ' .card').each(function () {
let title = $(this).find('.card-title').text().toLowerCase();
let cols = $(this).find('.col').text().toLowerCase();
let h4 = $(this).find('h4').text().toLowerCase();
let h3 = $(this).find('h3').text().toLowerCase();
let h2 = $(this).find('h2').text().toLowerCase();
let h1 = $(this).find('h1').text().toLowerCase();
let h5 = $(this).find('h5').text().toLowerCase();
let h6 = $(this).find('h6').text().toLowerCase();
if (title.includes(searchTerm) || cols.includes(searchTerm) ||
h1.includes(searchTerm) || h2.includes(searchTerm) || h3.includes(searchTerm)
|| h4.includes(searchTerm) || h5.includes(searchTerm) || h6.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
};
LoadDataPageFunc.main = function () {
if (LoadDataPageFunc.Settings.CurrentTargetRequired && (!currenttarget || currenttarget === '0')) {
$$$.UpdateMainContainer('<center>No Target<br><br>' + buttonprimary('View All Leads', '', "ButtonGo('ListLeads', '')") +
'<br><br>' + buttonprimary('Home', '', "ButtonGo('Home', '')") + '</center>'); return false;
}
const searchcard = UIInputGroup('Search', 'text', LoadDataPageFunc.ids.SearchInput, '', classs = '', span = '', '/assets/clear.png');
let LeadsListContainer = UICardSimple('', 'Loading Please Wait...', LoadDataPageFunc.ids.ListContainer);
LeadsListContainer = '<div id="' + LoadDataPageFunc.ids.ListContainer + '"><center>Loading Please Wait...</center></div>';
const FinalInnerHTML = searchcard + LeadsListContainer;
const MainCard = UICardSimple('', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
LoadDataPageFunc.LoadNow = function () {
LoadDataPageFunc.InitializeDynamicVariables();
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
LoadDataPageFunc.SearchKeyUPListPage();
changeTopbarTitle('Products');
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
};
LoadDataPageFunc.LoadNow();
</script>

View File

@@ -0,0 +1,144 @@
<div id="NewProductForm">
</div>
<script>
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.NewUrl = `/Products/New/${currenttarget}`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Products/New/Category/Datalist`;
LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Product`;
LoadDataPageFunc.PageTitle = 'New Product';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'NewProductPhotos';
LoadDataPageFunc.formclass = 'NewProductMarket';
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped = function () {
document.getElementById("NewProductCategory").addEventListener("keyup", function (event) {
const inputValue = event.target.value;
const categoryinputvalue = document.getElementById("NewProductCategory").value;
QueryandReplaceDatalist("NewProductSubCategoryDataList", LoadDataPageFunc.URLs.SubCategoryDatalist, 'POST', {category:categoryinputvalue}, fromvarcache = true);
});
};
LoadDataPageFunc.LoadUI = function () {
let finalhtml = '';
const formclass = LoadDataPageFunc.formclass;
const textbox = function (placeholder, label, idsuffix, required = false, datalist = '') {
return UIInputGroup(placeholder, 'text', 'New' + idsuffix, label, formclass, spanclass = '', imginsteadofspan = '', required, textvalue = '', datalist, imgwidth = '', imgheight = '');
};
const name = textbox('Product Name', 'Name', 'ProductName', true);
const description = UIInputGroupTEXTAREA(label = 'Description', 'NewProductDescription', required = true, textareacontent = '', formclass);
const category = textbox('Product Category', 'Category', 'ProductCategory', true, 'NewProductCategoryDataList');
const categorydatalist = ArraytoDatalist("NewProductCategoryDataList", [], false) || '';
const subcategory = textbox('Product Subcategory', 'Subcategory', 'ProductSubCategory', true, 'NewProductSubCategoryDataList');
const subcategorydatalist = ArraytoDatalist("NewProductSubCategoryDataList", [], false) || '';
const photoscontainer = UIInputGroupFileUploadDropzone(LoadDataPageFunc.ids.photodropzone, label = 'Photo', LoadDataPageFunc.URLs.PhotoUpload);
const price = UIInputGroupNumber('Price in Philippine Pesos', 'NewProductPrice', 'Price', formclass, 1, max = '', spanclass = '', imginsteadofspan = '', required = true, val = 1, datalist = '', imgwidth = '', imgheight = '');
const unit = textbox('ex 25kg', 'Unit', 'ProductUnitName', true);
const available = UIInputGroupNumber('Available Stock', 'NewProductAvailable', 'No of Stock', formclass, 1, max = '', spanclass = '', imginsteadofspan = '', required = true, val = 1, datalist = '', imgwidth = '', imgheight = '');
let barcode = textbox('12 Digits Barcode Number', 'Barcode', 'ProductBarcode', false);
barcode = $('<div>' + barcode + '</div>');
barcodeinput = barcode.find('input');
barcodeinput.attr('maxlength', 12).attr('pattern', '[0-9]*').on('input', function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
barcode = barcode.html();
const submitbutton = UIInputGroupButton('Submit', formclass, buttonid = '', onclick = 'LoadDataPageFunc.TryToSubmit();', buttonstyle = '');
finalhtml = name + description + category + categorydatalist + subcategory + subcategorydatalist + photoscontainer + price + unit + available + barcode + submitbutton;
finalhtml = CreateCardSimple(false, finalhtml);
document.getElementById('NewProductForm').innerHTML = finalhtml;
QueryandReplaceDatalist("NewProductCategoryDataList", LoadDataPageFunc.URLs.CategoryDatalist, 'POST', datatosend = null, fromvarcache = true);
QueryandReplaceDatalist("NewProductSubCategoryDataList", LoadDataPageFunc.URLs.SubCategoryDatalist, 'POST', datatosend = null, fromvarcache = true);
InitializeLoadDataPageFuncDropZonePhotoUpload(LoadDataPageFunc.URLs.PhotoUpload, LoadDataPageFunc.ids.photodropzone, ShowClearPhotoFUNC = '', clearphotosbuttonid = 'clearuploadbutton', acceptedfiles = '', maxsizeMB = 100);
LoadDataPageFunc.InitializePhotoDropZone();
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped();
};
LoadDataPageFunc.TryToSubmit = function () {
const errorModal = function (errorstring = '') {
ModalQuickDismiss('Error', 'Unable Submit To New Product. <br>' + errorstring, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
};
const successModal = function () {
hideallmodals();
ModalQuickDismiss('Success', 'New Product Submitted');
};
const submitsuccess = function (response) {
if (!response) {
errorModal();
return false;
}
if (response) {
Preloaders.ViewProductinMarket(response);
successModal();
gotoPage('BuyViewProductMarket', response);
return true;
}
};
SendPostDataFormwithTARGETUPLOADEDFILES(LoadDataPageFunc.URLs.NewUrl, LoadDataPageFunc.formclass, submitsuccess);
};
LoadDataPageFunc.ValidateForm = function () {
let inputsArray = getInputElementsValuesObjectbyCSSClassname(LoadDataPageFunc.formclass);
if (isObjectEmpty(inputsArray)) { return false; }
const isAnyoftheRequiredEmpty = !inputsArray['NewProductName'] || !inputsArray['NewProductDescription'] || !inputsArray['NewProductCategory'] || !inputsArray['NewProductSubCategory'] ||
!inputsArray['NewProductPrice'] || !inputsArray['NewProductAvailable'] || !inputsArray['NewProductUnitName'] || Target_Uploaded_Files.length === 0;
const isBarcodeNumeric = inputsArray['NewProductBarcode'] && isNumeric(inputsArray['NewProductBarcode']);
if (isAnyoftheRequiredEmpty || isBarcodeNumeric === false) {
return false;
}
const IsBarcodeValid = IsStringBarcode12Digits(inputsArray['NewProductBarcode']);
return true;
};
LoadDataPageFunc.Main = function () {
if (!currenttarget || currenttarget === '0') {
const modalbody = 'Unable to Load Store Details.';
const modalfooter = buttonGOTOPage('Home', 'Home', 0, '', 'hideallmodals();');;
ModalQuickDismiss(false, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter);
Backkey();
return false;
}
LoadDataPageFunc.LoadUI();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,186 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<div id="MainView" style="padding-top: 5px;">
<div class="row" id="CartListRow" style="margin-top: 5px; margin-bottom: 5px;">
</div>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Pending Delivery';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.SetQuantityUI = function (newquantity, rownum) {
if (typeof rownum !== 'number') { return false; }
if (typeof newquantity !== 'number') { return false; }
let controlid = "ProductCartMarket-" + rownum;
$('#' + controlid).html(newquantity);
const newvalue = $('#' + controlid).html();
if (newquantity !== newvalue) { return false; }
return true;
};
LoadDataPageFunc.FindRowNumByHash = function (hashkey) {
let element = $('[data-hash="' + hashkey + '"]');
if (element.length === 0) { return false; }
let nrownum = element.data('rownum');
return nrownum
};
LoadDataPageFunc.SetQuantitybyHash = function (newquantity, hashkey) {
if ( !hashkey || typeof hashkey !== 'string') { return false; }
let rownum = '';
rownum =LoadDataPageFunc.FindRowNumByHash(hashkey);
if (rownum===false) { return false; }
const changequantity = LoadDataPageFunc.SetQuantityUI(newquantity, rownum);
if (!changequantity) { return false; }
return true;
};
LoadDataPageFunc.UpdateProductQuantityCart=function(response,producthash){
if (response === false) { return false; }
if (typeof response !== 'number') {
return false;
};
return LoadDataPageFunc.SetQuantitybyHash(response, producthash);
};
LoadDataPageFunc.RequestData = new RequestData(false);
LoadDataPageFunc.PendingDeliveryRow = function (rowdata, rownum) {
const hashkey = rowdata.hashkey || false;
if (!hashkey){return '';}
let productviewonclick = "ButtonGo('TransactionDetailsProductMarket','" + hashkey + "');";
const photourlsArray = rowdata.photourl;
let photourl = ''
if (photourlsArray && typeof photourlsArray === "array") {
photourl = photourlsArray[0];
} else {
photourl = photourlsArray;
}
const name = rowdata.name;
const price = rowdata.transactionprice |'';
const unit = rowdata.unit;
const items=rowdata.noofitems;
const transactiondate= formatDateTimetoReadable(rowdata.date) || '';
const priceperunit = 'P' + price + ' / ' + unit;
photourl = '/RequestData/File/' + photourl;
const transactioncode =rowdata.transactioncode ||'';
return `<div class="col-md card ListRowCard" style="overflow:hidden;" data-hash="${hashkey}" data-rownum="${rownum}">
<div class="row">
<div class="col" id ="product-image-marketplace-pendingbuys-${rownum}" style=" padding-top: 10px; padding-bottom: 10px;">
<a href="javascript:void(0);" onclick="${productviewonclick}">
<img id="ProductPendingBuysMarketPlacePhoto-${rownum}" src="${photourl}" style="width: 200px;height: 200px;">
</a>
</div>
<div class="col" id=${'product-controls-pendingbuys-marketplace-container-' + rownum}>
<div class="row">
<div class="col">
</div>
<div class="col-12" style=" padding-top: 10px;text-align:center;">
<h6 style="font-weight:200;">${transactioncode}<br>${transactiondate}</h6>
<h3>${name}<br>...</h3>
<h6>${'Total items '+items}</h6>
</div>
<div class="col-12 " style="text-align: center;">
<br><br>
<h1 id="PendingBuysMarket-${rownum}">Total Price: P${price}</h1>
</div>
<div class="col-12">
<br><br>
</div>
</div>
</div>
</div>
</div>`;
};
LoadDataPageFunc.PopulateDetails = function () {
let reqq = new RequestData(true);
reqq.fromVarCache(true).data().url('/marketplace/pending/delivery').type('POST')
.success((response) => {
let htmllist = []; let finalhtml = '';
response =[];
response[0]={
hashkey:'afrvfdv',
date:'2024-04-29 21:26:09',
photourl:'d5650f203fcd447bc7c409f9f0d06a67315041dcd3fd599f63b80d8fe5cc95734b644c2d',
transactionprice: 200,
transactioncode:'BM-06A67315041DCD3FD-2024',
name: 'Sinandomeng',
noofitems: 3,
trackingnumber:'PXA38U67',
};
response[1]={
hashkey:'ddddd',
date:'2024-04-29 21:26:09',
photourl:'d5650f203fcd447bc7c409f9f0d06a67315041dcd3fd599f63b80d8fe5cc95734b644c2d',
transactionprice: 200,
transactioncode:'BM-06A67315041DCD3FD-2024',
name: 'cocopandan',
noofitems: 3,
trackingnumber:'PXA38U67',
} ;
if (!response) { return false; }
LoopArrayorObject(response, (item,rownum) => {
htmllist.push(LoadDataPageFunc.PendingDeliveryRow(item, rownum));
});
finalhtml = htmllist.join('');
$('#CartListRow').html(finalhtml);
LoopArrayorObject(response, (item,rownum) => {
LoadAndCreateURLfromFileHash(item.photourl).then(bloburl => {
const imgid = 'ProductPendingBuysMarketPlacePhoto-' + rownum;
$('#ProductPendingBuysMarketPlacePhoto-' + rownum).attr('src', bloburl);
});
});
}).go();
};
LoadDataPageFunc.Main = function () {
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>