<?php


// ============== Send a record to the database ==============
require 'connection.php';
$conn        = Connect();
$name        = $conn->real_escape_string($_POST['full_name']);
$company     = $conn->real_escape_string($_POST['company']);
$clientid    = $conn->real_escape_string($_POST['clientid']);
$email       = $conn->real_escape_string($_POST['email']);
$telephone   = $conn->real_escape_string($_POST['telephone']);
$url         = $conn->real_escape_string($_POST['url']);
$app         = $conn->real_escape_string($_POST['app']);
$reason      = $conn->real_escape_string($_POST['reason']);
$comments    = $conn->real_escape_string($_POST['comments']);
$query       = "INSERT into tb_fform (full_name,company,clientid,email,telephone,url,application,reason,comments)
                VALUES('" . $name . "','" . $company . "','" . $clientid . "','" . $email . "','" . $telephone . "',
                '" . $url . "','" . $app . "','" . $reason . "','" . $comments . "')";
$success = $conn->query($query);

if (!$success) {
    die("Couldn't enter data: ".$conn->error);

}

echo "<div style='font-family:Calibri; margin:0 auto; margin-top:50px; width: 500px'>
		<img src='https://documentation.wolterskluwerfs.com/Help/resources/img/checkbox-720.png' style='width:200px; display:block; margin:auto' /><br />
		<div style='text-align:center'>
		<h2 style='color:rgb(0, 122, 195);font-size:32px'>Thank you for contacting us.</h2>
		<p style='font-size:22px'>We value our customers and your opinion.<br />
		You can now close this window.</p>
		</div>
		</div>";

$conn->close();
// ============== End Send a record to the database ==============



// ============== Send Email ==============
// Comment out this entire section if you do not wish to send an email upon form submission

if ($app == 'Arta Lending') {
  $to = 'artalendingsup@wolterskluwer.com';
} elseif ($app == 'Cash Suite') {
  $to = 'CASHsupport@wolterskluwer.com';
} elseif ($app == 'ComplianceOne Deposit') {
  $to = 'ComplianceOnedeposit@wolterskluwer.com';
} elseif ($app == 'ComplianceOne Lending') {
  $to = 'ComplianceOneSupport@wolterskluwer.com';
} elseif ($app == 'ComplianceOne Interfaces') {
  $to = 'ComplianceOneManagerSupport@wolterskluwer.com';
} elseif ($app == 'ComplianceOne manager') {
  $to = 'ComplianceOneManagerSupport@wolterskluwer.com';
} elseif ($app == 'ComplianceOne mortgage') {
  $to = 'ComplianceOneMortgageSupport@wolterskluwer.com';
} elseif ($app == 'Document Generation Services') {
  $to = 'ExpereIESupport@wolterskluwer.com';
} elseif ($app == 'Expere Document Services') {
  $to = 'ExpereIESupport@wolterskluwer.com';
} elseif ($app == 'Medici') {
  $to = 'medicisupport@wolterskluwer.com';
} elseif ($app == 'PubAssist FTP') {
  $to = 'kelly.mankenberg@wolterskluwer.com';
} elseif ($app == 'Requirements Editor') {
  $to = 'ExpereIESupport@wolterskluwer.com';
} elseif ($app == 'TSoftPlus') {
  $to = 'tsoftsup@wolterskluwer.com';
} elseif ($app == 'Settlement Services') {
  $to = 'kelly.mankenberg@wolterskluwer.com';
} else {
  $to = 'kelly.mankenberg@wolterskluwer.com';
}

// $to = 'kelly.mankenberg@wolterskluwer.com';

$subject = "Online Documentation Feedback";
$email = $_POST['email'];
$headers = "From: $email";

$email_message .= "Online Documentation Feedback\r\n" ;
$email_message .= "The following feedback was received using the Feedback form within the InfoDev online documentation.\r\n\r\n" ;

$email_message .= "Date and Time: " . date('m/d/Y, H:i:s') . "\r\n";
$email_message .= "Page URL: " . strip_tags($_POST['url']) . "\r\n\r\n";

$email_message .= "Name: " . strip_tags($_POST['full_name']) . "\r\n";
$email_message .= "Company: " . strip_tags($_POST['company']) . "\r\n";
$email_message .= "Client ID: " . strip_tags($_POST['clientid']) . "\r\n";
$email_message .= "Email: " . strip_tags($_POST['email']) . "\r\n";
// $email_message .= "<tr>
					  // <td class='col1'>Contact me? </td>
					  // <td>" . $Contact . "</td>
					// </tr>";
$email_message .= "Contact Number: " . strip_tags($_POST['telephone']) . "\r\n";
$email_message .= "Product: " . strip_tags($_POST['app']) . "\r\n";
$email_message .= "Reason: " . strip_tags($_POST['reason']) . "\r\n";
$email_message .= "Comment: " . strip_tags($_POST['comments']) . "\r\n";


$sent = mail($to, $subject, $email_message, $headers);

if($sent)
//{print "Your mail was sent successfully"; }
	{print "";}

else
//{print "We encountered an error sending your mail"; }
echo "<div style='font-family:Calibri; margin:0 auto; margin-top:50px; width: 500px'>
		<p>We have encountered an error sending an email. However, your submission has been stored in our database.</p>
		</div>";

// ============== End of Send Email ==============

?>
