* Newsletter:
- Displays number of subscribers without any valid redirection -JAC
+ - Provides statistics about subscribers -JAC
* Search:
- Switches autocomplete to jQuery UI -JAC
/** Get the count of subscribers to the NL.
* @return Number of subscribers.
*/
- public function subscriberCount()
+ public function subscriberCount($lost = null, $sex = null, $grade = null, $first_promo = null, $last_promo = null)
{
- $uf = new UserFilter(new UFC_NLSubscribed($this->id));
+ $cond = new PFC_And(new UFC_NLSubscribed($this->id));
+ if (!is_null($sex)) {
+ $cond->addChild(new UFC_Sex($sex));
+ }
+ if (!is_null($grade)) {
+ $cond->addChild(new UFC_Promo('>=', $grade, $first_promo));
+ $cond->addChild(new UFC_Promo('<=', $grade, $last_promo));
+ }
+ if (!($lost === null)) {
+ if ($lost === true) {
+ $cond->addChild(new PFC_Not(new UFC_HasEmailRedirect()));
+ } else {
+ $cond->addChild(new UFC_HasEmailRedirect());
+ }
+ }
+ $uf = new UserFilter($cond);
return $uf->getTotalCount();
}
/** Get the count of subscribers with non valid redirection.
*/
- public function lostSubscriberCount()
+ public function lostSubscriberCount($sex = null)
{
- $uf = new UserFilter(new PFC_And(new UFC_NLSubscribed($this->id), new PFC_Not(new UFC_HasEmailRedirect())));
- return $uf->getTotalCount();
+ return $this->subscriberCount(true, $sex);
}
/** Get the number of subscribers to the NL whose last received mailing was $last.
$page->setTitle('Statistiques - Newsletter');
$page->changeTpl('newsletter/statistics.tpl');
+
+ $data = array();
+ foreach (Profile::$cycles as $grade => $name) {
+ $data[$name] = array();
+ list($min, $max) = Profile::extremePromotions($grade);
+ $bound = (((int)($min / 10)) + 1) * 10;
+ while ($bound <= $max) {
+ $data[$name][$min . ' - ' . $bound] = array(
+ 'count' => $nl->subscriberCount(null, null, $grade, $min, $bound),
+ 'lost' => $nl->subscriberCount(true, null, $grade, $min, $bound),
+ 'count_female' => $nl->subscriberCount(null, User::GENDER_FEMALE, $grade, $min, $bound),
+ 'lost_female' => $nl->subscriberCount(true, User::GENDER_FEMALE, $grade, $min, $bound)
+ );
+ $min = $bound + 1;
+ $bound += 10;
+ }
+ $bound -= 9;
+ if ($bound <= $max) {
+ $data[$name][$bound . ' - ' . $max] = array(
+ 'count' => $nl->subscriberCount(null, null, $grade, $bound, $max),
+ 'lost' => $nl->subscriberCount(true, null, $grade, $bound, $max),
+ 'count_female' => $nl->subscriberCount(null, User::GENDER_FEMALE, $grade, $bound, $max),
+ 'lost_female' => $nl->subscriberCount(true, User::GENDER_FEMALE, $grade, $bound, $max)
+ );
+ }
+ }
$page->assign_by_ref('nl', $nl);
+ $page->assign('count', $nl->subscriberCount());
+ $page->assign('lost', $nl->lostSubscriberCount());
+ $page->assign('count_female', $nl->subscriberCount(null, User::GENDER_FEMALE));
+ $page->assign('lost_female', $nl->lostSubscriberCount(User::GENDER_FEMALE));
+ $page->assign('data', $data);
}
}
{include file="newsletter/header.tpl" current="stats"}
-<p>Il y a actuellement {$nl->subscriberCount()} inscrits aux envois, parmi lesquels {$nl->lostSubscriberCount()} n'ont aucune redirection active.</p>
-
+<p>
+ Il y a actuellement {$count} inscrits aux envois, parmi lesquels {$lost} n'ont aucune redirection active.
+ En particulier, il y a {$count_female} femmes, parmi lesquelles {$lost_female} n'ont aucune redirection active.
+</p>
+<table class="bicol">
+{foreach from=$data item=education key=cycle}
+ <tr>
+ <th colspan="3">Cycle {$cycle}</th>
+ </tr>
+ <tr>
+ <td class="titre">Décade</td>
+ <td class="titre">Total (dont perdus)</td>
+ <td class="titre">Femmes (dont perdues)</td>
+ </tr>
+ {foreach from=$education item=counts key=period}
+ <tr>
+ <td>{$period}</td>
+ <td>{$counts.count} ({$counts.lost})</td>
+ <td>{$counts.count_female} ({$counts.lost_female})</td>
+ </tr>
+ {/foreach}
+{/foreach}
+</table>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}