<?php  

// load record from 'terms_and_conditions'
  list($terms_and_conditionsRecords, $terms_and_conditionsMetaData) = getRecords(array(
    'tableName'   => 'terms_and_conditions',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $terms_and_conditionsRecord = @$terms_and_conditionsRecords[0]; // get first record
  if (!$terms_and_conditionsRecord) { dieWith404("Record not found!"); } // show error message if no record found
  ?>


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<?php echo $page['short_description'] ?>">
<title><?php echo htmlspecialchars($page['name']) ?>. <?php echo htmlspecialchars($website_config['website_name']) ?></title>
<link rel="stylesheet" type="text/css" href="/common/css/wdd.min.css" />
<link rel="stylesheet" type="text/css" href="/common/css/<?php echo $website_style['colour'] ?>.css" />

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/common/js/ie10-viewport-bug-workaround.js"></script>

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<?php include_once('common/inc/analyticstracking.php') ?>
<?php  if ($website_style['nav_style']) {
$nav_stylesRecord = mysql_get('nav_styles', $website_style['nav_style']);
if ($nav_stylesRecord['path']) { include($nav_stylesRecord['path']); }
}
?>

<div class="container">
<?php include('common/inc/page-header.php') ?>

<div class="row">

<div class="col-sm-6 col-lg-5 marginBottom">

<?php if (@$_REQUEST['submit']) {
$errorsAndAlerts = "";
$successAlerts = "";

// error checking
if (!@$_REQUEST['title']) { $errorsAndAlerts .= "Please enter your name<br/>\n"; }
if (!@$_REQUEST['address']) { $errorsAndAlerts .= "Please enter your address<br/>\n"; }
if (!@$_REQUEST['city']) { $errorsAndAlerts .= "Please enter your city<br/>\n"; }
if (!@$_REQUEST['postcode']) { $errorsAndAlerts .= "Please enter your postcode<br/>\n"; }
if (!@$_REQUEST['email']) { $errorsAndAlerts .= "Please enter your email address<br/>\n"; }
if (!@$_REQUEST['telephone']) { $errorsAndAlerts .= "Please enter your telephone number<br/>\n"; }

if (!@$_REQUEST['petname']) { $errorsAndAlerts .= "Please enter your pet's name<br/>\n"; }
if (!@$_REQUEST['breed']) { $errorsAndAlerts .= "Please enter the breed of your dog<br/>\n"; }
if (!@$_REQUEST['size']) { $errorsAndAlerts .= "Please enter the size of your dog<br/>\n"; }
if (!@$_REQUEST['vetaddress']) { $errorsAndAlerts .= "Please enter your vet's name and address<br/>\n"; }

if (!@$_REQUEST['accessinfo']) { $errorsAndAlerts .= "Please give us some details on how to gain access to your dog<br/>\n"; }

if (!@$_REQUEST['termsandconditions']) { $errorsAndAlerts .= "Please accept the terms and conditions<br/>\n"; }
if (!@$_REQUEST['collar']) { $errorsAndAlerts .= "Please confirm that you will supply a collar or harness <br/>\n"; }
if (!@$_REQUEST['collar']) { $errorsAndAlerts .= "Please confirm that you allow Mad Dogs & Englishmen to exercise your dog off-leash<br/>\n"; }

// turn off strict mysql error checking for: STRICT_ALL_TABLES
mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
// add record
if (!@$errorsAndAlerts) {
mysql_query("INSERT INTO `{$TABLE_PREFIX}registration_forms` SET
title 			= '".mysql_real_escape_string( $_REQUEST['title'] )."',
address			= '".mysql_real_escape_string( $_REQUEST['address'] )."',
city		= '".mysql_real_escape_string( $_REQUEST['city'] )."',
postcode		= '".mysql_real_escape_string( $_REQUEST['postcode'] )."',
email			= '".mysql_real_escape_string( $_REQUEST['email'] )."',
telephone			= '".mysql_real_escape_string( $_REQUEST['telephone'] )."',

petname 			= '".mysql_real_escape_string( $_REQUEST['petname'] )."',
breed			= '".mysql_real_escape_string( $_REQUEST['breed'] )."',
size			= '".mysql_real_escape_string( $_REQUEST['size'] )."',
vetaddress		= '".mysql_real_escape_string( $_REQUEST['vetaddress'] )."',

Monday = '".(@$_REQUEST['Monday'] ? '1' : '0')."',
Tuesday = '".(@$_REQUEST['Tuesday'] ? '1' : '0')."',
Wednesday = '".(@$_REQUEST['Wednesday'] ? '1' : '0')."',
Thursday = '".(@$_REQUEST['Thursday'] ? '1' : '0')."',
Friday = '".(@$_REQUEST['Friday'] ? '1' : '0')."',

type			= '".mysql_real_escape_string( $_REQUEST['type'] )."',
date			= '".mysql_real_escape_string( $_REQUEST['date'] )."',
accessinfo			= '".mysql_real_escape_string( $_REQUEST['accessinfo'] )."',
otherinfo			= '".mysql_real_escape_string( $_REQUEST['otherinfo'] )."',

termsandconditions = '".(@$_REQUEST['termsandconditions'] ? '1' : '0')."',
collar = '".(@$_REQUEST['collar'] ? '1' : '0')."',
offleash = '".(@$_REQUEST['offleash'] ? '1' : '0')."',
earlywalk = '".(@$_REQUEST['earlywalk'] ? '1' : '0')."',

createdDate      = NOW(),
updatedDate      = NOW(),
createdByUserNum = '0',
updatedByUserNum = '0'")
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$recordNum = mysql_insert_id();

// send email alert
$mon = @$_REQUEST['Monday'] ? "Yes" : "No";
$tue = @$_REQUEST['Tuesday'] ? "Yes" : "No";
$wed = @$_REQUEST['Wednesday'] ? "Yes" : "No";
$thu = @$_REQUEST['Thursday'] ? "Yes" : "No";
$fri = @$_REQUEST['Friday'] ? "Yes" : "No";

$termsandconditions = @$_REQUEST['termsandconditions'] ? "Yes" : "No";
$collar = @$_REQUEST['collar'] ? "Yes" : "No";
$offleash = @$_REQUEST['offleash'] ? "Yes" : "No";
$earlywalk = @$_REQUEST['earlywalk'] ? "Yes" : "No";

$to="james@maddogsdogwalking.com.au"; 
$subject="A new registration form has been added to the database"; 
if(@$_REQUEST['info_request']){$_REQUEST['info_request']=1;}else{$_REQUEST['info_request']=0;} 
$message=<<<__TEXT__
A new registration form has been added to the database. The completed form can be viewed in the CMS.

Do not reply to this email as it is automatically generated and will not be read. To contact the person who has submitted the form use the contact details below: 
    
Pet Details
Pet Name: {$_REQUEST['petname'] }
Breed: {$_REQUEST['breed'] }
Size: {$_REQUEST['size'] }

Owner Details
Name: {$_REQUEST['title']} 
Address (pick-up): {$_REQUEST['address']}, {$_REQUEST['city']}, {$_REQUEST['postcode']} 
Email: {$_REQUEST['email'] }
Telephone: {$_REQUEST['telephone'] }    

Vet Details: {$_REQUEST['vetaddress']} 

Booking Details
Type of walk: {$_REQUEST['type']}
Commence Date: {$_REQUEST['date']}
Monday: {$mon}
Tuesday: {$tue}
Wednesday: {$wed}
Thursday: {$thu}
Friday: {$fri}
Access details: {$_REQUEST['accessinfo']}
Other info: {$_REQUEST['otherinfo']}

Terms and Conditions: {$termsandconditions}
Collar: {$collar}
Off leash: {$offleash}
Early Walk: {$earlywalk}  

	
__TEXT__;
$from="FROM: jeff@wemakemagazines.co.uk";
mail($to,$subject,$message,$from);

// display thanks message and clear form
$successAlerts = "Thanks, we have received your registration form.";
$_REQUEST = array();
}
}
?>

<?php if (@$errorsAndAlerts): ?>
<div class="alert alert-danger">
<p><?php echo $errorsAndAlerts; ?></p>
</div>
<?php endif ?>

<?php if (@$successAlerts): ?>
<div class="alert alert-success">
<p><?php echo $successAlerts; ?></p>
</div>
<?php endif ?>

<fieldset>

<form method="post" action="">
<input type="hidden" name="submit" value="1" />


<div class="form-group">
<label class="control-label" for="title"><h3>Your Pet's Details</h3></label>  

<div class="form-group">
<label class="control-label" for="petname">Pet Name</label>  
<div>
<input id="textinput" name="petname" type="text" placeholder="Pet Name" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['petname']) ?>">
</div>
</div>

<div class="form-group">
<label class="control-label" for="petbreed">Breed</label>  
<div>
<input id="textinput" name="breed" type="text" placeholder="Breed" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['breed']) ?>">
</div>
</div>

<div class="form-group">
<label class="control-label" for="petsize">Size</label>  
<div>
<input id="textinput" name="size" type="text" placeholder="size" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['size']) ?>">
</div>
</div>
</div>


