This commit is contained in:
Ludovic CANDELLIER
2021-03-29 23:46:01 +02:00
parent 4855254a7f
commit 993154674e
28 changed files with 300 additions and 105 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\DataTables\Shop;
use Yajra\DataTables\Html\Column;
use App\DataTables\ParentDataTable as DataTable;
use App\Models\Shop\Package;
class PackagesDataTable extends DataTable
{
public $model_name = 'packages';
public function query(Package $model)
{
$model = $model::with(['article_family'])->select('shop_packages.*');
return self::buildQuery($model);
}
protected function getColumns()
{
return [
Column::make('article_family.name')->title('Famille d\'articles'),
Column::make('value')->title('Valeur'),
self::makeColumnButtons(),
];
}
}

View File

@@ -8,19 +8,19 @@ use App\Models\Shop\Unity;
class UnitiesDataTable extends DataTable class UnitiesDataTable extends DataTable
{ {
public $model_name = 'Unity'; public $model_name = 'unities';
public function query(Unity $model) public function query(Unity $model)
{ {
$model = $model::with(['price_family']); $model = $model::with(['package'])->select('shop_unities.*');
return self::buildQuery($model); return self::buildQuery($model);
} }
protected function getColumns() protected function getColumns()
{ {
return [ return [
Column::make('value')->title('Attributs'), Column::make('package.value')->title('Package'),
Column::make('price_family.name')->title('Famille')->orderable(false), Column::make('value')->title('Valeur'),
self::makeColumnButtons(), self::makeColumnButtons(),
]; ];
} }

View File

@@ -30,6 +30,7 @@ class PackageController extends Controller
public function create() public function create()
{ {
$data['families'] = ArticleFamilies::getOptions();
return view('Shop.Admin.Packages.create'); return view('Shop.Admin.Packages.create');
} }
@@ -47,7 +48,8 @@ class PackageController extends Controller
public function edit($id) public function edit($id)
{ {
$data = Packages::get($id); $data['package'] = Packages::get($id);
$data['families'] = ArticleFamilies::getOptions();
return view('Shop.Admin.Packages.edit', $data); return view('Shop.Admin.Packages.edit', $data);
} }

View File

@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Shop\Admin;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Repositories\Shop\ArticleFamilies; use App\Repositories\Shop\Packages;
use App\Repositories\Shop\Unities; use App\Repositories\Shop\Unities;
use App\DataTables\Shop\UnitiesDataTable; use App\DataTables\Shop\UnitiesDataTable;
@@ -13,7 +13,7 @@ class UnityController extends Controller
{ {
public function index(UnitiesDataTable $dataTable) public function index(UnitiesDataTable $dataTable)
{ {
$data['families'] = ArticleFamilies::getOptions(); $data['packages'] = Packages::getOptions();
return $dataTable->render('Shop.Admin.Unities.list', $data); return $dataTable->render('Shop.Admin.Unities.list', $data);
} }
@@ -30,6 +30,7 @@ class UnityController extends Controller
public function create() public function create()
{ {
$data['packages'] = Packages::getOptions();
return view('Shop.Admin.Unities.create'); return view('Shop.Admin.Unities.create');
} }
@@ -47,7 +48,8 @@ class UnityController extends Controller
public function edit($id) public function edit($id)
{ {
$data = Unities::get($id); $data['packages'] = Packages::getOptions();
$data['unity'] = Unities::get($id)->toArray();
return view('Shop.Admin.Unities.edit', $data); return view('Shop.Admin.Unities.edit', $data);
} }

View File

@@ -36,6 +36,12 @@ class Shop
*/ */
$menu->addTo('shop', 'Prix génériques', [ 'route' => 'Shop.Admin.PriceGenerics.index', 'permission' => 'backend_access' ]) $menu->addTo('shop', 'Prix génériques', [ 'route' => 'Shop.Admin.PriceGenerics.index', 'permission' => 'backend_access' ])
->activeIfRoute(['Shop.Admin.PriceGenerics.*'])->order(10); ->activeIfRoute(['Shop.Admin.PriceGenerics.*'])->order(10);
$menu->addTo('shop', 'Packages', [ 'route' => 'Shop.Admin.Packages.index', 'permission' => 'backend_access' ])
->activeIfRoute(['Shop.Admin.Packages.*'])->order(12);
$menu->addTo('shop', 'Unités', [ 'route' => 'Shop.Admin.Unities.index', 'permission' => 'backend_access' ])
->activeIfRoute(['Shop.Admin.Unities.*'])->order(14);
} }

View File

@@ -14,6 +14,11 @@ class Package extends Model
return $this->belongsTo('App\Models\Shop\ArticleFamily'); return $this->belongsTo('App\Models\Shop\ArticleFamily');
} }
public function unities()
{
return $this->hasMany('App\Models\Shop\Unity');
}
public function scopeByFamily($query, $id) public function scopeByFamily($query, $id)
{ {
return $query->where('article_family_id', $id); return $query->where('article_family_id', $id);

View File

@@ -3,10 +3,6 @@
<input type="hidden" name="generics[id][]" value="{{ $generic['id'] ?? null }}"> <input type="hidden" name="generics[id][]" value="{{ $generic['id'] ?? null }}">
<input type="hidden" name="generics[price_generic_id][]" value="{{ $generic['price_generic_id'] ?? null }}"> <input type="hidden" name="generics[price_generic_id][]" value="{{ $generic['price_generic_id'] ?? null }}">
<button type="button" class="btn btn-xs btn-danger delete-price-btn mt-2" data-card-widget="collapse" data-toggle="tooltip" title="supprimer">
<i class="fas fa-trash"></i>
</button>
@include('Shop.Admin.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ]) @include('Shop.Admin.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ])
</div> </div>

View File

@@ -4,6 +4,4 @@
@include('Shop.Admin.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ]) @include('Shop.Admin.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ])
</div>
</div> </div>

