#CREATE DATABASE IF NOT EXISTS cradle2careertxdb;
#CREATE USER 'cradle2careertx'@'localhost' IDENTIFIED BY 'jdkfjRGfdkE305!fklldgkl';
#GRANT ALL ON cradle2careertxdb.* TO 'cradle2careertx'@'localhost';

#CREATE DATABASE IF NOT EXISTS roundcubedb;
#CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'jdkfjRGfdkE305!fklldgkl';
#GRANT ALL ON roundcubedb.* TO 'roundcube'@'localhost';

#CREATE DATABASE IF NOT EXISTS appfactorystudiodb;
#CREATE USER 'mailman'@'localhost' IDENTIFIED BY 'mailmandatabase777!';
#GRANT ALL ON appfactorystudiodb.* TO 'mailman'@'localhost';

/* /home/appfactorystudio/websites/www/plugins/app/php/server/create_domains */
USE cradle2careertxdb;    

ALTER TABLE managed_domain ADD CertPrivateKeyLocation VARCHAR(255) NULL;
ALTER TABLE managed_domain ADD CertPublicKeyLocation VARCHAR(255) NULL;
ALTER TABLE managed_domain ADD PaypalPort VARCHAR(255) NULL;
ALTER TABLE managed_domain ADD PaypalEndPoint VARCHAR(255) NULL;


ALTER TABLE managed_domain DROP COLUMN Addresss;
ALTER TABLE managed_domain DROP COLUMN Port;
ALTER TABLE managed_domain DROP COLUMN EndPoint;

# https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server
ALTER USER 'cradle2careertx'@'localhost' IDENTIFIED WITH mysql_native_password BY 'jdkfjRGfdkE305!fklldgkl';


