extranet/application/controllers/GiantController.php

438 lines
18 KiB
PHP
Raw Normal View History

2011-04-15 12:40:29 +00:00
<?php
2012-08-28 19:54:01 +00:00
require_once 'Giant/WSgiant.php';
require_once 'Giant/Controllers.lib.php';
require_once 'Giant/RequestDatabase.lib.php';
require_once 'Giant/Functions.lib.php';
2011-04-19 15:59:50 +00:00
2011-04-15 12:40:29 +00:00
class GiantController extends Zend_Controller_Action
{
2015-07-08 13:48:28 +00:00
protected $theme;
protected $TestIndication = false;
2013-09-23 08:47:30 +00:00
protected $config = array();
2013-06-14 16:00:22 +00:00
2012-08-28 19:54:01 +00:00
protected $TestCompanies = array(
2013-06-14 16:00:22 +00:00
'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'
),
2012-08-28 19:54:01 +00:00
);
2013-06-14 16:00:22 +00:00
2013-09-23 08:47:30 +00:00
protected $Companies = array(
'FR' =>'France',
'BE' => 'Belgium',
'ES' => 'Spain',
'GB' => 'United Kingdom',
'NL' => 'The Netherlands',
);
2011-04-19 15:59:50 +00:00
public function init()
{
2015-07-08 20:38:22 +00:00
// --- Theme
$this->theme = Zend_Registry::get('theme');
2013-11-29 13:54:52 +00:00
$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;
$this->config = new Zend_Config_Ini( APPLICATION_PATH.'/../library/Giant/giant.ini' );
2013-09-23 08:47:30 +00:00
$this->TestIndication = $this->config->test->TestIndication;
2011-04-15 12:40:29 +00:00
}
2011-04-19 15:59:50 +00:00
public function searchAction()
2011-08-26 14:02:45 +00:00
{
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur();
$params = $this->getRequest()->getParams();
$search = new GiantRechercheController($params['pays'], $this->TestIndication);
$result = $search->Liste($params, $this->getRequest()->getParam('page'));
2013-09-23 08:47:30 +00:00
$this->view->TestIndication= $this->TestIndication;
$this->view->TestCompanies = $this->TestCompanies[$params['pays']];
$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;
2011-04-19 15:59:50 +00:00
}
2011-06-27 16:34:26 +00:00
public function identiteAction()
2011-04-19 15:59:50 +00:00
{
2013-11-29 13:54:52 +00:00
$rechercheParams = new Scores_Session_Recherche();
$giantFunction = new GiantFunction();
2013-09-23 08:47:30 +00:00
$test = $this->getRequest()->getParam('test');
if($test == true){
$this->TestIndication = true;
}
2013-06-14 16:00:22 +00:00
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);
2013-09-16 15:41:31 +00:00
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$result = $giantController->commandePays($this->getRequest()->getParam('CompanyId'),$params['pays'], $this->TestIndication);
2013-09-23 08:47:30 +00:00
$this->view->TestIndication = $this->TestIndication;
2013-06-14 16:00:22 +00:00
$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;
2011-06-30 15:30:43 +00:00
}
public function creditrecommendationAction()
{
2013-09-23 08:47:30 +00:00
$test = $this->getRequest()->getParam('test');
if($test == true){
$this->TestIndication = true;
}
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
2013-06-14 16:00:22 +00:00
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->getRequest()->getParam('Language'),
$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');
2013-11-29 13:54:52 +00:00
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->assign('exportObjet', $creditrecommendation);
}
public function compactAction()
{
2013-09-23 08:47:30 +00:00
$test = $this->getRequest()->getParam('test');
if($test == true){
$this->TestIndication = true;
}
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
2013-06-14 16:00:22 +00:00
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->getRequest()->getParam('Language'),
$this->TestIndication
);
$compactAction = array('getAvisDeCredit' => 'CreditRecommendation', 'getPositionFinanciere' => 'FinancialSummary',
2013-06-14 16:00:22 +00:00
'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->assign('exportObjet', $compact);
}
public function fullAction()
{
2013-09-23 08:47:30 +00:00
$test = $this->getRequest()->getParam('test');
if($test == true){
$this->TestIndication = true;
}
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId').'-'.$this->getRequest()->getParam('Type'));
2012-05-20 16:31:28 +00:00
$id = $giantController->commande($this->getRequest()->getParam('CompanyId'),
2013-06-14 16:00:22 +00:00
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$this->getRequest()->getParam('Language'),
$this->TestIndication
);
$fullAction = array('getAvisDeCredit' => 'CreditRecommendation', 'getComptesAnnuels' => 'AnnualAccounts', 'getPositionFinanciere' => 'FinancialSummary',
2013-06-14 16:00:22 +00:00
'getComportementPaiement' => 'PaymentBehaviour', 'getStructureEntreprise' => 'Associated', 'getDirigeant' => 'Position',
'getComparaisonValeurs'=> 'PeerGroup', 'getHistoriques' => 'Event'
);
$full = unserialize(base64_decode($id));
2011-10-13 07:06:08 +00:00
$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->assign('exportObjet', $full);
2011-04-19 15:59:50 +00:00
}
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post')
2013-06-14 16:00:22 +00:00
->setAction('investigation');
$reference = $form->createElement('text', 'reference', array('label' => 'Votre Reference'));
$reference->setRequired(true);
$elements[] = $reference;
2012-05-20 16:31:28 +00:00
$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()
{
2012-05-20 16:31:28 +00:00
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();
}
2013-06-14 16:00:22 +00:00
public function startmonitoringAction()
{
$this->_helper->layout()->disableLayout();
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
2013-09-16 15:41:31 +00:00
$this->view->headScript()->appendFile('/themes/default/scripts/giant.js', 'text/javascript');
2013-06-14 16:00:22 +00:00
$this->view->lang = $this->getRequest()->getParam('lang');
$this->view->CompanyId = $this->getRequest()->getParam('CompanyId');
$this->view->Pays = $this->getRequest()->getParam('Pays');
2013-06-20 15:15:39 +00:00
$this->view->CompanyName = $this->getRequest()->getParam('CompanyName');
$this->view->action = $this->getRequest()->getParam('action');
2013-06-14 16:00:22 +00:00
$this->view->values = $this->getRequest()->getParams();
2013-09-23 08:47:30 +00:00
$result = new GiantControllerLib();
foreach($this->Companies as $key=>$pays){
if(($value = $result->getCache($key)) === false || empty($value->MonitoringOptions->MonitoringOption[0]->LanguageCodes->LanguageCode)) {
unset($this->Companies[$key]);
}
}
$this->view->countries = $this->Companies;
2013-06-14 16:00:22 +00:00
if ($this->getRequest()->isPost()) {
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
2013-06-20 15:15:39 +00:00
$result = $giantController->startmonitoring($this->getRequest()->getParam('CompanyId'),
2013-06-14 16:00:22 +00:00
$this->getRequest()->getParam('CategoryName'),
$this->getRequest()->getParam('EventType'),
$this->getRequest()->getParam('StartDate'),
$this->getRequest()->getParam('EndDate'),
$this->getRequest()->getParam('Version'),
$this->getRequest()->getParam('LanguageCode'),
2013-06-20 15:15:39 +00:00
$this->getRequest()->getParam('Pays'),
2013-07-30 08:24:34 +00:00
$this->TestIndication,
$this->getRequest()->getParam('CompanyName')
2013-06-20 15:15:39 +00:00
);
$this->view->result = $result;
}
}
public function stopmonitoringAction()
{
$this->_helper->layout()->disableLayout();
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
$this->view->CompanyId = $this->getRequest()->getParam('CompanyId');
2013-09-16 15:41:31 +00:00
$this->view->InternalOrderId = $this->getRequest()->getParam('InternalOrderId');
2013-06-20 15:15:39 +00:00
$this->view->Pays = $this->getRequest()->getParam('Pays');
$this->view->InternalOrderId = $this->getRequest()->getParam('InternalOrderId');
$this->view->CompanyName = $this->getRequest()->getParam('CompanyName');
$this->view->action = $this->getRequest()->getParam('action');
$this->view->values = $this->getRequest()->getParams();
if ($this->getRequest()->isPost()) {
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$result = $giantController->stopmonitoring($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('EndDate'),
$this->getRequest()->getParam('InternalOrderId'),
$this->getRequest()->getParam('Pays'),
$this->TestIndication
);
$this->view->result = $result;
}
}
public function updatemonitoringAction()
{
$this->_helper->layout()->disableLayout();
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
$this->view->lang = $this->getRequest()->getParam('lang');
$this->view->CompanyId = $this->getRequest()->getParam('CompanyId');
2013-09-16 15:41:31 +00:00
$this->view->InternalOrderId = $this->getRequest()->getParam('InternalOrderId');
2013-06-20 15:15:39 +00:00
$this->view->Pays = $this->getRequest()->getParam('Pays');
$this->view->CompanyName = $this->getRequest()->getParam('CompanyName');
$this->view->action = $this->getRequest()->getParam('action');
$this->view->values = $this->getRequest()->getParams();
if ($this->getRequest()->isPost()) {
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$result = $giantController->updatemonitoring($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('InternalOrderId'),
$this->getRequest()->getParam('CategoryName'),
$this->getRequest()->getParam('EventType'),
$this->getRequest()->getParam('StartDate'),
$this->getRequest()->getParam('Version'),
$this->getRequest()->getParam('LanguageCode'),
$this->getRequest()->getParam('Pays'),
$this->TestIndication
2013-06-14 16:00:22 +00:00
);
$this->view->result = $result;
}
2013-06-20 15:15:39 +00:00
2013-06-14 16:00:22 +00:00
}
2013-08-20 13:48:53 +00:00
public function retriveAction()
{
$this->view->headScript()->appendFile('/themes/default/scripts/giant_monitoring.js', 'text/javascript');
$giantController = new GiantControllerLib();
2013-09-16 15:41:31 +00:00
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$identity = $auth->getIdentity();
}
$result = $auth->getStorage()->read($identity);
if(!empty($result->result->mon_result)){
$result = $result->result->mon_result;
}
else{
$result = $giantController->retrive(1,$this->TestIndication,'RetrieveMonitoringEventsForCustomer');
$sess = new stdClass();
$sess->mon_result = $result;
$identity->result = $sess;
$auth->getStorage()->write($identity);
}
$resultDB = $giantController->retrivDB();
$this->view->resultDB = $resultDB;
2013-08-20 13:48:53 +00:00
$this->view->result = $result;
$merged =Array();
foreach ($result->MonitoringEvents->MonitoringEvent as $MonitoringEvent):
if ($merged[$MonitoringEvent->ProviderOrderId]){
array_push($merged[$MonitoringEvent->ProviderOrderId],$MonitoringEvent) ;
} else {
$merged[$MonitoringEvent->ProviderOrderId][]=$MonitoringEvent;
}
endforeach;
$this->view->val = $merged;
2013-09-16 15:41:31 +00:00
2013-08-20 13:48:53 +00:00
$merged_siren =Array();
foreach ($result->MonitoringEvents->MonitoringEvent as $MonitoringEvent):
if ($merged_siren[$MonitoringEvent->Company->CompanyId]){
array_push($merged_siren[$MonitoringEvent->Company->CompanyId],$MonitoringEvent) ;
} else {
$merged_siren[$MonitoringEvent->Company->CompanyId][]=$MonitoringEvent;
}
endforeach;
$this->view->val_siren = $merged_siren;
2013-09-16 15:41:31 +00:00
}
public function retAction()
{
$giantController = new GiantControllerLib();
$resultDB = $giantController->retrivDB($this->getRequest()->getParam('date_st'));
print_r(serialize($resultDB[0]));
}
public function getpaysAction()
{
$this->_helper->layout()->disableLayout();
$pays = $this->getRequest()->getParam('Pays');
$result = new GiantControllerLib();
if(($value = $result->getCache($pays)) === false || empty($value->MonitoringOptions->MonitoringOption[0]->LanguageCodes->LanguageCode)) {
print_r(array('no'));
}
else {
print_r(json_encode($value->MonitoringOptions->MonitoringOption[0]->LanguageCodes->LanguageCode));
2013-09-16 15:41:31 +00:00
}
}
public function reteventsAction()
{
$this->_helper->layout()->disableLayout();
$this->view->headScript()->appendFile('/themes/default/scripts/giant_monitoring.js', 'text/javascript');
$this->view->headScript()->appendFile('/themes/default/scripts/giant.js', 'text/javascript');
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$result = $auth->getStorage()->read($identity);
$result = $result->result->mon_result;
$merged_siren = Array();
foreach ($result->MonitoringEvents->MonitoringEvent as $MonitoringEvent):
if ($merged_siren[$MonitoringEvent->Company->CompanyId]){
array_push($merged_siren[$MonitoringEvent->Company->Event[0]->EventCode],$MonitoringEvent) ;
} else {
$merged_siren[$MonitoringEvent->Company->Event[0]->EventCode][]=$MonitoringEvent;
}
endforeach;
$type = $this->getRequest()->getParam('Type');
$id = $this->getRequest()->getParam('Id');
$merged = Array();
foreach ($merged_siren[$type] as $MonitoringEvent):
if ($merged[$MonitoringEvent->ProviderOrderId]){
array_push($merged[$MonitoringEvent->ProviderOrderId],$MonitoringEvent) ;
} else {
$merged[$MonitoringEvent->ProviderOrderId][]=$MonitoringEvent;
}
endforeach;
$this->view->result = $merged[$id];
2013-08-20 13:48:53 +00:00
}
2011-04-15 12:40:29 +00:00
}