isMobile() && !$detect->isTablet() ){ header('Location: ' . $config_http . 'mobile/'); exit(); } */ // Start Session HTTP_Session::start(); HTTP_Session::setExpire(time() + $session_expire); HTTP_Session::setIdle(time() + $session_idle); // Check Session if ((HTTP_Session::isNew()) || (HTTP_Session::isIdle())) { $_SESSION['referer'] = get_refererinfo($_SESSION['referer'], true); $_SESSION['form_variables'] = array(); } else { $_SESSION['referer'] = get_refererinfo($_SESSION['referer'], false); } $GLOBALS['options'] = get_options(); $GLOBALS['smarty'] = & new MySmarty(); $GLOBALS['renderer'] = & new HTML_QuickForm_Renderer_ArraySmarty($GLOBALS['smarty']); // Create Mortgage Form $form_insurance = & new HTML_Quickform_CRM('frmTest', 'post', $GLOBALS['options']); // If Button Submit Is Pressed if (!isset($_REQUEST['btnSubmit1'])) { $validate_ok = false; } else { $validate_ok = $form_insurance->validate(); } // Save Data In Session $form_insurance->accept($GLOBALS['renderer']); $_SESSION['form_insurance_smarty'] = $GLOBALS['renderer']->toArray(); $_SESSION['form_insurance_data'] = $form_insurance->exportValues(); $_SESSION['form_insurance_html'] = $form_insurance->toFrozenHtml(); // Assign Smarty Data $GLOBALS['smarty']->assign('invalid_item', $form_insurance->_validate_err); $GLOBALS['smarty']->assign('invalid_msg', $form_insurance->_validate_msg); $GLOBALS['smarty']->assign('warning', isset($_REQUEST['btnSubmit1'])); $GLOBALS['smarty']->assign('warning_col', $GLOBALS['warning_color']); $GLOBALS['smarty']->assign('mail_contact', $GLOBALS['mail_contact']); $GLOBALS['smarty']->assign('footer_title', $GLOBALS['footer_title']); $GLOBALS['smarty']->assign('terms_of', $GLOBALS['terms_of']); $GLOBALS['smarty']->assign('tab_id', ''); $GLOBALS['smarty']->assign('kw', urlencode($_SESSION['referer']['kw'])); $GLOBALS['smarty']->assign('ps', urlencode($_SESSION['referer']['program_search'])); $GLOBALS['smarty']->assign('subid', urlencode($_SESSION['referer']['kw'] . '@' . $_SESSION['referer']['session_id'])); $GLOBALS['smarty']->assign('related', $GLOBALS['related']); // If Button Submit Is Pressed if (!isset($_REQUEST['btnSubmit1'])) { form_insurance_export(0, true); } else { form_insurance_export(1, $validate_ok); } if (!$validate_ok) { // Add Submit Button $form_insurance->addElement('submit', 'btnSubmit1', '', array('class' => 'btn' , 'onClick' => 'document.forms[\'frmTest\'].submitbutton.disabled = true; document.forms[\'frmTest\'].submit(); ')); // Assign Additional Smarty Data $form_insurance->accept($GLOBALS['renderer']); $GLOBALS['smarty']->assign('form', $GLOBALS['renderer']->toArray()); // Display Mortgage Form HTTP_Session::updateIdle(); HTTP_Session::pause(); if ( ($_SESSION['referer']['cam'] == "contact") || ($_SERVER['PHP_SELF'] == "/contact-us.html")) { $GLOBALS['smarty']->display('contact-us.html'); } elseif ( ($_SESSION['referer']['cam'] == "about") || ($_SERVER['PHP_SELF'] == "/about-us.html")) { $GLOBALS['smarty']->display('about-us.html'); } elseif ( ($_SESSION['referer']['cam'] == "how-it-works") || ($_SERVER['PHP_SELF'] == "/how-it-works.html")) { $GLOBALS['smarty']->display('how-it-works.html'); } elseif ( ($_SESSION['referer']['cam'] == "privacy") || ($_SERVER['PHP_SELF'] == "/privacy-policy.html")) { $GLOBALS['smarty']->display('privacy-policy.html'); } elseif ( ($_SESSION['referer']['cam'] == "terms") || ($_SERVER['PHP_SELF'] == "/terms-and-conditions.html")) { $GLOBALS['smarty']->display('terms-and-conditions.html'); } else { $GLOBALS['smarty']->display('all_form_index.html'); } } else { // Display "Thank You" Form HTTP_Session::updateIdle(); HTTP_Session::pause(); $GLOBALS['smarty']->display('thank-you-fail.html'); } // http://www.globelink.co.uk/glaff.php?afflnk=b0E-w8a-vb1-d56 ////////////////////////////////////// // End ////////////////////////////////////// function form_insurance_export($form_id, $validate_ok) { // Get Export Type Variables $opened = false; $lastform = false; $completed = false; $validated = $validate_ok; if (($form_id == 0) && ($validated)) { $opened = true; } elseif (($form_id == 1) && (!$validated)) { $lastform = true; } elseif (($form_id == 1) && ($validated)) { $completed = true; } // Export Type $export_type = ""; $export_type_short = ""; if ($opened) { $export_type .= ' [OPENED]'; $export_type_short .= "OPENED"; } elseif ($completed) { $export_type .= ' [COMPLETED]'; $export_type_short .= "COMPLETED"; } else { $export_type .= ' FormID ' . $form_id; $export_type_short .= 'F' . $form_id; if ($validated) { $export_type .= ' [VALIDATED]'; $export_type_short .= "-VALID"; } else { } } // Application $application = "Health-Insurance"; if ($GLOBALS['input_string_enabled']) { $inputString = createInputString2($_SESSION['form_insurance_data']); } // Save File if ($GLOBALS['file_save']) { // Subject $subject = $GLOBALS['file_dir'] . date("Ymd-His") . '-' . session_id() . '-' . $application . '-' . $export_type_short . '.html'; // HTML $html = ''; switch($form_id) { case 1: //$html = $inputString . $html; $html = $_SESSION['form_insurance_html'] . $html; } $html = $_SESSION['referer']['HTML'] . $html; $html = '' . '' . $html . ''; // Save File ex_file2($form_id, $validated, $html, $subject); } // Send TCH if ($GLOBALS['tch_send']) { foreach ($GLOBALS['tch_configs'] as $tch_config) { if ($tch_config['enabled'] == true) { if ($completed) { $login = array( 'TCHuser' => $tch_config['username'], 'TCHpass' => $tch_config['password'], 'Type' => 'PMI', //PMM PMI 'SubmitAs' => 'CPA' ); $app1 = array( 'Title' => $_SESSION['form_insurance_data']['fa_title'], 'Forename' => $_SESSION['form_insurance_data']['fa_firstname'], 'Surname' => $_SESSION['form_insurance_data']['fa_surname'], 'DOB' => sprintf("%02d/%02d/%04d", (int)$_SESSION['form_insurance_data']['fa_dob']['d'], (int)$_SESSION['form_insurance_data']['fa_dob']['M'], (int)$_SESSION['form_insurance_data']['fa_dob']['Y']), 'Email' => $_SESSION['form_insurance_data']['email'], 'HomeTel' => ($_SESSION['form_insurance_data']['home_phone'] == '') ? $_SESSION['form_insurance_data']['mobile_phone'] : $_SESSION['form_insurance_data']['home_phone'], 'WorkTel' => ($_SESSION['form_insurance_data']['mobile_phone'] == '') ? $_SESSION['form_insurance_data']['home_phone'] : $_SESSION['form_insurance_data']['mobile_phone'], 'Smoker' => $_SESSION['form_insurance_data']['fa_smoker'], 'IPAddress' => $_SESSION['referer']['IP'] //Must be captured from applicant during submission ); $residential = array( 'HouseNumber' => (strlen($_SESSION['form_insurance_data']['house_num']) < 5) ? $_SESSION['form_insurance_data']['house_num'] : '', 'Address' => $_SESSION['form_insurance_data']['house_num'], 'Postcode' => $_SESSION['form_insurance_data']['postcode'] ); $insurance = array( 'HasInsurance' => $_SESSION['form_insurance_data']['already_insured'], //Do you already have medical nsurance 'WhoCovered' => ($_SESSION['form_insurance_data']['application_type'] == 'You') ? 'Self' : 'Self + Partner', 'NumPersonsCovered' => $_SESSION['form_insurance_data']['people_on_policy'] //How many people on the policy in total ); $lead = array( 'TCHLogin' => $login, 'Applicant1' => $app1, 'Residential' => $residential, 'Insurance' => $insurance ); $home_phone = (!empty($_SESSION['form_insurance_data']['home_phone'])) ? $_SESSION['form_insurance_data']['home_phone'] : $_SESSION['form_insurance_data']['mobile_phone']; if ((int)$_SESSION['form_insurance_data']['people_on_policy'] >= 3) { $cover_type = 3; } elseif ($_SESSION['form_insurance_data']['application_type'] == 'You') { $cover_type = 1; } else { $cover_type = 2; } $lead_soleads = array('strCoverType' => $cover_type, 'strNoOfemployees' => '0', 'strCurrentlyHaveMedicalInsurance' => ($_SESSION['form_insurance_data']['already_insured'] == 'No') ? '0' : '1', 'strPostcode' => $_SESSION['form_insurance_data']['postcode'], 'strAffiliateID' => '11319', 'strNameTitle' => $_SESSION['form_insurance_data']['fa_title'], 'strFirstName' => $_SESSION['form_insurance_data']['fa_firstname'], 'strSurname' => $_SESSION['form_insurance_data']['fa_surname'], 'strAdr1' => $_SESSION['form_insurance_data']['house_num'], 'strHomePhone' => $home_phone, 'strWorkPhone' => $_SESSION['form_insurance_data']['home_phone'], 'strMobilePhone' => $_SESSION['form_insurance_data']['mobile_phone'], 'strEmail' => $_SESSION['form_insurance_data']['email'], 'strPassword' => '', 'strIPAddress' => $_SESSION['referer']['IP'], 'strApplicantDOBDay' => (int)$_SESSION['form_insurance_data']['fa_dob']['d'], 'strApplicantDOBMonth' => (int)$_SESSION['form_insurance_data']['fa_dob']['M'], 'strApplicantDOBYear' => (int)$_SESSION['form_insurance_data']['fa_dob']['Y'], 'strDPOI' => '1' ); // Subject $subject_file = date("Ymd-His") . '-' . session_id() . '-' . $application . '-' . $export_type_short; $subject_mail = $tch_config['mail_subject']; if ($tch_config['mail_light'] == false) { $subject_mail .= 'Health-Insurance SI ' . session_id(); } else { $subject_mail .= ' IP ' . $_SESSION['referer']['IP']; } $subject_mail .= ' ' . $application . $export_type; if (is_full_quota()) { $Success = ex_soleads($lead_soleads, $subject_file, $tch_config['file_configs'], $subject_mail, $tch_config['mail_configs']); } else { $Success = ex_tch2($lead, $tch_config['url'], $subject_file, $tch_config['file_configs'], $subject_mail, $tch_config['mail_configs']); } } } } } // Send Mail if ($GLOBALS['mail_send']) { foreach ($GLOBALS['mail_configs'] as $mail_config) { if ($mail_config['enabled'] == true) { if (($opened && $mail_config['send_opened']) || ($lastform && $mail_config['send_lastform']) || ($completed && $mail_config['send_completed']) || ((!$opened) && $validated && $mail_config['send_validated']) || ((!$opened) && (!$validated) && $mail_config['send_invalidated'])) { // Subject $subject = $mail_config['subject']; if ($mail_config['light'] == false) { $subject .= ' SI ' . session_id(); } else { $subject .= ' IP ' . $_SESSION['referer']['IP']; } $subject .= ' ' . $application . $export_type; // HTML $html = ''; switch($form_id) { case 1: if (($GLOBALS['input_string_enabled']) && ($mail_config['light'] == false)) { $html = $inputString . $html; } $html = $_SESSION['form_insurance_html'] . $html; } if ($mail_config['light'] == false) { $html = $_SESSION['referer']['HTML'] . $html; } else { $html = "IP: " . $_SESSION['referer']['IP'] . "
" . $html; } $html = '' . '' . $html . ''; // Send Mail ex_mail2($mail_config['from'], $mail_config['to'], $html, $subject); } } } } // Send SMS if ($GLOBALS['sms_send']) { foreach ($GLOBALS['sms_configs'] as $sms_config) { if ($sms_config['enabled'] == true) { if (($opened && $sms_config['send_opened']) || ($lastform && $sms_config['send_lastform']) || ($completed && $sms_config['send_completed']) || ((!$opened) && $validated && $sms_config['send_validated']) || ((!$opened) && (!$validated) && $sms_config['send_invalidated'])) { // Subject $subject = $sms_config['subject'] . ' ' . $application . ' ' . $export_type_short; if ($GLOBALS['tch_send']) { $subject .= ($Success) ? ' [Submited]' : ' [Not Submited]'; } // Text $txt = 'IP:' . $_SESSION['referer']['IP']; //$txt = 'A:' . $_SESSION['form1_data']['ld_amount'] . ' ' . 'P:' . $_SESSION['form1_data']['ld_purpose'] ; if ($sms_config['light'] == false) { $txt .= ' KW1:' . $_SESSION['referer']['program_search'] . ' KW2:' . $_SESSION['referer']['kw'] ; //' SID:' . $_SESSION['referer']['session_id']; } // Send Mail ex_sms2($sms_config['from'], $sms_config['to'], $txt, $subject); } } } } } ?>