1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
<?php
$user_id = $_GET['user_id'];
$detail_id = $_GET['detail_id'];
$token = $_GET['user_token'];
$detail_type = $_GET['detail_type'];
//extract data from the post
//set POST variables
// $url = 'http://url-caché-volontairement/api/pro/get-devis-facture-detail';
$url = 'http://ip-caché-volontairement/test/api/web/api/pro/get-devis-facture-detail';
$fields = array(
'detail_id' => urlencode($detail_id),
'user_id' => urlencode($user_id),
'user_token' => $token,
'detail_type' => urlencode($detail_type),
'page' => 1,
'number_record' => 1
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$resulttr = curl_exec($ch);
$result = json_decode($resulttr, true);
?>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<title>PDF template</title>
<meta charset="utf-8">
<style>h1, h2, h3, h4, p, ul {padding: 0; margin: 0;} ul li {list-style: none;} * {box-sizing: border-box;} table td, table th {font-weight: normal;} dl dd, dl dt {line-height: 20px;}</style>
<link rel="stylesheet" href="http://blabla.com/css/cssFilename.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="js/l10n.js"></script>
</head>
<body style="background-color: #fff; color: #777777; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 1;">
<div style="background-color: #fff; padding: 0px; overflow: hidden;">
<div style="width: 100%; margin: 0 auto;">
<div style="overflow: hidden; padding-bottom: 20px;">
<div style="float: left; width: 45%;">
<h2 style="font-size: 25px; padding: 0 0 10px; margin: 0; color: #505151;" id="pro-name"><?php echo $result['data']['company_name'];?> </h2>
<ul style="padding: 0; margin: 0; color: #505151;">
<li style="font-size: 18px; padding-bottom: 5px;" id="address"><?php echo $result['data']['pro_address_rue']; ?></li>
<li style="font-size: 18px; padding-bottom: 5px;" id="city"><?php echo $result['data']['pro_address_code_portal'];?> <?php echo $result['data']['pro_address_city'];?></li>
<li style="font-size: 18px; padding-bottom: 5px;">Tel: <span id="phone"><?php echo $result['data']['pro_telephone'];?></span></li>
</ul>
</div>
<div style="text-align: right; float: right; width: 45%;">
<h2 style="font-size: 25px; padding: 0 0 10px; margin: 0; color: #505151;" id="type"><?php echo $detail_type == 'devis' ? 'Devis' : 'Facture'; ?> </h2>
<ul style="padding: 0; margin: 0; color: #505151;">
<li style="font-size: 18px; padding-bottom: 5px;" id="libercourt"> <?php echo $result['data']['pro_address_city'];?></li>
<li style="font-size: 18px; padding-bottom: 5px;" id="id">Numero: <?php echo $user_id; ?></li>
<li style="font-size: 18px; padding-bottom: 5px;" id="date"><?php echo "Date de livaison: ".$result['data']['intervention_converted_date']; ?></li>
<li style="font-size: 18px; padding-bottom: 5px;" id="date-validity"></li>
</ul>
</div>
</div>
<div>
<div style="padding-bottom: 20px; overflow: hidden;">
<div style="width: 45%; float: left; border-radius: 5px; border: 1px solid #27aeb1; min-height: 150px;">
<h3 style="background-color: #27aeb1; padding: 10px 20px; font-size: 18px; color: #fff; font-weight: normal; border-radius: 3px 3px 0 0;">Adresse de chantier</h3>
<div style="padding: 5px 15px; color: #7f8c8c" id="intervention-address">
<textarea rows="5" style="overflow: hidden; border: none; resize: none; width: 100%; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 1.5; color: #777777;"><?php echo $result['data']['address_intervention']; ?></textarea>
<!-- <p style="margin-bottom: 10px; line-height: 24px;"><?php //echo $result['data']['intervention_address']['name'].' '.$result['data']['intervention_address']['firstName'] ?></p>
<ul style="padding: 0; margin: 0;">
<li style="padding-bottom: 5px;"><?php //echo $result['data']['intervention_address']['address']; ?></li>
<li style="padding-bottom: 5px;"><?php //echo $result['data']['intervention_address']['codePostal'].' '.$result['data']['intervention_address']['codePostal']; ?></li>
</ul>-->
</div>
</div>
<div style="width: 45%; float: right; border-radius: 5px; border: 1px solid #27aeb1; min-height: 150px;">
<h3 style="background-color: #27aeb1; padding: 10px 20px; font-size: 18px; color: #fff; font-weight: normal ;border-radius: 3px 3px 0 0;">Adresse de Facturation</h3>
<div style="padding: 5px 15px; color: #7f8c8c" id="billing-address" class="content">
<textarea rows="5" style="overflow: hidden; border: none; resize: none; width: 100%; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 1.5; color: #777777;"><?php echo $result['data']['address_facture']; ?></textarea>
<!-- <p style="margin-bottom: 10px; line-height: 24px;"><?php //echo $result['data']['billing_address']['name'].' '.$result['data']['billing_address']['firstName'] ?></p>
<ul style="padding: 0; margin: 0;">
<li style="padding-bottom: 5px;"><?php //echo $result['data']['billing_address']['address']; ?></li>
<li style="padding-bottom: 5px;"><?php //echo $result['data']['billing_address']['codePostal'].' '.$result['data']['billing_address']['codePostal']; ?></li>
</ul>-->
</div>
</div>
</div>
<div style="width: 100%; border-radius: 5px; border: 1px solid #27aeb1; margin-bottom: 20px; height: 130px; overflow: hidden;">
<h3 style="background-color: #27aeb1; padding: 10px 20px; font-size: 18px; color: #fff; font-weight: normal; border-radius: 3px 3px 0 0;">Description des travaux</h3>
<div style="padding: 5px 15px; color: #7f8c8c">
<p style="padding-bottom: 5px; line-height: 16px; font-size: 12px;" id="desc"> <?php echo $result['data']['devis_description'] ?></p>
</div>
</div>
<!--
* THE
* Correction #006 & #007
* Le 13/06/16 à 10h15
* @TODOO : Problème mise en page sur génération d'un PDF
-->
<?php
$page = 1;
$maxlines = 20;
if (is_array($result['data']['items']) && count($result['data']['items'])) {
$i = 0;
$max = count($result['data']['items']);
if ($max <= $maxlines) {
$max = $maxlines;
$totalPage = 1;
} else if ($max <= 40) {
$max = 40;
$totalPage = 2;
} else {
$temp = round(count($result['data']['items'])/34, 2) - (int)(count($result['data']['items'])/34);
if ($temp < 0.18 ) {
$max = (int)(count($result['data']['items'])/34) * 34 + 5;
$totalPage = (int)(count($result['data']['items'])/34) + 1;
} else {
$max = ((int)(count($result['data']['items'])/34) + 1) * 34 + 5;
$totalPage = (int)(count($result['data']['items'])/34) + 2;
}
}
while ($i < $max)
{
if ($i == 0 || $i == 20 || (($i % 34) == 16 && (int)$i/34 >= 1)) {
?>
<div style="width: 100%; border-radius: 5px; border: 1px solid #27aeb1;">
<table style="border: none; width: 100%; border-spacing: 0; border-collapse: collapse;">
<thead>
<tr style="background-color: #27aeb1; color: #fff; font-weight: normal; border-radius: 3px 3px 0 0;">
<th style="padding:5px;">Numéro</th>
<th style="text-align:center;padding:5px;">Description</th>
<th style="text-align: center; padding: 5px;">Qté</th>
<th style="text-align: center; padding: 5px;">Unité</th>
<th style="text-align: center; padding: 5px;">PV HT</th>
<th style="text-align: center; padding: 5px;">% Rem.</th>
<th style="text-align: center; padding: 5px;">Montant HT</th>
<th style="text-align: center; ; padding: 5px;">TVA</th>
</tr>
</thead>
<tbody id="items">
<?php
}
?>
<tr class="item" style='max-height: 25px;'>
<td style="width: 115px; text-align: center; padding-right: 5px;"><?php echo isset($result['data']['items'][$i]['description']) ? $i + 1: ''; ?></td>
<td style="width: 80%; text-align: left; padding-right: 15px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['description']) ? wordwrap($result['data']['items'][$i]['description'], 40, "\n", true): '' ?></td> <!-- THE : Ajout d'un wordwrap pour retour à la ligne -->
<td style="text-align: center; width: 75px; padding-right: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['quantity']) ? $result['data']['items'][$i]['quantity'] : '' ?></td>
<td style="text-align: center; width: 90px; padding-right: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['unit']) ? $result['data']['items'][$i]['unit'] : '' ?></td>
<td style="text-align: center; width: 95px; padding-right: 5px; padding-left: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['price']) ? $result['data']['items'][$i]['price'] : '' ?></td>
<td style="text-align: center; width: 125px; padding-right: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['discount']) ? $result['data']['items'][$i]['discount'] : '' ?></td>
<td style="text-align: center; width: 180px; padding-right: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['total_ht']) ? $result['data']['items'][$i]['total_ht'] : '' ?></td>
<td style="text-align: center; width: 90px; padding-right: 5px; border-left: 1px solid #27aeb1;"><?php echo isset($result['data']['items'][$i]['VAT']) ? $result['data']['items'][$i]['VAT'] : '' ?></td>
</tr>
<?php
if ($i == $max - 1 || $i == 16 || (($i % 40) == 16 && (int)$i/40 >= 1)) {
?>
</tbody>
</table>
</div>
<br/>
<?php if ($i == 16 || (($i % 40) == 16 && (int)$i/40 >= 1)) { ?>
<div style="page-break-after:always;">
<div style="border-top: 1px solid #27aeb1; margin-top: 100px;font-weight: bold; padding-top: 7px; font-size: 14px;">
<div style="float: left; width: 23%;">Siret: <?php echo $result['data']['pro_siret']; ?></div>
<div style="float: left; width: 30%;">- Naf: <?php echo $result['data']['pro_naf'] ?></div>
<div style="float: left; width: 30%;">- TVA: <?php echo $result['data']['pro_tva'] ?></div>
<div style="float: right; text-align: right; padding-right: 10px;">Page <?php echo $page; ?>/<?php echo $totalPage; ?></div>
</div></div>
<?php
$page++;
}
?>
<?php
if ($i == 2) {
?>
</br></br>
<?php
}
?>
<?php
}
?>
<?php
$i++;
}
}
?>
<div style="display: table;">
<div style="display: table-cell; vertical-align: bottom; width: 49%; padding-right: 1%;">
<div style="border: 1px solid #505151; border-radius: 5px; padding: 15px;">
<h4 style="font-size: 18px; font-weight: bold; margin-bottom: 5px;">Clause de réserve de propriété</h4>
<p style="line-height: 18px; font-size: 13px;" id="clause-reserve"><?php echo ( $result['data']['clause_reserve'] ); ?></p>
</div>
</div>
<div style="display: table-cell; width: 49%; padding-left: 1%;">
<!-- THE 17/06/16 11h03 : Ajout d'un margin-top:600px; pour les deux tableaux -->
<div style="border: 1px solid #505151; border-radius: 5px; margin-top: 630px;">
<table style="width: 100%; border-spacing: 0; border-collapse: collapse;">
<?php if($detail_type == 'devis') { ?>
<tbody id="total-devis">
<tr>
<td style="font-weight:bold; width: 270px; height: 40px;padding: 7px 30px 3px 30px;">Total HT</td>
<td style="font-weight:bold; width: 270px; text-align: right; height: 40px;padding: 7px 30px 3px 30px;" id="total-ht"><?php echo ($result['data']['total_ht'] > 0)?$result['data']['total_ht']:0;?> €</td>
</tr>
<tr style="border-bottom: 1px #333 solid;">
<td style="height: 20px; padding: 0 30px 10px 30px;">Total HT Net</td>
<td style="font-weight:bold; width: 270px; text-align: right; padding: 0 30px 10px 30px;" id="total-ht-net"><?php echo ($result['data']['total_ht'] > 0)?$result['data']['total_ht']:0;?> €</td>
</tr>
<tr>
<td style="height: 20px; padding: 15px 30px 12px;"> TVA</td>
<td style="font-weight:bold; width: 270px; text-align: right; padding: 15px 30px 12px;" id="tva"><?php echo ($result['data']['total_vat'] > 0)?$result['data']['total_vat']:0;?> €</td>
</tr>
<tr style="border-bottom: 1px #333 solid;">
<td style="height: 20px; padding: 0 30px 15px 30px;"> Total TTC</td>
<td style="font-weight:bold; width: 270px; text-align: right; padding: 0 30px 15px 30px;" id="total-tcc"><?php echo ($result['data']['total_tcc'] > 0)?$result['data']['total_tcc']:0;?> €</td>
</tr>
<tr>
<td style="height: 20px; padding: 15px 30px 12px;">Acompte</td>
<td style="font-weight:bold; width: 270px; text-align: right; padding: 15px 30px 12px;" id="acompte"><?php echo ($result['data']['deposit_percent'] > 0)?$result['data']['deposit_percent']:0;?> €</td>
</tr>
<tr>
<td style="font-weight:bold; width: 270px; height: 20px; padding: 0 30px 15px 30px;">Net à payer</td>
<td style="font-weight:bold; width: 270px; text-align: right; height: 20px; padding: 0 30px 15px 30px;" id="net-payer"><?php echo ($result['data']['total_net_payer'] > 0)?$result['data']['total_net_payer']:0;?> €</td>
</tr>
</tbody>
<?php } else { ?>
<tbody id="total-facture">
<tr>
<td style="font-weight:bold; width: 55%; height: 35px; padding: 10px 0px 0px 30px;">Total</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px;"></td>
</tr>
<tr style="font-size: 13px;">
<td style="height: 35px; padding: 10px 0px 0px 30px;">Montant total lignes HT.</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px;" id="facture-total-ht"><?php echo ($result['data']['total_ht'] > 0)?$result['data']['total_ht']:0;?> €</td>
</tr>
<tr style="font-size: 13px;">
<td style="height: 35px; padding: 10px 0px 0px 30px;">Facture d'acompte de</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px;" id="facture-acompte"><?php echo ($result['data']['deposit_percent'] > 0)?$result['data']['deposit_percent']:0;?> €</td>
</tr>
<tr style="font-size: 13px;">
<td style="height: 35px; padding: 10px 0px 0px 30px;"> Total acompte HT avec transport et remise</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px; " id="facture-discount"><?php echo ($result['data']['total_remise'] > 0)?$result['data']['total_remise']:0;?> €</td>
</tr>
<tr style="font-size: 13px;">
<td style="height: 35px; padding: 10px 0px 0px 30px;"> Montant de la TVA</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px;" id="facture-tva"><?php echo ($result['data']['total_vat'] > 0)?$result['data']['total_vat']:0;?> €</td>
</tr>
<tr style="font-size: 13px;">
<td style="font-weight:bold; height: 35px; padding: 10px 0px 13px 30px;">Montant total TTC</td>
<td style="font-weight:bold; text-align: right; padding-right: 30px; padding-top: 10px; padding-bottom: 13px;" id="facture-total-ttc"><?php echo ($result['data']['total_net_payer'] > 0)?$result['data']['total_net_payer']:0;?> €</td>
</tr>
</tbody>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
<div style="page-break-before:avoid;">
<!-- THE 17/06/16 11h03 : Ajout d'un margin-top:75px; pour le footer -->
<div style="border-top: 1px solid #27aeb1; font-weight: bold; margin-top:85px; padding-top: 7px; font-size: 14px;">
<div style="float: left; width: 23%;">Siret: <?php echo $result['data']['pro_siret']; ?></div>
<div style="float: left; width: 30%;">- Naf: <?php echo $result['data']['pro_naf'] ?></div>
<div style="float: left; width: 30%;">- TVA: <?php echo $result['data']['pro_tva'] ?></div>
<div style="float: right; text-align: right; padding-right: 10px;">Page <?php echo $page; ?>/<?php echo $totalPage; ?></div>
</div><br/>
</div>
</div>
</body>
<script>
$(document).ready(function(){
var proPhone = $('#phone');
proPhone.text(formatPhone(proPhone.text()));
function formatPhone(number) {
if(number){
while (/(\d+)(\d{2})/.test(number.toString())) {
number = number.toString().replace(/(\d+)(\d{2})/, '$1' + ' ' + '$2');
}
}
return number;
}
});
</script>
</html> |
Partager