print 1 voucher will go to print or share

This commit is contained in:
Ibnu Maksum 2024-02-16 16:54:13 +07:00
parent 8e3e715c8c
commit e1272ec531
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
10 changed files with 180 additions and 50 deletions

View file

@ -156,11 +156,16 @@ switch ($action) {
case 'print':
$id = _post('id');
$d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one();
$ui->assign('in', $d);
$content = $_POST['content'];
if(!empty($content)){
$ui->assign('content', $content);
}else{
$id = _post('id');
$d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one();
$ui->assign('in', $d);
$ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
}
$ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
run_hook('print_invoice'); #HOOK
$ui->display('invoice-print.tpl');
break;
@ -282,7 +287,29 @@ switch ($action) {
->offset($paginator['startpoint'])
->limit($paginator['limit'])->find_many();
}
// extract admin
$admins = [];
foreach ($d as $k) {
if(!empty($k['generated_by'])){
$admins[] = $k['generated_by'];
}
}
if(count($admins) > 0){
$adms = ORM::for_table('tbl_users')->where_in('id', $admins)->find_many();
unset($admins);
foreach($adms as $adm){
$tipe = $adm['user_type'];
if($tipe == 'Sales'){
$tipe = ' [S]';
}else if($tipe == 'Agent'){
$tipe = ' [A]';
}else{
$tipe == '';
}
$admins[$adm['id']] = $adm['fullname'].$tipe;
}
}
$ui->assign('admins', $admins);
$ui->assign('d', $d);
$ui->assign('_code', $code);
$ui->assign('paginator', $paginator);
@ -466,6 +493,9 @@ switch ($action) {
$d->generated_by = $admin['id'];
$d->save();
}
if($numbervoucher == 1){
r2(U . 'prepaid/voucher-view/'.$d->id(), 's', Lang::T('Create Vouchers Successfully'));
}
r2(U . 'prepaid/voucher', 's', Lang::T('Create Vouchers Successfully'));
} else {
@ -473,6 +503,47 @@ switch ($action) {
}
break;
case 'voucher-view':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
$voucher = ORM::for_table('tbl_voucher')->find_one($id);
}else{
$voucher = ORM::for_table('tbl_voucher')->where('generated_by', $admin['id'])->find_one($id);
}
$plan = ORM::for_table('tbl_plans')->find_one($d['id_plan']);
if ($voucher && $plan) {
$content = Lang::pad($config['CompanyName'],' ', 2)."\n";
$content .= Lang::pad($config['address'],' ', 2)."\n";
$content .= Lang::pad($config['phone'],' ', 2)."\n";
$content .= Lang::pad("", '=')."\n";
$content .= Lang::pads('ID', $voucher['id'], ' ')."\n";
$content .= Lang::pads(Lang::T('Code'), $voucher['code'], ' ')."\n";
$content .= Lang::pads(Lang::T('Plan Name'), $plan['name_plan'], ' ')."\n";
$content .= Lang::pads(Lang::T('Type'), $voucher['type'], ' ')."\n";
$content .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($plan['price']), ' ')."\n";
$content .= Lang::pads(Lang::T('Sales'), $admin['fullname'].' #'.$admin['id'], ' ')."\n";
$content .= Lang::pad("", '=')."\n";
$content .= Lang::pad($config['note'],' ', 2)."\n";
$ui->assign('print', $content);
$config['printer_cols'] = 30;
$content = Lang::pad($config['CompanyName'],' ', 2)."\n";
$content .= Lang::pad($config['address'],' ', 2)."\n";
$content .= Lang::pad($config['phone'],' ', 2)."\n";
$content .= Lang::pad("", '=')."\n";
$content .= Lang::pads('ID', $voucher['id'], ' ')."\n";
$content .= Lang::pads(Lang::T('Code'), $voucher['code'], ' ')."\n";
$content .= Lang::pads(Lang::T('Plan Name'), $plan['name_plan'], ' ')."\n";
$content .= Lang::pads(Lang::T('Type'), $voucher['type'], ' ')."\n";
$content .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($plan['price']), ' ')."\n";
$content .= Lang::pads(Lang::T('Sales'), $admin['fullname'].' #'.$admin['id'], ' ')."\n";
$content .= Lang::pad("", '=')."\n";
$content .= Lang::pad($config['note'],' ', 2)."\n";
$ui->assign('_title', Lang::T('View'));
$ui->assign('wa', urlencode("```$content```"));
$ui->display('voucher-view.tpl');
}else{
r2(U . 'prepaid/voucher/', 'e', Lang::T('Voucher Not Found'));
}
break;
case 'voucher-delete':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));

