diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d67f73a..b2b3b33 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,49 +2,25 @@ - - - - - - - - - - - + + - - + + + + - - + + - - - - - - - - - + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - yout - tem ?> exca tax @@ -239,6 +147,8 @@ ac card_show route + $(this).find(".modal-body select[name='factor']").val(button.data('factor')); + dele @@ -276,15 +186,6 @@ @@ -578,6 +488,12 @@ + + + + + + @@ -790,17 +706,17 @@ + - - - + @@ -841,138 +757,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -987,13 +771,6 @@ - - - - - - - @@ -1018,27 +795,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -1067,13 +823,6 @@ - - - - - - - @@ -1094,15 +843,9 @@ - - - - - - @@ -1110,25 +853,6 @@ - - - - - - - - - - - - - - - - - - - @@ -1136,10 +860,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1150,35 +1035,77 @@ - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/Http/Controllers/DataTableController.php b/app/Http/Controllers/DataTableController.php index f678a7e..15c4b56 100644 --- a/app/Http/Controllers/DataTableController.php +++ b/app/Http/Controllers/DataTableController.php @@ -50,8 +50,14 @@ class DataTableController extends Controller $query = User::where('deleted_at', '=', null); return \DataTables::eloquent($query) + ->addColumn('first_name', function (User $user) { + return $user->account ? $user->account->first_name : ''; + }) + ->addColumn('last_name', function (User $user) { + return $user->account ? $user->account->last_name : ''; + }) ->addColumn('action_edit', function (User $user) { - return ''; + return ''; }) ->addColumn('admin', function (User $user) { return ''.HTMLHelper::getRoleLabel($user->admin).''; @@ -62,13 +68,24 @@ class DataTableController extends Controller ->addColumn('active', function (User $user) { return $user->active ? ' ' : ''; }) + ->addColumn('shop', function (User $user) { + if($user->shop){ + if($user->shop->active){ + return ' active'.$user->shop->getActiveDateFormatSmall(); + }else{ + return' deactive'.$user->shop->getActiveDateFormatSmall(); + } + } + return ''; + }) ->addColumn('action_delete', function (User $user) { return ''; }) ->orderColumn('confirmed', 'confirmed $1') ->orderColumn('active', 'active $1') + ->orderColumn('shop', 'shop $1') ->orderColumn('admin', 'active $1') - ->rawColumns(['action_edit', 'admin', 'confirmed', 'active', 'action_delete']) + ->rawColumns(['action_edit', 'admin', 'confirmed', 'active', 'shop', 'action_delete']) ->make(true); } diff --git a/app/Http/Controllers/ShippingController.php b/app/Http/Controllers/ShippingController.php index 1474c5c..342ac86 100755 --- a/app/Http/Controllers/ShippingController.php +++ b/app/Http/Controllers/ShippingController.php @@ -6,6 +6,8 @@ namespace App\Http\Controllers; use App\Models\Shipping; +use App\Models\ShippingCountry; +use App\Models\ShippingPrice; use Input; use Illuminate\Http\Request; use Validator; @@ -55,50 +57,94 @@ class ShippingController extends Controller */ public function store(Request $request) { - $data = Input::all(); - if ($data['id'] == "new") { - $shipping = new Shipping(); - $rules = array( - 'name' => 'required', - ); - - } else { - $shipping = Shipping::findOrFail($data['id']); - $rules = array( - 'name' => 'required', - ); - } - $data = [ - 'value' => $shipping, - ]; - $validator = Validator::make(Input::all(), $rules); - - if ($validator->fails()) { - return view('admin.shipping.edit', $data)->withErrors($validator); - - } + $shipping = false; $data = Input::all(); - $shipping->name = $data['name']; - $shipping->free = $data['free']; - $shipping->active = isset($data['active']) ? true : false; - $shipping->save(); + if($data['action'] == 'shipping'){ + if ($data['id'] == "new") { + $shipping = new Shipping(); + $rules = array('name' => 'required'); + } else { + $shipping = Shipping::findOrFail($data['id']); + $rules = array('name' => 'required'); + } + $ret = ['value' => $shipping]; + $validator = Validator::make(Input::all(), $rules); + if ($validator->fails()) { + return view('admin.shipping.edit', $ret)->withErrors($validator); + } + $data = Input::all(); + $shipping->name = $data['name']; + $shipping->free = $data['free']; + $shipping->active = isset($data['active']) ? true : false; + $shipping->save(); + } + if($data['action'] == 'price'){ + $shipping = Shipping::findOrFail($data['shipping_id']); + $rules = array('price' => 'required'); + $ret = ['value' => $shipping]; + $validator = Validator::make(Input::all(), $rules); + if ($validator->fails()) { + return view('admin.shipping.edit', $ret)->withErrors($validator); + } + if ($data['id'] == "new") { + $price = ShippingPrice::create($data); + } else { + $price = ShippingPrice::findOrFail($data['id']); + if($price->shipping_id != $shipping->id){ + abort(404); + } + $price->fill($data); + $price->save(); + } - \Session()->flash('alert-save', true); + } + if($data['action'] == 'country'){ + $shipping = Shipping::findOrFail($data['shipping_id']); + foreach($data['country_ids'] as $country_id){ + if(ShippingCountry::where('country_id', $country_id)->count() == 0){ + ShippingCountry::create([ + 'shipping_id' => $shipping->id, + 'country_id' => $country_id + ]); + } + } + } - return redirect(route('admin_shipping_edit', [$shipping->id])); + if($shipping){ + \Session()->flash('alert-save', true); + return redirect(route('admin_shipping_edit', [$shipping->id])); + } + return redirect(route('admin_shippings')); } - public function deleteShipping($shipping_id) - { - $shipping = Shipping::findOrFail($shipping_id); - $shipping->delete(); + public function deleteShipping($id) + { + $model = Shipping::findOrFail($id); + $model->delete(); \Session()->flash('alert-success', "Versandkosten gelöscht"); return redirect('/admin/shippings'); + } + public function deletePrice($id) + { + $model = ShippingPrice::findOrFail($id); + $shipping = $model->shipping; + $model->delete(); + \Session()->flash('alert-success', "Preis gelöscht"); + return redirect(route('admin_shipping_edit', [$shipping->id])); + } + + public function deleteCountry($id) + { + $model = ShippingCountry::findOrFail($id); + $shipping = $model->shipping; + $model->delete(); + \Session()->flash('alert-success', "Preis gelöscht"); + return redirect(route('admin_shipping_edit', [$shipping->id])); } } \ No newline at end of file diff --git a/app/Http/Controllers/Web/CardController.php b/app/Http/Controllers/Web/CardController.php index bb46d50..44eb9cb 100755 --- a/app/Http/Controllers/Web/CardController.php +++ b/app/Http/Controllers/Web/CardController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web; use App\Http\Controllers\Controller; use App\Models\Product; +use App\Models\ShippingCountry; use Util; use Yard; use Input; @@ -57,6 +58,15 @@ class CardController extends Controller } public function showCard(){ + + if(Input::get('selected_country')){ + $selected_country = Input::get('selected_country'); + }else{ + $ShippingCountry = ShippingCountry::where('country_id', 1)->first(); + $selected_country = $ShippingCountry->id; + } + Yard::instance('shopping')->setShippingCountry($selected_country); + $data = [ 'user_shop' => Util::getUserShop(), ]; @@ -76,7 +86,14 @@ class CardController extends Controller return back(); } - public function checkoutCard(){ + public function checkoutCard(){# + if(Input::get('selected_country')){ + $selected_country = Input::get('selected_country'); + }else{ + $ShippingCountry = ShippingCountry::where('country_id', 1)->first(); + $selected_country = $ShippingCountry->id; + } + Yard::instance('shopping')->setShippingCountry($selected_country); $data = [ 'user_shop' => Util::getUserShop(), ]; diff --git a/app/Models/Product.php b/app/Models/Product.php index e7f8606..19f6983 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -105,6 +105,7 @@ class Product extends Model 'price_ek', 'tax', 'price_old', + 'weight', 'contents', 'number', 'icons', diff --git a/app/Models/Shipping.php b/app/Models/Shipping.php index 61fab51..87296fe 100644 --- a/app/Models/Shipping.php +++ b/app/Models/Shipping.php @@ -30,7 +30,7 @@ class Shipping extends Model } public function getFormattedFree() { - if($this->attributes['free'] === null) { + if($this->free === null) { return ""; } if(\App::getLocale() == "en"){ diff --git a/app/Models/ShippingCountry.php b/app/Models/ShippingCountry.php index e278512..bac9a5d 100644 --- a/app/Models/ShippingCountry.php +++ b/app/Models/ShippingCountry.php @@ -22,4 +22,5 @@ class ShippingCountry extends Model { return $this->belongsTo('App\Models\Country', 'country_id'); } + } diff --git a/app/Models/ShippingPrice.php b/app/Models/ShippingPrice.php index 44d2035..2888505 100644 --- a/app/Models/ShippingPrice.php +++ b/app/Models/ShippingPrice.php @@ -18,47 +18,75 @@ class ShippingPrice extends Model } - public function _format_number($value){ + public function _format_number($value) + { return preg_replace("/[^0-9,]/", "", $value); } - public function setPriceAttribute( $value ) { + public function setPriceAttribute($value) + { $value = $this->_format_number($value); $this->attributes['price'] = floatval(str_replace(',', '.', $value)); - } - public function setFactorAttribute( $value ) { - $value = $this->_format_number($value); - $this->attributes['factor'] = floatval(str_replace(',', '.', $value)); - } - public function setTaxAttribute( $value ) { - $value = $this->_format_number($value); - $this->attributes['tax'] = floatval(str_replace(',', '.', $value)); - } - public function setPriceOldAttribute( $value ) { - $value = $this->_format_number($value); - $this->attributes['price_old'] = floatval(str_replace(',', '.', $value)); + } - public function setTotalFromAttribute( $value ) { + public function setFactorAttribute($value) + { $value = $this->_format_number($value); - $this->attributes['total_from'] = floatval(str_replace(',', '.', $value)); + if ($value == "") { + $this->attributes['factor'] = null; + } else { + $this->attributes['factor'] = floatval(str_replace(',', '.', $value)); + } } - public function setTotalToAttribute( $value ) { + + public function setTaxAttribute($value) + { $value = $this->_format_number($value); - $this->attributes['total_to'] = floatval(str_replace(',', '.', $value)); + if ($value == "") { + $this->attributes['tax'] = null; + } else { + $this->attributes['tax'] = floatval(str_replace(',', '.', $value)); + } + } + + + public function setTotalFromAttribute($value) + { + $value = $this->_format_number($value); + if ($value == "") { + $this->attributes['total_from'] = null; + } else { + $this->attributes['total_from'] = floatval(str_replace(',', '.', $value)); + } + } + + public function setTotalToAttribute($value) + { + $value = $this->_format_number($value); + if ($value == "") { + $this->attributes['total_to'] = null; + } else { + + $this->attributes['total_to'] = floatval(str_replace(',', '.', $value)); + } } public function getFormattedPrice() { - if(\App::getLocale() == "en"){ + if (\App::getLocale() == "en") { return number_format($this->attributes['price'], 2, '.', ','); } return number_format($this->attributes['price'], 2, ',', '.'); } + public function getFormattedTax() { - if(\App::getLocale() == "en"){ + if ($this->attributes['tax'] === NULL) { + return $this->attributes['tax']; + } + if (\App::getLocale() == "en") { return number_format($this->attributes['tax'], 2, '.', ','); } return number_format($this->attributes['tax'], 2, ',', '.'); @@ -66,7 +94,10 @@ class ShippingPrice extends Model public function getFormattedFactor() { - if(\App::getLocale() == "en"){ + if ($this->attributes['factor'] === NULL) { + return $this->attributes['factor']; + } + if (\App::getLocale() == "en") { return number_format($this->attributes['factor'], 2, '.', ','); } return number_format($this->attributes['factor'], 2, ',', '.'); @@ -75,19 +106,25 @@ class ShippingPrice extends Model public function getFormatTotalFrom() { - if(\App::getLocale() == "en"){ + if ($this->attributes['total_from'] === NULL) { + return $this->attributes['total_from']; + } + if (\App::getLocale() == "en") { return number_format($this->attributes['total_from'], 2, '.', ','); } return number_format($this->attributes['total_from'], 2, ',', '.'); } + public function getFormattedTotalTo() { - if(\App::getLocale() == "en"){ + if ($this->attributes['total_to'] === NULL) { + return $this->attributes['total_to']; + } + if (\App::getLocale() == "en") { return number_format($this->attributes['total_to'], 2, '.', ','); } return number_format($this->attributes['total_to'], 2, ',', '.'); } - } diff --git a/app/Models/UserShop.php b/app/Models/UserShop.php index ae0fbcb..14decc9 100644 --- a/app/Models/UserShop.php +++ b/app/Models/UserShop.php @@ -47,6 +47,11 @@ class UserShop extends Model return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB()); } + public function getActiveDateFormatSmall(){ + if(!$this->attributes['active_date']){ return ""; } + return Carbon::parse($this->attributes['active_date'])->format("d.m.Y"); + } + public function getSubdomain() { diff --git a/app/Services/HTMLHelper.php b/app/Services/HTMLHelper.php index 64e7f56..ffaa647 100644 --- a/app/Services/HTMLHelper.php +++ b/app/Services/HTMLHelper.php @@ -4,6 +4,7 @@ namespace App\Services; use App\Models\Attribute; use App\Models\Category; use App\Models\Country; +use App\Models\ShippingCountry; class HTMLHelper { @@ -189,6 +190,36 @@ class HTMLHelper return $ret; } + public static function getCountriesWithoutUsedShippings($all=true){# + $values = Country::all(); + $country_ids = ShippingCountry::all()->pluck('country_id')->toArray(); + $ret = ""; + if($all){ + $ret .= '\n'; + } + foreach ($values as $value){ + if(!in_array($value->id, $country_ids)){ + $ret .= '\n'; + } + } + return $ret; + } + + public static function getCountriesForShipping($id, $all=false){# + $values = ShippingCountry::all(); + $ret = ""; + if($all){ + $ret .= '\n'; + } + foreach ($values as $value){ + $attr = ($value->id == $id) ? 'selected="selected"' : ''; + $ret .= '\n'; + + } + return $ret; + } + + public static function getSalutation($id){ $values = array('mr' => __('MR'), 'ms' => __('MS')); diff --git a/app/Services/Yard.php b/app/Services/Yard.php index d8e8dfa..7d7505e 100644 --- a/app/Services/Yard.php +++ b/app/Services/Yard.php @@ -1,6 +1,7 @@ shipping_country_id = $shipping_country_id ; + if($this->shipping_country_id > 0){ + $shippingCountry = ShippingCountry::find($this->shipping_country_id); + $shipping = $shippingCountry->shipping; + $price = $shipping->prices->first(); + if($price){ + $this->setShipping($price->price); + } + } + } + + public function getShippingCountry() + { + return $this->shipping_country_id; + } + /** * @param null $decimals * @param null $decimalPoint diff --git a/resources/lang/de.json b/resources/lang/de.json index dc5bd28..60ad204 100755 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -161,7 +161,7 @@ "Contact": "Kontakt", "waiting for activation since": "wartet auf Aktivierung seit", "edit": "bearbeiten", - "delete": "\u00f6schen", + "delete": "l\u00f6schen", "your mivita.care team": "Dein mivita.care Team", "create new password": "neues Passwort erstellen", "Now assign a password.": "Vergeben Sie jetzt Ihr Passwort für den Zugriff auf Ihren Account.", diff --git a/resources/views/admin/product/form.blade.php b/resources/views/admin/product/form.blade.php index b7a9d45..1c985d9 100755 --- a/resources/views/admin/product/form.blade.php +++ b/resources/views/admin/product/form.blade.php @@ -75,9 +75,10 @@ {{ Form::text('amount', $product->amount, array('placeholder'=>__('amount'), 'class'=>'form-control', 'id'=>'amount')) }} - - - +
+ + {{ Form::text('weight', $product->weight, array('placeholder'=>__('Gewicht in g'), 'class'=>'form-control', 'id'=>'weight')) }} +
diff --git a/resources/views/admin/shipping/edit.blade.php b/resources/views/admin/shipping/edit.blade.php index 1097b3f..a8e663e 100755 --- a/resources/views/admin/shipping/edit.blade.php +++ b/resources/views/admin/shipping/edit.blade.php @@ -20,51 +20,254 @@ {{ __('Create/Edit Versandkosten') }} - {!! Form::open(['url' => route('admin_shipping_store'), 'class' => 'form-horizontal', 'id'=>'']) !!} - -
-   {{ __('back') }}
-
- + {!! Form::open(['url' => route('admin_shipping_store'), 'class' => 'form-horizontal', 'id'=>'']) !!} +
{{ __('Versandkosten') }} -
-
-
- - - {{ Form::text('name', $value->name, array('placeholder'=>__('Name'), 'class'=>'form-control'.($errors->has('name') ? ' is-invalid' : ''), 'id'=>'name', 'required')) }} +
+
+ + + {{ Form::text('name', $value->name, array('placeholder'=>__('Name'), 'class'=>'form-control'.($errors->has('name') ? ' is-invalid' : ''), 'required')) }} + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ + + {{ Form::text('free', $value->getFormattedFree(), array('placeholder'=>__('in Euro, leer lassen ohne Freigrenze'), 'class'=>'form-control')) }} +
- @if ($errors->has('name')) - - {{ $errors->first('name') }} - - @endif - - -
- - {{ Form::text('free', $value->getFormattedFree(), array('placeholder'=>__('Free'), 'class'=>'form-control', 'id'=>'free')) }} +
+  
+
+ {!! Form::close() !!} +
+ @if($value->id>0) +
+
+ {{__('Preise')}} +
+
+ + + + + + + + + + + + + + @foreach($value->prices as $price) + + + + + + + + + + @endforeach + +
 {{__('Preis')}}{{__('Tax')}}{{__('Preis von - bis')}}{{__('Gewicht von - bis')}}
+ + {{ $price->getFormattedPrice() }}{{ $price->getFormattedTax() }}{{ $price->getFormatTotalFrom() }} - {{ $price->getFormattedTotalTo() }}{{ $price->weight_from }} - {{ $price->weight_to }}
+
+ + + +
-
-   - {{ __('back') }} + + + - {!! Form::close() !!} +
+
+ {{__('Länder')}} +
+
+ + + + + + + + + @foreach($value->countries as $country) + + + + + + @endforeach + +
{{__('Land')}}
+ {{ $country->country->de }} +
+
+ + +
+
+
+ + + + + + + + @endif + diff --git a/resources/views/admin/shipping/index.blade.php b/resources/views/admin/shipping/index.blade.php index 074da9c..edb3779 100755 --- a/resources/views/admin/shipping/index.blade.php +++ b/resources/views/admin/shipping/index.blade.php @@ -47,7 +47,8 @@ "iDisplayLength": 50, "aoColumns": [ { "sWidth": "10%" }, - { "sWidth": "80%" }, + { "sWidth": "70%" }, + { "sWidth": "10%" }, { "sWidth": "10%" }, ], "language": { diff --git a/resources/views/admin/users.blade.php b/resources/views/admin/users.blade.php index 06f30fe..4ef2f09 100644 --- a/resources/views/admin/users.blade.php +++ b/resources/views/admin/users.blade.php @@ -15,11 +15,13 @@ {{__('edit')}} - {{__('Name')}} + {{__('First name')}} + {{__('Last name')}} {{__('E-Mail')}} {{__('Zugang')}} {{__('verified')}} {{__('active')}} + {{__('shop')}} {{__('delete')}} @@ -104,11 +106,13 @@ "ajax": '{!! route('data_table_users') !!}', "columns": [ { data: 'action_edit', orderable: false, searchable: false}, - { data: 'name', name: 'name' }, + { data: 'first_name', name: 'first_name' }, + { data: 'last_name', name: 'last_name' }, { data: 'email', name: 'email' }, { data: 'admin', name: 'admin' }, { data: 'confirmed', name: 'confirmed' }, { data: 'active', name: 'active' }, + { data: 'shop', name: 'shop' }, { data: 'action_delete', orderable: false, searchable: false}, ], "bLengthChange": false, diff --git a/resources/views/web/templates/card.blade.php b/resources/views/web/templates/card.blade.php index b643604..a3e0ec5 100644 --- a/resources/views/web/templates/card.blade.php +++ b/resources/views/web/templates/card.blade.php @@ -91,7 +91,6 @@ - {{ Yard::instance('shopping')->setShipping(5.9) }}
@@ -158,7 +157,7 @@ @endforeach
- Warenkorb löschen + Warenkorb löschen
@@ -171,7 +170,16 @@
- +
@@ -187,6 +195,18 @@ {{ Yard::instance('shopping')->total() }} € Zwischensumme:
+
+ +
+
Versandland:
+
+
+ +
+
+
{{ Yard::instance('shopping')->shipping() }} € diff --git a/resources/views/web/templates/checkout.blade.php b/resources/views/web/templates/checkout.blade.php index 64cea1c..9d1b82e 100644 --- a/resources/views/web/templates/checkout.blade.php +++ b/resources/views/web/templates/checkout.blade.php @@ -84,7 +84,6 @@ - {{ Yard::instance('shopping')->setShipping(5.9) }}
diff --git a/resources/views/web/user/start.blade.php b/resources/views/web/user/start.blade.php index 32dcf9d..c724bd6 100644 --- a/resources/views/web/user/start.blade.php +++ b/resources/views/web/user/start.blade.php @@ -9,7 +9,14 @@ } + diff --git a/routes/web.php b/routes/web.php index 69fcfb3..5a06448 100755 --- a/routes/web.php +++ b/routes/web.php @@ -189,7 +189,10 @@ Route::domain('mein.mivita.local')->group(function () { Route::get('/admin/shippings', 'ShippingController@index')->name('admin_shippings'); Route::get('/admin/shipping/edit/{shipping_id}', 'ShippingController@edit')->name('admin_shipping_edit'); Route::post('/admin/shipping/store', 'ShippingController@store')->name('admin_shipping_store'); - Route::get('/admin/shipping/delete/{shipping_id}', 'ShippingController@deleteUser')->name('admin_shipping_delete'); + Route::get('/admin/shipping/delete/{shipping_id}', 'ShippingController@deleteShipping')->name('admin_shipping_delete'); + Route::get('/admin/shipping/price/delete/{price_id}', 'ShippingController@deletePrice')->name('admin_shipping_price_delete'); + Route::get('/admin/shipping/country/delete/{price_id}', 'ShippingController@deleteCountry')->name('admin_shipping_country_delete'); + Route::get('data_table', 'DataTableController@datatable')->name('data_table'); // Route::get('datatables/leads', 'DataTableController@getLeads')->name('datatables-leads');