Library Update

This commit is contained in:
Michael RICOIS 2017-02-10 11:57:34 +01:00
parent 55a21524b0
commit b550386422
16 changed files with 1024 additions and 464 deletions

View File

@ -86,21 +86,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
*/
protected $logger;
protected $iDb;
/**
* MInsee
*/
public function __construct($db = null)
{
if ($db === null) {
$this->iDb = new Metier_Util_Db();
} else {
$this->iDb = $db;
}
$this->conn = Zend_Registry::get('doctrine');
$this->iBodacc = new Metier_Bodacc_MBodacc();
}
@ -1798,33 +1789,37 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$date = $this->companyEvenDateStop;
}
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$sql = $db->select()
->from(array('e'=>'insee_even'), array(
'CONCAT(LPAD(e.insSIREN,9,0), LPAD(e.insNIC,5,0)) AS Siret',
'LPAD(e.insSIREN,9,0) AS Siren',
'LPAD(e.insNIC,5,0) AS Nic',
'insSIEGE AS Siege',
'insNOMEN AS Nom',
'insCODPOS AS CP',
'insCJ AS FJ',
'insAPEN700 AS NafEnt',
'insAPEN700 AS NafEtab',
'insTEFEN AS EffEnTr',
'insEFENCENT AS Effectif',
'insDCRET AS DateCreaEt',
'insDCREN AS DateCreaEn',
'insEVE',
), 'insee')
->joinLeft(array('i'=>'insee_notices'), 'i.insSIREN=e.insSIREN AND i.insNIC=e.insNIC', array(
'insRECME AS RECME',
), 'insee')
->where('e.insSIREN = ?', $siren)
->where('idFlux < ?', $date)
->order('idFlux DESC')->order('insSIEGE DESC')->limit(1);
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
if ($result !== null) {
$identite = $result;
$sql = "SELECT CONCAT(LPAD(e.insSIREN,9,0), LPAD(e.insNIC,5,0)) AS Siret,
LPAD(e.insSIREN,9,0) AS Siren,
LPAD(e.insNIC,5,0) AS Nic,
e.insSIEGE AS Siege,
e.insNOMEN AS Nom,
e.insCODPOS AS CP,
e.insCJ AS FJ,
e.insAPEN700 AS NafEnt,
e.insAPEN700 AS NafEtab,
e.insTEFEN AS EffEnTr,
e.insEFENCENT AS Effectif,
e.insDCRET AS DateCreaEt,
e.insDCREN AS DateCreaEn,
e.insEVE,
i.insRECME AS RECME
FROM insee.insee_even e
LEFT OUTER JOIN insee.insee_notices i ON (i.insSIREN=e.insSIREN AND i.insNIC=e.insNIC)
WHERE e.insSIREN=:siren AND idFlux<:date ORDER BY idFlux DESC, insSIEGE DESC LIMIT 0,1";
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->bindValue('date', $date);
$stmt->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmt->rowCount() > 0) {
$identite = $stmt->fetch(\PDO::FETCH_ASSOC);
}
// --- Recherche dans le stock
else {
@ -1834,31 +1829,37 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
break;
}
}
$sql = $db->select()
->from(array('e'=>$notice), array(
'CONCAT(LPAD(SIREN,9,0), LPAD(NIC,5,0)) AS Siret',
'LPAD(SIREN,9,0) AS Siren',
'LPAD(NIC,5,0) AS Nic',
'SIEGE AS Siege',
'NOMEN_LONG AS Nom',
'CODPOS AS CP',
'CJ AS FJ',
'APEN700 AS NafEnt',
'APEN700 AS NafEtab',
'TEFEN AS EffEnTr',
'EFENCENT AS Effectif',
'DCRET AS DateCreaEt',
'insDCREN AS DateCreaEn',
), 'historiques')
->joinLeft(array('i'=>'insee_notices'), 'i.insSIREN=e.SIREN AND i.insNIC=e.NIC', array(
'insRECME AS RECME',
), 'insee')
->where('e.insSIREN = ?', $siren)
->where('idFlux < ?', $date)
->order('idFlux DESC')->order('insSIEGE DESC')->limit(1);
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
if ($result !== null) {
$identite = $result;
$sql = "SELECT CONCAT(LPAD(e.SIREN,9,0), LPAD(e.NIC,5,0)) AS Siret,
LPAD(e.SIREN,9,0) AS Siren,
LPAD(e.NIC,5,0) AS Nic,
e.SIEGE AS Siege,
e.NOMEN_LONG AS Nom,
e.CODPOS AS CP,
e.CJ AS FJ,
e.APEN700 AS NafEnt,
e.APEN700 AS NafEtab,
e.TEFEN AS EffEnTr,
e.EFENCENT AS Effectif,
e.DCRET AS DateCreaEt,
insDCREN AS DateCreaEn
i.insRECME AS RECME
FROM insee.$notice e
LEFT OUTER JOIN insee.insee_notices i ON (i.insSIREN=e.SIREN AND i.insNIC=e.NIC)
WHERE e.insSIREN=:siren AND idFlux<:date ORDER BY idFlux DESC, insSIEGE DESC LIMIT 0,1";
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->bindValue('date', $date);
$stmt->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmt->rowCount() > 0) {
$identite = $stmt->fetch(\PDO::FETCH_ASSOC);
}
}
if (count($identite) > 0) {
@ -1881,15 +1882,22 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
}
// --- Capital
$sql = $db->select()
->from('rncs_modifs', array('valeur'), 'jo')
->where('champs = ?', 'capitalMontant')
->where('siren = ? ', $siren)
->where('flux < ?', $date)
->order('flux DESC')->limit(1);
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_OBJ);
$sql = "SELECT valeur FROM jo.rncs_modifs
WHERE champs='capitalMontant' AND siren=:siren AND flux<:date
ORDER BY flux DESC LIMIT 0,1";
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->bindValue('date', $date);
$stmt->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$identite['Capital'] = '';
if ($result !== null) {
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$identite['Capital'] = $result->valeur;
}
@ -2239,7 +2247,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$iTva = new Metier_Partenaires_MTva();
$iTva->setCompanyId($siren);
$iTva->setRemote();
if ($tabInsee['ACTIF']==1 && (date('H')<10 || date('H')>=18)) {
$iTva->setRemote();
}
$iTva->getTVA();
$vatNumber = $iTva->vatNumber;
$vatDefined = $iTva->vatDefined;
@ -4869,13 +4879,42 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
*/
public function getAnnoncesLegalesPlan($type, $fj, $annonce)
{
// --- Bodacc
if ($type == 'bodacc') {
$tabEven = explode(';', $annonce['typeEven']);
foreach ($tabEven as $even) {
$this->matchPlanDuree($even, $annonce['dateJugement'], $annonce['annonce']);
}
}
// --- Annonce
if ($type == 'annonce') {
$this->matchPlanDuree($annonce['typeEven'], $annonce['dateJugement'], $annonce['annonce']);
}
// --- Historique
if ($type == 'histo') {
$this->matchPlanDuree($annonce['CODEVE'], $annonce['DATE'], $annonce['annonceTxt']);
}
}
/**
*
*/
protected function matchPlanDuree($eve, $date, $txt)
{
if ($this->debug) {
file_put_contents('procol.log', "MATCH DUREE PLAN : ", FILE_APPEND);
}
$evenDetect = array(
'75', // Histo
'1407', // Modification de plan
'1409', // Modification du plan de continuation
'1413', // Arrêt du plan de continuation
'1414', // Arrêt du plan de redressement
'1101', // Arrêt du plan de sauvegarde
);
$fjDetect = array(
16,1600, // Exploitant agricole
63,6316,6317,6318, // Société coopérative agricole
@ -4885,80 +4924,41 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
6597,6598,
);
// --- Bodacc
if ($type == 'bodacc') {
$tabEven = explode(';', $annonce['typeEven']);
foreach ($tabEven as $even) {
if (intval($even)!=0) {
if (($this->dureePlan==0 || $this->dureePlan==120) && in_array($even, $evenDetect)) {
if ($this->debug) {
file_put_contents('procol.log', "BODACC MATCH DUREE PLAN \n", FILE_APPEND);
}
// --- Lecture dureePlan dans annonce
$this->debutPlan = str_replace('-', '', $annonce['dateJugement']); // SSAAMMJJ
if (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+ans?/Uisu', $annonce['annonce'], $matches)) {
$this->dureePlan = $matches[1]*12; // 10 ans = 120 mois
}
// --- Duree du Plan par défaut sur FJ et par défaut
if ($this->dureePlan<1 || $this->dureePlan>120) {
if (in_array($fj, $fjDetect)) {
$this->dureePlan = 180; // 15 ans
} else {
$this->dureePlan = 120; // 10 ans = 120 mois
}
}
$this->finPlan = Metier_Util_Date::period2Days($this->debutPlan, $this->dureePlan.' mois');
}
}
}
}
// --- Historique
if ($type == 'histo') {
if (($this->dureePlan==0 || $this->dureePlan==120) && $annonce['CODEVE']==75) { // Modification de plan
$this->debutPlan = $annonce['DATE']; // SSAAMMJJ
if (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+ans?/Uisu', $annonce['annonceTxt'], $matches)) {
if (in_array($eve, $evenDetect)) {
if (($this->dureePlan == 0 || $this->dureePlan == 120)) {
// --- Lecture dureePlan dans annonce
$this->debutPlan = str_replace('-', '', $date); // SSAAMMJJ
if (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+ans?/Uisu', $txt, $matches)) {
$this->dureePlan = $matches[1]*12; // 10 ans = 120 mois
if ($this->debug) {
file_put_contents('procol.log', "HISTO MATCH DUREE PLAN \n", FILE_APPEND);
}
}
if (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+mois?/Uisu', $txt, $matches)) {
$this->dureePlan = $matches[1];
}
// --- Duree du Plan par défaut sur FJ et par défaut
if ($this->dureePlan<1 || $this->dureePlan>120) {
if ($this->dureePlan < 1 || $this->dureePlan > 120) {
if (in_array($fj, $fjDetect)) {
$this->dureePlan = 180; // 15 ans
} else {
$this->dureePlan = 120; // 10 ans = 120 mois
}
}
if ($this->debug) {
file_put_contents('procol.log', $this->dureePlan." mois", FILE_APPEND);
}
$this->finPlan = Metier_Util_Date::period2Days($this->debutPlan, $this->dureePlan.' mois');
}
}
// --- Annonce
if ($type == 'annonce') {
if (($this->dureePlan<1 || $this->dureePlan==120) && in_array($annonce['typeEven'], $evenDetect)) {
$this->debutPlan = str_replace('-', '', $annonce['dateJugement']); // SSAAMMJJ
if (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+ans?/Uisu', $annonce['annonce'], $matches)) {
$this->dureePlan = $matches[1]*12; // 10 ans = 120 mois
} elseif (preg_match('/dur.e(?:.*)plan(?:.*)(\d+)\s+ans?/Uisu', $annonce['annonce'], $matches)) {
$this->dureePlan = $matches[1]*12; // 10 ans = 120 mois
}
if ($this->dureePlan<1 || $this->dureePlan>120) {
if (in_array($fj, $fjDetect)) {
$this->dureePlan = 180; // 15 ans
} else {
$this->dureePlan = 120; // 10 ans = 120 mois
}
}
$this->finPlan = Metier_Util_Date::period2Days($this->debutPlan, $this->dureePlan.' mois');
}
if ($this->debug) {
file_put_contents('procol.log', "\n", FILE_APPEND);
}
}
protected function getAnnoncesLegalesEffacement($siren, $rubrique, $tabRet)
{
if ($this->debug) {
file_put_contents('procol.log', "Effacement Procol\n", FILE_APPEND);
}
$effacement = false;
$MaxPeriodProcol = 80000;
// --- Si il y a des annonces
@ -4997,7 +4997,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
// --- Gestions des conditions pour l'affichage de l'indicateur procédure collectives
if ($rubrique == 'P') {
if ($this->debug) {
file_put_contents('procol.log', "Rubrique P = ".print_r($tabRet, 1)."\n", FILE_APPEND);
file_put_contents('procol.log', "Rubrique P\n", FILE_APPEND);
}
// Si plan recherche des annonces suivantes
if ($this->dureePlan > 0) {
@ -5021,7 +5021,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
1417, 1418, 1419,
// Cloture
1500, 1501, 1502, 1503, 1504, 1514 ))) {
$this->dureePlan = 0;
$this->dureePlan = 0;
}
}
if ($this->debug) {
@ -5595,9 +5595,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
}
}
if ($this->debug && $rubrique == 'D') {
file_put_contents('procol.log', $sql."\n", FILE_APPEND);
}
try {
$stmt = $this->conn->executeQuery($sql);
} catch (\Doctrine\DBAL\DBALException $e) {

View File

@ -63,9 +63,22 @@ class Metier_Partenaires_MBanques
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Banque
*/
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -76,15 +89,25 @@ class Metier_Partenaires_MBanques
public function getInfoBanque($codeBanque)
{
$result = array();
$sql = "SELECT bdfFibCodeEtab, bdfFibCodeSituation, bdfFibDenom40,
bdfFibDenom10, bdfFibCodeActivite, bdfFibCodeOrganeRepr, bdfFibDateAgrement, *
bdfFibDateRetraitAgr, bdfFibDateFinDiffus, bdfFibAdresse1, bdfFibAdresse2,
bdfFibAdresse3, CP, Ville, bdfFibCodeEtabAbsorb, bdfFibOptionIdInvar,
bdfFibDateOptIdInvar FROM insee.BDF_Etabs WHERE bdfFibCodeEtab=:code LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('code', $codeBanque);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$stmtNb = 0;
try {
$sql = "SELECT bdfFibCodeEtab, bdfFibCodeSituation, bdfFibDenom40,
bdfFibDenom10, bdfFibCodeActivite, bdfFibCodeOrganeRepr, bdfFibDateAgrement, *
bdfFibDateRetraitAgr, bdfFibDateFinDiffus, bdfFibAdresse1, bdfFibAdresse2,
bdfFibAdresse3, CP, Ville, bdfFibCodeEtabAbsorb, bdfFibOptionIdInvar,
bdfFibDateOptIdInvar FROM insee.BDF_Etabs WHERE bdfFibCodeEtab=:code LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('code', $codeBanque);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
}
@ -103,19 +126,28 @@ class Metier_Partenaires_MBanques
$tabBanque = $this->getInfoBanque($codeBanque);
$tabTel = $this->getTelGuichet($codeBanque, $codeGuichet);
$sql = "SELECT bdfFibCodeEtab, bdfFibCodeGuichet, bdfFibCodeSituation AS guichetCodeSituation,
bdfFibDenom40 AS guichetDenom40, bdfFibDenom20 AS guichetDenom20, bdfFibCodeEtabCible,
bdfFibCodeGuichetRepr, bdfFibCodeGeoInsee, bdfFibCodeLocalite1, bdfFibCodeLocalite2,
bdfFibComptoirBDF, bdfFibAdresse1 AS guichetAdresse1, bdfFibAdresse2 AS guichetAdresse2,
bdfFibAdresse3 AS guichetAdresse3, CP AS guichetCP, Ville AS guichetVille,
bdfFibAdresseSWIFT, bdfFibDateOuverture, bdfFibDateFermeture, bdfFibDateFinDiffus,
bdfFibCodeRoutage, bdfFibLibelleRIB, bdfFibNatureGuichet, bdfFibCodeAchOperBDF,
bdfFibNomComptoirBDF FROM WHERE bdfFibCodeEtab=:banque AND bdfFibCodeGuichet=:guichet LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('banque', $codeBanque);
$stmt->bindValue('guichet', $codeGuichet);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$stmtNb = 0;
try {
$sql = "SELECT bdfFibCodeEtab, bdfFibCodeGuichet, bdfFibCodeSituation AS guichetCodeSituation,
bdfFibDenom40 AS guichetDenom40, bdfFibDenom20 AS guichetDenom20, bdfFibCodeEtabCible,
bdfFibCodeGuichetRepr, bdfFibCodeGeoInsee, bdfFibCodeLocalite1, bdfFibCodeLocalite2,
bdfFibComptoirBDF, bdfFibAdresse1 AS guichetAdresse1, bdfFibAdresse2 AS guichetAdresse2,
bdfFibAdresse3 AS guichetAdresse3, CP AS guichetCP, Ville AS guichetVille,
bdfFibAdresseSWIFT, bdfFibDateOuverture, bdfFibDateFermeture, bdfFibDateFinDiffus,
bdfFibCodeRoutage, bdfFibLibelleRIB, bdfFibNatureGuichet, bdfFibCodeAchOperBDF,
bdfFibNomComptoirBDF FROM WHERE bdfFibCodeEtab=:banque AND bdfFibCodeGuichet=:guichet LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('banque', $codeBanque);
$stmt->bindValue('guichet', $codeGuichet);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
}
@ -130,12 +162,21 @@ class Metier_Partenaires_MBanques
public function getTelGuichet($codeBanque, $codeGuichet)
{
$result = array();
$sql = "SELECT Tel, Fax FROM insee.Mandel_banques WHERE CodeB=:banque AND CodeG=:guichet LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('banque', $codeBanque);
$stmt->bindValue('guichet', $codeGuichet);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$stmtNb = 0;
try {
$sql = "SELECT Tel, Fax FROM insee.Mandel_banques WHERE CodeB=:banque AND CodeG=:guichet LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('banque', $codeBanque);
$stmt->bindValue('guichet', $codeGuichet);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
}

View File

@ -271,12 +271,22 @@ class Metier_Partenaires_MBilans
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* MBilans
*/
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -310,13 +320,18 @@ class Metier_Partenaires_MBilans
}
$where.= " ORDER BY dateEffet DESC LIMIT 0,1";
$listeSql = "SELECT $fields FROM jo.bodacc_detail WHERE $where";
$listeNb = 0;
try {
$listeStmt = $this->conn->prepare($listeSql);
$listeStmt->bindValue('siren', $this->siren);
$listeStmt->execute();
} catch(\Doctrine\DBAL\DBALException $e) {
$listeNb = $listeStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($listeStmt->rowCount() > 0) {
if ($listeNb > 0) {
$listResult = $listeStmt->fetch(\PDO::FETCH_ASSOC);
$dateDerDepot = Metier_Util_Date::dateT('Y-m-d', 'Ymd', $listResult['dateEffet'])*1;
if ($dateDerDepot != 0) {
@ -337,7 +352,7 @@ class Metier_Partenaires_MBilans
public function listeBilans($accesPartenaire = false, $nbMaxBilans = 0)
{
$dateDerDepot = 0;
$tabRet = $tabRet2 = $tabRet3 = array();
$tabRet = $tabRet2 = $tabRet3 = $tabRet = array();
$where = "siren=:siren";
if ($this->companyEvenDateStop !== null) {
@ -349,17 +364,20 @@ class Metier_Partenaires_MBilans
}
$fields = "typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire";
$listeNb = 0;
try {
$listeSql = "SELECT $fields FROM jo.bilans WHERE $where";
$listeStmt = $this->conn->prepare($listeSql);
$listeStmt->bindValue('siren', $this->siren);
$listeStmt->execute();
} catch(\Doctrine\DBAL\DBALException $e) {
$listeNb = $listeStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$tabTri = array();
if ($listeStmt->rowCount() > 0) {
if ($listeNb > 0) {
while($bil = $listeStmt->fetch(\PDO::FETCH_ASSOC)) {
$millesime = Metier_Util_Date::dateT('Ymd', 'd/m/Y', $bil['dateExercice']);
$tabRet[''.$bil['typeBilan'].$millesime] = array(
@ -439,6 +457,7 @@ class Metier_Partenaires_MBilans
}
// --- Selection du premier bilan
$bilanNb = 0;
try {
$bilanSql = "SELECT $fields FROM jo.bilans WHERE $where LIMIT 0,1";
$bilanStmt = $this->conn->prepare($bilanSql);
@ -446,12 +465,16 @@ class Metier_Partenaires_MBilans
$bilanStmt->bindValue('typeBilan', $typeBilan);
$bilanStmt->bindValue('clotureDate', $clotureDateSql);
$bilanStmt->execute();
$bilanNb = $bilanStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$tabBilan = $tabBilanPre = $bilanPre = array();
if ($bilanStmt->rowCount() > 0) {
if ($bilanNb > 0) {
$bilan = $bilanStmt->fetch(\PDO::FETCH_ASSOC);
$tabBilan['SIREN'] = $this->siren;
$tabBilan['DATE_FRAICHE_BILAN'] = $bilan['dateProvPartenaire']; // SSAAMMJJ
@ -684,6 +707,7 @@ class Metier_Partenaires_MBilans
$cloturePreDate = $clotureDate->sub(new DateInterval('P'.$bilan['dureeExercice'].'M'));
$cloturePreDateSql = $cloturePreDate->format('Ym');
// --- Recherche des infos du bilan précédent
$bilanpreNb = 0;
try {
$fields = "dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes";
$where = "siren=:siren AND typeBilan=:typeBilan AND dateExercice BETWEEN :clotureDateBegin AND :clotureDateEnd";
@ -694,9 +718,13 @@ class Metier_Partenaires_MBilans
$bilanpreStmt->bindValue('clotureDateBegin', $cloturePreDateSql.'01');
$bilanpreStmt->bindValue('clotureDateEnd', $cloturePreDateSql.'31');
$bilanpreStmt->execute();
$bilanpreNb = $bilanpreStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($bilanpreStmt->rowCount() > 0) {
if ($bilanpreNb > 0) {
$bilanPre = $bilanpreStmt->fetch(\PDO::FETCH_ASSOC);
$tabBilan['DATE_CLOTURE_PRE'] = $bilanPre['dateExercice']; // SSAAMMJJ
$tabBilan['DUREE_MOIS_PRE'] = $bilanPre['dureeExercice'];

View File

@ -13,9 +13,19 @@ class Metier_Partenaires_MBourse
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -110,11 +120,19 @@ class Metier_Partenaires_MBourse
$siren = $this->siren;
}
$sql = "SELECT isin FROM jo.infos_entrep WHERE siren=:siren AND isin!='' LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$sql = "SELECT isin FROM jo.infos_entrep WHERE siren=:siren AND isin!='' LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
return trim($result['isin']);
}
@ -129,11 +147,19 @@ class Metier_Partenaires_MBourse
*/
public function getCodeSiren($isin)
{
$sql = "SELECT siren FROM jo.infos_entrep WHERE isin=:isin AND siren!=0 LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('isin', $isin);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$sql = "SELECT siren FROM jo.infos_entrep WHERE isin=:isin AND siren!=0 LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('isin', $isin);
$stmt->execute();
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
return trim($result['siren']);
}
@ -165,11 +191,19 @@ class Metier_Partenaires_MBourse
pressReleaseAttachments, pressReleaseUrl, source, dateInsert
FROM presse.articles
WHERE companyIsin=:isin $sqlID ORDER BY pressReleaseDate DESC";
$bodaccStmt = $this->conn->prepare($bodaccSql);
$bodaccStmt->bindValue('isin', $isin);
$bodaccStmt->execute();
if ($bodaccStmt->rowCount() > 0) {
$nb = 0;
try {
$bodaccStmt = $this->conn->prepare($bodaccSql);
$bodaccStmt->bindValue('isin', $isin);
$bodaccStmt->execute();
$nb = $bodaccStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while($ann = $bodaccStmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array(
'id' => $ann['id'],
@ -219,10 +253,18 @@ class Metier_Partenaires_MBourse
FROM sdv1.bourse_isin b, sdv1.bourse_cours c
WHERE code_isin=:isin AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u')
ORDER BY c.`date` DESC, c.`heure` DESC LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('isin', $isin);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('isin', $isin);
$stmt->execute();
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$courSql = "SELECT min(close) AS coursMin, avg(close) AS coursMoy,
max(close) AS coursMax FROM sdv1.bourse_cours

View File

@ -13,6 +13,12 @@ class Metier_Partenaires_MCadastre
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Droits des locaux
* @var array
@ -65,7 +71,7 @@ class Metier_Partenaires_MCadastre
'MP' => 'Maison partagée par une limite territoriale',
'PP' => 'ND',
'SM' => 'Sol de maison',
'U' => 'Etablissement industriel',
'U' => 'Etablissement industriel',
'U1' => 'Gare',
'U2' => 'Gare - Triage',
'U3' => 'Gare - Atelier matériel',
@ -133,7 +139,7 @@ class Metier_Partenaires_MCadastre
private static $natureParcelles = array(
'AB' => 'Terrains à batir',
'AG' => 'Terrains d\'agrément',
'B' => 'Bois',
'B' => 'Bois',
'BF' => 'Futaies feuillues',
'BM' => 'Futaies mixtes',
'BO' => 'Oseraies',
@ -143,18 +149,18 @@ class Metier_Partenaires_MCadastre
'BT' => 'Taillies simples',
'CA' => 'Carrières',
'CH' => 'Chemins de fer, Canaux de Navigation',
'E' => 'Eaux',
'J' => 'Jardins',
'L' => 'Landes',
'E' => 'Eaux',
'J' => 'Jardins',
'L' => 'Landes',
'LB' => 'Landes Boisées',
'P' => 'Prés',
'P' => 'Prés',
'PA' => 'Pâtures ou Pâturages',
'PC' => 'Pacages ou Pâtis',
'PE' => 'Prés d\'embouche',
'PH' => 'Herbages',
'PP' => 'Prés, Pâtures ou Herbages plantes',
'S' => 'Sols',
'T' => 'Terre',
'S' => 'Sols',
'T' => 'Terre',
'TP' => 'Terres plantées',
'VE' => 'Vergers',
'VI' => 'Vignes',
@ -167,6 +173,10 @@ class Metier_Partenaires_MCadastre
public function __construct($conn = null)
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -233,13 +243,22 @@ class Metier_Partenaires_MCadastre
$siren = $this->siren;
}
$locaux = array();
$sql = "SELECT e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM AS companyCCOCOM,
l.CCODRO, l.CCOCOM, l.CCOPRF, l.CCOSEC, l.DNUPLA, l.DNUBAT, l.DESC, l.DNIV, l.DPOR, l.CCONLC, l.CCOAFF0, l.DSUPOD0, l.CCOAFF1, l.DSUPOD1, l.CCOAFF2, l.DSUPOD2, l.CCOAFF3, l.DSUPOD3, l.CCOAFF4, l.DSUPOD4, l.CCOAFF5, l.DSUPOD5, l.CCOAFF6, l.DSUPOD6, l.CCOAFF7, l.DSUPOD7, l.CCOAFF8, l.DSUPOD8, l.CCOAFF9, l.DSUPOD9, l.CCODEP, l.DLICOM, l.CCORIV, l.CNAVOI, l.DLIVOI, l.DNUVOI, l.DLTNUV
FROM sdv1.cad_perloc l, sdv1.cad_permor e WHERE e.DSIREN='$siren' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER";
$stmt = $this->conn->executeQuery($sql);
$locaux = array();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array(
'idCentre' => $loc['INTCIF'],
@ -307,15 +326,23 @@ class Metier_Partenaires_MCadastre
if ($siren === null) {
$siren = $this->siren;
};
$parcelles = array();
$sql = "SELECT e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM AS companyCCOCOM,
p.CCODRO, p.CCOCOM, p.CCOPRF, p.CCOSEC, p.DNUPLA, p.DCNPAR, p.DSGRPF0, p.DCNSUF0, p.DSGRPF1, p.DCNSUF1, p.DSGRPF2, p.DCNSUF2, p.DSGRPF3, p.DCNSUF3, p.DSGRPF4, p.DCNSUF4, p.DSGRPF5, p.DCNSUF5, p.DSGRPF6, p.DCNSUF6, p.DSGRPF7, p.DCNSUF7, p.DSGRPF8, p.DCNSUF8, p.DSGRPF9, p.DCNSUF9, p.CCODEP, p.DLICOM, p.CCORIV, p.CNAVOI, p.DLIVOI, p.DNUVOI, p.DLTNUV
FROM sdv1.cad_perpar p, sdv1.cad_permor e
WHERE e.DSIREN='$siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$stmt = $this->conn->executeQuery($sql);
$parcelles = array();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array(
'idCentre' => $loc['INTCIF'],
@ -387,8 +414,6 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT count(*) AS itemTotal, (SUM(l.DSUPOD0) + SUM(l.DSUPOD1) + SUM(l.DSUPOD2) + SUM(l.DSUPOD3) + SUM(l.DSUPOD4) + SUM(l.DSUPOD5) + SUM(l.DSUPOD7) + SUM(l.DSUPOD8) + SUM(l.DSUPOD9)) AS surfaceTotal
FROM sdv1.cad_perloc l, sdv1.cad_permor e
WHERE e.DSIREN='".$this->siren."' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER".$droitSql;
$stmt = $this->conn->executeQuery($sql);
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
} elseif ($type == 'parcelle') {
$droitSql = " AND p.CCODRO='P'";
if ($droit != 'P') {
@ -397,7 +422,19 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT count(*) AS itemTotal, sum(p.DCNPAR) AS surfaceTotal
FROM sdv1.cad_perpar p, sdv1.cad_permor e
WHERE e.DSIREN='".$this->siren."' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER".$droitSql;
}
$results = array();
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
@ -491,10 +528,19 @@ class Metier_Partenaires_MCadastre
"WHERE e.DSIREN='$this->siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$sql = "SELECT * FROM ( ($locauxSql) UNION ALL ($parcellesSql) ) results";
$stmt = $this->conn->executeQuery($sql);
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$list = array();
if ($stmt->rowCount() > 0) {
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
// Libellé role
$result['roleLib'] = self::$codeDroit[trim($result['role'])];

View File

@ -7,12 +7,22 @@ class Metier_Partenaires_MGreffes
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Greffes
*/
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -26,50 +36,52 @@ class Metier_Partenaires_MGreffes
dateRadiation, dateCloture, ca, res, eff, dateInsert
FROM jo.greffes_identite WHERE siren=:siren";
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return array(
'id' => $result['id'],
'Pertinence' => 100,
'Siret' => $result['siren'].'00000',
'Siege' => $result['siege'],
'Nom' => $result['nom'],
'Nom2' => $result['nomCommercial'],
'Sigle' => '',
'Enseigne' => $result['ens'],
'Adresse' => $result['adresse'],
'Adresse2' => $result['adresse2'],
'CP' => $result['cp'],
'Ville' => $result['ville'],
'Tel' => '',
'Fax' => '',
'FJ' => $result['fj'],
'FJLib' => $result['fjLib'],
'Siren' => $result['siren'],
'Nic' => '00000',
'Actif' => 0,
'NafEtab' => $result['naf'],
'NafEtabLib' => $result['nafLib'],
'NafEnt' => $result['naf'],
'NafEntLib' => $result['nafLib'],
'NumRC' => $result['numRC'],
'NumRC2' => $result['numRC2'],
'NumGreffe' => $result['numGreffe'],
'DateCreation' => $result['dateCreation'],
'DateRadiation' => $result['dateRadiation'],
'DateCloture' => $result['dateCloture'],
'DateUpdate' => substr($result['dateInsert'], 0, 10),
);
}
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return array(
'id' => $result['id'],
'Pertinence' => 100,
'Siret' => $result['siren'].'00000',
'Siege' => $result['siege'],
'Nom' => $result['nom'],
'Nom2' => $result['nomCommercial'],
'Sigle' => '',
'Enseigne' => $result['ens'],
'Adresse' => $result['adresse'],
'Adresse2' => $result['adresse2'],
'CP' => $result['cp'],
'Ville' => $result['ville'],
'Tel' => '',
'Fax' => '',
'FJ' => $result['fj'],
'FJLib' => $result['fjLib'],
'Siren' => $result['siren'],
'Nic' => '00000',
'Actif' => 0,
'NafEtab' => $result['naf'],
'NafEtabLib' => $result['nafLib'],
'NafEnt' => $result['naf'],
'NafEntLib' => $result['nafLib'],
'NumRC' => $result['numRC'],
'NumRC2' => $result['numRC2'],
'NumGreffe' => $result['numGreffe'],
'DateCreation' => $result['dateCreation'],
'DateRadiation' => $result['dateRadiation'],
'DateCloture' => $result['dateCloture'],
'DateUpdate' => substr($result['dateInsert'], 0, 10),
);
}
return false;
@ -85,34 +97,40 @@ class Metier_Partenaires_MGreffes
dateLJS, dateInventaire, dateBodacc, caDeclare, effectif, descriptif, pdfLink, pdfSize,
pdfVer, pdfPage, descDateDepot, dateLimite, mandataire, dateInsert
FROM jo.greffes_cessions WHERE siren=:siren";
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
if ($stmt->rowCount() > 1) {
$mail = new Metier_Common_Mail();
$mail->send('debug@scores-decisions.com', 'ylenaour@scores-decisions.com',
"classMGreffes.php : Debug getInfosCessions $siren", "Plus de 1 cession pour ce siren");
}
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
return array(
'cessJuge' => $result['etat'],
'cessDateJuge' => $result['dateJuge'],
'cessDateConv' => $result['dateConv'],
'cessDateLJS' => $result['dateLJS'],
'cessDateInv' => $result['dateInventaire'],
'cessDateBod' => $result['dateBodacc'],
'cessCAdec' => $result['caDeclare'],
'cessEffectif' => $result['effectif'],
'cessDesc' => $result['descriptif'],
'cessDateDesc' => $result['descDateDepot'],
'cessDateLim' => $result['dateLimite'],
'cessMand' => $result['mandataire'],
);
}
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
if ($nb > 1) {
$mail = new Metier_Common_Mail();
$mail->send('debug@scores-decisions.com', 'ylenaour@scores-decisions.com',
"classMGreffes.php : Debug getInfosCessions $siren", "Plus de 1 cession pour ce siren");
}
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
return array(
'cessJuge' => $result['etat'],
'cessDateJuge' => $result['dateJuge'],
'cessDateConv' => $result['dateConv'],
'cessDateLJS' => $result['dateLJS'],
'cessDateInv' => $result['dateInventaire'],
'cessDateBod' => $result['dateBodacc'],
'cessCAdec' => $result['caDeclare'],
'cessEffectif' => $result['effectif'],
'cessDesc' => $result['descriptif'],
'cessDateDesc' => $result['descDateDepot'],
'cessDateLim' => $result['dateLimite'],
'cessMand' => $result['mandataire'],
);
}
return false;

View File

@ -1,17 +1,25 @@
<?php
class Metier_Partenaires_MMarques
{
private $iDb;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
@ -28,19 +36,27 @@ class Metier_Partenaires_MMarques
dateExpir, idObjetImg, idObjetPdf FROM bopi.marques WHERE";
if ($siren > 0) {
if (substr($sql, -5) != "WHERE") {
$sql.= " AND ";
$sql.= " AND";
}
$sql.= "sirenDeposant=$siren";
$sql.= " sirenDeposant=$siren";
}
if ($idDepot > 0) {
if (substr($sql, -5) != "WHERE") {
$sql.= " AND ";
$sql.= " AND";
}
$sql.= "numeroMarque=$idDepot";
$sql.= " numeroMarque=$idDepot";
}
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($marque = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($marque['nomMarque'] == '&nbsp;') {
$nomMarque = '(figurative)';
@ -51,12 +67,19 @@ class Metier_Partenaires_MMarques
if ($idDepot != 0) {
if ($marque['numeroMarque'] == $idDepot) {
//Produits et Services
$psSql = "SELECT remarque FROM bopi.marques_classes WHERE numeroMarque=:id";
$psStmt = $this->conn->prepare($psSql);
$psStmt->bindValue('id', $idDepot);
$psStmt->execute();
try {
$psSql = "SELECT remarque FROM bopi.marques_classes WHERE numeroMarque=:id";
$psStmt = $this->conn->prepare($psSql);
$psStmt->bindValue('id', $idDepot);
$psStmt->execute();
$pNb = $psStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$txt = array();
if ($psStmt->rowCount() > 0) {
if ($pNb > 0) {
while ($ps = $psStmt->fetch(\PDO::FETCH_ASSOC)) {
$txt[] = $ps['remarque'];
}
@ -64,12 +87,19 @@ class Metier_Partenaires_MMarques
$marque['PS'] = $txt;
//Historique
$hSql = "SELECT histo2 FROM bopi.marques_histo WHERE numeroMarque=:id ORDER BY dat DESC";
$hStmt = $this->conn->prepare($psSql);
$hStmt->bindValue('id', $idDepot);
$hStmt->execute();
try {
$hSql = "SELECT histo2 FROM bopi.marques_histo WHERE numeroMarque=:id ORDER BY dat DESC";
$hStmt = $this->conn->prepare($psSql);
$hStmt->bindValue('id', $idDepot);
$hStmt->execute();
$hNb = $hStmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$txt = array();
if ($hStmt->rowCount() > 0) {
if ($hNb > 0) {
while ($h = $hStmt->fetch(\PDO::FETCH_ASSOC)) {
$txt[] = $h['histo2'];
}

View File

@ -66,8 +66,6 @@ class Metier_Partenaires_MPrivileges
'28' => "GAGE DES STOCKS",
);
protected $iDb;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection

View File

@ -1,27 +1,40 @@
<?php
require_once 'framework/common/curl.php';
class Metier_Partenaires_MQualibat
{
private $referer ='';
private $body = '';
private $header = '';
private $cookie = '';
private $codeRetour = 0;
private $accesDist=true;
private $iDb;
private $iBodacc;
private $iInsee;
protected $iBodacc;
protected $iInsee;
public $enCache=false;
public $force=false;
public $annee=0;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Enable remote
* @var string
*/
protected $remote = false;
public function __construct($accesDist = true)
/**
* MQualibat
*/
public function __construct()
{
$this->accesDist = $accesDist;
$this->iDb = new Metier_Util_Db();
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->iBodacc = new Metier_Bodacc_MBodacc();
$this->iInsee = new Metier_Insee_MInsee();
}
@ -77,23 +90,40 @@ class Metier_Partenaires_MQualibat
public function getMaxQualibat()
{
$ret = $this->iDb->select('sdv1.qualibat', 'MAX(id) AS id', '1', false, MYSQL_ASSOC);
return $ret[0]['id'];
$sql = "SELECT MAX(id) AS id FROM sdv1.qualibat";
try {
$stmt = $this->conn->executeQuery($sql);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$result = $stmt->fetch(\PDO::FETCH_OBJ);
return $result->id;
}
public function getTabQualibatManquants()
{
$tabRet = $tabQualibatCalc = $tabQualibatBase = array();
// Liste des Qualibat Calculés
$maxQualibat = $this->getMaxQualibat();
for ($i=1; $i<=$maxQualibat; $i++) {
$tabQualibatCalc[]=$i;
$tabQualibatCalc[] = $i;
}
// Liste des Qualibat en base
$ret = $this->iDb->select('sdv1.qualibat', 'id', '1 ORDER BY id ASC', false, MYSQL_ASSOC);
foreach ($ret as $i=>$res) {
$tabQualibatBase[]=$res['id'];
$sql = "SELECT id FROM sdv1.qualibat ORDER BY id ASC";
try {
$stmt = $this->conn->executeQuery($sql);
while ($result = $stmt->fetch(PDO::FETCH_OBJ)) {
$tabQualibatBase[] = $result->id;
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
return array_diff($tabQualibatCalc, $tabQualibatBase);
@ -109,34 +139,56 @@ class Metier_Partenaires_MQualibat
return false;
}
$ret = $this->iDb->select(
'sdv1.qualibat', 'siren, actif, id, nom, adresse, cp, ville, tel, fax, email, web,
eff, teff, ca, tca, libFJ, nace, dateFondation, dateDeb, dateFin, dateInsert',
$strWhere, false, MYSQL_ASSOC);
$sql = "SELECT siren, actif, id, nom, adresse, cp, ville, tel, fax, email, web, eff, teff,
ca, tca, libFJ, nace, dateFondation, dateDeb, dateFin, dateInsert
FROM sdv1.qualibat WHERE $strWhere";
try {
$stmt = $this->conn->executeQuery($sql);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
// In database
if (!$this->force && count($ret) > 0) {
$this->enCache=true;
$tabRet = $ret[0];//array();
if ($this->remote === false && $stmt->rowCount() > 0) {
$tabRet = $stmt->fetch(\PDO::FETCH_ASSOC);
// Ajout des qualifications
$ret = $this->iDb->select(
'sdv1.qualibatqualif', 'code, periodQualif, niveauQualif, mentions, nomQualif, dateAttrib, dateEch',
$strWhere, false, MYSQL_ASSOC);
foreach ($ret as $i => $tabTmp) {
$tabRet['qualifications'][] = $tabTmp;
$sql = "SELECT code, periodQualif, niveauQualif, mentions, nomQualif, dateAttrib, dateEch
FROM sdv1.qualibatqualif WHERE $strWhere";
try {
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabRet['qualifications'][] = $result;
}
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
// Ajout des dirigeants
$ret = $this->iDb->select(
'sdv1.qualibatdir', 'civNomPrenom, civilite, nom, prenom, fonction',
$strWhere, false, MYSQL_ASSOC);
foreach ($ret as $i => $tabTmp) {
$tabRet['dirigeants'][] = $tabTmp;
$sql = "SELECT civNomPrenom, civilite, nom, prenom, fonction
FROM sdv1.qualibatdir WHERE $strWhere";
try {
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabRet['dirigeants'][] = $result;
}
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
}
// WebSite
elseif ($this->accesDist == true) {
$this->enCache = false;
if ($this->remote === true) {
$url = 'http://www.qualibat.com/Views/EntreprisesRechercheDetail.aspx?id='.$idQualibat;
$page = getUrl($url, '', '', '', false, '', '', 3);
if ($page['code'] != 200) {
@ -258,10 +310,10 @@ class Metier_Partenaires_MQualibat
foreach ($matches[1] as $i => $nom) {
$strNom = trim($nom);
switch (strtoupper(substr($strNom, 0, 6))) {
case 'MONSIE': $civ='M'; $pDeb=8; break;
case 'MADAME': $civ='MME'; $pDeb=6; break;
case 'MADEMO': $civ='MLLE';$pDeb=12; break;
default: $civ=''; $pDeb=0; break;
case 'MONSIE': $civ='M'; $pDeb=8; break;
case 'MADAME': $civ='MME'; $pDeb=6; break;
case 'MADEMO': $civ='MLLE'; $pDeb=12; break;
default: $civ=''; $pDeb=0; break;
}
$libFonction = ucwords(strtolower(trim($matches[2][$i])));
$tabRet['dirigeants'][$i] = array(
@ -282,8 +334,19 @@ class Metier_Partenaires_MQualibat
'dateDeb' => @$tabDateAttrib[0],
'dateFin' => @$tabDateFin[0]));
unset($tabInsert['qualifications']);
if (!$this->iDb->insert('sdv1.qualibat', $tabInsert)) {
$this->iDb->update('sdv1.qualibat', $tabInsert, "id=$idQualibat");
$sql = "SELECT id FROM sdv1.qualibat WHERE id=$idQualibat";
try {
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
$this->conn->update('sdv1.qualibat', $tabInsert, array('id' => $idQualibat));
} else {
$this->conn->insert('sdv1.qualibat', $tabInsert);
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
/** Insertion des qualifications **/
@ -292,8 +355,24 @@ class Metier_Partenaires_MQualibat
$tabInsert['id'] = $idQualibat;
$tabInsert['siren'] = $siren;
$tabInsert['dateInsert'] = date('YmdHis');
if (!$this->iDb->insert('sdv1.qualibatqualif', $tabInsert)) {
$this->iDb->update('sdv1.qualibatqualif', $tabInsert, "id=$idQualibat AND code='".$tabInsert['code']."' AND periodQualif='".$tabInsert['periodQualif']."'");
$sql = "SELECT id FROM sdv1.qualibatqualif
WHERE id=$idQualibat AND code='".$tabInsert['code']."' AND periodQualif='".$tabInsert['periodQualif']."'";
try {
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
$this->conn->update('sdv1.qualibatqualif', $tabInsert, array(
'id' => $idQualibat,
'code' => $tabInsert['code'],
'periodQualif' => $tabInsert['periodQualif'],
));
} else {
$this->conn->insert('sdv1.qualibatqualif', $tabInsert);
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
}
}
@ -304,29 +383,66 @@ class Metier_Partenaires_MQualibat
$tabInsert['id'] = $idQualibat;
$tabInsert['siren'] = $siren;
$tabInsert['dateInsert'] = date('YmdHis');
if (!$this->iDb->insert('sdv1.qualibatdir', $tabInsert)) {
$this->iDb->update('sdv1.qualibatdir', $tabInsert, "id=$idQualibat AND civNomPrenom='".addslashes($tabInsert['civNomPrenom'])."' AND fonction='".addslashes($tabInsert['fonction'])."'");
$sql = "SELECT id FROM sdv1.qualibatdir
WHERE id=$idQualibat AND civNomPrenom='".addslashes($tabInsert['civNomPrenom'])."' AND fonction='".addslashes($tabInsert['fonction'])."'";
try {
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
$this->conn->update('sdv1.qualibatdir', $tabInsert, array(
'id' => $idQualibat,
'civNomPrenom' => $tabInsert['civNomPrenom'],
'fonction' => $tabInsert['fonction'],
));
} else {
$this->conn->insert('sdv1.qualibatdir', $tabInsert);
}
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
unset($tabRet['dirigeants'][$i]['civNomPrenom']);
}
}
return $tabRet;
} else {
$tabInsert = array(
'actif' => 0,
'id' => $idQualibat,
'id' => $idQualibat,
'idQualibatAttribue' => 0,
'dateInsert' => date('YmdHis')
);
$this->erreur = 'Numéro Qualibat inexistant';
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
if ($idQualibat < $this->getMaxQualibat()) {
$this->iDb->insert('sdv1.qualibat', $tabInsert);
try {
$stmt = $this->conn->insert('sdv1.qualibat', $tabInsert);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
}
return false;
}
}
return false;
}
}
/**
* Get Remote Infos
* @param unknown $id
*/
protected function getRemote($id)
{
}
}

View File

@ -58,6 +58,12 @@ class Metier_Partenaires_MRncs
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Flag to get remote data
* @var string
@ -71,6 +77,10 @@ class Metier_Partenaires_MRncs
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->tabDevises = $this->getTabDevisesInpi();
$this->tabPays = $this->getTabPaysInpi();
$this->tabTribunaux = $this->getTabTribunaux();
@ -109,13 +119,24 @@ class Metier_Partenaires_MRncs
return include $cache;
} else {
$sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabDevises[intval($item->devInpi)] = $item->devIso;
}
}
return $tabDevises;
}
}
@ -146,9 +167,19 @@ class Metier_Partenaires_MRncs
} else {
$tabJug = array();
$sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabJug[intval($item->codJugement)] = $item->codEven;
}
@ -178,9 +209,19 @@ class Metier_Partenaires_MRncs
} else {
$tabPays = array();
$sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tabPays[$item->codePaysInpi*1] = $item->codPays;
}
@ -195,12 +236,24 @@ class Metier_Partenaires_MRncs
*/
protected function getTabMandataires()
{
$tabMandSD = array();
$sql = "SELECT UPPER(CONCAT(SUBSTRING(Nom,1,4),'-',SUBSTRING(Prenom,1,3))) AS NomPre,
SUBSTRING(cp,1,2) AS dep, COUNT(*) AS Nb, sirenMand, id, sirenGrp, Nom, Prenom,
type, coursAppel, tribunal, Statut, adresse, adresseComp, cp, ville, tel, fax, email, web, contact
FROM jo.tabMandataires WHERE TYPE IN ('A', 'M') GROUP BY NomPre, dep, sirenMand ORDER BY NomPre ASC";
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($mand = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabMandSD[] = array(
'id' => $mand['id'],
@ -246,13 +299,22 @@ class Metier_Partenaires_MRncs
WHERE TYPE IN ('A', 'M') AND (Nom!='' OR Prenom!='')
AND MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE)
ORDER BY score DESC LIMIT 0,10";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb == 1) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$this->matching = $result['score'];
return $result['id'];
} elseif ($stmt->rowCount() > 1) {
} elseif ($nb > 1) {
while ($iRet = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($debug) {
echo "je compare '$cp' avec '".$iRet['cp']."' et '$ville' avec '".$iRet["ville"]."' (score=".$iRet['score'].")\n";
@ -296,9 +358,19 @@ class Metier_Partenaires_MRncs
} else {
$tabTribunaux = array();
$sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabTribunaux[$item->triNumGreffe*1] = array(
'Id' => $item->triId,
@ -321,8 +393,20 @@ class Metier_Partenaires_MRncs
$fj = $code_forme_juridique*1;
$label = 'En instance de chiffrement';
if ($fj > 0 && $fj < 10000) {
$stmt = $this->conn->executeQuery("SELECT libelle AS LibFJ FROM jo.tabFJur WHERE code=$fj");
if ($stmt->rowCount() > 0) {
$sql = "SELECT libelle AS LibFJ FROM jo.tabFJur WHERE code=$fj";
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['LibFJ'];
}
@ -338,10 +422,22 @@ class Metier_Partenaires_MRncs
*/
private function getLibelleNaf($codeNaf)
{
$stmt = $this->conn->executeQuery("SELECT libNaf700 AS LibNaf FROM jo.tabNaf4 WHERE codNaf700='$codeNaf'
UNION SELECT libNaf5 AS LibNaf FROM jo.tabNaf5 WHERE codNaf5='$codeNaf'");
$sql = "SELECT libNaf700 AS LibNaf FROM jo.tabNaf4 WHERE codNaf700='$codeNaf'
UNION SELECT libNaf5 AS LibNaf FROM jo.tabNaf5 WHERE codNaf5='$codeNaf'";
$label = "Inconnu";
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['LibNaf'];
}
@ -412,10 +508,19 @@ class Metier_Partenaires_MRncs
adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3,
naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate
FROM jo.rncs_etab WHERE siren=:siren $strSql";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() == 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb == 0) {
return false;
}
@ -483,10 +588,20 @@ class Metier_Partenaires_MRncs
$sql = "SELECT siren, sirenValide, actif, numGreffe, triCode, triId, numRC, numRC2, raisonSociale, nom, prenom, nomUsage, sigle, dateNaiss, lieuNaiss, sexe, nationalite, pays, naf, cj, capitalMontant, capitalDevise, capitalDevIso, dateImma, dateRad, capitalType, capitalCent, provisoires, flux, DATE(dateUpdate) AS jourUpdate
FROM jo.rncs_entrep WHERE siren=:siren";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$entrep = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($entrep['jourUpdate'] != '0000-00-00') {
$dateMaj = $entrep['jourUpdate'];
@ -539,6 +654,8 @@ class Metier_Partenaires_MRncs
*/
public function getListeDepots($siren, $dateDepot = null)
{
$tabDepots = array();
$sql = "SELECT e.siren, e.codeInterne, e.dateDepot, e.codeEven, l.libEven, e.flux, DATE(e.dateInsert) AS dateInsert
FROM jo.rncs_even e LEFT JOIN jo.tabEvenRncs l ON e.codeEven=l.codeEven";
$where = " e.siren=$siren ORDER BY e.dateDepot DESC, e.codeInterne ASC";
@ -546,10 +663,19 @@ class Metier_Partenaires_MRncs
$where = " e.siren=$siren AND e.dateDepot='$dateDepot'";
}
$sql.= " WHERE ".$where;
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$tabDepots = array();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array(
'codDepot' => $result['codeEven'],
@ -579,10 +705,20 @@ class Metier_Partenaires_MRncs
adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille
FROM jo.rncs_jugements j, jo.tabJugeRncs l, jo.tabEvenements e
WHERE j.siren=:siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array(
'codEven' => $result['codEven'],
@ -662,10 +798,20 @@ class Metier_Partenaires_MRncs
$sql = "SELECT siren, nic, `table`, champs, valeur, flux, dateInsert FROM jo.rncs_modifs
WHERE siren=:siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep'
ORDER BY flux DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$codEve = array();
switch ($result['champs']) {
@ -807,10 +953,20 @@ class Metier_Partenaires_MRncs
FROM jo.annonces WHERE siren=:siren $strDates
AND ( inter1type $strTypes OR inter2type $strTypes OR inter3type $strTypes OR inter4type $strTypes )
AND typeEven BETWEEN 1000 AND 2000 ORDER BY dateJugement DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$tabRet['dateCessationPaiement'] = $depot['dateCessationPaiement'];
for ($i=1; $i<4; $i++) {
@ -1079,15 +1235,25 @@ class Metier_Partenaires_MRncs
{
$siren = $siren*1;
$tabRet = array();
$numDir = 0;
$sql = "SELECT siren, raisonSociale, dirRS, civilite, nom, prenom, naissance_nom, naissance_date,
naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert
FROM jo.rncs_dirigeants WHERE siren=:siren AND actif%10=1 ORDER BY fonction_code DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$numDir = 0;
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$numDir++;
if ($result['naissance_date'] != '0000-00-00') {
@ -1126,16 +1292,26 @@ class Metier_Partenaires_MRncs
}
}
} else {
$sql = "SELECT siren, raisonSociale, '' AS dirRS, IF(sexe='M', 'M', IF(sexe='F', 'MME', '')) AS civilite,
nom, prenom, nomUsage AS naissance_nom, dateNaiss AS naissance_date, lieuNaiss AS naissance_lieu,
1050 AS fonction_code, 'Personne Physique' AS fonction_lib, 0 AS cinf, dateFer AS dateFin, flux, dateInsert
FROM jo.rncs_entrep WHERE siren=:siren";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt2 = $this->conn->prepare($sql);
$stmt2->bindValue('siren', $siren);
$stmt2->execute();
$nb = $stmt2->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$numDir = 0;
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
while ($result = $stmt2->fetch(\PDO::FETCH_ASSOC)) {
$numDir++;
if ($result['naissance_date'] != '0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['naissance_date']);

View File

@ -32,7 +32,7 @@ class Metier_Partenaires_MRnvp
public function __construct()
{
$this->iDb = new Metier_Util_Db();
$this->iInsee = new Metier_Insee_MInsee($this->iDb);
$this->iInsee = new Metier_Insee_MInsee();
}
/**

View File

@ -7,9 +7,22 @@ class Metier_Partenaires_MTel
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Tel
*/
public function __construct()
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -59,22 +72,35 @@ class Metier_Partenaires_MTel
partenaireConf, nbConf, idUpdate, dateUpdate, dateUpdate*1 AS dateUpdateYmd
FROM jo.telephonie WHERE siren=:siren $strNic $strActif AND dateSuppr=0
ORDER BY typeTel ASC, nbConf DESC";
$nb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
return $tabRet;
}
if ($stmt->rowCount() > 0) {
if ($nb > 0) {
$this->enCache = true;
while ($tabTel = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($tabTel['typeTel'] == 'an8' && $tabTel['infoTel']*1 > 0) {
$an8 = $tabTel['infoTel']*1;
$sql = "SELECT libAn8 FROM jo.tabAn8 WHERE codAn8='$an8'";
$an8Stmt = $this->conn->executeQuery($sql);
$an8Nb = 0;
try {
$an8Stmt = $this->conn->executeQuery($sql);
$an8Nb = $an8Stmt->rowCount();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$infoTel = '';
if ($an8Stmt->rowCount() > 0) {
if ($an8Nb > 0) {
$result = $an8Stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['libAn8'];
$infoTel = ucfirst(strtolower($label));

View File

@ -703,7 +703,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$iDb = $db;
}
$iInsee = new Metier_Insee_MInsee($iDb);
$iInsee = new Metier_Insee_MInsee();
/**
* Récupération des informations identitaire
@ -2193,7 +2193,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$tabA = $lienM->getActionnaires(null, true);
if (count($tabA)>0) {
foreach ($tabA as $i=>$lien) {
$lienInsee = new Metier_Insee_MInsee($iDb);
$lienInsee = new Metier_Insee_MInsee();
if (intval($lien->siren)>100 && ($lien->MajMin=='+' || $lien->PDetention>50)) {
$tabIdentiteA=$lienInsee->getIdentiteLight($lien->siren);
if ($NICMERE*1==0) {
@ -2235,7 +2235,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
if (count($tabP)>0) {
foreach ($tabP as $i=>$lien) {
if ($lien->siren>100 && ($lien->MajMin=='+' || $lien->PDetention>50)) {
$lienInsee = new Metier_Insee_MInsee($iDb);
$lienInsee = new Metier_Insee_MInsee();
$NBFILLE++; // Nombre de participations à plus de 50%
if ($NBFILLE==1) {
$tabIdentiteP=$lienInsee->getIdentiteLight($lien->siren);
@ -2611,7 +2611,6 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$ANNONCEINTERDIT=0;
$dirs = $iInsee->getDirigeants($siren, false);
$timer['getDirigeants'] = microtime(true);
//Metier_Util_Log::write('I', 'SCOREDIR = '. print_r($dirs,1), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$DIR_NB=$NBDIRLIENS=$NBDIRSCI=$NBDIRSCIADR=0;
if (count($dirs) > 0) {
foreach ($dirs as $nb => $dir) {
@ -3222,8 +3221,6 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$encoursEstime=$plafondEstime;
}
// Metier_Util_Log::write('I', "INDISCORE B $encoursIni $encoursEstime $encours", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
// Si l'entreprise à moins de 12 mois, on divise son encours estimé par 2
if ($encoursEstime>0) {
$dateCre=$tabIdentite['DateCreaEn']*1;

View File

@ -760,7 +760,7 @@ class Metier_Scoring_Base extends Metier_Scoring_Vars
$this->NIVEAU = $cycleClient; // 1, 2, 3 ou 5 Niveau de version des commentaires
$iInsee = new Metier_Insee_MInsee($this->db);
$iInsee = new Metier_Insee_MInsee();
if ($this->companyEvenDateStop !== null) {
$iInsee->setEvenLimit($this->companyEvenDateStop);
}
@ -2135,7 +2135,7 @@ class Metier_Scoring_Base extends Metier_Scoring_Vars
$tabA = $lienM->getActionnaires(null, true);
if (count($tabA)>0) {
foreach ($tabA as $i=>$lien) {
$lienInsee = new Metier_Insee_MInsee($this->db);
$lienInsee = new Metier_Insee_MInsee();
if (intval($lien->siren)>100 && ($lien->MajMin=='+' || $lien->PDetention>50)) {
$tabIdentiteA=$lienInsee->getIdentiteLight($lien->siren);
if ($this->NICMERE*1==0) {
@ -2177,7 +2177,7 @@ class Metier_Scoring_Base extends Metier_Scoring_Vars
if (count($tabP)>0) {
foreach ($tabP as $i=>$lien) {
if ($lien->siren>100 && ($lien->MajMin=='+' || $lien->PDetention>50)) {
$lienInsee = new Metier_Insee_MInsee($this->db);
$lienInsee = new Metier_Insee_MInsee();
$this->NBFILLE++; // Nombre de participations à plus de 50%
if ($this->NBFILLE==1) {
$tabIdentiteP=$lienInsee->getIdentiteLight($lien->siren);
@ -2553,7 +2553,6 @@ class Metier_Scoring_Base extends Metier_Scoring_Vars
$this->ANNONCEINTERDIT=0;
$dirs = $iInsee->getDirigeants($siren, false);
$timer['getDirigeants'] = microtime(true);
//Metier_Util_Log::write('I', 'SCOREDIR = '. print_r($dirs,1), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$this->DIR_NB=$this->NBDIRLIENS=$this->NBDIRSCI=$this->NBDIRSCIADR=0;
if (count($dirs) > 0) {
foreach ($dirs as $nb => $dir) {
@ -3168,8 +3167,6 @@ class Metier_Scoring_Base extends Metier_Scoring_Vars
$encoursEstime=$plafondEstime;
}
// Metier_Util_Log::write('I', "INDISCORE B $encoursIni $encoursEstime $encours", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
// Si l'entreprise à moins de 12 mois, on divise son encours estimé par 2
if ($encoursEstime>0) {
$dateCre=$tabIdentite['DateCreaEn']*1;

View File

@ -14,7 +14,19 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
protected $clients = array();
/**
*
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Auth DB
* @param string $username
* @param string $password
* @param boolean $checkWs
@ -25,6 +37,12 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
$this->_password = $password;
$this->_hash = md5($username.'|'.$password);
$this->checkWs = $checkWs;
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -33,7 +51,7 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
public function limitClient($id = null)
{
if (is_array($id) && count($id)>0) {
if (is_array($id) && count($id) > 0) {
$this->clients = $id;
}
}
@ -44,7 +62,7 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
public function setTimeout($seconds = null)
{
if ($seconds===null) {
if ($seconds === null) {
return;
}
@ -57,34 +75,39 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
public function authenticate()
{
$userM = new Application_Model_Sdv1Utilisateurs();
try {
$qb = $this->conn->createQueryBuilder();
$qb->select(array('u.idClient', 'u.id', 'u.login', 'u.password', 'c.timeout'))
->from('sdv1.utilisateurs', 'u')
->join('u', 'sdv1.clients', 'c', 'u.idClient = c.id')
->where("u.login=:login")->setParameter('login', $this->_username)
->andWhere("u.actif=1")
->andWhere("u.deleted=0")
->andWhere("c.actif='Oui'");
if (count($this->clients) > 0) {
$qb->andWhere('u.idClient IN('.join(',', $this->clients).')');
}
$sql = $userM->select()
->setIntegrityCheck(false)
->from(array('u'=>'sdv1.utilisateurs'), array('u.idClient', 'u.id', 'u.login', 'u.password'))
->join(array('c'=>'sdv1.clients'), 'u.idClient = c.id', array('c.timeout'))
->where('u.login=?', $this->_username)
->where('u.actif=?', 1)
->where('u.deleted=?', 0)
->where('c.actif=?', 'Oui');
if ($this->checkWs) {
$qb->andWhere('u.accesWS=1');
}
if (count($this->clients) > 0) {
$sql->where('u.idClient IN('.join(',', $this->clients).')');
$stmt = $qb->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($this->checkWs) {
$sql->where('u.accesWS=?', 1);
}
$result = $userM->fetchRow($sql);
$identity = new stdClass();
$identity->username = $this->_username;
$identity->hash = $this->_hash;
if (null === $result) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity, array("Identifiant ou mot de passe invalid"));
if ($stmt->rowCount() == 0) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity,
array("Identifiant ou mot de passe invalid"));
} else {
$result = $stmt->fetch(PDO::FETC_OBJ);
if ($this->_password == $result->password
|| $this->_password == md5($result->login.'|'.$result->password)) {
@ -93,9 +116,11 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
if (!empty($result->dateDebutCompte) && $result->dateDebutCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$dateDebutCompte = mktime(0, 0, 0, substr($result->dateDebutCompte, 5, 2), substr($result->dateDebutCompte, 8, 2), substr($result->dateDebutCompte, 0, 4));
$dateDebutCompte = mktime(0, 0, 0, substr($result->dateDebutCompte, 5, 2),
substr($result->dateDebutCompte, 8, 2), substr($result->dateDebutCompte, 0, 4));
if ($today < $dateDebutCompte) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Date de validité dépassé"));
}
}
@ -104,9 +129,11 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
if (!empty($result->dateFinCompte) && $result->dateFinCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$dateFinCompte = mktime(0, 0, 0, substr($result->dateFinCompte, 5, 2), substr($result->dateFinCompte, 8, 2), substr($result->dateFinCompte, 0, 4));
$dateFinCompte = mktime(0, 0, 0, substr($result->dateFinCompte, 5, 2),
substr($result->dateFinCompte, 8, 2), substr($result->dateFinCompte, 0, 4));
if ($today > $dateFinCompte) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Date de validité dépassé"));
}
}
@ -117,7 +144,8 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
$identity->time = time() + $timeout;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Identification impossible"));
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Identification impossible"));
}
}
}

View File

@ -5,10 +5,23 @@ class Scores_Ws_Trigger
protected $event;
protected $events = null;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct($event, $userInfos)
{
$this->event = $event;
$this->userInfos = $userInfos;
$this->conn = Zend_Registry::get('doctrine');
}
/**
@ -21,21 +34,27 @@ class Scores_Ws_Trigger
$service = 'default';
}
$model = new Application_Model_Sdv1ClientsServicesTrigger();
$sql = $model->select()
->where('event=?', $this->event)
->where('idClient=?', $this->userInfos['idClient'])
->where('service=?', $service)
->where('login=? OR login=""', $login);
$result = $model->fetchAll($sql);
if (count($result)>0) {
foreach ($result as $item) {
$sql = "SELECT * FROM sdv1.clients_services_trigger
WHERE idClient=:client AND service=:service AND (login=:login OR login='')";
$stmtNb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tmp->action = $item->action;
$tmp->params = json_decode($item->actionParams, true);
$this->events[] = $tmp;
}
}
return count($result);
return $stmtNb;
}
/**
@ -86,24 +105,25 @@ class Scores_Ws_Trigger
}
try {
$model = new Application_Model_JoSurveillancesSite();
$data = array(
'source' => $args['source'],
'login' => $this->userInfos['login'],
'email' => $this->userInfos['email'],
'siren' => $args['siren'],
'nic' => $args['nic'],
'ref' => $ref,
$this->conn->insert('jo.surveillances_site', array(
'source' => $args['source'],
'login' => $this->userInfos['login'],
'email' => $this->userInfos['email'],
'siren' => $args['siren'],
'nic' => $args['nic'],
'ref' => $ref,
'encoursClient' => 0,
'rs' => $args['Nom'],
'cp' => $args['CP'],
'ville' => $args['Ville'],
'rs' => $args['Nom'],
'cp' => $args['CP'],
'ville' => $args['Ville'],
'dateAjout' => date('Y-m-d'),
'dateSuppr' => 0,
);
$model->insert($data);
));
return true;
} catch (Zend_Db_Exception $e) {
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
return false;