View file

@ -129,6 +129,7 @@ switch ($action) {
$d = ORM::for_table('tbl_users')
->where_like('username', '%' . $username . '%')
->where('root', $admin['id'])
->where('id', $admin['id'])
->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
@ -145,7 +146,12 @@ switch ($action) {
])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else {
$paginator = Paginator::build(ORM::for_table('tbl_users'));
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
$d = ORM::for_table('tbl_users')
->where_any_is([
['id' => $admin['id']],
['root' => $admin['id']]
])
->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
}
@ -255,7 +261,7 @@ switch ($action) {
$d->ward = $ward;
$d->status = 'Active';
$d->creationdate = $date_now;
if($admin['user_type']=='Agent'){
if ($admin['user_type'] == 'Agent') {
$d->root = $admin['id'];
}
$d->save();
@ -324,7 +330,7 @@ switch ($action) {
if ($d['username'] != $username) {
$c = ORM::for_table('tbl_users')->where('username', $username)->find_one();
if ($c) {
$msg .= "<b>$username</b> ".Lang::T('Account already axist') . '<br>';
$msg .= "<b>$username</b> " . Lang::T('Account already axist') . '<br>';
}
}
run_hook('edit_admin'); #HOOK

View file

@ -408,5 +408,8 @@
"SuperAdmin": "SuperAdmin",
"Admin": "Admin",
"Report": "Report",
"Agent": "Agent"
"Agent": "Agent",
"Send To Customer": "Send To Customer",
"Code": "Code",
"Generated By": "Generated By"
}

View file

@ -4,11 +4,13 @@
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}customers/csv"
onclick="return confirm('This will export to CSV?')"><span
class="glyphicon glyphicon-download" aria-hidden="true"></span> CSV</a>
</div>
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}customers/csv"
onclick="return confirm('This will export to CSV?')"><span class="glyphicon glyphicon-download"
aria-hidden="true"></span> CSV</a>
</div>
{/if}
{Lang::T('Manage Contact')}
</div>
<div class="panel-body">

View file

@ -21,6 +21,7 @@
<table width="200">
<tr>
<td>
{if $content}<pre style="border-style: none; background-color: white;">{$content}</pre>{else}
<pre style="border-style: none; background-color: white;"><b>{Lang::pad($_c['CompanyName'],' ', 2)}</b>
{Lang::pad($_c['address'],' ', 2)}
{Lang::pad($_c['phone'],' ', 2)}
@ -42,6 +43,7 @@
{/if}
{Lang::pad("", '=')}
{Lang::pad($_c['note'],' ', 2)}</pre>
{/if}
</td>
</tr>
</table>

View file

