Bonjour à tous,
J’ai apporté des modifications à mon Dolibarr et je partage ici pour ceux que ça intéresse.
Il m’est utile d’avoir un visu de la part Service/Produit sur un devis.
Les multi-devises ne sont pas gérées
Voici la procédure en version 21 pour avoir le même rendu.
Pour la page devis :
Dans le fichier :
/htdocs/comm/propal/card.php
Ligne 2967, AVANT :
print '<tr>';
print '<td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
AJOUTER :
// BEGIN Custom: Totaux produits/services avec pourcentage
// -----------------------------------------------------------
// Compute and display product/service totals with percentage of the global amount
// Calcul et affichage des totaux produits/services avec pourcentage du montant global
$total_products = 0;
$total_services = 0;
$total_products_ttc = 0;
$total_services_ttc = 0;
foreach ($object->lines as $line) {
if ($line->fk_product_type == 0) {
$total_products += $line->total_ht;
$total_products_ttc += $line->total_ttc;
} elseif ($line->fk_product_type == 1) {
$total_services += $line->total_ht;
$total_services_ttc += $line->total_ttc;
}
}
// Determine if we show HT or TTC (same logic as standard totals)
$show_ht = true;
if (!empty($conf->global->PROPOSAL_TOTAL_SHOW_TTC)) {
$show_ht = false;
}
// On se base sur l'affichage principal
if ($show_ht) {
$total_general = $object->total_ht;
} else {
$total_general = $object->total_ttc;
}
// Avoid division by zero
$percent_products = $total_general != 0 ? round(100 * ($show_ht ? $total_products : $total_products_ttc) / $total_general, 2) : 0;
$percent_services = $total_general != 0 ? round(100 * ($show_ht ? $total_services : $total_services_ttc) / $total_general, 2) : 0;
// Affichage dans le tableau des totaux
print '<tr>';
print '<td class="titlefieldmiddle">'.$langs->trans("TotalProducts").' ('.$percent_products.'%)</td>';
print '<td class="nowrap amountcard right">'.price($show_ht ? $total_products : $total_products_ttc, 0, $langs, 1, -1, -1, $conf->currency).'</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multidevise non gérée pour le moment, éventuel à ajouter ici
print '<td class="nowrap amountcard right"></td>';
}
print '</tr>';
print '<tr>';
print '<td class="titlefieldmiddle">'.$langs->trans("TotalServices").' ('.$percent_services.'%)</td>';
print '<td class="nowrap amountcard right">'.price($show_ht ? $total_services : $total_services_ttc, 0, $langs, 1, -1, -1, $conf->currency).'</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multidevise non gérée pour le moment, éventuel à ajouter ici
print '<td class="nowrap amountcard right"></td>';
}
print '</tr>';
// END Custom: Totaux produits/services avec pourcentage
// -----------------------------------------------------------
Dans le fichier (si non ajouté par défaut sera affiché TotalProducts et TotalServices) :
htdocs/langs/fr_FR/bills.lang
AJOUTER :
TotalProducts=Total des produits
TotalServices=Total des services
Dans le fichier (pas indispensable, c’est pour la version anglaise de base) :
htdocs/langs/en_US/bills.lang
AJOUTER :
TotalProducts=Total products
TotalServices=Total services
Pour la page facture :
Dans le fichier :
htdocs/compta/facture/card.php
Ligne 5092, AVANT :
print '<tr>';
// Amount HT
print '<td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
AJOUTER :
// BEGIN Custom: Totaux produits/services avec pourcentage
// -----------------------------------------------------------
// Compute and display product/service totals with percentage of the global amount
// Calcul et affichage des totaux produits/services avec pourcentage du montant global
$total_products = 0;
$total_services = 0;
$total_products_ttc = 0;
$total_services_ttc = 0;
foreach ($object->lines as $line) {
if ($line->fk_product_type == 0) {
$total_products += $line->total_ht;
$total_products_ttc += $line->total_ttc;
} elseif ($line->fk_product_type == 1) {
$total_services += $line->total_ht;
$total_services_ttc += $line->total_ttc;
}
}
// Determine if we show HT or TTC (same logic as standard totals)
$show_ht = true;
if (!empty($conf->global->FACTURE_TOTAL_SHOW_TTC)) {
$show_ht = false;
}
// On se base sur l'affichage principal
if ($show_ht) {
$total_general = $object->total_ht;
} else {
$total_general = $object->total_ttc;
}
// Avoid division by zero
$percent_products = $total_general != 0 ? round(100 * ($show_ht ? $total_products : $total_products_ttc) / $total_general, 2) : 0;
$percent_services = $total_general != 0 ? round(100 * ($show_ht ? $total_services : $total_services_ttc) / $total_general, 2) : 0;
// Affichage dans le tableau des totaux
print '<tr>';
print '<td class="titlefieldmiddle">'.$langs->trans("TotalProducts").' ('.$percent_products.'%)</td>';
print '<td class="nowrap amountcard right">'.price($show_ht ? $total_products : $total_products_ttc, 0, $langs, 1, -1, -1, $conf->currency).'</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multidevise non gérée pour le moment, à ajouter si besoin
print '<td class="nowrap amountcard right"></td>';
}
print '</tr>';
print '<tr>';
print '<td class="titlefieldmiddle">'.$langs->trans("TotalServices").' ('.$percent_services.'%)</td>';
print '<td class="nowrap amountcard right">'.price($show_ht ? $total_services : $total_services_ttc, 0, $langs, 1, -1, -1, $conf->currency).'</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
print '<td class="nowrap amountcard right"></td>';
}
print '</tr>';
// END Custom: Totaux produits/services avec pourcentage
// -----------------------------------------------------------