// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/**COPYRIGHTS**/
$pageTitle = 'Ofuz :: Email Templates';
$Author = 'SQLFusion LLC';
$Keywords = 'Keywords for search engine';
$Description = 'Description for search engine';
$background_color = 'white';
include_once 'config.php';
include_once 'includes/ofuz_check_access.script.inc.php';
include_once 'includes/header.inc.php';
$do_auto_responder = new AutoResponder();
//$do_auto_responder->sessionPersistent('do_auto_responder', 'contacts.php', OFUZ_TTL);
//$user_email_templ  = new EmailTemplateUser();
$access = true;
if (isset($plugin_item_value)) {
    $do_auto_responder_email = new AutoResponderEmail();
    $do_auto_responder_email->getId($plugin_item_value);
    $do_auto_responder_email->sessionPersistent('do_auto_responder_email', 'contacts.php', OFUZ_TTL);
    $user_email_templ = new EmailTemplateUser();
    $do_auto_responder = new AutoResponder();
    $idautoresponder = $_SESSION['do_auto_responder_email']->idautoresponder;
    if (!$do_auto_responder->isOwner($_SESSION['do_auto_responder_email']->idautoresponder)) {
        $access = false;
    }
    $do_auto_responder->getId($_SESSION['do_auto_responder_email']->idautoresponder);
} else {
    $access = false;
}
?>
<script type="text/javascript">
//<![CDATA[
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
$pageTitle = 'Ofuz :: Email Templates';
$Author = 'SQLFusion LLC';
$Keywords = 'Keywords for search engine';
$Description = 'Description for search engine';
$background_color = 'white';
include_once 'config.php';
include_once 'includes/ofuz_check_access.script.inc.php';
include_once 'includes/header.inc.php';
$do_auto_responder = new AutoResponder();
//$do_auto_responder->sessionPersistent('do_auto_responder', 'contacts.php', OFUZ_TTL);
//$user_email_templ  = new EmailTemplateUser();
$access = true;
if (isset($_GET['id']) && $_GET['id'] != '') {
    $do_auto_responder_email = new AutoResponderEmail();
    $do_auto_responder_email->getId($_GET['id']);
    $do_auto_responder_email->sessionPersistent('do_auto_responder_email', 'contacts.php', OFUZ_TTL);
    $user_email_templ = new EmailTemplateUser();
    $do_auto_responder = new AutoResponder();
    $idautoresponder = $_SESSION['do_auto_responder_email']->idautoresponder;
    if (!$do_auto_responder->isOwner($_SESSION['do_auto_responder_email']->idautoresponder)) {
        $access = false;
    }
    $do_auto_responder->getId($_SESSION['do_auto_responder_email']->idautoresponder);
} else {
    $access = false;
}
?>
<script type="text/javascript">
//<![CDATA[
        <div id="ptask_ctlbar_1" style = "display:none;">
           <div align="right">
		<select name="email_template" onchange="getEmailTemplateText(this)">
                    <?php 
$user_email_templ->getUserSavedEmailTemplates();
echo '<option value="0">' . _('Select Email Template') . '</option>';
if ($user_email_templ->getNumRows()) {
    while ($user_email_templ->next()) {
        echo '<option value = ' . $user_email_templ->idemailtemplate_user . '>' . $user_email_templ->name . '</option>';
    }
}
?>
		</select>
        </div>
         <?php 
$do_auto_responder_email = new AutoResponderEmail();
$do_auto_responder_email->newAddForm();
$do_auto_responder_email->form->addEventAction('do_auto_responder_email->eventCheckEmptyFields', 700);
$do_auto_responder_email->setRegistry('autoresponder_email_add');
$do_auto_responder_email->form->goto = $_PHP['SELF'];
echo $do_auto_responder_email->form->getFormHeader();
echo $do_auto_responder_email->form->getFormEvent();
$do_auto_responder_email->idautoresponder = $_SESSION['do_auto_responder_detail']->idautoresponder;
echo $do_auto_responder_email->idautoresponder;
//echo '<b>'._('Name').':</b>'. $do_auto_responder_email->name;
echo '<b>' . _('Subject') . ':</b>' . $do_auto_responder_email->subject;
echo '<br/><br/><b>' . _('Send it in') . ' </b>' . $do_auto_responder_email->num_days_to_send . " <b>" . _('day(s)') . "</b>";
echo '<br/><br/><b>' . _('Message') . ':</b>' . $do_auto_responder_email->bodyhtml;
echo '<div align="right">' . $do_auto_responder_email->form->getFormFooter(_('Create')) . '</div>';
?>
        </div>