Portions created by the Initial Developer are Copyright (C) 2018 the Initial Developer. All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('email_template_add') || permission_exists('email_template_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $email_template_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (is_array($_POST)) { $domain_uuid = check_str($_POST["domain_uuid"]); $template_language = check_str($_POST["template_language"]); $template_category = check_str($_POST["template_category"]); $template_subcategory = check_str($_POST["template_subcategory"]); $template_subject = check_str($_POST["template_subject"]); $template_body = check_str($_POST["template_body"]); $template_type = check_str($_POST["template_type"]); $template_enabled = check_str($_POST["template_enabled"]); $template_description = check_str($_POST["template_description"]); } //process the user data and save it to the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //get the uuid from the POST if ($action == "update") { $email_template_uuid = check_str($_POST["email_template_uuid"]); } //check for all required data $msg = ''; if (strlen($template_language) == 0) { $msg .= $text['message-required']." ".$text['label-template_language']."
\n"; } if (strlen($template_category) == 0) { $msg .= $text['message-required']." ".$text['label-template_category']."
\n"; } //if (strlen($template_subcategory) == 0) { $msg .= $text['message-required']." ".$text['label-template_subcategory']."
\n"; } if (strlen($template_subject) == 0) { $msg .= $text['message-required']." ".$text['label-template_subject']."
\n"; } if (strlen($template_body) == 0) { $msg .= $text['message-required']." ".$text['label-template_body']."
\n"; } //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } //if (strlen($template_type) == 0) { $msg .= $text['message-required']." ".$text['label-template_type']."
\n"; } if (strlen($template_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-template_enabled']."
\n"; } //if (strlen($template_description) == 0) { $msg .= $text['message-required']." ".$text['label-template_description']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add the email_template_uuid if (strlen($_POST["email_template_uuid"]) == 0) { $email_template_uuid = uuid(); $_POST["email_template_uuid"] = $email_template_uuid; } //prepare the array $array['email_templates'][0] = $_POST; //save to the data $database = new database; $database->app_name = 'email_templates'; $database->app_uuid = null; if (strlen($email_template_uuid) > 0) { $database->uuid($email_template_uuid); } $database->save($array); $message = $database->message; //debug info //echo "
";
			//print_r($message);
			//echo "
"; //exit; //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } header('Location: email_template_edit.php?id='.$email_template_uuid); return; } } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $email_template_uuid = check_str($_GET["id"]); $sql = "select * from v_email_templates "; $sql .= "where email_template_uuid = '$email_template_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; $template_language = $row["template_language"]; $template_category = $row["template_category"]; $template_subcategory = $row["template_subcategory"]; $template_subject = $row["template_subject"]; $template_body = $row["template_body"]; $template_type = $row["template_type"]; $template_enabled = $row["template_enabled"]; $template_description = $row["template_description"]; } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['title-email_template']."

\n"; echo " "; echo " "; echo "
\n"; echo " ".$text['label-template_language']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_language']."\n"; echo "
\n"; echo " ".$text['label-template_category']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_category']."\n"; echo "
\n"; echo " ".$text['label-template_subcategory']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_subcategory']."\n"; echo "
\n"; echo " ".$text['label-template_subject']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_subject']."\n"; echo "
\n"; echo " ".$text['label-template_body']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_body']."\n"; echo "
\n"; echo " ".$text['label-domain']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-domain_uuid']."\n"; echo "
\n"; echo " ".$text['label-template_type']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_type']."\n"; echo "
\n"; echo " ".$text['label-template_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_enabled']."\n"; echo "
\n"; echo " ".$text['label-template_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-template_description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo "
"; echo "

"; //include the footer require_once "resources/footer.php"; ?>