Recherche Annonce

This commit is contained in:
Michael RICOIS 2016-05-09 10:51:48 +02:00
parent 2fbddfbb77
commit 03e015b877
3 changed files with 368 additions and 89 deletions

View File

@ -1,6 +1,167 @@
<?php
class Search_AnnonceController extends Zend_Controller_Action
{
public function indexAction(){}
public function listAction(){}
public function indexAction()
{
$this->view->headTitle()->prepend('Recherche Annonce');
$session = new Scores_Session_Recherche();
$recherche = $session->item(0);
if ($recherche['type']=='annonce') {
$params = $recherche['params']['formA'];
} else {
$params = array();
}
$this->view->assign('recherche', $params);
}
public function listAction()
{
$request = $this->getRequest();
$params = $request->getParams();
$token = $request->getParam('token', null);
$session = new Scores_Session_Recherche();
if (array_key_exists('formA', $params)) {
$token = $session->save('annonce', $params);
} else {
$recherche = $session->get($token);
$params = $recherche['params'];
}
if( !isset($params['formA']['annee']) && isset($params['formA']['dateparution']) )
{
$dateparution = str_replace('/', '', $dateparution);
$jj = substring($annee, 0, 2);
$mm = substring($annee, 2, 2);
$aa = substring($annee, 4, 4);
$dateparution = $aa.$mm.$jj;
}
$p = $request->getParam('p', 0);
if($params['formA']['histo']!='on')
{
$ra = array();
$ra['dateAnnee'] = $params['formA']['annee'];
$ra['numParution'] = $params['formA']['nparution'];
if($params['formA']['source']=='bodacc')
{
$ra['source'] = strtoupper('bod'.$params['formA']['bodacc']);
$ra['numAnnonce'] = $params['formA']['nannonce'];
}
elseif($params['formA']['source']=='balo')
{
$ra['source'] = strtoupper($params['formA']['source']);
$ra['numAnnonce'] = $params['formA']['naffaire'];
}
elseif($params['source']=='asso')
{
$ra['source'] = strtoupper($params['formA']['source']);
$ra['numAnnonce'] = $params['formA']['nannonce'];
}
$ws = new WsScores();
$result = $ws->rechercheAnnonce($ra['source'], $ra['dateAnnee'], $ra['numParution'], $ra['numAnnonce']);
$infos = $result->result->item;
$parametresTxt = array(
'source'=>'Source',
'annee'=>'Année',
'dateparution'=>'Date de parution',
'nparution'=>'Numéro de parution',
'bpage'=>'Page',
'nannonce'=>'Numéro d\'annonce',
'naffaire'=>'Numéro d\'affaire',
'txt'=>'Recherche');
$strCriteres = '';
foreach ($parametresTxt as $key => $param) {
if($params['formA'][$key]!='' && $param!='') {
$strCriteres.= $param.' : '.$params['formA'][$key].'&nbsp;';
}
}
$this->view->assign('criteres', $result->criteres);
$this->view->assign('infos', $infos);
} else {
//Suppression des caractères accentués
$txt = Scores_Locale_String::cleanstring($params['formA']['txt']);
//Remplacement du caractère § par ~
$txt = str_replace('$', '~', $txt);
// Recherche siren tenant compte des anomalies d'OCR
$txt = preg_replace('/([0-9]{3})([0-9]{3})([0-9]{3})/','"$1$2$3"|"$1 $2$3"|"$1$2 $3"|"$1 $2 $3"', $txt);
$ws = new WsScores();
$result = $ws->rechercheHisto($txt, $params['formA']['annee'], $params['formA']['bodacc'], $p);
$infos = $result->reponses->item;
$mots = $result->mots->item;
$annonces = array();
foreach($infos as $annonce)
{
//Mark all search words in bold
$texte = $annonce->Texte;
foreach( $mots as $mot ){
$texte = preg_replace('/'.$mot.'/i', '<b>'.strtoupper($mot).'</b>', $texte);
}
//Transform Code as a better text
$code = $annonce->Code;
if( substr($code,0,3)=='BOD' )
{
$code = '<u>BODACC :</u> '.substr($code,3,1);
}
//Change URL to download file
//$fichier = str_replace("http://wse.scores-decisions.com:8081/fichier/bodacc/q",'',$annonce->Fichier);
$pos = strrpos($annonce->Fichier, '/q/');
$host = substr($annonce->Fichier, 0, $pos);
$fichier = substr($annonce->Fichier, $pos+3);
$annonces[] = array (
'annee' => $annonce->Annee,
'code' => $code,
'text' => $texte,
'file' => $this->view->url(array('controller'=>'telechargement', 'action'=>'histopdf',
'q' => $fichier, 'host' => base64_encode($host)), 'default', true
),
);
}
$this->view->assign('annonces', $annonces);
$parametresTxt = array(
'source'=>'Source',
'bodacc'=>'Type',
'histo'=>'',
'annee'=>'Année',
'dateparution'=>'Date de parution',
'nparution'=>'Numéro de parution',
'bpage'=>'Page',
'nannonce'=>'Numéro d\'annonce',
'naffaire'=>'Numéro d\'affaire',
'txt'=>'Recherche');
$strCriteres = '';
foreach ($parametresTxt as $key => $param) {
if($params['formA'][$key]!='' && $param!='') {
$strCriteres.= $param.' : '.$params['formA'][$key].',&nbsp;';
}
}
}
$this->view->assign('p', $p);
$this->view->assign('token', $token);
$user = new Scores_Utilisateur();
$this->view->assign('userNbReponses', $user->getNbRep());
$this->view->assign('nbReponses', $result->nbReponses);
$this->view->assign('nbReponsesTotal', $result->nbReponsesTotal);
$this->view->assign('strCriteres', $strCriteres);
$this->view->assign('histo', $params['formA']['histo']);
}
}

