invoice Mail, weitere Punkte

This commit is contained in:
Kevin Adametz 2021-02-10 18:07:58 +01:00
parent 02e78e7255
commit 39ef16686a
10 changed files with 299 additions and 6 deletions

View file

@ -76,7 +76,7 @@ class PayController extends Controller
//make Payone payment //make Payone payment
public function setPrePayment($payment_method, $amount, $currency, $ret = []){ public function setPrePayment($payment_method, $amount, $currency, $ret = []){
$this->reference = substr(uniqid('m', false), 0, 16); $this->reference = $this->shopping_order->created_at->format('Ym').$this->shopping_order->id;//substr(uniqid('m', false), 0, 16);
$this->setMethod($payment_method, $ret); $this->setMethod($payment_method, $ret);
$this->prepayment = [ $this->prepayment = [

View file

@ -340,7 +340,7 @@ class CheckoutController extends Controller
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first(); $ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first();
if(!$ShoppingPayment){ if(!$ShoppingPayment){
//TODO log this //TODO log this
Util::setUserHistoryValue(['status'=>21]); Util::setUserHistoryValue(['status'=>21], $reference);
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference); \Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
return redirect(route('checkout.checkout_card')); return redirect(route('checkout.checkout_card'));
@ -363,13 +363,13 @@ class CheckoutController extends Controller
return view('web.templates.checkout-final', $data); return view('web.templates.checkout-final', $data);
} }
if($status === "cancel"){ if($status === "cancel"){
Util::setUserHistoryValue(['status'=>22]); Util::setUserHistoryValue(['status'=>22], $reference);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.'); \Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card')); return redirect(route('checkout.checkout_card'));
} }
if($status === "error"){ if($status === "error"){
Util::setUserHistoryValue(['status'=>23]); Util::setUserHistoryValue(['status'=>23], $reference);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.'); \Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card')); return redirect(route('checkout.checkout_card'));

50
app/Mail/MailInvoice.php Normal file
View file

@ -0,0 +1,50 @@
<?php
namespace App\Mail;
use App\User;
use App\Services\Invoice;
use App\Models\ShoppingOrder;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Storage;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailInvoice extends Mailable
{
use Queueable, SerializesModels;
protected $shopping_order;
public $subject;
public function __construct(ShoppingOrder $shopping_order)
{
$this->shopping_order = $shopping_order;
$this->subject = 'Rechnung zu Deiner Bestellung: '.$shopping_order->getLastShoppingPayment('reference') ;
}
public function build()
{
$title = __('email.invoice_title');
$copy1line = __('email.invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
$filename = Invoice::getFilename($this->shopping_order);
$path = Invoice::getDownloadPath($this->shopping_order);
if (!Storage::disk('public')->exists($path)) {
return;
}
$file = Storage::disk('public')->path($path);
$mime = Storage::disk('public')->mimeType($path);
return $this->view('emails.blank')->with([
'title' => $title,
'copy1line' => $copy1line,
])->attach($file,[
'as' => $filename,
'mime' => $mime,
]); // attach file;
}
}

View file

@ -21,6 +21,7 @@ class InvoiceRepository extends BaseRepository {
$invoice_number = isset($request['invoice_number']) ? $request['invoice_number'] : Invoice::getInvoiceNumber(); $invoice_number = isset($request['invoice_number']) ? $request['invoice_number'] : Invoice::getInvoiceNumber();
$invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y"); $invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
$invoice_send_mail = isset($request['invoice_send_mail']) ? true: false;
$invoice_number = Invoice::createInvoiceNumber($invoice_number, $invoice_date); $invoice_number = Invoice::createInvoiceNumber($invoice_number, $invoice_date);
$data = [ $data = [
@ -55,6 +56,11 @@ class InvoiceRepository extends BaseRepository {
]; ];
$this->model->invoice = $data_file; $this->model->invoice = $data_file;
$this->model->save(); $this->model->save();
if($invoice_send_mail){
Invoice::sendInvoiceMail($this->model);
}
Invoice::makeNextInvoiceNumber(); Invoice::makeNextInvoiceNumber();
return true; return true;
//return $pdf->stream('invoice.pdf'); //return $pdf->stream('invoice.pdf');

View file

@ -1,9 +1,11 @@
<?php <?php
namespace App\Services; namespace App\Services;
use App\Mail\MailInvoice;
use App\Services\Util; use App\Services\Util;
use App\Models\Setting; use App\Models\Setting;
use App\Models\ShoppingOrder; use App\Models\ShoppingOrder;
use Illuminate\Support\Facades\Mail;
class Invoice class Invoice
{ {
@ -57,4 +59,22 @@ class Invoice
} }
return \Storage::disk('public')->path($dir.$filename); return \Storage::disk('public')->path($dir.$filename);
} }
public static function sendInvoiceMail($shopping_order){
$bcc = [];
$billing_email = $shopping_order->shopping_user->billing_email;
if(!$billing_email){
if($shopping_order->mode === 'test'){
$billing_email = config('app.checkout_test_mail');
}else{
$billing_email = config('app.checkout_mail');
}
}
if($shopping_order->mode === 'test'){
$bcc[] = config('app.checkout_test_mail');
}else{
$bcc[] = config('app.checkout_mail');
}
Mail::to($billing_email)->bcc($bcc)->send(new MailInvoice($shopping_order));
}
} }

