Update with new price management

This commit is contained in:
Ludovic CANDELLIER
2021-03-22 00:47:44 +01:00
parent 083d358fbd
commit 37ffaa938b
64 changed files with 1118 additions and 984 deletions

View File

@@ -0,0 +1,77 @@
@if(!defined('LOAD_APPENDER'))
@push('js')
<script>
(function ($) {
$.fn.appender = function (settings) {
let appendArea = this;
let rowHtml = $(settings.rowSection)[0].outerHTML;
settings.hideSection ? $(settings.rowSection).remove() : "";
let rowCounter = 1;
if (settings.rowNumberStart) {
rowCounter = Number(settings.rowNumberStart);
}
$(document).on('click', settings.addBtn, function (event) {
$(appendArea).append(rowHtml);
if (settings.appendEffect === 'fade') {
$(settings.rowSection).last().hide().fadeIn();
} else if (settings.appendEffect === 'slide') {
$(settings.rowSection).last().hide().slideDown(200);
}
$(settings.rowSection).last().addClass(settings.addClass);
$(settings.rowNumber).last().text(rowCounter);
type = (settings.type) ? settings.type : settings.rowSection;
$(type).each(function(rowIndex) {
$(this).find('input[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('select[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('textarea[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('.appender').each(function() {
$(this).data('id',rowIndex);
});
});
rowCounter++;
if (settings.callback) {
settings.callback();
}
});
if (settings.deleteBtn) {
$(document).on('click', settings.deleteBtn, function (e) {
$(e.target).closest(settings.rowSection).remove();
if (settings.callback) {
settings.callback();
}
})
}
};
}(jQuery));
</script>
@endpush
@php(define('LOAD_APPENDER', true))
@endif

View File

@@ -0,0 +1,18 @@
@if(!defined('LOAD_AUTOCOMPLETE'))
@push('js')
<script src="{{ asset('/assets/plugins/autocomplete/bootstrap-autocomplete.min.js') }}"></script>
<script>
function initAutocomplete(sel) {
var selector = (typeof(sel) == 'undefined') ? '.autocomplete' : sel;
$(selector).autoComplete();
$(selector).on('autocomplete.select', function(evt, item) {
var field = $(this).data('field');
var id = item.value;
$('#'+field).val(id);
});
}
</script>
@endpush
@php(define('LOAD_AUTOCOMPLETE', true))
@endif

View File

@@ -0,0 +1,16 @@
@if(!defined('LOAD_CHEVRON'))
@push('scripts')
<script>
function initChevron(sel) {
var selector = (typeof(sel) == 'undefined') ? '.card-header .btn-link' : sel;
$(selector).click(function() {
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
});
}
</script>
@endpush
@php(define('LOAD_CHEVRON', true))
@endif

View File

@@ -1,23 +1,45 @@
@if(!defined('LOAD_DATATABLES'))
@push('css')
<link rel="stylesheet" href="{{ asset('css/datatables.min.css') }}">
<link rel="stylesheet" href="{!! mix('/js/datatables/datatables.min.css', '/assets/vendor/boilerplate') !!}">
<link rel="stylesheet" href="{{ asset('assets/plugins/datatables.min.css') }}">
@endpush
@push('scripts')
<script src="{{ asset('js/datatables.min.js') }}"></script>
@include('boilerplate::load.moment')
<script src="{{ asset('assets/plugins/datatables.min.js') }}"></script>
<script src="{{ asset('vendor/datatables/buttons.server-side.js') }}"></script>
<script>
$.extend( true, $.fn.dataTable.defaults, {
language: {
url: "/assets/vendor/boilerplate/js/datatables/i18n/French.json"
}
});
</script>
url: "/assets/plugins/datatables_lang/{{ \App::getLocale() }}.json"
},
});
function reloadDatatable(name) {
getDatatable(name).ajax.reload(null,false);
}
function getDatatable(name) {
if (typeof(window.LaravelDataTables) !== 'undefined') {
return window.LaravelDataTables[name + "-table"];
} else {
return false;
}
}
function getDatatableState(name) {
var table = getDatatable("{{ $model }}");
return table ? table.state.loaded() : false;
}
</script>
@endpush
@php(define('LOAD_DATATABLES', true))
@endif
@endif
@push('scripts')
@if ($dataTable)
{{ $dataTable->scripts() }}
@endif
@endpush

