initial: bootstrap from BukidBountyApp base
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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');
|
||||
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user