2011-04-19 07:37:39 +00:00
< ? php
class PiecesController extends Zend_Controller_Action
{
2011-05-11 13:38:14 +00:00
protected $association_cj = array (
'9150' , // Association syndicale libre
'9220' , // Association déclarée
'9221' , // Association déclarée "entreprises d'insertion par l'économique"
'9222' , // Association intermédiaire
'9223' , // Groupement d'employeurs
'9230' , // Association déclarée reconnue d'utilité publique
'9240' , // Congrégation
'9260' , // Association de droit local
'9300' , // Fondation
);
protected $siret ;
protected $id ;
protected $entrep ;
2011-04-19 07:37:39 +00:00
public function init ()
{
2011-05-11 13:38:14 +00:00
require_once 'Scores/WsScores.php' ;
2011-05-05 12:04:47 +00:00
require_once 'Scores/Utilisateur.php' ;
require_once 'Scores/SessionEntreprise.php' ;
require_once 'common/dates.php' ;
2011-05-11 13:38:14 +00:00
require_once 'Infogreffe/Infogreffe.php' ;
$request = $this -> getRequest ();
$this -> siret = $request -> getParam ( 'siret' );
$this -> id = $request -> getParam ( 'id' , 0 );
$this -> entrep = new SessionEntreprise ( $this -> siret , $this -> id );
2011-04-19 07:37:39 +00:00
}
2011-05-11 13:38:14 +00:00
public function indexAction (){}
2011-06-30 14:37:50 +00:00
/**
* Commande de status association
*/
2011-05-17 07:35:54 +00:00
public function cmdassociationAction ()
2011-05-11 13:38:14 +00:00
{
2011-06-29 15:48:05 +00:00
$user = new Utilisateur ();
$request = $this -> getRequest ();
2012-02-07 15:52:36 +00:00
$email = $request -> getParam ( 'email' , '' );
2011-06-29 15:48:05 +00:00
2011-06-29 16:07:23 +00:00
if ( ! empty ( $email )) {
2011-06-29 15:48:05 +00:00
$erreur = false ;
2011-09-29 15:15:14 +00:00
$configuration = Zend_Registry :: get ( 'configuration' );
$fp = fopen ( realpath ( $configuration -> path -> data ) . '/' . $configuration -> path -> log . '/commande_asso.csv' , 'a' );
2011-06-29 15:48:05 +00:00
fwrite ( $fp , date ( 'Y/m/d H:i:s' ) . " ; $siren ; " . $email . ';' . $login . ';' . $user -> getEmail () . ';' . $user -> getIpAddress () . " \n " );
fclose ( $fp );
$siren = substr ( $this -> siret , 0 , 9 );
$infoAsso = new stdClass ();
$infoAsso -> siren = $siren ;
$infoAsso -> waldec = '' ;
$infoAsso -> idEntreprise = $this -> id ;
$infoAsso -> raisonSociale = $this -> entrep -> getRaisonSociale ();
$infoDemande = new stdClass ();
2012-02-07 15:52:36 +00:00
$infoDemande -> reference = $request -> getParam ( 'reference' );
2011-06-29 15:48:05 +00:00
$infoDemande -> email = $email ;
$infoDemande -> tel = $request -> getParam ( 'tel' );
$infoDemande -> fax = '' ;
$infoDemande -> nom = '' ;
$infoDemande -> service = '' ;
$infoDemande -> societe = '' ;
$infoDemande -> adresse = '' ;
$infoDemande -> cp = '' ;
$infoDemande -> ville = '' ;
$ws = new WsScores ();
2012-02-16 17:15:54 +00:00
$reponse = $ws -> setCmdAsso ( $infoAsso , $infoDemande ); //@todo : vérfier les logs de facturation
2011-06-29 15:48:05 +00:00
$annee = substr ( $reponse -> result -> dateCommande , 0 , 4 );
$mois = substr ( $reponse -> result -> dateCommande , 4 , 2 );
$jour = substr ( $reponse -> result -> dateCommande , 6 , 2 );
$heure = substr ( $reponse -> result -> dateCommande , 8 , 2 );
$minutes = substr ( $reponse -> result -> dateCommande , 10 , 2 );
$ref = $reponse -> result -> refCmde ;
if ( isset ( $ref ) && ! empty ( $ref ) )
{
$message = 'Votre demande à été prise en compte le ' . $jour . '/' . $mois . '/' . $annee . ' à ' . $heure . ' h ' . $minutes . ' sous la référence <b>' . $ref . '</b>.' ;
} else {
$message = 'Une erreur s\'est produite lors du passage de votre commande.' ;
}
} else {
$message = " ERREUR : Veuillez saisir une adresse email valide pour la commande de pièces. " ;
}
$this -> view -> assign ( 'message' , $message );
$this -> view -> assign ( 'siren' , substr ( $this -> siret , 0 , 9 ));
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'id' , $this -> id );
$this -> view -> assign ( 'raisonSociale' , $this -> entrep -> getRaisonSociale ());
2011-05-11 13:38:14 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Affichage liste d ' actes infogreffe
*/
2011-05-11 13:38:14 +00:00
public function actesAction ()
2011-04-19 07:37:39 +00:00
{
2011-05-11 13:38:14 +00:00
$this -> view -> headLink () -> appendStylesheet ( '/themes/default/styles/pieces.css' , 'all' );
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
2011-06-29 15:48:05 +00:00
$user = new Utilisateur ();
2011-05-11 13:38:14 +00:00
//Catégorie Juridique
$cj = $this -> entrep -> getFormeJuridique ();
if ( in_array ( $cj , $this -> association_cj ) ) {
2012-02-16 17:15:54 +00:00
$this -> _forward ( 'associationactes' );
2011-05-11 13:38:14 +00:00
}
$request = $this -> getRequest ();
$siren = substr ( $this -> siret , 0 , 9 );
$vecteur = 'XL' ;
$ref = '' ;
2011-12-06 10:06:34 +00:00
//Récupération de la liste des infos du RNCS
$ws = new WsScores ();
2011-12-06 19:24:57 +00:00
$rncsDepots = $ws -> getListeDepots ( $siren );
2011-05-11 13:38:14 +00:00
//Affichage des actes disponible
$infogreffe = new Infogreffe ();
$reponse = $infogreffe -> getGreffeActes ( $siren , $vecteur , $ref );
2011-08-16 08:21:36 +00:00
2011-05-11 13:38:14 +00:00
/*
* Construire la réponse pour affichage
* Date , Type , Décisions ,
*/
$infosActes = array ();
2011-08-16 08:21:36 +00:00
if ( is_array ( $reponse [ 'result' ]) && count ( $reponse [ 'result' ]) > 0 ) {
2011-05-11 13:38:14 +00:00
$items = $reponse [ 'result' ];
//Traitement dernier statut à jour
2011-05-19 07:12:51 +00:00
if ( array_key_exists ( 0 , $items )) {
$acteS = $items [ 0 ][ 'actes' ][ 0 ];
//Commande enregistré dans la bdd et fichier existe
$lienCommande = '' ;
$checkFile = false ;
if ( $user -> checkModeEdition () ) {
$lib = 'Voir le dernier ficher dans le système.' ;
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( '*' )
-> where ( 'siren = ?' , $siren )
-> order ( 'dateCommande DESC' );
$rows = $commandes -> fetchAll ( $rowset );
} else {
$lib = 'Télécharger votre dernière commande.' ;
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( '*' )
-> where ( 'siren = ?' , $siren )
2012-01-24 11:40:06 +00:00
-> where ( 'login = ?' , $user -> getLogin ())
2011-05-19 07:12:51 +00:00
-> order ( 'dateCommande DESC' );
$rows = $commandes -> fetchAll ( $rowset );
}
$rows = $commandes -> fetchAll ( $rowset );
$nbCommandes = count ( $rows );
if ( $nbCommandes > 0 ) {
foreach ( $rows as $commande ) {
if ( substr ( $commande -> refDocument , 0 , 3 ) == 'ST-' ) {
$ref = trim ( $commande -> refDocument );
2011-09-29 15:15:14 +00:00
$configuration = Zend_Registry :: get ( 'configuration' );
$refFile = realpath ( $configuration -> path -> data ) . '/' .
$configuration -> path -> pdf . '/acte-' . $siren . '-' . trim ( $commande -> refDocument ) . '.pdf' ;
2011-05-19 07:12:51 +00:00
$checkFile = true ;
break ;
}
}
}
if ( $checkFile && file_exists ( $refFile ) ) {
$lienCommande = '<br/>' .
'<a href="./fichier/pdf/acte-' . $siren . '-' . $ref . '.pdf' .
'" target="_blank">' . $lib . '</a>' ;
}
2011-05-11 13:38:14 +00:00
//Génération du lien de commande suivant le mode de diffusion
2011-05-19 07:12:51 +00:00
switch ( $acteS [ 'mode' ]) {
2011-05-11 13:38:14 +00:00
case 'C' :
2011-05-19 07:12:51 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
2011-05-11 13:38:14 +00:00
$title = 'Commander le document correspondant' ;
2011-05-19 07:12:51 +00:00
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'statuts' ,
'mode' => 'C' ,
'siret' => $siren ,
'ref' => $acteS [ 'ref' ],
));
} else {
2011-05-11 13:38:14 +00:00
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
2011-05-19 07:12:51 +00:00
$href = '#' ;
2011-05-11 13:38:14 +00:00
}
break ;
}
2011-05-19 07:12:51 +00:00
$infosStatut [ 'mode' ] = $acteS [ 'mode' ];
$infosStatut [ 'lib' ] = $acteS [ 'type_lib' ];
$infosStatut [ 'ref' ] = $acteS [ 'ref' ];
$infosStatut [ 'href' ] = $href ;
$infosStatut [ 'title' ] = $title ;
$infosStatut [ 'decision' ] = 'Le dernier statut à jour' ;
$infosActes [] = $infosStatut ;
2011-05-11 13:38:14 +00:00
//Suppression du dernier statut à jour
unset ( $items [ 0 ]);
}
//Fin traitement dernier statut à jour
//Traitement des actes normaux
foreach ( $items as $key => $depot )
{
$infosActe = array ();
//Parcours standard des actes pour affichage
foreach ( $depot [ 'actes' ] as $num => $acte )
{
$infosActe [ 'date' ] = $acte [ 'date_acte' ];
$infosActe [ 'mode' ] = $acte [ 'mode' ];
$infosActe [ 'lib' ] = $acte [ 'type_lib' ];
$infosActe [ 'ref' ] = $acte [ 'ref' ];
$infos = array (
'num_acte' => $acte [ 'num_acte' ],
'date_acte' => $acte [ 'date_acte' ],
'type' => $acte [ 'type' ],
'type_lib' => $acte [ 'type_lib' ],
'decision' => $acte [ 'decision' ]
);
switch ( $acte [ 'mode' ])
{
case 'fichier' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'fichier' ,
'siret' => $siren ,
'ref' => $acte [ 'ref' ],
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'T' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'T' ,
'siret' => $siren ,
'ref' => $acte [ 'ref' ],
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'C' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'C' ,
'siret' => $siren ,
'ref' => $acte [ 'ref' ],
2011-05-17 07:35:54 +00:00
'info' => urlencode ( serialize ( $infos ))
2011-05-11 13:38:14 +00:00
));
$title = 'Recevoir le document directement par mail (sous 3/5 jours ouvrés)' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'courrier' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'courrier' ,
'siret' => $siren ,
'ref' => $acte [ 'ref' ],
2011-05-17 07:35:54 +00:00
'info' => urlencode ( serialize ( $infos ))
2011-05-11 13:38:14 +00:00
));
$title = 'Recevoir le document directement par mail (sous 15 jours ouvrés)' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
}
$infosActe [ 'href' ] = $href ;
$infosActe [ 'title' ] = $title ;
$infosActe [ 'decision' ] = '' ;
if ( $depot [ 'num_depot' ] >= 0 )
{
$data = '' ;
2011-12-06 10:06:34 +00:00
$data .= '<b>Dépot n°' . $depot [ 'num_depot' ] . ' du ' . $depot [ 'date_depot' ] . '</b>' ;
2011-05-11 13:38:14 +00:00
if ( $acte [ 'nbpages_acte' ] > 1 ) {
$data .= ', ' . $acte [ 'nbpages_acte' ] . ' pages' ;
} elseif ( $acte [ 'nbpages_acte' ] == 1 ) {
$data .= ', ' . $acte [ 'nbpages_acte' ] . ' page' ;
}
2011-12-06 18:54:27 +00:00
$data .= '<br/>' ;
2011-12-06 10:06:34 +00:00
if ( ! empty ( $acte [ 'decision' ]))
{
2011-12-06 19:13:45 +00:00
$data .= $acte [ 'decision' ];
2011-12-06 10:06:34 +00:00
}
2012-01-21 20:43:26 +00:00
if ( $rncsDepots !== false ) {
if ( count ( $rncsDepots -> item ) > 0 ) {
foreach ( $rncsDepots -> item as $d ) {
$date = WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $d -> DateDepot );
if ( $date == $depot [ 'date_depot' ]){
$data .= '<br/> - ' . $d -> LibDepot ;
}
2011-12-06 10:06:34 +00:00
}
}
}
2011-05-11 13:38:14 +00:00
$infosActe [ 'decision' ] = $data ;
}
$infosActes [] = $infosActe ;
} // Fin acte
} // Fin depot
2011-08-16 08:21:36 +00:00
} else {
$this -> view -> assign ( 'ErreurMessage' , $reponse [ 'error' ][ 'errNum' ] . ' - ' . $reponse [ 'error' ][ 'errMsg' ]);
2011-05-11 13:38:14 +00:00
}
2011-05-17 12:23:42 +00:00
$this -> view -> assign ( 'ModeEdition' , $user -> checkModeEdition ());
2011-05-11 13:38:14 +00:00
$this -> view -> assign ( 'InfosActes' , $infosActes );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $this -> entrep -> getRaisonSociale ());
2012-03-01 13:10:25 +00:00
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survbilan' ));
2011-04-19 07:37:39 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Affichage liste de bilans infogreffe
*/
2011-05-11 13:38:14 +00:00
public function bilansAction ()
{
$this -> view -> headLink () -> appendStylesheet ( '/themes/default/styles/pieces.css' , 'all' );
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
//Catégorie Juridique
$cj = $this -> entrep -> getFormeJuridique ();
if ( in_array ( $cj , $this -> association_cj ) ) {
2012-02-16 17:15:54 +00:00
$this -> _forward ( 'associationbilans' );
2011-05-11 13:38:14 +00:00
}
$user = new Utilisateur ();
$request = $this -> getRequest ();
$siren = substr ( $this -> siret , 0 , 9 );
$vecteur = 'XL' ;
$ref = '' ;
//Affichage des bilans disponible
$infogreffe = new Infogreffe ();
$reponse = $infogreffe -> getGreffeBilans ( $siren , $vecteur , $ref );
$infosBilans = array ();
2011-08-16 08:21:36 +00:00
if ( is_array ( $reponse [ 'result' ]) && count ( $reponse [ 'result' ]) > 0 ) {
2011-05-11 13:38:14 +00:00
$items = $reponse [ 'result' ];
foreach ( $items as $key => $item )
{
$infosBilan = array ();
$infosBilan [ 'date' ] = $item [ 'date_cloture' ];
$infosBilan [ 'type' ] = 'Comptes millésime ' . $item [ 'millesime' ];
$infosBilan [ 'mode' ] = $item [ 'mode' ];
$infos = array (
'date_cloture' => $item [ 'date_cloture' ],
'type' => $item [ 'millesime' ],
'decision' => $item [ 'num_depot' ]
);
switch ( $item [ 'mode' ])
{
case 'fichier' ;
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'ref' => $item [ 'ref' ],
'mode' => 'fichier' ,
2011-05-17 12:23:42 +00:00
'info' => urlencode ( serialize ( $infos )),
2011-05-11 13:38:14 +00:00
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'T' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'ref' => $item [ 'ref' ],
'mode' => 'T' ,
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'C' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'ref' => $item [ 'ref' ],
'mode' => 'C' ,
2011-05-17 07:35:54 +00:00
'info' => urlencode ( serialize ( $infos )),
2011-05-11 13:38:14 +00:00
));
$title = 'Recevoir le document directement par mail (sous 3/5 jours ouvrés)' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
case 'courrier' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'ref' => $item [ 'ref' ],
'mode' => 'courrier' ,
2011-05-17 07:35:54 +00:00
'info' => urlencode ( serialize ( $infos )),
2011-05-11 13:38:14 +00:00
));
$title = 'Recevoir le document directement par mail (sous 15 jours ouvrés)' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
break ;
}
$infosBilan [ 'href' ] = $href ;
$infosBilan [ 'title' ] = $title ;
$infosBilan [ 'decision' ] = 'Dépot n°' . $item [ 'num_depot' ];
$infosBilans [] = $infosBilan ;
}
2011-08-16 08:21:36 +00:00
} else {
$this -> view -> assign ( 'ErreurMessage' , $reponse [ 'error' ][ 'errNum' ] . ' - ' . $reponse [ 'error' ][ 'errMsg' ]);
2011-05-11 13:38:14 +00:00
}
2011-05-17 12:23:42 +00:00
$this -> view -> assign ( 'ModeEdition' , $user -> checkModeEdition ());
2011-05-11 13:38:14 +00:00
$this -> view -> assign ( 'InfosBilans' , $infosBilans );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $this -> entrep -> getRaisonSociale ());
2012-03-01 13:10:25 +00:00
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survactes' ));
2011-05-11 13:38:14 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Affichage formulaire de commande courrier S & D
*/
2011-05-17 07:35:54 +00:00
public function cmdcourrierAction ()
{
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
$request = $this -> getRequest ();
$dejaCommande = $request -> getParam ( 'dejaCommande' , false );
$noemail = $request -> getParam ( 'noemail' , false );
$sameLogin = $request -> getParam ( 'sameLogin' , false );
2011-08-05 08:45:47 +00:00
$typeCommande = $request -> getParam ( 'typeCommande' , '' );
$idCommande = $request -> getParam ( 'idCommande' , '' );
2011-05-17 07:35:54 +00:00
Zend_Registry :: get ( 'firebug' ) -> info ( 'cmdcourrier' );
if ( ! $dejaCommande || ( $dejaCommande && $noemail ) )
{
$user = new Utilisateur ();
$siren = $request -> getParam ( 'siret' , 0 );
$info = $request -> getParam ( 'info' , 0 );
2011-08-05 08:45:47 +00:00
2011-05-17 07:35:54 +00:00
$ref = $request -> getParam ( 'ref' , '' );
$vue = $request -> getParam ( 'vue' , '' );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'info' , $info );
$this -> view -> assign ( 'typeCommande' , $typeCommande );
2011-08-05 08:45:47 +00:00
$this -> view -> assign ( 'idCommande' , $idCommande );
2011-05-17 07:35:54 +00:00
$this -> view -> assign ( 'ref' , $ref );
$this -> view -> assign ( 'vue' , $vue );
$this -> view -> assign ( 'email' , $user -> getEmail ());
$this -> renderScript ( 'pieces/cmdcourrier.phtml' );
}
elseif ( ! $noemail && $dejaCommande && $sameLogin )
{
2011-08-05 08:45:47 +00:00
$this -> view -> assign ( 'typeCommande' , $typeCommande );
$this -> view -> assign ( 'idCommande' , $idCommande );
2011-05-17 07:35:54 +00:00
$this -> renderScript ( 'pieces/cmdcourrier-cmd1.phtml' );
}
elseif ( ! $noemail && $dejaCommande && ! $sameLogin )
{
$this -> renderScript ( 'pieces/cmdcourrier-cmd2.phtml' );
}
}
2011-12-10 17:08:26 +00:00
public function cmdfacticeAction ()
{
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
$request = $this -> getRequest ();
$ref = $request -> getParam ( 'ref' , '' );
$siren = substr ( $this -> siret , 0 , 9 );
$user = new Utilisateur ();
$tabCommande = array (
'idUser' => $user -> getId (),
'emailCommande' => '' ,
'login' => $user -> getLogin (),
'siren' => $siren ,
'refDocument' => $ref ,
'libDocument' => '' ,
'typeCommande' => 'G' ,
'dateCommande' => date ( 'YmdHis' ),
'statutCommande' => 0 ,
);
//Enregistrement dans la bdd des informations de la commande
$commande = new Application_Model_Commandes ();
$idCommande = $commande -> insert ( $tabCommande );
echo " Commande factice sous le numéro : G " . $idCommande ;
}
2011-06-30 14:37:50 +00:00
/**
* Enregistrement d ' une commande de pièces par courrier
*/
2011-05-17 07:35:54 +00:00
public function sauvcmdAction ()
{
2011-06-29 14:22:14 +00:00
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
$request = $this -> getRequest ();
$info = $request -> getParam ( 'info' , '' );
$email = $request -> getParam ( 'emailCommande' , '' );
$idCommande = $request -> getParam ( 'idCommande' , '' );
$type = $request -> getParam ( 'type' , '' );
2012-01-24 11:03:21 +00:00
$vue = $request -> getParam ( 'vue' , '' );
2011-06-29 14:22:14 +00:00
$ref = $request -> getParam ( 'ref' , '' );
$siren = substr ( $this -> siret , 0 , 9 );
2011-08-09 09:45:20 +00:00
$ws = new WsScores ();
2011-06-29 14:22:14 +00:00
$info = ! empty ( $info ) ? unserialize ( urldecode ( $_REQUEST [ 'info' ])) : $info = false ;
$lib = empty ( $info [ 'decision' ]) ? '' : $info [ 'decision' ];
if ( ! empty ( $email )){
$user = new Utilisateur ();
$login = $user -> getLogin ();
$ip = $user -> getIpAddress ();
2011-09-29 15:15:14 +00:00
$configuration = Zend_Registry :: get ( 'configuration' );
$fp = fopen ( $configuration -> path -> data . '/' . $configuraiton -> path -> log . '/commande_greffe.csv' , 'a' );
2011-06-29 14:22:14 +00:00
fwrite ( $fp , date ( 'Y/m/d H:i:s' ) . " ; $siren ; " . $ref . ';' . $login . ';' . $email . ';' . $ip . " \n " );
fclose ( $fp );
$tabCommande = array (
2011-12-10 17:08:26 +00:00
'idUser' => $user -> getId (),
'emailCommande' => $email ,
'login' => $login ,
'siren' => $siren ,
'refDocument' => $ref ,
'libDocument' => $lib ,
'typeCommande' => $type ,
'dateCommande' => date ( 'YmdHis' )
2011-06-29 14:22:14 +00:00
);
2011-05-17 07:35:54 +00:00
2011-06-29 14:22:14 +00:00
//Enregistrement dans la bdd des informations de la commande
2011-09-27 15:33:24 +00:00
$commande = new Application_Model_Commandes ();
2011-06-29 14:22:14 +00:00
$idCommande = $commande -> insert ( $tabCommande );
//Suppression fichier de vérouillage
$lockFile = APPLICATION_PATH . '/../cache/' . $siren . '-' . $ref . '.txt' ;
if ( file_exists ( $lockFile )) {
unlink ( $lockFile );
}
2012-02-03 09:12:16 +00:00
2011-06-29 14:22:14 +00:00
if ( $type == 'G' ) {
$infogreffe = new Infogreffe ();
//Commande
switch ( $vue ) {
case 'actes' :
$reponse = $infogreffe -> getGreffeActes ( $siren , 'C' , $ref , $idCommande );
break ;
case 'bilans' :
$reponse = $infogreffe -> getGreffeBilans ( $siren , 'C' , $ref , $idCommande );
break ;
case 'statuts' :
$reponse = $infogreffe -> getGreffeStatut ( $siren , 'C' , $ref , $idCommande );
break ;
}
}
2012-01-26 17:55:18 +00:00
2011-06-29 14:22:14 +00:00
if ( isset ( $reponse ) && ! empty ( $reponse [ 'error' ]) && $reponse [ 'error' ][ 'errNum' ] != 17 )
{
$message = $reponse [ 'error' ][ 'errNum' ] . ' - ' . $reponse [ 'error' ][ 'errMsg' ];
2011-08-09 09:45:20 +00:00
$ws -> setLog ( 'greffe_' . $vue , $siren , 0 , 'Erreur ' . $reponse [ 'error' ][ 'errNum' ]);
2011-06-29 14:22:14 +00:00
}
else
{
2012-01-26 17:55:18 +00:00
$ws -> setLog ( 'greffe_' . $vue , $siren , 0 , $ref . '/' . $type . $idCommande );
$commande -> update ( array ( 'statutCommande' => 0 ), " idCommande= $idCommande " );
2011-06-29 14:22:14 +00:00
$message = 'Votre commande a été enregistré le ' .
date ( 'd' ) . '/' . date ( 'm' ) . '/' . date ( 'Y' ) .
' à ' . date ( 'G' ) . ' h ' . date ( 'i' ) .
' sous la référence ' . $type . $idCommande ;
//Envoi mail de commande courrier
if ( $type == 'C' ) {
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'contact' );
2012-01-27 12:49:50 +00:00
$mail -> addToKey ( 'production' );
2011-06-29 14:22:14 +00:00
$mail -> setSubject ( '[COMMANDE PIECES] - ' . 'COMMANDE DE ' . strtoupper ( $vue ));
$mail -> setBodyTexte (
'COMMANDE DE ' . strtoupper ( $vue ) .
' en courrier manuel <br/>' . EOL .
'Ref Scores et Décision : ' . $ref . EOL .
'pour login ' . $login . EOL
);
$mail -> send ();
}
}
} else {
$message = 'Votre commande n\'a pas été prise en compte.' .
'Vous n\'avez pas saisie d\'adresse email' ;
}
$this -> view -> assign ( 'message' , $message );
2011-07-04 10:48:09 +00:00
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'siren' , $this -> siren );
2011-06-29 14:22:14 +00:00
2011-10-26 10:34:32 +00:00
$session = new SessionEntreprise ( $this -> siret , $this -> id );
2011-07-04 10:48:09 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-03-01 13:10:25 +00:00
$user = new Utilisateur ();
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survactes' ));
2011-05-17 07:35:54 +00:00
}
2012-01-24 10:36:28 +00:00
public function statutsAction ()
{
2012-01-24 11:03:21 +00:00
$this -> _helper -> layout () -> disableLayout ();
2012-01-24 10:36:28 +00:00
2012-01-24 11:03:21 +00:00
$request = $this -> getRequest ();
$dejaCommande = $request -> getParam ( 'dejaCommande' , false );
$noemail = $request -> getParam ( 'noemail' , false );
$sameLogin = $request -> getParam ( 'sameLogin' , false );
$typeCommande = $request -> getParam ( 'typeCommande' , '' );
$idCommande = $request -> getParam ( 'idCommande' , '' );
$user = new Utilisateur ();
$siren = $request -> getParam ( 'siret' , 0 );
$info = $request -> getParam ( 'info' , 0 );
$ref = $request -> getParam ( 'ref' , '' );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'info' , $info );
$this -> view -> assign ( 'typeCommande' , $typeCommande );
$this -> view -> assign ( 'idCommande' , $idCommande );
$this -> view -> assign ( 'ref' , $ref );
$this -> view -> assign ( 'vue' , 'statuts' );
$this -> view -> assign ( 'email' , $user -> getEmail ());
2012-01-24 10:36:28 +00:00
}
2011-05-11 13:38:14 +00:00
2011-06-30 14:37:50 +00:00
/**
* Commande de bilan
*/
2011-05-11 13:38:14 +00:00
public function bilanAction ()
{
2011-06-29 15:48:05 +00:00
$user = new Utilisateur ();
if ( ! $user -> checkPerm ( 'ACTES' )){
$this -> _forward ( 'perms' , 'error' );
}
2011-05-17 07:35:54 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
2011-05-11 13:38:14 +00:00
$request = $this -> getRequest ();
$vecteur = $request -> getParam ( 'mode' );
$info = $request -> getParam ( 'info' );
$ref = $request -> getParam ( 'ref' );
$siren = substr ( $this -> siret , 0 , 9 );
2011-06-29 14:22:14 +00:00
$ws = new WsScores ();
2011-05-11 13:38:14 +00:00
switch ( $vecteur ) {
2011-05-17 07:35:54 +00:00
case 'C' :
$dejaCommande = false ;
$noemail = false ;
$sameLogin = false ;
$idCommande = 0 ;
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( 'idCommande, login, emailCommande, dateCommande' )
-> where ( " siren= $siren AND refDocument=' $ref ' AND statutCommande!=9 " );
$rows = $commandes -> fetchAll ( $rowset );
if ( count ( $rows ) != 0 ) {
$dejaCommande = true ;
2011-09-27 15:33:24 +00:00
if ( $rows [ 0 ] -> login == $user -> getLogin ())
2011-05-17 07:35:54 +00:00
{
2011-09-27 15:33:24 +00:00
$dateCommande = WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $rows [ 0 ] -> dateCommande );
$idCommande = $rows [ 0 ] -> idCommande ;
if ( empty ( $rows [ 0 ] -> emailCommande )) $noemail = true ;
2011-05-17 07:35:54 +00:00
$sameLogin = true ;
}
}
$params = array (
'idCommande' => $idCommande ,
'dejaCommande' => $dejaCommande ,
'noemail' => $noemail ,
'sameLogin' => $sameLogin ,
'siren' => $siren ,
'info' => $info ,
'vue' => 'bilans' ,
);
$this -> _forward ( 'cmdcourrier' , 'pieces' , null , $params );
break ;
case 'courrier' :
$dejaCommande = false ;
$noemail = false ;
$sameLogin = false ;
$idCommande = 0 ;
//Vérification des commandes
if ( preg_match ( '/^([0-9]{4})[_sociaux-|_-]/' , $ref , $matches ))
{
$searchRef = '^' . $matches [ 1 ] . '[_-|_sociaux-]' ;
}
elseif ( preg_match ( '/^([0-9]{4})_consolide-/' , $ref , $matches ))
{
$searchRef = '^' . $matches [ 1 ] . '_consolide-' ;
}
else
{
$searchRef = $ref ;
}
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( 'idCommande, login, emailCommande, dateCommande' )
-> where ( " siren= $siren AND refDocument=' $searchRef ' " );
$rows = $commandes -> fetchAll ( $rowset );
if ( count ( $rows ) != 0 ) {
2011-06-29 15:48:05 +00:00
2011-05-17 07:35:54 +00:00
$dejaCommande = true ;
2011-09-27 15:33:24 +00:00
if ( $rows [ 0 ] -> login == $user -> getLogin ())
2011-05-17 07:35:54 +00:00
{
2011-09-27 15:33:24 +00:00
$dateCommande = WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $rows [ 0 ] -> dateCommande );
2011-05-17 07:35:54 +00:00
$idCommande = $rows [ 0 ][ 'idCommande' ];
2011-09-27 15:33:24 +00:00
if ( empty ( $rows [ 0 ] -> emailCommande )) $noemail = true ;
2011-05-17 07:35:54 +00:00
$sameLogin = true ;
}
}
$params = array (
'idCommande' => $idCommande ,
'dejaCommande' => $dejaCommande ,
'noemail' => $noemail ,
'sameLogin' => $sameLogin ,
'siren' => $siren ,
'info' => $info ,
'vue' => 'bilans' ,
);
$this -> _forward ( 'cmdcourrier' , 'pieces' , null , $params );
break ;
2011-05-11 13:38:14 +00:00
case 'fichier' :
2011-06-29 14:22:14 +00:00
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , $ref );
2011-05-11 13:38:14 +00:00
$info = unserialize ( $info );
2011-09-29 15:15:14 +00:00
$configuration = Zend_Registry :: get ( 'configuration' );
$pathData = realpath ( $configuration -> path -> data );
2011-05-17 12:23:42 +00:00
if ( file_exists ( $pathData . '/pdf/bilan-' . $siren . '-' . $ref . '.pdf' )){
2011-05-11 13:38:14 +00:00
$suffixe = 'bilan' ;
2011-05-17 12:23:42 +00:00
} elseif ( file_exists ( $pathData . '/pdf/acte-' . $siren . '-' . $ref . '.pdf' )){
2011-05-11 13:38:14 +00:00
$suffixe = 'acte' ;
}
$href = '/fichier/pdf/' . $suffixe . '-' . $siren . '-' . $ref . '.pdf' ;
echo '<br/><a href="' . $href . '" target="_blank">Ouvrir le bilan millésime ' . $info [ 'type' ] . '</a>' ;
break ;
break ;
case 'T' :
2011-10-19 15:28:49 +00:00
//Vérification que le fichier ne soit pas en erreur
$erreur = new Application_Model_CommandesErreur ();
$sql = $erreur -> select ()
2012-01-24 10:36:28 +00:00
-> from ( $erreur , array ( 'url' , 'dateCommande' ))
2011-10-19 15:28:49 +00:00
-> where ( " siren=' $siren ' AND type='bilan' AND ref=' $ref ' AND erreur!='' " );
$repErreur = $erreur -> fetchAll ( $sql ) -> toArray ();
if ( count ( $repErreur ) > 0 ){
//Téléchagement
$fichier = 'bilan-' . $siren . '-' . $ref . '.pdf' ;
if ( infogreffe_dl ( $fichier , $repErreur [ 0 ][ 'url' ], false )) {
$erreur -> update ( array ( 'erreur' => '' ), " siren=' $siren ' AND type='bilan' AND ref=' $ref ' " );
2012-02-03 09:12:16 +00:00
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , $ref );
2012-01-24 20:41:47 +00:00
echo '<br/><a href="/fichier/pdf/' . $fichier . '" target="_blank">Ouvrir le fichier ' . $info [ 'type_lib' ] . ' </a>' ;
2011-10-19 15:28:49 +00:00
} else {
echo '<br/>Impossible de télécharger le fichier auprès de notre partenaire.' ;
}
} else {
$infogreffe = new Infogreffe ();
$reponse = $infogreffe -> getGreffeBilans ( $siren , $vecteur , $ref );
if ( empty ( $reponse [ 'error' ])) {
$items = $reponse [ 'result' ][ 'bilan' ];
2011-05-11 13:38:14 +00:00
}
2011-10-19 15:28:49 +00:00
else {
$error = $reponse [ 'error' ][ 'errNum' ] . ' - ' . $reponse [ 'error' ][ 'errMsg' ];
}
if ( $error != '' ) {
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , 'Erreur ' . $reponse [ 'error' ][ 'errNum' ]);
echo '<br/>Erreur : ' . $error ;
2012-01-24 10:36:28 +00:00
} else {
2011-10-19 15:28:49 +00:00
2012-01-24 10:36:28 +00:00
foreach ( $items as $item ) {
if ( $item [ 'url_acces' ] !== false ) {
2012-01-24 13:33:51 +00:00
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , $ref );
2012-01-24 10:36:28 +00:00
$href = '/fichier/pdf/' . $item [ 'url_acces' ];
echo '<br/><a href="' . $href . '" target="_blank">Ouvrir le bilan millésime ' . $item [ 'millesime' ] . '</a>' ;
} else {
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , 'Erreur telechargement ' . $ref );
$message = '<br/>Impossible de télécharger le fichier auprès de notre partenaire.' ;
//Envoi Mail avec reférence erreur
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'supportdev' );
$mail -> addToKey ( 'supportdev' );
$sujet = " [ERREUR TELECHARGEMENT INFOGREFFE] - " . date ( 'd' ) . " / " . date ( 'm' ) . " / " . date ( 'Y' );
$mail -> setSubject ( $sujet );
$emailTxt = $sujet . $message ;
$emailTxt .= '<br/>' . print_r ( $reponse , 1 );
$mail -> setBodyHtml ( $emailTxt );
$mail -> send ();
echo $message ;
}
2011-10-19 15:28:49 +00:00
}
}
}
2011-05-11 13:38:14 +00:00
break ;
}
}
2011-06-30 14:37:50 +00:00
/**
* Commande d ' acte
*/
2011-05-11 13:38:14 +00:00
public function acteAction ()
{
2011-06-29 15:48:05 +00:00
$user = new Utilisateur ();
if ( ! $user -> checkPerm ( 'ACTES' )){
$this -> _forward ( 'perms' , 'error' );
}
2011-05-17 07:35:54 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
2011-05-11 13:38:14 +00:00
$request = $this -> getRequest ();
$vecteur = $request -> getParam ( 'mode' );
$info = $request -> getParam ( 'info' );
$ref = $request -> getParam ( 'ref' );
$siren = substr ( $this -> siret , 0 , 9 );
2011-06-29 14:22:14 +00:00
$ws = new WsScores ();
2011-05-11 13:38:14 +00:00
switch ( $vecteur ) {
2011-05-17 07:35:54 +00:00
case 'C' :
$dejaCommande = false ;
$noemail = false ;
$sameLogin = false ;
$idCommande = 0 ;
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( 'idCommande, login, emailCommande, dateCommande' )
-> where ( " siren= $siren AND refDocument=' $ref ' AND statutCommande!=9 " );
$rows = $commandes -> fetchAll ( $rowset );
if ( count ( $rows ) != 0 ) {
$dejaCommande = true ;
2011-09-27 15:33:24 +00:00
if ( $rows [ 0 ] -> login == $user -> getLogin ())
2011-05-17 07:35:54 +00:00
{
2011-09-27 15:33:24 +00:00
$dateCommande = WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $rows [ 0 ] -> dateCommande );
$idCommande = $rows [ 0 ] -> idCommande ;
if ( empty ( $rows [ 0 ] -> emailCommande )) $noemail = true ;
2011-05-17 07:35:54 +00:00
$sameLogin = true ;
}
}
$params = array (
'idCommande' => $idCommande ,
'dejaCommande' => $dejaCommande ,
'noemail' => $noemail ,
'sameLogin' => $sameLogin ,
'siren' => $siren ,
'info' => $info ,
'vue' => 'actes' ,
);
$this -> _forward ( 'cmdcourrier' , 'pieces' , null , $params );
break ;
case 'courrier' :
$dejaCommande = false ;
$noemail = false ;
$sameLogin = false ;
$idCommande = 0 ;
//Vérification des commandes
if ( preg_match ( '/^([0-9]{4})[_sociaux-|_-]/' , $ref , $matches ))
{
$searchRef = '^' . $matches [ 1 ] . '[_-|_sociaux-]' ;
}
elseif ( preg_match ( '/^([0-9]{4})_consolide-/' , $ref , $matches ))
{
$searchRef = '^' . $matches [ 1 ] . '_consolide-' ;
}
else
{
$searchRef = $ref ;
}
$commandes = new Application_Model_Commandes ();
$rowset = $commandes -> select ( 'idCommande, login, emailCommande, dateCommande' )
-> where ( " siren= $siren AND refDocument=' $searchRef ' " );
$rows = $commandes -> fetchAll ( $rowset );
if ( count ( $rows ) != 0 ) {
2011-06-29 15:48:05 +00:00
2011-05-17 07:35:54 +00:00
$dejaCommande = true ;
if ( $rows [ 0 ][ 'login' ] == $user -> getLogin ())
{
$dateCommande = WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $rows [ 0 ][ 'dateCommande' ]);
2011-09-27 15:33:24 +00:00
$idCommande = $rows [ 0 ] -> idCommande ;
if ( empty ( $rows [ 0 ] -> emailCommande )) $noemail = true ;
2011-05-17 07:35:54 +00:00
$sameLogin = true ;
}
}
$params = array (
'idCommande' => $idCommande ,
'dejaCommande' => $dejaCommande ,
'noemail' => $noemail ,
'sameLogin' => $sameLogin ,
'siren' => $siren ,
'info' => $info ,
'vue' => 'actes' ,
);
$this -> _forward ( 'cmdcourrier' , 'pieces' , null , $params );
break ;
2011-05-11 13:38:14 +00:00
case 'fichier' :
2011-06-29 14:22:14 +00:00
$ws -> setLog ( 'greffe_actes' , $siren , 0 , $ref );
2011-05-11 13:38:14 +00:00
$info = unserialize ( urldecode ( $info ));
$href = '/fichier/pdf/acte-' . $siren . '-' . $ref . '.pdf' ;
echo '<br/><a href="' . $href . '" target="_blank">Ouvrir le fichier ' . $info [ 'type_lib' ] . ' </a>' ;
exit ;
break ;
case 'T' :
2011-10-19 15:28:49 +00:00
//Vérification que le fichier ne soit pas en erreur
$erreur = new Application_Model_CommandesErreur ();
$sql = $erreur -> select ()
2012-01-24 10:36:28 +00:00
-> from ( $erreur , array ( 'url' , 'dateCommande' ))
2011-10-19 15:28:49 +00:00
-> where ( " siren=' $siren ' AND type='acte' AND ref=' $ref ' AND erreur!='' " );
$repErreur = $erreur -> fetchAll ( $sql ) -> toArray ();
2012-01-24 10:36:28 +00:00
2011-10-19 15:28:49 +00:00
if ( count ( $repErreur ) > 0 ){
//Téléchagement
$fichier = 'acte-' . $siren . '-' . $ref . '.pdf' ;
if ( infogreffe_dl ( $fichier , $repErreur [ 0 ][ 'url' ], false )) {
$erreur -> update ( array ( 'erreur' => '' ), " siren=' $siren ' AND type='acte' AND ref=' $ref ' " );
2012-02-03 09:12:16 +00:00
$ws -> setLog ( 'greffe_actes' , $siren , 0 , $ref );
2012-01-24 20:41:47 +00:00
echo '<br/><a href="/fichier/pdf/' . $fichier . '" target="_blank">Ouvrir le fichier ' . $info [ 'type_lib' ] . ' </a>' ;
2011-10-19 15:28:49 +00:00
} else {
echo '<br/>Impossible de télécharger le fichier auprès de notre partenaire.' ;
}
2011-08-16 07:29:24 +00:00
2011-10-19 15:28:49 +00:00
} else {
$infogreffe = new Infogreffe ();
$reponse = $infogreffe -> getGreffeActes ( $siren , $vecteur , $ref );
if ( empty ( $reponse [ 'error' ])) {
$items = $reponse [ 'result' ][ 'actes' ];
} else {
$error = $reponse [ 'error' ][ 'errNum' ] . ' - ' . $reponse [ 'error' ][ 'errMsg' ];
}
if ( $error != '' ) {
2012-01-24 13:33:51 +00:00
$ws -> setLog ( 'greffe_actes' , $siren , 0 , 'Erreur ' . $reponse [ 'error' ][ 'errNum' ]);
2011-10-19 15:28:49 +00:00
echo '<br/>Erreur : ' . $error ;
2012-01-24 10:36:28 +00:00
} else {
foreach ( $items as $item ) {
2011-10-19 15:28:49 +00:00
if ( $item [ 'url_acces' ] !== false ) {
$ws -> setLog ( 'greffe_actes' , $siren , 0 , $ref );
$href = '/fichier/pdf/' . $item [ 'url_acces' ];
echo '<br/><a href="' . $href . '" target="_blank">Ouvrir le fichier ' . $item [ 'type_acte_libelle' ] . ' </a>' ;
} else {
$ws -> setLog ( 'greffe_actes' , $siren , 0 , 'Erreur telechargement ' . $ref );
$message = '<br/>Impossible de télécharger le fichier ' . $item [ 'type_acte_libelle' ] . ' auprès de notre partenaire.' ;
//Enregistrement de l'erreur dans la bdd
//Envoi Mail avec reférence erreur
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'supportdev' );
$mail -> addToKey ( 'supportdev' );
$sujet = " [ERREUR TELECHARGEMENT INFOGREFFE] - " . date ( 'd' ) . " / " . date ( 'm' ) . " / " . date ( 'Y' );
$mail -> setSubject ( $sujet );
$emailTxt = $sujet . $message ;
$emailTxt .= '<br/>' . print_r ( $reponse , 1 );
$mail -> setBodyHtml ( $emailTxt );
$mail -> send ();
echo $message ;
}
2011-05-11 13:38:14 +00:00
}
}
}
break ;
}
}
/**
* Commande de pièces , kbis , privileges , nantissements
*/
2011-05-05 12:04:47 +00:00
public function commandeAction ()
{
2011-06-30 12:02:08 +00:00
$request = $this -> getRequest ();
2011-05-11 13:38:14 +00:00
$this -> view -> headLink () -> appendStylesheet ( '/themes/default/styles/pieces.css' , 'all' );
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
2011-05-05 12:04:47 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
$session = new SessionEntreprise ( $this -> siret , $this -> id );
$user = new Utilisateur ();
$permKbis = false ;
2011-05-24 15:42:43 +00:00
$kbisErrCJ = false ;
$kbisErrDEP = false ;
2011-06-30 08:47:00 +00:00
if ( $user -> checkPerm ( 'kbis' )) {
2011-05-05 12:04:47 +00:00
$permKbis = true ;
2011-05-24 15:42:43 +00:00
//Vérification que le kbis est disponible
//=> FormeJuridique
2012-02-22 09:11:41 +00:00
if ( ( $session -> getFormeJuridique () >= 91 && $session -> getFormeJuridique () <= 93 )
|| ( $session -> getFormeJuridique () >= 9110 && $session -> getFormeJuridique () <= 9300 )
2012-02-24 08:52:48 +00:00
|| in_array ( $session -> getFormeJuridique (), array ( 1100 , 1200 , 1500 , 1600 , 1900 ) )
2012-02-22 09:11:41 +00:00
){
2011-05-24 15:42:43 +00:00
$kbisErrCJ = true ;
}
//=> Département
$dep = substr ( $session -> getCodeCommune (), 0 , 2 );
if ( in_array ( $dep , array ( '00' , '57' , '67' , '68' , '97' , '98' )) ) {
2011-06-30 08:47:00 +00:00
$kbisErrDEP = true ;
2011-05-24 15:42:43 +00:00
}
2011-05-05 12:04:47 +00:00
}
$permPriv = false ;
if ( $user -> checkPerm ( 'privileges' )){
$permPriv = true ;
}
$permSurvPriv = false ;
if ( $user -> checkPerm ( 'survpriv' )){
$permSurvPriv = true ;
}
2011-06-30 08:47:00 +00:00
$message = '' ;
//Validation du formulaire
if ( $request -> isPost () && $request -> getParam ( 'op' ) == 'kbis' ) {
$ref = $request -> getParam ( 'ref' );
$method = $request -> getParam ( 'method' );
switch ( $method ) {
case 'M' :
$email = $request -> getParam ( 'emailKbisM' , '' );
//Vérification des champs
if ( ! empty ( $email )) {
//Envoi du mail
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'contact' );
2012-01-27 12:49:50 +00:00
$mail -> addToKey ( 'production' );
2011-06-30 08:47:00 +00:00
$mail -> setSubject ( '[COMMANDE PIECES] - KBIS par email' );
$mail -> setBodyTexte (
'COMMANDE DE PIECES - Demande de kbis par email <br/>' . EOL .
'Demande pour recevoir le KBIS de SIREN :' .
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret )) . '">' .
$this -> siret . '</a><br/>' . EOL .
'pour login ' . $user -> getLogin () . '(' . $email . ')<br/>' . EOL .
'Référence : ' . $ref
);
2012-01-27 12:49:50 +00:00
$mail -> send ();
2011-06-30 08:47:00 +00:00
//Enregistrement dans la bdd
2011-09-27 15:33:24 +00:00
$commandesKbis = new Application_Model_CommandesKbis ();
2011-06-30 08:47:00 +00:00
$data = array (
'idUser' => $user -> getId (),
'login' => $user -> getLogin (),
'email' => $email ,
'societe' => '' ,
'nom' => '' ,
'adresse' => '' ,
'cp' => '' ,
'ville' => '' ,
2011-06-30 12:02:08 +00:00
'siren' => substr ( $this -> siret , 0 , 9 ),
2011-06-30 08:47:00 +00:00
'raisonSociale' => $this -> entrep -> getRaisonSociale (),
'type' => 'M' ,
'dateCommande' => date ( 'Y-m-d H:i:s' ),
);
$commandesKbis -> insert ( $data );
$message = 'Votre demande de reception de Kbis par email a été prise en compte' ;
$ws = new WsScores ();
$ws -> setLog ( 'kbis' , $this -> siret , 0 , 'mail' );
} else {
$message = '<font color="red">Erreur : adresse email non renseignée.</font>' ;
$this -> view -> assign ( 'ref' , $ref );
$this -> view -> assign ( 'method' , $method );
$this -> view -> assign ( 'emailKbisM' , $email );
}
break ;
case 'C' :
$email = $ref = $request -> getParam ( 'emailKbisC' , '' );
//Vérification des champs
$fields = array ( 'societe' , 'nom' , 'prenom' , 'adresse' , 'cp' , 'ville' );
$params = $request -> getParams ();
$error = false ;
foreach ( $fields as $field ) {
if ( empty ( $params [ $field ])) $error = true ;
}
if ( ! $error ) {
//Envoi du mail
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'contact' );
2012-01-27 12:49:50 +00:00
$mail -> addToKey ( 'production' );
2011-06-30 08:47:00 +00:00
$mail -> setSubject ( '[COMMANDE PIECES] - KBIS par courrier' );
$mail -> setBodyTexte (
'COMMANDE DE PIECES - Demande de kbis par courrier' . EOL .
2011-08-09 09:45:20 +00:00
'Demande pour recevoir le kbis de SIREN : ' .
2011-06-30 08:47:00 +00:00
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret )) . '">' .
$this -> siret . '</a><br/>' . EOL .
'pour login ' . $user -> getLogin () .
'(' . $email . ')' . '<br/>' . EOL .
'Societe :' . $params [ 'societe' ] . '<br/>' . EOL .
'Nom : ' . $params [ 'nom' ] . '<br/>' . EOL .
'Prenom : ' . $params [ 'prenom' ] . '<br/>' . EOL .
'Adresse : ' . $params [ 'adresse' ] . '<br/>' . EOL .
'CP : ' . $params [ 'cp' ] . '<br/>' . EOL .
'Ville : ' . $params [ 'ville' ]
);
$mail -> send ();
//Enregistrement dans la bdd
2011-09-27 15:33:24 +00:00
$commandesKbis = new Application_Model_CommandesKbis ();
2011-06-30 08:47:00 +00:00
$data = array (
'idUser' => $user -> getId (),
'login' => $user -> getLogin (),
'email' => $email ,
'societe' => $params [ 'societe' ],
'nom' => $params [ 'nom' ] . ' ' . $$params [ 'prenom' ],
'adresse' => $params [ 'adresse' ],
'cp' => $params [ 'cp' ],
'ville' => $params [ 'ville' ],
2011-06-30 12:02:08 +00:00
'siren' => substr ( $this -> siret , 0 , 9 ),
2011-06-30 08:47:00 +00:00
'raisonSociale' => $this -> entrep -> getRaisonSociale (),
'type' => 'C' ,
'dateCommande' => date ( 'Y-m-d H:i:s' ),
);
$commandesKbis -> insert ( $data );
$message = 'Votre commande à été prise en compte, vous recevrez ce document sous 3/5 jours' ;
$ws = new WsScores ();
$ws -> setLog ( 'kbis' , $this -> siret , 0 , 'courrier' );
}
else
{
$message = '<font color="red">Erreur : Tous les champs doivent être renseigner.</font>' ;
$this -> view -> assign ( 'emailKbisC' , $email );
$this -> view -> assign ( 'method' , $method );
$this -> view -> assign ( 'societe' , $params [ 'societe' ]);
$this -> view -> assign ( 'nom' , $params [ 'nom' ]);
$this -> view -> assign ( 'prenom' , $params [ 'prenom' ]);
$this -> view -> assign ( 'adresse' , $params [ 'adresse' ]);
$this -> view -> assign ( 'cp' , $params [ 'cp' ]);
$this -> view -> assign ( 'ville' , $params [ 'ville' ]);
}
break ;
}
$this -> view -> assign ( 'message' , $message );
}
if ( $request -> isPost () && $request -> getParam ( 'op' ) == 'privileges' ) {
$ref = $request -> getParam ( 'ref' );
$privileges = $request -> getParam ( 'privileges' );
$email = $request -> getParam ( 'email' , '' );
if ( ! empty ( $email )) {
if ( in_array ( 'SprivSurv' , $privileges ) ) {
$ws = new WsScores ();
$ws -> setSurveillance ( $this -> siret , $email , $ref , 'privileges' );
$privilegesLog = join ( '-' , $privileges );
}
$key = array_search ( 'SprivSurv' , $privileges );
if ( $key !== FALSE ) unset ( $privileges [ $key ]);
if ( count ( $privileges ) > 0 ) {
$privilegesJ = join ( ', ' , $privileges );
$privilegesLog = join ( '-' , $privileges );
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'contact' );
2012-01-27 12:49:50 +00:00
$mail -> addToKey ( 'production' );
2011-06-30 08:47:00 +00:00
$mail -> setSubject ( '[COMMANDE PIECES] - PRIVILEGES par email' );
$mail -> setBodyTexte (
'COMMANDE DE PRIVILEGES - par email<br/>' . EOL .
'Demande pour recevoir (' . $privilegesJ . ') pour SIREN : ' .
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret )) . '">' .
$this -> siret . '</a><br/>' . EOL .
'pour login ' . $user -> getLogin () . '(' . $email . ')<br/>' . EOL .
'Référence : ' . $ref
);
$mail -> send ();
}
$message = 'Votre commande a bien été prise en compte, vous recevrez ces documents sur votre e-mail.' ;
$ws = new WsScores ();
$ws -> setLog ( 'privileges' , $this -> siret , 0 , 'mail:' . $privilegesLog );
} else {
$message = '<font color="red">Erreur : adresse email non renseignée.</font>' ;
$this -> view -> assign ( 'ref' , $ref );
$this -> view -> assign ( 'privileges' , $privileges );
$this -> view -> assign ( 'email' , $email );
}
$this -> view -> assign ( 'message' , $message );
}
2011-05-24 15:42:43 +00:00
$this -> view -> assign ( 'KbisErreurCJ' , $kbisErrCJ );
$this -> view -> assign ( 'KbisErreurDEP' , $kbisErrDEP );
$this -> view -> assign ( 'permKbis' , $permKbis );
2011-05-05 12:04:47 +00:00
$this -> view -> assign ( 'permKbis' , $permKbis );
$this -> view -> assign ( 'permPriv' , $permPriv );
$this -> view -> assign ( 'permSurvPriv' , $permSurvPriv );
2011-05-24 15:42:43 +00:00
$this -> view -> assign ( 'user' , $user );
2011-05-05 12:04:47 +00:00
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
}
2011-05-24 15:42:43 +00:00
2012-02-16 17:15:54 +00:00
/**
* Affichage status association
*/
public function associationactesAction ()
{
$user = new Utilisateur ();
2012-02-17 10:04:23 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
$configuration = Zend_Registry :: get ( 'configuration' );
$path = $configuration -> path -> data . '/association/actes' ;
$actes = array ();
if ( ! empty ( $siren ) || intval ( $siren ) == 0 ){
2012-02-20 15:21:22 +00:00
foreach ( glob ( " $path /ST- " . $siren . " -*.pdf " ) as $filename ) {
2012-02-17 10:04:23 +00:00
echo $filename ;
2012-02-20 15:21:22 +00:00
preg_match ( '/ST-([0-9]{9})-([0-9]{8})\.pdf$/' , $filename , $matches );
2012-02-17 10:04:23 +00:00
$date = $matches [ 2 ];
2012-02-17 10:43:43 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'associationacte' ,
'fichier' => basename ( $filename ),
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
2012-02-17 10:04:23 +00:00
$actes [ $date ] = array (
2012-02-17 10:43:43 +00:00
'date' => substr ( $date , 6 , 2 ) . '/' . substr ( $date , 4 , 2 ) . '/' . substr ( $date , 0 , 4 ),
'type' => 'Statut' ,
'href' => $href ,
'descision' => '' ,
2012-02-17 10:04:23 +00:00
);
}
}
2012-02-16 17:15:54 +00:00
2012-02-17 10:04:23 +00:00
$session = new SessionEntreprise ( $this -> siret );
if ( substr ( $session -> AutreId , 0.1 ) == 'W' ){
foreach ( glob ( " $path /ST- " . $session -> AutreId . " -*.pdf " ) as $filename ) {
2012-02-20 15:21:22 +00:00
preg_match ( '/ST-(.*)-([0-9]{8})\.pdf$/' , $filename , $matches );
2012-02-17 10:04:23 +00:00
$date = $matches [ 2 ];
$actes [ $date ] = array (
'date' => substr ( $date , 6 , 2 ) . '/' . substr ( $date , 4 , 2 ) . '/' . substr ( $date , 0 , 4 ),
'type' => 'Statut' ,
'fichier' => $filename ,
'descision' => '' ,
);
}
}
krsort ( $actes );
$this -> view -> assign ( 'actes' , $actes );
2012-02-16 17:15:54 +00:00
$this -> view -> assign ( 'ModeEdition' , $user -> checkModeEdition ());
$this -> view -> assign ( 'email' , $user -> getEmail ());
2012-02-17 10:04:23 +00:00
$this -> view -> assign ( 'siren' , $siren );
2012-02-16 17:15:54 +00:00
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'id' , $this -> id );
$this -> view -> assign ( 'raisonSociale' , $this -> entrep -> getRaisonSociale ());
}
/**
* Enter description here ...
*/
public function associationacteAction ()
{
2012-02-17 10:43:43 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
2012-02-16 17:15:54 +00:00
2012-02-17 10:43:43 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
$request = $this -> getRequest ();
$file = $request -> getParam ( 'fichier' );
$ws = new WsScores ();
$ws -> setLog ( 'greffe_actes' , $siren , 0 , 'Acte association' );
$href = $this -> view -> url ( array (
'controller' => 'fichier' ,
'action' => 'pdfassociation' ,
'type' => 'actes' ,
'fichier' => $file ,
));
2012-02-16 17:15:54 +00:00
2012-02-17 10:43:43 +00:00
echo '<br/><a href="' . $href . '" target="_blank">Cliquez ici pour ouvrir le fichier</a>' ;
exit ;
2012-02-16 17:15:54 +00:00
}
/**
* Enter description here ...
*/
public function associationbilansAction ()
{
2012-02-17 10:04:23 +00:00
$user = new Utilisateur ();
2012-02-20 15:21:22 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-02-17 10:04:23 +00:00
$configuration = Zend_Registry :: get ( 'configuration' );
$path = $configuration -> path -> data . '/association/bilans' ;
$bilans = array ();
2012-02-20 15:21:22 +00:00
if ( ! empty ( $siren ) || intval ( $siren ) == 0 ){
foreach ( glob ( " $path / " . $siren . " _*.pdf " ) as $filename ) {
preg_match ( '/([0-9]{9})_([0-9]{8})/' , $filename , $matches );
2012-02-17 10:04:23 +00:00
$date = $matches [ 2 ];
2012-02-17 10:43:43 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'associationbilan' ,
'fichier' => basename ( $filename ),
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
2012-02-20 14:53:28 +00:00
2012-02-20 15:21:22 +00:00
$decision = '' ;
2012-02-20 14:39:40 +00:00
$suffix = '-0' ;
2012-02-20 15:21:22 +00:00
if ( preg_match ( '/[0-9]{9}_[0-9]{8}_rectif([0-9]{0,})\.pdf$/' , $filename , $mSuffix ) ) {
$decision = 'Rectificatif' ;
2012-02-20 14:39:40 +00:00
$suffix = '-1' ;
2012-02-20 14:51:48 +00:00
if ( intval ( $mSuffix [ 1 ]) != 0 ) {
$suffix = '-' . $mSuffix [ 1 ];
2012-02-20 14:39:40 +00:00
}
2012-02-20 14:53:28 +00:00
}
2012-02-20 14:39:40 +00:00
$bilans [ substr ( $date , 4 , 4 ) . $suffix ] = array (
2012-02-17 11:30:43 +00:00
'date' => substr ( $date , 0 , 2 ) . '/' . substr ( $date , 2 , 2 ) . '/' . substr ( $date , 4 , 4 ),
'type' => 'Bilan ' . substr ( $date , 4 , 4 ),
2012-02-17 10:43:43 +00:00
'href' => $href ,
'title' => $title ,
2012-02-20 15:21:22 +00:00
'decision' => $decision ,
2012-02-17 10:04:23 +00:00
);
}
}
2012-02-20 14:53:28 +00:00
2012-02-17 10:04:23 +00:00
$session = new SessionEntreprise ( $this -> siret );
if ( substr ( $session -> AutreId , 0.1 ) == 'W' ){
2012-02-17 16:59:53 +00:00
foreach ( glob ( " $path / " . $session -> AutreId . " _*.pdf " ) as $filename ) {
2012-02-20 14:42:36 +00:00
preg_match ( '/(.*)_([0-9]{8}).pdf/' , $filename , $matches );
2012-02-17 10:04:23 +00:00
$date = $matches [ 2 ];
2012-02-17 16:59:53 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'associationbilan' ,
'fichier' => basename ( $filename ),
));
$title = 'Télécharger le document correspondant' ;
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
2012-02-20 14:59:51 +00:00
$suffix = '-0' ;
2012-02-20 14:39:40 +00:00
$bilans [ substr ( $date , 4 , 4 ) . $suffix ] = array (
2012-02-17 11:30:43 +00:00
'date' => substr ( $date , 0 , 2 ) . '/' . substr ( $date , 2 , 2 ) . '/' . substr ( $date , 4 , 4 ),
'type' => 'Bilan ' . substr ( $date , 4 , 4 ),
2012-02-17 16:59:53 +00:00
'href' => $href ,
'title' => $title ,
2012-02-17 10:04:23 +00:00
'descision' => '' ,
);
}
}
krsort ( $bilans );
$this -> view -> assign ( 'bilans' , $bilans );
2012-02-16 17:15:54 +00:00
$this -> view -> assign ( 'ModeEdition' , $user -> checkModeEdition ());
$this -> view -> assign ( 'siren' , substr ( $this -> siret , 0 , 9 ));
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'id' , $this -> id );
$this -> view -> assign ( 'raisonSociale' , $this -> entrep -> getRaisonSociale ());
}
/**
* Enter description here ...
*/
public function associationbilanAction ()
{
2012-02-17 10:43:43 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ( true );
2012-02-16 17:15:54 +00:00
2012-02-17 10:43:43 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-02-16 17:15:54 +00:00
2012-02-17 10:43:43 +00:00
$request = $this -> getRequest ();
$file = $request -> getParam ( 'fichier' );
$ws = new WsScores ();
$ws -> setLog ( 'greffe_bilans' , $siren , 0 , 'Bilan association' );
$href = $this -> view -> url ( array (
'controller' => 'fichier' ,
'action' => 'pdfassociation' ,
'type' => 'bilans' ,
'fichier' => $file ,
));
2012-02-16 17:15:54 +00:00
2012-02-17 10:43:43 +00:00
echo '<br/><a href="' . $href . '" target="_blank">Cliquez ici pour ouvrir le fichier</a>' ;
exit ;
2012-02-16 17:15:54 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Gestion téléchargement des kbis
*/
public function kbisAction ()
{
2011-08-08 19:03:26 +00:00
//On bascule soit vers kbispasserelle ou vers kbis infogreffe
$this -> _forward ( 'kbispasserelle' , 'pieces' , null , $this -> getRequest () -> getParams ());
2011-06-30 14:37:50 +00:00
}
2011-05-24 15:42:43 +00:00
2011-06-30 14:37:50 +00:00
/**
* Téléchargement de kbis par la passerelle SD
*/
public function kbispasserelleAction ()
{
2011-08-08 19:03:26 +00:00
$request = $this -> getRequest ();
2011-08-08 19:46:12 +00:00
$params = $request -> getParams ();
2011-08-09 09:45:20 +00:00
require_once 'Scores/Utilisateur.php' ;
$user = new Utilisateur ();
2012-03-09 14:06:40 +00:00
$this -> view -> headLink () -> appendStylesheet ( '/themes/default/styles/kbis.css' , 'all' );
$session = new SessionEntreprise ( $params [ 'siret' ]);
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
$this -> view -> assign ( 'siren' , $params [ 'siret' ]);
$this -> view -> assign ( 'email' , $user -> getEmail ());
$this -> view -> assign ( 'login' , $user -> getLogin ());
2011-08-08 19:03:26 +00:00
//Mail
2011-08-09 09:45:20 +00:00
if ( isset ( $params [ 'op' ]) && $params [ 'op' ] == 'mailkbis' )
{
if ( ! empty ( $params [ 'email' ]))
{
require_once 'Scores/Mail.php' ;
$mail = new Mail ();
$mail -> setFrom ( 'contact' );
2012-01-27 12:49:50 +00:00
$mail -> addToKey ( 'production' );
2011-08-09 09:45:20 +00:00
$mail -> setSubject ( '[COMMANDE PIECES] - KBIS par email après essai(s) de téléchargement' );
$mail -> setBodyTexte (
'COMMANDE DE PIECES - Demande de kbis par email après essai(s) de téléchargement <br/>' . EOL .
'Demande pour recevoir le kbis de SIREN : ' .
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret )) . '">' .
$this -> siret . '</a><br/>' . EOL .
'pour login ' . $user -> getLogin () . '(' . $params [ 'email' ] . ')<br/>'
);
$ws = new WsScores ();
$ws -> setLog ( 'kbis' , $this -> siret , 0 , 'mail' );
$this -> view -> assign ( 'message' , " Votre demande de reception de Kbis par email à été prise en compte " );
} else {
$this -> view -> assign ( 'message' , " Votre demande n'a pas été prise en compte vous n'avez pas saisi d'email. " );
}
}
2011-08-08 19:03:26 +00:00
//Téléchargement
2012-03-09 14:06:40 +00:00
else
2011-08-08 19:03:26 +00:00
{
$start = $params [ 'start' ];
2012-03-09 14:06:40 +00:00
$siren = substr ( $params [ 'siret' ], 0 , 9 );
2011-08-08 19:03:26 +00:00
2012-03-09 14:06:40 +00:00
$path = APPLICATION_PATH . '/../cache/kbis/' ;
if ( ! is_dir ( $path )) mkdir ( $path );
if ( file_exists ( $path . 'kbis-' . $siren . '.pdf' )
2012-01-26 17:55:18 +00:00
&& date ( 'Ymd' , filemtime ( $path . 'kbis-' . $siren . '.pdf' )) == date ( 'Ymd' )
&& filesize ( $path . 'kbis-' . $siren . '.pdf' ) > 2000 )
2012-03-09 14:06:40 +00:00
{
$msg = '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/fichier/kbis/kbis-' . $siren . '.pdf">Visualiser le Kbis <img src="/themes/default/images/interfaces/icone_pdf.gif"></a></u>' ;
$this -> view -> assign ( 'message' , $msg );
$ws = new WsScores ();
$ws -> setLog ( 'kbis' , $siren , 0 , 'direct' );
}
else
{
2012-03-09 14:23:57 +00:00
require_once 'Scores/WsScores.php' ;
2012-03-09 14:06:40 +00:00
$ws = new WsScores ();
$info = $ws -> getKbis ( $siren );
if ( substr ( $info , 0 , 7 ) == 'http://' ) {
2012-01-26 17:55:18 +00:00
//Suppression du fichier si il existe
if ( file_exists ( $path . 'kbis-' . $siren . '.pdf' )) unlink ( $path . 'kbis-' . $siren . '.pdf' );
//On check si le fichier est présent sur l'url
2012-03-09 14:06:40 +00:00
$page = getUrl ( $info , '' , '' , '' , false );
2012-01-26 17:55:18 +00:00
//Fichier non disponible
2012-03-09 14:06:40 +00:00
if ( $page [ 'code' ] == 408 || $page [ 'code' ] == 400 || subst ( $page [ 'body' ], 0 , 4 ) != '%PDF' ) {
$this -> view -> assign ( 'message' , " Impossible de récupérer le fichier " );
$this -> view -> assign ( 'mail' , true );
//Ecriture du fichier sur le serveur en local
} else {
2012-01-26 17:55:18 +00:00
$body = $page [ 'body' ];
$fp = fopen ( $path . 'kbis-' . $siren . '.pdf' , 'w' );
fwrite ( $fp , $body );
fclose ( $fp );
2012-03-09 14:06:40 +00:00
$msg = '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/fichier/kbis/kbis-' . $siren . '.pdf">Visualiser le Kbis <img src="/themes/default/images/interfaces/icone_pdf.gif"></a></u>' ;
$this -> view -> assign ( 'message' , $msg );
2012-01-26 17:55:18 +00:00
}
2011-08-08 19:03:26 +00:00
} else {
2012-03-09 14:06:40 +00:00
$this -> view -> assign ( 'mail' , true );
$this -> view -> assign ( 'message' , $info );
2011-08-08 19:03:26 +00:00
}
2012-03-09 14:06:40 +00:00
}
2011-08-08 19:03:26 +00:00
}
2011-06-30 14:37:50 +00:00
}
/**
2011-08-09 09:45:20 +00:00
* A supprimer
2011-08-08 19:03:26 +00:00
* @ param unknown_type $siren
2011-06-30 14:37:50 +00:00
*/
2011-08-08 19:03:26 +00:00
function getKbis ( $siren ){
2011-06-30 14:37:50 +00:00
2011-08-08 19:03:26 +00:00
require_once 'Scores/Utilisateur.php' ;
$user = new Utilisateur ();
$client = new SoapClient ( null , array (
'trace' => 1 ,
'soap_version' => SOAP_1_1 ,
'location' => 'http://78.31.45.206:8088/ws/' ,
'uri' => 'http://78.31.45.206:8088/' ,
'login' => $user -> getLogin (),
'password' => $user -> getPassword (),
));
2011-06-30 14:37:50 +00:00
2011-08-08 19:03:26 +00:00
//ini_set('default_socket_timeout', 120); //timeout 2 min
$return = FALSE ;
try {
$O = $client -> getKbis ( $siren , 1 , 0 );
$kbis = $O [ 'result' ];
$return = $kbis [ 'Url' ];
} catch ( SoapFault $fault ) {
Zend_Registry :: get ( 'firebug' ) -> info ( $fault );
}
return $return ;
}
2011-06-30 14:37:50 +00:00
2011-08-08 19:03:26 +00:00
/**
* Téléchargement de kbis par infogreffe
*/
public function kbisinfogreffeAction ()
{
2011-06-30 14:37:50 +00:00
}
2011-05-11 13:38:14 +00:00
/**
* Affiche les privilèges en surveillance
*/
2011-05-05 12:04:47 +00:00
public function privilegesAction ()
{
$request = $this -> getRequest ();
$type = $request -> getParam ( 'type' , null );
$siren = substr ( $this -> siret , 0 , 9 );
$detail = false ;
if ( ! empty ( $type )){
$detail = true ;
}
$session = new SessionEntreprise ( $this -> siret , $this -> id );
$ws = new WsScores ();
if ( $detail ){
$infos = $ws -> getPrivilegesDetail ( $siren , array ( $type ));
} else {
$infos = $ws -> getPrivilegesCumul ( $siren );
}
2011-06-29 16:07:23 +00:00
Zend_Registry :: get ( 'firebug' ) -> info ( $infos );
2011-05-05 12:04:47 +00:00
$privileges = $infos -> result -> item ;
$this -> view -> assign ( 'privileges' , $privileges );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-03-01 13:10:25 +00:00
$user = new Utilisateur ();
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survpriv' ));
2011-05-05 12:04:47 +00:00
}
2011-04-19 07:37:39 +00:00
}