initial commit

This commit is contained in:
equippedcoding-master
2025-09-17 09:37:06 -05:00
parent 86108ca47e
commit e2c98790b2
55389 changed files with 6206730 additions and 0 deletions

View File

@@ -0,0 +1,306 @@
(function(){
let req = "../../core/php/request.php";
if(mypage=="index"){
req = "../../core/php/request.php";
}
const REQUEST_URL = req;
let data = { retrieve_data_for_update: true };
const LOADER_REMOVE_WAIT = 0;
const LOADER_ID = "afs-main-loader-screen";
document.body.insertAdjacentHTML("afterbegin", application_loader_screen_html());
$.post(REQUEST_URL,{
get_html_client_templates:true,
path: "portal/user/html"
},function(clientHtmlTemplatesStr){
$.post(REQUEST_URL, data, function(resp){
afsconfig = JSON.parse(resp);
let app = new ApplicationContextManager();
app.extra.config = AFS_SCHEMA_DESCRIPTION_INTEGRATION(afsconfig);
app.extra.config.html = JSON.parse(clientHtmlTemplatesStr);
app.extra.config.afsanalytics = new AFSAnalytics(REQUEST_URL, app);;
app.extra.pay = afsconfig.configurations.payments;
app.extra.payments = new AFSPayments(app);
app.extra.views = {};
app.extra.payments.service.createPaypalInstance();
app.extra.payments.service.paypal().setupLink({
params: "components=buttons,hosted-fields", // default
log: true,
callback: function(isPaypalLoaded){
console.log("isPaypalLoaded: " + isPaypalLoaded);
requirejs.config({ baseUrl: './js/pages/' });
let routes = [mypage];
require(routes, function(_route_func){
setTimeout(() => {
$("#"+LOADER_ID).remove();
_route_func(app);
run(app);
},LOADER_REMOVE_WAIT);
});
}
});
function run(app){
$('.log_out_link').on('click',function(e){
e.preventDefault();
window.location.href = app.extra.config.managed_domain.Address + "/portal/user/logout.php";
});
}
window.gl_process_payment_donation = gl_process_payment_donation;
function gl_process_payment_donation(paypalContainerId,amountId,app){
afspayments.service.paypal().setupCheckout({
container_id: paypalContainerId,
options: {
price: document.getElementById(amountId).innerHTML,
appendNow: true,
paypal_error_message: "Sorry, your transaction could not be processed, please try again.",
showPaypalButton: true,
showPaypalForm: true,
billingAddressEnabled: false,
billingAddressNameEnabled: false,
onSubmit: {
showButton: true,
id: "submit",
className: "paypal-donate-btn",
label: "Donate",
}
},
button_onApprove_callback: function(){
const myModalAlternative = new bootstrap.Modal('#myModal', {});
myModalAlternative.hide();
},
button_onClick_callback: function(){
// dollar-amount
let textObj = document.getElementById("dollar-amount");
let amount = app.utils.moneyFormat(textObj);
if(amount==undefined || amount==""){
amount = "5.00";
}
let floatAmount = parseFloat(amount);
if(floatAmount < 0.5){ amount = "1.00"; }
// card-name
let name_obj = document.getElementById("card-name");
let name = app.utils.moneyFormat(name_obj);
// card-name
let emailObj = document.getElementById("card-email");
let email = app.utils.moneyFormat(emailObj);
return {amount:amount,email:email,name:name};
},
/**
* Called when the order is created. You should retrieve amount
* then validate amount return. If the amount is validate
* successufully then return pass:true otherwise pass:false.
* The amount also needs to be passed.
*
*
* @returns
*/
validate_price_callback: function(){
let textObj = document.getElementById("dollar-amount");
let amount = app.utils.moneyFormat(textObj);
return {pass:true,value:amount};
},
/**
* Called right before submit. Validate any input then return object
* with any data that needs to be passed through with the required
* property pass = true|false.
* @returns
*/
validation_callback: function(){
var nameValue = document.getElementById('card-name').value;
var emailValue = document.getElementById('card-email').value;
var charge = document.getElementById(amountId).innerHTML;
if(nameValue=="" || emailValue==""){
alert("Please provide your name and email!");
return {pass: false};
}
return {
pass: true,
name: nameValue,
email: emailValue,
charge: charge,
amount: charge
};
},
/**
* Called when the transaction has been made successfully.
* @param {*} orderData
*/
success_callback: function(paypalObj){
// nnnnn
// AR2VfeqErRvgVHp6B9ZPRAtfLzEA4tTz__C1EU0F60lsq9GgCLYPAomMgxscP3xEA9qiptKgnEgbJiBQ
// EDJNEZ7HofqGyGkBaSbuQvdbhWfGrkTp6sqXfA1T5Ry-OKrcnq-cm__vCcGy8Wx2LYmrPNyK5PBTBQB2
app.config.configurations.donations[0].json.reference_num = app.config.configurations.donations[0].json.reference_abbr + app.utils.numberId(6);
app.config.configurations.donations[0].json.name = paypalObj.values.name;
app.config.configurations.donations[0].json.email = paypalObj.values.email;
app.config.configurations.donations[0].json.amount = paypalObj.values.amount;
app.config.configurations.donations[0].json.orderData = paypalObj.orderData;
app.config.configurations.donations[0].json.email_response.email = paypalObj.values.email;
app.config.configurations.donations[0].json.
variables.push({name: "email", value: paypalObj.values.email });
app.config.configurations.donations[0].json.
variables.push({name: "fullname", value: paypalObj.values.name });
app.config.configurations.donations[0].json.
variables.push({name: "amount", value: paypalObj.values.amount });
app.config.configurations.donations[0].json.
variables.push({name: "reference_num", value: app.config.configurations.donations[0].json.reference_num });
let mydata = {
"donation_apply_success": true,
"category": app.config.configurations.donations[0].json.category,
"reference_abbr": app.config.configurations.donations[0].json.reference_abbr,
"reference_num": app.config.configurations.donations[0].json.reference_num,
"reference_acct": app.config.configurations.donations[0].json.email,
"json": JSON.stringify(app.config.configurations.donations[0].json)
};
console.log(mydata);
console.log(paypalObj);
$.post(REQUEST_URL,mydata,function(resp){
console.log(resp);
});
},
error_callback: function(err){
console.log(err);
},
success_content: function(paypalObj){
console.log(paypalObj);
return `
<div>
<style>
.tmp-flex-container {
display: flex;
flex-direction: column;
}
</style>
<div class="tmp-flex-container">
<h4>Thank you for your donation!</h4>
<span>You will receive an email receipt to the email address you provided <strong>${paypalObj.values.email}</strong></span>
<span>Continue to follow us and keep up to date with current <a href="#" style="text-decoration: none;">events</a> & <a href="#" style="text-decoration: none;">news</a> and how you can be a Cradle2career <a href="#" style="text-decoration: none";>sponsor.</a></span>
<button style="margin-top:40px;" data-bs-dismiss="modal" class="btn btn-success">Close</button>
</div>
</div>
`},
});
}
function __initialize_paypal(paypalContainerId, self){
self.afspayments.service.paypal().setupCheckout({
container_id: paypalContainerId,
options: {
appendNow: false,
paypal_error_message: "Sorry, your transaction could not be processed, please try again.",
showPaypalButton: true,
showPaypalForm: true,
billingAddressEnabled: true,
billingAddressNameEnabled: true,
onSubmit: {
showButton: false,
id: "sponsorship_submit_button"
}
},
validation_callback: function(){ return {pass: true}; },
validate_price_callback: function(){
console.log(self.sponsorship.json.form.selected_level);
return {pass:true,value: self.sponsorship.json.form.selected_level.price};
},
success_callback: function(orderData){
console.log(orderData);
self.sponsorship.json.order_data = orderData.processor_data;
let acct_password = "";
let acct_name = "";
console.log(self.sponsorship.json.variables);
for(let i=0; i < self.sponsorship.json.variables.length; i++){
if(self.sponsorship.json.variables[i]['name'] == "response_password"){
acct_password = self.sponsorship.json.variables[i]['value'];
}
// if(self.sponsorship.json.variables[i]['name'] == "response_email"){
// acct_name = self.sponsorship.json.variables[i]['value'];
// }
}
acct_name = self.sponsorship.json.reference_acct;
removeFormDataObject(self);
addSystemNeededVariables(self);
variableReplacement(self);
let mydata = {
new_sponsorship: true,
category: self.sponsorship.json.category,
reference_num: self.sponsorship.json.reference_num,
reference_abbr: self.sponsorship.json.reference_abbr,
reference_acct: self.sponsorship.json.reference_acct,
acct_name: acct_name,
password_hash: acct_password,
acct_email: self.sponsorship.json.reference_acct,
quick_view_token: self.sponsorship.json.quick_view_token,
domain: JSON.stringify(self.domain),
json: JSON.stringify(self.sponsorship.json)
};
console.log(mydata);
console.log(self.sponsorship);
$.post('../../core/php/request.php',mydata,function(e){
console.log(e);
});
},
error_callback: function(err){
console.log(err);
},
success_content: function(orderData){
return self.variablesReplace(self.sponsorship.json.success_message,"hash");
}
});
}// end gl_process_payment_sponsorship
});
});// end post client html template
function application_loader_screen_html(){
return `
<div id="${LOADER_ID}">
<div class="page page-center">
<div class="container container-slim py-4">
<div class="text-center">
<div class="mb-3">
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-small.svg" height="36" alt=""></a>
</div>
<div class="text-secondary mb-3">Preparing dashboard</div>
<div class="progress progress-sm">
<div class="progress-bar progress-bar-indeterminate"></div>
</div>
</div>
</div>
</div>
</div>
`;
}
})();// END function

