Download PDF invoice Customers
This commit is contained in:
parent
5f353392e3
commit
0868d61271
@ -87,7 +87,7 @@ class File
|
|||||||
$src_img = $image_create($source_file);
|
$src_img = $image_create($source_file);
|
||||||
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
|
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
|
||||||
|
|
||||||
$image($dst_img, $dst_dir, $quality);
|
imagepng($dst_img, $dst_dir);
|
||||||
|
|
||||||
if ($dst_img) imagedestroy($dst_img);
|
if ($dst_img) imagedestroy($dst_img);
|
||||||
if ($src_img) imagedestroy($src_img);
|
if ($src_img) imagedestroy($src_img);
|
||||||
|
@ -64,6 +64,17 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
if ($in) {
|
if ($in) {
|
||||||
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->display('customer/invoice-customer.tpl');
|
$ui->display('customer/invoice-customer.tpl');
|
||||||
} else {
|
} else {
|
||||||
r2(getUrl('voucher/list-activated'), 'e', Lang::T('Not Found'));
|
r2(getUrl('voucher/list-activated'), 'e', Lang::T('Not Found'));
|
||||||
|
@ -1145,5 +1145,7 @@
|
|||||||
"If_you_Download_manual_the_update_file__sometime_update_change_database__after_uploading__click_this_button_to_update_database_structure_": "If you Download manual the update file, sometime update change database, after uploading, click this button to update database structure.",
|
"If_you_Download_manual_the_update_file__sometime_update_change_database__after_uploading__click_this_button_to_update_database_structure_": "If you Download manual the update file, sometime update change database, after uploading, click this button to update database structure.",
|
||||||
"Update_Database": "Update Database",
|
"Update_Database": "Update Database",
|
||||||
"Credits": "Credits",
|
"Credits": "Credits",
|
||||||
"Continue_the_process_of_sending_messages": "Continue the process of sending messages"
|
"Continue_the_process_of_sending_messages": "Continue the process of sending messages",
|
||||||
|
"Yours_Balances": "Yours Balances",
|
||||||
|
"Friend_username": "Friend username"
|
||||||
}
|
}
|
@ -85,22 +85,32 @@
|
|||||||
listAtts.forEach(function(el) {
|
listAtts.forEach(function(el) {
|
||||||
if (el.addEventListener) { // all browsers except IE before version 9
|
if (el.addEventListener) { // all browsers except IE before version 9
|
||||||
el.addEventListener("click", function() {
|
el.addEventListener("click", function() {
|
||||||
|
var txt = $(this).html();
|
||||||
$(this).html(
|
$(this).html(
|
||||||
`<span class="loading"></span>`
|
`<span class="loading"></span>`
|
||||||
);
|
);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$(this).prop("disabled", true);
|
$(this).prop("disabled", true);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
setTimeout(() => {
|
||||||
|
$(this).html(txt);
|
||||||
|
$(this).prop("disabled", false);
|
||||||
|
}, 5000);
|
||||||
}, false);
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
if (el.attachEvent) { // IE before version 9
|
if (el.attachEvent) { // IE before version 9
|
||||||
el.attachEvent("click", function() {
|
el.attachEvent("click", function() {
|
||||||
|
var txt = $(this).html();
|
||||||
$(this).html(
|
$(this).html(
|
||||||
`<span class="loading"></span>`
|
`<span class="loading"></span>`
|
||||||
);
|
);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$(this).prop("disabled", true);
|
$(this).prop("disabled", true);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
setTimeout(() => {
|
||||||
|
$(this).html(txt);
|
||||||
|
$(this).prop("disabled", false);
|
||||||
|
}, 5000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,63 @@
|
|||||||
{include file="customer/header.tpl"}
|
{include file="customer/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-md-offset-3">
|
<div class="col-md-6 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;">{$invoice}</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">{$invoice}</pre>
|
||||||
<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="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank"
|
<a href="javascript:download()" class="btn btn-success btn-sm">
|
||||||
class="btn btn-primary btn-sm">
|
<i class="glyphicon glyphicon-share"></i> Download</a>
|
||||||
|
<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>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.font = '16px Courier';
|
||||||
|
var text = document.getElementById("content").innerHTML;
|
||||||
|
var lines = text.split(/\r\n|\r|\n/).length;
|
||||||
|
var meas = ctx.measureText("A");
|
||||||
|
let width = Math.round({$_c['printer_cols']} * 9.6); //Math.round(meas.width * {$_c['printer_cols']});
|
||||||
|
var height = Math.round((14 *
|
||||||
|
lines)); //.round((meas.actualBoundingBoxAscent + meas.actualBoundingBoxDescent) * lines);
|
||||||
|
console.log(width, height, lines);
|
||||||
|
var paid = new Image();
|
||||||
|
paid.src = '{$app_url}/system/uploads/pasid.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($('#content').html(), width / 2, new_height + 30, 'center');
|
||||||
|
doc.save('{$in['invoice']}.pdf');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{include file="customer/footer.tpl"}
|
{include file="customer/footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user