View File

@ -1,9 +1,7 @@
<script type="text/javascript">
function formSource(source)
{
function formSource(source) {
var fields = Array( 'bodacc', 'histo', 'date', 'nparution', 'fpage', 'nannonce', 'naffaire', 'txt' );
switch(source)
{
switch(source){
case 'asso':
var field_actif = new Array('date', 'nparution', 'fpage', 'nannonce');
break;
@ -22,8 +20,7 @@ function formSource(source)
}
}
$(document).ready(function()
{
$(document).ready(function(){
//Init
formSource($('#sourceSelect').val());
if ($('#histoSelect').prop('checked')) {
@ -47,48 +44,19 @@ $(document).ready(function()
$(this).prop('checked', false);
});
});
});
</script>
<style type="text/css">
.infoTitle {clear:both; float:left; width:180px; margin-left:30px; padding:0 10px 0 0;}
.infoData {float:left; width:320px; margin:2px 0;}
form {}
form em { color:#FF0000;}
fieldset {border:0; margin:0; padding:0;}
fieldset legend{ padding:0 0 0 10px;}
.fieldgrp{clear:both; width:100%; margin-bottom:.5em; overflow:hidden;}
.fieldgrp:after{content:"."; display:block; clear:both; visibility:hidden; line-height:0; height:0; }
.fieldgrp label{ width:150px; font-weight:bold; margin-left:30px; clear:both; padding:0 10px 0 0; line-height:22px; _padding-top:3px; float:left; display:block; font-size:108%;}
.fieldgrp label.inline{ clear:none; margin:0; float:left; display:block; width:auto;}
.fieldgrp label span{font-weight:normal;}
.fieldgrp label abbr{color:#4B911C; font-size:120%; vertical-align:middle;}
.fieldgrp p { clear:both; margin:0 0 0 30px; font-size:12px; }
.field { float:left; padding:0 10px 0 0; line-height:22px; _padding-top:3px;}
.field .longfield{width:215px;}
.field .longfield-select{width:220px;}
.field .smallfield{width:95px;}
.field .medfield{width:110px;}
.field input, .field select{ font-size:110%; margin:2px 0; }
.field input.radio { margin:0 5px; vertical-align:middle; border:none; }
.field input.checkbox { border:none; }
.field span { margin-left:10px; }
.noborder {border:none;}
div.submit{ text-align:center; }
</style>
<div id="center">
<div id="content">
<h1>Rechercher une annonce</h1>
<h3 class="text-center">Rechercher une annonce légale</h3>
<div class="paragraph">
<form name="annonces" method="post" action="<?=$this->url(array('controller'=>'recherche', 'action'=>'annonceliste'))?>">
<form class="form-horizontal" name="annonces" method="post" action="<?=$this->url(array('action'=>'list'))?>">
<input type="hidden" name="formA[type]" value="annonces"/>
<div class="fieldgrp">
<label for="source">Source</label>
<div class="field">
<select id="sourceSelect" name="formA[source]">
<div class="form-group form-group-sm">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<select id="sourceSelect" name="formA[source]" class="form-control">
<option value="bodacc" <?=(isset($this->recherche['source']) && $this->recherche['source']=='bodacc')? 'selected' : ''?>>BODACC / BORC</option>
<option value="asso" <?=(isset($this->recherche['source']) && $this->recherche['source']=='asso')? 'selected' : ''?>>JO Association</option>
<option value="balo" <?=(isset($this->recherche['source']) && $this->recherche['source']=='balo')? 'selected' : ''?>>BALO</option>
@ -96,91 +64,109 @@ div.submit{ text-align:center; }
</div>
</div>
<div id="bodacc" class="fieldgrp">
<label for="bodacc">Bodacc</label>
<div class="field">
<span><input class="radio" type="radio" name="formA[bodacc]" value="a" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='a')? 'checked' : ''?>/>A</span>
<span><input class="radio" type="radio" name="formA[bodacc]" value="b" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='b')? 'checked' : ''?>/>B</span>
<span><input class="radio" type="radio" name="formA[bodacc]" value="c" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='c')? 'checked' : ''?>/>C</span>
<span><a href="#" id="deselectBodacc">Désélection</a></span>
<div id="bodacc" class="form-group form-group-sm">
<label class="col-sm-3 control-label">Bodacc</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" name="formA[bodacc]" value="a" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='a')? 'checked' : ''?>/> A
</label>
<label class="radio-inline">
<input type="radio" name="formA[bodacc]" value="b" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='b')? 'checked' : ''?>/> B
</label>
<label class="radio-inline">
<input type="radio" name="formA[bodacc]" value="c" <?=(isset($this->recherche['bodacc']) && $this->recherche['bodacc']=='c')? 'checked' : ''?>/> C
</label>
</div>
</div>
<div id="histo" class="fieldgrp">
<label for="histo">Historique jusqu'à 1953</label>
<div class="field">
<input class="checkbox" type="checkbox" id="histoSelect" name="formA[histo]" <?=(isset($this->recherche['histo']) && $this->recherche['histo']=='on')? 'checked' : ''?>/>
<div id="histo" class="form-group form-group-sm">
<div class="col-sm-offset-3 col-sm-9">
<label class="checkbox-inline">
<input type="checkbox" id="histoSelect" name="formA[histo]" <?=(isset($this->recherche['histo']) && $this->recherche['histo']=='on') ? 'checked' : ''?>/> Historique jusqu'à 1953
</label>
</div>
</div>
<div id="date" class="fieldgrp">
<label for="annee">Année</label>
<div class="field">
<input type="text" name="formA[annee]" size="4" maxlength="4" value="<?=$this->recherche['annee']?>"/>
</div>
<label class="inline" for="dateparution">ou Date de parution</label>
<div class="field">
<input id="datepicker" type="text" name="formA[dateparution]" size="10" maxlength="10" value="<?=$this->recherche['dateparution']?>"/>
<div id="date">
<div class="form-group form-group-sm">
<label class="col-sm-3 control-label">Année</label>
<div class="col-sm-9">
<input type="text" name="formA[annee]" size="4" maxlength="4" value="<?=$this->recherche['annee']?>" class="form-control"/>
</div>
</div>
<div id="nparution" class="fieldgrp">
<label for="nparution">Numéro de parution</label>
<div class="field">
<input type="text" name="formA[nparution]" size="10" maxlength="10" value="<?=$this->recherche['nparution']?>"/>
<div class="form-group form-group-sm">
<label class="col-sm-3 control-label">ou Date de parution</label>
<div class="col-sm-9">
<input id="datepicker" type="text" name="formA[dateparution]" size="10" maxlength="10" value="<?=$this->recherche['dateparution']?>" class="form-control"/>
</div>
</div>
</div>
<div id="fpage" class="fieldgrp">
<label for="page">Page</label>
<div class="field">
<input type="text" name="formA[bpage]" size="10" maxlength="10" value="<?=$this->recherche['bpage']?>"/>
<div id="nparution" class="form-group form-group-sm">
<label class="col-sm-3 control-label">Numéro de parution</label>
<div class="col-sm-9">
<input type="text" name="formA[nparution]" size="10" maxlength="10" value="<?=$this->recherche['nparution']?>" class="form-control"/>
</div>
</div>
<div id="nannonce" class="fieldgrp">
<label for="nannonce">Numéro d'annonce</label>
<div class="field">
<input type="text" name="formA[nannonce]" size="10" maxlength="10" value="<?=$this->recherche['nannonce']?>"/>
<div id="fpage" class="form-group form-group-sm">
<label class="col-sm-3 control-label">Page</label>
<div class="col-sm-9">
<input type="text" name="formA[bpage]" size="10" maxlength="10" value="<?=$this->recherche['bpage']?>" class="form-control"/>
</div>
</div>
<div id="naffaire" class="fieldgrp">
<label for="naffaire">Numéro d'affaire</label>
<div class="field">
<input type="text" name="formA[naffaire]" size="10" maxlength="10" value="<?=$this->recherche['naffaire']?>"/>
<div id="nannonce" class="form-group form-group-sm">
<label class="col-sm-3 control-label">Numéro d'annonce</label>
<div class="col-sm-9">
<input type="text" name="formA[nannonce]" size="10" maxlength="10" value="<?=$this->recherche['nannonce']?>" class="form-control"/>
</div>
</div>
<div id="txt" class="fieldgrp">
<label for="txt">Recherche</label>
<div class="field">
<div id="naffaire" class="form-group form-group-sm">
<label class="col-sm-3 control-label">Numéro d'affaire</label>
<div class="col-sm-9">
<input type="text" name="formA[naffaire]" size="10" maxlength="10" value="<?=$this->recherche['naffaire']?>" class="form-control"/>
</div>
</div>
<div id="txt">
<div class="form-group form-group-sm">
<label class="col-sm-3 control-label">Recherche</label>
<div class="col-sm-9">
<input type="text" name="formA[txt]" size="55" maxlength="2048" value="<?
if (isset($this->recherche['txt'])) {
print htmlspecialchars($this->recherche['txt']);
}
?>"/>
</div>
?>" class="form-control" aria-describedby="helpBlock"/>
<span id="helpBlock" class="help-block">
<p>
<b><u>Attention :</u></b>
Ce formulaire de recherche permet de rechercher dans les pages entières du BORC, BODAC et BODACC telles qu'elles ont été numérisées par Scores & Décisions.
Cette recherche permet de rechercher des annonces dans des pages jusqu'à l'année de parution <b>1953</b>.
</p>
<p>&nbsp;</p>
<p><u>Opérateurs et méthodes de recherche :</u></p>
<p>Opérateur OU, <b>|</b> (ex: <b>societe | ville</b>)</p>
<p>Exclure des termes, <b>-</b> ou <b>!</b> (ex: <b>societe -ville</b> ou <b>societe !ville</b>)</p>
<p>Phrase (ex: <b>"boulangerie dupain"</b>)</p>
<p>Recherche de proximité (ex: <b>"boulangerie plantes"$50</b> , recherche d'une boulangerie dans rue des plantes )</p>
<p>Ordre de recherche (ex: <b>boulangerie << dupain</b> , recherche du mot "boulangerie" puis du mot "dupain") </p>
</span>
</div>
</div>
<div class="submit">
<p><input type="submit" name="submit" value="Ok"/></p>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-default btn-sm">Rechercher</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -1 +1,133 @@
<div id="content">
<?php if ($this->histo == 'on'){?>
<h3 class="text-center">Rechercher une annonce légale historique</h3>
<style type="text/css">
ol li { margin-bottom:10px; }
</style>
<?php if($this->p>=200) {?>
<p>Merci d'affiner votre recherche.</p>
<?php } ?>
<?php if ( $this->nbReponses==0) { ?>
<p class="StyleInfoLib">
Pas de r&eacute;sultat affich&eacute; avec le(s) crit&egrave;re(s)
<a title="Retour au formulaire de recherche" href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce',
'action'=>'index'), 'default', true)?>"><?=$this->strCriteres?></a>
</p>
<?php } else { ?>
<p class="StyleInfoLib">
<?=$this->nbReponsesTotal?> r&eacute;ponses. avec les critères <a title="Retour au formulaire de recherche"
href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce', 'action'=>'index'))?>">
<?=$this->strCriteres?></a>
<?php
if ( $this->p+$this->userNbReponses<$this->nbReponsesTotal )
{
$totPage = ceil($this->nbReponsesTotal/$this->userNbReponses);
$curPage = ceil($this->p/$this->userNbReponses)+1;
?>
<?=$this->nbReponses?> r&eacute;sultats affich&eacute;s. Page <?=$curPage?>/<?=$totPage?>.
<?php
$prec = $this->p-$this->userNbReponses;
$suiv = $this->p+$this->userNbReponses;
}
elseif( $this->p+$this->userNbReponses>=$this->nbReponsesTotal )
{
$totPage = ceil($this->nbReponsesTotal/$this->userNbReponses);
$curPage = $totPage;
?>
<?=$this->nbReponses?> r&eacute;sultats affich&eacute;s. Page <?=$curPage?>/<?=$totPage?>.
<?php
$prec = $this->p-$this->userNbReponses;
$suiv = $this->p+$this->userNbReponses;
}
else
{
$totPage = $curPage = 1;
}
echo '</p>';
?>
<ol>
<?php
$indice = 0;
foreach( $this->annonces as $annonce )
{
$indice++;
?>
<li type="1" value="<?=$this->p+$indice?>">
<?=$annonce['code']?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u>Année :</u> <?=$annonce['annee']?>
<br/>
...&nbsp;<?=$annonce['text']?>&nbsp;...
<br/>
<a href="<?=$annonce['file']?>" class="histopdf" target="_blank">Télécharger la page en PDF</a>
</li>
<?php
}
?>
</ol>
<?php
//Page précédentes
if($curPage>1) {?>
<a href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce', 'action'=>'list',
'p'=>$prec, 'token'=>$this->token))?>">Page précédente</a>
<?php } ?>
<< Page : <?=$curPage.'/'.$totPage?> >>
<?php
//Page suivante
if ($curPage<$totPage) { ?>
<a href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce', 'action'=>'list', 'p'=>$suiv,
'token'=>$this->token))?>">Page suivante</a>
<?php } ?>
<?php
}
?>
<?php } else {?>
<h3 class="text-center">Rechercher une annonce légale</h3>
<?php
if ( $this->nbReponses==0){
?>
<p class="StyleInfoLib">
Pas de r&eacute;sultat affich&eacute; avec le(s) crit&egrave;re(s)
<a title="Retour au formulaire de recherche" href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce', 'action'=>'index'), 'default', true)?>">
<?=$this->strCriteres?></a>
</p>
<?php
}
//Affichage des critères de recherche
else {
?>
<div class="blockh2">
<p class="StyleInfoLib">Critères de recherche
<a title="Retour au formulaire de recherche" href="<?=$this->url(array('module'=>'search', 'controller'=>'annonce', 'action'=>'index'), 'default', true)?>">
<?=$this->strCriteres?></a></p>
<div id="annonce">
<?php
//Affichage des données
foreach( $this->infos as $info ) {
$texte = $this->RemplaceSiren($info->Annonce);
if(substr($this->criteres->source, 0, 3) == 'BOD' ){
$date = new Zend_Date($info->Date_Parution, 'yyyy-MM-dd');
?>
Source BODACC n°<?=$info->Num_Parution?> <?=substr($this->criteres->source, 3, 1)?> du <?=$date->toString('dd/MM/yyyy')?>.
<?php
}
?>
Département n°<?=$info->Departement?>. <?=$info->Tribunal_Code?>
<br/><br/>
<code><?=$texte?></code><br/>
<?php
}
?>
</div>
</div>
<?php }?>
<?php }?>
</div>