<?PHP
/*
Simfatic Forms Main Form processor script

This script does all the server side processing. 
(Displaying the form, processing form submissions,
displaying errors, making CAPTCHA image, and so on.) 

All pages (including the form page) are displayed using 
templates in the 'templ' sub folder. 

The overall structure is that of a list of modules. Depending on the 
arguments (POST/GET) passed to the script, the modules process in sequence. 

Please note that just appending  a header and footer to this script won't work.
To embed the form, use the 'Copy & Paste' code in the 'Take the Code' page. 
To extend the functionality, see 'Extension Modules' in the help.

*/

@ini_set("display_errors", 1);//the error handler is added later in FormProc
error_reporting(E_ALL);

require_once(dirname(__FILE__)."/includes/contact_vinson-lib.php");
$formproc_obj =  new SFM_FormProcessor('contact_vinson');
$formproc_obj->initTimeZone('default');
$formproc_obj->setFormID('48139ef5-790f-443e-a4e4-d2934d6b7eac');
$formproc_obj->setFormKey('5c50bc2f-2a59-45a2-987b-2dc956f12446');
$formproc_obj->setLocale('en-US','yyyy-MM-dd');
$formproc_obj->setEmailFormatHTML(true);
$formproc_obj->EnableLogging(false);
$formproc_obj->SetDebugMode(false);
$formproc_obj->setIsInstalled(true);
$formproc_obj->SetPrintPreviewPage(sfm_readfile(dirname(__FILE__)."/templ/contact_vinson_print_preview_file.txt"));
$formproc_obj->SetSingleBoxErrorDisplay(true);
$formproc_obj->setFormPage(0,sfm_readfile(dirname(__FILE__)."/templ/contact_vinson_form_page_0.txt"));
$formproc_obj->AddElementInfo('Name','text','');
$formproc_obj->AddElementInfo('Company','text','');
$formproc_obj->AddElementInfo('Phone','text','');
$formproc_obj->AddElementInfo('Email','text','');
$formproc_obj->AddElementInfo('Information','multiline','');
$formproc_obj->SetHiddenInputTrapVarName('t138c19ef8adbe052022c');
$formproc_obj->SetFromAddress('Vinson <mikevinson@vinsonconstruction.com>');
$sfm_captcha =  new FM_CaptchaCreator('Captcha');
$sfm_captcha->SetSize(150,60);
$sfm_captcha->SetCharset('2356789ABCDEFGHJKLMNPQRSTUVWXYZ');
$sfm_captcha->SetCaseInsensitiveMatch(true);
$sfm_captcha->SetNChars(6);
$sfm_captcha->SetNLines(4);
$sfm_captcha->SetFontFile('images/SFOldRepublicBold.ttf');
$sfm_captcha->SetErrorStrings('Please input the code displayed in the image','The code does not match. Please try again.');
$formproc_obj->addModule($sfm_captcha);

$page_renderer =  new FM_FormPageDisplayModule();
$formproc_obj->addModule($page_renderer);

$validator =  new FM_FormValidator();
$validator->addValidation("Name","required","Please fill in Name");
$validator->addValidation("Company","required","Please fill in Company");
$validator->addValidation("Phone","required","Please fill in Phone");
$validator->addValidation("Email","required","Please fill in Email");
$validator->addValidation("Email","email","The input for Email should be a valid email value");
$formproc_obj->addModule($validator);

$data_email_sender =  new FM_FormDataSender(sfm_readfile(dirname(__FILE__)."/templ/contact_vinson_email_subj.txt"),sfm_readfile(dirname(__FILE__)."/templ/contact_vinson_email_body.txt"),'%Email%');
$data_email_sender->AddToAddr('Vinson <mikevinson@vinsonconstruction.com>');
$formproc_obj->addModule($data_email_sender);

$tupage =  new FM_ThankYouPage();
$tupage->SetRedirURL('http://vinsonconstruction.com/thankyou.html');
$formproc_obj->addModule($tupage);

$sfm_captcha->SetValidator($validator);
$page_renderer->SetFormValidator($validator);
$formproc_obj->ProcessForm();

?>