NEW Contract - Add consolidated total (#38249)
* NEW Contract - Add consolidated total * CI * CI * CI * English
This commit is contained in:
parent
b4c025712c
commit
ffae6a7de4
2 changed files with 140 additions and 18 deletions
|
|
@ -9,11 +9,11 @@
|
|||
* Copyright (C) 2014-2020 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2023-2026 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2023 Nick Fragoulis
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2024-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2025 William Mead <william@m34d.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -1138,6 +1138,7 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-contrat page-card');
|
|||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$staticcontractline = new ContratLigne($db);
|
||||
if (isModEnabled('project')) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
|
@ -1525,10 +1526,10 @@ if ($action == 'create') {
|
|||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Line info of thirdparty discounts
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
|
||||
|
|
@ -1560,6 +1561,86 @@ if ($action == 'create') {
|
|||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<!-- amounts -->'."\n";
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
// Qty by service status
|
||||
print '<tr><td class="titlefield">'."".'</td>';
|
||||
print '<td class=right>'.$langs->trans('Total').'</td>';
|
||||
print '<td class=right>'.$staticcontractline->LibStatut(0, 5, 0).'</td>';
|
||||
print '<td class=right>'.$staticcontractline->LibStatut(4, 5, 0).'</td>';
|
||||
print '<td class=right>'.$staticcontractline->LibStatut(4, 5, 1).'</td>';
|
||||
print '<td class=right>'.$staticcontractline->LibStatut(5, 5, 0).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$all= $object->getTotalizedLines(-1, 0);
|
||||
$draft= $object->getTotalizedLines(0, 0);
|
||||
$enabled= $object->getTotalizedLines(4, 0);
|
||||
$expired= $object->getTotalizedLines(4, 1);
|
||||
$close= $object->getTotalizedLines(5, 0);
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Qty").'</td>';
|
||||
print '<td class="right nowrap">'.price2num($all['total_qty']).'</td>';
|
||||
print '<td class="right">'.price2num($draft['total_qty']).'</td>';
|
||||
print '<td class="right">'.price2num($enabled['total_qty']).'</td>';
|
||||
print '<td class="right">'.price2num($expired['total_qty']).'</td>';
|
||||
print '<td class="right">'.price2num($close['total_qty']).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("TotalHT").'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($all['total_ht']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($draft['total_ht']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($enabled['total_ht']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($expired['total_ht']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($close['total_ht']).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("TotalVAT").'</td>';
|
||||
print '<td class="nowraponall amountcard right nowrap">'.price($all['total_tva']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($draft['total_tva']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($enabled['total_tva']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($expired['total_tva']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($close['total_tva']).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($mysoc->localtax1_assuj == "1" || $all['total_localtax1'] != 0) {
|
||||
print '<tr><td class="titlefield">' . $langs->trans("TotalLT1") . '</td>';
|
||||
print '<td class="nowraponall amountcard right nowrap">' . price($all['total_localtax1']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($draft['total_localtax1']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($enabled['total_localtax1']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($expired['total_localtax1']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($close['total_localtax1']) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if ($mysoc->localtax2_assuj == "1" || $all['total_localtax2'] != 0) {
|
||||
print '<tr><td class="titlefield">' . $langs->trans("TotalLT2") . '</td>';
|
||||
print '<td class="nowraponall amountcard right nowrap">' . price($all['total_localtax2']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($draft['total_localtax2']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($enabled['total_localtax2']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($expired['total_localtax2']) . '</td>';
|
||||
print '<td class="nowraponall amountcard right">' . price($close['total_localtax2']) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("TotalTTC").'</td>';
|
||||
print '<td class="nowraponall amountcard right nowrap">'.price($all['total_ttc']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($draft['total_ttc']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($enabled['total_ttc']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($expired['total_ttc']).'</td>';
|
||||
print '<td class="nowraponall amountcard right">'.price($close['total_ttc']).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div><br>';
|
||||
|
||||
if ($object->status == $object::STATUS_DRAFT && $user->hasRight('contrat', 'creer')) {
|
||||
print '</form>';
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2015-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2015-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2026 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com
|
||||
*
|
||||
* 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
|
||||
|
|
@ -2951,6 +2953,45 @@ class Contrat extends CommonObject
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return totalized lines
|
||||
*
|
||||
* @param int $statut Status of lines
|
||||
* @param int $expired 1=expired, 0=not expired
|
||||
* @return array<string,mixed>|int Array of totalized lines or int if error
|
||||
*/
|
||||
public function getTotalizedLines($statut, int $expired)
|
||||
{
|
||||
$sql = "SELECT SUM(cd.qty) as total_qty, SUM(cd.total_ht) as total_ht, SUM(cd.total_tva) as total_tva, SUM(cd.total_ttc) as total_ttc,";
|
||||
$sql .= " SUM(cd.total_localtax1) as total_localtax1, SUM(cd.total_localtax2) as total_localtax2";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
|
||||
$sql .= " WHERE cd.fk_contrat =".((int) $this->id);
|
||||
if ($statut >= 0) {
|
||||
$sql .= " AND cd.statut = ".((int) $statut);
|
||||
if ($expired > 0) {
|
||||
$sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'";
|
||||
} else {
|
||||
$sql .= " AND cd.date_fin_validite >= '".$this->db->idate(dol_now())."'";
|
||||
}
|
||||
}
|
||||
$ret = $this->db->query($sql);
|
||||
$response = array();
|
||||
if ($ret) {
|
||||
$obj = $this->db->fetch_object($ret);
|
||||
$response['total_qty'] = $obj->total_qty;
|
||||
$response['total_ht'] = $obj->total_ht;
|
||||
$response['total_tva'] = $obj->total_tva;
|
||||
$response['total_localtax1'] = $obj->total_localtax1;
|
||||
$response['total_localtax2'] = $obj->total_localtax2;
|
||||
$response['total_ttc'] = $obj->total_ttc;
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
// @Todo getLibSignedStatus, LibSignedStatus
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue