From 02e78e7255261c5c485eabc3f8bbc330036d648a Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Wed, 10 Feb 2021 10:42:24 +0100 Subject: [PATCH] Work to invoice --- app/Http/Controllers/FileController.php | 66 + app/Http/Controllers/LeadController.php | 7 +- app/Http/Controllers/SalesController.php | 19 +- app/Http/Controllers/User/OrderController.php | 72 +- app/Http/Controllers/UserDataController.php | 10 +- app/Http/Controllers/WizardController.php | 14 +- app/Models/Setting.php | 10 + app/Models/ShoppingOrder.php | 4 + app/Models/UserAccount.php | 3 + app/Repositories/InvoiceRepository.php | 63 + app/Repositories/UserRepository.php | 5 + app/Services/HTMLHelper.php | 33 + app/Services/Invoice.php | 60 + app/Services/MyPDFMerger.php | 188 + app/Services/Payment.php | 6 + app/User.php | 7 + composer.json | 1 + composer.lock | 51 +- config/dompdf.php | 10 +- ...23_163527_create_shopping_orders_table.php | 1 + ...021_01_15_102718_create_settings_table.php | 1 + partner-gs.code-workspace | 8 + public/10.pdf | Bin 0 -> 445602 bytes public/fonts/roboto-v20-latin-300.eot | Bin 0 -> 17895 bytes public/fonts/roboto-v20-latin-300.svg | 312 + public/fonts/roboto-v20-latin-300.ttf | Bin 0 -> 36224 bytes public/fonts/roboto-v20-latin-300.woff | Bin 0 -> 20348 bytes public/fonts/roboto-v20-latin-300.woff2 | Bin 0 -> 15784 bytes public/fonts/roboto-v20-latin-500.eot | Bin 0 -> 18071 bytes public/fonts/roboto-v20-latin-500.svg | 305 + public/fonts/roboto-v20-latin-500.ttf | Bin 0 -> 36420 bytes public/fonts/roboto-v20-latin-500.woff | Bin 0 -> 20464 bytes public/fonts/roboto-v20-latin-500.woff2 | Bin 0 -> 15872 bytes public/fonts/roboto-v20-latin-700.eot | Bin 0 -> 17851 bytes public/fonts/roboto-v20-latin-700.svg | 309 + public/fonts/roboto-v20-latin-700.ttf | Bin 0 -> 36012 bytes public/fonts/roboto-v20-latin-700.woff | Bin 0 -> 20356 bytes public/fonts/roboto-v20-latin-700.woff2 | Bin 0 -> 15816 bytes public/fonts/roboto-v20-latin-regular.eot | Bin 0 -> 17854 bytes public/fonts/roboto-v20-latin-regular.svg | 308 + public/fonts/roboto-v20-latin-regular.ttf | Bin 0 -> 36176 bytes public/fonts/roboto-v20-latin-regular.woff | Bin 0 -> 20268 bytes public/fonts/roboto-v20-latin-regular.woff2 | Bin 0 -> 15736 bytes public/pdf/_old_template_contract_de.pdf | 4430 +++++++ public/pdf/gs_contract_de.php | 179 +- public/pdf/template_contract_de.pdf | Bin 684779 -> 1180346 bytes public/pdf/template_invoice_de-1.pdf | Bin 0 -> 890057 bytes public/pdf/template_invoice_de-2.pdf | Bin 0 -> 890057 bytes resources/lang/de.json | 201 +- resources/lang/de/navigation.php | 7 +- resources/lang/de/validation.php | 4 +- resources/views/admin/lead/index.blade.php | 2 + .../views/admin/modal/show_product.blade.php | 36 +- resources/views/admin/sales/_detail.blade.php | 63 +- .../views/admin/settings/index.blade.php | 25 +- resources/views/dashboard.blade.php | 1 - .../layouts/includes/layout-navbar.blade.php | 7 +- .../layouts/includes/layout-sidenav.blade.php | 20 +- resources/views/pdf/invoice.blade.php | 463 + .../views/user/checkout/checkout.blade.php | 4 +- resources/views/user/order/list.blade.php | 4 +- resources/views/user/team/members.blade.php | 5 +- resources/views/user/user_form.blade.php | 47 +- resources/views/user/user_new_form.blade.php | 6 +- routes/web.php | 16 +- storage/fonts/DejaVuSans.ufm.php | 10773 ++++++++++++++++ storage/fonts/Helvetica-Oblique.afm.php | 572 + storage/fonts/Helvetica.afm.php | 572 + storage/fonts/Times-Roman.afm.php | 572 + storage/fonts/dompdf_font_family_cache.php | 86 + storage/fonts/roboto-v20-latin-300.eot | Bin 0 -> 17895 bytes storage/fonts/roboto-v20-latin-300.svg | 312 + storage/fonts/roboto-v20-latin-300.ttf | Bin 0 -> 36224 bytes storage/fonts/roboto-v20-latin-300.woff | Bin 0 -> 20348 bytes storage/fonts/roboto-v20-latin-300.woff2 | Bin 0 -> 15784 bytes storage/fonts/roboto-v20-latin-500.eot | Bin 0 -> 18071 bytes storage/fonts/roboto-v20-latin-500.svg | 305 + storage/fonts/roboto-v20-latin-500.ttf | Bin 0 -> 36420 bytes storage/fonts/roboto-v20-latin-500.woff | Bin 0 -> 20464 bytes storage/fonts/roboto-v20-latin-500.woff2 | Bin 0 -> 15872 bytes storage/fonts/roboto-v20-latin-700.eot | Bin 0 -> 17851 bytes storage/fonts/roboto-v20-latin-700.svg | 309 + storage/fonts/roboto-v20-latin-700.ttf | Bin 0 -> 36012 bytes storage/fonts/roboto-v20-latin-700.woff | Bin 0 -> 20356 bytes storage/fonts/roboto-v20-latin-700.woff2 | Bin 0 -> 15816 bytes storage/fonts/roboto-v20-latin-regular.eot | Bin 0 -> 17854 bytes storage/fonts/roboto-v20-latin-regular.svg | 308 + storage/fonts/roboto-v20-latin-regular.ttf | Bin 0 -> 36176 bytes storage/fonts/roboto-v20-latin-regular.woff | Bin 0 -> 20268 bytes storage/fonts/roboto-v20-latin-regular.woff2 | Bin 0 -> 15736 bytes ...o_300_ab1c4ce83665e42f607bea17e0c512f6.ttf | Bin 0 -> 36224 bytes ...o_300_ab1c4ce83665e42f607bea17e0c512f6.ufm | 248 + ...o_500_9fe4eefaabe67c0d9ffb5dfea5faf22c.ttf | Bin 0 -> 36420 bytes ...o_500_9fe4eefaabe67c0d9ffb5dfea5faf22c.ufm | 248 + ...0_9fe4eefaabe67c0d9ffb5dfea5faf22c.ufm.php | 481 + ..._bold_f1d63e51656415e249549767ae9ca561.ttf | Bin 0 -> 36012 bytes ..._bold_f1d63e51656415e249549767ae9ca561.ufm | 248 + ...d_f1d63e51656415e249549767ae9ca561.ufm.php | 481 + ...ormal_295f487ba351be606b24d76db5dd95fa.ttf | Bin 0 -> 36176 bytes ...ormal_295f487ba351be606b24d76db5dd95fa.ufm | 248 + ...l_295f487ba351be606b24d76db5dd95fa.ufm.php | 481 + 101 files changed, 23483 insertions(+), 154 deletions(-) create mode 100644 app/Http/Controllers/FileController.php create mode 100644 app/Repositories/InvoiceRepository.php create mode 100644 app/Services/Invoice.php create mode 100644 app/Services/MyPDFMerger.php create mode 100644 partner-gs.code-workspace create mode 100644 public/10.pdf create mode 100644 public/fonts/roboto-v20-latin-300.eot create mode 100644 public/fonts/roboto-v20-latin-300.svg create mode 100644 public/fonts/roboto-v20-latin-300.ttf create mode 100644 public/fonts/roboto-v20-latin-300.woff create mode 100644 public/fonts/roboto-v20-latin-300.woff2 create mode 100644 public/fonts/roboto-v20-latin-500.eot create mode 100644 public/fonts/roboto-v20-latin-500.svg create mode 100644 public/fonts/roboto-v20-latin-500.ttf create mode 100644 public/fonts/roboto-v20-latin-500.woff create mode 100644 public/fonts/roboto-v20-latin-500.woff2 create mode 100644 public/fonts/roboto-v20-latin-700.eot create mode 100644 public/fonts/roboto-v20-latin-700.svg create mode 100644 public/fonts/roboto-v20-latin-700.ttf create mode 100644 public/fonts/roboto-v20-latin-700.woff create mode 100644 public/fonts/roboto-v20-latin-700.woff2 create mode 100644 public/fonts/roboto-v20-latin-regular.eot create mode 100644 public/fonts/roboto-v20-latin-regular.svg create mode 100644 public/fonts/roboto-v20-latin-regular.ttf create mode 100644 public/fonts/roboto-v20-latin-regular.woff create mode 100644 public/fonts/roboto-v20-latin-regular.woff2 create mode 100644 public/pdf/_old_template_contract_de.pdf create mode 100644 public/pdf/template_invoice_de-1.pdf create mode 100644 public/pdf/template_invoice_de-2.pdf create mode 100644 resources/views/pdf/invoice.blade.php create mode 100644 storage/fonts/DejaVuSans.ufm.php create mode 100644 storage/fonts/Helvetica-Oblique.afm.php create mode 100644 storage/fonts/Helvetica.afm.php create mode 100644 storage/fonts/Times-Roman.afm.php create mode 100644 storage/fonts/dompdf_font_family_cache.php create mode 100644 storage/fonts/roboto-v20-latin-300.eot create mode 100644 storage/fonts/roboto-v20-latin-300.svg create mode 100644 storage/fonts/roboto-v20-latin-300.ttf create mode 100644 storage/fonts/roboto-v20-latin-300.woff create mode 100644 storage/fonts/roboto-v20-latin-300.woff2 create mode 100644 storage/fonts/roboto-v20-latin-500.eot create mode 100644 storage/fonts/roboto-v20-latin-500.svg create mode 100644 storage/fonts/roboto-v20-latin-500.ttf create mode 100644 storage/fonts/roboto-v20-latin-500.woff create mode 100644 storage/fonts/roboto-v20-latin-500.woff2 create mode 100644 storage/fonts/roboto-v20-latin-700.eot create mode 100644 storage/fonts/roboto-v20-latin-700.svg create mode 100644 storage/fonts/roboto-v20-latin-700.ttf create mode 100644 storage/fonts/roboto-v20-latin-700.woff create mode 100644 storage/fonts/roboto-v20-latin-700.woff2 create mode 100644 storage/fonts/roboto-v20-latin-regular.eot create mode 100644 storage/fonts/roboto-v20-latin-regular.svg create mode 100644 storage/fonts/roboto-v20-latin-regular.ttf create mode 100644 storage/fonts/roboto-v20-latin-regular.woff create mode 100644 storage/fonts/roboto-v20-latin-regular.woff2 create mode 100644 storage/fonts/roboto_300_ab1c4ce83665e42f607bea17e0c512f6.ttf create mode 100644 storage/fonts/roboto_300_ab1c4ce83665e42f607bea17e0c512f6.ufm create mode 100644 storage/fonts/roboto_500_9fe4eefaabe67c0d9ffb5dfea5faf22c.ttf create mode 100644 storage/fonts/roboto_500_9fe4eefaabe67c0d9ffb5dfea5faf22c.ufm create mode 100644 storage/fonts/roboto_500_9fe4eefaabe67c0d9ffb5dfea5faf22c.ufm.php create mode 100644 storage/fonts/roboto_bold_f1d63e51656415e249549767ae9ca561.ttf create mode 100644 storage/fonts/roboto_bold_f1d63e51656415e249549767ae9ca561.ufm create mode 100644 storage/fonts/roboto_bold_f1d63e51656415e249549767ae9ca561.ufm.php create mode 100644 storage/fonts/roboto_normal_295f487ba351be606b24d76db5dd95fa.ttf create mode 100644 storage/fonts/roboto_normal_295f487ba351be606b24d76db5dd95fa.ufm create mode 100644 storage/fonts/roboto_normal_295f487ba351be606b24d76db5dd95fa.ufm.php diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php new file mode 100644 index 0000000..c13ba76 --- /dev/null +++ b/app/Http/Controllers/FileController.php @@ -0,0 +1,66 @@ +path($file->dir.$file->filename); + if (file_exists($path)) { + return Response::file($path); + } + } + + + if ($disk === 'invoice'){ + $shopping_order = \App\Models\ShoppingOrder::findOrFail($id); + $filename = Invoice::getFilename($shopping_order); + $path = Invoice::getDownloadPath($shopping_order); + if (!Storage::disk('public')->exists($path)) { + return Response::make('File no found.', 404); + } + $file = Storage::disk('public')->get($path); + $type = Storage::disk('public')->mimeType($path); + + if($do === 'download'){ + return Response::make($file, 200) + ->header("Content-Type", $type) + ->header('Content-disposition', 'attachment; filename="'.$filename.'"'); + /* $full_path = Invoice::getDownloadPath($shopping_order, true); + $he + if (file_exists($full_path)) { + return Response::download($full_path, $filename); + }*/ + } + if($do === 'stream'){ + return Response::make($file, 200) + ->header("Content-Type", $type) + ->header('Content-disposition','filename="'.$filename.'"'); + } + + } + + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index 2a18979..6bd6507 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -158,8 +158,6 @@ class LeadController extends Controller if(isset($data['m_account']) && $data['m_account']){ $user = User::findOrFail($data['user_id']); $rules['m_account'] = 'unique:user_accounts,m_account,'.$user->account->id.',id'; - - } $validator = Validator::make(Request::all(), $rules); if ($validator->fails()) { @@ -363,6 +361,9 @@ class LeadController extends Controller ->addColumn('first_name', function (User $user) { return $user->account ? $user->account->first_name : ''; }) + ->addColumn('company', function (User $user) { + return $user->account ? $user->account->company : ''; + }) ->addColumn('last_name', function (User $user) { return $user->account ? $user->account->last_name : ''; }) @@ -400,8 +401,6 @@ class LeadController extends Controller return "-"; }) - - ->orderColumn('id', 'id $1') ->orderColumn('confirmed', 'confirmed $1') ->orderColumn('active', 'active $1') diff --git a/app/Http/Controllers/SalesController.php b/app/Http/Controllers/SalesController.php index 942aa35..91818c8 100755 --- a/app/Http/Controllers/SalesController.php +++ b/app/Http/Controllers/SalesController.php @@ -7,6 +7,7 @@ use App\Models\ShoppingOrder; use App\Models\ShoppingPayment; use App\Models\ShoppingUser; use App\Models\UserShop; +use App\Repositories\InvoiceRepository; use App\Services\CustomerPriority; use App\Services\Payment; use Request; @@ -302,10 +303,26 @@ class SalesController extends Controller } if(isset($data['back'])){ - return redirect($data['back']); } return back(); } + + public function invoice(){ + $data = Request::all(); + //$data['id'] ShoppingOrder id + if(!isset($data['id'])){ + abort(404); + } + if(isset($data['action'])){ + if($data['action'] === 'create_invoice'){ + $shopping_order = ShoppingOrder::findOrFail($data['id']); + $invoice_repo = new InvoiceRepository($shopping_order); + $invoice_repo->create($data); + return redirect(route('admin_sales_users_detail', [$shopping_order->id])); + } + } + } + } \ No newline at end of file diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php index 3c6639f..436e8ab 100755 --- a/app/Http/Controllers/User/OrderController.php +++ b/app/Http/Controllers/User/OrderController.php @@ -2,21 +2,22 @@ namespace App\Http\Controllers\User; -use App\Http\Controllers\Controller; +use Auth; +use Yard; +use Request; +use App\User; +use Validator; +use App\Services\Util; use App\Models\Product; -use App\Models\ShippingCountry; -use App\Models\ShoppingInstance; -use App\Models\ShoppingOrder; -use App\Models\ShoppingUser; -use App\Models\UserHistory; use App\Models\UserShop; use App\Services\Payment; -use App\Services\Util; -use App\User; -use Auth; -use Request; -use Validator; -use Yard; +use App\Models\UserHistory; +use App\Models\ShoppingUser; +use App\Models\ShoppingOrder; +use App\Models\ProductCategory; +use App\Models\ShippingCountry; +use App\Models\ShoppingInstance; +use App\Http\Controllers\Controller; class OrderController extends Controller @@ -278,12 +279,8 @@ class OrderController extends Controller public function datatable(){ $show_at = 1; - - // $user = User::find(\Auth::user()->id); - ; - if(Request::get('shipping_is_for') === 'me'){ - $query = Product::select('products.*')->where('active', true)->where(function ($q) { + $query = Product::with('categories')->select('products.*')->where('active', true)->where(function ($q) { $q->where('show_at', '=', 1) ->orWhere('show_at', '=', 2) ->orWhere('show_at', '=', 6); @@ -291,14 +288,11 @@ class OrderController extends Controller }); }else{ - $query = Product::select('products.*')->where('active', true)->where(function ($q) { + $query = Product::with('categories')->select('products.*')->where('active', true)->where(function ($q) { $q->where('show_at', '=', 0) ->orWhere('show_at', '=', 1); }); } - - - //Kunden und Vertriebspartner //->orWhere('show_at', '=', 2); // Nur Vertriebspartner //->orderBy('pos', 'DESC') @@ -347,21 +341,32 @@ class OrderController extends Controller '; })*/ - + + ->addColumn('category', function (Product $product) { + $ret = ""; + foreach($product->categories as $category){ + $ret .= '
'.$category->category->name.'
'; + } + + return $ret; + }) ->addColumn('picture', function (Product $product) { if(count($product->images)){ - return ''; + return ' + +
'; } return ""; }) ->addColumn('price_net', function (Product $product) { - return $product->getFormattedPriceWith(true, true). " €"; + return $product->getFormattedPriceWith(true, true). "€"; }) ->addColumn('price_gross', function (Product $product) { - return $product->getFormattedPriceWith(false, true). " €"; + return $product->getFormattedPriceWith(false, true). "€"; }) ->addColumn('price_vk_gross', function (Product $product) { - return $product->getFormattedPriceWith(false, false). " €"; + return $product->getFormattedPriceWith(false, false). "€"; }) ->addColumn('single_commission', function (Product $product) { return $product->single_commission ? 'Handelspanne: '.$product->getFormattedValueCommission().' %' : 'Staffelprovision + @endif + @else + @if(App\Services\Invoice::isInvoice($shopping_order)) + + + @endif + @endif + @@ -587,7 +609,6 @@ {{ Form::select('shipped', \App\Models\ShoppingOrder::$shippedTypes, $shopping_order->shipped, array('data-live-search'=>'false', 'class'=>'selectpicker') ) }} - - + - {{-- +
+
+

Rechnungen Einstellungen

+
- {{ Form::textarea('settings[prepayment-info][val]', \App\Models\Setting::getContentBySlug('prepayment-info'), array('placeholder'=>__('Inhalt zur Vorkasse'), 'class'=>'form-control summernote-small', 'rows'=>10)) }} - {{ Form::hidden('settings[prepayment-info][type]', 'full_text') }} + + {{ Form::text('settings[invoice-number][val]', \App\Models\Setting::getContentBySlug('invoice-number'), array('class'=>'form-control')) }} + {{ Form::hidden('settings[invoice-number][type]', 'int') }}
- --}} -
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 5f27bed..d1be2b4 100755 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -79,7 +79,6 @@
@endif

{{__('membership.home_copy_last_31', ['days'=>$user->daysActiveAccount()])}}

- @endif