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
);
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
protected $siret ;
protected $id ;
2012-05-20 16:31:28 +00:00
2011-04-19 07:37:39 +00:00
public function init ()
{
2011-05-11 13:38:14 +00:00
require_once 'Scores/WsScores.php' ;
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
$request = $this -> getRequest ();
$this -> siret = $request -> getParam ( 'siret' );
$this -> id = $request -> getParam ( 'id' , 0 );
2011-04-19 07:37:39 +00:00
}
2011-05-11 13:38:14 +00:00
public function indexAction (){}
2012-05-20 16:31:28 +00:00
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
{
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-05-20 16:31:28 +00:00
2011-06-29 15:48:05 +00:00
$request = $this -> getRequest ();
2012-02-07 15:52:36 +00:00
$email = $request -> getParam ( 'email' , '' );
2013-10-23 14:20:56 +00:00
$reference = $request -> getParam ( 'reference' );
2012-05-20 16:31:28 +00:00
2013-10-23 14:20:56 +00:00
if ( empty ( $email )) {
$message = " ERREUR : Veuillez saisir une adresse email valide pour la commande de pièces. " ;
} elseif ( empty ( $reference )) {
$message = " ERREUR : Veuillez saisir une référence pour la commande de pièces. " ;
} else {
$c = Zend_Registry :: get ( 'config' );
$fp = fopen ( realpath ( $c -> profil -> path -> data ) . '/log/commande_asso.csv' , 'a' );
fwrite ( $fp , date ( 'Y/m/d H:i:s' ) . " ; $siren ; " . $email . ';' . $login . ';' . $user -> getEmail () . ';' . $user -> getIpAddress () . " \n " );
fclose ( $fp );
2012-05-20 16:31:28 +00:00
2013-10-23 14:20:56 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2011-06-29 15:48:05 +00:00
2013-10-23 14:20:56 +00:00
$infoAsso = new stdClass ();
$infoAsso -> siren = $siren ;
$infoAsso -> waldec = '' ;
$infoAsso -> idEntreprise = $this -> id ;
2013-11-21 16:31:49 +00:00
$infoAsso -> raisonSociale = $session -> getRaisonSociale ();
2012-05-20 16:31:28 +00:00
2013-10-23 14:20:56 +00:00
$infoDemande = new stdClass ();
$infoDemande -> reference = $request -> getParam ( 'reference' );
$infoDemande -> email = $email ;
$infoDemande -> tel = $request -> getParam ( 'tel' );
$infoDemande -> fax = '' ;
$infoDemande -> nom = '' ;
$infoDemande -> service = '' ;
$infoDemande -> societe = '' ;
$infoDemande -> adresse = '' ;
$infoDemande -> cp = '' ;
$infoDemande -> ville = '' ;
2012-05-20 16:31:28 +00:00
2013-10-23 14:20:56 +00:00
$ws = new WsScores ();
$reponse = $ws -> setCmdAsso ( $infoAsso , $infoDemande ); //@todo : vérfier les logs de facturation
Zend_Registry :: get ( 'firebug' ) -> info ( $reponse );
$annee = substr ( $reponse -> commande -> dateCommande , 0 , 4 );
$mois = substr ( $reponse -> commande -> dateCommande , 4 , 2 );
$jour = substr ( $reponse -> commande -> dateCommande , 6 , 2 );
$heure = substr ( $reponse -> commande -> dateCommande , 8 , 2 );
$minutes = substr ( $reponse -> commande -> dateCommande , 10 , 2 );
$ref = $reponse -> commande -> refCmd ;
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.' ;
}
}
2012-05-20 16:31:28 +00:00
2011-06-29 15:48:05 +00:00
$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 );
2013-11-21 16:31:49 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2011-05-11 13:38:14 +00:00
}
2012-05-20 16:31:28 +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
{
2012-11-20 07:33:06 +00:00
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
2011-06-29 15:48:05 +00:00
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
//Catégorie Juridique
2013-11-21 16:31:49 +00:00
$cj = $session -> getFormeJuridique ();
2011-05-11 13:38:14 +00:00
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
}
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
$request = $this -> getRequest ();
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
//Affichage des actes disponible
2014-02-13 14:41:39 +00:00
$ws = new WsScores ();
$responses = $ws -> getPiecesActes ( $siren );
Zend_Registry :: get ( 'firebug' ) -> info ( $responses );
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 ();
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
if ( $responses -> nbReponses > 0 ) {
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
$items = $responses -> result -> item ;
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
//Traitement des actes normaux
$infosActe = array ();
foreach ( $items as $item ) {
if ( $item -> ActeDate == '0000-00-00' ) {
2014-02-27 10:32:09 +00:00
$date = new Zend_Date ( $item -> DepotDate , 'yyyy-MM-dd' );
$infosActe [ 'date' ] = $date -> toString ( 'dd/MM/yyyy' );
2014-02-13 14:41:39 +00:00
} else {
$date = new Zend_Date ( $item -> ActeDate , 'yyyy-MM-dd' );
$infosActe [ 'date' ] = $date -> toString ( 'dd/MM/yyyy' );
}
$infosActe [ 'isFileExist' ] = false ;
if ( $item -> File != '' ) {
$infosActe [ 'isFileExist' ] = true ;
}
$infosActe [ 'mode' ] = $item -> ModeDiffusion ;
$infosActe [ 'lib' ] = $item -> ActeTypeLabel ;
switch ( $item -> ModeDiffusion ) {
case 'T' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'T' ,
'siren' => $siren ,
'depotNum' => $item -> DepotNum ,
'depotDate' => $item -> DepotDate ,
'acteLabel' => $item -> ActeTypeLabel ,
'acteType' => $item -> ActeType ,
'acteNum' => $item -> ActeNum ,
'acteDate' => $item -> ActeDate ,
), null , true );
$title = " Télécharger le document correspondant " ;
} else {
$href = '#' ;
$title = " Vous n'avez pas les droits nécessaires pour commander le document correspondant. " ;
2011-05-19 07:12:51 +00:00
}
2014-02-13 14:41:39 +00:00
break ;
2011-05-11 13:38:14 +00:00
case 'C' :
2014-02-13 14:41:39 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
2011-05-19 07:12:51 +00:00
$href = $this -> view -> url ( array (
2014-02-13 14:41:39 +00:00
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'C' ,
'siren' => $siren ,
'depotNum' => $item -> DepotNum ,
'depotDate' => $item -> DepotDate ,
'acteLabel' => $item -> ActeTypeLabel ,
'acteType' => $item -> ActeType ,
'acteNum' => $item -> ActeNum ,
'acteDate' => $item -> ActeDate ,
), null , true );
$title = " Commande d'une pièce officielle " ;
2011-05-19 07:12:51 +00:00
} else {
$href = '#' ;
2014-02-13 14:41:39 +00:00
$title = " Vous n'avez pas les droits nécessaires pour commander le document correspondant. " ;
2011-05-11 13:38:14 +00:00
}
break ;
}
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
$infosActe [ 'factice' ] = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'acte' ,
'mode' => 'F' ,
'siren' => $siren ,
'depotNum' => $item -> DepotNum ,
'depotDate' => $item -> DepotDate ,
'acteLabel' => $item -> ActeTypeLabel ,
'acteType' => $item -> ActeType ,
'acteNum' => $item -> ActeNum ,
'acteDate' => $item -> ActeDate ,
), null , true );
$infosActe [ 'href' ] = $href ;
$infosActe [ 'title' ] = $title ;
$data = '' ;
if ( intval ( $item -> DepotNum ) >= 0 ) {
$date = new Zend_Date ( $item -> DepotDate , 'yyyy-MM-dd' );
$data .= '<b>Dépot n°' . $item -> DepotNum . ' du ' . $date -> toString ( 'dd/MM/yyyy' ) . '</b>' ;
//Nombre de pages
$nbPage = 0 ;
if ( $item -> FileNumberOfPages > 0 ) {
$nbPage = $item -> FileNumberOfPages ;
2014-03-03 16:40:07 +00:00
} elseif ( $item -> ActeNumberOfPages > 0 ) {
$nbPage = $item -> ActeNumberOfPages ;
2014-02-13 14:41:39 +00:00
}
if ( $nbPage > 1 ) {
$data .= '<br/>Document de ' . $nbPage . ' pages.' ;
2014-03-03 16:40:07 +00:00
} elseif ( $nbPage == 1 ) {
2014-02-13 14:41:39 +00:00
$data .= '<br/>Document de ' . $nbPage . ' page.' ;
2011-05-11 13:38:14 +00:00
}
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
//Informations
if ( count ( $item -> infos -> item ) > 0 ) {
foreach ( $item -> infos -> item as $txt ) {
$data .= '<br/>' . $txt ;
}
}
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
//@todo
if ( ! empty ( $acte [ 'decision' ])){
$data .= '<br/>' . $acte [ 'decision' ];
2011-05-11 13:38:14 +00:00
}
2014-02-13 14:41:39 +00:00
}
$infosActe [ 'decision' ] = $data ;
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
$infosActes [] = $infosActe ;
} // Fin acte
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
}
2012-05-20 16:31:28 +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 );
2013-11-21 16:31:49 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-05-20 16:31:28 +00:00
2012-03-01 13:10:25 +00:00
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survbilan' ));
2011-04-19 07:37:39 +00:00
}
2012-05-20 16:31:28 +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 ()
{
2012-08-17 13:02:12 +00:00
$user = new Scores_Utilisateur ();
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2013-01-23 12:55:12 +00:00
2012-11-20 07:33:06 +00:00
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
//Catégorie Juridique
2013-11-21 16:31:49 +00:00
$cj = $session -> getFormeJuridique ();
2011-05-11 13:38:14 +00:00
if ( in_array ( $cj , $this -> association_cj ) ) {
2012-02-16 17:15:54 +00:00
$this -> _forward ( 'associationbilans' );
2012-08-17 13:02:12 +00:00
} else {
$request = $this -> getRequest ();
$siren = substr ( $this -> siret , 0 , 9 );
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
//Affichage des bilans disponible
2014-02-13 14:41:39 +00:00
$ws = new WsScores ();
$response = $ws -> getPiecesBilans ( $siren );
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
$infosBilans = array ();
2014-02-13 14:41:39 +00:00
if ( $response -> nbReponses > 0 ) {
2013-01-23 12:55:12 +00:00
2014-02-13 14:41:39 +00:00
$items = $response -> result -> item ;
2012-08-17 13:02:12 +00:00
foreach ( $items as $key => $item )
{
$infosBilan = array ();
2014-02-13 14:41:39 +00:00
$date = new Zend_Date ( $item -> DateCloture , 'yyyy-MM-dd' );
$infosBilan [ 'date' ] = $date -> toString ( 'dd/MM/yyyy' );
$infosBilan [ 'type' ] = 'Comptes ' . $item -> Type . ' millésime ' . $item -> Millesime ;
$infosBilan [ 'mode' ] = $item -> ModeDiffusion ;
$infosBilan [ 'isFileExist' ] = false ;
if ( $item -> File != '' ) {
$infosBilan [ 'isFileExist' ] = true ;
}
switch ( $item -> ModeDiffusion ) {
2012-08-17 13:02:12 +00:00
case 'T' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'mode' => 'T' ,
2014-02-13 14:41:39 +00:00
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
2012-08-17 13:02:12 +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 'C' :
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
2014-02-13 14:41:39 +00:00
'mode' => 'C' ,
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
2012-08-17 13:02:12 +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 ;
}
2014-02-13 14:41:39 +00:00
$infosBilan [ 'factice' ] = $this -> view -> url ( array (
'controller' => 'pieces' ,
'action' => 'bilan' ,
'siret' => $siren ,
'mode' => 'T' ,
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
));
2012-08-17 13:02:12 +00:00
$infosBilan [ 'href' ] = $href ;
$infosBilan [ 'title' ] = $title ;
2013-01-23 12:55:12 +00:00
2014-02-13 14:41:39 +00:00
$infosBilan [ 'duree' ] = '' ;
if ( intval ( $item -> DureeExercice ) > 0 ) {
$infosBilan [ 'duree' ] = " Exercice sur " . $item -> DureeExercice . " mois " ;
}
$infosBilan [ 'decision' ] = 'Dépot n°' . $item -> NumDepot ;
if ( ! empty ( $item -> File ) && $item -> NumberOfPages > 0 ) {
$infosBilan [ 'decision' ] .= " <br/>Document de " . $item -> NumberOfPages . " pages " ;
}
2014-02-25 16:58:40 +00:00
2014-02-13 14:41:39 +00:00
if ( empty ( $item -> SaisieDate ) || $item -> SaisiDate == '0000-00-00' ) {
$infosBilan [ 'saisie' ] = " Bilan non saisi. " ;
} else if ( $item -> SaisieCode == '00' ) {
$date = new Zend_Date ( $item -> SaisieDate , 'yyyy-MM-dd' );
2014-02-25 16:58:40 +00:00
$infosBilan [ 'saisie' ] = " Bilan saisi le " . $date -> toString ( 'dd/MM/yyyy' ) . " . " ;
2014-02-13 14:41:39 +00:00
if ( ! empty ( $item -> SaisieLabel ) ) {
2014-02-25 16:58:40 +00:00
$infosBilan [ 'saisie' ] .= '<img class="ui-icon ui-icon-info" style="float:right;" title="' . $item -> SaisieLabel . '">' ;
2014-02-13 14:41:39 +00:00
}
} else {
$date = new Zend_Date ( $item -> SaisieDate , 'yyyy-MM-dd' );
2014-02-25 16:58:40 +00:00
$infosBilan [ 'saisie' ] = " Bilan non saisi le " . $date -> toString ( 'dd/MM/yyyy' ) . " . " ;
if ( ! empty ( $item -> SaisieLabel ) ) {
$infosBilan [ 'saisie' ] .= '<img class="ui-icon ui-icon-info" style="float:right;" title="' . $item -> SaisieLabel . '">' ;
}
2014-02-13 14:41:39 +00:00
}
2012-08-17 13:02:12 +00:00
$infosBilans [] = $infosBilan ;
}
}
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
$this -> view -> assign ( 'ModeEdition' , $user -> checkModeEdition ());
$this -> view -> assign ( 'InfosBilans' , $infosBilans );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
2013-11-21 16:31:49 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survactes' ));
2011-05-11 13:38:14 +00:00
}
}
2012-05-20 16:31:28 +00:00
2011-06-30 14:37:50 +00:00
/**
* Commande de bilan
*/
2011-05-11 13:38:14 +00:00
public function bilanAction ()
{
2014-02-13 14:41:39 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$user = new Scores_Utilisateur ();
2011-06-29 15:48:05 +00:00
if ( ! $user -> checkPerm ( 'ACTES' )){
$this -> _forward ( 'perms' , 'error' );
}
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
$request = $this -> getRequest ();
$siren = substr ( $this -> siret , 0 , 9 );
$this -> view -> assign ( 'siren' , $siren );
$mode = $request -> getParam ( 'mode' );
$dateCloture = $request -> getParam ( 'cloture' );
$type = $request -> getParam ( 'type' );
$ws = new WsScores ();
switch ( $mode ) {
case 'F' :
$response = $ws -> getPiecesBilan ( $siren , $type , $mode , $dateCloture , $ref );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
} else {
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . $response . " . " );
}
break ;
//Télécharger le fichier
case 'T' :
$response = $ws -> getPiecesBilan ( $siren , $type , $mode , $dateCloture );
2014-03-03 16:40:07 +00:00
if ( $response === false || $response == '' ) {
2014-02-13 14:41:39 +00:00
$this -> view -> assign ( 'msg' , " Fichier introuvable. " );
} else {
try {
$client = new Zend_Http_Client ( $response );
$client -> setStream ();
$stream = $client -> request ( 'GET' );
if ( $stream -> isSuccessful () && substr ( $stream -> getBody (), 0 , 4 ) == '%PDF' ) {
$c = Zend_Registry :: get ( 'config' );
2014-02-25 16:58:40 +00:00
$file = 'bilan-' . $siren . '-' . $type . '-' . $dateCloture . '.pdf' ;
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> files . '/' . $file )) {
$this -> view -> assign ( 'url' , $this -> view -> url ( array (
2014-02-13 14:41:39 +00:00
'controller' => 'fichier' ,
2014-02-25 16:58:40 +00:00
'action' => 'greffe' ,
), null , true ) . '/' . $file );
2014-02-13 14:41:39 +00:00
} else {
2014-02-25 16:58:40 +00:00
$this -> view -> assign ( 'msg' , " Impossible de distribuer le fichier. " );
2014-02-13 14:41:39 +00:00
}
2014-02-25 16:58:40 +00:00
} else {
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
2014-02-13 14:41:39 +00:00
}
} catch ( Zend_Http_Client_Exception $e ) {
Zend_Registry :: get ( 'firebug' ) -> info ( 'HTTP Exception : ' . $e -> getMessage ());
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
}
}
break ;
//Passer commande
case 'C' :
$ref = $request -> getParam ( 'ref' );
if ( $request -> isXmlHttpRequest () ) {
//Enregistrement de la commande
if ( $request -> isPost () ) {
$response = $ws -> getPiecesBilan ( $siren , $type , $mode , $dateCloture , $ref );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
} else {
2014-05-24 09:22:50 +00:00
$this -> view -> assign ( 'formEmail' , true );
$this -> view -> assign ( 'refCommande' , $response );
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . strtoupper ( $response ) . " . " );
2014-02-13 14:41:39 +00:00
}
}
//Affichage du formulaire
else {
$user = new Scores_Utilisateur ();
$email = explode ( ';' , $user -> getEmail ());
$this -> view -> assign ( 'email' , $email [ 0 ]);
$validator = new Zend_Validate_EmailAddress ();
$this -> view -> assign ( 'emailValide' , $validator -> isValid ( $email [ 0 ]));
$this -> view -> assign ( 'formCmd' , true );
$this -> view -> assign ( 'mode' , $mode );
$date = new Zend_Date ( $cloture , 'yyyy-MM-dd' );
$this -> view -> assign ( 'LabelCloture' , $date -> toString ( 'dd/MM/yyyy' ));
$this -> view -> assign ( 'cloture' , $cloture );
$this -> view -> assign ( 'type' , $type );
}
}
break ;
2014-05-24 09:22:50 +00:00
//Saisir email
case 'EMAIL' :
if ( $request -> isXmlHttpRequest () ) {
if ( $request -> isPost () ) {
$id = $request -> getParam ( 'refCommande' );
$email = trim ( $request -> getParam ( 'email' ));
if ( ! empty ( $email ) ) {
$response = $ws -> setPiecesBilanCmdEmail ( $id , $email );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Impossible d'enregistrer un email pour la commande " . strtoupper ( $id ) . " . " );
} else {
$this -> view -> assign ( 'msg' , " Email " . $email . " enregistré pour la commande " . strtoupper ( $id ) . " . " );
}
} else {
$this -> view -> assign ( 'msg' , " Email incorrect. " );
}
}
}
break ;
2014-02-13 14:41:39 +00:00
}
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Commande d ' acte
*/
2011-05-11 13:38:14 +00:00
public function acteAction ()
{
2014-02-13 14:41:39 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
$user = new Scores_Utilisateur ();
2011-06-29 15:48:05 +00:00
if ( ! $user -> checkPerm ( 'ACTES' )){
$this -> _forward ( 'perms' , 'error' );
}
2012-05-20 16:31:28 +00:00
2014-02-13 14:41:39 +00:00
$request = $this -> getRequest ();
$siren = $request -> getParam ( 'siren' );
$this -> view -> assign ( 'siren' , $siren );
$mode = $request -> getParam ( 'mode' );
$depotNum = $request -> getParam ( 'depotNum' );
$depotDate = $request -> getParam ( 'depotDate' );
$acteType = $request -> getParam ( 'acteType' );
$acteNum = $request -> getParam ( 'acteNum' );
$acteDate = $request -> getParam ( 'acteDate' );
$ws = new WsScores ();
switch ( $mode ) {
//Commande factice
case 'F' :
//Enregistrement de la commande
$response = $ws -> getPiecesActe ( $siren , $mode , $depotNum , $depotDate , $acteType , $acteNum , $acteDate , $ref );
if ( $response === false ) {
2014-03-03 16:40:07 +00:00
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
2014-02-13 14:41:39 +00:00
} else {
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . strtoupper ( $response ) . " . " );
}
break ;
//Télécharger le fichier
case 'T' :
2014-02-25 16:58:40 +00:00
$response = $ws -> getPiecesActe ( $siren , $mode , $depotNum , $depotDate , $acteType , $acteNum , $acteDate );
2014-03-03 16:40:07 +00:00
if ( $response === false || $response == '' ) {
2014-02-13 14:41:39 +00:00
$this -> view -> assign ( 'msg' , " Fichier introuvable. " );
} else {
try {
$client = new Zend_Http_Client ( $response );
$client -> setStream ();
$stream = $client -> request ( 'GET' );
if ( $stream -> isSuccessful () && substr ( $stream -> getBody (), 0 , 4 ) == '%PDF' ) {
$c = Zend_Registry :: get ( 'config' );
2014-02-25 16:58:40 +00:00
$file = 'acte-' . $siren . '-' . $depotNum . '-' . $acteNum . '.pdf' ;
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> files . '/' . $file )) {
$this -> view -> assign ( 'url' , $this -> view -> url ( array (
2014-02-13 14:41:39 +00:00
'controller' => 'fichier' ,
2014-02-25 16:58:40 +00:00
'action' => 'greffe' ,
), null , true ) . '/' . $file );
2014-02-13 14:41:39 +00:00
} else {
2014-02-25 16:58:40 +00:00
$this -> view -> assign ( 'msg' , " Impossible de distribuer le fichier. " );
2014-02-13 14:41:39 +00:00
}
2014-02-25 16:58:40 +00:00
} else {
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
2014-02-13 14:41:39 +00:00
}
} catch ( Zend_Http_Client_Exception $e ) {
Zend_Registry :: get ( 'firebug' ) -> info ( 'HTTP Exception : ' . $e -> getMessage ());
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
}
}
break ;
//Passer commande
case 'C' :
$ref = $request -> getParam ( 'ref' );
$label = $request -> getParam ( 'acteLabel' );
if ( $request -> isXmlHttpRequest () ) {
//Enregistrement de la commande
if ( $request -> isPost () ) {
$response = $ws -> getPiecesActe ( $siren , $mode , $depotNum , $depotDate , $acteType , $acteNum , $acteDate , $ref );
2014-05-24 09:22:50 +00:00
if ( $response === false ) {
2014-02-13 14:41:39 +00:00
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
} else {
2014-05-24 09:22:50 +00:00
$this -> view -> assign ( 'formEmail' , true );
$this -> view -> assign ( 'refCommande' , $response );
2014-02-13 14:41:39 +00:00
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . strtoupper ( $response ) . " . " );
}
}
//Affichage du formulaire
else {
$user = new Scores_Utilisateur ();
$email = explode ( ';' , $user -> getEmail ());
$this -> view -> assign ( 'email' , $email [ 0 ]);
$validator = new Zend_Validate_EmailAddress ();
$this -> view -> assign ( 'emailValide' , $validator -> isValid ( $email [ 0 ]));
$this -> view -> assign ( 'formCmd' , true );
$this -> view -> assign ( 'mode' , $mode );
$this -> view -> assign ( 'depotNum' , $depotNum );
$this -> view -> assign ( 'depotDate' , $depotDate );
$date = new Zend_Date ( $depotDate , 'yyyy-MM-dd' );
$this -> view -> assign ( 'LabelDepotDate' , $date -> toString ( 'dd/MM/yyyy' ));
$this -> view -> assign ( 'Label' , $label );
$this -> view -> assign ( 'acteType' , $acteType );
$this -> view -> assign ( 'acteNum' , $acteNum );
$this -> view -> assign ( 'acteDate' , $acteDate );
$date = new Zend_Date ( $acteDate , 'yyyy-MM-dd' );
$this -> view -> assign ( 'LabelActeDate' , $date -> toString ( 'dd/MM/yyyy' ));
}
}
break ;
2014-05-24 09:22:50 +00:00
//Saisir email
case 'EMAIL' :
if ( $request -> isXmlHttpRequest () ) {
if ( $request -> isPost () ) {
$id = $request -> getParam ( 'refCommande' );
$email = trim ( $request -> getParam ( 'email' ));
if ( ! empty ( $email ) ) {
$response = $ws -> setPiecesActeCmdEmail ( $id , $email );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Impossible d'enregistrer un email pour la commande " . strtoupper ( $id ) . " . " );
} else {
$this -> view -> assign ( 'msg' , " Email " . $email . " enregistré pour la commande " . strtoupper ( $id ) . " . " );
}
} else {
$this -> view -> assign ( 'msg' , " Email incorrect. " );
}
}
}
break ;
2014-02-13 14:41:39 +00:00
}
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
}
2012-05-20 16:31:28 +00:00
2011-05-11 13:38:14 +00:00
/**
* 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 ();
2012-11-20 07:33:06 +00:00
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/pieces.js' , 'text/javascript' );
2012-05-20 16:31:28 +00:00
2011-05-05 12:04:47 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-05-20 16:31:28 +00:00
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2011-05-05 12:04:47 +00:00
$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
2012-08-07 15:10:54 +00:00
if ( substr ( $session -> getFormeJuridique (), 0 , 1 ) == 7
|| substr ( $session -> getFormeJuridique (), 0 , 1 ) == 8
|| substr ( $session -> getFormeJuridique (), 0 , 1 ) == 9
2013-02-20 13:16:06 +00:00
|| in_array ( $session -> getFormeJuridique (), array_merge (
2014-06-18 13:29:09 +00:00
array ( 1300 , 1500 , 1600 , 1700 , 1800 , 1900 ), $this -> association_cj ) ) ){
2012-08-07 15:10:54 +00:00
$kbisErrCJ = true ;
}
2011-05-24 15:42:43 +00:00
//=> 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 ;
}
2012-05-20 16:31:28 +00:00
2011-06-30 08:47:00 +00:00
$message = '' ;
2012-05-20 16:31:28 +00:00
2014-04-24 10:46:36 +00:00
$emails = explode ( ';' , $user -> getEmail ());
$email = $emails [ 0 ];
$validator = new Zend_Validate_EmailAddress ();
$this -> view -> assign ( 'emailValid' , $validator -> isValid ( $email ));
2011-06-30 08:47:00 +00:00
if ( $request -> isPost () && $request -> getParam ( 'op' ) == 'privileges' ) {
2012-05-20 16:31:28 +00:00
2011-06-30 08:47:00 +00:00
$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 );
2012-05-20 16:31:28 +00:00
2013-10-25 14:30:46 +00:00
$mail = new Scores_Mail ();
2011-06-30 08:47:00 +00:00
$mail -> setFrom ( 'contact' );
2013-03-21 08:39:06 +00:00
$mail -> addToKey ( 'support' );
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 );
}
2012-05-20 16:31:28 +00:00
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 );
2012-05-20 16:31:28 +00:00
2011-05-24 15:42:43 +00:00
$this -> view -> assign ( 'user' , $user );
2012-05-20 16:31:28 +00:00
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 ());
}
2012-05-20 16:31:28 +00:00
2012-02-16 17:15:54 +00:00
/**
* Affichage status association
*/
public function associationactesAction ()
{
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2012-02-17 10:04:23 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-05-20 16:31:28 +00:00
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-11-05 15:33:01 +00:00
$c = Zend_Registry :: get ( 'config' );
2012-11-16 14:12:03 +00:00
$path = $c -> profil -> path -> data . '/association/actes' ;
2012-05-20 16:31:28 +00:00
2012-02-17 10:04:23 +00:00
$actes = array ();
if ( ! empty ( $siren ) || intval ( $siren ) == 0 ){
2012-02-20 15:21:22 +00:00
foreach ( glob ( " $path /ST- " . $siren . " -*.pdf " ) as $filename ) {
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 (
2012-05-20 16:31:28 +00:00
'controller' => 'pieces' ,
'action' => 'associationacte' ,
2012-02-17 10:43:43 +00:00
'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-05-20 16:31:28 +00:00
2012-02-17 10:04:23 +00:00
);
}
}
2012-05-20 16:31:28 +00:00
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret );
2012-02-17 10:04:23 +00:00
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-05-20 16:31:28 +00:00
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 );
2013-11-21 16:31:49 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-02-16 17:15:54 +00:00
}
2012-05-20 16:31:28 +00:00
2012-02-16 17:15:54 +00:00
/**
* 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-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
$request = $this -> getRequest ();
$file = $request -> getParam ( 'fichier' );
2012-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
$ws = new WsScores ();
$ws -> setLog ( 'greffe_actes' , $siren , 0 , 'Acte association' );
$href = $this -> view -> url ( array (
2012-05-20 16:31:28 +00:00
'controller' => 'fichier' ,
2012-02-17 10:43:43 +00:00
'action' => 'pdfassociation' ,
'type' => 'actes' ,
'fichier' => $file ,
));
2012-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
echo '<br/><a href="' . $href . '" target="_blank">Cliquez ici pour ouvrir le fichier</a>' ;
2012-05-20 16:31:28 +00:00
exit ;
2012-02-16 17:15:54 +00:00
}
2012-05-20 16:31:28 +00:00
2012-02-16 17:15:54 +00:00
/**
* Enter description here ...
*/
public function associationbilansAction ()
{
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-02-20 15:21:22 +00:00
$siren = substr ( $this -> siret , 0 , 9 );
2012-05-20 16:31:28 +00:00
2012-02-17 10:04:23 +00:00
$bilans = array ();
2013-01-23 12:55:12 +00:00
2012-05-20 16:31:28 +00:00
if ( ! empty ( $siren ) || intval ( $siren ) == 0 ){
2012-08-17 13:02:12 +00:00
require_once 'Scores/WsScores.php' ;
$ws = new WsScores ();
$reponse = $ws -> getPiecesBilans ( $siren );
$listBilans = $reponse -> result -> item ;
Zend_Registry :: get ( 'firebug' ) -> info ( $listBilans );
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
$decision = '' ;
foreach ( $listBilans as $item ) {
2012-02-17 10:43:43 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
2012-08-17 13:02:12 +00:00
if ( ! empty ( $item -> File ) ) {
$href = $this -> view -> url ( array (
2014-03-05 15:11:14 +00:00
'controller' => 'pieces' ,
'action' => 'associationbilan' ,
2012-08-17 13:02:12 +00:00
'siren' => $siren ,
'dateCloture' => $item -> DateCloture ,
'reference' => $item -> File ,
), null , true );
$title = 'Télécharger le document correspondant' ;
} else {
2012-11-19 15:53:10 +00:00
$href = '#' ;
2012-08-17 13:02:12 +00:00
$title = 'Document inexistant.' ;
}
2012-02-17 10:43:43 +00:00
} else {
$href = '#' ;
$title = 'Vous n\'avez pas les droits nécessaires pour commander le document correspondant.' ;
}
2012-05-20 16:31:28 +00:00
2012-08-17 13:02:12 +00:00
$decision = $item -> Type ;
if ( ! empty ( $item -> NumberOfPages ) ) {
$decision .= ', ' . $item -> NumberOfPages . ' pages' ;
2012-02-20 14:53:28 +00:00
}
2012-05-20 16:31:28 +00:00
2012-08-17 13:02:12 +00:00
$bilans [] = array (
'date' => substr ( $item -> DateCloture , 6 , 2 ) . '/' . substr ( $item -> DateCloture , 4 , 2 ) . '/' . substr ( $item -> DateCloture , 0 , 4 ),
'type' => 'Bilan ' . substr ( $item -> DateCloture , 0 , 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
);
}
}
$this -> view -> assign ( 'bilans' , $bilans );
2012-05-20 16:31:28 +00:00
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 );
2013-11-21 16:31:49 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-05-20 16:31:28 +00:00
2012-02-16 17:15:54 +00:00
}
2012-05-20 16:31:28 +00:00
2012-02-16 17:15:54 +00:00
/**
2014-04-24 10:46:36 +00:00
* Bilan association
*/
2012-02-16 17:15:54 +00:00
public function associationbilanAction ()
{
2012-02-17 10:43:43 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
2012-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
$request = $this -> getRequest ();
2012-08-17 13:02:12 +00:00
$siren = $request -> getParam ( 'siren' );
2014-03-05 15:11:14 +00:00
$diffusion = 'T' ;
2012-08-17 13:02:12 +00:00
$dateCloture = $request -> getParam ( 'dateCloture' );
$reference = $request -> getParam ( 'reference' );
2014-03-05 15:11:14 +00:00
$type = 'association' ;
2013-01-23 12:55:12 +00:00
2012-08-17 13:02:12 +00:00
//Récupération du l'URL
2012-02-17 10:43:43 +00:00
$ws = new WsScores ();
2014-03-05 15:11:14 +00:00
$url = $ws -> getPiecesBilan ( $siren , $type , $diffusion , $dateCloture , $reference );
if ( ! empty ( $url ) ) {
try {
$client = new Zend_Http_Client ( $url );
$client -> setStream ();
$stream = $client -> request ( 'GET' );
if ( $stream -> isSuccessful () && substr ( $stream -> getBody (), 0 , 4 ) == '%PDF' ) {
$c = Zend_Registry :: get ( 'config' );
$file = 'bilan-' . $siren . '-' . $type . '-' . $dateCloture . '.pdf' ;
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> files . '/' . $file )) {
$this -> view -> assign ( 'url' , $this -> view -> url ( array (
'controller' => 'fichier' ,
'action' => 'greffe' ,
), null , true ) . '/' . $file );
} else {
$this -> view -> assign ( 'msg' , " Impossible de distribuer le fichier. " );
}
} else {
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
}
} catch ( Zend_Http_Client_Exception $e ) {
Zend_Registry :: get ( 'firebug' ) -> info ( 'HTTP Exception : ' . $e -> getMessage ());
$this -> view -> assign ( 'msg' , " Erreur lors du téléchargement du fichier. " );
}
2012-02-17 10:43:43 +00:00
2012-08-17 13:02:12 +00:00
} else {
2014-03-05 15:11:14 +00:00
$this -> view -> assign ( 'msg' , " Fichier indisponible ! " );
2012-08-17 13:02:12 +00:00
}
2012-05-20 16:31:28 +00:00
}
2011-06-30 14:37:50 +00:00
/**
* Gestion téléchargement des kbis
*/
2014-04-24 10:46:36 +00:00
public function kbisAction ()
2011-06-30 14:37:50 +00:00
{
2014-06-18 13:29:09 +00:00
//Désactivation affichage
$this -> _helper -> layout () -> disableLayout ();
2011-08-08 19:03:26 +00:00
$request = $this -> getRequest ();
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur ();
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $params [ 'siret' ]);
2012-03-09 14:06:40 +00:00
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2012-05-20 16:31:28 +00:00
2014-06-18 13:29:09 +00:00
$siren = $request -> getParam ( 'siren' );
$this -> view -> assign ( 'siren' , $siren );
2012-05-20 16:31:28 +00:00
2014-06-18 13:29:09 +00:00
require_once 'Scores/WsScores.php' ;
$ws = new WsScores ();
$mode = $request -> getParam ( 'mode' );
switch ( $mode ) {
//Télécharger le fichier
case 'T' :
$c = Zend_Registry :: get ( 'config' );
$path = $c -> profil -> path -> files . '/' ;
//Le fichier est déjà présent sur le serveur
if ( file_exists ( $path . 'kbis-' . $siren . '.pdf' )
&& date ( 'Ymd' , filemtime ( $path . 'kbis-' . $siren . '.pdf' )) == date ( 'Ymd' )
&& filesize ( $path . 'kbis-' . $siren . '.pdf' ) > 2000 ) {
$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 );
$this -> view -> assign ( 'mode' , $mode );
$ws -> setLog ( 'kbis' , $siren , 0 , 'direct' );
}
//Téléchargement du fichier
else {
$info = $ws -> getKbis ( $siren , 'T' );
if ( substr ( $info , 0 , 7 ) == 'http://' ) {
//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
try {
$client = new Zend_Http_Client ( $info );
$client -> setStream ();
$response = $client -> request ( 'GET' );
//Ecriture du fichier sur le serveur en local
if ( $response -> isSuccessful () && copy ( $response -> getStreamName (), $path . 'kbis-' . $siren . '.pdf' ) ) {
$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 );
$this -> view -> assign ( 'mode' , $mode );
}
//Fichier non disponible
else {
$this -> view -> assign ( 'msg' , " Impossible de récupérer le fichier " );
}
} catch ( Zend_Http_Client_Exception $e ) {
//echo " - Erreur ".$e->getMessage();
}
} else {
$this -> view -> assign ( 'msg' , $info );
}
}
break ;
//Commande par email
case 'M' :
$ref = $request -> getParam ( 'ref' );
if ( $request -> isXmlHttpRequest () ) {
//Enregistrement de la commande
if ( $request -> isPost () ) {
$response = $ws -> getKbis ( $siren , $mode , $ref );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
} else {
$this -> view -> assign ( 'formEmail' , true );
$this -> view -> assign ( 'refCommande' , $response );
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . strtoupper ( $response ) . " . " );
//== Send email to operators - to be removed
$email = explode ( ';' , $user -> getEmail ());
$session = new Scores_Session_Entreprise ();
//Envoi de l'email
$mail = new Scores_Mail ();
$mail -> setFrom ( 'contact' );
$mail -> addToKey ( 'support' );
$mail -> setSubject ( '[COMMANDE PIECES] - KBIS par email' );
$mail -> setBodyTexte (
'COMMANDE DE PIECES - Demande de kbis par email' . PHP_EOL .
'Demande pour recevoir le KBIS de SIREN :' .
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret )) . '">' .
$this -> siret . '</a>' . PHP_EOL .
'pour login ' . $user -> getLogin () . '(' . $email . ')<br/>' . PHP_EOL .
'Référence Client : ' . $ref . PHP_EOL .
'Référence Backoffice : ' . strtoupper ( $response )
);
$mail -> send ();
//Enregistrement dans la bdd
$commandesKbis = new Application_Model_CommandesKbis ();
$data = array (
'idUser' => $user -> getId (),
'login' => $user -> getLogin (),
'email' => $email ,
'societe' => '' ,
'nom' => '' ,
'adresse' => '' ,
'cp' => '' ,
'ville' => '' ,
'siren' => $siren ,
'raisonSociale' => $session -> getRaisonSociale (),
'type' => 'M' ,
'dateCommande' => date ( 'Y-m-d H:i:s' ),
);
$commandesKbis -> insert ( $data );
//== Send email to operators - to be removed
}
}
//Affichage du formulaire
else {
$email = explode ( ';' , $user -> getEmail ());
$this -> view -> assign ( 'email' , $email [ 0 ]);
$validator = new Zend_Validate_EmailAddress ();
$this -> view -> assign ( 'emailValid' , $validator -> isValid ( $email [ 0 ]));
$this -> view -> assign ( 'formCmd' , true );
$this -> view -> assign ( 'mode' , $mode );
$this -> view -> assign ( 'siren' , $siren );
}
}
break ;
//Commande KBIS original courrier
case 'C' :
$ref = $request -> getParam ( 'ref' );
if ( $request -> isXmlHttpRequest () ) {
//Enregistrement de la commande
if ( $request -> isPost () ) {
//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 ) {
$response = $ws -> getKbis ( $siren , $mode , $ref );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Erreur lors du passage de la commande. " );
} else {
$this -> view -> assign ( 'refCommande' , $response );
$this -> view -> assign ( 'msg' , " Enregistrement de votre commande sous la référence " . strtoupper ( $response ) . " . " );
//== Send email to operators - to be removed
$email = explode ( ';' , $user -> getEmail ());
$session = new Scores_Session_Entreprise ();
//Envoi du mail
$mail = new Scores_Mail ();
$mail -> setFrom ( 'contact' );
$mail -> addToKey ( 'support' );
$mail -> setSubject ( '[COMMANDE PIECES] - KBIS par courrier' );
$mail -> setBodyTexte (
'COMMANDE DE PIECES - Demande de kbis par courrier' . 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/>' . PHP_EOL .
'pour login ' . $user -> getLogin () .
'(' . $email . ')' . '<br/>' . PHP_EOL .
'Référence Client : ' . $ref . PHP_EOL .
'Référence Backoffice : ' . strtoupper ( $response ) . PHP_EOL .
'Societe :' . $params [ 'societe' ] . '<br/>' . PHP_EOL .
'Nom : ' . $params [ 'nom' ] . '<br/>' . PHP_EOL .
'Prenom : ' . $params [ 'prenom' ] . '<br/>' . PHP_EOL .
'Adresse : ' . $params [ 'adresse' ] . '<br/>' . PHP_EOL .
'CP : ' . $params [ 'cp' ] . '<br/>' . PHP_EOL .
'Ville : ' . $params [ 'ville' ]
);
$mail -> send ();
//Enregistrement dans la bdd
$commandesKbis = new Application_Model_CommandesKbis ();
$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' ],
'siren' => $siren ,
'raisonSociale' => $session -> getRaisonSociale (),
'type' => 'C' ,
'dateCommande' => date ( 'Y-m-d H:i:s' ),
);
$commandesKbis -> insert ( $data );
//== Send email to operators - to be removed
}
} else {
$this -> view -> assign ( 'message' , '<font color="red">' . $this -> view -> translate ( 'Erreur : Tous les champs doivent être renseigner.' ) . '</font>' );
$this -> view -> assign ( 'mode' , $mode );
$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' ]);
}
}
//Affichage du formulaire
else {
$email = explode ( ';' , $user -> getEmail ());
$this -> view -> assign ( 'email' , $email [ 0 ]);
$this -> view -> assign ( 'nom' , $user -> getNom ());
$this -> view -> assign ( 'prenom' , $user -> getPrenom ());
$validator = new Zend_Validate_EmailAddress ();
$this -> view -> assign ( 'emailValid' , $validator -> isValid ( $email [ 0 ]));
$this -> view -> assign ( 'formCmd' , true );
$this -> view -> assign ( 'mode' , $mode );
}
}
break ;
//Saisir email différent
case 'EMAIL' :
if ( $request -> isXmlHttpRequest () ) {
if ( $request -> isPost () ) {
$id = $request -> getParam ( 'refCommande' );
$email = trim ( $request -> getParam ( 'email' ));
if ( ! empty ( $email ) ) {
$response = $ws -> setPiecesKbisCmdEmail ( $id , $email );
if ( $response === false ) {
$this -> view -> assign ( 'msg' , " Impossible d'enregistrer un email pour la commande " . strtoupper ( $id ) . " . " );
} else {
$this -> view -> assign ( 'msg' , " Email " . $email . " enregistré pour la commande " . strtoupper ( $id ) . " . " );
}
} else {
$this -> view -> assign ( 'msg' , " Email incorrect. " );
}
}
}
break ;
2011-08-08 19:03:26 +00:00
}
2014-06-18 13:29:09 +00:00
2011-06-30 14:37:50 +00:00
}
2012-05-20 16:31:28 +00:00
2012-10-26 14:48:51 +00:00
/**
* Affiche les privilèges en surveillance
*/
public function privilegesAction ()
{
$request = $this -> getRequest ();
$type = $request -> getParam ( 'type' , null );
$siren = substr ( $this -> siret , 0 , 9 );
$detail = false ;
if ( ! empty ( $type )){
$detail = true ;
}
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2012-10-26 14:48:51 +00:00
$ws = new WsScores ();
if ( $detail ){
$infos = $ws -> getPrivilegesDetail ( $siren , array ( $type ));
$this -> view -> assign ( 'detail' , $detail );
} else {
$infos = $ws -> getPrivilegesCumul ( $siren );
}
Zend_Registry :: get ( 'firebug' ) -> info ( $infos );
$this -> view -> assign ( 'privileges' , $infos -> result -> item );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
2013-01-23 12:55:12 +00:00
2012-10-26 14:48:51 +00:00
$user = new Scores_Utilisateur ();
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survpriv' ));
}
2011-04-19 07:37:39 +00:00
}