From 7f3bb2c3fbccaa7218503b60933c475dbe8f8028 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 7 Aug 2015 13:33:14 +0000 Subject: [PATCH] Fichier CRM --- application/controllers/FichierController.php | 2 +- .../Application/Controller/Plugin/Auth.php | 3 +- library/WsScore/Interne/v0.6/Service.php | 43 ++++++++----------- scripts/build/classmap.php | 4 +- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/application/controllers/FichierController.php b/application/controllers/FichierController.php index 973d20e2..8b8932bc 100644 --- a/application/controllers/FichierController.php +++ b/application/controllers/FichierController.php @@ -168,7 +168,7 @@ class FichierController extends Zend_Controller_Action $fichier = $this->getRequest()->getParam('fichier'); - $content_type = 'application/x-bzip2'; + $content_type = 'application/x-bzip'; // --- Envoi du fichier sur la sortie standard $filepath = $directory.'/'.$fichier; if ( file_exists($filepath) ) { diff --git a/library/Application/Controller/Plugin/Auth.php b/library/Application/Controller/Plugin/Auth.php index 0380d6af..6ba627e6 100644 --- a/library/Application/Controller/Plugin/Auth.php +++ b/library/Application/Controller/Plugin/Auth.php @@ -24,7 +24,8 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract || ( $controller == 'fichier' && $action == 'kbis' ) || ( $controller == 'fichier' && $action == 'csv' ) || ( $controller == 'fichier' && $action == 'associations' ) - || ( $controller == 'fichier' && $action == 'greffes' )) { + || ( $controller == 'fichier' && $action == 'greffes' ) + || ( $controller == 'fichier' && $action == 'crm' )) { $checkAuth = false; } diff --git a/library/WsScore/Interne/v0.6/Service.php b/library/WsScore/Interne/v0.6/Service.php index 95b78678..e0330314 100644 --- a/library/WsScore/Interne/v0.6/Service.php +++ b/library/WsScore/Interne/v0.6/Service.php @@ -1478,72 +1478,65 @@ class Interne extends Scores_Ws_Server public function getListeFichierSurv($login, $ref='*', $nomFic='') { $this->authenticate(); - - $path = '/mnt/ftp'; + $c = Zend_Registry::get('config'); + $path = "/mnt/clients/oldcrm"; if (empty($ref)) $ref = '*'; if (empty($nomFic)) $nomFic = ''; $error = new ErrorType(); $tabFichier=$tabDates=array(); $numAbo=substr($ref, 0,5); if (strtolower($login)=='vwbank') { - $repClient='volkswagen bank'; $ficClient='surveillanceBodacc_SURBODPRDCFTVWBANK'; $numAbo=$ref='19300'; } elseif (substr($login,0,6)=='apicil') { - $repClient='apicil'; $ficClient='surveillanceBodacc_SURBODPRDCFTAPICIL'; $numAbo=$ref=''; } elseif (strtolower($login)=='omni04') { - $repClient='aggm mederic '; $ficClient='surveillanceBodacc_SURBODPRDFTSOMNIREP'; $numAbo=$ref=''; } elseif (strtolower($login)=='bodacca3m') { - $repClient='aggm mederic '; $ficClient='surveillanceBodacc_SURBODPRDFTSMEDERIC'; $numAbo=$ref=''; } elseif (strtolower($login)=='bodaccomni') { - $repClient='aggm mederic '; $ficClient='surveillanceBodacc_SURBODPRDFTSOMNIREP'; $numAbo=$ref=''; } elseif (strtolower($login)=='bodacccrr') { - $repClient='aggm mederic '; $ficClient='surveillanceBodacc_SURBODPRDFTSCRR'; $numAbo=$ref=''; } elseif (strtolower($login)=='cpcambr13' || strtolower($login)=='cpcambr14') { - $repClient='cpcam des bouches du rhône'; $ficClient='diffusionBodacc_DIFBODPRDMAICPCAM13'; $numAbo=$ref=''; } elseif (strtolower($login)=='frbsurveillance'){ - $repClient='france boissons'; $ficClient='surveillanceBodacc_SURBODPRDFTPFBOISSON'; } else { - $repClient='cnasea'; $ficClient='surveillanceBodacc_SURBODTSTFTSCNASEA'; } // --- Lecture du repertoire - $dh = opendir($path."/$repClient/"); + $dh = opendir($path."/"); if (!$dh) { $error->errnum = 1; $error->errmsg = "Impossible d'ouvrir le dossier client"; } else { while (false !== ($filename = readdir($dh))) { - if ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,42)==$ficClient.$numAbo) { + if($filename=='.' && $filename=='..') + continue; + if (substr($filename, -4)=='.csv' && substr($filename,0,42)==$ficClient.$numAbo) { $tabFichier[] = $filename; $tabDates[]=substr($filename,43,8); $tabClients[]=substr($filename,0,42); } - elseif ($ref=='*' && $filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)<>'_') { + elseif ($ref=='*' && substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)<>'_') { $tabFichier[] = $filename; $tabDates[]=substr($filename,43,8); $tabClients[]=substr($filename,0,42); } - elseif ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)=='_' && $repClient=='apicil') { + elseif (substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)=='_') { $tabFichier[] = $filename; $tabDates[]=substr($filename,38,8); $tabClients[]=substr($filename,0,37); } - elseif ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,38)==$ficClient && substr($filename,38,1)=='_' && $repClient=='aggm mederic ') { + elseif (substr($filename, -4)=='.csv' && substr($filename,0,38)==$ficClient && substr($filename,38,1)=='_') { $tabFichier[] = $filename; $tabDates[]=substr($filename,39,8); $tabClients[]=substr($filename,0,38); @@ -1563,21 +1556,21 @@ class Interne extends Scores_Ws_Server // Boucle sur les dates de livraison foreach ($tabDates as $dateFic) { if (strlen($dateFic)<>8) continue; - if (!file_exists($path."/$repClient/$ficClient".'_'."$dateFic.csv") || - filesize($path."/$repClient/$ficClient".'_'."$dateFic.csv")==0) { + if (!file_exists($path."/$ficClient".'_'."$dateFic.csv") + || filesize($path."/$ficClient".'_'."$dateFic.csv")==0) { - $fpW=fopen($path."/$repClient/$ficClient".'_'."$dateFic.csv",'w'); + $fpW=fopen($path."/$ficClient".'_'."$dateFic.csv",'w'); $entete=true; // Boucle afin de vérifier si on est sur le bon client foreach ($tabClients as $nomClient) { - $dh = opendir($path."/$repClient/"); + $dh = opendir($path."/"); while (false !== ($filename = readdir($dh))) { if (substr($filename,0,51)==$nomClient.'_'.$dateFic && substr($filename,-4)=='.csv') { $fichier=$filename; //break; } } - $fpR=fopen($path."/$repClient/$fichier",'r'); + $fpR=fopen($path."/".$fichier,'r'); //return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>array(($fichier)));//die; if ($fpR) { while (!feof($fpR)) { @@ -1587,8 +1580,9 @@ class Interne extends Scores_Ws_Server $entete=false; } elseif (substr($ligne,0,5)<>'Siren' && trim($ligne)<>'') { - fwrite($fpW, strtr($nomClient, array('surveillanceBodacc_SURBODTSTFTS'=>'', - 'surveillanceBodacc_SURBODPRDCFT'=>'')).';'.$ligne.EOL); + fwrite($fpW, strtr($nomClient, array( + 'surveillanceBodacc_SURBODTSTFTS'=>'', + 'surveillanceBodacc_SURBODPRDCFT'=>'')).';'.$ligne.EOL); } } fclose($fpR); @@ -1603,10 +1597,9 @@ class Interne extends Scores_Ws_Server rsort($tabFichier); if ($nomFic!='') { - $c = Zend_Registry::get('config'); $directory = $c->profil->path->files; if (!file_exists($directory."/$nomFic.bz2") || filesize($directory."/$nomFic.bz2")<=14) { - $string = file_get_contents($path."/$repClient/$nomFic"); + $string = file_get_contents($path."/$nomFic"); $bz = bzopen($directory."/$nomFic.bz2",'w'); if ($bz) { bzwrite($bz, $string, strlen($string)); diff --git a/scripts/build/classmap.php b/scripts/build/classmap.php index 88eb73d0..7e8a86ed 100644 --- a/scripts/build/classmap.php +++ b/scripts/build/classmap.php @@ -1,11 +1,11 @@