mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-04 08:02:22 +01:00
NEW DEV Can set color of the on/off button.
This commit is contained in:
@@ -911,10 +911,11 @@ class FormSetupItem
|
||||
} elseif ($this->type == 'yesno') {
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
$input = $this->fieldParams['input'] ?? array();
|
||||
$revertonoff = !empty($this->fieldParams['revertonoff']) ? 1 : 0;
|
||||
$forcereload = !empty($this->fieldParams['forcereload']) ? 1 : 0;
|
||||
$revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
|
||||
$forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
|
||||
$suffixarray = array('ifoff' => empty($this->fieldParams['alertifoff']) ? '' : '_red', 'ifon' => empty($this->fieldParams['alertifon']) ? '' : '_red');
|
||||
|
||||
$out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload);
|
||||
$out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray);
|
||||
} else {
|
||||
$out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1);
|
||||
}
|
||||
|
||||
@@ -671,12 +671,12 @@ function ajax_event($htmlname, $events)
|
||||
* @param int<0,2> $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No left margin.
|
||||
* @param int<0,1> $forcenoajax 1 = Force to use a ahref link instead of ajax code.
|
||||
* @param int<0,1> $setzeroinsteadofdel 1 = Set constant to '0' instead of deleting it when $input is empty.
|
||||
* @param string $suffix Suffix to use on the name of the switch picto when option is on. Example: '', '_red'
|
||||
* @param string|array $suffix Suffix to use on the name of the switch picto when option is on. Example: array('ifoff' => '_red', 'ifon' => '_green')
|
||||
* @param string $mode Add parameter &mode= to the href link (Used for href link)
|
||||
* @param string $morecss More CSS
|
||||
* @param string $morecss More CSS. Example: 'inline-block reposition'
|
||||
* @param User|int $userconst If set, use the ajax On/Off for user or user ID $userconst
|
||||
* @param string $showwarning String to show a warning when enabled the option
|
||||
* @return string
|
||||
* @return string The HTML component of button
|
||||
* @see ajax_object_onoff() to update the status of an object
|
||||
*/
|
||||
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix = '', $mode = '', $morecss = 'inline-block', $userconst = 0, $showwarning = '')
|
||||
@@ -756,9 +756,18 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
|
||||
} else {
|
||||
$value = getDolGlobalString($code);
|
||||
}
|
||||
|
||||
if (is_array($suffix)) {
|
||||
$suffixon = $suffix['ifon'];
|
||||
$suffixoff = $suffix['ifoff'];
|
||||
} else { // old mode deprecated
|
||||
$suffixon = (string) $suffix;
|
||||
$suffixoff = '';
|
||||
}
|
||||
|
||||
$out .= '<div id="confirm_'.$code.'" title="" style="display: none;"></div>';
|
||||
$out .= '<span id="set_'.$code.'" class="valignmiddle inline-block linkobject '.($value ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">'.($revertonoff ? img_picto($langs->trans("Enabled"), 'switch_on', '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off', '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>';
|
||||
$out .= '<span id="del_'.$code.'" class="valignmiddle inline-block linkobject '.($value ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">'.($revertonoff ? img_picto($langs->trans("Disabled"), 'switch_off'.$suffix, '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on'.$suffix, '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>';
|
||||
$out .= '<span id="set_'.$code.'" class="valignmiddle inline-block linkobject '.($value ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">'.($revertonoff ? img_picto($langs->trans("Enabled"), 'switch_on'.$suffixoff, '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off'.$suffixoff, '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>';
|
||||
$out .= '<span id="del_'.$code.'" class="valignmiddle inline-block linkobject '.($value ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">'.($revertonoff ? img_picto($langs->trans("Disabled"), 'switch_off'.$suffixon, '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on'.$suffixon, '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>';
|
||||
$out .= "\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -5563,6 +5563,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
|
||||
'switch_on_grey',
|
||||
'switch_on_red',
|
||||
'switch_off',
|
||||
'switch_off_grey',
|
||||
'switch_off_red',
|
||||
'uparrow',
|
||||
'1uparrow',
|
||||
'1downarrow',
|
||||
@@ -5620,6 +5622,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
|
||||
'switch_on' => 'font-status4',
|
||||
'switch_on_warning' => 'font-status4 warning',
|
||||
'switch_on_red' => 'font-status8',
|
||||
'switch_off_warning' => 'font-status4 warning',
|
||||
'switch_off_red' => 'font-status8',
|
||||
'holiday' => 'infobox-holiday',
|
||||
'info' => 'opacityhigh',
|
||||
'info_black' => 'font-status1',
|
||||
@@ -5896,6 +5900,9 @@ function getImgPictoConv($mode = 'fa')
|
||||
'movement' => 'people-carry',
|
||||
'sign-out' => 'sign-out-alt',
|
||||
'switch_off' => 'toggle-off',
|
||||
'switch_off_grey' => 'toggle-off',
|
||||
'switch_off_warning' => 'toggle-off',
|
||||
'switch_off_red' => 'toggle-off',
|
||||
'switch_on' => 'toggle-on',
|
||||
'switch_on_grey' => 'toggle-on',
|
||||
'switch_on_warning' => 'toggle-on',
|
||||
|
||||
@@ -131,7 +131,7 @@ $item = $formSetup->newItem('MYMODULE_MYPARAM4');
|
||||
$item->setAsThirdpartyType();
|
||||
|
||||
// Setup conf for a selection of a boolean
|
||||
$formSetup->newItem('MYMODULE_MYPARAM5')->setAsYesNo();
|
||||
$formSetup->newItem('MYMODULE_MYPARAM5')->setAsYesNo(); // ->fieldParams['alertifoff'] = 1 or ->fieldParams['alertifon'] = 1;
|
||||
|
||||
// Setup conf for a selection of an Email template of type thirdparty
|
||||
$formSetup->newItem('MYMODULE_MYPARAM6')->setAsEmailTemplate('thirdparty');
|
||||
|
||||
Reference in New Issue
Block a user