Merge pull request #11225 from ATM-Nicolas/new_propal_list_column

NEW Add hidden option PROPOSAL_SHOW_INVOICED_AMOUNT (not reliable if one invoice is done on several order or several proposal)
This commit is contained in:
Laurent Destailleur 2019-06-20 03:27:45 +02:00 committed by GitHub
commit e99cf13ccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View File

@ -162,6 +162,8 @@ $arrayfields=array(
'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'p.total_ht_invoiced'=>array('label'=>$langs->trans("AmountInvoicedHT"), 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT),
'p.total_invoiced'=>array('label'=>$langs->trans("AmountInvoicedTTC"), 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
@ -644,6 +646,18 @@ if ($resql)
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['p.total_ht_invoiced']['checked']))
{
// Amount invoiced
print '<td class="liste_titre right">';
print '</td>';
}
if (! empty($arrayfields['p.total_invoiced']['checked']))
{
// Amount invoiced
print '<td class="liste_titre right">';
print '</td>';
}
if (! empty($arrayfields['u.login']['checked']))
{
// Author
@ -709,6 +723,8 @@ if ($resql)
if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
// Extra fields
@ -933,6 +949,48 @@ if ($resql)
if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
$totalarray['totalttc'] += $obj->total_ttc;
}
// Amount invoiced
if(! empty($arrayfields['p.total_ht_invoiced']['checked'])) {
$totalInvoiced = 0;
$p = new Propal($db);
$TInvoiceData = $p->InvoiceArrayList($obj->rowid);
if(! empty($TInvoiceData)) {
foreach($TInvoiceData as $invoiceData) {
$invoice = new Facture($db);
$invoice->fetch($invoiceData->facid);
if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
$totalInvoiced += $invoice->total_ht;
}
}
print '<td class="right">'.price($totalInvoiced)."</td>\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalhtinvoicedfield']=$totalarray['nbfield'];
$totalarray['totalhtinvoiced'] += $totalInvoiced;
}
// Amount invoiced
if(! empty($arrayfields['p.total_invoiced']['checked'])) {
$totalInvoiced = 0;
$p = new Propal($db);
$TInvoiceData = $p->InvoiceArrayList($obj->rowid);
if(! empty($TInvoiceData)) {
foreach($TInvoiceData as $invoiceData) {
$invoice = new Facture($db);
$invoice->fetch($invoiceData->facid);
if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
$totalInvoiced += $invoice->total_ttc;
}
}
print '<td class="right">'.price($totalInvoiced)."</td>\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalinvoicedfield']=$totalarray['nbfield'];
$totalarray['totalinvoiced'] += $totalInvoiced;
}
$userstatic->id=$obj->fk_user_author;
$userstatic->login=$obj->login;
@ -1059,6 +1117,8 @@ if ($resql)
elseif ($totalarray['totalhtfield'] == $i) print '<td class="right">'.price($totalarray['totalht']).'</td>';
elseif ($totalarray['totalvatfield'] == $i) print '<td class="right">'.price($totalarray['totalvat']).'</td>';
elseif ($totalarray['totalttcfield'] == $i) print '<td class="right">'.price($totalarray['totalttc']).'</td>';
elseif ($totalarray['totalhtinvoicedfield'] == $i) print '<td class="right">'.price($totalarray['totalhtinvoiced']).'</td>';
elseif ($totalarray['totalinvoicedfield'] == $i) print '<td class="right">'.price($totalarray['totalinvoiced']).'</td>';
elseif ($totalarray['totalizable']) {
$printed = false;
foreach ($totalarray['totalizable'] as $totalizable) {

View File

@ -347,6 +347,8 @@ PriceUTTC=P.U TTC
Amount=Montant
AmountInvoice=Montant facture
AmountInvoiced=Montant facturé
AmountInvoicedHT=Montant HT facturé
AmountInvoicedTTC=Montant TTC facturé
AmountPayment=Montant paiement
AmountHTShort=Montant HT
AmountTTCShort=Montant TTC