mail placeholders, accounts, images, cleanup

This commit is contained in:
Ulf Gebhardt 2018-05-30 23:45:44 +02:00
parent 0e253b3957
commit fd167f9a2d
19 changed files with 518 additions and 25 deletions

View File

@ -20,7 +20,7 @@ function init_saimod_mail_contacts() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -59,7 +59,7 @@ function init_saimod_mail_contact() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -103,7 +103,7 @@ function init_saimod_mail_contact_new() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -144,7 +144,7 @@ function init_saimod_mail_lists() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -177,7 +177,7 @@ function init_saimod_mail_list() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -211,7 +211,7 @@ function init_saimod_mail_list_new() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -248,7 +248,7 @@ function init_saimod_mail_emails() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -277,26 +277,72 @@ function init_saimod_mail_email() {
$('#btn-email-update').click(function(){
var id = $('#input-email-id').val();
var account = $('#select-email-account').val();
var sender = $('#input-email-sender').val();
var name = $('#input-email-name').val();
var subject = $('#input-email-subject').val();
var text_template = $('#select-email-text-template').val();
var html_template = $('#select-email-html-template').val();
var placeholders = [];
$('.email-placeholder').not('.email-placeholder-new').each(function() {
var id = $(this).attr('placeholder');
var name = $(this).find('.email-placeholder-name').val();
var type = $(this).find('.email-placeholder-type').val();
var deleted = $(this).hasClass('placeholder_deleted') ? 1 : 0
var data = {};
switch(type){
case "2":
data.table = $(this).find('.email-placeholder-data-switch-table').val();
data.field = $(this).find('.email-placeholder-data-switch-field').val();
data.default = $(this).find('.email-placeholder-data-switch-default').val();
var switch_values = {};
$(this).find('.email-placeholder-switch-value').not('.email-placeholder-switch-value-new').each(function(){
switch_values[$(this).find('.email-placeholder-data-switch-value-key').val()] = $(this).find('.email-placeholder-data-switch-value-value').val();
})
data.values = switch_values;
break;
case "3":
data.default = $(this).find('.email-placeholder-data-name-value').val();
break;
default:
data.value = $(this).find('.email-placeholder-data-text-value').val();
}
placeholders.push({
id: id,
name: name,
type: type,
data: data,
deleted: deleted
});
});
var images = [];
$('.email-image').not('.email-image-new').each(function() {
images.push({
id: $(this).attr('image'),
name: $(this).find('.email-image-name').val(),
file: $(this).find('.email-image-file').val(),
mime: $(this).find('.email-image-mime').val(),
deleted: $(this).hasClass('image_deleted') ? 1 : 0
});
});
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
action: 'update_email',
data: {
id: id,
account: account,
sender: sender,
name: name,
subject: subject,
text_template: text_template ? text_template : null,
html_template: html_template ? html_template : null
html_template: html_template ? html_template : null,
placeholders: placeholders,
images: images
}
},
success: function(data){
@ -318,7 +364,7 @@ function init_saimod_mail_email() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -340,6 +386,61 @@ function init_saimod_mail_email() {
}
});
});
$('#btn-email-template-text').click(function(){
var template = $('#select-email-text-template').val();
if(template === ""){
system.load('mail(template_new)');
} else {
system.load('mail(template);id.'+template);
}
});
$('#btn-email-template-html').click(function(){
var template = $('#select-email-html-template').val();
if(template === ""){
system.load('mail(template_new)');
} else {
system.load('mail(template);id.'+template);
}
});
$('#btn-email-image-new').click(function(){
var $new = $('.email-image-new').clone().removeClass('email-image-new');
$('#tbody_mail_email_images').append($new);
});
$('#btn-email-placeholder-new').click(function(){
var $new = $('.email-placeholder-new').clone().removeClass('email-placeholder-new');
$('#tbody_mail_email_placeholders').append($new);
});
$('.btn-email-placeholder-switch-value-new').click(function(){
var $new = $(this).parent().parent().parent().find('.email-placeholder-switch-value-new').clone().removeClass('email-placeholder-switch-value-new');
$(this).parent().parent().parent().append($new);
});
$('.email-placeholder-type').trigger('change');
}
function placeholder_type(e){
switch(e.val()){
case '2':
$(e).parent().parent().find('.email-placeholder-data-text').hide();
$(e).parent().parent().find('.email-placeholder-data-switch').show();
$(e).parent().parent().find('.email-placeholder-data-name').hide();
break;
case '3':
$(e).parent().parent().find('.email-placeholder-data-text').hide();
$(e).parent().parent().find('.email-placeholder-data-switch').hide();
$(e).parent().parent().find('.email-placeholder-data-name').show();
break;
default:
$(e).parent().parent().find('.email-placeholder-data-text').show();
$(e).parent().parent().find('.email-placeholder-data-switch').hide();
$(e).parent().parent().find('.email-placeholder-data-name').hide();
}
}
function init_saimod_mail_email_new() {
@ -349,6 +450,7 @@ function init_saimod_mail_email_new() {
$('#btn-email-new-insert').click(function(){
var name = $('#input-email-new-name').val();
var account = $('#select-email-new-account').val();
var sender = $('#input-email-new-sender').val();
var subject = $('#input-email-new-subject').val();
var text_template = $('#select-email-new-text-template').val();
@ -356,13 +458,14 @@ function init_saimod_mail_email_new() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
action: 'insert_email',
data: {
name: name,
account: account,
sender: sender,
subject: subject,
text_template: text_template,
@ -397,7 +500,7 @@ function init_saimod_mail_templates() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -432,7 +535,7 @@ function init_saimod_mail_template() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',
@ -470,7 +573,7 @@ function init_saimod_mail_template_new() {
$.ajax({
async: true,
url: this.endpoint,
type: 'GET',
type: 'POST',
dataType: 'JSON',
data: {
sai_mod: '.SAI.saimod_mail',

View File

@ -15,6 +15,14 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
const EMAIL_PROTOTYPE_ACCESS_ANDROID= 31;
const EMAIL_PROTOTYPE_ACCESS_IOS = 32;
const EMAIL_PLACEHOLDER_TYPE_TEXT = 1;
const EMAIL_PLACEHOLDER_TYPE_SWITCH = 2;
const EMAIL_PLACEHOLDER_TYPE_NAME = 3;
const EMAIL_ACCOUNT_CONTACT = 1;
const EMAIL_ACCOUNT_PROTOTYPING = 2;
const EMAIL_ACCOUNT_CROWDFUNDING = 3;
public static function subscribe($email,$list){
return \SQL\SUBSCRIBE::QI(array($email,$list));
}
@ -41,15 +49,57 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
$email_data = \SQL\EMAIL_SELECT::Q1(array($email_id));
$template_text = \SQL\EMAIL_TEMPLATE_SELECT::Q1(array($email_data['template_text']));
$template_html = \SQL\EMAIL_TEMPLATE_SELECT::Q1(array($email_data['template_html']));
//TODO
//$smtp = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_PROTOTYPING);
$smtp = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT);
$to = $email;
//TODO
$placeholders_qq= \SQL\EMAIL_PLACEHOLDER_SELECT_EMAIL::QQ(array($email_id));
$images_qq = \SQL\EMAIL_IMAGE_SELECT_EMAIL::QQ(array($email_id));
$smtp = null;
switch($email_data['account']){
case self::EMAIL_ACCOUNT_PROTOTYPING:
$smtp = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_PROTOTYPING);
break;
case self::EMAIL_ACCOUNT_CROWDFUNDING:
$smtp = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CROWDFUNDING);
break;
// contact
default:
$smtp = \SYSTEM\CONFIG\config::get(\config_ids::DEMOCRACY_EMAIL_CONTACT);
}
$replacements = [];
$replacements['emoji_mobile'] = '📱';
foreach($data as $k => $v){
$replacements['data_'.$k] = $v;}
while($placeholder = $placeholders_qq->next()){
switch($placeholder['type']){
case self::EMAIL_PLACEHOLDER_TYPE_TEXT:
$value = json_decode($placeholder['data'],true)['value'];
$value = str_replace('\\n', "\n", $value);
$replacements[$placeholder['name']] = $value;
break;
case self::EMAIL_PLACEHOLDER_TYPE_SWITCH:
$data = json_decode($placeholder['data'],true);
$d = null;
switch($data['table']){
case 'contact':
$d = $contact_data[$data['field']];
break;
}
$value = $data['default'];
foreach($data['values'] as $k => $v){
if($d == $k){
$value = $v;}
}
$replacements[$placeholder['name']] = $value;
break;
case self::EMAIL_PLACEHOLDER_TYPE_NAME:
$value = json_decode($placeholder['data'],true)['default'];
if($contact_data['name_first'] || $contact_data['name_last']){
$value = trim($contact_data['name_first'].' '.$contact_data['name_last']);
}
$replacements[$placeholder['name']] = $value;
break;
}
}
if($list){
$replacements['unsubscribe_link'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).
'#!unsubscribe;token.'.
@ -57,12 +107,17 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
array( 'email' => $email,'list' => $list),
true);
}
$to = $email;
$from = \SYSTEM\PAGE\replace::replace($email_data['sender'],$replacements);
$subject = \SYSTEM\PAGE\replace::replace($email_data['subject'],$replacements);
$text = \SYSTEM\PAGE\replace::replace($template_text['value'], $replacements);
$html = \SYSTEM\PAGE\replace::replace($template_html['value'], $replacements);
//TODO
$images = ["democracy_logo" => (new \PAPI('img/logo.png'))->SERVERPATH()];
$images = [];
while($image = $images_qq->next()){
$images[$image['name']] = [ 'file' => (new \PFILES('email/'.$image['file']))->SERVERPATH(),
'mime' => $image['mime']];
}
//TODO
$attachments = [];
@ -239,6 +294,8 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
public static function sai_mod__SAI_saimod_mail_action_email($id){
$vars = \SQL\EMAIL_SELECT::Q1(array($id));
$vars['template_lock'] = $vars['system_lock'] ? 'disabled' : '';
$vars['selected_account_1'] = $vars['selected_account_2'] = $vars['selected_account_3'] = '';
$vars['selected_account_'.$vars['account']] = 'selected';
//text template
$vars['text_options'] = '';
$res = \SQL\EMAIL_TEMPLATES_SELECT::QQ(array(0));
@ -253,6 +310,65 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
$row['selected'] = $row['id'] == $vars['template_html'] ? 'selected' : '';
$vars['html_options'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_template_option.tpl'))->SERVERPATH(),$row);
}
//placeholders
$vars['placeholders'] = '';
$res = \SQL\EMAIL_PLACEHOLDER_SELECT_EMAIL::QQ(array($id));
while($row = $res->next()){
$data = json_decode($row['data'],true);
$row['selected_1'] = $row['selected_2'] = $row['selected_3'] = '';
$row['selected_'.$row['type']] = 'selected';
$row['new_placeholder'] = '';
$row['text_value'] = $row['type'] == self::EMAIL_PLACEHOLDER_TYPE_TEXT ? $data['value'] : '';
$row['name_default'] = $row['type'] == self::EMAIL_PLACEHOLDER_TYPE_NAME ? $data['default'] : '';
$row['switch_table'] = $row['type'] == self::EMAIL_PLACEHOLDER_TYPE_SWITCH ? $data['table'] : '';
$row['switch_field'] = $row['type'] == self::EMAIL_PLACEHOLDER_TYPE_SWITCH ? $data['field'] : '';
$row['switch_default'] = $row['type'] == self::EMAIL_PLACEHOLDER_TYPE_SWITCH ? $data['default'] : '';
$row['switch_values'] = '';
if($row['type'] == self::EMAIL_PLACEHOLDER_TYPE_SWITCH){
if(!array_key_exists('values', $data)){
$data['values'] = [];
}
foreach($data['values'] as $k=>$v){
$d = ['k' => $k, 'v' => $v, 'new_switch_value' => ''];
$row['switch_values'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_placeholder_switch_value.tpl'))->SERVERPATH(),$d);
}
$d = ['k' => '', 'v' => '', 'new_switch_value' => 'email-placeholder-switch-value-new'];
$row['switch_values'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_placeholder_switch_value.tpl'))->SERVERPATH(),$d);
}
//new value
$vars['placeholders'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_placeholder.tpl'))->SERVERPATH(),$row);
}
//placeholder new
$new_placeholder = ['selected_1' => 'selected', 'selected_2' => '', 'selected_3' => '',
'name' => '',
'text_value' => '', 'name_default' => '',
'switch_table' => '', 'switch_field' => '', 'switch_default' => '',
'new_placeholder' => 'email-placeholder-new'];
$d = ['k' => '', 'v' => '', 'new_switch_value' => 'email-placeholder-switch-value-new'];
$new_placeholder['switch_values'] = \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_placeholder_switch_value.tpl'))->SERVERPATH(),$d);
$vars['placeholders'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_placeholder.tpl'))->SERVERPATH(),$new_placeholder);
//files
$files = \SYSTEM\FILES\files::get('email');
//images
$vars['images'] = '';
$res = \SQL\EMAIL_IMAGE_SELECT_EMAIL::QQ(array($id));
while($row = $res->next()){
$row['files'] = '';
$row['new_image'] = '';
foreach($files as $file){
$f = ['name' => $file, 'selected' => $row['file'] == $file ? 'selected' : ''];
$row['files'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_image_file.tpl'))->SERVERPATH(),$f);
}
$vars['images'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_image.tpl'))->SERVERPATH(),$row);
}
//image new
$new_image = ['name' => '', 'id' => '', 'mime' => 'image/png', 'files' => '', 'new_image' => 'email-image-new'];
foreach($files as $file){
$f = ['name' => $file, 'selected' => ''];
$new_image['files'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_image_file.tpl'))->SERVERPATH(),$f);
}
$vars['images'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mail/tpl/saimod_mail_email_image.tpl'))->SERVERPATH(),$new_image);
//send
$vars['send'] = '';
$res = \SQL\EMAIL_LISTS_SELECT::QQ();
@ -289,12 +405,30 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
}
public static function sai_mod__SAI_saimod_mail_action_update_email($data){
\SQL\EMAIL_UPDATE::QI(array($data['name'],$data['sender'],$data['subject'],$data['text_template'],$data['html_template'],$data['id']));
\SQL\EMAIL_UPDATE::QI(array($data['name'],$data['account'],$data['sender'],$data['subject'],$data['text_template'],$data['html_template'],$data['id']));
foreach($data['images'] as $image){
if($image['deleted'] && $image['id']){
\SQL\EMAIL_IMAGE_DELETE::QI(array($data['id'],$image['id']));
} else if($image['id']){
\SQL\EMAIL_IMAGE_UPDATE::QI(array($image['name'],$image['file'],$image['mime'],$data['id'],$image['id']));
} else if(!$image['deleted']){
\SQL\EMAIL_IMAGE_INSERT::QI(array($image['id'],$data['id'],$image['name'],$image['file'],$image['mime']));
}
}
foreach($data['placeholders'] as $placeholder){
if($placeholder['deleted'] && $placeholder['id']){
\SQL\EMAIL_PLACEHOLDER_DELETE::QI(array($data['id'],$placeholder['id']));
} else if($placeholder['id']){
\SQL\EMAIL_PLACEHOLDER_UPDATE::QI(array($placeholder['name'],$placeholder['type'],json_encode($placeholder['data']),$data['id'],$placeholder['id']));
} else if(!$placeholder['deleted']){
\SQL\EMAIL_PLACEHOLDER_INSERT::QI(array($placeholder['id'],$data['id'],$placeholder['name'],$placeholder['type'],json_encode($placeholder['data'])));
}
}
return \JsonResult::ok();
}
public static function sai_mod__SAI_saimod_mail_action_insert_email($data){
\SQL\EMAIL_INSERT::QI(array($data['name'],$data['sender'],$data['subject'],$data['text_template'],$data['html_template']));
\SQL\EMAIL_INSERT::QI(array($data['name'],$data['account'],$data['sender'],$data['subject'],$data['text_template'],$data['html_template']));
return \JsonResult::ok();
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_IMAGE_DELETE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'DELETE FROM email_image WHERE email = ? AND id = ?;';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_IMAGE_INSERT extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'INSERT INTO email_image (`id`,`email`,`name`,`file`,`mime`)VALUES(?,?,?,?,?);';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_IMAGE_SELECT_EMAIL extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT * FROM email_image WHERE email = ?;';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_IMAGE_UPDATE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'UPDATE email_image SET `name`=?,`file`=?,`mime`=? WHERE `email` = ? AND `id` = ?;';
}
}

View File

@ -4,6 +4,6 @@ namespace SQL;
class EMAIL_INSERT extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'INSERT INTO email (name,sender,subject,template_text,template_html)VALUES(?,?,?,?,?);';
'INSERT INTO email (name,account,sender,subject,template_text,template_html)VALUES(?,?,?,?,?,?);';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_PLACEHOLDER_DELETE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'DELETE FROM email_placeholder WHERE email = ? AND id = ?;';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_PLACEHOLDER_INSERT extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'INSERT INTO email_placeholder (`id`,`email`,`name`,`type`,`data`)VALUES(?,?,?,?,?);';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_PLACEHOLDER_SELECT_EMAIL extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT * FROM email_placeholder WHERE email = ?;';
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace SQL;
class EMAIL_PLACEHOLDER_UPDATE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'UPDATE email_placeholder SET `name`=?,`type`=?,`data`=? WHERE `email` = ? AND `id` = ?;';
}
}

View File

@ -4,6 +4,6 @@ namespace SQL;
class EMAIL_UPDATE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'UPDATE email SET name=?, sender=?, subject=?, template_text=?, template_html=? WHERE id=?;';
'UPDATE email SET name=?, account=?, sender=?, subject=?, template_text=?, template_html=? WHERE id=?;';
}
}

View File

@ -2,6 +2,10 @@ INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (1,'Test Liste'
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (2,'Newsletter',1);
INSERT IGNORE INTO email_list (`id`,`name`,`system_lock`) VALUES (3,'Prototype',1);
INSERT IGNORE INTO email (`id`,`name`,`sender`,`subject`,`template_text`,`template_html`,`system_lock`) VALUES (1,'Mail Test','Testing | DEMOCRACY <contact@democracy-deutschland.de>','${emoji_mobile} DEMOCRACY Mail Test',1,2,0);
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (1,0,'Mail Test Text','Use this Mail for testing',0);
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (2,1,'Mail Test HTML','Use this Mail for testing',0);
INSERT IGNORE INTO email (`id`,`name`,`sender`,`subject`,`template_text`,`template_html`,`system_lock`) VALUES (10,'Website Contact','${data_vorname} ${data_nachname} <${data_email}>','${emoji_mobile} DEMOCRACY Website: ${data_type} from ${data_email}',10,11,1);
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (10,0,'Website Contact Text','Eine Nachricht ist über die Website eingegangen:\n\n${data_json}\n\nAchtung: Diese EMail ist die einzige Kopie dieser Daten',1);
INSERT IGNORE INTO email_template (`id`,`type`,`name`,`value`,`system_lock`) VALUES (11,1,'Website Contact HTML','<style>\n table, th, td {\n border: 1px solid black;\n border-collapse: collapse;\n }\n</style>\nEine Nachricht ist über die Website eingegangen:<br>\n<br>\n<h3>Type: ${data_type}</h3>\n<table>\n <tr>\n <th>EMail</th>\n <td><a href=\"mailto:${data_email}\">${data_email}<a></td>\n </tr>\n <tr>\n <th>Name</th>\n <td>${data_vorname} ${data_nachname}</td>\n </tr>\n <tr>\n <th>Type</th>\n <td>${data_type}</td>\n </tr>\n <tr>\n <th>Text</th>\n <td><pre>${data_text}</pre></td>\n </tr>\n</table>\n<h3>Raw Data:</h3>\n<pre>${data_json}</pre>\n<br>\n<div class=\"footer\" style=\"margin-top: 3em; padding-top: 1em; border-top-width: 2px; border-top-color: #4494d3; border-top-style: solid;\">\n <p style=\"max-width: 35rem;\">\n Wir sind gespannt, welche großartigen Möglichkeiten in der Zukunft noch für unser Projekt offen stehen und verbleiben mit einem Lächeln und ganz herzlichen Grüßen,\n </p> \n <p style=\"max-width: 35rem;\">\n Ihr TEAM DEMOCRACY\n </p>\n <img class=\"logo\" alt=\"DEMOCRACY Logo\" src=\"cid:democracy_logo\" style=\"height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; border: 0 none;\" />\n <p style=\"max-width: 35rem;\">\n DEMOCRACY Deutschland e.V.<br />\n mobil +49 176 470 40 213<br />\n <a href=\"mailto:contact@democracy-deutschland.de\" style=\"color: #4f81bd; font-weight: bold;\">\n contact@democracy-deutschland.de\n </a><br />\n <a href=\"https://www.democracy-deutschland.de\" style=\"color: #4f81bd; font-weight: bold;\">\n https://www.democracy-deutschland.de\n </a><br />\n <a href=\"https://github.com/demokratie-live/\" style=\"color: #4f81bd; font-weight: bold;\">\n https://github.com/demokratie-live\n </a>\n </p>\n </div>\n',1);

View File

@ -9,6 +9,16 @@
<th>Name</th>
<td><input id="input-email-name" type="text" value="${name}" style="width: 100%"/></td>
</tr>
<tr>
<th>Account</th>
<td>
<select id="select-email-account">
<option value="1" ${selected_account_1}>contact@democracy-deutschland.de</option>
<option value="2" ${selected_account_2}>prototyping@democracy-deutschland.de</option>
<option value="3" ${selected_account_3}>crowdfunding@democracy-deutschland.de</option>
</select>
</td>
</tr>
<tr>
<th>From</th>
<td><input id="input-email-sender" type="text" value="${sender}" style="width: 100%"/></td>
@ -32,6 +42,7 @@
<option value="">No Template</option>
${text_options}
</select>
<button class="btn btn-sm btn-warning pull-right" id="btn-email-template-text"><i class="fa fa-pencil"></i></button>
</td>
</tr>
<tr>
@ -41,11 +52,84 @@
<option value="">No Template</option>
${html_options}
</select>
<button class="btn btn-sm btn-warning pull-right" id="btn-email-template-html"><i class="fa fa-pencil"></i></button>
</td>
</tr>
<tr>
<th colspan="2"></th>
</tr>
<tr>
<th colspan="2">Placeholders</th>
</tr>
<tr>
<style>
.email-placeholder-new, .placeholder_deleted, .email-placeholder-switch-value-new, .switch_value_deleted{
display: none;
}
</style>
<td colspan="2">
<table class="table table-striped table-condensed tablesorter sai_margin_off" id="table_mail_email_placeholders">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Data</th>
<th>
<button class="btn btn-sm btn-success" id="btn-email-placeholder-new"><i class="fa fa-plus"></i></button>
</th>
</tr>
</thead>
<tbody id="tbody_mail_email_placeholders">
<tr>
<td>emoji_mobile</td>
<td>STATIC</td>
<td>📱</td>
<td></td>
</tr>
<tr>
<td>data_*</td>
<td>STATIC</td>
<td>Mixed</td>
<td></td>
</tr>
<tr>
<td>unsubscribe_link</td>
<td>STATIC</td>
<td>Link</td>
<td></td>
</tr>
${placeholders}
</tbody>
</table>
</td>
</tr>
<tr>
<th colspan="2">Images</th>
</tr>
<tr>
<style>
.email-image-new, .image_deleted{
display: none;
}
</style>
<td colspan="2">
<table class="table table-striped table-condensed tablesorter sai_margin_off" id="table_mail_email_images">
<thead>
<tr>
<th>Name</th>
<th>File</th>
<th>Mime</th>
<th>
<button class="btn btn-sm btn-success" id="btn-email-image-new"><i class="fa fa-plus"></i></button>
</th>
</tr>
</thead>
<tbody id="tbody_mail_email_images">
${images}
</tbody>
</table>
</td>
</tr>
<tr>
<th colspan="2">Preview</th>
</tr>

View File

@ -0,0 +1,18 @@
<tr class="email-image ${new_image}" image="${id}">
<td>
<input class="email-image-name" type="text" value="${name}"/>
</td>
<td>
<select class="email-image-file">
${files}
</select>
</td>
<td>
<select class="email-image-mime">
<option value="${mime}" selected>${mime}</option>
</select>
</td>
<th>
<button class="btn btn-sm btn-danger btn-email-image-del" onclick="$(this).parent().parent().addClass('image_deleted');"><i class="fa fa-trash"></i></button>
</th>
</tr>

View File

@ -0,0 +1 @@
<option value="${name}" ${selected}>${name}</option>

View File

@ -5,6 +5,16 @@
<th>Name</th>
<td><input id="input-email-new-name" type="text" style="width: 100%"/></td>
</tr>
<tr>
<th>Account</th>
<td>
<select id="select-email-new-account">
<option value="1" selected>contact@democracy-deutschland.de</option>
<option value="2">prototyping@democracy-deutschland.de</option>
<option value="3">crowdfunding@democracy-deutschland.de</option>
</select>
</td>
</tr>
<tr>
<th>From</th>
<td><input id="input-email-new-sender" type="text" style="width: 100%"/></td>

View File

@ -0,0 +1,56 @@
<tr class="email-placeholder ${new_placeholder}" placeholder="${id}">
<td>
<input class="email-placeholder-name" type="text" value="${name}"/>
</td>
<td>
<select class="email-placeholder-type" onchange="placeholder_type($(this))">
<option value="1" ${selected_1}>Text</option>
<option value="2" ${selected_2}>Switch</option>
<option value="3" ${selected_3}>Name</option>
</select>
</td>
<td>
<div class="email-placeholder-data-text">
<textarea class="email-placeholder-data-text-value" style="width: 100%; min-height: 100px;">${text_value}</textarea>
</div>
<div class="email-placeholder-data-switch">
<table class="table table-striped table-condensed tablesorter sai_margin_off">
<tr>
<th>Table</th>
<th>
<input class="email-placeholder-data-switch-table" type="text" value="${switch_table}"/>
</th>
<th></th>
</tr>
<tr>
<th>Field</th>
<th>
<input class="email-placeholder-data-switch-field" type="text" value="${switch_field}"/>
</th>
<th></th>
</tr>
<tr>
<th>Default</th>
<th>
<input class="email-placeholder-data-switch-default" type="text" value="${switch_default}"/>
</th>
<th></th>
</tr>
<tr>
<th>Values</th>
<th></th>
<th>
<button class="btn btn-sm btn-success btn-email-placeholder-switch-value-new"><i class="fa fa-plus"></i></button>
</th>
</tr>
${switch_values}
</table>
</div>
<div class="email-placeholder-data-name">
<input class="email-placeholder-data-name-value" type="text" placeholder="Default Value" value="${name_default}" style="width: 100%;"/>
</div>
</td>
<th>
<button class="btn btn-sm btn-danger btn-email-palceholder-del" onclick="$(this).parent().parent().addClass('placeholder_deleted');"><i class="fa fa-trash"></i></button>
</th>
</tr>

View File

@ -0,0 +1,11 @@
<tr class="email-placeholder-switch-value ${new_switch_value}">
<td>
<input class="email-placeholder-data-switch-value-key" placeholder="Equals" type="text" value="${k}"/>
</td>
<th>
<input class="email-placeholder-data-switch-value-value" placeholder="Replace" type="text" value="${v}"/>
</th>
<td>
<button class="btn btn-sm btn-danger btn-email-placeholder-switch-value-del" onclick="$(this).parent().parent().addClass('switch_value_deleted');"><i class="fa fa-trash"></i></button>
</td>
</tr>