2011-04-19 07:37:39 +00:00
< ? php
class EvaluationController extends Zend_Controller_Action
{
2011-05-20 09:06:34 +00:00
protected $siret = null ;
protected $id = 0 ;
2011-04-19 07:37:39 +00:00
public function init ()
{
2011-05-20 09:06:34 +00:00
$request = $this -> getRequest ();
$this -> siret = $request -> getParam ( 'siret' );
$this -> id = $request -> getParam ( 'id' , 0 );
2011-06-03 08:52:01 +00:00
require_once 'common/dates.php' ;
2011-05-20 09:06:34 +00:00
require_once 'Scores/WsScores.php' ;
require_once 'Scores/Utilisateur.php' ;
require_once 'Scores/SessionEntreprise.php' ;
2011-06-07 15:01:03 +00:00
require_once 'Scores/IdentiteEntreprise.php' ;
2011-05-24 16:03:25 +00:00
$this -> view -> headLink ()
-> appendStylesheet ( '/themes/default/styles/evaluation.css' , 'all' );
2011-04-19 07:37:39 +00:00
}
2011-05-19 15:24:35 +00:00
public function indexAction (){}
2011-05-26 15:56:16 +00:00
public function printscoresAction ()
{
$this -> _helper -> layout () -> disableLayout ();
$request = $this -> getRequest ();
$score = strtolower ( $request -> getParam ( 'score' ));
2011-06-07 15:01:03 +00:00
if ( $score == 'indiscore' ){
$user = new Utilisateur ();
switch ( $user -> getTypeScore ()) {
case '20' : $score .= '20' ; break ;
case '100' :
default : $score .= '100' ; break ;
}
}
2011-05-26 15:56:16 +00:00
$note = $request -> getParam ( 'note' );
2011-06-07 15:01:03 +00:00
$bornes = array (
'conanh' => array ( 'min' => - 4.5 , 'max' => 16 ),
'afdcc2' => array ( 'min' => 0 , 'max' => 5 ),
'afdcc1' => array ( 'min' => - 10 , 'max' => 10 ),
'z' => array ( 'min' => - 3 , 'max' => 3 ),
'indiscore100' => array ( 'min' => 0 , 'max' => 100 ),
'indiscore20' => array ( 'min' => 0 , 'max' => 20 ),
2011-05-26 15:56:16 +00:00
);
$note = round (( $note - $bornes [ $score ][ 'min' ]) * 100 / ( $bornes [ $score ][ 'max' ] - $bornes [ $score ][ 'min' ]));
if ( $note < 0 ) $note = 0 ;
if ( $note > 100 ) $note = 100 ;
$this -> view -> assign ( 'note' , $note );
$this -> view -> assign ( 'min' , $bornes [ $score ][ 'min' ]);
$this -> view -> assign ( 'max' , $bornes [ $score ][ 'max' ]);
}
2011-05-19 15:24:35 +00:00
/**
* IndiScore
*/
2011-05-24 16:03:25 +00:00
public function indiscoreAction ()
{
$request = $this -> getRequest ();
$ws = new WsScores ();
$user = new Utilisateur ();
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'siret' , $this -> siret );
2011-05-24 16:03:25 +00:00
$this -> view -> assign ( 'typeScore' , $user -> getTypeScore ());
$this -> view -> assign ( 'indiscore' , $ws -> getIndiScore ( substr ( $this -> siret , 0 , 9 )));
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'AutrePage' , $request -> getParam ( 'page' ));
2011-05-24 16:03:25 +00:00
}
2011-04-19 07:37:39 +00:00
2011-05-26 15:56:16 +00:00
public function procedurejuridiqueAction ()
{
$indiscore = Zend_Registry :: get ( 'indiscore' );
print_r ( $indiscore );
}
2011-05-19 15:24:35 +00:00
/**
* Rapport de synthese
*/
2011-05-24 16:03:25 +00:00
public function indiscore2Action ()
{
2011-06-07 15:01:03 +00:00
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/finance.js' , 'text/javascript' );
$ws = new WsScores ();
$entreprise = new SessionEntreprise ( $this -> siret );
2011-06-07 16:15:53 +00:00
$identite = $ws -> getIdentite ( $this -> siret , $this -> id );
2011-05-26 15:56:16 +00:00
$indiscore = $ws -> getIndiScore ( substr ( $this -> siret , 0 , 9 ));
2011-06-07 16:15:53 +00:00
$user = new Utilisateur ();
2011-05-26 15:56:16 +00:00
$score = array ();
2011-06-07 15:01:03 +00:00
$bilanReference = array (
'r5' => array ( 'total' => 'r5' , 'total_info' => '% ca' , 'op' => 1000 , 'titre' => 'CHIFFRE D\'AFFAIRES' ),
'r16' => array ( 'total' => 'r5' , 'total_info' => '% ca' , 'op' => 1000 , 'titre' => 'RESULTAT D\'EXPLOITATION' ),
'r7' => array ( 'total' => 'r5' , 'total_info' => '% ca' , 'op' => 1000 , 'titre' => 'RESULTAT COURANT' ),
'r10' => array ( 'total' => 'r5' , 'total_info' => '% ca' , 'op' => 1000 , 'titre' => 'RESULTAT NET' ),
'r18' => array ( 'total' => 'r22' , 'total_info' => '% bilan' , 'op' => 1000 , 'titre' => 'FONDS PROPRES' ),
'r231' => array ( 'total' => 'r22' , 'total_info' => '% bilan' , 'op' => 1000 , 'titre' => 'FONDS DE ROULEMENT' ),
'r232' => array ( 'total' => 'r22' , 'total_info' => '% bilan' , 'op' => 1000 , 'titre' => 'BESOIN EN FONDS DE ROULEMENT' ),
'r249' => array ( 'total' => '' , 'total_info' => '' , 'op' => 1000 , 'titre' => 'TRESORERIE NETTE' ),
'r20' => array ( 'total' => 'r5' , 'total_info' => '% ca' , 'op' => 1000 , 'titre' => 'FRAIS FINANCIER' ),
2011-05-26 15:56:16 +00:00
);
2011-06-07 15:01:03 +00:00
2011-06-07 16:15:53 +00:00
/*
Correctiojn pour indiscore seule
$indiscore -> Siege ;
$indiscore -> SiretSiege ;
$indiscore -> NumRC ;
*/
$identite = new IdentiteEntreprise ( $identite , $this -> view );
2011-06-07 15:01:03 +00:00
//Définition des blocks
$blocks = array (
'SiretSiege' ,
'NumRC' ,
'Actif' ,
'RaisonSociale' ,
'FormeJuridique' ,
'DateImmat' ,
'DateCreaEt' ,
'Adresse' ,
'ActiviteEn' ,
'Naf4' ,
'OrigineFond' ,
'TypeExploitation' ,
'Saisonnalite' ,
'Capital' ,
'ChiffreAffaire' ,
);
$dBlock = array ();
foreach ( $blocks as $item ) {
$display = array (
'label' => method_exists ( $identite , 'get' . $item . 'Label' ) ? $identite -> { 'get' . $item . 'Label' }() : '' ,
'texte' => method_exists ( $identite , 'get' . $item . 'Texte' ) ? $identite -> { 'get' . $item . 'Texte' }() : '' ,
'titre' => method_exists ( $identite , 'get' . $item . 'Titre' ) ? $identite -> { 'get' . $item . 'Titre' }() : '' ,
);
$dBlock [ $item ] = $display ;
}
$this -> view -> assign ( 'dBlock' , $dBlock );
$dateRadiation = '' ;
2011-05-26 15:56:16 +00:00
if ( isset ( $indiscore -> DateRadiation ) && $indiscore -> DateRadiation != '' && $indiscore -> DateRadiation != '0000-00-00' )
$this -> view -> assign ( 'dateRadiation' , WDate :: dateT ( 'Ymd' , 'd/m/Y' , str_replace ( '-' , '' , $indiscore -> DateRadiation )));
foreach ( $indiscore -> scores as $name => $sc ){
if ( $name == 'ConanH' )
$score [ $name ] = array ( $sc , 'Score Conan Holder' );
if ( $name == 'Afdcc2' )
$score [ $name ] = array ( $sc , 'Score Afdcc 2' );
if ( $name == 'Z' )
$score [ $name ] = array ( $sc , 'Score Z' );
}
2011-06-07 15:01:03 +00:00
$typeScore = $user -> getTypeScore ();
switch ( $typeScore ) {
case '20' :
$maxIndiscore = $typeScore ;
$score [ 'Indiscore' ] = array ( $indiscore -> Indiscore20 , 'IndiScore' );
break ;
case '100' :
default :
$maxIndiscore = empty ( $typeScore ) ? '100' : $typeScore ;
$score [ 'Indiscore' ] = array ( $indiscore -> Indiscore , 'IndiScore' );
break ;
}
2011-05-26 15:56:16 +00:00
$score [ 'Indiscore' ] = array ( $indiscore -> Indiscore20 , 'IndiScore' );
2011-06-03 08:52:01 +00:00
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'id' , $this -> id );
2011-06-03 08:52:01 +00:00
$this -> view -> assign ( 'siren' , $entreprise -> getSiren ());
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'encours' , $indiscore -> encours );
$this -> view -> assign ( 'TendanceIndiscore' , $indiscore -> TendanceIndiscore );
$this -> view -> assign ( 'SituationJuridique' , $indiscore -> SituationJuridique );
2011-05-26 15:56:16 +00:00
$this -> view -> assign ( 'paiement' , $indiscore -> infoPaiement );
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'scores' , $score );
2011-05-26 15:56:16 +00:00
$this -> view -> assign ( 'bilanReference' , $bilanReference );
2011-05-24 16:03:25 +00:00
}
2011-05-18 10:07:45 +00:00
2011-05-19 15:24:35 +00:00
/**
* Rapport complet
*/
2011-06-03 08:52:01 +00:00
public function indiscore3Action ()
{
$request = $this -> getRequest ();
2011-06-07 15:01:03 +00:00
$sessionEntreprise = new SessionEntreprise ( $this -> siret , $this -> id );
2011-06-03 08:52:01 +00:00
$ws = new WsScores ();
2011-06-07 16:15:53 +00:00
//getRapport à la place de getIndiscore
2011-06-03 08:52:01 +00:00
$tabCommentaires = $ws -> getIndiScore ( $sessionEntreprise -> getSiren ());
2011-06-07 15:01:03 +00:00
$this -> view -> assign ( 'siret' , $this -> siret );
$this -> view -> assign ( 'id' , $this -> id );
$this -> view -> assign ( 'siren' , $sessionEntreprise -> getSiren ());
$this -> view -> assign ( 'raisonSociale' , $sessionEntreprise -> getRaisonSociale ());
2011-06-07 16:15:53 +00:00
//$tabProjection = $etab['tabVariables'];
2011-06-03 08:52:01 +00:00
$this -> view -> assign ( 'tabCommentaires' , $tabCommentaires -> tabCommentaires -> item );
}
2011-05-19 15:24:35 +00:00
/**
* Enquete commerciale
*/
public function enquetecAction ()
{
2011-05-20 09:06:34 +00:00
$this -> view -> headScript () -> appendFile ( '/themes/default/scripts/enquetec.js' , 'text/javascript' );
//isset($_REQUEST['pays']) ? $pays=$_REQUEST['pays'] : $pays='' ;
$commandeEnquete = false ;
$request = $this -> getRequest ();
if ( $request -> isPost ()){
$InfoUser = $request -> getParam ( 'InfoUser' );
$InfoEnq = $request -> getParam ( 'InfoEnq' );
//Affichage de la demande
//Vérification des informations
$formError = false ;
$fields = array ();
//Info utilisateur obligatoire :
if ( $InfoUser [ 'Identite' ] == '' ){ $fields [] = 'Votre Identite' ; $formError = true ;}
if ( $InfoUser [ 'Tel' ] == '' ){ $fields [] = 'Votre Téléphone' ; $formError = true ;}
if ( $InfoUser [ 'Email' ] == '' ){ $fields [] = 'Votre Email' ; $formError = true ;}
//Info entreprise obligatoire :
if ( isset ( $InfoEnq [ 'Type' ]) && $InfoEnq [ 'Type' ] == '' ){ $fields [] = 'Choix du type d\'enquête' ; $formError = true ;}
if ( $InfoEnq [ 'PrecisionsChoix' ] == '1' ){
if ( $InfoEnq [ 'Precisions' ][ 'Motif' ] == '' ){ $fields [] = 'Mofif de la demande' ; $formError = true ;}
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == '3' || $InfoEnq [ 'PrecisionsChoix' ] == '4' ){
if ( $InfoEnq [ 'Precisions' ][ 'MontantCA' ] == '' ){ $fields [] = 'Précisions de la demande' ; $formError = true ;}
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == '5' ){
if ( $InfoEnq [ 'Precisions' ][ 'Autre' ] == '' ){ $fields [] = 'Précisions de la demande' ; $formError = true ;}
}
if ( isset ( $InfoEnq [ 'ImpayeesChoix' ]) && $InfoEnq [ 'ImpayeesChoix' ] == 'oui' ){
if ( $InfoEnq [ 'Impayees' ][ 'Montant' ] == '' || $InfoEnq [ 'Impayees' ][ 'Nombre' ] == '' || $InfoEnq [ 'Impayees' ][ 'Date' ] == '' ){ $fields [] = 'Précisions sur les impayées' ; $formError = true ;}
}
if ( isset ( $InfoEnq [ 'RetardPaiementChoix' ]) && $InfoEnq [ 'RetardPaiementChoix' ] == 'oui' ){
if ( $InfoEnq [ 'RetardPaiement' ][ 'Montant' ] == '' || $InfoEnq [ 'Nombre' ] == '' || $InfoEnq [ 'RetardPaiement' ][ 'Date' ] == '' ){ $fields [] = 'Précisions sur le retarde de paiement' ; $formError = true ;}
}
if ( isset ( $_REQUEST [ 'InfoEnq' ][ 'LitigeChoix' ]) && $_REQUEST [ 'InfoEnq' ][ 'LitigeChoix' ] == 'oui' ){
if ( $_REQUEST [ 'InfoEnq' ][ 'Litige' ][ 'Precisions' ] == '' || $_REQUEST [ 'InfoEnq' ][ 'Litige' ][ 'Precisions' ] == '' ){ $fields [] = 'Précisions sur le litige' ; $formError = TRUE ;}
}
if ( $formError == true ){
$message = '<font color="red">' ;
$message .= 'Veuillez remplir les champs suivants : ' ;
$message .= join ( ', ' , $fields );
$message .= '</font>' ;
} else {
$InfoDemande = $InfoUser ;
$siren = $InfoEnq [ 'Siren' ];
unset ( $InfoEnq [ 'Siren' ]);
//Suppression et assigation des valeurs pour le webservice
2011-06-03 08:52:01 +00:00
if ( $InfoEnq [ 'PrecisionsChoix' ] = 1 ){
2011-05-20 09:06:34 +00:00
$InfoEnq [ 'Precisions' ][ 'Type' ] = " Enquête sur un client (contrôle crédit) " ;
unset ( $InfoEnq [ 'PrecisionsChoix' ]);
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == 2 ){
$InfoEnq [ 'Precisions' ][ 'Type' ] = " Enquête sur un prospect (ouverture de compte) " ;
unset ( $InfoEnq [ 'PrecisionsChoix' ]);
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == 3 ){
$InfoEnq [ 'Precisions' ][ 'Type' ] = " Enquête sur un fournisseur stratégique " ;
unset ( $InfoEnq [ 'PrecisionsChoix' ]);
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == 4 ){
$InfoEnq [ 'Precisions' ][ 'Type' ] = " Enquête sur un fournisseur non stratégique " ;
unset ( $InfoEnq [ 'PrecisionsChoix' ]);
} elseif ( $InfoEnq [ 'PrecisionsChoix' ] == 5 ){
$InfoEnq [ 'Precisions' ][ 'Type' ] = " Autre type d'enquête (Précisez...) " ;
unset ( $InfoEnq [ 'PrecisionsChoix' ]);
}
/*
$ws = new WsScore ();
$result = $ws -> commandeEnquete ( $siren , $InfoEnq , $InfoDemande );
$commandeEnquete = TRUE ;
*/
}
$this -> view -> assign ( 'formError' , $formError );
$this -> view -> assign ( 'message' , $message );
$this -> view -> assign ( 'InfoUser' , $InfoUser );
$this -> view -> assign ( 'InfoEnq' , $InfoEnq );
}
if ( $commandeEnquete == false ) {
$ws = new WsScores ();
$infosEntrep = $ws -> getIdentite ( $this -> siret , $this -> id );
$this -> view -> assign ( 'Etab' , $infosEntrep );
$user = new Utilisateur ();
$this -> view -> assign ( 'user' , $user );
}
$this -> view -> assign ( 'commandeEnquete' , $commandeEnquete );
2011-05-19 15:24:35 +00:00
}
2011-04-19 07:37:39 +00:00
}