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

This commit is contained in:
Laurent Destailleur 2023-02-17 16:05:12 +01:00
commit e489e10b65
10 changed files with 64 additions and 42 deletions

View File

@ -286,7 +286,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l
if ($sDay > 1) { if ($sDay > 1) {
$dayTranslate = $langs->trans("Days"); $dayTranslate = $langs->trans("Days");
} }
$sTime .= $sDay.' '.strtolower(dol_substr($dayTranslate, 0, 1)).'. '; $sTime .= $sDay.' '.$langs->trans("d").' ';
} }
if ($format == 'all') { if ($format == 'all') {

View File

@ -2135,9 +2135,10 @@ class pdf_crabe extends ModelePDFFactures
if (!empty($idaddressshipping)) { if (!empty($idaddressshipping)) {
$contactshipping = $object->fetch_Contact($idaddressshipping[0]); $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
$object->fetch_thirdparty($object->contact->fk_soc); $companystatic = new Societe($this->db);
$companystatic->fetch($object->contact->fk_soc);
$carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs);
$carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object);
} else { } else {
$carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
$carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
@ -2148,7 +2149,7 @@ class pdf_crabe extends ModelePDFFactures
// Show shipping frame // Show shipping frame
$pdf->SetXY($posx + 2, $posy - 5); $pdf->SetXY($posx + 2, $posy - 5);
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show shipping name // Show shipping name

View File

@ -2385,9 +2385,10 @@ class pdf_sponge extends ModelePDFFactures
if (!empty($idaddressshipping)) { if (!empty($idaddressshipping)) {
$contactshipping = $object->fetch_Contact($idaddressshipping[0]); $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
$object->fetch_thirdparty($object->contact->fk_soc); $companystatic = new Societe($this->db);
$companystatic->fetch($object->contact->fk_soc);
$carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs);
$carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object);
} else { } else {
$carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
$carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
@ -2398,7 +2399,7 @@ class pdf_sponge extends ModelePDFFactures
// Show shipping frame // Show shipping frame
$pdf->SetXY($posx + 2, $posy - 5); $pdf->SetXY($posx + 2, $posy - 5);
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
$pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show shipping name // Show shipping name

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr> * Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -531,7 +532,7 @@ $sqlfields = $sql; // $sql fields to remove for count total
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)";
} }
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'";
// Add table from hooks // Add table from hooks

View File

@ -66,7 +66,7 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_projet_ref = GETPOST('search_projet_ref', 'alpha'); $search_projet_ref = GETPOST('search_projet_ref', 'alpha');
$search_contrat_ref = GETPOST('search_contrat_ref', 'alpha'); $search_contrat_ref = GETPOST('search_contrat_ref', 'alpha');
$search_status = GETPOST('search_status', 'alpha'); $search_status = GETPOST('search_status', 'alpha');
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
@ -311,8 +311,8 @@ if (empty($user->rights->societe->client->voir) && empty($socid)) {
if ($socid) { if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid); $sql .= " AND s.rowid = ".((int) $socid);
} }
if ($sall) { if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall); $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
} }
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -321,7 +321,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
// Add GroupBy from hooks // Add GroupBy from hooks
$parameters = array('search_all' => $sall, 'fieldstosearchall' => $fieldstosearchall); $parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall);
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
@ -396,8 +396,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) { if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit); $param .= '&limit='.urlencode($limit);
} }
if ($sall) { if ($search_all) {
$param .= "&sall=".urlencode($sall); $param .= "&search_all=".urlencode($search_all);
} }
if ($socid) { if ($socid) {
$param .= "&socid=".urlencode($socid); $param .= "&socid=".urlencode($socid);
@ -474,11 +474,11 @@ $objecttmp = new Fichinter($db);
$trackid = 'int'.$object->id; $trackid = 'int'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall) { if ($search_all) {
foreach ($fieldstosearchall as $key => $val) { foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
} }
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
} }
$moreforfilter = ''; $moreforfilter = '';

View File

