extranet/application/controllers/GiantController.php
2012-08-28 19:54:01 +00:00

224 lines
9.9 KiB
PHP

<?php
require_once 'Scores/RechercheHistorique.php';
require_once 'Giant/WSgiant.php';
require_once 'Giant/Controllers.lib.php';
require_once 'Giant/RequestDatabase.lib.php';
require_once 'Giant/Functions.lib.php';
require_once 'common/dates.php';
class GiantController extends Zend_Controller_Action
{
protected $TestIndication = true;
protected $TestCompanies = array(
'BE' => array(
'0439546194', '0436576412', '0430459076', '0430000604', '0404869783', '0404869783',
'0406952018'
),
'ES' => array(
'A00000000', 'A80192727'
),
'GB' => array(
'00000086', '00082932', '98888888', '214436', '1777777', '991581', '1800000'
),
'NL' => array(
'533885', '1383988', '1383989', '891962239', '891974008', '892130032', '896614719',
'896614735', '896614735', '896615243'
),
'FR' => array(
'55214450300018', '49496793800031', '47997411500012', '48765114300017',
'43235433000040', '39435613300022', '39504742600014', '76980020200020',
'35379698000020', '56202109700018', '70204756400068', '70204756400068'
),
);
public function init()
{
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
$this->view->headScript()->appendFile('/themes/default/scripts/giant.js', 'text/javascript');
$this->view->debug = false;
}
public function searchAction()
{
$user = new Scores_Utilisateur();
$params = $this->getRequest()->getParams();
$search = new GiantRechercheController($params['pays'], $this->TestIndication);
$result = $search->Liste($params, $this->getRequest()->getParam('page'));
$this->view->label = $search->getObjet()->getLabelDesc();
$this->view->labelResults = $search->getObjet()->getLabelResults();
$this->view->pays = $params['pays'];
$this->view->currentPage = $search->getObjet()->getCurrentPage();
$this->view->userMaxResult = $user->getNbRep();
$this->view->resultats = $result;
$this->view->page = $this->getRequest()->getParam('page');
$this->view->referer = $search->getObjet()->getQuery();
$this->view->lienReferer = $search->getQueryLink($params);
if($this->view->debug)
$this->view->soap = $search->soapG;
}
public function identiteAction()
{
$rechercheParams = new RechercheHistorique();
$giantFunction = new GiantFunction();
if (count($rechercheParams->liste()) > 0)
{
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
$Commande = new Commandes();
$user = new Scores_Utilisateur();
$listeCommandes = $Commande->getCommandesByLogin($user->getLogin());
$total = 0;
$liste = $giantFunction->divCommande($listeCommandes, $total);
$ListeRapport = new GiantRechercheController($params['pays'], $this->TestIndication);
$result = $ListeRapport->ListeRapport($this->getRequest()->getParam('CompanyId'));
$this->view->total = $total;
$this->view->listeCommandes = $liste;
$this->view->modification = (isset($result->MonitoringOptions))?($ListeRapport->getModification($result->MonitoringOptions->MonitoringOption[0])):null;
$this->view->description = $ListeRapport->getDescription();
$this->view->raisonSociale = $this->getRequest()->getParam('raisonSociale');
$this->view->listeRapport = $result;
$this->view->telephone = $this->getRequest()->getParam('telephone');
$this->view->CompanyId = $this->getRequest()->getParam('CompanyId');
$this->view->raisonSociale = $this->getRequest()->getParam('raisonSociale');
$this->view->CompanyRegisterNumber = $this->getRequest()->getParam('CompanyRegisterNumber');
$this->view->Pays = $this->getRequest()->getParam('Pays');
$this->view->Adresse = explode(':', $this->getRequest()->getParam('Adresse'));
if($this->view->debug)
$this->view->soap = $ListeRapport->soapG;
}
public function creditrecommendationAction()
{
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->TestIndication
);
$creditrecommendationAction = array('getAvisDeCredit' => 'CreditRecommendation');
$creditrecommendation = unserialize(base64_decode($id));
$identiteController = new GiantIdentiteController($creditrecommendation);
$giantConstroller = new GiantControllerLib($this->getRequest()->getParam('CompanyId').'-'.$this->getRequest()->getParam('Type'));
$identiteController->ficheAction();
$fiche = $identiteController->getObjet('fiche');
foreach($creditrecommendationAction as $action => $val) {
if(isset($creditrecommendation->DataSet->Company->$val)) {
$creditrecommendation = $giantConstroller->$action($creditrecommendation);
}
}
$fiche = $giantConstroller->getInformationGenerale($creditrecommendation);
$this->view->carte = $this->getRequest()->getParam('Pays');
$this->view->reportType = $this->getRequest()->getParam('Type');
$this->view->report = $fiche;
$this->view->Type = $this->getRequest()->getParam('Type');
$this->view->dateFunction = new WDate();
}
public function compactAction()
{
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->TestIndication
);
$compactAction = array('getAvisDeCredit' => 'CreditRecommendation', 'getPositionFinanciere' => 'FinancialSummary',
'getStructureEntreprise' => 'Associated', 'getDirigeant' => 'Position'
);
$compact = unserialize(base64_decode($id));
$identiteController = new GiantIdentiteController($compact);
$giantConstroller = new GiantControllerLib($this->getRequest()->getParam('CompanyId').'-'.$this->getRequest()->getParam('Type'));
$identiteController->ficheAction();
$fiche = $identiteController->getObjet('fiche');
foreach($compactAction as $action => $val) {
if(isset($compact->DataSet->Company->$val)) {
$compact = $giantConstroller->$action($compact);
}
}
$fiche = $giantConstroller->getInformationGenerale($compact);
$this->view->carte = $this->getRequest()->getParam('Pays');
$this->view->reportType = $this->getRequest()->getParam('Type');
$this->view->report = $fiche;
$this->view->Type = $this->getRequest()->getParam('Type');
$this->view->dateFunction = new WDate();
}
public function fullAction()
{
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId').'-'.$this->getRequest()->getParam('Type'));
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->TestIndication
);
$fullAction = array('getAvisDeCredit' => 'CreditRecommendation', 'getComptesAnnuels' => 'AnnualAccounts', 'getPositionFinanciere' => 'FinancialSummary',
'getComportementPaiement' => 'PaymentBehaviour', 'getStructureEntreprise' => 'Associated', 'getDirigeant' => 'Position',
'getComparaisonValeurs'=> 'PeerGroup', 'getHistoriques' => 'Event'
);
$full = unserialize(base64_decode($id));
$full->DataSet->Company->CompanyId= $this->getRequest()->getParam('CompanyId');
$identiteController = new GiantIdentiteController($full);
$giantConstroller = new GiantControllerLib($this->getRequest()->getParam('CompanyId').'-'.$this->getRequest()->getParam('Type'));
$identiteController->ficheAction();
$fiche = $identiteController->getObjet('fiche');
foreach($fullAction as $action => $val) {
if(isset($full->DataSet->Company->$val))
$full = $giantConstroller->$action($full);
}
$fiche = $giantConstroller->getInformationGenerale($full);
$this->view->carte = $this->getRequest()->getParam('Pays');
$this->view->reportType = $this->getRequest()->getParam('Type');
$this->view->report = $fiche;
$this->view->Type = $this->getRequest()->getParam('Type');
$this->view->dateFunction = new WDate();
}
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post')
->setAction('investigation');
$reference = $form->createElement('text', 'reference', array('label' => 'Votre Reference'));
$reference->setRequired(true);
$elements[] = $reference;
$telephone = $form->createElement('text', 'telephone', array('label' => 'Votre téléphone'));
$telephone->setRequired(true);
$elements[] = $telephone;
$mail = $form->createElement('text', 'mail', array('label' => 'Adresse Email'));
$mail->setRequired(true);
$elements[] = $mail;
$elements[] = $form->createElement('textarea', 'remarque', array('label' => 'Remarque ou commentaire à destination de l\'enquêteur :'));
$elements[] = $form->createElement('text', 'domiciliation', array('label' => 'Domiciliation Bancaire :'));
$elements[] = $form->createElement('text', 'Encours', array('label' => 'Encours demandé :'));
$elements[] = $form->createElement('text', 'nbEcheance', array('label' => 'Nombre d\'échéances :'));
$form->addElements($elements)
->addElement('submit', 'Envoyer', array('label' => 'Envoyer'));
return ($form);
}
public function investigationAction()
{
if($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost();
if($this->getForm()->isValid($data))
$this->view->form = $this->getRequest()->getParam('reference');
else {
return ($this->view->form = $this->getForm());
}
} else
$this->view->form = $this->getForm();
}
}