@ -5,7 +5,9 @@
<div class="panel panel-hovered panel-primary panel-stacked mb30">
<div class="panel-heading">{$in['invoice']}</div>
<div class="panel-body">
<pre><b>{Lang::pad($_c['CompanyName'],' ', 2)}</b>
<form class="form-horizontal" method="post" action="{$_url}prepaid/print" target="_blank">
<pre id="content"></pre>
<textarea class="hidden" id="formcontent" name="content">{Lang::pad($_c['CompanyName'],' ', 2)}
{Lang::pad($_c['address'],' ', 2)}
{Lang::pad($_c['phone'],' ', 2)}
{Lang::pad("", '=')}
@ -25,8 +27,7 @@
{Lang::pads(Lang::T('Expires On'), Lang::dateAndTimeFormat($in['expiration'],$in['time']), ' ')}
{/if}
{Lang::pad("", '=')}
{Lang::pad($_c['note'],' ', 2)}</pre>
<form class="form-horizontal" method="post" action="{$_url}prepaid/print" target="_blank">
{Lang::pad($_c['note'],' ', 2)}</textarea>
<input type="hidden" name="id" value="{$in['id']}">
<a href="{$_url}prepaid/list" class="btn btn-primary btn-sm"><i
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
@ -35,19 +36,12 @@
<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-print"></i>
{Lang::T('Click Here to Print')}</button>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var s5_taf_parent = window.location;
function popup_print() {
window.open('print.php?page=<?php echo $_GET['
act '];?>', 'page',
'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left=50,top=50,titlebar=yes'
)
}
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
</script>
{include file="sections/footer.tpl"}

View file

@ -4,16 +4,19 @@
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}prepaid/sync"
onclick="return confirm('This will sync/send Caustomer active plan to Mikrotik?')"><span
class="glyphicon glyphicon-refresh" aria-hidden="true"></span> sync</a>
</div>
<div class="btn-group pull-right">
<a class="btn btn-info btn-xs" title="save" href="{$_url}customers/csv"
onclick="return confirm('This will export to CSV?')"><span
class="glyphicon glyphicon-download" aria-hidden="true"></span> CSV</a>
</div>{Lang::T('Prepaid Users')}
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}prepaid/sync"
onclick="return confirm('This will sync/send Caustomer active plan to Mikrotik?')"><span
class="glyphicon glyphicon-refresh" aria-hidden="true"></span> sync</a>
</div>
<div class="btn-group pull-right">
<a class="btn btn-info btn-xs" title="save" href="{$_url}customers/csv"
onclick="return confirm('This will export to CSV?')"><span class="glyphicon glyphicon-download"
aria-hidden="true"></span> CSV</a>
</div>
{/if}
{Lang::T('Prepaid Users')}
</div>
<div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
@ -63,9 +66,11 @@
<td>
<a href="{$_url}prepaid/edit/{$ds['id']}"
class="btn btn-warning btn-xs">{Lang::T('Edit')}</a>
<a href="{$_url}prepaid/delete/{$ds['id']}" id="{$ds['id']}"
onclick="return confirm('{Lang::T('Delete')}?')"
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<a href="{$_url}prepaid/delete/{$ds['id']}" id="{$ds['id']}"
onclick="return confirm('{Lang::T('Delete')}?')"
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
{/if}
</td>
</tr>
{/foreach}

View file

@ -55,7 +55,7 @@
<td>
<a href="{$_url}settings/users-edit/{$ds['id']}"
class="btn btn-info btn-xs">{Lang::T('Edit')}</a>
{if ($_admin['username']) neq ($ds['username'])}
{if ($_admin['id']) neq ($ds['id'])}
<a href="{$_url}settings/users-delete/{$ds['id']}" id="{$ds['id']}"
class="btn btn-danger btn-xs" onclick="return confirm('{Lang::T('Delete')}?')"><i class="glyphicon glyphicon-trash"></i></a>
{/if}

27
ui/ui/voucher-view.tpl Normal file
View file

