Beispiel #1
0
function GetDebitTypeInADebit($debit_id)
{
    $req = mysql_query("\nSELECT\n  ddr.bank_account_id,\n  i.id_client,\n  ROUND(SUM(ir.qtt*ir.prix_ht)*(i.tax)/100, 2) AS VAT,\n  ROUND(SUM(ir.qtt*ir.prix_ht)*(100+i.tax)/100, 2) AS TTC\nFROM direct_debit_row ddr\nJOIN webfinance_invoices i ON ddr.invoice_id = i.id_facture\nJOIN webfinance_invoice_rows ir ON ir.id_facture = i.id_facture\nWHERE debit_id = {$debit_id}\nGROUP BY i.id_facture") or die(mysql_error());
    $res = array('rcur' => array('nb_of_transactions' => 0, 'total_VAT' => 0, 'total' => 0), 'frst' => array('nb_of_transactions' => 0, 'total_VAT' => 0, 'total' => 0));
    while ($row = mysql_fetch_assoc($req)) {
        $type = GetDebitType($row['id_client'], $debit_id, $row['bank_account_id']);
        if ($type == 'RCUR') {
            $res['rcur']['nb_of_transactions']++;
            $res['rcur']['total_VAT'] += $row['VAT'];
            $res['rcur']['total'] += $row['TTC'];
        }
        if ($type == 'FRST') {
            $res['frst']['nb_of_transactions']++;
            $res['frst']['total_VAT'] += $row['VAT'];
            $res['frst']['total'] += $row['TTC'];
        }
    }
    return $res;
}
Beispiel #2
0
  <th align="right">Amount incl. VAT</th>
  <th align="right">SEPA type</th>
 </tr>

<?php 
$total_ht = 0;
$total_ttc = 0;
$Invoice = new Facture();
$count = 0;
while ($invoice = mysql_fetch_assoc($res)) {
    $count++;
    $info = $Invoice->getInfos($invoice['invoice_id']);
    $total[$info->nom_client]['HT'] += $info->total_ht;
    $total[$info->nom_client]['TTC'] += $info->total_ttc;
    $css_class = 'row_' . ($count % 2 == 0 ? "even" : "odd");
    $sepa_type = GetDebitType($invoice['id_client'], $_GET['id'], $invoice['bank_account_id']);
    echo "<tr class=\"{$css_class}\"> <td> {$info->nom_client} </td>";
    echo "<td> <a href=\"../prospection/edit_facture.php?id_facture={$invoice['invoice_id']}\">{$info->num_facture}</a> </td>";
    echo "<td> {$info->nice_date_facture} </td>";
    echo "<td> <a href=\"../../prospection/fiche_prospect.php?id={$invoice['id_client']}&onglet=other\">{$invoice['bank_name']}</a> </td>";
    echo "<td align=\"right\"> {$info->nice_total_ht} &euro; </td>";
    echo "<td align=\"right\"> {$info->nice_total_ttc} &euro; </td>";
    echo "<td align=\"right\"> {$sepa_type} </td>";
    echo "</tr>";
    $total_ht += $info->total_ht;
    $total_ttc += $info->total_ttc;
}
?>

<tr>
  <td></td>