aru_dn_pdf.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use Carbon\CarbonImmutable;
  4. use NumberFormatter;
  5. /**
  6. * @var Document $document
  7. * @var string $variant
  8. */
  9. $core = Core::getInstance();
  10. $delivery_note_number = $document->number;
  11. $company = $document->getCompany();
  12. $address = $company->getAddress();
  13. $address_lines = explode("\n", (string) $address);
  14. $aru = $document->getRelatedDocument();
  15. $goods_in_documents = $aru->getGoodsInDocuments();
  16. $sale_orders = $aru->getSalesOrders();
  17. $charges = "0.00";
  18. foreach($sale_orders as $sale_order) {
  19. $charges = bcadd($charges, $sale_order->getSubtotal(), 2);
  20. }
  21. $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
  22. $render_card = static function(string $title, ?string $content): void {
  23. $content = trim($content) ? htmlspecialchars($content) : "&nbsp;";
  24. ?>
  25. <div class="card mb-2">
  26. <div class="card-header">
  27. <strong>
  28. <?=htmlspecialchars($title)?>
  29. </strong>
  30. </div>
  31. <div class="card-body">
  32. <?=$content?>
  33. </div>
  34. </div>
  35. <?php
  36. }
  37. ?>
  38. <!doctype html>
  39. <html lang="en">
  40. <head>
  41. <meta charset="UTF-8">
  42. <meta name="viewport"
  43. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  44. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  45. <title><?=htmlspecialchars($core->getSiteName())?></title>
  46. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" integrity="sha256-IUOUHAPazai08QFs7W4MbzTlwEWFo7z/4zw8YmxEiko=" crossorigin="anonymous">
  47. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha256-xLI5SjD6DkojxrMIVBNT4ghypv12Xtj7cOa0AgKd6wA=" crossorigin="anonymous"></script>
  48. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
  49. <style>
  50. <?php
  51. echo file_get_contents("https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css");
  52. ?>
  53. :root {
  54. --bs-body-font-size: 0.7rem;
  55. }
  56. .card {
  57. border-radius: 0;
  58. }
  59. .card-header {
  60. padding: 0.25rem 0.5rem;
  61. border-radius: 0 !important;
  62. }
  63. .card-body {
  64. padding: 0.25rem 0.5rem;
  65. }
  66. .large {
  67. font-size: 125%;
  68. }
  69. .xlarge {
  70. font-size: 175%;
  71. }
  72. .border-4 {
  73. border: 4px solid black;
  74. }
  75. .compact {
  76. line-height: 1.25;
  77. }
  78. </style>
  79. </head>
  80. <body>
  81. <div class="container">
  82. <div class="row g-2 mb-2">
  83. <div class="col text-nowrap">
  84. <div class="text-uppercase xlarge">
  85. <strong>Advance Replacement Unit</strong>
  86. </div>
  87. </div>
  88. <div class="col text-center" >
  89. <img src="/img/logo.png" alt="Logo" style="width: 100px;" />
  90. </div>
  91. <div class="col-auto">
  92. <strong class="text-uppercase xlarge">
  93. ARU DN<br />
  94. </strong>
  95. <b class="large">No. <?=$delivery_note_number?></b>
  96. </div>
  97. </div>
  98. <div class="row g-2">
  99. <div class="col-6">
  100. <div class="card mb-2">
  101. <div class="card-header">
  102. <strong>Company, Name and Address</strong>
  103. </div>
  104. <div class="card-body">
  105. <?=$document->getBillingAddressHtml()?>
  106. </div>
  107. </div>
  108. <div class="card mb-2">
  109. <div class="card-header">
  110. <strong>Cost / Charge of Repairs</strong>
  111. </div>
  112. <div class="card-body">
  113. <?=htmlspecialchars($formatter->formatCurrency($charges, $aru->currency))?>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="col-6">
  118. <div class="card mb-2">
  119. <div class="card-header">
  120. <strong>Deliver To</strong>
  121. </div>
  122. <div class="card-body">
  123. <?=$document->getDeliveryAddressHtml()?>
  124. </div>
  125. </div>
  126. <div class="card mb-2">
  127. <div class="card-header">
  128. <strong>Delivery Cost</strong>
  129. </div>
  130. <div class="card-body">
  131. <?=htmlspecialchars($formatter->formatCurrency($document->delivery_cost, $aru->currency))?>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <div class="bg-danger text-center text-white p-1 mb-2 border-4 compact">
  137. <p class="mb-1">
  138. <strong class="large">IMPORTANT INFORMATION ON RETURNS OF ARUs</strong><br />
  139. <strong class="large">ON LOAN FOR A MAXIMUM OF 14 DAYS</strong><br />
  140. </p>
  141. <p class="mb-1">
  142. The FAULTY UNIT must be returned to us (if the item has been tampered warranty will be void and the full charge may be applied) at the address below within 14 days by Recorded Delivery Carriage / Insurance to be pre-paid. <strong>(WARNING)</strong> If not received back within 14 days you will be invoiced at the <b>FULL COST</b> and <b>ADVANCE REPLACEMENT UNIT FACILITIES</b> will be <b>WITHDRAWN</b> for any future requirements.
  143. </p>
  144. <p class="mb-1">
  145. <strong>Failure to return the faulty part(s) within 28 days will incur a 20% HANDLING CHARGE<br />AFTER 60 DAYS NO CREDIT WILL BE ISSUED</strong>
  146. </p>
  147. </div>
  148. <div class="row g-2">
  149. <div class="col-6">
  150. <div class="row g-2">
  151. <div class="col-6">
  152. <?php
  153. $render_card("Person Ordering", $document->contact_name);
  154. ?>
  155. </div>
  156. <div class="col-6">
  157. <?php
  158. $render_card("Date", CarbonImmutable::parse($document->date)->format("d/m/Y"));
  159. ?>
  160. </div>
  161. </div>
  162. <div class="card mb-2">
  163. <div class="card-header">
  164. <strong>Contact Details</strong>
  165. </div>
  166. <div class="card-body">
  167. <?php
  168. if($document->contact_phone) {
  169. ?>
  170. <div>
  171. <i class="fa fa-fw fa-phone"></i>
  172. <?=htmlspecialchars($document->contact_phone)?>
  173. </div>
  174. <?php
  175. }
  176. if($document->contact_email) {
  177. ?>
  178. <div>
  179. <i class="fa fa-fw fa-envelope"></i>
  180. <?=htmlspecialchars($document->contact_email)?>
  181. </div>
  182. <?php
  183. }
  184. if(!$document->contact_phone && !$document->contact_email) {
  185. ?>
  186. &nbsp;
  187. <?php
  188. }
  189. ?>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="col-6">
  194. <?php
  195. $render_card("Your Order No.", $document->po_number);
  196. ?>
  197. <div class="card mb-2">
  198. <div class="card-header">
  199. <strong>
  200. Help Us To Help Yourselves
  201. </strong>
  202. </div>
  203. <div class="card-body">
  204. Please return the Faulty Unit with a <strong>DUPLICATE COPY</strong> of the ARU Delivery Note, completing details of the fault - i.e. what the fault is; not needed; incorrect, to the address below.
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. <table class="table table-bordered mb-2">
  210. <colgroup>
  211. <col style="width: 40%"/>
  212. <col style="width: 40%"/>
  213. <col style="width: 20%"/>
  214. </colgroup>
  215. <thead>
  216. <tr>
  217. <th>Requested Items</th>
  218. <th>Serial Numbers</th>
  219. <th>Insurance Value</th>
  220. </tr>
  221. </thead>
  222. <tbody>
  223. <?php
  224. foreach($document->getItems() as $item) {
  225. ?>
  226. <tr>
  227. <td><?=htmlspecialchars($item->description)?></td>
  228. <td><?=$item->getSerialNumberHtml()?></td>
  229. <td class="text-end"><?=htmlspecialchars($formatter->formatCurrency($item->insurance_value, $aru->currency))?></td>
  230. </tr>
  231. <?php
  232. }
  233. ?>
  234. </tbody>
  235. <tfoot>
  236. <tr>
  237. <td colspan="3">
  238. <strong>
  239. The goods should be examined immediately on arrival and any apparent damage, shortage or misdescription notified at once to us, quoting this ARU DN number within 3 days.
  240. </strong>
  241. </td>
  242. </tr>
  243. </tfoot>
  244. </table>
  245. <div class="card mb-2">
  246. <div class="card-header">
  247. <div class="d-flex justify-content-between">
  248. <strong>Description of Fault / Additional Comments</strong>
  249. <div class="badge text-bg-danger">
  250. TO BE COMPLETED BY CUSTOMER
  251. </div>
  252. </div>
  253. </div>
  254. <div class="card-body" style="min-height: 100px;">
  255. <?=$document->getNotesHtml()?>
  256. </div>
  257. </div>
  258. <div class="mb-2 border-4 text-danger compact text-center p-1">
  259. <strong class="large text-uppercase">Items must be returned to the address below:</strong><br />
  260. <strong class="large"><?=htmlspecialchars($company->name)?>, <?=htmlspecialchars(implode(", ", $address_lines))?></strong><br />
  261. Tel: <?=htmlspecialchars($company->phone)?>
  262. <span class="px-1"></span>
  263. Email: <?=htmlspecialchars($company->email)?>
  264. </div>
  265. <div class="row g-2">
  266. <div class="col-4">
  267. <div class="card mb-2">
  268. <div class="card-header">
  269. <strong>Received Goods-In</strong>
  270. </div>
  271. <div class="card-body">
  272. <?php
  273. if(empty($goods_in_documents)) {
  274. ?>
  275. No Goods-Ins
  276. <?php
  277. }
  278. foreach($goods_in_documents as $goods_in_document) {
  279. ?>
  280. <div>
  281. <strong>
  282. GIN <?=$goods_in_document->number?>
  283. </strong>
  284. <span class="px-1"></span>
  285. <?=htmlspecialchars($goods_in_document->getDisplayDate())?>
  286. </div>
  287. <?php
  288. }
  289. ?>
  290. </div>
  291. </div>
  292. </div>
  293. <div class="col-4">
  294. <div class="card mb-2">
  295. <div class="card-header">
  296. <strong>Sales Orders</strong>
  297. </div>
  298. <div class="card-body">
  299. <?php
  300. if(empty($sale_orders)) {
  301. ?>
  302. No Sales Orders
  303. <?php
  304. }
  305. foreach($sale_orders as $sale_order) {
  306. ?>
  307. <div>
  308. <strong>
  309. INV <?=$sale_order->number?>
  310. </strong>
  311. <span class="px-1"></span>
  312. <?=htmlspecialchars($sale_order->getDisplayDate())?>
  313. <span class="px-1"></span>
  314. <strong>
  315. <?=htmlspecialchars($formatter->formatCurrency($sale_order->getSubtotal(), $aru->currency))?>
  316. </strong>
  317. </div>
  318. <?php
  319. }
  320. ?>
  321. </div>
  322. </div>
  323. </div>
  324. <div class="col-4">
  325. <div class="card mb-2">
  326. <div class="card-header">
  327. <strong>ARU Parts</strong>
  328. </div>
  329. <div class="card-body">
  330. <?php
  331. $aru_items = $aru->getItems();
  332. if(!$aru_items) {
  333. ?>
  334. No Items
  335. <?php
  336. }
  337. else {
  338. ?>
  339. <ul class="mb-0 list-unstyled">
  340. <?php
  341. foreach($aru_items as $aru_item) {
  342. ?>
  343. <li>
  344. <?=htmlspecialchars($aru_item->description)?> &times; <?=$aru_item->quantity?>
  345. <?php
  346. if($aru_item->serial_number) {
  347. ?>
  348. <span class="text-muted">(S/N: <?=$aru_item->getSerialNumberHtml()?>)</span>
  349. <?php
  350. }
  351. ?>
  352. </li>
  353. <?php
  354. }
  355. ?>
  356. </ul>
  357. <?php
  358. }
  359. ?>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. </div><!-- End of container -->
  365. </body>
  366. </html>