<div class="form-group">
<label class="control-label" for="title"><h3>Your Details</h3></label>  
  
 
<div class="form-group">
<label class="control-label" for="title">Name</label>  
<div>
<input id="textinput" name="title" type="text" placeholder="Name" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['title']) ?>">
</div>
</div>

<div class="form-group">
<label class="control-label" for="address">Address (pick-up)</label>  
<div>
<input id="textinput" name="address" type="text" placeholder="Address" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['address']) ?>">
</div>
<div>
<input id="textinput" name="city" type="text" placeholder="City" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['city']) ?>">
</div>
<div>
<input id="textinput" name="postcode" type="text" placeholder="Post Code" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['postcode']) ?>">
</div>
</div>

<div class="form-group">
<label class="control-label" for="email">Email</label>  
<div>
<input id="textinput" name="email" type="text" placeholder="Email" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['email']) ?>">
</div>
</div>

<div class="form-group">
<label class="control-label" for="telephone">Telephone</label>  
<div>
<input id="textinput" name="telephone" type="tel" placeholder="Telephone" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['telephone']) ?>">
</div>
</div>

</div>


<div class="form-group">
<label class="control-label" for="title"><h3>Your Vet's Details</h3></label>  
<div class="form-group">
<label class="control-label" for="address">Vet's Name and Address</label>  
<div>
<textarea class="form-control" rows="3" name="vetaddress" value="<?php echo htmlspecialchars(@$_REQUEST['vetaddress']) ?>"></textarea>
</div>
</div>
</div>

