templates_index.php
91 lines
| 1 | <?php |
| 2 | /* @var $templates array */ |
| 3 | /* @var $grouped_templates array */ |
| 4 | /* @var $heading string */ |
| 5 | /* @var $action_type string */ |
| 6 | /* @var $action_id string */ |
| 7 | /* @var $process_id string */ |
| 8 | /* @var $selected_template_id string */ |
| 9 | |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; // Exit if accessed directly |
| 13 | } |
| 14 | |
| 15 | |
| 16 | ?> |
| 17 | <div class="os-form-header"> |
| 18 | <h2><?php echo esc_html($heading); ?></h2> |
| 19 | <a href="#" class="latepoint-side-panel-close latepoint-side-panel-close-trigger"><i class="latepoint-icon latepoint-icon-x"></i></a> |
| 20 | </div> |
| 21 | <div class="os-form-content no-padding no-overflow"> |
| 22 | <div class="os-templates-wrapper"> |
| 23 | <div class="os-templates-list"> |
| 24 | <div class="template-type-selector-wrapper"> |
| 25 | <div class="template-type-selector" data-user-type="agent"><?php esc_html_e('For Agents', 'latepoint'); ?></div> |
| 26 | <div class="os-template-items hidden" data-user-type="agent"> |
| 27 | <?php |
| 28 | foreach($grouped_templates['agent'] as $template){ |
| 29 | echo '<div data-user-type="'.esc_attr($template['to_user_type']).'" class="os-template-item" data-id="'.esc_attr($template['id']).'">'; |
| 30 | echo '<div class="os-template-name">'.esc_html($template['name']).'</div>'; |
| 31 | echo '</div>'; |
| 32 | } ?> |
| 33 | </div> |
| 34 | <div class="template-type-selector" data-user-type="customer"><?php esc_html_e('For Customers', 'latepoint'); ?></div> |
| 35 | <div class="os-template-items hidden" data-user-type="customer"> |
| 36 | <?php |
| 37 | foreach($grouped_templates['customer'] as $template){ |
| 38 | echo '<div data-user-type="'.esc_attr($template['to_user_type']).'" class="os-template-item" data-id="'.esc_attr($template['id']).'">'; |
| 39 | echo '<div class="os-template-name">'.esc_html($template['name']).'</div>'; |
| 40 | echo '</div>'; |
| 41 | } ?> |
| 42 | </div> |
| 43 | </div> |
| 44 | </div> |
| 45 | <div class="os-template-previews"> |
| 46 | <div class="os-no-template-selected-message"> |
| 47 | <i class="latepoint-icon latepoint-icon-browser"></i> |
| 48 | <div><?php esc_html_e('Please select a template from the list on the left to generate a preview.', 'latepoint'); ?></div> |
| 49 | </div> |
| 50 | <?php |
| 51 | foreach($templates as $template) { |
| 52 | echo '<div class="os-template-preview type-'.esc_attr($action_type).'" data-id="'.esc_attr($template['id']).'" style="'.($template['id'] == $selected_template_id ? '' : 'display: none;').'">'; |
| 53 | switch($action_type){ |
| 54 | case 'send_email': |
| 55 | echo '<div class="os-template-preview-headings">'; |
| 56 | echo '<div class="os-template-preview-subject"><span class="os-label">'.esc_html__('Subject: ', 'latepoint').'</span><span class="os-value">'.$template['subject'].'</span></div>'; |
| 57 | echo '<div class="os-template-preview-to"><span class="os-label">'.esc_html__('To:', 'latepoint').'</span><span class="os-value">'.OsReplacerHelper::stylize_vars(esc_html($template['to_email'])).'</span></div>'; |
| 58 | echo '</div>'; |
| 59 | echo '<div class="os-template-preview-content">'.OsReplacerHelper::stylize_vars($template['content']).'</div>'; |
| 60 | break; |
| 61 | case 'send_sms': |
| 62 | echo '<div class="os-template-preview-content-wrapper">'; |
| 63 | echo '<div class="os-template-preview-to"><span class="os-label">'.esc_html__('To:', 'latepoint').'</span><span class="os-value">'.esc_html($template['to_phone']).'</span></div>'; |
| 64 | echo '<div class="os-template-preview-content">'.esc_html($template['content']).'</div>'; |
| 65 | echo '</div>'; |
| 66 | break; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Executed after each notification template preview |
| 71 | * |
| 72 | * @since 4.7.0 |
| 73 | * @hook latepoint_after_notification_template_preview |
| 74 | * |
| 75 | * @param {string} $action_type Type of action being previewed |
| 76 | * @param {array} $template Array of template information being previewed |
| 77 | * @param {string} $selected_template_id ID of selected template for which preview is to be shown |
| 78 | */ |
| 79 | do_action('latepoint_after_notification_template_preview', $action_type, $template, $selected_template_id); |
| 80 | echo '</div>'; |
| 81 | } |
| 82 | ?> |
| 83 | <div class="os-template-use-button-wrapper hidden"> |
| 84 | <button type="button" class="latepoint-btn latepoint-btn-primary latepoint-btn-lg latepoint-btn-block latepoint-select-template-btn" data-action-type="<?php echo esc_attr($action_type); ?>" data-process-id="<?php echo esc_attr($process_id); ?>" data-action-id="<?php echo esc_attr($action_id); ?>" data-route="<?php echo esc_attr(OsRouterHelper::build_route_name('processes', 'load_action_settings'));?>"> |
| 85 | <span><?php esc_html_e('Use this template', 'latepoint'); ?></span> |
| 86 | <i class="latepoint-icon latepoint-icon-arrow-right"></i> |
| 87 | </button> |
| 88 | </div> |
| 89 | </div> |
| 90 | </div> |
| 91 | </div> |