Merge branch 'develop' of github.com:Dolibarr/dolibarr into fix_element_type_part_05

This commit is contained in:
John BOTELLA
2024-03-13 14:42:43 +01:00
426 changed files with 4619 additions and 4327 deletions

View File

@@ -261,6 +261,16 @@ function isModEnabled($module)
$arrayconv['supplier_order'] = 'fournisseur';
$arrayconv['supplier_invoice'] = 'fournisseur';
}
// Special case.
// @TODO Replace isModEnabled('delivery_note') with
// isModEnabled('shipping') && getDolGlobalString('MAIN_SUBMODULE_EXPEDITION')
if ($module == 'delivery_note') {
if (!getDolGlobalString('MAIN_SUBMODULE_EXPEDITION')) {
return false;
} else {
$module = 'shipping';
}
}
$module_alt = $module;
if (!empty($arrayconv[$module])) {
@@ -2965,10 +2975,12 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
if ($tzoutput == 'tzserver') {
$to_gmt = false;
$offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion'
// @phan-suppress-next-line PhanPluginRedundantAssignment
$offsettz = 0; // Timezone offset with server timezone (because to_gmt is false), so 0
// @phan-suppress-next-line PhanPluginRedundantAssignment
$offsetdst = 0; // Dst offset with server timezone (because to_gmt is false), so 0
} elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
$to_gmt = true;
$to_gmt = true; // @phan-suppress-current-line PhanPluginRedundantAssignment
$offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion'
if (class_exists('DateTimeZone')) {
@@ -4015,7 +4027,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
} elseif ($withpicto == 'mobile') {
$picto = 'phoning_mobile';
} else {
$picto = '';
$picto = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment
}
}
if ($adddivfloat == 1) {
@@ -6416,7 +6428,7 @@ function price2num($amount, $rounding = '', $option = 0)
// So if number was already a good number, it is converted into local Dolibarr setup.
if (is_numeric($amount)) {
// We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10
$temps = sprintf("%0.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
$temps = sprintf("%10.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
$temps = preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1
$nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0."
$amount = number_format($amount, $nbofdec, $dec, $thousand);
@@ -6465,7 +6477,7 @@ function price2num($amount, $rounding = '', $option = 0)
// to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
if (is_numeric($amount)) {
// We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10
$temps = sprintf("%0.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
$temps = sprintf("%10.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
$temps = preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1
$nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0."
$amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand
@@ -8455,7 +8467,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__DIRECTDOWNLOAD_URL_CONTRACT__'] = 'Direct download url of a contract';
$substitutionarray['__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = 'Direct download url of a supplier proposal';
if (isModEnabled("delivery_note") && (!is_object($object) || $object->element == 'shipping')) {
if (isModEnabled("shipping") && (!is_object($object) || $object->element == 'shipping')) {
$substitutionarray['__SHIPPINGTRACKNUM__'] = 'Shipping tracking number';
$substitutionarray['__SHIPPINGTRACKNUMURL__'] = 'Shipping tracking url';
$substitutionarray['__SHIPPINGMETHOD__'] = 'Shipping method';
@@ -8704,7 +8716,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
// Complete substitution array with the url to make online payment
$paymenturl = '';
if (empty($substitutionarray['__REF__'])) {
$paymenturl = '';
} else {
@@ -10308,8 +10319,8 @@ function getLanguageCodeFromCountryCode($countrycode)
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param object|null $object Object object
* @param array $head Object head
* @param int $h New position to fill
* @param array<array<int,string>> $head List of head tabs (updated by this function)
* @param int $h New position to fill (updated by this function)
* @param string $type Value for object where objectvalue can be
* 'thirdparty' to add a tab in third party view
* 'intervention' to add a tab in intervention view
@@ -11193,12 +11204,12 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
$famime = 'file-alt';
} elseif (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) {
$mime = 'text/xml';
$imgmime = 'other.png';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$srclang = 'xml';
$famime = 'file-alt';
} elseif (preg_match('/\.xaml$/i', $tmpfile)) {
$mime = 'text/xml';
$imgmime = 'other.png';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$srclang = 'xaml';
$famime = 'file-alt';
} elseif (preg_match('/\.bas$/i', $tmpfile)) { // Languages
@@ -11362,16 +11373,16 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
$famime = 'file-image';
} elseif (preg_match('/\.vcs$/i', $tmpfile)) { // Calendar
$mime = 'text/calendar';
$imgmime = 'other.png';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$famime = 'file-alt';
} elseif (preg_match('/\.ics$/i', $tmpfile)) {
$mime = 'text/calendar';
$imgmime = 'other.png';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$famime = 'file-alt';
} elseif (preg_match('/\.torrent$/i', $tmpfile)) { // Other
$mime = 'application/x-bittorrent';
$imgmime = 'other.png';
$famime = 'file-o';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$famime = 'file-o'; // @phan-suppress-current-line PhanPluginRedundantAssignment
} elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { // Audio
$mime = 'audio';
$imgmime = 'audio.png';
@@ -11411,12 +11422,12 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
$famime = 'file-archive';
} elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { // Exe
$mime = 'application/octet-stream';
$imgmime = 'other.png';
$famime = 'file-o';
$imgmime = 'other.png'; // @phan-suppress-current-line PhanPluginRedundantAssignment
$famime = 'file-o'; // @phan-suppress-current-line PhanPluginRedundantAssignment
} elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { // Lib
$mime = 'library';
$imgmime = 'library.png';
$famime = 'file-o';
$famime = 'file-o'; // @phan-suppress-current-line PhanPluginRedundantAssignment
} elseif (preg_match('/\.err$/i', $tmpfile)) { // phpcs:ignore
$mime = 'error';
$imgmime = 'error.png';
@@ -11668,7 +11679,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
$return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
} elseif (getDolGlobalString('MAIN_STATUS_USES_IMAGES')) {
// Use status with images (for backward compatibility)
$return = '';
$return = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment
$htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '<span class="hideonsmartphone">' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '</span>' : '');
$htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ? '<span class="hideonsmartphone">' : '').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ? '</span>' : '');
@@ -12173,17 +12184,20 @@ function getElementProperties($elementType)
$classname = 'Expedition';
$module = 'expedition';
$table_element = 'expedition';
} elseif ($elementType == 'delivery_note') {
$classpath = 'delivery/class';
$subelement = 'delivery';
$module = 'expedition';
} elseif ($elementType == 'delivery') {
$classpath = 'delivery/class';
$subelement = 'delivery';
$module = 'expedition';
} elseif ($elementType == 'supplier_proposal') {
$classpath = 'supplier_proposal/class';
$module = 'supplier_proposal';
$element = 'supplierproposal';
$classfile = 'supplier_proposal';
$subelement = 'supplierproposal';
} elseif ($elementType == 'delivery') {
$classpath = 'delivery/class';
$subelement = 'delivery';
// TODO atm-john @2024-03-08 : Strange definition found on fetchObjectLinked of common object, before factoring, the value was $module = 'delivery_note'; Who's right?
$module = 'expedition';
} elseif ($elementType == 'contract') {
$classpath = 'contrat/class';
$module = 'contrat';
@@ -13044,7 +13058,7 @@ function getTimelineIcon($actionstatic, &$histo, $key)
} elseif ($actionstatic->code == 'AC_TICKET_MODIFY') {
$iconClass = 'fa fa-pencilxxx';
} elseif (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
$iconClass = 'fa fa-comments';
$iconClass = 'fa fa-comments'; // @phan-suppress-current-line PhanPluginRedundantAssignment
} elseif (preg_match('/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
$iconClass = 'fa fa-mask';
} elseif (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {