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

This commit is contained in:
Laurent Destailleur 2023-01-13 13:03:54 +01:00
commit ad00a17ac3
14 changed files with 175 additions and 50 deletions

View File

@ -498,7 +498,10 @@ if ($mode == 'feature') {
if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) {
$i = 0;
foreach ($objMod->boxes as $val) {
$text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]);
$boxstring = (empty($val['file']) ? (empty($val[0]) ? '' : $val[0]) : $val['file']);
if ($boxstring) {
$text .= ($i ? ', ' : '').$boxstring;
}
$i++;
}
} else {

View File

@ -632,7 +632,7 @@ if ($id) {
// Active
print '<td align="center" class="nowrap">';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'&token='.newToken().'">'.$actl[($obj->status ? 1 : 0)].'</a>';
print "</td>";
// Modify link

View File

@ -335,7 +335,7 @@ if ($modecompta == 'CREANCES-DETTES') {
// Previous Fiscal year (N-1)
foreach ($sommes as $code => $det) {
$vars[$code] = $det['NP'];
$vars[$code] = empty($det['NP']) ? 0 : $det['NP'];
}
$result = strtr($formula, $vars);
@ -355,12 +355,16 @@ if ($modecompta == 'CREANCES-DETTES') {
// Year N
$code = $cat['code']; // code of categorie ('VTE', 'MAR', ...)
$sommes[$code]['NP'] += $r;
if (empty($sommes[$code]['NP'])) {
$sommes[$code]['NP'] = $r;
} else {
$sommes[$code]['NP'] += $r;
}
// Current fiscal year (N)
if (is_array($sommes) && !empty($sommes)) {
foreach ($sommes as $code => $det) {
$vars[$code] = $det['N'];
$vars[$code] = empty($det['N']) ? 0 : $det['N'];
}
}
@ -371,13 +375,17 @@ if ($modecompta == 'CREANCES-DETTES') {
$r = dol_eval($result, 1, 1, '1');
print '<td class="liste_total right borderright"><span class="amount">'.price($r).'</span></td>';
$sommes[$code]['N'] += $r;
if (empty($sommes[$code]['N'])) {
$sommes[$code]['N'] = $r;
} else {
$sommes[$code]['N'] += $r;
}
// Detail by month
foreach ($months as $k => $v) {
if (($k + 1) >= $date_startmonth) {
foreach ($sommes as $code => $det) {
$vars[$code] = $det['M'][$k];
$vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k];
}
$result = strtr($formula, $vars);
$result = str_replace('--', '+', $result);
@ -386,14 +394,18 @@ if ($modecompta == 'CREANCES-DETTES') {
$r = dol_eval($result, 1, 1, '1');
print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
$sommes[$code]['M'][$k] += $r;
if (empty($sommes[$code]['M'][$k])) {
$sommes[$code]['M'][$k] = $r;
} else {
$sommes[$code]['M'][$k] += $r;
}
}
}
foreach ($months as $k => $v) {
if (($k + 1) < $date_startmonth) {
foreach ($sommes as $code => $det) {
$vars[$code] = $det['M'][$k];
$vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k];
}
$result = strtr($formula, $vars);
$result = str_replace('--', '+', $result);
@ -402,7 +414,11 @@ if ($modecompta == 'CREANCES-DETTES') {
$r = dol_eval($result, 1, 1, '1');
print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
$sommes[$code]['M'][$k] += $r;
if (empty($sommes[$code]['M'][$k])) {
$sommes[$code]['M'][$k] = $r;
} else {
$sommes[$code]['M'][$k] += $r;
}
}
}
@ -429,14 +445,14 @@ if ($modecompta == 'CREANCES-DETTES') {
$arrayofaccountforfilter = array();
foreach ($cpts as $i => $cpt) { // Loop on each account.
if (!is_null($cpt['account_number'])) {
if (isset($cpt['account_number'])) {
$arrayofaccountforfilter[] = $cpt['account_number'];
}
}
// N-1
if (!empty($arrayofaccountforfilter)) {
$return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0);
$return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, empty($cat['dc']) ? 0 : $cat['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultNP = 0;
@ -444,8 +460,16 @@ if ($modecompta == 'CREANCES-DETTES') {
foreach ($cpts as $i => $cpt) { // Loop on each account found
$resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']];
$totCat['NP'] += $resultNP;
$sommes[$code]['NP'] += $resultNP;
if (empty($totCat['NP'])) {
$totCat['NP'] = $resultNP;
} else {
$totCat['NP'] += $resultNP;
}
if (empty($sommes[$code]['NP'])) {
$sommes[$code]['NP'] = $resultNP;
} else {
$sommes[$code]['NP'] += $resultNP;
}
$totPerAccount[$cpt['account_number']]['NP'] = $resultNP;
}
}
@ -467,23 +491,47 @@ if ($modecompta == 'CREANCES-DETTES') {
}
//var_dump($monthtoprocess.'_'.$yeartoprocess);
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM = 0;
if (isset($cpt['account_number'])) {
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM = 0;
} else {
$resultM = $AccCat->sdc;
}
} else {
$resultM = $AccCat->sdc;
$resultM = 0;
}
if (empty($totCat['M'][$k])) {
$totCat['M'][$k] = $resultM;
} else {
$totCat['M'][$k] += $resultM;
}
if (empty($sommes[$code]['M'][$k])) {
$sommes[$code]['M'][$k] = $resultM;
} else {
$sommes[$code]['M'][$k] += $resultM;
}
if (isset($cpt['account_number'])) {
$totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
}
$totCat['M'][$k] += $resultM;
$sommes[$code]['M'][$k] += $resultM;
$totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
$resultN += $resultM;
}
$totCat['N'] += $resultN;
$sommes[$code]['N'] += $resultN;
$totPerAccount[$cpt['account_number']]['N'] = $resultN;
if (empty($totCat)) {
$totCat['N'] = $resultN;
} else {
$totCat['N'] += $resultN;
}
if (empty($sommes[$code]['N'])) {
$sommes[$code]['N'] = $resultN;
} else {
$sommes[$code]['N'] += $resultN;
}
if (isset($cpt['account_number'])) {
$totPerAccount[$cpt['account_number']]['N'] = $resultN;
}
}
@ -543,16 +591,26 @@ if ($modecompta == 'CREANCES-DETTES') {
// Loop on detail of all accounts to output the detail
if ($showaccountdetail != 'no') {
foreach ($cpts as $i => $cpt) {
$resultNP = $totPerAccount[$cpt['account_number']]['NP'];
$resultN = $totPerAccount[$cpt['account_number']]['N'];
if (isset($cpt['account_number'])) {
$resultNP = $totPerAccount[$cpt['account_number']]['NP'];
$resultN = $totPerAccount[$cpt['account_number']]['N'];
} else {
$resultNP = 0;
$resultN = 0;
}
if ($showaccountdetail == 'all' || $resultN != 0) {
print '<tr>';
print '<td></td>';
print '<td class="tdoverflowmax250 borderright">';
print ' &nbsp; &nbsp; '.length_accountg($cpt['account_number']);
print ' - ';
print $cpt['account_label'];
if (isset($cpt['account_number'])) {
$labeldetail = ' &nbsp; &nbsp; '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'];
} else {
$labeldetail = '-';
}
print '<td class="tdoverflowmax250 borderright" title="'.dol_escape_htmltag($labeldetail).'">';
print dol_escape_htmltag($labeldetail);
print '</td>';
print '<td class="right"><span class="amount">'.price($resultNP).'</span></td>';
print '<td class="right borderright"><span class="amount">'.price($resultN).'</span></td>';
@ -560,13 +618,21 @@ if ($modecompta == 'CREANCES-DETTES') {
// Make one call for each month
foreach ($months as $k => $v) {
if (($k + 1) >= $date_startmonth) {
$resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
if (isset($cpt['account_number'])) {
$resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
} else {
$resultM = 0;
}
print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
}
}
foreach ($months as $k => $v) {
if (($k + 1) < $date_startmonth) {
$resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
if (isset($cpt['account_number'])) {
$resultM = empty($totPerAccount[$cpt['account_number']]['M'][$k]) ? 0 : $totPerAccount[$cpt['account_number']]['M'][$k];
} else {
$resultM = 0;
}
print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
}
}

View File

@ -1789,6 +1789,8 @@ class Contact extends CommonObject
$sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
$sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."socpeople sp";
$sql .= " ON sc.fk_socpeople = sp.rowid AND sp.statut = 1";
$sql .= " WHERE sc.fk_soc =".((int) $this->socid);
$sql .= " AND sc.fk_c_type_contact=tc.rowid";
$sql .= " AND tc.element = '".$this->db->escape($element)."'";

View File

@ -34,6 +34,9 @@ class Utils
*/
public $db;
public $error;
public $errors;
public $output; // Used by Cron method to return message
public $result; // Used by Cron method to return data

View File

@ -976,8 +976,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$tmp = json_decode($obj->note, true);
}
return array(
'authorid' => $tmp['authorid'],
'ip' => $tmp['ip'],
'authorid' => empty($tmp['authorid']) ? '' : $tmp['authorid'],
'ip' => empty($tmp['ip']) ? '' : $tmp['ip'],
'lastactivationdate' => $this->db->jdate($obj->tms),
'lastactivationversion' => (!empty($tmp['lastactivationversion']) ? $tmp['lastactivationversion'] : 'unknown'),
);

View File

@ -40,6 +40,11 @@ class CommActionRapport
*/
public $db;
public $error;
public $errors;
/**
* @var string description
*/

View File

@ -4509,7 +4509,7 @@ if ($module == 'initmodule') {
print '</a>';
print '</strong>';
print ' <span class="opacitymedium">('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledocpdf), 'dayhour').')</span>';
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&token='.newToken().'&format='.$format.'&file='.urlencode($outputfiledocpdfrel).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>';
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&token='.newToken().'&format='.$format.'&file='.urlencode($outputfiledocrelpdf).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>';
}
print '</strong><br>';

View File

@ -147,7 +147,6 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= $hookmanager->resPrint;
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('stock').')';
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid';
}
@ -168,6 +167,7 @@ if (!empty($search_categ) && $search_categ != '-1') {
}
$sql .= ")";
}
$sql .= " AND EXISTS (SELECT e.rowid FROM ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = s.fk_entrepot AND e.entity IN (".getEntity('stock')."))";
if ($sall) {
$sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
}
@ -363,6 +363,13 @@ if ($resql) {
// Fields title search
print '<tr class="liste_titre_filter">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
}
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="sref" size="6" value="'.$sref.'">';
print '</td>';
@ -391,14 +398,20 @@ if ($resql) {
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
}
print '</tr>';
//Line for column titles
print "<tr class=\"liste_titre\">";
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre('');
}
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder);
if (isModEnabled("service") && $type == 1) {
@ -429,7 +442,10 @@ if ($resql) {
$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre('');
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre('');
}
print "</tr>\n";
while ($i < min($num, $limit)) {
@ -440,6 +456,10 @@ if ($resql) {
$product->load_stock();
print '<tr>';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td></td>';
}
print '<td class="nowrap">';
print $product->getNomUrl(1, '', 16);
//if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
@ -504,7 +524,11 @@ if ($resql) {
$parameters = array('obj'=>$objp);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $product); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '<td></td>';
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td></td>';
}
print "</tr>\n";
$i++;
}

View File

@ -227,7 +227,7 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_pro
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key
$sql .= " WHERE p.entity IN (".getEntity('product').")";
$sql .= " WHERE p.entity IN (".getEntity('product').") AND e.entity IN (".getEntity('stock').")";
if (!empty($search_categ) && $search_categ != '-1') {
$sql .= " AND ";
if ($search_categ == -2) {
@ -514,6 +514,13 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="sref" size="6" value="'.$sref.'">';
print '</td>';
@ -571,6 +578,10 @@ $totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre('');
}
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder);
if (isModEnabled("service") && $type == 1) {
@ -591,7 +602,9 @@ print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique",
print_liste_field_titre('');
print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre('');
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre('');
}
print "</tr>\n";
$product_static = new Product($db);
@ -648,6 +661,11 @@ while ($i < $imaxinloop) {
print '<tr>';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td></td>';
}
// Ref
print '<td class="nowrap">';
print $product_static->getNomUrl(1, '', 16);
@ -711,7 +729,10 @@ while ($i < $imaxinloop) {
print '<td class="right nowrap">'.$product_static->LibStatut($objp->tobuy, 5, 1).'</td>';
print '<td></td>';
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td></td>';
}
print "</tr>\n";
$i++;

View File

@ -46,9 +46,6 @@ if (!defined('NOLOGIN')) {
if (!defined('NOCSRFCHECK')) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', '1');
}

View File

@ -549,6 +549,8 @@ if ($action == "dosign" && empty($cancel)) {
$("#signbutton").attr("disabled",false);
if(!$._data($("#signbutton")[0], "events")){
$("#signbutton").on("click",function(){
console.log("We click on button sign");
$("#signbutton").val(\''.dol_escape_js($langs->transnoentities('PleaseBePatient')).'\');
var signature = $("#signature").jSignature("getData", "image");
$.ajax({
type: "POST",

View File

@ -252,7 +252,7 @@ if (is_array($results)) {
}
}
print '<b class="wordbreak">';
print $tmpuser->getFullName();
print $tmpuser->getFullName($langs);
print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
print '</b>';
print '</b><br>';

View File

@ -71,6 +71,8 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI)) {
$conf->global->MAILING_LIMIT_SENDBYCLI = 0;
}
$langs->loadLangs(array("main", "mails"));
/*
* Main