<?php
define('MAIN_DIR', dirname(__FILE__) . '/../');
define('SCRIPT_DIR', MAIN_DIR . 'scripts/' );
require_once(SCRIPT_DIR . 'db_calls.php');

$email = str_replace(' ', '+', $_GET['email']);


$results = getAppointment($email);
 $row = $results['results'];
//$stylist = getStylistName($row['stylist']);
//$service = getServiceName($row['service']);
//$row['stylist'] = $stylist;
//$row['service'] = $service;
$fields = array();
$values = array();
foreach ($row as $k=>$v) {
 $fields[]= '__' . $k . '__';
 $values[$k] = $v;
 }
 
 $locArray = getLocation($row['account_location_id']);
foreach ($locArray['results'] as $k=>$v) {
 $fields[]= '__LOCATION_' . $k . '__';
 $values['LOCATION_' . $k] = $v;
 }
$locID = $locArray['results']['id'];
$locName = $locArray['results']['name'];
$acctID = $locArray['results']['account_id'];
$acctArray = getAccount($acctID);
$acctName = $acctArray['results']['name'];
$fields[] = '__account__';
$values['account'] = $acctName;
$fields[] = '__terms__';
$values['terms'] = file_get_contents('terms/' . $acctName . '_terms.inc');
//echo implode(',', $fields);
//echo implode(',', $values);
$header = str_replace($fields, $values, file_get_contents('headers/' . $acctName . '-' . $locName . '_header.html.inc'));
$footer = str_replace($fields, $values, file_get_contents('thankyou.html.inc'));
//echo str_replace($fields, $values, file_get_contents('headers/3.html.inc'));
//echo str_replace($fields, $values, file_get_contents('confirm.html.inc'));
echo $header;
echo $footer;
//echo implode(',', $fields);
//echo implode(',', $values);
//echo str_replace($fields, $values, file_get_contents('headers/3.html.inc'));
//echo str_replace($fields, $values, file_get_contents('thankyou.html.inc'));

