Voucher Template Full Custom

This commit is contained in:
Ibnu Maksum 2023-10-18 17:24:00 +07:00
parent b9537d4a4b
commit d59f696fde
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
3 changed files with 73 additions and 67 deletions

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -49,9 +50,9 @@ switch ($action) {
} }
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']); $p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']); $c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
if($plan['routers'] == 'radius'){ if ($plan['routers'] == 'radius') {
Radius::customerAddPlan($c, $p, $plan['expiration'].' '.$plan['time']); Radius::customerAddPlan($c, $p, $plan['expiration'] . ' ' . $plan['time']);
}else{ } else {
if ($plan['type'] == 'Hotspot') { if ($plan['type'] == 'Hotspot') {
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} else if ($plan['type'] == 'PPPOE') { } else if ($plan['type'] == 'PPPOE') {
@ -261,10 +262,16 @@ switch ($action) {
$planid = _post('planid'); $planid = _post('planid');
$pagebreak = _post('pagebreak'); $pagebreak = _post('pagebreak');
$limit = _post('limit'); $limit = _post('limit');
$vpl = _post('vpl');
if ($pagebreak < 1) $pagebreak = 6; if(empty($vpl)){
$vpl = 3;
}
if ($pagebreak < 1) $pagebreak = 12;
if ($limit < 1) $limit = $pagebreak * 2; if ($limit < 1) $limit = $pagebreak * 2;
if(empty($from_id)){
$from_id = 0;
}
if ($from_id > 0 && $planid > 0) { if ($from_id > 0 && $planid > 0) {
$v = ORM::for_table('tbl_plans') $v = ORM::for_table('tbl_plans')
@ -315,9 +322,12 @@ switch ($action) {
->where('tbl_voucher.status', '0') ->where('tbl_voucher.status', '0')
->count(); ->count();
} }
$template = file_get_contents("pages/Voucher.html");
$template = str_replace('[[company_name]]', $config['CompanyName'], $template);
$ui->assign('_title', $_L['Voucher_Hotspot']); $ui->assign('_title', $_L['Voucher_Hotspot']);
$ui->assign('from_id', $from_id); $ui->assign('from_id', $from_id);
$ui->assign('vpl', $vpl);
$ui->assign('pagebreak', $pagebreak); $ui->assign('pagebreak', $pagebreak);
$plans = ORM::for_table('tbl_plans')->find_many(); $plans = ORM::for_table('tbl_plans')->find_many();
@ -325,7 +335,17 @@ switch ($action) {
$ui->assign('limit', $limit); $ui->assign('limit', $limit);
$ui->assign('planid', $planid); $ui->assign('planid', $planid);
$ui->assign('v', $v); $voucher = [];
foreach ($v as $vs) {
$temp = $template;
$temp = str_replace('[[qrcode]]', '<img src="qrcode/?data=' . $vs['code'] . '">', $temp);
$temp = str_replace('[[price]]', Lang::moneyFormat($vs['price']), $temp);
$temp = str_replace('[[voucher_code]]', $vs['code'], $temp);
$temp = str_replace('[[plan]]', $vs['name_plan'], $temp);
$voucher[] = $temp;
}
$ui->assign('voucher',$voucher);
$ui->assign('vc', $vc); $ui->assign('vc', $vc);
//for counting pagebreak //for counting pagebreak
@ -354,7 +374,11 @@ switch ($action) {
run_hook('create_voucher'); #HOOK run_hook('create_voucher'); #HOOK
for ($i = 0; $i < $numbervoucher; $i++) { for ($i = 0; $i < $numbervoucher; $i++) {
$code = strtoupper(substr(md5(time() . rand(10000, 99999)), 0, $lengthcode)); $code = strtoupper(substr(md5(time() . rand(10000, 99999)), 0, $lengthcode));
//TODO: IMPLEMENT Voucher Generator if ($config['voucher_format'] == 'low') {
$code = strtolower($code);
} else if ($config['voucher_format'] == 'rand') {
$code = Lang::randomUpLowCase($code);
}
$d = ORM::for_table('tbl_voucher')->create(); $d = ORM::for_table('tbl_voucher')->create();
$d->type = $type; $d->type = $type;
$d->routers = $server; $d->routers = $server;

View file

@ -3,39 +3,53 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class="panel mb20 panel-primary panel-hovered"> <div class="panel mb20 panel-primary panel-hovered">
<div class="panel-heading">{$pageHeader}</div> <div class="panel-heading">{$pageHeader}</div>
<div id="myNicPanel" style="width: 100%;"></div> <div id="myNicPanel" style="width: 100%;"></div>
<div id="panel-edit" class="panel-body">{$htmls}</div> <div id="panel-edit" class="panel-body">{$htmls}</div>
{if $writeable} {if $writeable}
<div class="panel-footer"> <div class="panel-footer">
<a href="javascript:saveIt()" class="btn btn-primary btn-block">SAVE</a> <a href="javascript:saveIt()" class="btn btn-primary btn-block">SAVE</a>
<br> <br>
<p class="help-block">{$_L['Info_Page']}</p> <p class="help-block">{$_L['Info_Page']}</p>
<input type="text" class="form-control" onclick="this.select()" readonly value="{$app_url}/pages/{$PageFile}.html"> <input type="text" class="form-control" onclick="this.select()" readonly
value="{$app_url}/pages/{$PageFile}.html">
</div> </div>
{else} {else}
<div class="panel-footer"> <div class="panel-footer">
{$_L['Failed_Save_Page']} {$_L['Failed_Save_Page']}
</div> </div>
{/if} {/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>
</p>
</div>
{/if}
</div> </div>
</div> </div>
</div> </div>
<form id="formpages" class="hidden" method="post" role="form" action="{$_url}pages/{$PageFile}-post" > <form id="formpages" class="hidden" method="post" role="form" action="{$_url}pages/{$PageFile}-post">
<textarea name="html" id="html"></textarea> <textarea name="html" id="html"></textarea>
</form> </form>
<script src="ui/ui/scripts/nicEdit.js"></script> <script src="ui/ui/scripts/nicEdit.js"></script>
{literal}
<script type="text/javascript"> <script type="text/javascript">
var myNicEditor var myNicEditor
bkLib.onDomLoaded(function() { bkLib.onDomLoaded(function() {
myNicEditor = new nicEditor(); myNicEditor = new nicEditor({fullPanel : true});
myNicEditor.setPanel('myNicPanel'); myNicEditor.setPanel('myNicPanel');
myNicEditor.addInstance('panel-edit'); myNicEditor.addInstance('panel-edit');
}); });
function saveIt(){
function saveIt() {
//alert(document.getElementById('panel-edit').innerHTML); //alert(document.getElementById('panel-edit').innerHTML);
document.getElementById('html').value = nicEditors.findEditor('panel-edit').getContent() document.getElementById('html').value = nicEditors.findEditor('panel-edit').getContent()
document.getElementById('formpages').submit(); document.getElementById('formpages').submit();
} }
</script> </script>
{/literal}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View file

@ -63,11 +63,13 @@
<form method="post" action="{$_url}prepaid/print-voucher/" class="no-print"> <form method="post" action="{$_url}prepaid/print-voucher/" class="no-print">
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="btn btn-default btn-sm"> <table width="100%" border="0" cellspacing="0" cellpadding="1" class="btn btn-default btn-sm">
<tr> <tr>
<td>ID &gt; <input type="text" name="from_id" style="width:40px" value="{$from_id}"> limit <input <td>From ID &gt; <input type="text" name="from_id" style="width:40px" value="{$from_id}"> limit
type="text" name="limit" style="width:40px" value="{$limit}"></td> <input type="text" name="limit" style="width:40px" value="{$limit}"></td>
<td>Voucher PerLine <input type="text" style="width:40px" name="vpl" value="{$vpl}">
vouchers</td>
<td>PageBreak after <input type="text" style="width:40px" name="pagebreak" value="{$pagebreak}"> <td>PageBreak after <input type="text" style="width:40px" name="pagebreak" value="{$pagebreak}">
vouchers</td> vouchers</td>
<td>Plans <select id="plan_id" name="planid" style="width:150px"> <td>Plans <select id="plan_id" name="planid" style="width:50px">
<option value="0">--all--</option> <option value="0">--all--</option>
{foreach $plans as $plan} {foreach $plans as $plan}
<option value="{$plan['id']}" {if $plan['id']==$planid}selected{/if}>{$plan['name_plan']} <option value="{$plan['id']}" {if $plan['id']==$planid}selected{/if}>{$plan['name_plan']}
@ -78,65 +80,31 @@
</tr> </tr>
</table> </table>
<hr> <hr>
<center><button type="button" id="actprint" <center><button type="button" onclick="window.print()"
class="btn btn-default btn-sm no-print">{$_L['Click_Here_to_Print']}</button><br> class="btn btn-default btn-sm no-print">{$_L['Click_Here_to_Print']}</button><br>
{$_L['Print_Info']}<br> {$_L['Print_Info']}<br>
show {$v|@count} vouchers from {$vc} vouchers<br> show {$v|@count} vouchers from {$vc} vouchers<br>
from ID {$v[0]['id']} limit {$limit} vouchers from ID {$v[0]['id']} limit {$limit} vouchers
</center> </center>
</form> </form>
<div id="printable"> <div id="printable" align="center">
<hr> <hr>
{foreach $v as $vs} {$n = 1}
{foreach $voucher as $vs}
{$jml = $jml + 1} {$jml = $jml + 1}
<table width="100%" height="200" border="0" cellspacing="0" cellpadding="1" style="margin-bottom:5px"> {if $n == 1}
<tbody> <table>
<tr> <tr>
<td align="center" valign="middle"></td> {/if}
</tr> <td>{$vs}</td>
<tr> {if $n == $vpl}
<td align="center" valign="top"> </table>
<table width="100%" border="0" cellspacing="0" cellpadding="2"> {$n = 1}
<tr> {else}
<td width="50%" valign="middle" style="padding-right:10px"> {$n = $n + 1}
<center><strong style="font-size:38px">{$_L['Voucher_Hotspot']}</strong><span {/if}
class="no-print"> ID {$vs['id']}</span></center>
<table width="100%" border="1" cellspacing="0" cellpadding="1"
bordercolor="#757575">
<tbody>
<tr>
<td rowspan="5" width="1"><img src="qrcode/?data={$vs['code']}">
</td>
</tr>
<tr>
<td valign="middle" align="center" style="font-size:25px">
{Lang::moneyFormat($vs['price'])}</td>
</tr>
<tr>
<td valign="middle" align="center" style="font-size:20px">
{$_L['Code_Voucher']}</td>
</tr>
<tr>
<td valign="middle" align="center" style="font-size:25px">
{$vs['code']}</td>
</tr>
<tr>
<td valign="middle" align="center" style="font-size:15px">
{$vs['name_plan']}</td>
</tr>
</tbody>
</table>
</td>
<td valign="top" style="padding-left:10px">
{include file="$_path/../pages/Voucher.html"}
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<hr>
{if $jml == $pagebreak} {if $jml == $pagebreak}
{$jml = 0} {$jml = 0}
<!-- pageBreak --> <!-- pageBreak -->