390 lines
13 KiB
PHP
390 lines
13 KiB
PHP
<?php
|
|
// --------------------------------------------------------------------------- //
|
|
// giant_rapport.php
|
|
// --------------------------------------------------------------------------- //
|
|
$commande_id = $_GET['OrderId'];
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// 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;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// 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)
|
|
{
|
|
$date = '';
|
|
$f = substr($d->format, 0, 1);
|
|
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)
|
|
{
|
|
if (isset($item->AccountItem) == true ||
|
|
isset($item->GroupTotalAmount) == true) {
|
|
if (isset($item->AccountItem) == true) {
|
|
foreach (getArray($item->AccountItem) as $it) {
|
|
fillAccountItem($tab, $num, $it, $year, $level + 1);
|
|
}
|
|
}
|
|
if (isset($item->GroupTotalAmount) == true) {
|
|
if (isset($tab[$num]) == true) {
|
|
for ($i = $num; $i < count($tab); ++$i) {
|
|
if ($tab[$i]->cde == $item->Description->code) {
|
|
$num = $i;
|
|
$tab[$num]->val[$year] = $item->GroupTotalAmount->_;
|
|
return;
|
|
}
|
|
}
|
|
$obj = new StdClass;
|
|
$obj->des = $item->Description->_;
|
|
$obj->val[$year] = $item->GroupTotalAmount->_;
|
|
$obj->cde = $item->Description->code;
|
|
$obj->niv = $level;
|
|
$tab = arrayInsert($tab, $num, $obj);
|
|
} else {
|
|
$obj = new StdClass;
|
|
$obj->des = $item->Description->_;
|
|
$obj->val[$year] = $item->GroupTotalAmount->_;
|
|
$obj->cde = $item->Description->code;
|
|
$obj->niv = $level;
|
|
$tab[$num] = $obj;
|
|
}
|
|
++$num;
|
|
}
|
|
} else {
|
|
if (isset($tab[$num]) == true) {
|
|
for ($i = $num; $i < count($tab); ++$i) {
|
|
if ($tab[$i]->cde == $item->Description->code) {
|
|
$num = $i;
|
|
$tab[$num]->val[$year] = $item->Value->_;
|
|
return;
|
|
}
|
|
}
|
|
$obj = new StdClass;
|
|
$obj->des = $item->Description->_;
|
|
$obj->val[$year] = $item->Value->_;
|
|
$obj->cde = $item->Description->code;
|
|
$obj->niv = $level;
|
|
$tab = arrayInsert($tab, $num, $obj);
|
|
} else {
|
|
$obj = new StdClass;
|
|
$obj->des = $item->Description->_;
|
|
$obj->val[$year] = $item->Value->_;
|
|
$obj->cde = $item->Description->code;
|
|
$obj->niv = $level;
|
|
$tab[$num] = $obj;
|
|
}
|
|
++$num;
|
|
}
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// printAccountItem
|
|
// --------------------------------------------------------------------------- //
|
|
function printAccountItem(&$company, $title)
|
|
{
|
|
$tab = array();
|
|
$years = array();
|
|
foreach ($company->AnnualAccounts as $i => $a) {
|
|
$num = 0;
|
|
switch ($title) {
|
|
case 'ACTIF':
|
|
$account = $a->OriginalAnnualAccounts
|
|
->BalanceSheet->Assets->AccountItem;
|
|
break;
|
|
case 'PASSIF':
|
|
$account = $a->OriginalAnnualAccounts
|
|
->BalanceSheet->Liabilities->AccountItem;
|
|
break;
|
|
default:
|
|
$account = $a->OriginalAnnualAccounts->ProfitAndLoss;
|
|
}
|
|
$year = substr($a->AccountsDate->_, 0, 4);
|
|
$years[] = $year;
|
|
fillAccountItem($tab, $num, $account, $year);
|
|
}
|
|
sort($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>';
|
|
}
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Type de rapport
|
|
// --------------------------------------------------------------------------- //
|
|
require_once 'dbbootstrap.php';
|
|
setDbConn('giantclient');
|
|
|
|
$r = Doctrine_Query::create()
|
|
->from('Rapports')
|
|
->where('OrderId = ?', $commande_id)
|
|
->fetchOne();
|
|
|
|
print '<div id="center">';
|
|
switch ($r->DataSetType) {
|
|
case 'Full':
|
|
print '<h1>RAPPORT COMPLET</h1>';
|
|
break;
|
|
case 'Compact':
|
|
print '<h1>RAPPORT DE SYNTHESE</h1>';
|
|
break;
|
|
}
|
|
$d = unserialize($r->DataSet);
|
|
$c = $d->Company;
|
|
print '<p id="rsynthese">SOCIÉTÉ : '.$c->CompanyName->_.'</p>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Identite de l'entreprise
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>IDENTITE DE L\'ENTREPRISE</h1>';
|
|
print '<table>';
|
|
dRow('Numéro identifiant', $c->CompanyId);
|
|
dRow('Numéro de TVA Intracom.', $c->Vat->VatNumber);
|
|
dRow('Numéro de Securité Sociale', $c->SocialSecurityNumber);
|
|
dRow('Etablissement actif', ($c->CompanyStatus == 'Active')? 'Oui':'Non');
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Raison sociale et coordonnees
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h2>Raison sociale & Coordonnées</h2>';
|
|
print '<table>';
|
|
dRow('Raison Sociale', $c->CompanyName->_);
|
|
dRow('Forme juridique', $c->LegalForm->CountryLegalForm->code.' : '.
|
|
$c->LegalForm->CountryLegalForm->_);
|
|
dRow('Adresse',
|
|
$c->CompanyAddress->HouseNumber.' '.
|
|
$c->CompanyAddress->Street.' '.
|
|
$c->CompanyAddress->PostCode.' '.
|
|
$c->CompanyAddress->City.' '.
|
|
$c->CompanyAddress->Country);
|
|
$libelle = 'Téléphone(s)';
|
|
foreach (getArray($c->TelephoneNumber) as $t) {
|
|
$mobile = (isset($t->isMobile) == true &&
|
|
$t->isMobile == 1) ? ' (mobile)' : '';
|
|
dRow($libelle, $t->_.$mobile);
|
|
$libelle = '';
|
|
}
|
|
dRow('Fax', $c->Telefax);
|
|
dRow('Site Internet',
|
|
'<a href="'.$c->WebAddress.'" target="_blank">'.$c->WebAddress.'</a>');
|
|
dRow('Courriel',
|
|
'<a href="mailto:'.$c->EmailAddress.'" target="_blank">'.
|
|
$c->EmailAddress.'</a>');
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Activite(s) et chiffre d'affaire
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h2>Activité(s) & Chiffre d\'affaire</h2>';
|
|
print '<table>';
|
|
$libelle = 'Activité(s)';
|
|
foreach (getArray($c->Operations->IndustryCode) as $t) {
|
|
dRow($libelle, $t->NaceCode.' '.$t->Description->_);
|
|
$libelle = '';
|
|
}
|
|
dRow('Capital', $c->FinancialSummary->AuthorizedCapital->_.' €');
|
|
$annee = 0;
|
|
$total = 0;
|
|
foreach (getArray($c->Employees) as $t) {
|
|
if ($t->Period->EndDate->_ > $annee) {
|
|
$annee = $t->Period->EndDate->_;
|
|
$total = $t->TotalStaffEmployed;
|
|
}
|
|
}
|
|
if ($total > 0) {
|
|
dRow('Effectif de l\'entreprise',
|
|
$total.' salarié(s) en '.substr($annee, 0, 4));
|
|
}
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Annonces legales
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>ANNONCES LÉGALES</h1>';
|
|
print '<table>';
|
|
$tab = getArray($c->Event);
|
|
usort($tab, 'cmp');
|
|
foreach ($tab as $t) {
|
|
if (isset($t->Value) == true) {
|
|
dRow(pdate($t->Date), $t->Description->_.' '.printObj($t->Value));
|
|
} else if (isset($t->Description->_) == true) {
|
|
dRow(pdate($t->Date), $t->Description->_);
|
|
} else {
|
|
dRow(pdate($t->Date), '('.$t->EventCode.')');
|
|
}
|
|
}
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Dirigeants
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>DIRIGEANTS</h1>';
|
|
print '<table>';
|
|
foreach (getArray($c->Position) as $i => $t) {
|
|
if (isset($t->Person) == false) {
|
|
continue;
|
|
}
|
|
$date = '';
|
|
if (isset($t->Period->StartDate) == true) {
|
|
$date .= pdate($t->Period->StartDate);
|
|
}
|
|
$date .= ' - ';
|
|
if (isset($t->Period->EndDate) == true) {
|
|
$date .= pdate($t->Period->EndDate);
|
|
}
|
|
dRow($date,
|
|
$t->PositionTitle->_.' '.
|
|
$t->Person->LastName.' '.
|
|
$t->Person->FirstName);
|
|
}
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Synthese
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>Synthèse</h1>';
|
|
print '<table>';
|
|
dRow('Revenue', $c->FinancialSummary->Revenue->_);
|
|
dRow('TotalEquity', $c->FinancialSummary->TotalEquity->_);
|
|
dRow('ProfitLossBeforeTax', $c->FinancialSummary->ProfitLossBeforeTax->_);
|
|
dRow('ProfitLoss', $c->FinancialSummary->ProfitLoss->_);
|
|
dRow('WorkingCapital', $c->FinancialSummary->WorkingCapital->_);
|
|
dRow('AuthorizedCapital', $c->FinancialSummary->AuthorizedCapital->_);
|
|
dRow('PaidUpCapital', $c->FinancialSummary->PaidUpCapital->_);
|
|
print '</table>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Bilans
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>ÉLÉMENTS FINANCIERS - BILANS</h1>';
|
|
print '<table rules="groups">';
|
|
printAccountItem($c, 'ACTIF');
|
|
printAccountItem($c, 'PASSIF');
|
|
printAccountItem($c, 'COMPTE DE RÉSULTAT');
|
|
print '</table>';
|
|
//print '<pre>';
|
|
//print_r($tab);
|
|
//print '</pre>';
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Score
|
|
// --------------------------------------------------------------------------- //
|
|
print '<h1>Score</h1>';
|
|
print '<table>';
|
|
drow('Date', pdate($c->CreditRecommendation->Date));
|
|
foreach (getArray($c->CreditRecommendation
|
|
->RiskClasses->ProviderRiskClass) as $i => $t) {
|
|
drow($t->RatingName->_, $t->RatingValue);
|
|
}
|
|
drow('CommonRiskClass',
|
|
$c->CreditRecommendation->RiskClasses->CommonRiskClass->RatingValue);
|
|
drow('AmountAdvised', $c->CreditRecommendation->AmountAdvised->_.' '.
|
|
$c->CreditRecommendation->AmountAdvised->currency);
|
|
print '</table>';
|
|
print '</div>';
|
|
?>
|