View file

@ -45,6 +45,8 @@
'checkout_copy3line' => 'Bei Fragen sind wir jederzeit für Dich da.', 'checkout_copy3line' => 'Bei Fragen sind wir jederzeit für Dich da.',
'checkout_copy3line_extern' => 'Bestellung über Berater:', 'checkout_copy3line_extern' => 'Bestellung über Berater:',
'status_copy1line' => 'Status zu Deiner Bestellung auf Grüne Seele', 'status_copy1line' => 'Status zu Deiner Bestellung auf Grüne Seele',
'invoice_title' => 'Rechnung zu Deiner Bestellung auf Grüne Seele',
'invoice_copy1line' => 'vielen Dank für Deine Bestellung bei Grüne Seele. Nachfolgend senden wir Dir die Rechnung zu deiner Bestellung: ',
'footer_copy1' => 'GRÜNE SEELE GbR | Hauptstrasse 174 | 51143 Köln | Telefon: (+49) 2203 183 86 14 | E-Mail: service@gruene-seele.bio', 'footer_copy1' => 'GRÜNE SEELE GbR | Hauptstrasse 174 | 51143 Köln | Telefon: (+49) 2203 183 86 14 | E-Mail: service@gruene-seele.bio',
'footer_copy2' => '', 'footer_copy2' => '',
'footer_copy3' => '© 2021 All Rights Reserved', 'footer_copy3' => '© 2021 All Rights Reserved',

View file

@ -641,6 +641,12 @@
{!! Form::text('invoice_number', App\Services\Invoice::getInvoiceNumber(), ['class'=>'form-control']) !!} {!! Form::text('invoice_number', App\Services\Invoice::getInvoiceNumber(), ['class'=>'form-control']) !!}
<em> nächste Rechnungsnummer <a href="{{ route('admin_settings') }}"><i class="fa fa-edit"></i></a></em> <em> nächste Rechnungsnummer <a href="{{ route('admin_settings') }}"><i class="fa fa-edit"></i></a></em>
</div> </div>
<div class="form-group col-sm-12">
<label class="custom-control custom-checkbox">
{!! Form::checkbox('invoice_send_mail', 1, true, ['class'=>'custom-control-input']) !!}
<span class="custom-control-label">Rechnung an {{ $shopping_order->shopping_user->billing_email }}</span>
</label>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button> <button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>

View file

