1072 lines
34 KiB
PHP
1072 lines
34 KiB
PHP
<?php
|
|
class SurveillanceController extends Zend_Controller_Action
|
|
{
|
|
/**
|
|
* Association source => texte
|
|
* @var array
|
|
*/
|
|
protected $sourceTxt = array(
|
|
'annonces' => 'Annonces',
|
|
'insee' => 'Insee',
|
|
'bilans' => 'Bilans',
|
|
'score' => 'IndiScore',
|
|
'actes' => 'Actes',
|
|
'dirigeants' => 'Dirigeants',
|
|
'privileges' => 'Privilèges',
|
|
'paiements' => 'Paiements',
|
|
'liens' => 'Liens',
|
|
);
|
|
|
|
/**
|
|
* Association source => droits
|
|
* @var array
|
|
*/
|
|
protected $sourceDroit = array(
|
|
'annonces' => 'survannonce',
|
|
'insee' => 'survinsee',
|
|
'bilans' => 'survbilan',
|
|
'score' => 'survscore',
|
|
'actes' => 'survactes',
|
|
'dirigeants' => 'survdirigeants',
|
|
'privileges' => 'survpriv',
|
|
'paiements' => 'survpaiements',
|
|
'liens' => 'survliens',
|
|
);
|
|
|
|
public function init()
|
|
{
|
|
require_once 'Scores/WsScores.php';
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
//What we want to do here
|
|
}
|
|
|
|
/**
|
|
* Ajouter une surveillance
|
|
*/
|
|
public function ajouterAction()
|
|
{
|
|
//Affichage formulaire demande ref et email
|
|
$this->_helper->layout->disableLayout();
|
|
$request = $this->getRequest();
|
|
$siret = $request->getParam('siret', '');
|
|
$email = $request->getParam('email', '');
|
|
$ref = $request->getParam('ref', '');
|
|
$source = $request->getParam('source', '');
|
|
$encours = $request->getParam('encours', 0);
|
|
|
|
$user = new Scores_Utilisateur();
|
|
$email = $user->getEmail();
|
|
|
|
if( empty($source) ) {
|
|
$source = array();
|
|
foreach($this->sourceTxt as $Source => $Txt) {
|
|
if( $user->checkPerm($this->sourceDroit[$Source]) ) {
|
|
$checked = 'checked';
|
|
if ($Source=='privileges') {
|
|
$checked = '';
|
|
}
|
|
$source[] = array(
|
|
'id' => $Source,
|
|
'txt' => $Txt,
|
|
'checked' => $checked,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
$this->view->assign('source', $source);
|
|
$this->view->assign('siret', $siret);
|
|
$this->view->assign('email', $email);
|
|
$this->view->assign('ref', $ref);
|
|
$this->view->assign('encours', $encours);
|
|
}
|
|
|
|
public function demanderefAction()
|
|
{
|
|
$this->_helper->layout->disableLayout();
|
|
$user = new Scores_Utilisateur();
|
|
$email = $user->getEmail();
|
|
$this->view->assign('email', $email);
|
|
}
|
|
|
|
/**
|
|
* Supprimer une surveillances
|
|
*/
|
|
public function supprimerAction()
|
|
{
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$page = $request->getParam('page');
|
|
$from = $request->getParam('from');
|
|
|
|
$siret = $request->getParam('siret', '');
|
|
$email = $request->getParam('email', '');
|
|
$ref = $request->getParam('ref', '');
|
|
$source = $request->getParam('source', 'annonces');
|
|
|
|
$ws = new WsScores();
|
|
$set = $ws->setSurveillance($siret, $email, urldecode($ref), $source, true);
|
|
|
|
if (isset($from)) {
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
if ( $set->result ) {
|
|
echo "Surveillance supprimé";
|
|
} else {
|
|
echo "Erreur lors de la suppression";
|
|
}
|
|
} elseif (isset($page)) {
|
|
$this->_redirect('surveillance/liste/page/'.$page);
|
|
} else {
|
|
$this->_redirect('surveillance/liste');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ajoute, Supprime, Edite la surveillance (Ajax)
|
|
*/
|
|
public function setAction()
|
|
{
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$siret = $request->getParam('siret', '');
|
|
$email = $request->getParam('email', '');
|
|
$ref = $request->getParam('ref', '');
|
|
$source = $request->getParam('source', 'annonces');
|
|
$delete = $request->getParam('delete', false);
|
|
$encours = $request->getParam('encours', 0);
|
|
|
|
$validateur = new Zend_Validate_EmailAddress();
|
|
|
|
//Vérification siret / email / ref
|
|
if (empty($siret) || empty($email) || empty($ref)){
|
|
$msg = 'Erreur email ou reférence non définie !';
|
|
}
|
|
elseif (!$validateur->isValid($email)) {
|
|
$msg = "Email invalide.";
|
|
}
|
|
//Vérification de l'encours (chiffres)
|
|
elseif (!preg_match('/([0-9]+)/', $encours)){
|
|
$msg = 'Encours incorrect';
|
|
} else {
|
|
if (!empty($delete)){
|
|
$delete = true;
|
|
}
|
|
$ws = new WsScores();
|
|
$set = $ws->setSurveillance($siret, $email, $ref, $source, $delete, $encours);
|
|
if ($set) {
|
|
if ($delete) { $msg = "Suppression surveillance $source"; }
|
|
else { $msg = "Mise sous surveillance $source"; }
|
|
} else {
|
|
if ($delete) { $msg = "Erreur lors de la suppression de la surveillance $source"; }
|
|
else { $msg = "Erreur lors de la mise sous surveillance $source"; }
|
|
}
|
|
}
|
|
$this->view->assign('msg', $msg);
|
|
}
|
|
|
|
/**
|
|
* Ajoute un encours client
|
|
*/
|
|
public function encoursAction()
|
|
{
|
|
$this->_helper->layout->disableLayout();
|
|
$this->_forward('ajouter', 'surveillance', null, array( 'source' => 'score' ));
|
|
}
|
|
|
|
/**
|
|
* Affiche les infos d'une surveillance
|
|
*/
|
|
public function infosAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
|
|
//Javascript
|
|
$theme = Zend_Registry::get('theme');
|
|
$this->view->headScript()
|
|
->appendFile($theme->pathScript.'/surveillance.js', 'text/javascript');
|
|
|
|
$source = $request->getParam('source', '');
|
|
$siret = $request->getParam('siret', 0);
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
//if ($user->checkPerm())
|
|
|
|
$listSurv = array();
|
|
|
|
if (intval($siret)!=0)
|
|
{
|
|
$ws = new WsScores();
|
|
|
|
$filtre = new stdClass();
|
|
$filtre->item = $siret;
|
|
$filtre->itemMode = 'siren';
|
|
$filtre->source = $source;
|
|
$filtre->tri = 'siren';
|
|
$filtre->triMode = 'asc';
|
|
$filtre->detail = false;
|
|
|
|
$infos = $ws->getSurveillances($filtre);
|
|
Zend_Registry::get('firebug')->info($infos);
|
|
|
|
if (property_exists($infos->result, 'item') && count($infos->result->item)>0) {
|
|
$titre = 'Ajouter une surveillance';
|
|
$texte = "L'entité est sous surveillance";
|
|
$item = $infos->result->item[0];
|
|
|
|
foreach($item->sources->item as $surv){
|
|
$tooltipTexte = '';
|
|
$ref = $surv->ref;
|
|
$tooltipTexte.= "Ref : ".$ref;
|
|
$dateAjout = new Zend_Date($surv->dateAjout, 'yyyy-MM-dd');
|
|
$tooltipTexte.= "<br/>Date d'ajout :".$dateAjout->toString('dd/MM/yyyy');
|
|
if ($surv->dateDerEnvoi!='0000-00-00 00:00:00') {
|
|
$date = new Zend_Date(substr($surv->dateDerEnvoi,0,10), 'yyyy-MM-dd');
|
|
$tooltipTexte.= "<br/>Date de dernier envoi : ".$date->toString('dd/MM/yyyy');
|
|
}
|
|
$listSurv[] = array(
|
|
'tooltipTexte' => $tooltipTexte,
|
|
'sourceTexte' => $this->sourceTxt[$surv->source]
|
|
);
|
|
}
|
|
} else {
|
|
$titre = 'Ajouter une surveillance';
|
|
$texte = 'Mettre sous surveillance';
|
|
if (!empty($source)){
|
|
$texte.= ' '.$this->sourceTxt[$source];
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($ref)) {
|
|
$this->view->assign('ref', $ref);
|
|
} else {
|
|
$this->view->assign('ref', '');
|
|
}
|
|
|
|
$this->view->assign('surveillances', $listSurv);
|
|
$this->view->assign('dialogTitre', $titre);
|
|
$this->view->assign('dialogTexte', $texte);
|
|
$this->view->assign('dialogSource', $source);
|
|
}
|
|
|
|
/**
|
|
* Liste les surveillances
|
|
*/
|
|
public function listeAction()
|
|
{
|
|
$user = new Scores_Utilisateur();
|
|
if (!$user->checkPerm('survliste')){
|
|
$this->_forward('perms', 'error');
|
|
}
|
|
|
|
$this->view->headLink()
|
|
->appendStylesheet('/libs/tablesorter/themes/blue/style.css', 'all');
|
|
|
|
$this->view->headScript()
|
|
->appendFile('/libs/tablesorter/jquery.tablesorter.js', 'text/javascript')
|
|
->appendFile('/themes/default/scripts/surveillance.js', 'text/javascript');
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$page = $request->getParam('page', 0);
|
|
$source = $request->getParam('source', '');
|
|
|
|
$tri = $request->getParam('tri', 'siren');
|
|
$this->view->assign('tri', $tri);
|
|
|
|
$triMode = $request->getParam('triMode', 'asc');
|
|
$this->view->assign('triMode', $triMode);
|
|
|
|
$q = $request->getParam('q', null);
|
|
if ( $q == 'Siren, Référence, Raison Sociale' ) { $q = null; }
|
|
$this->view->assign('q', $q);
|
|
|
|
$detail = true;
|
|
|
|
$nbAffichage = 50;
|
|
$position = $page*$nbAffichage;
|
|
|
|
switch ( $tri ) {
|
|
default:
|
|
case 'siren': $triws = 'siren'; break;
|
|
case 'rs': $triws = 'rs'; break;
|
|
case 'reference': $triws = 'ref'; break;
|
|
case 'dateajout': $triws = 'dateAjout'; break;
|
|
case 'datederenvoi': $triws = 'dateDerEnvoi'; break;
|
|
}
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
//Select Tri + Liste des sources autorisées
|
|
$selectTri = '';
|
|
$permSource = array();
|
|
foreach ($this->sourceDroit as $s => $perm) {
|
|
if ($user->checkPerm($perm)) {
|
|
$permSource[] = $s;
|
|
$selectTri.= '<option value="'.$s.'"';
|
|
if ($source == $s) {
|
|
$selectTri.= 'selected';
|
|
}
|
|
$selectTri.= '>'.$this->sourceTxt[$s].'</option>';
|
|
}
|
|
}
|
|
if ( !empty($source) ) {
|
|
$permSource = array( 0 => $source);
|
|
}
|
|
|
|
if ($q != null) {
|
|
$filtre = new stdClass();
|
|
$filtre->item = $q;
|
|
$filtre->itemMode = 'search';
|
|
$filtre->source = $source;
|
|
$filtre->tri = $tri;
|
|
$filtre->triMode = $triMode;
|
|
$filtre->detail = true;
|
|
} else {
|
|
$filtre = new stdClass();
|
|
$filtre->item = '';
|
|
$filtre->itemMode = 'siren';
|
|
$filtre->source = $source;
|
|
$filtre->tri = $tri;
|
|
$filtre->triMode = $triMode;
|
|
$filtre->detail = true;
|
|
}
|
|
|
|
$ws = new WsScores();
|
|
$infos = $ws->getSurveillances($filtre, $position, $nbAffichage);
|
|
|
|
$surveillances = $infos->result->item;
|
|
|
|
$listTrier = array();
|
|
if ( count($surveillances)>0 ) {
|
|
foreach ( $surveillances as $item ) {
|
|
$data = array();
|
|
$data['siren'] = $item->siren;
|
|
foreach ( $item->sources->item as $itemSource ) {
|
|
$data['rs'] = $itemSource->rs;
|
|
$data['cp'] = $itemSource->cp;
|
|
$data['ville'] = $itemSource->ville;
|
|
$data['email'] = $itemSource->email;
|
|
$data['ref'] = $itemSource->ref;
|
|
$data['nic'] = $itemSource->nic;
|
|
$data['sources'][] = array(
|
|
'email' => $itemSource->email,
|
|
'ref' => $itemSource->ref,
|
|
'source' => $itemSource->source,
|
|
'dateAjout' => $itemSource->dateAjout,
|
|
'dateDerEnvoi' => $itemSource->dateDerEnvoi,
|
|
);
|
|
}
|
|
$listTrier[] = $data;
|
|
}
|
|
}
|
|
|
|
//Calcul pagination
|
|
$nbReponses = $infos->nbReponses;
|
|
$nbSurveillances = $infos->nbReponsesTotal;
|
|
$totPage = ceil($nbSurveillances/$nbAffichage);
|
|
$curPage = ceil($position/$nbAffichage);
|
|
|
|
$this->view->assign('source', $source);
|
|
$this->view->assign('selectTri', $selectTri);
|
|
$this->view->assign('listSources', $permSource);
|
|
$this->view->assign('nbReponses', $nbReponses);
|
|
$this->view->assign('nbSurveillances', $nbSurveillances);
|
|
$this->view->assign('totPage', $totPage);
|
|
$this->view->assign('curPage', $curPage);
|
|
$this->view->assign('surveillances', $listTrier);
|
|
$this->view->assign('source', $source);
|
|
}
|
|
|
|
/**
|
|
* Liste les surveillances Scores
|
|
*/
|
|
public function portefeuilleAction()
|
|
{
|
|
$user = new Scores_Utilisateur();
|
|
if(!$user->checkPerm('portefeuille')){
|
|
$this->_forward('perms', 'error');
|
|
}
|
|
|
|
$this->view->headScript()
|
|
->appendFile('/libs/tablesorter/jquery.tablesorter.js', 'text/javascript')
|
|
->appendFile('/themes/default/scripts/surveillance.js', 'text/javascript');
|
|
|
|
$request = $this->getRequest();
|
|
$page = $request->getParam('page', 0);
|
|
|
|
$siren = $request->getParam('siren', null);
|
|
if ( $siren == 'Siren' ) { $siren = null; }
|
|
$this->view->assign('siren', $siren);
|
|
|
|
$ref = $request->getParam('ref', null);
|
|
if ( $ref == 'Référence' ) { $ref = null; }
|
|
$this->view->assign('ref', $ref);
|
|
|
|
$rs = $request->getParam('rs', null);
|
|
if ( $rs == 'Raison Sociale' ) { $rs = null; }
|
|
$this->view->assign('rs', $rs);
|
|
|
|
$tri = $request->getParam('tri', 'siren');
|
|
|
|
$nbAffichage = 100;
|
|
$position = $page*$nbAffichage;
|
|
|
|
switch ( $tri ){
|
|
default:
|
|
case 'siren': $triws = 'siren'; break;
|
|
case 'rs': $triws = 'rs'; break;
|
|
case 'reference': $triws = 'ref'; break;
|
|
case 'dateajout': $triws = 'dateAjout'; break;
|
|
case 'datederenvoi': $triws = 'dateDerEnvoi'; break;
|
|
case 'score' : $triws = 'indiScore'; break;
|
|
}
|
|
|
|
$user = new Scores_Utilisateur();
|
|
$maxIndiscore = $user->getTypeScore();
|
|
$typeScore = ($maxIndiscore == '100') ? '' : '20';
|
|
|
|
$dicoSource = array(
|
|
'ajout' => '',
|
|
'bilans1' => 'publication bilan',
|
|
'bilans2' => 'publication bilan',
|
|
'bodacc' => 'publication bodacc',
|
|
'collecte' => 'publication légale',
|
|
'dirigeants' => 'modification de l\'administration',
|
|
'insee' => 'modification identitaire',
|
|
'liens' => 'mise à jour de la structure du groupe',
|
|
'default' => 'modification identitaire',
|
|
);
|
|
|
|
$couleurRisque100 = array(
|
|
'rouge' => array('min'=>0, 'max'=>40),
|
|
'orange' => array('min'=>41, 'max'=>50),
|
|
'vert' => array('min'=>51, 'max'=>100),
|
|
);
|
|
|
|
$couleurRisque20 = array(
|
|
'rouge' => array('min'=>0, 'max'=>6),
|
|
'orange' => array('min'=>7, 'max'=>10),
|
|
'vert' => array('min'=>11, 'max'=>20),
|
|
);
|
|
|
|
$ws = new WsScores();
|
|
|
|
$filtre = new stdClass();
|
|
$filtre->tri = $triws;
|
|
$filtre->siret = ($siren!=null) ? $siren : '';
|
|
$filtre->ref = ($ref!=null) ? $ref : '';
|
|
$filtre->rs = ($rs!=null) ? $rs : '';
|
|
$infos = $ws->getPortefeuille($filtre, $position, $nbAffichage);
|
|
|
|
$portefeuille = $infos->result->item;
|
|
|
|
$tabResult = array();
|
|
if ( count($portefeuille)>0 ) {
|
|
foreach ( $portefeuille as $item ) {
|
|
$result = new stdClass();
|
|
$result = $item;
|
|
|
|
//Classe de risque
|
|
$couleurV = ${'couleurRisque'.$maxIndiscore};
|
|
foreach($couleurV as $couleur => $intervalle)
|
|
{
|
|
if($item->{'indiScore'.$typeScore}>=$intervalle['min'] &&
|
|
$item->{'indiScore'.$typeScore}<=$intervalle['max']){
|
|
break;
|
|
}
|
|
}
|
|
$indiScore = $item->{'indiScore'.$typeScore};
|
|
$indiScorePre = empty($item->{'indiScore'.$typeScore.'Pre'}) ?
|
|
0 : $item->{'indiScore'.$typeScore.'Pre'};
|
|
|
|
//Variation du risque
|
|
$variation = abs($item->indiScore-$item->indiScorePre);
|
|
if($variation>=5 && $variation<=9){
|
|
$deg = '45';
|
|
}else{
|
|
$deg = '';
|
|
}
|
|
|
|
//Tooltip
|
|
$tooltip = '';
|
|
if($item->procol=='P'){
|
|
$tooltip.= 'En procédure collective.<br/>';
|
|
}
|
|
if($item->actif==0){
|
|
$tooltip.= 'Établissement inactif.<br/>';
|
|
}
|
|
$tooltip.= '- Dernier exercice pris en compte : ';
|
|
if ($item->dateBilan=='0000-00-00') {
|
|
$tooltip.= 'Néant';
|
|
} else {
|
|
$date = new Zend_Date($item->dateBilan,'yyyy-MM-dd');
|
|
$tooltip.= 'le '.$date->toString('dd/MM/yyyy');
|
|
}
|
|
$tooltip.= '<br/>';
|
|
if ($item->sourceModif!='ajout') {
|
|
if (!empty($item->sourceModif)) {
|
|
$tooltip.= '- Dernière modification ';
|
|
if( $item->indiScoreDate=='0000-00-00') {
|
|
$tooltip.= '';
|
|
}
|
|
if (!empty($item->sourceModif)) {
|
|
if (in_array($item->sourceModif, $dicoSource)) {
|
|
$sourceModif = $item->sourceModif;
|
|
} else {
|
|
$sourceModif = 'default';
|
|
}
|
|
$tooltip.= ', suite à '.$dicoSource[$sourceModif];
|
|
}
|
|
$tooltip.= '<br/>';
|
|
}
|
|
if ($item->indiScoreDatePre!='0000-00-00') {
|
|
$tooltip.= '- Précédent score : '.$indiScorePre.'/'.$maxIndiscore;
|
|
}
|
|
}
|
|
|
|
$result->tooltip = $tooltip;
|
|
|
|
//Affichage score
|
|
$colScore = '';
|
|
if( $item->indiScoreDate!='0000-00-00' &&
|
|
$item->procol!='P' && $item->actif!=0)
|
|
{
|
|
$colScore.= '<span>'.$indiScore.'/'.$maxIndiscore.'</span>';
|
|
|
|
//Procols
|
|
if ($item->procol=='P') {
|
|
$colScore.= '<img src="/themes/default/images/portefeuille/score_alert.gif"/>';
|
|
//Constant
|
|
} elseif($indiScore==$indiScorePre || $item->sourceModif=='ajout') {
|
|
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'constant.gif"/>';
|
|
//Hausse
|
|
} elseif($indiScore>$indiScorePre) {
|
|
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'hausse'.$deg.'.gif"/>';
|
|
//Baisse
|
|
}elseif($indiScore<$indiScorePre){
|
|
$colScore.= '<img src="/themes/default/images/portefeuille/score_'.$couleur.'baisse'.$deg.'.gif"/>';
|
|
}
|
|
} else {
|
|
if ($item->procol=='P') {
|
|
$colScore.= '<img src="/themes/default/images/portefeuille/score_alert.gif"/>';
|
|
} else {
|
|
$colScore.= '-';
|
|
}
|
|
}
|
|
$result->colScore = $colScore;
|
|
|
|
$tabResult[] = $result;
|
|
}
|
|
}
|
|
|
|
//Calcul pagination
|
|
$nbReponses = $infos->nbReponses;
|
|
$nbSurveillances = $infos->nbReponsesTotal;
|
|
$totPage = ceil($nbSurveillances/$nbAffichage);
|
|
$curPage = ceil($position/$nbAffichage);
|
|
|
|
$this->view->assign('nbReponses', $nbReponses);
|
|
$this->view->assign('nbSurveillances', $nbSurveillances);
|
|
$this->view->assign('totPage', $totPage);
|
|
$this->view->assign('curPage', $curPage);
|
|
$this->view->assign('portefeuille',$tabResult);
|
|
}
|
|
|
|
/**
|
|
* Affiche le lien pour exporter le portefeuille au format csv
|
|
*/
|
|
public function portefeuillecsvAction()
|
|
{
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/portefeuillecsv.js', 'text/javascript');
|
|
}
|
|
|
|
/**
|
|
* Affiche le lien pour exporter les surveillances au format csv
|
|
*/
|
|
public function surveillancecsvAction()
|
|
{
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/surveillancecsv.js', 'text/javascript');
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
$request = $this->getRequest();
|
|
$source = $request->getParam('source');
|
|
|
|
$tabSource = array();
|
|
|
|
foreach ($this->sourceDroit as $s => $perm) {
|
|
if ($user->checkPerm($perm)) {
|
|
$tabSource[] = array(
|
|
'value' => $s,
|
|
'name' => $this->sourceTxt[$s],
|
|
'select' => (!empty($source) && $source==$s) ? ' selected' : '',
|
|
);
|
|
}
|
|
}
|
|
|
|
$this->view->assign('tabSource', $tabSource);
|
|
|
|
}
|
|
|
|
/**
|
|
* Affichage des surveillances par fichier pour les clients
|
|
*/
|
|
public function fichierAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
$this->view->assign('login', $user->getLogin());
|
|
$this->view->assign('nom', $user->getNom());
|
|
|
|
$client = new SoapClient(null, array(
|
|
'trace' => 1,
|
|
'soap_version' => SOAP_1_1,
|
|
'location' => 'http://78.31.45.206/ws2/',
|
|
'uri' => 'http://78.31.45.206/',
|
|
'login' => $user->getLogin(),
|
|
'password' => $user->getPassword()
|
|
));
|
|
|
|
$nomFic = $request->getParam('nomFic', '');
|
|
$getCSV = $request->getParam('get', '');
|
|
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->files;
|
|
|
|
//Lister les fichiers
|
|
if (empty($nomFic)){
|
|
$ref = $user->getPrenom();
|
|
if ( strtolower($user->getLogin())=='cnasea95'
|
|
|| strtolower($user->getLogin())=='cnasea96'
|
|
|| strtolower($user->getLogin())=='omni04'
|
|
|| strtolower($user->getLogin())=='bodacca3m'
|
|
|| strtolower($user->getLogin())=='bodaccomni'
|
|
|| strtolower($user->getLogin())=='bodacccrr'
|
|
|| strtolower($user->getLogin())=='cpcambr13'
|
|
|| strtolower($user->getLogin())=='cpcambr14'
|
|
|| $user->getIdClient()==32
|
|
|| $user->getIdClient()==82) {
|
|
$ref='*';
|
|
}
|
|
try {
|
|
$O = $client->getListeFichierSurv($user->getLogin(), $ref, $nomFic);
|
|
$tabFichier = $O['results'];
|
|
} catch (SoapFault $fault) {}
|
|
|
|
$listeFichier = array();
|
|
foreach($tabFichier as $fichier){
|
|
$tabTmp = explode('_', $fichier);
|
|
$date = new Zend_Date(substr($tabTmp[2],0,8),'yyyyMMdd');
|
|
$localfile = $path.'/'.$fichier;
|
|
$dejaLu = false;
|
|
if (!file_exists($localfile)) {
|
|
$dejaLu = true;
|
|
}
|
|
$result = array(
|
|
'fichier' => $fichier,
|
|
'date' => $date->toString('dd/MM/yyyy'),
|
|
'dejaLu' => $dejaLu,
|
|
);
|
|
$listeFichier[] = $result;
|
|
}
|
|
$this->view->assign('listeFichier', $listeFichier);
|
|
}
|
|
//Lister les annonces
|
|
elseif (empty($getCSV))
|
|
{
|
|
$selectFiltre = array(
|
|
'procol' => array('lib'=> 'Procédures collectives', 'select'=>''),
|
|
'radiations' => array('lib'=> 'Radiations', 'select'=>''),
|
|
'ventes' => array('lib'=> 'Ventes/Cessions', 'select'=>''),
|
|
'mmd' => array('lib'=> 'Modifications diverses', 'select'=>''),
|
|
);
|
|
|
|
$filtre = $request->getParam('filtre', '');
|
|
|
|
if (strtolower($user->getLogin())=='cpcambr13') {
|
|
$selectFiltre = array(
|
|
'procol' => array('lib'=> 'Procédures collectives', 'select'=>' selected'),
|
|
);
|
|
$filtre = 'procol';
|
|
} elseif (strtolower($user->getLogin())=='cpcambr14') {
|
|
$selectFiltre = array(
|
|
'radiations' => array('lib'=> 'Radiations', 'select'=>''),
|
|
'ventes' => array('lib'=> 'Ventes/Cessions', 'select'=>''),
|
|
'mmd' => array('lib'=> 'Modifications diverses', 'select'=>''),
|
|
);
|
|
}
|
|
|
|
if (!empty($filtre)) {
|
|
switch (trim(strtolower($filtre))) {
|
|
case 'procol': $filtre = 'procol'; break;
|
|
case 'mmd': $filtre = 'mmd'; break;
|
|
case 'radiations': $filtre = 'radiations'; break;
|
|
case 'ventes': $filtre = 'ventes'; break;
|
|
case 'comptes': $filtre = 'comptes'; break;
|
|
case 'creations': $filtre = 'creations'; break;
|
|
case 'bodacc': $filtre = 'bodacc'; break;
|
|
default: $filtre = ''; break;
|
|
}
|
|
if (array_key_exists($filtre, $selectFiltre)) {
|
|
$selectFiltre[$filtre]['select'] = ' selected';
|
|
}
|
|
}
|
|
$this->view->assign('selectFiltre', $selectFiltre);
|
|
|
|
//Récupération du fichier
|
|
$file = $path.'/'.$nomFic;
|
|
if (!file_exists($file) || filesize($file)==0 ) {
|
|
//Génération du fichier
|
|
try {
|
|
$O = $client->getListeFichierSurv($user->getLogin(), $user->getPrenom(), $nomFic);
|
|
} catch (SoapFault $fault) {}
|
|
|
|
try {
|
|
$client = new Zend_Http_Client('http://78.31.45.206/csv/'.$nomFic.'.bz2');
|
|
$client->setStream();
|
|
$response = $client->request('GET');
|
|
if ( copy($response->getStreamName(), $file.'.bz2') ) {
|
|
$bz = bzopen($file.'.bz2', "r") or die("Impossible d'ouvrir le fichier $file");
|
|
$fp=fopen($file, 'w');
|
|
while (!feof($bz)) {
|
|
fwrite($fp, bzread($bz, 4096));
|
|
}
|
|
bzclose($bz);
|
|
}
|
|
} catch (Zend_Http_Client_Exception $e) {}
|
|
}
|
|
|
|
$tab = array();
|
|
$row = 0;
|
|
$count = 0;
|
|
$handle = fopen($file, "r");
|
|
while (($ann = fgetcsv($handle, 3000, ';')) !== FALSE)
|
|
{
|
|
$row++;
|
|
if ($row==1)
|
|
{
|
|
// Ligne d'entête, on repère les colonnes
|
|
$num = count($ann);
|
|
for ($i=0; $i<$num; $i++)
|
|
{
|
|
if (utf8_encode($ann[$i])=='SITE_CNASEA') $colSiteCnasea=$i;
|
|
elseif(utf8_encode($ann[$i])=='Siren') $colSiren=$i;
|
|
elseif(utf8_encode($ann[$i])=='Nic') $colNic=$i;
|
|
elseif(utf8_encode($ann[$i])=='Référence') $colRef=$i;
|
|
elseif(utf8_encode($ann[$i])=='Parution') $colParution=$i;
|
|
elseif(utf8_encode($ann[$i])=='Bodacc') $colBodacc=$i;
|
|
elseif(utf8_encode($ann[$i])=='Date parution') $colDatePar=$i;
|
|
elseif(utf8_encode($ann[$i])=='Numéro Annonce') $colNumAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Type Annonce') $colTypeAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Tribunal') $colTribunal=$i;
|
|
elseif(utf8_encode($ann[$i])=='Numéro RCS') $colNumRCS=$i;
|
|
elseif(utf8_encode($ann[$i])=='Raison sociale') $colRaisonSociale=$i;
|
|
elseif(utf8_encode($ann[$i])=='Chapitre') $colChapitre=$i;
|
|
elseif(utf8_encode($ann[$i])=='Evènement(s)') $colEven=$i;
|
|
elseif(utf8_encode($ann[$i])=='Texte Annonce') $colTexteAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Date évènement') $colDateEven=$i;
|
|
}
|
|
}
|
|
elseif ($filtre!='' && $filtre!='bodacc' && $ann[$colChapitre]!=$filtre )
|
|
{
|
|
//On fait rien
|
|
}
|
|
else
|
|
{
|
|
//$filtre=='bodacc'
|
|
if( substr($user->getLogin(),0,6)=='cnasea' && $ann[$colBodacc]!='A' && $ann[$colBodacc]!='B' && $ann[$colBodacc]!='C' )
|
|
{
|
|
//on supprime toutes les annonces pas bodacc
|
|
}
|
|
elseif (strtolower($user->getLogin())=='cpcambr14' && $ann[$colChapitre]=='procol')
|
|
{
|
|
//On supprime les annnonces de procol pour ce login
|
|
}
|
|
else
|
|
{
|
|
$tab[$count]['RaisonSociale'] = utf8_encode($ann[$colRaisonSociale]);
|
|
$tab[$count]['Siren'] = utf8_encode($ann[$colSiren]);
|
|
$tab[$count]['SiteCnasea'] = utf8_encode($ann[$colSiteCnasea]);
|
|
$tab[$count]['Ref'] = utf8_encode($ann[$colRef]);
|
|
$tab[$count]['Parution'] = utf8_encode($ann[$colParution]);
|
|
$tab[$count]['Bodacc'] = utf8_encode($ann[$colBodacc]);
|
|
$date = new Zend_Date($ann[$colDatePar],'yyyyMMdd');
|
|
$tab[$count]['DatePar'] = $date->toString('dd/MM/yyyy');
|
|
$tab[$count]['Tribunal'] = utf8_encode($ann[$colTribunal]);
|
|
$tab[$count]['Even'] = utf8_encode(str_replace(', ','<br/>',$ann[$colEven]));
|
|
$tab[$count]['TexteAnn'] = utf8_encode($ann[$colTexteAnn]);
|
|
$count++;
|
|
}
|
|
}
|
|
}
|
|
fclose($handle);
|
|
|
|
$this->view->assign('annonces', $tab);
|
|
$this->view->assign('nomFic', $nomFic);
|
|
$this->renderScript('surveillance/fichier-ann.phtml');
|
|
} else {
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
//Récupération du fichier
|
|
$file = $path.'/'.$nomFic;
|
|
if (!file_exists($file) || filesize($file)==0 ) {
|
|
//Génération du fichier
|
|
try {
|
|
$O = $client->getListeFichierSurv($user->getLogin(), $user->getPrenom(), $nomFic);
|
|
} catch (SoapFault $fault) {}
|
|
|
|
try {
|
|
$client = new Zend_Http_Client('http://78.31.45.206/csv/'.$nomFic.'.bz2');
|
|
$client->setStream();
|
|
$response = $client->request('GET');
|
|
if ( copy($response->getStreamName(), $file.'.bz2') ) {
|
|
$bz = bzopen($file.'.bz2', "r") or die("Impossible d'ouvrir le fichier $file");
|
|
$fp=fopen($file, 'w');
|
|
while (!feof($bz)) {
|
|
fwrite($fp, bzread($bz, 4096));
|
|
}
|
|
bzclose($bz);
|
|
}
|
|
} catch (Zend_Http_Client_Exception $e) {}
|
|
}
|
|
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
//Envoi du fichier sur la sortie standard
|
|
if ( file_exists($file) ) {
|
|
header('Content-Transfer-Encoding: none');
|
|
header('Content-type: ' . $content_type.'');
|
|
header('Content-Length: ' . filesize($file));
|
|
header('Content-MD5: ' . base64_encode(md5_file($file)));
|
|
header('Content-Disposition: filename="' . basename($file) . '"');
|
|
header('Cache-Control: private, max-age=0, must-revalidate');
|
|
header('Pragma: public');
|
|
ini_set('zlib.output_compression', '0');
|
|
echo file_get_contents($file);
|
|
} else {
|
|
echo 'Impossible de charger le fichier.';
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Export surveillance en fichier pdf
|
|
*/
|
|
public function fichierpdfAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
$client = new SoapClient(null, array(
|
|
'trace' => 1,
|
|
'soap_version' => SOAP_1_1,
|
|
'location' => 'http://78.31.45.206/ws2/',
|
|
'uri' => 'http://78.31.45.206/',
|
|
'login' => $user->getLogin(),
|
|
'password' => $user->getPassword()
|
|
));
|
|
|
|
$nomFic = $request->getParam('q', '');
|
|
|
|
$filtre = $request->getParam('filtre', '');
|
|
|
|
if (strtolower($user->getLogin())=='cpcambr13') {
|
|
$filtre = 'procol';
|
|
}
|
|
|
|
if (!empty($filtre)){
|
|
switch (trim(strtolower($filtre))) {
|
|
case 'procol': $filtre = 'procol'; break;
|
|
case 'mmd': $filtre = 'mmd'; break;
|
|
case 'radiations': $filtre = 'radiations'; break;
|
|
case 'ventes': $filtre = 'ventes'; break;
|
|
case 'comptes': $filtre = 'comptes'; break;
|
|
case 'creations': $filtre = 'creations'; break;
|
|
case 'bodacc': $filtre = 'bodacc'; break;
|
|
default: $filtre = ''; break;
|
|
}
|
|
}
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->files;
|
|
|
|
//Récupération du fichier
|
|
$file = $path.'/'.$nomFic;
|
|
if (!file_exists($file) || filesize($file)==0 ) {
|
|
//Génération du fichier
|
|
try {
|
|
$O = $client->getListeFichierSurv($user->getLogin(), $user->getPrenom(), $nomFic);
|
|
} catch (SoapFault $fault) {}
|
|
|
|
try {
|
|
$client = new Zend_Http_Client('http://78.31.45.206/csv/'.$nomFic.'.bz2');
|
|
$client->setStream();
|
|
$response = $client->request('GET');
|
|
if ( copy($response->getStreamName(), $file.'.bz2') ) {
|
|
$bz = bzopen($file.'.bz2', "r") or die("Impossible d'ouvrir le fichier $file");
|
|
$fp=fopen($file, 'w');
|
|
while (!feof($bz)) {
|
|
fwrite($fp, bzread($bz, 4096));
|
|
}
|
|
bzclose($bz);
|
|
}
|
|
} catch (Zend_Http_Client_Exception $e) {}
|
|
}
|
|
|
|
$tab = array();
|
|
$row = 0;
|
|
$count = 0;
|
|
$handle = fopen($file, "r");
|
|
while (($ann = fgetcsv($handle, 3000, ';')) !== FALSE)
|
|
{
|
|
$row++;
|
|
if ($row==1)
|
|
{
|
|
// Ligne d'entête, on repère les colonnes
|
|
$num = count($ann);
|
|
for ($i=0; $i<$num; $i++)
|
|
{
|
|
if (utf8_encode($ann[$i])=='SITE_CNASEA') $colSiteCnasea=$i;
|
|
elseif(utf8_encode($ann[$i])=='Siren') $colSiren=$i;
|
|
elseif(utf8_encode($ann[$i])=='Nic') $colNic=$i;
|
|
elseif(utf8_encode($ann[$i])=='Référence') $colRef=$i;
|
|
elseif(utf8_encode($ann[$i])=='Parution') $colParution=$i;
|
|
elseif(utf8_encode($ann[$i])=='Bodacc') $colBodacc=$i;
|
|
elseif(utf8_encode($ann[$i])=='Date parution') $colDatePar=$i;
|
|
elseif(utf8_encode($ann[$i])=='Numéro Annonce') $colNumAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Type Annonce') $colTypeAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Tribunal') $colTribunal=$i;
|
|
elseif(utf8_encode($ann[$i])=='Numéro RCS') $colNumRCS=$i;
|
|
elseif(utf8_encode($ann[$i])=='Raison sociale') $colRaisonSociale=$i;
|
|
elseif(utf8_encode($ann[$i])=='Chapitre') $colChapitre=$i;
|
|
elseif(utf8_encode($ann[$i])=='Evènement(s)') $colEven=$i;
|
|
elseif(utf8_encode($ann[$i])=='Texte Annonce') $colTexteAnn=$i;
|
|
elseif(utf8_encode($ann[$i])=='Date évènement') $colDateEven=$i;
|
|
}
|
|
}
|
|
elseif ($filtre!='' && $filtre!='bodacc' && $ann[$colChapitre]!=$filtre )
|
|
{
|
|
//On fait rien
|
|
}
|
|
else
|
|
{
|
|
//$filtre=='bodacc'
|
|
if( substr($user->getLogin(),0,6)=='cnasea' && $ann[$colBodacc]!='A' && $ann[$colBodacc]!='B' && $ann[$colBodacc]!='C' )
|
|
{
|
|
//on supprime toutes les annonces pas bodacc
|
|
}
|
|
elseif (strtolower($user->getLogin())=='cpcambr14' && $ann[$colChapitre]=='procol')
|
|
{
|
|
//On supprime les annnonces de procol pour ce login
|
|
}
|
|
else
|
|
{
|
|
$tab[$count]['RaisonSociale'] = utf8_encode($ann[$colRaisonSociale]);
|
|
$tab[$count]['Siren'] = utf8_encode($ann[$colSiren]);
|
|
$tab[$count]['SiteCnasea'] = utf8_encode($ann[$colSiteCnasea]);
|
|
$tab[$count]['Ref'] = utf8_encode($ann[$colRef]);
|
|
$tab[$count]['Parution'] = utf8_encode($ann[$colParution]);
|
|
$tab[$count]['Bodacc'] = utf8_encode($ann[$colBodacc]);
|
|
$date = new Zend_Date($ann[$colDatePar],'yyyyMMdd');
|
|
$tab[$count]['DatePar'] = $date->toString('dd/MM/yyyy');
|
|
$tab[$count]['Tribunal'] = utf8_encode($ann[$colTribunal]);
|
|
$tab[$count]['Even'] = utf8_encode(str_replace(', ','<br/>',$ann[$colEven]));
|
|
$tab[$count]['TexteAnn'] = utf8_encode($ann[$colTexteAnn]);
|
|
$count++;
|
|
}
|
|
}
|
|
}
|
|
fclose($handle);
|
|
|
|
$page = $request->getParam('page', '');
|
|
$nbAnnoncesMin = ($page-1)*100;
|
|
$nbAnnoncesMax = $nbAnnoncesMin+100;
|
|
|
|
$output = '';
|
|
$count = 0;
|
|
$annonces = $tab;
|
|
$nbAnnonces = count($annonces);
|
|
|
|
if($nbAnnonces>0){
|
|
foreach($annonces as $annonce){
|
|
if($count>$nbAnnoncesMax) break;
|
|
if($count>=$nbAnnoncesMin)
|
|
{
|
|
$output.= '<page backtop="10mm" backbottom="10mm">';
|
|
$output.= '<page_header>';
|
|
$output.= '<table style="width:100%; border:solid 1px black;">';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="text-align:left; width:67%">Surveillance : '.$count.'/'.$nbAnnonces.'</td>';
|
|
$output.= '<td style="text-align:right; width:33%">'.date('d/m/Y').'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '</table>';
|
|
$output.= '</page_header>';
|
|
$output.= '<table style="width:100%;">';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:50%;">Entreprise : '.$annonce['RaisonSociale'].' ('.$annonce['Siren'].')</td>';
|
|
$output.= '<td style="width:50%;"> </td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:50%;">Site : '.$annonce['SiteCnasea'].'</td>';
|
|
$output.= '<td style="width:50%;">Référence : '.$annonce['Ref'].'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
if ($annonce['Bodacc']=='A' || $annonce['Bodacc']=='B' || $annonce['Bodacc']=='C')
|
|
{
|
|
$source = 'BODACC n°'.$annonce['Parution'].' '.$annonce['Bodacc'].' du '.$annonce['DatePar'].' '.$annonce['Tribunal'].'.';
|
|
}
|
|
elseif ($annonce['Bodacc']=='G')
|
|
{
|
|
$source = 'GREFFE du '.$annonce['Tribunal'].' au '.$annonce['DatePar'].'.';
|
|
}
|
|
elseif ($annonce['Bodacc']=='P')
|
|
{
|
|
$source = 'RNCS du '.$annonce['Tribunal'].' au '.$annonce['DatePar'].'.';
|
|
}
|
|
else
|
|
{
|
|
$source = 'Collecte SD du '.$annonce['Tribunal'].' au '.$annonce['DatePar'].'.';
|
|
}
|
|
$output.= '<td style="width:100%;" colspan="2">'.$source.'</td>';
|
|
|
|
$output.= '</tr>';
|
|
$output.= '<tr><td style="width:100%;" colspan="2"> </td></tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:100%;" colspan="2"><b>'.$annonce['Even'].'</b></td>';
|
|
$output.= '</tr>';
|
|
$output.= '<tr>';
|
|
$output.= '<td style="width:100%;" colspan="2">'.$annonce['TexteAnn'].'</td>';
|
|
$output.= '</tr>';
|
|
$output.= '</table>';
|
|
$output.= '</page>';
|
|
}
|
|
$count++;
|
|
}
|
|
}else{
|
|
/*
|
|
* Fermeture de la balise page lorsqu'il n'y a aucune annonce
|
|
* afin de générer un fichier pdf vide et non pas une erreur
|
|
*/
|
|
$output = '</page>';
|
|
}
|
|
// conversion HTML => PDF
|
|
require_once 'Vendors/html2pdf/html2pdf.class.php';
|
|
$html2pdf = new HTML2PDF('P','A4','fr');
|
|
$html2pdf->WriteHTML(utf8_decode($output));
|
|
$html2pdf->Output(str_replace('.csv', '.pdf', $nomFic), 'D');
|
|
}
|
|
} |