"Aide.", 'list' => "List item.", 'generate|g=s' => "Generate the specify cache.", ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } //Usage if( count($opts->getOptions())==0 || isset($opts->help)) { echo $opts->getUsageMessage(); exit; } if ( $opts->list ) { $tabItems = array( "tribunaux" => "Tribunaux", "FctDir" => "Fonctions de direction", "Evenements" => "Table des evenements bodacc", ); echo "\n"; foreach ( $tabItems as $code => $label ) { echo "\t" . $code . " => ". $label . PHP_EOL; } exit; } if( $opts->generate == 'tribunaux' ) { $c = new Zend_Config($application->getOptions()); $db = Zend_Db::factory($c->profil->db->metier); $result = $db->query("SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL"); $result->setFetchMode(Zend_Db::FETCH_OBJ); $rows = $result->fetchAll(); $fp=fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CacheTribunaux.php','w'); fwrite($fp, " 0 ) { foreach($rows as $item) { $dep = intval(substr($item->triCP,0,2)); if ($dep==97 || $dep==98) $dep=intval(substr($item->triCP,0,3)); fwrite($fp, "\t'" . $item->triCode . "' => array("); fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\""); fwrite($fp, "),\n"); } } fwrite($fp, ");\n"); } if ( $opts->generate == 'FctDir' ) { $c = new Zend_Config($application->getOptions()); $db = Zend_Db::factory($c->profil->db->metier); $result = $db->query("SELECT codeFct, libelle FROM jo.bodacc_fonctions"); $result->setFetchMode(Zend_Db::FETCH_OBJ); $rows = $result->fetchAll(); $fp=fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CacheFctDir.php','w'); fwrite($fp, " 0 ) { foreach($rows as $item) { fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n"); } } fwrite($fp, ");\n"); } if ( $opts->generate == 'Evenements' ) { $c = new Zend_Config($application->getOptions()); $db = Zend_Db::factory($c->profil->db->metier); $result = $db->query("SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements"); $result->setFetchMode(Zend_Db::FETCH_OBJ); $rows = $result->fetchAll(); $fp=fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CacheEvenements.php','w'); fwrite($fp, " 0 ) { foreach($rows as $item) { fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n"); fwrite($fp, "\t\t'libEven' => \"" . $item->libEven . "\",\n"); fwrite($fp, "\t\t'Bodacc_Code' => \"" . $item->Bodacc_Code . "\",\n"); fwrite($fp, "\t\t'Rubrique' => \"" . $item->Rubrique . "\",\n"); fwrite($fp, "\t\t'Version' => " . $item->version . ",\n"); fwrite($fp, "\t\t'LienEtab' => " . $item->lienEtab . ",\n"); fwrite($fp, "\t),\n"); } } fwrite($fp, ");\n"); }