<?php if( !ow_global_var( 'website_live_request' ) ) : ?>
<?php
//if the form is posted, has all the mandatory fields and captcha matches
if (!empty($_POST['ow-admin-submit'])) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
	
//FORM INPUTS	
	$recipient = OW_ADMIN_EMAIL;
	$fromEmail = ow_global_var( 'form_email' );
	$security = $_POST['ow-admin-security'];

//EMAIL SUBJECT	
	$mailSubject = 'MAKE LIVE request: ';
	$mailSubject .= html_entity_decode( ow_global_var( 'accountant_name' ) );
	
//EMAIL BODY	
	$mailBody = '<html><body>';
	$mailBody .= "This make live request was raised via: " . get_site_url() . "<br /><br />";
	$mailBody .= "Please call the customer " . ow_global_var('accountant_human_name') . " on " . ow_global_var('accountant_phone') . " to arrange for their website to be made live.";

//EMAIL FOOTER	
	$footer = get_email_footer();
	$mailBody .= $footer;
	$mailBody .= '</body></html>';

//EMAIL HEADERS
	$headers = get_email_headers();
	
//SECURITY CHECK	
	if ( $security != '' && $_SESSION['ow-admin-token'] != $_POST['ow-admin-token'] ) {
		//If the security check fails, don't send the email	
	} else {
		wp_mail( $recipient, $mailSubject, $mailBody, $headers );
		
		ow_new_global_var( 'website_live_request', 1 );
	}
	unset( $_POST );
	echo "<p><strong>Thank you for contacting ".PRODUCT_NAME."</strong></p><p>We will be in contact shortly to start your 'website live' process.</p><p>If you have any issues or questions, please see our knowledge base or get in touch on ".OW_SUPPORT_PHONE."</p>";
			
}} else {
//if the form has not been posted	
?>
<form id="form-ow-admin" class="form" method="post" action="<?php menu_page_url('iris-admin-panel'); ?>" role="form">
    <input type="text" name="ow-admin-security" class="security" value=""/>
    <input type="hidden" name="ow-admin-token" value="<?php session_token('ow-admin'); ?>"/>
    <input type="submit" name="ow-admin-submit" value="Make Your Website Live" class="button button-primary button-hero"/>
</form>
<?php } ?>


<?php endif; ?>