<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 2/3/2014
//
	
	include ("check_session.php");
	
	$query = "SELECT `language_folder` FROM " . BWB_TABLE_PREFIX . "plugins WHERE `name` = 'Contact/Mail Form with CAPTCHA'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$language_folder = $row['language_folder'];
	
	$document_root = $_SERVER['DOCUMENT_ROOT'];
	if ((defined("BWB_LANG")) && (file_exists($document_root . "/" . $language_folder . "/" . BWB_LANG . ".php")))
		include_once ($document_root . "/" . $language_folder . "/" . BWB_LANG . ".php");
	else
		include_once ($document_root . "/" . $language_folder . "/en.php");
	
?>
<!DOCTYPE html">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Form Recipients | Breeze Website Builder</title>

<link rel="stylesheet" href="../theme/<?php echo $theme; ?>/manager.css" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">

<style type="text/css">
#help_button	{
	position:relative;
	display:block;
	top:-15px;
	left:215px;
	height:31px;
	width:31px;
	z-index:100;
}

</style>

<script language="javascript" src="../js/ajax.js" type="text/javascript"> </script>
<script type="text/javascript" src="../js/mouse_position.js"></script>
<script language="javascript" src="../js/popup_msg.js" type="text/javascript"> </script>
<script language="javascript" src="js/edit_form_recipients.js" type="text/javascript"> </script>

<script>
<?php
	echo "	var FORM_RECIPIENTS_SAVING_RECIPIENT_MSG = \"" . FORM_RECIPIENTS_SAVING_RECIPIENT_MSG . "\";\n";
	echo "	var EDIT_CSS_UPDATE_READY_TO_SEND_MSG = \"" . EDIT_CSS_UPDATE_READY_TO_SEND_MSG . "\";\n";
	echo "	var EDIT_CSS_UPDATE_SENT_MSG = \"" . EDIT_CSS_UPDATE_SENT_MSG . "\";\n";
	echo "	var EDIT_CSS_UPDATE_COMPLETE_MSG = \"" . EDIT_CSS_UPDATE_COMPLETE_MSG . "\";\n";
?>
</script>

</head>

<body>

<table width="80%" align="center" border="0"><tr><td>
<div class="button_heading_sub_level_1" id="edit_form_recipient_heading"><div class="button_heading_text_sub_level_1"><?php echo FORM_RECIPIENTS_HEADING; ?></div><div class="help_button" id="help_button" onClick="OpenHelpWindow();">&nbsp;</div></div>
</td></tr></table>

<table width="80%" border="0" align="center" class="layout_box_table">
<tr bgcolor='#CCCCCC'>
	<td><b><?php echo FORM_RECIPIENTS_FORM_PAGE; ?></b></td><td><b><?php echo RECIPIENT_WORD; ?></b></td><td>&nbsp;</td>
<?php
	$i = 0;
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "page_data ORDER BY page_name";
	$result = $bwb_dbh->query($query);
	while($row = $result->fetch(PDO::FETCH_ASSOC))
	{		
		$page_name = $row["page_name"];
		$page_content = $row["page_content"];
		if (strpos($page_content, 'recipient') > 0)
		{
			if ($bgclr == "#DDDDDD")
				$bgclr = "#EEEEEE";
			else
				$bgclr = "#DDDDDD";
			
			$query = "SELECT * FROM form_recipients WHERE page_name = '$page_name'";
			$result2 = $bwb_dbh->query($query);
			$row2 = $result2->fetch(PDO::FETCH_ASSOC);
			$recipient = $row2["recipient"];
			echo "<tr bgcolor='$bgclr'><td>$page_name<input type='hidden' name='page_name$i' id='page_name$i' value='$page_name' /></td>\n";
			echo "<td><input name='recipient$i' id='recipient$i' type='text' value='$recipient' style='width:250px;' /></td>\n";
			echo "<td><div class='button_console_save_sm' style='width:100px;' onClick='SaveRecipient($i);'><span class='button_console_text_w_sm_icon'>" . UPDATE_WORD . "</span></div></td></tr>\n";
			$i++;
		}
	}
?>
</tr>
<tr><td colspan="3" align="center"><br />
    <span class="small_message"><?php echo FORM_RECIPIENTS_MULTIPLE_RECIPIENTS_NOTE; ?></span>
</td></tr>
</table>

<?php include("../lib/popup_msg.html"); ?>

<script language="javascript" type="text/javascript">
	popup_msg.HidePopupMsg();
</script>

</body>
</html>