Compare commits

...

2 Commits

Author SHA1 Message Date
Michael RICOIS
abd03f95df issue #0001090 : Integrate all changes from branch 2.3 2012-11-03 14:08:33 +00:00
Michael RICOIS
9cc18d0d02 issue #0001090 : Bilans Directory structure 2012-11-02 20:24:57 +00:00
6 changed files with 302 additions and 120 deletions

View File

@ -14,7 +14,7 @@ class DashboardController extends Zend_Controller_Action
'a1D' => 'AUGMENTATION ET REDUCTION CAPITAL',
'a25' => 'AUGMENTATION DE CAPITAL',
'a26' => 'REDUCTION DE CAPITAL',
'a31' => 'TRANSFERT SIEGE SOCIAL HORS RESSORT O',
'a31' => 'TRANSFERT SIEGE SOCIAL HORS RESSORT',
'a33' => 'CHANGEMENT DE GERANT',
'a39' => 'CHANGEMENT DE COMMISSAIRE AUX COMPTES',
'a77' => 'CONTINUATION MALGRE LA PERTE DE LA MOITIE DU CAPITAL',
@ -149,14 +149,10 @@ class DashboardController extends Zend_Controller_Action
'url' => $this->view->url(array('action'=>'clients')),
),
1 => array(
'libelle' => 'Créer un client',
'url' => $this->view->url(array('action'=>'client')),
),
2 => array(
'libelle' => 'Gestion des commandes',
'url' => $this->view->url(array('action'=>'commandes')),
),
3 => array(
2 => array(
'libelle' => 'Gestion des fichiers nouveautés',
'url' => $this->view->url(array('action'=>'newform')),
),
@ -395,17 +391,16 @@ class DashboardController extends Zend_Controller_Action
$document = 'Bilan de '.$matches[1];
require_once 'Infogreffe/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(
@ -537,22 +532,29 @@ class DashboardController extends Zend_Controller_Action
$idClient = $request->getParam('idClient', false);
$titre = 'CREATION NOUVEAU CLIENT';
$submitValue = 'Créer le client';
$ws = new WsScores();
if ($idClient!==false){
$ws = new WsScores();
$reponse = $ws->getListeClients($idClient);
$InfosClient = $reponse->result->item[0];
$titre = 'EDITION CLIENT';
$submitValue = 'Modifier le client';
}
$ws = new WsScores();
$reponse = $ws->getListeDroits();
$wsdroits = $reponse->item;
$wsdroits = array();
foreach ($reponse->item as $tmp) {
$wsdroits[$tmp->code] = $tmp->desc;
}
$this->view->assign('wsdroits', $wsdroits);
$reponse = $ws->getCategory();
$wscategory = $reponse->item;
$this->view->assign('wscategory', $wscategory);
$this->view->assign('idClient', $idClient);
$this->view->assign('InfosClient', $InfosClient);
$this->view->assign('titre', $titre);
$this->view->assign('submitValue', $submitValue);
$this->view->assign('wsdroits', $wsdroits);
}
/**
@ -600,7 +602,7 @@ class DashboardController extends Zend_Controller_Action
$this->view->headScript()->appendFile('/themes/default/scripts/user.js', 'text/javascript');
$request = $this->getRequest();
$op = $request->getParam('op');
$idClient = $request->getParam('idClient');
$login = $request->getParam('login');
@ -610,6 +612,11 @@ class DashboardController extends Zend_Controller_Action
require_once 'Scores/WsScores.php';
$ws = new WsScores();
//Liste des catégories d'accès
$reponse = $ws->getCategory();
$wscategory = $reponse->item;
$this->view->assign('wscategory', $wscategory);
//Liste de tous les droits
$listeDroits = $ws->getListeDroits();
$droitsLib = array();
@ -644,7 +651,12 @@ class DashboardController extends Zend_Controller_Action
require_once 'Scores/WsScores.php';
$ws = new WsScores();
//Liste des catégories d'accès
$reponse = $ws->getCategory();
$wscategory = $reponse->item;
$this->view->assign('wscategory', $wscategory);
//Liste de tous les droits
$listeDroits = $ws->getListeDroits();
$droitsLib = array();
@ -712,14 +724,16 @@ class DashboardController extends Zend_Controller_Action
break;
case 'save':
$action = 'new'; //update
$options = $request->getParam('frmOptions', '');
$action = $options['action'];
$idClient = $options['idClient'];
$login = $options['login'];
require_once 'Scores/WsScores.php';
$ws = new WsScores();
$ws->setInfosLogin($login, $action, $options);
$this->_redirect('/dashboard/users/idClient/'.$idClient);
break;
}
}
/**
@ -793,5 +807,111 @@ class DashboardController extends Zend_Controller_Action
echo json_encode($rep);
}
}
public function prestationsAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
$this->view->assign('idClient', $idClient);
}
public function prestationAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
$this->view->assign('idClient', $idClient);
$submitValue = "Créer";
$id = $request->getParam('id');
if ($id!=null) {
//Recup param prestation
$submitValue = "Modifier";
}
$this->view->assign('submitValue', $submitValue);
}
public function prestationsaveAction(){}
public function tarifsAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
$ws = new WsScores();
$tarifs = $ws->getClientTarifs($idClient);
$this->view->assign('tarifs', $tarifs);
$this->view->assign('idClient', $idClient);
}
public function tarifAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
if ($request->isPost()){
$log = $request->getParam('log');
$service = $request->getParam('service');
$type = $request->getParam('type');
$priceUnit = $request->getParam('priceUnit');
$date = $request->getParam('date');
$duree = $request->getParam('duree');
$doublon = $request->getParam('doublon');
$ws = new WsScores();
$result = $ws->setClientTarif($idClient, $log, $service, $type, $priceUnit, $date, $duree, $doublon);
if(is_int($result)) {
$url = $this->view->url(array('controller'=>'dashboard','action'=>'tarifs','idClient'=>$idClient));
$this->redirect($url);
} else {
$this->view->assign('log', $log);
$this->view->assign('service', $service);
$this->view->assign('type', $type);
$this->view->assign('priceUnit', $priceUnit);
$this->view->assign('date', $date);
$this->view->assign('duree', $duree);
$this->view->assign('doublon', $doublon);
$this->view->assign('error', $result);
}
}
$this->view->assign('idClient', $idClient);
}
public function servicesAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
$ws = new WsScores();
$services = $ws->getServices($idClient);
$this->view->assign('services', $services);
$this->view->assign('idClient', $idClient);
}
public function serviceAction()
{
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
if ($request->isPost()){
$code = $request->getParam('code');
$label = $request->getParam('label');
$ws = new WsScores();
$result = $ws->setService($idClient, $code, $label);
if(is_int($result)) {
$url = $this->view->url(array('controller'=>'dashboard','action'=>'services','idClient'=>$idClient));
$this->redirect($url);
} else {
$this->view->assign('code', $code);
$this->view->assign('label', $label);
$this->view->assign('error', $result);
}
}
$this->view->assign('idClient', $idClient);
}
}

View File

@ -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-[0-9]{9}-(consolides|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';

View File

@ -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 'Infogreffe/Infogreffe.php';
$infogreffe = new Infogreffe();
$path = $infogreffe->bilanPath($ref);
$file = $infogreffe->bilanFilename($siren, $ref);
$href = '/fichier/pdf/'.$file;
echo '<br/><a href="'.$href.'" target="_blank">Ouvrir le bilan millésime '.$info['type'].'</a>';
break;
@ -833,8 +830,12 @@ class PiecesController extends Zend_Controller_Action
$repErreur = $erreur->fetchAll($sql)->toArray();
if (count($repErreur)>0){
//Téléchagement
$fichier = 'bilan-'.$siren.'-'.$ref.'.pdf';
if (infogreffe_dl($fichier, $repErreur[0]['url'], false)) {
require_once 'Infogreffe/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);
echo '<br/><a href="/fichier/pdf/'.$fichier.'" target="_blank">Ouvrir le fichier '.$info['type_lib'].' </a>';
@ -844,7 +845,8 @@ class PiecesController extends Zend_Controller_Action
} else {
$infogreffe = new Infogreffe();
require_once 'Infogreffe/Infogreffe.php';
$infogreffe = new Infogreffe();
$reponse = $infogreffe->getGreffeBilans($siren, $vecteur, $ref);
if(empty($reponse['error'])) {
@ -862,6 +864,7 @@ class PiecesController extends Zend_Controller_Action
foreach($items as $item) {
if($item['url_acces']!==false) {
$ws->setLog('greffe_bilans', $siren, 0, $ref);
$path = $infogreffe->bilanPath($ref);
$href = '/fichier/pdf/'.$item['url_acces'];
echo '<br/><a href="'.$href.'" target="_blank">Ouvrir le bilan millésime '.$item['millesime'].'</a>';
} else {
@ -1639,35 +1642,34 @@ class PiecesController extends Zend_Controller_Action
}
/**
* Affiche les privilèges en surveillance
*/
public function privilegesAction()
{
$request = $this->getRequest();
$type = $request->getParam('type', null);
$siren = substr($this->siret, 0, 9);
$detail = false;
if (!empty($type)){
$detail = true;
}
$session = new SessionEntreprise($this->siret, $this->id);
$ws = new WsScores();
if ($detail){
$infos = $ws->getPrivilegesDetail($siren, array($type));
} else {
$infos = $ws->getPrivilegesCumul($siren);
}
Zend_Registry::get('firebug')->info($infos);
$privileges = $infos->result->item;
$this->view->assign('privileges', $privileges);
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$user = new Scores_Utilisateur();
$this->view->assign('surveillance', $user->checkPerm('survpriv'));
}
/**
* Affiche les privilèges en surveillance
*/
public function privilegesAction()
{
$request = $this->getRequest();
$type = $request->getParam('type', null);
$siren = substr($this->siret, 0, 9);
$detail = false;
if (!empty($type)){
$detail = true;
}
$session = new SessionEntreprise($this->siret, $this->id);
$ws = new WsScores();
if ($detail){
$infos = $ws->getPrivilegesDetail($siren, array($type));
$this->view->assign('detail', $detail);
} else {
$infos = $ws->getPrivilegesCumul($siren);
}
Zend_Registry::get('firebug')->info($infos);
$this->view->assign('privileges', $infos->result->item);
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$user = new Scores_Utilisateur();
$this->view->assign('surveillance', $user->checkPerm('survpriv'));
}
}

