From 5b1d26febfa0369f05fac5b76bb1bc610b8c63e2 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 5 Nov 2013 10:07:38 +0000 Subject: [PATCH] Merge 2.4 --- .../wkhtmltopdf.php => Scores/Wkhtml/Pdf.php} | 28 ++---- .../WsScore/Entreprise/v0.8/Entreprise.php | 89 +++++++++---------- library/WsScore/Pieces/v0.1/Pieces.php | 3 +- 3 files changed, 50 insertions(+), 70 deletions(-) rename library/{wkhtmltopdf/wkhtmltopdf.php => Scores/Wkhtml/Pdf.php} (65%) diff --git a/library/wkhtmltopdf/wkhtmltopdf.php b/library/Scores/Wkhtml/Pdf.php similarity index 65% rename from library/wkhtmltopdf/wkhtmltopdf.php rename to library/Scores/Wkhtml/Pdf.php index 94843d54..377b1e8d 100644 --- a/library/wkhtmltopdf/wkhtmltopdf.php +++ b/library/Scores/Wkhtml/Pdf.php @@ -1,15 +1,12 @@ pathWkhtml = $c->profil->wkhtmltopdf->path.'/'; + $c = Zend_Registry::get('config'); + $this->wkhtml = $c->profil->wkhtmltopdf->path; } /** @@ -45,24 +42,11 @@ class wkhtmltopdf foreach ( $this->options as $name => $value ) { $options.= ' --'.$name; - if ($value!= '') $options.= ' '.$value; + if ($value!= '') $options.= ' "'.$value.'"'; } } - if (stristr(PHP_OS, 'WIN')) - { - $wkhtmltopdf = 'wkhtmltopdf.exe'; - } - else - { - switch(WKHTMLTOPDF_ARCH) - { - default: - case 'amd64': $wkhtmltopdf = 'wkhtmltopdf-amd64'; break; - case 'i386': $wkhtmltopdf = 'wkhtmltopdf-i386'; break; - } - } - $cmd = $this->pathWkhtml.$wkhtmltopdf.' '.$options.' "'.$fileIn.'" "'.$fileOut.'"'; + $cmd = $this->wkhtml.' '.$options.' "'.$fileIn.'" "'.$fileOut.'"'; exec( $cmd ); return $fileOut; } diff --git a/library/WsScore/Entreprise/v0.8/Entreprise.php b/library/WsScore/Entreprise/v0.8/Entreprise.php index 9d90acfa..3b91cbe3 100644 --- a/library/WsScore/Entreprise/v0.8/Entreprise.php +++ b/library/WsScore/Entreprise/v0.8/Entreprise.php @@ -4011,61 +4011,58 @@ class Entreprise extends WsScore //Initialisation $iDb = new WDB('sdv1'); $tabRet = array(); - debugLog('I',"Liste des banques demandée pour siren $siren", - __LINE__,__FILE__, __FUNCTION__, __CLASS__); + debugLog('I',"Liste des banques demandée pour siren $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__); if (intval($siren)<=1000) { $this->sendError('1010'); } - $res=$iDb->select('banques', 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource', "siren=$siren", false, MYSQL_ASSOC); - $tmp=$iDb->select('fedRib', "codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource", "siren=$siren", false, MYSQL_ASSOC); + $res=$iDb->select('banques', 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource', "siren=$siren", true, MYSQL_ASSOC); + $tmp=$iDb->select('fedRib', "codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource", "siren=$siren", true, MYSQL_ASSOC); $res=array_merge($res, $tmp); - foreach ($res as $tabBanque){ - $dateSource=$tabBanque['dateSource']; - $codBanque=$tabBanque['codeBanque']; - $codGuichet=$tabBanque['codeGuichet']; - $libBanque=trim($tabBanque['libBanqueGuichet']); - $found=false; + foreach ($res as $tabBanque) + { + $dateSource = $tabBanque['dateSource']; + $codBanque = $tabBanque['codeBanque']; + $codGuichet = $tabBanque['codeGuichet']; + $libBanque = trim($tabBanque['libBanqueGuichet']); + $found = false; $adrBanque1=$adrBanque2=$adrBanqueCP=$adrBanqueVille=''; - if ($codBanque>0 && $codGuichet>0 && - $dateSource>(date('Y')-4)*10000+101 && - $dateSourceselect('insee.BDF_Etabs b, insee.BDF_Guichets g', - 'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville', "g.bdfFibCodeEtab=$codBanque AND g.bdfFibCodeGuichet=$codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab", - false, MYSQL_ASSOC); - if (isset($tmp[0])){ - $libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']); - $adrBanque1=$tmp[0]['adresse1']; - $adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']); - $adrBanqueCP=$tmp[0]['CP']; - $adrBanqueVille=$tmp[0]['Ville']; - $found=true; - }; - } - if (!$found && $codBanque>0 && - $dateSource>(date('Y')-4)*10000+101 && - $dateSourceselect('insee.BDF_Etabs', "bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville", "bdfFibCodeEtab=$codBanque", false, MYSQL_ASSOC); - if (isset($tmp[0])){ - $libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']); - $adrBanque1=$tmp[0]['adresse1']; - $adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']); - $adrBanqueCP=$tmp[0]['CP']; - $adrBanqueVille=$tmp[0]['Ville']; - } else continue; - } else continue; + if ( $codBanque>0 && $codGuichet>0 ) { + $tmp = $iDb->select('insee.BDF_Etabs b, insee.BDF_Guichets g', + 'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville', "g.bdfFibCodeEtab=$codBanque AND g.bdfFibCodeGuichet=$codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab", + true, MYSQL_ASSOC); + if (count($tmp)>0) { + $found = true; + + $banque = new Banque(); + $banque->codeBanque = $codBanque; + $banque->codeGuichet = $codGuichet; + $banque->libBanque = trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']); + $banque->adresse1 = $tmp[0]['adresse1']; + $banque->adresse2 = trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']); + $banque->cp = $tmp[0]['CP']; + $banque->ville = $tmp[0]['Ville']; + $tabRet[] = $banque; + } + } + + if ($found===false && $codBanque>0 ) { + $tmp = $iDb->select('insee.BDF_Etabs', "bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville", "bdfFibCodeEtab=$codBanque", true, MYSQL_ASSOC); + if (count($tmp)>0) { + $banque = new Banque(); + $banque->codeBanque = $codBanque; + $banque->codeGuichet = $codGuichet; + $banque->libBanque = trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']); + $banque->adresse1 = $tmp[0]['adresse1']; + $banque->adresse2 = trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']); + $banque->cp = $tmp[0]['CP']; + $banque->ville = $tmp[0]['Ville']; + $tabRet[] = $banque; + } + } - $banque = new Banque(); - $banque->codeBanque = $codBanque; - $banque->codeGuichet = $codGuichet; - $banque->libBanque = $libBanque; - $banque->adresse1 = $adrBanque1; - $banque->adresse2 = $adrBanque2; - $banque->cp = $adrBanqueCP; - $banque->ville = $adrBanqueVille; - $tabRet[] = $banque; } debugLog('I',"Liste des banques pour siren $siren : ".count($tabRet).' banques',__LINE__,__FILE__, __FUNCTION__, __CLASS__); diff --git a/library/WsScore/Pieces/v0.1/Pieces.php b/library/WsScore/Pieces/v0.1/Pieces.php index 9ed4c8d9..7add878d 100644 --- a/library/WsScore/Pieces/v0.1/Pieces.php +++ b/library/WsScore/Pieces/v0.1/Pieces.php @@ -78,8 +78,7 @@ class Pieces extends WsScore } //Génération du PDF - require_once 'wkhtmltopdf/wkhtmltopdf.php'; - $pdf = new wkhtmltopdf(); + $pdf = new Scores_Wkhtml_Pdf(); $fileOut = $pdf->exec($file, $filepdf); if ( !file_exists($filepdf) ) {