| Current Path : /var/www/cesa.co.za/Mailer/ |
| Current File : /var/www/cesa.co.za/Mailer/addNewsletter_old2.php |
<?php
require_once ('includes/globals.php');
if (isset($_SESSION['database'])) {
$db = $_SESSION['database'];
}
if (isset($_SESSION['userid'])) {
$userid = $_SESSION['userid'];
} else {
echo "<script>document.location.href='index.php';</script>\n";
}
$nl_title = '';
$nl_heading = '';
// $nl_dtcreated = new
$nl_pastissue = -1;
$UpdateMode = False;
if (isset($_GET['id'])) {
$nl_id = intval($_GET['id']);
$UpdateMode = True;
$rsNewsLetter = $db->Execute("SELECT sTitle, sHeading, idPreviousIssue, dtCreated, txtNotes FROM Newsletter where idNewsletter = " . $nl_id);
if(!$rsNewsLetter->EOF) {
$nl_title = $rsNewsLetter->fields[0];
$nl_heading = $rsNewsLetter->fields[1];
$nl_pastissue = $rsNewsLetter->fields[2];
$nl_dtcreated = $rsNewsLetter->fields[3];
$nl_notes = $rsNewsLetter->fields[4];
}
$sql_prev = "SELECT idNewsletter, sTitle, dtCreated FROM Newsletter\n" .
"where idUser = " . $userid . " and dtCreated < '" . $nl_dtcreated . "' and idNewsletter <> " . $nl_id;
}
else {
$sql_prev = "SELECT idNewsletter, sTitle, dtCreated FROM Newsletter where idUser = " . $userid;
}
//echo $sql_prev;
$rsPreviousNewsletters = $db->Execute($sql_prev);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Email template control panel</title>
<link rel="stylesheet" type="text/css" href="stylesheet/default_styles.css">
<script language="JavaScript" type="text/javascript">
function validate() {
if ((document.formOne.title.value != "") && (document.formOne.previousIssueID.value != "-2")) {
return true;
} else {
alert("Please ensure that you have supplied both a title and a valid previous issue link before proceeding");
return false;
}
}
</script>
</head>
<body bgcolor="#D0ECF8" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" onLoad="javascript:document.getElementById('title').focus();">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td height="10" bgcolor="#016694"><img src="images/spacer.gif" width="1" height="10"></td>
</tr>
<tr>
<td height="2" bgcolor="#FFFFFF"><img src="images/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td height="2" bgcolor="#016694"><img src="images/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td height="30"><img src="images/spacer.gif" width="1" height="30"></td>
</tr>
<tr>
<td class="paddingLeft20">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td valign="top" align="middle">
<table border="0" cellpadding="0" cellspacing="0">
<?php
if ($UpdateMode) {
?>
<form name="formOne" method="post" action="doUpdateNewsletter.php" onsubmit="return validate();">
<input type="hidden" name="updateid" value="<?php echo $_GET['id']; ?>">
<?php
} else {
?>
<form name="formOne" method="post" action="doAddNewsletter.php" onSubmit="return validate();">
<?php
}
?>
<tr>
<td colspan="2" height="20"></td>
</tr>
<tr>
<td class="blackTypeBold">Title for newsletter: </td>
<td><input class="textBox2" type="text" size="50" name="title" id="title" <?php if ($UpdateMode) { ?>value="<?php echo $nl_title ?>"<?php } ?>></td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td class="blackTypeBold">Newsletter heading: </td>
<td><input class="textBox2" type="text" size="50" name="heading" id="heading" <?php if ($UpdateMode) { ?>value="<?php echo $nl_heading ?>"<?php } ?>></td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td class="blackTypeBold">Notes: </td>
<td><input class="textBox2" type="text" size="50" name="notes" id="notes" <?php if ($UpdateMode) { ?>value="<?php echo $nl_notes ?>"<?php } ?>></td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td class="blackTypeBold">Last issue: </td>
<td class="blackTypeBold">
<select class="textBox2" name="previousIssueID">
<option value="-1">No previous issue</option>
<option value="-2">.......................</option>
<?php
//nl_pastissue
while (! $rsPreviousNewsletters->EOF) {
?>
<option value="<?php echo $rsPreviousNewsletters->fields[0]; ?>" <?php if ($nl_pastissue === $rsPreviousNewsletters->fields[0]) {?>selected<?php }?>><?php echo $rsPreviousNewsletters->fields[1]; ?></option>
<?php
$rsPreviousNewsletters->MoveNext();
}
?>
</select>
</td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" <?php if ($UpdateMode) { ?>value="Update"<?php } else { ?>value="Submit"<?php }?> class="button"> <input type="button" value="Cancel" class="button" onClick="javascript:document.location='doLogin.php';"></td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td height="100%"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
//}
?>