View File

@ -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 'Infogreffe/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 {

View File

@ -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)");
@ -70,17 +70,19 @@ if ( isset($opts->reprise) )
foreach($repErreur as $cmd)
{
require_once 'Scores/Infogreffe.php';
require_once 'Infogreffe/Infogreffe.php';
$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)) {
@ -125,18 +127,20 @@ if ( isset($opts->rapport) || isset($opts->rapportcomplet) )
$emailTxt.= '<tbody>';
foreach($repErreur as $cmd)
{
require_once 'Scores/Infogreffe.php';
require_once 'Infogreffe/Infogreffe.php';
$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);

View File

@ -604,12 +604,27 @@ 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);
Zend_Registry::get('firebug')->info($fichier);
if( file_exists($fichier) && filesize($fichier)>0 )
{
$mode = 'fichier';
$file_exist = true;
}
//As type_acte change, try to detect file by a pattern
//acte-388048308-ACSSPRH-20090630-9201-00-B-01374-30975-02.pdf
$filePattern = $this->acteFilename($siren,$ref);
$posBegin = 15;
$posEnd = strpos($filePattern, '-', $posBegin);
$filePattern = substr_replace($filePattern, '*', $posBegin, $posEnd-$posBegin);
Zend_Registry::get('firebug')->info($filePattern);
$detectedFiles = glob($this->pathData.$this->actePath($ref).$filePattern);
if ($detectedFiles!==false && count($detectedFiles)>0) {
$ref = str_replace('.pdf', '',substr(basename($detectedFiles[0]),15));
$mode = 'fichier';
$file_exist = true;
}
//Génération date (date_acte peut être vide)
if(!empty($acte['date_acte'])){ $date = WDate::dateT('Y-m-d', 'Ymd', $acte['date_acte']); }
@ -711,9 +726,10 @@ class Infogreffe
} else {
$siren = $bilan['num_siren'];
}
//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);
Zend_Registry::get('firebug')->info('Fichier : '.$fichier);
if( file_exists($fichier) && filesize($fichier)>0 )
{
$mode = 'fichier';
@ -725,7 +741,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 +752,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 +762,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 +864,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 +1056,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 +1148,11 @@ class Infogreffe
{
return 'acte-'.$siren.'-'.$ref.'.pdf';
}
function actePath($ref)
{
return '/pdf/';
}
function bilanRef($bilan)
{
@ -1161,9 +1170,26 @@ 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];
if ($type=='') {
$type = 'sociaux';
}
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];
if ($type=='') {
$type = 'sociaux';
}
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 +1199,16 @@ 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);
}
Zend_Registry::get('firebug')->info($fichier);
Zend_Registry::get('firebug')->info($url);
if(!file_exists($path.$fichier) || !filesize($path.$fichier)>2000)
{
$erreurDL = '';
@ -1187,13 +1222,18 @@ class Infogreffe
}
if( ($page['code']!=408 || $page['code']!=400) && substr($body,0,4)=='%PDF') {
//Ecriture du fichier sur le serveur en local
file_put_contents($path.$fichier, $body);
$return = $fichier;
$erreurDL = '';
Zend_Registry::get('firebug')->info($path.$fichier);
if ( file_put_contents($path.$fichier, $body) ) {
$return = basename($fichier);
$erreurDL = '';
} else {
$return = false;
$erreurDL = "Erreur lors de l'ecriture du fichier";
}
}
if ($trace) {
$erreur = new Application_Model_CommandesErreur();
preg_match('/^(acte|bilan)-([0-9]{9})-(.*)\.pdf$/', $fichier, $ref);
preg_match('/(acte|bilan)-([0-9]{9})-(.*)\.pdf$/', $fichier, $ref);
$data = array(
'siren' => $ref[2],
'type' => $ref[1],
@ -1205,7 +1245,7 @@ class Infogreffe
$erreur->insert($data);
}
} else {
$return = $fichier;
$return = basename($fichier);
}
return $return;
}