95650f60ae
Part 1
473 lines
14 KiB
PHP
473 lines
14 KiB
PHP
<?php
|
|
|
|
function _getLient($champ)
|
|
{
|
|
switch($champ){
|
|
case 'CompanyStatus':
|
|
return ('tick.png');
|
|
case 'CompanyAddress':
|
|
return('house.png');
|
|
case 'IncorporationDate':
|
|
return ('arrow_out.png');
|
|
case 'Telefax':
|
|
return ('telephone.png');
|
|
case 'TelephoneNumber':
|
|
return ('phone.png');
|
|
case 'EmailAddress':
|
|
return ('email.png');
|
|
case 'WebAddress':
|
|
return ('world_link.png');
|
|
case 'LegalForm':
|
|
return ('book_edit.png');
|
|
case 'Operations':
|
|
return ('monitor_go.png');
|
|
case 'ShareCapital':
|
|
return ('medal_gold_3.png');
|
|
case 'Bank':
|
|
return ('money.png');
|
|
case 'Position':
|
|
return ('text_list_numbers.png');
|
|
case 'Employees':
|
|
return ('user_gray.png');
|
|
case 'RealEstate':
|
|
return ('house.png');
|
|
case 'CreditRecommendation':
|
|
return ('chart_curve_go.png');
|
|
case 'FinancialSummary':
|
|
return ('book_open.png');
|
|
case 'AnnualAccounts':
|
|
return ('chart_line.png');
|
|
case 'PeerGroup':
|
|
return ('group_gear.png');
|
|
case 'PaymentBehaviour':
|
|
return ('money_euro.png');
|
|
case 'Event':
|
|
return ('application_cascade.png');
|
|
break;
|
|
case 'Associated':
|
|
return ('group.png');
|
|
break;
|
|
case 'Branch':
|
|
return ('attach.png');
|
|
break;
|
|
}
|
|
return (false);
|
|
}
|
|
|
|
function _setDateWithGiant($format, $date)
|
|
{
|
|
$indent = 0;
|
|
$dateFormat = array();
|
|
|
|
for($i = 0; $i < strlen($format); $i++)
|
|
{
|
|
$dateFormat[$indent] .= $date[$i];
|
|
if ($format[$i+1] != $format[$i])
|
|
$indent++;
|
|
}
|
|
return ($dateFormat);
|
|
}
|
|
|
|
function __createTitleOfSection($title, $affiche = false) {
|
|
if ($affiche)
|
|
echo '<h3>'.$title.'</h3>';
|
|
}
|
|
|
|
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 . '<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')
|
|
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 '<img title="valid VAT number" alt="valid VAT number" src="pages/giant/media/icons/accept.png" />';
|
|
return '<img title="invalid VAT number" alt="invalid VAT number" src="pages/giant/media/icons/exclamation.png" />';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fonction de Giant Maquette reprises
|
|
*
|
|
* PS : ne surtout pas reprendre ce code !
|
|
*/
|
|
// --------------------------------------------------------------------------- //
|
|
// dRow
|
|
// --------------------------------------------------------------------------- //
|
|
function dRow($lib, $data, $title = '')
|
|
{
|
|
$html = '<tr>'."\n";
|
|
$html .= ' <td width="30"> </td>'."\n";
|
|
$html .= ' <td width="200" class="StyleInfoLib">'.$lib.'</td>'."\n";
|
|
|
|
if ($title != '') {
|
|
$title = ' title="'.$title.'"';
|
|
}
|
|
$html .= ' <td width="350" class="StyleInfoData"'.
|
|
$title.'>'.$data.'</td>'."\n";
|
|
$html .= '</tr>'."\n";
|
|
print $html;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// dRow2
|
|
// --------------------------------------------------------------------------- //
|
|
function dRow2($lib, $data, $id)
|
|
{
|
|
$html = '<tr>'."\n";
|
|
$html .= ' <td width="30"> </td>'."\n";
|
|
$html .= ' <td width="100" class="StyleInfoLib" >'.$lib .'</td>'."\n";
|
|
$html .= ' <td width="350" class="StyleInfoData">'.$data.'</td>'."\n";
|
|
$html .= ' <td width="100" class="StyleInfoData">'.$id .'</td>'."\n";
|
|
$html .= '</tr>'."\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 '<tr>'.
|
|
'<td style="background-color: #00008c; color: #ffffff;"><b>'.
|
|
$title.'</b></td>';
|
|
foreach ($years as $y) {
|
|
print '<td style="background-color: #00008c; color: #ffffff;"'.
|
|
' align="right"><b>'.$y.'</b></td>';
|
|
}
|
|
$level = 0;
|
|
foreach ($tab as $line) {
|
|
while ($line->niv < $level) {
|
|
print '</tbody>';
|
|
--$level;
|
|
}
|
|
$level = $line->niv;
|
|
print '<tr>';
|
|
print '<td>';
|
|
for ($i = 0; $i < $line->niv; ++$i) {
|
|
print ' ';
|
|
}
|
|
print $line->des;
|
|
print '</td>';
|
|
foreach ($years as $y) {
|
|
print '<td align="right">';
|
|
if (isset($line->val[$y]) == true) {
|
|
print $line->val[$y];
|
|
}
|
|
print '</td>';
|
|
}
|
|
print '</tr>';
|
|
}
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// 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);
|
|
}
|
|
}
|
|
}
|