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