Changeset 2674


Ignore:
Timestamp:
May 12, 2012, 8:39:25 PM (8 years ago)
Author:
teymour
Message:

Ajout d'un champ pour les amendements multiples (+correction bug rectifié)

Location:
cpc/trunk/project
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/amendement/actions/actions.class.php

    r2672 r2674  
    4141       ->from('Amendement a')
    4242       ->where('a.sous_amendement_de = ?', $this->amendement->numero)
     43       ->andWhere('a.sort <> ?', 'Rectifié')
    4344       ->orderBy('a.numero')
    4445       ->fetchArray();
  • cpc/trunk/project/bin/updateDB5.sh

    r2672 r2674  
    11. bin/db.inc
     2
    23echo 'ALTER TABLE amendement ADD sous_amendement_de VARCHAR(8) NOT NULL AFTER numero' | mysql $MYSQLID $DBNAME
    34echo 'select a.id, a.texteloi_id, a.numero, t.triple_value from amendement a, tagging tg, tag t WHERE a.sort <> "Rectifié" and a.id = tg.taggable_id AND t.id = tg.tag_id AND t.triple_key = "sous_amendement_de"' |  mysql $MYSQLID $DBNAME | grep ^[0-9] | sed 's/\([A-F]\)\t/;\1;/'| sed 's/\t/;;/g' | awk -F';' '{print $1";"$3";"$5$6";"$7$6}'|awk -F';' '{print "update amendement set sous_amendement_de = \""$4"\" where id = "$1";"}' | mysql $MYSQLID $DBNAME
     5
     6echo 'ALTER TABLE amendement ADD nb_multiples INT NOT NULL DEFAULT 1 AFTER content_md5 ' | mysql $MYSQLID $DBNAME
     7echo 'select a.id, count(tg.id) FROM tagging tg LEFT JOIN amendement a ON a.id = tg.taggable_id LEFT JOIN tag t ON t.id = tg.tag_id  WHERE a.sort <> "Rectifié" AND t.triple_key = "amendement" AND taggable_model = "Amendement" group by a.id' |  mysql $MYSQLID $DBNAME | grep ^[0-9]  | awk '{print "UPDATE amendement SET nb_multiples = "$2" WHERE id = "$1";"}'  | mysql $MYSQLID $DBNAME
     8
    49php symfony doctrine:build-model
  • cpc/trunk/project/config/doctrine/schema.yml

    r2672 r2674  
    282282      type: string
    283283    content_md5: string(36)
     284    nb_multiples:
     285      type: integer
     286      default: 1
    284287  relations:
    285288    Parlementaires:
  • cpc/trunk/project/lib/model/doctrine/Amendement.class.php

    r2672 r2674  
    126126    $numeros = $this->numero;
    127127    $lettre = $this->getLettreLoi();
    128     $ident = $this->getTags(array('is_triple' => true,
     128    if ($this->nb_multiples > 1) {
     129      $ident = $this->getTags(array('is_triple' => true,
    129130          'namespace' => 'loi',
    130131          'key' => 'amendement',
    131132          'return'    => 'value'));
    132     if (count($ident) > 1 && $lettre != "") {
    133133      sort($ident);
    134       if ($lettre) foreach ($ident as $iden) $iden .= $lettre;
     134      foreach ($ident as $iden) if (preg_match('/'.$lettre.'/', $iden)) $iden.= $lettre;
    135135      $numeros = implode(', ', $ident);
    136136      $pluriel = "s";
  • cpc/trunk/project/lib/task/loadAmdmtsTask.class.php

    r2673 r2674  
    5959              $lettre = $amdmt->getLettreLoi();
    6060              if ($json->serie) {
     61                $nb_serie = 0;
    6162                if (preg_match('/,/', $json->serie)) {
    6263                  $arr = preg_split('/,/', $json->serie);
    6364                  foreach ($arr as $gap_stri) {
    6465                    $gap = preg_split('/-/', $gap_stri);
    65                     for ($n = $gap[0]; $n <= $gap[1]; $n++)
     66                    for ($n = $gap[0]; $n <= $gap[1]; $n++) {
    6667                      $amdmt->addTag('loi:amendement='.$n.$lettre);
     68                      $nb_serie++;
     69                    }
    6770                  }
    6871                } else {
    6972                  $gap = preg_split('/-/', $json->serie);
    70                   for ($n = $gap[0]; $n <= $gap[1]; $n++)
     73                  for ($n = $gap[0]; $n <= $gap[1]; $n++) {
    7174                    $amdmt->addTag('loi:amendement='.$n.$lettre);
     75                    $nb_serie++;
     76                  }
    7277                }
    73               } else $amdmt->addTag('loi:amendement='.$amdmt->numero);
     78                $amdmt->nb_multiples = $nb_serie;
     79              } else {
     80                $amdmt->addTag('loi:amendement='.$amdmt->numero);
     81                $amdmt->nb_multiples = 1;
     82              }
    7483              if ($json->parent)
    7584                $amdmt->sous_amendement_de = $json->parent.$lettre;
Note: See TracChangeset for help on using the changeset viewer.