Merge remote-tracking branch 'upstream/develop' into contact_canvas_phpstan

This commit is contained in:
Frédéric FRANCE
2024-12-16 09:42:35 +01:00
8 changed files with 67 additions and 49 deletions

View File

@@ -900,7 +900,7 @@ if ($resql) {
}
// Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
$urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
$urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?format=dayreduceformat&token='.currentToken();
print '
<script type="text/javascript">
$(function() {
@@ -909,10 +909,10 @@ if ($resql) {
current.click(function()
{
var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
console.log("We click on ajaxforbankoperationchange url="+url);
$.get(url, function(data)
{
console.log(url)
console.log(data)
console.log(data);
current.parent().parent().find(".spanforajaxedit").replaceWith(data);
});
return false;
@@ -1663,7 +1663,9 @@ if ($resql) {
// Date ope
if (!empty($arrayfields['b.dateo']['checked'])) {
print '<td class="nowraponall center">';
print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->do), "day").'">'.dol_print_date($db->jdate($objp->do), "dayreduceformat")."</span>";
print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->do), "day").'">';
print dol_print_date($db->jdate($objp->do), "dayreduceformat");
print "</span>";
print '&nbsp;';
print '<span class="inline-block">';
print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
@@ -1680,7 +1682,9 @@ if ($resql) {
// Date value
if (!empty($arrayfields['b.datev']['checked'])) {
print '<td class="nowraponall center">';
print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->dv), "day").'">'.dol_print_date($db->jdate($objp->dv), "dayreduceformat")."</span>";
print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->dv), "day").'">';
print dol_print_date($db->jdate($objp->dv), "dayreduceformat");
print "</span>";
print '&nbsp;';
print '<span class="inline-block">';
print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';

View File

@@ -672,10 +672,10 @@ if ($result) {
current.click(function()
{
var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
console.log("We click on ajaxforbankoperationchange url="+url);
$.get(url, function(data)
{
console.log(url)
console.log(data)
console.log(data);
current.parent().prev().replaceWith(data);
});
return false;

View File

@@ -744,12 +744,11 @@ if (empty($numref)) {
var current = $(this);
current.click(function()
{
console.log("We click on ajaxforbankoperationchange");
var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
console.log("We click on ajaxforbankoperationchange url="+url);
$.get(url, function(data)
{
console.log(url)
console.log(data)
console.log(data);
current.parent().parent().find(".spanforajaxedit").replaceWith(data);
});
return false;

View File

@@ -53,6 +53,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$action = GETPOST('action', 'aZ09');
$format = GETPOST('format');
// Security check
// Checks are done later
@@ -72,7 +74,7 @@ if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consoli
$al->datev_next(GETPOSTINT('rowid'));
$al->fetch(GETPOSTINT('rowid'));
print '<span class="spanforajaxedit" id="datevalue_'.$al->id.'">'.dol_print_date($al->datev, "day").'</span>';
print '<span class="spanforajaxedit" id="datevalue_'.$al->id.'">'.dol_print_date($al->datev, ($format ? $format : "day")).'</span>';
exit;
}
@@ -83,7 +85,7 @@ if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consoli
$al->datev_previous(GETPOSTINT('rowid'));
$al->fetch(GETPOSTINT('rowid'));
print '<span class="spanforajaxedit" id="datevalue_'.$al->id.'">'.dol_print_date($al->datev, "day").'</span>';
print '<span class="spanforajaxedit" id="datevalue_'.$al->id.'">'.dol_print_date($al->datev, ($format ? $format : "day")).'</span>';
exit;
}
@@ -94,7 +96,7 @@ if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consoli
$al->dateo_next(GETPOSTINT('rowid'));
$al->fetch(GETPOSTINT('rowid'));
print '<span class="spanforajaxedit" id="dateoperation_'.$al->id.'">'.dol_print_date($al->dateo, "day").'</span>';
print '<span class="spanforajaxedit" id="dateoperation_'.$al->id.'">'.dol_print_date($al->dateo, ($format ? $format : "day")).'</span>';
exit;
}
@@ -105,7 +107,7 @@ if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consoli
$al->dateo_previous(GETPOSTINT('rowid'));
$al->fetch(GETPOSTINT('rowid'));
print '<span class="spanforajaxedit" id="dateoperation_'.$al->id.'">'.dol_print_date($al->dateo, "day").'</span>';
print '<span class="spanforajaxedit" id="dateoperation_'.$al->id.'">'.dol_print_date($al->dateo, ($format ? $format : "day")).'</span>';
exit;
}

View File

@@ -7271,7 +7271,7 @@ class Form
// Input area to enter date manually
$retstring .= '<input id="' . $prefix . '" name="' . $prefix . '" type="text" class="maxwidthdate center" maxlength="11" value="' . $formated_date . '"';
$retstring .= ($disabled ? ' disabled' : '');
$retstring .= ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= ' onChange="dpChangeDay(\'' . dol_escape_js($prefix) . '\',\'' . dol_escape_js($langs->trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= ' autocomplete="off">';
// Icon calendar

View File

@@ -222,37 +222,59 @@ function getObjectFromID(id){
return theObject;
}
// Called after selection of a date to save details into detailed fields
// Called after the selection or typing of a date to save details into detailed fields
function dpChangeDay(dateFieldID, format)
{
//showDP.datefieldID=dateFieldID;
console.log("Call dpChangeDay, we save date into detailed fields from format = "+format);
var thefield=getObjectFromID(dateFieldID);
var thefieldday=getObjectFromID(dateFieldID+"day");
var thefieldmonth=getObjectFromID(dateFieldID+"month");
var thefieldyear=getObjectFromID(dateFieldID+"year");
var thefield = getObjectFromID(dateFieldID);
var thefieldday = getObjectFromID(dateFieldID+"day");
var thefieldmonth = getObjectFromID(dateFieldID+"month");
var thefieldyear = getObjectFromID(dateFieldID+"year");
var date=getDateFromFormat(thefield.value, format);
var date = getDateFromFormat(thefield.value, format);
//console.log(date);
if (date)
{
thefieldday.value=date.getDate();
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value=date.getMonth()+1;
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value=date.getFullYear();
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
thefieldday.value = date.getDate();
if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value = date.getMonth()+1;
if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value = date.getFullYear();
if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
return 1;
}
else
{
thefieldday.value='';
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value='';
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value='';
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
// Replace yyyy into yy
newformat = format.replace(/yyyy/g, 'yy');
if (newformat != format) {
console.log("dpChangeDay, we try now from format = "+newformat);
var date = getDateFromFormat(thefield.value, newformat);
//console.log(date);
if (date)
{
thefieldday.value = date.getDate();
if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value = date.getMonth()+1;
if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value = date.getFullYear();
if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
return 2;
}
}
thefieldday.value = '';
if (thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value = '';
if (thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value = '';
if (thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
return 0;
}
/*
@@ -337,13 +359,13 @@ function formatDate(date,format)
* Licence: GPL
* ==================================================================
*/
function getDateFromFormat(val,format)
function getDateFromFormat(val, format)
{
// alert('getDateFromFormat val='+val+' format='+format);
// Force parameters en chaine
val=val+"";
format=format+"";
val = val+"";
format = format+"";
if (val == '') return 0;
@@ -356,17 +378,14 @@ function getDateFromFormat(val,format)
var seconde=now.getSeconds();
var i=0;
var d=0; // -d- follows the date string while -i- follows the format
// string
var d=0; // -d- follows the date string while -i- follows the format string
while (i < format.length)
{
c=format.charAt(i); // Recupere char du format
substr="";
j=i;
while ((format.charAt(j)==c) && (j < format.length)) // Recupere char
// successif
// identiques
while ((format.charAt(j)==c) && (j < format.length)) // Get successive similar characters
{
substr += format.charAt(j++);
}

View File

@@ -453,9 +453,6 @@ a.vmenu span, span.vmenu, span.vmenu span {
.infobox-order_supplier:not(.error) {
color: #599caf;
}
.infobox-order_supplier::before {
margin-left: 5px;
}
.infobox-contrat, .infobox-ticket{
color: #3bbfa8;
}

View File

@@ -149,9 +149,6 @@ div.login_block_other a {
.infobox-order_supplier:not(.pictotitle):not(.error) {
color: #599caf;
}
.infobox-order_supplier::before {
margin-left: 3px;
}
.infobox-contrat, .infobox-ticket{
color: #46a676;