Skip to content
Snippets Groups Projects
Commit ef7a678f authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #5954 get mail template by entities

parent d8727f71
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,9 @@ require_once 'modules/sendmail/sendmail_tables.php'; ...@@ -42,7 +42,9 @@ require_once 'modules/sendmail/sendmail_tables.php';
require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR
. "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php";
require_once 'modules/sendmail/class/class_email_signatures.php'; require_once 'modules/sendmail/class/class_email_signatures.php';
require_once 'core/Models/DatabaseModel.php';
require_once 'core/Models/UserModel.php';
$core_tools = new core_tools(); $core_tools = new core_tools();
$request = new request(); $request = new request();
$sec = new security(); $sec = new security();
...@@ -101,6 +103,19 @@ $core_tools->load_html(); ...@@ -101,6 +103,19 @@ $core_tools->load_html();
$core_tools->load_header('', true, false); $core_tools->load_header('', true, false);
?><body><?php ?><body><?php
$core_tools->load_js(); $core_tools->load_js();
$aUserEntities = \Core\Models\UserModel::getEntitiesById(['userId' => $_SESSION['user']['UserId']]);
$userEntities = [];
foreach ($aUserEntities as $value) {
$userEntities[] = $value['entity_id'];
}
$userTemplates = \Core\Models\DatabaseModel::select(['select' => ['t.template_id', 't.template_label', 't.template_content'],
'table' => ['templates t', 'templates_association ta'],
'left_join' => ['t.template_id = ta.template_id'],
'where' => ['t.template_target = \'sendmail\'', '(ta.value_field is null or value_field in (?))'],
'data' => [$userEntities]
]);
//ADD //ADD
if ($mode == 'add') { if ($mode == 'add') {
$content .= '<div>'; $content .= '<div>';
...@@ -414,10 +429,9 @@ if ($mode == 'add') { ...@@ -414,10 +429,9 @@ if ($mode == 'add') {
. '&module=templates&page=templates_ajax_content_for_mails&id=' . $_REQUEST['identifier'] . '\');">'; . '&module=templates&page=templates_ajax_content_for_mails&id=' . $_REQUEST['identifier'] . '\');">';
$content .= '<option value="">' . _ADD_TEMPLATE_MAIL . '</option>'; $content .= '<option value="">' . _ADD_TEMPLATE_MAIL . '</option>';
$stmt = $db->query("select template_id, template_label, template_content from templates where template_target = 'sendmail'"); foreach ( $userTemplates as $result) {
while ( $result=$stmt->fetchObject()) { $content .= "<option value='" . $result['template_id'] ."'>" . $result['template_label'] . "</option>";
$content .= "<option value='" . $result->template_id ."'>" . $result->template_label . "</option>";
} }
$content .= '</select>'; $content .= '</select>';
$content .= '<label style="margin-left: 15%;padding-right:10px">' . 'Signature : ' . '</label>'; $content .= '<label style="margin-left: 15%;padding-right:10px">' . 'Signature : ' . '</label>';
...@@ -789,10 +803,9 @@ if ($mode == 'add') { ...@@ -789,10 +803,9 @@ if ($mode == 'add') {
. '&module=templates&page=templates_ajax_content_for_mails&id=' . $_REQUEST['identifier'] . '\');">'; . '&module=templates&page=templates_ajax_content_for_mails&id=' . $_REQUEST['identifier'] . '\');">';
$content .= '<option value="">' . _ADD_TEMPLATE_MAIL . '</option>'; $content .= '<option value="">' . _ADD_TEMPLATE_MAIL . '</option>';
$stmt = $db->query("select template_id, template_label, template_content from templates where template_target = 'sendmail'"); foreach ( $userTemplates as $result) {
while ( $result=$stmt->fetchObject()) { $content .= "<option value='" . $result['template_id'] ."'>" . $result['template_label'] . "</option>";
$content .= "<option value='" . $result->template_id ."'>" . $result->template_label . "</option>";
} }
$content .='</select>'; $content .='</select>';
$content .= '<label style="margin-left: 15%;padding-right:10px">' . 'Signature : ' . '</label>'; $content .= '<label style="margin-left: 15%;padding-right:10px">' . 'Signature : ' . '</label>';
...@@ -1184,4 +1197,4 @@ if ($mode == 'add') { ...@@ -1184,4 +1197,4 @@ if ($mode == 'add') {
} }
echo $content; echo $content;
?></body></html> ?></body></html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment