Nic siege si nic absent

This commit is contained in:
Michael RICOIS 2014-03-27 14:28:12 +00:00
parent 23fd0606b9
commit c2298b0679

View File

@ -517,6 +517,7 @@ foreach($tabExtract as $i => $key)
//Ajout colonne obligatoire
$tabEntete[] = 'nicSiege';
${'nicSiegeData'} = '';
$tabEntete[] = 'SiretValide';
if( null != $profilDoublon ) {
$tabEntete[] = 'Doublon';
@ -635,10 +636,10 @@ foreach($tabIdentifiant as $item)
//Vérifier les nic, ou sélectionner le nic du siege actif
$nicV = $nic; //Surcharge pour le nic
$strNic = '';
$sqlNic = 'SELECT nic AS nicTmp, cj AS cjTmp, IF(siege=1,1,0) AS triSiege FROM jo.etablissements WHERE siren='.$siren;
$sqlNic = 'SELECT LPAD(nic,5,0) AS nicTmp, cj AS cjTmp, IF(siege=1,1,0) AS triSiege FROM jo.etablissements WHERE siren='.$siren;
//Si identifiant est un siret, char(14) alors on vérifie que le NIC existe
if (strlen($item)==14 && intval($nic)>0){
if ( strlen($item)==14 && intval($nic)>0 ) {
$stmt = $dbMetier->query($sqlNic.' AND nic='.$nic);
$result = $stmt->fetchAll();
if (count($result)==0){
@ -650,7 +651,7 @@ foreach($tabIdentifiant as $item)
}
}
if (intval($nicV)==0){
if ( intval($nicV)==0 ) {
$strNic = ' AND nic>-1 AND actif>-1 ORDER BY triSiege DESC, actif DESC, nicTmp DESC LIMIT 0,1';
$stmt = $dbMetier->query($sqlNic.$strNic);
$result = $stmt->fetchAll();
@ -799,7 +800,7 @@ if ($opts->id) {
function nicSiegeData($siren, $nic, $values = false)
{
$tabData['nicSiege'] = $nic;
$tabData['nicSiege'] = $nic;
return $tabData;
}