Changeset 2722


Ignore:
Timestamp:
May 15, 2012, 11:15:06 PM (8 years ago)
Author:
goya
Message:

ajout sur graphe de courbe de présence médiane + fix link explications, legendes graphes et pages par session

Location:
cpc/trunk/project
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/parlementaire/templates/plotSuccess.php

    r2708 r2722  
    22$surtitre = "Graphes d'activité parlementaire";
    33$fin = myTools::isFinLegislature();
    4 if ($session == 'lastyear') {
     4if ($fin) $test = 'legislature';
     5else $test = 'lastyear';
     6if ($session == $test) {
    57 if ($fin) $titre = 'Sur toute la législature';
    68 else $titre = 'Sur les 12 derniers mois';
     
    1012?>
    1113<div class="par_session"><p>
    12 <?php if ($session != 'lastyear')
    13   echo '<a href="'.url_for('@parlementaire_plot?slug='.$parlementaire->slug.'&time=lastyear').'">';
     14<?php if ($session != $test)
     15  echo '<a href="'.url_for('@parlementaire_plot?slug='.$parlementaire->slug.'&time='.$test).'">';
    1416  else echo '<b>';
    1517  if ($fin) echo 'Toute la législature';
    1618  else echo 'Les 12 derniers mois';
    17   if ($session != 'lastyear') echo '</a>';
     19  if ($session != $test) echo '</a>';
    1820  else echo '</b>';
    1921  foreach ($sessions as $s) {
  • cpc/trunk/project/apps/frontend/modules/plot/actions/components.class.php

    r2717 r2722  
    99    static $seuil_invective = 20;
    1010    $this->data = array();
    11     $this->data['fin'] = myTools::isFinLegislature();
    1211    if (!isset($this->session) || $this->session === 'legislature') $this->session = 'lastyear';
     12    $this->data['fin'] = myTools::isFinLegislature() && ($this->session === 'lastyear');
    1313    if ($this->session === 'lastyear') {
    1414      if (!$this->data['fin'] && isset($this->parlementaire->fin_mandat) && $this->parlementaire->fin_mandat > $this->parlementaire->debut_mandat) {
     
    122122    unset($questionsorales);
    123123   }
     124
     125    # Données de présence mediane par semaine
     126    $this->data['presences_medi'] = array('commission' => array_fill(1, $n_weeks, 0),
     127                                          'hemicycle'  => array_fill(1, $n_weeks, 0),
     128                                          'total' => array_fill(1, $n_weeks, 0));
     129    $presences_medi = Doctrine::getTable('VariableGlobale')->findOneByChamp('presences_medi');
     130    if ($presences_medi) {
     131      $prmedi = unserialize($presences_medi->value);
     132      $debut_legis = strtotime(myTools::getDebutLegislature());
     133      $an_legis = date('Y', $debut_legis);
     134      $sem_legis = date('W', $debut_legis);
     135      if ($sem_legis == 53) { $an_legis++; $sem_legis = 1; }
     136      $startweek = ($annee0 - $an_legis)*53 + $sem0 - $sem_legis;
     137      $this->data['presences_medi']['commission'] = array_slice($prmedi['commission'], $startweek, $n_weeks);
     138      $this->data['presences_medi']['hemicycle'] = array_slice($prmedi['hemicycle'], $startweek, $n_weeks);
     139      $this->data['presences_medi']['total'] = array_slice($prmedi['total'], $startweek, $n_weeks);
     140    }
     141
    124142    # Clean interventiosn de ministre hors périodes de mandat
    125143    for($i=1; $i < $n_weeks; $i++)
     
    131149        $this->data['n_mots']['hemicycle'][$i] = 0;
    132150        $this->data['n_mots']['commission'][$i] = 0;
     151        $this->data['presences_medi']['hemicycle'][$i] = 0;
     152        $this->data['presences_medi']['commission'][$i] = 0;
     153        $this->data['presences_medi']['total'][$i] = 0;
    133154        if (isset($this->data['n_questions']))
    134155          $this->data['n_questions'][$i] = 0;
  • cpc/trunk/project/apps/frontend/modules/plot/templates/_plotParlementaire.php

    r2714 r2722  
    3333echo "<span style='background-color: rgb(255,200,0);'>&nbsp;</span>&nbsp;Participations&nbsp;&nbsp;&nbsp;";
    3434echo "<span style='background-color: rgb(0,255,0);'>&nbsp;</span>&nbsp;Mots prononcés (x&nbsp;10&nbsp;000)&nbsp;&nbsp;&nbsp;";
    35 if (!myTools::isFinLegislature() && $questions === 'true' && $type != 'commission')
    36     echo "<span style='background-color: rgb(0,0,255);'>&nbsp;</span>&nbsp;Questions orales&nbsp;&nbsp;&nbsp;";
    37 echo "<span style='background-color: rgb(150,150,150);'>&nbsp;</span>&nbsp;Vacances parlementaires";
     35if (!(myTools::isFinLegislature() && preg_match('/^l/', $time)) && $questions === 'true' && $type != 'commission')
     36    echo "<span style='background-color: rgb(0,0,255);'>&nbsp;</span>&nbsp;Questions orales<br/>";
     37echo "<span style='background-color: rgb(150,150,150);'>&nbsp;</span>&nbsp;Vacances parlementaires&nbsp;&nbsp;";
     38echo "<span style='font-weight: bolder; color: rgb(200,200,200);'>&mdash;</span>&nbsp;Présence médiane";
    3839if ($link === 'true')
    39   echo "&nbsp;&nbsp;&nbsp;&nbsp;".link_to('Explications', '@parlementaire_plot?slug='.$parlementaire->slug.'&time=lastyear#explications').'</p>';
     40  echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.url_for('@faq').'#post_4">Explications</a></p>';
    4041else echo '</p>';
    4142if ($link != 'true')
  • cpc/trunk/project/apps/frontend/modules/plot/templates/generatePlotParlementaireSuccess.php

    r2712 r2722  
    77$participations = array_fill(1, $n, 0);
    88$mots = array_fill(1, $n, 0);
     9$presences_medi = array_fill(1, $n, 0);
    910if ($type === 'total') for ($i = 1; $i <= $n; $i++) {
    1011  $presences[$i] = $data['n_presences']['hemicycle'][$i] + $data['n_presences']['commission'][$i];
     
    1617  $mots = $data['n_mots']["$type"];
    1718}
     19$presences_medi = $data['presences_medi']["$type"];
    1820
    1921if ($link === 'true') {
     
    8890}
    8991
     92$DataSet4 = new xsPData();
     93$DataSet4->AddPoint($data['labels'], "Serie1");
     94$DataSet4->AddPoint($presences_medi, "Serie8");
     95$DataSet4->AddPoint(array_fill(1, count($data['labels']), 0), "Serie5");
     96$DataSet4->AddSerie("Serie8");
     97$DataSet4->AddSerie("Serie5");
     98$DataSet4->SetAbsciseLabelSerie("Serie1");
     99$Data4 = $DataSet4->GetData();
     100$DataDescr4 = $DataSet4->GetDataDescription();
     101
    90102$Data = $DataSet->GetData();
    91103$DataDescr = $DataSet->GetDataDescription();
     
    113125  $Test->drawOverlayBarGraph($DataLegend,$DataDescrLegend,30,100);
    114126  $Test->setImageMap(FALSE,$mapId);
    115 }  
     127}
    116128$Test->drawGrid(0,TRUE,0,0,0,100);
    117129$Test->setColorPalette(0,50,50,50);
    118130$Test->drawOverlayBarGraph($Data2,$DataDescr2,30,100);
     131$Test->setColorPalette(0,200,200,200);
     132$Test->drawLineGraph($Data4,$DataDescr4);
    119133$Test->setColorPalette(0,255,0,0);
    120134$Test->setColorPalette(1,255,255,0);
  • cpc/trunk/project/lib/task/topDeputesTask.class.php

    r2715 r2722  
    482482      }
    483483    }
    484    }
     484   }
     485
     486    $date = time();
     487    $annee = date('Y', $date); $sem = date('W', $date);
     488    $start = strtotime(myTools::getDebutLegislature());
     489    $date_debut = date('Y-m-d', $start);
     490    $annee0 = date('Y', $start); $sem0 = date('W', $start);
     491    if ($sem >= 52 && date('n', $date) == 1) $sem = 0;
     492    if ($sem0 >= 52 && $sem <= 1) $sem0 = 0;
     493    $n_weeks = ($annee - $annee0)*53 + $sem - $sem0;
     494    $query = Doctrine_Query::create()
     495      ->select('COUNT(p.id) as nombre, p.id, p.parlementaire_id, s.type, s.annee, s.numero_semaine')
     496      ->from('Presence p')
     497      ->leftJoin('p.Seance s')
     498      ->where('s.date > ?', $date_debut)
     499      ->groupBy('s.type, s.annee, s.numero_semaine, p.parlementaire_id')
     500      ->orderBy('s.type, s.annee, s.numero_semaine, nombre');
     501    $presences_medi = array('commission' => array_fill(1, $n_weeks, 0),
     502                            'hemicycle' => array_fill(1, $n_weeks, 0),
     503                            'total' => array_fill(1, $n_weeks, 0));
     504    $presences = $query->fetchArray();
     505    $deps = floor(count($presences)/$n_weeks);
     506    $mid = floor($deps/2)+1;
     507    $ct = 0;
     508    foreach ($presences as $presence) {
     509      $ct++;
     510      if ($ct % $deps != $mid) continue;
     511      $n = ($presence['Seance']['annee'] - $annee0)*53 + $presence['Seance']['numero_semaine'] - $sem0 + 1;
     512      if ($n <= $n_weeks)
     513        $presences_medi[$presence['Seance']['type']][$n] = $presence['nombre'];
     514    }
     515    unset($presences);
     516    $query = Doctrine_Query::create()
     517      ->select('COUNT(p.id) as nombre, p.id, p.parlementaire_id, s.annee, s.numero_semaine')
     518      ->from('Presence p')
     519      ->leftJoin('p.Seance s')
     520      ->where('s.date > ?', $date_debut)
     521      ->groupBy('s.annee, s.numero_semaine, p.parlementaire_id')
     522      ->orderBy('s.annee, s.numero_semaine, nombre');
     523    $presences = $query->fetchArray();
     524    $deps = floor(count($presences)/$n_weeks);
     525    $mid = floor($deps/2)+1;
     526    $ct = 0;
     527    foreach ($presences as $presence) {
     528      $ct++;
     529      if ($ct % $deps != $mid) continue;
     530      $n = ($presence['Seance']['annee'] - $annee0)*53 + $presence['Seance']['numero_semaine'] - $sem0 + 1;
     531      if ($n <= $n_weeks) {
     532        $presences_medi['total'][$n] = $presence['nombre'];
     533      }
     534    }
     535    unset($presences);
     536    $globale2 = Doctrine::getTable('VariableGlobale')->findOneByChamp('presences_medi');
     537    if (!$globale2) {
     538      $globale2 = new VariableGlobale();
     539      $globale2->champ = 'presences_medi';
     540    }
     541    $globale2->value = serialize($presences_medi);
     542    $globale2->save();
     543
    485544  }
    486545}
Note: See TracChangeset for help on using the changeset viewer.