diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index eda10c1773b..60ed4386b66 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3838,180 +3838,10 @@ else if ($id > 0 || ! empty($ref))
print "";
print '';
- // Situations
- /*if (! empty($conf->global->INVOICE_USE_SITUATION))
- {
- if ($object->type == 5 && ($object->situation_counter > 1))
- {
- $prevsits = $object->get_prev_sits();
- print '
| ';
- print $langs->trans('SituationAmount');
- print ' ';
-
- print $prevsits[0]->situation_counter;
- $cprevsits = count($prevsits);
-
- for ($i = 1; $i < $cprevsits; $i++) {
- print ' + ';
- print $prevsits[$i]->situation_counter;
- }
- print ' + ';
- print $object->situation_counter;
-
- print ' | ';
- print '';
-
- $prevsits_total_amount = 0;
- foreach ($prevsits as $situation) {
- $prevsits_total_amount += $situation->total_ht;
- }
- $prevsits_total_amount += $object->total_ht;
-
- print price($prevsits_total_amount, 0, $langs, 1, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency) );
-
- print ' |
';
-
- // Previous situation(s) deduction(s)
- for ($i = 0; $i < $cprevsits; $i++) {
- print '';
-
-
- print '';
- print '| ' . $langs->trans('ListOfSituationInvoices') . ' | ';
- print ' | ';
- print '' . $langs->trans('Situation') . ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . $langs->trans('AmountHT') . ' | ';
- print '' . $langs->trans('AmountTTC') . ' | ';
- print ' | ';
- print '
';
-
-
- $total_prev_ht = $total_prev_ttc = 0;
- $total_global_ht = $total_global_ttc = 0;
-
- if (count($object->tab_previous_situation_invoice) > 0) {
- // List of previous invoices
-
- $current_situation_counter = array();
- foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
- $totalpaye = $prev_invoice->getSommePaiement();
- $total_prev_ht += $prev_invoice->total_ht;
- $total_prev_ttc += $prev_invoice->total_ttc;
- $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter;
- print '';
- print '| ' . $prev_invoice->getNomUrl(1) . ' | ';
- print ' | ';
- print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($prev_invoice->total_ht) . ' | ';
- print '' . price($prev_invoice->total_ttc) . ' | ';
- print '' . $prev_invoice->getLibStatut(3, $totalpaye) . ' | ';
- print '
';
- }
- }
-
-
- $total_global_ht += $total_prev_ht ;
- $total_global_ttc += $total_prev_ttc ;
- $total_global_ht += $object->total_ht;
- $total_global_ttc += $object->total_ttc;
- $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $object->situation_counter;
- print '';
- print '| ' . $object->getNomUrl(1) . ' | ';
- print ' | ';
- print ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($object->total_ht) . ' | ';
- print '' . price($object->total_ttc) . ' | ';
- print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ' | ';
- print '
';
-
-
- print '';
- print '| ' . $langs->trans('CurrentSituationTotal') . ' | ';
- print '';
- $i =0;
- foreach ($current_situation_counter as $sit)
- {
- $curSign = $sit>0?'+':'-';
- $curType = $sit>0?$langs->trans('situationInvoiceShortcode_S'):$langs->trans('situationInvoiceShortcode_AS');
- if($i>0) print ' '.$curSign.' ';
- print $curType . abs($sit);
- $i++;
- }
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($total_global_ht) . ' | ';
- print '' . price($total_global_ttc) . ' | ';
- print ' | ';
- print '
';
-
-
- if (count($object->tab_next_situation_invoice) > 0) {
- // List of next invoices
- /*print '';
- print '| ' . $langs->trans('ListOfNextSituationInvoices') . ' | ';
- print ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . $langs->trans('AmountHT') . ' | ';
- print '' . $langs->trans('AmountTTC') . ' | ';
- print ' | ';
- print '
';*/
-
- $total_next_ht = $total_next_ttc = 0;
-
- foreach ($object->tab_next_situation_invoice as $next_invoice) {
- $totalpaye = $next_invoice->getSommePaiement();
- $total_next_ht += $next_invoice->total_ht;
- $total_next_ttc += $next_invoice->total_ttc;
-
- print '';
- print '| ' . $next_invoice->getNomUrl(1) . ' | ';
- print ' | ';
- print ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($next_invoice->total_ht) . ' | ';
- print '' . price($next_invoice->total_ttc) . ' | ';
- print '' . $next_invoice->getLibStatut(3, $totalpaye) . ' | ';
- print '
';
-
- }
-
- $total_global_ht += $total_next_ht;
- $total_global_ttc += $total_next_ttc;
-
- print '';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($total_global_ht) . ' | ';
- print '' . price($total_global_ttc) . ' | ';
- print ' | ';
- print '
';
- }
-
- print '
';
- }
+
// Incoterms
if (!empty($conf->incoterm->enabled))
@@ -4170,88 +4000,129 @@ else if ($id > 0 || ! empty($ref))
if (! empty($conf->incoterm->enabled))
$nbrows += 1;
- if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION))
+ // List of previous situation invoices
+ if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION))
{
- if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0)
- print '';
-
- if (count($object->tab_previous_situation_invoice) > 0) {
- // List of previous invoices
- print '';
- print '| ' . $langs->trans('ListOfPreviousSituationInvoices') . ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . $langs->trans('AmountHT') . ' | ';
- print '' . $langs->trans('AmountTTC') . ' | ';
- print ' | ';
- print '
';
-
- $total_prev_ht = $total_prev_ttc = 0;
- foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
- $totalpaye = $prev_invoice->getSommePaiement();
- $total_prev_ht += $prev_invoice->total_ht;
- $total_prev_ttc += $prev_invoice->total_ttc;
- print '';
- print '| ' . $prev_invoice->getNomUrl(1) . ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($prev_invoice->total_ht) . ' | ';
- print '' . price($prev_invoice->total_ttc) . ' | ';
- print '' . $prev_invoice->getLibStatut(3, $totalpaye) . ' | ';
- print '
';
-
- }
-
- print '';
- print ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($total_prev_ht) . ' | ';
- print '' . price($total_prev_ttc) . ' | ';
- print ' | ';
- print '
';
- }
-
- if (count($object->tab_next_situation_invoice) > 0) {
- // List of next invoices
- print '';
- print '| ' . $langs->trans('ListOfNextSituationInvoices') . ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . $langs->trans('AmountHT') . ' | ';
- print '' . $langs->trans('AmountTTC') . ' | ';
- print ' | ';
- print '
';
-
- $total_next_ht = $total_next_ttc = 0;
-
- foreach ($object->tab_next_situation_invoice as $next_invoice) {
- $totalpaye = $next_invoice->getSommePaiement();
- $total_next_ht += $next_invoice->total_ht;
- $total_next_ttc += $next_invoice->total_ttc;
- print '';
- print '| ' . $next_invoice->getNomUrl(1) . ' | ';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
- print '' . price($next_invoice->total_ht) . ' | ';
- print '' . price($next_invoice->total_ttc) . ' | ';
- print '' . $next_invoice->getLibStatut(3, $totalpaye) . ' | ';
- print '
';
-
- }
-
- print '';
- print ' | ';
- if (! empty($conf->banque->enabled)) print ' | ';
-
- print '' . price($total_next_ht) . ' | ';
- print '' . price($total_next_ttc) . ' | ';
- print ' | ';
- print '
';
- }
-
- if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0)
- print '
';
+
+ print '';
+
+
+ print '';
+ print '| ' . $langs->trans('ListOfSituationInvoices') . ' | ';
+ print ' | ';
+ print '' . $langs->trans('Situation') . ' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . $langs->trans('AmountHT') . ' | ';
+ print '' . $langs->trans('AmountTTC') . ' | ';
+ print ' | ';
+ print '
';
+
+
+ $total_prev_ht = $total_prev_ttc = 0;
+ $total_global_ht = $total_global_ttc = 0;
+
+ if (count($object->tab_previous_situation_invoice) > 0) {
+ // List of previous invoices
+
+ $current_situation_counter = array();
+ foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
+ $totalpaye = $prev_invoice->getSommePaiement();
+ $total_prev_ht += $prev_invoice->total_ht;
+ $total_prev_ttc += $prev_invoice->total_ttc;
+ $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter;
+ print '';
+ print '| ' . $prev_invoice->getNomUrl(1) . ' | ';
+ print ' | ';
+ print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . price($prev_invoice->total_ht) . ' | ';
+ print '' . price($prev_invoice->total_ttc) . ' | ';
+ print '' . $prev_invoice->getLibStatut(3, $totalpaye) . ' | ';
+ print '
';
+ }
+ }
+
+
+ $total_global_ht += $total_prev_ht ;
+ $total_global_ttc += $total_prev_ttc ;
+ $total_global_ht += $object->total_ht;
+ $total_global_ttc += $object->total_ttc;
+ $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $object->situation_counter;
+ print '';
+ print '| ' . $object->getNomUrl(1) . ' | ';
+ print ' | ';
+ print ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . price($object->total_ht) . ' | ';
+ print '' . price($object->total_ttc) . ' | ';
+ print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ' | ';
+ print '
';
+
+
+ print '';
+ print '| ' . $langs->trans('CurrentSituationTotal') . ' | ';
+ print '';
+ $i =0;
+ foreach ($current_situation_counter as $sit)
+ {
+ $curSign = $sit>0?'+':'-';
+ $curType = $sit>0?$langs->trans('situationInvoiceShortcode_S'):$langs->trans('situationInvoiceShortcode_AS');
+ if($i>0) print ' '.$curSign.' ';
+ print $curType . abs($sit);
+ $i++;
+ }
+ print ' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . price($total_global_ht) . ' | ';
+ print '' . price($total_global_ttc) . ' | ';
+ print ' | ';
+ print '
';
+
+
+ if (count($object->tab_next_situation_invoice) > 0) {
+ // List of next invoices
+ /*print '';
+ print '| ' . $langs->trans('ListOfNextSituationInvoices') . ' | ';
+ print ' | ';
+ print ' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . $langs->trans('AmountHT') . ' | ';
+ print '' . $langs->trans('AmountTTC') . ' | ';
+ print ' | ';
+ print '
';*/
+
+ $total_next_ht = $total_next_ttc = 0;
+
+ foreach ($object->tab_next_situation_invoice as $next_invoice) {
+ $totalpaye = $next_invoice->getSommePaiement();
+ $total_next_ht += $next_invoice->total_ht;
+ $total_next_ttc += $next_invoice->total_ttc;
+
+ print '';
+ print '| ' . $next_invoice->getNomUrl(1) . ' | ';
+ print ' | ';
+ print ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . price($next_invoice->total_ht) . ' | ';
+ print '' . price($next_invoice->total_ttc) . ' | ';
+ print '' . $next_invoice->getLibStatut(3, $totalpaye) . ' | ';
+ print '
';
+
+ }
+
+ $total_global_ht += $total_next_ht;
+ $total_global_ttc += $total_next_ttc;
+
+ print '';
+ print ' | ';
+ if (! empty($conf->banque->enabled)) print ' | ';
+ print '' . price($total_global_ht) . ' | ';
+ print '' . price($total_global_ttc) . ' | ';
+ print ' | ';
+ print '
';
+ }
+
+ print '
';
}