save pdf invoice customer from admin page
This commit is contained in:
parent
0868d61271
commit
9301f1058c
@ -269,6 +269,17 @@ switch ($action) {
|
|||||||
r2(getUrl('plan/view/') . $id, 'd', "Customer not found");
|
r2(getUrl('plan/view/') . $id, 'd', "Customer not found");
|
||||||
}
|
}
|
||||||
Package::createInvoice($in);
|
Package::createInvoice($in);
|
||||||
|
$UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH);
|
||||||
|
$logo = '';
|
||||||
|
if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png')) {
|
||||||
|
$logo = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'logo.png';
|
||||||
|
$imgsize = getimagesize($logo);
|
||||||
|
$width = $imgsize[0];
|
||||||
|
$height = $imgsize[1];
|
||||||
|
$ui->assign('wlogo', $width);
|
||||||
|
$ui->assign('hlogo', $height);
|
||||||
|
}
|
||||||
|
$ui->assign('logo', $logo);
|
||||||
$ui->assign('_title', 'View Invoice');
|
$ui->assign('_title', 'View Invoice');
|
||||||
$ui->display('admin/plan/invoice.tpl');
|
$ui->display('admin/plan/invoice.tpl');
|
||||||
break;
|
break;
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
{include file="sections/header.tpl"}
|
{include file="sections/header.tpl"}
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js"></script>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 col-sm-12 col-md-offset-3">
|
<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 panel-hovered panel-primary panel-stacked mb30">
|
||||||
<div class="panel-heading">{$in['invoice']}</div>
|
<div class="panel-heading">{$in['invoice']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
{if !empty($logo)}
|
||||||
|
<center><img src="{$app_url}/{$logo}?"></center>
|
||||||
|
{/if}
|
||||||
<form class="form-horizontal" method="post" action="{Text::url('')}plan/print" target="_blank">
|
<form class="form-horizontal" method="post" action="{Text::url('')}plan/print" target="_blank">
|
||||||
<pre id="content" style="text-align: center;"></pre>
|
<pre id="content"
|
||||||
|
style="border: 0px; ;text-align: center; background-color: transparent; background-image: url('{$app_url}/system/uploads/paid.png');background-repeat:no-repeat;background-position: center"></pre>
|
||||||
<textarea class="hidden" id="formcontent" name="content">{$invoice}</textarea>
|
<textarea class="hidden" id="formcontent" name="content">{$invoice}</textarea>
|
||||||
<input type="hidden" name="id" value="{$in['id']}">
|
<input type="hidden" name="id" value="{$in['id']}">
|
||||||
<a href="{Text::url('')}plan/list" class="btn btn-default btn-sm"><i
|
<a href="{Text::url('plan/list')}" class="btn btn-default btn-sm"><i
|
||||||
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
|
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
|
||||||
|
<a href="javascript:download()" class="btn btn-success btn-sm text-black">
|
||||||
|
<i class="glyphicon glyphicon-share"></i> Download</a>
|
||||||
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank"
|
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank"
|
||||||
class="btn btn-primary btn-sm">
|
class="btn btn-primary btn-sm">
|
||||||
<i class="glyphicon glyphicon-share"></i> WhatsApp</a>
|
<i class="glyphicon glyphicon-share"></i> WhatsApp</a>
|
||||||
@ -38,7 +44,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script>
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.font = '16px Courier';
|
||||||
|
var text = document.getElementById("formcontent").innerHTML;
|
||||||
|
var lines = text.split(/\r\n|\r|\n/).length;
|
||||||
|
var meas = ctx.measureText("A");
|
||||||
|
let width = Math.round({$_c['printer_cols']} * 9.6);
|
||||||
|
var height = Math.round((14 * lines));
|
||||||
|
console.log(width, height, lines);
|
||||||
|
var paid = new Image();
|
||||||
|
paid.src = '{$app_url}/system/uploads/paid.png';
|
||||||
|
{if !empty($logo)}
|
||||||
|
var img = new Image();
|
||||||
|
img.src = '{$app_url}/{$logo}';
|
||||||
|
var new_width = (width / 4) * 2;
|
||||||
|
var new_height = Math.ceil({$hlogo} * (new_width/{$wlogo}));
|
||||||
|
height = height + new_height;
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
function download() {
|
||||||
|
var doc = new jsPDF('p', 'px', [width, height]);
|
||||||
|
{if !empty($logo)}
|
||||||
|
try {
|
||||||
|
doc.addImage(img, 'PNG', (width - new_width) / 2, 10, new_width, new_height);
|
||||||
|
} catch (err) {}
|
||||||
|
{/if}
|
||||||
|
try {
|
||||||
|
doc.addImage(paid, 'PNG', (width - 200) / 2, (height - 145) / 2, 200, 145);
|
||||||
|
} catch (err) {}
|
||||||
|
doc.setFont("Courier");
|
||||||
|
doc.setFontSize(16);
|
||||||
|
doc.text($('#formcontent').html(), width / 2, new_height + 30, 'center');
|
||||||
|
doc.save('{$in['invoice']}.pdf');
|
||||||
|
}
|
||||||
|
|
||||||
var s5_taf_parent = window.location;
|
var s5_taf_parent = window.location;
|
||||||
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
|
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<input type="hidden" name="id" value="{$in['id']}">
|
<input type="hidden" name="id" value="{$in['id']}">
|
||||||
<a href="{Text::url('voucher/list-activated')}" class="btn btn-default btn-sm"><i
|
<a href="{Text::url('voucher/list-activated')}" class="btn btn-default btn-sm"><i
|
||||||
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
|
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
|
||||||
<a href="javascript:download()" class="btn btn-success btn-sm">
|
<a href="javascript:download()" class="btn btn-success btn-sm text-black">
|
||||||
<i class="glyphicon glyphicon-share"></i> Download</a>
|
<i class="glyphicon glyphicon-share"></i> Download</a>
|
||||||
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" class="btn btn-primary btn-sm">
|
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" class="btn btn-primary btn-sm">
|
||||||
<i class="glyphicon glyphicon-share"></i> WhatsApp</a>
|
<i class="glyphicon glyphicon-share"></i> WhatsApp</a>
|
||||||
@ -30,12 +30,11 @@
|
|||||||
var text = document.getElementById("content").innerHTML;
|
var text = document.getElementById("content").innerHTML;
|
||||||
var lines = text.split(/\r\n|\r|\n/).length;
|
var lines = text.split(/\r\n|\r|\n/).length;
|
||||||
var meas = ctx.measureText("A");
|
var meas = ctx.measureText("A");
|
||||||
let width = Math.round({$_c['printer_cols']} * 9.6); //Math.round(meas.width * {$_c['printer_cols']});
|
let width = Math.round({$_c['printer_cols']} * 9.6);
|
||||||
var height = Math.round((14 *
|
var height = Math.round((14 * lines));
|
||||||
lines)); //.round((meas.actualBoundingBoxAscent + meas.actualBoundingBoxDescent) * lines);
|
|
||||||
console.log(width, height, lines);
|
console.log(width, height, lines);
|
||||||
var paid = new Image();
|
var paid = new Image();
|
||||||
paid.src = '{$app_url}/system/uploads/pasid.png';
|
paid.src = '{$app_url}/system/uploads/paid.png';
|
||||||
{if !empty($logo)}
|
{if !empty($logo)}
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = '{$app_url}/{$logo}';
|
img.src = '{$app_url}/{$logo}';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user