Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 4.72 KB | None | 0 0
  1.     //Controller
  2.     public function downloadReceiptPDF($id)
  3.     {
  4.  
  5.         $campaigns = DB::table('bill')
  6.             ->select('bill.b_id', 'c_code', 'c_name', 'b_fee', 'b_date', 'total_month')
  7.             ->join('campaign', 'campaign.c_id', '=', 'bill.c_id')
  8.             ->where('bill.b_id', $id)
  9.             ->get();
  10.         // // dd($campaigns);
  11.  
  12.         $pdf = PDF::loadView('campaign.receiptpdf', compact('campaigns'));
  13.         return $pdf->download('receipt.pdf');
  14.         // return $pdf->stream('receipt.pdf');
  15.         // return view('campaign.receiptpdf', compact('campaigns'));
  16.     }
  17.  
  18.  
  19.  
  20.     //Views
  21.     <!doctype html>
  22. <html>
  23.  
  24. <head>
  25.     <meta charset="utf-8">
  26.  
  27.     <style type="text/css" media="all">
  28.         .invoice-box {
  29.             max-width: 800px;
  30.             margin: auto;
  31.             padding: 30px;
  32.             border: 1px solid #eee;
  33.             box-shadow: 0 0 10px rgba(0, 0, 0, .15);
  34.             font-size: 16px;
  35.             line-height: 24px;
  36.             font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
  37.             color: #555;
  38.         }
  39.  
  40.         .invoice-box table {
  41.             width: 100%;
  42.             line-height: inherit;
  43.             text-align: left;
  44.         }
  45.  
  46.         .invoice-box table td {
  47.             padding: 5px;
  48.             vertical-align: top;
  49.         }
  50.  
  51.         .invoice-box table tr td:nth-child(2) {
  52.             text-align: right;
  53.         }
  54.  
  55.         .invoice-box table tr.top table td {
  56.             padding-bottom: 20px;
  57.         }
  58.  
  59.         .invoice-box table tr.top table td.title {
  60.             font-size: 45px;
  61.             line-height: 45px;
  62.             color: #333;
  63.         }
  64.  
  65.         .invoice-box table tr.information table td {
  66.             padding-bottom: 40px;
  67.         }
  68.  
  69.         .invoice-box table tr.heading td {
  70.             background: #eee;
  71.             border-bottom: 1px solid #ddd;
  72.             font-weight: bold;
  73.         }
  74.  
  75.         .invoice-box table tr.details td {
  76.             padding-bottom: 20px;
  77.         }
  78.  
  79.         .invoice-box table tr.item td {
  80.             border-bottom: 1px solid #eee;
  81.         }
  82.  
  83.         .invoice-box table tr.item.last td {
  84.             border-bottom: none;
  85.         }
  86.  
  87.         .invoice-box table tr.total td:nth-child(2) {
  88.             border-top: 2px solid #eee;
  89.             font-weight: bold;
  90.         }
  91.  
  92.         @media only screen and (max-width: 600px) {
  93.             .invoice-box table tr.top table td {
  94.                 width: 100%;
  95.                 display: block;
  96.                 text-align: center;
  97.             }
  98.  
  99.             .invoice-box table tr.information table td {
  100.                 width: 100%;
  101.                 display: block;
  102.                 text-align: center;
  103.             }
  104.         }
  105.  
  106.         /** RTL **/
  107.         .rtl {
  108.             direction: rtl;
  109.             font-family: Tahoma, 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
  110.         }
  111.  
  112.         .rtl table {
  113.             text-align: right;
  114.         }
  115.  
  116.         .rtl table tr td:nth-child(2) {
  117.             text-align: left;
  118.         }
  119.     </style>
  120. </head>
  121.  
  122. <body>
  123.     <div class="invoice-box">
  124.         <table cellpadding="0" cellspacing="0">
  125.             <tr class="top">
  126.                 <td colspan="2">
  127.                     <table>
  128.                         <tr>
  129.                             <td class="title">
  130.  
  131.                             </td>
  132.  
  133.                             <td>
  134.                                 Receipt #: {{ $campaigns[0]->b_id }}<br>
  135.                                 Date: {{ \Carbon\Carbon::parse($campaigns[0]->b_date)->format('d/m/Y') }}<br>
  136.                             </td>
  137.                         </tr>
  138.                     </table>
  139.                 </td>
  140.             </tr>
  141.  
  142.             <tr class="information">
  143.                 <td colspan="2">
  144.                     <table>
  145.                         <tr>
  146.                             <td>
  147.  
  148.                             </td>
  149.                         </tr>
  150.                     </table>
  151.                 </td>
  152.             </tr>
  153.             <tr class="heading">
  154.                 <td>
  155.                     Campaign Code
  156.                 </td>
  157.  
  158.                 <td>
  159.                     Price
  160.                 </td>
  161.             </tr>
  162.  
  163.             <tr class="item last">
  164.                 <td>
  165.                     {{ $campaigns[0]->c_code }} ({{ $campaigns[0]->total_month }} months)
  166.                 </td>
  167.  
  168.                 <td>
  169.                     {{ $campaigns[0]->b_fee }}
  170.                 </td>
  171.             </tr>
  172.  
  173.             <tr class="total">
  174.                 <td></td>
  175.  
  176.                 <td>
  177.                     Total: RM {{ $campaigns[0]->b_fee }}
  178.                 </td>
  179.             </tr>
  180.         </table>
  181.     </div>
  182. </body>
  183.  
  184. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement