Exemplo n.º 1
0
?>
"><?php 
echo _('TTC');
?>
</a></td>
  <td></td>
</tr>
<?php 
$total_ca_ht = 0;
$q = "SELECT webfinance_invoices.id_facture " . "FROM webfinance_users, webfinance_clients, webfinance_invoices " . "WHERE " . "( " . "webfinance_clients.id_user = webfinance_users.id_user " . "AND webfinance_clients.id_client = webfinance_invoices.id_client " . " ) " . "AND webfinance_invoices.type_doc='facture' " . "AND webfinance_invoices.num_facture!='' " . "AND webfinance_invoices.date_facture<=now() " . "AND {$where_clause} " . "ORDER BY {$order_clause} ";
$result = mysql_query($q) or wf_mysqldie();
$num_factures = array();
$count = 0;
while (list($id_facture) = mysql_fetch_array($result)) {
    $count++;
    $fa = $Facture->getInfos($id_facture);
    $class = $count % 2 == 0 ? "even" : "odd";
    $icon = $fa->is_paye ? "paid" : "not_paid";
    $total_ca_ht += $fa->total_ht;
    if (isset($mois[$fa->mois_facture])) {
        $mois[$fa->mois_facture]++;
    } else {
        $mois[$fa->mois_facture] = 1;
    }
    $description = "";
    $result2 = mysql_query("SELECT description FROM webfinance_invoice_rows WHERE id_facture=" . $fa->id_facture) or wf_mysqldie();
    while (list($desc) = mysql_fetch_array($result2)) {
        $desc = preg_replace("/\r\n/", " ", $desc);
        $desc = preg_replace("/\"/", "", $desc);
        $desc = preg_replace("/\\'/", "", $desc);
        $description .= $desc . "<br/>";
Exemplo n.º 2
0
function GetSepaContent($debit_id, $debit_type_asked)
{
    $Invoice = new Facture();
    $Client = new Client();
    # Fetch direct debit transactions
    $res = mysql_query("SELECT id, invoice_id, bank_account_id\n\tFROM direct_debit_row\n\tWHERE debit_id = {$debit_id}") or die(mysql_error());
    if (mysql_num_rows($res) == 0) {
        error_log(__FUNCTION__ . "(): No transaction found for debit_id {$debit_id}");
        return FALSE;
    }
    $total_ttc = 0;
    $invoice_client = array();
    $total = array();
    while ($invoice = mysql_fetch_assoc($res)) {
        $info = $Invoice->getInfos($invoice['invoice_id']);
        if (!isset($total[$info->nom_client])) {
            $total[$info->nom_client] = array();
        }
        if (!isset($total[$info->nom_client]['TTC'])) {
            $total[$info->nom_client]['TTC'] = 0;
        }
        $total[$info->nom_client]['TTC'] += $info->total_ttc;
        // On enlève les caractères génants
        $iban = str_replace(",", "", $info->iban);
        $bic = str_replace(",", "", $info->bic);
        $client_iban = preg_replace('/\\s+/', '', $iban);
        $client_bic = preg_replace('/\\s+/', '', $bic);
        $client_name = iconv('utf-8', 'ascii//TRANSLIT', $info->nom_client);
        $mandat_date = GetMandateDate($info->id_client);
        $debit_type = GetDebitType($info->id_client, $debit_id, $invoice['bank_account_id']);
        // On définit les variables de la remise de virement
        $ref_paiement = "F:" . $info->num_facture;
        $Client->Client($info->id_client);
        // Formatage du montant
        $montant = round($info->total_ttc, 2);
        $montant_centimes = round($info->total_ttc * 100, 0);
        if (array_key_exists($info->id_client, $invoice_client)) {
            $invoice_client[$info->id_client]['montant'] = $invoice_client[$info->id_client]['montant'] + $montant_centimes;
            $invoice_client[$info->id_client]['ref'] = $invoice_client[$info->id_client]['ref'] . "-" . $ref_paiement;
        } else {
            if (isset($debit_type)) {
                if ($debit_type == $debit_type_asked) {
                    $invoice_client[$info->id_client] = array('id' => $info->id_client, 'montant' => $montant_centimes, 'ref' => $ref_paiement, 'client_sepaid' => $Client->sepa_mndtid, 'iban' => $client_iban, 'bic' => $client_bic, 'name' => $client_name, 'mandat_date' => $mandat_date, 'debit_type' => $debit_type);
                }
            }
        }
    }
    if (count($invoice_client) === 0) {
        error_log(__FUNCTION__ . "(): No transaction found for debit_id {$debit_id} and type {$debit_type_asked}");
        return FALSE;
    }
    return $invoice_client;
}
Exemplo n.º 3
0
    echo "Missing arguments";
    exit;
}
if (!is_numeric($_GET['id_client']) or !is_numeric($_GET['id_invoice'])) {
    echo "Wrong arguments";
    exit;
}
$Client = new Client();
# check client and invoice
if (!$Client->exists($_GET['id_client'])) {
    echo _("This client doesn't exist");
    exit;
}
$Invoice = new Facture();
if ($Invoice->exists($_GET['id_invoice'])) {
    $inv = $Invoice->getInfos($_GET['id_invoice']);
    if ($inv->id_client != $_GET['id_client']) {
        echo _("This invoice isn't yours!");
        exit;
    }
    $Client = new Client($_GET['id_client']);
}
#site
$result = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1") or wf_mysqldie();
list($value) = mysql_fetch_array($result);
mysql_free_result($result);
$company = unserialize(base64_decode($value));
$site = "webfinance.dev.jexiste.org";
if (!empty($company->wf_url) and strlen($company->wf_url) > 3) {
    $site = preg_replace('/^http:\\/\\//i', '', $company->wf_url);
}
Exemplo n.º 4
0
require_once dirname(__FILE__) . '/../htdocs/inc/Client.php';
require_once '/usr/share/php/libphp-phpmailer/class.phpmailer.php';
$send_mail_print_invoice = false;
$send_mail_direct_debit = false;
$attachments = array();
$Invoice = new Facture();
// Define French locale in order to generate French dates
setlocale(LC_TIME, "fr_FR.UTF8");
// Fetch periodic invoices where the deadline is over
$result = mysql_query('SELECT id_facture ' . 'FROM webfinance_invoices ' . "WHERE period!='none' AND " . 'periodic_next_deadline<=NOW() AND ' . "type_doc = 'facture'") or die(mysql_error());
if (mysql_num_rows($result) == 0) {
    exit;
}
while (list($id_invoice) = mysql_fetch_row($result)) {
    // Fetch info from invoice
    $invoice = $Invoice->getInfos($id_invoice);
    // Calculate next deadline
    $next_deadline = $Invoice->nextDeadline($invoice->periodic_next_deadline, $invoice->period);
    // Duplicate the invoice
    $id_new_invoice = $Invoice->duplicate($id_invoice);
    // Delete setup fees that only have to be paid once
    $query = 'DELETE FROM webfinance_invoice_rows ' . "WHERE (description LIKE '%Frais d\\'accès au service%' " . "OR description LIKE '%Frais d\\'installation%' " . "OR description LIKE '%rais de migration%') " . "AND id_facture={$id_new_invoice}";
    mysql_query($query) or die("{$query}:" . mysql_error());
    // Add dynamic start date and deadline in invoice details
    $query = 'SELECT id_facture_ligne, description ' . 'FROM webfinance_invoice_rows ' . "WHERE id_facture={$id_new_invoice}";
    $res = mysql_query($query) or die("{$query}:" . mysql_error());
    // Update dates in invoices description
    while ($invoice_row = mysql_fetch_array($res)) {
        if (!preg_match('/ du \\d{4}-\\d{2}-\\d{2} au \\d{4}-\\d{2}-\\d{2}/', $invoice_row['description'])) {
            continue;
        }
Exemplo n.º 5
0
   (at your option) any later version.

    Webfinance is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Webfinance; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
include "../inc/main.php";
must_login();
$roles = 'manager,employee';
include "nav.php";
$Invoice = new Facture();
if (!isset($_GET['id']) or !is_numeric($_GET['id']) or !$Invoice->exists($_GET['id'])) {
    echo "Invalid invoice id";
    exit(1);
}
$facture = $Invoice->getInfos($_GET['id']);
if ($facture->is_paye) {
    echo "Invoice has already been paid";
    exit(1);
}
// Plan the invoice to be debited
mysql_query("INSERT INTO direct_debit_row " . "SET invoice_id = {$_GET['id']}, " . "    state='todo'") or die(mysql_error());
// Flag invoice as paid
$Invoice->setPaid($_GET['id']);
header("Location: ../prospection/edit_facture.php?id_facture={$_GET['id']}");
exit;
Exemplo n.º 6
0
  <th align="right">Amount excl. VAT</th>
  <th align="right">Amount incl. VAT</th>
  <th>SEPA type</th>
  <th></th>
 </tr>

<?php 
$total_ht = 0;
$total_ttc = 0;
$count = 0;
while ($invoice = mysql_fetch_assoc($res)) {
    $css_class = 'row_' . ($count % 2 == 0 ? "even" : "odd");
    if (empty($invoice['bank_name'])) {
        $invoice['bank_name'] = '<font color="red"> <strong> NONE! </strong> </font>';
    }
    $info = $Invoice->getInfos($invoice['invoice_id']);
    $total[$info->nom_client]['HT'] += $info->total_ht;
    $total[$info->nom_client]['TTC'] += $info->total_ttc;
    $pending_debit_type = GetPendingDebitType($invoice['id_client'], $invoice['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 align=\"center\"> <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=\"center\"> <a href=\"toggle_frst.php?invoice_id={$invoice['invoice_id']}&previous_state={$pending_debit_type}\">{$pending_debit_type}</a> </td>";
    echo "<td> <a href=\"del.php?id={$invoice['invoice_id']}\">Del</a> </td>";
    echo "</tr>";
    $total_ht += $info->total_ht;
    $total_ttc += $info->total_ttc;
    $count++;
    <div>
    <table border="0" cellspacing="0" cellpadding="1">
      <?php 
// Affichage des factures existantes pour ce client
// Affichage par année, avec une séparation lisible
$q = "\nSELECT\n  YEAR(f.date_facture) AS annee,\n  SUM(IF(f.type_doc='facture' AND f.is_abandoned=0,\n    (fl.qtt*fl.prix_ht)/f.exchange_rate, 0)) AS ca_ht_total,\n  SUM( IF(f.type_doc='facture' AND f.is_paye=0 AND f.is_abandoned=0,\n  (fl.qtt*fl.prix_ht)/f.exchange_rate, 0)) AS du_ht_total,\n  SUM( IF(f.type_doc='facture' AND f.is_paye=0 AND f.is_abandoned=0,\n  (fl.qtt*fl.prix_ht*(100+f.tax)/100)/f.exchange_rate, 0)) AS du_ttc_total\nFROM webfinance_invoices f\nLEFT JOIN webfinance_invoice_rows fl ON f.id_facture=fl.id_facture\nWHERE f.id_client = {$Client->id}\nGROUP BY YEAR(date_facture)\nORDER BY f.date_facture DESC";
$result = mysql_query($q) or wf_mysqldie();
$Facture = new Facture();
while ($year = mysql_fetch_object($result)) {
    printf('<tr><td style="border-bottom: solid 1px #777;" colspan="6"><b style="font-size: 16px;">%s</b> - <b><i>Encours %s&euro; HT - %s&euro; TTC</i></b> - <i>%s&euro; HT</i></td></tr>', $year->annee, number_format($year->du_ht_total, 2, ',', ' '), number_format($year->du_ttc_total, 2, ',', ' '), number_format($year->ca_ht_total, 2, ',', ' '));
    $q = "SELECT f.id_facture\n                FROM webfinance_invoices as f\n                WHERE f.id_client=" . $Client->id . "\n                AND year(f.date_facture) = '" . $year->annee . "'\n                ORDER BY f.date_facture DESC";
    $result2 = mysql_query($q) or die("{$q}: " . mysql_error());
    $count = 0;
    //            $total_du = 0;
    while (list($id_invoice) = mysql_fetch_array($result2)) {
        $facture = $Facture->getInfos($id_invoice);
        list($currency, $exchange) = getCurrency($facture->id_compte);
        // Récupération du texte des lignes facturées pour afficher en infobulle.
        $description = "<b>" . $facture->nice_date_facture . "</b><br/>";
        foreach ($facture->lignes as $l) {
            $l->description = preg_replace("/\r\n/", " ", $l->description);
            $l->description = preg_replace("/\"/", "", $l->description);
            $l->description = preg_replace("/\\'/", "", $l->description);
            $l->description = preg_replace("/\n/", "<br>", $l->description);
            $description .= $l->description . "<br/>";
        }
        //              if ((! $facture->is_paye) && ($facture->type_doc=="facture")) {
        //                $total_du += $facture->total;
        //              }
        $pdf = sprintf('&nbsp;<a href="gen_facture.php?id=%d"><img src="/imgs/icons/pdf.png" alt="FA" /></a>', $facture->id_facture);
        if ($facture->type_doc == "facture") {
Exemplo n.º 8
0
     if ($paypal_return['amount'] != $_POST['mc_gross']) {
         $error .= "Invalid amount, expected: {$paypal_return['amount']} got: {$_POST['payment_amount']}\n";
     }
     if ($paypal_return['currency'] != $_POST['mc_currency']) {
         $error .= "Invalid currency, expected: {$paypal_return['currency']} got: {$_POST['mc_currency']}\n";
     }
     if ($_POST['payment_status'] != 'Completed') {
         $error .= "Invalid payment status: {$_POST['payment_status']}\n";
     }
     if (!$paypal_params['debug']) {
         if ($_POST['test_ipn'] == 1) {
             $error .= "No test payment are allowed test_ipn: {$_POST['test_ipn']}\n";
         }
     }
     $Facture = new Facture();
     $facture = $Facture->getInfos($paypal_return['id_invoice']);
     $societe = GetCompanyInfo();
     if ($facture->is_paye > 0) {
         $error .= "We received a paypal payment for invoice: {$facture->num_facture} but it has already been paid ?!\n";
     }
     if ($facture->is_abandoned > 0) {
         $error .= "We received a paypal payment for invoice: {$facture->num_facture} but invoice got abandoned status?!\n";
     }
 }
 if (!empty($error)) {
     mail($paypal_params['email'], 'PAYPAL WARNING - IPN PROCESSING ERROR', $error . "\n\nDEBUG: \n\n" . $listener->getTextReport());
     error_log($listener->getTextReport());
     //Transaction OK
 } else {
     //Update invoice
     $req_update_invoice = "UPDATE webfinance_invoices SET \n\t\tpayment_method\t= 'paypal', \n\t\tis_paye\t\t\t= 1, \n\t\tdate_paiement\t= NOW() \n\t\tWHERE id_facture = " . $paypal_return[id_invoice];
Exemplo n.º 9
0
    $result = mysql_query("SELECT c.id_client,c.nom\n                         FROM webfinance_client AS c\n                         WHERE (\n                          c.nom LIKE '%{$q}%'\n                        )") or wf_mysqldie();
    if (mysql_num_rows($result)) {
        $nb = mysql_num_rows($result);
        print "<h2>" . _('Results found in companies :') . "</h2>";
        printf("<h3>" . _('%d invoice%s matching your search') . "</h3>", $nb, $nb > 1 ? "s" : "");
        print '<ul class="search_results">';
        print '</ul>';
    }
}
// Search in invoices
if ($search_in['invoices']) {
    $result = mysql_query("SELECT f.id_facture,id_client,sum(fl.qtt*fl.prix_ht) as total_facture,\n                                f.extra_top, f.extra_bottom, f.commentaire\n                         FROM webfinance_invoices AS f, webfinance_invoice_rows fl\n                         WHERE fl.id_facture=f.id_facture\n                         AND (\n                          f.extra_top LIKE '%{$q}%' OR\n                          f.extra_bottom LIKE '%{$q}%' OR\n                          f.num_facture LIKE '%{$q}%' OR\n                          f.commentaire LIKE '%{$q}%'  OR\n                          fl.description LIKE '%{$q}%'\n                        ) GROUP BY f.id_facture") or wf_mysqldie();
    if (mysql_num_rows($result)) {
        $nb = mysql_num_rows($result);
        print "<h2>" . _('Results found in invoices :') . "</h2>";
        printf("<h3>" . _('%d invoice%s matching your search') . "</h3>", $nb, $nb > 1 ? "s" : "");
        print '<ul class="search_results">';
        while ($found = mysql_fetch_object($result)) {
            $invoice = new Facture();
            $data = $invoice->getInfos($found->id_facture);
            print "<pre>";
            print_r($data);
            print "</pre>";
        }
    }
}
?>

<?php 
$Revision = '$Revision: 531 $';
require "bottom.php";
Exemplo n.º 10
0
function GenerateCfonb($debit_id = null)
{
    // Check $debit_id
    if (defined($debit_id) and !is_numeric($debit_id)) {
        die('Invalid $debit_id');
    }
    $where = "WHERE state='todo'";
    if (!empty($debit_id)) {
        $where = "WHERE debit_id = {$debit_id}";
    }
    $company_rib = GetCompanyMaiRIB();
    define('NUMERO_EMETTEUR', '484779');
    define('RAISON_SOCIALE', 'SARL ISVTEC');
    define('SIRET', '44875254300034');
    define('CODE_GUICHET_SOCIETE', $company_rib->code_guichet);
    define('NUMERO_COMPTE_SOCIETE', $company_rib->compte);
    define('CODE_BANQUE', $company_rib->code_banque);
    define('REF_REMISE', date('dmy'));
    define('PRELEVEMENT_TYPE', '08');
    //08 = standard, 85 = rapide
    define('LONGUEUR_CODE_BANQUE', '5');
    define('LONGUEUR_CODE_GUICHET', '5');
    define('LONGUEUR_NUMERO_COMPTE', '11');
    define('LONGUEUR_ENREGISTREMENT', '160');
    /**
    * On définit les variables
    */
    $nombre_virements = 0;
    $montant_total = 0;
    $montant_total_centimes = 0;
    $chaine_totale = "";
    $nb_erreurs = 0;
    $erreurs_details = "";
    /**
    * Enregistrement et données de la remise d'ordres de virement
    * Enregistrement "Emetteur"
    */
    $ligne = "";
    $ligne .= FormatBancaire("03", 2);
    // Code enregistrement - Constante à "03" (2 caractères)
    $ligne .= FormatBancaire(PRELEVEMENT_TYPE, 2);
    // Code opération - Virements ordinaires (2 caractères)
    $ligne .= FormatBancaire("", 8);
    // Zone réservée (8 caractères)
    $ligne .= FormatBancaire(NUMERO_EMETTEUR, 6);
    // Numéro d'émetteur ou d'identification (6 caractères)
    $ligne .= FormatBancaire("", 1);
    // Code CCD : inutile dans notre cas (1 caractères)
    $ligne .= FormatBancaire("", 6);
    // Zone réservée (6 caractères)
    $ligne .= FormatBancaire(date('dm') . substr(date('y'), -1), 5);
    // Date (JJMMA) (5 caractères)
    $ligne .= FormatBancaire(stripAccents(RAISON_SOCIALE), 24);
    // Nom ou raison sociale du donneur d'ordre (24 caractères)
    $ligne .= FormatBancaire(stripAccents(REF_REMISE), 11);
    // Référence de la remise (7 caractères)
    $ligne .= FormatBancaire("", 15);
    // Zone réservée (17 caractères)
    $ligne .= FormatBancaire("E", 1);
    // Code monnaie - Constante à "E" (1 caractères)
    $ligne .= FormatBancaire("", 5);
    // Zone réservée (5 caractères)
    $ligne .= FormatBancaire(CODE_GUICHET_SOCIETE, 5);
    // Code guichet de la banque du conneur d'ordre (5 caractères)
    $ligne .= FormatBancaire(NUMERO_COMPTE_SOCIETE, 11);
    // Numéro de compte du donneur d'ordre (11 caractères)
    $ligne .= FormatBancaire("", 47);
    // Zone réservée (31 caractères)
    $ligne .= FormatBancaire(CODE_BANQUE, 5);
    // Code établissement de la banque du donneur d'ordre (5 caractères)
    // $ligne .= FormatBancaire(SIRET, 16); // Identifiant du donneur d'ordre (16 caractères)
    // $ligne .= FormatBancaire("", 31); // Zone réservée (31 caractères)
    $ligne .= FormatBancaire("", 6);
    // Zone réservée (6 caractères)
    // On vérifie l'intégrité de la chaîne
    if (strlen($ligne) != LONGUEUR_ENREGISTREMENT) {
        $nb_erreurs++;
        $erreurs_details .= " - La première ligne \"Emetteur\" contient " . strlen($ligne) . " caractères au lieu de " . LONGUEUR_ENREGISTREMENT . ". La remise d'ordres de virement ne peut être poursuivie.<br />";
    }
    // On complète la chaîne totale
    $chaine_totale .= $ligne . "\n";
    $Invoice = new Facture();
    $res = mysql_query('SELECT id, invoice_id ' . 'FROM direct_debit_row ' . "{$where}") or die(mysql_error());
    $total_ttc = 0;
    while ($invoice = mysql_fetch_assoc($res)) {
        $info = $Invoice->getInfos($invoice['invoice_id']);
        $total[$info->nom_client]['TTC'] += $info->total_ttc;
        // On positionne le nombre d'erreurs de cette ligne à zéro
        $nb_erreurs_ligne = 0;
        // On définit les variables de la remise de virement
        $ref_paiement = "F:" . $info->num_facture;
        // Formatage du montant
        $montant = round($info->total_ttc, 2);
        $montant_centimes = round($info->total_ttc * 100, 0);
        $rib = GetRibFromIban($info->iban);
        // On recherche les éléments pouvant bloquer la génération du paiement
        if (strlen($rib['banque']) != LONGUEUR_CODE_BANQUE) {
            $nb_erreurs++;
            $nb_erreurs_ligne++;
            $erreurs_details .= " - Le code banque de \"" . $info->nom_client . "\" permettant de générer un virement d'un montant de " . $montant . " EUR contient " . strlen($rib['banque']) . " caractères au lieu de " . LONGUEUR_CODE_BANQUE . " (valeur constatée : " . $info->rib_code_banque . "). Cette ligne est abandonnée.<br />";
        }
        if (strlen($rib['guichet']) != LONGUEUR_CODE_GUICHET) {
            $nb_erreurs++;
            $nb_erreurs_ligne++;
            $erreurs_details .= " - Le code guichet de \"" . $info->nom_client . "\" permettant de générer un virement d'un montant de " . $montant . " EUR contient " . strlen($rib['guichet']) . " caractères au lieu de " . LONGUEUR_CODE_GUICHET . " (valeur constatée : " . $info->rib_code_guichet . "). Cette ligne est abandonnée.<br />";
        }
        if (strlen($rib['compte']) != LONGUEUR_NUMERO_COMPTE) {
            $nb_erreurs++;
            $nb_erreurs_ligne++;
            $erreurs_details .= " - Le numéro de compte de \"" . $info->nom_client . "\" permettant de générer un virement d'un montant de " . $montant . " EUR contient " . strlen($rib['compte']) . " caractères au lieu de " . LONGUEUR_NUMERO_COMPTE . " (valeur constatée : " . $info->rib_compte . "). Cette ligne est abandonnée.<br />";
        }
        /**
        * Enregistrement et données de la remise d'ordres de virement
        * Enregistrement "Destinataire"
        */
        $ligne = "";
        $ligne .= FormatBancaire("06", 2);
        // Code d'enregistrement - Constante à "06" (2 caractères)
        $ligne .= FormatBancaire(CODE_OPERATION, 2);
        // Code opération (2 caractères)
        $ligne .= FormatBancaire("", 8);
        // Zone réservée (8 caractères)
        $ligne .= FormatBancaire(NUMERO_EMETTEUR, 6);
        // Numéro d'émetteur (6 caractères)
        $ligne .= FormatBancaire($ref_paiement, 12);
        // Référence (12 caractères)
        $ligne .= FormatBancaire(stripAccents($info->nom_client), 24);
        // Nom/Raison sociale du bénéficaire (24 caractères)
        $ligne .= FormatBancaire(stripAccents(' '), 20);
        // Domicialiation : facultatif (24 caractères)
        $ligne .= FormatBancaire("", 12);
        // Déclaration à la balance des paiements : ??????? (8 caractères)
        $ligne .= FormatBancaire($rib['guichet'], 5);
        // Code guichet bénéficiaire (5 caractères)
        $ligne .= FormatBancaire($rib['compte'], 11);
        // Numéro de compte bénéficiaire (11 caractères)
        $ligne .= FormatBancaire($montant_centimes, 16, "0", "right");
        // Montant (16 caractères)
        $ligne .= FormatBancaire($ref_paiement, 31);
        // Libellé (31 caractères)
        $ligne .= FormatBancaire($rib['banque'], 5);
        // Code établissement bénéficiaire (5 caractères)
        $ligne .= FormatBancaire("", 6);
        // Zone réservée (6 caractères)
        // On vérifie l'intégrité de la chaîne
        if (strlen($ligne) != LONGUEUR_ENREGISTREMENT) {
            $nb_erreurs++;
            $nb_erreurs_ligne++;
            $erreurs_details .= " - La ligne de virement de \"" . $info->nom_client . "\" d'un montant de " . $montant . " EUR contient " . strlen($ligne) . " caractères au lieu de " . LONGUEUR_ENREGISTREMENT . ". Cette ligne est abandonnée.<br />";
        }
        if ($nb_erreurs_ligne == 0) {
            // Si cette ligne n'a pas générée d'erreur
            // On compte le nombre de virements à effectuer
            $nombre_virements++;
            // On additionne le montant total
            $montant_total += $montant;
            // On complèté la chaîne totale
            $chaine_totale .= $ligne . "\n";
            $montant_total_centimes += $montant_centimes;
        }
    }
    // On calcule le montant total en centimes
    //$montant_total_centimes = round($total_ttc * 100, 0);
    /**
    * Enregistrement et données de la remise d'ordres de virement
    * Enregistrement "Total"
    */
    $ligne = "";
    $ligne .= FormatBancaire("08", 2);
    // Code enregistrement - constante à "08" (2 caractères)
    $ligne .= FormatBancaire(CODE_OPERATION, 2);
    // Code opération (2 caractères)
    $ligne .= FormatBancaire("", 8);
    // Zone réservée (8 caractères)
    $ligne .= FormatBancaire(NUMERO_EMETTEUR, 6);
    // Numéro d'émetteur (6 caractères)
    $ligne .= FormatBancaire("", 84);
    // Zone réservée (12 caractères)
    $ligne .= FormatBancaire($montant_total_centimes, 16, "0", "right");
    // Montant de la remise (16 caractères)
    $ligne .= FormatBancaire("", 42);
    // Zone réservée (31 caractères)
    // On vérifie l'intégrité de la chaîne
    if (strlen($ligne) != LONGUEUR_ENREGISTREMENT) {
        $nb_erreurs++;
        $erreurs_details .= " - La dernière ligne \"Total\" contient " . strlen($ligne) . " caractères au lieu de " . LONGUEUR_ENREGISTREMENT . ". La remise d'ordres de virement ne peut être poursuivie.<br />";
    }
    // On complète la chaîne totale
    $chaine_totale .= $ligne . "\n";
    if ($nb_erreurs > 0) {
        // Des erreurs bloquantes ont été detectées
        ?>
<div class="mess_err">
<?php 
        echo $nb_erreurs;
        ?>
 erreur(s) bloquante(s) détectée(s) pour la génération du fichier de remise :<br />
<?php 
        echo $erreurs_details;
        ?>
<br />
Remise d'ordre de virement abandonnée <!-- ' -->
</div>
<br /><br />
<?php 
        return false;
    }
    $myFile = sys_get_temp_dir() . "/cfonb-{$debit_id}.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $chaine_totale);
    fclose($fh);
    return $myFile;
}
Exemplo n.º 11
0
    die;
}
if ($action == "send") {
    extract($_POST);
    require "/usr/share/php/libphp-phpmailer/class.phpmailer.php";
    $mail_addresses = explode(',', $mails2);
    $mails = array_merge($mail_addresses, $mails);
    if (count($mails) > 0) {
        //récupérer les info sur la société
        $result = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1") or wf_mysqldie();
        list($value) = mysql_fetch_array($result);
        mysql_free_result($result);
        $societe = unserialize(base64_decode($value));
        //récupération des infos sur la facture
        $Facture = new Facture();
        $invoice = $Facture->getInfos($id);
        //compléter l'entête de l'email
        $mail = new PHPMailer();
        if (preg_match('/^[A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-Za-z]{2,4}$/', $from)) {
            $mail->From = $from;
        } else {
            $mail->From = $societe->email;
        }
        $mail->FromName = $from_name;
        foreach ($mails as $address) {
            $mail->AddAddress($address);
        }
        $mail->Subject = stripslashes(utf8_decode($subject));
        $mail->Body = stripslashes(utf8_decode($body));
        $mail->WordWrap = 80;
        //générer la facture en pdf
Exemplo n.º 12
0
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Webfinance; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
include "../inc/main.php";
if (!is_numeric($_GET['id_facture'])) {
    $Facture = new Facture();
    $invoice = array('client_id' => $_GET['id_client'], 'rows' => array());
    $id_facture = $Facture->create($invoice);
    header("Location: edit_facture.php?id_facture=" . $id_facture);
    die;
}
$Facture = new Facture();
$facture = $Facture->getInfos($_GET['id_facture']);
list($currency, $exchange) = getCurrency($facture->id_compte);
$title = $facture->nom_client;
$roles = 'manager,employee,accounting';
include "../top.php";
include "nav.php";
?>

<script type="text/javascript" language="javascript"
  src="/js/ask_confirmation.js"></script>

<script type="text/javascript">
<?php 
$lignes = 'var id_lignes = new Array(\'new\', ';
foreach ($facture->lignes as $l) {
    $lignes .= $l->id_facture_ligne . ", ";
Exemplo n.º 13
0
    echo "Missing arguments";
    exit;
}
if (!is_numeric($id_client) or !is_numeric($id_invoice)) {
    echo "Wrong arguments";
    exit;
}
$Client = new Client();
# check client and invoice
if (!$Client->exists($id_client)) {
    echo _("This client doesn't exist");
    exit;
}
$Invoice = new Facture();
if ($Invoice->exists($id_invoice)) {
    $inv = $Invoice->getInfos($id_invoice);
    if ($inv->id_client != $id_client) {
        echo _("This invoice isn't yours!");
        exit;
    }
    if ($inv->is_paye > 0) {
        echo _("This invoice is already paid.");
        exit;
    }
    $Client = new Client($id_client);
}
//insert the transation in the db
$ref_cmd = "WEBFINANCE;" . random_int(10);
$r = mysql_query("INSERT INTO webfinance_payment SET id_invoice={$inv->id_facture}, " . "email='" . $Client->email . "' , " . "reference='" . $ref_cmd . "' , " . "state='pending', " . "amount='{$inv->nice_total_ttc}' , " . "currency='EUR' , " . "id_payment_type='" . $paypal_params['id_payment_type'] . "' , " . "date=NOW() ") or die('212' . mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Exemplo n.º 14
0
 function SendPaymentRequest($id_invoice, $mode = 'paypal')
 {
     $Invoice = new Facture();
     $invoice = $Invoice->getInfos($id_invoice);
     $client = new Client($invoice->id_client);
     $societe = GetCompanyInfo();
     $q = "SELECT value FROM webfinance_pref WHERE type_pref='mail_paypal_" . $invoice->language . "'";
     $result = mysql_query($q) or die(mysql_error());
     list($data) = mysql_fetch_array($result);
     $pref = unserialize(base64_decode($data));
     $varlink = $id_invoice . '|' . $invoice->id_client;
     $converter = new Encryption();
     $encoded_varlink = $converter->encode($varlink);
     $link = $societe->wf_url . "/payment/?id={$encoded_varlink}";
     $mails = array();
     $from = '';
     $fromname = '';
     $subject = '';
     $patterns = array('/%%NUM_INVOICE%%/', '/%%CLIENT_NAME%%/', '/%%URL_PAYPAL%%/', '/%%AMOUNT%%/', '/%%COMPANY%%/');
     $replacements = array($invoice->num_facture, $invoice->nom_client, $link, $invoice->nice_total_ttc, $societe->raison_sociale);
     $body = stripslashes(preg_replace($patterns, $replacements, stripslashes(utf8_decode($pref->body))));
     if (!$Invoice->sendByEmail($id_invoice, $mails, $from, $fromname, $subject, $body)) {
         die(_('Invoice was not sent'));
     }
     return $link;
 }
Exemplo n.º 15
0
    $text = trim($_GET['text']);
    $where_clause .= " AND ( reference RLIKE '{$text}' " . "OR autorisation RLIKE '{$text}' " . "OR amount RLIKE '{$text}' " . "OR email RLIKE '{$text}' ) ";
}
// if (isset($_GET['state']) AND $_GET['state']!="") {
//   $state=$_GET['state'];
//   $where_clause .= " AND state='$state' ";
// }
$where_clause = preg_replace('/^\\ AND/', ' WHERE ', $where_clause);
$q = "SELECT id_paybox, id_invoice, email, reference, state, amount, currency , " . "autorisation, transaction_id as trans, payment_type, card_type, transaction_sole_id, error_code, date, UNIX_TIMESTAMP(date) as ts_date  " . "FROM webfinance_paybox {$where_clause} ORDER BY date DESC";
$trs = mysql_query($q) or wf_mysqldie();
$count = 1;
$Invoice = new Facture();
while ($tr = mysql_fetch_object($trs)) {
    $class = $count % 2 ? "row_odd" : "row_even";
    //invoice description
    $facture = $Invoice->getInfos($tr->id_invoice);
    list($currency, $exchange) = getCurrency($facture->id_compte);
    // Récupération du texte des lignes facturées pour afficher en infobulle.
    $description = "<b>" . strftime('%x', $facture->timestamp_date_facture) . "</b><br/>";
    foreach ($facture->lignes as $l) {
        $l->description = preg_replace("/\r\n/", " ", $l->description);
        $l->description = preg_replace("/\"/", "", $l->description);
        $l->description = preg_replace("/\\'/", "", $l->description);
        $description .= $l->description . "<br/>";
    }
    //s�parer les mois
    $current_month = ucfirst(strftime("%B %Y", $tr->ts_date));
    $current_month = utf8_encode($current_month);
    if (!empty($prev_date)) {
        if (date("m", $prev_date) != date("m", $tr->ts_date)) {
            echo "<tr class=\"row_even\"><td colspan='8' align='center'><b>" . $current_month . "</b></td></tr>";
Exemplo n.º 16
0
	<table border="0" cellspacing="0" cellpadding="10" class="framed">
		
	<?php 
    if ($_GET['popup'] == 'devis_ip') {
        ?>
		<tr class="row_header" style="text-align: center;">
			<td>N devis</td>
			<td>Date de création</td>
			<td>Client</td>
			<td>Amount</td>
		</tr>
		<?php 
        $Facture = new Facture();
        $result = mysql_query($req3c) or die("QUERY ERROR: {$q} " . mysql_error());
        while ($row = mysql_fetch_object($result)) {
            $info_facture = $Facture->getInfos($row->id_facture);
            ?>
	
		<tr>
			<td><a href="/prospection/edit_facture.php?id_facture=<?php 
            echo $row->id_facture;
            ?>
">DE<?php 
            echo $row->num_facture;
            ?>
</a></td>
			<td><?php 
            echo $row->date_created;
            ?>
</td>
			<td><a href="/prospection/fiche_prospect.php?onglet=contacts&id=<?php