issue #0001090 : Bilans Directory structure
This commit is contained in:
parent
c3a3e55b0b
commit
e82ecfe3b8
@ -391,17 +391,16 @@ class DashboardController extends Zend_Controller_Action
|
||||
|
||||
$document = 'Bilan de '.$matches[1];
|
||||
|
||||
require_once 'Scores/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$path = $infogreffe->bilanPath($listCommandes[$i]->refDocument);
|
||||
$fichier = $infogreffe->bilanFilename($listCommandes[$i]->siren, $listCommandes[$i]->refDocument);
|
||||
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
$refFile = realpath($configuration->path->data).'/'.
|
||||
$configuration->path->pdf.'/bilan-'.
|
||||
$listCommandes[$i]->siren.'-'.
|
||||
trim($listCommandes[$i]->refDocument).'.pdf';
|
||||
$refFile = realpath($configuration->path->data).$path.$fichier;
|
||||
|
||||
if(file_exists($refFile)){
|
||||
$document = '<a href="./fichier/pdf/bilan-'.
|
||||
$listCommandes[$i]->siren.'-'.
|
||||
trim($listCommandes[$i]->refDocument).'.pdf'.
|
||||
'" target="_blank">'.$document.'</a>';
|
||||
$document = '<a href="./fichier/pdf/'.$fichier.'" target="_blank">'.$document.'</a>';
|
||||
}
|
||||
|
||||
$sirenLien = $this->view->url(array(
|
||||
|
@ -96,9 +96,17 @@ class FichierController extends Zend_Controller_Action
|
||||
*/
|
||||
public function pdfAction()
|
||||
{
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
$directory = realpath($configuration->path->data).'/'.$configuration->path->pdf;
|
||||
$file = $this->getRequest()->getParam('fichier');
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
//bilan
|
||||
if (preg_match('/^bilan-(consolide|sociaux)-([0-9]{8})/', $file, $matches)) {
|
||||
$directory = realpath($configuration->path->data).
|
||||
'/'.'greffes/bilans/'.$matches[1].'/'.substr($matches[2],0,4);
|
||||
}
|
||||
//acte
|
||||
else {
|
||||
$directory = realpath($configuration->path->data).'/'.$configuration->path->pdf;
|
||||
}
|
||||
$output_file = $directory.'/'.$file;
|
||||
if (file_exists($output_file) && filesize($output_file)>0) {
|
||||
$content_type = 'application/pdf';
|
||||
|
@ -771,16 +771,13 @@ class PiecesController extends Zend_Controller_Action
|
||||
case 'fichier':
|
||||
$ws->setLog('greffe_bilans', $siren, 0, $ref);
|
||||
$info = unserialize($info);
|
||||
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
$pathData = realpath($configuration->path->data);
|
||||
|
||||
if(file_exists($pathData.'/pdf/bilan-'.$siren.'-'.$ref.'.pdf')){
|
||||
$suffixe = 'bilan';
|
||||
}elseif(file_exists($pathData.'/pdf/acte-'.$siren.'-'.$ref.'.pdf')){
|
||||
$suffixe = 'acte';
|
||||
}
|
||||
$href = '/fichier/pdf/'.$suffixe.'-'.$siren.'-'.$ref.'.pdf';
|
||||
|
||||
require_once 'Scores/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$path = $infogreffe->bilanPath($ref);
|
||||
$file = $infogreffe->bilanFilename($siren, $ref);
|
||||
|
||||
$href = '/fichier/'.$path.$file;
|
||||
echo '<br/><a href="'.$href.'" target="_blank">Ouvrir le bilan millésime '.$info['type'].'</a>';
|
||||
|
||||
break;
|
||||
@ -833,7 +830,11 @@ class PiecesController extends Zend_Controller_Action
|
||||
$repErreur = $erreur->fetchAll($sql)->toArray();
|
||||
if (count($repErreur)>0){
|
||||
//Téléchagement
|
||||
$fichier = 'bilan-'.$siren.'-'.$ref.'.pdf';
|
||||
require_once 'Scores/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$path = $infogreffe->bilanPath($ref);
|
||||
$fichier = $infogreffe->bilanFilename($siren, $ref);
|
||||
|
||||
if (infogreffe_dl($fichier, $repErreur[0]['url'], false)) {
|
||||
$erreur->update(array('erreur'=>''), "siren='$siren' AND type='bilan' AND ref='$ref'");
|
||||
$ws->setLog('greffe_bilans', $siren, 0, $ref);
|
||||
@ -844,7 +845,8 @@ class PiecesController extends Zend_Controller_Action
|
||||
|
||||
} else {
|
||||
|
||||
$infogreffe = new Infogreffe();
|
||||
require_once 'Scores/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$reponse = $infogreffe->getGreffeBilans($siren, $vecteur, $ref);
|
||||
|
||||
if(empty($reponse['error'])) {
|
||||
@ -862,7 +864,8 @@ class PiecesController extends Zend_Controller_Action
|
||||
foreach($items as $item) {
|
||||
if($item['url_acces']!==false) {
|
||||
$ws->setLog('greffe_bilans', $siren, 0, $ref);
|
||||
$href = '/fichier/pdf/'.$item['url_acces'];
|
||||
$path = $infogreffe->bilanPath($ref);
|
||||
$href = '/fichier/'.$path.$item['url_acces'];
|
||||
echo '<br/><a href="'.$href.'" target="_blank">Ouvrir le bilan millésime '.$item['millesime'].'</a>';
|
||||
} else {
|
||||
$ws->setLog('greffe_bilans', $siren, 0, 'Erreur telechargement '.$ref);
|
||||
|
@ -135,7 +135,7 @@ $contents = ftp_nlist($conn_id, "*.pdf");
|
||||
$tabFichiersFtp = array();
|
||||
foreach ($contents as $filename){
|
||||
$indice = 0;
|
||||
if (preg_match('/[g|c][0-9]+\.pdf/', $filename)
|
||||
if (preg_match('/[g|c][0-9]+\.pdf/', $filename)
|
||||
|| preg_match('/[g|c][0-9]+-[0-9]{1,2}\.pdf/', $filename)){
|
||||
|
||||
list($ref, $indice) = explode('-', str_replace(array('.pdf', 'g', 'c'), array('','',''), $filename));
|
||||
@ -204,22 +204,30 @@ foreach ($tabCommandes as $ref => $commande){
|
||||
//Copie et renommage du fichier suivant la ref infogreffe (s'il n'existe pas déjà)
|
||||
$sirenC = $commande['siren'];
|
||||
$refC = $commande['refDocument'];
|
||||
$nomCible = "acte-$sirenC-$refC.pdf";
|
||||
|
||||
require_once 'Scores/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
if (preg_match('/^([0-9]{4}_).*?$/', $refC, $matches)){
|
||||
$nomCible = "bilan-$sirenC-$refC.pdf";
|
||||
$path = $infogreffe->bilanPath($refC);
|
||||
$nomCible = $infogreffe->bilanFilename($sirenC, $refC);
|
||||
} else {
|
||||
$path = $infogreffe->actePath($refC);
|
||||
$nomCible = $infogreffe->acteFilename($sirenC, $refC);
|
||||
|
||||
}
|
||||
|
||||
if (file_exists(ACTES_IGNUM_LOCAL_DIR.$fichier) &&
|
||||
!file_exists(ACTES_IG_LOCAL_DIR.$nomCible)){
|
||||
if (rename(ACTES_IGNUM_LOCAL_DIR.$fichier, ACTES_IG_LOCAL_DIR.$nomCible)){
|
||||
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déplacé en ".ACTES_IG_LOCAL_DIR.$nomCible.".\n";
|
||||
!file_exists(PATH_DATA.$path.$nomCible)) {
|
||||
if (rename(ACTES_IGNUM_LOCAL_DIR.$fichier, PATH_DATA.$path.$nomCible)){
|
||||
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déplacé en ".PATH_DATA.$path.$nomCible.".\n";
|
||||
} else {
|
||||
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".ACTES_IGNUM_LOCAL_DIR.$fichier." en ".ACTES_IG_LOCAL_DIR.$nomCible." !\n";
|
||||
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".ACTES_IGNUM_LOCAL_DIR.$fichier." en ".PATH_DATA.$path.$nomCible." !\n";
|
||||
}
|
||||
}
|
||||
|
||||
//Envoi du mail et Mise à jour de la commande
|
||||
$testMail = false;
|
||||
if (file_exists(ACTES_IG_LOCAL_DIR.$nomCible)){
|
||||
if (file_exists(PATH_DATA.$path.$nomCible)){
|
||||
if ($testMail){
|
||||
echo "Envoi fichier $nomCible ($ref) à ".$commande['emailCommande'];
|
||||
} else {
|
||||
|
@ -33,7 +33,7 @@ try {
|
||||
'rapportcomplet' => "Envoi d'un email listant toutes les commandes en erreur",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
@ -60,7 +60,7 @@ $db = Zend_Db::factory($configuration->databases->db->sdv1);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||
|
||||
if ( isset($opts->reprise) )
|
||||
if ( isset($opts->reprise) )
|
||||
{
|
||||
$commandesM = new Application_Model_CommandesErreur();
|
||||
$sql = $commandesM->select()->where("erreur!='' AND dateCommande > DATE_SUB(NOW(),INTERVAL 120 HOUR)");
|
||||
@ -74,13 +74,15 @@ if ( isset($opts->reprise) )
|
||||
$infogreffe = new Infogreffe();
|
||||
switch($cmd->type){
|
||||
case 'acte':
|
||||
$fichier = $infogreffe->acteFilename($cmd->siren, $cmd->ref);
|
||||
$path = $infogreffe->actePath($cmd->ref);
|
||||
$fichier = $infogreffe->acteFilename($cmd->siren, $cmd->ref);
|
||||
break;
|
||||
case 'bilan':
|
||||
$fichier = $infogreffe->bilanFilename($cmd->siren, $cmd->ref);
|
||||
$path = $infogreffe->bilanPath($cmd->ref);
|
||||
$fichier = $infogreffe->bilanFilename($cmd->siren, $cmd->ref);
|
||||
break;
|
||||
}
|
||||
$dl = $infogreffe->dl($fichier, $cmd->url, false);
|
||||
$dl = $infogreffe->dl($path.$fichier, $cmd->url, false);
|
||||
if( $dl ) {
|
||||
$data = array('erreur' => '', 'dateReception' => date('Y-m-d H:i:s'));
|
||||
$where = "siren='".$cmd->siren."' AND type='".$cmd->type."' AND ref='".$cmd->ref."' AND dateCommande='".$cmd->dateCommande."'";
|
||||
@ -90,7 +92,7 @@ if ( isset($opts->reprise) )
|
||||
|
||||
}
|
||||
|
||||
if ( isset($opts->rapport) || isset($opts->rapportcomplet) )
|
||||
if ( isset($opts->rapport) || isset($opts->rapportcomplet) )
|
||||
{
|
||||
$commandesM = new Application_Model_CommandesErreur();
|
||||
if (isset($opts->rapportcomplet)) {
|
||||
@ -129,14 +131,16 @@ if ( isset($opts->rapport) || isset($opts->rapportcomplet) )
|
||||
$infogreffe = new Infogreffe();
|
||||
switch($cmd->type){
|
||||
case 'acte':
|
||||
$path = $infogreffe->actePath($cmd->ref);
|
||||
$fichier = $infogreffe->acteFilename($cmd->siren, $cmd->ref);
|
||||
break;
|
||||
case 'bilan':
|
||||
$fichier = $infogreffe->bilanFilename($cmd->siren, $cmd->ref);
|
||||
$path = $infogreffe->bilanPath($cmd->ref);
|
||||
$fichier = $infogreffe->bilanFilename($cmd->siren, $cmd->ref);
|
||||
break;
|
||||
}
|
||||
//Le fichier existe, alors on a résolu le problème (mauellement ?)
|
||||
if( file_exists(PATH_DATA . '/pdf/' . $fichier) ) {
|
||||
if( file_exists(PATH_DATA . $path . $fichier) ) {
|
||||
$data = array('erreur' => '', 'dateReception' => date('Y-m-d H:i:s'));
|
||||
$where = "siren='".$cmd->siren."' AND type='".$cmd->type."' AND ref='".$cmd->ref."' AND dateCommande='".$cmd->dateCommande."'";
|
||||
$commandesM->update($data, $where);
|
||||
|
@ -604,7 +604,7 @@ class Infogreffe
|
||||
} else {
|
||||
$siren = $depot['num_siren'];
|
||||
}
|
||||
$fichier = $this->pathData.'/pdf/'.$this->acteFilename($siren,$ref);
|
||||
$fichier = $this->pathData.$this->actePath($ref).$this->acteFilename($siren,$ref);
|
||||
if( file_exists($fichier) && filesize($fichier)>0 )
|
||||
{
|
||||
$mode = 'fichier';
|
||||
@ -713,7 +713,7 @@ class Infogreffe
|
||||
}
|
||||
|
||||
//Cas de fichier correspondant à la référence
|
||||
$fichier = $this->pathData.'/pdf/'.$this->bilanFilename($siren,$ref);
|
||||
$fichier = $this->pathData.$this->bilanPath($ref).$this->bilanFilename($siren,$ref);
|
||||
if( file_exists($fichier) && filesize($fichier)>0 )
|
||||
{
|
||||
$mode = 'fichier';
|
||||
@ -725,7 +725,7 @@ class Infogreffe
|
||||
//Si AAAA_sociaux- alors on cherche sans
|
||||
if (preg_match('/^[0-9]{4}_sociaux-/', $ref)){
|
||||
$refR = str_replace('_sociaux-', '_-', $ref);
|
||||
$fichier = $this->pathData.'/pdf/'.$this->bilanFilename($siren,$refR);
|
||||
$fichier = $this->pathData.$this->bilanPath($refR).$this->bilanFilename($siren,$refR);
|
||||
if( file_exists($fichier) && filesize($fichier)>0 )
|
||||
{
|
||||
$mode = 'fichier';
|
||||
@ -736,7 +736,7 @@ class Infogreffe
|
||||
//Si AAAA_- alors on cherche avec
|
||||
} elseif (preg_match('/^[0-9]{4}_-/', $ref)){
|
||||
$refR = str_replace('_-', '_sociaux-', $ref);
|
||||
$fichier = $this->pathData.'/pdf/'.$this->bilanFilename($siren,$refR);
|
||||
$fichier = $this->pathData.$this->bilanPath($refR).$this->bilanFilename($siren,$refR);
|
||||
if( file_exists($fichier) && filesize($fichier)>0 )
|
||||
{
|
||||
$mode = 'fichier';
|
||||
@ -746,14 +746,6 @@ class Infogreffe
|
||||
}
|
||||
}
|
||||
|
||||
//Cas de fichier en acte (a faire disparaitre)
|
||||
$fichier = $this->pathData.'/pdf/acte-'.$siren.'-'.$ref.'.pdf';
|
||||
if( file_exists($fichier) && filesize($fichier)>0 )
|
||||
{
|
||||
$mode = 'fichier';
|
||||
$file_exist = true;
|
||||
$nomode = false;
|
||||
}
|
||||
//Suppression du mode courrier si le mode telechargement existe
|
||||
$modes = $bilan['mode_diffusion'];
|
||||
|
||||
@ -856,16 +848,11 @@ class Infogreffe
|
||||
else { $date = WDate::dateT('Y-m-d', 'Ymd', $result['date_depot']); }
|
||||
|
||||
$ref = $acte['type_acte'].'-'.$date.'-'.$num_gest.'-'.$acte['num_acte'];
|
||||
|
||||
|
||||
$path = $this->actePath($ref);
|
||||
$fichier = $this->acteFilename($siren, $ref);
|
||||
|
||||
//Si le fichier existe, on modifie l'url
|
||||
if( file_exists($this->pathData.'/pdf/'.$fichier) ){
|
||||
$acte['url_acces'] = $fichier;
|
||||
}else{
|
||||
$fichierdl = $this->dl($fichier, $acte['url_acces']);
|
||||
$acte['url_acces'] = $fichierdl;
|
||||
}
|
||||
$fichierdl = $this->dl($path.$fichier, $acte['url_acces']);
|
||||
$acte['url_acces'] = $fichierdl;
|
||||
$result['actes'][] = $acte;
|
||||
}
|
||||
}
|
||||
@ -1053,8 +1040,9 @@ class Infogreffe
|
||||
$items = $this->parsexmlBilansT($xmlReponse);
|
||||
$result = array();
|
||||
$bilan = $items['bilan'];
|
||||
$path = $this->bilanPath($ref);
|
||||
$fichier = $this->bilanFilename($siren, $ref);
|
||||
$fichierdl = $this->dl($fichier, $bilan['url_acces']);
|
||||
$fichierdl = $this->dl($path.$fichier, $bilan['url_acces']);
|
||||
$bilan['url_acces'] = $fichierdl;
|
||||
$result['bilan'][] = $bilan;
|
||||
}
|
||||
@ -1144,6 +1132,11 @@ class Infogreffe
|
||||
{
|
||||
return 'acte-'.$siren.'-'.$ref.'.pdf';
|
||||
}
|
||||
|
||||
function actePath($ref)
|
||||
{
|
||||
return '/pdf/';
|
||||
}
|
||||
|
||||
function bilanRef($bilan)
|
||||
{
|
||||
@ -1161,9 +1154,20 @@ class Infogreffe
|
||||
|
||||
function bilanFilename($siren, $ref)
|
||||
{
|
||||
return 'bilan-'.$siren.'-'.$ref.'.pdf';
|
||||
preg_match('/^([0-9]{4})_([a-z]{0,})-([0-9]{8})/', $ref, $matches);
|
||||
$type = $matches[2];
|
||||
$dateCloture = $matches[3];
|
||||
return 'bilan-'.$siren.'-'.type.'-'.$dateCloture.'.pdf';
|
||||
}
|
||||
|
||||
function bilanPath($ref)
|
||||
{
|
||||
preg_match('/^([0-9]{4})_([a-z]{0,})-([0-9]{8})/', $ref, $matches);
|
||||
$type = $matches[2];
|
||||
$dateCloture = $matches[3];
|
||||
return '/greffes/bilans/'.$type.'/'.substr($dateCloture,0,4).'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Télécharge les fichiers d'infogreffe, et renvoi le nom du fichier ou false
|
||||
* @param string $fichier
|
||||
@ -1173,7 +1177,13 @@ class Infogreffe
|
||||
function dl($fichier, $url, $trace = true)
|
||||
{
|
||||
$return = false;
|
||||
$path = $this->pathData.'/pdf/';
|
||||
$path = $this->pathData;
|
||||
|
||||
$wholePath = dirname($fichier);
|
||||
if ( !is_dir($path.$wholePath) ) {
|
||||
mkdir($path.$wholePath, 0777, true);
|
||||
}
|
||||
|
||||
if(!file_exists($path.$fichier) || !filesize($path.$fichier)>2000)
|
||||
{
|
||||
$erreurDL = '';
|
||||
|
Loading…
Reference in New Issue
Block a user