505 lines
17 KiB
PHP
505 lines
17 KiB
PHP
<?php
|
|
/*
|
|
* To change this template, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
require_once 'Vendors/ChartDirector/phpchartdir.php';
|
|
require_once ('Giant/WSgiant.php');
|
|
require_once ('Scores/WsScores.php');
|
|
require_once ('Scores/Cache.php');
|
|
require_once ('Partials.php');
|
|
|
|
Class GiantControllerLib
|
|
{
|
|
|
|
private $pathImg;
|
|
protected $configVal = array();
|
|
|
|
public function __construct($companyId)
|
|
{
|
|
$this->configVal = new Zend_Config_Ini( realpath(dirname(__FILE__)).'/giant.ini' );
|
|
$c = Zend_Registry::get('config');
|
|
$this->pathImg = $c->profil->path->shared.'/temp/pages/imgcache/'.$companyId;
|
|
}
|
|
|
|
public function getCache($pays){
|
|
$frontendOptions = array('lifetime' => $this->configVal->cache->lifetime,'automatic_serialization' => true);
|
|
$backendOptions = array('cache_dir' => $c->profil->path->shared . '/giant/');
|
|
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);
|
|
$result = $cache->load('Pays_'.$pays);
|
|
return ($result);
|
|
}
|
|
public function commande($CompanyId, $Type, $Pays, $Language, $TestIndication)
|
|
{
|
|
$function = new GiantFunction();
|
|
$Utilisateur = new Scores_Utilisateur();
|
|
$Commande = new Commandes();
|
|
$Rapport = new Rapports($Pays, $TestIndication);
|
|
$CommandeP = new stdClass();
|
|
$setLog = new WsScores();
|
|
|
|
switch ($Utilisateur->getIdClient()) {
|
|
case '0':
|
|
$price = $this->configVal->price->test;
|
|
break;
|
|
case '1':
|
|
$price = $this->configVal->price->snd;
|
|
break;
|
|
default:
|
|
$price = $this->configVal->price->other;
|
|
}
|
|
$id = $Rapport->getRapportExist($CompanyId, $Type, $Language);
|
|
if(empty($id)) {
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->GetRapport($CompanyId, $Type, $Language);
|
|
if (!empty($result)) {
|
|
$result = base64_encode(serialize($result));
|
|
$id = $Rapport->setReport($CompanyId,
|
|
$Type,
|
|
$Pays,
|
|
$result,
|
|
$Language);
|
|
}
|
|
}
|
|
//setLog in WS
|
|
//$setLog->setLog('giant'.$Type, $CompanyId);
|
|
//////////////
|
|
$report_id = $Rapport->getRapportExistId($CompanyId, $Language);
|
|
if (!empty($report_id)) {
|
|
$CommandeP->login = $Utilisateur->getLogin();
|
|
$CommandeP->date = date("Y-m-d");
|
|
$CommandeP->typeReport = $function->getTypeReport($Type);
|
|
$CommandeP->price = $price;
|
|
$CommandeP->pays = strtolower($Pays);
|
|
$CommandeP->rapportId = $report_id[0]['id'];
|
|
//$CommandeP->lang = $Utilisateur->getLang();
|
|
/*echo'<pre>';
|
|
print_r($report_id);
|
|
echo'</pre>';
|
|
if(!$Commande->getCommandeExistToday($CommandeP->login, $CommandeP->date, $CommandeP->typeReport, $CommandeP->pays)) {
|
|
$Commande->setCommandes($CommandeP);
|
|
}*/
|
|
$Commande->setCommandes($CommandeP);
|
|
}
|
|
return ($id);
|
|
}
|
|
public function commandePays($CompanyId,$Pays,$TestIndication)
|
|
{
|
|
$frontendOptions = array(
|
|
'lifetime' => $this->configVal->cache->lifetime,
|
|
'automatic_serialization' => true
|
|
);
|
|
$path = $c->profil->path->shared .'/giant/';
|
|
if (!is_dir($path)) mkdir($path, 0777, true)
|
|
;
|
|
//No, create it
|
|
$backendOptions = array('cache_dir' => $c->profil->path->shared . '/giant/');
|
|
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);
|
|
if(($result = $cache->load('Pays_'.$Pays)) === false) {
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->ListeRapport($CompanyId);
|
|
if (!empty($result)) {
|
|
$cache->save($result, 'Pays_'.$Pays);
|
|
}
|
|
}
|
|
return ($result);
|
|
}
|
|
public function startmonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode,$Pays,$TestIndication,$CompanyName)
|
|
{
|
|
$Utilisateur = new Scores_Utilisateur();
|
|
$Commande = new Commandes();
|
|
$CommandeP = new stdClass();
|
|
$CommandeP->login = $Utilisateur->getLogin();
|
|
$CommandeP->CompanyId = $CompanyId;
|
|
$CommandeP->CategorieName = $CategorieName;
|
|
$CommandeP->EventType = $EventType;
|
|
$CommandeP->Language = $LanguageCode;
|
|
$CommandeP->PreferredStartDate = $PreferredStartDate;
|
|
$CommandeP->PreferredEndDate = $PreferredEndDate;
|
|
$CommandeP->Version = $Version;
|
|
$CommandeP->Pays = $Pays;
|
|
$CommandeP->TestIndication = $TestIndication;
|
|
$CommandeP->CompanyName = $CompanyName;
|
|
if (!empty($PreferredStartDate)) {
|
|
$CommandeP->ActualStartDate = $PreferredStartDate;
|
|
} else {
|
|
$CommandeP->ActualStartDate = date("Y-m-d");
|
|
}
|
|
if (!empty($PreferredEndDate)) {
|
|
$CommandeP->ActualEndDate = $PreferredEndDate;
|
|
} else {
|
|
$CommandeP->ActualEndDate = date('Y-m-d', strtotime('+6 month'));
|
|
}
|
|
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->GetStartMonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode);
|
|
|
|
$CommandeP->InternalOrderId = $result->Order->InternalOrderId;
|
|
$CommandeP->ProviderOrderId = $result->Order->ProviderOrderId;
|
|
$Commande->setMonitoring($CommandeP);
|
|
return ($result);
|
|
}
|
|
|
|
public function stopmonitoring($CompanyId, $PreferredEndDate,$InternalOrderId,$Pays,$TestIndication)
|
|
{
|
|
$Commande = new Commandes();
|
|
$CommandeP = new stdClass();
|
|
$CommandeP->PreferredEndDate = $PreferredEndDate;
|
|
$CommandeP->InternalOrderId = $InternalOrderId;
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->GetStopMonitoring($CompanyId, $PreferredEndDate,$InternalOrderId);
|
|
if(!empty($result)){
|
|
$Commande->updateMonitoring($CommandeP);
|
|
}
|
|
return ($result);
|
|
}
|
|
|
|
public function updatemonitoring($CompanyId, $InternalOrderId, $CategorieName, $EventType, $PreferredStartDate, $Version, $LanguageCode, $Pays,$TestIndication)
|
|
{
|
|
$Commande = new Commandes();
|
|
$CommandeP = new stdClass();
|
|
$CommandeP->CategorieName = $CategorieName;
|
|
$CommandeP->EventType = $EventType;
|
|
$CommandeP->Language = $LanguageCode;
|
|
$CommandeP->PreferredStartDate = $PreferredStartDate;
|
|
$CommandeP->Version = $Version;
|
|
$CommandeP->InternalOrderId = $InternalOrderId;
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->GetUpdateMonitoring($CompanyId, $InternalOrderId, $CategorieName, $EventType, $PreferredStartDate, $Version, $LanguageCode);
|
|
if(!empty($result)){
|
|
$Commande->updateMonitoring($CommandeP);
|
|
}
|
|
return ($result);
|
|
}
|
|
public function retrivemonitoring($CompanyId, $StartFrom,$InternalOrderId,$Pays,$TestIndication,$EventType,$CompanyName)
|
|
{
|
|
$Utilisateur = new Scores_Utilisateur();
|
|
$Commande = new Commandes();
|
|
$CommandeP = new stdClass();
|
|
$CommandeP->login = $Utilisateur->getLogin();
|
|
$CommandeP->CompanyId = $CompanyId;
|
|
$CommandeP->CompanyName = $CompanyName;
|
|
$CommandeP->StartFrom = $StartFrom;
|
|
$CommandeP->Pays = $Pays;
|
|
$CommandeP->TestIndication = $TestIndication;
|
|
$CommandeP->Type = $EventType;
|
|
$CommandeP->InternalOrderId = $InternalOrderId;
|
|
$Commande->setRetrive($CommandeP);
|
|
$rapport = new GiantRechercheController($Pays, $TestIndication);
|
|
$result = $rapport->GetRetriveMonitoring($CompanyId, $StartFrom,$InternalOrderId,$EventType);
|
|
return ($result);
|
|
}
|
|
|
|
public function retrivDB($date_st)
|
|
{
|
|
$Rapport = new Rapports();
|
|
$id = $Rapport->getRetrive($date_st);
|
|
return $id;
|
|
}
|
|
public function retrive($StartFrom,$TestIndication,$EventType)
|
|
{
|
|
$Utilisateur = new Scores_Utilisateur();
|
|
$rapport = new GiantRechercheController('FR', $TestIndication);
|
|
$result = $rapport->GetRetrive($StartFrom,$TestIndication,$EventType);
|
|
return ($result);
|
|
}
|
|
protected function parcourTableau($array)
|
|
{
|
|
$tableau = array();
|
|
foreach($array as $key => $element){
|
|
if((is_array($element)) && (($element instanceof stdClass)))
|
|
GiantControllerLib::parcourTableau($element);
|
|
else
|
|
return $element;
|
|
}
|
|
}
|
|
|
|
public function getAvisDeCredit($report) {
|
|
$getAvisDeCredit = new AvisDeCredit($report, $this->pathImg);
|
|
return ($getAvisDeCredit->getDatas());
|
|
}
|
|
|
|
public function getStructureEntreprise($report) {
|
|
$StructureEntreprise = new StructureEntreprise($report, $this->pathImg);
|
|
return ($StructureEntreprise->getDatas());
|
|
}
|
|
|
|
public function getPositionFinanciere($report) {
|
|
$PositionFinanciere = new PositionFinanciere($report, $this->pathImg);
|
|
return ($PositionFinanciere->getDatas());
|
|
}
|
|
|
|
public function getInformationGenerale($report) {
|
|
$InformationGenerale = new InformationGenerale($report, $this->pathImg);
|
|
return ($InformationGenerale->getDatas());
|
|
}
|
|
|
|
public function getHistoriques($report) {
|
|
$Historique = new Historiques($report, $this->pathImg);
|
|
return ($Historique->getDatas());
|
|
}
|
|
|
|
public function getDirigeant($report) {
|
|
$Dirigeant = new Dirigeant($report, $this->pathImg);
|
|
return ($Dirigeant->getDatas());
|
|
}
|
|
|
|
public function getComportementPaiement($report) {
|
|
$ComportementPaiement = new ComportementPaiement($report, $this->pathImg);
|
|
return ($ComportementPaiement->getDatas());
|
|
}
|
|
|
|
public function getComptesAnnuels($report) {
|
|
$ComptesAnnuels = new ComptesAnnuels($report, $this->pathImg);
|
|
return ($ComptesAnnuels->getDatas());
|
|
}
|
|
|
|
public function getComparaisonValeurs($report) {
|
|
$ComparaisonValeurs = new ComparaisonValeurs($report, $this->pathImg);
|
|
return ($ComparaisonValeurs->getDatas());
|
|
}
|
|
}
|
|
|
|
Class GiantRechercheController extends GiantFunction
|
|
{
|
|
protected $listAutorized = array(
|
|
'FR' => '006', 'BE' => '001', 'ES' => '005',
|
|
'GB' => '002', 'NL' => '003'
|
|
);
|
|
protected $Provider;
|
|
public $soapG;
|
|
|
|
protected $Search;
|
|
public $CreditData;
|
|
|
|
public function __construct($CountryCode, $TestIndication = true)
|
|
{
|
|
$this->Provider = new stdClass();
|
|
$this->Provider->CountryCode = $CountryCode;
|
|
$this->Provider->ProviderId = parent::setCountryCode($CountryCode, $this->listAutorized);
|
|
$this->Provider->TestIndication = (bool)$TestIndication;
|
|
$this->soapG = new WSgiant($this->Provider,$TestIndication);
|
|
}
|
|
|
|
public function Liste($parametres, $page)
|
|
{
|
|
if (parent::selectTypeSearch($parametres))
|
|
return (self::ListeSearch($parametres, $page));
|
|
else
|
|
return (self::ListeAdvancedSearch($parametres, $page));
|
|
}
|
|
|
|
public function ListeSearch($parametres, $page)
|
|
{
|
|
$this->Search = new Search($this->soapG);
|
|
$searchParametre = new stdClass();
|
|
$searchParametre->Query = '';
|
|
$searchParametre->StartRow = $page;
|
|
$searchParametre->NumRows = parent::getNumRows();
|
|
$champQuery = array( 'raisonSociale', 'numero', 'voie', 'cpVille',
|
|
'telFax', 'naf', 'siret'
|
|
);
|
|
$parametres['siret']=str_replace(' ', '', $parametres['siret']);
|
|
$this->soapG->getAllMethodesFromWsdl('search');
|
|
foreach($parametres as $champ => $parametre) {
|
|
if(!empty($parametre)) {
|
|
foreach($champQuery as $valeur) {
|
|
if($champ == $valeur)
|
|
$searchParametre->Query .= $parametre.' ';
|
|
}
|
|
}
|
|
}
|
|
$result = $this->Search->getMethode('search', array($searchParametre, $page));
|
|
if ($result->NumberOfHits > 0)
|
|
$result = parent::replaceAcronyme($result);
|
|
|
|
return ($result);
|
|
}
|
|
|
|
public function ListeAdvancedSearch($parametres, $page)
|
|
{
|
|
$this->Search = new Search($this->soapG);
|
|
$advancedParametres = new stdClass();
|
|
$TypeAdvanced = new stdClass();
|
|
$advancedParametres->StartRow = $page;
|
|
$advancedParametres->NumRows = parent::getNumRows();
|
|
//((strlen($parametres['siret']) == 9) ? $id = 'CompanyRegisterNumber' : $id = 'CompanyId');
|
|
$labelForm = array(
|
|
'siret' => 'CompanyId',
|
|
'raisonSociale' => 'RegisteredName',
|
|
'numero' => 'HouseNumber',
|
|
'voie' => 'Street',
|
|
'cpVille' => 'City'
|
|
);
|
|
|
|
foreach ($parametres as $champ => $parametre) {
|
|
if (!empty($parametre)) {
|
|
foreach ($labelForm as $nameForm => $valeur) {
|
|
if ($champ == $nameForm)
|
|
$TypeAdvanced->$valeur = $parametre;
|
|
}
|
|
}
|
|
}
|
|
$advancedParametres->Query = $TypeAdvanced;
|
|
if($page == 0 and empty($_SESSION['recherche']['giant']['query'])) {
|
|
$_SESSION['recherche']['giant']['query'] = serialize($advancedParametres);
|
|
$result = $this->Search->getMethode('advancedSearch', array($advancedParametres, $page));
|
|
$this->Search->setQuery(implode(' ', $parametres));
|
|
} else {
|
|
$result = $this->Search->getMethode('advancedSearch', array(unserialize($_SESSION['recherche']['giant']['query']), $page));
|
|
$this->Search->setQuery(implode(' ', $parametres));
|
|
}
|
|
|
|
return ($result);
|
|
}
|
|
|
|
public function Identite($siret, $pays)
|
|
{
|
|
$this->Search = new Search($this->soapG);
|
|
$parametres = new stdClass();
|
|
$parametres->siret = $siret;
|
|
$parametres->pays = $pays;
|
|
$result = $this->Search->advancedSearch($parametres);
|
|
|
|
foreach ($result->Results->Company as $element) {
|
|
if ($element->CompanyId == $siret)
|
|
return ($element);
|
|
}
|
|
|
|
return (false);
|
|
}
|
|
|
|
public function GetRapport($CompanyId, $DataSetType, $Language)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('OrderDataSet', array($DataSetType, $Language));
|
|
$result = $this->CreditData->getMethode('RetrieveDataSet', array($result->Order->InternalOrderId));
|
|
return ($result);
|
|
}
|
|
public function GetStartMonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('StartMonitoring', array($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode));
|
|
return ($result);
|
|
}
|
|
public function GetStopMonitoring($CompanyId, $PreferredEndDate, $InternalOrderId)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('StopMonitoring', array($CompanyId, $PreferredEndDate, $InternalOrderId));
|
|
return ($result);
|
|
}
|
|
|
|
|
|
public function GetUpdateMonitoring($CompanyId, $InternalOrderId, $CategorieName, $EventType, $PreferredStartDate, $Version, $LanguageCode)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('UpdateMonitoringOptions', array($CompanyId, $InternalOrderId, $CategorieName, $EventType, $PreferredStartDate, $Version, $LanguageCode));
|
|
return ($result);
|
|
}
|
|
public function GetRetriveMonitoring($CompanyId, $StartFrom, $InternalOrderId,$EventType)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('RetrieveMonitoringEventsFor'.$EventType, array($CompanyId, $StartFrom, $InternalOrderId));
|
|
return ($result);
|
|
}
|
|
public function GetRetrive($StartFrom,$TestIndication, $EventType)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG);
|
|
$result = $this->CreditData->getMethode($EventType, array($CompanyId,$StartFrom));
|
|
return ($result);
|
|
}
|
|
public function ListeRapport($CompanyId)
|
|
{
|
|
$this->CreditData = new CreditData($this->soapG, $CompanyId);
|
|
$result = $this->CreditData->getMethode('RetreiveOptions', array($CompanyId));
|
|
return ($result);
|
|
}
|
|
}
|
|
|
|
Class GiantIdentiteController extends GiantControllerLib
|
|
{
|
|
protected $objet;
|
|
protected $datas = array();
|
|
protected $liste = array(
|
|
'CompanyId', 'Vat', 'CompanyName', 'CompanyStatus',
|
|
'CompanyAddress', 'TelephoneNumber', 'Telefax', 'WebAddress',
|
|
'EmailAddress', 'IncorporationDate', 'LegalForm', 'IsUltimateParent'
|
|
);
|
|
protected $changingStatus = array('FINANCIAL.CREDIT_RECOMMENDATION_CHANGE' => '',
|
|
'GENERAL.ADDRESS_CHANGE' => '',
|
|
'GENERAL.COMPANY_NAME_CHANGE' => '',
|
|
'GENERAL.LEGALFORM_CHANGE' => '',
|
|
'GENERAL.ACQUISITION' => '',
|
|
'GENERAL.NEWS' => '',
|
|
'FINANCIAL.ANNUAL_ACCOUNT_FILED' => '',
|
|
'FINANCIAL.CAPITAL_CHANGE' => '',
|
|
'FINANCIAL.CREDIT_RECOMMENDATION_CHANGE' => '',
|
|
'EXCEPTION.BANKRUPTCY_OR_LIQUIDATION' => ''
|
|
|
|
);
|
|
|
|
protected $FinancialSummary = array('Revenue', 'TotalEquity', 'WorkingCapital');
|
|
|
|
public function __construct($objet)
|
|
{
|
|
$this->objet = $objet;
|
|
}
|
|
|
|
public function ficheAction()
|
|
{
|
|
if(isset($this->objet->DataSet->Company)) {
|
|
foreach($this->objet->DataSet->Company as $key => $valeur) {
|
|
foreach ($this->liste as $element) {
|
|
if ($element == $key) {
|
|
if(!is_array($valeur)) {
|
|
if(!empty($valeur)) {
|
|
$this->datas['fiche'][$key] = $valeur;
|
|
}
|
|
} else {
|
|
$this->datas['fiche'][$key] = parent::parcourTableau($valeur);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function chiffreAction()
|
|
{
|
|
foreach ($this->objet->FinancialSummary[0] as $key => $valeur) {
|
|
foreach($this->FinancialSummary as $element) {
|
|
if (!empty($valeur)) {
|
|
$this->datas['chiffre'][$key] = $valeur->_;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function secondairesAction()
|
|
{
|
|
foreach($this->objet->Branch as $key => $valeur) {
|
|
if($key != 'BranchAddress') {
|
|
if(!is_array($valeur))
|
|
$this->datas['secondaires'][$key] = $valeur;
|
|
else
|
|
$this->datas['secondaires'][$key] = parent::parcourTableau($valeur);
|
|
|
|
} else
|
|
$this->datas['secondaires'][$key] = $valeur[0];
|
|
}
|
|
}
|
|
|
|
public function pieceAction()
|
|
{
|
|
foreach($this->objet->Event as $key => $valeur) {
|
|
$this->datas['piece'][$valeur->Source->code][$valeur->Date] = array($valeur->Description, $valeur->FreeText);
|
|
}
|
|
}
|
|
|
|
public function getObjet($data)
|
|
{
|
|
return ($this->datas[$data]);
|
|
}
|
|
}
|
|
?>
|