Example #1
0
/**
 * Generer un ticket resume de la transaction
 * pour les admins indiques dans la configuration
 * 
 * @param int $id_transaction
 * @param string $sujet
 */
function inc_bank_editer_ticket_admin_dist($id_transaction, $sujet = "Transaction OK")
{
    // il faut avoir configure un ou des emails de notification
    $c = unserialize($GLOBALS['meta']['bank_paiement']);
    if (!isset($c['email_ticket_admin']) or !strlen($email = $c['email_ticket_admin'])) {
        spip_log(var_export($GLOBALS['meta']['bank_paiement'], true), 'bank_ticket');
        return;
    }
    $ticket = "";
    if ($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction))) {
        $montant = $row['montant_regle'];
        $ticket .= "<h2>Transaction {$id_transaction}</h2>\n<table border='1'>";
        foreach ($row as $k => $v) {
            $ticket .= "<tr><td>{$k}</td><td>{$v}</td></tr>";
        }
        $ticket .= "</table>";
    }
    // ensuite un pipeline pour editer le ticket
    $ticket = pipeline('bank_editer_ticket_reglement', array('args' => array('id_transaction' => $id_transaction), 'data' => $ticket));
    $ticket = "<html>{$ticket}</html>";
    $header = "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=" . $GLOBALS['meta']['charset'] . "\n" . "Content-Transfer-Encoding: 8bit\n";
    $sujet = "{$sujet} #{$id_transaction} [" . affiche_monnaie($montant) . "]";
    if (!isset($c['email_from_ticket_admin']) or !strlen($email_from = $c['email_from_ticket_admin'])) {
        $url = parse_url($GLOBALS['meta']['adresse_site']);
        $email_from = "reglements@" . ltrim($url['host'], 'w.');
    }
    $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
    $envoyer_mail($email, $sujet, $ticket, $email_from, $header);
}
function souscription_campagne_historique_encaissements($id_campagne)
{
    $rows = sql_allfetsel("sum(T.montant_ht) as montant_mensuel_ht,sum(T.montant) as montant_mensuel,T.date_paiement", "spip_transactions AS T\n\t\t\tJOIN spip_souscriptions_liens AS L ON (L.objet='transaction' AND L.id_objet=T.id_transaction)\n\t\t\tJOIN spip_souscriptions AS S ON S.id_souscription=L.id_souscription", "T.statut='ok' AND S.id_souscription_campagne=" . intval($id_campagne), "month(T.date_paiement)", "T.date_paiement DESC");
    $out = "";
    foreach ($rows as $row) {
        $mois = affdate_mois_annee($row['date_paiement']);
        $montant = affiche_monnaie($row['montant_mensuel']);
        $montant_ht = affiche_monnaie($row['montant_mensuel_ht']);
        $out .= "<tr><td>{$mois}</td><td class='numeric'>{$montant_ht}</td><td class='numeric'>{$montant}</td></tr>\n";
    }
    $out = "<table class='spip'>\n<thead><tr class='row_first'><th>Mois</th><th class='numeric'>Montant HT</th><th class='numeric'>Montant</th></td></thead>\n<tbody>{$out}</tbody></table>";
    return $out;
}
Example #3
0
function genie_bank_daily_reporting_dist($t)
{
    // entre minuit et 7h du matin
    $now = time();
    if (intval(date('H', $now)) >= 1 and intval(date('H', $now)) <= 7) {
        // il faut avoir configure un ou des emails de notification
        $c = unserialize($GLOBALS['meta']['bank_paiement']);
        if (isset($c['email_reporting']) and strlen($email = $c['email_reporting'])) {
            include_spip('inc/filtres');
            $texte = "";
            // le nombre et le montant des transactions par jour sur les 15 derniers jours
            $j = date('Y-m-d 00:00:00', $now);
            $jm15 = date('Y-m-d 00:00:00', strtotime("-15 day", $now));
            $jours = sql_allfetsel('date_paiement,sum(montant_ht) as total_ht,sum(montant) as total,count(id_transaction) as nb', 'spip_transactions', 'statut=' . sql_quote('ok') . ' AND date_paiement>=' . sql_quote($jm15) . ' AND date_paiement<' . sql_quote($j), 'DAYOFMONTH(date_paiement)', 'date_paiement DESC');
            $lignes = "";
            foreach ($jours as $jour) {
                if ($jour['date_paiement'] > date('Y-m-d 00:00:00', strtotime("-1 day", $now))) {
                    $texte .= "<h2>" . affdate($jour['date_paiement']) . "</h2>\n" . $jour['nb'] . " Paiements OK <br />\nTotal HT : <b>" . affiche_monnaie($jour['total_ht']) . "</b><br />\nTotal TTC : <b>" . affiche_monnaie($jour['total']) . "</b><br />\n";
                }
                $lignes .= "<tr><td>" . affdate($jour['date_paiement']) . "</td><td>" . $jour['nb'] . "</td><td>" . affiche_monnaie($jour['total_ht']) . "</td><td>" . affiche_monnaie($jour['total']) . "</td></tr>\n";
            }
            $texte .= "<h2>Paiements 15 derniers jours</h2>\n<table class='spip'>\n<tr><th>Jour</th><th>Nb</th><th>Total HT</th><th>Total TTC</th></tr>\n{$lignes}\n</table>";
            $jm365 = date('Y-m-01 00:00:00', strtotime("-13 month", $now));
            $mois = sql_allfetsel('date_paiement,sum(montant_ht) as total_ht,sum(montant) as total,count(id_transaction) as nb', 'spip_transactions', 'statut=' . sql_quote('ok') . ' AND date_paiement>=' . sql_quote($jm365), "DATE_FORMAT(date_paiement,'%Y-%m')", 'date_paiement DESC');
            $lignes = "";
            foreach ($mois as $moi) {
                $lignes .= "<tr><td>" . affdate_mois_annee($moi['date_paiement']) . "</td><td>" . $moi['nb'] . "</td><td>" . affiche_monnaie($moi['total_ht']) . "</td><td>" . affiche_monnaie($moi['total']) . "</td></tr>\n";
            }
            $texte .= "<h2>Paiements 12 derniers mois</h2>\n<table class='spip'>\n<tr><th>Mois</th><th>Nb</th><th>Total HT</th><th>Total TTC</th></tr>\n{$lignes}\n</table>";
            $texte = "<html>{$texte}</html>";
            $header = "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=" . $GLOBALS['meta']['charset'] . "\n" . "Content-Transfer-Encoding: 8bit\n";
            $sujet = "[" . $GLOBALS['meta']['nom_site'] . "] Reporting Paiements";
            $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
            $envoyer_mail($email, $sujet, $texte, '', $header);
            spip_log("Envoi reporting quotidien", 'bank');
        }
    }
    return 1;
}
Example #4
0
File: bank.php Project: nursit/bank
/**
 * Jamais appele directement dans le plugin bank/
 * mais par une eventuelle methode abos/resilier d'un plugin externe
 * c'est une fallback quand le presta ne sait pas gerer le desabonnement en appel serveur
 * ou quand cela echoue
 *
 * @param string $uid
 * @param array|string $config
 * @return bool
 */
