clean code
This commit is contained in:
parent
5e692fa9db
commit
2894dac221
@ -6707,24 +6707,20 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add code for jquery to use multiselect
|
// 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.' -->
|
$out .= "\n".'<!-- JS CODE TO ENABLE select for id '.$htmlname.' -->
|
||||||
<script>'."\n";
|
<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;
|
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
||||||
$out .= 'function formatResult(record) {'."\n";
|
$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>\';';
|
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
|
||||||
} else {
|
} else {
|
||||||
$out .= 'return record.text;';
|
$out .= 'return record.text;';
|
||||||
}
|
}
|
||||||
$out .= '};'."\n";
|
$out .= '};'."\n";
|
||||||
$out .= 'function formatSelection(record) {'."\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>\';';
|
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
|
||||||
} else {
|
} else {
|
||||||
$out .= 'return record.text;';
|
$out .= 'return record.text;';
|
||||||
@ -6741,8 +6737,7 @@ class Form
|
|||||||
templateSelection: formatSelection /* For 4.0 */
|
templateSelection: formatSelection /* For 4.0 */
|
||||||
});
|
});
|
||||||
});'."\n";
|
});'."\n";
|
||||||
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT'))
|
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
|
||||||
{
|
|
||||||
// Add other js lib
|
// Add other js lib
|
||||||
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
|
// 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
|
// 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";
|
$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 (is_array($array) && !empty($array)) {
|
||||||
{
|
if ($value_as_key) {
|
||||||
if ($value_as_key) $array = array_combine($array, $array);
|
$array = array_combine($array, $array);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($array))
|
if (!empty($array)) {
|
||||||
{
|
foreach ($array as $key => $value) {
|
||||||
foreach ($array as $key => $value)
|
|
||||||
{
|
|
||||||
$newval = ($translate ? $langs->trans($value) : $value);
|
$newval = ($translate ? $langs->trans($value) : $value);
|
||||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||||
|
|
||||||
$out .= '<option value="'.$key.'"';
|
$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 .= ' selected';
|
||||||
}
|
}
|
||||||
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
|
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
|
||||||
@ -6805,36 +6798,36 @@ class Form
|
|||||||
{
|
{
|
||||||
global $conf, $langs, $user, $extrafields;
|
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
|
$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);
|
$tmparray = explode(',', $user->conf->$tmpvar);
|
||||||
foreach ($array as $key => $val)
|
foreach ($array as $key => $val) {
|
||||||
{
|
|
||||||
//var_dump($key);
|
//var_dump($key);
|
||||||
//var_dump($tmparray);
|
//var_dump($tmparray);
|
||||||
if (in_array($key, $tmparray)) $array[$key]['checked'] = 1;
|
if (in_array($key, $tmparray)) {
|
||||||
else $array[$key]['checked'] = 0;
|
$array[$key]['checked'] = 1;
|
||||||
|
} else {
|
||||||
|
$array[$key]['checked'] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lis = '';
|
$lis = '';
|
||||||
$listcheckedstring = '';
|
$listcheckedstring = '';
|
||||||
|
|
||||||
foreach ($array as $key => $val)
|
foreach ($array as $key => $val) {
|
||||||
{
|
|
||||||
/* var_dump($val);
|
/* var_dump($val);
|
||||||
var_dump(array_key_exists('enabled', $val));
|
var_dump(array_key_exists('enabled', $val));
|
||||||
var_dump(!$val['enabled']);*/
|
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
|
unset($array[$key]); // We don't want this field
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($val['label'])
|
if ($val['label']) {
|
||||||
{
|
|
||||||
if (!empty($val['langfile']) && is_object($langs)) {
|
if (!empty($val['langfile']) && is_object($langs)) {
|
||||||
$langs->load($val['langfile']);
|
$langs->load($val['langfile']);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,4 +174,5 @@ Unanswered=Unanswered
|
|||||||
Answered=Answered
|
Answered=Answered
|
||||||
IsNotAnAnswer=Is not answer (initial email)
|
IsNotAnAnswer=Is not answer (initial email)
|
||||||
IsAnAnswer=Is an answer of an 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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user