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;
}
Beispiel #2
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;
}
Beispiel #3
0
function statistiques_par_mois($entrees, $script){

	$maxgraph = maxgraph(max($entrees));
	$rapport = 200/$maxgraph;
	$largeur = floor(420 / (count($entrees)));
	if ($largeur < 1) $largeur = 1;
	if ($largeur > 50) $largeur = 50;
	$decal = 0;
	$tab_moyenne = array();

	$all = '';

	foreach($entrees as $key=>$value) {
		$key = substr($key,0,4).'-'.substr($key,4,2);
		$mois = affdate_mois_annee($key);
		if ($decal == 30) $decal = 0;
		$decal ++;
		$tab_moyenne[$decal] = $value;
		$moyenne = statistiques_moyenne($tab_moyenne);
		$hauteur_moyenne = round($moyenne * $rapport) - 1;
		$hauteur = round($value * $rapport) - 1;
		$res = '';
		$title= attribut_html(supprimer_tags("$mois | "
			._T('info_total')." ".$value));
		$tagtitle = $script ? '' : $title;
		if ($hauteur > 0){
			if ($hauteur_moyenne > $hauteur) {
				$difference = ($hauteur_moyenne - $hauteur) -1;
				$res .= http_img_rien($largeur, 1, 'trait_moyen');
				$res .= http_img_rien($largeur, $difference, '', $tagtitle);
				$res .= http_img_rien($largeur,1,"trait_haut");
				if (preg_match(",-01,",$key)){ // janvier en couleur foncee
					$res .= http_img_rien($largeur,$hauteur,"couleur_janvier", $tagtitle);
				} else {
					$res .= http_img_rien($largeur,$hauteur,"couleur_mois", $tagtitle);
				}
			}
			else if ($hauteur_moyenne < $hauteur) {
				$difference = ($hauteur - $hauteur_moyenne) -1;
				$res .= http_img_rien($largeur,1,"trait_haut", $tagtitle);
				if (preg_match(",-01,",$key)){ // janvier en couleur foncee
						$couleur =  'couleur_janvier';
				} else {
						$couleur = 'couleur_mois';
				}
				$res .= http_img_rien($largeur,$difference, $couleur, $tagtitle);
				$res .= http_img_rien($largeur,1,'trait_moyen',$tagtitle);
				$res .= http_img_rien($largeur,$hauteur_moyenne, $couleur, $tagtitle);
			} else {
				$res .= http_img_rien($largeur,1,"trait_haut", $tagtitle);
				if (preg_match(",-01,",$key)){ // janvier en couleur foncee
					$res .= http_img_rien($largeur, $hauteur, "couleur_janvier", $tagtitle);
				} else {
					$res .= http_img_rien($largeur,$hauteur, "couleur_mois", $tagtitle);
				}
			}
		}
		$res .= http_img_rien($largeur,1,'trait_bas', $tagtitle);

		if (!$script) {
			$y = annee($key);
			$m = mois($key);
			$href = generer_url_ecrire('calendrier', "type=mois&annee=$y&mois=$m&jour=1");
		} else $href = "$script&amp;date=$key";

		$all .= "\n<td style='width: ${largeur}px'><a href='"
		.  $href
		. '\' title="'
		. $title
		. '">'
		. $res
		. "</a></td>\n";
	}

	return
	  "\n<table cellpadding='0' cellspacing='0' border='0'><tr>"
	.  "\n<td ".http_style_background("fond-stats.gif").">"
	. "\n<table cellpadding='0' cellspacing='0' border='0' class='bottom'><tr>"
	. "\n<td class='trait_bas'>" . http_img_rien(1, 200) ."</td>"
	.  $all
	. "\n<td style='background-color: black'>" . http_img_rien(1, 1)
	. "</td>"
	. "</tr></table></td>"
	. "\n<td ".http_style_background("fond-stats.gif")." valign='bottom'>"
	. http_img_rien(3, 1, 'trait_bas') ."</td>"
	. "\n<td>" . http_img_rien(5, 1) ."</td>"
	. "\n<td valign='top'>"
	. statistiques_echelle($maxgraph)
	. "</td></tr></table>";
 }
