mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2024-11-10 09:12:51 +08:00
Voucher Template List, you can save multiple template for voucher
This commit is contained in:
parent
eb5d1f5819
commit
1b56680a6d
5 changed files with 161 additions and 35 deletions
27
pages_template/vouchers/Default.html
Normal file
27
pages_template/vouchers/Default.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tbody><tr>
|
||||
<td valign="middle">
|
||||
<center><strong style="font-size:38px">[[company_name]]</strong></center>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#757575">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="4" width="1">[[qrcode]]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:25px">
|
||||
[[price]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:20px">
|
||||
[[voucher_code]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:15px">
|
||||
[[plan]] - [[counter]]<br></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
24
pages_template/vouchers/Logo Header Center.html
Normal file
24
pages_template/vouchers/Logo Header Center.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tbody><tr>
|
||||
<td valign="middle">
|
||||
<center><img src="system/uploads/logo.png"></center>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#757575">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:25px">
|
||||
[[qrcode]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:20px">
|
||||
[[voucher_code]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:15px">
|
||||
[[plan]] [[price]]<br></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<center>[[company_name]]</center>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
28
pages_template/vouchers/Logo Header.html
Normal file
28
pages_template/vouchers/Logo Header.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tbody><tr>
|
||||
<td valign="middle">
|
||||
<center><img src="system/uploads/logo.png"></center>
|
||||
<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#757575">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="4" width="1">[[qrcode]]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:25px">
|
||||
[[price]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:20px">
|
||||
[[voucher_code]]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" align="center" style="font-size:15px">
|
||||
[[plan]] - [[counter]]<br></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<center>[[company_name]]</center>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
|
@ -31,6 +31,7 @@ if(strpos($action,"-reset")!==false){
|
|||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
}
|
||||
$path = "pages/".str_replace(".","",$action).".html";
|
||||
$ui->assign("action", $action);
|
||||
//echo $path;
|
||||
run_hook('view_edit_pages'); #HOOK
|
||||
if(!file_exists($path)){
|
||||
|
@ -44,6 +45,15 @@ if(strpos($action,"-reset")!==false){
|
|||
}
|
||||
}
|
||||
if(file_exists($path)){
|
||||
if($action=='Voucher'){
|
||||
if(!file_exists("pages/vouchers/")){
|
||||
mkdir("pages/vouchers/");
|
||||
if(file_exists("pages_template/vouchers/")){
|
||||
File::copyFolder("pages_template/vouchers/", "pages/vouchers/");
|
||||
}
|
||||
}
|
||||
$ui->assign("vouchers", scandir("pages/vouchers/"));
|
||||
}
|
||||
$html = file_get_contents($path);
|
||||
$ui->assign("htmls",str_replace(["<div","</div>"],"",$html));
|
||||
$ui->assign("writeable",is_writable($path));
|
||||
|
@ -61,7 +71,12 @@ if(strpos($action,"-reset")!==false){
|
|||
if(file_exists($path)){
|
||||
$html = _post("html");
|
||||
run_hook('save_pages'); #HOOK
|
||||
if(file_put_contents($path, str_replace(["<div","</div>"],"",$html))){
|
||||
if(file_put_contents($path, $html)){
|
||||
if(_post('template_save')=='yes'){
|
||||
if(!empty(_post('template_name'))){
|
||||
file_put_contents("pages/vouchers/"._post('template_name').'.html', $html);
|
||||
}
|
||||
}
|
||||
r2(U . 'pages/'.$action, 's', Lang::T("Saving page success"));
|
||||
}else{
|
||||
r2(U . 'pages/'.$action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>"));
|
||||
|
|
|
@ -1,50 +1,82 @@
|
|||
{include file="sections/header.tpl"}
|
||||
|
||||
<form id="formpages" method="post" role="form" action="{$_url}pages/{$PageFile}-post">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="panel mb20 panel-primary panel-hovered">
|
||||
<div class="panel-heading">
|
||||
<div class="btn-group pull-right">
|
||||
<a class="btn btn-danger btn-xs" title="Reset File" href="{$_url}pages/{$PageFile}-reset" onclick="return confirm('Reset File?')"><span
|
||||
class="glyphicon glyphicon-refresh" aria-hidden="true"></span></a>
|
||||
<div class="row">
|
||||
<div class="{if $action=='Voucher'}col-md-8{else}col-md-12{/if}">
|
||||
<div class="panel mb20 panel-primary panel-hovered">
|
||||
<div class="panel-heading">
|
||||
{if $action!='Voucher'}
|
||||
<div class="btn-group pull-right">
|
||||
<a class="btn btn-danger btn-xs" title="Reset File" href="{$_url}pages/{$PageFile}-reset"
|
||||
onclick="return confirm('Reset File?')"><span class="glyphicon glyphicon-refresh"
|
||||
aria-hidden="true"></span></a>
|
||||
</div>
|
||||
{/if}
|
||||
{$pageHeader}
|
||||
</div>
|
||||
{$pageHeader}
|
||||
<textarea name="html" id="summernote">{$htmls}</textarea>
|
||||
{if $writeable}
|
||||
<div class="panel-footer">
|
||||
{if $action=='Voucher'}
|
||||
<label>
|
||||
<input type="checkbox" name="template_save" value="yes"> {Lang::T('Save as template')}
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="basic-addon3">{Lang::T('Template Name')}</span>
|
||||
<input type="text" class="form-control" id="template_name" name="template_name">
|
||||
</div>
|
||||
<br>
|
||||
{/if}
|
||||
<button type="submit" class="btn btn-primary btn-block">SAVE</button>
|
||||
<br>
|
||||
<p class="help-block">{Lang::T("Sometimes you need to refresh 3 times until content change")}</p>
|
||||
<input type="text" class="form-control" onclick="this.select()" readonly
|
||||
value="{$app_url}/pages/{$PageFile}.html">
|
||||
</div>
|
||||
{else}
|
||||
<div class="panel-footer">
|
||||
{Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>")}
|
||||
</div>
|
||||
{/if}
|
||||
{if $PageFile=='Voucher'}
|
||||
<div class="panel-footer">
|
||||
<p class="help-block">
|
||||
<b>[[company_name]]</b> Your Company Name at Settings.<br>
|
||||
<b>[[price]]</b> Plan Price.<br>
|
||||
<b>[[voucher_code]]</b> Voucher Code.<br>
|
||||
<b>[[plan]]</b> Voucher Plan.<br>
|
||||
<b>[[counter]]</b> Counter.<br>
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<textarea name="html" id="summernote">{$htmls}</textarea>
|
||||
{if $writeable}
|
||||
<div class="panel-footer">
|
||||
<a href="javascript:saveIt()" class="btn btn-primary btn-block">SAVE</a>
|
||||
<br>
|
||||
<p class="help-block">{Lang::T("Sometimes you need to refresh 3 times until content change")}</p>
|
||||
<input type="text" class="form-control" onclick="this.select()" readonly
|
||||
value="{$app_url}/pages/{$PageFile}.html">
|
||||
</div>
|
||||
{else}
|
||||
<div class="panel-footer">
|
||||
{Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>")}
|
||||
</div>
|
||||
{/if}
|
||||
{if $PageFile=='Voucher'}
|
||||
<div class="panel-footer">
|
||||
<p class="help-block">
|
||||
<b>[[company_name]]</b> Your Company Name at Settings.<br>
|
||||
<b>[[price]]</b> Plan Price.<br>
|
||||
<b>[[voucher_code]]</b> Voucher Code.<br>
|
||||
<b>[[plan]]</b> Voucher Plan.<br>
|
||||
<b>[[counter]]</b> Counter.<br>
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{if $action=='Voucher'}
|
||||
<div class="col-md-4">
|
||||
{foreach $vouchers as $v}
|
||||
{if is_file("pages/vouchers/$v")}
|
||||
<div class="panel mb20 panel-primary panel-hovered" style="cursor: pointer;" onclick="selectTemplate(this)">
|
||||
<div class="panel-heading">{str_replace(".html", '', $v)}</div>
|
||||
<div class="panel-body">{include file="pages/vouchers/$v"}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
$('#summernote').summernote();
|
||||
});
|
||||
|
||||
function selectTemplate(f) {
|
||||
let children = f.children;
|
||||
$('#template_name').val(children[0].innerHTML)
|
||||
$('#summernote').summernote('code', children[1].innerHTML);
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
|
|
Loading…
Reference in a new issue