Fixes on adding price & errors

This commit is contained in:
Ludovic CANDELLIER
2021-07-27 17:33:18 +02:00
parent 0d421226fa
commit 734ec87b89
18 changed files with 123 additions and 76 deletions

View File

@@ -533,6 +533,12 @@ module.exports = function(grunt) {
src: ['**'],
dest: 'public/assets/plugins/tinymce/skins/ui/boilerplate',
},
{
expand: true,
cwd: 'node_modules/icheck-bootstrap/',
src: ['icheck-bootstrap.min.css'],
dest: 'public/assets/plugins/icheck/'
},
{
expand: true,
cwd: 'build/js/include/',
@@ -544,22 +550,10 @@ module.exports = function(grunt) {
},
watch: {
dist: {
files: [
'Admin/*',
],
files: ['build/js/*', 'build/css/*'],
tasks: ['concat', 'copy']
}
},
handlebars: {
compile: {
options: {
namespace: "JST"
},
files: {
"assets/tpl/content.hbs": "public/assets/tpl/content.hbs"
}
}
}
});
// Load the plugin that provides the "uglify" task.

View File

@@ -17,6 +17,7 @@ class PriceListsDataTable extends DataTable
public function query(PriceList $model)
{
$model = $model->with('sale_channel');
$model = self::filterByTariff($model);
return self::buildQuery($model);
}
@@ -32,6 +33,7 @@ class PriceListsDataTable extends DataTable
{
return [
Column::make('name')->title('Nom'),
Column::make('sale_channel.name')->title('Canal de vente'),
self::makeColumnButtons(),
];
}

View File

@@ -19,10 +19,10 @@ class TariffsDataTable extends DataTable
protected function getColumns()
{
return [
Column::make('sale_channel.name')->title('Canal de vente'),
Column::make('name')->title('Nom'),
Column::make('sale_channel.name')->title('Canal de vente par défaut'),
Column::make('code')->title('Code'),
Column::make('ref')->title('Référence'),
Column::make('name')->title('Nom'),
self::makeColumnButtons(),
];
}

View File

@@ -47,7 +47,7 @@ class PriceListController extends Controller
public function modalEdit($id)
{
$data['price_list'] = PriceLists::getFull($id);
$data['price_list'] = PriceLists::edit($id);
$data['sale_channels'] = SaleChannels::getOptions();
$data['statuses'] = Tariffs::getStatuses();
return view('Admin.Shop.PriceLists.modal', $data);

View File

@@ -21,11 +21,6 @@ class PriceListValueController extends Controller
return $dataTable->render('Admin.Shop.PriceListValues.list', $data);
}
public function getDatatable(Request $request)
{
return PriceListValues::getTables($request->all());
}
public function create()
{
$data['unities'] = Unities::getOptions();
@@ -66,4 +61,12 @@ class PriceListValueController extends Controller
$data['generic'] = PriceListValues::getFull($id);
return view('Admin.Shop.PriceListValues.partials.table-prices', $data);
}
public function addPrice($index)
{
$data['index'] = $index;
return view('Admin.Shop.PriceListValues.partials.row_price', $data);
}
}

View File

@@ -26,4 +26,19 @@ class PriceList extends Model
{
return $this->hasMany('App\Models\Shop\PriceListValue');
}
public function scopeByTariff($query, $id)
{
return $query->where('tariff_id', $id);
}
public function scopeBySaleChannel($query, $id)
{
return $query->where('sale_channel_id', $id);
}
public function scopeByStatus($query, $id)
{
return $query->where('status_id', $id);
}
}

View File

