extranet/library/Giant/Controllers.lib.php
2013-06-14 16:00:22 +00:00

342 lines
10 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/Cache.php');
require_once ('Partials.php');
Class GiantControllerLib
{
private $pathImg;
public function __construct($companyId)
{
$c = Zend_Registry::get('config');
$this->pathImg = $c->profil->path->pages.'/imgcache/'.$companyId;
}
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();
$id = $Rapport->getRapportExist($CompanyId, $Type, $Language);
if(empty($id)) {
$rapport = new GiantRechercheController($Pays, $TestIndication);
$result = $rapport->GetRapport($CompanyId, $Type, $Language);
$result = base64_encode(serialize($result));
$id = $Rapport->setReport($CompanyId,
$Type,
$Pays,
$result,
$Language);
}
$report_id = $Rapport->getRapportExistId($CompanyId, $Language);
$CommandeP->login = $Utilisateur->getLogin();
$CommandeP->date = date("Y-m-d");
$CommandeP->typeReport = $function->getTypeReport($Type);
$CommandeP->price = 0;
$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 monitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode,$Pays)
{
$rapport = new GiantRechercheController($Pays, $TestIndication);
$result = $rapport->GetStartMonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode);
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' => '001',
'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 = $TestIndication;
$this->soapG = new WSgiant($this->Provider);
}
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'
);
$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 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]);
}
}
?>