diff --git a/app/email_templates/app_languages.php b/app/email_templates/app_languages.php index 4126ad51c5..edf25b51cd 100644 --- a/app/email_templates/app_languages.php +++ b/app/email_templates/app_languages.php @@ -41,7 +41,7 @@ $text['title-email_template']['sv-se'] = ''; $text['title-email_template']['uk-ua'] = ''; - $text['title_description-email_template']['en-us'] = ''; + $text['title_description-email_template']['en-us'] = 'Define and manage dynamic templates used for system generated outbound emails.'; $text['title_description-email_template']['ar-eg'] = ''; $text['title_description-email_template']['de-at'] = ''; $text['title_description-email_template']['de-ch'] = ''; diff --git a/app/email_templates/email_templates.php b/app/email_templates/email_templates.php index 0e10aa5a28..fde317d9dd 100644 --- a/app/email_templates/email_templates.php +++ b/app/email_templates/email_templates.php @@ -24,9 +24,10 @@ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; + require_once "resources/paging.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('email_template_view')) { //access granted } @@ -39,26 +40,45 @@ $language = new text; $text = $language->get(); -//get the action - if (is_array($_POST["email_templates"])) { - $email_templates = $_POST["email_templates"]; - foreach($email_templates as $row) { - if ($row['action'] == 'delete') { - $action = 'delete'; - break; - } +//get posted data + if (is_array($_POST['email_templates'])) { + $action = $_POST['action']; + $search = $_POST['search']; + $email_templates = $_POST['email_templates']; + } + +//copy the email_templates + if (permission_exists('email_template_add')) { + if ($action == 'copy' && is_array($email_templates) && @sizeof($email_templates) != 0) { + //copy + $obj = new email_templates; + $obj->copy($email_templates); + //redirect + header('Location: email_templates.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; + } + } + +//toggle the email_templates + if (permission_exists('email_template_edit')) { + if ($action == 'toggle' && is_array($email_templates) && @sizeof($email_templates) != 0) { + //toggle + $obj = new email_templates; + $obj->toggle($email_templates); + //redirect + header('Location: email_templates.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; } } //delete the email_templates if (permission_exists('email_template_delete')) { - if ($action == "delete") { - //download + if ($action == 'delete' && is_array($email_templates) && @sizeof($email_templates) != 0) { + //delete $obj = new email_templates; $obj->delete($email_templates); //redirect - message::add($text['message-delete']); - header('Location: '.$_SERVER['PHP_SELF']); + header('Location: email_templates.php'.($search != '' ? '?search='.urlencode($search) : null)); exit; } } @@ -74,8 +94,8 @@ $sql_search .= " lower(template_language) like :search "; $sql_search .= " or lower(template_category) like :search "; $sql_search .= " or lower(template_subcategory) like :search "; - //$sql_search .= " or lower(template_subject) like :search "; - //$sql_search .= " or lower(template_body) like :search "; + $sql_search .= " or lower(template_subject) like :search "; + $sql_search .= " or lower(template_body) like :search "; $sql_search .= " or lower(template_type) like :search "; $sql_search .= " or lower(template_enabled) like :search "; $sql_search .= " or lower(template_description) like :search "; @@ -83,10 +103,6 @@ $parameters['search'] = '%'.$search.'%'; } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - //prepare to page the results $sql = "select count(*) from v_email_templates "; if ($_GET['show'] == "all" && permission_exists('email_template_all')) { @@ -106,156 +122,164 @@ //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; + $param = "&search=".$search; $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list $sql = str_replace('count(*)', '*', $sql); - $sql .= order_by($order_by, $order, 'template_language', 'asc'); + if ($order_by) { + $sql .= order_by($order_by, $order); + } + else { + $sql .= "order by domain_uuid, template_language asc, template_category asc, template_subcategory asc, template_type asc, template_description asc "; + } $sql .= limit_offset($rows_per_page, $offset); $database = new database; $result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); -//define the checkbox_toggle function - echo "\n"; +//additional includes + require_once "resources/header.php"; //show the content - echo "
| ".$text['title-email_templates']." | \n"; - echo " \n"; - echo "
| \n"; - echo " \n"; - echo " | \n"; + echo $text['title_description-email_template']."\n"; + echo "||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| \n"; + echo " \n"; + echo " | \n"; + } if ($_GET['show'] == "all" && permission_exists('email_template_all')) { - echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, '', '', $param); + echo "".$text['label-domain']." | \n"; + //echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param); } - echo th_order_by('template_language', $text['label-template_language'], $order_by, $order); - echo th_order_by('template_category', $text['label-template_category'], $order_by, $order); - echo th_order_by('template_subcategory', $text['label-template_subcategory'], $order_by, $order); - //echo th_order_by('domain_uuid', $text['label-domain_uuid'], $order_by, $order); - echo th_order_by('template_type', $text['label-template_type'], $order_by, $order); - echo th_order_by('template_enabled', $text['label-template_enabled'], $order_by, $order); - echo th_order_by('template_description', $text['label-template_description'], $order_by, $order); - echo ""; - if (permission_exists('email_template_add')) { - echo " $v_link_label_add"; + echo th_order_by('template_language', $text['label-template_language'], $order_by, $order, null, "class='shrink'", $param); + echo th_order_by('template_category', $text['label-template_category'], $order_by, $order, null, "class='shrink' style='min-width: 15%'", $param); + echo th_order_by('template_subcategory', $text['label-template_subcategory'], $order_by, $order, null, "class='shrink' style='min-width: 15%'", $param); + echo th_order_by('template_subject', $text['label-template_subject'], $order_by, $order, null, "class='hide-sm-dn' style='min-width: 20%'", $param); + echo th_order_by('template_type', $text['label-template_type'], $order_by, $order, null, "class='shrink'", $param); + echo th_order_by('template_enabled', $text['label-template_enabled'], $order_by, $order, null, "class='center' style='min-width: 15%'", $param); + echo th_order_by('template_description', $text['label-template_description'], $order_by, $order, null, "class='hide-sm-dn'", $param); + if (permission_exists('email_template_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " | \n"; } - else { - echo " \n"; - } - echo " \n"; - echo " | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| \n"; + echo " \n"; + echo " \n"; + echo " | \n"; } - echo "|||||||||||||||||||
| \n"; - echo " \n"; - echo " \n"; - echo " | \n"; if ($_GET['show'] == "all" && permission_exists('email_template_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { - $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; + echo ""; + if (is_uuid($row['domain_uuid'])) { + echo escape($_SESSION['domains'][$row['domain_uuid']]['domain_name']); } else { - $domain = $text['label-global']; + echo $text['label-global']; } - echo " | ".escape($domain)." | \n"; + echo "\n"; } - echo "".escape($row['template_language'])." | \n"; - echo "".escape($row['template_category'])." | \n"; - echo "".escape($row['template_subcategory'])." | \n"; - //echo "".escape($row['template_subject'])." | \n"; - //echo "".escape($row['template_body'])." | \n"; - //echo "".escape($row['domain_uuid'])." | \n"; - echo "".escape($row['template_type'])." | \n"; - echo "".escape($row['template_enabled'])." | \n"; - echo "".escape($row['template_description'])." | \n"; - echo ""; + echo " | ".escape($row['template_language'])." | \n"; + echo "".escape($row['template_category'])." | \n"; + echo "".escape($row['template_subcategory'])." | \n"; + echo " \n"; + echo "".escape($row['template_type'])." | \n"; + if (permission_exists('email_template_edit')) { + echo ""; + echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['template_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]); + } + else { + echo " | "; + echo $text['label-'.$row['template_enabled']]; + } + echo " | \n"; + echo " \n"; + if (permission_exists('email_template_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo ""; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo " | \n"; + } echo "
| \n"; - echo " | $paging_controls | \n"; - echo ""; - if (permission_exists('email_template_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo " | \n"; - echo "