<div class="form-group">
<label class="control-label" for="title"><h3>Booking Details</h3></label>  

<div class="form-group">
<label class="control-label" for="type">Type of Walk</label> 
<select class="form-control" name="type">
<option selected="selected">Please select one</option> 
<option value="Casual" <?php selectedIf(@$_REQUEST['Casual'], 'Casual') ?>>Casual</option>
<option value="Ongoing" <?php selectedIf(@$_REQUEST['Ongoing'], 'Ongoing') ?>>Ongoing</option>
</select>
</div>

<div class="form-group">
<label class="control-label" for="date">Date you would like regular walks to commence, or dates of all walks required if not a recurring booking</label>  
<div>
<textarea class="form-control" rows="3" name="date" value="<?php echo htmlspecialchars(@$_REQUEST['date']) ?>"></textarea>
</div>
</div>

<div class="form-group">
<label class="control-label" for="title">Day(s) you would like your dog walked</label>  
<div class="checkbox">
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox1" name="Monday" > Monday
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox2" name="Tuesday"> Tuesday
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox3" name="Wednesday"> Wednesday
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox4" name="Thursday"> Thursday
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox4" name="Friday"> Friday
</label>
</div>
</div>



<div class="form-group">
<label class="control-label" for="accessinfo">Give us some details on how to gain access to your dog</label>  
<div>
<textarea class="form-control" rows="3" name="accessinfo" value="<?php echo htmlspecialchars(@$_REQUEST['accessinfo']) ?>"></textarea>
</div>
</div>

<div class="form-group">
<label class="control-label" for="otherinfo">Any other information. Please include details of any any aggression, behavioural issues, medical conditions, nervousness or any other issues that may affect the safety of your dog or other dogs in our care.</label>  
<div>
<textarea class="form-control" rows="3" name="otherinfo" value="<?php echo htmlspecialchars(@$_REQUEST['otherinfo']) ?>"></textarea>
</div>
</div>

</div>



<div class="checkbox">
  <label>
    <input type="checkbox" name="termsandconditions"><?php checkedIf(@$_REQUEST['termsandconditions'], '1') ?>
    I have read and agree to the terms and conditions.
  </label>
</div>




<div class="checkbox">
  <label>
    <input type="checkbox" name="collar"><?php checkedIf(@$_REQUEST['collar'], '1') ?>
    I confirm I will provide a collar or harness that the dog can not slip out of.
  </label>
</div>



<div class="checkbox">
  <label>
    <input type="checkbox" name="offleash"><?php checkedIf(@$_REQUEST['offleash'], '1') ?>
    I agree to allow Mad Dogs & Englishmen to exercise my dog off leash.
  </label>
</div>



<div class="checkbox">
  <label>
    <input type="checkbox" name="earlywalk"><?php checkedIf(@$_REQUEST['earlywalk'], '1') ?>
        I am happy for my dog to go in the early group if a space is available on the day. Pick up approx 8am, drop back approx 10am. (If this walk is too early for your dog, do not tick this box, and we will ensure we always come after 9am.)
  </label>
</div>



<div class="control-group marginBottom">
<div class="controls">
<button id="singlebutton" type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
</fieldset>

</div>

<div class="col-sm-6 col-lg-6 col-lg-offset-1 marginBottom">
<?php if ($page['content']): ?>
<p class="marginBottom"><?php echo $page['content'] ?></p>
<?php endif ?>

<?php if ($page['blockquote']): ?>
<?php include('common/inc/blockquote.php') ?>
<?php endif ?>

<?php if ($page['attachments']): ?>
<?php include('common/inc/attachments.php') ?>
<?php endif ?>    
        
<?php if ($page['button_1_title'] || $page['button_2_title']): ?>
<?php include('common/inc/buttons.php') ?>
<?php endif ?>
</div>

<div class="col-xs-12 marginBottom">
<?php echo $terms_and_conditionsRecord['title']; ?>
<?php echo $terms_and_conditionsRecord['content']; ?>
</div>

</div>

<?php include('common/inc/footer.php') ?>
</body>
</html>