4d4e57b456
- Modification des rapport - Ajout des flags sur SOAP - Modification visuels
385 lines
8.1 KiB
PHP
385 lines
8.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Permet de gerer l'affichade des dates.
|
|
*
|
|
* @param $date
|
|
* @param $format
|
|
*/
|
|
function numberOfCompany($Branch) {
|
|
|
|
}
|
|
|
|
/**
|
|
* Permet de gerer l'affichage des champs.
|
|
*
|
|
* @param $champ
|
|
* @param $liste
|
|
*/
|
|
function isInAffichage($champ, $liste) {
|
|
if(is_array($liste)){
|
|
foreach($liste as $valeur)
|
|
{
|
|
if ($champ == $valeur)
|
|
return (true);
|
|
}
|
|
return (false);
|
|
}
|
|
return (false);
|
|
}
|
|
/**
|
|
* Selectionne la bonne unité pour la gestion des sommes.
|
|
*
|
|
* @param String $Unite
|
|
* @param int $nombre
|
|
*/
|
|
function SelectUnitForNumber($Unite, $nombre)
|
|
{
|
|
switch($Unite)
|
|
{
|
|
case 'M':
|
|
$nombre = $nombre / 1000000;
|
|
break;
|
|
case 'K':
|
|
$nombre = $nombre / 1000;
|
|
break;
|
|
default:
|
|
$nombre;
|
|
}
|
|
return ($nombre.' '.$Unite.'€');
|
|
}
|
|
|
|
/**
|
|
* Permet a partir du format de date de retourner le bon format :
|
|
* exemple : format YYYY return 2006
|
|
*
|
|
* @param $format
|
|
* @param $date
|
|
*/
|
|
function _setDateWithGiant($format, $date)
|
|
{
|
|
$indent = 0;
|
|
$dateFormat = array();
|
|
if(!empty($date))
|
|
{
|
|
for($i = 0; $i < strlen($format); $i++)
|
|
{
|
|
$dateFormat[$indent] .= $date[$i];
|
|
if ($format[$i+1] != $format[$i])
|
|
$indent++;
|
|
}
|
|
return ($dateFormat[2].'/'.$dateFormat[1].'/'.$dateFormat[0]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Crée un titre de section
|
|
*
|
|
* @param unknown_type $title
|
|
* @param unknown_type $affiche
|
|
*/
|
|
function __createTitleOfSection($title, $affiche = false) {
|
|
if ($affiche)
|
|
echo '<h3>'.$title.'</h3>';
|
|
}
|
|
|
|
/*
|
|
* Format une date.
|
|
*/
|
|
function _formartDateRapport($date)
|
|
{
|
|
$dateF = explode($date);
|
|
return ($dateF[0]+$dateF[1]+($dateF[2][0].$dateF[2][1]));
|
|
}
|
|
|
|
/**
|
|
* Verifie les date entre les rapport
|
|
* Pour l'enregistrement local du rapport.
|
|
*
|
|
* @param $NameFileRapport
|
|
* @param $dateNewRapport
|
|
*/
|
|
function checkDateRapport($NameFileRapport, $dateNewRapport)
|
|
{
|
|
$array = explode('-',$NameFileRapport);
|
|
if (($array[1]+$array[2]+$array[3]) < _formartDateRappor($dateNewRapport))
|
|
return (false);
|
|
return (true);
|
|
}
|
|
|
|
/**
|
|
* Verifie sur le dossier existe.
|
|
*
|
|
* @param $companyId
|
|
*/
|
|
function _ifDirectoryExist($companyId)
|
|
{
|
|
if (is_dir(PATH_DATA.$companyId))
|
|
return ($companyId);
|
|
mkdir(PATH_DATA.$companyId);
|
|
return ($companyId);
|
|
}
|
|
|
|
/**
|
|
* Verifie si la config existe pour les .ini
|
|
*
|
|
* @param $config
|
|
* @param $param
|
|
*/
|
|
function _ifConfigSet($config, $param)
|
|
{
|
|
if (!empty($config[$param]))
|
|
return($config[$param]);
|
|
return ($param);
|
|
}
|
|
|
|
/**
|
|
* Permet de retourner le nom se trouver dans le .ini
|
|
* Exemple pour la traduction des champs.
|
|
*
|
|
* @param $config
|
|
* @param $name
|
|
*/
|
|
function SelectTrueLabel($config, $name)
|
|
{
|
|
foreach($config as $param => $valeur)
|
|
{
|
|
if ($param == $name)
|
|
return (_ifConfigSet($config, $param));
|
|
}
|
|
return ($name);
|
|
}
|
|
|
|
/**
|
|
* Permet de retourner le signe de devise selon le retour de Giant.
|
|
*
|
|
* @param $devise
|
|
*/
|
|
function selectDevise($devise)
|
|
{
|
|
switch($devise)
|
|
{
|
|
case 'EUR':
|
|
return (' €');
|
|
case 'DOL':
|
|
return (' $');
|
|
default:
|
|
return (' €');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet de retourner les bon Flag pour les lang
|
|
* gestion des images.
|
|
*
|
|
* @param $lang
|
|
* @param $path_icons
|
|
*/
|
|
function _getFlags($lang, $path_icons)
|
|
{
|
|
switch($lang)
|
|
{
|
|
case 'en':
|
|
return ($path_icons.'/uk.png');
|
|
break;
|
|
case 'nl':
|
|
return ($path_icons.'/nl.png');
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Verification des paramatre du foreach
|
|
* (Pas utilisé)
|
|
*
|
|
* @param $champ
|
|
* @param $valeur
|
|
* @param $configNace
|
|
*/
|
|
function _setParamsHasChamps($champ, $valeur, $configNace)
|
|
{
|
|
if ($champ == 'NaceCode') {
|
|
$array_nace = explode(',', $valeur);
|
|
foreach($array_nace as $code)
|
|
echo $code . '<i> ' . SelectTrueLabel($configNace['Section_NaceCode'], $code).'</i><br />';
|
|
} else if($champ == 'CompanyWebSite')
|
|
{
|
|
$uri = parse_url($valeur);
|
|
echo '<a target="_blank" href="'.$valeur.'">'.$uri['host'] . '</a>';
|
|
}
|
|
else if ($champ == 'CompanyEmail')
|
|
echo '<a href="mailto:'.$valeur.'">'.$valeur.'</a>';
|
|
else if ($champ == 'VatNumber' and !_DEBUG_MODE_)
|
|
echo $valeur . ' '. _checkTVA($valeur);
|
|
else
|
|
{
|
|
if (!is_object($valeur))
|
|
echo $valeur;
|
|
else
|
|
{
|
|
foreach($valeur as $row) {
|
|
foreach($row as $val)
|
|
echo $val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Verifie la validité d'un numéro de TVA intra avec le WSDL de Europa !
|
|
*
|
|
* @param $tvaNumber
|
|
*/
|
|
function _checkTVA($tvaNumber)
|
|
{
|
|
$CatchError = new SOAPCatchError();
|
|
|
|
if (!empty($tvaNumber))
|
|
{
|
|
$VatNumber = str_replace($_GET['pays'], '', $tvaNumber);
|
|
$params = new stdClass();
|
|
$params->countryCode = $_GET['pays'];
|
|
$params->vatNumber = $VatNumber;
|
|
|
|
try{
|
|
$soap_client =
|
|
new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl');
|
|
} catch(SoapFault $f) {
|
|
$CatchError->_printInLogs($fault->detail);
|
|
if(_DEBUG_MODE_)
|
|
{
|
|
echo '<b>__getLastRequest return : </b><br /><xmp>';
|
|
echo $soap_client->__getLastRequest().'</xmp>';
|
|
echo '<br /><b>__getLastResponse return : </b><br /><xmp>';
|
|
echo $soap_client->__getLastResponse().'</xmp>';
|
|
}
|
|
else
|
|
echo $CatchError->_getMessage();
|
|
exit;
|
|
}
|
|
$result = $soap_client->checkVat($params);
|
|
if ($result->valid)
|
|
return '<img title="valid VAT number" alt="valid VAT number" src="img/icones/accept.png" />';
|
|
return '<img title="invalid VAT number" alt="invalid VAT number" src="img/icones/exclamation.png" />';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet de retourner un array ( transtypage )
|
|
* @param unknown_type $obj
|
|
*/
|
|
function getArray($obj)
|
|
{
|
|
if (!is_array($obj)) {
|
|
return array($obj);
|
|
} else {
|
|
return $obj;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affiche un object
|
|
* Pas de ma version ( surement pas utilisé )
|
|
*
|
|
* @param $obj
|
|
*/
|
|
function printObj($obj)
|
|
{
|
|
$ret = '';
|
|
foreach ($obj as $val) {
|
|
if (is_object($val) == true) {
|
|
$ret .= printObj($val);
|
|
} else if ($val == 'OldValue' ||
|
|
$val == 'NewValue') {
|
|
$ret .= '('.$val.') ';
|
|
} else if ($val != 'eq') {
|
|
$ret .= $val.' ';
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Pas de ma version ( surement pas utilisé )
|
|
*
|
|
* @param $a
|
|
* @param $b
|
|
*/
|
|
function cmp($a, $b)
|
|
{
|
|
if ($a->Date->_ == $b->Date->_) {
|
|
return 0;
|
|
}
|
|
return ($a->Date->_ < $b->Date->_) ? 1 : -1;
|
|
}
|
|
|
|
/**
|
|
* Pas de ma version ( surement pas utilisé )
|
|
*
|
|
* @param $d
|
|
*/
|
|
function pdate($d)
|
|
{
|
|
if (isset($d->format) == false) {
|
|
if (isset($d->_) == true) {
|
|
return $d->_;
|
|
} else {
|
|
return $d;
|
|
}
|
|
}
|
|
$f = substr($d->format, 0, 1);
|
|
$date = '';
|
|
for ($i = 0; $i < strlen($d->format); ++$i) {
|
|
if (substr($d->format, $i, 1) != $f) {
|
|
$f = substr($d->format, $i, 1);
|
|
$date .= ' / ';
|
|
}
|
|
$date .= substr($d->_, $i, 1);
|
|
}
|
|
return $date;
|
|
}
|
|
|
|
/**
|
|
* Permet d'inserer a la suite d'un tableau.
|
|
*
|
|
* @param $array
|
|
* @param $pos
|
|
* @param $value
|
|
*/
|
|
function arrayInsert($array, $pos, $value)
|
|
{
|
|
return array_merge(array_slice($array, 0 , $pos),
|
|
array($value),
|
|
array_slice($array, $pos));
|
|
}
|
|
|
|
/**
|
|
* Pas de ma version ( surement pas utilisé )
|
|
*
|
|
* @param $d
|
|
*/
|
|
function printLiensFinanciers(&$company, $type)
|
|
{
|
|
foreach (getArray($company->Associated) as $t) {
|
|
if ($t->RelationShip == $type) {
|
|
$libelle = '';
|
|
if (isset($t->Shares) == true) {
|
|
$libelle = $t->Shares->Percentage.' %';
|
|
}
|
|
$id = '';
|
|
if (isset($t->Company->CompanyId) == true) {
|
|
$id = $t->Company->CompanyId;
|
|
} else if (isset($t->Company->CompanyAddress) == true &&
|
|
isset($t->Company->CompanyAddress->Country) == true) {
|
|
$id = '('.$t->Company->CompanyAddress->Country.')';
|
|
}
|
|
$name = '';
|
|
if (isset($t->Company->CompanyName) == true) {
|
|
$name .= ' '.$t->Company->CompanyName->_;
|
|
}
|
|
dRow2($libelle, $name, $id);
|
|
}
|
|
}
|
|
}
|