HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/shootinschool/wp-content/plugins/shootin-school-plugin/core_tables.php
<?php

// function to create the DB tables
function siab_table_install()
{
	global $wpdb;

	$inst_admin_created = 'Hi {instructor_name}<br><br>
	<strong>Your Instructor account has been created successfully.</strong> <br><br>
	Username : {instructor_email} <br>
	Password : {instructor_password}';

	$cust_admin_cancelled= 'Hi {customer_name},<br><br>
	<strong>Your Appointment has been cancelled by the Site Administrator.</strong> <br><br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$inst_admin_cancelled = 'Hi {instructor_name},<br><br>
	<strong>An appointment assigned to you has been cancelled by the Site Administrator.</strong> <br><br>
	Customer Name : {customer_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$inst_admin_assigned = 'Hi {instructor_name},<br><br>
	<strong>An appointment has been assigned to you by the Site Administrator.</strong> <br><br>
	Customer Name : {customer_name} <br>
	Location : {location_name}<br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$cust_admin_assigned = 'Hi {customer_name},<br><br>
	<strong>Your appointment has been assigned to an Instructor by the Site Administrator.</strong> <br><br>
	Instructor Name : {instructor_name} <br>
	Location : {location_name}<br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$cust_cust_booked = 'Hi {customer_name},<br><br>
	<strong>Your Appointment has been Booked.</strong> <br><br>
	Location : {location_name}<br>
	Credits left : {credits} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$admin_cust_booked = 'Hi Admin ,<br><br>
	<strong>An Appointment has been booked against </strong> {customer_name} <br><br>
	Location : {location_name} <br>
	Package Name : {package} <br>
	Credits Left : {credits} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$cust_cust_cancelled = 'Hi {customer_name},<br><br>
	<strong>Your Appointment has been cancelled.</strong> <br><br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$admin_cust_cancelled = '  Hi Admin,<br><br>
	<strong>A Customer has cancelled his appointment.</strong> <br><br>
	Customer Name : {customer_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$inst_cust_cancelled = 'Hi {instructor_name},<br><br>
	<strong>An appointment assigned to you has been cancelled by the customer.</strong> <br><br>
	Customer Name : {customer_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$cust_inst_cancelled = 'Hi {customer_name},<br><br>
	<strong>Your appointment has been cancelled by the Instructor.</strong> <br><br>
	Appointment ID : <strong>{appointment_id}</strong> <br>
	Instructor Name : <strong>{instructor_name}</strong> <br>
	Appointment Date : <strong>{appointment_date}</strong> <br>
	Appointment Time : <strong>{appointment_time}</strong> ';

	$admin_inst_cancelled = 'Hi Admin,<br><br>
	<strong>An appointment has been cancelled by the Instructor.</strong> <br><br>
	Appointment ID : <strong>{appointment_id} </strong><br>
	Customer Name : <strong>{customer_name} </strong><br>
	Instructor Name : <strong>{instructor_name} </strong><br>
	Appointment Date : <strong>{appointment_date} </strong><br>
	Appointment Time : <strong>{appointment_time} </strong>';

	$cust_reminder_cron = 'Hi {customer_name},<br><br>
	<strong>You have an Appointment today</strong> <br><br>
	Appointment ID : <strong>{appointment_id} </strong><br>
	Instructor Name : <strong>{instructor_name} </strong><br>
	Appointment Time : <strong>{appointment_time} </strong>';

	$cust_charged_cancel = 'Hi {customer_name},<br><br>
	<strong>Your appointment has been cancelled.</strong> <br><br>
	Appointment ID : <strong>{appointment_id} </strong><br>
	Charged Fee : <strong>{charge} </strong><br>
	Instructor Name : <strong>{instructor_name} </strong><br>
	Appointment Date : <strong>{appointment_date} </strong><br>
	Appointment Time : <strong>{appointment_time} </strong>';

	$admin_charged_cancel = 'Hi Admin,<br><br>
	<strong>An appointment has been cancelled by the Customer.</strong> <br><br>
	Appointment ID : <strong>{appointment_id} </strong><br>
	Customer Name : <strong>{customer_name} </strong><br>
	Instructor Name : <strong>{instructor_name} </strong><br>
	Charged Fee : <strong>{charge} </strong><br>
	Appointment Date : <strong>{appointment_date} </strong><br>
	Appointment Time : <strong>{appointment_time} </strong>';

	$inst_charged_cancel = 'Hi Admin,<br><br>
	<strong>An appointment assigned to you has been cancelled by the Customer.</strong> <br><br>
	Appointment ID : <strong>{appointment_id} </strong><br>
	Customer Name : <strong>{customer_name} </strong><br>
	Instructor Name : <strong>{instructor_name} </strong><br>
	Appointment Date : <strong>{appointment_date} </strong><br>
	Appointment Time : <strong>{appointment_time} </strong>';

	$cust_appt_time_change = 'Hi {customer_name},<br><br>
	Admin has suggested a time change to <strong>{new_slot_time}</strong> for your appointment on {current_appt_date_time}<br/><br>
	Click to approve time change : {verification_url}<br/>
	Click to reject time change : {rejected_url}<br/>';

	$admin_attended = 'Hi Admin ,<br><br>
	<strong>An Appointment has been Marked as Attended </strong><br><br>
	Customer Name : {customer_name} <br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$cust_attended = 'Hi {customer_name},<br><br>
	<strong>Your Appointment has been Marked as Attended.</strong> <br><br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$admin_notattended = 'Hi Admin ,<br><br>
	<strong>{instructor_name} has marked Appointment as Not Attended </strong><br>
	Customer Name : {customer_name} <br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} <br>
	Charged amount : {charge}';

	$cust_notattended = 'Hi {customer_name},<br><br>
	<strong>Your Appointment has been Marked as Not Attended.</strong> <br><br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} <br>
	Charged amount : {charge}';

	$cust_please_pay_the_amount = 'Hi {customer_name},<br><br>
	<strong>A Package ( Order id #{order_id}) has been assigned you please pay amount of {charge} to admin via check.</strong> ';

	$inst_individual_Attendance = 'Hi {instructor_name},<br><br>
	<strong>Please mark attendance for the appointment .</strong> <br><br>
	Child Name : {child_name} <br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$admin_appt_time_change = 'Hi admin,<br><br>
	{customer_name} has {status} your Appointment time change suggestion <strong>
	{new_slot_time}</strong> for  appointment on {current_appt_date_time}<br/>';

    $inst_approval = 'Hi {instructor_name},<br><br>
    <strong>An appointment has been assigned to you. Please APPROVE or REJECT the assignment by logging in to our account.</strong><br><br>
	Customer Name : {customer_name} <br>
	Location : {location_name} <br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} ';

	$inst_reject = 'Hi Admin,<br><br>
	<strong>An appointment has been Rejected by {instructor_name}</strong> <br><br>
	Customer Name : {customer_name} <br>
	Location : {location_name}<br>
	Appointment Date : {appointment_date} <br>
	Appointment Time : {appointment_time} <br>';

	$recurring_payment_cust= 'Hi {customer_name},<br><br>
	<strong>You have been charged ${charge} as a part of recurring payment for the Order ID #{order_id}.</strong> <br><br>
	Your new credit expirydate is {expiry_date} <br>';

    $recurring_payment_admin = 'Hi Admin,<br><br>
	<strong>Customer {customer_name} has been pre-authorized for charging ${charge} as a part of recurring payment for the Order ID #{order_id} </strong> <br><br>
	Please manually authorize to capture payment within 7 days  <br>';

    $recurring_payment_authorized = 'Hi Admin,<br><br>
	<strong>you have manually authorized and hence the payment of ${charge} has been charged as a part of recurring payment for the Order ID #{order_id} for the Customer {customer_name} </strong> <br><br>
    <br>';

   $recurring_pause_cust= 'Hi {customer_name},<br><br>
   <strong>Admin has paused recurring payment for your Order ID #{order_id}.</strong>  <br>';

   $recurring_paus_admin = 'Hi Admin,<br><br>
   <strong>Recurring payment of Customer {customer_name} has been paused.</strong><br><br> Order ID #{order_id}   <br>';

   $recurring_resume_cust= 'Hi {customer_name},<br><br>
   <strong>Admin has resumed recurring payment for your Order ID #{order_id}.</strong>  <br><br>
   Your package will renew on :{renew_date} <br>';

   $recurring_resume_admin = 'Hi Admin,<br><br>
   <strong>Recurring payment of Customer {customer_name} has been resumed. </strong>  <br><br> Order ID #{order_id}  <br>';

   $recurring_cancel_cust= 'Hi {customer_name},<br><br>
   <strong>You have been successfully UnSubscribed the recurring payment for your Order ID #{order_id}.</strong> <br><br>
   Your package will expired on {expiry_date} <br>';

   $recurring_cancel_admin = 'Hi Admin,<br><br>
   <strong>Customer {customer_name} has been  UnSubscribed the recurring payment for the Order ID #{order_id} </strong>  <br><br>
   Package will expired on {expiry_date} <br>';

	// create siab_coaching_locations table
	if ($wpdb->get_var("show tables like " . DB_COACHING_LOCATIONS) != DB_COACHING_LOCATIONS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_COACHING_LOCATIONS . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				name varchar(190) NOT NULL,
				address LONGTEXT NOT NULL,
				phone varchar(190) NOT NULL,
				description LONGTEXT DEFAULT NULL,
				working_hours TEXT NOT NULL COMMENT 'Working Hours for each Coaching Location as Array',
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_package_sessions table
	if ($wpdb->get_var("show tables like " . DB_PACKAGE_SESSIONS) != DB_PACKAGE_SESSIONS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_PACKAGE_SESSIONS . " (
		        `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				`gf_form_id` bigint(20) UNSIGNED NOT NULL,
				`session_name` TEXT NOT NULL,
				`session_type` varchar(50) NOT NULL,
				`min_capacity` int(11) NOT NULL,
				`max_capacity` int(11) NOT NULL,
				`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (`id`)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);

		$packages = $wpdb->get_results('SELECT * FROM '.DB_PACKAGE_SESSIONS);
		if(count($packages) == 0){
			$wpdb->insert(
				DB_PACKAGE_SESSIONS,
				array(
					'gf_form_id' => GF_GROUP_FORM_ID,
					'session_name' => 'Group Instruction',
					'session_type' => 'group',
					'min_capacity' => 1,
					'max_capacity'=> 4
				)
			);

			$wpdb->insert(
				DB_PACKAGE_SESSIONS,
				array(
					'gf_form_id' => GF_INDIVIDUAL_FORM_ID,
					'session_name' => 'Individual Instruction',
					'session_type' => 'individual',
					'min_capacity' => 1,
					'max_capacity'=> 1
				)
			);

			$wpdb->insert(
				DB_PACKAGE_SESSIONS,
				array(
					'gf_form_id' => GF_TEAM_FORM_ID,
					'session_name' => 'Team Instruction',
					'session_type' => 'team',
					'min_capacity' => 1,
					'max_capacity'=> 1
				)
			);
		}
	}

	// create siab_instructors_availability table
	if ($wpdb->get_var("show tables like " . DB_INSTRUCTORS_AVAILABILITY) != DB_INSTRUCTORS_AVAILABILITY) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_INSTRUCTORS_AVAILABILITY . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				instructor_id bigint(20) UNSIGNED NOT NULL,
				location_id int(11) UNSIGNED NOT NULL,
				start_time varchar(50) NOT NULL,
				end_time varchar(50) NOT NULL,
				weekday varchar(50) NOT NULL,
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id),
				CONSTRAINT `siab_instructors_availability_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES " .DB_COACHING_LOCATIONS." (`id`) ON DELETE CASCADE
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
		// CONSTRAINT `siab_instructors_availability_ibfk_1` FOREIGN KEY (`instructor_id`) REFERENCES " .DB_USERS." (`ID`) ON DELETE CASCADE,
	}

	// create siab_instructors_off_days table
	if ($wpdb->get_var("show tables like " . DB_INSTRUCTORS_OFF_DAYS) != DB_INSTRUCTORS_OFF_DAYS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_INSTRUCTORS_OFF_DAYS . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				instructor_id bigint(20) UNSIGNED NOT NULL,
				off_day DATE NOT NULL,
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		// CONSTRAINT `siab_instructors_off_days_ibfk_1` FOREIGN KEY (`instructor_id`) REFERENCES " .DB_USERS." (`ID`) ON DELETE CASCADE
		dbDelta($sql);
	}

	// create siab_customer_purchase_credits table
	if ($wpdb->get_var("show tables like " . DB_WC_GF_CUSTOMER_PURCHASES) != DB_WC_GF_CUSTOMER_PURCHASES) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_WC_GF_CUSTOMER_PURCHASES . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				customer_id bigint(20) UNSIGNED NOT NULL,
				order_id bigint(20) UNSIGNED NOT NULL,
				gf_form_id bigint(20) UNSIGNED NOT NULL,
				gform_entry_id bigint(20) UNSIGNED NOT NULL,
				customer_purchase_amt bigint(20) UNSIGNED NULL COMMENT 'For giving discount on customer repeat purchase',
				package_hidden_name varchar(50) NOT NULL COMMENT 'Specify hidden GF keyword',
				credits int(11) NULL COMMENT '<int> : limited session, NULL : unlimited session',
				is_unlimited_type varchar(50) NULL COMMENT 'NULL : limited session, <text> : unlimited type',
				expiry DATE NULL COMMENT 'NULL : limited session, <date> : unlimited expiry',
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		// CONSTRAINT `siab_customer_purchase_credits_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES " .DB_USERS." (`ID`) ON DELETE CASCADE
		dbDelta($sql);
	}

	// create siab_customer_purchase_recurring table
	if ($wpdb->get_var("show tables like " . DB_WC_GF_CUSTOMER_PURCHASES_RECURRING) != DB_WC_GF_CUSTOMER_PURCHASES_RECURRING) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_WC_GF_CUSTOMER_PURCHASES_RECURRING . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				customer_purchase_id int(20) UNSIGNED NOT NULL,
				recurring_status int DEFAULT 0 COMMENT 'Active : 0, Pause : 1',
				next_payment_charging_amount bigint(20) UNSIGNED NOT NULL,
				prev_payment_charged_date DATE NULL,
				prev_stripe_transaction_id varchar(191) NULL,
				prev_stripe_status varchar(50) NULL,
				prev_stripe_capture_status int(11) DEFAULT NULL COMMENT 'Not Captured : 0, Captured : 1',
				stripe_error_log TEXT NULL,
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_appointments table
	if ($wpdb->get_var("show tables like " . DB_APPOINTMENTS) != DB_APPOINTMENTS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_APPOINTMENTS . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				unq_id varchar(20) NOT NULL,
				customer_id int (20) UNSIGNED NOT NULL,
				purchase_credits_id int (20) UNSIGNED NULL COMMENT 'Specify Package ID',
				location_id int(20) UNSIGNED NOT NULL,
				session_id int(11) UNSIGNED NOT NULL,
				instructor_id int(20) UNSIGNED NULL,
				assigned_instructor int(20),
				child_id_name varchar(50) NOT NULL,
				comments text DEFAULT NULL,
				team_child_details text DEFAULT NULL,
				appointment_date date NOT NULL,
				appointment_time text DEFAULT NULL,
				cust_appointment_time text NOT NULL,
				is_cancelled int DEFAULT 0,
				is_approved int DEFAULT 0,
				token varchar(191) NOT NULL,
				cancelled_by int,
				has_attended int,
				has_cancellation_charged int,
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_cancellation_charges table
	if ($wpdb->get_var("show tables like " . DB_CANCELLATION_CHARGE) != DB_CANCELLATION_CHARGE) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_CANCELLATION_CHARGE . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				appointment_id int (20) UNSIGNED NOT NULL,
				user_id int (20) UNSIGNED NOT NULL,
				stripe_charge_id varchar(50) DEFAULT NULL,
				charge_amount varchar(50) NOT NULL,
				charge_status varchar(50) NOT NULL,
				remarks TEXT,
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_emails table
	if ($wpdb->get_var("show tables like " . DB_EMAILS) != DB_EMAILS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_EMAILS . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				mailto text NOT NULL,
				title text NOT NULL,
				subject text NOT NULL,
				body longtext NOT NULL,
				notes text,
				notify_via_email int(10) DEFAULT '1',
			    notify_via_sms int(10) DEFAULT '1',
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY  (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);

		$emails = $wpdb->get_results('SELECT * FROM '.DB_EMAILS);
		if(count($emails) == 0){

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Instructor",
					'title' => 'Instructor Created',
					'subject' => 'Instructor Created | ShootinSchool',
					'body' => $inst_admin_created,
					'notes' => '["instructor_name","instructor_email","instructor_password"]'
				)
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Cancelled by admin',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $cust_admin_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Instructor",
			        'title' => 'Appointment Cancelled by admin',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $inst_admin_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Instructor",
			        'title' => 'Instructor Assigned',
			        'subject' => 'Appointment Assigned to you | ShootInSchool',
					'body' => $inst_admin_assigned,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","location_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Instructor Assigned',
			        'subject' => 'You have been Assigned | ShootinSchool',
					'body' => $cust_admin_assigned,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","location_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Booked',
			        'subject' => 'Appointment Booked | ShootinSchool',
					'body' => $cust_cust_booked,
					'notes' => '["customer_name","appointment_date","appointment_time","location_name","credits"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Admin",
			        'title' => 'Appointment Booked',
			        'subject' => 'Appointment Booked | ShootinSchool',
					'body' => $admin_cust_booked,
					'notes' => '["customer_name","appointment_date","appointment_time","location_name","credits","package"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Cancelled by customer',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $cust_cust_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Admin",
			        'title' => 'Appointment Cancelled by Customer',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
			        'body' => $admin_cust_cancelled,
			        'notes' => '["customer_name","appointment_date","appointment_time"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Instructor",
			        'title' => 'Appointment Cancelled by customer',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $inst_cust_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Cancelled by Instructor',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $cust_inst_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","appointment_id"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Admin",
			        'title' => 'Appointment Cancelled by Instructor',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $admin_inst_cancelled,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","appointment_id"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Reminder at 12PM',
			        'subject' => 'Appointment Reminder | ShootinSchool',
					'body' => $cust_reminder_cron,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Charged Cancellation',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $cust_charged_cancel,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","charge"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Admin",
			        'title' => 'Charged Cancellation',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $admin_charged_cancel,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name","charge"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Instructor",
			        'title' => 'Charged Cancellation',
			        'subject' => 'Appointment Cancelled | ShootinSchool',
					'body' => $inst_charged_cancel,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name"]'
			    )
			);

			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "Customer",
			        'title' => 'Appointment Time Change Suggestion',
			        'subject' => 'Appointment Time Change Suggestion | ShootinSchool',
					'body' => $cust_appt_time_change,
					'notes' => '["customer_name","new_slot_time","current_appt_date_time","verification_url","rejected_url"]'
			    )
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Appointment has been Marked as Attended ',
					'subject' => 'Appointment has been Marked as Attended | ShootinSchool',
					'body' => $admin_attended,
					'notes' => '["customer_name","location_name",appointment_date","appointment_time"]'
				)
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'Appointment has been Marked as Attended ',
					'subject' => 'Appointment has been Marked as Attended | ShootinSchool',
					'body' => $cust_attended,
					'notes' => '["customer_name","location_name",appointment_date","appointment_time"]'
				)
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Appointment has been Marked as Not Attended ',
					'subject' => 'Appointment has been Marked as Not Attended | ShootinSchool',
					'body' => $admin_notattended,
					'notes' => '["instructor_name","customer_name","location_name",appointment_date","appointment_time","charge"]'
				)
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'Appointment has been Marked as Not Attended ',
					'subject' => 'Appointment has been Marked as Not Attended | ShootinSchool',
					'body' => $cust_notattended,
					'notes' => '["customer_name","location_name",appointment_date","appointment_time","charge"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'Please pay the amount of Package  ',
					'subject' => 'Please pay the amount of Package | ShootinSchool',
					'body' => $cust_please_pay_the_amount,
					'notes' => '["order_id","charge"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Instructor",
					'title' => 'Mark attendance for the appointment  ',
					'subject' => 'Mark attendance for the appointment | ShootinSchool',
					'body' => $inst_individual_Attendance,
					'notes' => '["instructor_name","child_name","location_name",appointment_date","appointment_time"]'
				)
			);
			$wpdb->insert(
			    DB_EMAILS,
			    array(
			        'mailto' => "admin",
			        'title' => 'Appointment Time Change Suggestion Status',
			        'subject' => 'Appointment Time Change Suggestion Status | ShootinSchool',
					'body' => $admin_appt_time_change,
					'notes' => '["customer_name","new_slot_time","current_appt_date_time","status"]'
			    )
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Instructor",
					'title' => 'Instructor approval',
					'subject' => 'Instructor approval | ShootinSchool',
					'body' => $inst_approval,
					'notes' => '["customer_name","location_name","appointment_date","appointment_time","instructor_name","verification_cancel_url","verification_approve_url"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Instructor Reject',
					'subject' => 'Appointment rejected | ShootinSchool',
					'body' => $inst_reject,
					'notes' => '["customer_name","appointment_date","appointment_time","instructor_name"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'Recurring payment ',
					'subject' => 'Recurring payment | ShootinSchool',
					'body' => $recurring_payment_cust,
					'notes' => '["customer_name","charge",order_id","expiry_date"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Recurring payment',
					'subject' => 'Recurring payment | ShootinSchool',
					'body' => $recurring_payment_admin,
					'notes' => '["customer_name","charge","order_id"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Recurring payment authorized',
					'subject' => 'Recurring payment authorized | ShootinSchool',
					'body' => $recurring_payment_authorized,
					'notes' => '["customer_name","charge","order_id"]'
				)
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => ' Pause Recurring Payment ',
					'subject' => ' Pause Recurring Payment | ShootinSchool',
					'body' => $recurring_pause_cust,
					'notes' => '["customer_name","order_id"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => ' Pause Recurring Payment ',
					'subject' => ' Pause Recurring Payment  | ShootinSchool',
					'body' => $recurring_paus_admin,
					'notes' => '["customer_name","order_id"]'
				)
			);

			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'Resume Recurring Payment ',
					'subject' => 'Resume Recurring Payment | ShootinSchool',
					'body' => $recurring_resume_cust,
					'notes' => '["customer_name","order_id"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'Resume Recurring Payment ',
					'subject' => 'Resume Recurring Payment  | ShootinSchool',
					'body' => $recurring_resume_admin,
					'notes' => '["customer_name","order_id"]'
				)
			);


			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Customer",
					'title' => 'UnSubscribed Recurring Payment  ',
					'subject' => 'UnSubscribed Recurring Payment  | ShootinSchool',
					'body' => $recurring_cancel_cust,
					'notes' => '["customer_name","expiry_date","order_id"]'
				)
			);
			$wpdb->insert(
				DB_EMAILS,
				array(
					'mailto' => "Admin",
					'title' => 'UnSubscribed Recurring Payment  ',
					'subject' => 'UnSubscribed Recurring Payment   | ShootinSchool',
					'body' => $recurring_cancel_admin,
					'notes' => '["customer_name","expiry_date","order_id"]'
				)
			);
		}
	}

	// create siab_appointment_modify table
	if ($wpdb->get_var("show tables like " . DB_APPOINTMENT_MODIFY) != DB_APPOINTMENT_MODIFY) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_APPOINTMENT_MODIFY . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				appointment_id int(20) UNSIGNED NOT NULL,
				suggested_slot varchar(50) NOT NULL,
				token varchar(191) NOT NULL,
				status int(11) DEFAULT '0' COMMENT 'Pending : 0, Approved : 1,Rejected : 2',
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_child_details table
	if ($wpdb->get_var("show tables like " . DB_CHILD_DETAILS) != DB_CHILD_DETAILS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_CHILD_DETAILS . " (
				id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				user_id bigint(20) UNSIGNED NOT NULL,
				first_name varchar(100) NOT NULL,
				last_name varchar(100) NOT NULL,
				grade varchar(50),
				jersey_size varchar(50),
				child_type varchar(50),
				created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (id)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);
	}

	// create siab_package_sessions table
	if ($wpdb->get_var("show tables like " . DB_GRADE_SESSIONS) != DB_GRADE_SESSIONS) {
		$sql = "
			CREATE TABLE IF NOT EXISTS " . DB_GRADE_SESSIONS . " (
		        `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
				`grade` TEXT NOT NULL,
				`group` TEXT NOT NULL,
				`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
				PRIMARY KEY (`id`)
			)" . DB_CHARSET_COLLATE . ";
		";
		dbDelta($sql);

		$packages = $wpdb->get_results('SELECT * FROM '.DB_GRADE_SESSIONS);
		if(count($packages) == 0){
			$wpdb->insert(
				DB_GRADE_SESSIONS,
				array(
					'grade' => '1',
					'group' => '1-3'
				)
			);

			$wpdb->insert(
				DB_GRADE_SESSIONS,
				array(
					'grade' => '1',
					'group' => '1-3'
				)
			);

			$wpdb->insert(
				DB_GRADE_SESSIONS,
				array(
					'grade' => '1',
					'group' => '1-3'
				)
			);
		}
	}
}

// function to drop the DB tables and clean-up
function siab_table_uninstall()
{
	global $wpdb;
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_CHILD_DETAILS . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_APPOINTMENT_MODIFY . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_EMAILS . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_CANCELLATION_CHARGE . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_APPOINTMENTS . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_WC_GF_CUSTOMER_PURCHASES_RECURRING . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_WC_GF_CUSTOMER_PURCHASES . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_INSTRUCTORS_OFF_DAYS . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_INSTRUCTORS_AVAILABILITY . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_PACKAGE_SESSIONS . ";");
	// $wpdb->query("DROP TABLE IF EXISTS " . DB_COACHING_LOCATIONS . ";");
}