extranet/application/controllers/EvaluationController.php
2011-06-07 12:20:47 +00:00

230 lines
9.8 KiB
PHP

<?php
class EvaluationController extends Zend_Controller_Action
{
protected $siret = null;
protected $id = 0;
public function init()
{
$request = $this->getRequest();
$this->siret = $request->getParam('siret');
$this->id = $request->getParam('id', 0);
require_once 'common/dates.php';
require_once 'Scores/WsScores.php';
require_once 'Scores/Utilisateur.php';
require_once 'Scores/SessionEntreprise.php';
$this->view->headLink()
->appendStylesheet('/themes/default/styles/evaluation.css', 'all');
}
public function indexAction(){}
public function printscoresAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$score = strtolower($request->getParam('score'));
$note = $request->getParam('note');
$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 ),
'indiscore' => array( 'min' => 0 , 'max' => 20 ),
);
$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']);
}
/**
* IndiScore
*/
public function indiscoreAction()
{
$request = $this->getRequest();
$ws = new WsScores();
$user = new Utilisateur();
$this->view->assign('siret', $request->getParam('siret'));
$this->view->assign('typeScore', $user->getTypeScore());
$this->view->assign('indiscore', $ws->getIndiScore(substr($this->siret, 0,9)));
}
public function procedurejuridiqueAction()
{
$indiscore = Zend_Registry::get('indiscore');
print_r($indiscore);
}
/**
* Rapport de synthese
*/
public function indiscore2Action()
{
$request = $this->getRequest();
$ws = new WsScores();
$entreprise = new SessionEntreprise($request->getParam('siret'));
$indiscore = $ws->getIndiScore(substr($this->siret, 0, 9));
$score = array();
$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'),
);
$dateRadiation = '';
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');
}
$score['Indiscore'] = array($indiscore->Indiscore20, 'IndiScore');
$identite->DateCreaEt = WDate::dateT('Y-m-d', 'd/m/Y', $identite->DateCreaEt);
$identite->DateCreaEn = WDate::dateT('Y-m-d', 'd/m/Y', $identite->DateCreaEn);
$identite->DateImmat = WDate::dateT('Y-m-d', 'd/m/Y', $identite->DateImmat);
$identite->Bilan->Cloture = WDate::dateT('Ymd', 'd/m/Y', $identite->Bilan->Cloture);
$this->view->assign('siren', $entreprise->getSiren());
$this->view->assign('encours', $indiscore->encours);
$this->view->assign('identite', $identite);
$this->view->assign('scores', $score);
$this->view->assign('SituationJuridique', $indiscore->SituationJuridique);
$this->view->assign('paiement', $indiscore->infoPaiement);
$this->view->assign('bilanReference', $bilanReference);
$this->view->assign('siret', $request->getParam('siret'));
$this->view->assign('id', $request->getParam('id'));
}
/**
* Rapport complet
*/
public function indiscore3Action()
{
$request = $this->getRequest();
$sessionEntreprise = new SessionEntreprise($request->getParam('siret'));
$ws = new WsScores();
$tabCommentaires = $ws->getIndiScore($sessionEntreprise->getSiren());
$this->view->assign('tabCommentaires', $tabCommentaires->tabCommentaires->item);
$this->view->assign('SessionEntreprise', $sessionEntreprise);
}
/**
* Enquete commerciale
*/
public function enquetecAction()
{
$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
if($InfoEnq['PrecisionsChoix'] = 1){
$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);
}
}