From 57c124a1f0d2dc50549e3eaf3c4b408b05359019 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 14 Jun 2018 15:39:35 +0200 Subject: [PATCH] beta delete + contact, invite type, email clone, email count --- js/saimod_mail.js | 28 +++++++++++++++++++++++ saimod_mail.php | 13 +++++++++-- sql/EMAIL_CLONE.php | 10 ++++++++ sql/EMAIL_IMAGE_CLONE.php | 10 ++++++++ sql/EMAIL_LISTS_SELECT_AND_SENT_COUNT.php | 16 +++++++++++++ sql/EMAIL_PLACEHOLDER_CLONE.php | 10 ++++++++ sql/mysql/system_api.sql | 1 + tpl/saimod_mail_email_send.tpl | 5 +++- tpl/saimod_mail_emails.tpl | 3 ++- 9 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 sql/EMAIL_CLONE.php create mode 100644 sql/EMAIL_IMAGE_CLONE.php create mode 100644 sql/EMAIL_LISTS_SELECT_AND_SENT_COUNT.php create mode 100644 sql/EMAIL_PLACEHOLDER_CLONE.php diff --git a/js/saimod_mail.js b/js/saimod_mail.js index db4e455..63f4a3f 100644 --- a/js/saimod_mail.js +++ b/js/saimod_mail.js @@ -268,6 +268,34 @@ function init_saimod_mail_emails() { }); } }); + + $('#btn-mail-email-clone').click(function(){ + var emails = []; + $('.mail-email-check:checked').each(function() { + emails.push($(this).attr('email')); + }); + $.ajax({ + async: true, + url: this.endpoint, + type: 'POST', + dataType: 'JSON', + data: { + sai_mod: '.SAI.saimod_mail', + action: 'clone_email', + data: emails + }, + success: function(data){ + if(data.status){ + system.reload(); + } else { + alert('Something happend - try again!'); + } + }, + error: function(){ + alert('Something happend - try again!'); + } + }); + }); } function init_saimod_mail_email() { diff --git a/saimod_mail.php b/saimod_mail.php index 9f8f4b8..ca83a51 100644 --- a/saimod_mail.php +++ b/saimod_mail.php @@ -136,7 +136,7 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{ while($row = $list_handle->next()){ \set_time_limit(30); self::send_mail($row['email'], $email_id, $list) ? 1 : 0; - \sleep(3); + \sleep(1); } return \SYSTEM\LOG\JsonResult::ok(); } @@ -372,7 +372,7 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{ $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(); + $res = \SQL\EMAIL_LISTS_SELECT_AND_SENT_COUNT::QQ(array($id)); while($row = $res->next()){ $row['disabled'] = $row['id'] == self::EMAIL_LIST_TEST ? '' : 'disabled'; $row['btn-color'] = $row['id'] == self::EMAIL_LIST_TEST ? 'success' : 'danger'; @@ -462,6 +462,15 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{ return \JsonResult::ok(); } + public static function sai_mod__SAI_saimod_mail_action_clone_email($data){ + foreach($data as $id){ + $new_id = \SQL\EMAIL_CLONE::QI(array($id),true); + \SQL\EMAIL_PLACEHOLDER_CLONE::QI(array($new_id,$id)); + \SQL\EMAIL_IMAGE_CLONE::QI(array($new_id,$id)); + } + return \JsonResult::ok(); + } + public static function sai_mod__SAI_saimod_mail_action_templates($type=0){ $vars = array(); $vars['active_text'] = $type == 0 ? 'active' : ''; diff --git a/sql/EMAIL_CLONE.php b/sql/EMAIL_CLONE.php new file mode 100644 index 0000000..3e4e165 --- /dev/null +++ b/sql/EMAIL_CLONE.php @@ -0,0 +1,10 @@ + - ${name} + + ${name}
+ ${count_sent}/${count_all} Sent + diff --git a/tpl/saimod_mail_emails.tpl b/tpl/saimod_mail_emails.tpl index d115772..3e82f8e 100644 --- a/tpl/saimod_mail_emails.tpl +++ b/tpl/saimod_mail_emails.tpl @@ -6,10 +6,11 @@ Name From Subject - System Lock + Lock UpdatedAt +