Beispiel #4
0
function http_calendrier_agenda ($annee, $mois, $jour_ved, $mois_ved, $annee_ved, $semaine = false,  $script='', $ancre='', $evt='') {

  if (!$script) $script =  $GLOBALS['PHP_SELF'] ;

  if (!$mois) {$mois = 12; $annee--;}
  elseif ($mois==13) {$mois = 1; $annee++;}
  if (!$evt) $evt = quete_calendrier_agenda($annee, $mois);
  $nom = affdate_mois_annee("$annee-$mois-1");
  return 
    "<div class='calendrier-titre calendrier-arial10'>" .
    calendrier_href($script, $annee, $mois, 1, 'mois', '', $ancre,'', $nom,'','',    $nom,'color: black;') .
    "<table width='100%'>" .
    http_calendrier_agenda_rv ($annee, $mois, $evt,				
			        'calendrier_href', $script, $ancre,
			        $jour_ved, $mois_ved, $annee_ved, 
				$semaine) . 
    "</table>" .
    "</div>";
}
Beispiel #5
0
function agenda($mois, $annee, $jour_ved, $mois_ved, $annee_ved, $semaine = false)
{
    global $couleur_foncee, $couleur_claire;
    global $connect_id_auteur;
    global $spip_lang_left, $spip_lang_right;
    $today = getdate(time());
    $jour_today = $today["mday"];
    $mois_today = $today["mon"];
    $annee_today = $today["year"];
    $date = date("Y-m-d", mktime(0, 0, 0, $mois, 1, $annee));
    $mois = mois($date);
    $annee = annee($date);
    // rendez-vous personnels dans le mois
    $result_messages = spip_query("SELECT messages.* FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE ((lien.id_auteur='{$connect_id_auteur}' AND lien.id_message=messages.id_message) OR messages.type='affich') AND messages.rv='oui' AND messages.date_heure >='{$annee}-{$mois}-1' AND date_heure < DATE_ADD('{$annee}-{$mois}-1', INTERVAL 1 MONTH) AND messages.statut='publie' GROUP BY messages.id_message ORDER BY messages.date_heure");
    while ($row = spip_fetch_array($result_messages)) {
        $date_heure = $row["date_heure"];
        $lejour = journum($row['date_heure']);
        $les_rv[$lejour]++;
    }
    $nom = mktime(1, 1, 1, $mois, 1, $annee);
    $jour_semaine = date("w", $nom);
    $nom_mois = nom_mois('2000-' . sprintf("%02d", $mois) . '-01');
    if ($jour_semaine == 0) {
        $jour_semaine = 7;
    }
    if ($semaine) {
        $jour_valide = mktime(1, 1, 1, $mois_ved, $jour_ved, $annee_ved);
        $jour_semaine_valide = date("w", $jour_valide);
        if ($jour_semaine_valide == 0) {
            $jour_semaine_valide = 7;
        }
        $debut = mktime(1, 1, 1, $mois_ved, $jour_ved - $jour_semaine_valide + 1, $annee_ved);
        $fin = mktime(1, 1, 1, $mois_ved, $jour_ved - $jour_semaine_valide + 7, $annee_ved);
    }
    echo "<div align='center' style='padding: 5px;'><b class='verdana1'><a href='calendrier.php3?mois={$mois}&&annee={$annee}' style='color: black;'>" . affdate_mois_annee("{$annee}-{$mois}-1") . "</a></b></div>";
    echo "<table width='100%' cellspacing='0' cellpadding='0'>";
    echo "<tr>";
    for ($i = 1; $i < $jour_semaine; $i++) {
        echo "<td></td>";
    }
    for ($j = 1; $j < 32; $j++) {
        $jour_j = sprintf("%02d", $j);
        $nom = mktime(1, 1, 1, $mois, $jour_j, $annee);
        $jour_semaine = date("w", $nom);
        if ($jour_semaine == 0) {
            $jour_semaine = 7;
        }
        if (checkdate($mois, $j, $annee)) {
            if ($j == $jour_ved and $mois == $mois_ved and $annee == $annee_ved) {
                if ($semaine) {
                    $lien = "calendrier_jour.php3";
                } else {
                    $lien = "calendrier_semaine.php3";
                }
                echo "<td class='arial2' style='margin: 1px; padding: 2px; background-color: white; border: 1px solid {$couleur_foncee}; text-align: center; -moz-border-radius: 5px;'>";
                echo "<a href='{$lien}?jour={$j}&mois={$mois}&annee={$annee}' style='color: black'><b>{$j}</b></a>";
                echo "</td>";
            } else {
                if ($semaine and $nom >= $debut and $nom <= $fin) {
                    if ($jour_semaine == 1) {
                        $style = "-moz-border-radius-top{$spip_lang_left}: 10px; -moz-border-radius-bottom{$spip_lang_left}: 10px;";
                    } else {
                        if ($jour_semaine == 7) {
                            $style = "-moz-border-radius-top{$spip_lang_right}: 10px; -moz-border-radius-bottom{$spip_lang_right}: 10px;";
                        } else {
                            $style = "";
                        }
                    }
                    echo "<td class='arial2' style='margin: 0px; padding: 3px; background-color: white; text-align: center; {$style}'>";
                    echo "<a href='calendrier_semaine.php3?jour={$j}&mois={$mois}&annee={$annee}' style='color: black'><b>{$j}</b></a>";
                    echo "</td>";
                } else {
                    if ($j == $jour_today and $mois == $mois_today and $annee == $annee_today) {
                        $couleur_fond = $couleur_foncee;
                        $couleur = "white";
                    } else {
                        if ($jour_semaine == 7) {
                            $couleur_fond = "#aaaaaa";
                            $couleur = "white";
                        } else {
                            $couleur_fond = "#ffffff";
                            $couleur = "#aaaaaa";
                        }
                        if ($les_rv[$j] > 0) {
                            $couleur = "black";
                        }
                    }
                    echo "<td>";
                    echo "<div class='arial2' style='margin-left: 1px; margin-top: 1px; padding: 2px; background-color: {$couleur_fond}; text-align: center; -moz-border-radius: 5px;'>";
                    if ($semaine) {
                        echo "<a href='calendrier_semaine.php3?jour={$j}&mois={$mois}&annee={$annee}' style='color: {$couleur};'>{$j}</a>";
                    } else {
                        echo "<a href='calendrier_jour.php3?jour={$j}&mois={$mois}&annee={$annee}' style='color: {$couleur};'>{$j}</a>";
                    }
                    echo "</div>";
                    echo "</td>";
                }
            }
            if ($jour_semaine == 7) {
                echo "</tr>\n<tr>";
            }
        }
    }
    echo "</tr>\n";
    echo "</table>";
}
/**
 * Afficher la periode de l'agenda :
 * Le nom du mois si nb_mois = 1
 * L'annee si nb_mois=12 et debut du mois = janvier
 * sinon : mois annee - mois annee (xxx 12 - yyy 13)
 * si le debut de la periode est fixe (debut d'un mois donnee), on precede de
 * "Annee" ou "Saison" la periode
 *
 * @param string $date
 * @param int $nb_mois
 * @param string $affichage_debut
 * @return string
 */
