137 lines
4.8 KiB
PHP
137 lines
4.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @version CVS: 1.0.0
|
|
* @package Com_Circolari
|
|
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
|
|
* @copyright 2025 Tommaso Cippitelli
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
// No direct access
|
|
defined('_JEXEC') or die;
|
|
|
|
use \Joomla\CMS\HTML\HTMLHelper;
|
|
use \Joomla\CMS\Factory;
|
|
use \Joomla\CMS\Uri\Uri;
|
|
use \Joomla\CMS\Router\Route;
|
|
use \Joomla\CMS\Language\Text;
|
|
|
|
$wa = $this->document->getWebAssetManager();
|
|
$wa->useScript('keepalive')
|
|
->useScript('form.validate');
|
|
HTMLHelper::_('bootstrap.tooltip');
|
|
?>
|
|
|
|
<form
|
|
action="<?php echo Route::_('index.php?option=com_circolari&layout=edit&id=' . (int) $this->item->id); ?>"
|
|
method="post" enctype="multipart/form-data" name="adminForm" id="adminForm" class="form-validate form-horizontal">
|
|
|
|
|
|
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', array('active' => 'Circolari')); ?>
|
|
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'Circolari', Text::_('COM_CIRCOLARI_TAB_CIRCOLARI', true)); ?>
|
|
<div class="row-fluid">
|
|
<div class="col-md-12 form-horizontal">
|
|
<fieldset class="adminform">
|
|
<legend><?php echo Text::_('COM_CIRCOLARI_FIELDSET_CIRCOLARI'); ?></legend>
|
|
<?php echo $this->form->renderField('title'); ?>
|
|
<?php echo $this->form->renderField('alias'); ?>
|
|
<?php echo $this->form->renderField('categoria_id'); ?>
|
|
<?php echo $this->form->renderField('description'); ?>
|
|
<?php echo $this->form->renderField('attachment'); ?>
|
|
<?php echo $this->form->renderField('image'); ?>
|
|
<?php echo $this->form->renderField('firma_obbligatoria'); ?>
|
|
<?php echo $this->form->renderField('usergroup_ids'); ?>
|
|
<?php echo $this->form->renderField('scadenza'); ?>
|
|
<?php echo $this->form->renderField('notify'); ?>
|
|
</fieldset>
|
|
|
|
</div>
|
|
</div>
|
|
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
|
<?php echo \Joomla\CMS\HTML\HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('Pubblicazione', true)); ?>
|
|
<div class="row-fluid">
|
|
<div class="col-md-12 form-horizontal">
|
|
<fieldset class="adminform">
|
|
<legend><?php echo Text::_('Pubblicazione'); ?></legend>
|
|
<?php echo $this->form->renderField('hits'); ?>
|
|
<?php echo $this->form->renderField('created'); ?>
|
|
<?php echo $this->form->renderField('created_by'); ?>
|
|
<?php echo $this->form->renderField('modified'); ?>
|
|
<?php echo $this->form->renderField('modified_by'); ?>
|
|
<?php echo $this->form->renderField('publish_up'); ?>
|
|
<?php echo $this->form->renderField('publish_down'); ?>
|
|
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
<?php echo \Joomla\CMS\HTML\HTMLHelper::_('uitab.endTab'); ?>
|
|
|
|
<input type="hidden" name="jform[id]" value="<?php echo isset($this->item->id) ? $this->item->id : ''; ?>" />
|
|
<input type="hidden" name="jform[state]" value="<?php echo isset($this->item->state) ? $this->item->state : ''; ?>" />
|
|
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
|
<input type="hidden" name="task" value="" />
|
|
<?php echo HTMLHelper::_('form.token'); ?>
|
|
</form>
|
|
|
|
<?php
|
|
|
|
Factory::getDocument()->addScriptDeclaration(<<<'JS'
|
|
(function(){
|
|
// Supporta sia select che radio per jform_firma_obbligatoria
|
|
function getFirmaObbligatoriaValue(){
|
|
var radios = document.querySelectorAll('input[name="jform[firma_obbligatoria]"]');
|
|
if (radios.length){
|
|
var r = Array.prototype.find.call(radios, function(x){ return x.checked; });
|
|
return r ? r.value : '0';
|
|
}
|
|
var sel = document.getElementById('jform_firma_obbligatoria');
|
|
return sel ? sel.value : '0';
|
|
}
|
|
|
|
function toggleScadenzaRequired(){
|
|
var need = getFirmaObbligatoriaValue() === '1';
|
|
var input = document.getElementById('jform_scadenza');
|
|
var label = document.getElementById('jform_scadenza-lbl');
|
|
|
|
if (input){
|
|
if (need){
|
|
input.setAttribute('required','required');
|
|
input.setAttribute('aria-required','true');
|
|
} else {
|
|
input.removeAttribute('required');
|
|
input.removeAttribute('aria-required');
|
|
input.classList.remove('invalid');
|
|
}
|
|
}
|
|
|
|
if (label){
|
|
if (need){
|
|
label.classList.add('required');
|
|
if (!label.querySelector('.star')){
|
|
var s = document.createElement('span');
|
|
s.className = 'star';
|
|
s.setAttribute('aria-hidden','true');
|
|
s.innerHTML = ' *';
|
|
label.appendChild(s);
|
|
}
|
|
} else {
|
|
label.classList.remove('required');
|
|
var star = label.querySelector('.star');
|
|
if (star){ star.remove(); }
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bind change su select/radio
|
|
document.addEventListener('change', function(e){
|
|
if (e.target && (e.target.id === 'jform_firma_obbligatoria' || e.target.name === 'jform[firma_obbligatoria]')){
|
|
toggleScadenzaRequired();
|
|
}
|
|
});
|
|
|
|
// Init
|
|
document.addEventListener('DOMContentLoaded', toggleScadenzaRequired);
|
|
})();
|
|
JS);
|