shipping costs

This commit is contained in:
Kevin Adametz 2019-01-07 00:15:41 +01:00
parent d4f6a774d0
commit 22a2b4710a
20 changed files with 797 additions and 457 deletions

View file

@ -20,51 +20,254 @@
{{ __('Create/Edit Versandkosten') }}
</h4>
{!! Form::open(['url' => route('admin_shipping_store'), 'class' => 'form-horizontal', 'id'=>'']) !!}
<input type="hidden" name="id" id="id" value="@if($value->id>0){{$value->id}}@else new @endif">
<div class="text-left mt-0 mb-2">
<button type="submit" class="btn btn-submit">{{ __('save') }}</button>&nbsp;
<a href="{{ route('admin_shippings') }}" class="btn btn-default">{{ __('back') }}</a>
</div>
<div class="card mb-2">
{!! Form::open(['url' => route('admin_shipping_store'), 'class' => 'form-horizontal', 'id'=>'']) !!}
<input type="hidden" name="id" value="@if($value->id>0){{$value->id}}@else new @endif">
<h5 class="card-header">
{{ __('Versandkosten') }}
</h5>
<div class="card-body">
<div class="form-group">
<label class="custom-control custom-checkbox float-right">
{!! Form::checkbox('active', 1, $value->active, ['class'=>'custom-control-input']) !!}
<span class="custom-control-label">{{__('aktiv')}}</span>
</label>
<label class="form-label" for="name">{{ __('Name') }}*</label>
{{ Form::text('name', $value->name, array('placeholder'=>__('Name'), 'class'=>'form-control'.($errors->has('name') ? ' is-invalid' : ''), 'id'=>'name', 'required')) }}
<div class="form-row">
<div class="form-group col-md-6">
<label class="form-label" for="name">{{ __('Name') }}*</label>
{{ Form::text('name', $value->name, array('placeholder'=>__('Name'), 'class'=>'form-control'.($errors->has('name') ? ' is-invalid' : ''), 'required')) }}
@if ($errors->has('name'))
<span class="invalid-feedback" style="display: inline-block;">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
<div class="form-group col-md-6">
<label class="custom-control custom-checkbox float-right">
{!! Form::checkbox('active', 1, $value->active, ['class'=>'custom-control-input']) !!}
<span class="custom-control-label">{{__('aktiv')}}</span>
</label>
<label class="form-label" for="title">{{ __('Versandkosten frei ab') }}</label>
{{ Form::text('free', $value->getFormattedFree(), array('placeholder'=>__('in Euro, leer lassen ohne Freigrenze'), 'class'=>'form-control')) }}
</div>
</div>
@if ($errors->has('name'))
<span class="invalid-feedback" style="display: inline-block;">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
<div class="form-group">
<label class="form-label" for="title">{{ __('Free') }}</label>
{{ Form::text('free', $value->getFormattedFree(), array('placeholder'=>__('Free'), 'class'=>'form-control', 'id'=>'free')) }}
<div class="text-left mt-0 mb-2">
<button type="submit" class="btn btn-secondary" name="action" value="shipping">{{ __('save') }}</button>&nbsp;
</div>
</div>
{!! Form::close() !!}
</div>
@if($value->id>0)
<div class="card mb-2">
<h6 class="card-header">
{{__('Preise')}}
</h6>
<div class="card-datatable table-responsive">
<table class="datatables-style table table-striped table-bordered">
<thead>
<tr>
<th style="max-width: 60px;">&nbsp;</th>
<th>{{__('Preis')}}</th>
<th>{{__('Tax')}}</th>
<th>{{__('Preis von - bis')}}</th>
<th>{{__('Gewicht von - bis')}}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($value->prices as $price)
<tr>
<td>
<button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-price"
data-id="{{ $price->id }}"
data-price="{{ $price->getFormattedPrice() }}"
data-tax="{{ $price->getFormattedTax() }}"
data-factor="{{ $price->getFormattedFactor() }}"
data-total_from="{{ $price->getFormatTotalFrom() }}"
data-total_to="{{ $price->getFormattedTotalTo() }}"
data-weight_from="{{ $price->weight_from }}"
data-weight_to="{{ $price->weight_to }}">
<span class="far fa-edit"></span>
</button>
</td>
<td>{{ $price->getFormattedPrice() }}</td>
<td>{{ $price->getFormattedTax() }}</td>
<td>{{ $price->getFormatTotalFrom() }} - {{ $price->getFormattedTotalTo() }}</td>
<td>{{ $price->weight_from }} - {{ $price->weight_to }}</td>
<td><a class="text-danger" href="{{ route('admin_shipping_price_delete', [$price->id]) }}" onclick="return confirm('{{__('Really delete entry?')}}');"><i class="far fa-trash-alt"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
<div class="mt-4 ml-4">
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-price"
data-id="new"
data-price=""
data-tax=""
data-factor="1"
data-total_from=""
data-total_to=""
data-weight_from=""
data-weight_to=""
>{{__('Neuen Preis erstellen')}}</button>
</div>
</div>
</div>
<div class="text-left mt-0 mb-2">
<button type="submit" class="btn btn-submit">{{ __('save') }}</button>&nbsp;
<a href="{{ route('admin_shippings') }}" class="btn btn-default">{{ __('back') }}</a>
<!-- Modal template price -->
<div class="modal fade" id="modals-price">
<div class="modal-dialog">
<form class="modal-content" action="{{ route('admin_shipping_store') }}" method="post">
@csrf
<input type="hidden" name="id">
<input type="hidden" name="shipping_id" value="@if($value->id>0){{$value->id}}@else new @endif">
<div class="modal-header">
<h5 class="modal-title"> {{__('Preis')}} <span class="font-weight-light">{{__('create/edit')}}</span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col-6">
<label for="price" class="form-label">{{__('Preis (brutto)')}}*</label>
<input type="text" class="form-control" name="price" placeholder="{{__('Preis in Euro')}}" required>
</div>
<div class="form-group col-6">
<label for="tax" class="form-label">{{__('enthaltene Tax (%)')}}</label>
<input type="text" class="form-control" name="tax" placeholder="{{__('Tax in %')}}">
</div>
</div>
<div class="form-row">
<div class="form-group col-6">
<label for="total_from" class="form-label">{{__('von Preis')}}</label>
<input type="text" class="form-control" name="total_from" placeholder="{{__('Preis in Euro')}}">
</div>
<div class="form-group col-6">
<label for="total_to" class="form-label">{{__('bis Preis')}}</label>
<input type="text" class="form-control" name="total_to" placeholder="{{__('Preis in Euro')}}">
</div>
</div>
<div class="form-row">
<div class="form-group col-6">
<label for="weight_from" class="form-label">{{__('von Gewicht (g)')}}</label>
<input type="text" class="form-control" name="weight_from" placeholder="{{__('in g')}}">
</div>
<div class="form-group col-6">
<label for="weight_to" class="form-label">{{__('bis Gewicht (g)')}}</label>
<input type="text" class="form-control" name="weight_to" placeholder="{{__('in g')}}">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
<button type="submit" class="btn btn-primary" name="action" value="price">{{__('save')}}</button>
</div>
</form>
</div>
</div>
{!! Form::close() !!}
<div class="card mb-2">
<h6 class="card-header">
{{__('Länder')}}
</h6>
<div class="card-datatable table-responsive">
<table class="datatables-style table table-striped table-bordered">
<thead>
<tr>
<th>{{__('Land')}}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($value->countries as $country)
<tr>
<td>
{{ $country->country->de }}
</td>
<td><a class="text-danger" href="{{ route('admin_shipping_country_delete', [$country->id]) }}" onclick="return confirm('{{__('Really delete entry?')}}');"><i class="far fa-trash-alt"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
<div class="mt-4 ml-4">
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-country"
data-id="new"
>{{__('Land hinzufügen')}}</button>
</div>
</div>
</div>
<!-- Modal template -->
<div class="modal fade" id="modals-country">
<div class="modal-dialog">
<form class="modal-content" action="{{ route('admin_shipping_store') }}" method="post">
@csrf
<input type="hidden" name="id">
<input type="hidden" name="shipping_id" value="@if($value->id>0){{$value->id}}@else new @endif">
<div class="modal-header">
<h5 class="modal-title"> {{__('Preis')}} <span class="font-weight-light">{{__('create/edit')}}</span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col">
<label for="country_ids" class="form-label">{{__('Versandkosten gelten für diese Länder')}}</label>
<select class="selectpicker" data-style="btn-default" name="country_ids[]" multiple>
{!! HTMLHelper::getCountriesWithoutUsedShippings() !!}
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
<button type="submit" class="btn btn-primary" name="action" value="country">{{__('save')}}</button>
</div>
</form>
</div>
</div>
<script>
$( document ).ready(function() {
$('#modals-price').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
$(this).find(".modal-content input[name='id']").val(button.data('id'));
$(this).find(".modal-body input[name='price']").val(button.data('price'));
$(this).find(".modal-body input[name='tax']").val(button.data('tax'));
$(this).find(".modal-body input[name='factor']").val(button.data('factor'));
$(this).find(".modal-body input[name='total_from']").val(button.data('total_from'));
$(this).find(".modal-body input[name='total_to']").val(button.data('total_to'));
$(this).find(".modal-body input[name='weight_from']").val(button.data('weight_from'));
$(this).find(".modal-body input[name='weight_to']").val(button.data('weight_to'));
});
$('#modals-country').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
$(this).find(".modal-content input[name='id']").val(button.data('id'));
});
});
</script>
@endif
<div class="text-left mt-2 mb-2">
<a href="{{ route('admin_shippings') }}" class="btn btn-default">{{ __('back') }}</a>
</div>