Merge remote-tracking branch 'upstream/develop' into 16p5-php8

This commit is contained in:
Alexandre SPANGARO 2022-06-29 16:31:41 +02:00
commit d6814b2586
13 changed files with 67 additions and 34 deletions

View File

@ -634,7 +634,7 @@ if (empty($reshook)) {
exit;
}
} else {
$errmesg = $object->error;
setEventMessages($object->error, null, 'errors');
}
}

View File

@ -76,10 +76,15 @@ if ($action == 'add_currency') {
$currency->code = $code;
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
if (empty($currency->code) || $currency->code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Currency")), null, 'errors');
$error++;
}
if (empty($rate)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++;
}
if (!$error) {
if ($currency->create($user) > 0) {
if ($currency->addRate($rate)) {
@ -296,7 +301,7 @@ print '<table class="noborder centpercent nomarginbottom">';
print '<tr class="liste_titre">';
print '<td>'.$form->textwithpicto($langs->trans("CurrenciesUsed"), $langs->transnoentitiesnoconv("CurrenciesUsed_help_to_add")).'</td>'."\n";
print '<td class="center">'.$langs->trans("Rate").'</td>'."\n";
print '<td class="right">'.$langs->trans("Rate").' / '.$langs->getCurrencySymbol($conf->currency).'</td>'."\n";
print '</tr>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
@ -304,17 +309,19 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add_currency">';
print '<tr class="oddeven">';
print '<td>'.$form->selectCurrency('', 'code', 1).'</td>';
print '<td>'.$form->selectCurrency('', 'code', 1, '1').'</td>';
print '<td class="right">';
print '<input type="text" name="rate" value="" class="width75 right" placeholder="'.$langs->trans('Rate').'" />&nbsp;';
print '<input type="submit" class="button button-add small" value="'.$langs->trans("Add").'">';
print '<input type="submit" class="button button-add smallpaddingimp" value="'.$langs->trans("Add").'">';
print '</td>';
print '</tr>';
print '</form>';
print '<tr class="oddeven">';
print '<td>'.$conf->currency.$form->textwithpicto(' ', $langs->trans("BaseCurrency")).'</td>';
print '<td>'.$conf->currency;
print ' ('.$langs->getCurrencySymbol($conf->currency).')';
print $form->textwithpicto(' ', $langs->trans("BaseCurrency")).'</td>';
print '<td class="right">1</td>';
print '</tr>';

View File

@ -84,7 +84,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) {
}
}
} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) {
$result = $object->delete($id);
$result = $object->delete($user);
if ($result >= 0) {
header("Location: index.php");
exit;

View File

@ -1,4 +1,6 @@
<?php
use Stripe\ApiOperations\Delete;
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
@ -310,13 +312,15 @@ class Deplacement extends CommonObject
/**
* Delete record
*
* @param int $id Id of record to delete
* @param User $user USer that Delete
* @return int <0 if KO, >0 if OK
*/
public function delete($id)
public function delete($user)
{
$this->db->begin();
$id = $this->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."deplacement WHERE rowid = ".((int) $id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);

View File

@ -51,7 +51,7 @@ class Conf
public $use_javascript_ajax;
//! To store if javascript/ajax is enabked
public $disable_compute;
//! Used to store current currency (ISO code like 'USD', 'EUR', ...)
//! Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs->getCurrencySymbol($this->currency)
public $currency;
//! Used to store current css (from theme)

View File

@ -372,7 +372,7 @@ class EvalMath
/**
* Evaluate postfix notation
*
* @param string $tokens An array of expression to evaluate ('operators'). The operand are into ->stack.
* @param array $tokens Expression
* @param array $vars Array
* @return string Output
*/

View File

@ -4784,7 +4784,7 @@ class Form
* @param int $outputmode 0=HTML select string, 1=Array
* @param int $include [=0] Removed or 1=Keep only
* @param string $morecss More CSS
* @return string
* @return string|array
* @see select_categories()
*/
public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '')
@ -5848,12 +5848,13 @@ class Form
/**
* Retourne la liste des devises, dans la langue de l'utilisateur
*
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
* @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
* @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code
* @param string $useempty '1'=Allow empty value
* @return string
*/
public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0)
public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0, $useempty = '')
{
global $conf, $langs, $user;
@ -5866,6 +5867,9 @@ class Form
}
$out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty) {
$out .= '<option value="-1" selected></option>';
}
foreach ($langs->cache_currencies as $code_iso => $currency) {
$labeltoshow = $currency['label'];
if ($mode == 1) {

View File

@ -5383,7 +5383,8 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print '</li>';
}
if ((int) $limit > 0 && empty($hideselectlimit)) {
$pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000,25000:25000';
$pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
$pagesizechoices .= ',5000:5000,10000:10000,20000:20000';
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
//$pagesizechoices.=',2:2';
if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {

View File

@ -286,7 +286,7 @@ class modMultiCurrency extends DolibarrModules
$multicurrency = new MultiCurrency($this->db);
if (!$multicurrency->checkCodeAlreadyExists($conf->currency)) {
if (! $multicurrency->checkCodeAlreadyExists($conf->currency)) {
$langs->loadCacheCurrencies('');
$multicurrency->code = $conf->currency;

View File

@ -883,9 +883,9 @@ if ($step == 4 && $datatoexport) {
if (isset($objexport->array_export_fields[0][$code])) {
$list .= ($list ? ', ' : '');
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
$list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
$list .= '<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
} else {
$list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
$list .= '<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code])."</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
}
}
}
@ -1163,9 +1163,9 @@ if ($step == 5 && $datatoexport) {
if (isset($objexport->array_export_fields[0][$code])) {
$list .= ($list ? ', ' : '');
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
$list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
$list .= '<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code]).'</span>'.(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
} else {
$list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
$list .= '<span class="opacitymedium">'.$langs->trans($objexport->array_export_fields[0][$code])."</span>='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
}
}
}

View File

@ -66,7 +66,7 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "cr.date_sync";
if (!$sortorder) $sortorder = "ASC";
if (!$sortorder) $sortorder = "DESC";
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
@ -106,13 +106,27 @@ if (!$user->admin || empty($conf->multicurrency->enabled)) {
accessforbidden();
}
$error = 0;
/*
* Actions
*/
if ($action == "create") {
if (!empty($rateinput)) {
if (empty($multicurrency_code) || $multicurrency_code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Currency")), null, "errors");
$error++;
}
if ($rateinput === '0') {
setEventMessages($langs->trans('NoEmptyRate'), null, "errors");
$error++;
} elseif (empty($rateinput)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, "errors");
$error++;
}
if (!$error) {
$currencyRate_static = new CurrencyRate($db);
$currency_static = new MultiCurrency($db);
$fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code);
@ -129,8 +143,6 @@ if ($action == "create") {
dol_syslog("currencyRate:createRate", LOG_WARNING);
setEventMessages($currencyRate_static->error, $currencyRate_static->errors, 'errors');
}
} else {
setEventMessages($langs->trans('NoEmptyRate'), null, "errors");
}
}
@ -261,7 +273,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) {
print '<td> '.$langs->trans('Currency').'</td>';
print '<td>'.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$db->escape($conf->currency)."'", true).'</td>';
print ' <td>'.$langs->trans('Rate').'</td>';
print ' <td>'.$langs->trans('Rate').' / '.$langs->getCurrencySymbol($conf->currency).'</td>';
print ' <td><input type="text" min="0" step="any" class="maxwidth75" name="rateinput" value="'.dol_escape_htmltag($rateinput).'"></td>';
print '<td>';
@ -280,7 +292,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) {
$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name ';
$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name';
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
@ -496,7 +508,8 @@ if ($resql) {
// code
if (! empty($arrayfields['m.code']['checked'])) {
print '<td class="tdoverflowmax200">';
print $obj->code." ".$obj->name;
print $obj->code;
print ' - <span class="opacitymedium">'.$obj->name.'</span>';
print "</td>\n";
if (! $i) $totalarray['nbfield']++;

View File

@ -3091,7 +3091,10 @@ a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu {
margin: 1px 1px 1px 6px;
}
span.vsmenudisabled, font.vsmenudisabled {
font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; color: #aaa;
font-family: <?php print $fontlist ?>;
text-align: <?php print $left; ?>;
color: #aaa;
white-space: nowrap;
}
a.vsmenu:link, a.vsmenu:visited {
color: var(--colortextbackvmenu);

View File

@ -3055,6 +3055,7 @@ span.vsmenudisabled, font.vsmenudisabled {
text-align: <?php print $left; ?>;
font-weight: normal;
color: #aaa;
white-space: nowrap;
}
a.vsmenu:link, a.vsmenu:visited {
color: var(--colortextbackvmenu);
@ -7293,20 +7294,20 @@ div.clipboardCPValue.hidewithsize {
.a-mesure, .a-mesure-disabled {
text-align: center;
}
.underbanner.underbanner-before-box {
border-bottom: none;
}
div.divButAction {
margin-bottom: 0.5em;
}
div#card-errors {
max-width: unset;
}
#dolpaymenttable {
padding: 5px;
}