4d4e57b456
- Modification des rapport - Ajout des flags sur SOAP - Modification visuels
182 lines
6.2 KiB
PHP
182 lines
6.2 KiB
PHP
<?php
|
|
/**
|
|
* Function de gestion des bilan, permet de créer de switcher entre les différents bilans
|
|
* entre l'actif / Passif et default.
|
|
*
|
|
* @param $Account
|
|
* @param $title
|
|
* @param $config
|
|
*/
|
|
function switchAccountsItem(&$Account, $title, $config)
|
|
{
|
|
$tab = array();
|
|
$years = array();
|
|
static $lastYear;
|
|
|
|
foreach ($Account as $a)
|
|
{
|
|
switch ($title) {
|
|
case 'ACTIF':
|
|
foreach($a->OriginalAnnualAccounts->BalanceSheet->Assets as $account);
|
|
break;
|
|
case 'PASSIF':
|
|
foreach($a->OriginalAnnualAccounts->BalanceSheet->Liabilities as $account);
|
|
break;
|
|
default:
|
|
$account = $a->OriginalAnnualAccounts->ProfitAndLoss;
|
|
}
|
|
|
|
$num = 0;
|
|
$year = substr($a->AccountsDate->_, 0, 4);
|
|
$years[] = $year;
|
|
_getElementOfBalanceSheetType($tab, $num, $account, $year);
|
|
}
|
|
$params = new stdClass();
|
|
$params->tab = $tab;
|
|
$params->years = $years;
|
|
|
|
return ($params);
|
|
}
|
|
|
|
/**
|
|
* Permet de savoir si des doublon existe dans le tableau
|
|
* Exemple si deux années 2006 existe nous n'en affichons qu'une.
|
|
*
|
|
* @param $value
|
|
* @param $array
|
|
*/
|
|
function existInArray($value, $array)
|
|
{
|
|
foreach($array as $champ => $val) {
|
|
if ($val == $value)
|
|
return ($array[$value]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet de créer le tableau associatif selon le niveau demandé
|
|
* Exemple _simpleElementsOfBalanceSheetType(&$tab, 1, $years) nous renvoi toutes les ocurrence de niveau 1
|
|
*
|
|
* @param $tab
|
|
* @param $level
|
|
* @param $years
|
|
*/
|
|
function _simpleElementsOfBalanceSheetType(&$tab, $level, $years)
|
|
{
|
|
$array = getArray($tab);
|
|
|
|
for($i = 0; $i < count($array); $i++) {
|
|
if($tab[$i]->level == $level)
|
|
$prio[$tab[$i]->informations->description][]= $tab[$i]->informations->valeur;
|
|
}
|
|
return ($prio);
|
|
}
|
|
|
|
/**
|
|
* Permet de formater récursivement les données de l'objet en retour de Giant.
|
|
* ( Ne pas modifier le code ) il crée un tableau avec toutes les valeures les une derrière les autres
|
|
* pour pouvoir utiliser la recherche par niveau ( Fonction _simpleElementsOfBalanceSheetType() ).
|
|
*
|
|
* @param $tableBalanceSheet
|
|
* @param $etage
|
|
* @param $BalanceSheetType
|
|
* @param $year
|
|
* @param $level
|
|
* @param $description
|
|
*/
|
|
function _getElementOfBalanceSheetType(&$tableBalanceSheet, &$etage, $BalanceSheetType, $year, $level = 0, $description = '')
|
|
{
|
|
if (isset($BalanceSheetType->AccountItem) or isset($BalanceSheetType->GroupTotalAmount))
|
|
{
|
|
if (isset($BalanceSheetType->AccountItem))
|
|
{
|
|
foreach(getArray($BalanceSheetType->AccountItem) as $item)
|
|
{
|
|
if (isset($item->Description->_)){
|
|
_getElementOfBalanceSheetType($tableBalanceSheet, $etage, $item, $year,$level + 1 , $description.$item->Description->_);
|
|
} else {
|
|
_getElementOfBalanceSheetType($tableBalanceSheet, $etage, $item, $year, $level + 1, $description);
|
|
}
|
|
}
|
|
}
|
|
if (isset($BalanceSheetType->GroupTotalAmount))
|
|
{
|
|
if (isset($tableBalanceSheet[$etage]))
|
|
{
|
|
for($i = $etage; $i < count($tableBalanceSheet); ++$i) {
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$code = $BalanceSheetType->Description->code;
|
|
else
|
|
$code = $BalanceSheetType->Description->_;
|
|
if ($tableBalanceSheet[$i]->cde == $code) {
|
|
$etage = $i;
|
|
$tableBalanceSheet[$etage]->valeur[$year] = SelectUnitForNumber('M', $BalanceSheetType->GroupTotalAmount->_);
|
|
return;
|
|
}
|
|
}
|
|
$object = new stdClass();
|
|
$object->level = $level;
|
|
$object->informations = new stdClass();
|
|
$object->informations->description = $BalanceSheetType->Description->_;
|
|
$object->informations->valeur[$year] = SelectUnitForNumber('M', $BalanceSheetType->GroupTotalAmount->_);
|
|
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$object->code = $BalanceSheetType->Description->code;
|
|
else
|
|
$object->code = $BalanceSheetType->Description->_;
|
|
$tableBalanceSheet = arrayInsert($tableBalanceSheet, $etage, $object);
|
|
} else {
|
|
$object = new stdClass();
|
|
$object->level = $level;
|
|
$object->informations = new stdClass();
|
|
$object->informations->description = $BalanceSheetType->Description->_;
|
|
$object->informations->valeur[$year] = SelectUnitForNumber('M', $BalanceSheetType->GroupTotalAmount->_);
|
|
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$object->informations->code = $BalanceSheetType->Description->code;
|
|
else
|
|
$object->informations->code = $BalanceSheetType->Description->_;
|
|
$tableBalanceSheet[$etage] = $object;
|
|
}
|
|
++$etage;
|
|
}
|
|
} else {
|
|
if (isset($tableBalanceSheet[$etage]))
|
|
{
|
|
for($i = $etage; $i < count($tableBalanceSheet); ++$i) {
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$code = $BalanceSheetType->Description->code;
|
|
else
|
|
$code = $BalanceSheetType->Description->_;
|
|
if ($tableBalanceSheet[$i]->code == $code) {
|
|
$etage = $i;
|
|
$tableBalanceSheet[$etage]->valeur[$year] = SelectUnitForNumber('M',$BalanceSheetType->GroupTotalAmount->_);
|
|
return;
|
|
}
|
|
}
|
|
$object = new stdClass();
|
|
$object->level = $level;
|
|
$object->informations = new stdClass();
|
|
$object->informations->description = $BalanceSheetType->Description->_;
|
|
$object->informations->valeur[$year] = SelectUnitForNumber('M', $BalanceSheetType->Value->_);
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$object->code = $BalanceSheetType->Description->code;
|
|
else
|
|
$object->code = $BalanceSheetType->Description->_;
|
|
$tableBalanceSheet = arrayInsert($tableBalanceSheet, $etage, $object);
|
|
} else {
|
|
$object = new stdClass();
|
|
$object->level = $level;
|
|
$object->informations = new stdClass();
|
|
$object->informations->description = $BalanceSheetType->Description->_;
|
|
$object->informations->valeur[$year] = SelectUnitForNumber('M', $BalanceSheetType->Value->_);
|
|
if (isset($BalanceSheetType->Description->code))
|
|
$object->informations->code = $BalanceSheetType->Description->code;
|
|
else
|
|
$object->informations->code = $BalanceSheetType->Description->_;
|
|
$tableBalanceSheet[$etage] = $object;
|
|
}
|
|
++$etage;
|
|
}
|
|
}
|
|
?>
|