View File

@@ -0,0 +1,30 @@
@if(!defined('LOAD_DATEPICKER'))
@push('css')
<link rel="stylesheet" href="{!! mix('/js/datepicker/datepicker.min.css', '/assets/vendor/boilerplate') !!}">
@endpush
@push('js')
@include('load.moment')
<script src="{!! mix('/js/datepicker/datepicker.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script>
$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
locale: '{{ (App::getLocale() == 'en' ? 'en-GB' : App::getLocale()) }}',
icons: $.extend({}, $.fn.datetimepicker.Constructor.Default.icons, {
time: 'far fa-clock',
date: 'far fa-calendar-alt',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
})
});
function initDatepicker(sel, format, date) {
var selector = (typeof(sel) == 'undefined') ? '.datepicker' : sel;
var format = (typeof(format) == 'undefined') ? 'L' : format;
// var date = (typeof(date) == 'undefined') ? new Date() : date;
$(selector).datetimepicker({
format: format
});
}
</script>
@endpush
@php(define('LOAD_DATEPICKER', true))
@endif

View File

@@ -0,0 +1,15 @@
@if(!defined('LOAD_EDITOR'))
@include('load.editor.tinymce')
@push('js')
<script>
function initEditor(selector) {
var selector = '.editor';
$(selector).tinymce({});
}
</script>
@endpush
@php(define('LOAD_EDITOR', true))
@endif

View File

@@ -0,0 +1,39 @@
@if(!defined('LOAD_TINYMCE'))
@push('js')
<script src="{!! mix('/js/tinymce/tinymce.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script>
tinymce.defaultSettings = {
plugins: "autoresize fullscreen codemirror link lists table media image imagetools paste customalign stickytoolbar",
toolbar: "undo redo | styleselect | bold italic underline | customalignleft aligncenter customalignright | link media image | bullist numlist | table | code fullscreen",
contextmenu: "link image imagetools table spellchecker bold italic underline",
sticky_toolbar_container: '.tox-editor-header',
toolbar_drawer: "sliding",
sticky_offset: $('nav.main-header').outerHeight(),
codemirror: { config: { theme: 'storm' } },
menubar: false,
removed_menuitems: 'newdocument',
remove_linebreaks: false,
forced_root_block: false,
force_p_newlines: true,
relative_urls: false,
verify_html: false,
branding: false,
statusbar: false,
browser_spellcheck: true,
encoding: 'UTF-8',
image_uploadtab: false,
paste_preprocess: function(plugin, args) {
args.content = args.content.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ''); // Unwanted tags
args.content = args.content.replace(/\s(class|style|type|start)=("(.*?)"|(\w*))/gi, ''); // Unwanted attributes
args.content = args.content.replace(/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s|&nbsp;|<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi, ''); // Empty tags
},
skin : "boilerplate",
@if(config('boilerplate.app.locale') !== 'en')
language: '{{ config('boilerplate.app.locale') }}'
@endif
};
</script>
@endpush
@php(define('LOAD_TINYMCE', true))
@endif

View File