CREATE TABLE IF NOT EXISTS subdomains (
	id INT AUTO_INCREMENT PRIMARY KEY,
	SubDomain VARCHAR(255) NULL,
	Active INT DEFAULT 1, 
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
INSERT INTO subdomain_properties (SubDomain) VALUES ("www");
INSERT INTO subdomain_properties (SubDomain) VALUES ("www12");

CREATE TABLE IF NOT EXISTS subdomain_properties (
	id INT AUTO_INCREMENT PRIMARY KEY,
	SubDomain VARCHAR(255) NULL,
	PropertyName VARCHAR(255) NULL,
	PropertyValue TEXT,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
 
UPDATE subdomain_properties SET PropertyName="Address" WHERE PropertyName="Addresss";

INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","Domain",                 "cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","EmailUrl",               "https://www10.cradle2careertx.xyz/portal/validation/email_account/normal/index.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","EmailServer",            "server1.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","AutoEmailLoginUrl",      "https://www10.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","PaypalServiceUrl",       "https://www10.cradle2careertx.xyz:9001/get_token");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","AppfactoryUrl",          "http://live1.appfactory.studio/plugins/app/php/server/request.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","Address",               "https://www10.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","PayPalPort",             "9455");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","PayPalEndPoint",         "paypal_checkout");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","CertPrivateKeyLocation", "/etc/letsencrypt/live/www10.cradle2careertx.xyz/privkey.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","CertPublicKeyLocation",  "/etc/letsencrypt/live/www10.cradle2careertx.xyz/cert.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","PaypalClientId",         "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www10","PaypalAppSecret",        "EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-");


INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","Domain",                 "cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","EmailUrl",               "https://www12.cradle2careertx.xyz/portal/validation/email_account/normal/index.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","EmailServer",            "server1.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","AutoEmailLoginUrl",      "https://www12.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","PaypalServiceUrl",       "https://www12.cradle2careertx.xyz:9001/get_token");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","AppfactoryUrl",          "http://live1.appfactory.studio/plugins/app/php/server/request.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","Address",               "https://www12.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","PayPalPort",             "9456");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","PayPalEndPoint",         "paypal_checkout");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","CertPrivateKeyLocation", "/etc/letsencrypt/live/www12.cradle2careertx.xyz/privkey.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","CertPublicKeyLocation",  "/etc/letsencrypt/live/www12.cradle2careertx.xyz/cert.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PaypalClientId",         "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www11","PaypalAppSecret",        "EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-");


INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","Domain",                 "cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","EmailUrl",               "https://www12.cradle2careertx.xyz/portal/validation/email_account/normal/index.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","EmailServer",            "server1.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","AutoEmailLoginUrl",      "https://www12.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PaypalServiceUrl",       "https://www12.cradle2careertx.xyz:9001/get_token");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","AppfactoryUrl",          "http://live1.appfactory.studio/plugins/app/php/server/request.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","Address",               "https://www12.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PayPalPort",             "9457");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PayPalEndPoint",         "paypal_checkout");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","CertPrivateKeyLocation", "/etc/letsencrypt/live/www12.cradle2careertx.xyz/privkey.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","CertPublicKeyLocation",  "/etc/letsencrypt/live/www12.cradle2careertx.xyz/cert.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PaypalClientId",         "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www12","PaypalAppSecret",        "EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-");

INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","Domain",                 "cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","EmailUrl",               "https://www15.cradle2careertx.xyz/portal/validation/email_account/normal/index.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","EmailServer",            "server1.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","AutoEmailLoginUrl",      "https://www15.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","PaypalServiceUrl",       "https://www15.cradle2careertx.xyz:9001/get_token");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","AppfactoryUrl",          "http://live1.appfactory.studio/plugins/app/php/server/request.php");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","Address",               "https://www15.cradle2careertx.xyz");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","PayPalPort",             "9991");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","PayPalEndPoint",         "paypal_checkout");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","CertPrivateKeyLocation", "/etc/letsencrypt/live/www15.cradle2careertx.xyz/privkey.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","CertPublicKeyLocation",  "/etc/letsencrypt/live/www15.cradle2careertx.xyz/cert.pem");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","PaypalClientId",         "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN");
INSERT INTO subdomain_properties (SubDomain,PropertyName,PropertyValue) VALUES ("www15","PaypalAppSecret",        "EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-");



SELECT * FROM subdomain_properties WHERE SubDomain="www15" AND PropertyName="PayPalPort"; 
UPDATE subdomain_properties SET PropertyValue="9456" WHERE SubDomain="www15" AND PropertyName="PayPalPort"; 

CREATE TABLE IF NOT EXISTS managed_domain (
	id INT AUTO_INCREMENT PRIMARY KEY,
	SubDomain VARCHAR(255) NULL,
	Domain VARCHAR(255) NULL,
	EmailUrl TEXT,
	EmailServer VARCHAR(255) NULL,
	AutoEmailLoginUrl VARCHAR(255) NULL,
	PaypayServiceUrl VARCHAR(255) NULL,
	AppfactoryUrl VARCHAR(255) NULL,
	Addresss VARCHAR(255) NULL,
	PayPalPort VARCHAR(255) NULL,
	PayPalEndPoint VARCHAR(255) NULL,
	CertPrivateKeyLocation VARCHAR(255) NULL,
	CertPublicKeyLocation VARCHAR(255) NULL,
	PaypalClientId VARCHAR(255) NULL,
	PaypalAppSecret VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);











INSERT INTO managed_domain \
(SubDomain,\
Domain,\
EmailUrl,\
EmailServer,\
AutoEmailLoginUrl,\
PaypayServiceUrl,\
AppfactoryUrl,\
Address,\
PaypalPort,
PaypalEndPoint,\
CertPrivateKeyLocation,\
CertPublicKeyLocation,\
PaypalClientId,\
PaypalAppSecret) \
VALUES ( \
"www15", \
"cradle2careertx.xyz", \
"https://www15.cradle2careertx.xyz/portal/validation/email_account/normal/index.php", \
"server1.cradle2careertx.xyz", \
"https://www15.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php", \
"https://www15.cradle2careertx.xyz:9001/get_token", \
"http://live1.appfactory.studio/plugins/app/php/server/request.php",\
"https://www15.cradle2careertx.xyz",\
"9001",\
"paypal_checkout",\
"/etc/letsencrypt/live/www15.cradle2careertx.xyz/privkey.pem",\
"/etc/letsencrypt/live/www15.cradle2careertx.xyz/cert.pem",\
"AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN",\
"EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-"); 


UPDATE managed_domain SET PaypalClientId="AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN", PaypalAppSecret="[REDACTED]" WHERE id=1;
UPDATE managed_domain SET PaypalClientId="AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN", PaypalAppSecret="[REDACTED]" WHERE id=2;

UPDATE managed_domain SET PaypalPort="9005", Address="https://www15.cradle2careertx.xyz", PaypalEndPoint="paypal_checkout" WHERE id=1;
UPDATE managed_domain SET PaypalPort="9006", Address="https://www4.cradle2careertx.xyz", PaypalEndPoint="paypal_checkout" WHERE id=2;

UPDATE managed_domain SET CertPrivateKeyLocation="/etc/letsencrypt/live/www15.cradle2careertx.xyz/privkey.pem", CertPublicKeyLocation="/etc/letsencrypt/live/www15.cradle2careertx.xyz/cert.pem" WHERE id=1;
UPDATE managed_domain SET CertPrivateKeyLocation="/etc/letsencrypt/live/www4.cradle2careertx.xyz/privkey.pem", CertPublicKeyLocation="/etc/letsencrypt/live/www4.cradle2careertx.xyz/cert.pem" WHERE id=2;

UPDATE managed_domain SET PaypayServiceUrl="https://www15.cradle2careertx.xyz:9002/get_token" WHERE SubDomain="www4";
INSERT INTO managed_domain \
(SubDomain,Domain,EmailUrl,EmailServer,AutoEmailLoginUrl,PaypayServiceUrl,AppfactoryUrl) VALUES ( \
"www4", \
"cradle2careertx.xyz", \
"https://www4.cradle2careertx.xyz/portal/validation/email_account/normal/index.php", \
"server1.cradle2careertx.xyz", \
"https://www4.cradle2careertx.xyz/portal/mailclient/1/RoundcubeAutoLogin.php", \
"https://www4.cradle2careertx.xyz:9443/get_token", \
"http://live1.appfactory.studio/plugins/app/php/server/request.php"); 

UPDATE managed_domain SET PaypayServiceUrl="https://www4.cradle2careertx.xyz:9002/get_token" WHERE SubDomain="www4";
UPDATE managed_domain SET PaypayServiceUrl="https://www15.cradle2careertx.xyz:9001/get_token" WHERE SubDomain="www15";


INSERT INTO admin_users (Username,Password,Email) VALUES ("admin","private-909!","");
UPDATE admin_users SET Username = "admin", Password = "[REDACTED]
SELECT *, CASE WHEN LENGTH(WebsiteData) > 7 THEN CONCAT(SUBSTRING(WebsiteData, 1, 7), '99999999') ELSE WebsiteData END AS AddNumber FROM webbuilder;
INSERT INTO webbuilder (ProjectName,ImagesDirectory,ImageUploadURL,ImageUploadName) VALUES ("project_1","assets","other/request.php","upload_image");



CREATE TABLE IF NOT EXISTS managed_settings (
	id INT AUTO_INCREMENT PRIMARY KEY,
	RegistrationEmailFrom VARCHAR(255) NULL,
	ContactEmailFrom VARCHAR(255) NULL,
	RegistrationEmailTemplate VARCHAR(255) NULL,
	ContactEmailTemplate VARCHAR(255) NULL,
	SponsorshipEmailFrom VARCHAR(255) NULL,
	SponsorshipEmailTemplate VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
INSERT INTO managed_settings (RegistrationEmailFrom,ContactEmailFrom,RegistrationEmailTemplate,ContactEmailTemplate) VALUES ("registration","contact","index.html","index.html");

ALTER TABLE managed_settings ADD SponsorshipEmailFrom VARCHAR(255) NULL;
ALTER TABLE managed_settings ADD SponsorshipEmailTemplate VARCHAR(255) NULL;

UPDATE managed_settings SET SponsorshipEmailFrom="sponsorships", SponsorshipEmailTemplate="" WHERE id=1;

USE cradle2careertxdb; 
CREATE TABLE IF NOT EXISTS admin_users (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Username VARCHAR(255) NULL,
	Email VARCHAR(255) NULL,
	Password VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS webbuilder (
	id INT AUTO_INCREMENT PRIMARY KEY,
	ProjectName VARCHAR(255) NULL,
	ImagesDirectory VARCHAR(255) NULL,
	ImageUploadURL VARCHAR(255) NULL,
	ImageUploadName VARCHAR(255) NULL,
	WebsiteData MEDIUMTEXT,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS electronic_cards (
	id INT AUTO_INCREMENT PRIMARY KEY,
	CardNumber VARCHAR(255) NULL,
	ExpirationDate VARCHAR(255) NULL,
	CVV  VARCHAR(255) NULL,
	NameOnCard VARCHAR(255) NULL,
	email VARCHAR(255) NULL,
	BillingAddress VARCHAR(255) NULL,
	State VARCHAR(255) NULL,
	City VARCHAR(255) NULL,
	Zip VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
USE cradle2careertxdb;
CREATE TABLE IF NOT EXISTS receipts (
	id INT AUTO_INCREMENT PRIMARY KEY,
	type VARCHAR(255) NULL,
	name VARCHAR(255) NULL,
	email VARCHAR(255) NULL,
	amount VARCHAR(255) NULL,
	processor VARCHAR(255) NULL,
	receipt MEDIUMTEXT,
	orderId VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS notifications (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Type VARCHAR(255) NULL,
	Reviewed INT DEFAULT 0,
	MysqlTable VARCHAR(255) NULL,
	InsertId INT,
	Message TEXT,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS subscribers (
	id INT AUTO_INCREMENT PRIMARY KEY,
	email VARCHAR(255) NULL,
	name INT DEFAULT 1,
	subscribed INT DEFAULT 1,
	subscriptions VARCHAR(255) NULL,
	assigned_from VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS contact_us_form (
	id INT AUTO_INCREMENT PRIMARY KEY,
	name VARCHAR(255) NULL,
	email VARCHAR(255) NULL,
	message TEXT,
	assigned_from VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS contact (
	id INT AUTO_INCREMENT PRIMARY KEY,
	type VARCHAR(255) NULL,
	email VARCHAR(255) NULL,
	phone VARCHAR(255) NULL,
	address VARCHAR(255) NULL,
	name VARCHAR(255) NULL,
	message TEXT,
	assigned_from VARCHAR(255) NULL,
	checked INT DEFAULT 0,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
INSERT INTO contact (type,email,phone,address) VALUES ("contact_us","contact@cradle2careertx.xyz","000-000-000","24301 Brazos Town Crossing #500, PMB #318 Rosenberg, TX 77471");
INSERT INTO contact (type,email,phone,address) VALUES ("support","support@cradle2careertx.xyz","000-000-000","24301 Brazos Town Crossing #500, PMB #318 Rosenberg, TX 77471");

ALTER TABLE contact ADD message TEXT;

CREATE TABLE IF NOT EXISTS application_settings (
	id INT AUTO_INCREMENT PRIMARY KEY,
	category VARCHAR(255) NULL,
	json MEDIUMTEXT,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);

USE cradle2careertxdb;
ALTER TABLE application_settings RENAME COLUMN name TO category;

INSERT INTO application_settings (category,json) VALUES ("sponsorships",'{"name":"sponsorship_1","displayName":"Sponsor Level 1","type":"level","available":true,"canAdjust":true,"basePrice":"25","maxPrice":"10000","description":"By becoming a sponsor today youll have thhe oppertinuty to support a great orginazation and have your name or company logo displayed in our sponsors area. Once again thank you for your support.","image":""}');

INSERT INTO application_settings (category,json) VALUES ("sponsorships",'')




CREATE TABLE IF NOT EXISTS calender (
	id INT AUTO_INCREMENT PRIMARY KEY,
	EventName VARCHAR(255) NULL,
	EventDateStartFormat1 TIMESTAMP NULL,
	EventDateStartFormat2 VARCHAR(255) NULL,
	EventDateStartFormat3 VARCHAR(255) NULL,
	EventDateEndFormat1 TIMESTAMP NULL,
	EventDateEndFormat2 VARCHAR(255) NULL,
	EventDateEndFormat3 VARCHAR(255) NULL,
	EventDescription TEXT,
	EventLocation VARCHAR(255) NULL,
	EventImage VARCHAR(255) NULL,
	RSVPEnabled INT DEFAULT 0,
	ReminderEnabled INT DEFAULT 0,
	Cost VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);

CREATE TABLE IF NOT EXISTS event_rsvp (
	id INT AUTO_INCREMENT PRIMARY KEY,
	name VARCHAR(255) NULL,
	PlusOne VARCHAR(255) NULL,
	EventId INT,
	Email VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS event_reminders (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Name VARCHAR(255) NULL,
	CanBeNotified INT DEFAULT 1,
	Notified INT DEFAULT 0,
	Email VARCHAR(255) NULL,
	EventDate TIMESTAMP,
	EventName VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);

CREATE TABLE IF NOT EXISTS sponsorships (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Name VARCHAR(255) NULL,
	Type INT DEFAULT 1,
	Available INT DEFAULT 1,
	BasePrice VARCHAR(255) NULL,
	CanAdjust INT DEFAULT 0,
	Description TEXT,
	Image VARCHAR(255) NULL,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
UPDATE sponsorships SET BasePrice="25" WHERE id=1;

ALTER TABLE sponsorships ADD Available INT DEFAULT 1;

INSERT INTO sponsorships (Name,Type,BasePrice,CanAdjust,Description) VALUES \
("Sponsorship 1",1,"one","10.00","Become a sponsor have your name or company logo displayed");


CREATE TABLE IF NOT EXISTS sponsors (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Name VARCHAR(255) NULL,
	Email VARCHAR(255) NULL,
	CompanyName VARCHAR(255) NULL,
	Approved INT DEFAULT 2,
	Active INT DEFAULT 1,
	SponsorshipId INT NULL,
	Company INT DEFAULT 0,
	Months INT DEFAULT 1,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);

CREATE TABLE IF NOT EXISTS app_apply (
	id INT AUTO_INCREMENT PRIMARY KEY,
	name VARCHAR(255) NULL,
	answers MEDIUMTEXT,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);



USE cradle2careertxdb; 

/*
New Site Links
***** https://www15.cradle2careertx.xyz 
***** https://www15.cradle2careertx.xyz/portal/admin

This is the new url. The only section that has not been worked at all is Initiatives.
We'll go over the paypal intergration.

Issues:
- No response email's go out currently for receipts, subscribing and apply
- Chrome is the recommended browser, other browsers have not been fully tested yet.
- Some design artifacts such as incorrect sizes and positioning of elements
- Backend functionality incomplete (events,subscriptions,receipts)
- Credit card Processing issues
- Social media links needed

***** Creating Email
You can create as many emails as you like, we'll go over the process again but you can
play around with it to see the flow of creation. If you have any bug issues you can
notate them. Most everything is plain, such as the confirmation email, so you can take 
style notes also. 

***** Subscribe
This is a basic subscribe function for now. Once user enters their email and press the
Subscribe button they will receive a confrimation email. Then on the backend you'll 
be able to view who's subscribed. We'll work on how you would like to implement sending
emails to subscribed users.

***** I'm Ready To Apply
Copied verbatium from reference site but has not been fully completed.

***** Paypal
Test Credit Card numbers for a successful transaction
[REDACTED]
-------------------
08/26
-----
336
---
And of course use any numbers for a non successful transaction.
Once the user donates they will be sent a receipt and you will be able to view
it also on the backend. You'll need to log on to your paypal account and get 
your client-id and secret
If you don't know how to get that info this is a great video on how to find it
https://www.youtube.com/watch?v=9p-kA20-Bgg or we can go over it together because 
honestly it was hard for me to find. Also while your on there you can select 
your paypal button look. The current look that I have I chose it and more worked
on the on-site credit card processing intergration. It may be some other things I'm
forgetting cause implementing paypal was kinda extensive. 

***** Terms of Service and Privacy Policy
Becuase data is collected, such email and name, I've put up a temp privacy policy and terms of service 
I used a service to generate these documents but you may teller them to your liking.
https://www.cradle2careertx.org/terms_of_service.html
https://www.cradle2careertx.org/privacy_policy.html



*/



/** Users */
CREATE TABLE IF NOT EXISTS afs_users (
	id INT AUTO_INCREMENT PRIMARY KEY,
	Username VARCHAR(255) NULL,
	Firstname VARCHAR(255) NULL,
	Lastname VARCHAR(255) NULL,
	Email VARCHAR(255) NULL,
	Password VARCHAR(255) NULL,
	Country VARCHAR(255) NULL,
	City VARCHAR(255) NULL,
	State VARCHAR(255) NULL,
	Zip VARCHAR(255) NULL,
	EmailConfirmed INT DEFAULT 0,
	Robot INT DEFAULT 0,
	Tester INT DEFAULT 0,
	Dummy INT DEFAULT 0,
	date TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);











