Merge branch 'develop' into fix_eventcreation

This commit is contained in:
Florian HENRY
2020-09-27 17:58:05 +02:00
183 changed files with 3627 additions and 1768 deletions

View File

@@ -397,6 +397,8 @@ abstract class CommonDocGenerator
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)),
$array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''),
$array_key.'_bank_iban'=>$bank_account->iban,
$array_key.'_bank_bic'=>$bank_account->bic,

View File

@@ -544,7 +544,7 @@ abstract class CommonInvoice extends CommonObject
$labelStatus = $langs->trans('BillStatusClosedPaidPartially');
$labelStatusShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
$statusType = 'status9';
} elseif ($alreadypaid <= 0) {
} elseif ($alreadypaid == 0) {
$labelStatus = $langs->trans('BillStatusNotPaid');
$labelStatusShort = $langs->trans('Bill'.$prefix.'StatusNotPaid');
$statusType = 'status1';

View File

@@ -5741,11 +5741,9 @@ abstract class CommonObject
}
// Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine
if (empty($morecss) && !empty($val['css']))
{
if (empty($morecss) && !empty($val['css'])) {
$morecss = $val['css'];
} elseif (empty($morecss))
{
} elseif (empty($morecss)) {
if ($type == 'date')
{
$morecss = 'minwidth100imp';
@@ -5792,16 +5790,16 @@ abstract class CommonObject
{
$tmp = explode(',', $size);
$newsize = $tmp[0];
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (in_array($type, array('real')))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (preg_match('/varchar/', $type))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (in_array($type, array('mail', 'phone', 'url')))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif ($type == 'text')
{
if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
@@ -6641,7 +6639,7 @@ abstract class CommonObject
// Show only the key field in params
if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue;
// @todo Add test also on 'enabled' (different than 'list' that is 'visibility')
// Test on 'enabled' ('enabled' is different than 'list' = 'visibility')
$enabled = 1;
if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key]))
{
@@ -6686,13 +6684,17 @@ abstract class CommonObject
switch ($mode) {
case "view":
$value = $this->array_options["options_".$key.$keysuffix];
$value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later
break;
case "create":
case "edit":
$check = 'restricthtml';
// TODO Use check = 'alphahtml' or 'int' for some types
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, $check); // GETPOST can get value from GET, POST or setup of default values.
// We get the value of property found with GETPOST so it takes into account:
// default values overwrite, restore back to list link, ... (but not 'default value in database' of field)
$check = 'alphanohtml';
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text'))) {
$check = 'restricthtml';
}
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, $check, 3); // GETPOST can get value from GET, POST or setup of default values overwrite.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
@@ -6757,18 +6759,18 @@ abstract class CommonObject
{
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
}
// Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double')))
{
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key];
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? price2num($value) : $this->array_options['options_'.$key];
}
// HTML, select, integer and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'select', 'int')))
// HTML, text, select, integer and varchar: take into account default value in database if in create mode
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int')))
{
if ($action == 'create') $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ? GETPOST($keyprefix.'options_'.$key.$keysuffix, 'restricthtml', 3) : $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
if ($action == 'create') $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key];
}
$labeltoshow = $langs->trans($label);
@@ -6802,6 +6804,8 @@ abstract class CommonObject
$out .= $extrafields->showOutputField($key, $value);
break;
case "create":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
break;
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
break;

View File

@@ -132,6 +132,19 @@ class ExtraFields
*/
public $attribute_list;
/**
* @var array Array to store if field is summable
* @deprecated
*/
public $attribute_totalizable;
/**
* @var array Array to store entity id of extrafield
* @deprecated
*/
public $attribute_entityid;
/**
* @var array New array to store extrafields definition
*/

View File

@@ -4038,7 +4038,7 @@ class Form
* type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ...
* @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0'
* @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box (0 = auto)
* @param int|string $height Force height of box (0 = auto)
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
@@ -4058,7 +4058,7 @@ class Form
// Set height automatically if not defined
if (empty($height)) {
$height = 210;
$height = 220;
if (is_array($formquestion) && count($formquestion) > 2) {
$height += ((count($formquestion) - 2) * 24);
}
@@ -5280,10 +5280,11 @@ class Form
* @param string $openinghours Specify hour start and hour end for the select ex 8,20
* @param int $stepminutes Specify step for minutes between 1 and 30
* @param string $labeladddateof Label to use for the $adddateof parameter.
* @param string $placeholder Placeholder
* @return string Html for selectDate
* @see form_date(), select_month(), select_year(), select_dayofweek()
*/
public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '')
public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '')
{
global $conf, $langs;
@@ -5420,6 +5421,7 @@ class Form
$retstring .= '<div class="nowrap inline-block">';
$retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.'"';
$retstring .= ($disabled ? ' disabled' : '');
$retstring .= ($placeholder ? ' placeholder="'.$placeholder.'"' : '');
$retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>';
@@ -6461,11 +6463,12 @@ class Form
templateSelection: formatSelection /* For 4.0 */
});
});'."\n";
} elseif ($addjscombo == 2)
} 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
// ...
$out .= 'console.log(\'addjscombo=2 for htmlname='.$htmlname.'\');';
$out .= '$(document).ready(function () {
$(\'#'.$htmlname.'\').multiSelect({
containerHTML: \'<div class="multi-select-container">\',
@@ -7158,7 +7161,7 @@ class Form
}
//if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>';
$ret .= '<div class="inline-block floatleft valignmiddle maxwidth750 refid'.(($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '').'">';
$ret .= '<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid'.(($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '').'">';
// For thirdparty, contact, user, member, the ref is the id, so we show something else
if ($object->element == 'societe')

View File

@@ -1252,7 +1252,7 @@ class FormFile
} else {
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
}
print '<img class="photo maxwidth200" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6) ? '12' : $maxheightmini).'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$smallfile).'" title="">';
print '<img class="photo maxwidth200 shadow" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6) ? '12' : $maxheightmini).'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$smallfile).'" title="">';
print '</a>';
} else print '&nbsp;';
print '</td>';

View File

@@ -1048,6 +1048,7 @@ class FormOther
// Class Form must have been already loaded
$selectboxlist .= '<!-- Form with select box list -->'."\n";
$selectboxlist .= '<form id="addbox" name="addbox" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$selectboxlist .= '<input type="hidden" name="token" value="'.newToken().'">';
$selectboxlist .= '<input type="hidden" name="addbox" value="addbox">';
$selectboxlist .= '<input type="hidden" name="userid" value="'.$user->id.'">';
$selectboxlist .= '<input type="hidden" name="areacode" value="'.$areacode.'">';

View File

@@ -120,7 +120,8 @@ class Menu
$nb = 0;
foreach ($this->liste as $val)
{
if (!empty($val['enabled'])) $nb++;
//if (dol_eval($val['enabled'], 1)) $nb++;
if (!empty($val['enabled'])) $nb++; // $val['enabled'] is already evaluated to 0 or 1, no need for dol_eval()
}
return $nb;
}