Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/class/html.form.class.php
This commit is contained in:
Laurent Destailleur
2021-02-19 22:06:48 +01:00
7 changed files with 50 additions and 37 deletions

View File

@@ -41,6 +41,7 @@ FIX: #16135
FIX: #16143 FIX: #16143
FIX: #16156 FIX: #16156
FIX: #16160 FIX: #16160
FIX: #16165 Create customer discount without vat
FIX: #16185 FIX: #16185
FIX: #16189, fix download/see check deposit PDF FIX: #16189, fix download/see check deposit PDF
FIX: #16215 FIX: #16215
@@ -75,6 +76,7 @@ FIX: ODT generation very slow
FIX: amount in summary of report FIX: amount in summary of report
FIX: vat value when code contains number FIX: vat value when code contains number
FIX: payment term label on PDF FIX: payment term label on PDF
FIX: date selector when using reduced year (like on smartphone)
***** ChangeLog for 13.0.0 compared to 12.0.0 ***** ***** ChangeLog for 13.0.0 compared to 12.0.0 *****

View File

@@ -508,19 +508,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<tr><td>'.$langs->trans('Numero'); print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>'; print '</td>';
print '<td><input name="num_paiement" type="text" value="'.$paymentnum.'"></td></tr>'; print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
// Check transmitter // Check transmitter
print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter'); print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
print ' <em>('.$langs->trans("ChequeMaker").')</em>'; print ' <em>('.$langs->trans("ChequeMaker").')</em>';
print '</td>'; print '</td>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>'; print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
// Bank name // Bank name
print '<tr><td>'.$langs->trans('Bank'); print '<tr><td>'.$langs->trans('Bank');
print ' <em>('.$langs->trans("ChequeBank").')</em>'; print ' <em>('.$langs->trans("ChequeBank").')</em>';
print '</td>'; print '</td>';
print '<td><input name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>'; print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
// Comments // Comments
print '<tr><td>'.$langs->trans('Comments').'</td>'; print '<tr><td>'.$langs->trans('Comments').'</td>';
@@ -578,6 +578,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$i = 0; $i = 0;
//print '<tr><td colspan="3">'; //print '<tr><td colspan="3">';
print '<br>'; print '<br>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@@ -786,7 +788,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print "</tr>\n"; print "</tr>\n";
} }
print "</table>"; print "</table>";
//print "</td></tr>\n"; print "</div>\n";
} }
$db->free($resql); $db->free($resql);
} else { } else {

View File

@@ -5700,6 +5700,9 @@ class Form
if ($h == 3) $shour = ''; if ($h == 3) $shour = '';
if ($m == 3) $smin = ''; if ($m == 3) $smin = '';
$nowgmt = dol_now('gmt');
//var_dump(dol_print_date($nowgmt, 'dayhourinputnoreduce', 'tzuserrel'));
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
$usecalendar = 'combo'; $usecalendar = 'combo';
if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) {
@@ -5722,13 +5725,13 @@ class Form
// Calendrier popup version eldy // Calendrier popup version eldy
if ($usecalendar == "eldy") if ($usecalendar == "eldy")
{ {
// Zone de saisie manuelle de la date // Input area to enter date manually
$retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.'"'; $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.'"';
$retstring .= ($disabled ? ' disabled' : ''); $retstring .= ($disabled ? ' disabled' : '');
$retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>'; $retstring .= '>';
// Icone calendar // Icon calendar
$retstringbuttom = ''; $retstringbuttom = '';
if (!$disabled) { if (!$disabled) {
$retstringbuttom = '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"'; $retstringbuttom = '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"';
@@ -5912,8 +5915,7 @@ class Form
{ {
// Script which will be inserted in the onClick of the "Now" link // Script which will be inserted in the onClick of the "Now" link
$reset_scripts = ""; $reset_scripts = "";
if ($addnowlink == 2) // local computer time if ($addnowlink == 2) { // local computer time
{
// pad add leading 0 on numbers // pad add leading 0 on numbers
$reset_scripts .= "Number.prototype.pad = function(size) { $reset_scripts .= "Number.prototype.pad = function(size) {
var s = String(this); var s = String(this);
@@ -5924,14 +5926,12 @@ class Form
} }
// Generate the date part, depending on the use or not of the javascript calendar // Generate the date part, depending on the use or not of the javascript calendar
if ($addnowlink == 1) // server time expressed in user time setup if ($addnowlink == 1) { // server time expressed in user time setup
{ $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; } elseif ($addnowlink == 2) {
} elseif ($addnowlink == 2)
{
/* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix. /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
* This break application for foreign languages. * This break application for foreign languages.
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
@@ -5939,10 +5939,10 @@ class Form
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
*/ */
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
} }
/*if ($usecalendar == "eldy") /*if ($usecalendar == "eldy")
{ {
@@ -5962,7 +5962,7 @@ class Form
//$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
if ($addnowlink == 1) if ($addnowlink == 1)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
} elseif ($addnowlink == 2) } elseif ($addnowlink == 2)
{ {
@@ -5979,7 +5979,7 @@ class Form
//$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
if ($addnowlink == 1) if ($addnowlink == 1)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
} elseif ($addnowlink == 2) } elseif ($addnowlink == 2)
{ {
@@ -6004,22 +6004,22 @@ class Form
$reset_scripts = ""; $reset_scripts = "";
// Generate the date part, depending on the use or not of the javascript calendar // Generate the date part, depending on the use or not of the javascript calendar
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
// Update the hour part // Update the hour part
if ($h) if ($h)
{ {
if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
if ($fullday) $reset_scripts .= ' } '; if ($fullday) $reset_scripts .= ' } ';
} }
// Update the minute part // Update the minute part
if ($m) if ($m)
{ {
if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
if ($fullday) $reset_scripts .= ' } '; if ($fullday) $reset_scripts .= ' } ';
} }
// If reset_scripts is not empty, print the link with the reset_scripts in the onClick // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
@@ -6031,12 +6031,12 @@ class Form
} }
} }
// Add a "Plus one hour" link // Add a link to set data
if ($conf->use_javascript_ajax && $adddateof) if ($conf->use_javascript_ajax && $adddateof)
{ {
$tmparray = dol_getdate($adddateof); $tmparray = dol_getdate($adddateof);
if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice"); if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice");
$retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$labeladddateof.'</a>'; $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="console.log(\'Click on now link\'); jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'dayinputnoreduce').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$labeladddateof.'</a>';
} }
return $retstring; return $retstring;

View File

@@ -20,7 +20,7 @@
/** /**
* \file htdocs/core/class/html.formactions.class.php * \file htdocs/core/class/html.formactions.class.php
* \ingroup core * \ingroup core
* \brief Fichier de la classe des fonctions predefinie de composants html actions * \brief File of class with predefined functions and HTML components
*/ */

View File

@@ -183,17 +183,18 @@ function getObjectFromID(id){
} }
// Called after selection of a date to save details into detailed fields // Called after selection of a date to save details into detailed fields
function dpChangeDay(dateFieldID,format) function dpChangeDay(dateFieldID, format)
{ {
//showDP.datefieldID=dateFieldID; //showDP.datefieldID=dateFieldID;
console.log("Call dpChangeDay, we save date into detailed fields."); console.log("Call dpChangeDay, we save date into detailed fields from format = "+format);
var thefield=getObjectFromID(dateFieldID); var thefield=getObjectFromID(dateFieldID);
var thefieldday=getObjectFromID(dateFieldID+"day"); var thefieldday=getObjectFromID(dateFieldID+"day");
var thefieldmonth=getObjectFromID(dateFieldID+"month"); var thefieldmonth=getObjectFromID(dateFieldID+"month");
var thefieldyear=getObjectFromID(dateFieldID+"year"); var thefieldyear=getObjectFromID(dateFieldID+"year");
var date=getDateFromFormat(thefield.value,format); var date=getDateFromFormat(thefield.value, format);
//console.log(date);
if (date) if (date)
{ {
thefieldday.value=date.getDate(); thefieldday.value=date.getDate();

View File

@@ -1970,7 +1970,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
* "%d/%m/%Y %H:%M", * "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S", * "%d/%m/%Y %H:%M:%S",
* "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day * "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat" * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...inputnoreduce", "...reduceformat"
* @param string $tzoutput true or 'gmt' => string is for Greenwich location * @param string $tzoutput true or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage * false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel' * 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel'
@@ -2014,7 +2014,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
} }
if (!is_object($outputlangs)) $outputlangs = $langs; if (!is_object($outputlangs)) $outputlangs = $langs;
if (!$format) $format = 'daytextshort'; if (!$format) $format = 'daytextshort';
$reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
// Do we have to reduce the length of date (year on 2 chars) to save space.
// Note: dayinputnoreduce is same than day but no reduction of year length will be done
$reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; // Test on original $format param.
$format = preg_replace('/inputnoreduce/', '', $format); // so format 'dayinputnoreduce' is processed like day
$formatwithoutreduce = preg_replace('/reduceformat/', '', $format); $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day

View File

@@ -162,6 +162,10 @@ class ImportTest extends PHPUnit\Framework\TestCase
// according to option // according to option
$this->assertEquals(0, 0); $this->assertEquals(0, 0);
// TODO Export and compare the file exported with the $file imported.
return true; return true;
} }
} }