add actions and templates folder
This commit is contained in:
parent
8c772864b3
commit
934de3ad61
10 changed files with 792 additions and 0 deletions
79
actions/MailAnnuaireAction.php
Normal file
79
actions/MailAnnuaireAction.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
use YesWiki\Core\YesWikiAction;
|
||||
use YesWiki\Bazar\Service\EntryManager;
|
||||
|
||||
include_once('includes/email.inc.php');
|
||||
|
||||
class MailAnnuaireAction extends YesWikiAction
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$output = '';
|
||||
if ($this->wiki->userIsAdmin()) {
|
||||
$entryManager = $this->getService(EntryManager::class);
|
||||
$peoples = [];
|
||||
// get all users
|
||||
$res = $entryManager->search([
|
||||
'queries' => '', // Sélection par clé-valeur
|
||||
'formsIds' => [57,15,54,18,60], // Types de fiches (par ID de formulaire)
|
||||
'user' => '', // N'affiche que les fiches d'un utilisateur
|
||||
'keywords' => '', // Mots-clés pour la recherche fulltext
|
||||
'searchOperator' => 'OR', // Opérateur à appliquer aux mots-clés
|
||||
'minDate' => '', // Date minimale des fiches
|
||||
'correspondance' => ''
|
||||
]);
|
||||
foreach ($res as $k => $r) {
|
||||
if (empty($r['yunohost_username'])) {
|
||||
$peoples[$k] = [
|
||||
'bf_titre' => $r['bf_titre'],
|
||||
'id_fiche' => $r['id_fiche'],
|
||||
'yunohost_username' => $r['yunohost_username'] ?? '',
|
||||
'bf_mail' => $r['bf_mail']
|
||||
];
|
||||
}
|
||||
}
|
||||
$output .= 'Total de personnes ayant a créer ses identifiants : ' . count($peoples) . '<br />';
|
||||
|
||||
// format the mail
|
||||
$subject = '[Réseau Smart Academy] RAPPEL : mettez à jour votre fiche annuaire pour créer votre identifiant unique';
|
||||
$from = 'support@apps.reseau.s-mart.fr';
|
||||
$fromname = 'Réseau Smart Academy';
|
||||
$to = '';
|
||||
$messageend = '
|
||||
Saisissez les champs manquants demandés dans le formulaire et sauvegardez, vous recevrez un mail de confirmation.
|
||||
|
||||
Ensuite, vous devrez vous connecter une première fois seulement sur les espaces Réseau Smart Academy puis vous serez identifié.es pour une durée de 3 mois (sauf suppression des cookies). Pour le forum, toujours avec ces mêmes identifiants, il sera demandé à la première connexion de créer un pseudo pour ce forum, c\'est l\'ultime action à effectuer pour ensuite être tranquille !
|
||||
|
||||
Pour toute incompréhension ou difficulté technique, n\'hésitez pas à nous contacter par le formulaire de contact du site sur https://reseau.s-mart.fr/?FormulaireContact .
|
||||
|
||||
Merci de faire cette modification au plus vite, sans quoi vous ne pourrez pas interagir sur S.mart Academy.
|
||||
|
||||
Au plaisir vous retrouver prochainement sur la plateforme !
|
||||
|
||||
Lionel Roucoules, Directeur du Réseau Smart Academy';
|
||||
foreach ($peoples as $k => $fiche) {
|
||||
$to = $fiche['bf_mail'] ?? '';
|
||||
$message = 'Bonjour,' . PHP_EOL . PHP_EOL .
|
||||
|
||||
'La plateforme Réseau Smart Academy évolue et propose maintenant un identifiant unique pour vous connecter au réseau central, à votre communauté (Doctorants, Fabadd-Académie, Ingénieurs techniciens, Sciences humaines et sociales), ainsi qu\'au forum.' . PHP_EOL . PHP_EOL .
|
||||
|
||||
'Pour créer votre identifiant et le mot de passe de votre choix, rendez-vous sur votre fiche :' . PHP_EOL . PHP_EOL .
|
||||
$GLOBALS['wiki']->href('edit', $fiche['id_fiche']);
|
||||
|
||||
$message .= PHP_EOL . $messageend;
|
||||
$output .= '<h2>' . $subject . '</h2>';
|
||||
$output .= '<em>Pour ' . $to . '</em> - <a href="' . $GLOBALS['wiki']->href('', '', 'sendmail=' . $k) . '">Envoyer le mail</a><br /><br />';
|
||||
$output .= nl2br($message);
|
||||
$output .= '<hr />';
|
||||
if (!empty($_GET['sendmail']) && ($_GET['sendmail'] == $k || $_GET['sendmail'] == 'all')) {
|
||||
send_mail($from, $fromname, $to, $subject, $message, nl2br($message));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$output .= 'Faut etre admin';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
427
actions/StatsAction.php
Normal file
427
actions/StatsAction.php
Normal file
|
@ -0,0 +1,427 @@
|
|||
<?php
|
||||
/**
|
||||
* Stats generator for indicators
|
||||
*/
|
||||
|
||||
use YesWiki\Core\Service\DbService;
|
||||
use YesWiki\Core\YesWikiAction;
|
||||
use YesWiki\Bazar\Service\EntryManager;
|
||||
|
||||
class StatsAction extends YesWikiAction
|
||||
{
|
||||
protected $communities;
|
||||
protected $indicateurs;
|
||||
public function run()
|
||||
{
|
||||
if ($this->wiki->UserIsAdmin() || $this->wiki->UserIsInGroup('indicateurs')) {
|
||||
$period = $this->getGlobalPeriod();
|
||||
$this->communities = [
|
||||
'doctorants' => [
|
||||
'title'=> "Doctorants",
|
||||
'idcommu'=>'Doc',
|
||||
'indicators' => [],
|
||||
],
|
||||
'ecocloud' => [
|
||||
'title'=> "Ecocloud",
|
||||
'idcommu'=>'EcoC',
|
||||
'indicators' => [],
|
||||
],
|
||||
'ingetech' => [
|
||||
'title'=> "IngéTech",
|
||||
'idcommu'=>'IngeTech',
|
||||
'indicators' => [],
|
||||
],
|
||||
'shs' => [
|
||||
'title'=> "Sciences Humaines et Sociales",
|
||||
'idcommu'=>'SHS',
|
||||
'indicators' => [],
|
||||
],
|
||||
'fabadd' => [
|
||||
'title'=> "FabAdd-Académie",
|
||||
'idcommu'=>'FabAdd',
|
||||
'indicators' => [],
|
||||
],
|
||||
'reseaucentral' => [
|
||||
'title'=> "Réseau central",
|
||||
'idcommu'=>'ResC',
|
||||
'indicators' => [],
|
||||
]
|
||||
];
|
||||
$community = $this->wiki->GetParameter('community');
|
||||
// on vide les autres commus
|
||||
if (!empty($community) and in_array($community, array_keys($this->communities))) {
|
||||
$onlyCommunity = $this->communities[$community];
|
||||
$this->communities = [];
|
||||
$this->communities[$community] = $onlyCommunity;
|
||||
}
|
||||
$this->indicateurs = [
|
||||
'nb_annuaire' => [
|
||||
'name' => '👫🏻👩🏻🤝👩🏾👨🏾🤝👨🏽 Nombre d\'inscrits de l\'annuaire',
|
||||
'formsIds' => [60,18,54,15,57],
|
||||
'queries' => ['checkboxListeCommunautesbf_checkbox_inscription_commus' => '{idcommu}'],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_annuaire_ecocloud' => [
|
||||
'name' => '👫🏻👩🏻🤝👩🏾👨🏾🤝👨🏽 Nombre d\'inscrits de l\'annuaire du wiki Ecocloud',
|
||||
'url' => 'https://ecocloud.s-mart.fr/?api/forms/1/entries',
|
||||
'type' => 'bazarapi',
|
||||
'onlyfor' => 'ecocloud'
|
||||
],
|
||||
'nb_besoins_non-resolus' => [
|
||||
'name' => '🙏🏻 Nombre de besoins Non résolus déposés',
|
||||
'formsIds' => [51,53,22,58],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}',
|
||||
"listeListeEtatDuBesoinbesoin_etat" => "NR",
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_besoins_en-cours-resolution' => [
|
||||
'name' => '🙏🏻 Nombre de besoins En cours de résolution déposés',
|
||||
'formsIds' => [51,53,22,58],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}',
|
||||
"listeListeEtatDuBesoinbesoin_etat" => "ECR",
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_besoins_part-resolus' => [
|
||||
'name' => '🙏🏻 Nombre de besoins Partiellement résolus déposés',
|
||||
'formsIds' => [51,53,22,58],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}',
|
||||
"listeListeEtatDuBesoinbesoin_etat" => "PR",
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_besoins_resolus' => [
|
||||
'name' => '🙏🏻 Nombre de besoins résolus déposés',
|
||||
'formsIds' => [51,53,22,58],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}',
|
||||
"listeListeEtatDuBesoinbesoin_etat" => "R",
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_besoins_total' => [
|
||||
'name' => '🙏🏻 Nombre total de besoins déposés',
|
||||
'formsIds' => [51,53,22,58],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}',
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
|
||||
'nb_ressources_tech' => [
|
||||
'name' => '📚 Nombre de ressources Techno déposées',
|
||||
'formsIds' => [4,24,61,21,20,23,55],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}',
|
||||
'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Tech'
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_ressources_peda' => [
|
||||
'name' => '📚 Nombre de ressources Pédagogiques déposées',
|
||||
'formsIds' => [4,24,61,21,20,23,55],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}',
|
||||
'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Peda'
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_ressources_science' => [
|
||||
'name' => '📚 Nombre de ressources Scientifiques déposées',
|
||||
'formsIds' => [4,24,61,21,20,23,55],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}',
|
||||
'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Sci'
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_ressources_autres' => [
|
||||
'name' => '📚 Nombre de ressources autres déposées',
|
||||
'formsIds' => [4,24,61,21,20,23,55],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}',
|
||||
'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Other'
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_ressources_total' => [
|
||||
'name' => '📚 Nombre total de ressources déposées',
|
||||
'formsIds' => [4,24,61,21,20,23,55],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}',
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_agenda' => [
|
||||
'name' => '📆 Nombre total d\'événements déposés dans l\'agenda',
|
||||
'formsIds' => [2,59,17,13,56],
|
||||
'queries' => [
|
||||
'checkboxListeCommunautesbf_checkbox_evenement_commu' => '{idcommu}',
|
||||
],
|
||||
'type' => 'bazar'
|
||||
],
|
||||
'nb_amelioration_total' => [
|
||||
'name' => '🛠️ Nombre total d’améliorations du site déposées',
|
||||
'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries',
|
||||
'type' => 'bazarapi',
|
||||
'onlyfor' => 'doctorants'
|
||||
],
|
||||
'nb_amelioration_non_resolu' => [
|
||||
'name' => '🛠️ Nombre d’améliorations du site non-résolues',
|
||||
'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=U',
|
||||
'type' => 'bazarapi',
|
||||
'onlyfor' => 'doctorants'
|
||||
],
|
||||
'nb_amelioration_dev' => [
|
||||
'name' => '🛠️ Nombre d’améliorations du site "demander aux développeurs"',
|
||||
'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=AD',
|
||||
'type' => 'bazarapi',
|
||||
'onlyfor' => 'doctorants'
|
||||
],
|
||||
'nb_amelioration_resolu' => [
|
||||
'name' => '🛠️ Nombre d’améliorations du site résolus',
|
||||
'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=OK',
|
||||
'type' => 'bazarapi',
|
||||
'onlyfor' => 'doctorants'
|
||||
],
|
||||
'nb_contribs-page_total' => [
|
||||
'name' => '📝 Nombre de contributions aux pages',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {commuusers}',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_contribs-page_total' => [
|
||||
'name' => '📝 Nombre total de contributions aux pages',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_contribs-page_ariane' => [
|
||||
'name' => '📝 Nombre de contributions aux pages par le groupe Ariane',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {groupariane}',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_contribs-page_anim' => [
|
||||
'name' => '📝 Nombre de contributions aux pages par le groupe Animateurs',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {groupanim}',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_contribs-page_other' => [
|
||||
'name' => '📝 Nombre de contributions aux pages par d\'autres contributeurs',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user NOT IN {groupanim} AND user NOT IN {groupariane}',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_comments-total' => [
|
||||
'name' => '💬 Nombre total de commentaires',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_comments-ressources' => [
|
||||
'name' => '💬 Nombre de commentaires sur les ressources',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE comment_on != ""',
|
||||
'type' => 'sql',
|
||||
],
|
||||
//todo
|
||||
'nb_reactions-ressources-total' => [
|
||||
'name' => '📚 Nombre total de ressources qualifiées',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_reactions-ressources-relues' => [
|
||||
'name' => '📚 Nombre total de ressources relues',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_reactions-ressources-reutilisees' => [
|
||||
'name' => '📚 Nombre total de ressources réutilisées',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
'nb_reactions-meme-besoin' => [
|
||||
'name' => '🙏🏻 Nombre de "J\'ai le même besoin"',
|
||||
'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1',
|
||||
'type' => 'sql',
|
||||
],
|
||||
// - Nombre de téléchargements des ressources de cette communauté Se baser sur bf_checkbox_commu_ress + bf_fichier_ressource
|
||||
// - Nombre de vues de l'ensemble des ressources directement intégrées aux fiches ressources réaction « relue » Se baser sur bf_checkbox_commu_ress + nb de clics sur les fiches du formulaire ressource / communauté ET checkbox_besoin_commu + besoins/communauté
|
||||
// - Nombre de clics sur liens web des ressources Se baser sur bf_checkbox_commu_ress + bf_url_ressource
|
||||
// Commentaires - Sur améliorations du site Commentaires des fiches du formulaire 23 dans le wiki Doctorants
|
||||
// Partage et diffusion des ressources
|
||||
// - - Delta qualifiées/non qualifiées
|
||||
|
||||
// TODO :
|
||||
// finir les stats
|
||||
// modification par la commu des pages du wiki central
|
||||
// verifier si table des pages avec nb contrib nb commentaires et nb reactions
|
||||
// mettre les affichages par communautés
|
||||
// Emoji https://reseau.s-mart.fr/?RecupererLesLiensDesFluxRssDeMonChoixS
|
||||
// revoir les ecarts type mensuel
|
||||
|
||||
];
|
||||
|
||||
$period = [
|
||||
'deb'=> $_GET['datedeb'] ?? $period['deb'],
|
||||
'end' => $_GET['datefin'] ?? $period['end']
|
||||
];
|
||||
|
||||
foreach($this->communities as $k => $com) {
|
||||
foreach($this->indicateurs as $i => $ind) {
|
||||
if ($ind['type'] == 'bazar') {
|
||||
$this->calculateBazarIndicators($i, $k, $period);
|
||||
}
|
||||
if ($ind['type'] == 'bazarapi') {
|
||||
if ($ind['onlyfor'] == $k) {
|
||||
$this->calculateBazarApiIndicators($i, $k, $period);
|
||||
}
|
||||
}
|
||||
if ($ind['type'] == 'sql') {
|
||||
$this->calculateSqlIndicators($i, $k, $period);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$total = [];
|
||||
if (count($this->communities) > 1) {
|
||||
$total = $this->calculateTotal();
|
||||
}
|
||||
|
||||
return $this->render('@templates/tablestats.twig', [
|
||||
'indicateurs'=> $this->indicateurs,
|
||||
'communities'=> $this->communities,
|
||||
'period' => $period,
|
||||
'selecteddatedeb' => $_GET['datedeb'] ?? $period['deb'],
|
||||
'selecteddatefin' => $_GET['datefin'] ?? $period['end'],
|
||||
'total' => $total,
|
||||
'wiki' => $_GET['wiki'] ?? $this->wiki->getPageTag()
|
||||
]);
|
||||
} else {
|
||||
return $this->render('@templates/alert-message.twig', [
|
||||
'type'=>'danger',
|
||||
'message'=> _t('Page réservée aux admins')
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function calculateTotal() {
|
||||
$total = [];
|
||||
foreach($this->communities['reseaucentral']['indicators'] as $k => $ind) {
|
||||
$valcommuperiod = [
|
||||
$this->communities['doctorants']['indicators'][$k]['periodvalue'],
|
||||
$this->communities['ecocloud']['indicators'][$k]['periodvalue'],
|
||||
$this->communities['ingetech']['indicators'][$k]['periodvalue'],
|
||||
$this->communities['shs']['indicators'][$k]['periodvalue'],
|
||||
$this->communities['fabadd']['indicators'][$k]['periodvalue'],
|
||||
$this->communities['reseaucentral']['indicators'][$k]['periodvalue'],
|
||||
];
|
||||
$valcommutotal = [
|
||||
$this->communities['doctorants']['indicators'][$k]['totalvalue'],
|
||||
$this->communities['ecocloud']['indicators'][$k]['totalvalue'],
|
||||
$this->communities['ingetech']['indicators'][$k]['totalvalue'],
|
||||
$this->communities['shs']['indicators'][$k]['totalvalue'],
|
||||
$this->communities['fabadd']['indicators'][$k]['totalvalue'],
|
||||
$this->communities['reseaucentral']['indicators'][$k]['totalvalue'],
|
||||
];
|
||||
$total[$k]['title'] = $ind['title'];
|
||||
$total[$k]['periodvalue'] = array_sum($valcommuperiod);
|
||||
$total[$k]['ecarttype'] = $this->calculateEcartType($valcommuperiod);
|
||||
$total[$k]['moyenne'] = $this->calculateMoyenne($valcommuperiod);
|
||||
$total[$k]['totalvalue'] = array_sum($valcommutotal);
|
||||
$total[$k]['totalecarttype'] = $this->calculateEcartType($valcommutotal);
|
||||
$total[$k]['totalmoyenne'] = $this->calculateMoyenne($valcommutotal);
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
public function calculateBazarIndicators($idIndicator, $community, $period) {
|
||||
$indic = $this->indicateurs[$idIndicator];
|
||||
foreach($indic['queries'] as $id => $val) {
|
||||
$indic['queries'][$id] = str_replace('{idcommu}', $this->communities[$community]['idcommu'], $val);
|
||||
}
|
||||
$res = $this->getService(EntryManager::class)->search($indic);
|
||||
$filterPeriod = [];
|
||||
foreach($res as $i => $f) {
|
||||
$deb = new DateTime($period['deb']);
|
||||
$end = new DateTime($period['end']);
|
||||
$fiche = new DateTime($f['date_creation_fiche']);
|
||||
if ($deb < $fiche && $fiche < $end) {
|
||||
$filterPeriod[$i] = $f;
|
||||
}
|
||||
};
|
||||
$this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = count($filterPeriod);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = count($res);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name'];
|
||||
|
||||
}
|
||||
|
||||
public function calculateBazarApiIndicators($idIndicator, $community, $period) {
|
||||
$indic = $this->indicateurs[$idIndicator];
|
||||
|
||||
$json = file_get_contents($indic['url']);
|
||||
$res = json_decode($json,true);
|
||||
$filterPeriod = [];
|
||||
foreach($res as $i => $f) {
|
||||
$deb = new DateTime($period['deb']);
|
||||
$end = new DateTime($period['end']);
|
||||
$fiche = new DateTime($f['date_creation_fiche']);
|
||||
if ($deb < $fiche && $fiche < $end) {
|
||||
$filterPeriod[$i] = $f;
|
||||
}
|
||||
};
|
||||
$this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = count($filterPeriod);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = count($res);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name'];
|
||||
}
|
||||
|
||||
public function calculateSqlIndicators($idIndicator, $community, $period) {
|
||||
$indic = $this->indicateurs[$idIndicator];
|
||||
$res = [];
|
||||
$filterPeriod = [];
|
||||
foreach($res as $i => $f) {
|
||||
$deb = new DateTime($period['deb']);
|
||||
$end = new DateTime($period['end']);
|
||||
$fiche = new DateTime($f['time']);
|
||||
if ($deb < $fiche && $fiche < $end) {
|
||||
$filterPeriod[$i] = $f;
|
||||
}
|
||||
};
|
||||
$this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = rand(0,3);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = rand(0,10);
|
||||
$this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name'];
|
||||
}
|
||||
|
||||
public function getGlobalPeriod() {
|
||||
$sql = 'select date(min(time)) as deb, date(max(time)) as end from '.$this->wiki->config['table_prefix'].'pages';
|
||||
return $this->getService(DbService::class)->loadSingle($sql);
|
||||
}
|
||||
|
||||
public function getAllMonthsUntilToday($startDate) {
|
||||
$start = (new DateTime($startDate))->modify('first day of this month');
|
||||
$end = (new DateTime('today'))->modify('first day of next month');
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod($start, $interval, $end);
|
||||
|
||||
return $period;
|
||||
}
|
||||
|
||||
public function arrondi($value, $precision = 4) {
|
||||
round((float) $value, $precision);
|
||||
}
|
||||
|
||||
public function calculateMoyenne($values) {
|
||||
return array_sum($values) / count($values);
|
||||
}
|
||||
|
||||
public function calculateEcartType($values) {
|
||||
$moyenne = $this->calculateMoyenne($values);
|
||||
$variances = [];
|
||||
foreach($values as $key => $val) {
|
||||
$variances[$key] = pow($val - $moyenne, 2);
|
||||
}
|
||||
$p =(count($values) - 1);
|
||||
if ($p >= 1) {
|
||||
return sqrt(array_sum($variances) / $p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
43
actions/annuaire.js
Normal file
43
actions/annuaire.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
import renderHelper from '../../tools/bazar/presentation/javascripts/form-edit-template/fields/commons/render-helper.js'
|
||||
import { defaultMapping } from '../../tools/bazar/presentation/javascripts/form-edit-template/fields/commons/attributes.js'
|
||||
|
||||
|
||||
window.formBuilderFields.annuaire = {
|
||||
field: {
|
||||
label: _t('Annuaire'),
|
||||
name: 'annuaire',
|
||||
attrs: { type: 'annuaire' },
|
||||
icon: '<i class="fas fa-users"></i>'
|
||||
},
|
||||
attributes: {
|
||||
name: { label: _t('Identifiant unique'), value: 'bf_annuaire' },
|
||||
entries_field: {
|
||||
label: _t('Identifiants des formulaires source (séparés par des virgules)'),
|
||||
value: ''
|
||||
},
|
||||
},
|
||||
advancedAttributes: [],
|
||||
disabledAttributes: [],
|
||||
attributesMapping: {
|
||||
...defaultMapping,
|
||||
...{
|
||||
0: 'type',
|
||||
1: 'name',
|
||||
2: 'label',
|
||||
3: 'entries_field'
|
||||
// 5: '', /* 5:"mailing_list", */
|
||||
// 6: 'auto_add_to_group',
|
||||
// 8: '',
|
||||
// 9: 'autoupdate_email'
|
||||
}
|
||||
},
|
||||
renderInput(field) {
|
||||
return {
|
||||
field: '',
|
||||
onRender() {
|
||||
//renderHelper.defineLabelHintForGroup(field, 'auto_add_to_group', _t('BAZ_FORM_EDIT_ADD_TO_GROUP_HELP'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
actions/yunohostJsAction.php
Normal file
19
actions/yunohostJsAction.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use YesWiki\Core\YesWikiAction;
|
||||
use YesWiki\Core\Service\AssetsManager;
|
||||
|
||||
class YunohostJsAction extends YesWikiAction
|
||||
{
|
||||
public function formatArguments($arg)
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->wiki->services->get(AssetsManager::class)->AddJavascriptFile('custom/actions/annuaire.js', false, true);
|
||||
$this->wiki->services->get(AssetsManager::class)->AddJavascriptFile('custom/actions/yunohost_user.js', false, true);
|
||||
}
|
||||
}
|
54
actions/yunohost_user.js
Normal file
54
actions/yunohost_user.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
import renderHelper from '../../tools/bazar/presentation/javascripts/form-edit-template/fields/commons/render-helper.js'
|
||||
import { defaultMapping } from '../../tools/bazar/presentation/javascripts/form-edit-template/fields/commons/attributes.js'
|
||||
|
||||
|
||||
window.formBuilderFields.yunohost_user = {
|
||||
field: {
|
||||
label: _t('Utilisateur Yunohost'),
|
||||
name: 'yunohost_user',
|
||||
attrs: { type: 'yunohost_user' },
|
||||
icon: '<i class="fas fa-user"></i>'
|
||||
},
|
||||
attributes: {
|
||||
name_field: { label: _t('BAZ_FORM_EDIT_USERS_WIKINI_NAME_FIELD_LABEL'), value: 'bf_titre' },
|
||||
email_field: {
|
||||
label: _t('BAZ_FORM_EDIT_USERS_WIKINI_EMAIL_FIELD_LABEL'),
|
||||
value: 'bf_mail'
|
||||
},
|
||||
// mailing_list: {
|
||||
// label: "Inscrite à une liste de diffusion"
|
||||
// },
|
||||
autoupdate_email: {
|
||||
label: _t('BAZ_FORM_EDIT_USERS_WIKINI_AUTOUPDATE_MAIL'),
|
||||
options: { 0: _t('NO'), 1: _t('YES') }
|
||||
},
|
||||
auto_add_to_group: {
|
||||
label: _t('BAZ_FORM_EDIT_ADD_TO_GROUP_LABEL'),
|
||||
value: '',
|
||||
placeholder: _t('BAZ_FORM_EDIT_ADD_TO_GROUP_DESCRIPTION'),
|
||||
description: _t('BAZ_FORM_EDIT_ADD_TO_GROUP_DESCRIPTION')
|
||||
}
|
||||
},
|
||||
advancedAttributes: ['autoupdate_email', 'auto_add_to_group'],
|
||||
// disabledAttributes: [],
|
||||
attributesMapping: {
|
||||
...defaultMapping,
|
||||
...{
|
||||
0: 'type',
|
||||
1: 'name_field',
|
||||
2: 'email_field',
|
||||
5: '', /* 5:"mailing_list", */
|
||||
6: 'auto_add_to_group',
|
||||
8: '',
|
||||
9: 'autoupdate_email'
|
||||
}
|
||||
},
|
||||
renderInput(field) {
|
||||
return {
|
||||
field: '',
|
||||
onRender() {
|
||||
renderHelper.defineLabelHintForGroup(field, 'auto_add_to_group', _t('BAZ_FORM_EDIT_ADD_TO_GROUP_HELP'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
templates/bazar/fields/annuaire.twig
Normal file
3
templates/bazar/fields/annuaire.twig
Normal file
|
@ -0,0 +1,3 @@
|
|||
{% extends "@bazar/layouts/field.twig" %}
|
||||
|
||||
{% block value %}{{ value|raw }}{% endblock %}
|
9
templates/bazar/fields/user.twig
Normal file
9
templates/bazar/fields/user.twig
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "@bazar/layouts/field.twig" %}
|
||||
|
||||
{% block label %}{{ _t('BAZ_GIVEN_ID') }}{% endblock %}
|
||||
|
||||
{% block value %}
|
||||
{{ value }}
|
||||
{% if isLoggedUser %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
15
templates/bazar/inputs/annuaire.twig
Normal file
15
templates/bazar/inputs/annuaire.twig
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% extends "@bazar/layouts/input.twig" %}
|
||||
|
||||
{% block input %}
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="text"
|
||||
value="{{ value }}"
|
||||
id="{{ field.name }}"
|
||||
name="{{ field.name }}"
|
||||
class="form-control yeswiki-input-pagetag"
|
||||
size="{{ field.maxChars }}"
|
||||
{% if field.required %}required{% endif %}
|
||||
/>
|
||||
</div>
|
||||
{% endblock %}
|
62
templates/loginldap/modal.tpl.html
Executable file
62
templates/loginldap/modal.tpl.html
Executable file
|
@ -0,0 +1,62 @@
|
|||
<?php if ($connected) : ?>
|
||||
<a href="#LoginModal" role="button" class="<?php if (empty($nobtn)) { echo 'btn btn-default '.$btnclass.' '; } ?>" data-toggle="modal">
|
||||
<i class="glyphicon glyphicon-user"></i> <?php echo $user; ?>
|
||||
</a>
|
||||
<div class="modal fade" id="LoginModal" tabindex="-1" role="dialog" aria-labelledby="LoginModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="LoginModalLabel"><?php echo _t('LOGIN_CONNECTED_AS').' '.$user; ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="login-actions">
|
||||
<?php echo $PageMenuUser; ?>
|
||||
<li><a href="<?php echo $profileurl; ?>" title="<?php echo _t('LOGIN_MODIFY_USER'); ?>"><?php echo _t('LOGIN_MODIFY_USER'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="<?php echo $incomingurl; ?>&action=logout" class="btn btn-default" title="<?php echo _t('LOGIN_LOGOUT'); ?>"><?php echo _t('LOGIN_LOGOUT'); ?></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div> <!-- /#LoginModal-->
|
||||
<?php else : ?>
|
||||
<a href="#LoginModal" role="button" class="<?php if (empty($nobtn)) { echo 'btn btn-default '.$btnclass.' '; } ?>" data-toggle="modal">
|
||||
<i class="glyphicon glyphicon-user"></i> <?php echo _t('LOGIN_LOGIN'); ?>
|
||||
</a>
|
||||
<div class="modal fade" id="LoginModal" tabindex="-1" role="dialog" aria-labelledby="LoginModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="LoginModalLabel"><?php echo _t('LOGIN_LOGIN'); ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="<?php echo $incomingurl; ?>" method="post">
|
||||
<div class="form-group">
|
||||
<input type="text" name="name" class="form-control" value="<?php echo ($user ? htmlspecialchars($user, ENT_COMPAT, YW_CHARSET) : ''); ?>" required placeholder="<?php echo _t('LDAP_USERNAME'); ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="password" class="form-control" name="password" required placeholder="<?php echo _t('LOGIN_PASSWORD'); ?>">
|
||||
</div>
|
||||
<?php if (!empty($lostpasswordurl)) { ?>
|
||||
<small><a href="<?php echo $lostpasswordurl ?>"><?php echo _t('LOGIN_LOST_PASSWORD'); ?></a></small>
|
||||
<?php } ?>
|
||||
<div class="checkbox">
|
||||
<label for="remember-modal">
|
||||
<input type="checkbox" id="remember-modal" name="remember" value="1" /> <?php echo _t('LOGIN_REMEMBER_ME'); ?>
|
||||
</label>
|
||||
</div>
|
||||
<input type="submit" name="login" class="btn btn-block <?php echo $btnclass; ?> btn-primary" value="<?php echo _t('LOGIN_LOGIN'); ?>">
|
||||
<input type="hidden" name="action" value="ldaplogin" />
|
||||
<input type="hidden" name="incomingurl" value="<?php echo $userpage; ?>" />
|
||||
<input type="hidden" name="remember" value="0" />
|
||||
</form>
|
||||
<hr>
|
||||
<a class="btn btn-block <?php echo $btnclass; ?>" href="<?php echo 'https://reseau.s-mart.fr/?InscriptionSmart' ?>"><?php echo _t('LOGIN_SIGNUP'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div> <!-- /#LoginModal-->
|
||||
<?php endif; ?>
|
81
templates/templates/tablestats.twig
Normal file
81
templates/templates/tablestats.twig
Normal file
|
@ -0,0 +1,81 @@
|
|||
{{ include_javascript('javascripts/vendor/datatables-full/jquery.dataTables.min.js') }}
|
||||
{{ include_css('styles/vendor/datatables-full/dataTables.bootstrap.min.css') }}
|
||||
|
||||
<h2>{{ _t('Tableau de bord') }}</h2>
|
||||
<form id="date-filters" method="get" class="no-dblclick form-inline">
|
||||
<div class="form-group">
|
||||
<label for="datedeb" class="control-label">Date de début</label>
|
||||
<input class="form-control" id="datedeb" name="datedeb" type="date" value="{{ selecteddatedeb }}" min="{{ period.deb }}" max="{{ period.end }}" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="datefin" class="control-label">Date de fin</label>
|
||||
<input class="form-control" id="datefin" name="datefin" type="date" value="{{ selecteddatefin }}" min="{{ period.deb }}" max="{{ period.end }}" />
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit" style="top: 15px;">Actualiser</button>
|
||||
<input type="hidden" name="wiki" value="{{ wiki }}">
|
||||
</form>
|
||||
<div class="table-responsive">
|
||||
{% for k, com in communities %}
|
||||
<hr />
|
||||
<h3>Indicateurs pour la communauté {{ com.title}}</h3>
|
||||
<table id="stats-table-{{k}}" class="bazar-table table table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Indicateur</th>
|
||||
<th>sur la période du {{ selecteddatedeb }} au {{ selecteddatefin }}</th>
|
||||
<th>depuis la création du site</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key, indic in com.indicators %}
|
||||
<tr>
|
||||
<td>{{ indic.title }}</td>
|
||||
<td>{{ indic.periodvalue }}</td>
|
||||
<td>{{ indic.totalvalue }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
{% endfor %}
|
||||
</div> <!-- /.table-responsive -->
|
||||
{% if total|length != 0 %}
|
||||
<hr /><hr /><hr />
|
||||
<div class="table-responsive">
|
||||
<h3>Indicateurs pour toutes les communautés</h3>
|
||||
<table id="stats-table-{{k}}" class="bazar-table table table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Indicateur</th>
|
||||
<th>sur la période du {{ selecteddatedeb }} au {{ selecteddatefin }}</th>
|
||||
<th>Ecart type mensuel sur la période</th>
|
||||
<th>Moyenne mensuelle sur la période</th>
|
||||
<th>depuis la création du site</th>
|
||||
<th>Ecart type mensuel</th>
|
||||
<th>Moyenne mensuelle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key, indic in total %}
|
||||
<tr>
|
||||
<td>{{ indic.title }}</td>
|
||||
<td>{{ indic.periodvalue }}</td>
|
||||
<td>{{ indic.ecarttype }}</td>
|
||||
<td>{{ indic.moyenne }}</td>
|
||||
<td>{{ indic.totalvalue }}</td>
|
||||
<td>{{ indic.totalecarttype }}</td>
|
||||
<td>{{ indic.totalmoyenne }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.table-responsive -->
|
||||
{% endif %}
|
||||
<style>
|
||||
#date-filters .control-label {
|
||||
margin-right: 10px;
|
||||
max-width: 100% !important;
|
||||
left: 10px !important;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Add table
Reference in a new issue