2011-04-19 07:37:39 +00:00
< ? php
class PiecesController extends Zend_Controller_Action
{
2015-07-08 13:48:28 +00:00
protected $theme ;
2015-07-08 20:38:22 +00:00
2015-07-08 13:48:28 +00:00
protected $association_cj = array (
2011-05-11 13:38:14 +00:00
'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 ()
{
2015-07-08 20:38:22 +00:00
// --- Theme
$this -> theme = Zend_Registry :: get ( 'theme' );
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
{
2015-04-03 12:57:04 +00:00
$this -> _helper -> layout () -> disableLayout ();
2015-06-10 15:06:21 +00:00
2011-06-29 15:48:05 +00:00
$request = $this -> getRequest ();
2012-05-20 16:31:28 +00:00
2015-04-03 12:57:04 +00:00
if ( $request -> isPost ()) {
$siren = $request -> getParam ( 'siren' );
$ws = new Scores_Ws_Client ( 'pieces' , '0.1' );
$parameters = new stdClass ();
$parameters -> companyId = $siren ;
$parameters -> type = 'siren' ;
$result = $ws -> setAssoStatut ( $parameters );
if ( $result === false ) {
$this -> view -> msg = " Erreur lors de l'enregistrement des informations " ;
} else {
$this -> view -> ref = strtoupper ( $result );
}
} else {
$user = new Scores_Utilisateur ();
$this -> view -> UserEmail = $user -> getEmail ();
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
$this -> view -> siren = substr ( $this -> siret , 0 , 9 );
$this -> view -> siret = $this -> siret ;
$this -> view -> id = $this -> id ;
$this -> view -> raisonSociale = $session -> getRaisonSociale ();
}
}
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
/**
* Commande de privilege
*/
public function privilegeAction ()
{
$this -> _helper -> layout () -> disableLayout ();
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$request = $this -> getRequest ();
$type = $request -> getParam ( 'type' );
$siren = $request -> getParam ( 'siren' );
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
if ( $request -> isPost ()) {
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
try {
$ws = new Scores_Ws_Client ( 'pieces' , '0.1' );
$parameters = new stdClass ();
$parameters -> companyId = $siren ;
$parameters -> doc = $type ;
$result = $ws -> setPrivileges ( $parameters );
if ( $result === false ) {
$this -> view -> msg = " Erreur lors de l'enregistrement des informations " ;
} else {
$this -> view -> ref = strtoupper ( $result );
}
} catch ( Zend_Db_Exception $e ) {
$this -> view -> msg = $e -> getMessage ();
}
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
} else {
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$this -> view -> type = $type ;
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$user = new Scores_Utilisateur ();
$this -> view -> UserEmail = $user -> getEmail ();
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
$this -> view -> siren = $siren ;
$this -> view -> raisonSociale = $session -> getRaisonSociale ();
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
}
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
{
2015-07-10 14:14:55 +00:00
$this -> view -> headScript () -> appendFile ( $this -> theme -> pathScript . '/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 ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
2014-02-13 14:41:39 +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. " ;
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 ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
2014-02-13 14:41:39 +00:00
$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 ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
2014-02-13 14:41:39 +00:00
$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
2015-07-10 14:14:55 +00:00
$this -> view -> headScript () -> appendFile ( $this -> theme -> pathScript . '/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' );
2014-08-28 14:12:47 +00:00
$infosBilan [ 'dateIso' ] = $date -> toString ( 'yyyy-MM-dd' );
2014-02-13 14:41:39 +00:00
$infosBilan [ 'type' ] = 'Comptes ' . $item -> Type . ' millésime ' . $item -> Millesime ;
2014-08-28 14:12:47 +00:00
$infosBilan [ 'typeCode' ] = $item -> Type ;
2014-02-13 14:41:39 +00:00
$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' ,
2014-06-20 14:55:54 +00:00
'siren' => $siren ,
2012-08-17 13:02:12 +00:00
'mode' => 'T' ,
2014-02-13 14:41:39 +00:00
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
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' ,
2014-06-20 14:55:54 +00:00
'siren' => $siren ,
2014-02-13 14:41:39 +00:00
'mode' => 'C' ,
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
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' ,
2014-06-20 14:55:54 +00:00
'siren' => $siren ,
2014-02-13 14:41:39 +00:00
'mode' => 'T' ,
'type' => $item -> Type ,
'cloture' => $item -> DateCloture ,
2014-08-11 12:11:23 +00:00
), 'default' , true );
2014-02-13 14:41:39 +00:00
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-08-28 14:12:47 +00:00
$infosBilan [ 'isEnter' ] = 0 ;
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
}
2014-08-28 14:12:47 +00:00
$infosBilan [ 'isEnter' ] = 1 ;
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
2014-08-28 14:12:47 +00:00
/**
* Commande de saisie d ' un bilan
* Boite de dialog
*/
public function bilanenterAction ()
{
$request = $this -> getRequest ();
if ( $request -> isXmlHttpRequest () ) {
$this -> _helper -> layout () -> disableLayout ();
}
$user = new Scores_Utilisateur ();
2015-04-03 12:57:04 +00:00
$this -> view -> assign ( 'isAuthorize' , $user -> checkPerm ( 'UPLOADBILAN' ));
2014-08-28 14:12:47 +00:00
$siren = $request -> getParam ( 'siren' );
$date = $request -> getParam ( 'date' );
$type = $request -> getParam ( 'type' );
if ( $request -> isPost () ) {
2015-06-10 15:06:21 +00:00
2015-04-03 12:57:04 +00:00
$ws = new Scores_Ws_Client ( 'order' , '0.1' );
$parameters = new stdClass ();
$parameters -> siren = $siren ;
$parameters -> date = $date ;
$parameters -> type = $type ;
$parameters -> source = 'infogreffe' ;
$parameters -> private = 0 ;
$result = $ws -> setBilanInput ( $parameters );
if ( $result === false ) {
$this -> view -> msg = " Erreur lors du passage de la commande " ;
2014-08-28 14:12:47 +00:00
} else {
2015-04-03 12:57:04 +00:00
$this -> view -> msg = " Commande enregistré sous la référence " . strtoupper ( $result );
2014-08-28 14:12:47 +00:00
}
} else {
2015-06-10 15:06:21 +00:00
2014-08-28 14:12:47 +00:00
$this -> view -> assign ( 'form' , 'display' );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'date' , $date );
if ( $type == 'sociaux' ) {
$type = 'N' ;
}
if ( $type == 'consolides' ) {
$type = 'C' ;
}
$this -> view -> assign ( 'type' , $type );
}
2015-06-10 15:06:21 +00:00
2014-08-28 14:12:47 +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 ();
2014-06-20 14:55:54 +00:00
$siren = $request -> getParam ( 'siren' );
2014-02-13 14:41:39 +00:00
$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' ;
2016-02-12 14:25:27 +00:00
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> shared . '/temp/files/' . $file )) {
2016-02-09 08:41:36 +00:00
$this -> view -> assign ( 'url' , $this -> view -> url ( array ( 'module' => 'file' ,
'controller' => 'greffe' , 'action' => 'bilan' , 'q' => $file ), 'default' , true ));
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 );
2014-06-20 08:00:43 +00:00
$date = new Zend_Date ( $dateCloture , 'yyyy-MM-dd' );
2014-02-13 14:41:39 +00:00
$this -> view -> assign ( 'LabelCloture' , $date -> toString ( 'dd/MM/yyyy' ));
2014-06-20 08:00:43 +00:00
$this -> view -> assign ( 'cloture' , $dateCloture );
2014-02-13 14:41:39 +00:00
$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' ;
2016-02-12 14:25:27 +00:00
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> shared . '/temp/files/' . $file )) {
2016-02-09 08:41:36 +00:00
$this -> view -> assign ( 'url' , $this -> view -> url ( array ( 'module' => 'file' ,
'controller' => 'greffe' , 'action' => 'acte' , 'q' => $file ), 'default' , true ));
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 ();
2015-07-10 14:14:55 +00:00
$this -> view -> headScript () -> appendFile ( $this -> theme -> pathScript . '/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
2015-06-10 15:06:21 +00:00
$mail = new Scores_Mail_Method ();
2015-06-11 15:29:14 +00:00
$mail -> setFromKey ( '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' );
2015-06-11 15:29:14 +00:00
$mail -> setBodyText (
2011-06-30 08:47:00 +00:00
'COMMANDE DE PRIVILEGES - par email<br/>' . EOL .
'Demande pour recevoir (' . $privilegesJ . ') pour SIREN : ' .
2014-08-11 12:11:23 +00:00
'<a href="' . $this -> view -> url ( array ( 'controller' => 'identite' , 'action' => 'fiche' , 'siret' => $this -> siret ), 'default' , true ) . '">' .
2011-06-30 08:47:00 +00:00
$this -> siret . '</a><br/>' . EOL .
'pour login ' . $user -> getLogin () . '(' . $email . ')<br/>' . EOL .
'Référence : ' . $ref
);
2015-06-11 15:29:14 +00:00
$mail -> execute ();
2011-06-30 08:47:00 +00:00
}
$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
/**
2015-04-01 13:34:43 +00:00
* Affichage status association
*/
2012-02-16 17:15:54 +00:00
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 );
2015-07-28 08:51:50 +00:00
// --- Liste des documents depuis le webservice
$ws = new Scores_Ws_Client ( 'pieces' , '0.1' );
$params = new stdClass ();
$params -> companyId = $siren ;
$result = $ws -> getAssoActes ( $params );
$actes = array ();
2015-07-28 13:24:59 +00:00
Zend_Registry :: get ( 'firebug' ) -> info ( $result );
2015-07-28 08:51:50 +00:00
if ( count ( $result -> item ) > 0 ) {
foreach ( $result -> item as $item ) {
2015-07-28 13:24:59 +00:00
Zend_Registry :: get ( 'firebug' ) -> info ( $item );
2015-07-28 08:51:50 +00:00
if ( $user -> checkPerm ( 'actes' ) ) {
$href = $this -> view -> url ( array ( 'controller' => 'pieces' , 'action' => 'associationacte' ,
2015-09-09 15:44:07 +00:00
'siren' => $siren , 'date' => $item -> Date ), 'default' , true );
2015-07-28 08:51:50 +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. " ;
}
$actes [] = array (
2015-07-28 13:24:59 +00:00
'date' => substr ( $item -> Date , 8 , 2 ) . '/' . substr ( $item -> Date , 5 , 2 ) . '/' . substr ( $item -> Date , 0 , 4 ),
2015-07-28 08:51:50 +00:00
'type' => 'Statut' ,
'href' => $href ,
'title' => $title ,
2015-07-28 13:24:59 +00:00
'file' => $item -> File ,
2015-07-28 08:51:50 +00:00
'decision' => '' ,
);
}
}
$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 ()
{
2015-07-28 08:51:50 +00:00
// --- Désactivation affichage
2012-02-17 10:43:43 +00:00
$this -> _helper -> layout () -> disableLayout ();
2012-05-20 16:31:28 +00:00
2012-02-17 10:43:43 +00:00
$request = $this -> getRequest ();
2015-09-09 15:44:07 +00:00
$siren = $request -> getParam ( 'siren' );
2015-07-28 08:51:50 +00:00
$date = $request -> getParam ( 'date' );
// --- Chemin du fichier
$ws = new Scores_Ws_Client ( 'pieces' , '0.1' );
$params = new stdClass ();
$params -> companyId = $siren ;
$params -> type = 'siren' ;
$params -> date = $date ;
$result = $ws -> getAssoActe ( $params );
if ( $result === false ) {
$this -> view -> assign ( 'msg' , " Erreur lors de la demande du fichier " );
} else {
// --- Récupération du fichier
if ( ! empty ( $result ) ) {
try {
$client = new Zend_Http_Client ( $result );
$client -> setStream ();
$stream = $client -> request ( 'GET' );
if ( $stream -> isSuccessful () && substr ( $stream -> getBody (), 0 , 4 ) == '%PDF' ) {
$c = Zend_Registry :: get ( 'config' );
$file = 'ST-' . $siren . '-' . $date . '.pdf' ;
2016-02-12 14:25:27 +00:00
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> shared . '/temp/files/' . $file )) {
2016-02-09 08:41:36 +00:00
$this -> view -> assign ( 'url' , $this -> view -> url ( array ( 'module' => 'file' , 'controller' => 'greffe' ,
'action' => 'association' , 'q' => $file ), 'default' , true ));
2015-07-28 08:51:50 +00:00
} 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. " );
}
} else {
$this -> view -> assign ( 'msg' , " Fichier indisponible ! " );
}
}
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 ) ) {
2015-07-28 08:51:50 +00:00
$href = $this -> view -> url ( array ( 'controller' => 'pieces' , 'action' => 'associationbilan' ,
'siren' => $siren , 'dateCloture' => $item -> DateCloture , 'reference' => $item -> File ),
'default' , true );
2012-08-17 13:02:12 +00:00
$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' ;
2016-02-12 14:25:27 +00:00
if ( copy ( $stream -> getStreamName (), $c -> profil -> path -> shared . '/temp/files/' . $file )) {
$this -> view -> assign ( 'url' , $this -> view -> url ( array ( 'module' => 'file' , 'controller' => 'fichier' ,
'action' => 'greffe' , 'q' => $file ), 'default' , true ));
2014-03-05 15:11:14 +00:00
} 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' );
2016-02-12 14:25:27 +00:00
$path = $c -> profil -> path -> shared . '/temp/files/' ;
2014-06-18 13:29:09 +00:00
//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 ) {
2016-02-09 08:41:36 +00:00
$msg = '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/file/greffe/kbis/q/kbis-' . $siren . '.pdf">Visualiser le Kbis <img src="/themes/default/images/interfaces/icone_pdf.gif"></a></u>' ;
2014-06-18 13:29:09 +00:00
$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' ) ) {
2016-02-09 08:41:36 +00:00
$msg = '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/file/greffe/kbis/q/kbis-' . $siren . '.pdf">Visualiser le Kbis <img src="/themes/default/images/interfaces/icone_pdf.gif"></a></u>' ;
2014-06-18 13:29:09 +00:00
$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 ) {
2015-06-10 15:06:21 +00:00
$this -> view -> assign ( 'msg' , " Impossible de récupérer le fichier " );
2014-06-18 13:29:09 +00:00
//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 ) . " . " );
}
}
//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 ) . " . " );
}
} 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
/**
2016-01-14 11:06:51 +00:00
* Affiche les privilèges
2012-10-26 14:48:51 +00:00
*/
public function privilegesAction ()
{
$request = $this -> getRequest ();
$siren = substr ( $this -> siret , 0 , 9 );
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
2016-01-14 11:06:51 +00:00
2012-10-26 14:48:51 +00:00
$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
2016-01-14 11:06:51 +00:00
$ws = new Scores_Ws_Client ( 'entreprise' , '0.9' );
$parameters = new stdClass ();
$parameters -> companyId = $siren ;
$result = $ws -> getPrivilegeList ( $parameters );
$this -> view -> assign ( 'PrivilegesNb' , $result -> NbTotal );
$this -> view -> assign ( 'PrivilegesMt' , $result -> MtTotal );
$this -> view -> assign ( 'PrivilegesCumul' , $result -> Cumul -> item );
$this -> view -> assign ( 'Privileges' , $result -> List -> item );
2012-10-26 14:48:51 +00:00
$user = new Scores_Utilisateur ();
$this -> view -> assign ( 'surveillance' , $user -> checkPerm ( 'survpriv' ));
}
2016-01-14 11:06:51 +00:00
/**
* Détail d ' un privilege
*/
public function privilegedetailAction ()
{
$request = $this -> getRequest ();
$id = $request -> getParam ( 'viewId' );
$siren = substr ( $this -> siret , 0 , 9 );
$session = new Scores_Session_Entreprise ( $this -> siret , $this -> id );
$this -> view -> assign ( 'siren' , $siren );
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'raisonSociale' , $session -> getRaisonSociale ());
$ws = new Scores_Ws_Client ( 'entreprise' , '0.9' );
$parameters = new stdClass ();
$parameters -> companyId = $siren ;
$parameters -> id = $id ;
$result = $ws -> getPrivilegeDetail ( $parameters );
$this -> view -> assign ( 'Privilege' , $result );
}
2011-04-19 07:37:39 +00:00
}