organization as field for contact, csv import, contact fields in email template as value

This commit is contained in:
Ulf Gebhardt 2019-01-21 13:34:12 +01:00
parent 139347b8e5
commit 1680d38142
9 changed files with 32 additions and 6 deletions

View File

@ -145,6 +145,7 @@ function init_saimod_mail_contact() {
var sex = $('#input-contact-sex').val();
var name_first = $('#input-contact-name-first').val();
var name_last = $('#input-contact-name-last').val();
var organization = $('#input-contact-organization').val();
var email_lists = [];
$(".list-check").each(function(){
email_lists.push({id: $(this).attr('list'), subscribed: $(this).prop('checked') === true ? 1 : 0});
@ -162,6 +163,7 @@ function init_saimod_mail_contact() {
sex: sex,
name_first: name_first,
name_last: name_last,
organization: organization,
email_lists: email_lists
}
},
@ -189,6 +191,7 @@ function init_saimod_mail_contact_new() {
var sex = $('#input-contact-new-sex').val();
var name_first = $('#input-contact-new-name-first').val();
var name_last = $('#input-contact-new-name-last').val();
var organization = $('#input-contact-new-organization').val();
var email_lists = [];
$(".list-check").each(function(){
email_lists.push({id: $(this).attr('list'), subscribed: $(this).prop('checked') === true ? 1 : 0});
@ -206,6 +209,7 @@ function init_saimod_mail_contact_new() {
sex: sex,
name_first: name_first,
name_last: name_last,
organization: organization,
email_lists: email_lists
}
},

View File

@ -82,6 +82,8 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
$replacements['emoji_mobile'] = '📱';
foreach($data as $k => $v){
$replacements['data_'.$k] = $v;}
foreach($contact_data as $k => $v){
$replacements['contact_'.$k] = $v;}
while($placeholder = $placeholders_qq->next()){
switch($placeholder['type']){
case self::EMAIL_PLACEHOLDER_TYPE_TEXT:
@ -425,7 +427,7 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
}
public static function sai_mod__SAI_saimod_mail_action_update_contact($data){
\SQL\CONTACT_UPDATE::QI(array($data['sex'],$data['name_first'],$data['name_last'],$data['email']));
\SQL\CONTACT_UPDATE::QI(array($data['sex'],$data['name_first'],$data['name_last'],$data['organization'],$data['email']));
foreach($data['email_lists'] as $list){
if($list['subscribed']){
self::subscribe($data['email'],$list['id']);
@ -440,7 +442,7 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
if($data['email'] == ''){
throw new \SYSTEM\LOG\ERROR('Please provide an EMail');
}
\SQL\CONTACT_INSERT::QI(array($data['email'],$data['sex'],$data['name_first'],$data['name_last']));
\SQL\CONTACT_INSERT::QI(array($data['email'],$data['sex'],$data['name_first'],$data['name_last'],$data['organization']));
foreach($data['email_lists'] as $list){
if($list['subscribed']){
\SQL\SUBSCRIBE::QI(array($data['email'],$list['id']));
@ -756,11 +758,15 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
if(count($data) >= 4 && $data[3]){
$name_first = $data[3];
}
$organization = $db ? $db['organization'] : null;
if(count($data) >= 5 && $data[4]){
$organization = $data[4];
}
if($db){
\SQL\CONTACT_UPDATE::QI(array($sex,$name_first,$name_last,$email));
\SQL\CONTACT_UPDATE::QI(array($sex,$name_first,$name_last,$organization,$email));
} else {
\SQL\CONTACT_INSERT::QI(array($email,$sex,$name_first,$name_last));
\SQL\CONTACT_INSERT::QI(array($email,$sex,$name_first,$name_last,$organization));
}
\SQL\SUBSCRIBE::QI(array($email,$list));

View File

@ -4,6 +4,6 @@ namespace SQL;
class CONTACT_INSERT extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'INSERT IGNORE INTO contact (email,sex,name_first,name_last)VALUES(?,?,?,?);';
'INSERT IGNORE INTO contact (email,sex,name_first,name_last,organization)VALUES(?,?,?,?,?);';
}
}

View File

@ -4,6 +4,6 @@ namespace SQL;
class CONTACT_UPDATE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'UPDATE contact SET sex=?, name_first=?, name_last=? WHERE email=?;';
'UPDATE contact SET sex=?, name_first=?, name_last=?, organization=? WHERE email=?;';
}
}

View File

@ -17,6 +17,10 @@
<th>LastName</th>
<td><input id="input-contact-name-last" type="text" value="${name_last}" style="width: 100%"/></td>
</tr>
<tr>
<th>Organization</th>
<td><input id="input-contact-organization" type="text" value="${organization}" style="width: 100%"/></td>
</tr>
<tr>
<th>UpdatedAt</th>
<td>${updated_at}</td>

View File

@ -17,6 +17,10 @@
<th>LastName</th>
<td><input id="input-contact-new-name-last" type="text" style="width: 100%"/></td>
</tr>
<tr>
<th>Organization</th>
<td><input id="input-contact-new-organization" type="text" style="width: 100%"/></td>
</tr>
<tr>
<th colspan="2"></th>
</tr>

View File

@ -12,6 +12,7 @@
<th>Sex</th>
<th>FirstName</th>
<th>LastName</th>
<th>Organization</th>
<th>UpdatedAt</th>
<th>
<button type="button" id="btn-mail-contact-del" class="btn btn-sm btn-danger pull-right"><i class="fa fa-trash"></i></button>

View File

@ -3,6 +3,7 @@
<td>${sex}</td>
<td>${name_first}</td>
<td>${name_last}</td>
<td>${organization}</td>
<td>${updated_at}</td>
<td>
<input type="checkbox" class="pull-right mail-contact-check" email="${email}"/>

View File

@ -93,6 +93,12 @@
<td>Mixed</td>
<td></td>
</tr>
<tr>
<td>contact_*</td>
<td>STATIC</td>
<td>Mixed</td>
<td></td>
</tr>
<tr>
<td>unsubscribe_link</td>
<td>STATIC</td>