2011-06-27 16:34:26 +00:00
< ? php
2011-10-13 10:22:44 +00:00
Class GiantFunction
2011-06-27 16:34:26 +00:00
{
2011-10-13 10:22:44 +00:00
public function randomColor ()
2011-08-29 15:49:41 +00:00
{
mt_srand (( double ) microtime () * 1000000 );
$c = '' ;
while ( strlen ( $c ) < 6 ){
$c .= sprintf ( " %02X " , mt_rand ( 0 , 255 ));
}
return '0x80' . $c ;
}
2011-09-06 12:40:31 +00:00
public function setLimit ( $limit )
{
if ( $limit == $userLimit )
return ( true );
return ( false );
}
2011-09-05 10:08:40 +00:00
public function setDate ( $date , $format )
{
2011-11-14 10:01:41 +00:00
$date = new WDate ();
2011-09-05 10:08:40 +00:00
switch ( $format ) {
case 'YYYYMMDD' :
$formatIn = 'Ymd' ;
2011-11-14 10:01:41 +00:00
$date = $date -> dateT ( $formatIn , 'd/m/Y' , $date );
2011-09-05 10:08:40 +00:00
return ( $date );
case 'YYYY' :
return ( $date );
case 'YYYYMM' :
return ( substr ( $date , 0 , 3 ) . '/' . substr ( $date , 3 ));
}
}
2011-08-29 13:22:02 +00:00
public function getFormatDate ( $format )
{
switch ( $format ) {
case 'YYYYMMDD' :
return ( 'Ymd' );
}
}
public function getPoundName ( $name )
{
switch ( $name ) {
case 'EUR' :
return ( 'Euros' );
case 'DOL' :
return ( 'Dolards' );
}
}
2011-09-06 12:40:31 +00:00
public function getModification ( $obj )
{
$reference = array ( 'CREDIT_RECOMMENDATION_CHANGE' => 'Changement Avis de crédit' ,
'ADDRESS_CHANGE' => 'Changement d\'adresse' ,
'COMPANY_NAME_CHANGE' => 'Changement dénomination / RS' ,
'LEGALFORM_CHANGE' => 'Changement Forme juridique' ,
'ACQUISITION' => 'Acquisition sociétaire' ,
'NEWS' => 'Nouvelles' ,
'ANNUAL_ACCOUNT_FILED' => 'Dépot des comptes annuels' ,
'CAPITAL_CHANGE' => 'Changement Capital' ,
'BANKRUPTCY_OR_LIQUIDATION' => 'Faillite ou liquidation'
);
$array = array ();
foreach ( $obj -> Categories -> Category as $Category ) {
foreach ( $Category -> EventCodes -> EventCode as $code ) {
$valeur = explode ( '.' , $code );
$array [ $valeur [ 0 ]][] = $valeur [ 1 ];
2011-06-30 15:30:43 +00:00
}
2011-09-06 12:40:31 +00:00
}
$html = '<fieldset><legend><center><b>Modifications au ' . date ( 'd/m/Y' ) . '</b></center></legend><br />' ;
$html .= '<ol style="list-style:none">' ;
foreach ( $array as $name => $ar ) {
$html .= '<li><b>' . $name . ' :</b></li>' ;
foreach ( $ar as $a ) {
$html .= '<li> <b>-</b> ' . $reference [ $a ] . '</li>' ;
}
$html .= '<br />' ;
}
$html .= '</ol></fieldset>' ;
return ( $html );
}
2011-10-13 10:22:44 +00:00
2011-06-30 15:30:43 +00:00
public function getDescription ()
{
$description = new stdClass ();
$description -> Full = " <table><tr><td><b>Information sur le rapport</b></td></tr><tr><td>Ce rapport est composés en plusieurs parties</td></tr><tr><td style='margin-left:5px'><ol><li>Identite et raison sociale</li><li>CreditRecommandation</li><li>Dirigeants</li><li>Les Bilans (actifs, Passifs, Compte de résultats)</li><li>Les Etablissements financiés</li><li>Comportement de paiement</li><li>Les partenaires financiés</li><li>Les actionnaires</li><li>Les annonces légales</li><li>Le Score</li></ol></td></tr></table> " ;
$description -> Compact = '<table><tr><b>Information sur le rapport</b></tr><tr><td>Ce rapport est composés en plusieurs parties</td></tr><tr><td><ol><li>Identite et raison sociale</li><li>CreditRecommandation</li><li>Dirigeants</li><li>Les Bilans (actifs, Passifs, Compte de résultats)</li><li>Les Etablissements financiés</li><li>Comportement de paiement</li><li>Les partenaires financiés</li><li>Les actionnaires</li><li>Les annonces légales</li><li>Le Score</li></ol></td></tr></table>' ;
$description -> CreditRecommendation = '<table><tr><b>Information sur le rapport</b></tr><tr><td>Ce rapport est composés en plusieurs parties</td></tr><tr><td><ol><li>Identite et raison sociale</li><li>CreditRecommandation</li><li>Dirigeants</li><li>Les Bilans (actifs, Passifs, Compte de résultats)</li><li>Les Etablissements financiés</li><li>Comportement de paiement</li><li>Les partenaires financiés</li><li>Les actionnaires</li><li>Les annonces légales</li><li>Le Score</li></ol></td></tr></table>' ;
$description -> Flex = '<table><tr><b>Information sur le rapport</b></tr><tr><td>Ce rapport est composés en plusieurs parties</td></tr><tr><td><ol><li>Identite et raison sociale</li><li>CreditRecommandation</li><li>Dirigeants</li><li>Les Bilans (actifs, Passifs, Compte de résultats)</li><li>Les Etablissements financiés</li><li>Comportement de paiement</li><li>Les partenaires financiés</li><li>Les actionnaires</li><li>Les annonces légales</li><li>Le Score</li></ol></td></tr></table>' ;
2011-10-13 10:22:44 +00:00
2011-06-30 15:30:43 +00:00
return ( $description );
}
2011-10-13 10:22:44 +00:00
2011-06-30 15:30:43 +00:00
public function getObjet ()
{
return ( $this -> Search );
}
2011-10-13 10:22:44 +00:00
2011-06-29 14:39:30 +00:00
protected function getNumRows ()
{
$user = new Utilisateur ();
2011-10-13 10:22:44 +00:00
return ( $user -> getNbRep ());
2011-06-29 14:39:30 +00:00
}
2011-10-13 10:22:44 +00:00
2011-06-29 14:39:30 +00:00
public function selectTypeSearch ( $form )
{
$type = array ( 'siret' , 'raisonSociale' , 'numero' , 'voie' , 'cpVille' , 'telFax' , 'naf' );
$i = 0 ;
2011-10-13 10:22:44 +00:00
2011-06-29 14:39:30 +00:00
foreach ( $type as $key => $element ) {
if ( $key == 'siret' )
return ( false );
2011-10-13 10:22:44 +00:00
if ( ! empty ( $form [ $element ]))
2011-06-29 14:39:30 +00:00
$i ++ ;
}
return (( $i == 1 ) ? true : false );
}
2011-10-13 10:22:44 +00:00
2011-06-28 15:28:45 +00:00
public function getQueryLink ( $parametres )
{
2011-12-07 08:58:50 +00:00
if ( ! empty ( $_SESSION [ 'recherche' ][ 'giant' ][ 'query' ])) {
foreach ( unserialize ( $_SESSION [ 'recherche' ][ 'giant' ][ 'query' ]) as $name => $element ) {
switch ( $name ) {
case 'RegisteredName' :
$parametres [ 'raisonSociale' ] = $element ;
}
}
}
$url = '/recherche/entreprise/siret/' . ( ! empty ( $parametres [ 'siret' ])) ? $parametres [ 'siret' ] : '' .
'/raisonSociale/' . ( ! empty ( $parametres [ 'raisonSociale' ])) ? $parametres [ 'raisonSociale' ] : '' .
'/numero/' . ( ! empty ( $parametres [ 'numero' ])) ? $parametres [ 'numero' ] : '' .
'/voie/' . ( ! empty ( $parametres [ 'voie' ])) ? $parametres [ 'voie' ] : '' .
'/cpVille/' . ( ! empty ( $parametres [ 'cpVille' ])) ? $parametres [ 'cpVille' ] : '' .
'/telFax/' . ( ! empty ( $parametres [ 'telFax' ])) ? $parametres [ 'telFax' ] : '' .
'/naf/' . ( ! empty ( $parametres [ 'naf' ])) ? $parametres [ 'naf' ] : '' .
'/pays/' . ( ! empty ( $parametres [ 'pays' ])) ? $parametres [ 'pays' ] : '' ;
2011-06-28 15:28:45 +00:00
return ( $url );
}
2011-10-13 10:22:44 +00:00
2011-06-28 15:28:45 +00:00
protected function replaceAcronyme ( $result )
{
$type = array ( 'AV' => 'Avenue' , 'RUE' => 'Rue' , 'BD' => 'Boulevard' , ' R ' => 'Rue' , 'RTE' => 'Route' );
2011-10-13 10:22:44 +00:00
2011-06-28 15:28:45 +00:00
foreach ( $result -> Results -> Company as $societe ) {
foreach ( $type as $element => $val ) {
$societe -> Address -> Street = str_replace ( $element , $val , $societe -> Address -> Street );
}
}
return ( $result );
}
2011-10-13 10:22:44 +00:00
2011-06-27 16:34:26 +00:00
protected function setCountryCode ( $CountryCode , $listeAutorized )
{
if ( array_key_exists ( $CountryCode , $listeAutorized )) {
return ( $this -> listAutorized [ $CountryCode ]);
}
return ( false );
}
2011-10-13 10:22:44 +00:00
2011-06-27 16:34:26 +00:00
public function getPays ( $code )
{
return ( $this -> listAutorized [ $code ]);
}
2011-10-13 10:22:44 +00:00
public function divCommande ( $listeCommandes , & $total )
{
$i = 1 ;
2011-11-14 10:01:41 +00:00
$date = new WDate ();
2011-10-13 10:22:44 +00:00
$liste .= '<b>Liste de vos commandes :</b><br /><br /><ul>' ;
foreach ( $listeCommandes as $commande ) {
$total = $total + $commande [ 'price' ];
$liste .= '<li>' ;
2011-11-14 10:01:41 +00:00
$liste .= $i ++. '- ' . GiantFunction :: getFlag ( $commande [ 'pays' ]) . ' ' . $date -> dateT ( 'Y-m-d' , 'd/m/Y' , $commande [ 'date' ]) . ' ' . $commande [ 'typeReport' ] . ' ' . $commande [ 'price' ] . ' euros' ;
2011-10-13 10:22:44 +00:00
$liste .= '</li>' ;
}
$liste .= '</ul>' ;
return ( $liste );
}
public function getFlag ( $flag )
{
return ( '<img src="/themes/default/images/drapeaux/' . $flag . '.png" />' );
}
public function getTypeReport ( $reportType )
{
switch ( $reportType ) {
case 'Full' :
return ( 'FU' );
case 'Compact' :
return ( 'CO' );
case 'CreditRecommendation' :
return ( CR );
case 'Flex' :
return ( 'FL' );
default :
return ( false );
}
}
public function getMethode ( $methode , $parametres )
{
foreach ( $this -> methodes as $fonction ) {
if ( $methode == $fonction )
return ( call_user_func_array ( array ( $this , $fonction ), $parametres ));
}
}
public function checkValide ( $valeur )
{
if ( ! empty ( $valeur ))
return ( $valeur );
return ( null );
}
public function checkVat ( $vatNumber , $countryCode )
{
try {
$client = new Zend_Soap_Client ( 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' ,
array ( 'compression' => SOAP_COMPRESSION_ACCEPT ));
} catch ( SoapFault $e ) {
echo $e -> getMessage ();
}
$parametres = new stdClass ();
$parametres -> countryCode = $countryCode ;
$parametres -> vatNumber = $vatNumber ;
return ( $client -> checkVat ( $parametres ) -> valid );
}
public function setQuery ( $query )
{
$this -> query = $query ;
}
public function getQuery ()
{
return ( $this -> query );
}
public function getLabelDesc ()
{
return ( $this -> label );
}
public function getLabelResults ()
{
return ( $this -> labelResults );
}
public function getCountryCode ()
{
return ( $this -> Provider -> Countrycode );
}
public function getCurrentPage ()
{
2011-12-07 08:58:50 +00:00
return ( $_SESSION [ 'recherche' ][ 'giant' ][ 'page' ]);
2011-10-13 10:22:44 +00:00
}
2011-06-27 16:34:26 +00:00
}