Correction génération du cache

This commit is contained in:
Michael RICOIS 2016-10-26 10:41:13 +02:00
parent 05c6a0e662
commit dedb38020f

View File

@ -86,7 +86,7 @@ try {
*/
if( $opts->generate == 'Tribunaux' ) {
$sql = "SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$sql = "SELECT triCode, triNom, LPAD(triCP,5,0) AS triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
@ -97,9 +97,9 @@ if( $opts->generate == 'Tribunaux' ) {
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
$dep = intval(substr($item->triCP, 0, 2));
$dep = substr($item->triCP, 0, 2);
if ($dep == 97 || $dep == 98) {
$dep = intval(substr($item->triCP, 0, 3));
$dep = substr($item->triCP, 0, 3);
}
fwrite($fp, "\t'" . $item->triCode . "' => array(");
fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\"");
@ -124,7 +124,7 @@ if ( $opts->generate == 'FctDir' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n");
}
}
@ -146,7 +146,7 @@ if ( $opts->generate == 'Evenements' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n");
fwrite($fp, "\t\t'libEven' => \"" . $item->libEven . "\",\n");
@ -176,7 +176,7 @@ if ( $opts->generate == 'Devises' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n");
}
}
@ -198,9 +198,9 @@ if ( $opts->generate == 'RncsTribunaux' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array(");
fwrite($fp, "'Id'=>\"" . $item->triId . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
fwrite($fp, "'Id'=>\"" . intval($item->triId) . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
fwrite($fp, "),\n");
}
}
@ -222,7 +222,7 @@ if ( $opts->generate == 'DevisesInpi' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n");
}
}
@ -244,7 +244,7 @@ if ( $opts->generate == 'Jugements' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n");
}
}
@ -266,7 +266,7 @@ if ( $opts->generate == 'PaysInpi' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n");
}
}
@ -288,7 +288,7 @@ if ( $opts->generate == 'CodesNaf' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n");
}
}
@ -299,7 +299,7 @@ if ( $opts->generate == 'CodesNaf' ) {
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n");
}
}
@ -322,7 +322,7 @@ if ( $opts->generate == 'CodesNace' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n");
}
}
@ -344,7 +344,7 @@ if ( $opts->generate == 'CodesNafa' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n");
}
}
@ -366,7 +366,7 @@ if ( $opts->generate == 'CodesFJ' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n");
}
}
@ -389,7 +389,7 @@ if ( $opts->generate == 'AffairesTypes' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->code . "' => \"" . $item->label ."\",\n");
}
}
@ -411,7 +411,7 @@ if ( $opts->generate == 'ProcolDelete' ) {
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($rows as $item) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .",\n");
}
}