diff --git a/app/View/Components/EmailHistory.php b/app/View/Components/EmailHistory.php new file mode 100644 index 000000000..59e5ea7f9 --- /dev/null +++ b/app/View/Components/EmailHistory.php @@ -0,0 +1,40 @@ +emails = Mail::whereRaw('id IN (SELECT id_email FROM zz_operations WHERE id_record = '.prepare($record).' AND id_module = '.prepare($module).' AND id_email IS NOT NULL)') + ->orderBy('created_at', 'DESC') + ->get(); + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|string + */ + public function render() + { + return view('components.email-history', [ + 'emails' => $this->emails, + ]); + } +} diff --git a/app/View/Components/Input.php b/app/View/Components/InputWrapper.php similarity index 96% rename from app/View/Components/Input.php rename to app/View/Components/InputWrapper.php index 4aa85a064..0891b5633 100644 --- a/app/View/Components/Input.php +++ b/app/View/Components/InputWrapper.php @@ -5,7 +5,7 @@ namespace App\View\Components; use Illuminate\Support\Collection; use Illuminate\View\Component; -class Input extends Component +class InputWrapper extends Component { public $props; @@ -99,6 +99,6 @@ class Input extends Component */ public function render() { - return view('components.input'); + return view('components.input-wrapper'); } } diff --git a/app/View/Components/Inputs/Checkbox.php b/app/View/Components/Inputs/Checkbox.php index 9b1ae7c51..e4466156d 100644 --- a/app/View/Components/Inputs/Checkbox.php +++ b/app/View/Components/Inputs/Checkbox.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Checkbox extends Input +class Checkbox extends InputWrapper { public function init() { diff --git a/app/View/Components/Inputs/Editor.php b/app/View/Components/Inputs/Editor.php index 4cd97a0a4..a84d0de1c 100644 --- a/app/View/Components/Inputs/Editor.php +++ b/app/View/Components/Inputs/Editor.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Editor extends Input +class Editor extends InputWrapper { public function init() { diff --git a/app/View/Components/Inputs/File.php b/app/View/Components/Inputs/File.php index 46081ce87..aaecda298 100644 --- a/app/View/Components/Inputs/File.php +++ b/app/View/Components/Inputs/File.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class File extends Input +class File extends InputWrapper { public $type = 'file'; diff --git a/app/View/Components/Inputs/Image.php b/app/View/Components/Inputs/Image.php index cb7b6f86b..7665c8bd5 100644 --- a/app/View/Components/Inputs/Image.php +++ b/app/View/Components/Inputs/Image.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Image extends Input +class Image extends InputWrapper { /** * Get the view / contents that represent the component. diff --git a/app/View/Components/Inputs/Number.php b/app/View/Components/Inputs/Number.php index d74d486bd..6be69c80b 100644 --- a/app/View/Components/Inputs/Number.php +++ b/app/View/Components/Inputs/Number.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Number extends Input +class Number extends InputWrapper { /** * Create a new component instance. diff --git a/app/View/Components/Inputs/Password.php b/app/View/Components/Inputs/Password.php index 63efdb99a..e9df69d77 100644 --- a/app/View/Components/Inputs/Password.php +++ b/app/View/Components/Inputs/Password.php @@ -2,9 +2,9 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; -class Password extends Input +class Password extends InputWrapper { /** * Get the view / contents that represent the component. diff --git a/app/View/Components/Inputs/Select.php b/app/View/Components/Inputs/Select.php index f1cd69150..3769aa4a3 100644 --- a/app/View/Components/Inputs/Select.php +++ b/app/View/Components/Inputs/Select.php @@ -2,17 +2,90 @@ namespace App\View\Components\Inputs; +use AJAX; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Select extends Component +class Select extends InputWrapper { + /** * Create a new component instance. * - * @return void + * @param string $name + * @param string|null $id + * @param string|null $value + * @param bool|string $required + * @param string|null $label + * @param string|null $placeholder + * @param bool $multiple + * @param string $source + * @param string $query + * @param array $values + * @param array $options */ - public function __construct() - { + public function __construct( + $name, + $id = null, + $value = null, + $required = false, + $label = null, + $placeholder = null, + $multiple = false, + $source = null, + $query = null, + $values = null, + $options = [] + ) { + parent::__construct($name, $id, $value, $required, $label, $placeholder); + + // Aggiunta classe CSS dedicata + $this->get('class') + ->add('select-input') + // Individuazione della classe per la corretta gestione JavaScript + ->add(!empty($source) ? 'superselectajax' : 'superselect'); + + // Parsing del campo value come array + $value = $this->get('value'); + $value = explode(',', $value); + if (count($value) === 1 && strlen($value[0]) === 0) { + $value = []; + } + + // Impostazione dei dati aggiuntivi + $this->set([ + 'value' => $value, + 'multiple' => $multiple, + 'options' => $options, + 'source' => $source, + ]); + + // Gestione del caricamento delle opzioni opzioni + if (!empty($source)) { + // Richiamo del file dedicato alle richieste AJAX per ottenere il valore iniziale del select + $response = AJAX::select($source, $value, null, 0, 100, $options); + $values = $response['results']; + } elseif (!empty($query)) { + $values = database()->fetchArray($query); + } else { + $values = isset($values) ? $values : []; + } + + // Raggruppamento per campo optgroup + $is_grouped = false; + $groups = collect($values)->mapToGroups(function ($item) { + return [isset($item['optgroup']) ? $item['optgroup'] : '' => $item]; + }); + if (!($groups->count() == 1 && $groups->keys()->first() == '')) { + $values = $groups; + $is_grouped = true; + } + + // Aggiornamento delle informazioni + $this->set([ + 'values' => $values, + 'is_grouped' => $is_grouped, + ]); } /** diff --git a/app/View/Components/Inputs/Text.php b/app/View/Components/Inputs/Text.php index c7249224e..427097b39 100644 --- a/app/View/Components/Inputs/Text.php +++ b/app/View/Components/Inputs/Text.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Text extends Input +class Text extends InputWrapper { /** * Get the view / contents that represent the component. diff --git a/app/View/Components/Inputs/Textarea.php b/app/View/Components/Inputs/Textarea.php index 7efd29364..922c9c3b0 100644 --- a/app/View/Components/Inputs/Textarea.php +++ b/app/View/Components/Inputs/Textarea.php @@ -2,10 +2,10 @@ namespace App\View\Components\Inputs; -use App\View\Components\Input; +use App\View\Components\InputWrapper; use Illuminate\View\Component; -class Textarea extends Input +class Textarea extends InputWrapper { /** * Get the view / contents that represent the component. diff --git a/app/View/Components/WidgetGroup.php b/app/View/Components/WidgetGroup.php new file mode 100644 index 000000000..2b9cf4864 --- /dev/null +++ b/app/View/Components/WidgetGroup.php @@ -0,0 +1,75 @@ +id); + + $query = 'SELECT id FROM zz_widgets WHERE id_module = '.prepare($module->id).' AND (|position|) AND enabled = 1 ORDER BY `order` ASC'; + + // Mobile (tutti i widget a destra) + if (isMobile()) { + if ($position == 'right') { + $position = "location = '".$place."_right' OR location = '".$place."_top'"; + } elseif ($position == 'top') { + $position = '1=0'; + } + } + + // Widget a destra + elseif ($position == 'right') { + $position = "location = '".$place."_right'"; + } + + // Widget in alto + elseif ($position == 'top') { + $position = "location = '".$place."_top'"; + } + + $query = str_replace('|position|', $position, $query); + + // Individuazione dei widget interessati + $this->widgets = database()->fetchArray($query); + $this->position = $position; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|string + */ + public function render() + { + return view('components.widget-group', [ + 'widgets' => $this->widgets, + 'position' => $this->position, + ]); + } +} diff --git a/resources/views/components/email-history.blade.php b/resources/views/components/email-history.blade.php new file mode 100644 index 000000000..e563bfbb6 --- /dev/null +++ b/resources/views/components/email-history.blade.php @@ -0,0 +1,40 @@ +@if(!$emails->isEmpty()) +
+
+

{{ tr('Email inviate: _NUM_', [ + '_NUM_' => $emails->count(), + ]) }}

+
+ +
+
+
+ +
+
+@endif diff --git a/resources/views/components/input.blade.php b/resources/views/components/input-wrapper.blade.php similarity index 100% rename from resources/views/components/input.blade.php rename to resources/views/components/input-wrapper.blade.php diff --git a/resources/views/components/inputs/checkbox.blade.php b/resources/views/components/inputs/checkbox.blade.php index fe6e79748..e6995bdaa 100644 --- a/resources/views/components/inputs/checkbox.blade.php +++ b/resources/views/components/inputs/checkbox.blade.php @@ -1,4 +1,4 @@ - + {{-- "+ this.checked" rende il valore booleano un numero --}}
@@ -23,4 +23,4 @@ {{ isset($before) ? $before : null }} {{ isset($after) ? $after : null }} - + diff --git a/resources/views/components/inputs/editor.blade.php b/resources/views/components/inputs/editor.blade.php index b05f35b93..3a1921c7b 100644 --- a/resources/views/components/inputs/editor.blade.php +++ b/resources/views/components/inputs/editor.blade.php @@ -1,4 +1,4 @@ - +