2009-05-20 15:49:08 +00:00
|
|
|
<?php
|
2009-12-16 11:14:54 +00:00
|
|
|
require_once 'user/user.php';
|
|
|
|
|
|
|
|
function assocSourceDroit(){
|
|
|
|
return array(
|
|
|
|
'annonces' => 'survannonce',
|
|
|
|
'insee' => 'survinsee',
|
|
|
|
'bilans' => 'survbilan',
|
|
|
|
'score' => 'survscore',
|
|
|
|
'actes' => 'survactes',
|
|
|
|
'dirigeants' => 'survdirigeants',
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function assocSourceTxt(){
|
|
|
|
return array(
|
2010-02-10 17:27:03 +00:00
|
|
|
'annonces' => 'les annonces légales',
|
|
|
|
'insee' => 'les événements INSEE',
|
2009-12-16 11:14:54 +00:00
|
|
|
'bilans' => 'les bilans',
|
|
|
|
'score' => 'IndiScore',
|
|
|
|
'actes' => 'les actes & status',
|
|
|
|
'dirigeants' => 'les dirigeants',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-20 15:49:08 +00:00
|
|
|
/**
|
|
|
|
* Affiche le formulaire surveillance.
|
|
|
|
*
|
|
|
|
* @param string $page
|
2010-02-10 17:27:03 +00:00
|
|
|
* La page ou l'on affiche le formulaire, détermine le type de surveillance.
|
2009-05-20 15:49:08 +00:00
|
|
|
* @param string $siret
|
2010-02-10 17:27:03 +00:00
|
|
|
* L'établissement à surveiller.
|
2009-05-20 15:49:08 +00:00
|
|
|
* @param array $notEmail
|
|
|
|
* Un tableau de login pour exclure l'affichage de l'adresse email
|
|
|
|
* @return string
|
2010-02-10 17:27:03 +00:00
|
|
|
* Retourne sous forme de chaine de caractère le fomulaire en HTML
|
2009-05-20 15:49:08 +00:00
|
|
|
*/
|
|
|
|
function formSurveillance($source, $siret, $notEmail, $displayAjax = TRUE){
|
2009-12-16 11:14:54 +00:00
|
|
|
|
2009-12-17 09:40:18 +00:00
|
|
|
$assocSourceTxt = assocSourceTxt();
|
2009-12-16 11:14:54 +00:00
|
|
|
$assocSourceDroit = assocSourceDroit();
|
2009-05-20 15:49:08 +00:00
|
|
|
|
|
|
|
$fileStyle = 'style.css';
|
|
|
|
$fileJs = 'script.js';
|
2009-12-22 07:59:16 +00:00
|
|
|
if($displayAjax || empty($source))
|
2009-12-21 17:40:59 +00:00
|
|
|
{
|
|
|
|
if(!empty($source)) $fileStyle = 'style-ajax.css';
|
2009-05-22 09:53:48 +00:00
|
|
|
$fileJs = 'script-ajax.js';
|
2009-05-20 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$style = file_get_contents(realpath(dirname(__FILE__)).'/'.$fileStyle);
|
|
|
|
$js = file_get_contents(realpath(dirname(__FILE__)).'/'.$fileJs);
|
|
|
|
|
|
|
|
$formHTML = '';
|
|
|
|
$formHTML.= '<script type="text/javascript" src="./js/jquery.form.js"></script>'."\n";
|
|
|
|
$formHTML.= '<script type="text/javascript">'.$js.'</script>'."\n";
|
|
|
|
$formHTML.= '<style type="text/css">'.$style.'</style>'."\n";
|
2009-12-16 08:17:03 +00:00
|
|
|
$formHTML.= '<form id="frmSurv" name="frmSurv" action="./pages/ajax_surveillance.php" method="post">'."\n";
|
2009-05-22 12:26:07 +00:00
|
|
|
if($displayAjax){
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '<input name="surveillance" type="checkbox"/> Mettre sous surveillance '.$assocSourceTxt[$source].'<br/>'."\n";
|
2009-05-22 12:26:07 +00:00
|
|
|
}
|
2009-05-20 15:49:08 +00:00
|
|
|
$formHTML.= '<input name="q" type="hidden" value="setsurv"/>';
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '<input name="formSurv[siret]" type="hidden" value="'.$siret.'"/>'."\n";
|
2009-12-15 16:55:43 +00:00
|
|
|
|
2009-12-16 08:17:03 +00:00
|
|
|
if(empty($source))
|
|
|
|
{
|
2009-12-15 16:55:43 +00:00
|
|
|
$formHTML.= '<div class="fieldgrp">'."\n";
|
2009-12-16 08:17:03 +00:00
|
|
|
$formHTML.= '<label>Types</label>'."\n";
|
2009-12-15 16:55:43 +00:00
|
|
|
$formHTML.= '<div class="field">'."\n";
|
2009-12-15 15:29:42 +00:00
|
|
|
foreach($assocSourceTxt as $Source => $Txt)
|
|
|
|
{
|
2009-12-18 17:47:59 +00:00
|
|
|
if(hasPerm($assocSourceDroit[$Source]))
|
2009-12-16 11:14:54 +00:00
|
|
|
{
|
2009-12-18 17:47:59 +00:00
|
|
|
$formHTML.='<input type="checkbox" name="formSurv[source][]" value="'.$Source.'" checked/> '.$Txt."<br/>\n";
|
2009-12-16 11:14:54 +00:00
|
|
|
}
|
2009-12-15 15:29:42 +00:00
|
|
|
}
|
2009-12-15 16:55:43 +00:00
|
|
|
$formHTML.= '</div>'."\n";
|
|
|
|
$formHTML.= '</div>'."\n";
|
2009-12-15 15:29:42 +00:00
|
|
|
}else{
|
|
|
|
$formHTML.= '<input name="formSurv[source]" type="hidden" value="'.$source.'"/>'."\n";
|
|
|
|
}
|
2009-05-20 15:49:08 +00:00
|
|
|
|
2009-05-22 15:16:50 +00:00
|
|
|
$ref='';
|
|
|
|
if(isset($_REQUEST['ref'])){
|
|
|
|
$ref = $_REQUEST['ref'];
|
|
|
|
}
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '<div id="survForm">'."\n";
|
|
|
|
$formHTML.= '<div class="fieldgrp">'."\n";
|
2010-02-10 17:27:03 +00:00
|
|
|
$formHTML.= '<label class="StyleInfoLib">Votre référence</label><div class="field"><input name="formSurv[ref]" type="text" value="'.$ref.'" size="10"/></div>'."\n";
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '</div>'."\n";
|
2009-05-22 15:16:50 +00:00
|
|
|
|
2009-05-20 15:49:08 +00:00
|
|
|
$email = '';
|
2009-05-22 15:16:50 +00:00
|
|
|
if(!in_array($_SESSION['tabInfo']['login'],$notEmail) && !isset($_REQUEST['email'])){
|
2009-05-20 15:49:08 +00:00
|
|
|
$email = $_SESSION['tabInfo']['email'];
|
2009-05-22 15:16:50 +00:00
|
|
|
}elseif(isset($_REQUEST['email'])){
|
|
|
|
$email = $_REQUEST['email'];
|
2009-05-20 15:49:08 +00:00
|
|
|
}
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '<div class="fieldgrp">'."\n";;
|
|
|
|
$formHTML.= '<label class="StyleInfoLib">Adresse email du destinataire</label><div class="field"><input name="formSurv[email]" type="text" value="'.$email.'" size="20"/></div>'."\n";
|
|
|
|
$formHTML.= '</div>'."\n";;
|
2009-12-16 10:09:30 +00:00
|
|
|
$formHTML.= '<div class="submit"><p class="submit-button">'."\n";
|
2009-09-18 17:09:22 +00:00
|
|
|
$formHTML.= '<input class="submit" type="image" src="./img/boutton_valider_off.gif" name="submit" onmouseover="this.src=\'./img/boutton_valider_on.gif\'" onmouseout="this.src=\'./img/boutton_valider_off.gif\'" title="Mettre sous surveillance...">'."\n";
|
|
|
|
$formHTML.= '</p></div>'."\n";
|
|
|
|
$formHTML.= '</div>'."\n";
|
|
|
|
$formHTML.= '</form>'."\n";
|
2009-05-20 15:49:08 +00:00
|
|
|
return $formHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* Gère la détection des droits et des préférences pour l'affichage de la surveillance.
|
2009-05-20 15:49:08 +00:00
|
|
|
*
|
|
|
|
* @param string $page
|
2010-02-10 17:27:03 +00:00
|
|
|
* La page ou l'on affiche le formulaire, détermine le type de surveillance.
|
2009-05-20 15:49:08 +00:00
|
|
|
* @param string $siret
|
2010-02-10 17:27:03 +00:00
|
|
|
* L'établissement à surveiller.
|
2009-05-20 15:49:08 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2009-12-15 16:23:31 +00:00
|
|
|
function getSurveillance($source, $siret){
|
|
|
|
global $client, $firephp;
|
2009-12-16 11:14:54 +00:00
|
|
|
$assocSourceDroit = assocSourceDroit();
|
2009-06-03 08:47:14 +00:00
|
|
|
$return = '';
|
2009-12-15 16:23:31 +00:00
|
|
|
if(!empty($source) && array_key_exists($source, $assocSourceDroit) &&
|
|
|
|
preg_match('/\b'.$assocSourceDroit[$source].'\b/i', $_SESSION['tabInfo']['droits']))
|
2009-10-12 13:31:05 +00:00
|
|
|
{
|
2009-12-10 09:54:47 +00:00
|
|
|
if( preg_match('/\bvoirsurv\b/i', $_SESSION['tabInfo']['pref']) &&
|
2010-01-11 09:57:47 +00:00
|
|
|
inSurveillance($source, $siret))
|
2009-10-12 13:31:05 +00:00
|
|
|
{
|
2010-02-10 17:27:03 +00:00
|
|
|
$return = '<br/>L\'entité est sous surveillance.'."\n";
|
2009-10-12 13:31:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-20 15:49:08 +00:00
|
|
|
$notEmail = array('testreunica', 'reunicacsf');
|
2009-12-15 16:23:31 +00:00
|
|
|
$return = formSurveillance($source, $siret, $notEmail);
|
2009-05-20 15:49:08 +00:00
|
|
|
}
|
2009-10-12 13:31:05 +00:00
|
|
|
}
|
2009-12-18 17:36:42 +00:00
|
|
|
elseif(preg_match('/\b'.$assocSourceDroit[$source].'\b/i', $_SESSION['tabInfo']['droits']))
|
2009-12-15 16:23:31 +00:00
|
|
|
{
|
|
|
|
$return = formSurveillance('', $siret, $notEmail);
|
|
|
|
}
|
2009-05-20 15:49:08 +00:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* Vérifie si l'établissement est en surveillance
|
2009-05-20 15:49:08 +00:00
|
|
|
*
|
|
|
|
* @param string $source
|
|
|
|
* Le type de surveillance.
|
|
|
|
* @param string $siret
|
2010-02-10 17:27:03 +00:00
|
|
|
* L'établissement surveillé.
|
2009-05-20 15:49:08 +00:00
|
|
|
* @return boolean
|
|
|
|
* true or false
|
|
|
|
*/
|
|
|
|
function inSurveillance($source, $siret){
|
2009-12-15 16:55:43 +00:00
|
|
|
global $client, $firephp;
|
2009-12-16 10:09:30 +00:00
|
|
|
$firephp->log($source, 'source');
|
2010-01-11 09:57:47 +00:00
|
|
|
$firephp->log($siret, 'siret');
|
2009-05-20 15:49:08 +00:00
|
|
|
try{
|
|
|
|
$result = $client->getSurveillances($siret,$source);
|
2009-12-16 10:09:30 +00:00
|
|
|
$firephp->log($result['results']['reponses'], 'response');
|
2009-06-12 12:14:35 +00:00
|
|
|
if(count($result['results']['reponses'])>0 ){
|
2009-05-22 15:16:50 +00:00
|
|
|
$find = FALSE;
|
|
|
|
if(strlen($siret)>9) $siret = substr($siret, 0, 9);
|
2009-06-12 12:14:35 +00:00
|
|
|
foreach($result['results']['reponses'] as $item){
|
2009-05-22 15:16:50 +00:00
|
|
|
if($item['siren'] == $siret){ $find = TRUE; }
|
|
|
|
}
|
|
|
|
return $find;
|
|
|
|
}else{ return false; }
|
2009-05-20 15:49:08 +00:00
|
|
|
}catch(SoapFault $fault){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-22 12:26:07 +00:00
|
|
|
/**
|
|
|
|
* Envoi la surveillance au webservice
|
|
|
|
*
|
|
|
|
* @param array $tabForm
|
|
|
|
* Le type de surveillance.
|
|
|
|
* @return mixed
|
2010-02-10 17:27:03 +00:00
|
|
|
* Retourne la réponse du webservice ou false
|
2009-05-22 12:26:07 +00:00
|
|
|
*/
|
2009-12-21 17:40:59 +00:00
|
|
|
function setSurveillance($tabForm)
|
|
|
|
{
|
2009-12-15 16:55:43 +00:00
|
|
|
global $client, $firephp;
|
2009-05-20 15:49:08 +00:00
|
|
|
$siret = $tabForm['siret'];
|
|
|
|
$email = $tabForm['email'];
|
|
|
|
$ref = $tabForm['ref'];
|
|
|
|
$source = $tabForm['source'];
|
2009-12-21 17:40:59 +00:00
|
|
|
$firephp->log($tabForm,'tabForm');
|
2009-12-16 10:09:30 +00:00
|
|
|
if(is_array($source))
|
|
|
|
{
|
|
|
|
foreach($source as $s)
|
2009-12-16 08:17:03 +00:00
|
|
|
{
|
2009-12-16 10:09:30 +00:00
|
|
|
try{
|
|
|
|
$result = $client->setSurveillance($siret, $email, $ref, $s);
|
|
|
|
$firephp->log($s, 'Surveillance');
|
|
|
|
}catch(SoapFault $fault){
|
|
|
|
$firephp->log($fault,'fault');
|
|
|
|
$result = false;
|
|
|
|
}
|
2009-12-21 17:40:59 +00:00
|
|
|
}
|
2009-12-16 10:09:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try{
|
2009-12-16 08:17:03 +00:00
|
|
|
$result = $client->setSurveillance($siret, $email, $ref, $source);
|
2009-12-21 17:40:59 +00:00
|
|
|
$firephp->log($source, 'Surveillance seul');
|
2009-12-16 10:09:30 +00:00
|
|
|
}catch(SoapFault $fault){
|
|
|
|
$firephp->log($fault,'fault');
|
|
|
|
$result = false;
|
2009-12-16 08:17:03 +00:00
|
|
|
}
|
2009-05-20 15:49:08 +00:00
|
|
|
}
|
2009-12-16 10:09:30 +00:00
|
|
|
return $result;
|
2009-05-20 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 12:26:07 +00:00
|
|
|
/**
|
|
|
|
* Supprime la surveillance
|
|
|
|
*
|
|
|
|
* @param string $siret
|
2010-02-10 17:27:03 +00:00
|
|
|
* L'établissement surveillé.
|
2009-05-22 12:26:07 +00:00
|
|
|
* @param $email
|
2010-02-10 17:27:03 +00:00
|
|
|
* L'email enregistré pour la surveillance
|
2009-05-22 12:26:07 +00:00
|
|
|
* @param $ref
|
2010-02-10 17:27:03 +00:00
|
|
|
* La référence ajouté pour cette surveillance
|
2009-05-22 12:26:07 +00:00
|
|
|
* @param $source
|
|
|
|
* La source pour cette surveillance
|
|
|
|
* @return mixed
|
2010-02-10 17:27:03 +00:00
|
|
|
* Retourne la réponse du webservice ou false
|
2009-05-22 12:26:07 +00:00
|
|
|
*/
|
2009-05-20 15:49:08 +00:00
|
|
|
function deleteSurveillance($siret, $email, $ref, $source){
|
2009-12-15 16:55:43 +00:00
|
|
|
global $client, $firephp;
|
2009-05-25 15:25:44 +00:00
|
|
|
$firephp->log($siret, 'siret');
|
|
|
|
$firephp->log($email, 'email');
|
|
|
|
$firephp->log($ref, 'ref');
|
|
|
|
$firephp->log($source, 'source');
|
2009-05-20 15:49:08 +00:00
|
|
|
try{
|
|
|
|
$result = $client->setSurveillance($siret, $email, $ref, $source, TRUE);
|
|
|
|
$firephp->log('Suppression surveillance');
|
2009-05-25 13:19:02 +00:00
|
|
|
return TRUE;
|
2009-05-20 15:49:08 +00:00
|
|
|
}catch(SoapFault $fault){
|
|
|
|
$firephp->log($fault,'fault');
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|