@@ -10,19 +10,14 @@ use App\Models\Shop\PriceList;
class PriceLists
{
public static function getByArticle($id)
public static function getByTariff($id)
{
return PriceList::byArticle($id)->get();
}
public static function getByArticleWithValues($id)
{
return PriceList::with('values')->byArticle($id)->get();
return PriceList::byTariff($id)->get();
}
public static function getOptions()
{
return PriceList::with('prices')->get()->toArray();
return PriceList::pluck('name','id')->toArray();
}
public static function getAll()
@@ -30,6 +25,14 @@ class PriceLists
return PriceList::orderBy('name', 'asc')->get();
}
public static function edit($id)
{
$price_list = self::getFull($id)->toArray();
$n = count($price_list['price_list_values']);
$price_list['price_list_values'] += array_fill($n, 3 - $n, '');
return $price_list;
}
public static function get($id)
{
return PriceList::find($id);

View File

@@ -52,4 +52,4 @@ ul .jqtree_common {
.yellow {
color: #F2B90F!important;
}
}

View File

@@ -0,0 +1,12 @@
<tr>
<input type="hidden" name="price_list_values[{{ $index }}][id]" value="{{ $price_list_value['id'] ?? null }}">
<td>
@include('components.input', ['name' => 'price_list_values[' . $index . '][code]', 'value' => $price_list_value['code'] ?? null, 'required' => true])
</td>
<td>
@include('components.number', ['name' => 'price_list_values[' . $index . '][quantity]', 'value' => $price_list_value['quantity'] ?? null, 'required' => true, 'meta' => "step = '.01'"])
</td>
<td>
@include('components.money', ['name' => 'price_list_values[' . $index . '][price]', 'value' => $price_list_value['price'] ?? null, 'required' => true])
</td>
</tr>

View File

@@ -4,26 +4,25 @@
<input type="hidden" name="tariff_id" value="{{ $price_list['tariff_id'] ?? null }}">
<div class="row mb-3">
<div class="col-6">
<div class="col-8">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $price_list['name'] ?? null, 'required' => true])
</div>
<div class="col-4">
{{ Form::label('status_id', 'Etat') }}
@include('components.select', ['name' => 'status_id', 'list' => $statuses ?? [], 'value' => $price_list['status_id'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('sale_channel_id', 'Canal de vente') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $price_list['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $price_list['name'] ?? null, 'required' => true])
</div>
</div>
@component('components.card', ['title' => 'Prix'])
<table class="table table-bordered table-hover table-striped w-100 mb-0 dataTable">
<table class="table table-bordered table-hover table-striped w-100 mb-0 dataTable" id="prices-table">
<thead>
<tr>
<th>Code</th>
@@ -33,20 +32,37 @@
</thead>
<tbody>
@foreach ($price_list['price_list_values'] as $price_list_value)
<tr>
<td>
@include('components.input', ['name' => 'price_list_values[' . $loop->index . '][code]', 'value' => $price_list_value['name'] ?? null, 'required' => true])
</td>
<td>
@include('components.number', ['name' => 'price_list_values[' . $loop->index . '][quantity]', 'value' => $price_list_value['quantity'] ?? null, 'required' => true, 'meta' => "step = '.01'"])
</td>
<td>
@include('components.money', ['name' => 'price_list_values[' . $loop->index . '][price]', 'value' => $price_list_value['price'] ?? null, 'required' => true])
</td>
</tr>
@include('admin.Shop.PriceListValues.partials.row_price', ['index' => $loop->index])
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="3">
<button type='button' class='btn btn-primary btn-xs' id='add_price'>
Ajouter un seuil
<i class='pl-2 fa fa-plus'></i>
</button>
</td>
</tr>
</tfoot>
</table>
@endcomponent
</form>
</form>
<script>
function handleAddPrice() {
$('#add_price').click( function () {
var index = $('#prices-table tbody tr').length;
$.get("{{ route('Admin.Shop.PriceListValues.addPrice') }}/" + index, function(data) {
$("#prices-table").prepend(data);
})
})
}
$(function() {
handleAddPrice();
});
</script>

View File

@@ -2,37 +2,39 @@
<div class="col-6">
<div class="row mb-3">
<div class="col-12">
<div class="col-8">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $tariff['name'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('name', 'Canal de vente') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $tariff['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
<div class="col-6">
<div class="col-4">
{{ Form::label('name', 'Etat') }}
@include('components.select', ['name' => 'status_id', 'list' => $statuses ?? [], 'value' => $tariff['status_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-3">
<div class="col-6">
{{ Form::label('name', 'Code') }}
@include('components.input', ['name' => 'code', 'value' => $tariff['code'] ?? null, 'required' => true])
</div>
<div class="col-3">
<div class="col-6">
{{ Form::label('name', 'Ref') }}
@include('components.input', ['name' => 'ref', 'value' => $tariff['ref'] ?? null, 'required' => true])
</div>
<div class="col-6">
</div>
<div class="row mb-3">
<div class="col-8">
{{ Form::label('name', 'Canal de vente par défaut') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $tariff['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
<div class="col-4">
{{ Form::label('name', 'Unité du tarif') }}
@include('components.select', ['name' => 'tariff_unity_id', 'list' => $tariff_unities ?? [], 'value' => $tariff['tariff_unity_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('description', 'Description') }}

View File

@@ -26,13 +26,12 @@
@include('components.save')
@include('boilerplate::load.tinymce')
@include('load.form.editor')
@push('js')
<script>
$(function() {
$('.editor').tinymce({});
initEditor();
});
</script>
@endpush

View File

@@ -5,9 +5,9 @@
@section('content')
{!! Form::open(['route' => 'boilerplate.login', 'method' => 'post', 'autocomplete'=> 'off']) !!}
<div class="row">
<div class="row" style="width: 380px;">
<div class="col-12 text-center">
<img src="/img/logo.png" height="96">
<img src="/img/logo.png" height="128">
</div>
</div>
@@ -26,7 +26,7 @@
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<div class="col-12 col-lg-8">
<div class="checkbox icheck">
<label style="padding-left: 0">
<input type="checkbox" name="remember" class="icheck" {{ old('remember') ? 'checked' : '' }}>
@@ -34,7 +34,7 @@
</label>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 mbs">
<div class="col-12 col-lg-4 mbs">
<button type="submit" class="btn btn-primary btn-block btn-flat">{{ __('boilerplate::auth.login.signin') }}</button>
</div>
</div>

View File

@@ -7,7 +7,7 @@
<h3 class="card-title">{{ $title }}</h3>
@isset($tools)
<div class="card-tools">
{{ $tools }}
{!! $tools !!}
</div>
@endisset
@endisset

View File

@@ -14,8 +14,8 @@
@if (isset($buttons))
{{ $buttons }}
@endif
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-info apply">Apply</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ __('close') }}</button>
<button type="button" class="btn btn-info apply">{{ __('apply') }}</button>
</div>
</div>
</div>

View File

@@ -57,11 +57,11 @@
if (!no_confirm) {
var buttons = {
cancel: {
label: '{{ __('cancel') }}',
label: '{{ __('Annuler') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('save') }}',
label: '{{ __('Sauver') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);

View File

@@ -4,8 +4,8 @@ Route::prefix('PriceListValues')->name('PriceListValues.')->group(function () {
Route::get('', 'PriceListValueController@index')->name('index');
Route::get('create', 'PriceListValueController@create')->name('create');
Route::delete('destroy/{id?}', 'PriceListValueController@destroy')->name('destroy');
Route::post('update', 'PriceListValueController@update')->name('update');
Route::post('store', 'PriceListValueController@store')->name('store');
Route::get('edit/{id}', 'PriceListValueController@edit')->name('edit');
Route::get('addPrice/{index?}', 'PriceListValueController@addPrice')->name('addPrice');
});

View File

@@ -13,6 +13,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
include __DIR__ . '/Orders.php';
include __DIR__ . '/Packages.php';
include __DIR__ . '/PriceLists.php';
include __DIR__ . '/PriceListValues.php';
include __DIR__ . '/SaleChannels.php';
include __DIR__ . '/Tags.php';
include __DIR__ . '/TagGroups.php';