243 lines
6.0 KiB
PHP
Executable File

<?php
$id = $_GET['id'];
$get_invoices_sql = mysqli_query($db, "SELECT bonds.id, bonds.date_time, bonds.price, bonds.bond_type, bonds.account_type, bonds.name, bonds.number, bonds.account_id, bonds.price_type, bonds.reason, bonds.user_id, user.name AS user_name FROM `bonds` LEFT JOIN user ON bonds.user_id = user.id WHERE bonds.id = $id LIMIT 1");
$invoices_row = mysqli_fetch_assoc($get_invoices_sql);
$name = $invoices_row['name'];
$number = $invoices_row['number'];
if ($invoices_row['account_type'] != 0) {
$get_data = "";
$user_id = $invoices_row['account_id'];
if ($invoices_row['account_type'] == 1) { // for user
$get_data = mysqli_query($db, "SELECT name,number FROM `user` WHERE id = $user_id LIMIT 1");
} elseif ($invoices_row['account_type'] == 2) { //for emplyee
$get_data = mysqli_query($db, "SELECT name,number FROM `emplyee` WHERE id = $user_id LIMIT 1");
}
$data = mysqli_fetch_assoc($get_data);
$name = $data['name'];
$number = $data['number'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>طباعة سند</title>
<!-- Normalize or reset CSS with your favorite library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">
<!-- Load paper.css for happy printing -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paper-css/0.3.0/paper.css">
<!-- Custom styles for this document -->
<link href="https://fonts.googleapis.com/css?family=Tangerine:700" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="assets/css/mo2_style.css">
<style>
body {
font-family: 'Cairo', sans-serif !important;
}
</style>
<style>
@page { size: A4 }
body { font-size: 21pt; font-weight: 700; }
.mo_border { border-bottom: #000 solid 1px; padding-bottom: 15px; margin-bottom:15px; }
</style>
</head>
<body onload="print_f()" class="A4" dir="rtl" style="margin: 0 320px;">
<?php
require_once('assets/php/barcode/vendor/autoload.php');
$label = '';
$code = $invoices_row['id'];
$type = 'C128';
$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
$code2 ='';
foreach(str_split($code) as $key => $c){
$code2 .=$c;
if(count(str_split($code)) != $key)
$code2 .=' ';
}
?>
<section>
<article>
<table width="100%" border="0">
<tbody>
<tr>
<td colspan="4" height="25px" align="center">
<img src="<?=$campany_info['logo-sm']?>" style="width: 20%;">
</td>
</tr>
<tr>
<td colspan="4">
<div class="mo_border"><h3 style="text-align: center;"><?=$campany_info['company_name']?></h3></div>
<div class="mo_border" style="display: flex;justify-content: space-between;"><span><b>الموظف</b> : <?=$invoices_row['user_name']?></span></div>
</td>
</tr>
</tbody>
</table>
<div style="text-align: center;">
<h1>
سند
<?php
switch ($invoices_row['bond_type']) {
case 2:
echo "قبض";
break;
case 1:
echo "صرف";
break;
default:
echo " ";
break;
}
?>
</h1>
</div>
<table width="100%" border="0">
<tbody>
<tr>
<td colspan="4" height="25px" align="center">
</td>
</tr>
<tr>
<td class="mo_border"><b>رقم السند</b></td>
<td class="mo_border"><b>التاريخ</b></td>
<td class="mo_border"><b>
<?php
switch ($invoices_row['bond_type']) {
case 2:
echo "استلمنا من";
break;
case 1:
echo "المستلم";
break;
}
?>
</b></td>
<td class="mo_border"><b>رقم الجوال</b></td>
</tr>
<tr>
<td class="mo_border"><b><?=$invoices_row['id']?></b></td>
<td class="mo_border"><?=date('d-m-Y h:i A', strtotime($invoices_row['date_time']))?></td>
<td class="mo_border"><?=$name?></td>
<td class="mo_border">0<?=$number?></td>
</tr>
</tbody>
</table>
<table width="100%" border="0">
<tbody>
<tr>
<td colspan="2" height="25px" align="center">
</td>
</tr>
<tr>
<td class="mo_border" width="20%"><b>المبلغ</b></td>
<td class="mo_border" width="60%"><b><?=$invoices_row['price']?></b></td>
</tr>
<tr>
<td class="mo_border" width="20%"><b>وذلك عن : </b></td>
<td class="mo_border" width="60%"><b><?=$invoices_row['reason']?></b></td>
</tr>
<?php
if ($invoices_row['bond_type'] == 1) {
?>
<tr>
<td colspan="2" height="25px" align="center">
</td>
</tr>
<tr>
<td class="mo_border" width="20%"><b>توقيع المستلم</b></td>
<td class="mo_border" width="60%"><b></b></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" height="75px" align="center">
</td>
</tr>
<tr>
<td style="direction: ltr;" colspan="4" height="35px" align="center">
<div id="field">
<center><large><b><?php echo $label ?></b></large></center>
<img src="data:image/png;base64,<?php echo base64_encode($generator->getBarcode($code, $type)) ?>" style="width: 50%;">
<div id="code"><?php echo $code2 ?></div>
</div>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<h3>شكراً على زيارتكم</h3>
<h3></h3>
</td>
</tr>
<tr>
<td colspan="4" height="75px" align="center">
</td>
</tr>
<tr>
<td colspan="4" align="center">
<?=$campany_info['link']?>
</td>
</tr>
<tr>
<td style="direction: ltr;" colspan="4" height="35px" align="center">
<?= date('d-m-Y h:i A', strtotime($date_time));?>
</td>
</tr>
</tbody>
</table>
</article>
</section>
<script type="text/javascript">
window.onafterprint = function(e){
closePrintView();
};
function print_f(){
window.print();
}
function closePrintView() {
window.close();
}
</script>
</body>
</html>