diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7c384facac1..6d7325eb85f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -9,11 +9,11 @@ * Copyright (C) 2014-2020 Ferran Marcet * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2026 Frédéric France - * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2018-2026 Frédéric France + * Copyright (C) 2023-2026 Charlene Benke * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2024-2026 Alexandre Spangaro * Copyright (C) 2025 William Mead * * 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 '
'; + print '
'; print '
'; - - print ''; + print '
'; // Line info of thirdparty discounts print '
'.$langs->trans('Discount').''; @@ -1560,6 +1561,86 @@ if ($action == 'create') { print "
"; print '
'; + print '
'; + + print ''."\n"; + print '
'; + + print ''; + + // Qty by service status + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $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 ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($mysoc->localtax1_assuj == "1" || $all['total_localtax1'] != 0) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + if ($mysoc->localtax2_assuj == "1" || $all['total_localtax2'] != 0) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'."".''.$langs->trans('Total').''.$staticcontractline->LibStatut(0, 5, 0).''.$staticcontractline->LibStatut(4, 5, 0).''.$staticcontractline->LibStatut(4, 5, 1).''.$staticcontractline->LibStatut(5, 5, 0).'
'.$langs->trans("Qty").''.price2num($all['total_qty']).''.price2num($draft['total_qty']).''.price2num($enabled['total_qty']).''.price2num($expired['total_qty']).''.price2num($close['total_qty']).'
'.$langs->trans("TotalHT").''.price($all['total_ht']).''.price($draft['total_ht']).''.price($enabled['total_ht']).''.price($expired['total_ht']).''.price($close['total_ht']).'
'.$langs->trans("TotalVAT").''.price($all['total_tva']).''.price($draft['total_tva']).''.price($enabled['total_tva']).''.price($expired['total_tva']).''.price($close['total_tva']).'
' . $langs->trans("TotalLT1") . '' . price($all['total_localtax1']) . '' . price($draft['total_localtax1']) . '' . price($enabled['total_localtax1']) . '' . price($expired['total_localtax1']) . '' . price($close['total_localtax1']) . '
' . $langs->trans("TotalLT2") . '' . price($all['total_localtax2']) . '' . price($draft['total_localtax2']) . '' . price($enabled['total_localtax2']) . '' . price($expired['total_localtax2']) . '' . price($close['total_localtax2']) . '
'.$langs->trans("TotalTTC").''.price($all['total_ttc']).''.price($draft['total_ttc']).''.price($enabled['total_ttc']).''.price($expired['total_ttc']).''.price($close['total_ttc']).'
"; + + print '
'; + print '
'; + + print '

'; if ($object->status == $object::STATUS_DRAFT && $user->hasRight('contrat', 'creer')) { print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 814e223449c..82ae9b8635c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1,18 +1,20 @@ - * Copyright (C) 2004-2012 Destailleur Laurent - * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Destailleur Laurent + * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2015-2018 Ferran Marcet - * Copyright (C) 2024 William Mead - * Copyright (C) 2024-2026 MDW + * Copyright (C) 2015-2018 Ferran Marcet + * Copyright (C) 2024 William Mead + * Copyright (C) 2024-2026 MDW + * Copyright (C) 2026 Charlene Benke + * Copyright (C) 2026 Alexandre Spangaro |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 /**