'.$title.'';
}
function _formartDateRapport($date)
{
$dateF = explode($date);
return ($dateF[0]+$dateF[1]+($dateF[2][0].$dateF[2][1]));
}
function checkDateRapport($NameFileRapport, $dateNewRapport)
{
$array = explode('-',$NameFileRapport);
if (($array[1]+$array[2]+$array[3]) < _formartDateRappor($dateNewRapport))
return (false);
return (true);
}
function _ifDirectoryExist($companyId)
{
if (is_dir($companyId))
return ($companyId);
mkdir($companyId);
return ($companyId);
}
function _ifConfigSet($config, $param)
{
if (!empty($config[$param]))
return($config[$param]);
return ($param);
}
function SelectTrueLabel($config, $name)
{
foreach($config as $param => $valeur)
{
if ($param == $name)
return (_ifConfigSet($config, $param));
}
return ($name);
}
function _getFlags($lang, $path_icons)
{
switch($lang)
{
case 'en':
return ($path_icons.'/en.png');
break;
case 'nl':
return ($path_icons.'/nl.png');
break;
default:
}
}
function _setParamsHasChamps($champ, $valeur, $configNace)
{
if ($champ == 'NaceCode') {
$array_nace = explode(',', $valeur);
foreach($array_nace as $code)
echo $code . ' ' . SelectTrueLabel($configNace['Section_NaceCode'], $code).'
';
} else if($champ == 'CompanyWebSite')
{
$uri = parse_url($valeur);
echo ''.$uri['host'] . '';
}
else if ($champ == 'CompanyEmail')
echo ''.$valeur.'';
else if ($champ == 'VatNumber')
echo $valeur . ' '. _checkTVA($valeur);
else
{
if (!is_object($valeur))
echo $valeur;
else
{
foreach($valeur as $row) {
foreach($row as $val)
echo $val;
}
}
}
}
function _checkTVA($tvaNumber)
{
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) {
echo $f->getMessage();
}
$result = $soap_client->checkVat($params);
if ($result->valid)
return '';
return '';
}
}
/**
* Fonction de Giant Maquette reprises
*
* PS : ne surtout pas reprendre ce code !
*/
// --------------------------------------------------------------------------- //
// dRow
// --------------------------------------------------------------------------- //
function dRow($lib, $data, $title = '')
{
$html = '
'."\n";
$html .= ' | '."\n";
$html .= ' '.$lib.' | '."\n";
if ($title != '') {
$title = ' title="'.$title.'"';
}
$html .= ' '.$data.' | '."\n";
$html .= '
'."\n";
print $html;
}
// --------------------------------------------------------------------------- //
// dRow2
// --------------------------------------------------------------------------- //
function dRow2($lib, $data, $id)
{
$html = ''."\n";
$html .= ' | '."\n";
$html .= ' '.$lib .' | '."\n";
$html .= ' '.$data.' | '."\n";
$html .= ' '.$id .' | '."\n";
$html .= '
'."\n";
print $html;
}
// --------------------------------------------------------------------------- //
// getArray
// --------------------------------------------------------------------------- //
function getArray($obj)
{
if (is_array($obj) == false) {
return array($obj);
} else {
return $obj;
}
}
// --------------------------------------------------------------------------- //
// printObj
// --------------------------------------------------------------------------- //
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;
}
// --------------------------------------------------------------------------- //
// cmp
// --------------------------------------------------------------------------- //
function cmp($a, $b)
{
if ($a->Date->_ == $b->Date->_) {
return 0;
}
return ($a->Date->_ < $b->Date->_) ? 1 : -1;
}
// --------------------------------------------------------------------------- //
// pdate
// --------------------------------------------------------------------------- //
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;
}
// --------------------------------------------------------------------------- //
// arrayInsert
// --------------------------------------------------------------------------- //
function arrayInsert($array, $pos, $value)
{
return array_merge(array_slice($array, 0 , $pos),
array($value),
array_slice($array, $pos));
}
// --------------------------------------------------------------------------- //
// fillAccountItem
// --------------------------------------------------------------------------- //
function fillAccountItem(&$tab, &$num, $item, $year, $level = 0, $desPrec = '')
{
if (isset($item->AccountItem) == true ||
isset($item->GroupTotalAmount) == true) {
if (isset($item->AccountItem) == true) {
foreach (getArray($item->AccountItem) as $it) {
if (isset($item->Description->_) == true) {
fillAccountItem($tab, $num, $it, $year,
$level + 1, $desPrec.$item->Description->_);
} else {
fillAccountItem($tab, $num, $it, $year,
$level + 1, $desPrec);
}
}
}
if (isset($item->GroupTotalAmount) == true) {
if (isset($tab[$num]) == true) {
for ($i = $num; $i < count($tab); ++$i) {
if (isset($item->Description->code) == true) {
$code = $item->Description->code;
} else {
$code = $desPrec.$item->Description->_;
}
if ($tab[$i]->cde == $code) {
$num = $i;
$tab[$num]->val[$year] = $item->GroupTotalAmount->_;
return;
}
}
$obj = new StdClass;
$obj->des = $item->Description->_;
$obj->val[$year] = $item->GroupTotalAmount->_;
if (isset($item->Description->code) == true) {
$obj->cde = $item->Description->code;
} else {
$obj->cde = $desPrec.$item->Description->_;
}
$obj->niv = $level;
$tab = arrayInsert($tab, $num, $obj);
} else {
$obj = new StdClass;
$obj->des = $item->Description->_;
$obj->val[$year] = $item->GroupTotalAmount->_;
if (isset($item->Description->code) == true) {
$obj->cde = $item->Description->code;
} else {
$obj->cde = $desPrec.$item->Description->_;
}
$obj->niv = $level;
$tab[$num] = $obj;
}
++$num;
}
} else {
if (isset($tab[$num]) == true) {
for ($i = 0; $i < count($tab); ++$i) {
if (isset($item->Description->code) == true) {
$code = $item->Description->code;
} else {
$code = $desPrec.$item->Description->_;
}
if ($tab[$i]->cde == $code) {
$num = $i;
$tab[$num]->val[$year] = $item->Value->_;
return;
}
}
$obj = new StdClass;
$obj->des = $item->Description->_;
$obj->val[$year] = $item->Value->_;
if (isset($item->Description->code) == true) {
$obj->cde = $item->Description->code;
} else {
$obj->cde = $desPrec.$item->Description->_;
}
$obj->niv = $level;
$tab = arrayInsert($tab, $num, $obj);
} else {
$obj = new StdClass;
$obj->des = $item->Description->_;
$obj->val[$year] = $item->Value->_;
if (isset($item->Description->code) == true) {
$obj->cde = $item->Description->code;
} else {
$obj->cde = $desPrec.$item->Description->_;
}
$obj->niv = $level;
$tab[$num] = $obj;
}
++$num;
}
}
// --------------------------------------------------------------------------- //
// printAccountItem
// --------------------------------------------------------------------------- //
function printAccountItem(&$company, $title)
{
$tab = array();
$years = array();
foreach ($company->AnnualAccounts as $a) {
switch ($title) {
case 'ACTIF':
$account = $a->OriginalAnnualAccounts
->BalanceSheet->Assets;
break;
case 'PASSIF':
$account = $a->OriginalAnnualAccounts
->BalanceSheet->Liabilities;
break;
default:
$account = $a->OriginalAnnualAccounts->ProfitAndLoss;
}
$num = 0;
$year = substr($a->AccountsDate->_, 0, 4);
$years[] = $year;
fillAccountItem($tab, $num, $account, $year);
}
rsort($years);
print ''.
''.
$title.' | ';
foreach ($years as $y) {
print ''.$y.' | ';
}
$level = 0;
foreach ($tab as $line) {
while ($line->niv < $level) {
print '';
--$level;
}
$level = $line->niv;
print '
';
print '';
for ($i = 0; $i < $line->niv; ++$i) {
print ' ';
}
print $line->des;
print ' | ';
foreach ($years as $y) {
print '';
if (isset($line->val[$y]) == true) {
print $line->val[$y];
}
print ' | ';
}
print '
';
}
}
// --------------------------------------------------------------------------- //
// printLiensFinanciers
// --------------------------------------------------------------------------- //
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);
}
}
}