View File

@@ -0,0 +1,11 @@
define(["methods"], function(methods) {
return {
methods: methods
};
});

View File

@@ -0,0 +1,11 @@
define(['manager'], function(AppManager) {
function init(app,afsconfig,afspayments){
let appmanager = new AppManager(app,afsconfig,afspayments);
appmanager.init('content_container');
}
return init;
});

View File

@@ -0,0 +1,272 @@
define(["views","methods"], function(routeViews,routeMethods) {
// https://www15.cradle2careertx.xyz/portal/admin/
// https://www15.cradle2careertx.xyz/portal/sponsor/
// https://www15.cradle2careertx.xyz/portal/email/
// https://www15.cradle2careertx.xyz/portal/dashboard/
function AppManager(app,afsconfig,afspayments){
let self = this;
self._props_ = {};
self.container = {};
self.container.views = {};
self.routeViews = routeViews;
self.app = app;
self.afsconfig = afsconfig;
self.domain = afsconfig.managed_domain;
self.afspayments = afspayments;
let notif = [];
for(let i=0; i < afsconfig.notifications.length; i++){
// console.log(afsconfig.notifications[i].json.reference_acct + " | " + afsconfig.user.email)
if(afsconfig.notifications[i].json.reference_acct==afsconfig.user.email){
notif.push(afsconfig.notifications[i]);
}
}
self.sponsorships = notif;
self.sponsor = {};
}
// mmmmm
function ___add_request_object(self){
if(self.sponsor.afssponsorship.sponsorship.json["request"]==undefined){
self.sponsor.afssponsorship.sponsorship.json["request"] = {
"url":"core/php/request.php",
"onsubmit":"api_submit_form_become_a_member",
"dataupload":"api_upload_data",
"fileupload":"api_upload_file",
"savedirectory": "sponsors/files"
};
}
}
function __remove_file_input(self){
let $el = $("#image_logo_upload");
$el.wrap('<form>').closest(
'form').get(0).reset();
$el.unwrap();
}
AppManager.prototype = {
init: function(appendto){
let self = this;
self.container.views.rootview = routeViews.createRootView(self);
document.getElementById(appendto).appendChild(self.container.views.rootview.getHtml());
},
_root_view: {
createSponsorshipCards: function(self){
// console.log(self)
self.sponsor._tmp = {};
self.sponsor.afssponsorship = new AFSSponsorship(self.app, self.afsconfig, self.afspayments);
let cards = "";
let sponsorshipList = [];
self.sponsor.selected_sponsorship = null;
for(let i=0; i < self.sponsorships.length; i++){
// console.log(self.sponsor.afssponsorship.sponsorships[i]);
self.sponsor.afssponsorship.sponsorship = self.sponsorships[i];
cards = (cards=="") ? self.afsconfig.html.card_sponsor : (self.afsconfig.html.card_sponsor + cards);
console.log(cards)
console.log(self.afsconfig.html)
cards = self.sponsor.afssponsorship.variablesReplace(cards,"normal");
let id = "manage_sponsorship_btn"+i;
if(self.sponsor.afssponsorship.sponsorship.json.account.status==0){
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "description", "Pending", "normal");
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "manage_button", "", "normal");
}else if(self.sponsor.afssponsorship.sponsorship.json.account.status==1){
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "description", "Active", "normal");
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "manage_button", `<a href="#" id="${id}" class="card-link">manage</a>`, "normal");
sponsorshipList.push({id:id, sponsorship: self.sponsor.afssponsorship});
}else if(self.sponsor.afssponsorship.sponsorship.json.account.status==2){
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "description", "Denied", "normal");
cards = self.sponsor.afssponsorship.sanitizeReplace(cards, "manage_button", "", "normal");
sponsorshipList.push({id:id, sponsorship: self.sponsor.afssponsorship});
}
}
// console.log(self.afsconfig.html.index);
self.sponsor._tmp.sponsorshipList = sponsorshipList;
return self.app.factory.container({
body: self.afsconfig.html.index,
listener: function(e){
let cardhtml = self.app.utils.convertStringToHTMLNode(cards);
document.getElementById("main_container1").appendChild(cardhtml);
}
});
},
_listener_sponsorship_card: function(e,self){
let sponsorshipList = self.sponsor._tmp.sponsorshipList;
// console.log(sponsorshipList);
for (let index = 0; index < sponsorshipList.length; index++) {
const element = sponsorshipList[index];
$("#"+element.id).on('click',function(e){
e.preventDefault();
self.selected_sponsorship = element.sponsorship;
self.container.views.rootview.render('view2');
});
}
},
createSponsorshipView: function(self){
let x = self.sponsor.afssponsorship.variablesReplace(afsconfig.html.sponsorship_view,"normal");
return x;
},
_listener_sponsorship_sponsor_dashboard: function(e,self){
$('#image_logo_upload_btn').on('click',function(event){
event.preventDefault();
self.__upload();
});
self.__getimagesize("image_logo_upload");
self.__display_logo_image();
}
},
__display_logo_image: function(){
let self = this;
let userid = self.afsconfig.user.id;
console.log(self.selected_sponsorship.sponsorship)
let sponsorship = self.selected_sponsorship.sponsorship;
if(sponsorship.json.brand==undefined || sponsorship.json.brand.images==undefined){
return;
}
let filename = sponsorship.json.brand.images[0].new_name;
let systemuser = self.domain.SystemUser;
let savedirectory = self.sponsor.afssponsorship.sponsorship.json.request.savedirectory;
let urlparams = `api_download_file=true&userid=${userid}&file=${filename}&savedirectory=${savedirectory}&systemuser=${systemuser}`;
// mmmmm
let x = `
<div class="card logo_images_card mb-5" style="">
<img style="height:100%;" src="../../core/php/request.php?${urlparams}" class="card-img-top" alt="Cradle2Career">
<div class="card-body">
<p class="card-text"></p>
</div>
</div>
`;
$("#logo_images").empty();
$("#logo_images").append(x);
},
__getimagesize: function(id){
let self = this;
var _URL = window.URL || window.webkitURL;
$("#"+id).on("change",function(e) {
var file, img;
if ((file = this.files[0])) {
img = new Image();
img.onload = function(event) {
// console.log(this.width + " " + this.height);
self.__upload_file = file;
};
img.onerror = function() {
alert( "not a valid file: " + file.type + "- use only PNG,JPG,JPEG,SVG,GIF");
__remove_file_input(self);
};
img.src = _URL.createObjectURL(file);
}
});
},
__upload: function(){
let self = this;
___add_request_object(self);
let file = self.__upload_file;
if(file==undefined || file==null){
return;
}
// console.log(file);
// console.log(self.sponsor.afssponsorship.sponsorship.json);
let filedataobject = {
original_name: file.name,
new_name: self.sponsor.afssponsorship.sponsorship.json.reference_abbr + "_" + self.sponsor.afssponsorship.___filenameGenerator(32) + "." + file.name.split('.').pop(),
category: self.sponsor.afssponsorship.sponsorship.json.category,
savedirectory: self.sponsor.afssponsorship.sponsorship.json.request.savedirectory
}
if(self.sponsor.afssponsorship.sponsorship.json.brand==undefined){
self.sponsor.afssponsorship.sponsorship.json.brand = {};
self.sponsor.afssponsorship.sponsorship.json.brand.images = [];
}
let old_images = self.sponsor.afssponsorship.sponsorship.json.brand.images;
self.sponsor.afssponsorship.sponsorship.json.brand.images = [];
self.sponsor.afssponsorship.sponsorship.json.brand.images.push(filedataobject);
let formData = new FormData();
let datauploadUrl = self.sponsor.afssponsorship.sponsorship.json.request.dataupload;
let fileuploadUrl = self.sponsor.afssponsorship.sponsorship.json.request.fileupload;
let systemuser = self.domain.SystemUser;
formData.append(fileuploadUrl, file);
formData.append(datauploadUrl, JSON.stringify(filedataobject));
formData.append("systemuser", systemuser);
formData.append("savedirectory", self.sponsor.afssponsorship.sponsorship.json.request.savedirectory);
let req = new XMLHttpRequest();
req.addEventListener('progress', function(e) {
var done = e.position || e.loaded, total = e.totalSize || e.total;
// console.log(filedataobject.original_name + ' progress: ' + (Math.floor(done/total*1000)/10) + '%');
}, false);
if ( req.upload ) {
self.upload_in_progress = true;
req.upload.onprogress = function(e) {
var done = e.position || e.loaded, total = e.totalSize || e.total;
// console.log(filedataobject.original_name + ' req.upload progress: ' + done + ' / ' + total + ' = ' + (Math.floor(done/total*1000)/10) + '%');
};
}
req.onreadystatechange = function(e) {
if ( 4 == this.readyState ) {
console.log(this.responseText);
self.upload_in_progress = false;
let url = self.domain.Address + "/core/php/request.php";
$.post(url,{
update_notifications_json: true,
mysql_id: self.sponsor.afssponsorship.sponsorship.json.mysql_id,
data: JSON.stringify(self.sponsor.afssponsorship.sponsorship.json)
},function(resp){
// mmmmm
self.__display_logo_image();
for(let m=0; m < old_images.length; m++){
setTimeout(function(){
// do a marked for deletetest here
// console.log(old_images)
$.post(url,{
delete_file: true,
filename: old_images[m].new_name,
systemuser: systemuser,
savedirectory: "sponsors/files"
},function(resp){
// console.log(resp);
});
},500);
}
// console.log(resp);
});
__remove_file_input(self);
}
};
let requesturl = self.domain.Address + "/" + self.sponsor.afssponsorship.sponsorship.json.request.url
req.open("POST", requesturl);
// req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
req.send(formData);
}
};
return AppManager;
});

