Fixes
This commit is contained in:
@@ -12,6 +12,7 @@ class PriceGenericCategoriesDataTable extends DataTable
|
||||
|
||||
public function query(PriceGenericCategory $model)
|
||||
{
|
||||
$model = $model->withCount('price_generics');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -19,6 +20,7 @@ class PriceGenericCategoriesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('price_generics_count')->title('Nb Tarifs')->class('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class PriceGenericController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$data['unities'] = Unities::getOptions();
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.create',$data);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class PriceGenericController extends Controller
|
||||
$data['generic'] = PriceGenerics::getFull($id)->toArray();
|
||||
$data['packages'] = Packages::getSelectByFamily($data['generic']['category']['article_family_id']);
|
||||
$data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : [];
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.edit', $data);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
function append_price() {
|
||||
handle_prices();
|
||||
handle_prices_taxed();
|
||||
handle_change_package();
|
||||
// handle_append_attribute();
|
||||
// $('.select2').select2();
|
||||
}
|
||||
@@ -61,16 +62,41 @@
|
||||
})
|
||||
}
|
||||
|
||||
function handle_packages() {
|
||||
$('.delete-price-btn').click(function() {
|
||||
var $selector = $(this).parents('.row-price');
|
||||
var id = $selector.find('.price_id').val();
|
||||
|
||||
confirm_delete(id, laroute.route('Shop.Admin.PriceGenericValues.destroy', {id : id}), function() {
|
||||
$selector.remove();
|
||||
});
|
||||
});
|
||||
function handle_change_package() {
|
||||
$('.packages').change( function() {
|
||||
var package_id = $(this).val();
|
||||
var $package = $(this);
|
||||
var $parent = $package.parent().parent();
|
||||
var $selector = $parent.find('.unities');
|
||||
load_unities($selector, package_id);
|
||||
});
|
||||
}
|
||||
|
||||
function init_unities() {
|
||||
$('.packages').each( function() {
|
||||
var package_id = $(this).val();
|
||||
var $package = $(this);
|
||||
var $parent = $package.parent().parent();
|
||||
var $selector = $parent.find('.unities');
|
||||
load_unities($selector, package_id);
|
||||
value_id = $selector.data('id');
|
||||
$selector.val(value_id).trigger('change');
|
||||
});
|
||||
}
|
||||
|
||||
function load_unities($selector, package_id) {
|
||||
$.ajax({
|
||||
url : "{{ route('Shop.Admin.Unities.getOptionsByPackage') }}",
|
||||
method : 'POST',
|
||||
data: { package_id: package_id },
|
||||
success : function(data) {
|
||||
setOptions($selector, data);
|
||||
// $selector.empty().select2({data: data});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user