function affdate_periode($date, $nb_mois, $affichage_debut = 'date_jour')
{
    $fixe = in_array($affichage_debut, array('debut_mois_1', 'debut_mois_2', 'debut_mois_3', 'debut_mois_4', 'debut_mois_5', 'debut_mois_6', 'debut_mois_7', 'debut_mois_8', 'debut_mois_9', 'debut_mois_10', 'debut_mois_11', 'debut_mois_12'));
    if ($nb_mois == 1) {
        return affdate_mois_annee($date);
    }
    if ($nb_mois == 12 and mois($date) == 1) {
        return ($fixe ? _T('agenda:label_annee') . ' ' : '') . annee($date);
    }
    return ($fixe ? _T('agenda:label_periode_saison') . ' ' : '') . affdate_mois_annee($date) . " - " . affdate_mois_annee(agenda_moisdecal($date, $nb_mois - 1));
}
Beispiel #7
0
function http_calendrier_agenda($month, $year, $day_ved, $month_ved, $annee_ved, $week = false, $script = '', $target = '')
{
    if (!$script) {
        $script = $_ENV['PHP_SELF'];
    }
    if (!strpos($script, '?')) {
        $script .= '?';
    }
    if (!$month) {
        $month = 12;
        $year--;
    } elseif ($month == 13) {
        $month = 1;
        $year++;
    }
    return "\n<!-- http_calendrier_agenda -->\n" . "<div style='width: 100%; text-align: center; padding: 2px; font-size: 10px;'>" . "<div style='padding-bottom: 5px;'>" . http_href($script . "mois={$month}&annee={$year}{$target}", affdate_mois_annee("{$year}-{$month}-1"), '', 'color: black;') . "</div>\n" . http_calendrier_agenda_rv($year, $month, sql_calendrier_agenda($month, $year), 'http_jour_clic', array($script, $target), $day_ved, $month_ved, $annee_ved, $week) . "</div>\n";
}