Damien LASSERRE 987ff9efe9 Giant Beta 1.1
Modification :

- Affichage des informations
- Réalisation de l'affichage des bilans
- Réalisation de l'affichage des Banques
- Sectionnalisation des catégories 

Mise en accord avec la charte graphique S&D

PARTIE BACKEND
2011-04-05 14:11:19 +00:00

257 lines
6.4 KiB
PHP

<?php
function SelectUnitForNumber($Unite, $nombre)
{
switch($Unite)
{
case 'M':
$nombre = $nombre / 1000000;
break;
case 'K':
$nombre = $nombre / 1000;
break;
default:
$nombre;
}
return ($nombre.' '.$Unite.'€');
}
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 selectDevise($devise)
{
switch($devise)
{
case 'EUR':
return (' €');
case 'DOL':
return (' $');
default:
return (' €');
}
}
function _getFlags($lang, $path_icons)
{
switch($lang)
{
case 'en':
return ($path_icons.'/uk.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="img/icones/accept.png" />';
return '<img title="invalid VAT number" alt="invalid VAT number" src="img/icones/exclamation.png" />';
}
}
// --------------------------------------------------------------------------- //
// 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));
}
// --------------------------------------------------------------------------- //
// 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);
}
}
}