@@ -0,0 +1,25 @@
@if(!defined('LOAD_FILEINPUT'))
@push('css')
<link rel="stylesheet" href="{!! mix('/js/fileinput/bootstrap-fileinput.min.css', '/assets/vendor/boilerplate') !!}">
@endpush
@push('js')
<script src="{!! mix('/js/fileinput/bootstrap-fileinput.min.js', '/assets/vendor/boilerplate') !!}"></script>
@if(App::getLocale() !== 'en')
<script src="{!! asset('/assets/vendor/boilerplate/js/fileinput/locales/'.config('boilerplate.app.locale').'.js') !!}"></script>
<script>
$.fn.fileinput.defaults.language = '{{ config('boilerplate.app.locale') }}';
</script>
@endif
@endpush
<script>
function initUpload(selector) {
var selector = '.file';
$(selector).fileinput({
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
});
}
</script>
@php(define('LOAD_FILEINPUT', true))
@endif

View File

@@ -0,0 +1,74 @@
@if(!defined('LOAD_HANDLEBARS'))
@push('scripts')
<script>
function renderContractDriveTPL(filename, data, selector) {
data.translate = translate;
var path = '/assets/apps/ContractDrive/templates/';
var content = getTemplate(path + filename, data);
if (typeof(selector) == 'undefined')
{
return content;
} else {
$(selector).html(content);
}
}
function getTemplate(file, data) {
var source = getSource(file);
var template = Handlebars.compile(source);
return template(data);
}
function getSource(file) {
var source = null;
$.ajax({
async: false,
dataType: 'html',
type: 'GET',
url: file + '?' + Date.now(),
success: function(data) {
source = data;
}
});
return source;
}
function view(template_id, data) {
// console.log(template_id);
// console.log(data);
var source = document.getElementById(template_id).innerHTML;
var template = Handlebars.compile(source);
return template(data);
}
function helperSelect(name, items, selected, options) {
// If the selected value is an array, then convert the
// select to a multiple select
if (selected instanceof Array) {
options.hash.multiple = 'multiple';
}
// Generate the list of options
var optionsHtml = '';
for (var i = 0, j = items.length; i < j; i++) {
// <option> attributes
var attr = {
value: items[i].value
};
// We can specify which options are selected by using either:
// * an array of selected values or
// * a single selected value
if ((selected instanceof Array && indexOf(selected, items[i].value) !== -1) || (selected === items[i].value)) {
attr.selected = 'selected';
}
optionsHtml += createElement('option', true, attr, items[i].text);
}
}
</script>
@endpush
@php(define('LOAD_HANDLEBARS', true))
@endif

View File

@@ -0,0 +1,114 @@
@if(!defined('LOAD_MODAL'))
@push('js')
<script>
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm) {
var status = 0;
var dialog = bootbox.dialog({
title: title,
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large',
scrollable: true,
onHide: function(e) {
console.log(status);
},
buttons: buildModalButtons(form_id, no_confirm)
});
/*
changeModalContent(dialog, url_open);
var callback = handlePostModal(form_id,url_save, callback);
handlePostModal(form_id,url_save, callback);
*/
dialog.init(function() {
$.get(url_open, function(data) {
dialog.find('.bootbox-body').html(data);
handlePostModal(form_id,url_save, callback);
});
});
}
function changeModalContent(dialog, url, callback) {
dialog.init(function() {
$.get(url, function(data) {
dialog.find('.bootbox-body').html(data);
});
});
}
function viewModal(url, size, title) {
var dialog = bootbox.dialog({
title: title ? title : 'Web viewer',
message: '<iframe style="border:0;" src="' + url + '" height="400" width="100%"></iframe>',
size: size ? size : 'xl',
scrollable: true,
});
}
function buildModalButtons(form_id, no_confirm) {
if (!no_confirm) {
var buttons = {
cancel: {
label: '{{ __('cancel') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('save') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);
}
},
};
} else {
buttons = '';
}
return buttons;
}
function submitModal(form_id) {
/*
var data = $(form_id).serialize();
$.post(url_save, data)
.done(function(data) {
if (callback) {
eval(callback);
}
});
*/
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
var oForm = 'form' + form_id;
$(oForm).submit();
status = 1;
}
function handlePostModal(form_id,url_save, callback) {
var oForm = 'form'+form_id;
$(oForm).submit(function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url: url_save,
type: 'POST',
data: formData,
success: function (data) {
if (callback) {
eval(callback);
}
},
cache: false,
contentType: false,
processData: false
});
});
}
</script>
@endpush
@php(define('LOAD_MODAL', true))
@endif

