'."\n"; $html.= '  '."\n"; $html.= ' '.$lib.''."\n"; if ($title!='') { $title = ' title="'.$title.'"'; } $html.= ' '.$data.''."\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) { $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 ''. $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 ''; } } // --------------------------------------------------------------------------- // // Type de rapport // --------------------------------------------------------------------------- // require_once 'dbbootstrap.php'; setDbConn('giantclient'); $r = Doctrine_Query::create() ->from('Rapports') ->where('OrderId = ?', $commande_id) ->fetchOne(); print '
'; switch ($r->DataSetType) { case 'Full': print '

RAPPORT COMPLET

'; break; case 'Compact': print '

RAPPORT DE SYNTHESE

'; break; } $d = unserialize($r->DataSet); $c = $d->Company; print '

SOCIÉTÉ : '.$c->CompanyName->_.'

'; // --------------------------------------------------------------------------- // // Identite de l'entreprise // --------------------------------------------------------------------------- // print '

IDENTITE DE L\'ENTREPRISE

'; print ''; 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 '
'; // --------------------------------------------------------------------------- // // Raison sociale et coordonnees // --------------------------------------------------------------------------- // print '

Raison sociale & Coordonnées

'; print ''; 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', ''.$c->WebAddress.''); dRow('Courriel', ''. $c->EmailAddress.''); print '
'; // --------------------------------------------------------------------------- // // Activite(s) et chiffre d'affaire // --------------------------------------------------------------------------- // print '

Activité(s) & Chiffre d\'affaire

'; print ''; $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 '
'; // --------------------------------------------------------------------------- // // Annonces legales // --------------------------------------------------------------------------- // print '

ANNONCES LÉGALES

'; print ''; $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 '
'; // --------------------------------------------------------------------------- // // Dirigeants // --------------------------------------------------------------------------- // print '

DIRIGEANTS

'; print ''; 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 '
'; // --------------------------------------------------------------------------- // // Synthese // --------------------------------------------------------------------------- // print '

Synthèse

'; print ''; 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 '
'; // --------------------------------------------------------------------------- // // Bilans // --------------------------------------------------------------------------- // print '

ÉLÉMENTS FINANCIERS - BILANS

'; print ''; printAccountItem($c, 'ACTIF'); printAccountItem($c, 'PASSIF'); printAccountItem($c, 'COMPTE DE RÉSULTAT'); print '
'; //print '
';
//print_r($tab);
//print '
'; // --------------------------------------------------------------------------- // // Score // --------------------------------------------------------------------------- // print '

Score

'; print ''; 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 '
'; print '
'; ?>