clean code

This commit is contained in:
Frédéric FRANCE 2021-01-02 10:17:11 +01:00
parent 5e692fa9db
commit 2894dac221
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 28 additions and 34 deletions

View File

@ -6707,24 +6707,20 @@ class Form
}
// Add code for jquery to use multiselect
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
$out .= "\n".'<!-- JS CODE TO ENABLE select for id '.$htmlname.' -->
<script>'."\n";
if ($addjscombo == 1)
{
if ($addjscombo == 1) {
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out .= 'function formatResult(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
}
$out .= '};'."\n";
$out .= 'function formatSelection(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
@ -6741,8 +6737,7 @@ class Form
templateSelection: formatSelection /* For 4.0 */
});
});'."\n";
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT'))
{
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
// Add other js lib
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
// ...
@ -6763,20 +6758,18 @@ class Form
// Try also magic suggest
$out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
if (is_array($array) && !empty($array))
{
if ($value_as_key) $array = array_combine($array, $array);
if (is_array($array) && !empty($array)) {
if ($value_as_key) {
$array = array_combine($array, $array);
}
if (!empty($array))
{
foreach ($array as $key => $value)
{
if (!empty($array)) {
foreach ($array as $key => $value) {
$newval = ($translate ? $langs->trans($value) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out .= '<option value="'.$key.'"';
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
{
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) {
$out .= ' selected';
}
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
@ -6805,36 +6798,36 @@ class Form
{
global $conf, $langs, $user, $extrafields;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return '';
}
$tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties
if (!empty($user->conf->$tmpvar))
{
if (!empty($user->conf->$tmpvar)) {
$tmparray = explode(',', $user->conf->$tmpvar);
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
//var_dump($key);
//var_dump($tmparray);
if (in_array($key, $tmparray)) $array[$key]['checked'] = 1;
else $array[$key]['checked'] = 0;
if (in_array($key, $tmparray)) {
$array[$key]['checked'] = 1;
} else {
$array[$key]['checked'] = 0;
}
}
}
$lis = '';
$listcheckedstring = '';
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
/* var_dump($val);
var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled'])
{
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
unset($array[$key]); // We don't want this field
continue;
}
if ($val['label'])
{
if ($val['label']) {
if (!empty($val['langfile']) && is_object($langs)) {
$langs->load($val['langfile']);
}

View File

@ -92,7 +92,7 @@ MailingModuleDescEmailsFromUser=Emails input by user
MailingModuleDescDolibarrUsers=Users with Emails
MailingModuleDescThirdPartiesByCategories=Third parties (by categories)
SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed.
EmailCollectorFilterDesc=All filters must match to have an email being collected
EmailCollectorFilterDesc=All filters must match to have an email being collected
# Libelle des modules de liste de destinataires mailing
LineInFile=Line %s in file
@ -174,4 +174,5 @@ Unanswered=Unanswered
Answered=Answered
IsNotAnAnswer=Is not answer (initial email)
IsAnAnswer=Is an answer of an initial email
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
RecordCreatedByEmailCollector=Record created by the Email Collector %s from
email %s