View File

@@ -5,10 +5,10 @@
@endif @endif
@push('js') @push('js')
<script> <script>
$(function () { $(function () {
handle_delete_generic_price(); handle_delete_generic_price();
}); });
</script> </script>
@endpush @endpush

View File

@@ -5,14 +5,14 @@
@endif @endif
@push('js') @push('js')
<script> <script>
$(function () { $(function () {
handle_delete_price(); handle_delete_price();
init_unities(); init_unities();
handle_change_package(); handle_change_package();
handle_prices(); handle_prices();
handle_prices_taxed(); handle_prices_taxed();
}); });
</script> </script>
@endpush @endpush

View File

@@ -0,0 +1,15 @@
@extends('layout.index', [
'title' => __('packages.title'),
'subtitle' => __('packages.create.title'),
'breadcrumb' => [__('packages.title')]
])
@include('boilerplate::load.fileinput')
@section('content')
{{ Form::open(['route' => 'Shop.Admin.Packages.store', 'id' => 'package-form', 'autocomplete' => 'off']) }}
@include('Shop.Admin.Packages.form')
</form>
@endsection

View File

@@ -0,0 +1,14 @@
@extends('layout.index', [
'title' => 'Package',
'subtitle' => 'Edition d\'un package',
'breadcrumb' => ['Articles']
])
@section('content')
{{ Form::open(['route' => 'Shop.Admin.Packages.store', 'id' => 'package-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $package['id'] }}">
@include('Shop.Admin.Packages.form')
</form>
@endsection

View File

@@ -0,0 +1,19 @@
<div class="row">
<div class="col-md-8">
{{ Form::label('name', 'Famille') }}
@include('components.select', ['name' => 'article_family_id', 'value' => $package['article_family_id'] ?? null, 'list' => $families, 'required' => false, 'with_empty' => ''])
{{ Form::label('name', 'Valeur') }}
@include('components.input', ['name' => 'value', 'value' => $package['value'] ?? null, 'required' => true])
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="float-right mt-3">
@include('components.button-save')
</div>
</div>
</div>

View File

@@ -0,0 +1,48 @@
@extends('layout.index', [
'title' => __('Shop.packages.title'),
'subtitle' => __('Shop.packages.list'),
'breadcrumb' => [__('Shop.packages.title')]
])
@include('boilerplate::load.select2')
@section('content')
<nav>
<div class="nav nav-tabs">
<a href="#families" data-toggle="tab" class="nav-item nav-link" role="tab" aria-controls="families" aria-selected="true">
{{ __('Shop.packages.title') }}
</a>
<a href="#values" data-toggle="tab" class="nav-item nav-link active" role="tab" aria-controls="values" aria-selected="false">
{{ __('Shop.packages.title') }}
</a>
</div>
</nav>
<div class="tab-content mb-0">
<div class="tab-pane fade" id="families">
@section('content')
@include('components.datatable', ['route' => route('Shop.Admin.Unities.index'), 'model' => 'ArticleAttributefamilies'])
@endsection
</div>
<div class="tab-pane fade show active" id="values">
@section('content')
@component('components.card')
@include('components.datatable', ['route' => route('Shop.Admin.ArticleAttributeValues.index'), 'model' => 'Unities'])
@endcomponent
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-filters'])
@include('Shop.Admin.Unities.partials.filters')
@endcomponent
@endsection
</div>
</div>
@endsection
@push('scripts')
@include('components.js.datatable', ['route' => route('Shop.Admin.Unities.index'), 'model' => 'Unities'])
@endpush

View File

@@ -0,0 +1,16 @@
@extends('layout.index', [
'title' => __('Shop.packages.title'),
'subtitle' => __('Shop.packages.list'),
'breadcrumb' => [__('Shop.packages.title')]
])
@section('content')
@component('components.card')
@include('components.datatable', ['route' => route('Shop.Admin.Packages.index'), 'model' => 'packages'])
@endcomponent
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-packages-filters'])
@include('Shop.Admin.Packages.partials.filters')
@endcomponent
@endsection

View File

@@ -0,0 +1,9 @@
<form id="filters">
<div class="row">
<label class="col-4">Familles d'attributs</label>
<div class="col-8">
@include('components.select', ['name' => 'article_attribute_family_id', 'list' => (isset($families)) ? $families : [], 'value' => (isset($filters['article_attribute_family_id'])) ? $filters['article_attribute_family_id'] : null, 'class' => 'form-control-sm select2', 'with_empty' => ' '])
</div>
</div>
</form>

View File

@@ -0,0 +1,36 @@
@extends('layout.index', [
'title' => __('products.title'),
'subtitle' => __('products.title'),
'breadcrumb' => [__('products.title')]
])
@section('content')
<form action="{{ route('Shop.Products') }}" method="GET">
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="box box-info">
<div class="box-body">
<div class="col-md-6">
<h3>{{ name }}</h3>
<h4>
{{ $product.section.name }}<br>
</h4>
</div>
<div class="col-md-6 text-right">
<h2>{{ $prix_total }} </h2>
<h4>{{ $residence['type_produit']['name'] }}</h4>
</div>
<div class="col-md-12">
@include('Hestimmo.modules.Lot.partials.carousel')
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

View File

@@ -7,19 +7,6 @@
@section('content') @section('content')
{{ Form::open(['route' => 'Shop.Admin.PriceGenerics.store', 'id' => 'price-generic-form', 'autocomplete' => 'off']) }} {{ Form::open(['route' => 'Shop.Admin.PriceGenerics.store', 'id' => 'price-generic-form', 'autocomplete' => 'off']) }}
<div class="row">
<div class="col-sm-12 mbl">
<a href="{{ route("Shop.Admin.PriceGenerics.index") }}" class="btn btn-default">
{{ __('price_generics.list.title') }}
</a>
<span class="btn-group pull-right">
@include('components.button-save')
</span>
</div>
</div>
@include('Shop.Admin.PriceGenerics.form') @include('Shop.Admin.PriceGenerics.form')
</form> </form>

View File

@@ -7,29 +7,55 @@
<div class="row"> <div class="row">
<div class="col-2"> <div class="col-1">
{{ Form::label('quantity', 'Quantité') }}<br/> {{ Form::label('quantity', 'Quantité') }}<br/>
@include('components.number', ['name' => 'prices[0][quantity]', 'value' => $quantity ?? 1, 'required' => true, 'class' => 'form-control-sm']) @include('components.number', ['name' => 'prices[0][quantity]', 'value' => $quantity ?? 1, 'required' => true, 'class' => 'form-control-sm'])
</div> </div>
<div class="col-3"> <div class="col-3">
{{ Form::label('package_id', 'Unité') }}<br/>
@include('components.select', ['name' => 'prices[0][package_id]', 'value' => $package_id ?? null, 'list' => $packages ?? null, 'required' => true, 'class' => 'select2 form-control-sm w-100'])
</div>
<div class="col-lg-1">
{{ Form::label('package_qty', 'Pack Qté') }}<br/>
@include('components.number', [
'name' => "prices[0][package_quantity]",
'value' => $price['package_quantity'] ?? null,
'required' => true,
'class' => 'form-control-sm',
])
</div>
<div class="col-lg-3">
{{ Form::label('unity_id', 'Unité') }}<br/> {{ Form::label('unity_id', 'Unité') }}<br/>
@include('components.select', ['name' => 'prices[0][unity_id]', 'value' => $unity_id ?? null, 'list' => $unities ?? null, 'required' => true, 'class' => 'form-control-sm']) @include('components.select', [
'name' => "prices[0][unity_id]",
'value' => $price['unity_id'] ?? null,
'list' => $unities ?? null,
'required' => true,
'class' => 'select2 form-control-sm unities w-100',
'with_empty' => ''
])
</div> </div>
<div class="col-2"> <div class="col-lg-3">
{{ Form::label('tax_id', 'TVA') }}<br/> <div class="row">
@include('components.select', ['name' => 'prices[0][tax_id]', 'value' => $tax_id ?? null, 'list' => $taxes ?? null, 'required' => true, 'class' => 'form-control-sm']) <div class="col-4">
</div> {{ Form::label('tax_id', 'TVA') }}<br/>
@include('components.select', ['name' => "prices[0][tax_id]", 'value' => $price['tax_id'] ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
</div>
<div class="col-2"> <div class="col-4">
{{ Form::label('price', 'Prix HT') }} {{ Form::label('price', 'Prix HT') }}
@include('components.money', ['name' => 'prices[0][price]', 'value' => $price ?? 0, 'required' => true, 'class' => 'form-control-sm price-item']) @include('components.money', ['name' => "prices[0][price]", 'value' => $price['price'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-item'])
</div> </div>
<div class="col-2"> <div class="col-4">
{{ Form::label('price_taxed', 'Prix TTC') }} {{ Form::label('price_taxed', 'Prix TTC') }}
@include('components.money', ['name' => 'prices[0][price_taxed]', 'value' => $price_taxed ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item']) @include('components.money', ['name' => "prices[0][price_taxed]", 'value' => $price['price_taxed'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
</div>
</div>
</div> </div>
<div class="col-1 text-right"> <div class="col-1 text-right">

View File

@@ -3,6 +3,10 @@
<thead> <thead>
<th> <th>
<button type="button" class="btn btn-xs btn-danger delete-price-btn mt-2" data-card-widget="collapse" data-toggle="tooltip" title="supprimer" data-id="{{ $generic['id'] }}">
<i class="fas fa-trash"></i>
</button>
{{ $generic['category']['name'] ?? null }} {{ $generic['category']['name'] ?? null }}
</th> </th>
@foreach ($generic['prices'] as $price) @foreach ($generic['prices'] as $price)

View File

@@ -1,19 +1,19 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => __('article_attributes.title'), 'title' => __('unities.title'),
'subtitle' => __('article_attributes.create.title'), 'subtitle' => __('unities.create.title'),
'breadcrumb' => [__('article_attributes.title'), __('article_attributes.create.title')] 'breadcrumb' => [__('unities.title')]
]) ])
@include('boilerplate::load.fileinput') @include('boilerplate::load.fileinput')
@section('content') @section('content')
{{ Form::open(['route' => 'Shop.Admin.ArticleAttributes.store', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }} {{ Form::open(['route' => 'Shop.Admin.Unities.store', 'id' => 'unity-form', 'autocomplete' => 'off', 'files' => true]) }}
<div class="row"> <div class="row">
<div class="col-sm-12 mbl"> <div class="col-sm-12 mbl">
<a href="{{ route("Shop.Admin.ArticleAttributes.index") }}" class="btn btn-default"> <a href="{{ route("Shop.Admin.Unities.index") }}" class="btn btn-default">
{{ __('article_attributes.list.title') }} {{ __('unities.list.title') }}
</a> </a>
<span class="btn-group pull-right"> <span class="btn-group pull-right">
@@ -22,7 +22,7 @@
</div> </div>
</div> </div>
@include('Shop.Admin.ArticleAttributeValues.form') @include('Shop.Admin.Unities.form')
</form> </form>
@endsection @endsection

View File

@@ -1,29 +1,14 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => 'Attributs d\'articles', 'title' => 'Unités',
'subtitle' => 'Edition d\'un attribut d\'article', 'subtitle' => 'Edition d\'une unité',
'breadcrumb' => ['Articles'] 'breadcrumb' => ['Unités']
]) ])
@include('boilerplate::load.fileinput')
@section('content') @section('content')
{{ Form::open(['route' => 'Shop.Admin.ArticleAttributeValues.update', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }} {{ Form::open(['route' => 'Shop.Admin.Unities.store', 'id' => 'unity-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $unity['id'] ?? null }}">
<div class="row"> @include('Shop.Admin.Unities.form')
<div class="col-sm-12 mbl">
<a href="{{ route("Shop.Admin.ArticleAttributeValues.index") }}" class="btn btn-default">
{{ __('article_attributes.list.title') }}
</a>
<span class="btn-group pull-right">
@include('components.button-save')
</span>
</div>
</div>
<input type="hidden" name="id" value="{{ $id }}">
@include('Shop.Admin.ArticleAttributeValues.form')
</form> </form>
@endsection @endsection

View File

@@ -1,14 +1,12 @@
@include('boilerplate::load.tinymce')
<div class="row"> <div class="row">
<div class="col-md-8">
{{ Form::label('name', 'Package') }}
@include('components.select', ['name' => 'package_id', 'value' => $unity['package_id'] ?? null, 'list' => $packages ?? [], 'required' => false, 'with_empty' => ''])
</div>
<div class="col-md-8"> <div class="col-md-8">
{{ Form::label('name', 'Nom') }} {{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => (isset($family['name'])) ? $family['name'] : null, 'required' => true]) @include('components.input', ['name' => 'value', 'value' => $unity['value'] ?? null, 'required' => true])
{{ Form::label('description', 'Description') }}
@include('components.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'required' => false])
</div> </div>
</div> </div>
@@ -19,11 +17,3 @@
</div> </div>
</div> </div>
</div> </div>
@push('js')
<script>
$(function() {
$('.editor').tinymce({});
});
</script>
@endpush

View File

@@ -1,16 +1,16 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => __('Shop.article_attribute_values.title'), 'title' => __('Shop.unities.title'),
'subtitle' => __('Shop.article_attribute_values.list'), 'subtitle' => __('Shop.unities.list'),
'breadcrumb' => [__('Shop.article_attribute_values.title')] 'breadcrumb' => [__('Shop.unities.title')]
]) ])
@section('content') @section('content')
@component('components.card') @component('components.card')
@include('components.datatable', ['route' => route('Shop.Admin.ArticleAttributeValues.index'), 'model' => 'ArticleAttributeValues']) @include('components.datatable', ['route' => route('Shop.Admin.Unities.index'), 'model' => 'unities'])
@endcomponent @endcomponent
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-filters']) @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-unities-filters'])
@include('Shop.Admin.ArticleAttributeValues.partials.filters') @include('Shop.Admin.Unities.partials.filters')
@endcomponent @endcomponent
@endsection @endsection

View File

@@ -47,7 +47,6 @@
</script> </script>
@stack('js') @stack('js')
<script src="{{ mix('js/app.js') }}"></script> <script src="{{ mix('js/app.js') }}"></script>
<script src="{{ asset('vendor/datatables/buttons.server-side.js') }}"></script>
@stack('scripts') @stack('scripts')
</body> </body>
</html> </html>

View File

@@ -0,0 +1,8 @@
<?php
Route::prefix('Packages')->name('Packages.')->group(function () {
Route::any('getOptionsByFamily', 'PackageController@getOptionsByFamily')->name('getOptionsByFamily');
Route::get('edit/{id}', 'PackageController@edit')->name('edit');
});
Route::resource('Packages', 'PackageController');

View File

@@ -2,6 +2,7 @@
Route::prefix('Unities')->name('Unities.')->group(function () { Route::prefix('Unities')->name('Unities.')->group(function () {
Route::any('getOptionsByPackage', 'UnityController@getOptionsByPackage')->name('getOptionsByPackage'); Route::any('getOptionsByPackage', 'UnityController@getOptionsByPackage')->name('getOptionsByPackage');
Route::get('edit/{id}', 'UnityController@edit')->name('edit');
}); });
Route::resource('Unities', 'UnityController'); Route::resource('Unities', 'UnityController');

View File

@@ -13,6 +13,7 @@ Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')->
include __DIR__ . '/Invoices.php'; include __DIR__ . '/Invoices.php';
include __DIR__ . '/OrderPayments.php'; include __DIR__ . '/OrderPayments.php';
include __DIR__ . '/Orders.php'; include __DIR__ . '/Orders.php';
include __DIR__ . '/Packages.php';
include __DIR__ . '/PriceGenerics.php'; include __DIR__ . '/PriceGenerics.php';
include __DIR__ . '/Tags.php'; include __DIR__ . '/Tags.php';
include __DIR__ . '/TagGroups.php'; include __DIR__ . '/TagGroups.php';