diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0eefa2178c3..0ae59c31044 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -927,7 +927,7 @@ if (empty($reshook)) $id = $object->create($user); - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if ((GETPOST('invoiceAvoirWithLines', 'int')==1 || $object->situation_cycle_ref>0 ) && $id>0) { if (!empty($facture_source->lines)) @@ -3804,22 +3804,27 @@ else if ($id > 0 || ! empty($ref)) if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices print ''; - print '' . $langs->trans('ListOfPreviousSituationInvoices') . ''; + 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; + $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)?'A':'S') . $prev_invoice->situation_counter; print ''; print '' . $prev_invoice->getNomUrl(1) . ''; print ''; + print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?'A':'S') . $prev_invoice->situation_counter.''; if (! empty($conf->banque->enabled)) print ''; print '' . price($prev_invoice->total_ht) . ''; print '' . price($prev_invoice->total_ttc) . ''; @@ -3827,27 +3832,46 @@ else if ($id > 0 || ! empty($ref)) print ''; } - - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($total_prev_ht) . ''; - print '' . price($total_prev_ttc) . ''; - print ' '; - 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)?'A':'S') . $object->situation_counter; + print ''; + print '' . $object->getNomUrl(1) . ''; + print ''; + print ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?'A':'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 ''.implode(' + ', $current_situation_counter).''; + 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 ''; print '' . $langs->trans('ListOfNextSituationInvoices') . ''; print ''; + print ''; if (! empty($conf->banque->enabled)) print ''; print '' . $langs->trans('AmountHT') . ''; print '' . $langs->trans('AmountTTC') . ''; print ' '; - print ''; + print '';*/ $total_next_ht = $total_next_ttc = 0; @@ -3855,9 +3879,11 @@ else if ($id > 0 || ! empty($ref)) $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)?'AS':'S') . $next_invoice->situation_counter.''; if (! empty($conf->banque->enabled)) print ''; print '' . price($next_invoice->total_ht) . ''; print '' . price($next_invoice->total_ttc) . ''; @@ -3865,13 +3891,15 @@ else if ($id > 0 || ! empty($ref)) print ''; } - + + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; + print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) print ''; - - print '' . price($total_next_ht) . ''; - print '' . price($total_next_ttc) . ''; + print '' . price($total_global_ht) . ''; + print '' . price($total_global_ttc) . ''; print ' '; print ''; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e3719d2427..1ba9fc4a65f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2650,7 +2650,7 @@ abstract class CommonObject $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE ) { $prev_sits = $this->get_prev_sits(); @@ -2694,7 +2694,7 @@ abstract class CommonObject $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; $sql .= ' WHERE rowid = '.$this->id; - //print "xx".$sql; + print "xx".$sql; dol_syslog(get_class($this)."::update_price", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 122d1a2a69a..48a2a9d0535 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -339,6 +339,8 @@ PaymentOnDifferentThirdBills=Allow payments on different thirdparties bills but PaymentNote=Payment note ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices +ListOfSituationInvoices=List of situation invoices +CurrentSituationTotal=Total current situation FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years