Comments (3)
@Chrisx84 can you share a code snippet? it looks like there's an issue with your loop
from laravel-invoices.
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ $invoice->name }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css" media="screen">
html {
font-family: sans-serif;
line-height: 1.15;
margin: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
font-size: 10px;
margin: 36pt;
}
h4 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
strong {
font-weight: bolder;
}
img {
vertical-align: middle;
border-style: none;
}
table {
border-collapse: collapse;
}
th {
text-align: inherit;
}
h4, .h4 {
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
}
h4, .h4 {
font-size: 1.5rem;
}
.table {
width: 100%;
margin-bottom: 1rem;
color: #212529;
}
.table th,
.table td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #dee2e6;
}
.table tbody + tbody {
border-top: 2px solid #dee2e6;
}
.mt-5 {
margin-top: 3rem !important;
}
.pr-0,
.px-0 {
padding-right: 0 !important;
}
.pl-0,
.px-0 {
padding-left: 0 !important;
}
.text-right {
text-align: right !important;
}
.text-center {
text-align: center !important;
}
.text-uppercase {
text-transform: uppercase !important;
}
* {
font-family: "DejaVu Sans";
}
body, h1, h2, h3, h4, h5, h6, table, th, tr, td, p, div {
line-height: 1.1;
}
.party-header {
font-size: 1.5rem;
font-weight: 400;
}
.total-amount {
font-size: 12px;
font-weight: 700;
}
.border-0 {
border: none !important;
}
</style>
</head>
<body>
{{-- Header --}}
@if($invoice->logo)
<img src="{{ $invoice->getLogo() }}" alt="logo" height="100">
@endif
<table class="table mt-5">
<tbody>
<tr>
<td class="border-0 pl-0" width="70%">
<h4 class="text-uppercase">
<strong>{{ $invoice->name }}</strong>
</h4>
</td>
<td class="border-0 pl-0">
<p>{{ __('invoices::invoice.serial') }} <strong>{{ $invoice->getSerialNumber() }}</strong></p>
<p>{{ __('invoices::invoice.date') }}: <strong>{{ $invoice->getDate() }}</strong></p>
</td>
</tr>
</tbody>
</table>
{{-- Seller - Buyer --}}
<table class="table">
<thead>
<tr>
<th class="border-0 pl-0 party-header" width="48.5%">
{{ __('invoices::invoice.seller') }}
</th>
<th class="border-0" width="3%"></th>
<th class="border-0 pl-0 party-header">
{{ __('invoices::invoice.buyer') }}
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="px-0">
@if($invoice->seller->name)
<p class="seller-name">
<strong>{{ $invoice->seller->name }}</strong>
</p>
@endif
@if($invoice->seller->address)
<p class="seller-address">
{{ __('invoices::invoice.address') }}: {{ $invoice->seller->address }}
</p>
@endif
@if($invoice->seller->code)
<p class="seller-code">
{{ __('invoices::invoice.code') }}: {{ $invoice->seller->code }}
</p>
@endif
@if($invoice->seller->vat)
<p class="seller-vat">
{{ __('invoices::invoice.vat') }}: {{ $invoice->seller->vat }}
</p>
@endif
@if($invoice->seller->phone)
<p class="seller-phone">
{{ __('invoices::invoice.phone') }}: {{ $invoice->seller->phone }}
</p>
@endif
@foreach($invoice->seller->custom_fields as $key => $value)
<p class="seller-custom-field">
{{ ucfirst($key) }}: {{ $value }}
</p>
@endforeach
</td>
<td class="border-0"></td>
<td class="px-0">
@if($invoice->buyer->name)
<p class="buyer-name">
<strong>{{ $invoice->buyer->name }}</strong>
</p>
@endif
@if($invoice->buyer->address)
<p class="buyer-address">
{{ __('invoices::invoice.address') }}: {{ $invoice->buyer->address }}
</p>
@endif
@if($invoice->buyer->code)
<p class="buyer-code">
{{ __('invoices::invoice.code') }}: {{ $invoice->buyer->code }}
</p>
@endif
@if($invoice->buyer->vat)
<p class="buyer-vat">
{{ __('invoices::invoice.vat') }}: {{ $invoice->buyer->vat }}
</p>
@endif
@if($invoice->buyer->phone)
<p class="buyer-phone">
{{ __('invoices::invoice.phone') }}: {{ $invoice->buyer->phone }}
</p>
@endif
@foreach($invoice->buyer->custom_fields as $key => $value)
<p class="buyer-custom-field">
{{ ucfirst($key) }}: {{ $value }}
</p>
@endforeach
</td>
</tr>
</tbody>
</table>
{{-- Table --}}
<table class="table">
<thead>
<tr>
<th scope="col" class="border-0 pl-0">{{ __('invoices::invoice.description') }}</th>
@if($invoice->hasItemUnits)
<th scope="col" class="text-center border-0">{{ __('invoices::invoice.units') }}</th>
@endif
<th scope="col" class="text-center border-0">{{ __('invoices::invoice.quantity') }}</th>
<th scope="col" class="text-right border-0">{{ __('invoices::invoice.price') }}</th>
@if($invoice->hasItemDiscount)
<th scope="col" class="text-right border-0">{{ __('invoices::invoice.discount') }}</th>
@endif
@if($invoice->hasItemTax)
<th scope="col" class="text-right border-0">{{ __('invoices::invoice.tax') }}</th>
@endif
<th scope="col" class="text-right border-0 pr-0">{{ __('invoices::invoice.sub_total') }}</th>
</tr>
</thead>
<tbody>
{{-- Items --}}
@foreach($invoice->items as $item)
<tr>
<td class="pl-0">{{ $item->title }}</td>
@if($invoice->hasItemUnits)
<td class="text-center">{{ $item->units }}</td>
@endif
<td class="text-center">{{ $item->quantity }}</td>
<td class="text-right">
{{ $invoice->formatCurrency($item->price_per_unit) }}
</td>
@if($invoice->hasItemDiscount)
<td class="text-right">
{{ $invoice->formatCurrency($item->discount) }}
</td>
@endif
@if($invoice->hasItemTax)
<td class="text-right">
{{ $invoice->formatCurrency($item->tax) }}
</td>
@endif
<td class="text-right pr-0">
{{ $invoice->formatCurrency($item->sub_total_price) }}
</td>
</tr>
@endforeach
{{-- Summary --}}
@if($invoice->hasItemOrInvoiceDiscount())
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.total_discount') }}</td>
<td class="text-right pr-0">
{{ $invoice->formatCurrency($invoice->total_discount) }}
</td>
</tr>
@endif
@if($invoice->taxable_amount)
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.taxable_amount') }}</td>
<td class="text-right pr-0">
{{ $invoice->formatCurrency($invoice->taxable_amount) }}
</td>
</tr>
@endif
@if($invoice->tax_rate)
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.tax_rate') }}</td>
<td class="text-right pr-0">
{{ $invoice->tax_rate }}%
</td>
</tr>
@endif
@if($invoice->hasItemOrInvoiceTax())
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.total_taxes') }}</td>
<td class="text-right pr-0">
{{ $invoice->formatCurrency($invoice->total_taxes) }}
</td>
</tr>
@endif
@if($invoice->shipping_amount)
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.shipping') }}</td>
<td class="text-right pr-0">
{{ $invoice->formatCurrency($invoice->shipping_amount) }}
</td>
</tr>
@endif
<tr>
<td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
<td class="text-right pl-0">{{ __('invoices::invoice.total_amount') }}</td>
<td class="text-right pr-0 total-amount">
{{ $invoice->formatCurrency($invoice->total_amount) }}
</td>
</tr>
</tbody>
</table>
@if($invoice->notes)
<p>
{{ trans('invoices::invoice.notes') }}: {!! $invoice->notes !!}
</p>
@endif
<p>
{{ trans('invoices::invoice.amount_in_words') }}: {{ $invoice->getTotalAmountInWords() }}
</p>
<p>
{{ trans('invoices::invoice.pay_until') }}: {{ $invoice->getPayUntilDate() }}
</p>
<script type="text/php">
if (isset($pdf) && $PAGE_COUNT > 1) {
$text = "Page {PAGE_NUM} / {PAGE_COUNT}";
$size = 10;
$font = $fontMetrics->getFont("Verdana");
$width = $fontMetrics->get_text_width($text, $font, $size) / 2;
$x = ($pdf->get_width() - $width);
$y = $pdf->get_height() - 35;
$pdf->page_text($x, $y, $text, $font, $size);
}
</script>
</body>
</html>
and my code is
<?php
namespace Core;
use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\Party;
use LaravelDaily\Invoices\Classes\InvoiceItem;
class Invoices extends Core {
public static function MakeInvoice() {
$d = request()->only(['name', 'service',
'price', 'discount']);
$customer = new Buyer(['name' => $d['name']]);
$item = (new InvoiceItem())->title($d['service'])->pricePerUnit($d['price'])->discount($d['discount']);
$invoice = Invoice::make()
->buyer($customer)
->addItem($item)
->logo(public_path('favicon.png'));
return $invoice->url();
}
}
from laravel-invoices.
@Chrisx84 you changed your code, and now it should be valid
and this is incorrect calls because stream() returns response and not an invoice object so calling url is pointless return $invoice->stream()->url()
;
im closing this because this was a problem with your code
from laravel-invoices.
Related Issues (20)
- Encryption of pdf with master password HOT 1
- Adding css "break-inside: auto;" HOT 3
- Typo in German translation
- Multiple Tax HOT 1
- Products number and serial number HOT 1
- Arabic Character issue HOT 1
- Malformed UTF-8 characters, possibly incorrectly encoded HOT 2
- How to add additional amount besides total taxes and total discount and auto-calculate it to the totals? HOT 1
- path to translations is incorrect HOT 1
- How to get the invoice number without saving the file to disk or outputting to browser HOT 2
- to be able to change the view file on the fly without it having to be fixed for populating credit notes
- file_exists(): open_basedir restriction in effect HOT 10
- php unit test keep receiving error: Invoice: unable to set tax twice HOT 1
- pdf file size HOT 3
- Can I add a Class for Salary Invoice type ? HOT 1
- Invocies without due date HOT 1
- Precalculation HOT 3
- Add inclusive tax option
- Add option to use Puppeteer with Browsershot as a PDF render engine
- Translate Carbon Date Format HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-invoices.