diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 163718ea6dbf..55e61356dbe7 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -63,8 +63,10 @@ class Statement $variables = []; $variables = $html->generateLabelsAndValues(); + + $option_template = &$this->options['template']; - if($this->client->getSetting('statement_design_id') != '') { + if($this->client->getSetting('statement_design_id') != '' || $option_template && $option_template != '') { $variables['values']['$start_date'] = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()); $variables['values']['$end_date'] = $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale()); diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index 919cbe4a0a9d..538320fa9564 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -11,33 +11,34 @@ namespace App\Services\Template; -use App\Libraries\MultiDB; +use App\Models\Task; +use App\Models\User; +use App\Models\Quote; use App\Models\Client; -use App\Models\Company; use App\Models\Credit; use App\Models\Design; +use App\Models\Vendor; +use App\Models\Company; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; use App\Models\Product; use App\Models\Project; +use App\Libraries\MultiDB; use App\Models\PurchaseOrder; -use App\Models\Quote; +use Illuminate\Bus\Queueable; +use App\Utils\Traits\MakesHash; use App\Models\RecurringInvoice; -use App\Models\Task; -use App\Models\User; -use App\Models\Vendor; use App\Services\Email\AdminEmail; use App\Services\Email\EmailObject; -use App\Utils\Traits\MakesHash; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; +use App\Services\PdfMaker\PdfMerge; use Illuminate\Mail\Mailables\Address; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\Middleware\WithoutOverlapping; class TemplateAction implements ShouldQueue { @@ -111,6 +112,39 @@ class TemplateAction implements ShouldQueue /** Set a global currency_code */ $first_entity = $result->first(); + /** Lets be clever and sniff out Statements */ + if($first_entity instanceof Client && stripos(json_encode($template->design), '##statement##') !== false) { + + $options = [ + 'show_payments_table' => true, + 'show_aging_table' => true, + 'status' => 'all', + 'show_credits_table' => false, + 'template' => $this->template, + ]; + + $pdfs = []; + + foreach($result as $client) { + $pdfs[] = $client->service()->statement($options); + } + + if(count($pdfs) == 1) { + $pdf = $pdfs[0]; + } else { + $pdf = (new PdfMerge($pdfs))->run(); + } + + if($this->send_email) { + $this->sendEmail($pdf, $template); + } else { + $filename = "templates/{$this->hash}.pdf"; + Storage::disk(config('filesystems.default'))->put($filename, $pdf); + return $pdf; + } + + } + if($first_entity instanceof Client) $currency_code = $first_entity->currency()->code; elseif($first_entity->client) diff --git a/resources/views/templates/delivery_notes/td13.html b/resources/views/templates/delivery_notes/td13.html new file mode 100644 index 000000000000..f095de7a2073 --- /dev/null +++ b/resources/views/templates/delivery_notes/td13.html @@ -0,0 +1,205 @@ + + + + +
+ + + + + + + +Delivery Note | +{{ img('$company.logo') }} | +
+
+
+
+
+ Bill To: +
+
+ $client.name +
+
+ $client.shipping_address + |
+
+
+
+
+
+
+ Ship To: +
+
+ $client.name +
+
+ $client.shipping_address + |
+
+
+
+ Order # $invoice.po_number + |
+
+
+
+ Order Date: $invoice.date + |
+
Item # | +Description | +Delivered | +
---|---|---|
{{ item.product_key }} | +{{ item.notes }} | +{{ item.quantity }} | +
+ + | +||||||||||||||||||||
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $statement_label+$start_date - $end_date +
+
+ {% endif %}
+
|
+ ||||||||||||||||||||
+ + | +