View File

@@ -0,0 +1,7 @@
@if(!defined('LOAD_MOMENT'))
<script src="{!! mix('/js/moment/moment-with-locales.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script>
moment.locale('{{ App::getLocale() }}');
</script>
@php(define('LOAD_MOMENT', true))
@endif

View File

@@ -0,0 +1,53 @@
@if(!defined('LOAD_NESTABLE'))
@push('scripts')
<script src="{{ asset('/assets/plugins/nestable2/jquery.nestable.min.js') }}"></script>
<script>
function getPrevious(id, tree)
{
var next = _.find(tree, {'id': id}).right + 1;
var before = _.find(tree, {'left': next});
return (typeof(before) != 'undefined') ? before.id : false;
}
function getAfter(id, tree)
{
var previous = _.find(tree, {'id': id}).left - 1;
var after = _.find(tree, {'right': previous});
return (typeof(after) != 'undefined') ? after.id : false;
}
function nestable_move(id, l, moveBefore, moveAfter, callback) {
var target_id = getPrevious(id, l.nestable('toArray'));
if (target_id) {
var url = moveBefore;
} else {
var target_id = getAfter(id, l.nestable('toArray'));
var url = moveAfter;
}
if (target_id) {
$.ajax({
url: url,
method: 'post',
data: {
id : id,
target_id : target_id,
}
}).done(function() {
growl("admin.movesuccess", 'success');
if (callback != 'undefined') {
eval(callback);
}
});
}
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/nestable2/jquery.nestable.min.css') }}">
@endpush
@php(define('LOAD_NESTABLE', true))
@endif

View File

@@ -0,0 +1,18 @@
@if(!defined('LOAD_SELECT2'))
@push('scripts')
<script src="{!! mix('/js/select2/select2.full.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script src="{!! asset('/assets/vendor/boilerplate/js/select2/i18n/'.config('boilerplate.app.locale').'.js') !!}"></script>
<script>
function initSelect2() {
$(".select2").select2({
placeholder: "Select a value",
allowClear: false,
width: {
value: '100%'
}
});
}
</script>
@endpush
@php(define('LOAD_SELECT2', true))
@endif

View File

@@ -0,0 +1,25 @@
@if(!defined('LOAD_SET_OPTIONS'))
@push('js')
<script>
function setOptions(selector,data,selected,all) {
// console.log(data);
var $el = $(selector);
$el.empty(); // remove old options
if (all) {
$el.append($("<option></option>").attr("value",'').text('{{ __("all") }}'));
}
$.each(data, function(key, name) {
console.log(name);
if (key != null) {
if (key == selected) {
$el.append($("<option selected='selected'></option>").attr("value", key).text(name));
} else {
$el.append($("<option></option>").attr("value", key).text(name));
}
}
});
}
</script>
@endpush
@php(define('LOAD_SET_OPTIONS', true))
@endif

View File

@@ -0,0 +1,34 @@
@if(!defined('LOAD_TOGGLE'))
@push('scripts')
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
<script>
function initToggle(url, sel, data, callback) {
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
if (typeof(data) == 'undefined') {
var data = {};
}
$(selector).bootstrapToggle();
$('input' + selector).change(function() {
console.log($(this));
data['id'] = $(this).data('id');
data['active'] = $(this).is(':checked');
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
var dataJson = Object.assign({}, data);
$.post(url, dataJson);
}
if (typeof(callback) != 'undefined') {
eval(callback);
}
});
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
@endpush
@php(define('LOAD_TOGGLE', true))
@endif