View File

@@ -0,0 +1,23 @@
define([], function() {
function init(myapp,afsconfig){
}
return init;
});

View File

@@ -0,0 +1,10 @@
define(["views/root_view"], function(root_view) {
return {
createRootView: function(appmanager){
return root_view(appmanager);
}
}
});

View File

@@ -0,0 +1,64 @@
define([], function() {
function root_view(appmanager){
let app = appmanager.app;
var view = app.factory.view();
let width = "260px";
let height = "200px";
view.newSubView({
id: "load",
init: true,
body: app.factory.container({
body: `<div class="row"><div class="col-12 col-lg-3"><div class="" style="" id="square"></div></div></div>`,
listener: function(e){
let spin = AFSSpinner.create({
type: "default",
id: "square",
width: width,
height: height,
opacity: ".0",
top: "0px",
left: "0px",
spin_color: "blue",
spin_color_bg: "#fff",
mt: "30%"
});
spin.show();
setTimeout(() => {
view.render('view1');
},2000);
}
})
});
view.newSubView({
id: "view1",
init: false,
body: app.factory.container({
body: appmanager._root_view.createSponsorshipCards(appmanager),
listener: function(e){
appmanager._root_view._listener_sponsorship_card(e,appmanager);
}
})
});
view.newSubView({
id: "view2",
init: false,
body: app.factory.container({
body: appmanager._root_view.createSponsorshipView(appmanager),
listener: function(e){
// console.log(13);
appmanager._root_view._listener_sponsorship_sponsor_dashboard(e,appmanager);
}
})
});
return view;
}
return root_view;
});

View File

@@ -0,0 +1,60 @@
const validation = new JustValidate("#signup");
validation
.addField("#name", [
{
rule: "required"
}
])
.addField("#email", [
{
rule: "required"
},
{
rule: "email"
},
{
validator: (value) => () => {
return fetch("validate-email.php?email=" + encodeURIComponent(value))
.then(function(response) {
return response.json();
})
.then(function(json) {
return json.available;
});
},
errorMessage: "email already taken"
}
])
.addField("#password", [
{
rule: "required"
},
{
rule: "password"
}
])
.addField("#password_confirmation", [
{
validator: (value, fields) => {
return value === fields["#password"].elem.value;
},
errorMessage: "Passwords should match"
}
])
.onSuccess((event) => {
document.getElementById("signup").submit();
});