@ -0,0 +1,27 @@
{include file="sections/header.tpl"}
<div class="row">
<div class="col-md-6 col-sm-12 col-md-offset-3">
<div class="panel panel-hovered panel-primary panel-stacked mb30">
<div class="panel-body">
<form class="form-horizontal" method="post" action="{$_url}prepaid/print" target="_blank">
<pre id="content"></pre>
<textarea class="hidden" id="formcontent" name="content">{$print}</textarea>
<input type="hidden" name="id" value="{$in['id']}">
<a href="{$_url}prepaid/voucher" class="btn btn-primary btn-sm"><i
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
<a href="https://api.whatsapp.com/send/?text={$wa}" target="_blank" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-envelope"></i> {Lang::T("Send To Customer")}</a>
<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-print"></i>
{Lang::T('Click Here to Print')}</button>
</form>
<javascript type="text/javascript">
</javascript>
</div>
</div>
</div>
</div>
<script type="text/javascript">
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
</script>
{include file="sections/footer.tpl"}

View file

@ -4,11 +4,14 @@
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
<div class="btn-group pull-right">
<a class="btn btn-danger btn-xs" title="Remove used Voucher" href="{$_url}prepaid/remove-voucher" onclick="return confirm('Delete all used voucher code?')"><span
class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete All</a>
</div>
{Lang::T('Prepaid Vouchers')}
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<div class="btn-group pull-right">
<a class="btn btn-danger btn-xs" title="Remove used Voucher" href="{$_url}prepaid/remove-voucher"
onclick="return confirm('Delete all used voucher code?')"><span
class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete All</a>
</div>
{/if}
{Lang::T('Prepaid Vouchers')}
</div>
<div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
@ -50,12 +53,13 @@
<th>{Lang::T('Code Voucher')}</th>
<th>{Lang::T('Status Voucher')}</th>
<th>{Lang::T('Customer')}</th>
<th>{Lang::T('Generated By')}</th>
<th>{Lang::T('Manage')}</th>
</tr>
</thead>
<tbody>
{foreach $d as $ds}
<tr {if $ds['status'] eq '1'}class="danger"{/if}>
<tr {if $ds['status'] eq '1'}class="danger" {/if}>
<td>{$ds['id']}</td>
<td>{$ds['type']}</td>
<td>{$ds['routers']}</td>
@ -64,14 +68,30 @@
style="width:120px;border: 0px; text-align: right;" class="pull-right"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
onclick="this.select()"></td>
<td align="center">{if $ds['status'] eq '0'} <label class="btn-tag btn-tag-success">Not
<td align="center">{if $ds['status'] eq '0'} <label class="btn-tag btn-tag-success">Not
Use</label> {else} <label class="btn-tag btn-tag-danger">Used</label>
{/if}</td>
<td align="center">{if $ds['user'] eq '0'} - {else}<a href="{$_url}customers/viewu/{$ds['user']}">{$ds['user']}</a>{/if}</td>
<td align="center">{if $ds['user'] eq '0'} -
{else}<a href="{$_url}customers/viewu/{$ds['user']}">{$ds['user']}</a>
{/if}</td>
<td align="center">{if $ds['generated_by']}
<a
href="{$_url}settings/users-edit/{$ds['generated_by']}">{$admins[$ds['generated_by']]}</a>
{else} -
{/if}
</td>
<td>
<a href="{$_url}prepaid/voucher-delete/{$ds['id']}" id="{$ds['id']}"
class="btn btn-danger btn-xs"
onclick="return confirm('{Lang::T('Delete')}?')"><i class="glyphicon glyphicon-trash"></i></a>
{if $ds['status'] neq '1'}
<a href="{$_url}prepaid/voucher-view/{$ds['id']}" id="{$ds['id']}"
style="margin: 0px;"
class="btn btn-success btn-xs">&nbsp;&nbsp;{Lang::T('View')}&nbsp;&nbsp;</a>
{/if}
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<a href="{$_url}prepaid/voucher-delete/{$ds['id']}" id="{$ds['id']}"
class="btn btn-danger btn-xs"
onclick="return confirm('{Lang::T('Delete')}?')"><i
class="glyphicon glyphicon-trash"></i></a>
{/if}
</td>
</tr>
{/foreach}