@ -667,13 +667,14 @@ class ProductFournisseur extends Product
/** /**
* List all supplier prices of a product * List all supplier prices of a product
* *
* @param int $prodid Id of product * @param int $prodid Id of product
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit * @param int $limit Limit
* @param int $offset Offset * @param int $offset Offset
* @param int $socid Filter on a third party id * @param int $socid Filter on a third party id
* @return array|int Array of ProductFournisseur with new properties to define supplier price * @return array|int Array of ProductFournisseur with new properties to define supplier price
* @see find_min_price_product_fournisseur()
*/ */
public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0)
{ {
@ -784,6 +785,7 @@ class ProductFournisseur extends Product
* @param int $qty Minimum quantity * @param int $qty Minimum quantity
* @param int $socid get min price for specific supplier * @param int $socid get min price for specific supplier
* @return int <0 if KO, 0=Not found of no product id provided, >0 if OK * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
* @see list_product_fournisseur_price()
*/ */
public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0)
{ {

View File

@ -1695,15 +1695,14 @@ if ($action == 'create') {
} else { } else {
print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations // reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) {
print '<script type="text/javascript"> print '<script>
$(document).ready(function() { $(document).ready(function() {
$("#socid").change(function() { $("#socid").change(function() {
console.log("We have changed the company - Reload page"); console.log("We have changed the company - Reload page");
// reload page // reload page
$("input[name=action]").val("create"); $("input[name=action]").val("create");
$("form[name=add]").submit(); $("form[name=add]").submit();
});
}); });
</script>'; </script>';
} }

View File

@ -2177,7 +2177,7 @@ if ($action == 'create') {
} else { } else {
print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500'); print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500');
// reload page to retrieve supplier informations // reload page to retrieve supplier informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) {
print '<script type="text/javascript"> print '<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#socid").change(function() { $("#socid").change(function() {

View File

@ -1,4 +1,6 @@
<?php <?php
use Stripe\BankAccount;
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
@ -37,6 +39,7 @@ if (isModEnabled('accounting')) {
} }
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "loan")); $langs->loadLangs(array("compta", "bills", "loan"));
@ -633,12 +636,14 @@ if ($id > 0) {
/* /*
* Payments * Payments
*/ */
$sql = "SELECT p.rowid, p.num_payment, datep as dp,"; $sql = "SELECT p.rowid, p.num_payment, p.datep as dp,";
$sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,"; $sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,";
$sql .= " b.fk_account,";
$sql .= " c.libelle as paiement_type"; $sql .= " c.libelle as paiement_type";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
$sql .= ", ".MAIN_DB_PREFIX."loan as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id,";
$sql .= " ".MAIN_DB_PREFIX."loan as l";
$sql .= " WHERE p.fk_loan = ".((int) $id); $sql .= " WHERE p.fk_loan = ".((int) $id);
$sql .= " AND p.fk_loan = l.rowid"; $sql .= " AND p.fk_loan = l.rowid";
$sql .= " AND l.entity IN ( ".getEntity('loan').")"; $sql .= " AND l.entity IN ( ".getEntity('loan').")";
@ -659,11 +664,14 @@ if ($id > 0) {
print '<td>'.$langs->trans("RefPayment").'</td>'; print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("BankAccount").'</td>';
print '<td class="right">'.$langs->trans("Insurance").'</td>'; print '<td class="right">'.$langs->trans("Insurance").'</td>';
print '<td class="right">'.$langs->trans("Interest").'</td>'; print '<td class="right">'.$langs->trans("Interest").'</td>';
print '<td class="right">'.$langs->trans("LoanCapital").'</td>'; print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
print '</tr>'; print '</tr>';
$conf->cache['bankaccount'] = array();
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
@ -671,9 +679,19 @@ if ($id > 0) {
print '<td><a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n"; print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
print "<td>".$objp->paiement_type.' '.$objp->num_payment."</td>\n"; print "<td>".$objp->paiement_type.' '.$objp->num_payment."</td>\n";
print '<td class="nowrap right">'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n"; print "<td>";
print '<td class="nowrap right">'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n"; if (!empty($conf->cache['bankaccount'][$objp->fk_account])) {
print '<td class="nowrap right">'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."</td>\n"; $tmpbank = $conf->cache['bankaccount'][$objp->fk_account];
} else {
$tmpbank = new Account($db);
$tmpbank->fetch($objp->fk_account);
$conf->cache['bankaccount'][$objp->fk_account] = $tmpbank;
}
print $tmpbank->getNomUrl(1);
print "</td>\n";
print '<td class="nowrap right"><span class="amount">'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."</span></td>\n";
print '<td class="nowrap right"><span class="amount">'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."</span></td>\n";
print '<td class="nowrap right"><span class="amount">'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."</span></td>\n";
print "</tr>"; print "</tr>";
$total_capital += $objp->amount_capital; $total_capital += $objp->amount_capital;
$i++; $i++;
@ -682,12 +700,12 @@ if ($id > 0) {
$totalpaid = $total_capital; $totalpaid = $total_capital;
if ($object->paid == 0 || $object->paid == 2) { if ($object->paid == 0 || $object->paid == 2) {
print '<tr><td colspan="5" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td colspan="6" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
print '<tr><td colspan="5" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td colspan="6" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
$staytopay = $object->capital - $totalpaid; $staytopay = $object->capital - $totalpaid;
print '<tr><td colspan="5" class="right">'.$langs->trans("RemainderToPay").' :</td>'; print '<tr><td colspan="6" class="right">'.$langs->trans("RemainderToPay").' :</td>';
print '<td class="nowrap right'.($staytopay ? ' amountremaintopay' : ' amountpaymentcomplete').'">'; print '<td class="nowrap right'.($staytopay ? ' amountremaintopay' : ' amountpaymentcomplete').'">';
print price($staytopay, 0, $langs, 0, -1, -1, $conf->currency); print price($staytopay, 0, $langs, 0, -1, -1, $conf->currency);
print '</td></tr>'; print '</td></tr>';

View File

@ -344,7 +344,7 @@ class DateLibTest extends PHPUnit\Framework\TestCase
$result=convertSecondToTime(86400, 'all', 86400); $result=convertSecondToTime(86400, 'all', 86400);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertSame('1 '.strtolower(dol_substr($langs->trans("Day"), 0, 1).'.'), $result); $this->assertSame('1 '.$langs->trans("d"), $result);
return $result; return $result;
} }