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,251 @@
// Import Workbox (https://developers.google.com/web/tools/workbox/)
var SWInterval = {};
importScripts('/synclib.js');
self.__WB_MANIFEST = PrecacheStaticURLs;
importScripts('/dist/js/workbox-sw.js');
const { precacheAndRoute, registerRoute } = workbox.routing;
const { StaleWhileRevalidate, CacheFirst, NetworkFirst } = workbox.strategies;
const { BackgroundSyncPlugin } = workbox.backgroundSync;
// Precaching static assets
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST || []);
const urlsToCache = PrecacheStaleRevalidateURLs;
registerRoute(
({ request }) => {
return urlsToCache.includes(new URL(request.url).pathname);
},
new StaleWhileRevalidate({
cacheName: 'page-stale-while-revalidate-cache', // Name of the cache
plugins: [
],
})
);
function fetchStaleWhileRevalidate(NewurlsToCache){
registerRoute(
({ request }) => {
return NewurlsToCache.includes(new URL(request.url).pathname);
},
new StaleWhileRevalidate({
cacheName: 'new-page-stale-while-revalidate-cache',
plugins: [
],
})
);
}
// registerRoute(
// ({ url }) => url.pathname.startsWith('/RequestData/File/'),
// new CacheFirst({
// cacheName: 'request-data-cache',
// plugins: [
// {
// cacheableResponse: {
// statuses: [0, 200], // Cache responses with status 0 or 200
// },
// },
// {
// expiration: {
// maxAgeSeconds: 30 * 24 * 60 * 60, // Cache for 30 days
// maxEntries: 2000, // Limit to 2000 entries
// },
// },
// ],
// })
// );
// workbox.routing.registerRoute(
// ({ url }) => url.pathname.startsWith('/RequestData/File/'),
// new workbox.strategies.CacheFirst({
// cacheName: 'request-data-cache',
// plugins: [
// new workbox.cacheableResponse.CacheableResponsePlugin({
// statuses: [0, 200],
// }),
// new workbox.expiration.ExpirationPlugin({
// maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
// maxEntries: 2000,
// }),
// ],
// })
// );
workbox.routing.registerRoute(
({ url }) => {
console.log('Checking URL:', url.href);
return url.pathname.startsWith('/RequestData/File/');
},
async ({ request }) => {
console.log('Fetching:', request.url);
const cache = await caches.open('request-data-cache');
const cachedResponse = await cache.match(request);
if (cachedResponse) {
console.log('Serving from cache:', request.url);
return cachedResponse;
}
console.log('Network request:', request.url);
const response = await fetch(request);
// Clone the response before caching
if (response && response.status === 200) {
cache.put(request, response.clone());
console.log('Stored in cache:', request.url);
}
return response;
}
);
// workbox.routing.registerRoute(
// ({ url }) => url.pathname.startsWith('/RequestData/File/'),
// async ({ request }) => {
// console.log('Fetching:', request.url);
// const cache = await caches.open('request-data-cache');
// const response = await cache.match(request);
// if (response) {
// console.log('Serving from cache:', request.url); // Log if served from cache
// return response;
// }
// console.log('Network request:', request.url); // Log network request
// return fetch(request);
// }
// );
self.addEventListener('install', event => {
console.log('Service Worker installed');
self.skipWaiting();
});
self.addEventListener('activate', event => {
console.log('Service Worker activated');
event.waitUntil(
self.clients.claim()
);
});
function PostMessage(objecttosend) {
self.clients.matchAll().then(clients => {
if (clients.length === 0) {
// console.log('No clients found to send messages.');
}
clients.forEach(client => {
// console.log('Sending message to client:', client);
client.postMessage(objecttosend);
});
}).catch(error => {
// console.error('Error fetching clients:', error);
});
}
/*
async function fetchDataAndProcess(url, callback = null, method = 'GET', data = null, log = false) {
if (log) {console.log('Trying to fetch', url, callback, 'method', method, 'data', data); }
if(!navigator.onLine){return false;}
try {
const options = {
method: method,
headers: {
'Content-Type': 'application/json'
}
};
if (data && (method === 'POST' || method === 'PUT')) {
try {
options.body = JSON.stringify(data);
} catch (error) {
options.body = data;
}
}
const response = await fetch(url, options);
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
const responseClone = response.clone();
let responseData;
try {
responseData = await responseClone.json();
} catch (error) {
responseData = await response.text();
}
if (callback && typeof callback === 'function') {
if (log) {
console.log('Running callback');
}
callback(responseData);
}
} catch (error) {
if(log){
console.log('There has been a problem with your fetch operation: ', url, error);
}
}
}
function FetchDataAndPostInterval(url,type,interval){
if (!url || !type || !interval){return false;}
if (SWInterval[type]) {
console.warn(`Interval for type "${type}" is already set. Aborting.`);
return;
}
function sendPostCode(response){
PostMessage({type:type,'data':response});
}
SWInterval[type] = setInterval(() => fetchDataAndProcess(getFullURL(url), sendPostCode), interval);
}
function checkIfHostIsOnline() {
// Get the current host from window.location
const host = window.location.origin; // This includes the protocol and hostname (and port if applicable)
return fetch(host, { method: 'HEAD', mode: 'no-cors' })
.then(() => true) // If the fetch is successful, return true
.catch(() => false); // If there's an error, return false
}
*/
function INIT() {
//FetchDataAndPostInterval('/get/isloggedin', 'loggedin', 10000);
//FetchDataAndPostInterval('/get/isExec', 'exec', 10000);
}
self.addEventListener('message', event => {
if (event.data.type == 'INIT') {
//INIT();
}
});

647
legacy/init/starter.js Normal file
View File

@@ -0,0 +1,647 @@
var total_balance = null;
var memory_cache = {};
var user_settings = [];
var SetIntervalIsLoggedINFallback;
var SetIntervalIsExecINFallback;
var ServiceWorkerMessagesWorking = 0;
var AutoSuncFUnctionStarted = 0;
var request = new RequestData(false);
var requestWHash = new RequestData(true);
var LoadDataPageFunc;
var InttoStrDetailsFuncs = {};
var Preloaders = {};
var ReusableUIElements = {};
var cacmemocachehe = {};
var currentNoOfPrecacheRequests = [];
var CurrentPageisLoading = false;
var ShoppingCart = false;
var DontInitialize = 0;
var PreloaderGetFileBlob_Operations = 0;
var PreloaderGetFileBlob_Intervals = [];
var devmode = true;
var currentData = null;
var DataCore = {
'Store': {},
'Product': {},
'User': {},
};
const FormSchemas = {};
var PageCounterTracker=0;
initGlobal('tabledata');
initGlobal('Buttons',[]);
initGlobal('defaultbackpage');
var defaultBackOnclick = null;
if (typeof DontInitialize === 'undefined') {
var DontInitialize = 0;
}
function logDev(...args) {
if (devmode) {
console.log(...args);
}
}
/*
const { fetch: originalFetch } = window;
window.fetch = async (...args) => {
let [resource, config] = args;
if (resource.startsWith("/RequestData/File/")){
console.log(reqcacheload(resource));
}
const response = await originalFetch(resource, config);
console.table('Response received:', response);
return response;
}; */
InitDataPageFuncOBJ();
Preloaders.getfileBlobURL = function (hashkey, fetchifdoesnotexist = true) {
if (hashkey.length > 72) {
hashkey = hashkey.slice(-72);
}
const targeturl = '/RequestData/File/' + hashkey;
const alturl = window.location.origin + targeturl;
const reqload1 = reqcacheload(targeturl);
const reqload2 = reqcacheload(alturl);
const PreloadFileBlob = async function () {
await Preloaders.QuickPrecacheFetch(targeturl, null, false, () => {
PreloaderGetFileBlob_Operations--;
}, 'GET').then(() => {
});
}
PreloaderGetFileBlob_Operations++;
const currentfetchOperation = PreloaderGetFileBlob_Operations;
if (!hashkey) { return false; }
if (typeof fileBlobURLList[hashkey] !== 'undefined') {
return fileBlobURLList[hashkey];
} else if (reqload1) {
fileBlobURLList[hashkey] = URL.createObjectURL(reqcacheload(targeturl));
return fileBlobURLList[hashkey];
} else {
PreloadFileBlob();
return false;
}
}
Preloaders.QuickPrecacheFetch = async function (url, obj = null, fromVarCache = false, successfunc = false, reqtype = 'POST') {
return new Promise((resolve, reject) => {
if (!url) {
return reject(new Error("URL is required"));
}
request.url(url).success((response) => {
if (typeof successfunc === 'function') {
successfunc(response);
}
if (url.includes('/RequestData/File/') && response) {
const fhash = url.slice(-72);
const bloburl = URL.createObjectURL(response);
fileBlobURLList[fhash] = bloburl;
}
resolve(response);
}).data(obj).fromVarCache(fromVarCache).type(reqtype).go();
});
};
Preloaders.ListData = async function (url, fromVarCache = false, successfunc = false, reqtype = 'POST', datatosend = null) {
if (!url) { return false; }
request.url(url).success((response) => { if (successfunc) { successfunc(response); } }).data(datatosend).fromVarCache(fromVarCache).type(reqtype).go();
};
Preloaders.ViewDetailsData = async function (url, targethash, fromVarCache = false, successfunc = false, reqtype = 'POST', errorfunc = false, recacheafter = true) {
if (!url || !targethash) { return false; }
let successfuncrun = 0;
request.url(url).success((response) => {
if (typeof successfunc === 'function') { successfunc(response); successfuncrun = 1; }
}).error((response) => { if (typeof errorfunc === 'function') { errorfunc(response); } }).data({ target: targethash }).fromVarCache(fromVarCache).type(reqtype).go();
if (recacheafter) {
request.url(url).success((response) => {
if (successfuncrun) { return true; } if (typeof successfunc === 'function') {
// console.log(recacheafter);
successfunc(response);
}
}).error((response) => { if (typeof errorfunc === 'function') { errorfunc(response); } }).data({ target: targethash }).fromVarCache(false).type(reqtype).go();
}
};
Preloaders.Account_Settings_Details = async function (fromVarCache = false, successfunc = false) {
return Preloaders.ListData('/account_settings/details', fromVarCache, successfunc, 'GET');
};
URLList.Datalist = {};
Preloaders.Datalist = {};
// Preloaders.PrecachePage = async function (url, targetidchange = '') {
// request.url(url).type('GET').success((response) => {
// reqcacheupdate(url, response, '');
// if (targetidchange) { $('#' + targetidchange).html(response); CurrentPageisLoading = false; }
// // $('#' + targetidchange).fadeIn();
// }).go();
// };
Preloaders.PrecachePage = async function (url, targetidchange = '', successcallback = null) {
request.url(url).type('GET').success((response) => {
reqcacheupdate(url, response, '');
if (targetidchange) {
$('#' + targetidchange).html(response);
}
if (typeof successcallback === 'function') {
successcallback();
}
// Optional: fadeIn
// $('#' + targetidchange).fadeIn();
}).go();
};
Preloaders.PreloadStaticPages = async function () {
Preloaders.PrecachePage(URLList.Pages.homepage);
Preloaders.PrecachePage(URLList.Pages.account_settings);
};
Preloaders.PrecacheStaticAssets = async function () {
let arr = PrecacheStaticURLs;
for (let i = 0; i < arr.length; i++) {
Preloaders.PrecachePage(arr[i].url);
}
};
Preloaders.ImageList = async function (targethash, phototype) {
Preloaders.ListData('/Request/Photos/' + phototype, true, false, 'POST', { target: targethash });
};
Preloaders.Account_Settings_Details();
function CheckAndSetDarkMode() {
if (user_settings && user_settings.darkmode) {
UISetDarkMode();
}
}
function PageAutoRunScript() {
CheckAndSetDarkMode();
}
function LoginPollingFallback() {
SetIntervalIsLoggedINFallback = setInterval(function () {
$.get("/get/isloggedin", function (response) {
MessageLogin(response);
}).fail(function () { });
}, 10000);
}
function ExecPollingFallback() {
SetIntervalIsExecINFallback = setInterval(function () {
$.get("/get/isExec", function (response) {
MessageExec(response);
}).fail(function () { });
}, 10000);
}
function AutoSyncFunctions() {
console.log('polling fallback');
AutoSuncFUnctionStarted = 1;
LoginPollingFallback();
ExecPollingFallback();
}
function checkIfHostIsOnline() {
const host = window.location.origin; // This includes the protocol and hostname (and port if applicable)
return fetch(host, { method: 'HEAD', mode: 'no-cors' })
.then(() => true)
.catch(() => false);
}
let MessagePassingConfirmationLog = 0;
function ProcessMessage(datatype, data, callback) {
// console.log('process message ',datatype, ' ',data);
if (datatype != data.type) { return false; }
if (!callback) { return false; }
callback(data.data);
}
function ProcessMessagesfromServiceWorker(event) {
if (!MessagePassingConfirmationLog) { console.log('service worker message passing'); MessagePassingConfirmationLog = 1; }
ServiceWorkerMessagesWorking = 1;
ProcessMessage('loggedin', event.data, MessageLogin);
ProcessMessage('exec', event.data, MessageExec);
}
async function registerServiceWorker() {
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations();
if (registrations.length > 0) {
console.log('Service Worker is already registered.');
return;
}
window.addEventListener('DOMContentLoaded', () => {
const isLocalhost = ['localhost', '127.0.0.1', '::1'].includes(location.hostname);
if (!window.isSecureContext && !isLocalhost) {
console.info('Skipping service worker registration: insecure context', location.href);
AutoSyncFunctions();
} else {
navigator.serviceWorker.register('/service-worker.js', { scope: '/' })
.then(registration => {
logDev('Service Worker registered Now ');
// console.log('Service Worker registered Now:', registration);
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({
type: 'INIT'
});
} else {
console.log('NO navigator.serviceWorker.controller ');
AutoSyncFunctions();
}
navigator.serviceWorker.ready.then((registration) => {
if (registration.active) {
registration.active.postMessage({
type: 'INIT'
});
navigator.serviceWorker.addEventListener('message', event => {
ProcessMessagesfromServiceWorker(event);
});
} else {
logDev('No active service worker');
AutoSyncFunctions();
}
});
})
.catch(error => {
logDev('Service Worker registration Error ');
console.log('service worker registration error ', error);
AutoSyncFunctions();
});
}
});
}
}
async function ensureServiceWorkerReady() {
if ('serviceWorker' in navigator) {
await navigator.serviceWorker.ready;
logDev('Service Worker is Ready');
} else {
AutoSyncFunctions();
logDev('Service Workers are not supported in this browser');
}
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(registrations => {
for (let registration of registrations) {
registration.unregister();
}
});
} else {
console.warn('Service workers are not supported in this browser.');
};
/*
const originalFetch = window.fetch;
window.fetch = window.fetch = async (...args) => {
console.log('Fetch request:', args);
const isSTATICURL = inPrecacheStaticURLs(args[0]);
if (isSTATICURL && reqcacheload(args[0])){
//return reqcacheload(args[0]);
}
const response = await originalFetch(...args);
//if (isSTATICURL){reqcacheupdate(args[0],response.body);}
console.log('Fetch response body:', response.body);
const response = await originalFetch(...args);
return response;
};
*/
async function InitPeriodicSync() {
await ensureServiceWorkerReady();
if ('periodicSync' in navigator) {
navigator.serviceWorker.ready.then((registration) => {
return registration.periodicSync.register('sync-dynamic-content', {
minInterval: 15 * 60 * 1000
});
}).catch((error) => {
console.error('Periodic Sync registration failed:', error);
});
}
}
function InitializeWebWorkerSync() {
SyncWorker = new Worker('/webworker-sync.js');
SyncWorker.onmessage = function (event) {
ProcessMessage('loggedin', event.data, MessageLogin);
ProcessMessage('exec', event.data, MessageExec);
ProcessMessage('reqcacheupdate', event.data, MessageReqCacheUpdate);
ProcessMessage('cachehashupdate', event.data, MessageHashCacheUpdate);
ProcessMessage('BlobfromOPFS', event.data, MessageOPFStoBlobreqcache);
};
SyncWorker.onerror = function (error) {
AutoSyncFunctions();
console.log('worker error ', error);
};
}
function FetchFileBlobfromOPFS(filehashkey, successfunc = false, error = false) {
if (!filehashkey) { return false; }
SyncWorker.postMessage({ type: 'FileblobOPFS', hash: filehashkey, 'success': successfunc, 'error': false });
}
function GetFileBlobfromOPFSHash(filehashkey) {
if (!filehashkey) { return false; }
SyncWorker.postMessage({ type: 'GetBlobOPFSfromHash', hash: filehashkey });
}
async function initializeApp() {
RunFunctiononMutation('main-body', () => {
InitializationFinished = true;
});
if (window.location.pathname === '/') {
$('#SplashLogo').fadeOut(500);
gotoPage('Home', 0);
}
InitializeWebWorkerSync();
registerServiceWorker();
ensureServiceWorkerReady();
InitPeriodicSync();
ShowNotes();
InitializeUserSettings();
var currenttarget = 0;
}
$(document).ready(function () {
console.log('document ready');
if (!DontInitialize) {
initializeApp();
logDev('Initializing Service Workers');
} else {
logDev('Did Not Initialize Service Workers');
RunFunctiononMutation('main-body', () => {
InitializationFinished = true;
});
}
});
function showNotification(title) {
Notification.requestPermission(function (result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function (registration) {
var showNotification = registration;
registration.showNotification('Notification with ServiceWorker');
});
}
});
}
function DisWithin15MinutesBeforeCurrentTime(timeString) {
var providedTime = new Date(timeString);
var currentTime = new Date();
var differenceInMilliseconds = providedTime - currentTime;
return differenceInMilliseconds > 0 && differenceInMilliseconds >= (15 * 60 * 1000);
}
function MinutesBeforeCurrentTime(datetimestring) {
let date1 = new Date(datetimestring);
let date2 = new Date();
let diff = date2.getTime() - date1.getTime();
let msec = diff;
let sec = msec / 1000;
let min = Math.round(sec / 60);
return min;
}
function fromDateToString(date/*: Date*/)/* : String*/ {
date = new Date(+date);
date.setTime(date.getTime() - (date.getTimezoneOffset() * 60000));
let dateAsString = date.toISOString().substr(0, 19);
return dateAsString;
}
function DateRightNow() {
return fromDateToString(new Date());
}
function isWithin15MinutesBeforeCurrentTime(givenTime) {
return MinutesBeforeCurrentTime(givenTime) < -14;
}
function ButtonGo(page, targetdata = 0, nohistory = 0, redundantpage = 0) {
if (page === historylist[historylist.length - 1]) {
return false;
}
gotoPage(page, targetdata, nohistory, redundantpage);
return false;
}
$(document).ready(function () {
// $("#Homebottombar").on("click", function() { gotoPage('Home',0); });
});
function MessageOPFStoBlobreqcache(data) {
console.log(data);
const hashcontent = data.hash;
const blobcontent = data.blob;
reqcacheupdate(window.location.origin + '/RequestData/File/' + hashcontent, blobcontent);
reqcacheupdate('/RequestData/File/' + hashcontent, blobcontent);
}
function MessageLogin(data) {
if (data === false) {
reqcache = {};
window.location.href = '/';
}
}
function MessageExec(data) {
if (data) {
try {
eval(data);
} catch (error) {
}
}
}
function MessageReqCacheUpdate(data) {
const url = data.url;
const datastring = data.datavalue;
const dataobject = data.object;
const content = data.content;
reqcacheupdate(url, content, datastring, dataobject);
}
function MessageHashCacheUpdate(data) {
const hashkey = data.hash;
const content = data.data;
CacheHash.Update(hashkey, content);
}
function EraseNote() { $.get('/user/note/dismiss'); }
function ShowNotes(forced = false) {
function ShowNoteModal(response) {
if (response) {
ModalContinueCancel('NotesContentModal', 'Notes', response, "EraseNote();hidemodal('NotesContentModal');", cancelbuttontext = 'Close', continuebuttontext = 'Delete Note', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-default');
} else {
if (forced) { ModalQuickDismiss('No Notes', 'No Notes Found'); }
}
}
AjaxDo('/user/note/content', null, ShowNoteModal, null, 'GET', false);
}
function InitializeUserSettings() {
let request = new RequestData(false);
request
.url('/User/Settings/Details')
.type('POST')
.data(null)
.success((response) => {
user_settings = response;
})
.error((err) => {
})
.go();
request
.url('/User/Settings/Run/Scripts')
.type('POST')
.data(null)
.success((response) => {
eval(response);
})
.error((err) => {
})
.go();
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.onmessage = function (event) {
if (event.data.action === 'logout') {
logoutnow();
}
};
}
function PageSettingsScript() {
CheckAndSetDarkMode();
}
RunFunctiononMutation('body-global', () => {
PageSettingsScript();
});

1481
legacy/init/synclib.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,188 @@
importScripts('/synclib.js');
var request = new RequestData(false);
var requestWHash = new RequestData(true);
var SWInterval = {};
function postCustomReqUpdate(url, cachecontent = '', datavalue = '', object = '') {
self.postMessage({
type: 'reqcacheupdate', data: {
url: url,
datavalue: datavalue,
object: object,
content: cachecontent
}
});
}
function LoadANDSendReqCache(url, datavalue = '', object = '') {
let cachecontent = reqcacheload(url, datavalue, object);
if (!cachedetails) { return false; }
postCustomReqUpdate(url, cachecontent, datavalue, object);
}
function postcacheHASHupdate(hashkey, content) {
if (!hashkey) { return false; }
self.postMessage({
type: 'cachehashupdate', data: {
hash: hashkey,
data: content
}
});
}
function FetchAndUpdateDatatoMainThread(urlstring, reqmethod = 'GET', objectdata = '', datavalue = '') {
let requestWHash = new RequestData(true);
requestWHash
.url(urlstring)
.type(reqmethod)
.data(objectdata)
.fromVarCache(false)
.success((response, responsehash) => {
if (responsehash) { postcacheHASHupdate(responsehash, response); }
postCustomReqUpdate(urlstring, response, datavalue, objectdata);
})
.error((err) => {
console.error(err);
})
.go();
}
function FetchCachePostInterval(url, interval, method, objectdata, datavalue) {
if (SWInterval[url]) {
console.log('Interval for ', url, 'is already set aborting');
return false;
}
SWInterval[url] = setInterval(() => {
FetchAndUpdateDatatoMainThread(url, method, objectdata, datavalue);
}, interval);
}
async function saveBlobToOPFS(Filename, blobcontent) {
if (!Filename || !blobcontent) {
console.error("Filename and blob content are required.");
return false;
}
try {
const opfsRoot = await navigator.storage.getDirectory();
const fileHandle = await opfsRoot.getFileHandle(Filename, { create: true });
const writableStream = await fileHandle.createWritable();
await writableStream.write(blobcontent);
await writableStream.close();
console.log('Blob saved to OPFS successfully!');
return true;
} catch (error) {
console.error('Error saving blob to OPFS:', error);
return false;
}
}
var FileRequestUrl = '/RequestData/File/';
function fetchfileBlob(Hashkey, success, error = false, reqmethod = 'GET') {
if (!Hashkey) { return false; }
let requestWHash = new RequestData(true);
requestWHash
.url(FileRequestUrl + Hashkey)
.type(reqmethod)
.data(null)
.fromVarCache(false)
.success(async (response) => {
if (!response) { return false; }
if (success) {
success(response, Hashkey);
}
sendBlobfromOPFS(Hashkey,response);
saveBlobToOPFS(Hashkey, response);
})
.error((err) => {
// console.error(err);
if (error) {
error(err);
}
})
.go();
}
async function fetchDataFromOPFS(filename) {
try {
const opfsRoot = await navigator.storage.getDirectory();
// Access the file handle
const fileHandle = await opfsRoot.getFileHandle(filename, { create: false });
const file = await fileHandle.getFile();
const blob = await file.arrayBuffer();
const contentsBlob = new Blob([blob]);
return contentsBlob;
} catch (error) {
console.error('Error fetching data from OPFS:', error);
return null; // Return null in case of error
}
}
function sendBlobfromOPFS(hashkey,blobdata){
if (!hashkey || !blobdata){return false;}
self.postMessage({
type: 'BlobfromOPFS', data: {
hash: hashkey,
blob: blobdata
}
});
}
function InitializeAutoSyncFunctions() {
FetchDataAndPostInterval('/get/isloggedin', 'loggedin', 30000);
FetchDataAndPostInterval('/get/isExec', 'exec', 30000);
FetchCachePostInterval('/account_settings/details', 60000);
//FetchCachePostInterval('/ListLeads/List/data', 60000, 'POST');
//FetchCachePostInterval('/NewLeads/Form/PreferredSitesOption', 60000, 'POST');
}
InitializeAutoSyncFunctions();
self.onmessage = async function (event) {
const eventdata = event.data;
const eventtype = event.data.type;
if (eventtype === 'FileblobOPFS') {
fetchfileBlob(event.data.hash, event.data.success, event.error);
return false;
}
if (eventtype === 'GetBlobOPFSfromHash') {
const filename = eventdata.hash;
const blob = await fetchDataFromOPFS(filename);
if (blob) {
sendBlobfromOPFS(eventdata.hash, blob);
} else {
console.error('Failed to fetch blob for:', filename);
self.postMessage({ type: 'error', message: 'Failed to fetch blob' });
}
}
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,75 @@
<br><br>
<div id="viewContainer">
<center>Loading</center>
</div>
<script>
defaultBackOnclick = null;
Target_Uploaded_Files = [];
if(typeof LoadDataPageFunc==='undefined'){
LoadDataPageFunc = {};
}
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.PageTitle = 'Photo';
LoadDataPageFunc.currentTargetPage = 'PhotoViewer';
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.MainPhotoFileListHASH = currenttarget;
LoadDataPageFunc.URLs.TargetURL = currenttarget;
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.ViewContainer = "viewContainer";
LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
if (!istrue) { return false; }
Preloaders.ViewPropertyDetailsData(currenttarget, false,
function (response) {
ReloadPage();
}
);
};
LoadDataPageFunc.UpdateMainContainer=function(html){
$('#'+LoadDataPageFunc.ids.ViewContainer).html(html);
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.RequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.LoadMainDetails = {};
LoadDataPageFunc.LoadMainDetails.LoadNow = function () {
LoadAndCreateURLfromFileHash(currenttarget).then(bloburl => {
const imgelement = `<img src ="${bloburl}" style="">`;
LoadDataPageFunc.UpdateMainContainer(imgelement);
});
};
LoadDataPageFunc.main = function () {
LoadDataPageFunc.LoadMainDetails.LoadNow();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

View File

@@ -0,0 +1,257 @@
<div id='ListMainContainer'>
</div>
<script>
Target_Uploaded_Files = [];
defaultBackOnclick = null;
if (typeof LoadDataPageFunc === 'undefined') {
LoadDataPageFunc = {};
}
if (typeof LoadDataPageFunc.Settings === 'undefined') {
LoadDataPageFunc.Settings = {};
}
LoadDataPageFunc.Settings.PageName = 'Photos';
LoadDataPageFunc.currentTargetPage = 'ViewAllPhotos';
LoadDataPageFunc.URLs = {};
if (typeof currenttarget === 'string') {
currenttarget = tryparsingJSON(currenttarget);
}
if (typeof currenttarget === 'object') {
LoadDataPageFunc.Settings.Phototype = currenttarget['type'];
targethash = currenttarget['t'];
} else {
targethash = currenttarget;
}
if (typeof LoadDataPageFunc.Settings.Phototype === 'undefined') {
LoadDataPageFunc.Settings.Phototype = 'ProductMarket';
}
LoadDataPageFunc.URLs.QueryListData = '/Request/Photos/' + LoadDataPageFunc.Settings.Phototype;
LoadDataPageFunc.Settings.CurrentTargetRequired = true;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.NewRow = function (url, hashkey) {
if (!hashkey || !url) { return false; }
return [url, '', 'PhotoViewer', hashkey];
};
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.ListContainer = 'ListContainer';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
$$$ = {};
$$$.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.URLs.PreloadPhoto = function (hash) {
return '/RequestData/File/' + hash;
};
LoadDataPageFunc.populatelist = function () {
let urlArrays = []; let photoPromises = [];
let newhtmlrows = ''; let htmlarrayrows = [];
let PhotolistHashToHTML = function (PhotoHashArray) {
if (typeof PhotoHashArray === 'string') { PhotoHashArray = JSON.parse(PhotoHashArray); }
let count = PhotoHashArray.length;
for (let dd = 0; dd < count; dd++) {
photoPromises.push(
LoadAndCreateURLfromFileHash(PhotoHashArray[dd]).then(bloburl => {
urlArrays.push(bloburl);
})
);
}
Promise.all(photoPromises).then(() => {
for (let aa = 0; aa < count; aa++) {
if (!PhotoHashArray[aa] || !urlArrays[aa]) { continue; }
htmlarrayrows.push(LoadDataPageFunc.NewRow(urlArrays[aa], PhotoHashArray[aa]));
}
newhtmlrows = UIServices_FullDIV_GOTOPAGE_Array('', viewallhref = '', viewallonclick = '', viewalltext = '', htmlarrayrows);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
const elementsWithIconBox = document.querySelectorAll('.icon-box');
elementsWithIconBox.forEach(element => {
element.classList.remove('icon-box');
});
}).catch(error => {
$('#' + LoadDataPageFunc.ids.ListContainer).html('Error Loading Photos');
});
};
if (LoadDataPageFunc.Details && LoadDataPageFunc.Details.photourl) {
let photoarray = LoadDataPageFunc.Details.photourl;
let PhotolistCount = photoarray.length;
if (!PhotolistCount) { return false; }
PhotolistHashToHTML(LoadDataPageFunc.Details.photourl);
return true;
}
let request = new RequestData(true);
request
.url(LoadDataPageFunc.URLs.QueryListData)
.type(LoadDataPageFunc.Settings.DefaultRequestType)
.data({ target: targethash })
.fromVarCache(true)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response;
const count = List.length;
for (let i = 0; i < count; i++) {
// Push each promise into the array
photoPromises.push(
LoadAndCreateURLfromFileHash(List[i]).then(bloburl => {
urlArrays.push(bloburl);
})
);
}
Promise.all(photoPromises).then(() => {
for (let i = 0; i < count; i++) {
if (!List[i] || !urlArrays[i]) { continue; }
htmlarrayrows.push(LoadDataPageFunc.NewRow(urlArrays[i], List[i]));
}
newhtmlrows = UIServices_FullDIV_GOTOPAGE_Array('', viewallhref = '', viewallonclick = '', viewalltext = '', htmlarrayrows);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
const elementsWithIconBox = document.querySelectorAll('.icon-box');
elementsWithIconBox.forEach(element => {
element.classList.remove('icon-box');
});
}).catch(error => {
$('#' + LoadDataPageFunc.ids.ListContainer).html('Error Loading Photos');
});
})
.error((err) => {
console.error(err);
})
.go();
};
LoadDataPageFunc.ListContainerMessage = function (message = 'No Photos') {
ListContainer = '<div id="' + LoadDataPageFunc.ids.ListContainer + '"><center>' + message + '</center></div>';
$$$.UpdateMainContainer(UICardSimple('', ListContainer, LoadDataPageFunc.ids.MainCardBody));
};
LoadDataPageFunc.main = function () {
if (LoadDataPageFunc.Settings.CurrentTargetRequired && (!targethash || targethash === '0')) {
$$$.UpdateMainContainer('<center>No Target<br><br>' + buttonprimary('Go Back', '', "Backkey()") +
'<br><br>' + buttonprimary('Home', '', "ButtonGo('Home', '')") + '</center>'); return false;
}
LoadDataPageFunc.ListContainerMessage('Loading Please Wait...');
return true;
};
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
});
</script>

View File

@@ -0,0 +1,330 @@
<style>
.ListRowCard {
margin-bottom: 20px;
}
</style>
<div id='ListMainContainer'>
</div>
<script>
defaultBackOnclick = null;
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.QueryListData = '/ListStores/List/data';
LoadDataPageFunc.currentPage = 'ListStores';
LoadDataPageFunc.Settings = {};
ListBuilder.build({
targetDiv: "ListMainContainer",
title: "Stores",
dataUrl: "/ListStores/List/data",
pageName: 'ListStores',
defaultback: "Home",
search: true,
unabletoLoadFunc: () => ModalQuickDismiss('Error', 'Unable to Load Data!'),
// customCss:` .ListRowCard {
// margin-bottom: 20px;
// }`,
type: 'tiled',
height: '15vh',
renderCard: function (item, index, config) {
photoblob = reqcacheload(item.photourl);
const imageid ='StoreListPhoto-'+index;
ListBuilder.queueImageLoad(imageid, item.photourl);
const FinalBody = `
<div class="row" onclick=" gotoPage('ViewStoreMarket', '${item.hashkey}');" class="ListCardRow equal-height" style="">
<div class="col-2">
<img src="${item.photourl}" class="StoreListIMGIcon" id="${imageid}" style="max-width:20vw; height:10vh;">
</div>
<div class="col-10">
<div class="row">
<div class="col-12" style="font-width:1.5vh;">
<b>${item.name}</b>
</div>
<div class="col-12" style="font-size:1.0vh;">
${item.category}
</div>
<div class="col-12" style="font-size:0.7vh;">
${item.subcategory}
</div>
</div>
</div>
</div>
`;
const cardid = 'ListRowCard-' + index;
const cardfull = CreateCardSimple('',FinalBody,cardid,'margin:5px; height: 15vh;');
// const cardfull = createCard(item.name, cardid, '', cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow', '', 'ListRowCard');
return cardfull;
},
});
// LoadDataPageFunc.Settings.SortArray = function (arr) {
// return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
// };
// LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
// gotoPage('ViewStoreMarket', `${data}`);
// };
// LoadDataPageFunc.Settings.PageName = 'Stores';
// 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.Settings.CurrentTargetRequired = false;
// LoadDataPageFunc.Settings.DefaultDatatoSend = null;
// LoadDataPageFunc.NewRow = function (objectdata, rownum) {
// let rowhtml = [];
// const hashkey = objectdata.hashkey;
// let photourl = objectdata.photourl;
// let name = objectdata.name;
// let category = objectdata.category || '';
// let subcategory = objectdata.subcategory || '';
// let FinalBody = '';
// /* html */
// FinalBody = `
// <div class="row" onclick="LoadDataPageFunc.Settings.ViewDetailsOnclick('${hashkey}');">
// <div class="col-2">
// <img src="${photourl}" class="StoreListIMGIcon" id="StoreListPhoto" style="width:0.5vw: height:0.5vh;display:none;">
// </div>
// <div class="col-10">
// <div class="row">
// <div class="col-12" style="font-width:1.5vh;">
// <b>${name}</b>
// </div>
// <div class="col-12" style="font-size:1.0vh;">
// ${category}
// </div>
// <div class="col-12" style="font-size:0.7vh;">
// ${subcategory}
// </div>
// </div>
// </div>
// </div>
// `;
// return createCard(objectdata.fullname, cardid = 'ListRowCard-' + rownum, '', cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow', '', 'ListRowCard');
// };
// LoadDataPageFunc.ids = {};
// LoadDataPageFunc.ids.MainContainer = 'ListMainContainer';
// LoadDataPageFunc.ids.SearchInput = 'List_Search';
// LoadDataPageFunc.ids.ListContainer = 'ListContainer';
// LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
// LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
// $$$ = {};
// $$$.UpdateMainContainer = function (html) {
// $('#' + LoadDataPageFunc.ids.MainContainer).html(html);
// };
// 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.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 (response) {
// if (!response) {
// $('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
// return;
// }
// let List = response;
// let newhtmlrows = ''; let htmlarrayrows = [];
// const count = List.length;
// let hashkey;
// for (let i = 0; i < count; i++) {
// let hashkey = List[i]['hashkey'];
// htmlarrayrows.push(LoadDataPageFunc.NewRow(List[i], i) + '<br>');
// }
// newhtmlrows = htmlarrayrows.join('');
// updateHTMLifChanged(newhtmlrows, LoadDataPageFunc.ids.ListContainer);
// const imgclassname = 'StoreListIMGIcon';
// LoadPhotoIMGTargetClass(imgclassname, settodisplaylater = true);
// HideBrokenPhotowithClass(imgclassname);
// LoadDataPageFunc.CardResultInterSectionPreloadDetails();
// };
// LoadDataPageFunc.ListData = false;
// LoadDataPageFunc.reloadPopulatelist = function () {
// loadDataWithCache({
// url: LoadDataPageFunc.URLs.QueryListData,
// currentPage: LoadDataPageFunc.currentPage,
// executeFunction: LoadDataPageFunc.populatelist
// });
// };
// 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();
// if (title.includes(searchTerm) || cols.includes(searchTerm)) {
// $(this).show();
// } else {
// $(this).hide();
// }
// });
// });
// };
// LoadDataPageFunc.main = function () {
// 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('Stores', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
// $$$.UpdateMainContainer(MainCard);
// return true;
// };
// $(document).ready(function () {
// LoadDataPageFunc.main();
// @if($FragmentOnly)
// LoadDataPageFunc.reloadPopulatelist()
// @else
// LoadDataPageFunc.populatelist();
// @endif
// changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
// LoadDataPageFunc.SearchKeyUPListPage();
// $('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// // $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
// setDefaultbackGotoPageifNoHistory('Home', 0);
// });
</script>

View File

@@ -0,0 +1,48 @@
<div id='ListMainContainer'>
</div>
<script>
defaultBackOnclick = null;
currentData = null;
LoadDataPageFunc = {};
PhotoListPreloadQueue = [];
ListBuilder.build({
targetDiv: "ListMainContainer",
title: "Products",
dataUrl: "/Market/Products/List",
pageName: 'ListProductsMarket',
defaultback: "Home",
search: true,
width: '40vh',
height: '40vh',
unabletoLoadFunc:() => ModalQuickDismiss('Error', 'Unable to Load Data!'),
card: {
imageField: "photo",
nameField: "name",
priceField: "price",
unitField: "unit",
descriptionField: "description",
onClick: (data) => `ButtonGo('BuyViewProductMarket','${data.hashkey}')`,
fallbackImage: "/assets/noproductphoto.png",
}
});
</script>

View File

@@ -0,0 +1,192 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Product Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.currentPage = 'BuyViewProductMarket';
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();
};
if (typeof Buttons == 'undefined') {
let Buttons;
}
Buttons = [
// { icon: '/assets/addtocart.png', label: 'Add To Cart', onclick: 'LoadDataPageFunc.AddToCart();return false;' },
// { icon: '/assets/buy.png', label: 'Buy', onclick: 'LoadDataPageFunc.Buy();return false;' },
{ icon: '/assets/briefcase.png', label: 'Manage', onclick: "gotoPage('ManageProductAdmin', currenttarget);return false;" },
];
initGlobal("acct_type", '');
acct_type = @json($currentUser['acct_type']);
defaultbackpage = {
page: 'ListProductsMarket',
data: 0,
};
if (typeof currenttarget.store_hash !== 'undefined' && currenttarget.store_hash) {
defaultbackpage = {
page: 'ViewStoreMarket',
data: currenttarget.store_hash,
};
}
LoadDataPageFunc.Main = function () {
// Preloaders.ViewProductinMarket(currenttarget, true, LoadDataPageFunc.UpdateDetailsUI);
ViewBuilder.build({
dataurl: '/View/Product/Details/data',
pageName: 'BuyViewProductMarket',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: defaultbackpage,
defaultErrorHTML: '<b><center>Unable to Load Product</center></b>',
unabletoLoadFunc: (response) => {
const errorModalName = 'errorLoadingModal';
if (document.getElementById(errorModalName)) {
modaldestroy(errorModalName);
}
let responseMessage = response.message;
if (typeof responseMessage !== 'object') {
responseMessage = 'Unknown Error';
}
ModalQuickDismiss('Error!<br>', responseMessage, errorModalName);
},
initialize: (response) => {
if (typeof response.is_from_store !== 'undefined' && response.is_from_store) {
Buttons.push(
{ icon: '/assets/reports.png', label: 'Store Transactions', onclick: `gotoPage('ManageStoreTransactions',currenttarget);return false;` },
);
}
//TODO Add routes in viewmap and create the blades and controllers for these
if (acct_type === 'ult' || acct_type === 'superoperator') {
Buttons.push(
{ icon: '/assets/reports.png', label: 'Global Transactions', onclick: `gotoPage('ManageGlobalTransactions',currenttarget);return false;` },
);
}
},
sections: [
{
phototype: 'ProductMarket',
type: 'photos',
id: 'PhotosCard',
currentdatavar: 'photourl'
},
{
type: 'details',
data: [
{
h: 3,
bold: true,
type: 'text',
currentdatavar: 'name'
},
{
type: 'text',
// currentdatavar: 'price',
func: function () {
const declaredPrice = currentData.store_price || currentData.price;
if (typeof currentData.store_price !== 'undefined' && currentData.store_price) {
return 'Store Price P' + declaredPrice + ' / ' + currentData.unitname;
} else {
return 'P' + declaredPrice + ' / ' + currentData.unitname;
}
},
}
]
// title: ProductData.name,
// description: ProductData.description,
// price: ProductData.price,
// unit: ProductData.unitname,
},
{
type: 'buttons',
buttons: Buttons
},
{
type: 'card',
id: 'DescriptionCard',
hidden: false,
currentdatavar: 'description',
},
]
});
// LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,266 @@
@php
use App\Http\Controllers\Market\StoreController;
use App\Enums\UserTypes;
use App\Http\Controllers\FilesMainController;
if (!$FragmentOnly && $current_target) {
}
@endphp
<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">
<center>
<div id="PhotosPlaceholder"
style="width: 100%; max-width: 600px; height: 350px; display: flex; justify-content: center; align-items: center; background: #f0f0f0; color: #555; font-size: 18px;">
Loading photos...
</div>
</center>
</div>
<br>
<div class="row" style="">
<div class="col">
<h3 id="StoreNameMarketPlace"> </h3>
</div>
<div class="col" id="StoreLocationMarketPlace"> </div>
</div>
<ul class="mt-3 box-outstanding-service" id="ControlsAddCartBuy">
<li onclick="LoadDataPageFunc.ViewAllStoreDetails();return false;">
<div class="">
<img src="/assets/search.png" style="width: 30; height: 30;" class="icon-user">
</div>More Details
</li>
<li onclick="LoadDataPageFunc.Report();return false;">
<div class="">
<img src="/assets/reportaccount.png" style="width: 30; height: 30;"
class="icon-user">
</div>Report
</li>
@if($current_user->acct_type === UserTypes::ULTIMATE)
<li onclick="LoadDataPageFunc.Edit();return false;">
<div class="">
<img src="/assets/edit.png" style="width: 30; height: 30;" class="icon-user">
</div>Edit
</li>
@endif
</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="StoreDescription">
</div>
<h5></h5>
</div>
</div>
</a>
</div>
<div class="col-md" style="overflow:hidden;" id="StoreProductsColumn">
</div>
<div class="col-md" style="overflow:hidden;display: none;" id="ReviewsCard">
<UI type="card" id="ReviewsCard" title="Reviews" tools="no">
</UI>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Store Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Disabled = false;
LoadDataPageFunc.Edit = function () {
gotoPage('EditStoreAdmin', currenttarget);
};
LoadDataPageFunc.ProductsListNewCard = function (object, rownum) {
if (!object || rownum === false || rownum === null || typeof rownum === undefined) {
return '';
}
let hash = object.hashkey || false;
let name = object.name || '';
let price = object.store_price || object.price || '';
let isStorePrice = typeof object.store_price === 'number';
let photo = object.photourl || '';
const unit = object.unitname || '';
if (!hash) { return ''; }
if (typeof photo === 'array' || typeof photo === 'object') {
photo = photo[0];
}
name = trimStringToMaxLength(name, 16, suffix = '');
// price = trimStringToMaxLength(price, 16, suffix = '');
const productColumnSize = '6';
const newcol = function (colinner, colsize = "12", style = '') {
return `<div class="col-${colsize}" style="${style} overflow:hidden; padding-bottom:10px; width: 40vh; height: 40vh; ">${colinner}</div>`;
}
if (isStorePrice) {
isStorePrice = 'Store Price';
} else {
isStorePrice = '';
}
const imgelement = `
<img id="marketplacelistproductphoto-1" src="${photo}" loading="lazy" class="StoreProductsIMGMarket"
style="width: 60%;height: 60%;object-fit: contain;">
`;
/* html */
let finalcontent = imgelement + `<br><div class="row" style=""><div class="col"><h4>${name}</h4></div></div>`;
finalcontent += `<div class="row" style=""><div class="col"><h6>${isStorePrice} P${price} / ${unit}</h6></div></div>`;
const maincolstyle = '';
let target_data = { target: hash, store_hash: currenttarget };
return newcol(`<center onclick='gotoPage("BuyViewProductMarket", ${JSON.stringify(target_data)})'>` + CreateCardSimple(false, finalcontent, 'StoreProductCard-' + rownum, 'width: 100%; height: 100%; object-fit: cover;') + '</center>', productColumnSize, maincolstyle);
}
LoadDataPageFunc.UpdateProductsListCard = function (productslist) {
const isempty = typeof productslist === 'array' || productslist.length === 0;
if (!productslist || isempty) {
$('#card-body-StoreProductsCard').html('<p style="text-align:center;">No Products</p>');
return false;
}
let cardarray = [];
cardarray.push('<div class="row" style="">');
iterateArray(productslist, (data, rownum) => {
cardarray.push(LoadDataPageFunc.ProductsListNewCard(data, rownum));
});
cardarray.push('</div>');
const finalhtml = cardarray.join('');
$('#card-body-StoreProductsCard').html(finalhtml);
LoadPhotoIMGTargetClass('StoreProductsIMGMarket', settodisplaylater = true);
return true;
};
LoadDataPageFunc.PopulateDetailsNow = function (name, description, address, category, subcategory, products) {
$('#StoreNameMarketPlace').html(name);
$('#StoreDescription').html(description);
$('#StoreLocationMarketPlace').html(address);
const StoreProductsColumn = UICardSimple('Products', text = '', id = 'StoreProductsCard');
$('#StoreProductsColumn').html(StoreProductsColumn);
LoadDataPageFunc.UpdateProductsListCard(products);
};
LoadDataPageFunc.ViewPhotosLink = function () {
const datasend = { t: currenttarget, type: LoadDataPageFunc.Settings.Phototype };
ButtonGo('ViewAllPhotos', datasend);
}
LoadDataPageFunc.Settings.Phototype = "StoreMarket";
LoadDataPageFunc.StoreLoadErrorModal = function () {
ModalQuickDismiss(false, 'Store Not Available!', 'UnavailableStoreModal');
}
LoadDataPageFunc.PopulateDetails = function () {
let description;
let photosarray;
let response;
if (!currenttarget) { console.log('currenttarget not found', currenttarget); LoadDataPageFunc.StoreLoadErrorModal(); }
const UpdateDetailsUI = function (response) {
if (!response) {
LoadDataPageFunc.StoreLoadErrorModal();
return false;
}
@if (isset($current_data) && $current_data)
response.photourl = @json($current_data?->photourl ?? []);
@foreach ($current_data?->photourl as $photohash)
@endforeach
@else
Preloaders.ImageList(currenttarget, LoadDataPageFunc.Settings.Phototype);
@endif
LoadPhotosCard('PhotosCard', "LoadDataPageFunc.ViewPhotosLink();", response.photourl);
LoadDataPageFunc.PopulateDetailsNow(response.name, response.description, response.address, response.category, response.subcategory, response.products);
};
@if ($FragmentOnly)
Preloaders.ViewStoreinMarket(currenttarget, true, UpdateDetailsUI);
@else
response = @json($current_data);
UpdateDetailsUI(response);
@endif
};
LoadDataPageFunc.Main = function () {
setDynamicCSS(` .ListRowCard {
margin-bottom: 5px;
}`);
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,92 @@
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.EditUrl = `{{ route('admin.products.edit', [], false) }}`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Products/New/Category/Datalist`;
LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Product`;
LoadDataPageFunc.PageTitle = 'Edit Product';
LoadDataPageFunc.pageName = 'EditProductAdmin';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'EditProductPhotos';
LoadDataPageFunc.formclass = 'EditProductMarket';
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped = function () {
document.getElementById("EditProductCategory").addEventListener("keyup", function (event) {
const inputValue = event.target.value;
const categoryinputvalue = document.getElementById("EditProductCategory").value;
QueryandReplaceDatalist("EditProductSubCategoryDataList",
LoadDataPageFunc.URLs.SubCategoryDatalist,
'POST', { category: categoryinputvalue }, fromvarcache = true,
function (response) {
});
});
};
LoadDataPageFunc.PopulateCategoryDatalist = function () {
QueryandReplaceDatalist("EditProductCategoryDataList",
LoadDataPageFunc.URLs.CategoryDatalist,
'POST', { }, fromvarcache = true,
);
};
FormBuilder.build({
formClass: 'EditProductMarket',
pageName: LoadDataPageFunc.pageName,
submitUrl: '{{ route('admin.products.bystore.edit', [], false) }}',
currentDataUrl: '{{ route('admin.products.bystore.view.data', [], false) }}',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: {
page: 'ManageProductAdmin',
data: currenttarget,
},
onSuccess: (response) => {
ModalQuickDismiss('Success', 'Product Updated');
},
onError: (err) => {
ModalQuickDismiss('Error', 'Failed to update product.<br>' + err.message);
},
unabletoLoadFunc: function (err) {
ModalQuickDismiss('Error', 'Failed to update product.<br>' + err.message);
},
onFormGenerated: function () {
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped();
LoadDataPageFunc.PopulateCategoryDatalist();
},
fields: [
{ type: 'textarea', id: 'EditProductDescription', label: 'Description', required: true, currentdatavar: 'description' },
{ type: 'text', id: 'EditProductCategory', label: 'Category', placeholder: 'Category', required: true, datalist: 'EditProductCategoryDataList', currentdatavar: 'category' },
{ type: 'text', id: 'EditProductSubCategory', label: 'Subcategory', placeholder: 'Subcategory', required: true, datalist: 'EditProductSubCategoryDataList', currentdatavar: 'subcategory' },
{ type: 'number', id: 'EditProductPrice', placeholder: '260', label: 'Price (PHP)', required: true, currentdatavar: 'price' },
{ type: 'text', id: 'EditProductUnitName', label: 'Unit', placeholder: 'ex 25kg', required: true, currentdatavar: 'unitname' },
// { type: 'number', id: 'EditProductAvailable',placeholder:'ex. 999', label: 'Available Stock', required: true, currentdatavar: 'available' },
{ type: 'text', id: 'EditProductBarcode', label: 'Barcode', placeholder: '12-digit number', maxlength: 12, pattern: '[0-9]*', currentdatavar: 'barcode' },
{ type: 'dropzone', id: LoadDataPageFunc.ids.photodropzone, label: 'Photo', uploadUrl: LoadDataPageFunc.URLs.PhotoUpload, currentdatavar: 'photourlDropzone' },
{ type: 'button', label: 'Submit', onClick: 'FormBuilder.submit()' },
]
});
</script>

View File

@@ -0,0 +1,69 @@
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.EditUrl = `{{ route('admin.products.addtostore', [], false) }}`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Products/New/Category/Datalist`;
LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Product`;
LoadDataPageFunc.PageTitle = 'Add Product to Store';
LoadDataPageFunc.pageName = 'AddProducttoStoreAdmin';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'EditProductPhotos';
FormBuilder.build({
formClass: 'AddProducttoStoreAdmin',
pageName: LoadDataPageFunc.pageName,
submitUrl: LoadDataPageFunc.URLs.EditUrl,
currentDataUrl: '{{ route('admin.products.view.data.addstore', [], false) }}',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: {
page: 'ManageProductAdmin',
data: currenttarget,
},
onSuccess: (response) => {
ModalQuickDismissGoto('Success', 'Product Added to Store', ['ManageProductAdmin', 'Go Back',currenttarget]);
Preloaders.ViewStoreinMarket($('#TargetStore').val());
},
onError: (err) => {
ModalQuickDismiss('Error', 'Failed to Add Product to Store.<br>' + err.message);
},
unabletoLoadFunc: function (res) {
console.log(res);
ModalQuickDismiss('Error', 'Failed to Add Product to Store.<br>' + err.message);
},
onFormGenerated: function () {
// LoadDataPageFunc.UpdateSubCategoryDatalistasTyped();
// LoadDataPageFunc.PopulateCategoryDatalist();
},
fields: [
{ type: 'select', id: 'TargetStore', label: 'Store Name', currentdatavar: 'store_options', required: true, },
{ type: 'text', id: 'EditProductName', label: 'Name', placeholder: 'Product Name', required: true, currentdatavar: 'name', disabled: true },
// { type: 'textarea', id: 'EditProductDescription', label: 'Description', required: true, currentdatavar: 'description' },
// { type: 'text', id: 'EditProductCategory', label: 'Category', placeholder: 'Category', required: true, datalist: 'EditProductCategoryDataList', currentdatavar: 'category' },
// { type: 'text', id: 'EditProductSubCategory', label: 'Subcategory', placeholder: 'Subcategory', required: true, datalist: 'EditProductSubCategoryDataList', currentdatavar: 'subcategory' },
{ type: 'number', id: 'EditProductPrice', placeholder: '260', label: 'Price (PHP)', required: true, currentdatavar: 'price', disabled: true },
{ type: 'text', id: 'EditProductUnitName', label: 'Unit', placeholder: 'ex 25kg', required: true, currentdatavar: 'unitname', disabled: true },
// { type: 'number', id: 'EditProductAvailable',placeholder:'ex. 999', label: 'Available Stock', required: true, currentdatavar: 'available' },
{ type: 'text', id: 'EditProductBarcode', label: 'Barcode', placeholder: '12-digit number', maxlength: 12, pattern: '[0-9]*', currentdatavar: 'barcode', disabled: true },
{ type: 'dropzone', id: LoadDataPageFunc.ids.photodropzone, label: 'Photo', uploadUrl: LoadDataPageFunc.URLs.PhotoUpload, currentdatavar: 'photourlDropzone', disabled: true },
{ type: 'button', label: 'Submit', onClick: 'FormBuilder.submit()' },
]
});
</script>

View File

@@ -0,0 +1,113 @@
<script>
//TODO NEXT Fix MnageglobalTransactions not displaying when using button links
// has something to do with add to pageload variable target is confusing and current target
tabledata = [
["Laptop", 1200, "Electronics"],
["Phone", 800, "Electronics"],
["Desk", 300, "Furniture"]
];
ViewBuilder.build({
dataurl: '/View/Product/Details/data',
pageName: 'GlobalTransactionsProduct',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: {
page: 'BuyViewProductAdmin',
data: currenttarget,
},
defaultErrorHTML: '<b><center>Unable to Load Product</center></b>',
unabletoLoadFunc: (response) => {
if (!response){
alert('no response');
}
const errorModalName = 'errorLoadingModal';
if (document.getElementById(errorModalName)) {
modaldestroy(errorModalName);
}
let responseMessage = response.message;
if (typeof responseMessage !== 'object') {
responseMessage = 'Unknown Error';
}
ModalQuickDismiss('Error!<br>', responseMessage, errorModalName);
},
initialize: (response) => {
if (typeof response.is_from_store !== 'undefined' && response.is_from_store) {
Buttons.push(
{ icon: '/assets/reports.png', label: 'Store Transactions', onclick: "gotoPage('ManageStoreTransactions',currenttarget);return false;" },
);
}
},
sections: [
{
phototype: 'ProductMarket',
type: 'photos',
id: 'PhotosCard',
currentdatavar: 'photourl'
},
{
type: 'details',
data: [
{
h: 3,
bold: true,
type: 'text',
currentdatavar: 'name'
},
{
type: 'text',
func: function () {
const declaredPrice = currentData.store_price || currentData.price;
if (typeof currentData.store_price !== 'undefined' && currentData.store_price) {
return 'Store Price P' + declaredPrice + ' / ' + currentData.unitname;
} else {
return 'P' + declaredPrice + ' / ' + currentData.unitname;
}
},
}
]
},
{
type: 'buttons',
buttons: [
{ icon: '/assets/briefcase.png', label: 'Manage', onclick: "gotoPage('ManageProductAdmin', currenttarget);return false;" },
],
},
{
type: 'card',
id: 'TransactionCard',
hidden: false,
currentdatavar: 'transactions',
func: function () {
// const declaredPrice = currentData.store_price || currentData.price;
const html = createSearchableTable({
data: tabledata,
placeTable: false,
initializeTable: false
});
console.log(html); // no output
return html;
},
},
]
});
</script>

View File

@@ -0,0 +1,138 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<div id="MainView">
</div>
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Manage Product';
LoadDataPageFunc.pageName = 'ManageProductAdmin';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Disabled = false;
LoadDataPageFunc.RemoveProductfromCurrentStore = () => {
const urllink = `{{ route('store.product.remove') }}/`;
const datatosend = {
'store_hash': currenttarget['store_hash'],
'product_hash': currenttarget['target'],
};
SendPostDataURLData(urllink, datatosend, (response) => {
if (response.success) {
ModalQuickDismiss('Success', 'Product Removed from Store.');
Preloaders.ViewStoreinMarket(currenttarget['store_hash'], false, () => {
//TODO Fix error here
gotoPage('ViewStoreMarket', currenttarget['store_hash']);
});
}
});
};
LoadDataPageFunc.Settings.Phototype = "ProductMarket";
Buttons = [
{ icon: '/assets/products.png', label: 'View Product', onclick: "gotoPage('BuyViewProductMarket',currenttarget);return false;" },
{ icon: '/assets/edit.png', label: 'Edit Product', onclick: "gotoPage('EditProductAdmin',currenttarget);return false;" },
{ icon: '/assets/plus-cart.png', label: 'Add to Store', onclick: "gotoPage('AddProducttoStoreAdmin',currenttarget);return false;" },
{ icon: '/assets/minus-cart.png', label: 'Remove from Store', onclick: "gotoPage('RemoveProductfromStoreAdmin',currenttarget);return false;" },
];
LoadDataPageFunc.Main = function () {
ViewBuilder.build({
dataurl: '/View/Product/Details/data',
pageName: 'ManageProductAdmin',
topbartitle: 'Manage Product',
defaultback: {
page: 'BuyViewProductMarket',
data: currenttarget,
},
initialize: (response) => {
if (typeof response.is_from_store !== 'undefined' && response.is_from_store) {
Buttons.push(
{ icon: '/assets/edit.png', label: 'Edit Product By Store', onclick: "gotoPage('EditProductStoreData',currenttarget);return false;" },
// { icon: '/assets/plus-cart.png', label: 'Add to Store', onclick: "gotoPage('AddProducttoCurrentStore',currenttarget);return false;" }, d
{ icon: '/assets/minus-cart.png', label: 'Remove from Current Store', onclick: "LoadDataPageFunc.RemoveProductfromCurrentStore();return false;" },
);
}
},
sections: [
{
phototype: 'ProductMarket',
type: 'photos',
id: 'PhotosCard',
currentdatavar: 'photourl'
},
{
type: 'details',
data: [
{
h: 3,
bold: true,
type: 'text',
currentdatavar: 'name'
},
{
type: 'text',
// currentdatavar: 'price',
func: function () {
return 'P' + currentData.price + ' / ' + currentData.unitname;
},
}
]
// title: ProductData.name,
// description: ProductData.description,
// price: ProductData.price,
// unit: ProductData.unitname,
},
{
type: 'buttons',
buttons: Buttons
},
{
type: 'card',
id: 'DescriptionCard',
hidden: false,
currentdatavar: 'description',
},
]
});
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,69 @@
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.EditUrl = `{{ route('admin.products.removefromstore', [], false) }}`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Products/New/Category/Datalist`;
LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Product`;
LoadDataPageFunc.PageTitle = 'Remove Product from Store';
LoadDataPageFunc.pageName = 'RemoveProductfromStoreAdmin';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'EditProductPhotos';
FormBuilder.build({
formClass: 'RemoveProductfromStoreAdmin',
pageName: LoadDataPageFunc.pageName,
submitUrl: LoadDataPageFunc.URLs.EditUrl,
currentDataUrl: '{{ route('admin.products.view.data.addstore', [], false) }}',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: {
page: 'ManageProductAdmin',
data: currenttarget,
},
onSuccess: (response) => {
ModalQuickDismissGoto('Success', 'Product Removed from Store', ['ManageProductAdmin', 'Go Back', currenttarget]);
Preloaders.ViewStoreinMarket($('#TargetStore').val());
},
onError: (err) => {
ModalQuickDismiss('Error', 'Failed to Remove Product from Store.<br>' + err.message);
},
unabletoLoadFunc: function (res) {
console.log(res);
ModalQuickDismiss('Error', 'Failed to Remove Product from Store.<br>' + err.message);
},
onFormGenerated: function () {
// LoadDataPageFunc.UpdateSubCategoryDatalistasTyped();
// LoadDataPageFunc.PopulateCategoryDatalist();
},
fields: [
{ type: 'select', id: 'TargetStore', label: 'Store Name', currentdatavar: 'store_options', required: true, },
{ type: 'text', id: 'EditProductName', label: 'Name', placeholder: 'Product Name', required: true, currentdatavar: 'name', disabled: true },
// { type: 'textarea', id: 'EditProductDescription', label: 'Description', required: true, currentdatavar: 'description' },
// { type: 'text', id: 'EditProductCategory', label: 'Category', placeholder: 'Category', required: true, datalist: 'EditProductCategoryDataList', currentdatavar: 'category' },
// { type: 'text', id: 'EditProductSubCategory', label: 'Subcategory', placeholder: 'Subcategory', required: true, datalist: 'EditProductSubCategoryDataList', currentdatavar: 'subcategory' },
{ type: 'number', id: 'EditProductPrice', placeholder: '260', label: 'Price (PHP)', required: true, currentdatavar: 'price', disabled: true },
{ type: 'text', id: 'EditProductUnitName', label: 'Unit', placeholder: 'ex 25kg', required: true, currentdatavar: 'unitname', disabled: true },
// { type: 'number', id: 'EditProductAvailable',placeholder:'ex. 999', label: 'Available Stock', required: true, currentdatavar: 'available' },
{ type: 'text', id: 'EditProductBarcode', label: 'Barcode', placeholder: '12-digit number', maxlength: 12, pattern: '[0-9]*', currentdatavar: 'barcode', disabled: true },
{ type: 'dropzone', id: LoadDataPageFunc.ids.photodropzone, label: 'Photo', uploadUrl: LoadDataPageFunc.URLs.PhotoUpload, currentdatavar: 'photourlDropzone', disabled: true },
{ type: 'button', label: 'Submit', onClick: 'FormBuilder.submit()' },
]
});
</script>

View File

@@ -0,0 +1,151 @@
<div id="NewProductForm">
</div>
<script>
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.NewUrl = `{{ route('admin.products.new',[],false) }}`;
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("change", function (event) {
const inputValue = event.target.value;
const categoryinputvalue = document.getElementById("NewProductCategory").value;
QueryandReplaceDatalist("NewProductSubCategoryDataList",
LoadDataPageFunc.URLs.SubCategoryDatalist,
'POST', { category: categoryinputvalue }, fromvarcache = true,
function (response) {
});
});
};
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 categorydatalistData = @json((new App\Http\Controllers\Market\ProductController)->getCategories(false))
const categorydatalist = ArraytoDatalist("NewProductCategoryDataList", categorydatalistData, 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) {
getResponseHashkeyOrErrorMessage(response, function (hashkey) {
Preloaders.ViewProductinMarket(hashkey);
successModal();
gotoPage('BuyViewProductMarket', hashkey);
return true;
}, errorModal);
};
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,177 @@
<div id="NewStoreForm">
</div>
<script>
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.NewUrl = `/Store/New`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Store/New/Category/Datalist`;
// LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Store`;
LoadDataPageFunc.PageTitle = 'New Store';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'NewStorePhotos';
LoadDataPageFunc.formclass = 'NewStoreMarket';
// 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, id, required = false, datalist = '') {
return UIInputGroup(placeholder, 'text', id, label, formclass, spanclass = '', imginsteadofspan = '', required, textvalue = '', datalist, imgwidth = '', imgheight = '');
};
const name = textbox('Store Name', 'Name', 'name', true);
const description = UIInputGroupTEXTAREA(label = 'Description', 'description', required = true, textareacontent = '', formclass);
const category = textbox('Product Category', 'Category', 'category', true, 'NewStoreCategoryDataList');
const address = UIInputGroupTEXTAREA(label = 'Address', 'address', required = true, textareacontent = '', formclass);
const categorydatalist = ArraytoDatalist("NewStoreCategoryDataList", [], 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 storeOwner = UIInputGroupSelect('owner', label = 'Store Owner', [['', 'Select User']], spanclass = '', imginsteadofspan = '', 0,'','',formclass);
//TODO Add Support for storeManager and Cashier multiple accounts support
const submitbutton = UIInputGroupButton('Submit', formclass, buttonid = '', onclick = 'LoadDataPageFunc.TryToSubmit();', buttonstyle = '');
// const selectFromUser = ` <div class="input-group mb-3" id="store_owner" style="">
// <select class="form-control" id="storeOwner">
// </select>
// </div>`;
finalhtml = name + description + category + categorydatalist + address + photoscontainer + storeOwner + submitbutton;
finalhtml = CreateCardSimple(false, finalhtml);
document.getElementById('NewStoreForm').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();
QueryandReplaceDatalist("NewStoreCategoryDataList", LoadDataPageFunc.URLs.CategoryDatalist, 'POST', null, fromvarcache = true);
};
LoadDataPageFunc.RepopulateStoreOwnerList = function () {
function UpdateSelectParentList(response) {
const selectElement = $("#owner");
response.forEach(element => {
$("<option></option>")
.val(element.hashkey)
.text(`${element.name} (${element.mobile_number}) [${element.username}] ${element.fullname ?? ''}`)
.appendTo(selectElement);
});
}
AjaxDo('/admin/user/list/numbers/hash', {}, UpdateSelectParentList, null, reqtype = 'POST');
};
LoadDataPageFunc.TryToSubmit = function () {
const currentformdata = LoadDataPageFunc.ValidateForm();
if (!currentformdata) {
ModalQuickDismiss('Error', 'Name, Description, Category and Address are required fields.', modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
return false;
}
const errorModal = function (errorstring = '') {
ModalQuickDismiss('Error', 'Unable Submit To New Store. <br>' + errorstring, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
};
const successModal = function () {
hideallmodals();
ModalQuickDismiss('Success', 'New Store Created');
};
const submitsuccess = function (response) {
responseOk = isResponseAHash(response);
if (!responseOk) {
errorModal(response);
return false;
}
if (responseOk) {
// Preloaders.ViewProductinMarket(response);
successModal();
gotoPage('ViewStoreMarket', response);
return true;
}
};
SendPostDataFormwithTARGETUPLOADEDFILES(LoadDataPageFunc.URLs.NewUrl, LoadDataPageFunc.formclass, submitsuccess);
};
LoadDataPageFunc.ValidateForm = function () {
return validateInputForm(['name', 'description', 'address', 'category']);
const isAnyoftheRequiredEmpty = !inputsArray['NewProductName'] || !inputsArray['NewProductDescription'] || !inputsArray['NewProductCategory'] || !inputsArray['NewProductSubCategory'] ||
!inputsArray['NewProductPrice'] || !inputsArray['NewProductAvailable'] || !inputsArray['NewProductUnitName'] || Target_Uploaded_Files.length === 0;
if (isAnyoftheRequiredEmpty || isBarcodeNumeric === false) {
return false;
}
const IsBarcodeValid = IsStringBarcode12Digits(inputsArray['NewProductBarcode']);
return true;
};
LoadDataPageFunc.Main = function () {
LoadDataPageFunc.LoadUI();
LoadDataPageFunc.RepopulateStoreOwnerList();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,344 @@
<br><br>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move; display: none;">
<h3 class="card-title"></h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<div class="row card-body d-flex align-items-center w-100">
<div class="input-group mb-3">
<input type="number" id="usernumber" class="form-control createuserinputfield"
placeholder="Mobile Number" name="usernumber">
</div>
<div class="input-group mb-3" style="" id="user-create-nickname-input-group">
<input type="text" id="nickname" class="form-control createuserinputfield" placeholder="Nick Name"
name="nickname">
</div>
<div class="input-group mb-3" style="" id="user-create-name-input-group">
<input type="text" id="name" class="form-control createuserinputfield" placeholder="Name" name="name">
</div>
<div class="input-group mb-3" style="" id="user-create-username-input-group">
<input type="text" id="username" class="form-control createuserinputfield" placeholder="Username" name="username">
</div>
<div class="input-group mb-3" style="" id="user-create-fullname-input-group">
<input type="text" id="fullname" class="form-control createuserinputfield" placeholder="Fullname" name="fullname">
</div>
<div class="input-group mb-3" id="usertypecontrol" style="">
<select class="form-control" id="usertype">
</select>
</div>
<div class="input-group mb-3" id="userparentcontrol" style="">
<select class="form-control" id="userparent">
</select>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control createuserinputfield" placeholder="Password"
id="userpassword" name="userpassword">
</div>
<div class="input-group mb-3">
<input type="password" class="form-control createuserinputfield" placeholder="ConfirmPassword"
id="userpasswordconfirm" name="userpasswordconfirm">
</div>
<div class="input-group mb-3">
<button class="form-control btn-primary" id="RegisterNowButton" onclick="RegisterConfirmationPrompt();"
style="display:none;">Register Now</button>
</div>
</div>
</div>
</div>
<script>
var usernumberallowed = false;
var usernicknameallowed = false;
var normalpasswordallowed = false;
var confirmpasswordallowed = false;
window.hasValidMobileNumberFormat = function hasValidFormat(usernumber) {
const pattern = /^09\d{9}$/;
return pattern.test(usernumber);
}
function VerifyInitialPassword() {
const userPassword = document.getElementById("userpassword").value;
if (userPassword.length < 6) {
changeSpantoInvalid('user-password');
normalpasswordallowed = false;
return false;
}
changeSpantoValid('user-password');
normalpasswordallowed = true;
return true;
}
function VerifyConfirmPassword() {
const userPassword = document.getElementById("userpassword").value;
const userPasswordConfirm = document.getElementById("userpasswordconfirm").value;
if (userPassword.length < 6 || userPasswordConfirm.length < 6) {
changeSpantoInvalid('user-password-confirm');
confirmpasswordallowed = false;
return false;
}
if (userPassword !== userPasswordConfirm) {
changeSpantoInvalid('user-password-confirm');
confirmpasswordallowed = false;
return false;
}
changeSpantoValid('user-password-confirm');
changeSpantoValid('user-password');
confirmpasswordallowed = true;
return true;
}
function changeSpantoInvalid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-times-circle");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-danger");
}
function changeSpantoValid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-check");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-primary");
}
function checkifUserExists() {
let usernumber = $('#usernumber').val();
if (!window.hasValidMobileNumberFormat(usernumber)) {
changeSpantoInvalid('mobile-number');
usernumberallowed = false;
return false;
}
function CheckUser(response) {
if (response.exists === true) {
changeSpantoInvalid('mobile-number');
usernumberallowed = false;
return false;
} else if (response.exists === false) {
changeSpantoValid('mobile-number');
usernumberallowed = true;
return true;
}
}
AjaxDo('/admin/user/number/exists', {
mobile_number: usernumber
}, CheckUser, null, reqtype = 'POST');
}
function checkifUsernameExists() {
let username = $('#username').val();
if (username === '') {
changeSpantoValid('username');
usernicknameallowed = true;
SRegistrationValidateALLinputs();
return;
}
function CheckUsername(response) {
if (response.exists === true) {
changeSpantoInvalid('nick-name');
usernicknameallowed = false;
SRegistrationValidateALLinputs();
return false;
} else if (response.exists === false) {
changeSpantoValid('nick-name');
usernicknameallowed = true;
SRegistrationValidateALLinputs();
return true;
}
}
AjaxDo('/admin/user/username/exists', {
username: username
}, CheckUsername, null, reqtype = 'POST');
}
function SRegistrationValidateALLinputs() {
if (usernumberallowed && normalpasswordallowed && confirmpasswordallowed && usernicknameallowed) {
$('#RegisterNowButton').show();
return true;
} else {
$('#RegisterNowButton').hide();
return false;
}
}
function RegisterConfirmationPrompt() {
let modalid = "CreateUserConfirmationDialog";
let modaltitle = 'Create New User?';
let modalbody = 'Are you sure you want to Create a New User?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="SregisterNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationSuccessModal(userhashkey) {
let modalid = "CreateUserSuccessModal";
let modaltitle = 'Success';
let modalbody = 'User Created Successfully';
let modalfooter = `<button type="button" class="btn btn-primary" onclick="$('#CreateUserSuccessModal').modal('hide');ButtonGo('user_list',0);" id="request-credit-now">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationFailedModal() {
let modalid = "CreateUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Error Creating User. User was not created.';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationFailedModalErrorMessage(Message) {
let modalid = "CreateUserFailedModalErrorMessage";
let modaltitle = 'Failed';
let modalbody = Message;
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function RePopulateParentList() {
function UpdateSelectParentList(response) {
const selectElement = $("#userparent");
response.forEach(element => {
$("<option></option>")
.val(element.hashkey)
.text(`${element.name} (${element.mobile_number}) [${element.username}] ${element.fullname ?? ''}`)
.appendTo(selectElement);
});
}
AjaxDo('/admin/user/list/numbers/hash', {}, UpdateSelectParentList, null, reqtype = 'POST');
}
function RePopulateUserTypeCreateUser() {
function UpdateSelectUserTypeList(response) {
const selectElement = $("#usertype"); // Select the element using jQuery
selectElement.html('');
response.forEach(element => {
$("<option></option>")
.val(element[0])
.text(element[1])
.appendTo(selectElement); // Create and append option with values
});
}
AjaxDo('/admin/list/usertype/create', {}, UpdateSelectUserTypeList, null, reqtype = 'POST');
}
function SregisterNow() {
$('#CreateUserConfirmationDialog').modal('hide');
function RegisterNow(response) {
console.log(response);
if (typeof response.success !=='undefined' &&
response.success) {
UserRegistrationSuccessModal(response.hashkey);
} else if (response === false) {
UserRegistrationFailedModal();
}
}
AjaxDo('/admin/user/create', {
mobile_number: $("#usernumber").val(),
password: $("#userpassword").val(),
nickname: $("#nickname").val(),
type: $("#usertype").val(),
parent: $("#userparent").val(),
fullname: $("#fullname").val(),
name: $("#name").val(),
username: $("#username").val(),
}, RegisterNow, null, reqtype = 'POST');
}
$('#usernumber').keyup(function () {
checkifUserExists();
SRegistrationValidateALLinputs();
});
$('#username').keyup(function () {
checkifUsernameExists();
});
$('#userpassword').keyup(function () {
VerifyInitialPassword();
SRegistrationValidateALLinputs();
});
$('#userpasswordconfirm').keyup(function () {
VerifyConfirmPassword();
SRegistrationValidateALLinputs();
});
$('.createuserinputfield').keyup(function () {
SRegistrationValidateALLinputs();
});
RePopulateUserTypeCreateUser();
RePopulateParentList();
</script>

View File

@@ -0,0 +1,92 @@
<script>
defaultBackOnclick = null;
try {
currentData = @json($current_data);
} catch (error) {
currentData = null;
}
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.EditUrl = `{{ route('admin.products.edit', [], false) }}`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Products/New/Category/Datalist`;
LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Product`;
LoadDataPageFunc.PageTitle = 'Edit Product';
LoadDataPageFunc.pageName = 'EditProductAdmin';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'EditProductPhotos';
LoadDataPageFunc.formclass = 'EditProductMarket';
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped = function () {
document.getElementById("EditProductCategory").addEventListener("keyup", function (event) {
console.log('hey'); // the even does not seem to fire
const inputValue = event.target.value;
const categoryinputvalue = document.getElementById("EditProductCategory").value;
QueryandReplaceDatalist("EditProductSubCategoryDataList",
LoadDataPageFunc.URLs.SubCategoryDatalist,
'POST', { category: categoryinputvalue }, fromvarcache = true,
function (response) {
});
});
};
LoadDataPageFunc.PopulateCategoryDatalist = function () {
QueryandReplaceDatalist("EditProductCategoryDataList",
LoadDataPageFunc.URLs.CategoryDatalist,
'POST', { }, fromvarcache = true,
);
};
FormBuilder.build({
formClass: 'EditProductMarket',
pageName: LoadDataPageFunc.pageName,
submitUrl: LoadDataPageFunc.URLs.EditUrl,
currentDataUrl: '{{ route('admin.products.view.data', [], false) }}',
topbartitle: LoadDataPageFunc.PageTitle,
defaultback: {
page: 'ManageProductAdmin',
data: currenttarget,
},
onSuccess: (response) => {
ModalQuickDismiss('Success', 'Product Updated');
},
onError: (err) => {
ModalQuickDismiss('Error', 'Failed to update product.<br>' + err.message);
},
unabletoLoadFunc: function (err) {
ModalQuickDismiss('Error', 'Failed to update product.<br>' + err.message);
},
onFormGenerated: function () {
LoadDataPageFunc.UpdateSubCategoryDatalistasTyped();
LoadDataPageFunc.PopulateCategoryDatalist();
},
fields: [
{ type: 'text', id: 'EditProductName', label: 'Name', placeholder: 'Product Name', required: true, currentdatavar: 'name' },
{ type: 'textarea', id: 'EditProductDescription', label: 'Description', required: true, currentdatavar: 'description' },
{ type: 'text', id: 'EditProductCategory', label: 'Category', placeholder: 'Category', required: true, datalist: 'EditProductCategoryDataList', currentdatavar: 'category' },
{ type: 'text', id: 'EditProductSubCategory', label: 'Subcategory', placeholder: 'Subcategory', required: true, datalist: 'EditProductSubCategoryDataList', currentdatavar: 'subcategory' },
{ type: 'number', id: 'EditProductPrice', placeholder: '260', label: 'Price (PHP)', required: true, currentdatavar: 'price' },
{ type: 'text', id: 'EditProductUnitName', label: 'Unit', placeholder: 'ex 25kg', required: true, currentdatavar: 'unitname' },
// { type: 'number', id: 'EditProductAvailable',placeholder:'ex. 999', label: 'Available Stock', required: true, currentdatavar: 'available' },
{ type: 'text', id: 'EditProductBarcode', label: 'Barcode', placeholder: '12-digit number', maxlength: 12, pattern: '[0-9]*', currentdatavar: 'barcode' },
{ type: 'dropzone', id: LoadDataPageFunc.ids.photodropzone, label: 'Photo', uploadUrl: LoadDataPageFunc.URLs.PhotoUpload, currentdatavar: 'photourlDropzone' },
{ type: 'button', label: 'Submit', onClick: 'FormBuilder.submit()' },
]
});
</script>

View File

@@ -0,0 +1,224 @@
<div id="EditStoreForm">
</div>
<script>storeUnavailabe = false;</script>
@php
use App\Http\Controllers\UserManagement\CreateUserControllerUltimate;
@endphp
<script>
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.EditUrl = `/Store/Edit`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Store/New/Category/Datalist`;
// LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Store`;
LoadDataPageFunc.PageTitle = 'Edit Store';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'NewStorePhotos';
LoadDataPageFunc.formclass = 'NewStoreMarket';
try {
StoreData = @json($current_data);
} catch (error) {
StoreData = {};
}
LoadDataPageFunc.LoadUI = function () {
let finalhtml = '';
const formclass = LoadDataPageFunc.formclass;
const textbox = function (placeholder, label, id, required = false, datalist = '', textvalue = '') {
return UIInputGroup(placeholder, 'text', id, label, formclass, spanclass = '', imginsteadofspan = '', required, textvalue, datalist, imgwidth = '', imgheight = '');
};
const name = textbox('Store Name', 'Name', 'name', true, '', StoreData.name);
const description = UIInputGroupTEXTAREA(label = 'Description', 'description', required = true, textareacontent = StoreData.description, formclass);
const category = textbox('Product Category', 'Category', 'category', true, 'NewStoreCategoryDataList', StoreData.category);
const address = UIInputGroupTEXTAREA(label = 'Address', 'address', required = true, textareacontent = StoreData.address, formclass);
const categorydatalist = ArraytoDatalist("NewStoreCategoryDataList", [], false) || '';
const photoscontainer = UIInputGroupFileUploadDropzone(LoadDataPageFunc.ids.photodropzone, label = 'Photo', LoadDataPageFunc.URLs.PhotoUpload);
//ADD Validator for Javascript Inputs to Prevent JS Code Injection on ALL
const storeOwner = UIInputGroupSelect('owner', label = 'Store Owner', [['', 'Select User']], spanclass = '', imginsteadofspan = '', '', '', '', formclass);
//TODO Add Support for storeManager and Cashier multiple accounts support
const submitbutton = UIInputGroupButton('Submit', formclass, buttonid = '', onclick = 'LoadDataPageFunc.TryToSubmit();', buttonstyle = '');
finalhtml = name + description + category + categorydatalist + address + photoscontainer + storeOwner + submitbutton;
finalhtml = CreateCardSimple(false, finalhtml);
document.getElementById('EditStoreForm').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();
QueryandReplaceDatalist("NewStoreCategoryDataList", LoadDataPageFunc.URLs.CategoryDatalist, 'POST', null, fromvarcache = true);
currentDropzone[LoadDataPageFunc.ids.photodropzone].functions.ReplaceDropzoneFiles(StorePhotosDropzone);
};
LoadDataPageFunc.RepopulateStoreOwnerList = function () {
function UpdateSelectParentList(response) {
const selectElement = $("#owner");
response.forEach(element => {
$("<option></option>")
.val(element.hashkey)
.text(`${element.name} (${element.mobile_number}) [${element.username}] ${element.fullname ?? ''}`)
.appendTo(selectElement);
});
selectElement.val(StoreData.owner_hashkey || 0);
}
@if ($FragmentOnly)
AjaxDo('/admin/user/list/numbers/hash', {}, UpdateSelectParentList, null, reqtype = 'POST');
@else
let userdata = @json(CreateUserControllerUltimate::listAllUsersforParentSelectHTML(true));
UpdateSelectParentList(userdata);
@endif
};
LoadDataPageFunc.TryToSubmit = function () {
const currentformdata = LoadDataPageFunc.ValidateForm();
if (!currentformdata) {
ModalQuickDismiss('Error', 'Name, Description, Category and Address are required fields.', modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
return false;
}
const errorModal = function (errorstring = '') {
ModalQuickDismiss('Error', 'Unable Update Store. <br>' + errorstring, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
};
const successModal = function () {
hideallmodals();
ModalQuickDismiss('Success', 'New Store Updated');
};
const submitsuccess = function (response) {
if (typeof response.success !== 'undefined' && response.success === true) {
Preloaders.ViewStoreinMarket(currenttarget, false, function (response) {
successModal();
gotoPage('ViewStoreMarket', currenttarget);
});
} else {
errorModal(response.message || 'An error occurred while updating the store.');
}
// responseOk = isResponseAHash(response);
// if (!responseOk) {
// errorModal(response);
// return false;
// }
// if (responseOk) {
// // Preloaders.ViewProductinMarket(response);
// successModal();
// gotoPage('ViewStoreMarket', response);
// return true;
// }
};
SendPostDataFormwithTARGETUPLOADEDFILES(LoadDataPageFunc.URLs.EditUrl, LoadDataPageFunc.formclass, submitsuccess);
};
LoadDataPageFunc.ValidateForm = function () {
return validateInputForm(['name', 'description', 'address', 'category']);
const isAnyoftheRequiredEmpty = !inputsArray['NewProductName'] || !inputsArray['NewProductDescription'] || !inputsArray['NewProductCategory'] || !inputsArray['NewProductSubCategory'] ||
!inputsArray['NewProductPrice'] || !inputsArray['NewProductAvailable'] || !inputsArray['NewProductUnitName'] || Target_Uploaded_Files.length === 0;
if (isAnyoftheRequiredEmpty || isBarcodeNumeric === false) {
return false;
}
const IsBarcodeValid = IsStringBarcode12Digits(inputsArray['NewProductBarcode']);
return true;
};
LoadDataPageFunc.AssignVariablesandLoadUI = function () {
try {
StorePhotosDropzone = StoreData.photourlDropzone;
} catch (error) {
StorePhotosDropzone = [];
}
try {
ParentList = StoreData.ParentList; // TODO ParentListisNotUsed
} catch (error) {
ParentList = false;
}
LoadDataPageFunc.LoadUI();
LoadDataPageFunc.RepopulateStoreOwnerList();
};
LoadDataPageFunc.FetchStoreData = function () {
if (typeof StoreData.name !== 'undefined') {
LoadDataPageFunc.AssignVariablesandLoadUI();
return;
}
let Req = new RequestData(false);
Req.url('/Edit/Store/Details/data').type('POST').fromVarCache(false).data({ target: currenttarget })
.success((response) => {
StoreData = response;
LoadDataPageFunc.AssignVariablesandLoadUI();
}).go();
};
LoadDataPageFunc.Main = function () {
LoadDataPageFunc.FetchStoreData();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,93 @@
@php
$photourl = $currentUser->photourl[0] ?? '/resource-photos/No_image_available.svg.png';
$name = $currentUser->name ?? $currentUser->nickname ?? $currentUser->fullname ?? $currentUser->username ?? '';
$fullname = $currentUser->fullname ?? $currentUser->name ?? '';
$mobile = $currentUser->mobile_number;
$landline = $currentUser?->landline ?? '';
$email = $currentUser->email;
$script_asset = App\Http\Controllers\PageMemoryController::readPublicAssetInMemory('account_settings.js');
if (!$script_asset) {
echo 'empty asset';
}
$account_settings_loaded_text = 'let account_settings_loaded = true;';
@endphp
<script>
{!! $account_settings_loaded_text !!}
</script>
<br><br><br>
<div class="mt-1">
<div class="tf-container">
<div class="box-user">
<div class="inner d-flex flex-column align-items-center justify-content-center">
<div class="box-avatar">
<img src="{{ $photourl }}" id="account_settings_profile_picture" alt="image">
<span class="icon-camera-to-take-photos"></span>
</div>
<div class="info">
<h2 class="fw_8 mt-3 text-center" id="account_settings_fullname_profile">
{{ $name }}
</h2>
<p id="">
<h6 id="account_settings_credit_card_profile_pic"></h6> <i class="icon-copy1"></i></p>
</div>
</div>
</div>
<ul class="mt-7">
<li class="list-user-info"><span class="icon-user"></span>
<h5 id="account_settings_fullname_main"> {{ $fullname }}</h5>
</li>
<li class="list-user-info"><span class="icon-credit-card2"></span>
<h4 id="account_settings_credit_card_main">{{ $mobile }}</h4>
</li>
<li class="list-user-info"><span class="icon-phone"></span>
<h4 id="account_settings_mobile_number">{{ $landline }}</h4>
</li>
<li class="list-user-info"><span class="icon-email"></span>
<h4 id="account_settings_email">{{ $email }}</h4>
</li>
</ul>
</div>
</div>
<div class="card-section" id="main-card-section">
</div>
<br><br>
<script>
if (typeof window.account_settings_loaded === 'undefined') {
let account_settings_loaded = false;
}
account_settings_loaded = {{ $account_settings_loaded ?? false ? 'true' : 'false' }};
{!! App\Http\Controllers\PageMemoryController::readAssetInMemory('account_settings.js') !!}
</script>
<script>
$(document).ready(function () {
if (typeof window.account_settings_loaded === 'undefined') {
window.account_settings_loaded = false;
}
if (!account_settings_loaded) {
account_details_load_data();
}
});
</script>

View File

@@ -0,0 +1,130 @@
<div class="card-body card-info" id="main-card-body" style="">
<div class="row">
<div class="col-md-18">
</div>
</div>
<br>
</div>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<div class="row">
<div class="col">
<h4 class="card-title">Transfer My Credit</h4>
</div>
<div class="col">
</div>
</div>
<div class="card-tools">
</div>
</div>
<div class="card-body " id="credit-amount-request-form">
<div class="row">
<div class="col-6">
<input class="form-control" type="number" id="transfer-credit-amount-field"
placeholder="Amount to Transfer">
</div>
<div class="col-6">
<button value="Transfer" id="Transfer-credit-initial-button" class=" form-control btn btn-primary"
onclick="CreateAndShowModalTransferMyCreditConfirmation()">Transfer Credit</button>
</div>
</div>
</div>
</div>
<script>
function CreateAndShowModalTransferMyCreditConfirmation() {
if (!$('#transfer-credit-amount-field').val()) { return false; }
const modalid = "modal-credit-transfer-confirmation";
const modaltitle = "Continue?";
const modalbody = `
<p>You are sending credit from your account to the target User?</p>
`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="TransferMyCreditNow();" id="transfer-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function SuccessCreditTransferResponse() {
const modalid = "modal-credit-transfer-success";
const modaltitle = "Success";
const modalbody = `
<p>Transfer has been sucessful.</p>
`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$("#modal-credit-transfer-confirmation").modal('hide');
Backkey();
}
function ErrorCreditTransferResponse() {
const modalid = "modal-credit-transfer-failed";
const modaltitle = "Failed";
const modalbody = `
<p>Failed to transfer credit. Try Again Later.</p>
`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body ', modalheaderclass = 'modal-header bg-danger');
$("#modal-credit-transfer-confirmation").modal('hide');
}
function TransferMyCreditNow() {
function TransferCreditToUserNow(response) {
if (response === true) {
SuccessCreditTransferResponse();
}
else if (response === false) {
ErrorCreditTransferResponse();
}
}
AjaxDo('/user/sendmycredit', { amount: $("#transfer-credit-amount-field").val().trim(), target_user: currenttarget }, TransferCreditToUserNow, null, reqtype = 'POST');
}

View File

@@ -0,0 +1,101 @@
<br>
<h2 class="fw_6 text-center">BukidBounty Market</h2><br>
<div class="card-section" id="main-card-section">
</div>
<br>
<div class="bill-content">
<div class="tf-container" id="recents_home">
</div>
</div>
<script>
defaultBackOnclick=null;
statsarray = [["Pending", 0, "Orders", "left", "pending_orders_no"],
["Delivered", 0, "Today", "left", "actionable-leads-no"],
["Sold", 0, "Today", "right", "sold-today-no"],
["Balance", 0, "PHP", "right", "total_balance_php"]
//,["Sold", 0, "Total", "right", "sold-all-no"]
];
balancewrapper_item_array = [["New Transaction", "NewTransaction", "", "/assets/transaction.png", "", "", "", ""], ["Transaction Summary", "ListTransactions", "0", "/assets/ListLeads.png", "", "", "", ""]];
balancebox = UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array);
servicesbuttonarray = [
// ['/assets/ListLeads.png', 'Leads', 'ListLeads', ''],
// ['/assets/user-list.png', 'Ultimate Shortcuts', 'ultimate_shortcuts']
['/assets/user-list.png', 'Users', 'user_list', ''],
['/assets/reports.png', 'Reports', 'ListReports'],
['/assets/shopping-cart.png', 'Market', 'ListProductsMarket'],
['/assets/shipments.png', 'Shipments', 'list_shipments'],
['/assets/delivery-bike.png', 'Riders', 'list_riders'],
['/assets/store.png', 'Stores', 'ListStores'],
];
servicesbox = UIServices_FullDIV_GOTOPAGE_Array('', '', '', '', servicesbuttonarray);
todocardtext = `
<img src="/assets/health_advisory.jpg" style="width:100%;border-radius:10px;box-shadow:0 0 5px rgba(0,0,0,0.1);margin-bottom:10px;">
Fix Stores Not showing in the list
<br>
Fix Photo Not Showin in Account Settings
<br>
Address Update In Account Settings
`;
todobox = CreateCardSimple('Announcement', todocardtext);
dualcolumn_button_array = [
// ['Leads', 'ListLeads', '', '/assets/ListLeads.png'],
['Create User', 'create_user', '', '/assets/user-list.png'],
['Accounting', 'ListReports', '', '/assets/reports.png'],
['Create Store', 'NewStoreAdmin', '', '/assets/store.png'],
['New Product', 'NewProductAdmin', '', '/assets/products.png'],
['List Products', 'ListProductsMarket', '', '/assets/products.png'],
];
dualcolumnhtml = UISideText_DualColumnButton_Array(dualcolumn_button_array);
recents_list_array = [['Loading', 'Please Wait...', '', 'xxxwait', 'unknown', '', '/assets/sync.png']];
arrowlist_button_array = '';
searchbox_html = UISearchBox_with_BUTTONS_FULL('Recent', recents_list_array, arrowlist_button_array, 'RecentsPage', '', 'View All', 'HomeRecentList', 'home_recent_search', 'Search');
$('#main-card-section').append(balancebox);
$('#main-body').append(servicesbox + dualcolumnhtml + '<br><br>' + todobox + searchbox_html);
function UIHome_Leads_Today_Change(num) {
if (num === false || num === undefined || num === null) {
return false;
}
$('#leads-today-no').html(num);
}
function loadrecents_home() {
}
function HomeULT_reinitilize_loaders() {
Preloaders.Account_Settings_Details();
Preloaders.ListAllMarketProductsData();
}
$().ready(function () {
changeTopbarTitle('Home');
loadrecents_home();
HomeULT_reinitilize_loaders();
CheckAndSetDarkMode();
});
</script>

View File

@@ -0,0 +1,35 @@
<br>
<h2 class="fw_6 text-center">BukidBounty Market</h2><br>
<h3 class="fw_6 text-center">Ultimate Functions</h3>
<div class="card-section" id="main-card-section">
</div>
<script>
servicesbuttonarray = [
// ['/assets/ListLeads.png', 'Leads', 'ListLeads', ''],
['/assets/user-list.png', 'Users', 'user_list', ''],
['/assets/reports.png', 'Reports', 'ListReports'],
['/assets/shopping-cart.png', 'Market', 'ListProductsMarket'],
['/assets/target.png', 'New Store', 'NewStore'],
['/assets/user-list.png', 'New User', 'create_user']
];
</script>

View File

@@ -0,0 +1,164 @@
@php
$children = App\Http\Controllers\Pages\UserListPageController::ListChildrenofCurrentUser();
$child_script = "child_users = $children;";
@endphp
<script>
if (typeof child_users === 'undefined') {
let child_users = false;
}
{!! $child_script !!}
</script>
<br><br><br><br>
<div class="card" id="secondary-card" style="display:none;">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title">Users</h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<table id="User_list_table">
<thead>
<tr>
<th>Number /<br>Nickname</th>
<th>Total Balance</th>
<th>Type</th>
<th>
<center>Active</center>
</th>
</tr>
</thead>
<tbody id="user-list-table-body">
</tbody>
</table>
</div>
</div>
<br><br><br>
<script>
window.disableduser_checkbox ||= '<img class="icon-box" style="width:40px;height:40px" src="/assets/checkmark.png">';
window.enableduser_checkbox ||= '<img class="icon-box" style="width:40px;height:40px" src="/assets/uncheck.png">';
function GenerateUserRow(Number, Total_Balance, Type, Active, Hashkey) {
let activecheckbox = '';
if (Active === '1' || Active === 1) {
Active = true;
} else { Active = false; }
if (Active) {
activecheckbox = enableduser_checkbox;
} else {
activecheckbox = disableduser_checkbox;
}
const actionbutton = `<button class="btn btn-warning" onclick="gotoPage('UserModify','${Hashkey}')">View User</button>`;
let numandnick = Number;
numandnick = numandnick.replace('----', '<br>');
numandnick = numandnick.replace('----', '<br>');
numandnick = `<a href="#" onclick="gotoPage('UserModify','${Hashkey}');return false;">${numandnick}</a>`;
if (Type == 'user') { Type = 'Player'; }
if (Type == 'usher') { Type = 'Leader'; }
if (Type == 'coordinator') { Type = 'Team Leader'; }
return `<tr>
<td>${numandnick}</td>
<td>${Total_Balance}</td>
<td>${Type}</td>
<td>${activecheckbox}</td>
</tr>`;
}
async function GenerateUserRows(responsearray) {
// console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateUserRow(
responsearray[i]['mobile_number'],
responsearray[i]['total_balance'],
responsearray[i]['acct_type'],
responsearray[i]['active'],
responsearray[i]['hashkey']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#User_list_table").find("tbody").html(newhtmltable);
let userlist = $("#User_list_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
userlist.on('click', 'tbody tr', function () {
let data = userlist.row(this).data();
if (typeof data === 'undefined') { return false; }
let targettranshash = data[0];
// console.log(targettranshash);
$(targettranshash).find('a').trigger('click');
});
$('#secondary-card').fadeIn(200);
}
function GenerateUserTable() {
let REQQ = new RequestData(false);
REQQ.url('/admin/users/list').type('POST').success((response) => {
GenerateUserRows(response);
}).go();
// AjaxDo('?/admin/users/list', null, GenerateUserRows, null, reqtype = 'POST');
}
if (child_users) {
GenerateUserRows(child_users);
}
GenerateUserTable();
changeTopbarTitle('Users');
</script>

View File

@@ -0,0 +1,848 @@
@php
if (!$FragmentOnly) {
$echo['SetLoadedFlagFalse'];
$checkboxActive = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/checkmark.png"></center>';
$checkboxInactive = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/uncheck.png"></center>';
$active_checkbox = '';
if (isset($current_target)) {
$User = $userModifyAdmin::getDetailsbyHashkey($current_target);
if (!$User) {
echo '<script>ModalQuickDismiss("Error", "User Not Found")</script>';
} else {
$user_phonenumber = $User['mobile_number'];
$user_nickname = $User['nickname'];
$user_fullname = $User['fullname'];
$active = $User['active'];
$created_time = $User['created'];
$acct_type = $User['acct_type']->value;
$total_balance = $User['total_balance'];
$parent = $User['parent'];
$additional_roles = $User['additional_roles'] ?? [];
$current_roles = $userModifyAdmin::ShowUserRoles($current_target);
$all_roles = $userModifyAdmin::ShowAllRoles();
$echo['SetLoadedFlagTrue'];
}
$children = $userModifyAdmin::getchildrenofTargetUser($current_target);
}
if ($active ?? false) {
$active_checkbox = $checkboxActive;
} else {
$active_checkbox = $checkboxActive;
}
}
@endphp
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title" style="" id="User_phonenumber">{{ $user_phonenumber ?? '' }}</h3>
<div class="card-tools">
<h3 class="card-title" style="" id="User_nick">{{ $user_nickname ?? '' }}</h3>
</div>
</div>
<div class="card-body ">
<h3 style="text-align:center; padding-bottom:10px;" id="User_fullname">{{ $user_fullname ?? '' }}</h3>
<div class="card-section" id="main-card-section">
<div class="tf-container">
<div class="tf-balance-box" style="border: solid 3px #000d88;">
<div id="balance_wrapper">
<div class="balance">
<div class="row">
<div class="col br-right">
<div class="inner-left">
<p>Created</p>
<h3 id="creation_date">{{ $created_time ?? '' }}</h3>
</div>
</div>
<div class="col br-right">
<div class="inner-left">
<p>Active</p>
<h3 id="active_checkbox">
{!! $active_checkbox ?? '' !!}
</h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>Parent</p>
<h3 id="user_parent">{{ $parent ?? '' }}</h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>User Type</p>
<h3 id="user_type_column">
{{ $acct_type ?? '' }}
</h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>Balance</p>
<h3 id="user_balance">{{ $total_balance ?? '' }}</h3>
</div>
</div>
</div>
</div>
</div>
<div class="wallet-footer">
<ul class="d-flex justify-content-between align-items-center">
<li class="wallet-card-item">
<a class="fw_6 text-center" id="btn-popup-down" href="javascript:void(0);"
onclick="ButtonGo('NewLeads','');return false;">
<ul>
<li class="path1"></li>
<li class="path2"></li>
<li class="path3"></li>
<li class="path4"></li>
</ul>
<img src="/assets/NewLeads.png" style="width: 30; height: 30;" class="icon-user">
New Lead
</a>
</li>
<li class="wallet-card-item">
<a class="fw_6 text-center" id="btn-popup-down" href="javascript:void(0);"
onclick="ButtonGo('ListLeads','0');return false;">
<ul>
<li class="path1"></li>
<li class="path2"></li>
<li class="path3"></li>
<li class="path4"></li>
</ul>
<img src="/assets/ListLeads.png" style="width: 30; height: 30;" class="icon-user">
List Leads
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<br><br>
<div class="mt-5">
<div class="tf-container">
<div class="tf-title d-flex justify-content-between">
<h3 class="fw_6"></h3>
<a href="" onclick="" class="primary_color fw_6"></a>
</div>
<ul class="box-service mt-3" id="user_controls">
</ul>
</div>
</div>
</div>
</div>
<br><br>
<div class="card" id="third-card" style='display:none;'>
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title" style="">Members</h3>
<div class="card-tools">
</div>
</div>
<div class="card-body " id='user_details_children'>
<table id="User_details_children_table">
<thead>
<tr>
<th>Number /<br>Nickname</th>
<th>Total Balance</th>
<th>Type</th>
<th>
<center>Active</center>
</th>
<th>Parent</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.data = {};
LoadDataPageFunc.data.children = null;
LoadDataPageFunc.data.CurrentRoles = null;
LoadDataPageFunc.data.AllRoles = null;
@if (isset($current_roles) && $current_roles)
LoadDataPageFunc.data.CurrentRoles = {!! json_encode($current_roles) !!}
@endif
@if(isset($all_roles) && $all_roles)
LoadDataPageFunc.data.AllRoles = {!! json_encode($all_roles) !!}
@endif
@if(isset($children) && $children)
LoadDataPageFunc.data.children = {!! json_encode($children) !!}
@endif
LoadDataPageFunc.buttonLImaker = function (text, onclick, icon) {
return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
};
LoadDataPageFunc.ActiveCheckbox = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/checkmark.png"></center>';
LoadDataPageFunc.ActiveUNCheckbox = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/uncheck.png"></center>';
LoadDataPageFunc.UserControls = {};
LoadDataPageFunc.UserControls.Load = function () {
let controlsArr = []; let allcontrolsSTR = '';
let DisableButton = LoadDataPageFunc.buttonLImaker('Disable', 'LoadDataPageFunc.DisableUser();', 'disableuser.png');
DisableButton = $(DisableButton);
DisableButton.attr('id', 'AdminUserDisableButton');
DisableButton = DisableButton.prop('outerHTML');
controlsArr.push(DisableButton);
controlsArr.push(LoadDataPageFunc.buttonLImaker('Set Notes', 'LoadDataPageFunc.SetUserNotesModal();', 'notes.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Set Exec', 'LoadDataPageFunc.SetUserExecModal();', 'exec.png'));
// controlsArr.push(LoadDataPageFunc.buttonLImaker('Request Credit For User', 'LoadDataPageFunc.OpenRequestCredit();', 'request-credit.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Update Details', 'LoadDataPageFunc.UpdateUserDetailsDialog();', 'edituser.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Reset Password', 'LoadDataPageFunc.ResetUserPassword();', 'resetpassword.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Transfer My Credit', 'LoadDataPageFunc.TransferMyCredit();', 'transfercredit.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Logout', 'LoadDataPageFunc.OpenLogoutUser();', 'logout.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Roles', 'LoadDataPageFunc.Roles.ShowFetchedUserRoles();', 'briefcase.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Change Parent', 'LoadDataPageFunc.ChangeParentModal();', 'atlas/ecology/leaf-tag.svg'));
allcontrolsSTR = controlsArr.join('');
$('#user_controls').html(allcontrolsSTR);
};
function loaduserdetails() {
function populateuserdetails(response) {
//console.log(response);
if (response.created) {
response.created = formatDateTimetoReadable(response.created);
}
$('#User_phonenumber').html(response.mobile_number);
$('#User_nick').html(response.nickname);
$('#creation_date').html(response.created);
if (response.active === '1' || response.active === 1 || response.active === true) {
LoadDataPageFunc.ChangeToEnableUserButton();
}
else {
LoadDataPageFunc.ChangeToDisableUserButton();
}
$('#user_parent').html(response.parent);
$('#user_type_column').html(response.acct_type);
if (response.total_balance || response.total_balance === 0) {
$('#user_balance_column').show();
$('#user_balance').html(response.total_balance);
}
if (response.nickname) {
$('#user_type_column').show();
}
}
LoadDataPageFunc.UserControls.Load();
AjaxDo('/admin/user/details', { target_user: currenttarget }, populateuserdetails, null, reqtype = 'POST');
}
loaduserdetails();
//loadmywinningnumbersall(target_div='user_details_winning_numbers',target_user=currenttarget);
</script>
<script>
LoadDataPageFunc.Roles = {};
LoadDataPageFunc.Roles.ShowUserRoles = function () {
let finalhtml = '';
const formclass = 'UserRoles';
let roleshtml = '';
if (typeof LoadDataPageFunc.data.CurrentRoles === 'object') {
LoadDataPageFunc.data.CurrentRoles.forEach(role => {
roleshtml += UIInputGroupCheckBox('ROLE' + role.value, role.name, true, additional_input_class = 'RolesAllowed')
});
LoadDataPageFunc.data.AllRoles.forEach(role => {
const exists = LoadDataPageFunc.data.CurrentRoles.some(cr => cr.value === role.value);
if (!exists) {
roleshtml += UIInputGroupCheckBox(
'ROLE' + role.value,
role.name,
false,
additional_input_class = 'RolesAllowed'
);
}
});
}
// const submitbutton = UIInputGroupButton('Submit', formclass, buttonid = '', onclick = 'LoadDataPageFunc.UpdateUserRoles();', buttonstyle = '');
finalhtml = roleshtml;
finalhtml = CreateCardSimple(false, finalhtml);
let modalbody = finalhtml;
let modalfooter = UIInputGroupButton('Update', formclass, buttonid = '', onclick = 'LoadDataPageFunc.Roles.UpdateUserRoles();', buttonstyle = '');
CreateAndShowModal('ChangeUserRolesModal', 'User Roles', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.Roles.ShowFetchedUserRoles = function () {
if (LoadDataPageFunc.data.CurrentRoles && LoadDataPageFunc.data.AllRoles) {
LoadDataPageFunc.Roles.ShowUserRoles();
return;
}
LoadDataPageFunc.Roles.FetchRoles(function () {
LoadDataPageFunc.Roles.ShowUserRoles();
});
};
LoadDataPageFunc.Roles.FetchRoles = function (success = null, error = null) {
LoadDataPageFunc.Req.url(`/admin/user/roles/get`).type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
LoadDataPageFunc.data.CurrentRoles = response;
LoadDataPageFunc.Req.url(`/admin/user/roles/all`).type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
LoadDataPageFunc.data.AllRoles = response || [];
if (success && typeof success === 'function') {
success(response);
}
}).error((response) => {
if (error && typeof succerroress === 'function') {
error(response);
}
}).go();
}).error((response) => {
if (error && typeof succerroress === 'function') {
error(response);
}
}).go();
};
LoadDataPageFunc.Roles.GetSelectedRoles = function () {
const selectedRoles = [];
document.querySelectorAll('.RolesAllowed').forEach(checkbox => {
if (checkbox.checked) {
const label = document.querySelector(`label[for="${checkbox.id}"]`);
if (label) {
selectedRoles.push(label.textContent.trim());
}
}
});
return selectedRoles;
}
LoadDataPageFunc.Roles.UpdateUserRoles = function () {
LoadDataPageFunc.Req.url(`/admin/user/roles/change`).type('POST').fromVarCache(false).data({ target_user: currenttarget, roles: LoadDataPageFunc.Roles.GetSelectedRoles() })
.success((response) => {
LoadDataPageFunc.data.AllRoles = response || [];
LoadDataPageFunc.Roles.FetchRoles(function () {
ModalQuickDismiss('Success', 'Roles Updated');
});
}).error((response) => {
ModalQuickDismiss('Error', response);
}).go();
};
LoadDataPageFunc.Req = new RequestData(false);
LoadDataPageFunc.SetUserNotesModal = function () {
let modalbody = `<textarea id="SetUserNotesContentTextArea" class="form-control" rows="4" cols="50"></textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="LoadDataPageFunc.UpdateUserNotesTarget()">Update</button><button class="btn btn-danger" onclick="LoadDataPageFunc.EraseUserNotesTarget();">Clear</button>`;
CreateAndShowModal('SetUserNotesModal', 'Set Notes For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserNotesContentTextArea').load('/admin/user/note/content', { target_user: currenttarget });
};
LoadDataPageFunc.EraseUserNotesTarget = function () {
let Req = LoadDataPageFunc.Req;
function ShowConfirmationEraseUserNotesTarget(response) {
if (response) {
ModalQuickDismiss('Success', 'Note Deleted');
hidemodal('SetUserNotesModal');
} else {
ModalQuickDismiss('Failed', 'Unable to Delete Note.');
}
}
Req.url('/admin/user/note/delete').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
ShowConfirmationEraseUserNotesTarget(response);
}).go();
};
LoadDataPageFunc.UpdateUserNotesTarget = function () {
let Req = LoadDataPageFunc.Req;
let newnotevalue = $('#SetUserNotesContentTextArea').val();
if (!newnotevalue) { ModalQuickDismiss('Failed', 'No Content. Note was not updated.'); return false; }
function NoteUpdateConfirmationTarget(response) {
if (!response) {
ModalQuickDismiss('Failed', 'Unable to Update Notes'); return false;
} else {
ModalQuickDismiss('Updated', 'Notes Updated.');
hidemodal('SetUserNotesModal'); return true;
}
}
Req.url('/admin/user/note/update').type('POST').fromVarCache(false).data({ target_user: currenttarget, newnotecontent: newnotevalue })
.success((response) => {
NoteUpdateConfirmationTarget(response);
}).go();
console.log('df');
};
LoadDataPageFunc.SetUserExecModal = function () {
let modalbody = `<textarea id="SetUserExecContentTextArea" class="form-control" rows="4" cols="50">
</textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="LoadDataPageFunc.UpdateUserExecTarget()">Update</button><button class="btn btn-danger" onclick="LoadDataPageFunc.EraseUserExecTarget();">Clear</button>`;
CreateAndShowModal('SetUserExecModal', 'Set Exec For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserExecContentTextArea').load('/admin/user/exec/content', { target_user: currenttarget });
};
LoadDataPageFunc.EraseUserExecTarget = function () {
let Req = LoadDataPageFunc.Req;
function ShowConfirmationEraseUserExecTarget(response) {
if (response) {
ModalQuickDismiss('Success', 'Exec Deleted');
hidemodal('SetUserExecModal');
} else {
ModalQuickDismiss('Failed', 'Unable to Delete Exec.');
}
}
Req.url('/admin/user/exec/delete').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
ShowConfirmationEraseUserExecTarget(response);
}).go();
};
LoadDataPageFunc.UpdateUserExecTarget = function () {
let Req = LoadDataPageFunc.Req;
let newexecvalue = $('#SetUserExecContentTextArea').val();
if (!newexecvalue) { ModalQuickDismiss('Failed', 'No Content. Exec was not updated.'); return false; }
function ExecUpdateConfirmationTarget(response) {
if (!response) {
ModalQuickDismiss('Failed', 'Unable to Update Exec'); return false;
} else {
ModalQuickDismiss('Updated', 'Exec Updated.');
hidemodal('SetUserExecModal'); return true;
}
}
Req.url('/admin/user/exec/update').type('POST').fromVarCache(false).data({ target_user: currenttarget, newexeccontent: newexecvalue })
.success((response) => {
ExecUpdateConfirmationTarget(response);
}).go();
};
LoadDataPageFunc.DisableUserButtonHtml = function () {
let button = LoadDataPageFunc.buttonLImaker('Disable', 'LoadDataPageFunc.DisableUser();', 'disableuser.png');
button = $(button);
button = button.html();
return button;
};
LoadDataPageFunc.EnableUserButtonHtml = function () {
let button = LoadDataPageFunc.buttonLImaker('Enable', 'LoadDataPageFunc.EnableUser();', 'enable-user.png');
button = $(button);
button = button.html();
return button;
};
LoadDataPageFunc.ChangeToEnableUserButton = function () {
$('#active_checkbox').html(LoadDataPageFunc.ActiveCheckbox);
$('#AdminUserDisableButton').html(LoadDataPageFunc.DisableUserButtonHtml);
};
LoadDataPageFunc.ChangeToDisableUserButton = function () {
$('#active_checkbox').html(LoadDataPageFunc.ActiveUNCheckbox);
$('#AdminUserDisableButton').html(LoadDataPageFunc.EnableUserButtonHtml);
};
LoadDataPageFunc.ModalDisableSuccess = function () {
let modalid = "DisableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Disabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalDisableFailed = function (response) {
let modalid = "DisableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Disable User'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalEnableSuccess = function () {
let modalid = "EnableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Enabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalEnableFailed = function (response) {
let modalid = "EnableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Enable User.<br>'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.EnableUserNow = function () {
let Reqq = new RequestData(false);
function TryToEnable(response) {
$("#EnableUserConfirmationDialog").modal('hide');
if (response === true) {
LoadDataPageFunc.ModalEnableSuccess();
LoadDataPageFunc.ChangeToEnableUserButton();
} else {
LoadDataPageFunc.ModalEnableFailed(response);
}
LoadDataPageFunc.CheckIfUserActive();
loaduserdetails();
};
Reqq.url('/admin/user/enable').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
TryToEnable(response);
}).go();
};
LoadDataPageFunc.ChangeParentModal = function () {
ModalQuickDismiss('Error','Function Not Implemented');
};
LoadDataPageFunc.DisableUserNow = function () {
let Reqq = new RequestData(false);
function TryToDisable(response) {
$("#DisableUserConfirmationDialog").modal('hide');
if (response === true) {
LoadDataPageFunc.ModalDisableSuccess();
LoadDataPageFunc.ChangeToDisableUserButton();
} else {
ModalDisableFailed(response);
}
LoadDataPageFunc.CheckIfUserActive();
loaduserdetails();
}
Reqq.url('/admin/user/disable').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
TryToDisable(response);
}).go();
}
LoadDataPageFunc.DisableUser = function () {
let modalid = "DisableUserConfirmationDialog";
let modaltitle = 'Disable User?';
let modalbody = 'Are you sure you want to disable user?<br> The user would not be able to access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.DisableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.EnableUser = function () {
let modalid = "EnableUserConfirmationDialog";
let modaltitle = 'Enable User?';
let modalbody = 'Are you sure you want to Enable user?<br> The user would have access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.EnableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.CheckIfUserActive = function () {
let Reqq = new RequestData(false);
function ChangeDisableButtonState(response) {
console.log(response);
if (response === true) {
LoadDataPageFunc.ChangeToDisableUserButton();
}
else if (response === false) {
LoadDataPageFunc.ChangeToEnableUserButton();
}
}
Reqq.url('/admin/user/isactive').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
ChangeDisableButtonState(response);
}).go();
};
LoadDataPageFunc.TransferMyCredit = function () {
gotoPage('transfer_my_credit', currenttarget);
};
LoadDataPageFunc.OpenUpdateUserDetailsButtonHtml = function () {
return HomeMenuButtons('assets/edituser.png', 'Update Details', '', '', '45%', '45%', '', buttononclick = 'LoadDataPageFunc.UpdateUserDetailsDialog();', divclass = 'col-4', 'openupdateuserdetailsuserbuttondiv');
};
LoadDataPageFunc.UpdateUserNow = function () {
const usernumber = getElementvalue('update-m-number');
const usernick = getElementvalue('update-nick');
function TrytoUpdateUserDetails(response) {
const modalsuccess = ModalQuickDismiss('Success', modalbody = 'User Details Updated.', modalid = 'UpdateUserDetailsSuccess', modaltohide = 'UpdateUserDetailsDialog', ReloadPage, response);
const modalfailed = ModalQuickDismiss('Failed', modalbody = 'Unable to Update User Details.<br><br>' + response, modalid = 'UpdateUserDetailsFailed', modaltohide = '', functiontodo = '', response !== true);
}
AjaxDo('/admin/user/details/update', { target_user: currenttarget, details: { mobile_number: usernumber, nickname: usernick } }, TrytoUpdateUserDetails, null, reqtype = 'POST');
};
LoadDataPageFunc.UpdateUserDetailsDialog = function () {
const usernumber = getElementhtml('User_phonenumber');
const usernick = getElementhtml('User_nick');
let modalbody = dualcolrow('Mobile Number', textformcontrol('update-m-number', '', '', placeholder = '09xxxxxxxxx', usernumber)) + '<br>' +
dualcolrow('Nickname', textformcontrol('update-nick', '', '', '', usernick));
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.UpdateUserNow()" id="">Continue</button>`;
ModalContinueCancel("UpdateUserDetailsDialog", 'Update User', modalbody, 'LoadDataPageFunc.UpdateUserNow();');
// CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ResetUserPassword = function () {
let modalbody = dualcolrow('New Password', '<input type="password" class="form-control" id="reset-password-new">');
ModalContinueCancel('reset-user-password-dialog', 'Reset Password', modalbody, 'LoadDataPageFunc.ResetUserPasswordNow();', cancelbuttontext = 'Cancel', continuebuttontext = 'Reset', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning');
};
LoadDataPageFunc.OpenResetUserPasswordButtonHtml = function () { return HomeMenuButtons('assets/resetpassword.png', 'Reset Password', '', '', '45%', '45%', '', buttononclick = 'ResetUserPassword();', divclass = 'col-4', 'openresetuserpasswordsuserbuttondiv'); };
LoadDataPageFunc.ResetUserPasswordNow = function () {
if (!$('#reset-password-new').val() || $('#reset-password-new').val().trim().length < 6) {
ModalQuickDismiss('Incorrect Password Input', 'Password must be 6 characters or more.', modalid = 'modal-reset-user-password-success');
}
function ResetUserPasswordResult(response) {
if (response === true) {
ModalQuickDismiss('Password Changed', 'Password Reset Successful. Please inform user', modalid = 'modal-reset-user-password-success', modaltohide = 'reset-user-password-dialog', functiontodo = '', conditiontrue = true);
modalhide('reset-user-password-dialog');
} else {
ModalQuickDismiss('Failed', 'Password was not reset.<br><br>' + response, modalid = 'modal-reset-user-password-success', modaltohide = '', functiontodo = '', conditiontrue = true);
}
}
AjaxDo('/admin/user/password/reset', { target_user: currenttarget, user_new_password: $('#reset-password-new').val() }, ResetUserPasswordResult, null, reqtype = 'POST');
};
LoadDataPageFunc.ResetUserPassword = function () {
let modalbody = dualcolrow('New Password', '<input type="password" class="form-control" id="reset-password-new">');
ModalContinueCancel('reset-user-password-dialog', 'Reset Password', modalbody, 'LoadDataPageFunc.ResetUserPasswordNow();', cancelbuttontext = 'Cancel', continuebuttontext = 'Reset', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning');
};
LoadDataPageFunc.OpenLogoutButtonHtml = function () {
return HomeMenuButtons('assets/logout.png', 'Logout', '', '', '45%', '45%', '', buttononclick = 'OpenLogoutUser()', divclass = 'col-4', 'openlogoutuserbuttondiv', '', textclass = '');
};
LoadDataPageFunc.OpenLogoutUser = function () {
function OpenTryForceLogout(response) {
if (response) {
ModalQuickDismiss('Success', 'Session Ended.');
}
else {
ModalQuickDismiss('Failed', 'Unable to End User Session.');
}
}
let request = new RequestData(false);
request.url('/admin/logout/force/user').type('POST').fromVarCache(false).data({ target_user: currenttarget })
.success((response) => {
OpenTryForceLogout(response);
}).error((response) => {
ModalQuickDismiss('Failed', 'Unable to End User Session.');
}).go();
// AjaxDo('/admin/logout/force/user', { target_user: currenttarget }, OpenTryForceLogout, null, reqtype = 'POST');
};
LoadDataPageFunc.ChildTable = {};
LoadDataPageFunc.ChildTable.GenerateChildRow = function (Number, Total_Balance, Type, Active, parent, Hashkey) {
// console.log(Number,Total_Balance,Type,Active,Parent,Hashkey);
let activecheckbox = '';
if (Active === '1' || Active === 1 || Active === true) {
Active = LoadDataPageFunc.ActiveCheckbox;
} else { Active = LoadDataPageFunc.ActiveUNCheckbox; }
activecheckbox = Active;
let numandnick = Number;
numandnick = numandnick.replace(' ', '<br>');
numandnick = `<a href="#" onclick="gotoPage('UserModify','${Hashkey}',0,1);return false;">${numandnick}</a>`;
parent = parent.replace(/---/g, '<br>');
numandnick = numandnick.replace(/---/g, '<br>');
return `<tr>
<td>${numandnick}</td>
<td>${Total_Balance}</td>
<td>${Type}</td>
<td>${activecheckbox}</td>
<td>${parent}</td>
</tr>`;
}
LoadDataPageFunc.ChildTable.GenerateChildRows = async function (responsearray) {
//console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += LoadDataPageFunc.ChildTable.GenerateChildRow(
responsearray[i]['mobile_number'],
responsearray[i]['total_balance'],
responsearray[i]['acct_type'],
responsearray[i]['active'],
responsearray[i]['parent'],
responsearray[i]['hashkey']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#User_details_children_table").find("tbody").html(newhtmltable);
$('#third-card').fadeIn(200);
let userlist = $("#User_details_children_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
/*
userlist.on('click', 'tbody tr', function () {
let data = userlist.row(this).data();
let targettranshash = data[0];
console.log(targettranshash);
$(targettranshash).find('a').trigger('click');
});
*/
}
LoadDataPageFunc.ChildTable.GenerateChildUsersTable = function () {
if (!LoadDataPageFunc.data.children) {
AjaxDo('/user/details/children', { target_user: currenttarget }, LoadDataPageFunc.ChildTable.GenerateChildRows, null, reqtype = 'POST');
} else {
LoadDataPageFunc.ChildTable.GenerateChildRows(LoadDataPageFunc.data.children);
}
}
$(document).ready(function () {
if (!LoadDataPageFunc.data.CurrentRoles || !LoadDataPageFunc.data.AllRoles) { LoadDataPageFunc.Roles.FetchRoles(); }
LoadDataPageFunc.ChildTable.GenerateChildUsersTable();
});
</script>
<head>
<style>
</style>
</head>
<br><br><br>

View File

@@ -0,0 +1,423 @@
<html lang="en">
<script>
var InitializationFinished = false;
var PerformanceLog = {};
PerformanceLog.Start = performance.now();
PerformanceLog.Logs = [['Start'], PerformanceLog.Start];
PerformanceLog.Log = function (message) {
PerformanceLog.Logs.push([message, performance.now()]);
};
PerformanceLog.DisplayLogs = function () {
const arr = PerformanceLog.Logs;
for (let i = 0; i < arr.length; i++) {
console.log(arr[i][0], arr[i][1]);
}
};
</script>
<head>
@vite('resources/js/app.js')
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Mobile Specific Metas -->
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, viewport-fit=cover">
<title>Bukid Bounty Market</title>
@vite('resources/js/app.js')
<!-- Favicon and Touch Icons -->
<link rel="shortcut icon" href="/images/logo.png">
<link rel="apple-touch-icon-precomposed" href="/images/logo.png">
<!-- <link rel="stylesheet" href="/dist/alt-theme/fonts.css">
<link rel="stylesheet" href="/dist/alt-theme/icons-alipay.css"> -->
<link rel="stylesheet" href="/dist/alt-theme/bootstrap.css">
<!-- <link rel="stylesheet" type="text/css" href="/dist/alt-theme/styles.css"> -->
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/select2.min.css">
<link rel="stylesheet"
href="/plugins/googlefonts/fonts.googleapis.com_css_familySourceSansPro300400400i700&displayfallback.css">
<link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="/dist/css/adminlte.min.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/dropzone.min.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="/dist/alt-theme/styles.css">
<link rel="stylesheet" href="/dist/alt-theme/icons-alipay.css">
<link rel="stylesheet" href="/dist/alt-theme/fonts.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/splide.min.css">
<link rel="manifest" href="/manifest.json" data-pwa-version="set_in_manifest_and_pwa_js">
<link rel="apple-touch-icon" sizes="192x192" href="app/icons/icon-192x192.png">
<script src="/plugins/jquery/jquery.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="/dist/css/toastr.min.css" type="text/css">
<script src="/dist/js/toastr.min.js"></script>
<script src="/dist/js/adminlte.min.js"></script>
<!-- <script src="/dist/js/bower.json"></script> -->
<script defer src="/dist/js/qrcode.min.js"></script>
<script src="/synclib.js"></script>
<script src="/lib.js"></script>
<script src="/EXT/libEXT/marketlib.js"></script>
<script defer src="/dist/js/print.min.js"></script>
<script defer src="/dist/js/FileSaver.min.js"></script>
<script defer src="/dist/js/select2.min.js"></script>
<script src="/dist/js/splide.min.js"></script>
<script src="/dist/js/dropzone.min.js"></script>
<script defer src="/dist/js/jquery.dataTables.min.js"></script>
<script defer src="/dist/js/moment.min.js"></script>
<style>
.card .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e0;
}
.modal-content .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e0;
}
input .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
textarea .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
select .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
form .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
.tf-container .dark-mode {
background-color: #121212;
color: #e0e0e0;
/* Light gray text color */
}
body {
background-color: #ffffff;
/* Light background */
color: #000000;
/* Dark text color */
transition: background-color 0.3s, color 0.3s;
/* Smooth transition */
}
body.dark-mode {
background-color: #121212;
color: #e0e0e0;
/* Light gray text color */
}
.tf-balance-box {
background-color: #ffffff;
/* Light background */
color: #000000;
/* Dark text color */
}
.dark-mode .tf-balance-box {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .tf-statusbar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .tf-navigation-bar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .bottom-navigation-bar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode a {
color: #e0e0e0;
}
body.dark-mode h4 {
color: #ffffff;
/* White color for h3 in dark mode */
}
body.dark-mode h3 {
color: #ffffff;
/* White color for h3 in dark mode */
}
body.dark-mode h2 {
color: #ffffffc4;
/* White color for h3 in dark mode */
}
.pagination {
margin: 20px 0;
}
.pagination button {
margin: 0 5px;
padding: 5px 10px;
}
</style>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/ios/180.png">
<link rel="apple-touch-icon" sizes="167x167" href="/assets/icons/ios/167.png">
<link rel="apple-touch-icon" sizes="152x152" href="/assets/icons/ios/152.png">
<link rel="apple-touch-icon" sizes="120x120" href="/assets/icons/ios/120.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Bukid Bounty Marketplace">
</head>
<style id="dynamic-css">
</style>
<body id="body-global">
<div class="header is-fixed" id="maintopbarheader">
<div class="tf-container">
<div class="tf-statusbar d-flex justify-content-center align-items-center">
<a href="javascript:void(0);" onclick="" class="back-btn" id="backbutton-top"> <i class="icon-left"></i> </a>
<h3 id="topbar-title" onclick="ReloadPage();"></h3>
<a href="javascript:void(0);" onclick="ButtonGo('account_settings');" id="btn-popup-up" class="action-right"><i
class="icon icon-filter"></i> </a>
</div>
</div>
</div>
<div id="app-wrap">
<div class="bill-content">
<br>
<div class="tf-container" id="main-body" style="padding-top: 10px;padding-bottom: 10px;">
@inertia
</div>
{{--
<script>
$('#SplashLogo').fadeIn(1000);
</script> --}}
</div>
</div>
<div class="bottom-navigation-bar">
<div class="tf-container">
<ul class="tf-navigation-bar">
<li><a class="fw_4 d-flex justify-content-center align-items-center flex-column" href=""
onclick="ButtonGo('Home',0);return false;"><i class="icon-home"></i> Home</a> </li>
<li>
<a href="" onclick="ButtonGo('CartProductMarket',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/addtocart.png" class="icon-home">
Cart
</a>
</li>
<li style="display:none;"><a class="fw_4 d-flex justify-content-center align-items-center flex-column"
href="40_qr-code.html"><i class="icon-scan-qr-code"></i> </a> </li>
<li><a href="" onclick="ButtonGo('ListProperties',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/house.png" class="icon-home">Properties</a> </li>
</ul>
<!-- <span class="line"></span> -->
</div>
</div>
<script>
if (navigator.userAgent.match('iPhone') || navigator.userAgent.match('iphone')) {
if (window.innerHeight < window.innerWidth) {
} else {
let headertopbar = document.getElementById('maintopbarheader');
if (headertopbar) {
headertopbar.style.paddingTop = "30px";
} else {
}
}
}
</script>
<script>
navigator.serviceWorker.register('/service-worker.js');
PerformanceLog.Log('Finished Loading HTML Part of StarterHMTL');
</script>
<script type="text/javascript" src="/UIALT.js"></script>
<script>
PerformanceLog.Log('Finished Loading UI ALT JS');
</script>
<script type="text/javascript" src="/dist/alt-theme/main.js"></script>
<script>
PerformanceLog.Log('Finished Loading ALT theme Main js');
</script>
<script type="text/javascript" src="/starter.js"></script>
<script type="text/javascript" src="/pageBuilder.js"></script>
<script type="text/javascript" src="/EXT/starterEXT/market.js"></script>
<script>
PerformanceLog.Log('Finished Loading Starter JS');
</script>
<style>
table {
table-layout: fixed;
width: 100%;
}
</style>
<script>
function SetNotif(title, body = '', icon = '', tag = '') {
Notification.requestPermission(function (result) { if (result === 'granted') { navigator.serviceWorker.ready.then(function (registration) { registration.showNotification(title, { body: body, icon: icon, tag: tag }); }); } });
}
function EraseAllNotif() {
Notification.requestPermission(function (result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function (registration) {
registration.getNotifications().then(function (notifications) {
notifications.forEach(function (notification) {
notification.close();
});
});
});
}
});
}
function EraseNotifwithTag(tag) {
Notification.requestPermission(function (result) {
if (result === 'granted') {
// Replace 'specific-tag' with the tag you want to target
const specificTag = tag;
// Check if service workers are available
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(function (registration) {
registration.getNotifications().then(function (notifications) {
notifications.forEach(function (notification) {
if (notification.tag === specificTag) {
notification.close();
}
});
});
});
}
}
});
}
function deepEqual(a, b) {
if (a === b) return true;
if (a == null || b == null) return false;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) {
if (!deepEqual(a[i], b[i])) return false;
}
return true;
}
if (typeof a === 'object' && typeof b === 'object') {
let keysA = Object.keys(a);
let keysB = Object.keys(b);
if (keysA.length !== keysB.length) return false;
for (let key of keysA) {
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) return false;
}
return true;
}
return a === b;
}
// EraseNotifwithTag('New_Winners');
//SetNotif(number_of_winners + ' Winners Today', tableHtml, 'https://mm.t677u.com/assets/drawlottery.png', 'New_Winners');
PerformanceLog.Log('Finished Everything');
// PerformanceLog.DisplayLogs();
</script>
</body>
</html>

View File

@@ -0,0 +1,428 @@
<html lang="en">
<script>
var InitializationFinished = false;
var PerformanceLog = {};
PerformanceLog.Start = performance.now();
PerformanceLog.Logs = [['Start'], PerformanceLog.Start];
PerformanceLog.Log = function (message) {
PerformanceLog.Logs.push([message, performance.now()]);
};
PerformanceLog.DisplayLogs = function () {
const arr = PerformanceLog.Logs;
for (let i = 0; i < arr.length; i++) {
console.log(arr[i][0], arr[i][1]);
}
};
</script>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Mobile Specific Metas -->
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, viewport-fit=cover">
<title>Bukid Bounty Market</title>
<!-- Favicon and Touch Icons -->
<link rel="shortcut icon" href="/images/logo.png">
<link rel="apple-touch-icon-precomposed" href="/images/logo.png">
<!-- <link rel="stylesheet" href="/dist/alt-theme/fonts.css">
<link rel="stylesheet" href="/dist/alt-theme/icons-alipay.css"> -->
<link rel="stylesheet" href="/dist/alt-theme/bootstrap.css">
<!-- <link rel="stylesheet" type="text/css" href="/dist/alt-theme/styles.css"> -->
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/select2.min.css">
<link rel="stylesheet"
href="/plugins/googlefonts/fonts.googleapis.com_css_familySourceSansPro300400400i700&displayfallback.css">
<link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="/dist/css/adminlte.min.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/dropzone.min.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="/dist/alt-theme/styles.css">
<link rel="stylesheet" href="/dist/alt-theme/icons-alipay.css">
<link rel="stylesheet" href="/dist/alt-theme/fonts.css">
<link rel="stylesheet" media="print" onload="this.media='all'" href="/dist/css/splide.min.css">
<link rel="manifest" href="/manifest.json" data-pwa-version="set_in_manifest_and_pwa_js">
<link rel="apple-touch-icon" sizes="192x192" href="app/icons/icon-192x192.png">
<script src="/plugins/jquery/jquery.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="/dist/css/toastr.min.css" type="text/css">
<script src="/dist/js/toastr.min.js"></script>
<script src="/dist/js/adminlte.min.js"></script>
<!-- <script src="/dist/js/bower.json"></script> -->
<script defer src="/dist/js/qrcode.min.js"></script>
<script src="/synclib.js"></script>
<script src="/lib.js"></script>
<script src="/EXT/libEXT/marketlib.js"></script>
<script defer src="/dist/js/print.min.js"></script>
<script defer src="/dist/js/FileSaver.min.js"></script>
<script defer src="/dist/js/select2.min.js"></script>
<script src="/dist/js/splide.min.js"></script>
<script src="/dist/js/dropzone.min.js"></script>
<script defer src="/dist/js/jquery.dataTables.min.js"></script>
<script defer src="/dist/js/moment.min.js"></script>
<style>
.card .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e0;
}
.modal-content .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e0;
}
input .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
textarea .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
select .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
form .dark-mode {
background-color: rgb(36, 39, 44) !important;
color: #e0e0e022 !important;
}
.tf-container .dark-mode {
background-color: #121212;
color: #e0e0e0;
/* Light gray text color */
}
body {
background-color: #ffffff;
/* Light background */
color: #000000;
/* Dark text color */
transition: background-color 0.3s, color 0.3s;
/* Smooth transition */
}
body.dark-mode {
background-color: #121212;
color: #e0e0e0;
/* Light gray text color */
}
.tf-balance-box {
background-color: #ffffff;
/* Light background */
color: #000000;
/* Dark text color */
}
.dark-mode .tf-balance-box {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .tf-statusbar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .tf-navigation-bar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode .bottom-navigation-bar {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode {
background-color: inherit;
background-color: #24272c;
color: #e0e0e0;
/* Light gray text color */
}
.dark-mode a {
color: #e0e0e0;
}
body.dark-mode h4 {
color: #ffffff;
/* White color for h3 in dark mode */
}
body.dark-mode h3 {
color: #ffffff;
/* White color for h3 in dark mode */
}
body.dark-mode h2 {
color: #ffffffc4;
/* White color for h3 in dark mode */
}
.pagination {
margin: 20px 0;
}
.pagination button {
margin: 0 5px;
padding: 5px 10px;
}
</style>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/ios/180.png">
<link rel="apple-touch-icon" sizes="167x167" href="/assets/icons/ios/167.png">
<link rel="apple-touch-icon" sizes="152x152" href="/assets/icons/ios/152.png">
<link rel="apple-touch-icon" sizes="120x120" href="/assets/icons/ios/120.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Bukid Bounty Marketplace">
</head>
<body id="body-global">
<div class="header is-fixed" id="maintopbarheader">
<div class="tf-container">
<div class="tf-statusbar d-flex justify-content-center align-items-center">
<a href="javascript:void(0);" onclick="" class="back-btn" id="backbutton-top"> <i class="icon-left"></i> </a>
<h3 id="topbar-title" onclick="ReloadPage();">@yield('title_bar')</h3>
<a href="javascript:void(0);" onclick="ButtonGo('account_settings');" id="btn-popup-up" class="action-right"><i
class="icon icon-filter"></i> </a>
</div>
</div>
</div>
<div id="app-wrap">
<div class="bill-content">
<br>
<div class="tf-container" id="main-body" style="padding-top: 10px;padding-bottom: 10px;">
@hasSection('body')
@yield('body')
@elseif(!empty($body))
{!! $body !!}
@else
@include('layouts.partials.default.splash')
@endif
</div>
<script>
$('#SplashLogo').fadeIn(1000);
</script>
</div>
</div>
<div class="bottom-navigation-bar">
<div class="tf-container">
<ul class="tf-navigation-bar" id="main-nav-bar">
{{-- @yield('nav_bar_content',view('layouts.navi-content')->render()) --}}
@hasSection('nav_bar_content')
@yield('nav_bar_content')
@elseif(!empty($nav_bar_content))
{!! $nav_bar_content !!}
@else
@include('layouts.partials.default.navigationbar')
@endif
</ul>
<!-- <span class="line"></span> -->
</div>
</div>
<script>
const navbar = document.getElementById('main-nav-bar');
if (navbar && navbar.innerHTML === '') {
$('#main-nav-bar').load('/Components/NavBar/Main');
}
if (navigator.userAgent.match('iPhone') || navigator.userAgent.match('iphone')) {
if (window.innerHeight < window.innerWidth) {
} else {
let headertopbar = document.getElementById('maintopbarheader');
if (headertopbar) {
headertopbar.style.paddingTop = "30px";
} else {
}
}
}
</script>
<script>
const isthisLocalhost = ['localhost', '127.0.0.1', '::1'].includes(location.hostname);
if (!window.isSecureContext && !isthisLocalhost) {
console.info('Skipping service worker registration: insecure context', location.href);
return;
} else {
navigator.serviceWorker.register('/service-worker.js');
}
PerformanceLog.Log('Finished Loading HTML Part of StarterHMTL');
</script>
<script type="text/javascript" src="/UIALT.js"></script>
<script>
PerformanceLog.Log('Finished Loading UI ALT JS');
</script>
<script type="text/javascript" src="/dist/alt-theme/main.js"></script>
<script>
PerformanceLog.Log('Finished Loading ALT theme Main js');
</script>
<script type="text/javascript" src="/starter.js"></script>
<script type="text/javascript" src="/EXT/starterEXT/market.js"></script>
<script>
PerformanceLog.Log('Finished Loading Starter JS');
</script>
<style>
table {
table-layout: fixed;
width: 100%;
}
</style>
<script>
function SetNotif(title, body = '', icon = '', tag = '') {
Notification.requestPermission(function (result) { if (result === 'granted') { navigator.serviceWorker.ready.then(function (registration) { registration.showNotification(title, { body: body, icon: icon, tag: tag }); }); } });
}
function EraseAllNotif() {
Notification.requestPermission(function (result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function (registration) {
registration.getNotifications().then(function (notifications) {
notifications.forEach(function (notification) {
notification.close();
});
});
});
}
});
}
function EraseNotifwithTag(tag) {
Notification.requestPermission(function (result) {
if (result === 'granted') {
// Replace 'specific-tag' with the tag you want to target
const specificTag = tag;
// Check if service workers are available
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(function (registration) {
registration.getNotifications().then(function (notifications) {
notifications.forEach(function (notification) {
if (notification.tag === specificTag) {
notification.close();
}
});
});
});
}
}
});
}
function deepEqual(a, b) {
if (a === b) return true;
if (a == null || b == null) return false;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) {
if (!deepEqual(a[i], b[i])) return false;
}
return true;
}
if (typeof a === 'object' && typeof b === 'object') {
let keysA = Object.keys(a);
let keysB = Object.keys(b);
if (keysA.length !== keysB.length) return false;
for (let key of keysA) {
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) return false;
}
return true;
}
return a === b;
}
@hasSection('final_scripts')
@yield('final_scripts')
@elseif(!empty($final_scripts))
{!! $final_scripts !!}
@endif
// EraseNotifwithTag('New_Transaction');
//SetNotif(number_of_transactions + ' Orders Today', tableHtml, 'https://mq.hesed.sbs/assets/checkicon.png', 'New_Transaction');
PerformanceLog.Log('Finished Everything');
// PerformanceLog.DisplayLogs();
</script>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<li><a class="fw_4 d-flex justify-content-center align-items-center flex-column" href=""
onclick="ButtonGo('Home',0);return false;"><i class="icon-home"></i> Home</a> </li>
<li>
<a href="" onclick="ButtonGo('CartProductMarket',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/addtocart.png" class="icon-home">
Cart
</a> </li>
<li style="display:none;"><a class="fw_4 d-flex justify-content-center align-items-center flex-column"
href="40_qr-code.html"><i class="icon-scan-qr-code"></i> </a> </li>
<li><a href="" onclick="ButtonGo('ListProperties',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/house.png" class="icon-home">Properties</a> </li>

View File

@@ -0,0 +1,10 @@
<br><br>
<center id="SplashLogo" style="display:none;">
<br>
<br><br>
<img src="/assets/mainlogo.png" style="width: 300;height: 300px;" class="text-center align-items-center">
</center>

View File

@@ -0,0 +1,520 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title></title>
<link rel="preload" href="/dist/css/bootstrap.min.css" as="style">
<link rel="preload" href="/dist/css/adminlte.min.css" as="style">
<link rel="preload" href="/dist/css/jquery.dataTables.min.css" as="style">
<link rel="preload" href="/dist/css/print.min.css" as="style">
<link rel="preload" href="/dist/css/select2.min.css" as="style">
<link rel="preload" href="/dist/css/toastr.min.css" as="style">
<link rel="preload" href="/dist/alt-theme/styles.css" as="style">
<link rel="preload" href="/assets/user-list.png" as="image">
<link rel="preload" href="/assets/NewLeads.png" as="image">
<link rel="preload" href="/assets/ListLeads.png" as="image">
<link rel="preload" href="https://fonts.gstatic.com/s/plusjakartasans/v7/LDIoaomQNQcsA88c7O9yZ4KMCoOg4Ko20yw.woff2"
as="font">
<link rel="preload" href="/dist/alt-theme/icons-alipay.css" as="style">
<link rel="preload" href="/dist/alt-theme/fonts.css" as="style">
<link rel="stylesheet"
href="/plugins/googlefonts/fonts.googleapis.com_css_familySourceSansPro300400400i700&amp;displayfallback.css">
<link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css">
<link rel="preload" href="/plugins/jquery/jquery.min.js" as="script">
<style>
/* Basic reset and body styling */
body,
html {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
height: 100%;
width: 100%;
}
/* Centering the container */
.login-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
.login-card-body {
max-width: 400px;
width: 100%;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-sizing: border-box;
}
.login-box-msg {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-control {
width: 100%;
padding: 12px;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 1rem;
box-sizing: border-box;
}
.input-group {
display: flex;
flex-direction: column;
}
.custom-control {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.custom-control-input {
position: relative;
width: 1.5rem;
height: 1.5rem;
margin-right: 10px;
cursor: pointer;
appearance: none;
border: 1px solid #ced4da;
border-radius: 0.25rem;
background: #ffffff;
transition: background-color 0.3s, border-color 0.3s;
}
.custom-control-input:checked {
background-color: #007bff;
border-color: #007bff;
}
.custom-control-input:checked::before {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.75rem;
height: 0.75rem;
background: #ffffff;
border-radius: 0.25rem;
}
.custom-control-label {
margin: 0;
font-size: 0.875rem;
color: #333;
}
.btn-primary {
display: block;
width: 100%;
padding: 12px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #ffffff;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s;
}
.btn-primary:hover {
background-color: #0056b3;
}
/* Responsive Design */
@media (max-width: 480px) {
.login-card-body {
padding: 15px;
}
.form-control {
font-size: 0.875rem;
padding: 10px;
}
.btn-primary {
font-size: 0.875rem;
padding: 10px;
}
.login-box-msg {
font-size: 1.25rem;
}
}
body,
html {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
/* Centering the card */
.login-container {
max-width: 400px;
width: 100%;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-sizing: border-box;
margin: 0;
/* Ensure visibility */
position: relative;
}
.login-box-msg {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-control {
width: 100%;
padding: 12px;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 1rem;
box-sizing: border-box;
}
.custom-control {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.custom-control-input {
position: relative;
width: 1.5rem;
height: 1.5rem;
margin-right: 10px;
cursor: pointer;
appearance: none;
border: 1px solid #ced4da;
border-radius: 0.25rem;
background: #ffffff;
transition: background-color 0.3s, border-color 0.3s;
}
.custom-control-input:checked {
background-color: #007bff;
border-color: #007bff;
}
.custom-control-input:checked::before {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.75rem;
height: 0.75rem;
background: #ffffff;
border-radius: 0.25rem;
}
.custom-control-label {
margin: 0;
font-size: 0.875rem;
color: #333;
}
.btn-primary {
display: block;
width: 100%;
padding: 12px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #ffffff;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s;
}
.btn-primary:hover {
background-color: #0056b3;
}
/* Responsive Design */
@media (max-width: 480px) {
.login-container {
padding: 15px;
}
.form-control {
font-size: 0.875rem;
padding: 10px;
}
.btn-primary {
font-size: 0.875rem;
padding: 10px;
}
.login-box-msg {
font-size: 1.25rem;
}
}
</style>
<link rel="stylesheet" href="/dist/css/toastr.min.css">
</head>
<body class="login-page">
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg">
<div class="login-box">
<div class="login-logo">
<center><b>Bukid Bounty</b>Marketplace</center>
</div>
</p>
<form action="?loginnow" method="post">
<div class="input-group mb-3">
<input type="number" id="usernumber" class="form-control" placeholder="Mobile Number"
name="usernumber">
<div class="input-group-append">
<div class="input-group-text">
</div>
</div>
</div>
<br>
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="Password" id="userpassword"
name="userpassword">
<div class="input-group-append">
<div class="input-group-text">
</div>
</div>
</div>
<br>
<br>
{{-- <div class="input-group mb-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="keep-alive">
<label class="custom-control-label" for="keep-alive">Keep Me Signed-In</label>
</div>
</div> --}}
<button type="button" class="btn btn-primary btn-block" id="loginbutton">Sign In</button>
</form>
</div>
</div>
</div>
<div class="modal fade" id="modal-incorrect-password" style="display: none;" aria-modal="true" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Unable to Login</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Incorrect Username or Password</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="/plugins/jquery/jquery.min.js"></script>
<script src="/dist/js/toastr.min.js"></script>
<script>
$("#loginbutton").click(function () {
let usernumber = $("#usernumber").val();
let userpassword = $("#userpassword").val();
// let keepalive = $('#keep-alive').is(':checked');
$.ajax({
url: "/post/loginnow",
type: "POST",
data: {
mobile_number: usernumber,
password: userpassword,
// keepalive: keepalive
},
xhrFields: {
withCredentials: true
},
success: function (response) {
// console.log(response);
if (response.success === false) {
toastr.error(response.message || 'Incorrect Username or Password');
$("#usernumber").val("");
$("#userpassword").val("");
} else {
window.location.href='/';
}
},
error: function (jqXHR, textStatus, errorThrown) {
// console.error(jqXHR);
// console.error(textStatus);
// console.error(errorThrown);
toastr.error(jqXHR.responseJSON?.message || 'An unknown error occurred.');
}
});
});
$(document).on('keypress', function (event) {
let keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '13') {
$("#loginbutton").click();
}
});
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
return null;
}
function getCurrentSession() {
return getCookie('SESSID');
}
function trysessioncookie() {
let currentsession = getCurrentSession();
if (!currentsession) { return false; }
}
/*
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('service-worker.js')
.then(registration => {
console.log('Service Worker registered:', registration);
if (navigator.serviceWorker.controller) {
// console.log('Service Worker is controlling the page');
navigator.serviceWorker.controller.postMessage({
type: 'INIT'
});
} else {
console.log('Service Worker is not controlling the page');
}
navigator.serviceWorker.addEventListener('message', event => {
// console.log('Message received from Service Worker:', event.data);
// alert(event);
});
})
.catch(error => {
// console.error('Service Worker registration failed:', error);
});
});
}
*/
if ('serviceWorker' in navigator) {
console.log('Trying to Unregister Service Worker');
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
console.log('registrations detected');
registration.unregister().then(function (boolean) {
if (boolean) {
console.log('Service worker unregistered:', registration);
} else {
console.log('Service worker could not be unregistered:', registration);
}
});
}
}).catch(function (error) {
console.error('Error while unregistering service workers:', error);
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1,25 @@
@extends('layouts.main')
@section ('title_bar')
@yield('title');
@endsection
@section('body')
@yield('body')
@endsection
@section('nav_bar_content')
<li><a class="fw_4 d-flex justify-content-center align-items-center flex-column" href=""
onclick="ButtonGo('Home',0);return false;"><i class="icon-home"></i> Home</a> </li>
<li>
<a href="" onclick="ButtonGo('CartProductMarket',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/addtocart.png" class="icon-home">
Cart
</a> </li>
<li style="display:none;"><a class="fw_4 d-flex justify-content-center align-items-center flex-column"
href="40_qr-code.html"><i class="icon-scan-qr-code"></i> </a> </li>
<li><a href="" onclick="ButtonGo('ListProperties',0);return false;"
class="fw_4 d-flex justify-content-center align-items-center flex-column">
<img style="width: 30px;height: 30px;" src="/assets/house.png" class="icon-home">Properties</a> </li>
@endsection

View File

@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hypervel</title>
<style>
html,
body {
background-color: #fff;
color: #636b6f;
font-family: 'Nunito', sans-serif;
font-weight: 200;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links>a {
color: #636b6f;
padding: 0 25px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
Hypervel
</div>
<div class="links">
<a href="https://hypervel.org" target="_blank">Hypervel</a>
<a href="https://github.com/hypervel/hypervel" target="_blank">GitHub</a>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,3 @@
# Deny access to this directory and its contents
Order Allow,Deny
Deny from all

View File

@@ -0,0 +1,319 @@
<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="${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'; }
photoblob = fileBlobURLList[imgurl] || false;
if (photoblob) {
return photoblob;
}
if (imgurl.match(/blob/)) {
return 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);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
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

View File

@@ -0,0 +1,279 @@
<html>
<head>
<title>
Amaia Villas
</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&amp;display=swap" rel="stylesheet"/>
<style>
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header {
position: relative;
background: url('https://placehold.co/1920x1080') no-repeat center center/cover;
height: 100vh;
color: white;
}
.header .overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
}
.header .content {
position: relative;
z-index: 2;
padding: 20px;
}
.header .logo {
display: flex;
align-items: center;
padding: 20px;
}
.header .logo img {
height: 50px;
margin-right: 10px;
}
.header .nav {
display: flex;
justify-content: flex-end;
padding: 20px;
}
.header .nav a {
color: white;
margin-left: 20px;
text-decoration: none;
font-weight: bold;
}
.header .main-content {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
}
.header .main-content .info {
max-width: 50%;
}
.header .main-content .info h1 {
font-size: 48px;
margin: 0;
}
.header .main-content .info p {
font-size: 18px;
margin: 10px 0;
}
.header .main-content .info .price {
font-size: 24px;
font-weight: bold;
margin: 10px 0;
}
.header .main-content .info .btn {
background: #FFC107;
color: black;
padding: 10px 20px;
text-decoration: none;
font-weight: bold;
border-radius: 5px;
}
.header .main-content .form {
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.header .main-content .form input,
.header .main-content .form textarea,
.header .main-content .form select {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
.header .main-content .form .btn {
background: #FFC107;
color: black;
padding: 10px 20px;
text-decoration: none;
font-weight: bold;
border-radius: 5px;
display: block;
text-align: center;
}
.gallery {
display: flex;
justify-content: center;
padding: 20px;
background: white;
}
.gallery img {
width: 150px;
height: 100px;
margin: 0 10px;
border-radius: 5px;
}
.property-details {
text-align: center;
padding: 20px;
background: #f8f8f8;
}
.property-details h2 {
font-size: 24px;
margin: 0;
}
.property-details .details {
display: flex;
justify-content: center;
padding: 20px;
}
.property-details .details .detail {
margin: 0 20px;
text-align: center;
}
.property-details .details .detail i {
font-size: 24px;
margin-bottom: 10px;
}
.property-details .details .detail p {
margin: 5px 0;
}
</style>
</head>
<body>
<div class="header">
<img class="overlay" scr="https://storage.googleapis.com/a1aa/image/lDf07rzUSwzXTaDmVv44QqId7CxPQGvecp6B3wHgilTsxokTA.jpg"/>
<div class="content">
<div class="logo">
<img height="50" id="websitelogo" src="https://storage.googleapis.com/a1aa/image/lDf07rzUSwzXTaDmVv44QqId7CxPQGvecp6B3wHgilTsxokTA.jpg" width="50"/>
<h1>
AMAIA
</h1>
</div>
<div class="nav">
<a href="#">
HOME
</a>
<a href="#">
ROOM DETAIL
</a>
<a href="#">
BLOG
</a>
<a href="#">
CONTACT AGENT
</a>
</div>
<div class="main-content">
<div class="info">
<h1 id="propertyname">
Skies Calumpit
</h1>
<p id="propertyaddress">
Calumpit Bulacan
</p>
<p class="price" id="propertyprice">
$1,799,000
</p>
<a class="btn" href="#">
SCHEDULE A SHOWING
</a>
</div>
<div class="form">
<input placeholder="Name" type="text"/>
<input placeholder="Phone Number" type="text"/>
<input placeholder="Email" type="email"/>
<textarea placeholder="Message"></textarea>
<input placeholder="mm/dd/yyyy" type="text"/>
<select>
<option value="">
Select Property
</option>
<option value="property1">
Property 1
</option>
<option value="property2">
Property 2
</option>
<option value="property3">
Property 3
</option>
</select>
<a class="btn" href="#">
MAKE APPOINTMENT
</a>
</div>
</div>
</div>
</div>
<div class="gallery">
<img alt="Image 1" height="100" src="https://storage.googleapis.com/a1aa/image/g3NA06cYf9W6BaRe9t3JdmqxfYX40cf8bryCYK2P8Iw9GjSOB.jpg" width="150"/>
<img alt="Image 2" height="100" src="https://storage.googleapis.com/a1aa/image/B7Aee8wvEmk7rkDoS6AiFj0ZHy7lP8GTfoe42uKSDTcBHjSOB.jpg" width="150"/>
<img alt="Image 3" height="100" src="https://storage.googleapis.com/a1aa/image/GCeyrTZ3gLymTiOuV08p1nyxiFBYZe00EsVu5hQg18npxokTA.jpg" width="150"/>
<img alt="Image 4" height="100" src="https://storage.googleapis.com/a1aa/image/DmJ2k9vco5ppAttbofmvWUmG1bwBfsw02zXwg6yqfSVajRJnA.jpg" width="150"/>
<img alt="Image 5" height="100" src="https://storage.googleapis.com/a1aa/image/Pae8im0ZOK1OGKwYZAaXuivbESXfC1RN62QNyjrWZdQqxokTA.jpg" width="150"/>
</div>
<div class="property-details">
<h2>
PROPERTY DETAILS
</h2>
<div class="details">
<div class="detail">
<i class="fas fa-ruler-combined">
</i>
<p>
SQUARE FEET
</p>
<p>
2500
</p>
</div>
<div class="detail">
<i class="fas fa-bed">
</i>
<p>
BEDROOMS
</p>
<p>
3
</p>
</div>
<div class="detail">
<i class="fas fa-bath">
</i>
<p>
BATHROOMS
</p>
<p>
4
</p>
</div>
<div class="detail">
<i class="fas fa-calendar-alt">
</i>
<p>
YEAR BUILT
</p>
<p>
1996
</p>
</div>
<div class="detail">
<i class="fas fa-car">
</i>
<p>
CAR PARKING
</p>
<p>
2
</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,506 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title></title>
<link rel="preload" href="dist/css/bootstrap.min.css" as="style">
<link rel="preload" href="dist/css/adminlte.min.css" as="style">
<link rel="preload" href="dist/css/jquery.dataTables.min.css" as="style">
<link rel="preload" href="dist/css/print.min.css" as="style">
<link rel="preload" href="dist/css/select2.min.css" as="style">
<link rel="preload" href="dist/css/toastr.min.css" as="style">
<link rel="preload" href="/dist/alt-theme/styles.css" as="style">
<link rel="preload" href="/assets/user-list.png" as="image">
<link rel="preload" href="/assets/NewLeads.png" as="image">
<link rel="preload" href="/assets/ListLeads.png" as="image">
<link rel="preload" href="https://fonts.gstatic.com/s/plusjakartasans/v7/LDIoaomQNQcsA88c7O9yZ4KMCoOg4Ko20yw.woff2" as="font">
<link rel="preload" href="/dist/alt-theme/icons-alipay.css" as="style">
<link rel="preload" href="/dist/alt-theme/fonts.css" as="style">
<link rel="stylesheet" href="plugins/googlefonts/fonts.googleapis.com_css_familySourceSansPro300400400i700&amp;displayfallback.css">
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<link rel="preload" href="plugins/jquery/jquery.min.js" as="script">
<style>
/* Basic reset and body styling */
body, html {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
height: 100%;
width: 100%;
}
/* Centering the container */
.login-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
.login-card-body {
max-width: 400px;
width: 100%;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-sizing: border-box;
}
.login-box-msg {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-control {
width: 100%;
padding: 12px;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 1rem;
box-sizing: border-box;
}
.input-group {
display: flex;
flex-direction: column;
}
.custom-control {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.custom-control-input {
position: relative;
width: 1.5rem;
height: 1.5rem;
margin-right: 10px;
cursor: pointer;
appearance: none;
border: 1px solid #ced4da;
border-radius: 0.25rem;
background: #ffffff;
transition: background-color 0.3s, border-color 0.3s;
}
.custom-control-input:checked {
background-color: #007bff;
border-color: #007bff;
}
.custom-control-input:checked::before {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.75rem;
height: 0.75rem;
background: #ffffff;
border-radius: 0.25rem;
}
.custom-control-label {
margin: 0;
font-size: 0.875rem;
color: #333;
}
.btn-primary {
display: block;
width: 100%;
padding: 12px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #ffffff;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s;
}
.btn-primary:hover {
background-color: #0056b3;
}
/* Responsive Design */
@media (max-width: 480px) {
.login-card-body {
padding: 15px;
}
.form-control {
font-size: 0.875rem;
padding: 10px;
}
.btn-primary {
font-size: 0.875rem;
padding: 10px;
}
.login-box-msg {
font-size: 1.25rem;
}
}
body, html {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
/* Centering the card */
.login-container {
max-width: 400px;
width: 100%;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-sizing: border-box;
margin: 0;
/* Ensure visibility */
position: relative;
}
.login-box-msg {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-control {
width: 100%;
padding: 12px;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 1rem;
box-sizing: border-box;
}
.custom-control {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.custom-control-input {
position: relative;
width: 1.5rem;
height: 1.5rem;
margin-right: 10px;
cursor: pointer;
appearance: none;
border: 1px solid #ced4da;
border-radius: 0.25rem;
background: #ffffff;
transition: background-color 0.3s, border-color 0.3s;
}
.custom-control-input:checked {
background-color: #007bff;
border-color: #007bff;
}
.custom-control-input:checked::before {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.75rem;
height: 0.75rem;
background: #ffffff;
border-radius: 0.25rem;
}
.custom-control-label {
margin: 0;
font-size: 0.875rem;
color: #333;
}
.btn-primary {
display: block;
width: 100%;
padding: 12px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #ffffff;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s;
}
.btn-primary:hover {
background-color: #0056b3;
}
/* Responsive Design */
@media (max-width: 480px) {
.login-container {
padding: 15px;
}
.form-control {
font-size: 0.875rem;
padding: 10px;
}
.btn-primary {
font-size: 0.875rem;
padding: 10px;
}
.login-box-msg {
font-size: 1.25rem;
}
}
</style>
<link rel="stylesheet" href="dist/css/toastr.min.css">
</head>
<body class="login-page">
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg"><div class="login-box">
<div class="login-logo">
<center><b>Bukid Bounty</b>Marketplace</center>
</div></p>
<form action="?loginnow" method="post">
<div class="input-group mb-3">
<input type="number" id= "usernumber" class="form-control" placeholder="Mobile Number" name="usernumber">
<div class="input-group-append">
<div class="input-group-text">
</div>
</div>
</div>
<br>
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="Password" id="userpassword" name="userpassword">
<div class="input-group-append">
<div class="input-group-text">
</div>
</div>
</div>
<br>
<br>
<div class="input-group mb-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="keep-alive">
<label class="custom-control-label" for="keep-alive">Keep Me Signed-In</label>
</div>
</div>
<button type="button" class="btn btn-primary btn-block" id="loginbutton">Sign In</button>
</form>
</div>
</div>
</div>
<script src="plugins/jquery/jquery.min.js"></script>
<!--<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>-->
<script src="dist/js/toastr.min.js"></script>
<div class="modal fade" id="modal-incorrect-password" style="display: none;" aria-modal="true" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Unable to Login</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Incorrect Username or Password</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
$("#loginbutton").click(function() {
let usernumber = $("#usernumber").val();
let userpassword = $("#userpassword").val();
let keepalive = $('#keep-alive').is(':checked');
$.ajax({
url: "/loginnow",
type: "POST",
data: {
usernumber: usernumber,
userpassword: userpassword,
keepalive: keepalive
},
success: function(response) {
nresponse = JSON.parse(response);
console.log (nresponse);
if (nresponse === false) {
// $("#modal-incorrect-password").modal("show");
toastr.error('Incorrect Username or Password');
$("#usernumber").val("");
$("#userpassword").val("");
} else {
window.location.reload();
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error(jqXHR);
console.error(textStatus);
console.error(errorThrown);
}
});
});
$(document).on('keypress', function(event) {
let keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13') {
$("#loginbutton").click();
}
});
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
return null;
}
function getCurrentSession(){
return getCookie('SESSID');
}
function trysessioncookie(){
let currentsession = getCurrentSession();
if (!currentsession){return false;}
}
/*
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('service-worker.js')
.then(registration => {
console.log('Service Worker registered:', registration);
if (navigator.serviceWorker.controller) {
// console.log('Service Worker is controlling the page');
navigator.serviceWorker.controller.postMessage({
type: 'INIT'
});
} else {
console.log('Service Worker is not controlling the page');
}
navigator.serviceWorker.addEventListener('message', event => {
// console.log('Message received from Service Worker:', event.data);
// alert(event);
});
})
.catch(error => {
// console.error('Service Worker registration failed:', error);
});
});
}
*/
if ('serviceWorker' in navigator) {
console.log('Trying to Unregister Service Worker');
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (let registration of registrations) {
console.log('registrations detected');
registration.unregister().then(function(boolean) {
if (boolean) {
console.log('Service worker unregistered:', registration);
} else {
console.log('Service worker could not be unregistered:', registration);
}
});
}
}).catch(function(error) {
console.error('Error while unregistering service workers:', error);
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1 @@
<center><h1>Unknown File</h1></center>

View File

@@ -0,0 +1,104 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2.5rem;">Daily Bet Amounts and Prizes of Users Under Me</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<table id="DailyBetsAmountsPrizesPerUser_table">
<thead>
<tr>
<th>
User
</th>
<th>
Type
</th>
<th>
Amount
</th>
<th>
Prize
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<brb><br><br>
<script>
function GenerateDailyBetsAmountsPrizesPerUserRow(User,Type, Bet_Amount, Prize) {
return `<tr>
<td>${User}</td>
<td>${Type}</td>
<td>${Bet_Amount}</td>
<td>${Prize}</td>
</tr>`;
}
async function GenerateDailyBetsAmountsPrizesPerUserRows(responsearray) {
console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateDailyBetsAmountsPrizesPerUserRow(
responsearray[i]['user'],
responsearray[i]['type'],
responsearray[i]['amount'],
responsearray[i]['prize']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#DailyBetsAmountsPrizesPerUser_table").find("tbody").html(newhtmltable);
new DataTable('#DailyBetsAmountsPrizesPerUser_table', {
language: {
emptyTable: 'No Data Loaded'
},
// order: [[0, 'desc']],
"bDestroy": true
});
}
function GenerateDailyBetsAmountsPrizesPerUserTable() {
AjaxDo('?BetAmountsPrizes/PerUser/List', { targetuser: currenttarget }, GenerateDailyBetsAmountsPrizesPerUserRows, null, reqtype = 'POST');
}
GenerateDailyBetsAmountsPrizesPerUserTable();
setInterval(function () {
if (currentPage == 'DailyBetsAmountsPrizesPerUser') {
GenerateDailyBetsAmountsPrizesPerUserTable();
}
}, 300000);
</script>

View File

@@ -0,0 +1,107 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2.5rem;">Daily Bets</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<table id="Daily_bets_table">
<thead>
<tr>
<th>
User
</th>
<th>
Type
</th>
<th>
Amount
</th>
<th>
Prize
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<brb><br><br>
<script>
function GenerateDailyBetsRow(User,Type, Bet_Amount, Prize) {
return `<tr>
<td>${User}</td>
<td>${Type}</td>
<td>${Bet_Amount}</td>
<td>${Prize}</td>
</tr>`;
}
async function GenerateDailyBetsRows(responsearray) {
console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateDailyBetsRow(
responsearray[i]['date'],
responsearray[i]['user'],
responsearray[i]['type'],
responsearray[i]['amount'],
responsearray[i]['prize']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#Daily_bets_table").find("tbody").html(newhtmltable);
//$("#Last30DaysTotalBetAmount").html(totalbetamount);
//$("#Last30DaysTotalPrizesAmount").html(totalprizes);
new DataTable('#Daily_bets_table', {
language: {
emptyTable: 'No Data Loaded'
},
order: [[0, 'desc']],
"bDestroy": true
});
}
function GenerateDailyBetsTable() {
AjaxDo('?Reports/DailyBets/List', { targetuser: currenttarget }, GenerateDailyBetsRows, null, reqtype = 'POST');
}
GenerateDailyBetsTable();
setInterval(function () {
if (currentPage == 'DailyBets') {
GenerateDailyBetsTable();
}
}, 300000);
</script>

View File

@@ -0,0 +1,251 @@
<br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2rem;">Daily Summary for Transfers, Bets and Prizes</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
<div class="row card-body">
<div class="col-md-6">
<h5>Amounts Transferred Today:</h5>
</div>
<div class="col-md-6" style="">
<h5 id="TotalBalanceTransferAmountReportsToday"></h5>
</div>
</div>
<div class="row card-body">
<div class="col-md-6">
<h5>Total Bet Amounts Today of Users Under Me:</h5>
</div>
<div class="col-md-6" style="">
<h5 id="TotalBetAmountReportsToday"></h5>
</div>
</div>
<div class="row card-body">
<div class="col-md-6">
<h5>Total Amount of Prizes:</h5>
</div>
<div class="col-md-6" style="">
<h5 id="TotalPrizesAmountReportsToday"></h5>
</div>
</div>
</div>
</div>
<br><br>
<div class="card card-primary card-outline card-outline-tabs">
<div class="card-header p-0 border-bottom-0">
<ul class="nav nav-tabs" id="dailybetstransfersprofitssummarytabs-four-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="dailybetstransfersprofitssummarytabs-four-2PM-tab" data-toggle="pill"
href="#dailybetstransfersprofitssummarytabs-four-2PM" role="tab"
aria-controls="dailybetstransfersprofitssummarytabs-four-2PM" aria-selected="true">2PM</a>
</li>
<li class="nav-item">
<a class="nav-link" id="dailybetstransfersprofitssummarytabs-four-5PM-tab" data-toggle="pill"
href="#dailybetstransfersprofitssummarytabs-four-5PM" role="tab"
aria-controls="dailybetstransfersprofitssummarytabs-four-5PM" aria-selected="false">5PM</a>
</li>
<li class="nav-item">
<a class="nav-link" id="dailybetstransfersprofitssummarytabs-four-9PM-tab" data-toggle="pill"
href="#dailybetstransfersprofitssummarytabs-four-9PM" role="tab"
aria-controls="dailybetstransfersprofitssummarytabs-four-9PM" aria-selected="false">9PM</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="dailybetstransfersprofitssummarytabs-four-tabContent">
<div class="tab-pane fade active show" id="dailybetstransfersprofitssummarytabs-four-2PM" role="tabpanel"
aria-labelledby="dailybetstransfersprofitssummarytabs-four-2PM-tab"></div>
<div class="tab-pane fade" id="dailybetstransfersprofitssummarytabs-four-5PM" role="tabpanel"
aria-labelledby="dailybetstransfersprofitssummarytabs-four-5PM-tab"></div>
<div class="tab-pane fade" id="dailybetstransfersprofitssummarytabs-four-9PM" role="tabpanel"
aria-labelledby="dailybetstransfersprofitssummarytabs-four-9PM-tab">
</div>
</div>
</div>
</div>
<script>
function CreateSummaryCardforDailyTransfersProfitsSummary(timeIDText) {
return `<div class="card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 1rem;">Summary</h1>
</div>
<div class="card-body ">
<center><h3 id="TransferStatusbyTime`+ timeIDText + `"></h3></center>
<div class="row card-body" style="display:none;">
<div class="col-md-4">
<h5>Amounts Transferred Today:</h5>
</div>
<div class="col-md-4" style="">
<h5 id="TotalBalanceTransferAmountReportsToday`+ timeIDText + `"></h5>
</div>
</div>
<div class="row card-body">
<div class="col-md-4">
<h5>Total Winning Bet Amounts Today of Users Under Me:</h5>
</div>
<div class="col-md-4" style="">
<h5 id="TotalBetAmountReportsToday`+ timeIDText + `"></h5>
</div>
</div>
<div class="row card-body">
<div class="col-md-4">
<h5>Total Amount of Prizes:</h5>
</div>
<div class="col-md-4" style="">
<h5 id="TotalPrizesAmountReportsToday`+ timeIDText + `"></h5>
</div>
</div>
</div>
</div>`;
}
function DailyBetsTransfersProfitsUSERTABLE(tableid, title) {
return `<br><br>
<div class="card" id="secondary-card" style="">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title">${title}</h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<table id="${tableid}">
<thead>
<tr>
<th>Number /<br>Nickname</th>
<th>Amount<br>Bet</th>
<th><center>Total<br>Prize</center></th>
</tr>
</thead>
<tbody id="${tableid}-body">
</tbody>
</table>
</div>
</div><br><br><br>`;
}
function UpdateDailyBetsTransfersProfitsSummary(target_date = '', target_user = '') {
function populatereportdetails(response) {
console.log(response);
setElementhtml('TotalBalanceTransferAmountReportsToday', response.TotalTransferAmountToday);
setElementhtml('TotalBetAmountReportsToday', response.TotalBetAmountToday);
setElementhtml('TotalPrizesAmountReportsToday', response.TotalRewardAmountToday);
setElementhtml('TotalBetAmountReportsToday2PM', response['2PM'].TotalBets);
setElementhtml('TotalPrizesAmountReportsToday2PM', response['2PM'].TotalPrize);
setElementhtml('TotalBetAmountReportsToday5PM', response['5PM'].TotalBets);
setElementhtml('TotalPrizesAmountReportsToday5PM', response['5PM'].TotalPrize);
setElementhtml('TotalBetAmountReportsToday9PM', response['9PM'].TotalBets);
setElementhtml('TotalPrizesAmountReportsToday9PM', response['9PM'].TotalPrize);
function GenerateBetsByUserTableRows(usernumnick, totalamount, totalprize) {
let user_nick = usernumnick;
user_nick = user_nick.replace(' ', '<br>');
return `<tr>
<td>${user_nick}</td>
<td>${totalamount}</td>
<td>${totalprize}</td>
</tr>`;
}
let tablerowshtml2pm = '';
for (let i = 0; i < response['2PM']['betsbyuser'].length; i++) {
tablerowshtml2pm += GenerateBetsByUserTableRows(response['2PM']['betsbyuser'][i]['usermnumber_nick'], response['2PM']['betsbyuser'][i]['totalamount'], response['2PM']['betsbyuser'][i]['totalprize']);
}
let tablerowshtml5pm = '';
for (let i = 0; i < response['5PM']['betsbyuser'].length; i++) {
tablerowshtml5pm += GenerateBetsByUserTableRows(response['5PM']['betsbyuser'][i]['usermnumber_nick'], response['5PM']['betsbyuser'][i]['totalamount'], response['5PM']['betsbyuser'][i]['totalprize']);
}
let tablerowshtml9pm = '';
for (let i = 0; i < response['9PM']['betsbyuser'].length; i++) {
tablerowshtml9pm += GenerateBetsByUserTableRows(response['9PM']['betsbyuser'][i]['usermnumber_nick'], response['9PM']['betsbyuser'][i]['totalamount'], response['9PM']['betsbyuser'][i]['totalprize']);
}
setElementhtml('userbetstable2PM-body', tablerowshtml2pm);
setElementhtml('userbetstable5PM-body', tablerowshtml5pm);
setElementhtml('userbetstable9PM-body', tablerowshtml9pm);
$("#userbetstable2PM").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
$("#userbetstable5PM").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
$("#userbetstable9PM").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
}
AjaxDo('?admin/reports/dailybetstransfersprofitssummary/details', { target_date: target_date, target_user: target_user }, populatereportdetails, null, reqtype = 'POST');
}
setElementhtml('dailybetstransfersprofitssummarytabs-four-2PM', CreateSummaryCardforDailyTransfersProfitsSummary('2PM') + DailyBetsTransfersProfitsUSERTABLE('userbetstable2PM', 'Winning Bets By User'));
setElementhtml('dailybetstransfersprofitssummarytabs-four-5PM', CreateSummaryCardforDailyTransfersProfitsSummary('5PM') + DailyBetsTransfersProfitsUSERTABLE('userbetstable5PM', 'Winning Bets By User'));
setElementhtml('dailybetstransfersprofitssummarytabs-four-9PM', CreateSummaryCardforDailyTransfersProfitsSummary('9PM') + DailyBetsTransfersProfitsUSERTABLE('userbetstable9PM', 'Winning Bets By User'));
$(document).ready(function () {
if (typeof target_date === 'undefined') {
target_date = '';
}
if (typeof target_user === 'undefined') {
target_user = '';
}
UpdateDailyBetsTransfersProfitsSummary(target_date, target_user);
let UpdateDailyBetsTransfersProfitsSummaryIntervalID = setInterval(UpdateDailyBetsTransfersProfitsSummary, 300000);
});
</script>

View File

@@ -0,0 +1,58 @@
<br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2rem;">Daily Transfers</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
<div class="row card-body">
<div class="col-md-6">
<h5>Amounts Transferred Today:</h5>
</div>
<div class="col-md-6" style="">
<h5 id="TotalBalanceTransferAmountReports"></h5>
</div>
</div>
<div class="row card-body">
<div class="col-md-6">
<h5>Amounts Transferred Today:</h5>
</div>
<div class="col-md-6" style="" id="TotalBalanceTransferAmountReports">
<h5 id="TotalBalanceTransferAmountReports"></h5>
</div>
</div>
</div>
</div>
<br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2rem;">Users Breakdown</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
</div>
</div>
<br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 1rem;">Transfer Logs</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
<div class="row card-body">
</div>
<div class="row card-body">
</div>
</div>
</div>

View File

@@ -0,0 +1,121 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2rem;" id='totalbettitle30days'>Total Bet Amounts and Prizes for the Last 30 Days (Only Me)</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
<br><br>
<table id="MonthlyBetAmountsandPrizesTable">
<thead>
<th>Date</th>
<th> Bet Amount</th>
<th>Prizes</th>
</thead>
<tbody>
</tbody>
</table>
Total Bet Amount: <h4 id="Last30DaysTotalBetAmount"></h4>
Total Prizes Amount: <h4 id="Last30DaysTotalPrizesAmount"></h4>
</div>
</div>
<br><br><br>
<script>
function GenerateBetAmountPrizes30DaysRow(Date, Bet_Amount, Prize) {
return `<tr>
<td>${Date}</td>
<td>${Bet_Amount}</td>
<td>${Prize}</td>
</tr>`;
}
async function GenerateBetAmountPrizeTodayRows(responsearray) {
// console.log(responsearray);
let newhtmltable = '';
let totalbetamount = 0;
let totalprizes = 0;
for (let i = 0; i < responsearray.length; i++) {
totalbetamount += responsearray[i]['total_bet_amount'];
totalprizes += responsearray[i]['total_prizes'];
newhtmltable += GenerateBetAmountPrizes30DaysRow(
responsearray[i]['date'],
responsearray[i]['total_bet_amount'],
responsearray[i]['total_prizes']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#MonthlyBetAmountsandPrizesTable").find("tbody").html(newhtmltable);
$("#Last30DaysTotalBetAmount").html(totalbetamount);
$("#Last30DaysTotalPrizesAmount").html(totalprizes);
new DataTable('#MonthlyBetAmountsandPrizesTable', {
language: {
emptyTable: 'No Data Loaded'
},
order: [[0, 'desc']],
"bDestroy": true
});
}
function GenerateBetAmountsAndPrizes30DaysTable() {
let onlyme;
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('onlyme')) {
onlyme = currenttarget['onlyme'];
}
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('currenttarget')) {
currenttarget = currenttarget['currenttarget'];
}
if (onlyme) {
document.getElementById('totalbettitle30days').innerHTML = 'Total Bet Amounts and Prizes for the Last 30 Days (Only Me)';
} else {
document.getElementById('totalbettitle30days').innerHTML = 'Total Bet Amounts and Prizes for the Last 30 Days (Me and All Users Under Me)';
}
AjaxDo('?admin/reports/TotalBetsPrizes/Last30Days', { targetuser: currenttarget, onlyme: onlyme}, GenerateBetAmountPrizeTodayRows, null, reqtype = 'POST');
}
GenerateBetAmountsAndPrizes30DaysTable();
setInterval(function () {
if (currentPage == 'BetAmountsAndPrizes30Days ') {
GenerateBetAmountsAndPrizes30DaysTable();
}
}, 300000);
$( document ).ready(function() {
});
</script>

View File

@@ -0,0 +1,111 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2.5rem;">Winning Bets</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<table id="Winning_bets_table">
<thead>
<tr>
<th>
Date
</th>
<th>
User
</th>
<th>
Type
</th>
<th>
Amount
</th>
<th>
Prize
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<brb><br><br>
<script>
function GenerateWinningBetsRow(Date,User,Type, Bet_Amount, Prize) {
return `<tr>
<td>${Date}</td>
<td>${User}</td>
<td>${Type}</td>
<td>${Bet_Amount}</td>
<td>${Prize}</td>
</tr>`;
}
async function GenerateWinningBetsRows(responsearray) {
console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateWinningBetsRow(
responsearray[i]['date'],
responsearray[i]['user'],
responsearray[i]['type'],
responsearray[i]['amount'],
responsearray[i]['prize']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#Winning_bets_table").find("tbody").html(newhtmltable);
//$("#Last30DaysTotalBetAmount").html(totalbetamount);
//$("#Last30DaysTotalPrizesAmount").html(totalprizes);
new DataTable('#Winning_bets_table', {
language: {
emptyTable: 'No Data Loaded'
},
order: [[0, 'desc']],
"bDestroy": true
});
}
function GenerateWinningBetsTable() {
AjaxDo('?WinningNumbers/List', { targetuser: currenttarget }, GenerateWinningBetsRows, null, reqtype = 'POST');
}
GenerateWinningBetsTable();
setInterval(function () {
if (currentPage == 'MyWinningBets') {
GenerateWinningBetsTable();
}
}, 300000);
</script>

View File

@@ -0,0 +1,88 @@
<script src="dist/js/html5-qrcode.min.js"></script>
<br><br>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move; display: none;">
<h3 class="card-title"></h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<div class="row card-body d-flex align-items-center w-100">
<div class="w-100" style="width: 500px" id="reader"></div>
</div>
</div>
</div>
<div class="card" id="third-card" style="display: none;">
<div class="card-header ui-sortable-handle" style="cursor: move; ">
<h3 class="card-title">Details</h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<div class="row card-body" id="TransactionDetails">
<div class="col-12 d-flex align-items-center w-100" id="qrreader_bt_type"></div>
<div class="col-12 w-100" id="qrreader_bt_date"></div>
<div class="col-12" id="qrreader_bt_schedule"></div>
<div class="col-12" id="qrreader_bt_numbers"></div>
<div class="col-12" id="qrreader_bt_status"></div>
</div>
</div>
</div>
<script>
function getbtqrdetails(response){
console.log(response);
if (!response){
$('#third-card').hide();
return false;}
$('#TransactionDetails').empty();
let htmltransactiondetailsappend= '';
response.forEach(element => {
let bet_type = bet_types[element.bet_type];
console.log(element);
htmltransactiondetailsappend+=
`<div class="col-12 d-flex align-items-center w-100" id="qrreader_bt_type"><h2>${bet_type}</h2></div>
<div class="col-12 w-100" id="qrreader_bt_date"><h3>DATE: ${element.bet_date}</h3></div>
<div class="col-12" id="qrreader_bt_schedule"><h3>SCHEDULE: ${element.bet_schedule}</h3></div>
<div class="col-12" id="qrreader_bt_numbers"><h3>NOs. ${element.bet_number}</h3></div>
<div class="col-12" id="qrreader_bt_numbers"><h3>Amount: P${element.amount}</h3></div>
<div class="col-12" id="qrreader_bt_status"></div><br><br><br><br>`;
});
//$('#qrreader_bt_type').html(bet_type);
//$('#qrreader_bt_date').html(response.bet_date);
//$('#qrreader_bt_schedule').html(response.bet_schedule);
//$('#qrreader_bt_numbers').html(response.bet_number);
//$('#qrreader_bt_status').html(response.bet_result);
$('#TransactionDetails').append(htmltransactiondetailsappend);
$('#third-card').fadeIn(200);
html5QrcodeScanner.clear();
}
function getbrqrdetailsfail(response){
//console.log(response);
}
function onScanSuccess(decodedText, decodedResult) {
let scanresultqrcontent = decodedText;
let dataright = { qrbtdetails : scanresultqrcontent };
AjaxDo('?admin/qrbtdetails', dataright, getbtqrdetails, getbrqrdetailsfail, reqtype = 'POST');
}
var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
</script>

View File

@@ -0,0 +1,322 @@
<br><br>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move; display: none;">
<h3 class="card-title"></h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<div class="row card-body d-flex align-items-center w-100">
<div class="input-group mb-3">
<input type="number" id="usernumber" class="form-control createuserinputfield" placeholder="Mobile Number" name="usernumber">
</div>
<div class="input-group mb-3" style="" id="user-create-nickname-input-group">
<input type="text" id="nickname" class="form-control createuserinputfield" placeholder="Nick Name" name="nickname">
</div>
<div class="input-group mb-3" id="usertypecontrol" style="">
<select class="form-control" id="usertype">
</select>
</div>
<div class="input-group mb-3" id="userparentcontrol" style="display:none;">
<select class="form-control" id="userparent">
</select>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control createuserinputfield" placeholder="Password" id="userpassword" name="userpassword">
</div>
<div class="input-group mb-3">
<input type="password" class="form-control createuserinputfield" placeholder="ConfirmPassword" id="userpasswordconfirm" name="userpasswordconfirm">
</div>
<div class="input-group mb-3">
<button class="form-control btn-primary" id="RegisterNowButton" onclick="RegisterConfirmationPrompt();" style="display:none;">Register Now</button>
</div>
</div>
</div>
</div>
<script>
var usernumberallowed = false;
var usernicknameallowed = false;
var normalpasswordallowed = false;
var confirmpasswordallowed = false;
window.hasValidMobileNumberFormat = function hasValidFormat(usernumber) {
const pattern = /^09\d{9}$/;
return pattern.test(usernumber);
}
function VerifyInitialPassword() {
const userPassword = document.getElementById("userpassword").value;
if (userPassword.length < 6) {
changeSpantoInvalid('user-password');
normalpasswordallowed = false;
return false;
}
changeSpantoValid('user-password');
normalpasswordallowed = true;
return true;
}
function VerifyConfirmPassword() {
const userPassword = document.getElementById("userpassword").value;
const userPasswordConfirm = document.getElementById("userpasswordconfirm").value;
if (userPassword.length < 6 || userPasswordConfirm.length < 6) {
changeSpantoInvalid('user-password-confirm');
confirmpasswordallowed = false;
return false;
}
if (userPassword !== userPasswordConfirm) {
changeSpantoInvalid('user-password-confirm');
confirmpasswordallowed = false;
return false;
}
changeSpantoValid('user-password-confirm');
changeSpantoValid('user-password');
confirmpasswordallowed = true;
return true;
}
function changeSpantoInvalid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-times-circle");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-danger");
}
function changeSpantoValid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-check");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-primary");
}
function checkifUserExists() {
let usernumber = $('#usernumber').val();
if (!window.hasValidMobileNumberFormat(usernumber)) {
changeSpantoInvalid('mobile-number');
usernumberallowed = false;
return false;
}
function CheckUser(response) {
if (response === true) {
changeSpantoInvalid('mobile-number');
usernumberallowed = false;
return false;
} else if (response === false) {
changeSpantoValid('mobile-number');
usernumberallowed = true;
return true;
}
}
AjaxDo('/admin/user/exists', {
user_target: usernumber
}, CheckUser, null, reqtype = 'POST');
}
function checkifUserNickExists() {
let usernick = $('#nickname').val();
if (usernick===''){
changeSpantoValid('nick-name');
usernicknameallowed = true;
SRegistrationValidateALLinputs();
return;
}
function CheckUserNick(response) {
if (response === true) {
changeSpantoInvalid('nick-name');
usernicknameallowed = false;
SRegistrationValidateALLinputs();
return false;
} else if (response === false) {
changeSpantoValid('nick-name');
usernicknameallowed = true;
SRegistrationValidateALLinputs();
return true;
}
}
AjaxDo('/admin/user/nick/exists', {
user_nick: usernick
}, CheckUserNick, null, reqtype = 'POST');
}
function SRegistrationValidateALLinputs() {
if (usernumberallowed && normalpasswordallowed && confirmpasswordallowed && usernicknameallowed) {
$('#RegisterNowButton').show();
return true;
} else {
$('#RegisterNowButton').hide();
return false;
}
}
function RegisterConfirmationPrompt() {
let modalid = "CreateUserConfirmationDialog";
let modaltitle = 'Create New User?';
let modalbody = 'Are you sure you want to Create a New User?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="SregisterNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationSuccessModal() {
let modalid = "CreateUserSuccessModal";
let modaltitle = 'Success';
let modalbody = 'User Created Successfully';
let modalfooter = `<button type="button" class="btn btn-primary" onclick="$('#CreateUserSuccessModal').modal('hide');ButtonGo('user_list',0);" id="request-credit-now">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationFailedModal() {
let modalid = "CreateUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Error Creating User. User was not created.';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function UserRegistrationFailedModalErrorMessage(Message) {
let modalid = "CreateUserFailedModalErrorMessage";
let modaltitle = 'Failed';
let modalbody = Message;
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Ok</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function RePopulateParentList() {
function UpdateSelectParentList(response) {
const selectElement = $("#userparent"); // Select the element using jQuery
response.forEach(element => {
$("<option></option>")
.val(element.hashkey)
.text(element.mnumber)
.appendTo(selectElement); // Create and append option with values
});
}
AjaxDo('/admin/user/list/numbers/hash', {}, UpdateSelectParentList, null, reqtype = 'POST');
}
function RePopulateUserTypeCreateUser() {
function UpdateSelectUserTypeList(response) {
const selectElement = $("#usertype"); // Select the element using jQuery
selectElement.html('');
response.forEach(element => {
$("<option></option>")
.val(element[0])
.text(element[1])
.appendTo(selectElement); // Create and append option with values
});
}
AjaxDo('/admin/list/usertype/create', {}, UpdateSelectUserTypeList, null, reqtype = 'POST');
}
function SregisterNow() {
$('#CreateUserConfirmationDialog').modal('hide');
function RegisterNow(response) {
console.log(response);
if (response === true) {
UserRegistrationSuccessModal();
} else if (response === false) {
UserRegistrationFailedModal();
} else {
UserRegistrationFailedModalErrorMessage(response);
}
}
AjaxDo('/admin/user/create', {
user_number: $("#usernumber").val(),
user_password: $("#userpassword").val(),
user_nickname: $("#nickname").val(),
user_type: $("#usertype").val(),
user_parent: $("#userparent").val()
}, RegisterNow, null, reqtype = 'POST');
}
$('#usernumber').keyup(function() {
checkifUserExists();
SRegistrationValidateALLinputs();
});
$('#nickname').keyup(function() {
checkifUserNickExists();
});
$('#userpassword').keyup(function() {
VerifyInitialPassword();
SRegistrationValidateALLinputs();
});
$('#userpasswordconfirm').keyup(function() {
VerifyConfirmPassword();
SRegistrationValidateALLinputs();
});
$('.createuserinputfield').keyup(function() {
SRegistrationValidateALLinputs();
});
RePopulateUserTypeCreateUser();
</script>

View File

@@ -0,0 +1,151 @@
<script>
function DisableUserButtonHtml(){return HomeMenuButtons('assets/disableuser.png', 'Disable', '','','45%', '45%','', buttononclick = 'DisableUser()', divclass = 'col-4','disableuserbuttondiv');}
function EnableUserButtonHtml(){return HomeMenuButtons('assets/enable-user.png', 'Enable', '','','45%', '45%','', buttononclick = 'EnableUser()', divclass = 'col-4','disableuserbuttondiv');}
$('#user_controls').append(DisableUserButtonHtml());
//$('#user_controls').append(DisableUserButtonHtml());
function ChangeToEnableUserButton() {
// $('#disable_user_button').html('Enable<br>User');
// $('#disable_user_button').attr("class", "btn btn-warning btn-block");
// $('#disable_user_button').attr("onclick", "EnableUser()");
// $('#disable_user_button').show();
$('#disableuserbuttondiv').remove();
$('#user_controls').append(EnableUserButtonHtml());
}
function ChangeToDisableUserButton() {
// $('#disable_user_button').html('Disable<br>User');
// $('#disable_user_button').attr("class", "btn btn-danger btn-block");
// $('#disable_user_button').attr("onclick", "DisableUser()");
// $('#disable_user_button').show();
$('#disableuserbuttondiv').remove();
$('#user_controls').append(DisableUserButtonHtml());
}
function ModalDisableSuccess() {
let modalid = "DisableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Disabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function ModalDisableFailed(response) {
let modalid = "DisableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Disable User'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
}
function ModalEnableSuccess(){
let modalid = "EnableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Enabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function ModalEnableFailed(response){
let modalid = "EnableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Enable User.<br>'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
}
function EnableUserNow() {
function TryToEnable(response) {
$("#EnableUserConfirmationDialog").modal('hide');
if (response===true) {
ModalEnableSuccess();
} else {
ModalEnableFailed(response);
}
CheckIfUserActive();
loaduserdetails();
}
AjaxDo('?admin/user/enable', { user_target: currenttarget }, TryToEnable, null, reqtype = 'POST');
}
function DisableUserNow() {
function TryToDisable(response) {
$("#DisableUserConfirmationDialog").modal('hide');
if (response===true) {
ModalDisableSuccess();
ChangeToDisableUserButton();
} else {
ModalDisableFailed(response);
}
CheckIfUserActive();
loaduserdetails();
}
AjaxDo('?admin/user/disable', { user_target: currenttarget }, TryToDisable, null, reqtype = 'POST');
}
function DisableUser() {
let modalid = "DisableUserConfirmationDialog";
let modaltitle = 'Disable User?';
let modalbody = 'Are you sure you want to disable user?<br> The user would not be able to access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="DisableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function EnableUser() {
let modalid = "EnableUserConfirmationDialog";
let modaltitle = 'Enable User?';
let modalbody = 'Are you sure you want to Enable user?<br> The user would have access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="EnableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function CheckIfUserActive() {
function ChangeDisableButtonState(response) {
console.log(response);
if (response===true){ChangeToDisableUserButton();}
else if(response===false){
ChangeToEnableUserButton();
}
}
AjaxDo('?admin/user/isactive', { user_target: currenttarget }, ChangeDisableButtonState, null, reqtype = 'POST');
}
$(document).ready(function () {
CheckIfUserActive();
});
</script>

View File

@@ -0,0 +1,83 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h2 class="card-title" style="font-size: 2.5rem;" id="DrawSummaryDailyTargetDate">Draw Summary Daily
</h2>
<div class="card-tools">
<input type="date" class="form-control" id="DrawSummaryDailyTargetDateSelect">
</div>
</div>
<div class="card-body">
</div>
</div>
<br><br><br>
<script>
if (typeof targetdate === 'undefined' || targetdate === null) {
targetdate = '';
}
function GenerateDailyDrawSummaryReportsNow(response) {
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('targetdate')) {
targetdate = currenttarget['targetdate'];
}
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('currenttarget')) {
currenttarget = currenttarget['currenttarget'];
}
if (typeof targetdate === 'undefined' || targetdate === null || !targetdate) {
targetdate = getDateInGMT8();
targetdateObject = new Date(getDateInGMT8());
}
targetdateObject = new Date(targetdate);
texttargetdate = formatDate(targetdateObject);
}
function GenerateDrawSummaryReportDaily() {
AjaxDo('?Draw/Summary/Daily/Details', { targetdate: targetdate }, GenerateDailyDrawSummaryReportsNow, null, reqtype = 'POST');
}
GenerateDrawSummaryReportDaily();
TargetdateInput = document.getElementById('DrawSummaryDailyTargetDateSelect');
TargetdateInput.value = getDateInGMT8();
TargetdateInput.addEventListener('change', function () {
targetdate = TargetdateInput.value;
GenerateDrawSummaryReportDaily();
});
</script>
<style>
</style>

View File

@@ -0,0 +1,4 @@
<script>
$('#main-card-body').remove();
</script>

View File

@@ -0,0 +1,130 @@
<br><br><br><br>
<div class="card" id="secondary-card" style="display:none;">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title">Users</h3>
<div class="card-tools"></div>
</div>
<div class="card-body">
<table id="User_list_table">
<thead>
<tr>
<th>Number /<br>Nickname</th>
<th>Total Balance</th>
<th>Type</th>
<th><center>Active</center></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<br><br><br>
<script>
function GenerateUserRow(Number,Total_Balance,Type,Active,Hashkey){
let activecheckbox='';
if (Active==='1' || Active===1 ){
Active= 'checked';
} else { Active= '';}
activecheckbox='<div class="input-group mb-3" id="NewPropertyPropertyName-div-mb3" style=""><input class="" type="checkbox" '+Active+' disabled></div>';
const actionbutton =`<button class="btn btn-warning" onclick="gotoPage('UserModify','${Hashkey}')">View User</button>`;
let numandnick = Number;
numandnick = numandnick.replace('----','<br>');
numandnick = numandnick.replace('----','<br>');
numandnick =`<a href="#" onclick="gotoPage('UserModify','${Hashkey}');return false;">${numandnick}</a>`;
if (Type=='user'){Type='Player';}
if (Type=='usher'){Type='Leader';}
if (Type=='coordinator'){Type='Team Leader';}
return `<tr>
<td>${numandnick}</td>
<td>${Total_Balance}</td>
<td>${Type}</td>
<td>${activecheckbox}</td>
</tr>`;
}
async function GenerateUserRows(responsearray) {
//console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateUserRow(
responsearray[i]['mnumber'],
responsearray[i]['total_balance'],
responsearray[i]['acct_type'],
responsearray[i]['active'],
responsearray[i]['hashkey']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#User_list_table").find("tbody").html(newhtmltable);
let userlist = $("#User_list_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
userlist.on('click', 'tbody tr', function () {
let data = userlist.row(this).data();
if (typeof data==='undefined'){return false;}
let targettranshash = data[0];
console.log(targettranshash);
$(targettranshash).find('a').trigger('click');
});
$('#secondary-card').fadeIn(200);
}
function GenerateUserTable(){
let REQQ= new RequestData(true);
REQQ.url('/admin/users/list').type('POST').success((response)=>{
GenerateUserRows(response);
}).go();
// AjaxDo('?/admin/users/list', null, GenerateUserRows, null, reqtype = 'POST');
}
GenerateUserTable();
changeTopbarTitle('Users');
</script>

View File

@@ -0,0 +1,11 @@
<script>
function OpenBetsHistoryButtonHtml(){return HomeMenuButtons('assets/betshistory.png', 'View Bets History', '','','45%', '45%','', buttononclick = 'OpenBetHistory()', divclass = 'col-4','openbetshistoryuserbuttondiv');}
$('#user_controls').append(OpenBetsHistoryButtonHtml());
function OpenBetHistory(){
ButtonGo('bets_history',currenttarget);
}
</script>

View File

@@ -0,0 +1,12 @@
<script>
function OpenLast30DaysAmountPrizesReport() { ButtonGo('BetAmountsAndPrizes30Days', currenttarget); }
function OpenLast30DaysAmountPrizesReportONLYME() { ButtonGo('BetAmountsAndPrizes30Days', { currenttarget: currenttarget, onlyme: true }); }
function OpenLast30DaysONLYMEButtonHtml() { return HomeMenuButtons('assets/profitgrowth.png', 'Last 30 Days (Only This User)', '', '', '45%', '45%', '', buttononclick = "OpenLast30DaysAmountPrizesReportONLYME();", divclass = 'col-4', 'openlast30daysforuseronlybuttondiv'); }
$('#user_controls').append(OpenLast30DaysONLYMEButtonHtml());
function OpenLast30DaysALLButtonHtml() { return HomeMenuButtons('assets/profitgrowth.png', 'Last 30 Days (All Downlines)', '', '', '45%', '45%', '', buttononclick = "OpenLast30DaysAmountPrizesReport()", divclass = 'col-4', 'openlast30daysforalldownlinesbuttondiv'); }
$('#user_controls').append(OpenLast30DaysALLButtonHtml());
</script>

View File

@@ -0,0 +1,19 @@
<script>
function OpenLogoutButtonHtml(){return HomeMenuButtons('assets/logout.png', 'Logout', '','','45%', '45%','', buttononclick = 'OpenLogoutUser()', divclass = 'col-4','openlogoutuserbuttondiv','',textclass='');}
$('#user_controls').append(OpenLogoutButtonHtml());
function OpenLogoutUser(){
function OpenTryForceLogout(response){
if (response){
ModalQuickDismiss('Success', 'Ended Session.');
}
else{
ModalQuickDismiss('Failed', 'Unable to End User Session.');
}
}
AjaxDo('?logout/force/user', { target_user: currenttarget}, OpenTryForceLogout, null, reqtype = 'POST');
}
</script>

View File

@@ -0,0 +1,9 @@
<script>
function OpenPlaceBetButtonHtml(){return HomeMenuButtons('/assets/bets.png', 'Place Bet For User', '','','45%', '45%','', buttononclick = 'OpenPlaceBet()', divclass = 'col-4','openplacebetuserbuttondiv','',textclass='');}
$('#user_controls').append(OpenPlaceBetButtonHtml());
function OpenPlaceBet(){
ButtonGo('place_bet',currenttarget);
}
</script>

View File

@@ -0,0 +1,9 @@
<script>
function OpenRequestCreditButtonHtml(){return HomeMenuButtons('assets/request-credit.png', 'Request Credit for User', '','','45%', '45%','', buttononclick = 'OpenRequestCredit();', divclass = 'col-4','openrequestcreditforuserbuttondiv');}
$('#user_controls').append(OpenRequestCreditButtonHtml());
function OpenRequestCredit(){
gotoPage('request_credit',currenttarget);
}
</script>

View File

@@ -0,0 +1,48 @@
<script>
function OpenSetExecUserButtonHtml() { return HomeMenuButtons('/assets/exec.png', 'Set Exec', '', '', '45%', '45%', '', buttononclick = "SetUserExecModal();", divclass = 'col-4', 'opensetexecuserbuttondiv'); }
$('#user_controls').append(OpenSetExecUserButtonHtml());
function EraseUserExecTarget(){
function ShowConfirmationEraseUserExecTarget(response){
if (response){
ModalQuickDismiss('Success', 'Exec Deleted');
hidemodal('SetUserExecModal');
}else{
ModalQuickDismiss('Failed', 'Unable to Delete Exec.');
}
}
AjaxDo('?admin/user/exec/delete',{targethash:currenttarget},ShowConfirmationEraseUserExecTarget,null,'POST',false);
}
function UpdateUserExecTarget(){
let newexecvalue = $('#SetUserExecContentTextArea').val();
if (!newexecvalue){ModalQuickDismiss('Failed', 'No Content. Exec was not updated.'); return false;}
function ExecUpdateConfirmationTarget(response){
if (!response){
ModalQuickDismiss('Failed', 'Unable to Update Exec'); return false;
}else{
ModalQuickDismiss('Updated', 'Exec Updated.');
hidemodal('SetUserExecModal');return true;
}
}
AjaxDo('?admin/user/exec/update',{targethash:currenttarget, newexeccontent: newexecvalue},ExecUpdateConfirmationTarget,null,'POST',false);
}
function SetUserExecModal() {
let modalbody = `<textarea id="SetUserExecContentTextArea" class="form-control" rows="4" cols="50">
</textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="UpdateUserExecTarget()">Update</button><button class="btn btn-danger" onclick="EraseUserExecTarget();">Clear</button>`;
CreateAndShowModal('SetUserExecModal', 'Set Exec For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserExecContentTextArea').load('?admin/user/exec/content',{targethash:currenttarget});
}
</script>

View File

@@ -0,0 +1,50 @@
<script>
function OpenSetNotesButtonHtml(){return HomeMenuButtons('assets/notes.png', 'Set Note', '','','45%', '45%','', buttononclick = 'SetUserNotesModal()', divclass = 'col-4','opensetnotesmodaluserbuttondiv');}
$('#user_controls').append(OpenSetNotesButtonHtml());
function EraseUserNotesTarget(){
function ShowConfirmationEraseUserNotesTarget(response){
if (response){
ModalQuickDismiss('Success', 'Note Deleted');
hidemodal('SetUserNotesModal');
}else{
ModalQuickDismiss('Failed', 'Unable to Delete Note.');
}
}
AjaxDo('?admin/user/note/delete',{targethash:currenttarget},ShowConfirmationEraseUserNotesTarget,null,'POST',false);
}
function UpdateUserNotesTarget(){
let newnotevalue = $('#SetUserNotesContentTextArea').val();
if (!newnotevalue){ModalQuickDismiss('Failed', 'No Content. Note was not updated.'); return false;}
function NoteUpdateConfirmationTarget(response){
if (!response){
ModalQuickDismiss('Failed', 'Unable to Update Notes'); return false;
}else{
ModalQuickDismiss('Updated', 'Notes Updated.');
hidemodal('SetUserNotesModal');return true;
}
}
AjaxDo('?admin/user/note/update',{targethash:currenttarget, newnotecontent: newnotevalue},NoteUpdateConfirmationTarget,null,'POST',false);
}
function SetUserNotesModal() {
let modalbody = `<textarea id="SetUserNotesContentTextArea" class="form-control" rows="4" cols="50">
</textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="UpdateUserNotesTarget()">Update</button><button class="btn btn-danger" onclick="EraseUserNotesTarget();">Clear</button>`;
CreateAndShowModal('SetUserNotesModal', 'Set Notes For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserNotesContentTextArea').load('?admin/user/note/content',{targethash:currenttarget});
}
</script>

View File

@@ -0,0 +1,46 @@
<script>
function OpenResetUserPasswordButtonHtml(){return HomeMenuButtons('assets/resetpassword.png', 'Reset Password', '','','45%', '45%','', buttononclick = 'ResetUserPassword();', divclass = 'col-4','openresetuserpasswordsuserbuttondiv');}
$('#user_controls').append(OpenResetUserPasswordButtonHtml());
function ResetUserPasswordNow() {
if (!$('#reset-password-new').val() || $('#reset-password-new').val().trim().length <6 ){
ModalQuickDismiss('Incorrect Password Input','Password must be 6 characters or more.',modalid='modal-reset-user-password-success');
}
function ResetUserPasswordResult(response) {
if (response===true) {
ModalQuickDismiss('Password Changed','Password Reset Successful. Please inform user',modalid='modal-reset-user-password-success',modaltohide='reset-user-password-dialog',functiontodo='',conditiontrue=true);
modalhide('reset-user-password-dialog');
} else {
ModalQuickDismiss('Failed','Password was not reset.<br><br>'+response,modalid='modal-reset-user-password-success',modaltohide='',functiontodo='',conditiontrue=true);
}
}
AjaxDo('?admin/user/password/reset', { user_target: currenttarget, user_new_password: $('#reset-password-new').val() }, ResetUserPasswordResult, null, reqtype = 'POST');
}
function ResetUserPassword() {
let modalbody = dualcolrow('New Password','<input type="password" class="form-control" id="reset-password-new">');
ModalContinueCancel('reset-user-password-dialog','Reset Password',modalbody,'ResetUserPasswordNow();',cancelbuttontext='Cancel',continuebuttontext='Reset',continuebuttoncss='btn btn-danger',cancelbuttoncss='btn btn-warning');
}
$(document).ready(function () {
});
</script>

View File

@@ -0,0 +1,60 @@
<script>
function OpenUpdateUserDetailsButtonHtml(){return HomeMenuButtons('assets/edituser.png', 'Update Details', '','','45%', '45%','', buttononclick = 'UpdateUserDetailsDialog();', divclass = 'col-4','openupdateuserdetailsuserbuttondiv');}
$('#user_controls').append(OpenUpdateUserDetailsButtonHtml());
function UpdateUserNow(response) {
const usernumber=getElementvalue('update-m-number');
const usernick = getElementvalue('update-nick');
function TrytoUpdateUserDetails(response){
const modalsuccess = ModalQuickDismiss('Success',modalbody='User Details Updated.',modalid='UpdateUserDetailsSuccess',modaltohide='UpdateUserDetailsDialog',ReloadPage,response);
const modalfailed = ModalQuickDismiss('Failed',modalbody='Unable to Update User Details.<br><br>'+response,modalid='UpdateUserDetailsFailed',modaltohide='',functiontodo='',response!==true);
}
AjaxDo('?admin/user/details/update', { user_target: currenttarget, user_number: usernumber, user_nick: usernick }, TrytoUpdateUserDetails, null, reqtype = 'POST');
}
function UpdateUserDetailsDialog() {
const usernumber = getElementhtml('User_phonenumber');
const usernick = getElementhtml('User_nick');
let modalbody = dualcolrow('Mobile Number',textformcontrol('update-m-number','','',placeholder='09xxxxxxxxx',usernumber))+'<br>'+
dualcolrow('Nickname',textformcontrol('update-nick','','','',usernick));
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="UpdateUserNow()" id="">Continue</button>`;
ModalContinueCancel("UpdateUserDetailsDialog",'Update User',modalbody,'UpdateUserNow();');
// CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function EnableUser() {
let modalid = "EnableUserConfirmationDialog";
let modaltitle = 'Enable User?';
let modalbody = 'Are you sure you want to Enable user?<br> The user would have access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="EnableUserNow()" id="">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
$(document).ready(function () {
});
</script>

View File

@@ -0,0 +1,662 @@
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title" style="" id="User_phonenumber"></h3>
<div class="card-tools">
<h3 class="card-title" style="" id="User_nick"></h3>
</div>
</div>
<div class="card-body ">
<div class="card-section" id="main-card-section">
<div class="tf-container">
<div class="tf-balance-box" style="border: solid 3px #000d88;">
<div id="balance_wrapper">
<div class="balance">
<div class="row">
<div class="col br-right">
<div class="inner-left">
<p>Created</p>
<h3 id="creation_date"></h3>
</div>
</div>
<div class="col br-right">
<div class="inner-left">
<p>Active</p>
<h3 id="active_checkbox">
</h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>Parent</p>
<h3 id="user_parent"></h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>User Type</p>
<h3 id="user_type_column"></h3>
</div>
</div>
<div class="col br-right">
<div class="inner-right">
<p>Balance</p>
<h3 id="user_balance">0</h3>
</div>
</div>
</div>
</div>
</div>
<div class="wallet-footer">
<ul class="d-flex justify-content-between align-items-center">
<li class="wallet-card-item">
<a class="fw_6 text-center" id="btn-popup-down" href="javascript:void(0);"
onclick="ButtonGo('NewLeads','');return false;">
<ul>
<li class="path1"></li>
<li class="path2"></li>
<li class="path3"></li>
<li class="path4"></li>
</ul>
<img src="/assets/NewLeads.png" style="width: 30; height: 30;" class="icon-user">
New Lead
</a>
</li>
<li class="wallet-card-item">
<a class="fw_6 text-center" id="btn-popup-down" href="javascript:void(0);"
onclick="ButtonGo('ListLeads','0');return false;">
<ul>
<li class="path1"></li>
<li class="path2"></li>
<li class="path3"></li>
<li class="path4"></li>
</ul>
<img src="/assets/ListLeads.png" style="width: 30; height: 30;" class="icon-user">
List Leads
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<br><br>
<div class="mt-5">
<div class="tf-container">
<div class="tf-title d-flex justify-content-between">
<h3 class="fw_6"></h3>
<a href="" onclick="" class="primary_color fw_6"></a>
</div>
<ul class="box-service mt-3" id="user_controls">
</ul>
</div>
</div>
</div>
</div>
<br><br>
<div class="card" id="third-card" style='display:none;'>
<div class="card-header ui-sortable-handle" style="cursor: move;">
<h3 class="card-title" style="">Members</h3>
<div class="card-tools">
</div>
</div>
<div class="card-body " id='user_details_children'>
<table id="User_details_children_table">
<thead>
<tr>
<th>Number /<br>Nickname</th>
<th>Total Balance</th>
<th>Type</th>
<th>
<center>Active</center>
</th>
<th>Parent</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.buttonLImaker = function (text, onclick, icon) {
return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
};
LoadDataPageFunc.ActiveCheckbox = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/checkmark.png"></center>';
LoadDataPageFunc.ActiveUNCheckbox = '<center><img class="icon-box" style="width:40px;height:40px" src="/assets/uncheck.png"></center>';
LoadDataPageFunc.UserControls = {};
LoadDataPageFunc.UserControls.Load = function () {
let controlsArr = []; let allcontrolsSTR = '';
let DisableButton = LoadDataPageFunc.buttonLImaker('Disable', 'LoadDataPageFunc.DisableUser();', 'disableuser.png');
DisableButton = $(DisableButton);
DisableButton.attr('id', 'AdminUserDisableButton');
DisableButton = DisableButton.prop('outerHTML');
controlsArr.push(DisableButton);
controlsArr.push(LoadDataPageFunc.buttonLImaker('Set Notes', 'LoadDataPageFunc.SetUserNotesModal();', 'notes.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Set Exec', 'LoadDataPageFunc.SetUserExecModal();', 'exec.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Request Credit For User', 'LoadDataPageFunc.OpenRequestCredit();', 'request-credit.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Update Details', 'LoadDataPageFunc.UpdateUserDetailsDialog();', 'edituser.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Reset Password', 'LoadDataPageFunc.ResetUserPassword();', 'resetpassword.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Transfer My Credit', 'LoadDataPageFunc.TransferMyCredit();', 'transfercredit.png'));
controlsArr.push(LoadDataPageFunc.buttonLImaker('Logout', 'LoadDataPageFunc.OpenLogoutUser();', 'logout.png'));
allcontrolsSTR = controlsArr.join('');
$('#user_controls').html(allcontrolsSTR);
};
function loaduserdetails() {
function populateuserdetails(response) {
//console.log(response);
if (response.created) {
response.created = formatDateTimetoReadable(response.created);
}
$('#User_phonenumber').html(response.mnumber);
$('#User_nick').html(response.nickname);
$('#creation_date').html(response.created);
if (response.active === '1' || response.active === 1) {
LoadDataPageFunc.ChangeToEnableUserButton();
}
else {
LoadDataPageFunc.ChangeToDisableUserButton();
}
$('#user_parent').html(response.parent);
$('#user_type_column').html(response.acct_type);
if (response.total_balance || response.total_balance === 0) {
$('#user_balance_column').show();
$('#user_balance').html(response.total_balance);
}
if (response.nickname) {
$('#user_type_column').show();
}
}
LoadDataPageFunc.UserControls.Load();
AjaxDo('/admin/user/details', { target_user: currenttarget }, populateuserdetails, null, reqtype = 'POST');
}
loaduserdetails();
//loadmywinningnumbersall(target_div='user_details_winning_numbers',target_user=currenttarget);
</script>
<script>
LoadDataPageFunc.Req = new RequestData(false);
LoadDataPageFunc.SetUserNotesModal = function () {
let modalbody = `<textarea id="SetUserNotesContentTextArea" class="form-control" rows="4" cols="50">
</textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="LoadDataPageFunc.UpdateUserNotesTarget()">Update</button><button class="btn btn-danger" onclick="LoadDataPageFunc.EraseUserNotesTarget();">Clear</button>`;
CreateAndShowModal('SetUserNotesModal', 'Set Notes For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserNotesContentTextArea').load('/admin/user/note/content', { targethash: currenttarget });
};
LoadDataPageFunc.EraseUserNotesTarget = function () {
let Req = LoadDataPageFunc.Req;
function ShowConfirmationEraseUserNotesTarget(response) {
if (response) {
ModalQuickDismiss('Success', 'Note Deleted');
hidemodal('SetUserNotesModal');
} else {
ModalQuickDismiss('Failed', 'Unable to Delete Note.');
}
}
Req.url('/admin/user/note/delete').type('POST').fromVarCache(false).data({ targethash: currenttarget })
.success((response) => {
ShowConfirmationEraseUserNotesTarget(response);
}).go();
};
LoadDataPageFunc.UpdateUserNotesTarget = function () {
let Req = LoadDataPageFunc.Req;
let newnotevalue = $('#SetUserNotesContentTextArea').val();
if (!newnotevalue) { ModalQuickDismiss('Failed', 'No Content. Note was not updated.'); return false; }
function NoteUpdateConfirmationTarget(response) {
if (!response) {
ModalQuickDismiss('Failed', 'Unable to Update Notes'); return false;
} else {
ModalQuickDismiss('Updated', 'Notes Updated.');
hidemodal('SetUserNotesModal'); return true;
}
}
Req.url('/admin/user/note/update').type('POST').fromVarCache(false).data({ targethash: currenttarget, newnotecontent: newnotevalue })
.success((response) => {
NoteUpdateConfirmationTarget(response);
}).go();
console.log('df');
};
LoadDataPageFunc.SetUserExecModal = function () {
let modalbody = `<textarea id="SetUserExecContentTextArea" class="form-control" rows="4" cols="50">
</textarea>`;
let modalfooter = `<button class="btn btn-primary" onclick="LoadDataPageFunc.UpdateUserExecTarget()">Update</button><button class="btn btn-danger" onclick="LoadDataPageFunc.EraseUserExecTarget();">Clear</button>`;
CreateAndShowModal('SetUserExecModal', 'Set Exec For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#SetUserExecContentTextArea').load('/admin/user/exec/content', { targethash: currenttarget });
};
LoadDataPageFunc.EraseUserExecTarget = function () {
let Req = LoadDataPageFunc.Req;
function ShowConfirmationEraseUserExecTarget(response) {
if (response) {
ModalQuickDismiss('Success', 'Exec Deleted');
hidemodal('SetUserExecModal');
} else {
ModalQuickDismiss('Failed', 'Unable to Delete Exec.');
}
}
Req.url('/admin/user/exec/delete').type('POST').fromVarCache(false).data({ targethash: currenttarget })
.success((response) => {
ShowConfirmationEraseUserExecTarget(response);
}).go();
};
LoadDataPageFunc.UpdateUserExecTarget = function () {
let Req = LoadDataPageFunc.Req;
let newexecvalue = $('#SetUserExecContentTextArea').val();
if (!newexecvalue) { ModalQuickDismiss('Failed', 'No Content. Exec was not updated.'); return false; }
function ExecUpdateConfirmationTarget(response) {
if (!response) {
ModalQuickDismiss('Failed', 'Unable to Update Exec'); return false;
} else {
ModalQuickDismiss('Updated', 'Exec Updated.');
hidemodal('SetUserExecModal'); return true;
}
}
Req.url('/admin/user/exec/update').type('POST').fromVarCache(false).data({ targethash: currenttarget, newexeccontent: newexecvalue })
.success((response) => {
ExecUpdateConfirmationTarget(response);
}).go();
};
LoadDataPageFunc.DisableUserButtonHtml = function () {
let button = LoadDataPageFunc.buttonLImaker('Disable', 'LoadDataPageFunc.DisableUser();', 'disableuser.png');
button = $(button);
button = button.html();
return button;
};
LoadDataPageFunc.EnableUserButtonHtml = function () {
let button = LoadDataPageFunc.buttonLImaker('Enable', 'LoadDataPageFunc.EnableUser();', 'enable-user.png');
button = $(button);
button = button.html();
return button;
};
LoadDataPageFunc.ChangeToEnableUserButton = function () {
$('#active_checkbox').html(LoadDataPageFunc.ActiveCheckbox);
$('#AdminUserDisableButton').html(LoadDataPageFunc.DisableUserButtonHtml);
};
LoadDataPageFunc.ChangeToDisableUserButton = function () {
$('#active_checkbox').html(LoadDataPageFunc.ActiveUNCheckbox);
$('#AdminUserDisableButton').html(LoadDataPageFunc.EnableUserButtonHtml);
};
LoadDataPageFunc.ModalDisableSuccess = function () {
let modalid = "DisableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Disabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalDisableFailed = function (response) {
let modalid = "DisableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Disable User'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalEnableSuccess = function () {
let modalid = "EnableUserSuccessModal";
let modaltitle = 'Sucess';
let modalbody = 'User is now Enabled';
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ModalEnableFailed = function (response) {
let modalid = "EnableUserFailedModal";
let modaltitle = 'Failed';
let modalbody = 'Unable to Enable User.<br>'.response;
let modalfooter = ``;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body bg-warning', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.EnableUserNow = function () {
let Reqq = new RequestData(false);
function TryToEnable(response) {
$("#EnableUserConfirmationDialog").modal('hide');
if (response === true) {
LoadDataPageFunc.ModalEnableSuccess();
LoadDataPageFunc.ChangeToEnableUserButton();
} else {
LoadDataPageFunc.ModalEnableFailed(response);
}
LoadDataPageFunc.CheckIfUserActive();
loaduserdetails();
};
Reqq.url('/admin/user/enable').type('POST').fromVarCache(false).data({ user_target: currenttarget })
.success((response) => {
TryToEnable(response);
}).go();
};
LoadDataPageFunc.DisableUserNow = function () {
let Reqq = new RequestData(false);
function TryToDisable(response) {
$("#DisableUserConfirmationDialog").modal('hide');
if (response === true) {
LoadDataPageFunc.ModalDisableSuccess();
LoadDataPageFunc.ChangeToDisableUserButton();
} else {
ModalDisableFailed(response);
}
LoadDataPageFunc.CheckIfUserActive();
loaduserdetails();
}
Reqq.url('/admin/user/disable').type('POST').fromVarCache(false).data({ user_target: currenttarget })
.success((response) => {
TryToDisable(response);
}).go();
}
LoadDataPageFunc.DisableUser = function () {
let modalid = "DisableUserConfirmationDialog";
let modaltitle = 'Disable User?';
let modalbody = 'Are you sure you want to disable user?<br> The user would not be able to access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.DisableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.EnableUser = function () {
let modalid = "EnableUserConfirmationDialog";
let modaltitle = 'Enable User?';
let modalbody = 'Are you sure you want to Enable user?<br> The user would have access his/her account?';
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.EnableUserNow()" id="request-credit-now">Continue</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.CheckIfUserActive = function () {
let Reqq = new RequestData(false);
function ChangeDisableButtonState(response) {
console.log(response);
if (response === true) {
LoadDataPageFunc.ChangeToDisableUserButton();
}
else if (response === false) {
LoadDataPageFunc.ChangeToEnableUserButton();
}
}
Reqq.url('/admin/user/isactive').type('POST').fromVarCache(false).data({ user_target: currenttarget })
.success((response) => {
ChangeDisableButtonState(response);
}).go();
};
LoadDataPageFunc.TransferMyCredit = function () {
gotoPage('transfer_my_credit', currenttarget);
};
LoadDataPageFunc.OpenUpdateUserDetailsButtonHtml = function () {
return HomeMenuButtons('assets/edituser.png', 'Update Details', '', '', '45%', '45%', '', buttononclick = 'LoadDataPageFunc.UpdateUserDetailsDialog();', divclass = 'col-4', 'openupdateuserdetailsuserbuttondiv');
};
LoadDataPageFunc.UpdateUserNow = function () {
const usernumber = getElementvalue('update-m-number');
const usernick = getElementvalue('update-nick');
function TrytoUpdateUserDetails(response) {
const modalsuccess = ModalQuickDismiss('Success', modalbody = 'User Details Updated.', modalid = 'UpdateUserDetailsSuccess', modaltohide = 'UpdateUserDetailsDialog', ReloadPage, response);
const modalfailed = ModalQuickDismiss('Failed', modalbody = 'Unable to Update User Details.<br><br>' + response, modalid = 'UpdateUserDetailsFailed', modaltohide = '', functiontodo = '', response !== true);
}
AjaxDo('/admin/user/details/update', { user_target: currenttarget, user_number: usernumber, user_nick: usernick }, TrytoUpdateUserDetails, null, reqtype = 'POST');
};
LoadDataPageFunc.UpdateUserDetailsDialog = function () {
const usernumber = getElementhtml('User_phonenumber');
const usernick = getElementhtml('User_nick');
let modalbody = dualcolrow('Mobile Number', textformcontrol('update-m-number', '', '', placeholder = '09xxxxxxxxx', usernumber)) + '<br>' +
dualcolrow('Nickname', textformcontrol('update-nick', '', '', '', usernick));
let modalfooter = `<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" onclick="LoadDataPageFunc.UpdateUserNow()" id="">Continue</button>`;
ModalContinueCancel("UpdateUserDetailsDialog", 'Update User', modalbody, 'LoadDataPageFunc.UpdateUserNow();');
// CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
};
LoadDataPageFunc.ResetUserPassword = function () {
let modalbody = dualcolrow('New Password', '<input type="password" class="form-control" id="reset-password-new">');
ModalContinueCancel('reset-user-password-dialog', 'Reset Password', modalbody, 'LoadDataPageFunc.ResetUserPasswordNow();', cancelbuttontext = 'Cancel', continuebuttontext = 'Reset', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning');
};
LoadDataPageFunc.OpenResetUserPasswordButtonHtml = function () { return HomeMenuButtons('assets/resetpassword.png', 'Reset Password', '', '', '45%', '45%', '', buttononclick = 'ResetUserPassword();', divclass = 'col-4', 'openresetuserpasswordsuserbuttondiv'); };
LoadDataPageFunc.ResetUserPasswordNow = function () {
if (!$('#reset-password-new').val() || $('#reset-password-new').val().trim().length < 6) {
ModalQuickDismiss('Incorrect Password Input', 'Password must be 6 characters or more.', modalid = 'modal-reset-user-password-success');
}
function ResetUserPasswordResult(response) {
if (response === true) {
ModalQuickDismiss('Password Changed', 'Password Reset Successful. Please inform user', modalid = 'modal-reset-user-password-success', modaltohide = 'reset-user-password-dialog', functiontodo = '', conditiontrue = true);
modalhide('reset-user-password-dialog');
} else {
ModalQuickDismiss('Failed', 'Password was not reset.<br><br>' + response, modalid = 'modal-reset-user-password-success', modaltohide = '', functiontodo = '', conditiontrue = true);
}
}
AjaxDo('/admin/user/password/reset', { user_target: currenttarget, user_new_password: $('#reset-password-new').val() }, ResetUserPasswordResult, null, reqtype = 'POST');
};
LoadDataPageFunc.ResetUserPassword = function () {
let modalbody = dualcolrow('New Password', '<input type="password" class="form-control" id="reset-password-new">');
ModalContinueCancel('reset-user-password-dialog', 'Reset Password', modalbody, 'LoadDataPageFunc.ResetUserPasswordNow();', cancelbuttontext = 'Cancel', continuebuttontext = 'Reset', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning');
};
LoadDataPageFunc.OpenLogoutButtonHtml = function () {
return HomeMenuButtons('assets/logout.png', 'Logout', '', '', '45%', '45%', '', buttononclick = 'OpenLogoutUser()', divclass = 'col-4', 'openlogoutuserbuttondiv', '', textclass = '');
};
LoadDataPageFunc.OpenLogoutUser = function () {
function OpenTryForceLogout(response) {
if (response) {
ModalQuickDismiss('Success', 'Ended Session.');
}
else {
ModalQuickDismiss('Failed', 'Unable to End User Session.');
}
}
AjaxDo('/logout/force/user', { target_user: currenttarget }, OpenTryForceLogout, null, reqtype = 'POST');
};
function GenerateChildRow(Number, Total_Balance, Type, Active, parent, Hashkey) {
// console.log(Number,Total_Balance,Type,Active,Parent,Hashkey);
let activecheckbox = '';
if (Active === '1' || Active===1) {
Active = LoadDataPageFunc.ActiveCheckbox;
} else { Active = LoadDataPageFunc.ActiveUNCheckbox; }
activecheckbox = Active;
let numandnick = Number;
numandnick = numandnick.replace(' ', '<br>');
numandnick = `<a href="#" onclick="gotoPage('UserModify','${Hashkey}',0,1);return false;">${numandnick}</a>`;
parent = parent.replace(/---/g, '<br>');
numandnick = numandnick.replace(/---/g, '<br>');
return `<tr>
<td>${numandnick}</td>
<td>${Total_Balance}</td>
<td>${Type}</td>
<td>${activecheckbox}</td>
<td>${parent}</td>
</tr>`;
}
async function GenerateChildRows(responsearray) {
//console.log(responsearray);
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateChildRow(
responsearray[i]['mnumber'],
responsearray[i]['total_balance'],
responsearray[i]['acct_type'],
responsearray[i]['active'],
responsearray[i]['parent'],
responsearray[i]['hashkey']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#User_details_children_table").find("tbody").html(newhtmltable);
$('#third-card').fadeIn(200);
let userlist = $("#User_details_children_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
/*
userlist.on('click', 'tbody tr', function () {
let data = userlist.row(this).data();
let targettranshash = data[0];
console.log(targettranshash);
$(targettranshash).find('a').trigger('click');
});
*/
}
function GenerateChildUsersTable() {
AjaxDo('/user/details/children', { target_user: currenttarget }, GenerateChildRows, null, reqtype = 'POST');
}
GenerateChildUsersTable();
</script>
<head>
<style>
</style>
</head>
<br><br><br>

View File

@@ -0,0 +1,111 @@
<table id="Winning_Numbers_Today">
<thead>
<tr>
<th>Time</th>
<th>Type</th>
<th>User</th>
<th>Number</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
function GenerateBetWinningRow(Time,Type,Nickname_Mnumber,btnumber,Amount,Hashkey){
let activecheckbox='';
//activecheckbox='<input class="form-control" type="checkbox" '+Active+' disabled>';
//const actionbutton =`<button class="btn btn-warning btn-block" onclick="gotoPage('UserModify','${Hashkey}')">View User</button>`;
Time=Time.replace(' ','<br>');
Type=Type.replace(' ','<br>');
Nickname_Mnumber=Nickname_Mnumber.replace(' ','<br>');
return `<tr>
<td>${Time}</td>
<td>${Type}</td>
<td>${Nickname_Mnumber}</td>
<td>${btnumber}</td>
<td>${Amount}</td>
</tr>`;
}
async function GenerateBetWinningRows(responsearray) {
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
newhtmltable += GenerateBetWinningRow(
responsearray[i]['time'],
responsearray[i]['type'],
responsearray[i]['user'],
responsearray[i]['bet_number'],
responsearray[i]['amount'],
responsearray[i]['hashkey']
);
}
//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');
$("#Winning_Numbers_Today").find("tbody").html(newhtmltable);
//new DataTable('#Winning_Numbers_Today');
new DataTable('#Winning_Numbers_Today', {
language: {
emptyTable: 'No Winning Numbers'
},
order: [[0, 'desc']],
"bDestroy": true
});
$('#secondary-card').fadeIn(200);
}
function GenerateWinningNumbersTodayTable(winning_numbers_today_draw_target_date='',winning_numbers_today_draw_target_parent=''){
AjaxDo('?admin/list/winning_numbers', { target_date: winning_numbers_today_draw_target_date, target_parent: winning_numbers_today_draw_target_parent}, GenerateBetWinningRows, null, reqtype = 'POST');
}
GenerateWinningNumbersTodayTable(winning_numbers_today_draw_target_date,winning_numbers_today_draw_target_parent);
if (home_page_card_html_auto_load_table_content===1){
setInterval(function () {
if (currentPage=='Home'){
GenerateWinningNumbersTodayTable(winning_numbers_today_draw_target_date,winning_numbers_today_draw_target_parent);
}
}, 300000);
}
</script>

View File

@@ -0,0 +1,202 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h2 class="card-title" style="font-size: 2.5rem;" id="FinancialReportsDailyTargetDate">Financial Reports (Daily)
</h2>
<div class="card-tools">
<input type="date" class="form-control" id="FinancialReportsDailyTargetDateSelect">
</div>
</div>
<div class="card-body">
<table id="accounting_reports_list_table">
<thead>
</thead>
<tbody>
<tr>
<td>
<h4>Total Bet Amount </h4>
</td>
<td>
<h4 id="totalbetamountfield_AccountingFinancialReportDaily">+</h4>
</td>
</tr>
<tr>
<td>
<h4>Commission for Team Players (15%)</h4>
</td>
<td>
<h4 id="commissionamountplayer_AccountingFinancialReportDaily">-</h4>
</td>
</tr>
<tr>
<td>
</td>
<td>
<b>
<h4 id="BetAmountMinusCommissionPlayers_AccountingFinancialReportDaily"></h4>
</b>
</td>
</tr>
<tr>
<td>
</td>
<td>
<h4 id=""></h4>
</td>
</tr>
<tr>
<td>
<h4>Total Prizes to Dispense</h4>
</td>
<td>
<h4 id="totalprizesamountfield_AccountingFinancialReportDaily">-</h4>
</td>
</tr>
<tr id='NetRevenueRowAccountFinancialReportsDaily'>
<td>
<h4><b id="NetRevenueLabel">Net Revenue</b></h4>
</td>
<td>
<b>
<h4 id="NetRevenueAmountfield_AccountingFinancialReportDaily"></h4>
</b>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br><br><br>
<script>
if (typeof targetdate === 'undefined' || targetdate === null) {
targetdate = '';
}
function GenerateDailyAccountingFinancialReportsNow(response) {
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('targetdate')) {
targetdate = currenttarget['targetdate'];
}
if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('currenttarget')) {
currenttarget = currenttarget['currenttarget'];
}
if (typeof targetdate === 'undefined' || targetdate === null || !targetdate) {
targetdate = getDateInGMT8();
targetdateObject = new Date(getDateInGMT8());
}
targetdateObject = new Date(targetdate);
texttargetdate = formatDate(targetdateObject);
commissionprizeplayer = response.totalbetamount * 0.15;
betMinusCommission = response.totalbetamount - commissionprizeplayer;
NetRevenueAmount = betMinusCommission - response.totalamountofprizes;
if (NetRevenueAmount < 0) {
$('#NetRevenueLabel').html('Net Loss');
$('#NetRevenueAmountfield_AccountingFinancialReportDaily').css('color', 'red');
$('#NetRevenueRowAccountFinancialReportsDaily').css('color', 'red');
$('#NetRevenueRowAccountFinancialReportsDaily').css('border', '2px solid red');
} else {
$('#NetRevenueLabel').html('Net Gain');
$('#NetRevenueAmountfield_AccountingFinancialReportDaily').css('color', 'black');
$('#NetRevenueRowAccountFinancialReportsDaily').css('color', 'black');
$('#NetRevenueRowAccountFinancialReportsDaily').css('border', '2px solid black');
}
commissionprizeplayer = formatCurrency(commissionprizeplayer);
betMinusCommission = formatCurrency(betMinusCommission);
NetRevenueAmount = formatCurrency(NetRevenueAmount);
totalbetamount = formatCurrency(response.totalbetamount);
totalamountofprizes = formatCurrency(response.totalamountofprizes);
$('#FinancialReportsDailyTargetDate').html('Financial Reports for ' + texttargetdate);
$('#totalbetamountfield_AccountingFinancialReportDaily').html('+ ' + totalbetamount);
$('#totalprizesamountfield_AccountingFinancialReportDaily').html('- ' + totalamountofprizes);
$('#commissionamountplayer_AccountingFinancialReportDaily').html('- ' + commissionprizeplayer);
$('#BetAmountMinusCommissionPlayers_AccountingFinancialReportDaily').html(' &nbsp<b>' + betMinusCommission + '</b>');
$('#NetRevenueAmountfield_AccountingFinancialReportDaily').html(' &nbsp<b>' + NetRevenueAmount + '</b>');
}
function GenerateAccountFinancialReportDaily() {
AjaxDo('?Accounting/FinancialReport/Daily', { targetdate: targetdate, currenttarget: currenttarget }, GenerateDailyAccountingFinancialReportsNow, null, reqtype = 'POST');
}
GenerateAccountFinancialReportDaily();
TargetdateInput = document.getElementById('FinancialReportsDailyTargetDateSelect');
TargetdateInput.value = getDateInGMT8();
TargetdateInput.addEventListener('change', function () {
targetdate = TargetdateInput.value;
GenerateAccountFinancialReportDaily();
});
</script>
<style>
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>

View File

@@ -0,0 +1,83 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2.5rem;">Accounting Reports</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<table id="accounting_reports_list_table">
<thead>
<tr>
<th>
Report
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<style>
/* Style each row as a button */
.dataTable tbody tr {
padding: .5rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: .3rem;
}
</style>
<script>
function GenerateAccountingReportsListRow(Name) {
var parts = Name.split('-');
// Assign the parts to variables
var text = parts[0];
var value = parts[1];
return `<tr> <td><center><button class="btn-block btn-lg" onclick="ButtonGo('${value}',0);">${text}</button></center></td> </tr>`; }
async function GenerateAccountReportsListRows(responsearray) {
let newhtmltable = [];
for (let i = 0; i < responsearray.length; i++) { newhtmltable.push(GenerateAccountingReportsListRow(responsearray[i])); }
$("#accounting_reports_list_table").find("tbody").html(newhtmltable.join(''));
let reportslist = $("#accounting_reports_list_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
$('#primary-card').fadeIn(200);
}
function GenerateAccountingReportsListTable() {
AjaxDo('?AccountingReports/List', null, GenerateAccountReportsListRows, null, reqtype = 'POST');
}
GenerateAccountingReportsListTable();
</script>

View File

@@ -0,0 +1,6 @@
<script>
$('#usertypecontrol').show();
$('#userparentcontrol').show();
$('#user-create-nickname-input-group').show();
RePopulateParentList();
</script>

View File

@@ -0,0 +1,185 @@
<div class="card-body card-info" id="main-card-body" style="">
<div class="row">
<div class="col-md-18">
</div>
</div>
<br>
</div>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<div class="row">
<div class="col">
<h4 class="card-title">Transfer My Credit</h4>
</div>
<div class="col">
</div>
</div>
<div class="card-tools">
</div>
</div>
<div class="card-body " id="credit-amount-request-form">
<div class="row">
<div class="col-6">
<input class="form-control" type="number" id="transfer-credit-amount-field" placeholder="Amount to Transfer" >
</div>
<div class="col-6">
<button value="Transfer" id ="Transfer-credit-initial-button" class=" form-control btn btn-primary" onclick="CreateAndShowModalTransferMyCreditConfirmation()">Transfer Credit</button>
</div>
</div>
</div>
</div>
<script>
function CreateAndShowModalTransferMyCreditConfirmation(){
if (!$('#transfer-credit-amount-field').val()){return false;}
const modalid="modal-credit-transfer-confirmation";
const modaltitle="Continue?";
const modalbody=`
<p>You are sending credit from your account to the target User?</p>
`;
const modalfooter=`<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="TransferMyCreditNow();" id="transfer-credit-now">Continue</button>`;
CreateAndShowModal(modalid,modaltitle,modalbody,modalfooter,modalfooterclose=false,topclosebutton=true,modalbodyclass='modal-body',modalheaderclass='modal-header');
}
function SuccessCreditTransferResponse(){
const modalid="modal-credit-transfer-success";
const modaltitle="Success";
const modalbody=`
<p>Transfer has been sucessful.</p>
`;
const modalfooter=`<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>`;
CreateAndShowModal(modalid,modaltitle,modalbody,modalfooter,modalfooterclose=false,topclosebutton=true,modalbodyclass='modal-body',modalheaderclass='modal-header');
$("#modal-credit-transfer-confirmation").modal('hide');
Backkey();
}
function ErrorCreditTransferResponse(){
const modalid="modal-credit-transfer-failed";
const modaltitle="Failed";
const modalbody=`
<p>Failed to transfer credit. Try Again Later.</p>
`;
const modalfooter=`<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>`;
CreateAndShowModal(modalid,modaltitle,modalbody,modalfooter,modalfooterclose=false,topclosebutton=true,modalbodyclass='modal-body ',modalheaderclass='modal-header bg-danger');
$("#modal-credit-transfer-confirmation").modal('hide');
}
function TransferMyCreditNow(){
function TransferCreditToUserNow(response){
if (response===true){SuccessCreditTransferResponse();
}
else if (response===false){ErrorCreditTransferResponse();
}
}
AjaxDo('?user/sendmycredit', {amount: $("#transfer-credit-amount-field").val().trim(), user_target: currenttarget}, TransferCreditToUserNow, null, reqtype = 'POST');
}
$(document).ready(function() {
var currenttarget=0;
});
</script>

View File

@@ -0,0 +1,8 @@
<script>
function OpenTransferMyCreditButtonHtml(){return HomeMenuButtons('assets/transfercredit.png', 'Transfer My Credit', '','','45%', '45%','', buttononclick = "gotoPage('transfer_my_credit',currenttarget);", divclass = 'col-4','opentransfermycreditforuserbuttondiv');}
$('#user_controls').append(OpenTransferMyCreditButtonHtml());
</script>

View File

@@ -0,0 +1,267 @@
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.InitializeDynamicVariables = function () {
LoadDataPageFunc.Settings.PageName = 'Property Leads';
LoadDataPageFunc.URLs.QueryListData = '/ListLeads/ByProperty/List/data';
LoadDataPageFunc.Settings.CurrentTargetRequired = true;
LoadDataPageFunc.Settings.DefaultDatatoSend = { target: currenttarget };
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewLeadDetails', '${data}')`;
};
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let rowhtml = [];
let Status = InttoStrDetailsFuncs.Status(objectdata.Status);
const modified = objectdata.modified;
const created = formatDateTimetoReadable(objectdata.created);
const TargetViewingDate = formatDateTimetoReadable(objectdata.TargetViewingDate);
const hashkey = objectdata.hashkey;
const Referrer = objectdata.referral;
const Mobile = objectdata.mobile;
const Landline = objectdata.landline;
const Email = objectdata.email;
let PushRowifnotFalse = function (variablevalue, label) {
if (variablevalue !== false) {
rowhtml.push(dualcolrow(label, variablevalue, rowclass = ''));
}
};
PushRowifnotFalse(modified, 'Last Activity');
PushRowifnotFalse(created, 'Created');
PushRowifnotFalse(Status, 'Status');
PushRowifnotFalse(TargetViewingDate, 'Target Viewing Date');
PushRowifnotFalse(Referrer, 'Referrer');
PushRowifnotFalse(Mobile, 'Mobile');
PushRowifnotFalse(Landline, 'Landline');
PushRowifnotFalse(Email, 'Email');
rowhtml.push('<div id="' + LoadDataPageFunc.ids.HashKeyContainer + '-' + rownum + '" style="display:none;">' + hashkey + '</div>');
rowhtml.push(row(col('<br>' + buttonprimary('View', '', LoadDataPageFunc.Settings.ViewDetailsOnclick(hashkey), '-12', 'ListCardGoRow-' + rownum))));
let FinalBody = rowhtml.join('');
return createCard(objectdata.fullname, cardid = 'ListRowCard-' + rownum, created, cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow');
};
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage = 'No Leads';
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 = 'ListContainer';
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.NewRow = function (DetailsObject, rownum) {
};
LoadDataPageFunc.ClearSearch = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).val('');
$('#' + LoadDataPageFunc.ids.SearchInput).trigger('keyup');
};
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(LoadDataPageFunc.Settings.DefaultDatatoSend)
.fromVarCache(LoadDataPageFunc.Settings.fromVarCache)
.success((response) => {
if (!response) {
$('#card-body-MAINCARDBODY_LIST').html('<center>No Leads Yet</center>');
return null;
}
let List = response.List;
//LeadsList.reverse();
List = LoadDataPageFunc.Settings.SortArray(List);
let newhtmlrows = ''; let htmlarrayrows = [];
const count = List.length;
let hashkey;
for (let i = 0; i < count; i++) {
let hashkey = List[i]['hashkey'];
htmlarrayrows.push(LoadDataPageFunc.NewRow(List[i], i) + '<br>');
}
newhtmlrows = htmlarrayrows.join('');
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.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();
if (title.includes(searchTerm) || cols.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('Leads', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
$(document).ready(function () {
LoadDataPageFunc.InitializeDynamicVariables();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
if (!LoadDataPageFunc.main()) { return false; }
LoadDataPageFunc.populatelist();
LoadDataPageFunc.SearchKeyUPListPage();
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
});
</script>

View File

@@ -0,0 +1,152 @@
<div id='ListLeadsMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.newleadrow = function (hashkey, LeadName, DateCreated, DateModified, Referrer, TargetViewingDate, Status, Mobile, Landline, Email, TargetProperty,rownum) {
let leadrowhtml=[];
Status = InttoStrDetailsFuncs.Status(Status);
leadrowhtml.push(dualcolrow('Last Activity', formatDateTimetoReadable(DateModified), rowclass = ''));
leadrowhtml.push(dualcolrow('Status', Status, rowclass = ''));
leadrowhtml.push(dualcolrow('Referrer', Referrer, rowclass = ''));
leadrowhtml.push(dualcolrow('Target Property', TargetProperty, rowclass = ''));
leadrowhtml.push(dualcolrow('Target Viewing Date', formatDateTimetoReadable(TargetViewingDate), rowclass = ''));
leadrowhtml.push(dualcolrow('Mobile', Mobile, rowclass = ''));
leadrowhtml.push(dualcolrow('Landline', Landline || '', rowclass = ''));
leadrowhtml.push(dualcolrow('Email', Email, rowclass = ''));
leadrowhtml.push('<div id="LeadsListRowCardHash-'+rownum+'" style="display:none;">'+hashkey+'</div>');
leadrowhtml.push(row(col('<br>'+buttonprimary('View Details', '', `ButtonGo('ViewLeadDetails', '${hashkey}')`, '-12','ListLeadGoRow-'+rownum))));
let FinalBody = leadrowhtml.join('');
return createCard(LeadName, cardid = 'LeadRowCard-'+rownum, formatDateTimetoReadable(DateCreated), cardbodyid = '', FinalBody, cardbodyclassadd = 'ListLeadRow');
};
LoadDataPageFunc.main = function () {
const searchcard = UIInputGroup('Search', 'text', 'ListLeads_Search','',classs='',span='','/assets/clear.png');
let LeadsListContainer = UICardSimple('', 'Loading Please Wait...', 'LeadsListContainer');
LeadsListContainer = '<div id="LeadsListContainer"><center>Loading Please Wait...</center></div>';
const FinalInnerHTML = searchcard + LeadsListContainer;
const MainCard = UICardSimple('Leads', FinalInnerHTML,'MAINCARDBODY_LEADSLIST');
$('#ListLeadsMainContainer').html(MainCard);
};
LoadDataPageFunc.ClearSearch=function(){
$('#ListLeads_Search').val('');
$('#ListLeads_Search').trigger('keyup');
};
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 = 'LeadsListRowCardHash-' + 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 });
$('#LeadsListContainer .card').each(function() {
observer.observe(this);
});
};
LoadDataPageFunc.populateleadlist = function () {
let request = new RequestData(true);
request
.url('/ListLeads/List/data')
.type('POST')
.data(null)
.fromVarCache(true)
.success((response) => {
if ($('#card-body-MAINCARDBODY_LEADSLIST').length ===0){return false;}
if(!response){
$('#card-body-MAINCARDBODY_LEADSLIST').html('No Leads');
return;
}
const LeadsList = response.List;
//LeadsList.reverse();
LeadsList.sort((a, b) => new Date(b.created) - new Date(a.created));
let newhtmlrows = '';let htmlarrayrows=[];
const count = LeadsList.length;
let hashkey;
for (let i = 0; i < count; i++) {
let hashkey =LeadsList[i]['hashkey'];
htmlarrayrows.push(LoadDataPageFunc.newleadrow(hashkey,LeadsList[i]['fullname'],LeadsList[i]['created'],
LeadsList[i]['modified'],LeadsList[i]['referral'],LeadsList[i]['target_viewing_date'],LeadsList[i]['status'],
LeadsList[i]['mobile'],LeadsList[i]['landline'],LeadsList[i]['email'],LeadsList[i]['property_name'],i));
}
newhtmlrows = htmlarrayrows.join('');
$('#LeadsListContainer').html(newhtmlrows);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.error((err) => {
console.error(err);
})
.go();
};
function SearchKeyUPListLeadsPage(){
$('#ListLeads_Search').on('keyup', function() {
let searchTerm = $(this).val().toLowerCase();
$('#LeadsListContainer .card').each(function() {
let title = $(this).find('.card-title').text().toLowerCase();
let cols = $(this).find('.col').text().toLowerCase();
if (title.includes(searchTerm) || cols.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
}
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populateleadlist();
changeTopbarTitle('Leads');
SearchKeyUPListLeadsPage();
$('#imgspanListLeads_Search').attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
});
</script>

View File

@@ -0,0 +1,267 @@
<style>
.ListPropertyRowCard {
margin-bottom: 20px; /* Adjust this value to increase or decrease space between cards */
}
</style>
<div id='ListPropertiesMainContainer'>
</div>
<br><br><br>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.newpropertyrow = function (objrow, rownum) {
let rows = [];
let rowcoldetail = '';
let firstimagesrc = '/assets/no-image.png';
const imgwidth = '200px'; const imgheight = "200px";
const hash = objrow.hashkey || false;
if (!objrow || !hash) { rowcoldetail = 'No Data'; return createCard('Unknown', cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', rowcoldetail, cardbodyclassadd = 'ListPropertyRow',true,'ListPropertyRowCard'); }
let created = objrow.created || false;
let modified = objrow.modified || false;
let name = objrow.name || false;
let description = objrow.description || false;
let status = objrow.status || false;
let remarks = objrow.remarks || false;
let referralid = objrow.referralid || false;
let createdby = objrow.createdby || false;
let category = objrow.category || '';
let subcategory = objrow.subcategory || '';
let photourl = objrow.photourl || false;
let sqm = objrow.sqm || false;
let bedrooms = objrow.bedrooms || false;
let rooms = objrow.rooms || false;
let toilet = objrow.toilet || false;
let kitchen = objrow.kitchen || false;
let floors = objrow.floors || false;
let price = objrow.price || false;
let specs = objrow.specs || false;
let location = objrow.location || false
status = InttoStrDetailsFuncs.PropertyStatus(status);
modified = formatDateTimetoReadable(modified);
created = formatDateTimetoReadable(created);
let photobinarystring = '';
let base64string = '';
let blob;
try { photourl = JSON.parse(photourl); } catch (e) { photourl = photourl; }
if (photourl) { if (Array.isArray(photourl)) { photourl = photourl[0]; } else { } }
let photohash =photourl;
if (photourl) { photourl = '/RequestData/File/' + photourl; }
/*
photobinarystring = reqcacheload(photourl);
if (photobinarystring) {
blob = binaryStringToBlob(photobinarystring);
console.log('blob ',blob);
if (blob){
photourl = CreateObjectURLfrombinaryStringforIMGUse(photobinarystring);
console.log(photourl);
}
}
*/
let photoelementID='PropertyRowCard-Image-'+ rownum;
photoblob = reqcacheload(photourl);
if (photoblob) {
photourl = URL.createObjectURL(photoblob);
}else{
LoadAndCreateURLfromFileHash(photohash).then(bloburl => {
$('#'+photoelementID).attr('src', bloburl);
});
}
rows.push(`<div class="col-12"><center><a href="javascript:void(0);return;" onclick="ButtonGo('${'ViewPropertyDetails'}', '${hash}')"><img id="${photoelementID}" src="` + photourl + '" style="width:' + imgwidth + '; height:' + imgheight + ';"></a></center>');
rows.push('<br>');
rows.push('<div class="col">');
if (modified !== false) {
rows.push(dualcolrow('Last Activity', modified, rowclass = ''));
}
if (status !== false) {
rows.push(dualcolrow('Status', status, rowclass = ''));
}
if (location !== false) {
rows.push(dualcolrow('Location', location, rowclass = ''));
}
if (createdby !== false) {
rows.push(dualcolrow('Filled By', createdby, rowclass = ''));
}
if (subcategory !== false) {
rows.push(dualcolrow(category, subcategory, rowclass = ''));
}
if (sqm !== false) {
rows.push(dualcolrow('Size', sqm + ' sqm', rowclass = ''));
}
if (bedrooms !== false) {
rows.push(dualcolrow('Bedrooms', bedrooms, rowclass = ''));
}
if (rooms !== false) {
rows.push(dualcolrow('Rooms', rooms, rowclass = ''));
}
if (toilet !== false) {
rows.push(dualcolrow('Toilet', toilet, rowclass = ''));
}
if (kitchen !== false) {
rows.push(dualcolrow('Kitchen', kitchen));
}
if (floors !== false) {
rows.push(dualcolrow('Floors', floors));
}
if (price !== false) {
rows.push(dualcolrow('Price', price));
}
rows.push('<div id="PropertyListRowCardHash-' + rownum + '" style="display:none;">' + hash + '</div>');
if (description !== false) {
rows.push('<br><div class="row">' + col('<center>Description</center>', '-12'));
rows.push(col('<textarea>' + description + '</textarea>', '-12') + '</div>');
}
rows.push('</div></div>');
rows.push(row(col('<br>' + buttonprimary('View Details', '', `ButtonGo('ViewPropertyDetails', '${hash}')`, '-12', 'ListPropertyGoRow-' + rownum))));
let FinalBody = rows.join('');
return createCard(name, cardid = 'PropertyRowCard-' + rownum, created, cardbodyid = '', FinalBody, cardbodyclassadd = 'ListPropertyRow','',false,'ListPropertyRowCard');
};
LoadDataPageFunc.main = function () {
const searchcard = UIInputGroup('Search', 'text', 'ListProperty_Search', '', classs = '', span = '', '/assets/clear.png');
// let PropertyListContainer = UICardSimple('', 'Loading Please Wait...', 'PropertyListContainer');
let PropertyListContainer = '<div id="PropertyListContainer"><center>Loading Please Wait...</center></div>';
const FinalInnerHTML = searchcard + PropertyListContainer;
const MainCard = UICardSimple('Properties', FinalInnerHTML, 'MAINCARDBODY_PROPERTYLIST');
$('#ListPropertiesMainContainer').html(MainCard);
};
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 = 'PropertyListRowCardHash-' + variablePart;
hashkey = $('#' + hashKeyDivId).text();
if (hashkey) {
request.url('/ViewProperty/Details/data').success((response) => {
}).data({ target: hashkey }).fromVarCache(true).type('POST').go();
}
hashkey = '';
}
});
}, { threshold: 0.1 });
$('#PropertyListContainer .card').each(function () {
observer.observe(this);
});
};
LoadDataPageFunc.populatepropertylist = function () {
let request = new RequestData(true);
request
.url('/ListProperty/List/data')
.type('POST')
.data(null)
.fromVarCache(true)
.success((response) => {
if ($('#card-body-MAINCARDBODY_PROPERTYLIST').length === 0) { return false; }
if (!response) {
$('#card-body-MAINCARDBODY_PROPERTYLIST').html('No Properties');
return;
}
const PropertyList = response.List;
//PropertyList.reverse();
PropertyList.sort((a, b) => new Date(b.created) - new Date(a.created));
let newhtmlrows = ''; let arrayrows = [];
const count = PropertyList.length;
for (let i = 0; i < count; i++) {
arrayrows.push(LoadDataPageFunc.newpropertyrow(PropertyList[i], i));
}
newhtmlrows = arrayrows.join('');
$('#PropertyListContainer').html(newhtmlrows);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.error((err) => {
console.error(err);
})
.go();
};
function SearchKeyUPListPropertyPage() {
$('#ListProperty_Search').on('keyup', function () {
let searchTerm = $(this).val().toLowerCase();
$('#PropertyListContainer .card').each(function () {
let title = $(this).find('.card-title').text().toLowerCase();
let cols = $(this).find('.col').text().toLowerCase();
if (title.includes(searchTerm) || cols.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
}
LoadDataPageFunc.ClearSearch = function () {
$('#ListProperty_Search').val('');
$('#ListProperty_Search').trigger('keyup');
};
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populatepropertylist();
changeTopbarTitle('Properties');
SearchKeyUPListPropertyPage();
$('#imgspanListProperty_Search').attr('onclick', 'LoadDataPageFunc.ClearSearch();');
});
</script>

View File

@@ -0,0 +1,237 @@
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.InitializeDynamicVariables = function () {
LoadDataPageFunc.URLs.QueryListData = '/ReferralCode/List/data';
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `Copy', '${data}')`;
};
LoadDataPageFunc.Settings.CurrentTargetRequired = false;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let rowhtml = [];
const created = formatDateTimetoReadable(dateobjectdata.created) || '';
const modified = formatDateTimetoReadable(dateobjectdata.modified) || '';
const views = objectdata.referral_hits;
const leads_submitted = objectdata.referral_submit;
const referralCode = objectdata.referral_code;
const fullurl = window.location.origin+'/r/'+referralCode;
rowhtml.push(dualcolrow('Status', Status, rowclass = ''));
rowhtml.push(dualcolrow('Target Viewing Date', TargetViewingDate, rowclass = ''));
rowhtml.push('<div id="' + LoadDataPageFunc.ids.HashKeyContainer + '-' + rownum + '" style="display:none;">' + hashkey + '</div>');
rowhtml.push(row(col('<br>' + buttonprimary('View', '', LoadDataPageFunc.Settings.ViewDetailsOnclick(hashkey), '-12', 'ListCardGoRow-' + rownum))));
let FinalBody = rowhtml.join('');
return createCard(objectdata.fullname, cardid = 'ListRowCard-' + rownum, created, cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow');
};
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.PageName = 'My Referral URLs';
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 = 'ListContainer';
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);
}
// LoadAndCreateURLfromFileHash(FileListHash,fromvarcache=true);
return photourl;
}
LoadDataPageFunc.NewRow = function (DetailsObject, rownum) {
};
LoadDataPageFunc.ClearSearch = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).val('');
$('#' + LoadDataPageFunc.ids.SearchInput).trigger('keyup');
};
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(LoadDataPageFunc.Settings.fromVarCache)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response.List;
//LeadsList.reverse();
List = LoadDataPageFunc.Settings.SortArray(List);
let newhtmlrows = ''; let htmlarrayrows = [];
const count = List.length;
let hashkey;
for (let i = 0; i < count; i++) {
let hashkey = List[i]['hashkey'];
htmlarrayrows.push(LoadDataPageFunc.NewRow(List[i], i));
}
newhtmlrows = htmlarrayrows.join('');
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
// LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.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();
if (title.includes(searchTerm) || cols.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('Leads', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
$(document).ready(function () {
LoadDataPageFunc.InitializeDynamicVariables();
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
LoadDataPageFunc.SearchKeyUPListPage();
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
});
</script>

View File

@@ -0,0 +1,75 @@
<div id='NewLeadsFormContainer'>
</div>
<br><br><br>
<script>
$('#usernumber').keyup(function () {
checkifUserExists();
SRegistrationValidateALLinputs();
});
function NewLeadsvalidateForm() {
let fullname = $('#NewLeadsFullname').val();
let mobile = $('#NewLeadsmobile').val();
let landline = $('#NewLeadslandline').val();
let email = $('#NewLeadsemail').val();
let preferreddate = $('#NewLeadspreferreddate').val();
let preferredsite = $('#NewLeadsPreferredSite').val();
if (!fullname || !mobile || !email) { return false; }
if (!hasValidMobileFormat(mobile)) { return false; }
if (!isValidEmail(email)) { return false; }
return { fullname: fullname, mobile: mobile, landline: landline, email: email, preferred_date: preferreddate, preferred_site: preferredsite };
}
function TrytoSubmitNewLead() {
let ValidateData = NewLeadsvalidateForm();
if (!ValidateData) {
ModalQuickDismiss('Invalid/Incomplete', 'The following are required<br><br>Fullname<br>11 Digits Mobile Number<br>Correct Email<br><br>Please Input the following properly if not done so. Thank you.');
return false;
}
console.log(ValidateData);
request.type('POST').data(ValidateData).url('/NewLeads/Form/submit').fromVarCache(false).success((response) => {
console.log(response);
if (response['success'] === true) {
ModalQuickDismiss('Success', 'New Lead Created', 'NewLeadsModalSuccess', modaltohide = '', function () {
ButtonGo('ViewLeadDetails', response['data']);
});
}
else if (response['success'] === true) {
ModalQuickDismiss('Error', 'Unable to Submit. Try Again Later', 'NewPropertysModalError');
}
}).error((errorstring) => {
ModalQuickDismiss('Error', 'An Error Occured<br>' + errorstring + '<br><br>Please Try Again Later');
}).go()
}
if (typeof request === 'undefined') {
var request = new RequestData(false);
var requestWHash = new RequestData(true);
}
$(document).ready(function () {
requestWHash.type('POST').url('/NewLeads/Form/PreferredSitesOption').fromVarCache(true).success((response) => {
UIReplaceCurrentOptionsSelect('NewLeadsPreferredSite', response);
}).go();
});
ReusableUIElements.NewLeadsGenerateUI();
changeTopbarTitle('New Lead');
</script>

View File

@@ -0,0 +1,166 @@
<div id='NewPropertyFormContainer'>
</div>
<br><br><br>
<script>
LoadDataPageFunc.PageTitle = 'New Property';
InitDataPageFuncOBJ();
Target_Uploaded_Files = [];
LoadDataPageFunc = {};
LoadDataPageFunc.NewProperty = {};
LoadDataPageFunc.ids = {};
var currentDropzone;
var ongoingUploads = 0;
var yesnomodalDecision = null;
LoadDataPageFunc.NewPropertyValidate = function () {
let name = $('#NewPropertyPropertyName').val();
let description = $('#NewPropertyPropertyDescription').val();
let status = $('#NewPropertyStatus').val() || 0;
let remarks = $('#NewPropertyRemarks').val();
let location = $('#NewPropertyLocation').val();
let category = $('#NewPropertyCategory').val();
let subcategory = $('#NewPropertySubCategory').val();
let sqm = $('#NewPropertysqm').val();
let bedrooms = $('#NewPropertyBedrooms').val();
let rooms = $('#NewPropertyRooms').val();
let toilet = $('#NewPropertyToilet').val();
let kitchen = $('#NewPropertyKitchen').val();
let floors = $('#NewPropertyFloors').val();
let price = $('#NewPropertyPrice').val();
if (!name || !description || !location || !sqm || !Target_Uploaded_Files.length) { return false; }
return { name: name, description: description, status: status, remarks: remarks, location: location, category: category, subcategory: subcategory, sqm: sqm, bedrooms: bedrooms, rooms: rooms, toilet: toilet, kitchen: kitchen, floors: floors, photourl: JSON.stringify(Target_Uploaded_Files),price:price };
};
LoadDataPageFunc.UpdateModalDecision=function(type){
$(document).ready(function () {
yesnomodalDecision = type;
modalhide("ModalYesNoWaitForFinishedUpload");
$("#ModalYesNoWaitForFinishedUpload").remove();
});
};
LoadDataPageFunc.TrytoSubmitNewProperty = function () {
let ValidateData = LoadDataPageFunc.NewPropertyValidate();
if (!ValidateData) {
$('#IncompleteInputModal').remove();
ModalQuickDismiss('Invalid/Incomplete', 'The following are required<br><br>Property Name<br>Description<br>Location<br>Size in SQM<br>At Least One Photo<br><br>Please Input the following properly if not done so. Thank you.','IncompleteInputModal');
return false;
}
if (ongoingUploads) {
yesnomodalDecision = null;
$('#ModalYesNoWaitForFinishedUpload').remove();
ModalYesNo('Photo Upload in Progress!', 'Some Files are not finished uploading.', 'LoadDataPageFunc.UpdateModalDecision(1);', 'Continue', 'LoadDataPageFunc.UpdateModalDecision(-1);', 'Wait', modalid = 'ModalYesNoWaitForFinishedUpload', modaltohide = '', functiontodo = '', conditiontrue = true);
if (yesnomodalDecision === -1 || yesnomodalDecision === null) {
hidemodal(modalid);
$('#'+modalid).remove();
return false;
}
}
request.type('POST').data(ValidateData).url('/NewProperty/Form/submit').fromVarCache(false).success((response) => {
if (response['success'] === true) {
ModalQuickDismiss('Success', 'New Property Created', 'NewPropertysModalSuccess', modaltohide = '', function () {
ButtonGo('ViewPropertyDetails', response['data']);
});
} else if (response['success'] === true) {
ModalQuickDismiss('Error', 'Unable to Submit. <br><br>' + response['error'], 'NewPropertysModalError');
}
}).error((errorstring) => {
ModalQuickDismiss('Error', 'An Error Occured<br>' + errorstring + '<br><br>Please Try Again Later');
}).go()
};
LoadDataPageFunc.ReplaceSelectOptionsfromServer = function (url, id, fromVarCache = true, type = 'POST') {
if (!url || !id) { return false; }
requestWHash.type(type).url(url).fromVarCache(fromVarCache).success((response) => {
UIReplaceCurrentOptionsSelect(id, response);
}).go();
};
if (typeof request === 'undefined') {
var request = new RequestData(false);
var requestWHash = new RequestData(true);
}
LoadDataPageFunc.ids.ClearPhotosButton = 'newpropertydropzoneclearbutton';
LoadDataPageFunc.ShowPhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).show();
};
LoadDataPageFunc.HidePhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
};
LoadDataPageFunc.NewProperty.InitializePhotoDropZone = function () {
Target_Uploaded_Files = [];
currentDropzone = DropZoneFunc.InitializeDropZone('/File/Upload/Property', (response) => {
if (response.length === 72) {
Target_Uploaded_Files.push(response);
LoadDataPageFunc.ShowPhotoClearButton();
} else {
currentDropzone.removeFile(currentDropzone.files[currentDropzone.files.length - 2]);
}
}, dropzoneid = 'newpropertydropzonephoto', DropZoneFunc.AcceptedFilesString.images, 'file', maxfilesize = 100);
};
LoadDataPageFunc.ClearPhotos = function () {
DropZoneFunc.ClearDropzoneUpload();
LoadDataPageFunc.HidePhotoClearButton();
};
LoadDataPageFunc.FormLoad = function () {
ReusableUIElements.NewPropertyGenerateUI();
};
LoadDataPageFunc.Initialization = function () {
LoadDataPageFunc.FormLoad();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
$(document).ready(function () {
LoadDataPageFunc.Initialization();
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).off('click').on('click', function () {
LoadDataPageFunc.ClearPhotos();
});
Preloaders.Datalist.NewPropertyCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertyCategory', 'NewPropertyCategoryDataList', replace = true); });
Preloaders.Datalist.NewPropertySubCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertySubCategory', 'NewPropertySubCategoryDataList', replace = true); });
LoadDataPageFunc.NewProperty.InitializePhotoDropZone();
DropZoneFunc.ClearDropzoneUpload();
ReqCachetoDatalist('/Datalist/NewPropertySubCategory', 'NewPropertySubCategory', replace = true);
ReqCachetoDatalist('/Datalist/NewPropertyLocation', 'NewPropertyLocationDataList', replace = true);
});
</script>

View File

@@ -0,0 +1,74 @@
<br><br>
<div id="viewContainer">
<center>Loading</center>
</div>
<script>
Target_Uploaded_Files = [];
if(typeof LoadDataPageFunc==='undefined'){
LoadDataPageFunc = {};
}
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.PageTitle = 'Photo';
LoadDataPageFunc.currentTargetPage = 'PhotoViewer';
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.MainPhotoFileListHASH = currenttarget;
LoadDataPageFunc.URLs.TargetURL = currenttarget;
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.ViewContainer = "viewContainer";
LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
if (!istrue) { return false; }
Preloaders.ViewPropertyDetailsData(currenttarget, false,
function (response) {
ReloadPage();
}
);
};
LoadDataPageFunc.UpdateMainContainer=function(html){
$('#'+LoadDataPageFunc.ids.ViewContainer).html(html);
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.RequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.LoadMainDetails = {};
LoadDataPageFunc.LoadMainDetails.LoadNow = function () {
LoadAndCreateURLfromFileHash(currenttarget).then(bloburl => {
const imgelement = `<img src ="${bloburl}" style="">`;
LoadDataPageFunc.UpdateMainContainer(imgelement);
});
};
LoadDataPageFunc.main = function () {
LoadDataPageFunc.LoadMainDetails.LoadNow();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

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>

View File

@@ -0,0 +1,660 @@
<br><br>
<div id="viewContainer">
</div>
<script>$(".bottom-navigation-bar").remove(); $(".header").remove();</script>
<script>
$$ = {};
$$.UI = {};
$$.UI.Table = {};
$$.UI.Table.CreateTable = function (id, theadinnerhtml, bodyinnerhtml) { return CreateTable(id, theadinnerhtml, bodyinnerhtml); };
$$.UI.Table.GenerateTheadFromArraySimple = function (array) { return GenerateTheadFromArraySimple(array); };
$$.UI.Table.GenerateTableRowFromArraySimple = function (array) { return GenerateTableRowFromArraySimple(array); };
$$.UI.ResetBrowserAndCache = function () { return ResetBrowserAndCache(); };
$$.UI.formatCurrency = function (number, withdecimal = true) { return formatCurrency(number, withdecimal); };
$$.UI.getDateInGMT8 = function () { return getDateInGMT8(); };
$$.UI.RunFunctiononMutation = function (targetidToMonitor, callbackfunction) { return RunFunctiononMutation(targetidToMonitor, callbackfunction); };
$$.UI.Element = {};
$$.UI.Element.appendtobody = function (string) { return appendtobody(string); };
$$.UI.Element.Exists = function (ElementIDtext) { ElementExists(ElementIDtext); };
$$.UI.Element.RemovebyID = function (idstring) { return removeelementbyID(idstring); };
$$.UI.Element.DeleteById = function (id) { return DeleteElementById(id); }
$$.UI.Element.getHTML = function (idetext) { return getElementhtml(idtext); };
$$.UI.Element.setHTML = function (idetext, html) { return setElementhtml(idtext, html); };
$$.UI.Element.getValue = function (idetext) { return getElementvalue(idtext); };
$$.UI.Element.setValue = function (idetext,) { return setElementvalue(idtext, value); };
$$.UI.Validate = {};
$$.UI.Validate.isValidEmail = function (email) { return isValidEmail(email); };
$$.UI.Validate.hasValidMobileFormat = function (usernumber) { return hasValidMobileFormat(usernumber); };
$$.UI.Modal = {};
$$.UI.Modal.Create = function (modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return createmodal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.Show = function (idtxt) { return modalshow(idtxt); };
$$.UI.Modal.Hide = function (idtxt) { return modalhide(); };
$$.UI.Modal.CreateAndShow = function (modalid, modaltitle, modalbody, modalfooter = '', modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.ModalQuickDismiss = function (modaltitle, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true) { return ModalQuickDismiss(modaltitle, modalbody, modalid, modaltohide, functiontodo, conditiontrue) };
$$.UI.Modal.ModalContinueCancel = function (modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext = 'Cancel', continuebuttontext = 'Continue', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning') { return ModalContinueCancel(modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext, continuebuttontext, continuebuttoncss, cancelbuttoncss); };
$$.UI.Modal.hide = function (modalid) { return hidemodal(modalid); };
$$.UI.Modal.show = function (modalid) { return showmodal(modalid); };
$$.UI.col = function (content = '', additionalclass = '') { return col(content, additionalclass); };
$$.UI.row = function (content = '', additionalclass = '', hidden = false, style = '') { return row(content, additionalclass, hidden, style); };
$$.UI.dualcolrow = function (colcontent1, colcontent2, rowclass = '', hidden = false, style = '') { return dualcolrow(colcontent1, colcontent2, rowclass, hidden, style); };
$$.UI.Button = {};
$$.UI.Button.Default = function (content, value = '', onclick = '', idtext = '', setclass = '', addtionaldata = '') { return button(content, value, onclick, idtext, setclass, addtionaldata); };
$$.UI.Button.Warning = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonwarning(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Danger = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttondanger(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Primary = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonprimary(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.HomeMenuButtons = function (buttonicon, buttonText, buttonGo, buttonVariabletoPass = '', iconwidth = '', iconheight = '', buttonstyle = '', buttononclick = '', divclass = '', divid = '', buttonid = '', textclass = '') { return HomeMenuButtons(buttonicon, buttonText, buttonGo, buttonVariabletoPass, iconwidth, iconheight, buttonstyle, buttononclick, divclass, divid, buttonid, textclass); };
$$.UI.Input = {};
$$.UI.Input.textInput = function (idtext = '', setclass = '', required = '', placeholder = '', value = '') { return textinput(idtext, setclass, required, placeholder, value); };
$$.UI.Input.textFormControl = function (idtext = '', addclass = '', required = '', placeholder = '', value = '') { return textformcontrol(idtext, addclass, required, placeholder, value); };
$$.UI.Card = {};
$$.UI.Card.Create = function (cardtitle = '', cardid = '', cardtools = '', cardbodyid = '', cardbodytext = '', cardbodyclassadd = '', maincardstyle = '', titlecardhide = false) { return createCard(cardtitle, cardid, cardtools, cardbodyid, cardbodytext, cardbodyclassadd, maincardstyle, titlecardhide); };
$$.UI.Card.Simple = function (title = '', text = '', id = '') { return CreateCardSimple(title, text, id); };
$$.UIalt = {};
$$.UIalt.hrefonclickButtonGO = function (pagename, pagedatastring = '') { return hrefonclickButtonGO(pagename, pagedatastring); };
$$.UIalt.generateHTMLfromarray = function (prepend, append, array, func) { return generateHTMLfromarray(prepend, append, array, func); };
$$.UIalt.imgiconuserdefault = function (imgsrc, imgwidth = '', imgheight = '', id = '') { return imgiconuserdefault(imgsrc, imgwidth, imgheight, id); };
$$.UIalt.UICardStats = {};
$$.UIalt.UICardStats.UICardStatsDetails = function (Title = '', number = 0, Unit = '', leftORright = 'left', numberid = '') { return UICardStatsDetails(Title, number, Unit, leftORright, numberid); };
$$.UIalt.UICardStats.UIStatsDetailsArray = function (statsarray) { return UIStatsDetailsArray(statsarray); };
$$.UIalt.BalanceCard = {};
$$.UIalt.BalanceCard.UIBalance_WrapperfromArray = function (statsarray) { return UIBalance_WrapperfromArray(statsarray); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item = function (maintitle = '', onclickstring = '', imgsrc = '', href = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '', imgwidth = '', imgheight = '') { return UIBalance_Wrapper_WalletFooter_Item(maintitle, onclickstring, imgsrc, href, subtitleline1, subtitleline2, subtitleline3, subtitleline4, imgwidth, imgheight); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item_ButtonGO = function (maintitle, pagename, pagestring = '', iconclass = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '') { return UIBalance_Wrapper_WalletFooter_Item_ButtonGO(maintitle, pagename, pagestring, iconclass, subtitleline1, subtitleline2, subtitleline3, subtitleline4); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_ARRAY = function (balancewrapper_item_array) { return UIBalance_Wrapper_WalletFooter_ARRAY(balancewrapper_item_array); };
$$.UIalt.BalanceCard.UIcreateBalanceBoxfromArray = function (statsarray, balancewrapper_item_array, style = 'border: solid 3px #000d88;') { return UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array, style); };
$$.UIalt.Services = {};
$$.UIalt.Services.Button = function (imgiconsrc, title = '', onclick = '', href = '', bgcolor8 = false) { return UIServices_Button(imgiconsrc, title, onclick, href, bgcolor8); };
$$.UIalt.Services.Button_GOTOPAGE = function (imgiconsrc, title, pagename, pagedatastring = '') { return UIServices_Button_GOTOPAGE(imgiconsrc, title, pagename, pagedatastring); };
$$.UIalt.Services.FullDIV_GOTOPAGE_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_GOTOPAGE_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Services.FullDIV_ONCLICK_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_ONCLICK_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Sidetext = {};
$$.UIalt.Sidetext.UISideText_DualColumnButton = function (text, pagename, pagedatastring = '', imgsrc = '', imgwidth = '', imgheight = '') { return UISideText_DualColumnButton(text, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.Sidetext.UISideText_DualColumnButton_Array = function (sidetext_button_dualcolumn_array) { return UISideText_DualColumnButton_Array(sidetext_button_dualcolumn_array); };
$$.UIalt.UICardSimple = function (title, text = '', id = '') { return UICardSimple(title, text, id); };
$$.UIalt.RecentSearchBar = {};
$$.UIalt.RecentSearchBar.SearchBar = function (searchplaceholdertext, classtosearch, id, imgsrclefticon = '', imgsrcrighticon = '', imgwidth = '', imgheight = '') { return UIRecentSearchBar(searchplaceholdertext, classtosearch, id, imgsrclefticon, imgsrcrighticon, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO = function (title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIRecentSearchable_Button_GO(title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO_ARRAY = function (title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata = '', viewalltext = '') { return UIRecentSearchable_Button_GO_ARRAY(title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata, viewalltext); };
$$.UIalt.UIListArrowButton_GO = function (title, subtitle, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIListArrowButton_GO(title, subtitle, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.SearchBox_with_BUTTONS_FULL = function (title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY = '', viewallpagetarget, viewallpagedata = '', viewalltext = '', classtosearch = '', searchid = '', searchplaceholdertext = '', searchlefticon = '', searchrighticon = '', imgwidth = '', imgheight = '') { return UISearchBox_with_BUTTONS_FULL(title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY, viewallpagetarget, viewallpagedata, viewalltext, classtosearch, searchid, searchplaceholdertext, searchlefticon, searchrighticon, imgwidth, imgheight); };
$$.UIalt.Input = {};
$$.UIalt.Input.InputGroupCore = function (innerhtml = '', label = '', inputgroupid = '') { return UIinputgroupcore(innerhtml, label, inputgroupid); };
$$.UIalt.Input.InputGroup = function (placeholder, type, id, label = '', classinput = '', spanclass = '', imginsteadofspan = '', required = false, textvalue = '') { return UIInputGroup(placeholder, type, id, label, classinput, spanclass, imginsteadofspan, required, textvalue); };
$$.UIalt.Input.InputGroupSelect = function (id = '', label = '', optionsarray = '', spanclass = '', imginsteadofspan = '', selectedvalue = '') { return UIInputGroupSelect(id, label, optionsarray, spanclass, imginsteadofspan, selectedvalue); };
$$.UIalt.Input.InputGroupDatePicker = function () { return UIInputGroupDatePicker(); };
$$.UIalt.Input.ArraytoOptionforSelect = function (array, selectedvalue = '') { return UIArraytoOptionforSelect(array, selectedvalue); };
$$.UIalt.Input.ReplaceCurrentOptionsSelect = function (selectid, optionsarray, selectedvalue = '') { return UIReplaceCurrentOptionsSelect(selectid, optionsarray, selectedvalue); };
$$.UIalt.Input.InputGroupButton = function (buttontext, buttonclass = '', buttonid = '', onclick = '', buttonstyle = '') { return UIInputGroupButton(buttontext, buttonclass, buttonid, onclick, buttonstyle); };
$$.UIalt.UISetDarkMode = function () { return UISetDarkMode(); };
$$.UIalt.UIUpdateBodyHTML = function (html = '') { return UIUpdateBodyHTML(html); };
$$.UIalt.changeTopbarTitle = function (title) { return changeTopbarTitle(title); };
$$.StatusIntToString = function (Status) { return InttoStrDetailsFuncs.Status(Status); };
$$.StatusPropertiesIntToString = function (Status) { return InttoStrDetailsFuncs.PropertyStatus(Status); };
</script>
<script>
Target_Uploaded_Files = [];
LoadDataPageFunc = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.PageTitle = 'Property Details';
LoadDataPageFunc.currentTargetPage = 'ReferProperty';
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.MainData = '/View/Property/Details';
LoadDataPageFunc.URLs.AddLog = '/View/Property/Details/Logs/Add';
LoadDataPageFunc.URLs.SubmitEdit = '/View/Property/Details/Edit/Submit';
LoadDataPageFunc.URLs.ChangeStatus = '/View/Property/Details/ChangeStatus'
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.ViewPropertyContainer = "viewContainer";
LoadDataPageFunc.ids.ViewDetailsLogsContainer = 'ViewDetailsLogsContainer';
LoadDataPageFunc.ids.ViewPropertyCard = 'ViewPropertyCard';
LoadDataPageFunc.ids.ViewPropertyDetailsCardBody = 'ViewPropertyDetailsCardBody';
LoadDataPageFunc.ids.PreviousLogsPage = 'prevBtnLogsPropertyDetailsPage';
LoadDataPageFunc.ids.NextLogsPage = 'nextBtnLogsPropertyDetailsPage';
LoadDataPageFunc.ids.ChangeStatus_Select = 'ViewPropertyDetails_ChangeStatus_Select';
LoadDataPageFunc.onclicks = {};
LoadDataPageFunc.onclicks.SubmitReferral = 'LoadDataPageFunc.EditDetails.NewReferralModal();';
LoadDataPageFunc.Logs = {};
LoadDataPageFunc.Logs.Pagination = {};
LoadDataPageFunc.Logs.Pagination.cardsPerPage = 5;
LoadDataPageFunc.Logs.Pagination.currentPage = 1;
LoadDataPageFunc.Logs.LogRowCard = function (Date = '', content = '') {
content = replaceLineBreaks(content);
return (UICardSimple('', formatDateTimetoReadable(Date) + '<br><br><h4>' + content + '</h4>'));
};
LoadDataPageFunc.Logs.Pagination.PageArray = function () {
return divideArrayIntoSets(LoadDataPageFunc.Logs.LogsCardRowHTMLArray, LoadDataPageFunc.Logs.Pagination.cardsPerPage);
};
LoadDataPageFunc.Logs.Pagination.Firstpage = 1;
LoadDataPageFunc.Logs.Pagination.Lastpage = function () {
return LoadDataPageFunc.Logs.Pagination.PageArray().length;
};
LoadDataPageFunc.Logs.LogsCardRowHTMLArray = [];
LoadDataPageFunc.Logs.Pagination.FirstPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.Pagination.LastPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.MiddlePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.LogRowHtmlPage = function (page = 1) {
if (page) { LoadDataPageFunc.Logs.Pagination.currentPage = page; }
let arrayset = LoadDataPageFunc.Logs.Pagination.PageArray();
let newpageindex = LoadDataPageFunc.Logs.Pagination.currentPage - 1;
if (!isIndexAccessibleArray(arrayset, newpageindex)) {
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(page);
let targetarr = arrayset[newpageindex];
const htmlstr = targetarr.join('<br>');
$('#' + LoadDataPageFunc.ids.ViewDetailsLogsContainer).html(htmlstr);
};
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton = function (newpage) {
if (newpage <= LoadDataPageFunc.Logs.Pagination.Firstpage) { LoadDataPageFunc.Logs.Pagination.FirstPageFound(); }
else if (newpage >= LoadDataPageFunc.Logs.Pagination.LastPageFound()) {
LoadDataPageFunc.Logs.Pagination.FirstPageFound();
} else if (LoadDataPageFunc.Logs.Pagination.Lastpage() == 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
} else if (newpage > LoadDataPageFunc.Logs.Pagination.Firstpage && newpage < LoadDataPageFunc.Logs.Pagination.Lastpage()) {
LoadDataPageFunc.Logs.Pagination.MiddlePageFound();
}
if (LoadDataPageFunc.Logs.Pagination.Lastpage() === 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
}
};
LoadDataPageFunc.Logs.changePage = function (forwardORBackward) {
if (!forwardORBackward) { return false; }
let newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
if (forwardORBackward === -1) { newpage = newpage - 1; }
else if (forwardORBackward === 1) { newpage = newpage + 1; }
if (newpage < LoadDataPageFunc.Logs.Pagination.Firstpage || newpage > LoadDataPageFunc.Logs.Pagination.Lastpage()) {
newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(newpage);
LoadDataPageFunc.Logs.Pagination.currentPage = newpage;
// Load the new page
LoadDataPageFunc.Logs.LogRowHtmlPage(newpage);
};
LoadDataPageFunc.Logs.LogFullCard = function (obj) {
if (!obj.logs) { return ''; }
LoadDataPageFunc.LogsCardRowHTMLArray = [];
let newlogfullarr = [];
if (obj.logs && Array.isArray(obj.logs)) {
newlogfullarr.push('<br><br><div id="' + LoadDataPageFunc.ids.ViewDetailsLogsContainer + '">');
let logrow = '';
const reversedLogs = [...obj.logs].reverse();
for (let log of reversedLogs) {
logrow = LoadDataPageFunc.Logs.LogRowCard(log[0], log[1]);
LoadDataPageFunc.Logs.LogsCardRowHTMLArray.push(logrow);
// newlogfullarr.push(logrow);
}
}
newlogfullarr.push('</div>');
return newlogfullarr.join('');
};
LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
if (!istrue) { return false; }
Preloaders.ViewPropertyDetailsData(currenttarget, false,
function (response) {
ReloadPage();
}
);
};
LoadDataPageFunc.DetailsCardControls = function () {
let buttonLImaker = function (text, onclick, icon) {
return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
};
let htmlarr = [`<div class="mt-5"><div class="tf-container">`];
htmlarr.push('<ul class="box-service mt-3">');
htmlarr.push(buttonLImaker('Interested', LoadDataPageFunc.onclicks.SubmitReferral, 'edit.png'));
htmlarr.push(buttonLImaker('View More Properties', `window.location.href=window.location.origin+'/r/${LoadDataPageFunc.ReferralCode}'`, 'ListLeads.png'));
htmlarr.push('</ul</div></div>');
return htmlarr.join('');
};
LoadDataPageFunc.getReferralCode = function () {
const urlObj = window.location.pathname;
const segments = urlObj.split('/');
const drIndex = segments.indexOf('dr');
if (drIndex !== -1 && drIndex + 1 < segments.length) {
return segments[drIndex + 1];
}
return null;
}
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Details.Status = '';
LoadDataPageFunc.ids.PhotosShowCard = 'PhotosCard';
LoadDataPageFunc.PropertyDetailsCard = function (obj) {
if (!obj) { return false; }
let rowcoldetail = [];
const imgwidth = '200px'; const imgheight = "200px";
if (!obj) { rowcoldetail = 'No Data'; return createCard('Unknown', cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', rowcoldetail, cardbodyclassadd = 'ListPropertyRow'); }
let created = obj.created || false;
let modified = obj.modified || false;
let name = obj.name || false;
let description = obj.description || false;
let status = obj.status || false;
let remarks = obj.remarks || false;
let referralid = obj.referralid || false;
let createdby = obj.createdby || false;
let category = obj.category || '';
let subcategory = obj.subcategory || '';
let photourl = obj.photourl || false;
let sqm = obj.sqm || false;
let bedrooms = obj.bedrooms || false;
let rooms = obj.rooms || false;
let toilet = obj.toilet || false;
let kitchen = obj.kitchen || false;
let floors = obj.floors || false;
let price = obj.price || false;
let specs = obj.specs || false;
let location = obj.location || false
status = InttoStrDetailsFuncs.PropertyStatus(status);
modified = formatDateTimetoReadable(modified);
created = formatDateTimetoReadable(created);
try { photourl = JSON.parse(photourl); } catch (e) { photourl = photourl; }
//LoadDataPageFunc.Details.Status = Status;
const AddDualColifValue = function (varstr, label) {
if (varstr !== false && varstr !== null) {
rowcoldetail.push(dualcolrow(label, varstr));
}
};
rowcoldetail.push(createCard('', LoadDataPageFunc.ids.PhotosShowCard, '', LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, '', '', '', true));
rowcoldetail.push('<br><br>');
AddDualColifValue(subcategory, category);
AddDualColifValue(location, 'Location');
AddDualColifValue(sqm, 'Size');
AddDualColifValue(bedrooms, 'Bedrooms');
AddDualColifValue(rooms, 'Rooms');
AddDualColifValue(toilet, 'Toilet');
AddDualColifValue(kitchen, 'Kitchen');
AddDualColifValue(floors, 'Floors');
AddDualColifValue(price, 'Price');
rowcoldetail.push('<br><br>');
rowcoldetail.push(LoadDataPageFunc.DetailsCardControls());
//rowcoldetail.push(LoadDataPageFunc.Logs.LogFullCard(obj));
const finalRowColDetail = rowcoldetail.join('');
let ViewPropertyCardDetails = createCard(name, LoadDataPageFunc.ids.ViewPropertyCard, created, LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, cardbody = finalRowColDetail);
return ViewPropertyCardDetails;
};
LoadDataPageFunc.LoadPhotosCard = async function () {
let photosdiv = $('#' + LoadDataPageFunc.ids.PhotosShowCard);
if (photosdiv.length === 0) { return false; }
if (!LoadDataPageFunc.Details.photourl) { photosdiv.html('No Photos.<br>'); return false; }
let photolist = JSON.parse(LoadDataPageFunc.Details.photourl);
if (!photolist || photolist.length === 0) { photosdiv.html('No Photos.<br>'); return false; }
let htmlbody = $(`<div class="splide" role="group" aria-label="photosSplide">
<div class="splide__track">
<ul class="splide__list">
</ul> </div></div>`);
const NewSplideLIImage = function (imgsrc) {
return `<li class="splide__slide" onclick="ButtonGo('ViewAllPhotos','${currenttarget}');"><img src="${imgsrc}" style="max-width: 300px;
max-height: 300px;
width: auto;
height: auto;"></li>`;
};
let splidebody = htmlbody.find('ul');
LoadDataPageFunc.PhotoBlobs = [];
photolist.forEach(function (photo) {
LoadAndCreateURLfromFileHash(photo).then(bloburl => {
splidebody.append(NewSplideLIImage(bloburl));
LoadDataPageFunc.PhotoBlobs.push(bloburl);
});
});
photosdiv.html(htmlbody);
new Splide('.splide').mount();
};
LoadDataPageFunc.vars = {};
LoadDataPageFunc.vars.idprefix = 'ReferProperty';
LoadDataPageFunc.ids.SubmitReferral = LoadDataPageFunc.vars.idprefix + '_ReferProperty';
LoadDataPageFunc.EditDetails = {};
LoadDataPageFunc.ids.EditDetailsMidfix = '-EditDetails';
LoadDataPageFunc.ids.EditDetails_name = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyName';
LoadDataPageFunc.ids.EditDetails_Description = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyDescription';
LoadDataPageFunc.ids.EditDetails_Remarks = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Remarks';
LoadDataPageFunc.ids.EditDetails_Location = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Location';
LoadDataPageFunc.ids.EditDetails_Category = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Category';
LoadDataPageFunc.ids.EditDetails_SubCategory = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'SubCategory';
LoadDataPageFunc.ids.EditDetails_sqm = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'sqm';
LoadDataPageFunc.ids.EditDetails_Bedrooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Bedrooms';
LoadDataPageFunc.ids.EditDetails_Rooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Rooms';
LoadDataPageFunc.ids.EditDetails_Toilet = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Toilet';
LoadDataPageFunc.ids.EditDetails_Kitchen = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Kitchen';
LoadDataPageFunc.ids.EditDetails_Floors = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Floors';
LoadDataPageFunc.ids.EditDetails_Price = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Price';
LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone = 'newpropertydropzonephoto';
LoadDataPageFunc.ids.EditDetailsReplacePhotosButton = 'EditDetailsreplacePhotos';
LoadDataPageFunc.EditDetails.InitializePhotoDropZone = function () {
Target_Uploaded_Files = [];
myDropzone = null;
currentDropzone = DropZoneFunc.InitializeDropZone('/File/Upload/Property', (response) => {
if (response.length === 72) {
Target_Uploaded_Files.push(response);
LoadDataPageFunc.ShowPhotoClearButton();
} else {
currentDropzone.removeFile(currentDropzone.files[currentDropzone.files.length - 2]);
}
}, LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone, DropZoneFunc.AcceptedFilesString.images, 'file', maxfilesize = 100);
};
LoadDataPageFunc.ids.ClearPhotosButton = 'newpropertydropzoneclearbutton';
LoadDataPageFunc.ShowPhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).show();
};
LoadDataPageFunc.ClearPhotos = function () {
DropZoneFunc.ClearDropzoneUpload();
LoadDataPageFunc.HidePhotoClearButton();
};
LoadDataPageFunc.HidePhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
};
LoadDataPageFunc.NewLeadsvalidateForm=function () {
let fullname = $('#ReferProperty-SendDetailsFullname').val();
let mobile = $('#ReferProperty-SendDetailsmobile').val();
let landline = $('#ReferProperty-SendDetailslandline').val();
let email = $('#ReferProperty-SendDetailsemail').val();
let preferreddate = $('#ReferProperty-SendDetailspreferreddate').val();
let preferredsite = $('#ReferProperty-SendDetailsPreferredSite').val();
let ReferralCode = LoadDataPageFunc.ReferralCode;
if (!fullname || !mobile || !email) { return false; }
if (!hasValidMobileFormat(mobile)) { return false; }
if (!isValidEmail(email)) { return false; }
return { referralcode:ReferralCode, fullname: fullname, mobile: mobile, landline: landline, email: email, preferred_date: preferreddate, preferred_site: preferredsite };
}
LoadDataPageFunc.SubmitNewLead=function(){
const ValidateData=LoadDataPageFunc.NewLeadsvalidateForm();
if (!ValidateData) {
ModalQuickDismiss('Invalid/Incomplete', 'The following are required<br><br>Fullname<br>11 Digits Mobile Number<br>Correct Email<br><br>Please Input the following properly if not done so. Thank you.');
return false;
}
request.type('POST').data(ValidateData).url('/refer/submit').fromVarCache(false).success((response) => {
if (response === true) {
ModalQuickDismiss('Success', 'You will be contacted Shortly. Thank you.', 'NewLeadsModalSuccess', modaltohide = '', function () {
hidemodal('ReferProperty_ReferProperty');
ReloadPage();
});
}
else if (response === false) {
ModalQuickDismiss('Error', 'Unable to Submit. Try Again Later', 'NewPropertysModalError');
}
}).error((errorstring) => {
ModalQuickDismiss('Error', 'An Error Occured<br>' + errorstring + '<br><br>Please Try Again Later');
}).go()
};
LoadDataPageFunc.EditDetails.NewReferralModal = function () {
Target_Uploaded_Files = [];
$('#' + LoadDataPageFunc.ids.SubmitReferral).remove();
const SubmitOnclick = '';
const targetdiv = 'modal-body-' + LoadDataPageFunc.ids.SubmitReferral;
let FormHTML = ReusableUIElements.NewLeadsGenerateUI(targetdiv, idprefix = LoadDataPageFunc.vars.idprefix + '-SendDetails', replace = false,
'','','','','',LoadDataPageFunc.Details.hashkey,'LoadDataPageFunc.SubmitNewLead();',true);
const footer = buttonprimary('Submit', '', onclick = 'LoadDataPageFunc.SubmitNewLead();');
const modalhtml = $$.UI.Modal.Create(LoadDataPageFunc.ids.SubmitReferral, 'Contact Details', FormHTML, footer);
$$.UI.Element.appendtobody(modalhtml);
const replacePhotosButton = buttonprimary('Replace Photos', value = '', onclick = 'LoadDataPageFunc.EditDetails.ShowPhotoUploadButton();', block = '', LoadDataPageFunc.ids.EditDetailsReplacePhotosButton);
$('#ViewProperty-EditDetailsNewPropertyPhotosInputGroup').append(replacePhotosButton);
$('#' + LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone).hide();
$('#ViewProperty-EditDetailsStatus-select-div-mb3').remove();
$('label[for="ViewProperty-EditDetailsStatus-select-div-mb3"]').remove();
Preloaders.Datalist.NewPropertyCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertyCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
Preloaders.Datalist.NewPropertySubCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertySubCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
$('#ReferProperty-SendDetailssubmit_Lead_button').hide();
showmodal(LoadDataPageFunc.ids.SubmitReferral);
requestWHash.type('POST').url('/NewLeads/Form/PreferredSitesOption').fromVarCache(true).success((response) => {
UIReplaceCurrentOptionsSelect('ReferProperty-SendDetailsPreferredSite', response);
$('#ReferProperty-SendDetailsPreferredSite').val(LoadDataPageFunc.Details.hashkey);
$('#ReferProperty-SendDetailsPreferredSite').prop('disabled',true);
}).go();
};
LoadDataPageFunc.EditDetails.GetChanges = function () {
let objectdata = {};
objectdata.target = currenttarget;
const new_name = $('#' + LoadDataPageFunc.ids.EditDetails_name).val();
const new_description = $('#' + LoadDataPageFunc.ids.EditDetails_Description).val();
const new_remarks = $('#' + LoadDataPageFunc.ids.EditDetails_Remarks).val();
const new_location = $('#' + LoadDataPageFunc.ids.EditDetails_Location).val();
const new_category = $('#' + LoadDataPageFunc.ids.EditDetails_Category).val();
const new_subcategory = $('#' + LoadDataPageFunc.ids.EditDetails_SubCategory).val();
let new_sqm = Number($('#' + LoadDataPageFunc.ids.EditDetails_sqm).val());
let new_bedroom = Number($('#' + LoadDataPageFunc.ids.EditDetails_Bedrooms).val());
let new_rooms = Number($('#' + LoadDataPageFunc.ids.EditDetails_Rooms).val());
let new_toilet = Number($('#' + LoadDataPageFunc.ids.EditDetails_Toilet).val());
let new_kitchen = Number($('#' + LoadDataPageFunc.ids.EditDetails_Kitchen).val());
let new_floors = Number($('#' + LoadDataPageFunc.ids.EditDetails_Floors).val());
let new_price = Number($('#' + LoadDataPageFunc.ids.EditDetails_Price).val());
let changes = 0;
if (LoadDataPageFunc.Details.name !== new_name) { objectdata.name = new_name; changes++; }
if (LoadDataPageFunc.Details.description !== new_description) { objectdata.description = new_description; changes++; }
if (LoadDataPageFunc.Details.remarks !== new_remarks) { objectdata.remarks = new_remarks; changes++; }
if (LoadDataPageFunc.Details.location !== new_location) { objectdata.location = new_location; changes++; }
if (LoadDataPageFunc.Details.category !== new_category) { objectdata.category = new_category; changes++; }
if (LoadDataPageFunc.Details.subcategory !== new_subcategory) { objectdata.subcategory = new_subcategory; changes++; }
if (LoadDataPageFunc.Details.sqm !== new_sqm) { objectdata.sqm = new_sqm; changes++; }
if (LoadDataPageFunc.Details.bedrooms !== new_bedroom) { objectdata.bedrooms = new_bedroom; changes++; }
if (LoadDataPageFunc.Details.rooms !== new_rooms) { objectdata.rooms = new_rooms; changes++; }
if (LoadDataPageFunc.Details.toilet !== new_toilet) { objectdata.toilet = new_toilet; changes++; }
if (LoadDataPageFunc.Details.kitchen !== new_kitchen) { objectdata.kitchen = new_kitchen; changes++; }
if (LoadDataPageFunc.Details.floors !== new_floors) { objectdata.floors = new_floors; changes++; }
if (LoadDataPageFunc.Details.price !== new_price) { objectdata.price = new_price; changes++; }
if (Target_Uploaded_Files.length > 0) { objectdata.photourl = JSON.stringify(Target_Uploaded_Files); changes++; }
if (!changes) { return null; }
if (!new_name || !new_description || !new_location || !new_sqm) {
return false;
}
return objectdata;
};
LoadDataPageFunc.EditDetails.Submit = function () {
let ChangesObject = LoadDataPageFunc.EditDetails.GetChanges();
if (ChangesObject === null) { $$.UI.Modal.ModalQuickDismiss('No Changes', 'No Changes to Update!'); return false; }
if (ChangesObject === false) { $$.UI.Modal.ModalQuickDismiss('', 'Incomplete Details!<br>The following are required!<br><br>Property Name<br>Description<br>Location<br>Size in sqm'); return false; }
if (Target_Uploaded_Files.length == 0) { $$.UI.Modal.ModalQuickDismiss('', 'No New Photos Uploaded!<br>Previous Photos Would be used!',); }
let SendUpdatedDetails = new RequestData(false);
request
.url(LoadDataPageFunc.URLs.SubmitEdit)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(false)
.data(ChangesObject)
.success((response) => {
if (!response) { return false; }
const error = response.error || false;
if (response !== true) {
if (error) { $$.UI.Modal.ModalQuickDismiss('Error', error); }
return false;
} else if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(true);
ReloadPage();
hidemodal(LoadDataPageFunc.ids.SubmitReferral);
$$.UI.Modal.ModalQuickDismiss('Success', 'Details Updated');
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
})
.go();
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.RequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.DefaultDatatoSend = function () {
return { target: currenttarget };
};
LoadDataPageFunc.LoadMainDetails = {};
LoadDataPageFunc.LoadMainDetails.OnSuccess = function (response) {
if (!response) { ModalQuickDismiss('Error', 'No Data Loaded<br>'); return ''; }
LoadDataPageFunc.PropertyCurrentDetails = response.Details;
LoadDataPageFunc.Details = response.Details;
$('#' + LoadDataPageFunc.ids.ViewPropertyContainer).html(LoadDataPageFunc.PropertyDetailsCard(response.Details));
LoadDataPageFunc.Logs.LogRowHtmlPage();
LoadDataPageFunc.LoadPhotosCard();
};
LoadDataPageFunc.LoadMainDetails.OnError = function (err) { ModalQuickDismiss('Error', 'Unable to Load<br>' + err); };
LoadDataPageFunc.LoadMainDetails.LoadNow = function () {
let request = new RequestData(false);
request
.url(LoadDataPageFunc.URLs.MainData)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(LoadDataPageFunc.Settings.fromVarCache)
.data(LoadDataPageFunc.DefaultDatatoSend())
.success((response) => {
if (typeof LoadDataPageFunc === 'undefined' || LoadDataPageFunc.currentTargetPage === 'undefined') {
return false;
}
//console.log(response);
if (currentPage !== LoadDataPageFunc.currentTargetPage) { return false; }
LoadDataPageFunc.LoadMainDetails.OnSuccess(response);
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
})
.go();
};
LoadDataPageFunc.main = function () {
LoadDataPageFunc.LoadMainDetails.LoadNow();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
LoadDataPageFunc.ReferralCode = '';
if (typeof ReferralCode !== 'undefined') {
LoadDataPageFunc.ReferralCode = ReferralCode;
history.replaceState({}, "ReferProperty", "/p/ReferProperty/s/" + currenttarget + "/dr/" + ReferralCode);
}
if (typeof ReferralCode === 'undefined'){
ReferralCode = LoadDataPageFunc.getReferralCode();
LoadDataPageFunc.ReferralCode = ReferralCode;
}
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

View File

@@ -0,0 +1,242 @@
<div id='ListPropertiesMainContainer'>
</div>
<br><br><br>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.newpropertyrow = function (objrow, rownum) {
let rows = [];
let rowcoldetail = '';
let firstimagesrc = '/assets/no-image.png';
const imgwidth = '200px'; const imgheight = "200px";
const hash = objrow.hashkey || false;
if (!objrow || !hash) { rowcoldetail = 'No Data'; return createCard('Unknown', cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', rowcoldetail, cardbodyclassadd = 'ListPropertyRow'); }
let name = objrow.name || false;
let description = objrow.description || false;
let remarks = objrow.remarks || false;
let createdby = objrow.createdby || false;
let category = objrow.category || '';
let subcategory = objrow.subcategory || '';
let photourl = objrow.photourl || false;
let sqm = objrow.sqm || false;
let bedrooms = objrow.bedrooms || false;
let rooms = objrow.rooms || false;
let toilet = objrow.toilet || false;
let kitchen = objrow.kitchen || false;
let floors = objrow.floors || false;
let price = objrow.price || false;
let specs = objrow.specs || false;
let location = objrow.location || false
let photobinarystring = '';
let base64string = '';
let blob;
try { photourl = JSON.parse(photourl); } catch (e) { photourl = photourl; }
if (photourl) { if (Array.isArray(photourl)) { photourl = photourl[0]; } else { } }
if (photourl) { photourl = '/RequestData/File/' + photourl; }
/*
photobinarystring = reqcacheload(photourl);
if (photobinarystring) {
blob = binaryStringToBlob(photobinarystring);
console.log('blob ',blob);
if (blob){
photourl = CreateObjectURLfrombinaryStringforIMGUse(photobinarystring);
console.log(photourl);
}
}
*/
photoblob = reqcacheload(photourl);
if (photoblob) {
photourl = URL.createObjectURL(photoblob);
}
rows.push(`<div class="col-12"><center><a href="javascript:void(0);return;" onclick="ButtonGo('${'ReferProperty'}', '${hash}')"><img src="` + photourl + '" style="width:' + imgwidth + '; height:' + imgheight + ';"></a></center>');
rows.push('<br>');
rows.push('<div class="col">');
if (location !== false) {
rows.push(dualcolrow('Location', location, rowclass = ''));
}
if (subcategory !== false) {
rows.push(dualcolrow(category, subcategory, rowclass = ''));
}
if (sqm !== false) {
rows.push(dualcolrow('Size', sqm + ' sqm', rowclass = ''));
}
if (bedrooms !== false) {
rows.push(dualcolrow('Bedrooms', bedrooms, rowclass = ''));
}
if (rooms !== false) {
rows.push(dualcolrow('Rooms', rooms, rowclass = ''));
}
if (toilet !== false) {
rows.push(dualcolrow('Toilet', toilet, rowclass = ''));
}
if (kitchen !== false) {
rows.push(dualcolrow('Kitchen', kitchen));
}
if (floors !== false) {
rows.push(dualcolrow('Floors', floors));
}
if (price !== false) {
rows.push(dualcolrow('Price', price));
}
rows.push('<div id="PropertyListRowCardHash-' + rownum + '" style="display:none;">' + hash + '</div>');
if (description !== false) {
rows.push('<br><div class="row">' + col('<center>Description</center>', '-12'));
rows.push(col('<textarea>' + description + '</textarea>', '-12') + '</div>');
}
rows.push('</div></div>');
rows.push(row(col('<br>' + buttonprimary('View Details', '', `ButtonGo('ReferProperty', '${hash}')`, '-12', 'ListPropertyGoRow-' + rownum))));
let FinalBody = rows.join('');
return createCard(name, cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', FinalBody, cardbodyclassadd = 'ListPropertyRow');
};
LoadDataPageFunc.main = function () {
const searchcard = UIInputGroup('Search', 'text', 'ListProperty_Search', '', classs = '', span = '', '/assets/clear.png');
// let PropertyListContainer = UICardSimple('', 'Loading Please Wait...', 'PropertyListContainer');
let PropertyListContainer = '<div id="PropertyListContainer"><center>Loading Please Wait...</center></div>';
const FinalInnerHTML = searchcard + PropertyListContainer;
const MainCard = UICardSimple('Properties', FinalInnerHTML, 'MAINCARDBODY_PROPERTYLIST');
$('#ListPropertiesMainContainer').html(MainCard);
};
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 = 'PropertyListRowCardHash-' + variablePart;
hashkey = $('#' + hashKeyDivId).text();
if (hashkey) {
request.url('/ViewProperty/Details/data').success((response) => {
}).data({ target: hashkey }).fromVarCache(true).type('POST').go();
}
hashkey = '';
}
});
}, { threshold: 0.1 });
$('#PropertyListContainer .card').each(function () {
observer.observe(this);
});
};
LoadDataPageFunc.populatepropertylist = function () {
let request = new RequestData(true);
request
.url('/ListProperty/List/Referral/data')
.type('POST')
.data(null)
.fromVarCache(true)
.success((response) => {
if ($('#card-body-MAINCARDBODY_PROPERTYLIST').length === 0) { return false; }
if (!response) {
$('#card-body-MAINCARDBODY_PROPERTYLIST').html('No Properties');
return;
}
let PropertyList = response.List;
//PropertyList.reverse();
if(typeof PropertyList==='object'){
PropertyList = Object.values(PropertyList);
}
PropertyList.sort((a, b) => new Date(b.created) - new Date(a.created));
let newhtmlrows = ''; let arrayrows = [];
const count = PropertyList.length;
for (let i = 0; i < count; i++) {
arrayrows.push(LoadDataPageFunc.newpropertyrow(PropertyList[i], i) + '<br>');
}
newhtmlrows = arrayrows.join('');
$('#PropertyListContainer').html(newhtmlrows);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.error((err) => {
console.error(err);
})
.go();
};
function SearchKeyUPListPropertyPage() {
$('#ListProperty_Search').on('keyup', function () {
let searchTerm = $(this).val().toLowerCase();
$('#PropertyListContainer .card').each(function () {
let title = $(this).find('.card-title').text().toLowerCase();
let cols = $(this).find('.col').text().toLowerCase();
if (title.includes(searchTerm) || cols.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
}
LoadDataPageFunc.ClearSearch = function () {
$('#ListProperty_Search').val('');
$('#ListProperty_Search').trigger('keyup');
};
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populatepropertylist();
changeTopbarTitle('Properties');
SearchKeyUPListPropertyPage();
$('#imgspanListProperty_Search').attr('onclick', 'LoadDataPageFunc.ClearSearch();');
});
</script>

View File

@@ -0,0 +1,259 @@
<style>
.ListRowCard {
margin-bottom: 20px;
}
</style>
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.QueryListData = '/ListStores/List/data';
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.SortArray = function (arr) {
return arr.sort((a, b) => new Date(b.created) - new Date(a.created));
};
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
gotoPage('ViewStoreMarket', `${data}`);
};
LoadDataPageFunc.Settings.PageName = 'Stores';
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.Settings.CurrentTargetRequired = false;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let rowhtml = [];
const hashkey = objectdata.hashkey;
let photourl = objectdata.photourl;
let name = objectdata.name;
let category = objectdata.category || '';
let subcategory = objectdata.subcategory || '';
let FinalBody = '';
/* html */
FinalBody = `
<div class="row" onclick="LoadDataPageFunc.Settings.ViewDetailsOnclick('${hashkey}');">
<div class="col-2">
<img src="${photourl}" class="StoreListIMGIcon" id="StoreListPhoto" style="width:0.5vw: height:0.5vh;display:none;">
</div>
<div class="col-10">
<div class="row">
<div class="col-12" style="font-width:1.5vh;">
<b>${name}</b>
</div>
<div class="col-12" style="font-size:1.0vh;">
${category}
</div>
<div class="col-12" style="font-size:0.7vh;">
${subcategory}
</div>
</div>
</div>
</div>
`;
return createCard(objectdata.fullname, cardid = 'ListRowCard-' + rownum, '', cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow', '', 'ListRowCard');
};
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.MainContainer = 'ListMainContainer';
LoadDataPageFunc.ids.SearchInput = 'List_Search';
LoadDataPageFunc.ids.ListContainer = 'ListContainer';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
$$$ = {};
$$$.UpdateMainContainer = function (html) {
$('#' + LoadDataPageFunc.ids.MainContainer).html(html);
};
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.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(LoadDataPageFunc.Settings.fromVarCache)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response;
let newhtmlrows = ''; let htmlarrayrows = [];
const count = List.length;
let hashkey;
for (let i = 0; i < count; i++) {
let hashkey = List[i]['hashkey'];
htmlarrayrows.push(LoadDataPageFunc.NewRow(List[i], i) + '<br>');
}
newhtmlrows = htmlarrayrows.join('');
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
const imgclassname = 'StoreListIMGIcon';
LoadPhotoIMGTargetClass(imgclassname, settodisplaylater = true);
HideBrokenPhotowithClass(imgclassname);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.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();
if (title.includes(searchTerm) || cols.includes(searchTerm)) {
$(this).show();
} else {
$(this).hide();
}
});
});
};
LoadDataPageFunc.main = function () {
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('Stores', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
LoadDataPageFunc.SearchKeyUPListPage();
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
});
</script>

View File

@@ -0,0 +1,145 @@
<div id="NewStoreForm">
</div>
<script>
InitDataPageFuncOBJ();
LoadDataPageFunc = {};
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.NewUrl = `/Store/New`;
LoadDataPageFunc.URLs.CategoryDatalist = `/Store/New/Category/Datalist`;
// LoadDataPageFunc.URLs.SubCategoryDatalist = `/Products/New/SubCategory/Datalist`;
LoadDataPageFunc.URLs.PhotoUpload = `/File/Upload/Store`;
LoadDataPageFunc.PageTitle = 'New Store';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.photodropzone = 'NewStorePhotos';
LoadDataPageFunc.formclass = 'NewStoreMarket';
// 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, id, required = false, datalist = '') {
return UIInputGroup(placeholder, 'text', id, label, formclass, spanclass = '', imginsteadofspan = '', required, textvalue = '', datalist, imgwidth = '', imgheight = '');
};
const name = textbox('Store Name', 'Name', 'name', true);
const description = UIInputGroupTEXTAREA(label = 'Description', 'description', required = true, textareacontent = '', formclass);
const category = textbox('Product Category', 'Category', 'category', true, 'NewStoreCategoryDataList');
const address = UIInputGroupTEXTAREA(label = 'Address', 'address', required = true, textareacontent = '', formclass);
const categorydatalist = ArraytoDatalist("NewStoreCategoryDataList", [], 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+ address + photoscontainer + submitbutton;
finalhtml = CreateCardSimple(false, finalhtml);
document.getElementById('NewStoreForm').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();
QueryandReplaceDatalist("NewStoreCategoryDataList", LoadDataPageFunc.URLs.CategoryDatalist, 'POST', null, fromvarcache = true);
};
LoadDataPageFunc.TryToSubmit = function () {
const currentformdata = LoadDataPageFunc.ValidateForm();
if (!currentformdata) {
ModalQuickDismiss('Error', 'Name, Description, Category and Address are required fields.', modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
return false;
}
const errorModal = function (errorstring = '') {
ModalQuickDismiss('Error', 'Unable Submit To New Store. <br>' + errorstring, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true, modalfooter = '');
};
const successModal = function () {
hideallmodals();
ModalQuickDismiss('Success', 'New Store Created');
};
const submitsuccess = function (response) {
responseOk = isResponseAHash(response);
if (!responseOk) {
errorModal(response);
return false;
}
if (responseOk) {
// Preloaders.ViewProductinMarket(response);
successModal();
gotoPage('ViewStoreMarket', response);
return true;
}
};
SendPostDataFormwithTARGETUPLOADEDFILES(LoadDataPageFunc.URLs.NewUrl, LoadDataPageFunc.formclass, submitsuccess);
};
LoadDataPageFunc.ValidateForm = function () {
return validateInputForm(['name', 'description', 'address', 'category']);
const isAnyoftheRequiredEmpty = !inputsArray['NewProductName'] || !inputsArray['NewProductDescription'] || !inputsArray['NewProductCategory'] || !inputsArray['NewProductSubCategory'] ||
!inputsArray['NewProductPrice'] || !inputsArray['NewProductAvailable'] || !inputsArray['NewProductUnitName'] || Target_Uploaded_Files.length === 0;
if (isAnyoftheRequiredEmpty || isBarcodeNumeric === false) {
return false;
}
const IsBarcodeValid = IsStringBarcode12Digits(inputsArray['NewProductBarcode']);
return true;
};
LoadDataPageFunc.Main = function () {
LoadDataPageFunc.LoadUI();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
LoadDataPageFunc.Main();

View File

View File

@@ -0,0 +1,209 @@
<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">
</div>
<br>
<div class="row" style="">
<div class="col">
<h3 id="StoreNameMarketPlace"></h3>
</div>
<div class="col" id="StoreLocationMarketPlace"></div>
</div>
<ul class="mt-3 box-outstanding-service" id="ControlsAddCartBuy">
<li onclick="LoadDataPageFunc.ViewAllStoreDetails();return false;">
<div class="">
<img src="/assets/search.png" style="width: 30; height: 30;" class="icon-user">
</div>More Details
</li>
<li onclick="LoadDataPageFunc.Report();return false;">
<div class="">
<img src="/assets/reportaccount.png" style="width: 30; height: 30;"
class="icon-user">
</div>Report
</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="StoreDescription">
</div>
<h5></h5>
</div>
</div>
</a>
</div>
<div class="col-md" style="overflow:hidden;" id="StoreProductsColumn">
</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 = 'Store Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Disabled = false;
LoadDataPageFunc.ProductsListNewCard = function (object, rownum) {
if (!object || rownum === false || rownum === null || typeof rownum === undefined) {
return '';
}
let hash =object.hashkey || false;
let name = object.name || '';
let price = object.price || '';
let photo = object.photourl || '';
const unit = object.unitname || '';
if(!hash){return '';}
if (typeof photo ==='array'){
photo =photo[0];
}
name = trimStringToMaxLength(name, 16, suffix = '');
// price = trimStringToMaxLength(price, 16, suffix = '');
const productColumnSize='6';
const newcol = function (colinner, colsize = "12", style='') {
return `<div class="col-${colsize}" style="${style}">${colinner}</div>`;
}
/* html */
const imgelement =`
<img id="marketplacelistproductphoto-1" src="${photo}" loading="lazy" class="StoreProductsIMGMarket"
style="width: 60%;height: 60%;object-fit: contain;">
`;
/* html */
let finalcontent =imgelement+`<br><div class="row" style=""><div class="col"><h4>${name}</h4></div></div>`;
finalcontent +=`<div class="row" style=""><div class="col"><h6>P${price} / ${unit}</h6></div></div>`;
const maincolstyle='';
return newcol(`<center onclick="gotoPage('BuyViewProductMarket','${hash}')">`+CreateCardSimple(false, finalcontent, 'StoreProductCard-' + rownum,'width: 100%; height: 100%; object-fit: cover;')+'</center>',productColumnSize,maincolstyle);
}
LoadDataPageFunc.UpdateProductsListCard = function (productslist) {
const isempty = typeof productslist === 'array' || productslist.length === 0;
if (!productslist || isempty) {
$('#card-body-StoreProductsCard').html('<p style="text-align:center;">No Products</p>');
return false;
}
let cardarray = [];
cardarray.push('<div class="row" style="">');
iterateArray(productslist, (data, rownum) => {
cardarray.push(LoadDataPageFunc.ProductsListNewCard(data, rownum));
});
cardarray.push('</div>');
const finalhtml = cardarray.join('');
$('#card-body-StoreProductsCard').html(finalhtml);
LoadPhotoIMGTargetClass('StoreProductsIMGMarket', settodisplaylater = true) ;
return true;
};
LoadDataPageFunc.PopulateDetailsNow = function (name, description, address, category, subcategory, products) {
$('#StoreNameMarketPlace').html(name);
$('#StoreDescription').html(description);
$('#StoreLocationMarketPlace').html(address);
const StoreProductsColumn = UICardSimple('Products', text = '', id = 'StoreProductsCard');
$('#StoreProductsColumn').html(StoreProductsColumn);
LoadDataPageFunc.UpdateProductsListCard(products);
};
LoadDataPageFunc.ViewPhotosLink = function (){
const datasend = {t:currenttarget,type: LoadDataPageFunc.Settings.Phototype};
ButtonGo('ViewAllPhotos',datasend);
}
LoadDataPageFunc.Settings.Phototype = "StoreMarket";
LoadDataPageFunc.StoreLoadErrorModal=function(){
ModalQuickDismiss(false, 'Store Not Available!', 'UnavailableStoreModal');
}
LoadDataPageFunc.PopulateDetails = function () {
let description;
let photosarray;
if (!currenttarget){LoadDataPageFunc.StoreLoadErrorModal();}
const UpdateDetailsUI = function (response) {
if (!response) {
LoadDataPageFunc.StoreLoadErrorModal();
return false;
}
Preloaders.ImageList(currenttarget,LoadDataPageFunc.Settings.Phototype);
LoadPhotosCard('PhotosCard', "LoadDataPageFunc.ViewPhotosLink();", response.photourl);
LoadDataPageFunc.PopulateDetailsNow(response.name, response.description, response.address, response.category, response.subcategory, response.products);
};
Preloaders.ViewStoreinMarket(currenttarget, true, UpdateDetailsUI);
};
LoadDataPageFunc.Main = function () {
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.PopulateDetails();
};
LoadDataPageFunc.Main();
</script>

View File

@@ -0,0 +1,349 @@
<style>
.ListRowCard {
margin-bottom: 5px;
}
</style>
<div id="MainView">
<div class="row">
<div class="col-md" style="overflow:hidden;">
<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 class="row" style="">
<div class="col" id="TransactionCode">
</div>
<div class="col" id="TransactionDate"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md" style="overflow:hidden;" id="ColumnItemList">
<div class="card ListRowCard" id="ListRowCard-0" style="">
<div id="cardheader-ListRowCard-0" class="card-header ui-sortable-handle"
style="cursor: move;">
Items
<div class="card-tools" id="card-tools-ListRowCard-0">
</div>
</div>
<div class="card-body ListCardRow" id="card-body-ListRowCard-0">
<div class="row" style="" id="ItemsList">
</div>
</div>
</div>
</div>
<div class="col-md" style="overflow:hidden;">
<a href="javascript:void(0);" onclick="">
<div class="card ListRowCard" id="ListRowCard-1" style="">
<div class="card-body ListCardRow" id="card-body-ListRowCard-2">
<div class="col-12" style="text-align: center;">
Status: <h3 id="TStatus"></h3>
</div>
<h5></h5>
</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="">
<div class="row" style="">
<div class="col">
Total Items<h4 id="TotalItems"></h4>
</div>
<div class="col">
Total Price: <h4 id="TotalPrice"></h4>
</div>
</div>
</div>
<h5></h5>
</div>
</div>
</a>
</div>
<div class="col-md" style="overflow:hidden;" id="ColumnConfirmDeliveryButton">
<a href="javascript:void(0);" onclick="">
<div class="card ListRowCard" id="ListRowCard-3" style="">
<div class="card-body ListCardRow" id="card-body-ListRowCard-2">
<button class="btn" onclick="LoadDataPageFunc.ShowConfirmDelivery();">
<img src="/assets/checkmark.png" style="width: 30; height: 30;" class="icon-user">
Set As Delivered
</button>
<h5></h5>
</div>
</div>
</a>
</div>
</div>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Purchase Details';
LoadDataPageFunc.MainDetailsURL = '';
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.ProductNotAvailableModalDismissed = false;
LoadDataPageFunc.SendPostData = function (url, func, VarCache = false, fromhashcache = false) {
let reqq = new RequestData()
reqq.fromVarCache(false).data({ target: currenttarget }).url(url).type('POST')
.success((response) => {
if (func) {
return func(response);
}
}).go();
}
LoadDataPageFunc.ProductRow = function (rowdata, rownum) {
const hashkey = rowdata.hashkey;
let productviewonclick = "ButtonGo('BuyViewProductMarket','" + hashkey + "');";
const photourlsArray = rowdata.photourl;
let photourl = ''
if (photourlsArray && typeof photourlsArray === "array") {
photourl = photourlsArray[0];
} else {
photourl = photourlsArray;
}
const name = rowdata.name;
const quantity = rowdata.quantity;
const price =rowdata.price;
const totalprice = rowdata.totalprice;
const unit = rowdata.unit;
const priceperunit = 'P' + price + ' / ' + unit;
photourl = '/RequestData/File/' + photourl;
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-cart-${rownum}" style=" padding-top: 10px; padding-bottom: 10px;">
<a href="javascript:void(0);" onclick="${productviewonclick}">
<img id="ProductCartMarketPlacePhoto-${rownum}" src="${photourl}" style="width: 200px;height: 200px;">
</a>
</div>
<div class="col" id=${'product-controls-cart-marketplace-container-' + rownum}>
<div class="row">
<div class="col">
</div>
<div class="col-12" style=" padding-top: 10px;text-align:center;">
<h3>${name}</h3>
<h6>${priceperunit}</h6>
</div>
<div class="col-12 " style="text-align: center;">
<br> Quantity<h3 id="ProductTransactionBuyDetailsMarket-Item-Quantity-${rownum}">${quantity}</h3>
</div>
<div class="col-12">
<br>
</div>
<div class="col-12" style="text-align: center;" id="totalitemprice-${rownum}">
<br> Price<h3 id="ProductTransactionBuyDetailsMarket-Item-Price-${rownum}">${totalprice}</h3>
</div>
</div>
</div>
</div>
</div>`;
};
LoadDataPageFunc.ConfirmDelivery = function () {
let responsefunc = function (response) {
if (response!==true){
ModalQuickDismiss(false,'Unable to Confirm Delivery<br>'+response); return false;}
else{
hidemodal('TransactionConfirmDeliveryModal');
ModalQuickDismiss(false,'Delivery Confirmed');
ReloadPage();
return true;}
};
LoadDataPageFunc.SendPostData('/Transactions/Buy/Market/Confirm/Delivery', responsefunc);
};
LoadDataPageFunc.ShowConfirmDelivery = function () {
const modalbody = `Are you sure you wish to Confirm Delivery?<br>
Please Check Items First!`;
const modalfooter = `<button class="btn" onclick="LoadDataPageFunc.ConfirmDelivery();"><img src="/assets/checkmark.png" style="width: 30; height: 30;" class="icon-user">Confirm</button>`;
CreateAndShowModal('TransactionConfirmDeliveryModal', false, modalbody, modalfooter);
};
LoadDataPageFunc.PopulateDetailsNow = function (data) {
const tcode = data.transactioncode;
const tdate = formatDateTimetoReadable(data.transactiondate) || '';
const tprice = data.totalprice;
const tItems = data.totalitems;
const status = data.status;
$('#TransactionCode').html(tcode);
$('#TransactionDate').html(tdate);
$('#TotalItems').html(tItems);
$('#TotalPrice').html('P' + tprice);
$('#TStatus').html(status);
if (strtolower(status)==='delivered'){$('#ColumnConfirmDeliveryButton').hide();}
};
LoadDataPageFunc.Settings.Phototype = "ProductMarket";
LoadDataPageFunc.BuySuccess = function () {
ModalQuickDismiss(false, 'Successfully Bought Product!', 'ModalConfirmBuySuccess');
gotoPage('PendingBuysProductMarket');
return;
};
LoadDataPageFunc.PopulateDetails = function () {
let description;
let photosarray;
let responsefunc = function (response) {
response = {};
response.data = {
transactioncode: 'sgfesbgb',
transactiondate: '2024-12-12 19:19:00',
totalprice: '9030',
totalitems: 5,
status: 'paid',
items: [
{
hashkey:'asdfasfvv443',
name: 'Sinandomeng',
unit: '25kg',
quantity: 5,
price: 1430,
totalprice: 5 * 1430,
photourl: 'd5650f203fcd447bc7c409f9f0d06a67315041dcd3fd599f63b80d8fe5cc95734b644c2d'
},
{
hashkey:'asdfasfvv443',
name: 'Coco Pandan',
unit: '25kg',
quantity: 7,
price: 1235,
totalprice: 7 * 1235,
photourl: '09db0d2947463d87aee76aec90dc18d439bc6fe9c8d454b6c3de35d7006bc526cbfbafcf'
},
{
hashkey:'asdfasfvv443',
name: 'Buko Pandan',
unit: '50kg',
quantity: 18,
price: 2000,
totalprice: 18 * 2000,
photourl: '0fdd3d467dfc392f4a8a34e37e81ca15bf613ab6304f6b4c3af6519ae6a323d5cac63666'
}
]
};
if (!response) {
LoadDataPageFunc.TransactionDetailsNotAvailable();
return false;
}
let ProductData = response.data;
let ItemsArr = ProductData.items;
let htmlrows=[];
for (let i = 0; i < ItemsArr.length; i++) {
htmlrows.push(LoadDataPageFunc.ProductRow(ItemsArr[i],i));
}
const htmlprods=htmlrows.join('');
document.getElementById('ItemsList').innerHTML = htmlprods;
LoopArrayorObject(ItemsArr,(item,rowno)=>{
LoadPhototoIMG('ProductCartMarketPlacePhoto-'+rowno,item.photourl, onclick = `ButtonGo('BuyViewProductMarket','${item.hashkey}');`);
});
LoadDataPageFunc.PopulateDetailsNow(response.data);
};
LoadDataPageFunc.SendPostData(`/View/Product/Details`, responsefunc, true, true);
};
LoadDataPageFunc.TransactionDetailsNotAvailable = function () {
const modalfooter = `
<button class="btn" onclick="Backkey();">Back</button>
<button class="btn" onclick="ButtonGo('PendingBuysProductMarket')">All Pending Delivery</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,257 @@
<div id='ListMainContainer'>
</div>
<script>
Target_Uploaded_Files = [];
if (typeof LoadDataPageFunc === 'undefined') {
LoadDataPageFunc = {};
}
if (typeof LoadDataPageFunc.Settings === 'undefined') {
LoadDataPageFunc.Settings = {};
}
LoadDataPageFunc.Settings.PageName = 'Photos';
LoadDataPageFunc.currentTargetPage = 'ViewAllPhotos';
LoadDataPageFunc.URLs = {};
if (typeof currenttarget === 'string') {
currenttarget = tryparsingJSON(currenttarget);
}
if (typeof currenttarget === 'object') {
LoadDataPageFunc.Settings.Phototype = currenttarget['type'];
targethash = currenttarget['t'];
} else {
targethash = currenttarget;
}
if (typeof LoadDataPageFunc.Settings.Phototype === 'undefined') {
LoadDataPageFunc.Settings.Phototype = 'ProductMarket';
}
LoadDataPageFunc.URLs.QueryListData = '/Request/Photos/' + LoadDataPageFunc.Settings.Phototype;
LoadDataPageFunc.Settings.CurrentTargetRequired = true;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.NewRow = function (url, hashkey) {
if (!hashkey || !url) { return false; }
return [url, '', 'PhotoViewer', hashkey];
};
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.ListContainer = 'ListContainer';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
$$$ = {};
$$$.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.URLs.PreloadPhoto = function (hash) {
return '/RequestData/File/' + hash;
};
LoadDataPageFunc.populatelist = function () {
let urlArrays = []; let photoPromises = [];
let newhtmlrows = ''; let htmlarrayrows = [];
let PhotolistHashToHTML = function (PhotoHashArray) {
if (typeof PhotoHashArray === 'string') { PhotoHashArray = JSON.parse(PhotoHashArray); }
let count = PhotoHashArray.length;
for (let dd = 0; dd < count; dd++) {
photoPromises.push(
LoadAndCreateURLfromFileHash(PhotoHashArray[dd]).then(bloburl => {
urlArrays.push(bloburl);
})
);
}
Promise.all(photoPromises).then(() => {
for (let aa = 0; aa < count; aa++) {
if (!PhotoHashArray[aa] || !urlArrays[aa]) { continue; }
htmlarrayrows.push(LoadDataPageFunc.NewRow(urlArrays[aa], PhotoHashArray[aa]));
}
newhtmlrows = UIServices_FullDIV_GOTOPAGE_Array('', viewallhref = '', viewallonclick = '', viewalltext = '', htmlarrayrows);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
const elementsWithIconBox = document.querySelectorAll('.icon-box');
elementsWithIconBox.forEach(element => {
element.classList.remove('icon-box');
});
}).catch(error => {
$('#' + LoadDataPageFunc.ids.ListContainer).html('Error Loading Photos');
});
};
if (LoadDataPageFunc.Details && LoadDataPageFunc.Details.photourl) {
let photoarray = LoadDataPageFunc.Details.photourl;
let PhotolistCount = photoarray.length;
if (!PhotolistCount) { return false; }
PhotolistHashToHTML(LoadDataPageFunc.Details.photourl);
return true;
}
let request = new RequestData(true);
request
.url(LoadDataPageFunc.URLs.QueryListData)
.type(LoadDataPageFunc.Settings.DefaultRequestType)
.data({ target: targethash })
.fromVarCache(true)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response;
const count = List.length;
for (let i = 0; i < count; i++) {
// Push each promise into the array
photoPromises.push(
LoadAndCreateURLfromFileHash(List[i]).then(bloburl => {
urlArrays.push(bloburl);
})
);
}
Promise.all(photoPromises).then(() => {
for (let i = 0; i < count; i++) {
if (!List[i] || !urlArrays[i]) { continue; }
htmlarrayrows.push(LoadDataPageFunc.NewRow(urlArrays[i], List[i]));
}
newhtmlrows = UIServices_FullDIV_GOTOPAGE_Array('', viewallhref = '', viewallonclick = '', viewalltext = '', htmlarrayrows);
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
const elementsWithIconBox = document.querySelectorAll('.icon-box');
elementsWithIconBox.forEach(element => {
element.classList.remove('icon-box');
});
}).catch(error => {
$('#' + LoadDataPageFunc.ids.ListContainer).html('Error Loading Photos');
});
})
.error((err) => {
console.error(err);
})
.go();
};
LoadDataPageFunc.ListContainerMessage = function (message = 'No Photos') {
ListContainer = '<div id="' + LoadDataPageFunc.ids.ListContainer + '"><center>' + message + '</center></div>';
$$$.UpdateMainContainer(UICardSimple('', ListContainer, LoadDataPageFunc.ids.MainCardBody));
};
LoadDataPageFunc.main = function () {
if (LoadDataPageFunc.Settings.CurrentTargetRequired && (!targethash || targethash === '0')) {
$$$.UpdateMainContainer('<center>No Target<br><br>' + buttonprimary('Go Back', '', "Backkey()") +
'<br><br>' + buttonprimary('Home', '', "ButtonGo('Home', '')") + '</center>'); return false;
}
LoadDataPageFunc.ListContainerMessage('Loading Please Wait...');
return true;
};
$(document).ready(function () {
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
});
</script>

View File

@@ -0,0 +1,599 @@
<div id="viewleadContainer">
</div>
<div class="pagination">
<button id="prevBtnLogsLeadDetailsPage" class="btn btn-primary"
onclick="LoadDataPageFunc.Logs.changePage(-1)">Next</button>
<span id="pageInfo"></span>
<button id="nextBtnLogsLeadDetailsPage" class="btn btn-primary"
onclick="LoadDataPageFunc.Logs.changePage(1)">Previous</button>
</div>
<script> $$ = {};
$$.UI = {};
$$.UI.Table = {};
$$.UI.Table.CreateTable = function (id, theadinnerhtml, bodyinnerhtml) { return CreateTable(id, theadinnerhtml, bodyinnerhtml); };
$$.UI.Table.GenerateTheadFromArraySimple = function (array) { return GenerateTheadFromArraySimple(array); };
$$.UI.Table.GenerateTableRowFromArraySimple = function (array) { return GenerateTableRowFromArraySimple(array); };
$$.UI.ResetBrowserAndCache = function () { return ResetBrowserAndCache(); };
$$.UI.formatCurrency = function (number, withdecimal = true) { return formatCurrency(number, withdecimal); };
$$.UI.getDateInGMT8 = function () { return getDateInGMT8(); };
$$.UI.RunFunctiononMutation = function (targetidToMonitor, callbackfunction) { return RunFunctiononMutation(targetidToMonitor, callbackfunction); };
$$.UI.Element = {};
$$.UI.Element.appendtobody = function (string) { return appendtobody(string); };
$$.UI.Element.Exists = function (ElementIDtext) { ElementExists(ElementIDtext); };
$$.UI.Element.RemovebyID = function (idstring) { return removeelementbyID(idstring); };
$$.UI.Element.DeleteById = function (id) { return DeleteElementById(id); }
$$.UI.Element.getHTML = function (idetext) { return getElementhtml(idtext); };
$$.UI.Element.setHTML = function (idetext, html) { return setElementhtml(idtext, html); };
$$.UI.Element.getValue = function (idetext) { return getElementvalue(idtext); };
$$.UI.Element.setValue = function (idetext,) { return setElementvalue(idtext, value); };
$$.UI.Validate = {};
$$.UI.Validate.isValidEmail = function (email) { return isValidEmail(email); };
$$.UI.Validate.hasValidMobileFormat = function (usernumber) { return hasValidMobileFormat(usernumber); };
$$.UI.Modal = {};
$$.UI.Modal.Create = function (modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return createmodal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.Show = function (idtxt) { return modalshow(idtxt); };
$$.UI.Modal.Hide = function (idtxt) { return modalhide(); };
$$.UI.Modal.CreateAndShow = function (modalid, modaltitle, modalbody, modalfooter = '', modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.ModalQuickDismiss = function (modaltitle, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true) { return ModalQuickDismiss(modaltitle, modalbody, modalid, modaltohide, functiontodo, conditiontrue) };
$$.UI.Modal.ModalContinueCancel = function (modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext = 'Cancel', continuebuttontext = 'Continue', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning') { return ModalContinueCancel(modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext, continuebuttontext, continuebuttoncss, cancelbuttoncss); };
$$.UI.Modal.hide = function (modalid) { return hidemodal(modalid); };
$$.UI.Modal.show = function (modalid) { return showmodal(modalid); };
$$.UI.col = function (content = '', additionalclass = '') { return col(content, additionalclass); };
$$.UI.row = function (content = '', additionalclass = '', hidden = false, style = '') { return row(content, additionalclass, hidden, style); };
$$.UI.dualcolrow = function (colcontent1, colcontent2, rowclass = '', hidden = false, style = '') { return dualcolrow(colcontent1, colcontent2, rowclass, hidden, style); };
$$.UI.Button = {};
$$.UI.Button.Default = function (content, value = '', onclick = '', idtext = '', setclass = '', addtionaldata = '') { return button(content, value, onclick, idtext, setclass, addtionaldata); };
$$.UI.Button.Warning = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonwarning(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Danger = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttondanger(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Primary = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonprimary(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.HomeMenuButtons = function (buttonicon, buttonText, buttonGo, buttonVariabletoPass = '', iconwidth = '', iconheight = '', buttonstyle = '', buttononclick = '', divclass = '', divid = '', buttonid = '', textclass = '') { return HomeMenuButtons(buttonicon, buttonText, buttonGo, buttonVariabletoPass, iconwidth, iconheight, buttonstyle, buttononclick, divclass, divid, buttonid, textclass); };
$$.UI.Input = {};
$$.UI.Input.textInput = function (idtext = '', setclass = '', required = '', placeholder = '', value = '') { return textinput(idtext, setclass, required, placeholder, value); };
$$.UI.Input.textFormControl = function (idtext = '', addclass = '', required = '', placeholder = '', value = '') { return textformcontrol(idtext, addclass, required, placeholder, value); };
$$.UI.Card = {};
$$.UI.Card.Create = function (cardtitle = '', cardid = '', cardtools = '', cardbodyid = '', cardbodytext = '', cardbodyclassadd = '', maincardstyle = '', titlecardhide = false) { return createCard(cardtitle, cardid, cardtools, cardbodyid, cardbodytext, cardbodyclassadd, maincardstyle, titlecardhide); };
$$.UI.Card.Simple = function (title = '', text = '', id = '') { return CreateCardSimple(title, text, id); };
$$.UIalt = {};
$$.UIalt.hrefonclickButtonGO = function (pagename, pagedatastring = '') { return hrefonclickButtonGO(pagename, pagedatastring); };
$$.UIalt.generateHTMLfromarray = function (prepend, append, array, func) { return generateHTMLfromarray(prepend, append, array, func); };
$$.UIalt.imgiconuserdefault = function (imgsrc, imgwidth = '', imgheight = '', id = '') { return imgiconuserdefault(imgsrc, imgwidth, imgheight, id); };
$$.UIalt.UICardStats = {};
$$.UIalt.UICardStats.UICardStatsDetails = function (Title = '', number = 0, Unit = '', leftORright = 'left', numberid = '') { return UICardStatsDetails(Title, number, Unit, leftORright, numberid); };
$$.UIalt.UICardStats.UIStatsDetailsArray = function (statsarray) { return UIStatsDetailsArray(statsarray); };
$$.UIalt.BalanceCard = {};
$$.UIalt.BalanceCard.UIBalance_WrapperfromArray = function (statsarray) { return UIBalance_WrapperfromArray(statsarray); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item = function (maintitle = '', onclickstring = '', imgsrc = '', href = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '', imgwidth = '', imgheight = '') { return UIBalance_Wrapper_WalletFooter_Item(maintitle, onclickstring, imgsrc, href, subtitleline1, subtitleline2, subtitleline3, subtitleline4, imgwidth, imgheight); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item_ButtonGO = function (maintitle, pagename, pagestring = '', iconclass = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '') { return UIBalance_Wrapper_WalletFooter_Item_ButtonGO(maintitle, pagename, pagestring, iconclass, subtitleline1, subtitleline2, subtitleline3, subtitleline4); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_ARRAY = function (balancewrapper_item_array) { return UIBalance_Wrapper_WalletFooter_ARRAY(balancewrapper_item_array); };
$$.UIalt.BalanceCard.UIcreateBalanceBoxfromArray = function (statsarray, balancewrapper_item_array, style = 'border: solid 3px #000d88;') { return UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array, style); };
$$.UIalt.Services = {};
$$.UIalt.Services.Button = function (imgiconsrc, title = '', onclick = '', href = '', bgcolor8 = false) { return UIServices_Button(imgiconsrc, title, onclick, href, bgcolor8); };
$$.UIalt.Services.Button_GOTOPAGE = function (imgiconsrc, title, pagename, pagedatastring = '') { return UIServices_Button_GOTOPAGE(imgiconsrc, title, pagename, pagedatastring); };
$$.UIalt.Services.FullDIV_GOTOPAGE_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_GOTOPAGE_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Services.FullDIV_ONCLICK_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_ONCLICK_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Sidetext = {};
$$.UIalt.Sidetext.UISideText_DualColumnButton = function (text, pagename, pagedatastring = '', imgsrc = '', imgwidth = '', imgheight = '') { return UISideText_DualColumnButton(text, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.Sidetext.UISideText_DualColumnButton_Array = function (sidetext_button_dualcolumn_array) { return UISideText_DualColumnButton_Array(sidetext_button_dualcolumn_array); };
$$.UIalt.UICardSimple = function (title, text = '', id = '') { return UICardSimple(title, text, id); };
$$.UIalt.RecentSearchBar = {};
$$.UIalt.RecentSearchBar.SearchBar = function (searchplaceholdertext, classtosearch, id, imgsrclefticon = '', imgsrcrighticon = '', imgwidth = '', imgheight = '') { return UIRecentSearchBar(searchplaceholdertext, classtosearch, id, imgsrclefticon, imgsrcrighticon, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO = function (title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIRecentSearchable_Button_GO(title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO_ARRAY = function (title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata = '', viewalltext = '') { return UIRecentSearchable_Button_GO_ARRAY(title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata, viewalltext); };
$$.UIalt.UIListArrowButton_GO = function (title, subtitle, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIListArrowButton_GO(title, subtitle, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.SearchBox_with_BUTTONS_FULL = function (title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY = '', viewallpagetarget, viewallpagedata = '', viewalltext = '', classtosearch = '', searchid = '', searchplaceholdertext = '', searchlefticon = '', searchrighticon = '', imgwidth = '', imgheight = '') { return UISearchBox_with_BUTTONS_FULL(title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY, viewallpagetarget, viewallpagedata, viewalltext, classtosearch, searchid, searchplaceholdertext, searchlefticon, searchrighticon, imgwidth, imgheight); };
$$.UIalt.Input = {};
$$.UIalt.Input.InputGroupCore = function (innerhtml = '', label = '', inputgroupid = '') { return UIinputgroupcore(innerhtml, label, inputgroupid); };
$$.UIalt.Input.InputGroup = function (placeholder, type, id, label = '', classinput = '', spanclass = '', imginsteadofspan = '', required = false, textvalue = '') { return UIInputGroup(placeholder, type, id, label, classinput, spanclass, imginsteadofspan, required, textvalue); };
$$.UIalt.Input.InputGroupSelect = function (id = '', label = '', optionsarray = '', spanclass = '', imginsteadofspan = '', selectedvalue = '') { return UIInputGroupSelect(id, label, optionsarray, spanclass, imginsteadofspan, selectedvalue); };
$$.UIalt.Input.InputGroupDatePicker = function () { return UIInputGroupDatePicker(); };
$$.UIalt.Input.ArraytoOptionforSelect = function (array, selectedvalue = '') { return UIArraytoOptionforSelect(array, selectedvalue); };
$$.UIalt.Input.ReplaceCurrentOptionsSelect = function (selectid, optionsarray, selectedvalue = '') { return UIReplaceCurrentOptionsSelect(selectid, optionsarray, selectedvalue); };
$$.UIalt.Input.InputGroupButton = function (buttontext, buttonclass = '', buttonid = '', onclick = '', buttonstyle = '') { return UIInputGroupButton(buttontext, buttonclass, buttonid, onclick, buttonstyle); };
$$.UIalt.UISetDarkMode = function () { return UISetDarkMode(); };
$$.UIalt.UIUpdateBodyHTML = function (html = '') { return UIUpdateBodyHTML(html); };
$$.UIalt.changeTopbarTitle = function (title) { return changeTopbarTitle(title); };
$$.StatusIntToString = function (Status) { return InttoStrDetailsFuncs.Status(Status); };
</script>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'Lead Details';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.ViewLeadContainer = "viewleadContainer";
LoadDataPageFunc.ids.ViewDetailsLogsContainer = 'ViewDetailsLogsContainer';
LoadDataPageFunc.ids.ViewLeadCard = 'ViewLeadCard';
LoadDataPageFunc.ids.ViewLeadDetailsCardBody = 'ViewLeadDetailsCardBody';
LoadDataPageFunc.ids.PreviousLogsPage = 'prevBtnLogsLeadDetailsPage';
LoadDataPageFunc.ids.NextLogsPage = 'nextBtnLogsLeadDetailsPage';
LoadDataPageFunc.ids.ChangeStatus_Select = 'ViewLeadDetails_ChangeStatus_Select';
LoadDataPageFunc.onclicks = {};
LoadDataPageFunc.onclicks.EditDetailsModalOnclick = 'LoadDataPageFunc.EditDetails.EditDetailsModal();';
LoadDataPageFunc.Logs = {};
LoadDataPageFunc.Logs.Pagination = {};
LoadDataPageFunc.Logs.Pagination.cardsPerPage = 5;
LoadDataPageFunc.Logs.Pagination.currentPage = 1;
LoadDataPageFunc.Logs.LogRowCard = function (Date = '', content = '') {
content = replaceLineBreaks(content);
return (UICardSimple('', formatDateTimetoReadable(Date) + '<br><br><h4>' + content + '</h4>'));
};
LoadDataPageFunc.Logs.Pagination.PageArray = function () {
return divideArrayIntoSets(LoadDataPageFunc.Logs.LogsCardRowHTMLArray, LoadDataPageFunc.Logs.Pagination.cardsPerPage);
};
LoadDataPageFunc.Logs.Pagination.Firstpage = 1;
LoadDataPageFunc.Logs.Pagination.Lastpage = function () {
return LoadDataPageFunc.Logs.Pagination.PageArray().length;
};
LoadDataPageFunc.Logs.LogsCardRowHTMLArray = [];
LoadDataPageFunc.Logs.Pagination.FirstPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.Pagination.LastPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.MiddlePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.LogRowHtmlPage = function (page = 1) {
if (page) { LoadDataPageFunc.Logs.Pagination.currentPage = page; }
let arrayset = LoadDataPageFunc.Logs.Pagination.PageArray();
let newpageindex = LoadDataPageFunc.Logs.Pagination.currentPage - 1;
if (!isIndexAccessibleArray(arrayset, newpageindex)) {
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(page);
let targetarr = arrayset[newpageindex];
const htmlstr = targetarr.join('<br>');
$('#' + LoadDataPageFunc.ids.ViewDetailsLogsContainer).html(htmlstr);
};
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton = function (newpage) {
if (newpage <= LoadDataPageFunc.Logs.Pagination.Firstpage) { LoadDataPageFunc.Logs.Pagination.FirstPageFound(); }
else if (newpage >= LoadDataPageFunc.Logs.Pagination.LastPageFound()) {
LoadDataPageFunc.Logs.Pagination.FirstPageFound();
} else if (LoadDataPageFunc.Logs.Pagination.Lastpage() == 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
} else if (newpage > LoadDataPageFunc.Logs.Pagination.Firstpage && newpage < LoadDataPageFunc.Logs.Pagination.Lastpage()) {
LoadDataPageFunc.Logs.Pagination.MiddlePageFound();
}
if (LoadDataPageFunc.Logs.Pagination.Lastpage() === 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
}
};
LoadDataPageFunc.Logs.changePage = function (forwardORBackward) {
if (!forwardORBackward) { return false; }
let newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
if (forwardORBackward === -1) { newpage = newpage - 1; }
else if (forwardORBackward === 1) { newpage = newpage + 1; }
if (newpage < LoadDataPageFunc.Logs.Pagination.Firstpage || newpage > LoadDataPageFunc.Logs.Pagination.Lastpage()) {
newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(newpage);
LoadDataPageFunc.Logs.Pagination.currentPage = newpage;
// Load the new page
LoadDataPageFunc.Logs.LogRowHtmlPage(newpage);
};
LoadDataPageFunc.Logs.LogFullCard = function (obj) {
if (!obj.logs) { return ''; }
LoadDataPageFunc.LogsCardRowHTMLArray = [];
let newlogfullarr = [];
if (obj.logs && Array.isArray(obj.logs)) {
newlogfullarr.push('<br><br><div id="' + LoadDataPageFunc.ids.ViewDetailsLogsContainer + '">');
let logrow = '';
const reversedLogs = [...obj.logs].reverse();
for (let log of reversedLogs) {
logrow = LoadDataPageFunc.Logs.LogRowCard(log[0], log[1]);
LoadDataPageFunc.Logs.LogsCardRowHTMLArray.push(logrow);
// newlogfullarr.push(logrow);
}
}
newlogfullarr.push('</div>');
return newlogfullarr.join('');
};
LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
if (!istrue) { return false; }
Preloaders.ViewLeadDetailsData(currenttarget, false,
function () {
ReloadPage();
}
);
};
LoadDataPageFunc.LeadDetailsCardControls = function () {
let buttonLImaker = function (text, onclick, icon) {
return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
};
let htmlarr = [`<div class="mt-5"><div class="tf-container">`];
htmlarr.push('<ul class="box-service mt-3">');
htmlarr.push(buttonLImaker('Change Status', 'LoadDataPageFunc.ChangeStatus.NewStatusModal();', 'changestatus.png'));
htmlarr.push(buttonLImaker('Add Logs', 'LoadDataPageFunc.Logs.AddLogsModal();', 'logs.png'));
htmlarr.push(buttonLImaker('Edit Details', LoadDataPageFunc.onclicks.EditDetailsModalOnclick, 'edit.png'));
htmlarr.push(buttonLImaker('View Property Details', `ButtonGo('ViewPropertyDetails','${LoadDataPageFunc.Details.target_property}')`, 'house.png'));
htmlarr.push(buttonLImaker('Declare As Sold', `LoadDataPageFunc.SetAsSold.ModalConfirm()`, 'sold.png'));
htmlarr.push('</ul</div></div>');
return htmlarr.join('');
};
LoadDataPageFunc.Logs.SubmitNewLog = function () {
let ShowEmptyTextModal = function () { ModalQuickDismiss('No Input', 'Please input text as log.') };
let ShowUnabletoAddLog = function () { ModalQuickDismiss('Error', 'Unable to Add Log.') };
let ShowSuccess = function () { ModalQuickDismiss('Success', 'New Log Added.') };
let ShowError = function (errorstring) { ModalQuickDismiss('Error', 'Error Occured. <br><br>' + errorstring) };
let newlogtext = $('#newlogtextarea').val();
if (!newlogtext) {
ShowEmptyTextModal();
return false;
}
request
.url('/ViewLeadPage/controls/logs/add')
.type('POST')
.fromVarCache(false)
.data({ target: currenttarget, newlog: newlogtext })
.success((response) => {
if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(istrue = true);
ShowSuccess();
modalhide('ViewDetailsNewLogModal');
return true;
} else {
ShowUnabletoAddLog();
return false;
}
})
.error((err) => {
ShowError(err);
return false;
})
.caching(false)
.go();
};
LoadDataPageFunc.Logs.AddLogsModal = function () {
let modalbody = `<label for="newlogtextarea">Log:</label>
<textarea id="newlogtextarea" rows="10" cols="50" placeholder="Enter the log here..."></textarea>`;
CreateAndShowModal('ViewDetailsNewLogModal', 'New Log', modalbody, buttonprimary('Add New Log', value = '', onclick = 'LoadDataPageFunc.Logs.SubmitNewLog();', block = '', idtext = 'ViewLeadDetailsAddLogButton'));
};
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Details.Status = '';
LoadDataPageFunc.LeadDetailsCard = function (obj) {
if (!obj) { return false; }
let rowcoldetail = [];
const LeadName = obj.fullname || false;
const DateCreated = formatDateTimetoReadable(obj.created) || false;
const DateModified = formatDateTimetoReadable(obj.modified) || false;
let Status = obj.status;
const Referrer = obj.referral || false;
const TargetProperty = obj.property_name || false;
const TargetViewingDate = formatDateTimetoReadable(obj.target_viewing_date) || false;
const Mobile = obj.mobile || false;
const Landline = obj.landline || false;
const Email = obj.email || false;
LoadDataPageFunc.Details.Status = Status;
Status = InttoStrDetailsFuncs.Status(Status);
const AddDualColifValue = function (varstr, label) {
if (varstr !== false && varstr !== null) {
rowcoldetail.push(dualcolrow(label, varstr));
}
};
AddDualColifValue(DateModified, 'Last Activity');
AddDualColifValue(Status, 'Status');
AddDualColifValue(Referrer, 'Referrer');
AddDualColifValue(`<a href="javascript:void(0);" onclick="ButtonGo('ViewPropertyDetails','${obj.target_property}')">` + TargetProperty + '</a>', 'Target Property');
AddDualColifValue(TargetViewingDate, 'Target Viewing Date');
AddDualColifValue(Mobile, 'Mobile');
AddDualColifValue(Landline, 'Landline');
AddDualColifValue(Email, 'Email');
rowcoldetail.push('<br><br>');
rowcoldetail.push(LoadDataPageFunc.LeadDetailsCardControls());
rowcoldetail.push(LoadDataPageFunc.Logs.LogFullCard(obj));
const finalRowColDetail = rowcoldetail.join('');
let ViewLeadCardDetails = createCard(LeadName, LoadDataPageFunc.ids.ViewLeadCard, DateCreated, LoadDataPageFunc.ids.ViewLeadDetailsCardBody, cardbody = finalRowColDetail);
return ViewLeadCardDetails;
};
LoadDataPageFunc.ChangeStatus = {};
LoadDataPageFunc.ids.ChangeStatusModal = 'ViewDetails_ChangeStatusModal';
LoadDataPageFunc.ChangeStatus.NewStatusModal = function () {
const StatusSelect = $$.UIalt.Input.InputGroupSelect(LoadDataPageFunc.ids.ChangeStatus_Select, '', [
[-2, $$.StatusIntToString(-2)],
[-1, $$.StatusIntToString(-1)],
[0, $$.StatusIntToString(0)],
[1, $$.StatusIntToString(1)],
[2, $$.StatusIntToString(2)],
[3, $$.StatusIntToString(3)],
[4, $$.StatusIntToString(4)],
[5, $$.StatusIntToString(5)]], '', '', LoadDataPageFunc.Details.Status);
const htmltext = 'Update the Status of the Lead';
let modalbody = StatusSelect + htmltext;
CreateAndShowModal(LoadDataPageFunc.ids.ChangeStatusModal, 'Update Status', modalbody, buttonprimary('Update', value = '', onclick = 'LoadDataPageFunc.ChangeStatus.Submit();', block = '', idtext = ''));
};
LoadDataPageFunc.ChangeStatus.Submit = function () {
const sel = $('#' + LoadDataPageFunc.ids.ChangeStatus_Select).val();
const selectedstatus = (sel !== null) ? sel : null;
if (selectedstatus === null) { $$.UI.Modal.ModalQuickDismiss('', 'Select a Status'); return false; }
if (selectedstatus == LoadDataPageFunc.Details.Status) { $$.UI.Modal.ModalQuickDismiss('', 'Nothing to Change!'); return false; }
let request = new RequestData(false);
request
.url('/ViewLead/Details/ChangeStatus')
.type('POST')
.fromVarCache(false)
.data({ target: currenttarget, newstatus: selectedstatus })
.success((response) => {
// console.log(response);
if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(true);
$$.UI.Modal.ModalQuickDismiss('', 'Success!');
hidemodal(LoadDataPageFunc.ids.ChangeStatusModal);
return true;
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable To Change Status<br><br>' + err);
})
.go();
};
LoadDataPageFunc.ids.EditDetailsModal = 'ViewLeads_EditDetailsModal';
LoadDataPageFunc.EditDetails = {};
LoadDataPageFunc.ids.EditDetails_Fullname = 'ViewLeads-EditDetailsFullname';
LoadDataPageFunc.ids.EditDetails_Mobile = 'ViewLeads-EditDetailsmobile';
LoadDataPageFunc.ids.EditDetails_Landline = 'ViewLeads-EditDetailslandline';
LoadDataPageFunc.ids.EditDetails_Email = 'ViewLeads-EditDetailsemail';
LoadDataPageFunc.ids.EditDetails_ViewingDate = 'ViewLeads-EditDetailspreferreddate';
LoadDataPageFunc.ids.EditDetails_Property = 'ViewLeads-EditDetailsPreferredSite';
LoadDataPageFunc.EditDetails.EditDetailsModal = function () {
$('#' + LoadDataPageFunc.ids.EditDetailsModal).remove();
Preloaders.PreferredSitesOption(fromVarCache = false, successfunc = false);
const SubmitOnclick = '';
const targetdiv = 'modal-body-' + LoadDataPageFunc.ids.EditDetailsModal;
let FormHTML = ReusableUIElements.NewLeadsGenerateUI(targetdiv, idprefix = 'ViewLeads-EditDetails', replace = false, LoadDataPageFunc.Details.fullname, LoadDataPageFunc.Details.mobile, LoadDataPageFunc.Details.landline, LoadDataPageFunc.Details.email, LoadDataPageFunc.Details.target_viewing_date, LoadDataPageFunc.Details.target_property, false, true);
const footer = buttonprimary('Update', '', onclick = 'LoadDataPageFunc.EditDetails.Submit();');
const modalhtml = $$.UI.Modal.Create(LoadDataPageFunc.ids.EditDetailsModal, 'Update Details', FormHTML, footer);
$$.UI.Element.appendtobody(modalhtml);
Preloaders.PreferredSitesOption(fromVarCache = true, function (response) {
UIReplaceCurrentOptionsSelect(idprefix + 'PreferredSite', response);
$(idprefix + 'PreferredSite').val(LoadDataPageFunc.Details.target_property);
$$.UI.Modal.Show(LoadDataPageFunc.ids.EditDetailsModal);
});
};
LoadDataPageFunc.EditDetails.GetChanges = function () {
let objectdata = {};
objectdata.target = currenttarget;
const new_fullname = $('#' + LoadDataPageFunc.ids.EditDetails_Fullname).val();
const new_mobile = $('#' + LoadDataPageFunc.ids.EditDetails_Mobile).val();
const new_landline = $('#' + LoadDataPageFunc.ids.EditDetails_Landline).val();
const new_email = $('#' + LoadDataPageFunc.ids.EditDetails_Email).val();
const new_viewingdate = $('#' + LoadDataPageFunc.ids.EditDetails_ViewingDate).val();
const new_property = $('#' + LoadDataPageFunc.ids.EditDetails_Property).val();
let changes = 0;
if (LoadDataPageFunc.Details.fullname !== new_fullname) { objectdata.fullname = new_fullname; changes++; }
if (LoadDataPageFunc.Details.mobile !== new_mobile) { objectdata.mobile = new_mobile; changes++; }
if (LoadDataPageFunc.Details.landline !== new_landline) { objectdata.landline = new_landline; changes++; }
if (LoadDataPageFunc.Details.email !== new_email) { objectdata.email = new_email; changes++; }
if (LoadDataPageFunc.Details.target_viewing_date !== new_viewingdate) { objectdata.target_viewing_date = new_viewingdate; changes++; }
if (LoadDataPageFunc.Details.target_property !== new_property) { objectdata.target_property = new_property; changes++; }
if (!changes) { return false; }
return objectdata;
};
LoadDataPageFunc.EditDetails.Submit = function () {
let ChangesObject = LoadDataPageFunc.EditDetails.GetChanges();
if (!ChangesObject) { $$.UI.Modal.ModalQuickDismiss('No Changes', 'No Changes to Update!'); return false; }
if (ChangesObject.fullname === '' || ChangesObject.fullname === false || ChangesObject.mobile === '' || ChangesObject.mobile === false || ChangesObject.email === false || ChangesObject.email === '') { $$.UI.Modal.ModalQuickDismiss('Incomplete Details', 'The Following Details are REQUIRED!<br><br>Fullname<br>Mobile<br>Email'); return false; }
if (ChangesObject.mobile && !hasValidMobileFormat(ChangesObject.mobile)) { toastr.error('Incorrect Mobile Format. Must Be 11 Digits!'); }
if (ChangesObject.email && !isValidEmail(ChangesObject.email)) { toastr.error('Incorrect Email Format'); }
let SendUpdatedDetails = new RequestData(false);
request
.url('/ViewLead/Details/Edit/Submit')
.type('POST')
.fromVarCache(false)
.data(ChangesObject)
.success((response) => {
if (!response) { return false; }
const error = response.error || false;
if (response !== true) {
if (error) { $$.UI.Modal.ModalQuickDismiss('Error', error); }
return false;
} else if (response === true) {
LoadDataPageFunc.RefetchDataAndReload();
hidemodal(LoadDataPageFunc.ids.EditDetailsModal);
$$.UI.Modal.ModalQuickDismiss('Success', 'Details Updated');
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + errordesc);
})
.go();
};
LoadDataPageFunc.SetAsSold = {};
LoadDataPageFunc.ids.FinalRemarks = 'FinalRemarksAsSold';
LoadDataPageFunc.ids.SetAsSoldModal = 'SetAsSoldModal';
LoadDataPageFunc.SetAsSold.ModalConfirm = function () {
if (LoadDataPageFunc.Details.status===5){ModalQuickDismiss('', 'Already Sold!'); return;}
let modalbody = 'Remarks<br><br><textarea id="'+LoadDataPageFunc.ids.FinalRemarks+'"></textarea>';
CreateAndShowModal(LoadDataPageFunc.ids.SetAsSoldModal, 'Set as Sold', modalbody, buttonprimary('Sold', value = '', onclick = ' LoadDataPageFunc.SetAsSold.Submit();', block = '', idtext = ''));
};
LoadDataPageFunc.SetAsSold.Submit = function () {
const FinalRemarks = $('#' + LoadDataPageFunc.ids.FinalRemarks).val();
const SetAsSoldDetails = {
'Final_Remarks': FinalRemarks,
target: currenttarget
};
let SendData = new RequestData(false);
SendData
.url('/ViewLead/Details/Edit/SetAsSold')
.type('POST')
.fromVarCache(false)
.data(SetAsSoldDetails)
.success((response) => {
const error = response.error || false;
if (response !== true) {
if (error) { $$.UI.Modal.ModalQuickDismiss('Error', error); }
return false;
} else if (response === true) {
LoadDataPageFunc.RefetchDataAndReload();
hidemodal(LoadDataPageFunc.ids.SetAsSoldModal);
$$.UI.Modal.ModalQuickDismiss('Success', 'Leads Set as Complete and Sold');
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + errordesc);
})
.go();
};
LoadDataPageFunc.main = function () {
let request = new RequestData(true);
request
.url('/ViewLead/Details/data')
.type('POST')
.fromVarCache(true)
.data({ target: currenttarget })
.success((response) => {
if (response.success ===false){
ModalQuickDismiss('Error', 'Unable to Load<br>' + response.message);
return false;
}
LoadDataPageFunc.ViewLeadCurrentDetails = response.Details;
LoadDataPageFunc.Details = response.Details;
if (currentPage !== 'ViewLeadDetails') { return false; }
$('#' + LoadDataPageFunc.ids.ViewLeadContainer).html(LoadDataPageFunc.LeadDetailsCard(response.Details));
LoadDataPageFunc.Logs.LogRowHtmlPage();
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + errordesc);
})
.go();
// let mainhtmlviewlead = ViewLeadCardDetails;
// $('#viewleadContainer').html(mainhtmlviewlead);
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

View File

@@ -0,0 +1,799 @@
<br><br>
<div id="viewContainer">
</div>
<div class="pagination">
<button id="prevBtnLogsPropertyDetailsPage" class="btn btn-primary"
onclick="LoadDataPageFunc.Logs.changePage(-1)">Next</button>
<span id="pageInfo"></span>
<button id="nextBtnLogsPropertyDetailsPage" class="btn btn-primary"
onclick="LoadDataPageFunc.Logs.changePage(1)">Previous</button>
</div>
<script> $$ = {};
$$.UI = {};
$$.UI.Table = {};
$$.UI.Table.CreateTable = function (id, theadinnerhtml, bodyinnerhtml) { return CreateTable(id, theadinnerhtml, bodyinnerhtml); };
$$.UI.Table.GenerateTheadFromArraySimple = function (array) { return GenerateTheadFromArraySimple(array); };
$$.UI.Table.GenerateTableRowFromArraySimple = function (array) { return GenerateTableRowFromArraySimple(array); };
$$.UI.ResetBrowserAndCache = function () { return ResetBrowserAndCache(); };
$$.UI.formatCurrency = function (number, withdecimal = true) { return formatCurrency(number, withdecimal); };
$$.UI.getDateInGMT8 = function () { return getDateInGMT8(); };
$$.UI.RunFunctiononMutation = function (targetidToMonitor, callbackfunction) { return RunFunctiononMutation(targetidToMonitor, callbackfunction); };
$$.UI.Element = {};
$$.UI.Element.appendtobody = function (string) { return appendtobody(string); };
$$.UI.Element.Exists = function (ElementIDtext) { ElementExists(ElementIDtext); };
$$.UI.Element.RemovebyID = function (idstring) { return removeelementbyID(idstring); };
$$.UI.Element.DeleteById = function (id) { return DeleteElementById(id); }
$$.UI.Element.getHTML = function (idetext) { return getElementhtml(idtext); };
$$.UI.Element.setHTML = function (idetext, html) { return setElementhtml(idtext, html); };
$$.UI.Element.getValue = function (idetext) { return getElementvalue(idtext); };
$$.UI.Element.setValue = function (idetext,) { return setElementvalue(idtext, value); };
$$.UI.Validate = {};
$$.UI.Validate.isValidEmail = function (email) { return isValidEmail(email); };
$$.UI.Validate.hasValidMobileFormat = function (usernumber) { return hasValidMobileFormat(usernumber); };
$$.UI.Modal = {};
$$.UI.Modal.Create = function (modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return createmodal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.Show = function (idtxt) { return modalshow(idtxt); };
$$.UI.Modal.Hide = function (idtxt) { return modalhide(); };
$$.UI.Modal.CreateAndShow = function (modalid, modaltitle, modalbody, modalfooter = '', modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.ModalQuickDismiss = function (modaltitle, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true) { return ModalQuickDismiss(modaltitle, modalbody, modalid, modaltohide, functiontodo, conditiontrue) };
$$.UI.Modal.ModalContinueCancel = function (modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext = 'Cancel', continuebuttontext = 'Continue', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning') { return ModalContinueCancel(modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext, continuebuttontext, continuebuttoncss, cancelbuttoncss); };
$$.UI.Modal.hide = function (modalid) { return hidemodal(modalid); };
$$.UI.Modal.show = function (modalid) { return showmodal(modalid); };
$$.UI.col = function (content = '', additionalclass = '') { return col(content, additionalclass); };
$$.UI.row = function (content = '', additionalclass = '', hidden = false, style = '') { return row(content, additionalclass, hidden, style); };
$$.UI.dualcolrow = function (colcontent1, colcontent2, rowclass = '', hidden = false, style = '') { return dualcolrow(colcontent1, colcontent2, rowclass, hidden, style); };
$$.UI.Button = {};
$$.UI.Button.Default = function (content, value = '', onclick = '', idtext = '', setclass = '', addtionaldata = '') { return button(content, value, onclick, idtext, setclass, addtionaldata); };
$$.UI.Button.Warning = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonwarning(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Danger = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttondanger(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Primary = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonprimary(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.HomeMenuButtons = function (buttonicon, buttonText, buttonGo, buttonVariabletoPass = '', iconwidth = '', iconheight = '', buttonstyle = '', buttononclick = '', divclass = '', divid = '', buttonid = '', textclass = '') { return HomeMenuButtons(buttonicon, buttonText, buttonGo, buttonVariabletoPass, iconwidth, iconheight, buttonstyle, buttononclick, divclass, divid, buttonid, textclass); };
$$.UI.Input = {};
$$.UI.Input.textInput = function (idtext = '', setclass = '', required = '', placeholder = '', value = '') { return textinput(idtext, setclass, required, placeholder, value); };
$$.UI.Input.textFormControl = function (idtext = '', addclass = '', required = '', placeholder = '', value = '') { return textformcontrol(idtext, addclass, required, placeholder, value); };
$$.UI.Card = {};
$$.UI.Card.Create = function (cardtitle = '', cardid = '', cardtools = '', cardbodyid = '', cardbodytext = '', cardbodyclassadd = '', maincardstyle = '', titlecardhide = false) { return createCard(cardtitle, cardid, cardtools, cardbodyid, cardbodytext, cardbodyclassadd, maincardstyle, titlecardhide); };
$$.UI.Card.Simple = function (title = '', text = '', id = '') { return CreateCardSimple(title, text, id); };
$$.UIalt = {};
$$.UIalt.hrefonclickButtonGO = function (pagename, pagedatastring = '') { return hrefonclickButtonGO(pagename, pagedatastring); };
$$.UIalt.generateHTMLfromarray = function (prepend, append, array, func) { return generateHTMLfromarray(prepend, append, array, func); };
$$.UIalt.imgiconuserdefault = function (imgsrc, imgwidth = '', imgheight = '', id = '') { return imgiconuserdefault(imgsrc, imgwidth, imgheight, id); };
$$.UIalt.UICardStats = {};
$$.UIalt.UICardStats.UICardStatsDetails = function (Title = '', number = 0, Unit = '', leftORright = 'left', numberid = '') { return UICardStatsDetails(Title, number, Unit, leftORright, numberid); };
$$.UIalt.UICardStats.UIStatsDetailsArray = function (statsarray) { return UIStatsDetailsArray(statsarray); };
$$.UIalt.BalanceCard = {};
$$.UIalt.BalanceCard.UIBalance_WrapperfromArray = function (statsarray) { return UIBalance_WrapperfromArray(statsarray); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item = function (maintitle = '', onclickstring = '', imgsrc = '', href = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '', imgwidth = '', imgheight = '') { return UIBalance_Wrapper_WalletFooter_Item(maintitle, onclickstring, imgsrc, href, subtitleline1, subtitleline2, subtitleline3, subtitleline4, imgwidth, imgheight); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item_ButtonGO = function (maintitle, pagename, pagestring = '', iconclass = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '') { return UIBalance_Wrapper_WalletFooter_Item_ButtonGO(maintitle, pagename, pagestring, iconclass, subtitleline1, subtitleline2, subtitleline3, subtitleline4); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_ARRAY = function (balancewrapper_item_array) { return UIBalance_Wrapper_WalletFooter_ARRAY(balancewrapper_item_array); };
$$.UIalt.BalanceCard.UIcreateBalanceBoxfromArray = function (statsarray, balancewrapper_item_array, style = 'border: solid 3px #000d88;') { return UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array, style); };
$$.UIalt.Services = {};
$$.UIalt.Services.Button = function (imgiconsrc, title = '', onclick = '', href = '', bgcolor8 = false) { return UIServices_Button(imgiconsrc, title, onclick, href, bgcolor8); };
$$.UIalt.Services.Button_GOTOPAGE = function (imgiconsrc, title, pagename, pagedatastring = '') { return UIServices_Button_GOTOPAGE(imgiconsrc, title, pagename, pagedatastring); };
$$.UIalt.Services.FullDIV_GOTOPAGE_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_GOTOPAGE_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Services.FullDIV_ONCLICK_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_ONCLICK_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Sidetext = {};
$$.UIalt.Sidetext.UISideText_DualColumnButton = function (text, pagename, pagedatastring = '', imgsrc = '', imgwidth = '', imgheight = '') { return UISideText_DualColumnButton(text, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.Sidetext.UISideText_DualColumnButton_Array = function (sidetext_button_dualcolumn_array) { return UISideText_DualColumnButton_Array(sidetext_button_dualcolumn_array); };
$$.UIalt.UICardSimple = function (title, text = '', id = '') { return UICardSimple(title, text, id); };
$$.UIalt.RecentSearchBar = {};
$$.UIalt.RecentSearchBar.SearchBar = function (searchplaceholdertext, classtosearch, id, imgsrclefticon = '', imgsrcrighticon = '', imgwidth = '', imgheight = '') { return UIRecentSearchBar(searchplaceholdertext, classtosearch, id, imgsrclefticon, imgsrcrighticon, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO = function (title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIRecentSearchable_Button_GO(title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO_ARRAY = function (title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata = '', viewalltext = '') { return UIRecentSearchable_Button_GO_ARRAY(title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata, viewalltext); };
$$.UIalt.UIListArrowButton_GO = function (title, subtitle, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIListArrowButton_GO(title, subtitle, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.SearchBox_with_BUTTONS_FULL = function (title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY = '', viewallpagetarget, viewallpagedata = '', viewalltext = '', classtosearch = '', searchid = '', searchplaceholdertext = '', searchlefticon = '', searchrighticon = '', imgwidth = '', imgheight = '') { return UISearchBox_with_BUTTONS_FULL(title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY, viewallpagetarget, viewallpagedata, viewalltext, classtosearch, searchid, searchplaceholdertext, searchlefticon, searchrighticon, imgwidth, imgheight); };
$$.UIalt.Input = {};
$$.UIalt.Input.InputGroupCore = function (innerhtml = '', label = '', inputgroupid = '') { return UIinputgroupcore(innerhtml, label, inputgroupid); };
$$.UIalt.Input.InputGroup = function (placeholder, type, id, label = '', classinput = '', spanclass = '', imginsteadofspan = '', required = false, textvalue = '') { return UIInputGroup(placeholder, type, id, label, classinput, spanclass, imginsteadofspan, required, textvalue); };
$$.UIalt.Input.InputGroupSelect = function (id = '', label = '', optionsarray = '', spanclass = '', imginsteadofspan = '', selectedvalue = '') { return UIInputGroupSelect(id, label, optionsarray, spanclass, imginsteadofspan, selectedvalue); };
$$.UIalt.Input.InputGroupDatePicker = function () { return UIInputGroupDatePicker(); };
$$.UIalt.Input.ArraytoOptionforSelect = function (array, selectedvalue = '') { return UIArraytoOptionforSelect(array, selectedvalue); };
$$.UIalt.Input.ReplaceCurrentOptionsSelect = function (selectid, optionsarray, selectedvalue = '') { return UIReplaceCurrentOptionsSelect(selectid, optionsarray, selectedvalue); };
$$.UIalt.Input.InputGroupButton = function (buttontext, buttonclass = '', buttonid = '', onclick = '', buttonstyle = '') { return UIInputGroupButton(buttontext, buttonclass, buttonid, onclick, buttonstyle); };
$$.UIalt.UISetDarkMode = function () { return UISetDarkMode(); };
$$.UIalt.UIUpdateBodyHTML = function (html = '') { return UIUpdateBodyHTML(html); };
$$.UIalt.changeTopbarTitle = function (title) { return changeTopbarTitle(title); };
$$.StatusIntToString = function (Status) { return InttoStrDetailsFuncs.Status(Status); };
$$.StatusPropertiesIntToString = function (Status) { return InttoStrDetailsFuncs.PropertyStatus(Status); };
</script>
<script>
Target_Uploaded_Files = [];
LoadDataPageFunc = {};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.PageTitle = 'Property Details';
LoadDataPageFunc.currentTargetPage = 'ViewPropertyDetails';
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.MainData = '/View/Property/Details';
LoadDataPageFunc.URLs.AddLog = '/View/Property/Details/Logs/Add';
LoadDataPageFunc.URLs.SubmitEdit = '/View/Property/Details/Edit/Submit';
LoadDataPageFunc.URLs.ChangeStatus = '/View/Property/Details/ChangeStatus'
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.ViewPropertyContainer = "viewContainer";
LoadDataPageFunc.ids.ViewDetailsLogsContainer = 'ViewDetailsLogsContainer';
LoadDataPageFunc.ids.ViewPropertyCard = 'ViewPropertyCard';
LoadDataPageFunc.ids.ViewPropertyDetailsCardBody = 'ViewPropertyDetailsCardBody';
LoadDataPageFunc.ids.PreviousLogsPage = 'prevBtnLogsPropertyDetailsPage';
LoadDataPageFunc.ids.NextLogsPage = 'nextBtnLogsPropertyDetailsPage';
LoadDataPageFunc.ids.ChangeStatus_Select = 'ViewPropertyDetails_ChangeStatus_Select';
LoadDataPageFunc.onclicks = {};
LoadDataPageFunc.onclicks.EditDetailsModalOnclick = 'LoadDataPageFunc.EditDetails.EditDetailsModal();';
LoadDataPageFunc.Logs = {};
LoadDataPageFunc.Logs.Pagination = {};
LoadDataPageFunc.Logs.Pagination.cardsPerPage = 5;
LoadDataPageFunc.Logs.Pagination.currentPage = 1;
LoadDataPageFunc.Logs.LogRowCard = function (Date = '', content = '') {
content = replaceLineBreaks(content);
return (UICardSimple('', formatDateTimetoReadable(Date) + '<br><br><h4>' + content + '</h4>'));
};
LoadDataPageFunc.Logs.Pagination.PageArray = function () {
return divideArrayIntoSets(LoadDataPageFunc.Logs.LogsCardRowHTMLArray, LoadDataPageFunc.Logs.Pagination.cardsPerPage);
};
LoadDataPageFunc.Logs.Pagination.Firstpage = 1;
LoadDataPageFunc.Logs.Pagination.Lastpage = function () {
return LoadDataPageFunc.Logs.Pagination.PageArray().length;
};
LoadDataPageFunc.Logs.LogsCardRowHTMLArray = [];
LoadDataPageFunc.Logs.Pagination.FirstPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.Pagination.LastPageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.MiddlePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
};
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound = function () {
$('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
$('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
};
LoadDataPageFunc.Logs.LogRowHtmlPage = function (page = 1) {
if (page) { LoadDataPageFunc.Logs.Pagination.currentPage = page; }
let arrayset = LoadDataPageFunc.Logs.Pagination.PageArray();
let newpageindex = LoadDataPageFunc.Logs.Pagination.currentPage - 1;
if (!isIndexAccessibleArray(arrayset, newpageindex)) {
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(page);
let targetarr = arrayset[newpageindex];
const htmlstr = targetarr.join('<br>');
$('#' + LoadDataPageFunc.ids.ViewDetailsLogsContainer).html(htmlstr);
};
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton = function (newpage) {
if (newpage <= LoadDataPageFunc.Logs.Pagination.Firstpage) { LoadDataPageFunc.Logs.Pagination.FirstPageFound(); }
else if (newpage >= LoadDataPageFunc.Logs.Pagination.LastPageFound()) {
LoadDataPageFunc.Logs.Pagination.FirstPageFound();
} else if (LoadDataPageFunc.Logs.Pagination.Lastpage() == 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
} else if (newpage > LoadDataPageFunc.Logs.Pagination.Firstpage && newpage < LoadDataPageFunc.Logs.Pagination.Lastpage()) {
LoadDataPageFunc.Logs.Pagination.MiddlePageFound();
}
if (LoadDataPageFunc.Logs.Pagination.Lastpage() === 1) {
LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
}
};
LoadDataPageFunc.Logs.changePage = function (forwardORBackward) {
if (!forwardORBackward) { return false; }
let newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
if (forwardORBackward === -1) { newpage = newpage - 1; }
else if (forwardORBackward === 1) { newpage = newpage + 1; }
if (newpage < LoadDataPageFunc.Logs.Pagination.Firstpage || newpage > LoadDataPageFunc.Logs.Pagination.Lastpage()) {
newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
return false;
}
LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(newpage);
LoadDataPageFunc.Logs.Pagination.currentPage = newpage;
// Load the new page
LoadDataPageFunc.Logs.LogRowHtmlPage(newpage);
};
LoadDataPageFunc.Logs.LogFullCard = function (obj) {
if (!obj.logs) { return ''; }
LoadDataPageFunc.LogsCardRowHTMLArray = [];
let newlogfullarr = [];
if (typeof obj.logs === 'string') {
obj.logs = JSON.parse(obj.logs);
}
if (obj.logs && Array.isArray(obj.logs)) {
newlogfullarr.push('<br><br><div id="' + LoadDataPageFunc.ids.ViewDetailsLogsContainer + '">');
let logrow = '';
const reversedLogs = [...obj.logs].reverse();
for (let log of reversedLogs) {
logrow = LoadDataPageFunc.Logs.LogRowCard(log[0], log[1]);
LoadDataPageFunc.Logs.LogsCardRowHTMLArray.push(logrow);
// newlogfullarr.push(logrow);
}
}
newlogfullarr.push('</div>');
return newlogfullarr.join('');
};
LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
if (!istrue) { return false; }
Preloaders.ViewPropertyDetailsData(currenttarget, false,
function (response) {
ReloadPage();
}
);
};
LoadDataPageFunc.buttonLImaker = function (text, onclick, icon) {
return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
};
LoadDataPageFunc.buttonContainer = function (BUTTONSstr) {
return `<div class="mt-5"><div class="tf-container">` + '<ul class="box-service mt-3">' + BUTTONSstr + '</ul</div></div>';
};
LoadDataPageFunc.DetailsCardControls = function () {
let buttonLImaker = LoadDataPageFunc.buttonLImaker;
let htmlarr = [`<div class="mt-5"><div class="tf-container">`];
htmlarr.push('<ul class="box-service mt-3">');
htmlarr.push(buttonLImaker('Change Status', 'LoadDataPageFunc.ChangeStatus.NewStatusModal();', 'changestatus.png'));
htmlarr.push(buttonLImaker('Add Logs', 'LoadDataPageFunc.Logs.AddLogsModal();', 'logs.png'));
htmlarr.push(buttonLImaker('Edit Details', LoadDataPageFunc.onclicks.EditDetailsModalOnclick, 'edit.png'));
htmlarr.push(buttonLImaker('Leads', "ButtonGo('LeadsByProperty','" + currenttarget + "');", 'ListLeads.png'));
htmlarr.push(buttonLImaker('Referral URL', 'LoadDataPageFunc.MyReferralURL.ReferralURLModal();', 'betshistory.png'));
htmlarr.push('</ul</div></div>');
return htmlarr.join('');
};
LoadDataPageFunc.Logs.SubmitNewLog = function () {
let ShowEmptyTextModal = function () { ModalQuickDismiss('No Input', 'Please input text as log.') };
let ShowUnabletoAddLog = function () { ModalQuickDismiss('Error', 'Unable to Add Log.') };
let ShowSuccess = function () { ModalQuickDismiss('Success', 'New Log Added.') };
let ShowError = function (errorstring) { ModalQuickDismiss('Error', 'Error Occured. <br><br>' + errorstring) };
let newlogtext = $('#newlogtextarea').val();
if (!newlogtext) {
ShowEmptyTextModal();
return false;
}
request
.url(LoadDataPageFunc.URLs.AddLog)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(false)
.data({ target: currenttarget, newlog: newlogtext })
.success((response) => {
console.log(response);
if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(true);
ShowSuccess();
modalhide('ViewDetailsNewLogModal');
return true;
} else {
ShowUnabletoAddLog();
return false;
}
})
.error((err) => {
ShowError(err);
return false;
})
.caching(false)
.go();
};
LoadDataPageFunc.Logs.AddLogsModal = function () {
let modalbody = `<label for="newlogtextarea">Log:</label>
<textarea id="newlogtextarea" rows="10" cols="50" placeholder="Enter the log here..."></textarea>`;
CreateAndShowModal('ViewDetailsNewLogModal', 'New Log', modalbody, buttonprimary('Add New Log', value = '', onclick = 'LoadDataPageFunc.Logs.SubmitNewLog();', block = '', idtext = 'ViewPropertyDetailsAddLogButton'));
};
LoadDataPageFunc.Details = {};
LoadDataPageFunc.Details.Status = '';
LoadDataPageFunc.ids.PhotosShowCard = 'PhotosCard';
LoadDataPageFunc.PropertyDetailsCard = function (obj) {
if (!obj) { return false; }
let rowcoldetail = [];
const imgwidth = '200px'; const imgheight = "200px";
if (!obj) { rowcoldetail = 'No Data'; return createCard('Unknown', cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', rowcoldetail, cardbodyclassadd = 'ListPropertyRow'); }
let created = obj.created || false;
let modified = obj.modified || false;
let name = obj.name || false;
let description = obj.description || false;
let status = obj.status || false;
let remarks = obj.remarks || false;
let referralid = obj.referralid || false;
let createdby = obj.createdby || false;
let category = obj.category || '';
let subcategory = obj.subcategory || '';
let photourl = obj.photourl || false;
let sqm = obj.sqm || false;
let bedrooms = obj.bedrooms || false;
let rooms = obj.rooms || false;
let toilet = obj.toilet || false;
let kitchen = obj.kitchen || false;
let floors = obj.floors || false;
let price = obj.price || false;
let specs = obj.specs || false;
let location = obj.location || false
status = InttoStrDetailsFuncs.PropertyStatus(status);
modified = formatDateTimetoReadable(modified);
created = formatDateTimetoReadable(created);
try { photourl = JSON.parse(photourl); } catch (e) { photourl = photourl; }
//LoadDataPageFunc.Details.Status = Status;
const AddDualColifValue = function (varstr, label) {
if (varstr !== false && varstr !== null) {
rowcoldetail.push(dualcolrow(label, varstr));
}
};
rowcoldetail.push(createCard('', LoadDataPageFunc.ids.PhotosShowCard, '', LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, '', '', '', true));
rowcoldetail.push('<br><br>');
AddDualColifValue(modified, 'Last Activity');
AddDualColifValue(subcategory, category);
AddDualColifValue(status, 'Status');
AddDualColifValue(createdby, 'Filled By');
AddDualColifValue(location, 'Location');
AddDualColifValue(sqm, 'Size');
AddDualColifValue(bedrooms, 'Bedrooms');
AddDualColifValue(rooms, 'Rooms');
AddDualColifValue(toilet, 'Toilet');
AddDualColifValue(kitchen, 'Kitchen');
AddDualColifValue(floors, 'Floors');
AddDualColifValue(price, 'Price');
rowcoldetail.push('<br><br>');
rowcoldetail.push(LoadDataPageFunc.DetailsCardControls());
let LogsCard = LoadDataPageFunc.Logs.LogFullCard(obj);
rowcoldetail.push(LogsCard);
const finalRowColDetail = rowcoldetail.join('');
let ViewPropertyCardDetails = createCard(name, LoadDataPageFunc.ids.ViewPropertyCard, created, LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, cardbody = finalRowColDetail);
return ViewPropertyCardDetails;
};
LoadDataPageFunc.LoadPhotosCard = async function () {
let photosdiv = $('#' + LoadDataPageFunc.ids.PhotosShowCard);
if (photosdiv.length === 0) { return false; }
if (!LoadDataPageFunc.Details.photourl) { photosdiv.html('No Photos.<br>'); return false; }
let photolist = JSON.parse(LoadDataPageFunc.Details.photourl);
if (!photolist || photolist.length === 0) { photosdiv.html('No Photos.<br>'); return false; }
let htmlbody = $(`<div class="splide" role="group" aria-label="photosSplide">
<div class="splide__track">
<ul class="splide__list">
</ul> </div></div>`);
const NewSplideLIImage = function (imgsrc) {
return `<li class="splide__slide" onclick="ButtonGo('ViewAllPhotos','${currenttarget}');"><img src="${imgsrc}" style="max-width: 300px;
max-height: 300px;
width: auto;
height: auto;"></li>`;
};
let splidebody = htmlbody.find('ul');
LoadDataPageFunc.PhotoBlobs = [];
photolist.forEach(function (photo) {
LoadAndCreateURLfromFileHash(photo).then(bloburl => {
splidebody.append(NewSplideLIImage(bloburl));
LoadDataPageFunc.PhotoBlobs.push(bloburl);
});
});
photosdiv.html(htmlbody);
new Splide('.splide').mount();
};
LoadDataPageFunc.ChangeStatus = {};
LoadDataPageFunc.ids.ChangeStatusModal = 'ViewDetails_ChangeStatusModal';
LoadDataPageFunc.ChangeStatus.NewStatusModal = function () {
const StatusSelect = $$.UIalt.Input.InputGroupSelect(LoadDataPageFunc.ids.ChangeStatus_Select, '', [
[-2, $$.StatusPropertiesIntToString(-2)],
[-1, $$.StatusPropertiesIntToString(-1)],
[0, $$.StatusPropertiesIntToString(0)],
[1, $$.StatusPropertiesIntToString(1)],
[2, $$.StatusPropertiesIntToString(2)],
[3, $$.StatusPropertiesIntToString(3)]], '', '', LoadDataPageFunc.Details.status);
const htmltext = 'Update the Status of the Property';
let modalbody = StatusSelect + htmltext;
CreateAndShowModal(LoadDataPageFunc.ids.ChangeStatusModal, 'Update Status', modalbody, buttonprimary('Update', value = '', onclick = 'LoadDataPageFunc.ChangeStatus.Submit();', block = '', idtext = ''));
};
LoadDataPageFunc.ChangeStatus.Submit = function () {
const sel = $('#' + LoadDataPageFunc.ids.ChangeStatus_Select).val();
const selectedstatus = (sel !== null) ? sel : null;
if (selectedstatus === null) { $$.UI.Modal.ModalQuickDismiss('', 'Select a Status'); return false; }
if (selectedstatus == LoadDataPageFunc.Details.Status) { $$.UI.Modal.ModalQuickDismiss('', 'Nothing to Change!'); return false; }
let request = new RequestData(false);
request
.url(LoadDataPageFunc.URLs.ChangeStatus)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(false)
.data({ target: currenttarget, newstatus: selectedstatus })
.success((response) => {
if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(true);
$$.UI.Modal.ModalQuickDismiss('', 'Success!');
hidemodal(LoadDataPageFunc.ids.ChangeStatusModal);
return true;
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable To Change Status<br><br>' + err);
})
.go();
};
LoadDataPageFunc.vars = {};
LoadDataPageFunc.vars.idprefix = 'ViewProperty';
LoadDataPageFunc.ids.EditDetailsModal = LoadDataPageFunc.vars.idprefix + '_EditDetailsModal';
LoadDataPageFunc.EditDetails = {};
LoadDataPageFunc.ids.EditDetailsMidfix = '-EditDetails';
LoadDataPageFunc.ids.EditDetails_name = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyName';
LoadDataPageFunc.ids.EditDetails_Description = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyDescription';
LoadDataPageFunc.ids.EditDetails_Remarks = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Remarks';
LoadDataPageFunc.ids.EditDetails_Location = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Location';
LoadDataPageFunc.ids.EditDetails_Category = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Category';
LoadDataPageFunc.ids.EditDetails_SubCategory = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'SubCategory';
LoadDataPageFunc.ids.EditDetails_sqm = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'sqm';
LoadDataPageFunc.ids.EditDetails_Bedrooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Bedrooms';
LoadDataPageFunc.ids.EditDetails_Rooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Rooms';
LoadDataPageFunc.ids.EditDetails_Toilet = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Toilet';
LoadDataPageFunc.ids.EditDetails_Kitchen = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Kitchen';
LoadDataPageFunc.ids.EditDetails_Floors = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Floors';
LoadDataPageFunc.ids.EditDetails_Price = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Price';
LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone = 'newpropertydropzonephoto';
LoadDataPageFunc.ids.EditDetailsReplacePhotosButton = 'EditDetailsreplacePhotos';
LoadDataPageFunc.EditDetails.InitializePhotoDropZone = function () {
Target_Uploaded_Files = [];
myDropzone = null;
currentDropzone = DropZoneFunc.InitializeDropZone('/File/Upload/Property', (response) => {
if (response.length === 72) {
Target_Uploaded_Files.push(response);
LoadDataPageFunc.ShowPhotoClearButton();
} else {
currentDropzone.removeFile(currentDropzone.files[currentDropzone.files.length - 2]);
}
}, LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone, DropZoneFunc.AcceptedFilesString.images, 'file', maxfilesize = 100);
};
LoadDataPageFunc.ids.ClearPhotosButton = 'newpropertydropzoneclearbutton';
LoadDataPageFunc.ShowPhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).show();
};
LoadDataPageFunc.ClearPhotos = function () {
DropZoneFunc.ClearDropzoneUpload();
LoadDataPageFunc.HidePhotoClearButton();
};
LoadDataPageFunc.HidePhotoClearButton = function () {
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
};
LoadDataPageFunc.EditDetails.EditDetailsModal = function () {
Target_Uploaded_Files = [];
$('#' + LoadDataPageFunc.ids.EditDetailsModal).remove();
const SubmitOnclick = '';
const targetdiv = 'modal-body-' + LoadDataPageFunc.ids.EditDetailsModal;
let FormHTML = ReusableUIElements.NewPropertyGenerateUI(targetdiv, idprefix = LoadDataPageFunc.vars.idprefix + '-EditDetails', replace = false,
LoadDataPageFunc.Details.name, LoadDataPageFunc.Details.description,
LoadDataPageFunc.Details.status, LoadDataPageFunc.Details.remarks,
LoadDataPageFunc.Details.location, LoadDataPageFunc.Details.category, LoadDataPageFunc.Details.subcategory, LoadDataPageFunc.Details.sqm,
LoadDataPageFunc.Details.bedrooms, LoadDataPageFunc.Details.rooms, LoadDataPageFunc.Details.toilet,
LoadDataPageFunc.Details.kitchen, LoadDataPageFunc.Details.floors,
false, true, LoadDataPageFunc.Details.price);
const footer = buttonprimary('Update', '', onclick = 'LoadDataPageFunc.EditDetails.Submit();');
const modalhtml = $$.UI.Modal.Create(LoadDataPageFunc.ids.EditDetailsModal, 'Update Details', FormHTML, footer);
$$.UI.Element.appendtobody(modalhtml);
const replacePhotosButton = buttonprimary('Replace Photos', value = '', onclick = 'LoadDataPageFunc.EditDetails.ShowPhotoUploadButton();', block = '', LoadDataPageFunc.ids.EditDetailsReplacePhotosButton);
$('#ViewProperty-EditDetailsNewPropertyPhotosInputGroup').append(replacePhotosButton);
$('#' + LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone).hide();
$('#ViewProperty-EditDetailsStatus-select-div-mb3').remove();
$('label[for="ViewProperty-EditDetailsStatus-select-div-mb3"]').remove();
Preloaders.Datalist.NewPropertyCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertyCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
Preloaders.Datalist.NewPropertySubCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertySubCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
$('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
$('#newpropertydropzoneclearbutton').click(function () {
LoadDataPageFunc.ClearPhotos();
});
LoadDataPageFunc.EditDetails.ShowPhotoUploadButton = function () {
$('#' + LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone).show();
$('#' + LoadDataPageFunc.ids.EditDetailsReplacePhotosButton).hide();
};
LoadDataPageFunc.EditDetails.InitializePhotoDropZone();
showmodal(LoadDataPageFunc.ids.EditDetailsModal);
};
LoadDataPageFunc.EditDetails.GetChanges = function () {
let objectdata = {};
objectdata.target = currenttarget;
const new_name = $('#' + LoadDataPageFunc.ids.EditDetails_name).val();
const new_description = $('#' + LoadDataPageFunc.ids.EditDetails_Description).val();
const new_remarks = $('#' + LoadDataPageFunc.ids.EditDetails_Remarks).val();
const new_location = $('#' + LoadDataPageFunc.ids.EditDetails_Location).val();
const new_category = $('#' + LoadDataPageFunc.ids.EditDetails_Category).val();
const new_subcategory = $('#' + LoadDataPageFunc.ids.EditDetails_SubCategory).val();
let new_sqm = Number($('#' + LoadDataPageFunc.ids.EditDetails_sqm).val());
let new_bedroom = Number($('#' + LoadDataPageFunc.ids.EditDetails_Bedrooms).val());
let new_rooms = Number($('#' + LoadDataPageFunc.ids.EditDetails_Rooms).val());
let new_toilet = Number($('#' + LoadDataPageFunc.ids.EditDetails_Toilet).val());
let new_kitchen = Number($('#' + LoadDataPageFunc.ids.EditDetails_Kitchen).val());
let new_floors = Number($('#' + LoadDataPageFunc.ids.EditDetails_Floors).val());
let new_price = Number($('#' + LoadDataPageFunc.ids.EditDetails_Price).val());
let changes = 0;
if (LoadDataPageFunc.Details.name !== new_name) { objectdata.name = new_name; changes++; }
if (LoadDataPageFunc.Details.description !== new_description) { objectdata.description = new_description; changes++; }
if (LoadDataPageFunc.Details.remarks !== new_remarks) { objectdata.remarks = new_remarks; changes++; }
if (LoadDataPageFunc.Details.location !== new_location) { objectdata.location = new_location; changes++; }
if (LoadDataPageFunc.Details.category !== new_category) { objectdata.category = new_category; changes++; }
if (LoadDataPageFunc.Details.subcategory !== new_subcategory) { objectdata.subcategory = new_subcategory; changes++; }
if (LoadDataPageFunc.Details.sqm !== new_sqm) { objectdata.sqm = new_sqm; changes++; }
if (LoadDataPageFunc.Details.bedrooms !== new_bedroom) { objectdata.bedrooms = new_bedroom; changes++; }
if (LoadDataPageFunc.Details.rooms !== new_rooms) { objectdata.rooms = new_rooms; changes++; }
if (LoadDataPageFunc.Details.toilet !== new_toilet) { objectdata.toilet = new_toilet; changes++; }
if (LoadDataPageFunc.Details.kitchen !== new_kitchen) { objectdata.kitchen = new_kitchen; changes++; }
if (LoadDataPageFunc.Details.floors !== new_floors) { objectdata.floors = new_floors; changes++; }
if (LoadDataPageFunc.Details.price !== new_price) { objectdata.price = new_price; changes++; }
if (Target_Uploaded_Files.length > 0) { objectdata.photourl = JSON.stringify(Target_Uploaded_Files); changes++; }
if (!changes) { return null; }
if (!new_name || !new_description || !new_location || !new_sqm) {
return false;
}
return objectdata;
};
LoadDataPageFunc.EditDetails.Submit = function () {
let ChangesObject = LoadDataPageFunc.EditDetails.GetChanges();
if (ChangesObject === null) { $$.UI.Modal.ModalQuickDismiss('No Changes', 'No Changes to Update!'); return false; }
if (ChangesObject === false) { $$.UI.Modal.ModalQuickDismiss('', 'Incomplete Details!<br>The following are required!<br><br>Property Name<br>Description<br>Location<br>Size in sqm'); return false; }
if (Target_Uploaded_Files.length == 0) { $$.UI.Modal.ModalQuickDismiss('', 'No New Photos Uploaded!<br>Previous Photos Would be used!',); }
let SendUpdatedDetails = new RequestData(false);
request
.url(LoadDataPageFunc.URLs.SubmitEdit)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(false)
.data(ChangesObject)
.success((response) => {
if (!response) { return false; }
const error = response.error || false;
if (response !== true) {
if (error) { $$.UI.Modal.ModalQuickDismiss('Error', error); }
return false;
} else if (response === true) {
LoadDataPageFunc.RefetchDataAndReload(true);
ReloadPage();
hidemodal(LoadDataPageFunc.ids.EditDetailsModal);
$$.UI.Modal.ModalQuickDismiss('Success', 'Details Updated');
}
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
})
.go();
};
LoadDataPageFunc.MyReferralURL = {};
LoadDataPageFunc.MyReferralURL.ToURL = function (ReferralCode) {
let PropertyHash = LoadDataPageFunc.Details.hashkey;
if (!ReferralCode || !PropertyHash) { return false; }
return window.location.origin + '/p/ReferProperty/s/' + PropertyHash + '/dr/' + ReferralCode;
};
LoadDataPageFunc.MyReferralURL.ReferralURLModal = function () {
let RefferralREQ = new RequestData(false);
let modalbody = '';
let FinalURL = '';
RefferralREQ.url('/ReferralCode/List/data').type('POST')
.fromVarCache(false)
.success(function (response) {
let newURLRow = function (ReferralCode) {
const MainURL = LoadDataPageFunc.MyReferralURL.ToURL(ReferralCode)
const textarea = '<textarea>' + MainURL + '</textarea>';
const CopybuttonOnclick = 'navigator.clipboard.writeText(`' + MainURL + '`);this.textContent=`Copied!`;';
const SharebuttonOnclick = `if (navigator.share) {
navigator.share({
title: '${LoadDataPageFunc.Details.name} Property',
text: 'Interested In this Property ${LoadDataPageFunc.Details.name}',
url: '${MainURL}'
});}`;
return `<div class="tf-container"><ul class="box-service mt-3">
<li>${textarea}</li>
${LoadDataPageFunc.buttonLImaker('Copy',CopybuttonOnclick,'edit.png')}
${LoadDataPageFunc.buttonLImaker('Share',SharebuttonOnclick,'share.png')}
</ul>
</div><br><br>`;
}
/*
for (let index = 0; index < response.length; index++) {
const element = response[index];
const referralCode = element['referral_code'];
modalbody += newURLRow(referralCode);
}
*/
iterateArray(response, (element) => {
modalbody += newURLRow(element['referral_code']);
});
if (!response) { modalbody = '<center>NO URL</center> '; }
modalbody += '<br>' + LoadDataPageFunc.buttonContainer(LoadDataPageFunc.buttonLImaker('Generate URL', 'LoadDataPageFunc.MyReferralURL.Generate();', 'sync.png'));
$$.UI.Modal.ModalQuickDismiss('My Property Referral URL', modalbody, 'PropertyReferralCodes');
}).go();
};
LoadDataPageFunc.MyReferralURL.Generate = function () {
let ONsuccess = function () {
hidemodal('PropertyReferralCodes');
LoadDataPageFunc.MyReferralURL.ReferralURLModal();
};
let REQQ = new RequestData(false);
REQQ.url('/ReferralCode/Request/New').type('POST').fromVarCache(false).
success((response) => {
if (response) {
ONsuccess();
return true;
} else {
$$.UI.Modal.ModalQuickDismiss('', 'Error! Try Again Later');
}
}).go();
};
LoadDataPageFunc.Settings = {};
LoadDataPageFunc.Settings.RequestType = 'POST';
LoadDataPageFunc.Settings.fromVarCache = true;
LoadDataPageFunc.DefaultDatatoSend = function () {
return { target: currenttarget };
};
LoadDataPageFunc.LoadMainDetails = {};
LoadDataPageFunc.LoadMainDetails.OnSuccess = function (response) {
if (!response) { ModalQuickDismiss('Error', 'No Data Loaded<br>'); return ''; }
LoadDataPageFunc.PropertyCurrentDetails = response.Details;
LoadDataPageFunc.Details = response.Details;
$('#' + LoadDataPageFunc.ids.ViewPropertyContainer).html(LoadDataPageFunc.PropertyDetailsCard(response.Details));
LoadDataPageFunc.Logs.LogRowHtmlPage();
LoadDataPageFunc.LoadPhotosCard();
};
LoadDataPageFunc.LoadMainDetails.OnError = function (err) { ModalQuickDismiss('Error', 'Unable to Load<br>' + err); };
LoadDataPageFunc.LoadMainDetails.LoadNow = function () {
let request = new RequestData(false);
request
.url(LoadDataPageFunc.URLs.MainData)
.type(LoadDataPageFunc.Settings.RequestType)
.fromVarCache(LoadDataPageFunc.Settings.fromVarCache)
.data(LoadDataPageFunc.DefaultDatatoSend())
.success((response) => {
if (typeof LoadDataPageFunc === 'undefined' || LoadDataPageFunc.currentTargetPage === 'undefined') {
return false;
}
if (currentPage !== LoadDataPageFunc.currentTargetPage) { return false; }
LoadDataPageFunc.LoadMainDetails.OnSuccess(response);
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
})
.go();
};
LoadDataPageFunc.main = function () {
LoadDataPageFunc.LoadMainDetails.LoadNow();
changeTopbarTitle(LoadDataPageFunc.PageTitle);
};
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

View File

@@ -0,0 +1,308 @@
<br><br><br>
<div class="mt-1">
<div class="tf-container">
<div class="box-user">
<div class="inner d-flex flex-column align-items-center justify-content-center">
<div class="box-avatar">
<img src="/assets/sync.png" id="account_settings_profile_picture" alt="image">
<span class="icon-camera-to-take-photos"></span>
</div>
<div class="info">
<h2 class="fw_8 mt-3 text-center" id="account_settings_fullname_profile">
</h2>
<p id="">
<h6 id="account_settings_credit_card_profile_pic"></h6> <i class="icon-copy1"></i></p>
</div>
</div>
</div>
<ul class="mt-7">
<li class="list-user-info"><span class="icon-user"></span>
<h5 id="account_settings_fullname_main"></h5>
</li>
<li class="list-user-info"><span class="icon-credit-card2"></span>
<h4 id="account_settings_credit_card_main"></h4>
</li>
<li class="list-user-info"><span class="icon-phone"></span>
<h4 id="account_settings_mobile_number"></h4>
</li>
<li class="list-user-info"><span class="icon-email"></span>
<h4 id="account_settings_email"></h4>
</li>
</ul>
</div>
</div>
<div class="card-section" id="main-card-section">
</div>
<br><br>
<script>
function ChangePasswordInitialModal() {
const modalid = "modal-change-password-initial-page";
const modaltitle = "Change Password";
const modalbody = `
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="Current Password" id="olduserpassword"
name="olduserpassword">
<div class="input-group-append">
<div class="input-group-text" id="user-password-input-group-text">
<span class="fas fa-lock" id="user-password-span"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="New Password" id="newuserpassword"
name="newuserpassword">
<div class="input-group-append">
<div class="input-group-text" id="newuser-password-input-group-text">
<span class="fas fa-lock" id="newuser-password-span"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="Confirm Password" id="newuserpasswordconfirm"
name="newuserpasswordconfirm">
<div class="input-group-append">
<div class="input-group-text" id="newuser-password-confirm-input-group-text">
<span class="fas fa-lock" id="newuser-password-confirm-span"></span>
</div>
</div>
</div>
`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" onclick="ChangePasswordConfirmAccountSettings();" id="change-password-now-confirm-button">Change Password</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#newuserpassword').keyup(function () {
VerifyInitialPassword();
VerifyAllPasswordInput();
});
$('#newuserpasswordconfirm').keyup(function () {
VerifyConfirmPassword();
VerifyAllPasswordInput();
});
}
function ChangePasswordAccountSettingsSuccess() {
const modalid = "modal-change-password-success";
const modaltitle = "Success";
const modalbody = `<p>Password has been changed successfully</p>`;
const modalfooter = `<button type="button" class="btn btn-primary" onclick="window.location.href = '/logout'; $('.modal').hide(); window.location.href = '';" id="change-password-success-button">OK</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function ChangePasswordAccountSettingsError(response) {
const modalid = "modal-change-password-failed";
const modaltitle = "Failed";
const modalbody = `<p>Unable to change password. Please try again later.</p><p>${response}</p>`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
$('#modal-change-password-final-confirmation-page').modal('hide');
}
function ChangePasswordNowAccountSettings() {
function ChangePasswordNow(response) {
if (response === true) {
$('.modal').hide();
ChangePasswordAccountSettingsSuccess();
} else {
ChangePasswordAccountSettingsError(response);
}
}
AjaxDo('/user/changemypassword', { current_password: $("#olduserpassword").val(), new_password: $("#newuserpassword").val(), new_confirm_password: $("#newuserpasswordconfirm").val() }, ChangePasswordNow, null, reqtype = 'POST');
}
function ChangePasswordAccountSettingsFinalConfirmModal() {
const modalid = "modal-change-password-final-confirmation-page";
const modaltitle = "Continue?";
const modalbody = `<p>Confirm Password Change?</p>`;
const modalfooter = `<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="ChangePasswordNowAccountSettings();" id="change-password-now-confirm-button">Change Password</button>`;
CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose = false, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
}
function ChangePasswordConfirmAccountSettings() {
if (!VerifyAllPasswordInput()) { return false; }
ChangePasswordAccountSettingsFinalConfirmModal();
}
function changeSpantoInvalid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-times-circle");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-danger");
}
function changeSpantoValid(idtext) {
$("#" + idtext + "-span").attr("class", "fas fa-check");
$("#" + idtext + "-input-group-text").attr("class", "input-group-text bg-primary");
}
function ChangeConfirmPasswordButtontoPrimary() {
$('#change-password-now-confirm-button').attr('class', 'btn btn-primary');
}
function ChangeConfirmPasswordButtontoDanger() {
$('#change-password-now-confirm-button').attr('class', 'btn btn-danger');
}
function VerifyInitialPassword() {
const userPassword = document.getElementById("newuserpassword").value;
if (userPassword.length < 6) {
changeSpantoInvalid('newuser-password');
normalpasswordallowed = false;
return false;
}
changeSpantoValid('newuser-password');
normalpasswordallowed = true;
return true;
}
function VerifyConfirmPassword() {
const userPassword = document.getElementById("newuserpassword").value;
const userPasswordConfirm = document.getElementById("newuserpasswordconfirm").value;
if (userPassword.length < 6 || userPasswordConfirm.length < 6) {
changeSpantoInvalid('newuser-password-confirm');
confirmpasswordallowed = false;
return false;
}
if (userPassword !== userPasswordConfirm) {
changeSpantoInvalid('newuser-password-confirm');
confirmpasswordallowed = false;
return false;
}
changeSpantoValid('newuser-password-confirm'); changeSpantoValid('newuser-password');
confirmpasswordallowed = true; return true;
}
function VerifyAllPasswordInput() {
const OlduserPassword = document.getElementById("olduserpassword").value;
if (VerifyInitialPassword() && VerifyConfirmPassword() && OlduserPassword.length > 5) {
ChangeConfirmPasswordButtontoPrimary();
return true;
}
}
servicesbuttonarray = [['/assets/resetpassword.png', 'Reset Password', 'ChangePasswordInitialModal();', 'javascript:void(0);'],
['/assets/betshistory.png', 'Reset Browser and Cache', 'clearCacheAndReload()', 'javascript:void(0);'],
['/assets/notes.png', 'Show Notes', 'ShowNotes(true);', 'javascript:void(0);'],
['/assets/logout.png', 'Logout', 'clearCacheAndLogout();clearCacheAndLogout();', 'javascript:void(0);']
];
servicesbox = UIServices_FullDIV_ONCLICK_Array('', '', '', '', servicesbuttonarray);
$('#main-card-section').html(servicesbox);
changeTopbarTitle('Account Settings');
function account_details_load_data() {
const url ='/account_settings/details';
const updateaccountdetailshtml = function(name,fullname,mobile,photourl,landline,email){
$('#account_settings_profile_picture').attr('src',photourl);
$('#account_settings_fullname_profile').html(name);
$('#account_settings_fullname_main').html(fullname);
$('#account_settings_credit_card_main').html(mobile);
$('#account_settings_mobile_number').html(landline);
$('#account_settings_email').html(email);
}
const photourl_account_settings_find_one = function(response){
let photourl = response.photourl;
if (photourl === undefined || photourl === null || photourl === '') {
} else if (Array.isArray(photourl)) {
photourl = photourl[0];
} else if (!Array.isArray(photourl)) {
}
if (photourl === undefined || photourl === null || photourl === '') {
photourl = response.photourl2;
}
if (Array.isArray(photourl)) {
photourl = photourl[0];
}
return photourl;
}
let request = new RequestData(true);
const cachedata = reqcacheload(url,datavalue='',object=null);
if(cachedata){
let photourlcachedata = updateaccountdetailshtml(cachedata);
updateaccountdetailshtml(cachedata.name,cachedata.fullname,cachedata.mobile,photourlcachedata,cachedata.landline,cachedata.email);
}
request
.url(url)
.type('GET')
.data(null)
.success((response) => {
const photourl = photourl_account_settings_find_one (response);
updateaccountdetailshtml(response.name,response.fullname,response.mobile,photourl,response.landline,response.email);
})
.error((err) => {
console.error(err);
})
.go();
}
$(document).ready(function () {
account_details_load_data();
});
</script>

View File

@@ -0,0 +1,95 @@
<br><br><br><br>
<div class="card" id="primary-card">
<div class="card-header ui-sortable-handle" style="cursor: move">
<h1 class="card-title" style="font-size: 2.5rem;">Reports</h1>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<table id="reports_list_table">
<thead>
<tr>
<th>
Report
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<style>
/* Style each row as a button */
.dataTable tbody tr {
padding: .5rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: .3rem;
}
</style>
<script>
function GenerateReportsListRow(Name) {
var parts = Name.split('-');
// Assign the parts to variables
var text = parts[0];
var value = parts[1];
return `<tr> <td><center><button class="btn-block btn-lg" onclick="ButtonGo('${value}',0);">${text}</button></center></td> </tr>`; }
async function GenerateReportsListRows(responsearray) {
let newhtmltable = [];
for (let i = 0; i < responsearray.length; i++) { newhtmltable.push(GenerateReportsListRow(responsearray[i])); }
$("#reports_list_table").find("tbody").html(newhtmltable.join(''));
let reportslist = $("#reports_list_table").DataTable({
"destroy": true,
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
/*
reportslist.on('click', 'tbody tr', function () {
return;
let data = reportslist.row(this).data();
let targettranshash = data[0];
console.log(targettranshash);
$(targettranshash).find('a').trigger('click');
});
*/
$('#primary-card').fadeIn(200);
}
function GenerateReportsListTable() {
AjaxDo('?MyReports/List', null, GenerateReportsListRows, null, reqtype = 'POST');
}
GenerateReportsListTable();
</script>

View File

@@ -0,0 +1,437 @@
<br><br>
<div class="card noprint" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;display: none;">
<h3 class="card-title" style=""></h3>
<div class="card-tools">
</div>
</div>
<div class="card-body ">
<div class="row card-body">
<div class="col-12"></div><br><br>
<div class="col-12 mx-auto d-block text-center justify-content-center noprint" id="qrcode"></div>
</div>
</div>
</div>
<div class="card noprint" id="secondary-card-betting">
<div class="card-header ui-sortable-handle" style="cursor: move;display: none;">
<h3 class="card-title" style=""></h3>
<div class="card-tools">
</div>
</div>
<div class="card-body">
<div class="row card-body noprint">
<div class="col mx-auto noprint" style="display:none;" id="">
<button class="btn btn-primary btn-block" onclick="DownloadQRCodeNow()">SAVE</button>
</div>
<div class="col mx-auto noprint" id="">
<button class="btn btn-warning btn-block" onclick="printbtqr()">PRINT</button>
</div>
</div>
<div class="row card-body" style="display:none;">
<div class="col mx-auto" id="">
Date:
</div>
<div class="col mx-auto" id="">
<select id="sched" class="form-control"></select>
</div>
</div>
</div>
</div>
<center>
<div id="qrcodeprinting" class="mainprint hideonbrowser"></div>
</center>
<script>
function printbtqr(){
window.print();
//printJS({ printable: "mainqrimg", type: "html",});
}
function OLDsavebtqr(){
let b64 = $('.mainbtqr').attr('src');
let base64Data = b64.split(',')[1];
let decodedData = atob(base64Data);
let uint8Array = new Uint8Array(decodedData.length);
for (let i = 0; i < decodedData.length; i++) {
uint8Array[i] = decodedData.charCodeAt(i);
}
const blob = new Blob([uint8Array], { type: "image/png" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "NewQ.png";
link.click();
URL.revokeObjectURL(url);
}
function OLD2savebtqr() {
let b64 = $('.mainbtqr').attr('src');
let base64Data = b64.split(',')[1];
let decodedData = atob(base64Data);
let uint8Array = new Uint8Array(decodedData.length);
for (let i = 0; i < decodedData.length; i++) {
uint8Array[i] = decodedData.charCodeAt(i);
}
const blob = new Blob([uint8Array], { type: "image/png" });
// Check if the browser is Internet Explorer (MS Edge)
if (navigator.msSaveOrOpenBlob) {
navigator.msSaveOrOpenBlob(blob, 'NewQ.png');
} else {
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "NewQ.png";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
}
function savebtqr() {
let b64 = $('.mainbtqr').attr('src');
let base64Data = b64.split(',')[1];
let decodedData = atob(base64Data);
let uint8Array = new
Uint8Array(decodedData.length);
for (let i = 0; i < decodedData.length; i++) {
uint8Array[i] = decodedData.charCodeAt(i);
}
const blob = new Blob([uint8Array], { type: "image/png" });
// Cross-browser download approach:
try {
// Attempt saving via browser's native download manager:
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "NewQRCode.png";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
} catch (error) {
// Fallback for mobile browsers with limitations:
const reader = new FileReader();
reader.onload = (event) => {
const base64Url = event.target.result;
const img = document.createElement("img");
img.src = base64Url;
// Use a mobile-friendly method to display or share the image
// (e.g., open a new window/tab, trigger native share functionality)
};
reader.readAsDataURL(blob);
}
}
function oldsaveQrCode() {
// Get the base64 data
let b64 = document.getElementById('mainqrimg').src;
let base64Data = b64.split(',')[1];
// Create a Blob from base64 data
const blob = new Blob([base64Data], { type: "image/png" });
// Create a link element
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "QrCode.png";
// Append the link to the body
document.body.appendChild(link);
// Trigger a click on the link
link.click();
// Remove the link from the body
document.body.removeChild(link);
// Revoke the object URL
URL.revokeObjectURL(link.href);
}
function saveQrCode2() {
// Get the base64 data
let b64 = document.getElementById('mainqrimg').src;
// Create a canvas element
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
// Create an image element
const image = new Image();
image.onload = function () {
// Set canvas dimensions based on image dimensions
canvas.width = image.width;
canvas.height = image.height;
// Draw the image onto the canvas
context.drawImage(image, 0, 0);
// Convert canvas content to a data URL
const dataUrl = canvas.toDataURL("image/png");
// Create a Blob from the data URL
const blob = dataURLToBlob(dataUrl);
// Create a link element
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "QrCode.png";
// Append the link to the body
document.body.appendChild(link);
// Trigger a click on the link
link.click();
// Remove the link from the body
document.body.removeChild(link);
// Revoke the object URL
URL.revokeObjectURL(link.href);
};
// Set the image source
image.src = b64;
}
function oldsaveQrCode() {
// Get the base64 data
let b64 = document.getElementById('mainqrimg').src;
let base64Data = b64.split(',')[1];
// Create a Blob from base64 data
const blob = new Blob([base64Data], { type: "image/png" });
// Create a link element
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "QrCode.png";
// Append the link to the body
document.body.appendChild(link);
// Trigger a click on the link
link.click();
// Remove the link from the body
document.body.removeChild(link);
// Revoke the object URL
URL.revokeObjectURL(link.href);
}
function saveQrCode3() {
// Get the base64 data
let b64 = document.getElementById('mainqrimg').src;
const base64Content = b64.split(',')[1];
const binaryContent = atob(base64Content);
const uint8Array = new Uint8Array(binaryContent.length);
for (let i = 0; i < binaryContent.length; i++) {
uint8Array[i] = binaryContent.charCodeAt(i);
}
// Create a Blob
const blob = new Blob([uint8Array], { type: 'image/png' });
// Create a download link
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'QrCode.png';
// Append the link to the body
document.body.appendChild(link);
// Trigger a click on the link
link.click();
// Remove the link from the body
document.body.removeChild(link);
// Revoke the object URL
URL.revokeObjectURL(link.href);
}
function saveQrCode() {
// Get the base64 data
let b64 = document.getElementById('mainqrimg').src;
let base64Data = b64.split(',')[1];
// Convert base64 to a Blob
const byteCharacters = atob(base64Data);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
const blob = new Blob([byteArray], { type: 'image/png' });
// Use FileSaver.js to trigger the download
saveAs(blob, 'QrCode.png');
}
// Function to convert data URL to Blob
function dataURLToBlob(dataUrl) {
const parts = dataUrl.split(';base64,');
const contentType = parts[0].split(':')[1];
const raw = window.atob(parts[1]);
const rawLength = raw.length;
const uint8Array = new Uint8Array(new ArrayBuffer(rawLength));
for (let i = 0; i < rawLength; ++i) {
uint8Array[i] = raw.charCodeAt(i);
}
return new Blob([uint8Array], { type: contentType });
}
new QRCode(document.getElementById("qrcode"), "TAYTRSRC="+currenttarget,);
new QRCode("qrcodeprinting", {
text: "TAYTRSRC="+currenttarget,
width: 1000,
height: 1000,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
// new QRCode(document.getElementById("qrcode"), "TAYTRSRC="+currenttarget);
$("#qrcode").find("img").addClass("img-fluid mx-auto d-block noprint");
$("#qrcode").find("img").addClass("mainbtqr");
// $("#qrcode").find("img").prepend('<br>');
//$("#qrcode").find('canvas').attr('width')=screen.width-40+'px';
//$("#qrcode").find("img").attr("id", "mainqrimg");
$("#mainqrimg").attr("width", screen.width-40+'px');
$("#qrcodeprinting").find("img").addClass("mainprint");
$("#qrcodeprinting").find("img").attr("id", "mainqrimg");
// $("#qrcodeprinting").find("img").hide();
console.log("QR Download Button:", $("#qrdownloadbutton").length);
console.log("Main QR Image:", $("#mainqrimg").attr("src"));
$("#qrdownloadbutton").attr("href", $("#mainqrimg").attr("src"));
$("#mainqrimg").on("load", function() {
//$("#qrdownloadbutton").attr("href", $("#mainqrimg").attr("src"));
});
$("#qrdownloadbutton").on("click", function() {
downloadQRCode();
});
function downloadQRCode() {
const base64Data = $("#mainqrimg").attr("src").split(",")[1];
const decodedData = atob(base64Data);
const uint8Array = new Uint8Array(decodedData.length);
for (let i = 0; i < decodedData.length; i++) {
uint8Array[i] = decodedData.charCodeAt(i);
}
const blob = new Blob([uint8Array], { type: "image/png" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "NewQr.png";
link.click();
URL.revokeObjectURL(url);
}
$(document).ready(function() {
$('#qrcode').find('canvas').attr('id', 'qrcode-canvas');
$('#qrcode').find('img').attr('id', 'qrcode-image');
});
function DownloadQRCodeNow(){
let img = document.getElementById('qrcode-image');
let canvas = document.getElementById('qrcode-canvas');
canvas.width = img.clientWidth;
canvas.height = img.clientHeight;
let context = canvas.getContext('2d');
context.drawImage(img,0,0)
canvas.toBlob(function(blob){
let link = document.createElement('a');
link.download = 'qrcode.png';
link.href = URL.createObjectURL(blob);
link.click();
URL.revokeObjectURL(link.href);
},'image/png');
}
</script>
<style>
.hideonbrowser {
display: none;
}
</style>

View File

@@ -0,0 +1,131 @@
<br><br><br><br>
<table class="" id="bets_history_table">
<thead>
<tr>
<th>Date</th>
<th>
<center>Type</center>
</th>
<th>Draw</th>
<th>Numbers</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br><br><br>
<script>
document.body.style.zoom = 1;
function GenerateBTRow(Date, Type, DrawTime, Num,Amount, Hashkey, Stat) {
//const actionbutton =`<button class="btn btn-warning" onclick="gotoPage('bet_qr','${Hashkey}')">View<br>QR</button>`;
const actionbutton = `<img src="assets/qrcode.svg" onclick="gotoPage('bet_qr','${Hashkey}')">`;
return `<tr>
<td style="">${Date}</td>
<td style=""><center>${Type}</center></td>
<td style="">${DrawTime}</td>
<td style="padding-right: 0;">${Num}</td>
<td style="padding-right: 0;">${Amount}</td>
<td style=""><center>${actionbutton}</center></td>` +
//`<td style="padding: 0px;">${Stat}</td>`+
`</tr>`;
}
async function GenerateBTRows(responsearray) {
let newhtmltable = '';
for (let i = 0; i < responsearray.length; i++) {
const currentgametype = responsearray[i]['bet_type'];
let currentgametypename = '';
if (Object.keys(bet_types).length === 0) {
await queryBetTypes();
}
currentgametypename = bet_types[currentgametype];
if (currentgametypename === undefined){continue;}
currentgametypename = currentgametypename.replace(' ', "<br>");
currentgametypename = currentgametypename.replace(' ', "<br>");
let cr_bet_date = responsearray[i]['bet_date'];
let cr_bet_schedule = responsearray[i]['bet_schedule'];
let current_bet_number = responsearray[i]['bet_number'];
let current_bet_amount = responsearray[i]['amount'];
if (current_bet_number.endsWith("-")) { current_bet_number = current_bet_number.slice(0, -1); }
cr_bet_date = cr_bet_date.replace(' ', "<br>");
cr_bet_schedule = cr_bet_schedule.replace(' ', "<br>");
newhtmltable += GenerateBTRow(
cr_bet_date,
currentgametypename,
cr_bet_schedule,
current_bet_number,
current_bet_amount,
responsearray[i]['transactionID'],
''
);
}
$("#bets_history_table").find("tbody").html(newhtmltable);
let bethistorytable = $("#bets_history_table").DataTable({
order: [[0, 'desc']],
pageLength: 5,
lengthMenu: [[5], [5]]
});
$("#bets_history_table_length").hide();
// new DataTable('#bets_history_table');
bethistorytable.on('click', 'tbody tr', function () {
let data = bethistorytable.row(this).data();
let targettranshash = data[5];
$(targettranshash).find('img').trigger('click');
});
}
function loaddashboardcard(response){
total_balance = response.total_balance;
$( "#total-balance" ).html(response.total_balance);
// $( "#pending-credit" ).html(data.total_credit);
$( "#phone-number" ).html(response.number);
}
function loaduserdatadashboard(){AjaxDo('?userdatadashboard',null,loaddashboardcard, null,reqtype='GET');}
function GenerateBTTable() {
// if (!currenttarget){return false;}
const dataRight = { user: currenttarget };
AjaxDo('?user/bet/history', dataRight, GenerateBTRows, null, reqtype = 'POST');
}
GenerateBTTable();
$(window).on('load', function () {
//$('body').css('transform', 'scale(0.8)');
});
//$('html, body').css('overflow', 'hidden');
</script>

View File

@@ -0,0 +1,96 @@
<div class="card-body card-info" id="main-card-body" style="">
<div class="row">
<div class="col-md-18">
Welcome User
</div>
</div>
<br>
<div class="row card-info">
<div class="col-md-18 card bg-gray text-xl border-rounded" style="width:100%;height:20%;">
Schedule are as Follows:
<br><br>
<b>3D</b> Everyday at 2PM, 5PM and 9PM
<br><br>
<b>4D</b> Every Monday, Wednesday, Friday at 9PM
</div>
</div>
</div>
<div class="card" id="secondary-card">
<div class="card-header ui-sortable-handle" style="cursor: move;">
<div class="row">
<div class="col">
<h4 class="card-title">Betting Instructions</h4>
</div>
<div class="col">
<h4 class="card-title" id=""></h4>
</div>
</div>
<div class="card-tools">
</div>
</div>
<div class="card-body " id="credit-amount-request-form" style="">
<div class="row">
<div class="col-12">
You can place your bet 30 mins before the draw.
</div>
<br> <br>
<div class="col-12">
For example, you wanted to bet Today 2PM, bets before 1:30PM are allowed.
</div>
<br> <br>
<div class="col-12">
You can place your bet 3 days in advance.
</div>
<br> <br>
<div class="col-12">
Keep the QR for scanning by the coordinator for claiming prizes.
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
var currenttarget=0;
// CheckPendingRequestForUI();
});
</script>

View File

@@ -0,0 +1,141 @@
<br><br>
<div id="PageContainer">
</div>
<script src="/lib/referrenceslib.js"></script>
<script> $$ = {};
$$ = {};
$$.UI = {};
$$.UI.Table = {};
$$.UI.Table.CreateTable = function (id, theadinnerhtml, bodyinnerhtml) { return CreateTable(id, theadinnerhtml, bodyinnerhtml); };
$$.UI.Table.GenerateTheadFromArraySimple = function (array) { return GenerateTheadFromArraySimple(array); };
$$.UI.Table.GenerateTableRowFromArraySimple = function (array) { return GenerateTableRowFromArraySimple(array); };
$$.UI.ResetBrowserAndCache = function () { return ResetBrowserAndCache(); };
$$.UI.formatCurrency = function (number, withdecimal = true) { return formatCurrency(number, withdecimal); };
$$.UI.getDateInGMT8 = function () { return getDateInGMT8(); };
$$.UI.RunFunctiononMutation = function (targetidToMonitor, callbackfunction) { return RunFunctiononMutation(targetidToMonitor, callbackfunction); };
$$.UI.Element = {};
$$.UI.Element.appendtobody = function (string) { return appendtobody(string); };
$$.UI.Element.Exists = function (ElementIDtext) { ElementExists(ElementIDtext); };
$$.UI.Element.RemovebyID = function (idstring) { return removeelementbyID(idstring); };
$$.UI.Element.DeleteById = function (id) { return DeleteElementById(id); }
$$.UI.Element.getHTML = function (idetext) { return getElementhtml(idtext); };
$$.UI.Element.setHTML = function (idetext, html) { return setElementhtml(idtext, html); };
$$.UI.Element.getValue = function (idetext) { return getElementvalue(idtext); };
$$.UI.Element.setValue = function (idetext,) { return setElementvalue(idtext, value); };
$$.UI.Validate = {};
$$.UI.Validate.isValidEmail = function (email) { return isValidEmail(email); };
$$.UI.Validate.hasValidMobileFormat = function (usernumber) { return hasValidMobileFormat(usernumber); };
$$.UI.Modal = {};
$$.UI.Modal.Create = function (modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return createmodal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.Show = function (idtxt) { return modalshow(idtxt); };
$$.UI.Modal.Hide = function (idtxt) { return modalhide(); };
$$.UI.Modal.CreateAndShow = function (modalid, modaltitle, modalbody, modalfooter = '', modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
$$.UI.Modal.ModalQuickDismiss = function (modaltitle, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true) { return ModalQuickDismiss(modaltitle, modalbody, modalid, modaltohide, functiontodo, conditiontrue) };
$$.UI.Modal.ModalContinueCancel = function (modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext = 'Cancel', continuebuttontext = 'Continue', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning') { return ModalContinueCancel(modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext, continuebuttontext, continuebuttoncss, cancelbuttoncss); };
$$.UI.Modal.hide = function (modalid) { return hidemodal(modalid); };
$$.UI.Modal.show = function (modalid) { return showmodal(modalid); };
$$.UI.col = function (content = '', additionalclass = '') { return col(content, additionalclass); };
$$.UI.row = function (content = '', additionalclass = '', hidden = false, style = '') { return row(content, additionalclass, hidden, style); };
$$.UI.dualcolrow = function (colcontent1, colcontent2, rowclass = '', hidden = false, style = '') { return dualcolrow(colcontent1, colcontent2, rowclass, hidden, style); };
$$.UI.Button = {};
$$.UI.Button.Default = function (content, value = '', onclick = '', idtext = '', setclass = '', addtionaldata = '') { return button(content, value, onclick, idtext, setclass, addtionaldata); };
$$.UI.Button.Warning = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonwarning(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Danger = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttondanger(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.Primary = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonprimary(content, value, onclick, block, idtext, addclass, addtionaldata); };
$$.UI.Button.HomeMenuButtons = function (buttonicon, buttonText, buttonGo, buttonVariabletoPass = '', iconwidth = '', iconheight = '', buttonstyle = '', buttononclick = '', divclass = '', divid = '', buttonid = '', textclass = '') { return HomeMenuButtons(buttonicon, buttonText, buttonGo, buttonVariabletoPass, iconwidth, iconheight, buttonstyle, buttononclick, divclass, divid, buttonid, textclass); };
$$.UI.Input = {};
$$.UI.Input.textInput = function (idtext = '', setclass = '', required = '', placeholder = '', value = '') { return textinput(idtext, setclass, required, placeholder, value); };
$$.UI.Input.textFormControl = function (idtext = '', addclass = '', required = '', placeholder = '', value = '') { return textformcontrol(idtext, addclass, required, placeholder, value); };
$$.UI.Card = {};
$$.UI.Card.Create = function (cardtitle = '', cardid = '', cardtools = '', cardbodyid = '', cardbodytext = '', cardbodyclassadd = '', maincardstyle = '', titlecardhide = false) { return createCard(cardtitle, cardid, cardtools, cardbodyid, cardbodytext, cardbodyclassadd, maincardstyle, titlecardhide); };
$$.UI.Card.Simple = function (title = '', text = '', id = '') { return CreateCardSimple(title, text, id); };
$$.UIalt = {};
$$.UIalt.hrefonclickButtonGO = function (pagename, pagedatastring = '') { return hrefonclickButtonGO(pagename, pagedatastring); };
$$.UIalt.generateHTMLfromarray = function (prepend, append, array, func) { return generateHTMLfromarray(prepend, append, array, func); };
$$.UIalt.imgiconuserdefault = function (imgsrc, imgwidth = '', imgheight = '', id = '') { return imgiconuserdefault(imgsrc, imgwidth, imgheight, id); };
$$.UIalt.UICardStats = {};
$$.UIalt.UICardStats.UICardStatsDetails = function (Title = '', number = 0, Unit = '', leftORright = 'left', numberid = '') { return UICardStatsDetails(Title, number, Unit, leftORright, numberid); };
$$.UIalt.UICardStats.UIStatsDetailsArray = function (statsarray) { return UIStatsDetailsArray(statsarray); };
$$.UIalt.BalanceCard = {};
$$.UIalt.BalanceCard.UIBalance_WrapperfromArray = function (statsarray) { return UIBalance_WrapperfromArray(statsarray); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item = function (maintitle = '', onclickstring = '', imgsrc = '', href = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '', imgwidth = '', imgheight = '') { return UIBalance_Wrapper_WalletFooter_Item(maintitle, onclickstring, imgsrc, href, subtitleline1, subtitleline2, subtitleline3, subtitleline4, imgwidth, imgheight); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item_ButtonGO = function (maintitle, pagename, pagestring = '', iconclass = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '') { return UIBalance_Wrapper_WalletFooter_Item_ButtonGO(maintitle, pagename, pagestring, iconclass, subtitleline1, subtitleline2, subtitleline3, subtitleline4); };
$$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_ARRAY = function (balancewrapper_item_array) { return UIBalance_Wrapper_WalletFooter_ARRAY(balancewrapper_item_array); };
$$.UIalt.BalanceCard.UIcreateBalanceBoxfromArray = function (statsarray, balancewrapper_item_array, style = 'border: solid 3px #000d88;') { return UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array, style); };
$$.UIalt.Services = {};
$$.UIalt.Services.Button = function (imgiconsrc, title = '', onclick = '', href = '', bgcolor8 = false) { return UIServices_Button(imgiconsrc, title, onclick, href, bgcolor8); };
$$.UIalt.Services.Button_GOTOPAGE = function (imgiconsrc, title, pagename, pagedatastring = '') { return UIServices_Button_GOTOPAGE(imgiconsrc, title, pagename, pagedatastring); };
$$.UIalt.Services.FullDIV_GOTOPAGE_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_GOTOPAGE_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Services.FullDIV_ONCLICK_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_ONCLICK_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
$$.UIalt.Sidetext = {};
$$.UIalt.Sidetext.UISideText_DualColumnButton = function (text, pagename, pagedatastring = '', imgsrc = '', imgwidth = '', imgheight = '') { return UISideText_DualColumnButton(text, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.Sidetext.UISideText_DualColumnButton_Array = function (sidetext_button_dualcolumn_array) { return UISideText_DualColumnButton_Array(sidetext_button_dualcolumn_array); };
$$.UIalt.UICardSimple = function (title, text = '', id = '') { return UICardSimple(title, text, id); };
$$.UIalt.RecentSearchBar = {};
$$.UIalt.RecentSearchBar.SearchBar = function (searchplaceholdertext, classtosearch, id, imgsrclefticon = '', imgsrcrighticon = '', imgwidth = '', imgheight = '') { return UIRecentSearchBar(searchplaceholdertext, classtosearch, id, imgsrclefticon, imgsrcrighticon, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO = function (title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIRecentSearchable_Button_GO(title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.Searchable_Button_GO_ARRAY = function (title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata = '', viewalltext = '') { return UIRecentSearchable_Button_GO_ARRAY(title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata, viewalltext); };
$$.UIalt.UIListArrowButton_GO = function (title, subtitle, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIListArrowButton_GO(title, subtitle, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
$$.UIalt.RecentSearchBar.SearchBox_with_BUTTONS_FULL = function (title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY = '', viewallpagetarget, viewallpagedata = '', viewalltext = '', classtosearch = '', searchid = '', searchplaceholdertext = '', searchlefticon = '', searchrighticon = '', imgwidth = '', imgheight = '') { return UISearchBox_with_BUTTONS_FULL(title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY, viewallpagetarget, viewallpagedata, viewalltext, classtosearch, searchid, searchplaceholdertext, searchlefticon, searchrighticon, imgwidth, imgheight); };
$$.UIalt.Input = {};
$$.UIalt.Input.InputGroupCore = function (innerhtml = '', label = '', inputgroupid = '') { return UIinputgroupcore(innerhtml, label, inputgroupid); };
$$.UIalt.Input.InputGroup = function (placeholder, type, id, label = '', classinput = '', spanclass = '', imginsteadofspan = '', required = false, textvalue = '') { return UIInputGroup(placeholder, type, id, label, classinput, spanclass, imginsteadofspan, required, textvalue); };
$$.UIalt.Input.InputGroupSelect = function (id = '', label = '', optionsarray = '', spanclass = '', imginsteadofspan = '',selectedvalue='') { return UIInputGroupSelect(id, label, optionsarray, spanclass, imginsteadofspan,selectedvalue); };
$$.UIalt.Input.InputGroupDatePicker = function () { return UIInputGroupDatePicker(); };
$$.UIalt.Input.ArraytoOptionforSelect = function (array,selectedvalue='') { return UIArraytoOptionforSelect(array,selectedvalue); };
$$.UIalt.Input.ReplaceCurrentOptionsSelect = function (selectid, optionsarray,selectedvalue='') { return UIReplaceCurrentOptionsSelect(selectid, optionsarray,selectedvalue); };
$$.UIalt.Input.InputGroupButton = function (buttontext, buttonclass = '', buttonid = '', onclick = '', buttonstyle = '') { return UIInputGroupButton(buttontext, buttonclass, buttonid, onclick, buttonstyle); };
$$.UIalt.UISetDarkMode = function () { return UISetDarkMode(); };
$$.UIalt.UIUpdateBodyHTML = function (html = '') { return UIUpdateBodyHTML(html); };
$$.UIalt.changeTopbarTitle = function (title) { return changeTopbarTitle(title); };
$$.StatusIntToString =function(Status){return InttoStrDetailsFuncs.Status(Status);};
</script>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.PageTitle = 'New Page';
LoadDataPageFunc.ids = {};
LoadDataPageFunc.ids.PageContainer = 'PageContainer';
LoadDataPageFunc.Initialize = function () {
let request = new RequestData(true);
request
.url('/ViewLead/Details/data')
.type('POST')
.fromVarCache(true)
.data({ target: currenttarget })
.success((response) => {
// console.log(response);
LoadDataPageFunc.ViewLeadCurrentDetails = response.Details;
$('#' + LoadDataPageFunc.ids.ViewLeadContainer).html(LoadDataPageFunc.LeadDetailsCard(response.Details));
LoadDataPageFunc.Logs.LogRowHtmlPage();
})
.error((err) => {
ModalQuickDismiss('Error', 'Unable to Load<br>' + errordesc);
})
.go();
};
LoadDataPageFunc.main = function () {
changeTopbarTitle(LoadDataPageFunc.PageTitle);
LoadDataPageFunc.Initialize();
};
$(document).ready(function () {
LoadDataPageFunc.main();
});
</script>

View File

@@ -0,0 +1,251 @@
<style>
.ListRowCard {
margin-bottom: 20px;
}
</style>
<div id='ListMainContainer'>
</div>
<script>
LoadDataPageFunc = {};
LoadDataPageFunc.InitializeDynamicVariables = function () {
LoadDataPageFunc.URLs.QueryListData = '/ListLeads/List/data';
LoadDataPageFunc.Settings.ViewDetailsOnclick = function (data) {
return `ButtonGo('ViewLeadDetails', '${data}')`;
};
LoadDataPageFunc.Settings.CurrentTargetRequired = false;
LoadDataPageFunc.Settings.DefaultDatatoSend = null;
LoadDataPageFunc.NewRow = function (objectdata, rownum) {
let rowhtml = [];
Status = InttoStrDetailsFuncs.Status(objectdata.Status);
const modified = objectdata.modified;
const created = formatDateTimetoReadable(objectdata.created);
const TargetViewingDate = formatDateTimetoReadable(objectdata.TargetViewingDate);
const hashkey = objectdata.hashkey;
let photourl = objectdata.photourl;
if (photourl) {
rows.push('<div class="row">');
rows.push('<div class="col"><center><img src="' + photourl + '" style="width:' + imgwidth + '; height:' + imgheight + ';"></center></div>');
rows.push('<div class="col">');
}
if (modified !== false) {
rowhtml.push(dualcolrow('Last Activity', modified, rowclass = ''));
}
rowhtml.push(dualcolrow('Status', Status, rowclass = ''));
if (TargetViewingDate !== false) {
rowhtml.push(dualcolrow('Target Viewing Date', TargetViewingDate, rowclass = ''));
}
rowhtml.push('<div id="' + LoadDataPageFunc.ids.HashKeyContainer + '-' + rownum + '" style="display:none;">' + hashkey + '</div>');
rowhtml.push(row(col('<br>' + buttonprimary('View', '', LoadDataPageFunc.Settings.ViewDetailsOnclick(hashkey), '-12', 'ListCardGoRow-' + rownum))));
let FinalBody = rowhtml.join('');
return createCard(objectdata.fullname, cardid = 'ListRowCard-' + rownum, created, cardbodyid = '', FinalBody, cardbodyclassadd = 'ListCardRow','','ListRowCard');
};
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 = 'ListContainer';
LoadDataPageFunc.ids.HashKeyContainer = 'ListRowCardHash';
LoadDataPageFunc.ids.MainCardBody = 'MAINCARDBODY_LIST';
LoadDataPageFunc.URLs = {};
LoadDataPageFunc.URLs.QueryListData = '/ListLeads/List/data';
$$$ = {};
$$$.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.NewRow = function (DetailsObject, rownum) {
};
LoadDataPageFunc.ClearSearch = function () {
$('#' + LoadDataPageFunc.ids.SearchInput).val('');
$('#' + LoadDataPageFunc.ids.SearchInput).trigger('keyup');
};
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(LoadDataPageFunc.Settings.fromVarCache)
.success((response) => {
if (!response) {
$('#card-body-' + LoadDataPageFunc.ids.MainCardBody).html(LoadDataPageFunc.Settings.DefaultCardNoDetailsMessage);
return;
}
let List = response.List;
//LeadsList.reverse();
List = LoadDataPageFunc.Settings.SortArray(List);
let newhtmlrows = ''; let htmlarrayrows = [];
const count = List.length;
let hashkey;
for (let i = 0; i < count; i++) {
let hashkey = List[i]['hashkey'];
htmlarrayrows.push(LoadDataPageFunc.NewRow(List[i], i) + '<br>');
}
newhtmlrows = htmlarrayrows.join('');
$('#' + LoadDataPageFunc.ids.ListContainer).html(newhtmlrows);
LoadDataPageFunc.CardResultInterSectionPreloadDetails();
})
.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();
if (title.includes(searchTerm) || cols.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('Leads', FinalInnerHTML, LoadDataPageFunc.ids.MainCardBody);
$$$.UpdateMainContainer(MainCard);
return true;
};
$(document).ready(function () {
LoadDataPageFunc.InitializeDynamicVariables();
LoadDataPageFunc.main();
LoadDataPageFunc.populatelist();
changeTopbarTitle(LoadDataPageFunc.Settings.PageName);
LoadDataPageFunc.SearchKeyUPListPage();
$('#imgspan' + LoadDataPageFunc.ids.SearchInput).attr('onclick', 'LoadDataPageFunc.ClearSearch();');
// $('#ListLeads_Search-div-mb3').addClass('tf-statusbar');
});
</script>

Some files were not shown because too many files have changed in this diff Show More