summaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
Diffstat (limited to 'site')
-rw-r--r--site/app/Http/Controllers/WPOfferController.php95
-rw-r--r--site/resources/views/snippets/wpsortbuttons.blade.php62
-rw-r--r--site/resources/views/wpoffer.blade.php104
-rw-r--r--site/routes/web.php7
4 files changed, 268 insertions, 0 deletions
diff --git a/site/app/Http/Controllers/WPOfferController.php b/site/app/Http/Controllers/WPOfferController.php
new file mode 100644
index 0000000..d84f9d2
--- /dev/null
+++ b/site/app/Http/Controllers/WPOfferController.php
@@ -0,0 +1,95 @@
+<?php
+namespace App\Http\Controllers;
+use Illuminate\Http\Request;
+use App\Helpers\CryptoHelper;
+
+use Illuminate\Support\Facades\DB;
+use App\Http\Controllers\Controller;
+
+use Carbon;
+use Illuminate\Support\Facades\Input;
+
+class WPOfferController extends Controller {
+ /**
+ * Shows the index page.
+ *
+ * @return Response
+ */
+ public function showPage(Request $request) {
+
+ /*
+ * Sorting
+ */
+ $sort_by = Input::get("_sort");
+ switch ($sort_by) {
+ case("price"):
+ $sort_by = "discounted_price";
+ break;
+ case("discounted_price"):
+ $sort_by = "discounted_price";
+ break;
+ case("name"):
+ $sort_by = "name";
+ break;
+ case("shop"):
+ $sort_by = "shop";
+ break;
+ case("procent"):
+ $sort_by = "procent";
+ break;
+ case("time"):
+ $sort_by = "created_at";
+ break;
+ case("created_at"):
+ $sort_by = "created_at";
+ break;
+ default:
+ $sort_by = "created_at";
+ break;
+ }
+
+ $order_by = $request->input("_order");
+ if ( "asc" != $order_by ) {
+ $order_by = "desc";
+ }
+
+ /*
+ * Database query
+ */
+ $view_name = \Request::route()->getName();
+ $data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->simplePaginate(10);
+ $data->withPath("/angebote/whisky/");
+ $count = DB::table($view_name . '_view')->whereNotNull('url')->count();
+
+ $rss_feed = "/" . $view_name . "/feed/";
+ $query_string = "";
+ $query_params = Input::except('page');
+ foreach( $query_params as $key => $value) {
+ $query_string .= "&" . $key . "=" . $value;
+ }
+ if ( "" != $query_string ) {
+ $query_string = ltrim($query_string, "&");
+ $rss_feed .= "?" . $query_string;
+ }
+
+ if ( "misc" == $view_name ) {
+ $view_name = "Andere Angebote";
+ if ( $data->count() ) {
+ $title = "andere Angebote";
+ } else {
+ $title = "anderen Angebote";
+ }
+ } else if ( "all" == $view_name ) {
+ $view_name = "Alle Angebote";
+ if ( $data->count() ) {
+ $title = "alle Angebote";
+ } else {
+ $title = "Angebote";
+ }
+ } else {
+ $title = ucfirst($view_name) . "-Angebote";
+ }
+
+ return view('wpoffer', ['data' => $data, 'count' => $count, 'spirit_type' => $view_name, 'rss_feed' => $rss_feed, 'title' => $title ]);
+ }
+}
diff --git a/site/resources/views/snippets/wpsortbuttons.blade.php b/site/resources/views/snippets/wpsortbuttons.blade.php
new file mode 100644
index 0000000..3f283c0
--- /dev/null
+++ b/site/resources/views/snippets/wpsortbuttons.blade.php
@@ -0,0 +1,62 @@
+
+<div class="container" style="margin-bottom: 1rem;">
+<div class="row">
+<div class="btn-toolbar mb-2 align-top w-100" role="toolbar" aria-label="Sortieren">
+ <div class="btn-group" role="group" aria-label="Sortieren">
+ <div class="dropdown mr-2">
+ <button class="btn btn-tertiary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Preis
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <a class="dropdown-item" href="?_sort=price&_order=asc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Preis', 'Niedrigster Preis']);">Niedrigster Preis</a>
+ <a class="dropdown-item" href="?_sort=price&_order=desc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Preis', 'Höchster Preis']);">Höchster Preis</a>
+ </div>
+ </div>
+ <div class="dropdown mr-2">
+ <button class="btn btn-tertiary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Name
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <a class="dropdown-item" href="?_sort=name&_order=asc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Name', 'Alphabetisch']);">Alphabetisch</a>
+ <a class="dropdown-item" href="?_sort=name&_order=desc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Name', 'Umgekehrt']);">Umgekehrt</a>
+ </div>
+ </div>
+ <div class="dropdown mr-2">
+ <button class="btn btn-tertiary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Shop
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <a class="dropdown-item" href="?_sort=shop&_order=asc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Shop', 'Alphabetisch']);">Alphabetisch</a>
+ <a class="dropdown-item" href="?_sort=shop&_order=desc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Shop', 'Umgekehrt']);">Umgekehrt</a>
+ </div>
+ </div>
+ </div>
+ <div class="btn-group mr-auto" role="group" aria-label="Sortieren">
+ <div class="dropdown mr-2">
+ <button class="btn btn-tertiary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Preisnachlass
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <a class="dropdown-item" href="?_sort=procent&_order=asc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Preisnachlass', 'Niedrigster Preisnachlass']);">Niedrigster Preisnachlass</a>
+ <a class="dropdown-item" href="?_sort=procent&_order=desc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Preisnachlass', 'Höchster Preisnachlass']);">Höchster Preisnachlass</a>
+ </div>
+ </div>
+ <div class="dropdown">
+ <button class="btn btn-tertiary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Aktualität
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <a class="dropdown-item" href="?_sort=time&_order=desc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Aktualität', 'Neueste zuerst']);">Neueste zuerst</a>
+ <a class="dropdown-item" href="?_sort=time&_order=asc{!! Request::is('search') ? '&q=' : '' !!}{{ Request::is('search') ? $search_phrase : '' }}" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'Aktualität', 'Älteste zuerst']);">Älteste zuerst</a>
+ </div>
+ </div>
+ </div>
+ <div class="btn-group " role="group" aria-label="Sortieren" style="justify-content: flex-end;">
+ <a class="btn btn-rss text-white" href={{ secure_url($rss_feed) }} title="Link zum RSS-Feed" oonclick="javascript:_paq.push(['trackEvent', 'Sort-Button', 'RSS-Feed']);">
+ <span class="oi oi-rss-alt" title="RSS-Feed" aria-hidden="true"></span>
+ </a>
+ </div>
+</div>
+</div>
+</div>
+
diff --git a/site/resources/views/wpoffer.blade.php b/site/resources/views/wpoffer.blade.php
new file mode 100644
index 0000000..3243b26
--- /dev/null
+++ b/site/resources/views/wpoffer.blade.php
@@ -0,0 +1,104 @@
+<?php
+if ( !$data->count() ) {
+ /* Keine Angebote */
+?>
+<div class="alert alert-secondary" data-track-content data-content-name="{{ ucfirst($spirit_type) }}" data-content-piece="Keine Angebote" data-content-target="">
+ <h4 class="alert-heading">Keine Angebote</h4>
+ Momentan liegen keine {{ $title }} vor. Probieren Sie es später noch einmal.
+</div>
+<?php
+ /* Ende Keine Angebote */
+} else {
+ /* Liste Angebote */
+
+?>
+
+@include('snippets.wpsortbuttons')
+<?php
+ foreach( $data as $offer) {
+?>
+
+ <div class="card">
+ <div class="row ">
+ <div class="col-md-4">
+<?php
+if ( "Drankdozijn" == $offer->shop ) {
+ $img_style = 'style="padding-top: 0.75rem;"';
+ $badge_style = 'style="margin-bottom: 150% !important;"';
+ $badge_style = 'style="top: 0 !important;"';
+ #$badge_style = "";
+} else {
+ $img_style = "";
+ $badge_style = "";
+?>
+ <div class="card-header-dp-none">
+ <p><strong>
+ <span style="visibility: hidden;">
+ {{ ucfirst($spirit_type) }} <span class="float-right">{{ $offer->shop }}</span>
+ </span>
+ </strong></p>
+ </div>
+<?php
+}
+?>
+ <div class="card-img-overlay card-img-overlay-badge" {!! $badge_style !!}>
+ <p class="card-text float-right rounded off-badge" {!! $badge_style !!}>{{ $offer->procent}}%</p>
+ </div>
+ <img src="{{ $offer->image_url}}" class="w-100 card-img" {!! $img_style !!}>
+ </div>
+ <div class="col-md-8 px-10">
+ <div class="card-header">
+ <p><strong>
+ {{ ucfirst($spirit_type) }} <span class="float-right">{{ $offer->shop }}</span>
+ </strong></p>
+ </div>
+ <div class="card-block card-body px-3">
+ <h3 class="card-title">{{ $offer->name }}</h3>
+ <div class="row">
+ <p class="card-text col-md-6">
+ Preis: {{ TF::fF($offer->discounted_price) }} €
+ <br>
+ Alter Preis: {{ TF::fF($offer->original_price) }} €
+ <br>
+<?php
+ if ( "" != $offer->free_shipping ) {
+ # todo: remove € sign from $free_shipping variable
+ $free_shipping = str_replace("€", "", $offer->free_shipping);
+?>
+ Versand: {{ TF::fF($offer->shipping_costs) }} €, gratis ab {{ $free_shipping }} €
+<?php
+ } else {
+?>
+ Versand ist nie kostenlos
+<?php
+ }
+?>
+ </p>
+ <p class="card-text col-md-6">
+ Alkohol: {{ TF::fF($offer->abv) . " %" }}
+ <br>
+ Volumen: {{ TF::fF($offer->volume) . " Liter" }}
+ <br>
+ {{ TF::fF($offer->base_price ) }} € / Liter
+ </p>
+ </div>
+ </div>
+ <div class="card-footer">
+ <a href="{{ $offer->url }}" class="btn btn-primary">Zum Shop</a>
+ <p class="float-right">Preis vom {{ strftime("%d. %B", $offer->created_at) }}</p>
+ </div>
+ </div>
+
+ </div>
+ </div>
+<?php
+}
+?>
+
+{{ $data->appends(Input::except('page'))->links() }}
+
+<?php
+ /* Ende Liste Angebote */
+}
+
+?>
diff --git a/site/routes/web.php b/site/routes/web.php
index d467ce0..4d58046 100644
--- a/site/routes/web.php
+++ b/site/routes/web.php
@@ -20,6 +20,13 @@ Route::get('/rum', 'OfferController@showPage')->name('rum');
Route::get('/misc', 'OfferController@showPage')->name('misc');
Route::get('/all', 'OfferController@showPage')->name('all');
+Route::get('/wp/whisky', 'WPOfferController@showPage')->name('whisky');
+Route::get('/wp/wodka', 'WPOfferController@showPage')->name('wodka');
+Route::get('/wp/gin', 'WPOfferController@showPage')->name('gin');
+Route::get('/wp/rum', 'WPOfferController@showPage')->name('rum');
+Route::get('/wp/misc', 'WPOfferController@showPage')->name('misc');
+Route::get('/wp/all', 'WPOfferController@showPage')->name('all');
+
Route::get('/search', 'SearchController@showPage')->name('search');
Route::get('/feeds', 'PageFeedController@showPage')->name('feed');