@ -0,0 +1,209 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>gruene-seele.bio</title>
<style type="text/css">
img {
max-width: 600px;
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
a {
text-decoration: none;
border: 0;
outline: none;
color: #919f7a;
}
a:hover {
color: #b6b600;
}
a img {
border: none;
}
td, h1, h2, h3 {
font-family: Helvetica, Verdana, Arial, sans-serif;
font-weight: 400;
}
td {
text-align: left;
}
body {
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: none;
width: 100%;
height: 100%;
color: #37302d;
background: #ffffff;
font-size: 15px;
line-height: 26px
}
table {
border-collapse: separate !important;
}
.headline {
color: #37302d;
font-size: 18px;
}
.sub_headline {
color: #788662;
font-size: 15px;
}
.force-full-width {
width: 100% !important;
}
hr {
border: none;
border-top: 1px solid #b7c59e;
}
</style>
</head>
<body class="body" style="padding:0; margin:0; display:block; background:#f8f8f8; -webkit-text-size-adjust:none" bgcolor="#f8f8f8">
@if(isset($copy1line))
<div style="display: none; mso-hide: all; width: 0px; height: 0px; max-width: 0px; max-height: 0px; font-size: 0px; line-height: 0px;">
{{ $copy1line }}
</div>
@endif
<table align="left" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td align="left" valign="top" bgcolor="#f4f1ef" width="100%">
<br>
<table style="margin: 0 auto;" cellpadding="0" cellspacing="0" width="700" class="w320">
<tr>
<td align="left" valign="top">
<table style="margin: 0 auto;" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style=" text-align:center;">
<center>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="">
<tbody class="">
<tr class="">
<td align="center" valign="middle" style="font-size: 0px;" class="">
<center>
<picture style="text-align: center">
<img src="https://partner.gruene-seele.bio/images/gruene-seele-logo.jpg" alt="gruene-seele.bio" style="border:none" width="230">
</picture>
</center>
</td>
</tr>
<tr>
<td><br></td>
</tr>
</tbody>
</table>
</center>
</td>
</tr>
</table>
<table cellpadding="10" style="padding: 10px;" cellspacing="0" border="0" width="100%" bgcolor="#f4f1ef">
@if(isset($title))
<tr>
<td class="headline">
<b>{{ $title }} </b>
</td>
</tr>
@endif
@if(isset($copy1line))
<tr>
<td style="color:#37302d;line-height:1.6em;">
{!! nl2br($copy1line) !!}
</td>
</tr>
@endif
@if(isset($url))
<tr>
<td>
<center>
<table role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="word-wrap:break-word;background:transparent;font-size:0px;padding:10px 25px;padding-top:15px;padding-bottom:15px;padding-right:40px;padding-left:40px;" align="center" valign="top" background="data:image/gif;base64,">
<table role="presentation" cellpadding="0" cellspacing="0" align="center" border="0">
<tbody>
<tr>
<td style="border:none;border-radius:20px;color:#ffffff;cursor:auto;padding:15px 25px;" align="center" valign="middle" bgcolor="#5f7567">
<p style="text-decoration:none;background:#5f7567;color:#ffffff;font-family:Arial, sans-serif;font-size:13px;font-weight:normal;line-height:120%;text-transform:none;margin:0px;text-align: center">
<a href="{{ $url }}" style="color:#ffffff;font-size:14px;font-weight:bold;text-align:center;text-decoration:none;-webkit-text-size-adjust:none;">{{ $button }}</a>
</p>
</td>
</tr>
<tr>
<td style="color:#37302d;text-align: center">
<span style="color: #cabda9; font-weight: normal; font-size: 13px; text-decoration: underline; word-wrap: break-word;white-space: pre-line;">{{ $url }}</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</td>
<tr>
@endif
@if(isset($content))
<tr>
<td>
<table style="padding: 20px; border:1px solid #eee; background-color: #fff;line-height:1.6em;" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td>
{!! nl2br($content) !!}
</td>
</tr>
</table>
</td>
</tr>
@endif
</table>
<center>
<table style="margin: 0 auto;" cellpadding="0" cellspacing="0" class="force-full-width"
bgcolor="#f4f1ef">
<tr>
<td style="color:#7B7B7E; font-size:14px;padding:20px;line-height:1.6em" align="center">
<p>
{{__('email.footer_copy1')}}
</p>
<br>
<a href="https://www.gruene-seele.bio" style="color: #7B7B7E; text-decoration: underline;">www.gruene-seele.bio</a>
<br>
</td>
</tr>
<tr>
<td style="color:#bbbbbb; font-size:12px;padding:20px;line-height:1.6em" align="center">
<p>{{__('email.footer_copy2')}}</p>
<a href="https://www.gruene-seele.bio/datenschutzerklaerung/">Datenschutzerklärung</a> <br>
<p>{{__('email.footer_copy3')}}</p>
<br>
<br>
</td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

View file

@ -146,7 +146,7 @@
// d.filter_customer_member = $('select[name=filter_customer_member]').val(); // d.filter_customer_member = $('select[name=filter_customer_member]').val();
} }
}, },
"order": [[4, "asc" ]], "order": [[8, "asc" ]],
"columns": [ "columns": [
{ data: 'picture', name: 'picture', searchable: false, width: 35 }, { data: 'picture', name: 'picture', searchable: false, width: 35 },
{ data: 'product', name: 'product' }, { data: 'product', name: 'product' },

View file

@ -17,7 +17,7 @@
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-6">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="company" class="form-label">{{ __('Company name') }}*</label> <label for="company" class="form-label">{{ __('Company name') }}* (alternativ: Vor- und Nachname)</label>
{{ Form::text('company', $user->account->company, array('placeholder'=>__('Company name'), 'class'=>'form-control', 'id'=>'company', 'required'=>true, 'tabindex' => 1)) }} {{ Form::text('company', $user->account->company, array('placeholder'=>__('Company name'), 'class'=>'form-control', 'id'=>'company', 'required'=>true, 'tabindex' => 1)) }}
</div> </div>
</div> </div>