extranet/application/controllers/GiantController.php

153 lines
8.0 KiB
PHP

<?php
require_once ('Giant/ChromePhp.php');
require_once ('Giant/WSgiant.php');
require_once ('Giant/Search.lib.php');
require_once ('Scores/RechercheHistorique.php');
require_once ('Giant/CreditData.lib.php');
require_once ('Giant/Controller/RechercheController.php');
require_once ('Scores/Utilisateur.php');
require_once ('Giant/Functions.php');
require_once ('Giant/Controller/GiantController.php');
require_once ('Giant/Controller/IdentiteController.php');
require_once ('common/dates.php');
require_once ('Giant/Commandes.php');
require_once ('Giant/Rapports.php');
class GiantController extends Zend_Controller_Action
{
protected $TestIndication = true;
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 Utilisateur();
$rechercheParams = new RechercheHistorique();
if (count($rechercheParams->liste()) > 0)
{
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
$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();
if (count($rechercheParams->liste()) > 0)
{
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
$Commande = new Commandes();
$Utilisateur = new Utilisateur();
$listeCommandes = $Commande->getCommandesByLogin($Utilisateur->getLogin());
$i = 1;
$liste .= '<b>Liste de vos commandes :</b><br /><br /><ul>';
foreach($listeCommandes as $commande) {
$total = $total + $commande['price'];
$liste .= '<li>';
$liste .= $i++.'- '. GiantFunction::getFlag($commande['pays']).' '.WDate::dateT('Y-m-d', 'd/m/Y', $commande['date']).' '.$commande['typeReport'].' '.$commande['price'].' euros';
$liste .= '</li>';
}
$liste .= '</ul>';
$ListeRapport = new GiantRechercheController($params['pays'], $this->TestIndication);
$result = $ListeRapport->ListeRapport($this->getRequest()->getParam('CompanyId'));
ChromePhp::log($result);
$this->view->total = $total;
$this->view->listeCommandes = $liste;
$this->view->modification = $ListeRapport->getModification($result->MonitoringOptions->MonitoringOption[0]);
$this->view->description = $ListeRapport->getDescription();
$this->view->raisonSociale = $this->getRequest()->getParam('raisonSociale');
$this->view->listeRapport = $result;
$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 commandesAction()
{
$Utilisateur = new Utilisateur();
$Commande = new Commandes();
$Rapport = new Rapports($this->getRequest()->getParam('Pays'), $this->TestIndication);
$CommandeP = new stdClass();
$id = $Rapport->getRapportExist($this->getRequest()->getParam('CompanyId'), $this->getRequest()->getParam('Type'));
if(empty($id)) {
$rapport = new GiantRechercheController($this->getRequest()->getParam('Pays'), $this->TestIndication);
$result = $rapport->GetRapport($this->getRequest()->getParam('CompanyId'), $this->getRequest()->getParam('Type'));
$result = base64_encode(serialize($result));
$id = $Rapport->setReport($this->getRequest()->getParam('CompanyId'),
$this->getRequest()->getParam('Type'),
$this->getRequest()->getParam('Pays'),
$result);
}
$CommandeP->login = $Utilisateur->getLogin();
$CommandeP->date = date("Y-m-d");
$CommandeP->typeReport = GiantFunction::getTypeReport($this->getRequest()->getParam('Type'));
$CommandeP->price = 150;
$CommandeP->rapportId = 1;
$CommandeP->pays = 'fr';
if(!$Commande->getCommandeExistToday($CommandeP->login, $CommandeP->date, $CommandeP->rapportId, $CommandeP->typeReport)) {
$Commande->setCommandes($CommandeP);
}
$this->_forward('rapport', 'giant', null, array('idRapport' => $id));
}
public function rapportAction()
{
$request = $this->getRequest();
$result = unserialize(base64_decode($request->getParam('idRapport')));
$rechercheParams = new RechercheHistorique();
if (count($rechercheParams->liste()) > 0)
{
$recherche = $rechercheParams->item(0);
$type = $recherche['type'];
$params = $recherche['params'];
}
$result =
$identiteController = new GiantIdentiteController($result);
$identiteController->ficheAction();
$fiche = $identiteController->getObjet('fiche');
$fiche['Vat'] = $fiche['Vat']->VatNumber;
$fiche['CompanyName'] = $fiche['CompanyName']->_;
$fiche['CompanyAddress'] = $fiche['CompanyAddress']->HouseNumber.' '.$fiche['CompanyAddress']->Street.'<br />'.$fiche['CompanyAddress']->PostCode.' '.$fiche['CompanyAddress']->City;
$fiche['TelephoneNumber'] = $fiche['TelephoneNumber']->_;
$fiche['IncorporationDate'] = WDate::dateT($fiche['IncorporationDate']->format, 'd/m/Y', $fiche['IncorporationDate']->_);
$fiche['UnifiedLegalForm'] = $fiche['LegalForm']->UnifiedLegalForm;
$fiche['LegalForm'] = $fiche['LegalForm']->CountryLegalForm->_;
$fiche['WebAddress'] = '<a href="http://'.$fiche['WebAddress'].'">'.$fiche['WebAddress'].'</a>';
$fiche['EmailAddress'] = '<a href="mailto:'.$fiche['EmailAddress'].'">'.$fiche['EmailAddress'].'</a>';
$fiche['ValideNumber'] = GiantFunction::checkVat(substr($fiche['Vat'], 2), $request->getParam('Pays'));
$this->view->rapport = $result;
$this->view->rapportType = $this->getRequest()->getParam('Type');
$this->view->fiche = $fiche;
}
}