<div id="custom-notices"></div>
<div class="wrap" id="iris-openwebsite-admin">
	<h1><?php echo PRODUCT_NAME; ?> Options</h1>
	<div id="dashboard-widgets-wrap">
		<div id="dashboard-widgets" class="metabox-holder">

<?php
global $wpdb; //global calls the wordpress database
			
if ( ! empty( $_FILES['json_upload'] ) && $_FILES['json_upload']['type'] === 'application/json' ) {
	
	$json_import = json_decode( file_get_contents( $_FILES['json_upload']['tmp_name'] ), true );

	$defaults = [
		'accountant_id' => CLIENT_USERNAME,
		'in_production' => 'false',
		'opt_newsletter' => 'true',
		'opt_twitter' => 'true',
		'opt_card' => 'true',
	];
	
	$_POST = array_merge( $defaults, $json_import );
	
	$_POST['admin-submit'] = true;
}
else if ( ! empty( $_FILES['json_upload'] ) && $_FILES['json_upload']['type'] !== 'application/json' ) {
	echo '<div class="notice notice-error is-dismissible custom-notice"><p><strong>There was a problem importing the client options.</strong></p></div>';
}
			
			
//if the form is posted, has all the mandatory fields and captcha matches
if ( ! empty( $_POST['admin-submit'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
?>
<?php
	
	$filters = [
		'IRISgoogleA' 			 => FILTER_SANITIZE_STRING,
        'IRISgoogleGA4' 	     => FILTER_SANITIZE_STRING,
		'accountant_address' 	 => FILTER_SANITIZE_STRING,
		'accountant_email' 		 => FILTER_SANITIZE_EMAIL,
		'accountant_fax' 		 => FILTER_SANITIZE_STRING,
		'accountant_full_name' 	 => FILTER_SANITIZE_STRING,
		'accountant_human_name'  => FILTER_SANITIZE_STRING,
		'accountant_main_area' 	 => FILTER_SANITIZE_STRING,
		'accountant_memberships' => FILTER_SANITIZE_STRING,
		'accountant_name' 		 => FILTER_SANITIZE_STRING,
		'accountant_phone2' 	 => FILTER_SANITIZE_STRING,
		'accountant_phone' 		 => FILTER_SANITIZE_STRING,
		'accountant_vat' 		 => FILTER_SANITIZE_STRING,
		'accountant_website' 	 => FILTER_SANITIZE_URL,
		'company_reg' 			 => FILTER_SANITIZE_STRING,
		'company_reg_country'	 => FILTER_SANITIZE_STRING,
		'facebook'				 => FILTER_SANITIZE_URL,
		'form_email'			 => FILTER_SANITIZE_EMAIL,
		'googleA'				 => FILTER_SANITIZE_STRING,
        'googleGA4'				 => FILTER_SANITIZE_STRING,
		'googleplus'			 => FILTER_SANITIZE_URL,
		'gpsLocation'			 => FILTER_SANITIZE_STRING,
		'in_production'			 => FILTER_SANITIZE_NUMBER_INT,
		'iris_mtd'				 => FILTER_SANITIZE_NUMBER_INT,
		'kashflow'				 => FILTER_SANITIZE_STRING,
		'linkedin'				 => FILTER_SANITIZE_URL,
		'mailchimp_action'		 => FILTER_SANITIZE_URL,
		'mailchimp_id'			 => FILTER_DEFAULT,
		'mailchimp_u'			 => FILTER_DEFAULT,
		'mailchimp_username'	 => FILTER_DEFAULT,
		'map_api_key'			 => FILTER_DEFAULT,
		'openspace'				 => FILTER_SANITIZE_STRING,
		'paypal_merchant_id'	 => FILTER_DEFAULT,
		'twitter' 				 => FILTER_SANITIZE_URL,
		'instagram' 			 => FILTER_SANITIZE_URL,
		'website_package'		 => FILTER_SANITIZE_STRING,
		'opt_newsletter'		 => FILTER_SANITIZE_NUMBER_INT,
		'newsletter_theme'		 => FILTER_SANITIZE_STRING,
		'theme_font'			 =>	FILTER_SANITIZE_STRING,
		'opt_twitter'			 => FILTER_SANITIZE_NUMBER_INT,
		'opt_card'		 		 => FILTER_SANITIZE_NUMBER_INT,
		'hosted_in'			     => FILTER_SANITIZE_STRING,
	];

	$_POST = ow_sanitize_options_post_array( $_POST, $filters );

if ( ! current_user_can( 'administrator' ) ) {
	$_POST['in_production'] = ow_global_var( 'in_production' );
	$_POST['website_live_request'] = ow_global_var( 'website_live_request' );
	$_POST['website_package'] = ow_global_var( 'website_package' );
	$_POST['IRISgoogleA'] = ow_global_var( 'IRISgoogleA' );
    $_POST['IRISgoogleGA4'] = ow_global_var( 'IRISgoogleGA4' );
	$_POST['map_api_key'] = ow_global_var( 'map_api_key' );
	$_POST['iris_mtd'] = ow_global_var( 'iris_mtd' );
	$_POST['openspace'] = ow_global_var( 'openspace' );
	$_POST['kashflow'] = ow_global_var( 'kashflow' );
	$_POST['paypal_merchant_id'] = ow_global_var( 'paypal_merchant_id' );
	$_POST['accountant_human_name'] = ow_global_var( 'accountant_human_name' );
	$_POST['accountant_website'] = ow_global_var( 'accountant_website' );
	$_POST['mailchimp_action'] = ow_global_var( 'mailchimp_action' );
	$_POST['mailchimp_u'] = ow_global_var( 'mailchimp_u' );
	$_POST['mailchimp_id'] = ow_global_var( 'mailchimp_id' );
	$_POST['mailchimp_username'] = ow_global_var( 'mailchimp_username' );
	$_POST['opt_newsletter'] = ow_global_var( 'opt_newsletter' );
	$_POST['newsletter_theme'] = ow_global_var( 'newsletter_theme' );
	$_POST['theme_font'] = ow_global_var( 'theme_font' );
	$_POST['opt_twitter'] = ow_global_var( 'opt_twitter' );
	$_POST['opt_card'] = ow_global_var( 'opt_card' );
}
if ( ! $_POST['form_email'] ) {
	$_POST['form_email'] = $_POST['accountant_email'];
}

if ( CLIENT_USERNAME ) {
	$result = $wpdb->query( ow_create_options_sql_query( $_POST ) );
	if ( $result === false ) { // If this returns false, there is incorrect code. Check all the database column names are correct. 
		echo '<div class="notice notice-error custom-notice"><p><strong>There was an error updating the database. Please contact the administrator.</strong></p></div>';
	} else if ( $result == 0 ) { // This isn't an error
		echo '<div class="notice notice-warning is-dismissible custom-notice"><p><strong>The database hasn\'t been updated as the values haven\'t changed. Please make sure you enter the correct details.</strong></p></div>';		
	} else { // Success message
		update_newsletter_status( $_POST['website_package'] );
		update_opt_newsletter_status();
		draft_card_status();
		update_client_area_status( $_POST['website_package'] );
		update_tax_tips_status( $_POST['website_package'] );
		echo '<div class="notice notice-success is-dismissible custom-notice"><p><strong>The database has been successfully updated.</strong></p></div>';
	}
} else {
	echo '<div class="notice notice-error custom-notice"><p><strong>Unable to update the database - You haven\'t specified a username.</strong></p></div>';
}
unset( $_POST );
query_db();	
?>
	
<?php } }
//if the form has not been posted	
?>

<?php $access = ( ! current_user_can( 'administrator' ) ) ? 'disabled' : ''; ?>

<?php if ( current_user_can( 'administrator' ) ) : ?>
<form method="post" action="<?php echo get_permalink(); ?>" enctype="multipart/form-data">
	<div id="postbox-container-import">
		<div id="main-sortables" class="meta-box-sortables">
			<div id="data-import" class="postbox">
				<h2 class="hndle"><span class="dashicons dashicons-upload"></span> Data Import</h2>
				<div class="inside">
					<label class="json-importer">
						<input type="file" name="json_upload" accept="application/json" required class="json-importer__input" onchange="jQuery(this).closest('form').submit()"/>
						<span class="before-upload">Export a file from the design form and upload it here.</span>
						<span class="after-upload">Please wait...</span>
					</label>
				</div>
			</div>
		</div>
	</div>
</form>
<?php endif; ?>			
			
<form id="form-admin" method="post" action="<?php echo get_permalink(); ?>">
	<div id="postbox-container-1" class="postbox-container">
	<div id="main-sortables" class="meta-box-sortables">
		<div id="website-package" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-dashboard"></span> Website Package</h2>
			<div class="inside">
				<p>
					<label>Is website live?</label>
					<span class="help-toggle">i</span>
					<span class="help-content">When you want to make your website live, please get in touch.</span>
					<select <?php echo $access; ?> name="in_production">
						<option value="1" <?php echo ( ow_global_var( 'in_production' ) == 1 ) ? 'selected' : ''; ?>>True</option>
						<option value="0" <?php echo ( ow_global_var( 'in_production' ) == 0 ) ? 'selected' : ''; ?>>False</option>
					</select>
				</p>
				<p>
					<label>Website package:</label>
					<span class="help-toggle">i</span>
					<span class="help-content">This is the website package that you purchased. For upgrades, please get in touch.</span>
					<select <?php echo $access; ?> name="website_package" id="website-package-select">
						<option value="<?php echo PACKAGE_1; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_1 ) ? 'selected' : ''; ?>><?php echo PACKAGE_1; ?></option>
						<option value="<?php echo PACKAGE_2; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_2 ) ? 'selected' : ''; ?>><?php echo PACKAGE_2; ?></option>
						<option value="<?php echo PACKAGE_3; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_3 ) ? 'selected' : ''; ?>><?php echo PACKAGE_3; ?></option>
						<option value="<?php echo PACKAGE_4; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_4 ) ? 'selected' : ''; ?>><?php echo PACKAGE_4; ?></option>
						<option value="<?php echo PACKAGE_5; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_5 ) ? 'selected' : ''; ?>><?php echo PACKAGE_5; ?></option>
						<option value="<?php echo PACKAGE_6; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_6 ) ? 'selected' : ''; ?>><?php echo PACKAGE_6; ?></option>
						<option value="<?php echo PACKAGE_7; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_7 ) ? 'selected' : ''; ?>><?php echo PACKAGE_7; ?></option>
						<option value="<?php echo PACKAGE_8; ?>" <?php echo ( ow_global_var( 'website_package' ) == PACKAGE_8 ) ? 'selected' : ''; ?>><?php echo PACKAGE_8; ?></option>
					</select>
				</p>
				<div id="opt-newsletter">
					<p>
						<label>Client opted for Newsletter?</label>
						<span class="help-toggle">i</span>
						<span class="help-content">Check if client have purchased this add-on feature or as a Email marketer package in web ticket.</span>
						<select <?php echo $access; ?> name="opt_newsletter" id="opt_newsletter">
							<option value="1" <?php echo ( ow_global_var( 'opt_newsletter' ) == 1 ) ? 'selected' : ''; ?> >Yes</option>
							<option value="0" <?php echo ( ow_global_var( 'opt_newsletter' ) == 0 ) ? 'selected' : ''; ?>>No</option>
						</select>
					</p>
					<p>

						<label>Selected Newsletter Theme by Client</label>

						<span class="help-toggle">i</span>

						<span class="help-content">Check which theme client has opted.</span>

						<select <?php echo $access; ?> name="newsletter_theme" id="newsletter_theme">

							<option value="theme1" <?php echo ( ow_global_var( 'newsletter_theme' ) == 'theme1' ) ? 'selected' : ''; ?> >Default</option>

							<option value="theme2" <?php echo ( ow_global_var( 'newsletter_theme' ) == 'theme2' ) ? 'selected' : ''; ?>>Design with images</option>
							
							<option value="theme3" <?php echo ( ow_global_var( 'newsletter_theme' ) == 'theme3' ) ? 'selected' : ''; ?>>Design without images</option>

						</select>

					</p>
					
					<p>

						<label>Selected Font by Client</label>

						<span class="help-toggle">i</span>

						<span class="help-content">Check which font client has opted.</span>

						<select <?php echo $access; ?> name="theme_font" id="theme_font">

							<option value="Open Sans" <?php echo ( ow_global_var( 'theme_font' ) == 'Open Sans' ) ? 'selected' : ''; ?> >Open Sans</option>

							<option value="Quicksand" <?php echo ( ow_global_var( 'theme_font' ) == 'Quicksand' ) ? 'selected' : ''; ?>>Quicksand</option>
							
							<option value="Dosis" <?php echo ( ow_global_var( 'theme_font' ) == 'Dosis' ) ? 'selected' : ''; ?>>Dosis</option>
							
							<option value="Open Sans" <?php echo ( ow_global_var( 'theme_font' ) == 'Open Sans' ) ? 'selected' : ''; ?>>Open Sans</option>
							
							<option value="Lato" <?php echo ( ow_global_var( 'theme_font' ) == 'Lato' ) ? 'selected' : ''; ?>>Lato</option>
							
							<option value="Didact Gothic" <?php echo ( ow_global_var( 'theme_font' ) == 'Didact Gothic' ) ? 'selected' : ''; ?>>Didact Gothic</option>
							
							<option value="gothic" <?php echo ( ow_global_var( 'theme_font' ) == 'gothic' ) ? 'selected' : ''; ?>>gothic</option>

						</select>

					</p>
						<p>
						<label>Client opted for Twitter?</label>
						<span class="help-toggle">i</span>
						<span class="help-content">Check if client have opted Twitter Feed.</span>
						<select <?php echo $access; ?> name="opt_twitter" id="opt_twitter">
							<option value="1" <?php echo ( ow_global_var( 'opt_twitter' ) == 1 ) ? 'selected' : ''; ?> >Yes</option>
							<option value="0" <?php echo ( ow_global_var( 'opt_twitter' ) == 0 ) ? 'selected' : ''; ?>>No</option>
						</select>
					</p>
					<p>
						<label>Client opted for Seasonal Card?</label>
						<span class="help-toggle">i</span>
						<span class="help-content">Check if client have purchased this add-on feature in web ticket.</span>
						<select <?php echo $access; ?> name="opt_card" id="opt_card">
							<option value="1" <?php echo ( ow_global_var( 'opt_card' ) == 1 ) ? 'selected' : ''; ?> >Yes</option>
							<option value="0" <?php echo ( ow_global_var( 'opt_card' ) == 0 ) ? 'selected' : ''; ?>>No</option>
						</select>
					</p>
				</div>
				<p>
					<label>Has Monthly Newsletter:</label>
					<span class="help-toggle">i</span>
					<span class="help-content">Not all of our website packages come with our Tax Tips &amp; News monthly newsletter included.</span>
					<input type="text" disabled value="<?php echo ( has_newsletter() ) ? 'True' : 'False'; ?>">
				</p>
			</div>
		</div>
		<div id="website-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-admin-site"></span> Website Details</h2>
			<div class="inside">
        		<p>
					<label class="url">Domain Name: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">If you need to change your domain name, please get in touch.</span>
					<input type="text" <?php echo $access; ?> name="accountant_website" value="<?php echo ow_global_var( 'accountant_website' ); ?>"/>
        		</p>
				<?php if ( current_user_can( 'administrator' ) ) : ?>
					<p>
						<label>Website Hosted In:</label>
						<span class="help-toggle">i</span>
						<span class="help-content">Select the server where the website is hosted.</span>
						<select <?php echo $access; ?> name="hosted_in">
							<option value="">Select the hosted server</option>
							<option value="185.41.10.150" <?php echo ( ow_global_var( 'hosted_in' ) == SERVER_1) ? 'selected' : ''; ?>>Server 1</option>
							<option value="62.182.18.252" <?php echo ( ow_global_var( 'hosted_in' ) == SERVER_2 ) ? 'selected' : ''; ?>>Server 2</option>
						</select>
					</p>
				<?php endif; ?>
        		<p>
					<label>Google Analytics Code: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">Google Analytics enables you to track your website usage. For more information about Google Analytics, please see our knowledge base.</span>
                    <input type="text" name="googleA" value="<?php echo ow_global_var( 'googleA' ); ?>"/>
                    <label>Google Analytics GA4 Code: </label>
					<input type="text" name="googleGA4" value="<?php echo ow_global_var( 'googleGA4' ); ?>"/>
        		</p>
				<?php if ( current_user_can( 'administrator' ) ) : ?>
					<p><label>IRIS Google Analytics Code: </label><input type="text" name="IRISgoogleA" value="<?php echo ow_global_var( 'IRISgoogleA' ); ?>"/></p>
                <p><label>IRIS Google Analytics GA4 Code: </label><input type="text" name="IRISgoogleGA4" value="<?php echo ow_global_var( 'IRISgoogleGA4' ); ?>"/></p>
				<?php endif; ?>
			</div>
		</div>
		<?php if ( current_user_can( 'administrator' ) ) : ?>
			<div id="mailchimp-details" class="postbox">
				<h2 class="hndle"><span class="dashicons dashicons-email"></span> MailChimp Details</h2>
				<div class="inside">
					<p>
						<label class="url">MailChimp URL:</label>
						<input type="text" <?php echo $access; ?> name="mailchimp_action" value="<?php echo ow_global_var( 'mailchimp_action' ); ?>"/>
					</p>
					<p>
						<label class="url">MailChimp User ID (u):</label>
						<input type="text" <?php echo $access; ?> name="mailchimp_u" value="<?php echo ow_global_var( 'mailchimp_u' ); ?>"/>
					</p>

					<p>
						<label class="url">MailChimp Form ID (id):</label>
						<input type="text" <?php echo $access; ?> name="mailchimp_id" value="<?php echo ow_global_var( 'mailchimp_id' ); ?>"/>
					</p>
					<p>
						<label class="url">MailChimp Username:</label>
						<input type="text" <?php echo $access; ?> name="mailchimp_username" value="<?php echo ow_global_var( 'mailchimp_username' ); ?>"/>
					</p>
				</div>
			</div>
   		<?php endif; ?>
    </div>
	</div>
	<div id="postbox-container-2" class="postbox-container">
	<div id="side-sortables" class="meta-box-sortables">
		<div id="contact-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-location"></span> Contact Details</h2>
			<div class="inside">
				<p>
					<label>Contact Name: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The name of the contact with <?php echo PRODUCT_NAME; ?>. This name is not published on your website.</span>				
					<input type="text" <?php echo $access; ?> name="accountant_human_name" value="<?php echo ow_global_var( 'accountant_human_name' ); ?>"/>
				</p>
				<p>
					<label>Address: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">Your main address. To add multiple address to your site, please get in touch with <?php echo PRODUCT_NAME; ?> Support.</span>
					<textarea name="accountant_address"><?php echo ow_global_var( 'accountant_address' ); ?></textarea>
				</p>
				<p>
					<label>Main Area: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The main geographical area you operate. This is used for search engine optimisation.</span>
					<input type="text" name="accountant_main_area" value="<?php echo ow_global_var( 'accountant_main_area' ); ?>"/>
				</p>
				<p>
					<label>Published Email: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The email address that will appear on your website.</span>
					<input type="email" name="accountant_email" value="<?php echo ow_global_var( 'accountant_email' ); ?>"/>
				</p>
				<p>
				<label>Form Email: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The email address that your website contact forms will send to. This can be different from the published email address.</span>
					<input type="email" name="form_email" value="<?php echo ow_global_var( 'form_email' ); ?>"/>
				</p>
				<p>
					<label>Main Tel: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The published telephone number.</span>
					<input type="tel" name="accountant_phone" value="<?php echo ow_global_var( 'accountant_phone' ); ?>"/>
				</p>
				<p>
					<label>Alt Tel: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">An alternative published phone number if applicable.</span>
					<input type="tel" name="accountant_phone2" value="<?php echo ow_global_var( 'accountant_phone2' ); ?>"/>
				</p>
				<p>
					<label>Fax No: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The published fax number if applicable.</span>
					<input type="tel" name="accountant_fax" value="<?php echo ow_global_var( 'accountant_fax' ); ?>"/>
				</p>
			</div>
		</div>
    </div>
	</div>
	<div id="postbox-container-3" class="postbox-container">
		<div id="column3-sortables" class="meta-box-sortables">
		<div id="company-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-building"></span> Company Details</h2>
			<div class="inside">
				<?php if ( current_user_can( 'administrator' ) ) : ?>
					<p><label>Client Username: </label><input type="text" disabled value="<?php echo CLIENT_USERNAME; ?>"/></p>
				<?php endif; ?>
				<p>
					<label>Practice Name: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The name you use for your company e.g. Andrew &amp; Brown.</span>
					<input type="text" name="accountant_name" value="<?php echo ow_global_var( 'accountant_name' ); ?>"/>
				</p>
				<p>
					<label>Practice Full Name: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full name you use for your company e.g. Andrews &amp; Brown Chartered Accountants. This can be the same as your Practice Name.</span>
					<input type="text" name="accountant_full_name" value="<?php echo ow_global_var( 'accountant_full_name' ); ?>"/>
				</p>
				<p>
					<label>Company Reg Number: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">Your company registration number if applicable.</span>				
					<input type="text" name="company_reg" value="<?php echo ow_global_var( 'company_reg' ); ?>"/>
				</p>
				<p>
					<label>Company Registered in: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The country/countries your company is registered if applicable.</span>	
					<input type="text" list="company-reg-country" name="company_reg_country" value="<?php echo ow_global_var( 'company_reg_country' ); ?>"/>	
					<datalist id="company-reg-country">
						<option value="England">
						<option value="England & Wales">
						<option value="Ireland">
						<option value="Northern Ireland">
						<option value="Scotland">
						<option value="United Kingdom">
					</datalist>
				</p>
				<p>
					<label>Company VAT Number: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">Your company VAT number if applicable.</span>				
					<input type="text" name="accountant_vat" value="<?php echo ow_global_var( 'accountant_vat' ); ?>"/>
				</p>
				<p>
					<label>Accountant Memberships: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">If you have any memberships such as ICAEW, ACCA, please enter them here. Put each membership onto a new line.</span>
					<textarea name="accountant_memberships"><?php echo ow_global_var( 'accountant_memberships' ); ?></textarea>
   				</p>
    		</div>
    	</div>
		<?php if ( current_user_can( 'administrator' ) ) : ?>
			<div id="iris-products" class="postbox">
				<h2 class="hndle"><span class="dashicons dashicons-iris"></span> IRIS Making Tax Digital</h2>
				<div class="inside">
					<p><label>Has customer purchased this add-on? </label>
					<select <?php echo $access; ?> name="iris_mtd" id="mtd-ctrl">
						<option value="1" <?php echo ( ow_global_var( 'iris_mtd' ) == 1 || ! is_package_1() ) ? 'selected' : ''; ?>>True</option>
						<option value="0" <?php echo ( ow_global_var( 'iris_mtd' ) == 0 && is_package_1() ) ? 'selected' : ''; ?>>False</option>
					</select>
					</p>
					<div id="mtd-inputs">
						<p><label>OpenSpace Subdomain: </label><input type="text" <?php echo $access; ?> name="openspace" value="<?php echo ow_global_var( 'openspace' ); ?>"/></p>
						<p><label>KashFlow Unique ID: </label><input type="text" <?php echo $access; ?> name="kashflow" value="<?php echo ow_global_var( 'kashflow' ); ?>"/></p>
						<p><label>PayPal Merchant ID: </label><input type="text" <?php echo $access; ?> name="paypal_merchant_id" value="<?php echo ow_global_var( 'paypal_merchant_id' ); ?>"/></p>
					</div>
				</div>
			</div>
		 <?php endif; ?>
    </div>
	</div>
	<div id="postbox-container-4" class="postbox-container">
		<div id="column4-sortables" class="meta-box-sortables">

        <div id="social-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-share"></span> Social Media Details</h2>
			<div class="inside">
				<p>
					<label class="url">Facebook URL: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full URL of your Facebook page. Leave blank if you don't have a Facebook page.</span>
					<input type="text" name="facebook" value="<?php echo ow_global_var( 'facebook' ); ?>"/>
				</p>
				<p>
					<label class="url">Google+ URL: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full URL of your Google+ page. Leave blank if you don't have a Google+ page.</span>
					<input type="text" name="googleplus" value="<?php echo ow_global_var( 'googleplus' ); ?>"/>
				</p>
				<p>
					<label class="url">LinkedIn URL: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full URL of your LinkedIn page. Leave blank if you don't have a LinkedIn page.</span>
					<input type="text" name="linkedin" value="<?php echo ow_global_var( 'linkedin' ); ?>"/>
				</p>
				<p>
					<label class="url">Twitter URL: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full URL of your Twitter page. Leave blank if you don't have a Twitter page.</span>
					<input type="text" name="twitter" value="<?php echo ow_global_var( 'twitter' ); ?>"/>
				</p>
				<p>
					<label class="url">Instagram URL: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The full URL of your Instagram page. Leave blank if you don't have a Instagram page.</span>
					<input type="text" name="instagram" value="<?php echo ow_global_var( 'instagram' ); ?>"/>
				</p>
			</div>
		</div>
        <div id="social-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-location-alt"></span> Map Details</h2>
			<div class="inside">
				<?php if ( current_user_can( 'administrator' ) ) : ?>
					<p><label>Google Map API Key: </label><input type="text" <?php echo $access; ?> name="map_api_key" value="<?php echo ow_global_var( 'map_api_key' ); ?>"/></p>
				<?php endif; ?>
				<p>
					<label>Google Map Latitude &amp; Longitude: </label>
					<span class="help-toggle">i</span>
					<span class="help-content">The latitude and longitude co-ordinates of your practice e.g. 51.4869709, -0.5722636. To find out your latitude &amp; longitude, please see our knowledge base.</span>
					<input type="text" name="gpsLocation" value="<?php echo ow_global_var( 'gpsLocation' ); ?>"/>
				</p>
			</div>
		</div>
        <div id="update-details" class="postbox">
			<h2 class="hndle"><span class="dashicons dashicons-upload"></span> Update Options</h2>
			<div class="inside">
				<p class="alert"><strong>Changing the above options will take effect immediately. Please ensure all options are correctly filled out before clicking update.</strong></p>
				<p><input type="checkbox" id="confirm-update" required/><label for="confirm-update">Are you sure you want to update your options</label></p>
				<p><input type="submit" name="admin-submit" value="Update Options" class="button button-primary"/></p>
			</div>
		</div>
    </div>
	</div>
</form>

</div>
</div>
</div>