function bank_simple_call_resilier_abonnement($uid, $config)
{
    include_spip('inc/bank');
    if (!is_array($config)) {
        $mode = sql_getfetsel("mode", "spip_transactions", "abo_uid=" . sql_quote($uid) . " AND statut=" . sql_quote('ok') . " AND mode LIKE " . sql_quote($config . '%'));
        $config = bank_config($mode);
    }
    // on envoie un mail au webmestre avec reference pour que le webmestre aille faire la resiliation manuellement
    $sujet = "[" . $GLOBALS['meta']['nom_site'] . "] Demande Resiliation Abonnement " . $config['presta'];
    $message = "Abonne UID : {$uid}\nTransactions :\n";
    $trans = sql_allfetsel("id_transaction,date_paiement,montant", "spip_transactions", "abo_uid=" . sql_quote($uid) . " AND statut=" . sql_quote('ok') . " AND mode LIKE " . sql_quote($config['presta'] . '%'));
    foreach ($trans as $tran) {
        $message .= "#" . $tran['id_transaction'] . " " . $tran['date_paiement'] . " " . affiche_monnaie($tran['montant']) . "\n";
    }
    $envoyer_mail = charger_fonction("envoyer_mail", "inc");
    $envoyer_mail($GLOBALS['meta']['email_webmaster'], $sujet, $message);
    return false;
}