Fixes on prices & add ArticlePriceGeneric
This commit is contained in:
30
app/DataTables/Shop/ArticlePriceGenericsDataTable.php
Normal file
30
app/DataTables/Shop/ArticlePriceGenericsDataTable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\ArticlePriceGeneric;
|
||||
|
||||
class ArticlePriceGenericsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'article-price-generics';
|
||||
|
||||
public function query(ArticlePriceGeneric $model)
|
||||
{
|
||||
$model = $model::withCount('article_prices');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('price')->title('Prix HT')->class('text-right'),
|
||||
Column::make('price_taxed')->title('Prix TTC')->class('text-right'),
|
||||
Column::make('article_prices_count')->title('Nb de tarifs')->class('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\ArticlePrice;
|
||||
|
||||
class ArticlePricessDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticlePrices';
|
||||
|
||||
public function query(ArticlePrice $model)
|
||||
{
|
||||
$model = $model::with(['Article', 'ArticleAttributes']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\Shop\ArticlePriceGeneric;
|
||||
use App\Repositories\Shop\ArticlePriceGenerics;
|
||||
use App\Repositories\Shop\Taxes;
|
||||
use App\DataTables\Shop\ArticlePriceGenericsDataTable;
|
||||
|
||||
class ArticlePriceGenericController extends Controller
|
||||
{
|
||||
public function index(ArticlePriceGenericsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.ArticlePriceGenerics.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return ArticlePriceGenerics::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
return view('Shop.Admin.ArticlePriceGenerics.create',$data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = ArticlePriceGenerics::store($request->all());
|
||||
return redirect()->route('Shop.Admin.ArticlePriceGenerics.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = ArticlePriceGenerics::get($id);
|
||||
return view('Shop.Admin.ArticlePriceGenerics.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['generic'] = ArticlePriceGenerics::get($id);
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
return view('Shop.Admin.ArticlePriceGenerics.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return ArticlePriceGenerics::destroy($id);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ class Shop
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(8);
|
||||
$menu->addTo('shop', 'Stock', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(9);
|
||||
$menu->addTo('shop', 'Prix génériques', [ 'route' => 'Shop.Admin.ArticlePriceGenerics.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticlePriceGenerics.*'])->order(10);
|
||||
|
||||
|
||||
}
|
||||
|
||||
20
app/Models/Shop/ArticlePriceGeneric.php
Normal file
20
app/Models/Shop/ArticlePriceGeneric.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class ArticlePriceGeneric extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_price_generics';
|
||||
|
||||
public function article_prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
}
|
||||
67
app/Repositories/Shop/ArticlePriceGenerics.php
Normal file
67
app/Repositories/Shop/ArticlePriceGenerics.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticlePriceGeneric;
|
||||
|
||||
class ArticlePriceGenerics
|
||||
{
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePriceGeneric::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePriceGeneric::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePriceGeneric::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePriceGeneric::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePriceGeneric::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePriceGeneric::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePriceGeneric::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePriceGeneric::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
@extends('layout.index', [
|
||||
'title' => __('article_price_generics.title'),
|
||||
'subtitle' => __('article_price_generics.create.title'),
|
||||
'breadcrumb' => [__('article_price_generics.title'), __('article_price_generics.create.title')]
|
||||
])
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Shop.Admin.ArticlePriceGenerics.store', 'id' => 'article-price-generic-form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mbl">
|
||||
<a href="{{ route("Shop.Admin.ArticlePriceGenerics.index") }}" class="btn btn-default">
|
||||
{{ __('article_price_generics.list.title') }}
|
||||
</a>
|
||||
|
||||
<span class="btn-group pull-right">
|
||||
@include('components.button-save')
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('Shop.Admin.ArticlePriceGenerics.form')
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
@@ -0,0 +1,14 @@
|
||||
@extends('layout.index', [
|
||||
'title' => __('article_price_generics.title'),
|
||||
'subtitle' => __('article_price_generics.edit.title'),
|
||||
'breadcrumb' => [__('article_price_generics.title'), __('article_price_generics.edit.title')]
|
||||
])
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Shop.Admin.ArticlePriceGenerics.update', 'id' => 'article-price-generic-form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
<input type="hidden" name="id" value="{{ $generic['id'] }}">
|
||||
@include('Shop.Admin.ArticlePriceGenerics.form')
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{{ Form::label('name', 'Nom') }}
|
||||
@include('components.input', ['name' => 'name', 'value' => $generic['name'] ?? null, 'required' => true])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
{{ Form::label('tax_id', 'TVA') }}
|
||||
@include('components.select', ['name' => 'tax_id', 'value' => $generic['tax_id'] ?? null, 'list' => $taxes ?? null, 'class' => 'tva', 'required' => true])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
{{ Form::label('price', 'Prix HT') }}
|
||||
@include('components.input', ['name' => 'price', 'value' => $generic['price'] ?? null, 'class' => 'price', 'required' => true])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
{{ Form::label('price_taxed', 'Prix TTC') }}
|
||||
@include('components.input', ['name' => 'price_taxed', 'value' => $generic['price_taxed'] ?? null, 'class' => 'price_taxed', 'required' => true])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="float-right mt-3">
|
||||
@include('components.button-save')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
function set_price(item) {
|
||||
$row = $(item).parent();
|
||||
tva = $row.find('.tva').val();
|
||||
price_taxed = $row.find('.price_taxed').val();
|
||||
console.log(tva);
|
||||
console.log(price_taxed);
|
||||
}
|
||||
|
||||
function set_price_taxed(item) {
|
||||
$row = $(item).parent();
|
||||
tva = $row.find('.tva').val();
|
||||
price = $row.find('.price').val();
|
||||
console.log(tva);
|
||||
console.log(price);
|
||||
}
|
||||
|
||||
$('.price_taxed').change(function() {
|
||||
set_price(this);
|
||||
});
|
||||
|
||||
$('.price').change(function() {
|
||||
set_price_taxed(this);
|
||||
});
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,8 @@
|
||||
@extends('layout.index', [
|
||||
'title' => __('article_price_generics.title'),
|
||||
'subtitle' => __('article_price_generics.list.title'),
|
||||
'breadcrumb' => [__('article_price_generics.title')]
|
||||
])
|
||||
@section('content')
|
||||
@include('components.datatable', ['route' => route('Shop.Admin.ArticlePriceGenerics.index'), 'model' => 'article-price-generics'])
|
||||
@endsection
|
||||
@@ -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
|
||||
@@ -27,7 +27,7 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#stock" class="nav-link" data-toggle="tab" aria-expanded="true">
|
||||
Quantités
|
||||
Stock
|
||||
@if(isset($stock_count))<span class="badge">{{ $stock_count }}</span>@endif
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
'value' => $attribute['attribute_value']['article_attribute_family_id'] ?? null,
|
||||
'list' => $attribute_families_options,
|
||||
'required' => true,
|
||||
'class' => 'select2 form-control form-control-sm attributes-family'
|
||||
'class' => 'select2 form-control-sm attributes-family'
|
||||
])
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
'value' => $attribute['article_attribute_value_id'] ?? null,
|
||||
'list' => $attribute_values ?? null,
|
||||
'required' => true,
|
||||
'class' => 'select2 form-control form-control-sm attributes-value',
|
||||
'class' => 'select2 form-control-sm attributes-value',
|
||||
'meta' => (isset($attribute['article_attribute_value_id'])) ? 'data-id="' . $attribute['article_attribute_value_id'] . '"' : ''
|
||||
])
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
'value' => $attribute_value['article_attribute_family_id'] ?? null,
|
||||
'list' => $attribute_families_options,
|
||||
'required' => true,
|
||||
'class' => 'select2 form-control form-control-sm attributes-family'
|
||||
'class' => 'select2 form-control-sm attributes-family'
|
||||
])
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
'value' => $attribute_value['id'] ?? null,
|
||||
'list' => $attribute_values ?? null,
|
||||
'required' => true,
|
||||
'class' => 'select2 form-control form-control-sm attributes-value'
|
||||
'class' => 'select2 form-control-sm attributes-value'
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<div class="col-lg-1">
|
||||
{{ Form::label('quantity', 'Qté.') }}<br/>
|
||||
@include('components.number', ['name' => "prices[$key][quantity]", 'value' => (isset($price['quantity'])) ? $price['quantity'] : 1, 'required' => true, 'class' => 'form-control-sm'])
|
||||
@include('components.number', ['name' => "prices[$key][quantity]", 'value' => $price['quantity'] ?? 1, 'required' => true, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
@@ -18,24 +18,24 @@
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="col-2">
|
||||
{{ Form::label('tax_id', 'TVA') }}<br/>
|
||||
@include('components.select', ['name' => "prices[$key][tax_id]", 'value' => (isset($price['tax_id'])) ? $price['tax_id'] : null, 'list' => isset($taxes_options) ? $taxes_options : null, 'required' => true, 'class' => 'form-control form-control-sm'])
|
||||
@include('components.select', ['name' => "prices[$key][tax_id]", 'value' => $price['tax_id'] ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
<div class="col-4">
|
||||
{{ Form::label('generic_price_id', 'Générique') }}<br/>
|
||||
@include('components.select', ['name' => "prices[$key][generic_price_id]", 'value' => (isset($price['generic_price_id'])) ? $price['generic_price_id'] : null, 'list' => ['Tarif barquette','Tarif semences'], 'required' => false, 'class' => 'form-control-sm'])
|
||||
@include('components.select', ['name' => "prices[$key][article_generic_price_id]", 'value' => $price['article_generic_price_id'] ?? null, 'list' => ['Tarif barquette','Tarif semences'], 'required' => false, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price', 'Prix HT') }}
|
||||
@include('components.money', ['name' => "prices[$key][price]", 'value' => (isset($price['price'])) ? $price['price'] : 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
@include('components.money', ['name' => "prices[$key][price]", 'value' => $price['price'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price_taxed', 'Prix TTC') }}
|
||||
@include('components.money', ['name' => "prices[$key][price_taxed]", 'value' => (isset($price['price_taxed'])) ? $price['price_taxed'] : 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
@include('components.money', ['name' => "prices[$key][price_taxed]", 'value' => $price['price_taxed'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,26 +9,34 @@
|
||||
|
||||
<div class="col-lg-1">
|
||||
{{ Form::label('quantity', 'Quantité') }}<br/>
|
||||
@include('components.number', ['name' => 'prices[0][quantity]', 'value' => (isset($quantity)) ? $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 class="col-lg-5">
|
||||
<div class="col-lg-4">
|
||||
@include('Shop.Admin.Articles.partials.prices.block_attribute_new')
|
||||
</div>
|
||||
|
||||
<div class="col-lg-1">
|
||||
<div class="col-lg-6">
|
||||
|
||||
<div class="col-2">
|
||||
{{ Form::label('tax_id', 'TVA') }}<br/>
|
||||
@include('components.select', ['name' => 'prices[0][tax_id]', 'value' => (isset($tax_id)) ? $tax_id : null, 'list' => isset($taxes_options) ? $taxes_options : null, 'required' => true, 'class' => 'form-control form-control-sm'])
|
||||
@include('components.select', ['name' => 'prices[0][tax_id]', 'value' => $tax_id ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2">
|
||||
<div class="col-4">
|
||||
{{ Form::label('generic_price_id', 'Générique') }}<br/>
|
||||
@include('components.select', ['name' => "prices[0][article_generic_price_id]", 'value' => $price['article_generic_price_id'] ?? null, 'list' => ['Tarif barquette','Tarif semences'], 'required' => false, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price', 'Prix HT') }}
|
||||
@include('components.money', ['name' => 'prices[0][price]', 'value' => (isset($price)) ? $price : 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
@include('components.money', ['name' => 'prices[0][price]', 'value' => $price ?? 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2">
|
||||
<div class="col-3">
|
||||
{{ Form::label('price_taxed', 'Prix TTC') }}
|
||||
@include('components.money', ['name' => 'prices[0][price_taxed]', 'value' => (isset($price_taxed)) ? $price_taxed : 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
@include('components.money', ['name' => 'prices[0][price_taxed]', 'value' => $price_taxed ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-1 text-right">
|
||||
|
||||
12
routes/Shop/Admin/ArticlePriceGenerics.php
Normal file
12
routes/Shop/Admin/ArticlePriceGenerics.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
Route::prefix('ArticlePriceGenerics')->name('ArticlePriceGenerics.')->group(function () {
|
||||
Route::get('', 'ArticlePriceGenericController@index')->name('index');
|
||||
Route::get('create', 'ArticlePriceGenericController@create')->name('create');
|
||||
Route::delete('destroy', 'ArticlePriceGenericController@destroy')->name('destroy');
|
||||
Route::post('update', 'ArticlePriceGenericController@update')->name('update');
|
||||
Route::post('store', 'ArticlePriceGenericController@store')->name('store');
|
||||
Route::get('edit/{id}', 'ArticlePriceGenericController@edit')->name('edit');
|
||||
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')->
|
||||
include( __DIR__ . '/ArticleAttributeValues.php');
|
||||
include( __DIR__ . '/ArticleAttributes.php');
|
||||
include( __DIR__ . '/ArticleFamilies.php');
|
||||
include( __DIR__ . '/ArticlePriceGenerics.php');
|
||||
include( __DIR__ . '/ArticlePrices.php');
|
||||
include( __DIR__ . '/Articles.php');
|
||||
include( __DIR__ . '/Categories.php');
|
||||
|
||||
Reference in New Issue
Block a user