include "../lib/Form/Class.FormHandler.inc.php";
include "../lib/smarty.php";
if (!has_rights(ACX_MISC)) {
    Header("HTTP/1.0 401 Unauthorized");
    Header("Location: PP_error.php?c=accessdenied");
    die;
}
getpost_ifset(array('id', 'languages', 'subject', 'mailtext', 'translate_data', 'id_language'));
$handle = DbConnect();
$instance_table = new Table();
/***********************************************************************************/
// #### HEADER SECTION
$smarty->display('main.tpl');
if (isset($translate_data) && $translate_data == 'translate') {
    //print check_translated($id, $languages);
    if (check_translated($id, $languages)) {
        update_translation($id, $languages, $subject, $mailtext);
    } else {
        insert_translation($id, $languages, $subject, $mailtext);
    }
}
// Query to get mail template information
$QUERY = "SELECT id,mailtype,subject,messagetext,id_language from cc_templatemail where id = {$id}";
if (isset($languages)) {
    $QUERY .= " and id_language = '{$languages}'";
}
$mail = $instance_table->SQLExec($handle, $QUERY);
// #### HELP SECTION
echo $CC_help_list_misc;
// Query to get all languages with ids
$QUERY = "SELECT code,name from cc_iso639 order by code";
include '../lib/admin.module.access.php';
include '../lib/Form/Class.FormHandler.inc.php';
include '../lib/admin.smarty.php';
if (!has_rights(ACX_MAIL)) {
    Header("HTTP/1.0 401 Unauthorized");
    Header("Location: PP_error.php?c=accessdenied");
    die;
}
getpost_ifset(array('id', 'languages', 'subject', 'mailtext', 'translate_data', 'id_language', 'mailtype'));
$handle = DbConnect();
$instance_table = new Table();
// #### HEADER SECTION
$smarty->display('main.tpl');
if (isset($translate_data) && $translate_data == 'translate') {
    //print check_translated($id, $languages);
    if (check_translated($id, $languages, $mailtype)) {
        update_translation($id, $languages, $subject, $mailtext, $mailtype);
    } else {
        insert_translation($id, $languages, $subject, $mailtext, $mailtype);
    }
}
// Query to get mail template information
$QUERY = "SELECT id, mailtype, subject, messagetext, id_language FROM cc_templatemail WHERE mailtype = '{$mailtype}'";
if (isset($languages)) {
    $QUERY .= " and id_language = '{$languages}'";
}
$mail = $instance_table->SQLExec($handle, $QUERY);
// #### HELP SECTION
echo $CC_help_list_misc;
// Query to get all languages with ids
$QUERY = "SELECT code, name FROM cc_iso639 ORDER BY code";