Example #1
0
</a></td>
</tr>
<?php 
$Client = new Client();
$grand_total_ca_ht = 0;
$grand_total_ca_ht_year = 0;
$count = 0;
while ($client = mysql_fetch_object($result)) {
    $count++;
    $grand_total_ca_ht += $client->ca_total_ht;
    $grand_total_ca_ht_year += $client->ca_total_ht_year;
    $total_dehors += $client->total_du_ht;
    $client->total_du_ht = $client->total_du_ht == 0 ? "-&nbsp;&nbsp;" : number_format($client->total_du_ht, 0, ',', ' ') . "&euro; HT";
    $client->ca_total_ht = $client->ca_total_ht == 0 ? "-&nbsp;&nbsp;" : number_format($client->ca_total_ht, 0, ',', ' ') . "&euro; HT";
    $client->ca_total_ht_year = $client->ca_total_ht_year == 0 ? "-&nbsp;&nbsp;" : number_format($client->ca_total_ht_year, 0, ',', ' ') . "&euro; HT";
    $type_comp_temp = strtoupper($Client->GetCompanyTypeById($client->id_company_type));
    $type_comp = $type_comp_temp[0];
    print "<tr align=center class=row_" . ($count % 2 == 0 ? "even" : "odd") . ">\n" . "  <td><a href=fiche_prospect.php?onglet=billing&id=" . $client->id_client . "&onglet=facturation>" . "    <img src=\"/imgs/icons/" . ($client->has_unpaid ? "not_paid" : ($client->has_devis ? "paid_orange" : "paid")) . ".gif\" /></a>\n" . "    <a href=edit_facture.php?id_facture=new&id_client=" . $client->id_client . "><img src=\"/imgs/icons/add.png\"></a></td>\n" . "  <td style=\"text-align: right;\">{$type_comp}</td>\n" . "  <td><a href=fiche_prospect.php?onglet=billing&id=" . $client->id_client . ">" . $client->nom . "</a>" . "</td>\n" . "  <td style=\"text-align: right;\">" . $client->ca_total_ht . "</td>\n" . "  <td style=\"text-align: right;\">" . $client->ca_total_ht_year . "</td>\n" . "  <td style=\"text-align: right;\">" . $client->total_du_ht . "</td>\n" . "</tr>\n";
}
mysql_free_result($result);
// CA total sur l'année N-2
$result = mysql_query("SELECT sum(fl.qtt*prix_ht), sum((1+tax/100)*prix_ht*fl.qtt)\n                       FROM webfinance_invoice_rows fl \n                       JOIN webfinance_invoices f ON (f.id_facture=fl.id_facture)\n                       WHERE f.type_doc='facture'\n                       AND year(f.date_facture) = year(now()) - 2") or wf_mysqldie();
list($ca_total_ht_annee_nmoisun, $ca_total_ttc_annee_nmoisun) = mysql_fetch_array($result);
mysql_free_result($result);
// CA total sur l'année N-1
$result = mysql_query("SELECT sum(fl.qtt*prix_ht), sum((1+tax/100)*prix_ht*fl.qtt)\n                       FROM webfinance_invoice_rows fl \n                       JOIN webfinance_invoices f ON (f.id_facture=fl.id_facture)\n                       WHERE f.type_doc='facture'\n                       AND year(f.date_facture) = year(now()) - 1") or wf_mysqldie();
list($ca_total_ht_annee_precedente, $ca_total_ttc_annee_precedente) = mysql_fetch_array($result);
mysql_free_result($result);
// CA Total sur année en cours
$result = mysql_query("SELECT sum(fl.qtt*prix_ht), sum((1+tax/100)*prix_ht*fl.qtt)\n                       FROM webfinance_invoice_rows fl\n                       JOIN webfinance_invoices f ON (f.id_facture=fl.id_facture)\n                       WHERE f.type_doc='facture'\n                       AND year(f.date_facture) = year(now())") or wf_mysqldie();
list($ca_total_ht_annee_encours, $ca_total_ttc_annee_encours) = mysql_fetch_array($result);