File: //var/www/html/inventory.breadsecret.com/view/template/form.php
<?php
include("view/layout/meta.php");
include("view/layout/head.php");
?>
<main class="content">
<div class="funcBar d-flex text-white">
<span class="funcTitle mr-auto"><?=L('menu.template');?> - <?=$this->obj['subject'];?></span>
<div class="funcMenu mx-3 py-2">
</div>
</div>
<div class="container"><div class="row">
<?php
$options = [''=>L('template.selectATemplate')];
foreach ($stmTemp as $opt) { $options[$opt['name']] = $opt['name'].' - '.$opt['subject']; }
$this->select(L('template.name'), 'name', 'templateName', $options);
?></div>
</div></div>
<?php if (!is_null($this->obj)) { ?>
<form id="form-template" class="container my-3">
<input type="hidden" name="id" value="<?=$this->obj['id']; ?>">
<input type="hidden" name="template" value="<?=$this->obj['name']; ?>">
<?php
$this->input(L('template.emailSubject'), 'subject', 'templateSubject', 'text');
if ($stmVar->rowCount()) {
?>
<h5><?=L('template.emailVariables');?></h5>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="p-0">
<th scope="col" class="p-0"><?=L('template.emailVariable');?></th>
<th scope="col" class="p-0"><?=L('template.emailVarDesc');?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($stmVar as $listObj) {
?>
<tr class="p-0">
<td scope="row" class="p-0">{{<?=$listObj['name'];?>}}</td>
<td class="p-0"><?=$listObj['description'];?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
}
?>
<h5><?=L('template.emailContent');?></h5>
<?=L('modifyTime');?>: <span class="text-muted"><?=Utility\WebSystem::displayDate($this->obj['modifyDate']);?></span>
<textarea id="templateContent" name="content"><?=$this->obj['content'];?></textarea>
<button type="submit" class="btn btn-primary my-3"><?=L('Save');?></button>
</form>
<?php } ?>
</main>
<?php
include("view/layout/foot.php");
include("view/layout/js.php");
?>
<script>
$('#templateName').change(function (e) { window.location = "<?=Utility\WebSystem::path(Routing\Route::getRouteByName('page.templateEdit')->path(['template'=>'"+this.value']), false, false);?>; });
tinymce.init({ selector: '#templateContent', height: 500, menubar: false, plugins: 'lists code link fullscreen table',
toolbar: 'undo redo | fontselect fontsizeselect | styleselect | bold italic | forecolor backcolor | numlist bullist | alignleft aligncenter alignright alignjustify outdent indent | table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | link code fullscreen',
relative_urls : false,
remove_script_host : false,
});
$('#form-template').submit(function (e) {
tinymce.triggerSave();
var data = new FormData(this);
ajaxFunc.apiCall("POST", "template/save", data, "multipart/form-data", ajaxFunc.responseHandle);
e.preventDefault();
});
</script>
<?php
include("view/layout/endpage.php");
?>