102 lines
4.9 KiB
PHP
102 lines
4.9 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
|
|
<?php init_head(); ?>
|
|
<div id="wrapper">
|
|
<div class="content">
|
|
<div class="row">
|
|
<div class="col-md-8 col-md-offset-2">
|
|
<div class="panel_s">
|
|
<div class="panel-body">
|
|
<h4 class="no-margin">
|
|
<?php echo $title; ?>
|
|
<a href="<?php echo admin_url('hubtel_sms'); ?>" class="btn btn-default pull-right">
|
|
<i class="fa fa-arrow-left"></i> <?php echo _l('back'); ?>
|
|
</a>
|
|
</h4>
|
|
<hr class="hr-panel-heading" />
|
|
|
|
<?php echo form_open(admin_url('hubtel_sms/template/' . (isset($template) ? $template->id : ''))); ?>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<label for="name" class="control-label"><?php echo _l('template_name'); ?></label>
|
|
<input type="text" class="form-control" id="name" name="name"
|
|
value="<?php echo (isset($template) ? $template->name : ''); ?>" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="template" class="control-label">
|
|
<?php echo _l('template_content'); ?>
|
|
<small class="pull-right">
|
|
<span id="character_count">0</span>/160 <?php echo _l('characters'); ?>
|
|
</small>
|
|
</label>
|
|
<textarea class="form-control" id="template" name="template"
|
|
rows="6" maxlength="160" required><?php echo (isset($template) ? $template->template : ''); ?></textarea>
|
|
</div>
|
|
|
|
<!-- Merge Fields -->
|
|
<div class="panel panel-info mtop20">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title"><?php echo _l('available_merge_fields'); ?></h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="row">
|
|
<?php foreach($available_merge_fields as $group => $fields) { ?>
|
|
<div class="col-md-6">
|
|
<p><strong><?php echo _l($group . '_fields'); ?></strong></p>
|
|
<?php foreach($fields as $key => $label) { ?>
|
|
<p class="merge-field" data-key="<?php echo $key; ?>">
|
|
<?php echo $key; ?>
|
|
</p>
|
|
<?php } ?>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<button type="submit" class="btn btn-info pull-right">
|
|
<?php echo _l('submit'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<?php echo form_close(); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php init_tail(); ?>
|
|
|
|
<script>
|
|
$(function() {
|
|
// Character counter
|
|
$('#template').on('keyup', function() {
|
|
var chars = $(this).val().length;
|
|
$('#character_count').text(chars);
|
|
}).trigger('keyup');
|
|
|
|
// Merge fields click handler
|
|
$('.merge-field').on('click', function() {
|
|
var template = $('#template');
|
|
var field = $(this).data('key');
|
|
var cursorPos = template.prop('selectionStart');
|
|
var content = template.val();
|
|
|
|
// Insert merge field at cursor position
|
|
var newContent = content.slice(0, cursorPos) + field + content.slice(cursorPos);
|
|
template.val(newContent);
|
|
|
|
// Update character count
|
|
template.trigger('keyup');
|
|
|
|
// Set focus back to textarea
|
|
template.focus();
|
|
});
|
|
});
|
|
</script>
|