Merge remote-tracking branch 'origin/develop'

This commit is contained in:
Michael RICOIS 2017-02-10 11:36:24 +01:00
commit ac8d185c6e
38 changed files with 3787 additions and 2251 deletions

View File

@ -1,4 +1,8 @@
<?php <?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Processor\IntrospectionProcessor;
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{ {
protected function _initConfig() protected function _initConfig()
@ -96,10 +100,10 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
foreach ($services as $section => $params) { foreach ($services as $section => $params) {
if ($params['actif']) { if ($params['actif']) {
$route = new Zend_Controller_Router_Route($section.'/:version', array( $route = new Zend_Controller_Router_Route($section.'/:version', array(
'controller' => 'service', 'controller' => 'service',
'action' => 'index', 'action' => 'index',
'service' => $section, 'service' => $section,
'version' => '', 'version' => '',
)); ));
$router->addRoute($section, $route); $router->addRoute($section, $route);
} }
@ -107,17 +111,17 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
// Route pour WS Clients // Route pour WS Clients
$route = new Zend_Controller_Router_Route('clients/:client/:version', array( $route = new Zend_Controller_Router_Route('clients/:client/:version', array(
'controller' => 'service', 'controller' => 'service',
'action' => 'index', 'action' => 'index',
'service' => 'clients', 'service' => 'clients',
'client' => '', 'client' => '',
'version' => '' 'version' => ''
)); ));
$router->addRoute('client', $route); $router->addRoute('client', $route);
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array( $fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
'controller' => 'fichier', 'controller' => 'fichier',
'fichier' => '', 'fichier' => '',
)); ));
$router->addRoute('fichier', $fichierRoute); $router->addRoute('fichier', $fichierRoute);
return $router; return $router;
@ -194,4 +198,21 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
} }
} }
protected function _initLogger()
{
$config = new Zend_Config($this->getOptions());
$logFile = $config->profil->path->shared.'/log/application.log';
$log = new Logger('APP');
if (APPLICATION_ENV == 'development') {
$level = Logger::DEBUG;
} else {
$level = Logger::INFO;
}
$log->pushHandler(new StreamHandler($logFile), $level);
$log->pushProcessor(new IntrospectionProcessor());
Zend_Registry::set('logger', $log);
}
} }

View File

@ -7,7 +7,8 @@
"league/csv": "^8.1", "league/csv": "^8.1",
"doctrine/dbal": "^2.5", "doctrine/dbal": "^2.5",
"mikehaertl/phpwkhtmltopdf": "^2.2", "mikehaertl/phpwkhtmltopdf": "^2.2",
"guzzlehttp/guzzle": "^6.2" "guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22"
}, },
"include-path": ["library/"], "include-path": ["library/"],
"autoload": { "autoload": {

161
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f1e440444eb2e2707d495c95551a35f6", "content-hash": "1b530fbc9321c88cb523070b302fe495",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -285,20 +285,20 @@
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.5.5", "version": "v2.5.11",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9" "reference": "1b1effbddbdc0f40d1c8f849f44bcddac4f52a48"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", "url": "https://api.github.com/repos/doctrine/dbal/zipball/1b1effbddbdc0f40d1c8f849f44bcddac4f52a48",
"reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", "reference": "1b1effbddbdc0f40d1c8f849f44bcddac4f52a48",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": ">=2.4,<2.7-dev", "doctrine/common": ">=2.4,<2.8-dev",
"php": ">=5.3.2" "php": ">=5.3.2"
}, },
"require-dev": { "require-dev": {
@ -352,7 +352,7 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2016-09-09T19:13:33+00:00" "time": "2017-02-04T21:20:13+00:00"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -685,16 +685,16 @@
}, },
{ {
"name": "league/csv", "name": "league/csv",
"version": "8.1.2", "version": "8.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/csv.git", "url": "https://github.com/thephpleague/csv.git",
"reference": "33447984f7a7038fefaa5a6177e8407b66bc85b4" "reference": "ef7eef710810c8bd0cf9371582ccd0123ff96d4b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/csv/zipball/33447984f7a7038fefaa5a6177e8407b66bc85b4", "url": "https://api.github.com/repos/thephpleague/csv/zipball/ef7eef710810c8bd0cf9371582ccd0123ff96d4b",
"reference": "33447984f7a7038fefaa5a6177e8407b66bc85b4", "reference": "ef7eef710810c8bd0cf9371582ccd0123ff96d4b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -708,7 +708,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "8.1-dev" "dev-master": "8.2-dev"
} }
}, },
"autoload": { "autoload": {
@ -738,20 +738,20 @@
"read", "read",
"write" "write"
], ],
"time": "2016-10-27T11:21:24+00:00" "time": "2017-01-25T13:32:07+00:00"
}, },
{ {
"name": "mikehaertl/php-shellcommand", "name": "mikehaertl/php-shellcommand",
"version": "1.2.2", "version": "1.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mikehaertl/php-shellcommand.git", "url": "https://github.com/mikehaertl/php-shellcommand.git",
"reference": "0de4e2cce17936ec7cef60a62c722a4aaa56c18c" "reference": "a628505cd99b201375dd6bcd0b062ee07c8ba556"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mikehaertl/php-shellcommand/zipball/0de4e2cce17936ec7cef60a62c722a4aaa56c18c", "url": "https://api.github.com/repos/mikehaertl/php-shellcommand/zipball/a628505cd99b201375dd6bcd0b062ee07c8ba556",
"reference": "0de4e2cce17936ec7cef60a62c722a4aaa56c18c", "reference": "a628505cd99b201375dd6bcd0b062ee07c8ba556",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -774,7 +774,7 @@
"keywords": [ "keywords": [
"shell" "shell"
], ],
"time": "2016-07-16T09:42:31+00:00" "time": "2017-01-26T08:29:31+00:00"
}, },
{ {
"name": "mikehaertl/php-tmpfile", "name": "mikehaertl/php-tmpfile",
@ -861,6 +861,84 @@
], ],
"time": "2016-06-02T08:06:45+00:00" "time": "2016-06-02T08:06:45+00:00"
}, },
{
"name": "monolog/monolog",
"version": "1.22.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "~5.3"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"time": "2016-11-26T00:15:39+00:00"
},
{ {
"name": "psr/http-message", "name": "psr/http-message",
"version": "1.0.1", "version": "1.0.1",
@ -911,6 +989,53 @@
], ],
"time": "2016-08-06T14:39:51+00:00" "time": "2016-08-06T14:39:51+00:00"
}, },
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10T12:19:37+00:00"
},
{ {
"name": "zendframework/zendframework1", "name": "zendframework/zendframework1",
"version": "1.12.20", "version": "1.12.20",

View File

@ -27,16 +27,13 @@ WebService
- Créer les repertoires de données nécessaires - Créer les repertoires de données nécessaires
[WORKSPACE]/data/backoffice/ [WORKSPACE]/data/webservice/
- clients => lien symbolique vers les fichiers clients - cache
- conso => données à conserver, dossier persistent - logs
- datafile => lien symbolique vers les fichiers PDF, et autres des partenaires - sessions
- export - wsdl
- import - files
- log - greffes
- sources => lien symbolique vers les données des sources
- stats
- upload
Fonctionnement Fonctionnement

View File

@ -38,22 +38,22 @@ profil.infogreffe.cache.time = 8
profil.infogreffe.storage.path = "PROJECT_DIR/shared/datafile/greffes" profil.infogreffe.storage.path = "PROJECT_DIR/shared/datafile/greffes"
; Sphinx configuration ; Sphinx configuration
profil.sphinx.ent.host = "192.168.78.249" profil.sphinx.ent.host = "172.18.8.5"
profil.sphinx.ent.port = 9312 profil.sphinx.ent.port = 9312
profil.sphinx.ent.version = 2 profil.sphinx.ent.version = "2.2.10"
profil.sphinx.dir.host = "192.168.78.249" profil.sphinx.dir.host = "172.18.8.5"
profil.sphinx.dir.port = 9312 profil.sphinx.dir.port = 9312
profil.sphinx.dir.version = 2 profil.sphinx.dir.version = "2.2.10"
profil.sphinx.act.host = "192.168.78.249" profil.sphinx.act.host = "172.18.8.5"
profil.sphinx.act.port = 9312 profil.sphinx.act.port = 9312
profil.sphinx.act.version = 2 profil.sphinx.act.version = "2.2.10"
profil.sphinx.histo.host = "192.168.78.249" profil.sphinx.histo.host = "172.18.8.5"
profil.sphinx.histo.port = 9312 profil.sphinx.histo.port = 9312
profil.sphinx.histo.version = 2 profil.sphinx.histo.version = "2.2.10"
; For old configuration - see Configure.php ; For old configuration - see Configure.php
profil.db.metier.adapter=mysqli profil.db.metier.adapter=mysqli
profil.db.metier.params.host=192.168.78.249 profil.db.metier.params.host=172.18.8.5
profil.db.metier.params.username=wsuser profil.db.metier.params.username=wsuser
profil.db.metier.params.password=scores profil.db.metier.params.password=scores
profil.db.metier.params.dbname=sdv1 profil.db.metier.params.dbname=sdv1

View File

@ -493,6 +493,12 @@ class Metier_Bodacc_MBodacc
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Bodacc * Bodacc
* @param \Doctrine\DBAL\Connection $conn * @param \Doctrine\DBAL\Connection $conn
@ -505,6 +511,10 @@ class Metier_Bodacc_MBodacc
$this->conn = $conn; $this->conn = $conn;
} }
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
/* Charge toute la table des tribunaux pour ne pas lancer systématiquement des /* Charge toute la table des tribunaux pour ne pas lancer systématiquement des
* requètes sur le serveur MySQL lors des intégrations de Bodacc * requètes sur le serveur MySQL lors des intégrations de Bodacc
*/ */
@ -545,11 +555,18 @@ class Metier_Bodacc_MBodacc
return include $cache; return include $cache;
} else { } else {
$tribunaux = array(); $tribunaux = array();
$sql = "SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL"; $sql = "SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->execute(); try {
if ($stmt->rowCount()) { $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 ($t = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($t = $stmt->fetch(\PDO::FETCH_OBJ)) {
$dep = intval(substr($t->triCP, 0, 2)); $dep = intval(substr($t->triCP, 0, 2));
if ($dep == 97 || $dep == 98) { if ($dep == 97 || $dep == 98) {
@ -578,11 +595,18 @@ class Metier_Bodacc_MBodacc
return include $cache; return include $cache;
} else { } else {
$result = array(); $result = array();
$sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions"; $sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->execute(); try {
if ($stmt->rowCount()) { $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 ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$result[intval($row->codeFct)] = $row->libelle; $result[intval($row->codeFct)] = $row->libelle;
} }
@ -619,10 +643,18 @@ class Metier_Bodacc_MBodacc
FROM jo.tribunaux t, jo.tribunauxInsee i FROM jo.tribunaux t, jo.tribunauxInsee i
WHERE i.CodeInsee= :inseeCode AND i.triId=t.triId WHERE i.CodeInsee= :inseeCode AND i.triId=t.triId
ORDER BY t.triNumGreffe DESC, t.triId ASC"; ORDER BY t.triNumGreffe DESC, t.triId ASC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('inseeCode', $codeInseeCommune); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->bindValue('inseeCode', $codeInseeCommune);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
} }
@ -643,16 +675,24 @@ class Metier_Bodacc_MBodacc
t.triSiret, t.triAdrNum, t.triAdrIndRep, t.triAdrTypeVoie, t.triAdrVoie, t.triAdrComp, t.triSiret, t.triAdrNum, t.triAdrIndRep, t.triAdrTypeVoie, t.triAdrVoie, t.triAdrComp,
t.triVille, t.triStatut, t.triDateCessation, t.triCommentaire, t.triNumGreffe t.triVille, t.triStatut, t.triDateCessation, t.triCommentaire, t.triNumGreffe
FROM jo.tribunaux t WHERE t.triCP BETWEEN :dep1 AND :dep2 ORDER BY t.triType ASC"; FROM jo.tribunaux t WHERE t.triCP BETWEEN :dep1 AND :dep2 ORDER BY t.triType ASC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
if ($dep < 96) { try {
$stmt->bindValue('dep1', $dep.'000'); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('dep2', $dep.'999'); if ($dep < 96) {
} else { $stmt->bindValue('dep1', $dep.'000');
$stmt->bindValue('dep1', $dep.'00'); $stmt->bindValue('dep2', $dep.'999');
$stmt->bindValue('dep2', $dep.'99'); } else {
$stmt->bindValue('dep1', $dep.'00');
$stmt->bindValue('dep2', $dep.'99');
}
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
} }
$stmt->execute(); if ($stmtNb > 0) {
if ($stmt->rowCount()) {
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
} }
@ -666,10 +706,18 @@ class Metier_Bodacc_MBodacc
public function getTribunalIdCA($codeTribunal) public function getTribunalIdCA($codeTribunal)
{ {
$sql = "SELECT triIdSup FROM jo.tribunaux WHERE triCode = :code"; $sql = "SELECT triIdSup FROM jo.tribunaux WHERE triCode = :code";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('code', $codeTribunal); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->bindValue('code', $codeTribunal);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
return $stmt->fetch(\PDO::FETCH_ASSOC); return $stmt->fetch(\PDO::FETCH_ASSOC);
} }
@ -695,11 +743,18 @@ class Metier_Bodacc_MBodacc
return include $cache; return include $cache;
} else { } else {
$result = array(); $result = array();
$sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements"; $sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->execute(); try {
if ($stmt->rowCount()) { $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 ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$result[$row->codEven] = array( $result[$row->codEven] = array(
'libEven' => $row->libEven, 'libEven' => $row->libEven,
@ -726,11 +781,17 @@ class Metier_Bodacc_MBodacc
return include $cache; return include $cache;
} else { } else {
$result = array(); $result = array();
$sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises"; $sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises";
$stmt = $this->conn->prepare($sql); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$result[$row->libDeviseBodacc] = $row->devIso; $result[$row->libDeviseBodacc] = $row->devIso;
} }
@ -1170,7 +1231,7 @@ class Metier_Bodacc_MBodacc
} catch (\Doctrine\DBAL\DBALException $e) { } catch (\Doctrine\DBAL\DBALException $e) {
continue; continue;
} }
if ($stmt->rowCount()) { if ($stmt->rowCount() > 0) {
$tabPrenom = $stmt->fetch(\PDO::FETCH_ASSOC); $tabPrenom = $stmt->fetch(\PDO::FETCH_ASSOC);
// C'est plutôt le nom de famille au début de la chaîne // C'est plutôt le nom de famille au début de la chaîne
if ($i == 0) { if ($i == 0) {
@ -1209,12 +1270,20 @@ class Metier_Bodacc_MBodacc
$sql = "SELECT Bodacc_Code, Bodacc_Annee_Parution, Bodacc_Num, Num_Annonce, Tribunal_Dept, Tribunal_Code, Rubrique_Bodacc, length(annonce) as Long $sql = "SELECT Bodacc_Code, Bodacc_Annee_Parution, Bodacc_Num, Num_Annonce, Tribunal_Dept, Tribunal_Code, Rubrique_Bodacc, length(annonce) as Long
FROM jo.bodacc WHERE Bodacc_Code=:code AND Bodacc_Annee_Parution=:annee AND Bodacc_Num=:num"; FROM jo.bodacc WHERE Bodacc_Code=:code AND Bodacc_Annee_Parution=:annee AND Bodacc_Num=:num";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('code', $bodaccCode); try {
$stmt->bindValue('annee', $annee); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('num', $num); $stmt->bindValue('code', $bodaccCode);
$stmt->execute(); $stmt->bindValue('annee', $annee);
if ($stmt->rowCount()) { $stmt->bindValue('num', $num);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$result[] = array( $result[] = array(
'BodaccCode' => $ann->Bodacc_Code, 'BodaccCode' => $ann->Bodacc_Code,
@ -1301,10 +1370,18 @@ class Metier_Bodacc_MBodacc
$sql = "SELECT id, dep, nomJal, siteWeb, email, adresse, cp, ville, tel, fax, parution, aboAnnuel, infos $sql = "SELECT id, dep, nomJal, siteWeb, email, adresse, cp, ville, tel, fax, parution, aboAnnuel, infos
FROM jo.tabJAL WHERE dep = :dep"; FROM jo.tabJAL WHERE dep = :dep";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('dep', $dep); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->bindValue('dep', $dep);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
} }
@ -1316,10 +1393,18 @@ class Metier_Bodacc_MBodacc
$result = array(); $result = array();
$sql = "SELECT id, nomJal FROM jo.tabJAL WHERE sedDateAbo!=0 GROUP BY nomJal ORDER BY nomJal ASC"; $sql = "SELECT id, nomJal FROM jo.tabJAL WHERE sedDateAbo!=0 GROUP BY nomJal ORDER BY nomJal ASC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('dep', $dep); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->bindValue('dep', $dep);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$result['_'.$row->id] = $row->nomJal; $result['_'.$row->id] = $row->nomJal;
} }
@ -1338,37 +1423,69 @@ class Metier_Bodacc_MBodacc
{ {
$strEvenVtLg = " AND Rubrique!='ventes' AND typeEven NOT LIKE '%2700%' AND typeEven NOT LIKE '%2701%' AND typeEven NOT LIKE '%2702%' AND typeEven NOT LIKE '%2703%' AND typeEven NOT LIKE '%2710%' AND typeEven NOT LIKE '%2720%' AND typeEven NOT LIKE '%2721%' AND typeEven NOT LIKE '%2725%' AND typeEven NOT LIKE '%2730%' AND typeEven NOT LIKE '%2740%' AND typeEven NOT LIKE '%2750%' AND typeEven NOT LIKE '%2800%' AND typeEven NOT LIKE '%2840%' AND typeEven NOT LIKE '%2850%' AND typeEven NOT LIKE '%2851%' AND typeEven NOT LIKE '%2860%' AND typeEven NOT LIKE '%2870%' AND typeEven NOT LIKE '%2875%' AND typeEven NOT LIKE '%2880%' AND typeEven NOT LIKE '%2881%' AND typeEven NOT LIKE '%2885%' AND typeEven NOT LIKE '%2890%' AND typeEven NOT LIKE '%2891%' AND typeEven NOT LIKE '%2892%' "; $strEvenVtLg = " AND Rubrique!='ventes' AND typeEven NOT LIKE '%2700%' AND typeEven NOT LIKE '%2701%' AND typeEven NOT LIKE '%2702%' AND typeEven NOT LIKE '%2703%' AND typeEven NOT LIKE '%2710%' AND typeEven NOT LIKE '%2720%' AND typeEven NOT LIKE '%2721%' AND typeEven NOT LIKE '%2725%' AND typeEven NOT LIKE '%2730%' AND typeEven NOT LIKE '%2740%' AND typeEven NOT LIKE '%2750%' AND typeEven NOT LIKE '%2800%' AND typeEven NOT LIKE '%2840%' AND typeEven NOT LIKE '%2850%' AND typeEven NOT LIKE '%2851%' AND typeEven NOT LIKE '%2860%' AND typeEven NOT LIKE '%2870%' AND typeEven NOT LIKE '%2875%' AND typeEven NOT LIKE '%2880%' AND typeEven NOT LIKE '%2881%' AND typeEven NOT LIKE '%2885%' AND typeEven NOT LIKE '%2890%' AND typeEven NOT LIKE '%2891%' AND typeEven NOT LIKE '%2892%' ";
$sql = "SELECT Activite FROM jo.bodacc_detail WHERE siren=:siren AND Activite<>'' AND Activite NOT LIKE 'non precis%' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"; $sql = "SELECT Activite FROM jo.bodacc_detail WHERE siren=:siren AND Activite<>'' AND Activite NOT LIKE 'non precis%' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute();
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($fj < 7000 || $fj > 7999) {
$activite = trim($annCap['Activite']);
}
if ($activite == '' && ($fj > 90 && $fj < 94 || $fj > 9000 && $fj < 9400)) {
$sql = "SELECT Assoc_Objet, Assoc_NObjet FROM jo.asso WHERE siren=:siren AND (Assoc_Objet!='' OR Assoc_NObjet!='') ORDER BY Date_Parution DESC LIMIT 0,1";
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $stmt->bindValue('siren', $siren);
$stmt->execute(); $stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC); $annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
$activite = trim($annCap['Assoc_NObjet']); if ($fj < 7000 || $fj > 7999) {
if ($activite == '') { $activite = trim($annCap['Activite']);
$activite = trim($annCap['Assoc_Objet']); }
}
if ($activite == '' && ($fj > 90 && $fj < 94 || $fj > 9000 && $fj < 9400)) {
$sql = "SELECT Assoc_Objet, Assoc_NObjet FROM jo.asso
WHERE siren=:siren AND (Assoc_Objet!='' OR Assoc_NObjet!='')
ORDER BY Date_Parution DESC LIMIT 0,1";
$stmtNb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
$activite = trim($annCap['Assoc_NObjet']);
if ($activite == '') {
$activite = trim($annCap['Assoc_Objet']);
}
} }
} elseif ($activite == '' && ($fj < 7000 || $fj > 7999)) { } elseif ($activite == '' && ($fj < 7000 || $fj > 7999)) {
$sql = "SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt $sql = "SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt
FROM historiques.entrep e, historiques.texte x FROM historiques.entrep e, historiques.texte x
WHERE e.E1GSIR=:siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 AND x.annonceTxt LIKE '%ctivit%' WHERE e.E1GSIR=:siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 AND x.annonceTxt LIKE '%ctivit%'
GROUP BY e.ANBASE ORDER BY e.DATE DESC"; GROUP BY e.ANBASE ORDER BY e.DATE DESC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount()) { $stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if (($ann['CODEVE'] < 20) || ($ann['CODEVE'] >= 30 && $ann['CODEVE'] < 42) || ($ann['CODEVE'] >= 51 && $ann['CODEVE'] < 80)) { if (($ann['CODEVE'] < 20) || ($ann['CODEVE'] >= 30 && $ann['CODEVE'] < 42)
|| ($ann['CODEVE'] >= 51 && $ann['CODEVE'] < 80)) {
if (preg_match('/(.*)Activit(?:e|é)(?:.|)\:(.*)(?:Adresse(?:.*|)|Commentaires?|Administration|Etablissement principal|Date d\'effet|Date.de.d.but d.activit.|Capital|Nom commercial)(?:.|)\:/Uisu', $ann['annonceTxt'], $matches)) { if (preg_match('/(.*)Activit(?:e|é)(?:.|)\:(.*)(?:Adresse(?:.*|)|Commentaires?|Administration|Etablissement principal|Date d\'effet|Date.de.d.but d.activit.|Capital|Nom commercial)(?:.|)\:/Uisu', $ann['annonceTxt'], $matches)) {
if (strpos(substr($matches[1], -20), 'cess') === false && strpos(substr($matches[1], -20), 'date') === false) { if (strpos(substr($matches[1], -20), 'cess') === false
&& strpos(substr($matches[1], -20), 'date') === false) {
$activite = $matches[2]; $activite = $matches[2];
break; break;
} }

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,20 @@ class Metier_Partenaires_MAmabis
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->client = new SoapClient(null, array( $this->client = new SoapClient(null, array(
'location' => 'http://sw2.amabis.com:5100/', 'location' => 'http://sw2.amabis.com:5100/',
'uri' => 'http://www.amabis.com/ns.xsd', 'uri' => 'http://www.amabis.com/ns.xsd',
@ -51,16 +61,23 @@ class Metier_Partenaires_MAmabis
$adresse = addslashes(trim(preg_replace('/ +/', ' ', "$adrNum $adrIndRep $adrTypeVoie $adrLibVoie"))); $adresse = addslashes(trim(preg_replace('/ +/', ' ', "$adrNum $adrIndRep $adrTypeVoie $adrLibVoie")));
$ville = addslashes($ville); $ville = addslashes($ville);
$majForcee = false; $majForcee = false;
$stmtNb = 0;
try {
$sql = "SELECT zus, zru, zfu, cucs, rnvpStatut, rnvpCorr, rnvpTrt, adr3, adr4, adr5, adr6,
adr7, numVoieA, indRepA, typeVoieAlong, typeVoieAcourt, corpVoie, motDir, motDirD,
libVoieSec, adr4n32, adr4n38, clePostaleVoie, secteur, cleRoutage, cpx, cleAd,
codPaysIso2, codPaysIso3, libPays, codeInsee
FROM jo.zonage WHERE address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$sql = "SELECT zus, zru, zfu, cucs, rnvpStatut, rnvpCorr, rnvpTrt, adr3, adr4, adr5, adr6, if ($stmtNb > 0) {
adr7, numVoieA, indRepA, typeVoieAlong, typeVoieAcourt, corpVoie, motDir, motDirD,
libVoieSec, adr4n32, adr4n38, clePostaleVoie, secteur, cleRoutage, cpx, cleAd,
codPaysIso2, codPaysIso3, libPays, codeInsee
FROM jo.zonage WHERE address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$zones = $stmt->fetch(\PDO::FETCH_ASSOC); $zones = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($zones['rnvpStatut'] === null && $rnvp) { if ($zones['rnvpStatut'] === null && $rnvp) {
$majForcee = true; $majForcee = true;
@ -113,7 +130,7 @@ class Metier_Partenaires_MAmabis
} }
} }
if ($stmt->rowCount() == 0 || $majForcee) { if ($stmtNb == 0 || $majForcee) {
try { try {
// Le RNVP ne fonctionne pas sans la Raison Sociale qui est la 1ère ligne d'adresse // Le RNVP ne fonctionne pas sans la Raison Sociale qui est la 1ère ligne d'adresse
if (trim($raisonSociale) == '') { if (trim($raisonSociale) == '') {
@ -128,7 +145,6 @@ class Metier_Partenaires_MAmabis
new SoapParam('type=M', 'options') new SoapParam('type=M', 'options')
); );
/** Découpage des ZFU, CUCS etcs... **/ /** Découpage des ZFU, CUCS etcs... **/
$fp = fopen(LOG_PATH.'/amabis.log', 'a'); $fp = fopen(LOG_PATH.'/amabis.log', 'a');
fwrite($fp, date('d-m-Y H:i:s').' - '.implode("\n", $rep)."\n============================================================================\n"); fwrite($fp, date('d-m-Y H:i:s').' - '.implode("\n", $rep)."\n============================================================================\n");
@ -225,25 +241,45 @@ class Metier_Partenaires_MAmabis
$villeL = addslashes($ville); $villeL = addslashes($ville);
$sql = "SELECT dateInsert*1 as dateInsert FROM jo.zonage $sql = "SELECT dateInsert*1 as dateInsert FROM jo.zonage
WHERE address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'"; WHERE address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'";
$stmt = $this->conn->prepare($sql); $majNb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $majStmt = $this->conn->prepare($sql);
$majStmt->execute();
$majNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($majNb > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ); $result = $stmt->fetch(\PDO::FETCH_OBJ);
$dateInsert = $result->dateInsert; $dateInsert = $result->dateInsert;
if ($dateInsert != 0) { if ($dateInsert != 0) {
$this->conn->update('jo.zonage', array_merge($tabUpdate, try {
array('dateInsert' => $dateInsert)), $this->conn->update('jo.zonage', array_merge($tabUpdate,
array( array('dateInsert' => $dateInsert)),
'address' => $adresseL, array(
'adr_cp' => $cp, 'address' => $adresseL,
'adr_ville' => $villeL, 'adr_cp' => $cp,
)); 'adr_ville' => $villeL,
));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} }
} }
} }
if ($dateInsert == 0) { if ($dateInsert == 0) {
$this->conn->insert('jo.zonage', array_merge($tabInsert, $tabUpdate)); try {
$this->conn->insert('jo.zonage', array_merge($tabInsert, $tabUpdate));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} }
$tabTmp[0] = explode(',', $tabZones['LOCREFCLEP']); $tabTmp[0] = explode(',', $tabZones['LOCREFCLEP']);
@ -264,7 +300,13 @@ class Metier_Partenaires_MAmabis
'source' => 'Amabis', 'source' => 'Amabis',
'dateInsert' => date('YmdHis'), 'dateInsert' => date('YmdHis'),
); );
$this->conn->insert('jo.villesCP', $tabInsert); try {
$this->conn->insert('jo.villesCP', $tabInsert);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} }
/** Autres Informations de la RNVP **/ /** Autres Informations de la RNVP **/
@ -286,11 +328,19 @@ class Metier_Partenaires_MAmabis
$codeInsee = substr($codeRivoli, 0, 5); $codeInsee = substr($codeRivoli, 0, 5);
$sql = "SELECT typeZone, arreteDate, decretDate, decretNum, decretModifieDate, decretModifieNum, dateDebut, dateFin $sql = "SELECT typeZone, arreteDate, decretDate, decretNum, decretModifieDate, decretModifieNum, dateDebut, dateFin
FROM jo.zonageInsee WHERE codeInsee=:code"; FROM jo.zonageInsee WHERE codeInsee=:code";
$stmt = $this->conn->prepare($sql); $zonageNb = 0;
$stmt->bindValue('code', $codeInsee); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('code', $codeInsee);
$stmt->execute();
$zonageNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$tabRep['ZRR'] = $tabRep['AFR'] = 'NON'; $tabRep['ZRR'] = $tabRep['AFR'] = 'NON';
if ($stmt->rowCount() > 0) { if ($zonageNb > 0) {
while ($zones = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($zones = $stmt->fetch(\PDO::FETCH_ASSOC)) {
switch ($zones['typeZone']) { switch ($zones['typeZone']) {
case 'ZRR': case 'ZRR':

View File

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

View File

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

View File

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

View File

@ -13,6 +13,12 @@ class Metier_Partenaires_MCadastre
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Droits des locaux * Droits des locaux
* @var array * @var array
@ -65,7 +71,7 @@ class Metier_Partenaires_MCadastre
'MP' => 'Maison partagée par une limite territoriale', 'MP' => 'Maison partagée par une limite territoriale',
'PP' => 'ND', 'PP' => 'ND',
'SM' => 'Sol de maison', 'SM' => 'Sol de maison',
'U' => 'Etablissement industriel', 'U' => 'Etablissement industriel',
'U1' => 'Gare', 'U1' => 'Gare',
'U2' => 'Gare - Triage', 'U2' => 'Gare - Triage',
'U3' => 'Gare - Atelier matériel', 'U3' => 'Gare - Atelier matériel',
@ -133,7 +139,7 @@ class Metier_Partenaires_MCadastre
private static $natureParcelles = array( private static $natureParcelles = array(
'AB' => 'Terrains à batir', 'AB' => 'Terrains à batir',
'AG' => 'Terrains d\'agrément', 'AG' => 'Terrains d\'agrément',
'B' => 'Bois', 'B' => 'Bois',
'BF' => 'Futaies feuillues', 'BF' => 'Futaies feuillues',
'BM' => 'Futaies mixtes', 'BM' => 'Futaies mixtes',
'BO' => 'Oseraies', 'BO' => 'Oseraies',
@ -143,18 +149,18 @@ class Metier_Partenaires_MCadastre
'BT' => 'Taillies simples', 'BT' => 'Taillies simples',
'CA' => 'Carrières', 'CA' => 'Carrières',
'CH' => 'Chemins de fer, Canaux de Navigation', 'CH' => 'Chemins de fer, Canaux de Navigation',
'E' => 'Eaux', 'E' => 'Eaux',
'J' => 'Jardins', 'J' => 'Jardins',
'L' => 'Landes', 'L' => 'Landes',
'LB' => 'Landes Boisées', 'LB' => 'Landes Boisées',
'P' => 'Prés', 'P' => 'Prés',
'PA' => 'Pâtures ou Pâturages', 'PA' => 'Pâtures ou Pâturages',
'PC' => 'Pacages ou Pâtis', 'PC' => 'Pacages ou Pâtis',
'PE' => 'Prés d\'embouche', 'PE' => 'Prés d\'embouche',
'PH' => 'Herbages', 'PH' => 'Herbages',
'PP' => 'Prés, Pâtures ou Herbages plantes', 'PP' => 'Prés, Pâtures ou Herbages plantes',
'S' => 'Sols', 'S' => 'Sols',
'T' => 'Terre', 'T' => 'Terre',
'TP' => 'Terres plantées', 'TP' => 'Terres plantées',
'VE' => 'Vergers', 'VE' => 'Vergers',
'VI' => 'Vignes', 'VI' => 'Vignes',
@ -167,6 +173,10 @@ class Metier_Partenaires_MCadastre
public function __construct($conn = null) public function __construct($conn = null)
{ {
$this->conn = Zend_Registry::get('doctrine'); $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; $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, $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 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"; 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(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array( $format = array(
'idCentre' => $loc['INTCIF'], 'idCentre' => $loc['INTCIF'],
@ -307,15 +326,23 @@ class Metier_Partenaires_MCadastre
if ($siren === null) { if ($siren === null) {
$siren = $this->siren; $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, $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 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 FROM sdv1.cad_perpar p, sdv1.cad_permor e
WHERE e.DSIREN='$siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER"; WHERE e.DSIREN='$siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$stmt = $this->conn->executeQuery($sql);
$parcelles = array(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array( $format = array(
'idCentre' => $loc['INTCIF'], '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 $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 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; 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') { } elseif ($type == 'parcelle') {
$droitSql = " AND p.CCODRO='P'"; $droitSql = " AND p.CCODRO='P'";
if ($droit != 'P') { if ($droit != 'P') {
@ -397,7 +422,19 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT count(*) AS itemTotal, sum(p.DCNPAR) AS surfaceTotal $sql = "SELECT count(*) AS itemTotal, sum(p.DCNPAR) AS surfaceTotal
FROM sdv1.cad_perpar p, sdv1.cad_permor e 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; 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); $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); $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"; "WHERE e.DSIREN='$this->siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$sql = "SELECT * FROM ( ($locauxSql) UNION ALL ($parcellesSql) ) results"; $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(); $list = array();
if ($stmt->rowCount() > 0) { if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
// Libellé role // Libellé role
$result['roleLib'] = self::$codeDroit[trim($result['role'])]; $result['roleLib'] = self::$codeDroit[trim($result['role'])];

View File

@ -16,6 +16,12 @@ D. 067 200 329 I 2010-06-30 La CS est valide jusq'au 30/06/2010... Quid
*/ */
class Metier_Partenaires_MFacto class Metier_Partenaires_MFacto
{ {
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public $risqueImpaye = false; // Y a t'il un risque d'impayé ? public $risqueImpaye = false; // Y a t'il un risque d'impayé ?
public $risqueImpayeMois = 0; public $risqueImpayeMois = 0;
public $profilPayeur = 0; // 0:N/D, 1:Excellent, 2=Bon, 3=Normal, 4=Lent, 5=Mauvais ou Défaut public $profilPayeur = 0; // 0:N/D, 1:Excellent, 2=Bon, 3=Normal, 4=Lent, 5=Mauvais ou Défaut
@ -93,6 +99,10 @@ class Metier_Partenaires_MFacto
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
} }
public function setTypeFic($typeFic) public function setTypeFic($typeFic)
@ -150,11 +160,19 @@ class Metier_Partenaires_MFacto
WHERE siren=:siren AND (dateSuppr=0 OR dateConf>dateSuppr) WHERE siren=:siren AND (dateSuppr=0 OR dateConf>dateSuppr)
AND (dateFin=0 OR dateFin>NOW()) AND cs NOT IN (20,22,27,33,34) AND (dateFin=0 OR dateFin>NOW()) AND cs NOT IN (20,22,27,33,34)
ORDER BY dateConf DESC, dateInsert DESC"; ORDER BY dateConf DESC, dateInsert DESC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$tabRet = array(); $tabRet = array();
if ($stmt->rowCount() > 0) { if ($stmtNb > 0) {
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$dateEven = $tabCS['dateConf']; $dateEven = $tabCS['dateConf'];
if ($dateEven == '0000-00-00') { if ($dateEven == '0000-00-00') {
@ -179,15 +197,23 @@ class Metier_Partenaires_MFacto
public function getCoteSpecialeOld($siren) public function getCoteSpecialeOld($siren)
{ {
$sql = "SELECT DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE $sql = "SELECT DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE
FROM sdv1.ge_cs c LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=c.NUMGFH FROM sdv1.ge_cs c LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=c.NUMGFH
WHERE a.SIRENE=:siren ORDER BY a.SIRENE ASC, c.DATMAJ1 DESC"; WHERE a.SIRENE=:siren ORDER BY a.SIRENE ASC, c.DATMAJ1 DESC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$tabRet = array(); $tabRet = array();
if ($stmt->rowCount() > 0) { if ($stmtNb > 0) {
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabRet[] = array( $tabRet[] = array(
'DateEven' => $tabCS['DATMAJ1'], 'DateEven' => $tabCS['DATMAJ1'],
@ -228,10 +254,18 @@ class Metier_Partenaires_MFacto
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE
FROM sdv1.ge_paiements p LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=p.NUMACH FROM sdv1.ge_paiements p LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=p.NUMACH
WHERE a.SIRENE=:siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC"; WHERE a.SIRENE=:siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount() > 0) { $stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($tabPai = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($tabPai = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$nbJoursMoyen = $tabPai['nbJourRetard'] - $tabPai['nbJourPaiement']; $nbJoursMoyen = $tabPai['nbJourRetard'] - $tabPai['nbJourPaiement'];
if ($nbJoursMoyen < 6) { if ($nbJoursMoyen < 6) {
@ -387,10 +421,18 @@ class Metier_Partenaires_MFacto
WHERE idClient='SURBODPRDFTSRECOCASH' AND siren=:siren AND dateSuppr=0 WHERE idClient='SURBODPRDFTSRECOCASH' AND siren=:siren AND dateSuppr=0
AND ABS(DATEDIFF(dateAjout, NOW()))<365 AND ABS(DATEDIFF(dateAjout, NOW()))<365
ORDER BY dateConf DESC, dateAjout DESC"; ORDER BY dateConf DESC, dateAjout DESC";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount() > 0) { $stmt->bindValue('siren', $siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$dateMAJ = Metier_Util_Date::dateT('Y-m-d', 'M Y', $tabCS['dateAjout']); $dateMAJ = Metier_Util_Date::dateT('Y-m-d', 'M Y', $tabCS['dateAjout']);
$libProfil = "En date du $dateMAJ : Contentieux importants."; $libProfil = "En date du $dateMAJ : Contentieux importants.";

View File

@ -7,12 +7,22 @@ class Metier_Partenaires_MGreffes
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Greffes * Greffes
*/ */
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $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 dateRadiation, dateCloture, ca, res, eff, dateInsert
FROM jo.greffes_identite WHERE siren=:siren"; FROM jo.greffes_identite WHERE siren=:siren";
$nb = 0;
try { try {
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $stmt->bindValue('siren', $siren);
$stmt->execute(); $stmt->execute();
$nb = $stmt->rowCount();
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),
);
}
} catch(\Doctrine\DBAL\DBALException $e) { } 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; return false;
@ -85,34 +97,40 @@ class Metier_Partenaires_MGreffes
dateLJS, dateInventaire, dateBodacc, caDeclare, effectif, descriptif, pdfLink, pdfSize, dateLJS, dateInventaire, dateBodacc, caDeclare, effectif, descriptif, pdfLink, pdfSize,
pdfVer, pdfPage, descDateDepot, dateLimite, mandataire, dateInsert pdfVer, pdfPage, descDateDepot, dateLimite, mandataire, dateInsert
FROM jo.greffes_cessions WHERE siren=:siren"; FROM jo.greffes_cessions WHERE siren=:siren";
$nb = 0;
try { try {
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $stmt->bindValue('siren', $siren);
$stmt->execute(); $stmt->execute();
$nb = $stmt->rowCount();
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'],
);
}
} catch(\Doctrine\DBAL\DBALException $e) { } 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; return false;

View File

@ -4,6 +4,12 @@ require_once __DIR__ . '/MMapFunctions.php';
class Metier_Partenaires_MMap class Metier_Partenaires_MMap
{ {
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
private $referer =''; private $referer ='';
private $body = ''; private $body = '';
private $header = ''; private $header = '';

View File

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

View File

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

View File

@ -1,27 +1,40 @@
<?php <?php
require_once 'framework/common/curl.php';
class Metier_Partenaires_MQualibat class Metier_Partenaires_MQualibat
{ {
private $referer =''; protected $iBodacc;
private $body = ''; protected $iInsee;
private $header = '';
private $cookie = '';
private $codeRetour = 0;
private $accesDist=true;
private $iDb;
private $iBodacc;
private $iInsee;
public $enCache=false; /**
public $force=false; * PDO Connection with Doctrine
public $annee=0; * @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Enable remote
* @var string
*/
protected $remote = false; protected $remote = false;
public function __construct($accesDist = true) /**
* MQualibat
*/
public function __construct()
{ {
$this->accesDist = $accesDist; $this->conn = Zend_Registry::get('doctrine');
$this->iDb = new Metier_Util_Db();
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->iBodacc = new Metier_Bodacc_MBodacc(); $this->iBodacc = new Metier_Bodacc_MBodacc();
$this->iInsee = new Metier_Insee_MInsee(); $this->iInsee = new Metier_Insee_MInsee();
} }
@ -77,23 +90,40 @@ class Metier_Partenaires_MQualibat
public function getMaxQualibat() public function getMaxQualibat()
{ {
$ret = $this->iDb->select('sdv1.qualibat', 'MAX(id) AS id', '1', false, MYSQL_ASSOC); $sql = "SELECT MAX(id) AS id FROM sdv1.qualibat";
return $ret[0]['id']; 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() public function getTabQualibatManquants()
{ {
$tabRet = $tabQualibatCalc = $tabQualibatBase = array(); $tabRet = $tabQualibatCalc = $tabQualibatBase = array();
// Liste des Qualibat Calculés // Liste des Qualibat Calculés
$maxQualibat = $this->getMaxQualibat(); $maxQualibat = $this->getMaxQualibat();
for ($i=1; $i<=$maxQualibat; $i++) { for ($i=1; $i<=$maxQualibat; $i++) {
$tabQualibatCalc[]=$i; $tabQualibatCalc[] = $i;
} }
// Liste des Qualibat en base // Liste des Qualibat en base
$ret = $this->iDb->select('sdv1.qualibat', 'id', '1 ORDER BY id ASC', false, MYSQL_ASSOC); $sql = "SELECT id FROM sdv1.qualibat ORDER BY id ASC";
foreach ($ret as $i=>$res) { try {
$tabQualibatBase[]=$res['id']; $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); return array_diff($tabQualibatCalc, $tabQualibatBase);
@ -109,34 +139,56 @@ class Metier_Partenaires_MQualibat
return false; return false;
} }
$ret = $this->iDb->select( $sql = "SELECT siren, actif, id, nom, adresse, cp, ville, tel, fax, email, web, eff, teff,
'sdv1.qualibat', 'siren, actif, id, nom, adresse, cp, ville, tel, fax, email, web, ca, tca, libFJ, nace, dateFondation, dateDeb, dateFin, dateInsert
eff, teff, ca, tca, libFJ, nace, dateFondation, dateDeb, dateFin, dateInsert', FROM sdv1.qualibat WHERE $strWhere";
$strWhere, false, MYSQL_ASSOC); try {
$stmt = $this->conn->executeQuery($sql);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
// In database // In database
if (!$this->force && count($ret) > 0) { if ($this->remote === false && $stmt->rowCount() > 0) {
$this->enCache=true; $tabRet = $stmt->fetch(\PDO::FETCH_ASSOC);
$tabRet = $ret[0];//array();
// Ajout des qualifications // Ajout des qualifications
$ret = $this->iDb->select( $sql = "SELECT code, periodQualif, niveauQualif, mentions, nomQualif, dateAttrib, dateEch
'sdv1.qualibatqualif', 'code, periodQualif, niveauQualif, mentions, nomQualif, dateAttrib, dateEch', FROM sdv1.qualibatqualif WHERE $strWhere";
$strWhere, false, MYSQL_ASSOC); try {
foreach ($ret as $i => $tabTmp) { $stmt = $this->conn->executeQuery($sql);
$tabRet['qualifications'][] = $tabTmp; 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 // Ajout des dirigeants
$ret = $this->iDb->select( $sql = "SELECT civNomPrenom, civilite, nom, prenom, fonction
'sdv1.qualibatdir', 'civNomPrenom, civilite, nom, prenom, fonction', FROM sdv1.qualibatdir WHERE $strWhere";
$strWhere, false, MYSQL_ASSOC); try {
foreach ($ret as $i => $tabTmp) { $stmt = $this->conn->executeQuery($sql);
$tabRet['dirigeants'][] = $tabTmp; 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 // WebSite
elseif ($this->accesDist == true) { if ($this->remote === true) {
$this->enCache = false;
$url = 'http://www.qualibat.com/Views/EntreprisesRechercheDetail.aspx?id='.$idQualibat; $url = 'http://www.qualibat.com/Views/EntreprisesRechercheDetail.aspx?id='.$idQualibat;
$page = getUrl($url, '', '', '', false, '', '', 3); $page = getUrl($url, '', '', '', false, '', '', 3);
if ($page['code'] != 200) { if ($page['code'] != 200) {
@ -258,10 +310,10 @@ class Metier_Partenaires_MQualibat
foreach ($matches[1] as $i => $nom) { foreach ($matches[1] as $i => $nom) {
$strNom = trim($nom); $strNom = trim($nom);
switch (strtoupper(substr($strNom, 0, 6))) { switch (strtoupper(substr($strNom, 0, 6))) {
case 'MONSIE': $civ='M'; $pDeb=8; break; case 'MONSIE': $civ='M'; $pDeb=8; break;
case 'MADAME': $civ='MME'; $pDeb=6; break; case 'MADAME': $civ='MME'; $pDeb=6; break;
case 'MADEMO': $civ='MLLE';$pDeb=12; break; case 'MADEMO': $civ='MLLE'; $pDeb=12; break;
default: $civ=''; $pDeb=0; break; default: $civ=''; $pDeb=0; break;
} }
$libFonction = ucwords(strtolower(trim($matches[2][$i]))); $libFonction = ucwords(strtolower(trim($matches[2][$i])));
$tabRet['dirigeants'][$i] = array( $tabRet['dirigeants'][$i] = array(
@ -282,8 +334,19 @@ class Metier_Partenaires_MQualibat
'dateDeb' => @$tabDateAttrib[0], 'dateDeb' => @$tabDateAttrib[0],
'dateFin' => @$tabDateFin[0])); 'dateFin' => @$tabDateFin[0]));
unset($tabInsert['qualifications']); 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 **/ /** Insertion des qualifications **/
@ -292,8 +355,24 @@ class Metier_Partenaires_MQualibat
$tabInsert['id'] = $idQualibat; $tabInsert['id'] = $idQualibat;
$tabInsert['siren'] = $siren; $tabInsert['siren'] = $siren;
$tabInsert['dateInsert'] = date('YmdHis'); $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['id'] = $idQualibat;
$tabInsert['siren'] = $siren; $tabInsert['siren'] = $siren;
$tabInsert['dateInsert'] = date('YmdHis'); $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']); unset($tabRet['dirigeants'][$i]['civNomPrenom']);
} }
} }
return $tabRet; return $tabRet;
} else { } else {
$tabInsert = array( $tabInsert = array(
'actif' => 0, 'actif' => 0,
'id' => $idQualibat, 'id' => $idQualibat,
'idQualibatAttribue' => 0, 'idQualibatAttribue' => 0,
'dateInsert' => date('YmdHis') 'dateInsert' => date('YmdHis')
); );
$this->erreur = 'Numéro Qualibat inexistant'; $this->erreur = 'Numéro Qualibat inexistant';
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué // On enregistre ce numéro comme non attribué si < au dernier numéro attribué
if ($idQualibat < $this->getMaxQualibat()) { 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;
} }
} }
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; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Flag to get remote data * Flag to get remote data
* @var string * @var string
@ -71,6 +77,10 @@ class Metier_Partenaires_MRncs
{ {
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->tabDevises = $this->getTabDevisesInpi(); $this->tabDevises = $this->getTabDevisesInpi();
$this->tabPays = $this->getTabPaysInpi(); $this->tabPays = $this->getTabPaysInpi();
$this->tabTribunaux = $this->getTabTribunaux(); $this->tabTribunaux = $this->getTabTribunaux();
@ -109,13 +119,24 @@ class Metier_Partenaires_MRncs
return include $cache; return include $cache;
} else { } else {
$sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC"; $sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabDevises[intval($item->devInpi)] = $item->devIso; $tabDevises[intval($item->devInpi)] = $item->devIso;
} }
} }
return $tabDevises; return $tabDevises;
} }
} }
@ -146,9 +167,19 @@ class Metier_Partenaires_MRncs
} else { } else {
$tabJug = array(); $tabJug = array();
$sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs"; $sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$stmt = $conn->prepare($sql);
$stmt->execute(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabJug[intval($item->codJugement)] = $item->codEven; $tabJug[intval($item->codJugement)] = $item->codEven;
} }
@ -178,9 +209,19 @@ class Metier_Partenaires_MRncs
} else { } else {
$tabPays = array(); $tabPays = array();
$sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC"; $sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tabPays[$item->codePaysInpi*1] = $item->codPays; $tabPays[$item->codePaysInpi*1] = $item->codPays;
} }
@ -195,12 +236,24 @@ class Metier_Partenaires_MRncs
*/ */
protected function getTabMandataires() protected function getTabMandataires()
{ {
$tabMandSD = array();
$sql = "SELECT UPPER(CONCAT(SUBSTRING(Nom,1,4),'-',SUBSTRING(Prenom,1,3))) AS NomPre, $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, 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 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"; 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)) { while ($mand = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabMandSD[] = array( $tabMandSD[] = array(
'id' => $mand['id'], 'id' => $mand['id'],
@ -246,13 +299,22 @@ class Metier_Partenaires_MRncs
WHERE TYPE IN ('A', 'M') AND (Nom!='' OR Prenom!='') WHERE TYPE IN ('A', 'M') AND (Nom!='' OR Prenom!='')
AND MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE) AND MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE)
ORDER BY score DESC LIMIT 0,10"; ORDER BY score DESC LIMIT 0,10";
$stmt = $this->conn->prepare($sql); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() == 1) { $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); $result = $stmt->fetch(\PDO::FETCH_ASSOC);
$this->matching = $result['score']; $this->matching = $result['score'];
return $result['id']; return $result['id'];
} elseif ($stmt->rowCount() > 1) { } elseif ($nb > 1) {
while ($iRet = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($iRet = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($debug) { if ($debug) {
echo "je compare '$cp' avec '".$iRet['cp']."' et '$ville' avec '".$iRet["ville"]."' (score=".$iRet['score'].")\n"; 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 { } else {
$tabTribunaux = array(); $tabTribunaux = array();
$sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL"; $sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute(); $nb = 0;
if ($stmt->rowCount() > 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)) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabTribunaux[$item->triNumGreffe*1] = array( $tabTribunaux[$item->triNumGreffe*1] = array(
'Id' => $item->triId, 'Id' => $item->triId,
@ -321,8 +393,20 @@ class Metier_Partenaires_MRncs
$fj = $code_forme_juridique*1; $fj = $code_forme_juridique*1;
$label = 'En instance de chiffrement'; $label = 'En instance de chiffrement';
if ($fj > 0 && $fj < 10000) { if ($fj > 0 && $fj < 10000) {
$stmt = $this->conn->executeQuery("SELECT libelle AS LibFJ FROM jo.tabFJur WHERE code=$fj"); $sql = "SELECT libelle AS LibFJ FROM jo.tabFJur WHERE code=$fj";
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); $result = $stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['LibFJ']; $label = $result['LibFJ'];
} }
@ -338,10 +422,22 @@ class Metier_Partenaires_MRncs
*/ */
private function getLibelleNaf($codeNaf) private function getLibelleNaf($codeNaf)
{ {
$stmt = $this->conn->executeQuery("SELECT libNaf700 AS LibNaf FROM jo.tabNaf4 WHERE codNaf700='$codeNaf' $sql = "SELECT libNaf700 AS LibNaf FROM jo.tabNaf4 WHERE codNaf700='$codeNaf'
UNION SELECT libNaf5 AS LibNaf FROM jo.tabNaf5 WHERE codNaf5='$codeNaf'"); UNION SELECT libNaf5 AS LibNaf FROM jo.tabNaf5 WHERE codNaf5='$codeNaf'";
$label = "Inconnu"; $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); $result = $stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['LibNaf']; $label = $result['LibNaf'];
} }
@ -412,10 +508,19 @@ class Metier_Partenaires_MRncs
adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3, adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3,
naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate
FROM jo.rncs_etab WHERE siren=:siren $strSql"; FROM jo.rncs_etab WHERE siren=:siren $strSql";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() == 0) { $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; 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 $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"; FROM jo.rncs_entrep WHERE siren=:siren";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $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); $entrep = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($entrep['jourUpdate'] != '0000-00-00') { if ($entrep['jourUpdate'] != '0000-00-00') {
$dateMaj = $entrep['jourUpdate']; $dateMaj = $entrep['jourUpdate'];
@ -539,6 +654,8 @@ class Metier_Partenaires_MRncs
*/ */
public function getListeDepots($siren, $dateDepot = null) 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 $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"; 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"; $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'"; $where = " e.siren=$siren AND e.dateDepot='$dateDepot'";
} }
$sql.= " WHERE ".$where; $sql.= " WHERE ".$where;
$stmt = $this->conn->prepare($sql);
$stmt->execute(); $nb = 0;
$tabDepots = array(); try {
if ($stmt->rowCount() > 0) { $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)) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array( $tabDepots[] = array(
'codDepot' => $result['codeEven'], '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 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 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"; 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); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $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)) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array( $tabDepots[] = array(
'codEven' => $result['codEven'], 'codEven' => $result['codEven'],
@ -662,10 +798,20 @@ class Metier_Partenaires_MRncs
$sql = "SELECT siren, nic, `table`, champs, valeur, flux, dateInsert FROM jo.rncs_modifs $sql = "SELECT siren, nic, `table`, champs, valeur, flux, dateInsert FROM jo.rncs_modifs
WHERE siren=:siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep' WHERE siren=:siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep'
ORDER BY flux DESC"; ORDER BY flux DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $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)) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$codEve = array(); $codEve = array();
switch ($result['champs']) { switch ($result['champs']) {
@ -807,10 +953,20 @@ class Metier_Partenaires_MRncs
FROM jo.annonces WHERE siren=:siren $strDates FROM jo.annonces WHERE siren=:siren $strDates
AND ( inter1type $strTypes OR inter2type $strTypes OR inter3type $strTypes OR inter4type $strTypes ) AND ( inter1type $strTypes OR inter2type $strTypes OR inter3type $strTypes OR inter4type $strTypes )
AND typeEven BETWEEN 1000 AND 2000 ORDER BY dateJugement DESC"; AND typeEven BETWEEN 1000 AND 2000 ORDER BY dateJugement DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $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); $result = $stmt->fetch(\PDO::FETCH_ASSOC);
$tabRet['dateCessationPaiement'] = $depot['dateCessationPaiement']; $tabRet['dateCessationPaiement'] = $depot['dateCessationPaiement'];
for ($i=1; $i<4; $i++) { for ($i=1; $i<4; $i++) {
@ -1079,15 +1235,25 @@ class Metier_Partenaires_MRncs
{ {
$siren = $siren*1; $siren = $siren*1;
$tabRet = array(); $tabRet = array();
$numDir = 0;
$sql = "SELECT siren, raisonSociale, dirRS, civilite, nom, prenom, naissance_nom, naissance_date, $sql = "SELECT siren, raisonSociale, dirRS, civilite, nom, prenom, naissance_nom, naissance_date,
naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert 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"; 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); $nb = 0;
$stmt->execute(); try {
$numDir = 0; $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount() > 0) { $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)) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$numDir++; $numDir++;
if ($result['naissance_date'] != '0000-00-00') { if ($result['naissance_date'] != '0000-00-00') {
@ -1126,16 +1292,26 @@ class Metier_Partenaires_MRncs
} }
} }
} else { } else {
$sql = "SELECT siren, raisonSociale, '' AS dirRS, IF(sexe='M', 'M', IF(sexe='F', 'MME', '')) AS civilite, $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, 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 1050 AS fonction_code, 'Personne Physique' AS fonction_lib, 0 AS cinf, dateFer AS dateFin, flux, dateInsert
FROM jo.rncs_entrep WHERE siren=:siren"; FROM jo.rncs_entrep WHERE siren=:siren";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $nb = 0;
$stmt->execute(); try {
if ($stmt->rowCount() > 0) { $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; $numDir = 0;
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($result = $stmt2->fetch(\PDO::FETCH_ASSOC)) {
$numDir++; $numDir++;
if ($result['naissance_date'] != '0000-00-00') { if ($result['naissance_date'] != '0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['naissance_date']); $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() public function __construct()
{ {
$this->iDb = new Metier_Util_Db(); $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; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Tel
*/
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $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 partenaireConf, nbConf, idUpdate, dateUpdate, dateUpdate*1 AS dateUpdateYmd
FROM jo.telephonie WHERE siren=:siren $strNic $strActif AND dateSuppr=0 FROM jo.telephonie WHERE siren=:siren $strNic $strActif AND dateSuppr=0
ORDER BY typeTel ASC, nbConf DESC"; ORDER BY typeTel ASC, nbConf DESC";
$nb = 0;
try { try {
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren); $stmt->bindValue('siren', $siren);
$stmt->execute(); $stmt->execute();
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) { } catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
return $tabRet; return $tabRet;
} }
if ($stmt->rowCount() > 0) { if ($nb > 0) {
$this->enCache = true; $this->enCache = true;
while ($tabTel = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($tabTel = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($tabTel['typeTel'] == 'an8' && $tabTel['infoTel']*1 > 0) { if ($tabTel['typeTel'] == 'an8' && $tabTel['infoTel']*1 > 0) {
$an8 = $tabTel['infoTel']*1; $an8 = $tabTel['infoTel']*1;
$sql = "SELECT libAn8 FROM jo.tabAn8 WHERE codAn8='$an8'"; $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 = ''; $infoTel = '';
if ($an8Stmt->rowCount() > 0) { if ($an8Nb > 0) {
$result = $an8Stmt->fetch(\PDO::FETCH_ASSOC); $result = $an8Stmt->fetch(\PDO::FETCH_ASSOC);
$label = $result['libAn8']; $label = $result['libAn8'];
$infoTel = ucfirst(strtolower($label)); $infoTel = ucfirst(strtolower($label));

View File

@ -27,6 +27,12 @@ class Metier_Partenaires_MTva
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Remote Flag * Remote Flag
* @var boolean * @var boolean
@ -40,6 +46,10 @@ class Metier_Partenaires_MTva
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
} }
/** /**
@ -74,10 +84,18 @@ class Metier_Partenaires_MTva
$sql = "SELECT LPAD(cle,2,0) AS cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ $sql = "SELECT LPAD(cle,2,0) AS cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ
FROM sdv1.siren_tva WHERE siren=:siren"; FROM sdv1.siren_tva WHERE siren=:siren";
$stmt = $this->conn->prepare($sql); $stmtNb = 0;
$stmt->bindValue('siren', $this->siren); try {
$stmt->execute(); $stmt = $this->conn->prepare($sql);
if ($stmt->rowCount() > 0) { $stmt->bindValue('siren', $this->siren);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
$exist = true; $exist = true;
$result = $stmt->fetch(\PDO::FETCH_OBJ); $result = $stmt->fetch(\PDO::FETCH_OBJ);
$cle = $result->cle; $cle = $result->cle;
@ -104,7 +122,7 @@ class Metier_Partenaires_MTva
return true; return true;
} }
Metier_Util_Log::write('W', "Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s. Cas impossible !", __LINE__, __FILE__, __FUNCTION__, __CLASS__); $this->logger->error("Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Cas impossible !");
return true; return true;
} }
@ -160,11 +178,23 @@ class Metier_Partenaires_MTva
if (preg_match('/Yes, valid VAT number/i', $body) if (preg_match('/Yes, valid VAT number/i', $body)
|| preg_match('/Oui, numéro de TVA valide/i', $body)) { || preg_match('/Oui, numéro de TVA valide/i', $body)) {
if ($exist) { if ($exist) {
$this->conn->update('sdv1.siren_tva', array('cle' => intval($this->cle), try {
$this->conn->update('sdv1.siren_tva', array('cle' => intval($this->cle),
'duree' => $time), array('siren' => $this->siren)); 'duree' => $time), array('siren' => $this->siren));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} else { } else {
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren, try {
'cle' => intval($this->cle), 'duree' => $time)); $this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
'cle' => intval($this->cle), 'duree' => $time));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} }
$this->vatNumber = "FR".$this->cle.$this->siren; $this->vatNumber = "FR".$this->cle.$this->siren;
$this->vatDefined = true; $this->vatDefined = true;
@ -172,16 +202,28 @@ class Metier_Partenaires_MTva
} }
} }
} catch (RequestException $e) { } catch (RequestException $e) {
Metier_Util_Log::write('I', "TVA ".$e->getMessage(), __LINE__, __FILE__, __FUNCTION__, __CLASS__); $this->logger->error($e->getMessage());
} }
// Non disponible // Non disponible
if ($exist) { if ($exist) {
$this->conn->update('sdv1.siren_tva', array('cle' => 'NULL', 'duree' => $time), try {
array('siren' => $this->siren)); $this->conn->update('sdv1.siren_tva', array('cle' => 'NULL', 'duree' => $time),
array('siren' => $this->siren));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} else { } else {
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren, try {
'cle' => 'NULL', 'duree' => $time)); $this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
'cle' => 'NULL', 'duree' => $time));
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} }
$this->vatNumber = "FR".$this->cle.$this->siren; $this->vatNumber = "FR".$this->cle.$this->siren;

View File

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

View File

@ -6,6 +6,12 @@ class Metier_Util_Db
*/ */
protected $db = null; protected $db = null;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* *
* @var unknown * @var unknown
@ -21,6 +27,10 @@ class Metier_Util_Db
if ($db === null) { if ($db === null) {
$this->db = Zend_Db_Table::getDefaultAdapter(); $this->db = Zend_Db_Table::getDefaultAdapter();
} }
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
} }
/** /**
@ -265,11 +275,14 @@ class Metier_Util_Db
$duree = 'N/D'; $duree = 'N/D';
} }
if ($this->errorCode == 0) { if ($this->errorCode == 0) {
$msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; if ($this->logger != null) {
$this->logger->debug($this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree);
}
} else { } else {
$msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; if ($this->logger != null) {
$this->logger->error($this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree);
}
} }
file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND);
} }
/** /**

View File

@ -1,74 +0,0 @@
<?php
class Metier_Util_PdoLib
{
/**
*
* @var \PDO
*/
protected $conn = false;
/**
* Connection PDO
* Note : Transition avant de faire les librairies Metier PSR-4
* @param array $config
* 'host' => 'IP',
* 'port' => '3306',
* 'dbname' => 'db',
* 'charset' => 'utf8',
* 'user' => 'user',
* 'password' => 'password',
* @return boolean|PDO
*/
public function __construct(array $config = array())
{
$user = null;
$password = null;
$options = array();
// Get Application config from registry
if (count($config) == 0) {
$c = Zend_Registry::get('config');
$params = $c->profil->db->metier->params;
$dsn = "mysql:host=".$params->host.
";port=".(isset($params->port) ? $params->port : '3306').
";dbname=".$params->dbname.
";charset=utf8";
$user = $params->username;
$password = $params->password;
}
// Get config from params
else {
$dsn = "mysql:host=".$config['host'].
";port=".(isset($config['port']) ? $config['port'] : '3306').
";dbname=".$config['dbname'].
";charset=".(isset($config['charset']) ? $config['charset'] : 'utf8');
if (array_key_exists('username', $config)) {
$user = $config['username'];
}
if (array_key_exists('password', $config)) {
$password = $config['password'];
}
if (array_key_exists('options', $config)) {
$options = $config['options'];
}
}
// Try to load PDO
try {
$this->conn = new PDO($dsn, $user, $password, $options);
$this->conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo $e->getMessage();
$this->conn = false;
}
}
/**
* Get connection
* @return PDO
*/
public function getConnection()
{
return $this->conn;
}
}

View File

@ -14,7 +14,19 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
protected $clients = array(); 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 $username
* @param string $password * @param string $password
* @param boolean $checkWs * @param boolean $checkWs
@ -25,6 +37,12 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
$this->_password = $password; $this->_password = $password;
$this->_hash = md5($username.'|'.$password); $this->_hash = md5($username.'|'.$password);
$this->checkWs = $checkWs; $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) public function limitClient($id = null)
{ {
if (is_array($id) && count($id)>0) { if (is_array($id) && count($id) > 0) {
$this->clients = $id; $this->clients = $id;
} }
} }
@ -44,7 +62,7 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/ */
public function setTimeout($seconds = null) public function setTimeout($seconds = null)
{ {
if ($seconds===null) { if ($seconds === null) {
return; return;
} }
@ -57,34 +75,39 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/ */
public function authenticate() 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() if ($this->checkWs) {
->setIntegrityCheck(false) $qb->andWhere('u.accesWS=1');
->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 (count($this->clients) > 0) { $stmt = $qb->execute();
$sql->where('u.idClient IN('.join(',', $this->clients).')'); } 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 = new stdClass();
$identity->username = $this->_username; $identity->username = $this->_username;
$identity->hash = $this->_hash; $identity->hash = $this->_hash;
if (null === $result) { if ($stmt->rowCount() == 0) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity, array("Identifiant ou mot de passe invalid")); return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity,
array("Identifiant ou mot de passe invalid"));
} else { } else {
$result = $stmt->fetch(PDO::FETC_OBJ);
if ($this->_password == $result->password if ($this->_password == $result->password
|| $this->_password == md5($result->login.'|'.$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') { if (!empty($result->dateDebutCompte) && $result->dateDebutCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $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) { 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') { if (!empty($result->dateFinCompte) && $result->dateFinCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $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) { 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; $identity->time = time() + $timeout;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity); return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else { } 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

@ -240,6 +240,12 @@ class Scores_Ws_Server
*/ */
protected $conn; protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/** /**
* Server SOAP * Server SOAP
* Document/Literal Wrapped - WS-I Compliant * Document/Literal Wrapped - WS-I Compliant
@ -247,6 +253,11 @@ class Scores_Ws_Server
public function __construct() public function __construct()
{ {
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$this->listeDroits = include APPLICATION_PATH . '/../library/Scores/Account/Access.php'; $this->listeDroits = include APPLICATION_PATH . '/../library/Scores/Account/Access.php';
$this->listeCategory = include APPLICATION_PATH . '/../library/Scores/Account/Category.php'; $this->listeCategory = include APPLICATION_PATH . '/../library/Scores/Account/Category.php';
} }
@ -568,9 +579,9 @@ class Scores_Ws_Server
try { try {
$result = $stmt->fetch(\PDO::FETCH_OBJ); $result = $stmt->fetch(\PDO::FETCH_OBJ);
} catch (\Doctrine\DBAL\DBALException $e) { } catch (\Doctrine\DBAL\DBALException $e) {
$c = Zend_Registry::get('config'); if ($this->logger != null) {
file_put_contents($c->profil->path->shared.'/log/application.log', $this->logger->error("AUTH : ".$e->getMessage());
date('Y-m-d H:i:s').'- AUTH : '.$e->getMessage()."\n", FILE_APPEND); }
return '0000'; return '0000';
} }

View File

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

View File

@ -21,45 +21,45 @@ class Entreprise extends Scores_Ws_Server
*/ */
public function getIdentite($siret, $id, $dept, $waldec) public function getIdentite($siret, $id, $dept, $waldec)
{ {
$forceVerif=false; $forceVerif = false;
Metier_Util_Log::write('W',"Recherche par identifiant Siren=$siret, Dept=$dep, Id=$id, Waldec=$waldec",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W',"Recherche par identifiant Siren=$siret, Dept=$dep, Id=$id, Waldec=$waldec",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$iInsee = new Metier_Insee_MInsee(); $iInsee = new Metier_Insee_MInsee();
$result = new EntrepResult(); $result = new EntrepResult();
if ($waldec != '' && substr($waldec,0,1) == 'W' && $siret*1 == 0) {
if ($waldec<>'' && substr($waldec,0,1)=='W' && $siret*1==0) {
Metier_Util_Log::write('I',"AFNIC Recherche par identifiant Waldec $waldec (Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"AFNIC Recherche par identifiant Waldec $waldec (Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$rep = $iInsee->getEtablissementsParId('AUTRE', $waldec, 0, 20, 20);
$rep=$iInsee->getEtablissementsParId('AUTRE', $waldec, 0, 20, 20); $etabs = $rep['reponses'];
if ($rep['nbReponses'] > 0) {
$etabs=$rep['reponses']; foreach ($etabs as $nb => $etab) {
if ($rep['nbReponses']>0) { $siret = $etab['Siret'];
foreach ($etabs as $nb=>$etab) { $id = $etab['id'];
$siret=$etab['Siret'];
$id=$etab['id'];
break; break;
} }
} else { } else {
Metier_Util_Log::write('W', "Waldec $waldec non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W', "Waldec $waldec non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$error = new ErrorElement(); $error = new ErrorElement();
$error->errnum = 108; $error->errnum = 108;
$error->errmsg = 'Waldec inconnu'; $error->errmsg = 'Waldec inconnu';
$result->error = $error; $result->error = $error;
return $result; return $result;
} }
} }
$tabRet=array(); $tabRet = array();
$siret=trim($siret); $siret = trim($siret);
$len=strlen($siret); $len = strlen($siret);
$id=trim($id)*1; $id = trim($id)*1;
if ($len==14) $nic=substr(''.$siret,9,5)*1; if ($len == 14) {
elseif ($len== 9) $nic=''; $nic = substr(''.$siret,9,5)*1;
}
elseif ($len == 9) {
$nic='';
}
elseif ($len== 0) { elseif ($len== 0) {
$siren=0; $nic=''; $siren = 0;
$nic = '';
} }
else { else {
Metier_Util_Log::write('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
@ -70,8 +70,8 @@ class Entreprise extends Scores_Ws_Server
$result->result = $tabRet; $result->result = $tabRet;
return $result; return $result;
} }
$siren=substr(''.$siret,0,9)*1; $siren = substr(''.$siret,0,9)*1;
if ($siren==0 && $id==0) { if ($siren == 0 && $id == 0) {
Metier_Util_Log::write('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$error = new ErrorElement(); $error = new ErrorElement();
$error->errnum = 102; $error->errnum = 102;
@ -81,7 +81,7 @@ class Entreprise extends Scores_Ws_Server
return $result; return $result;
} }
if ($id==0 && !$iInsee->valideSiren($siren, $nic)) { if ($id == 0 && !$iInsee->valideSiren($siren, $nic)) {
Metier_Util_Log::write('W', "Siren $siren/$nic invalide (105)", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W', "Siren $siren/$nic invalide (105)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$error = new ErrorElement(); $error = new ErrorElement();
$error->errnum = 105; $error->errnum = 105;
@ -91,15 +91,15 @@ class Entreprise extends Scores_Ws_Server
return $result; return $result;
} }
if ($dep==974) { if ($dep == 974) {
Metier_Util_Log::write('I',"AFNIC Recherche par Siren/Dept (Waldec=$waldec, Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"AFNIC Recherche par Siren/Dept (Waldec=$waldec, Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$rep=$iInsee->getEtablissements($siren, $nic, 0, 20, 20, $dep); $rep = $iInsee->getEtablissements($siren, $nic, 0, 20, 20, $dep);
$etabs=$rep['reponses']; $etabs = $rep['reponses'];
if ($rep['nbReponses']>0) { if ($rep['nbReponses']>0) {
foreach ($etabs as $nb=>$etab) { foreach ($etabs as $nb=>$etab) {
$siren=$etab['siren']; $siren = $etab['siren'];
$nic=$etab['nic']; $nic = $etab['nic'];
$id=$etab['id']; $id = $etab['id'];
break; break;
} }
} else { } else {
@ -116,7 +116,7 @@ class Entreprise extends Scores_Ws_Server
Metier_Util_Log::write('I',"AFNIC Identités demandée pour siret ".strtr(print_r($siret, true),array("\r"=>'',"\n"=>'')). " (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"AFNIC Identités demandée pour siret ".strtr(print_r($siret, true),array("\r"=>'',"\n"=>'')). " (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
Metier_Util_Log::write('I', "Avant getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I', "Avant getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$entrep=$iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif); $entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
Metier_Util_Log::write('I', "Après getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I', "Après getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if (empty($entrep)) { if (empty($entrep)) {
@ -132,23 +132,22 @@ class Entreprise extends Scores_Ws_Server
$codePaysIso2='FR'; $codePaysIso2='FR';
if ($entrep['Dept'] > 98) { if ($entrep['Dept'] > 98) {
$codePaysInsee = $entrep['codeCommune']; $codePaysInsee = $entrep['codeCommune'];
$sql = "SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, j.libPays, i.LIBCOG, i.ACTUAL $sql = "SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, j.libPays, i.LIBCOG, i.ACTUAL
FROM jo.tabPays j, insee.insee_tabPays i FROM jo.tabPays j, insee.insee_tabPays i
WHERE j.codePaysInsee=:codePays AND j.codePaysInsee=substring(i.COG, 3, 3) AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL"; WHERE j.codePaysInsee=:codePays AND j.codePaysInsee=substring(i.COG, 3, 3) AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL";
$stmt = $this->conn->prepare($sql); $paysStmt = $this->conn->prepare($sql);
$stmt->bindValue('codePays', $codePaysInsee); $paysStmt->bindValue('codePays', $codePaysInsee);
$stmt->execute(); $paysStmt->execute();
if ($stmt->rowCount() == 1) { if ($paysStmt->rowCount() == 1) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC); $paysResult = $paysStmt->fetch(\PDO::FETCH_ASSOC);
$codePaysIso2 = $result['codPays']; $codePaysIso2 = $paysResult['codPays'];
} else { } else {
$codePaysIso2 = ''; $codePaysIso2 = '';
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($paysResult = $paysStmt->fetch(\PDO::FETCH_ASSOC)) {
if (trim(strtoupper(strtr($result['libPays'], if (trim(strtoupper(strtr($paysResult['libPays'],
'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝ', 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝ',
"aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUY")))==trim(strtoupper($result['LIBCOG']))) { "aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUY")))==trim(strtoupper($paysResult['LIBCOG']))) {
$codePaysIso2 = $result['codPays']; $codePaysIso2 = $paysResult['codPays'];
break; break;
} }
} }
@ -161,24 +160,38 @@ class Entreprise extends Scores_Ws_Server
} }
// Source RNCS prioritaire pour les infos entreprises // Source RNCS prioritaire pour les infos entreprises
$nom=$entrep['nomLong']; $nom = $entrep['nomLong'];
if ($nom=='') $nom=$entrep['Nom']; if ($nom == '') {
$sigle=$entrep['sigleLong']; $nom = $entrep['Nom'];
if ($sigle=='') $sigle=$entrep['Sigle']; }
$sigle = $entrep['sigleLong'];
if ($sigle == '') {
$sigle = $entrep['Sigle'];
}
// Actif RNCS // Actif RNCS
if ($entrep['EntActiveRCS']) $actif=1; if ($entrep['EntActiveRCS']) {
$actif = 1;
}
// Inactif RNCS // Inactif RNCS
elseif (isset($entrep['EntActiveRCS']) && $entrep['EntActiveRCS']==0) $actif=0; elseif (isset($entrep['EntActiveRCS']) && $entrep['EntActiveRCS']==0) {
$actif = 0;
}
// Actif Insee et périmètre Insee // Actif Insee et périmètre Insee
elseif ($entrep['Actif'] || $entrep['NbEtab']) $actif=1; elseif ($entrep['Actif'] || $entrep['NbEtab']) {
else $actif=0; $actif = 1;
}
else {
$actif =0;
}
// Source INSEE prioritaire sur l'établissement // Source INSEE prioritaire sur l'établissement
$enseigne=$entrep['Enseigne']; $enseigne = $entrep['Enseigne'];
if ($enseigne=='') $enseigne=$entrep['enseigneLong']; if ($enseigne == '') {
$tabCarInvalides=array('/'=>' ','*'=>' ', '&amp;'=>' ET ', '&'=>' ET ', '&AMP;'=>' ET ', $enseigne = $entrep['enseigneLong'];
'"'=>' ', "'"=>' '); }
$tabCarInvalides = array('/'=>' ','*'=>' ', '&amp;'=>' ET ', '&'=>' ET ', '&AMP;'=>' ET ',
'"'=>' ', "'"=>' ');
$item = new EntrepElement(); $item = new EntrepElement();
$item->id = $entrep['id']; $item->id = $entrep['id'];
@ -241,12 +254,14 @@ class Entreprise extends Scores_Ws_Server
$item->Naf4EtabLib = $entrep2['apet4_lib']; $item->Naf4EtabLib = $entrep2['apet4_lib'];
} }
Metier_Util_Log::write('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$this->wsLog('identite',$siret,$id); $this->wsLog('identite', $siret, $id);
$error = new ErrorElement(); $error = new ErrorElement();
$error->errmsg = ''; $error->errmsg = '';
$error->errnum = 0; $error->errnum = 0;
$result->result = $item; $result->result = $item;
return $result; return $result;
} }

View File

@ -100,8 +100,11 @@ class Entreprise extends Scores_Ws_Server
$inseeLResult->insL6_POST $inseeLResult->insL6_POST
); );
} }
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
} }
catch (\Doctrine\DBAL\DBALException $e) {}
if (is_array($rnvpResult) && array_key_exists('HexaViaMat', $rnvpResult)) { if (is_array($rnvpResult) && array_key_exists('HexaViaMat', $rnvpResult)) {
$Infos->AdresseComplement = $rnvpResult['L3']; $Infos->AdresseComplement = $rnvpResult['L3'];
@ -120,8 +123,7 @@ class Entreprise extends Scores_Ws_Server
} }
$Infos->PaiementInfo = $PaiementInfo; $Infos->PaiementInfo = $PaiementInfo;
if ($evaluation['NbBilansScore'] > 0) if ($evaluation['NbBilansScore'] > 0) {
{
$bilan = $evaluation['tabBilan'][0]; $bilan = $evaluation['tabBilan'][0];
$Infos->BilanCA = $bilan['FL']; $Infos->BilanCA = $bilan['FL'];
$Infos->BilanDateCloture = $bilan['DATE_CLOTURE']; $Infos->BilanDateCloture = $bilan['DATE_CLOTURE'];
@ -134,9 +136,6 @@ class Entreprise extends Scores_Ws_Server
$Infos->Encours = round($evaluation['encours']/1000) * 1000; $Infos->Encours = round($evaluation['encours']/1000) * 1000;
// --- Ajouter en surveillance // --- Ajouter en surveillance
$survM = new Application_Model_JoSurveillancesSite();
try { try {
$sql = "SELECT * FROM jo.surveillances_sites WHERE login=:login AND siren=:siren"; $sql = "SELECT * FROM jo.surveillances_sites WHERE login=:login AND siren=:siren";
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
@ -160,8 +159,11 @@ class Entreprise extends Scores_Ws_Server
); );
$this->conn->insert('jo.surveillances_sites', $data); $this->conn->insert('jo.surveillances_sites', $data);
} }
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
} }
catch (\Doctrine\DBAL\DBALException $e) {}
// --- Fin ajout surveillance // --- Fin ajout surveillance
$this->wsLog('identite', $siren); $this->wsLog('identite', $siren);

View File

@ -127,8 +127,6 @@ class Entreprise extends Scores_Ws_Server
//Initialisation //Initialisation
if (empty($histo)) { $histo = false; } if (empty($histo)) { $histo = false; }
//Zend_Registry::get('WsLogger')->info('HISTO : '.$histo);
Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$tabRet = array(); $tabRet = array();
if (strlen($siren)<>9) { if (strlen($siren)<>9) {
@ -141,11 +139,9 @@ class Entreprise extends Scores_Ws_Server
$iInsee = new Metier_Insee_MInsee(); $iInsee = new Metier_Insee_MInsee();
$dirs = $iInsee->getDirigeants($siren, $histo); $dirs = $iInsee->getDirigeants($siren, $histo);
//Metier_Util_Log::write('W', print_r($dirs, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$liste = array(); $liste = array();
foreach ($dirs as $nb => $dir) foreach ($dirs as $nb => $dir)
{ {
//Metier_Util_Log::write('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$dirigeant = new Dirigeant(); $dirigeant = new Dirigeant();
$dirigeant->Code = $dir['Fonction']; $dirigeant->Code = $dir['Fonction'];
$dirigeant->Titre = $dir['Titre']; $dirigeant->Titre = $dir['Titre'];

View File

@ -812,8 +812,6 @@ class Entreprise extends Scores_Ws_Server
//Initialisation //Initialisation
if (empty($histo)) { $histo = false; } if (empty($histo)) { $histo = false; }
//Zend_Registry::get('WsLogger')->info('HISTO : '.$histo);
Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$tabRet = array(); $tabRet = array();
if (strlen($siren)<>9) { if (strlen($siren)<>9) {
@ -826,11 +824,9 @@ class Entreprise extends Scores_Ws_Server
$iInsee = new Metier_Insee_MInsee(); $iInsee = new Metier_Insee_MInsee();
$dirs = $iInsee->getDirigeants($siren, $histo); $dirs = $iInsee->getDirigeants($siren, $histo);
//Metier_Util_Log::write('W', print_r($dirs, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$liste = array(); $liste = array();
foreach ($dirs as $nb => $dir) foreach ($dirs as $nb => $dir)
{ {
//Metier_Util_Log::write('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$dirigeant = new Dirigeant(); $dirigeant = new Dirigeant();
$dirigeant->Code = $dir['Fonction']; $dirigeant->Code = $dir['Fonction'];
$dirigeant->Titre = $dir['Titre']; $dirigeant->Titre = $dir['Titre'];
@ -924,7 +920,6 @@ class Entreprise extends Scores_Ws_Server
elseif ($filtre==4) elseif ($filtre==4)
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
//Metier_Util_Log::write('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM)) if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM))
{ {
Metier_Util_Log::write('W', "Aucune annonce pour le siren $siren (source=$filtre, id=$idAnn)", __LINE__, __FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('W', "Aucune annonce pour le siren $siren (source=$filtre, id=$idAnn)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
@ -935,7 +930,6 @@ class Entreprise extends Scores_Ws_Server
{ {
foreach ($anns as $nb=>$ann) foreach ($anns as $nb=>$ann)
{ {
//Metier_Util_Log::write('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$evens = array(); $evens = array();
foreach ($ann['evenements'] as $tabEven) foreach ($ann['evenements'] as $tabEven)
{ {
@ -980,7 +974,6 @@ class Entreprise extends Scores_Ws_Server
{ {
foreach ($annsB as $nb=>$ann) foreach ($annsB as $nb=>$ann)
{ {
//Metier_Util_Log::write('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$evens = array(); $evens = array();
foreach ($ann['evenements'] as $tabEven) foreach ($ann['evenements'] as $tabEven)
{ {
@ -1021,7 +1014,6 @@ class Entreprise extends Scores_Ws_Server
{ {
foreach ($annsA as $nb=>$ann) foreach ($annsA as $nb=>$ann)
{ {
//Metier_Util_Log::write('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$evens = array(); $evens = array();
foreach ($ann['evenements'] as $tabEven) foreach ($ann['evenements'] as $tabEven)
{ {
@ -4194,10 +4186,8 @@ class Entreprise extends Scores_Ws_Server
* base de données, l'accès FTP, l'accès HTTP, l'accès système de fichier * base de données, l'accès FTP, l'accès HTTP, l'accès système de fichier
*/ */
//Enregistrement des accès à la requête getIdentite $this->logger->info($_SERVER['REMOTE_ADDR'].", login:".
Zend_Registry::get('WsLogger')->info("status - ip:". $_SERVER['PHP_AUTH_USER'].", hash:".$_SERVER['PHP_AUTH_PW']);
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER'].
", hash:".$_SERVER['PHP_AUTH_PW']);
$error = new StatusReturn(); $error = new StatusReturn();
//Test connexion à la base de données //Test connexion à la base de données

View File

@ -293,7 +293,6 @@ class Entreprise extends Scores_Ws_Server
$db = Zend_Db_Table_Abstract::getDefaultAdapter(); $db = Zend_Db_Table_Abstract::getDefaultAdapter();
$output = new AvisRncs(); $output = new AvisRncs();
$iDb = new Metier_Util_Db();
$rncs = new Metier_Partenaires_MRncs(); $rncs = new Metier_Partenaires_MRncs();
//jo.etablissements => insee uniquement, rncs ? //jo.etablissements => insee uniquement, rncs ?
@ -359,7 +358,7 @@ class Entreprise extends Scores_Ws_Server
$output->ConstitutionTribunalCode = ''; $output->ConstitutionTribunalCode = '';
$output->ConstitutionTribunalLabel = ''; $output->ConstitutionTribunalLabel = '';
$iInsee = new Metier_Insee_MInsee($iDb); $iInsee = new Metier_Insee_MInsee();
$dirs = $iInsee->getDirigeants($siren, false); $dirs = $iInsee->getDirigeants($siren, false);
$liste = array(); $liste = array();
foreach ($dirs as $nb => $dir) foreach ($dirs as $nb => $dir)
@ -1430,8 +1429,6 @@ class Entreprise extends Scores_Ws_Server
//Initialisation //Initialisation
if (empty($histo)) { $histo = false; } if (empty($histo)) { $histo = false; }
//Zend_Registry::get('WsLogger')->info('HISTO : '.$histo);
Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__); Metier_Util_Log::write('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$tabRet = array(); $tabRet = array();
if (strlen($siren)<>9) { if (strlen($siren)<>9) {
@ -3485,7 +3482,7 @@ class Entreprise extends Scores_Ws_Server
elseif (strlen($siret) == 9) $nic = ''; elseif (strlen($siret) == 9) $nic = '';
$iDb = new Metier_Util_Db(); $iDb = new Metier_Util_Db();
$iInsee = new Metier_Insee_MInsee($iDb); $iInsee = new Metier_Insee_MInsee();
$rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, $dep, $actif, $siege); $rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, $dep, $actif, $siege);
if ( count($rep['reponses'])==0 && $dep>0 ) { if ( count($rep['reponses'])==0 && $dep>0 ) {
@ -5429,10 +5426,8 @@ class Entreprise extends Scores_Ws_Server
* base de données, l'accès FTP, l'accès HTTP, l'accès système de fichier * base de données, l'accès FTP, l'accès HTTP, l'accès système de fichier
*/ */
//Enregistrement des accès à la requête getIdentite $this->logger->info($_SERVER['REMOTE_ADDR'].", login:".
/*Zend_Registry::get('WsLogger')->info("status - ip:". $_SERVER['PHP_AUTH_USER'].", hash:".$_SERVER['PHP_AUTH_PW']);
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER'].
", hash:".$_SERVER['PHP_AUTH_PW']);*/
$error = new StatusReturn(); $error = new StatusReturn();
//Test connexion à la base de données //Test connexion à la base de données

View File

@ -33,9 +33,8 @@ class Entreprise extends Scores_Ws_Server
$this->sendError('1020'); $this->sendError('1020');
} }
$db = new Metier_Util_Db(); $iInsee = new Metier_Insee_MInsee();
$iInsee->setLogger();
$iInsee = new Metier_Insee_MInsee($db);
$entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif); $entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
if (empty($entrep) || empty($entrep['id']) ) { if (empty($entrep) || empty($entrep['id']) ) {
$this->sendError('1020'); $this->sendError('1020');
@ -99,15 +98,22 @@ class Entreprise extends Scores_Ws_Server
// --- Indicateur Adresse RNVP // --- Indicateur Adresse RNVP
try { try {
$rnvpM = new Application_Model_VillesRnvpSources(); $sql = "SELECT dateRetourRnvp, codeRetour FROM villes.rnvpSources
$sql = $rnvpM->select(true)->columns(array('dateRetourRnvp','codeRetour')) WHERE source=:source AND source_id=:id";
->where('source=?', $entrep['Source'])->where('source_id=?', $entrep['SourceId']); $stmt = $this->conn->prepare($sql);
$rnvpResult = $rnvpM->fetchRow($sql); $stmt->bindValue('source', $entrep['Source']);
if ($rnvpResult !== null) { $stmt->bindValue('id', $entrep['SourceId']);
$identite->AdresseRnvpDate = $rnvpResult->dateRetourRnvp; $stmt->execute();
$identite->AdresseRnvpCode = $rnvpResult->codeRetour; if ($stmt->rowCount() > 0) {
$rnvpResult = $stmt->fetch(\PDO::FETCH_OBJ);
$identite->AdresseRnvpDate = $rnvpResult->dateRetourRnvp;
$identite->AdresseRnvpCode = $rnvpResult->codeRetour;
}
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
} }
} catch (Zend_Db_Exception $e) {} }
$identite->Civilite = $entrep['Civilite']; $identite->Civilite = $entrep['Civilite'];
$identite->NbEtab = $entrep['NbEtab']; $identite->NbEtab = $entrep['NbEtab'];
@ -295,7 +301,7 @@ class Entreprise extends Scores_Ws_Server
$identite->GroupeName = $grpHeadFiche->RS; $identite->GroupeName = $grpHeadFiche->RS;
// --- Recherche code Isin // --- Recherche code Isin
$nbIdNum = 3; $nbIdNum = 3;
for ($i=0;$i<$nbIdNum;$i++) { for ($i = 0; $i < $nbIdNum; $i++) {
if( !empty($grpHeadFiche->{'idLoc'.$i.'Num'}) && $grpHeadFiche->{'idLoc'.$i.'Type'} == 63 ) { if( !empty($grpHeadFiche->{'idLoc'.$i.'Num'}) && $grpHeadFiche->{'idLoc'.$i.'Type'} == 63 ) {
$identite->GroupeIsin = $grpHeadFiche->{'idLoc'.$i.'Num'}; $identite->GroupeIsin = $grpHeadFiche->{'idLoc'.$i.'Num'};
break; break;
@ -303,22 +309,25 @@ class Entreprise extends Scores_Ws_Server
} }
$identite->GroupeCountryCode = $grpHeadFiche->adresse_pays; $identite->GroupeCountryCode = $grpHeadFiche->adresse_pays;
if (!empty($grpHeadFiche->adresse_pays)) { if (!empty($grpHeadFiche->adresse_pays)) {
try {
$countryM = new Application_Model_JoTabPays();
$sql = $countryM->select()->from($countryM, array('codPays3', 'libPays'));
$result = $countryM->fetchAll($sql);
} catch (Zend_Db_Adapter_Exception $e) {}
$tabPays = array(); $tabPays = array();
if ( $result->count()>0 ) { try {
foreach ( $result as $item ) { $sql = "SELECT codPays3, libPays FROM jo.tabPays";
$tabPays[$item->codPays3] = $item->libPays; $stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
while($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabPays[$item->codPays3] = $item->libPays;
}
}
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
} }
} }
$libPays = ''; $libPays = '';
if ($grpHeadFiche->adresse_pays!='') { if ($grpHeadFiche->adresse_pays!='') {
$libPays = array_key_exists($grpHeadFiche->adresse_pays, $tabPays) ? $libPays = array_key_exists($grpHeadFiche->adresse_pays, $tabPays) ?
$tabPays[$grpHeadFiche->adresse_pays] : $grpHeadFiche->adresse_pays; $tabPays[$grpHeadFiche->adresse_pays] : $grpHeadFiche->adresse_pays;
} else { } else {
$libPays = $tabPays['FRA']; $libPays = $tabPays['FRA'];
} }
@ -348,7 +357,6 @@ class Entreprise extends Scores_Ws_Server
} }
$output = new AvisRncs(); $output = new AvisRncs();
$iDb = new Metier_Util_Db();
$rncs = new Metier_Partenaires_MRncs(); $rncs = new Metier_Partenaires_MRncs();
//jo.etablissements => insee uniquement, rncs ? //jo.etablissements => insee uniquement, rncs ?
@ -398,29 +406,31 @@ class Entreprise extends Scores_Ws_Server
//Date du dernier bilan - MOIS/JOUR au pire chercher dans l'annonce //Date du dernier bilan - MOIS/JOUR au pire chercher dans l'annonce
try { try {
$bilanM = new Application_Model_JoBilans(); $sql = "SELECT dateExercice FROM jo.bilans
$sql = $bilanM->select(true) WHERE siren=:siren ORDER BY dateExercice DESC LIMIT 0,1";
->columns(array('dateExercice')) $stmt = $this->conn->prepare($sql);
->where('siren=?', $siren) $stmt->bindValue('siren', $siren);
->order('dateExercice DESC')->limit(1); $stmt->execute();
$result = $bilanM->fetchRow($sql); if ($stmt->rowCount() > 0) {
if ($result !== null) { $result = $stmt->fetch(\PDO::FETCH_OBJ);
$output->CompteArretMois = substr($result->dateExercice,4,2); $output->CompteArretMois = substr($result->dateExercice,4,2);
$output->CompteArretJour = substr($result->dateExercice,6,2); $output->CompteArretJour = substr($result->dateExercice,6,2);
} }
} catch(Zend_Db_Exception $e) {} } catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
//=> Avec l'adresse du premier siège //=> Avec l'adresse du premier siège
$output->ConstitutionTribunalCode = ''; $output->ConstitutionTribunalCode = '';
$output->ConstitutionTribunalLabel = ''; $output->ConstitutionTribunalLabel = '';
$iInsee = new Metier_Insee_MInsee($iDb); $iInsee = new Metier_Insee_MInsee();
$dirs = $iInsee->getDirigeants($siren, false); $dirs = $iInsee->getDirigeants($siren, false);
$liste = array(); $liste = array();
foreach ($dirs as $nb => $dir) foreach ($dirs as $nb => $dir) {
{
$dirigeant = new AvisRncsAdmin(); $dirigeant = new AvisRncsAdmin();
$dirigeant->Code = $dir['Fonction']; $dirigeant->Code = $dir['Fonction'];
$dirigeant->Label = $dir['Titre']; $dirigeant->Label = $dir['Titre'];
$dirigeant->CompanyName = $dir['Societe']; $dirigeant->CompanyName = $dir['Societe'];
@ -544,17 +554,19 @@ class Entreprise extends Scores_Ws_Server
throw new SoapFault('ERR', 'Identifiant incorrect.'); throw new SoapFault('ERR', 'Identifiant incorrect.');
} }
try { try {
$etabM = new Application_Model_JoEtablissements(); $sql = "SELECT LPAD(source,3,0) AS source, LPAD(source_id,20,0) AS sourceId
$sql = $etabM->select(true)->columns(array('LPAD(source,3,0) AS source', 'LPAD(source_id,20,0) AS sourceId')) FROM jo.etablissements WHERE siren=:siren AND nic=:nic";
->where('siren=?', substr($companyId,0,9)) $stmt = $this->conn->prepare($sql);
->where('nic=?', substr($companyId,9,5)); $stmt->bindValue('siren', substr($companyId,0,9));
$etabResult = $etabM->fetchRow($sql); $stmt->bindValue('nic', substr($companyId,9,5));
if ($etabResult === null) { $stmt->execute();
if ($stmt->rowCount() == 0) {
throw new SoapFault('MSG', 'Etablissement inconnu.'); throw new SoapFault('MSG', 'Etablissement inconnu.');
} }
$source = $etabResult->source; } catch (\Doctrine\DBAL\DBALException $e) {
$sourceId = $etabResult->source_id; if ($this->logger !== null) {
} catch (Zend_Db_Exception $e) { $this->logger->error($e->getMessage());
}
if ($this->User->idClient == 1) { if ($this->User->idClient == 1) {
throw new SoapFault('ERR', $e->getMessage()); throw new SoapFault('ERR', $e->getMessage());
} else { } else {

View File

@ -366,14 +366,6 @@ class Gestion extends Scores_Ws_Server
$tabUpdate['typeCompte'] = $typeCompte; $tabUpdate['typeCompte'] = $typeCompte;
//@todo : See issue #0001209 //@todo : See issue #0001209
/*
if ($this->User->profil=='SuperAdministrateur' && !empty($infos['filtre_ip'])) {
$tabUpdate['filtre_ip'] = $infos['filtre_ip'];
} else {
$rep = $iDbCrm->select('clients', 'filtre_ip', "id='$idClient'",false, MYSQL_ASSOC);
$tabUpdate['filtre_ip'] = $rep[0]['filtre_ip'];
}
*/
//$tabUpdate['civilite'] = 'M'; //$tabUpdate['civilite'] = 'M';
$tabUpdate['nom'] = stripslashes($infos['nom']); $tabUpdate['nom'] = stripslashes($infos['nom']);
$tabUpdate['prenom'] = stripslashes($infos['prenom']); $tabUpdate['prenom'] = stripslashes($infos['prenom']);

View File

@ -2273,15 +2273,14 @@ class Interne extends Scores_Ws_Server
if (empty($nbRep)) $nbRep = 50; if (empty($nbRep)) $nbRep = 50;
if ($nbRep>200) $nbRep = 200; if ($nbRep>200) $nbRep = 200;
$bilansM = new Application_Model_FedasoBilans(); $qb = $this->conn->createQueryBuilder();
$qb->select('*')->from('sdv1.fedaso_bilans')->orderBy('dateEntree', 'DESC');
$sql = $bilansM->select()->order('dateEntree DESC');
if (is_array($filtre) && count($filtre)>0) { if (is_array($filtre) && count($filtre)>0) {
foreach($filtre as $item) { foreach($filtre as $item) {
switch($item->key) { switch($item->key) {
case 'siren': case 'siren':
$sql->where('siren=?', $item->value); $siren = $item->value;
break; break;
case 'etat': case 'etat':
@ -2302,20 +2301,29 @@ class Interne extends Scores_Ws_Server
} }
} }
//Select user id // Select user id
$sql->where('idUtilisateur=?', $idUtilisateur); $qb->where('idUtilisateur=:id')->setParameter('id', $idUtilisateur);
//Paginate if ($siren) {
$sql->limit($nbRep, $position); $qb->andWhere('siren=:siren')->setParameter('siren', $siren);
//Get results }
$results = $bilansM->fetchAll($sql)->toArray();
// Paginate
$qb->setMaxResults($nbRep)->setFirstResult($position);
try {
$stmt = $qb->execute();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$iInsee = new Metier_Insee_MInsee(); $iInsee = new Metier_Insee_MInsee();
$output = array(); $output = array();
if (count($results)>0) { if ($stmt->rowCount() > 0) {
foreach ($results as $result) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$entrep = $iInsee->getIdentiteLight($result['siren']); $entrep = $iInsee->getIdentiteLight($result['siren']);
$saisie = new BilanSaisieInfos(); $saisie = new BilanSaisieInfos();
@ -2359,17 +2367,17 @@ class Interne extends Scores_Ws_Server
{ {
$this->authenticate(); $this->authenticate();
if ( strlen($siret)!=9 && strlen($siret)!=14 ) { if ( strlen($siret) != 9 && strlen($siret) != 14 ) {
$this->sendError('1010'); $this->sendError('1010');
} }
$siren = substr($siret,0,9); $siren = substr($siret,0,9);
if (intval($siren)==0 ) { if (intval($siren) == 0) {
$this->sendError('1010'); $this->sendError('1010');
} }
$nic = substr($siret,9,5); $nic = substr($siret,9,5);
if (intval($nic)==0) { if (intval($nic) == 0) {
$nic = '00000'; $nic = '00000';
} }
@ -2378,65 +2386,70 @@ class Interne extends Scores_Ws_Server
if ($filtre !== null && !in_array($filtre, $typeToSelect)) { if ($filtre !== null && !in_array($filtre, $typeToSelect)) {
throw new SoapFault('ERR', "Unknown filtre"); throw new SoapFault('ERR', "Unknown filtre");
} }
$telephonieM = new Application_Model_JoTelephonie(); // Comptage
$sql = $telephonieM->select() $qb = $this->conn->createQueryBuilder();
->from($telephonieM, array( $qb->select(array('COUNT(*) AS nb'))
'id', ->from('jo.telephonie')
'LPAD(siren,9,0) AS siren', ->where('actif=1')
'LPAD(nic,5,0) AS nic', ->andWhere('typeTel IN ("'.join('","', $typeToSelect).'")')
'typeTel', ->andWhere('siren=:siren')->setParameter('siren', $siren);
'infoTel',
'LPAD(telephone, 10, 0) AS telephone',
'partenaire',
"dateProvPartenaire",
'IF(dateSuppr!=0,1,0) AS deleted',
))
->where('actif=1')
->where('typeTel IN ("'.join('","', $typeToSelect).'")')
->where('siren=?',$siren);
if ( intval($nic) > 0 ) { if ( intval($nic) > 0 ) {
$sql->where('nic=?',$nic); $qb->where('nic=:nic')->setParameter('nic', $nic);
} }
$stmt = $qb->execute();
$nbContacts = 0;
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$nbContacts = $result->nb;
}
if ( $filtre != null ) { // List
$sql->where('typeTel=?', $filtre); $qb = $this->conn->createQueryBuilder();
} $qb->select(array(
'id',
$sql->order('typeTel ASC'); 'LPAD(siren,9,0) AS siren',
$sql->order('dateInsert DESC')->limit($nbRep, $position); 'LPAD(nic,5,0) AS nic',
'typeTel',
try { 'infoTel',
$contacts = $telephonieM->fetchAll($sql); 'LPAD(telephone, 10, 0) AS telephone',
} catch (Zend_Db_Exception $e) { 'partenaire',
if ($this->User->idClient!=1) { "dateProvPartenaire",
throw new SoapFault('ERR', "Application error"); 'IF(dateSuppr!=0,1,0) AS deleted'))
} else { ->from('jo.telephonie')
throw new SoapFault('ERR', $e->getMessage()); ->where('actif=1')
} ->andWhere('typeTel IN ("'.join('","', $typeToSelect).'")')
} ->andWhere('siren=:siren')->setParameter('siren', $siren);
//Comptage
$sql = $telephonieM->select()
->from($telephonieM, 'COUNT(*) as nb')
->where('actif=1')
->where('typeTel IN ("'.join('","', $typeToSelect).'")')
->where('siren=?',$siren);
if ( intval($nic) > 0 ) { if ( intval($nic) > 0 ) {
$sql->where('nic=?',$nic); $qb->andWhere('nic=:nic')->setParameter('nic', $nic);
}
$result = $telephonieM->fetchRow($sql);
$nbContacts = 0;
if ( $result !== null ) {
$nbContacts = $result->nb;
} }
if ($filtre != null) {
$qb->andWhere('typeTel=:filtre')->setParameter('filtre', $filtre);
}
$qb->orderBy('typeTel', 'ASC')
->orderBy('dateInsert', 'DESC')
->setFirstResult($position)->setMaxResults($nbRep);
try {
$listStmt = $qb->execute();
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
if ($this->User->idClient == 1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
$list = array(); $list = array();
if ( $contacts->count() > 0) { if ($listStmt->rowCount() > 0) {
foreach ( $contacts as $item ) { while ($item = $listStmt->fetch(\PDO::FETCH_OBJ)) {
$contact = new ContactEt(); $contact = new ContactEt();
$contact->id = $item->id; $contact->id = $item->id;
$contact->siren = $item->siren; $contact->siren = $item->siren;
@ -2456,7 +2469,7 @@ class Interne extends Scores_Ws_Server
$contact->date = $date->format('Y-m-d'); $contact->date = $date->format('Y-m-d');
$contact->deleted = false; $contact->deleted = false;
if ($item->deleted==1) { if ($item->deleted == 1) {
$contact->deleted = true; $contact->deleted = true;
} }
@ -2464,7 +2477,7 @@ class Interne extends Scores_Ws_Server
} }
} }
//Return // Return
$output = new ContactEtReturn(); $output = new ContactEtReturn();
$output->nbReponses = $nbContacts; $output->nbReponses = $nbContacts;
$output->result = $list; $output->result = $list;
@ -2489,13 +2502,15 @@ class Interne extends Scores_Ws_Server
//Retrieve data //Retrieve data
try { try {
$idlocalM = new Application_Model_Sdv1TabIdLocal(); $sql = "SELECT id, idLocal, idLocalLong, idPrincipal, infoIden FROM sdv1.tabIdLocal
$sql = $idlocalM->select() WHERE (codPays=:pays OR codPays IS NULL) AND dateSuppr='0000-00-00 00:00:00'";
->where('codPays=?', $codeCountry) $stmt = $this->conn->prepare($sql);
->orWhere('codPays IS NULL') $stmt->bindValue('pays', $codeCountry);
->where('dateSuppr=?', '0000-00-00 00:00:00'); $stmt->execute();
$row = $idlocalM->fetchAll($sql); } catch(\Doctrine\DBAL\DBALException $e) {
} catch (Zend_Db_Exception $e) { if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
if ($this->User->idClient!=1) { if ($this->User->idClient!=1) {
throw new SoapFault('ERR', "Application error"); throw new SoapFault('ERR', "Application error");
} else { } else {
@ -2504,8 +2519,8 @@ class Interne extends Scores_Ws_Server
} }
$output = array(); $output = array();
if ($row->count()>0) { if ($stmt->rowCount() > 0) {
foreach ( $row as $item ) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$struct = new CountryId(); $struct = new CountryId();
$struct->internalId = $item->id; $struct->internalId = $item->id;
$struct->name = $item->idLocal; $struct->name = $item->idLocal;
@ -2539,77 +2554,69 @@ class Interne extends Scores_Ws_Server
{ {
$this->authenticate(); $this->authenticate();
if ( strlen($siret)!=9 && strlen($siret)!=14 ) { if (strlen($siret) != 9 && strlen($siret) != 14) {
$this->sendError('1010'); $this->sendError('1010');
} }
$siren = substr($siret,0,9); $siren = substr($siret,0,9);
if ( intval($siren)==0 ) { if (intval($siren) == 0) {
$this->sendError('1010'); $this->sendError('1010');
} }
if( strtolower($type)=='indiscore' ) { if(strtolower($type) == 'indiscore') {
$type = ( $this->User->typeScore==20 ) ? 'indiScore20' : 'indiScore'; $type = ($this->User->typeScore == 20) ? 'indiScore20' : 'indiScore';
} }
$scoresDb = new Application_Model_JoScoresSurveillance(); $motifLib = array(
'ajout' => "Initialisation",
'ancien' => "Score trop ancien",
'bilans1' => "Publication bilan",
'bilans2' => "Publication bilan",
'bilansasso'=> "Publication bilan Association",
'bodacc' => "Publication Bodacc",
'collecte' => "Publication JAL ou Greffe",
'dirigeants'=> "Modification de l'administration",
'impayes' => "Informations de paiements",
'insee' => "Modification identitaires INSEE",
'jour' => "Modifications identitaires",
'liens' => "Mise à jour de la structure du groupe",
'modifenc' => "Autre modification identitaire",
'privileges'=> "Mise à jour des privilèges",
'regulier' => "Informations de paiements",
'rncs' => "Modifications identitaires RNCS",
'default' => "Modification identitaire",
);
$sql1 = $scoresDb->select() try {
->from(array('j'=>'scores_surveillance'), array("j.$type", 'j.encours', 'j.indiScoreDate', 'j.sourceModif'), 'jo') $sql = "(SELECT j.$type, j.encours, j.indiScoreDate, j.sourceModif FROM jo.scores_surveillance j
->where('siren=?',$siren) WHERE siren=:siren AND indiScoreDate >= (CURDATE() - INTERVAL 5 YEAR) GROUP BY indiScoreDate)
->where('indiScoreDate >= (CURDATE() - INTERVAL 5 YEAR)') UNION (SELECT h.$type, h.encours, h.indiScoreDate, h.sourceModif FROM historiques.scores_surveillance h
->group('indiScoreDate'); WHERE siren=:siren AND indiScoreDate >= (CURDATE() - INTERVAL 5 YEAR) GROUP BY indiScoreDate)
ORDER BY indiScoreDate DESC";
$sql2 = $scoresDb->select() $stmt = $this->conn->prepare($sql);
->from(array('h'=>'scores_surveillance'), array("h.$type", 'h.encours', 'h.indiScoreDate', 'h.sourceModif'), 'historiques') $stmt->bindValue('siren', $siren);
->where('siren=?',$siren) $stmt->execute();
->where('indiScoreDate >= (CURDATE() - INTERVAL 5 YEAR)') } catch(\Doctrine\DBAL\DBALException $e) {
->group('indiScoreDate'); if ($this->logger !== null) {
$this->logger->error($e->getMessage());
$query = $scoresDb->select() }
->union(array($sql1, $sql2)) if ($this->User->idClient == 1) {
->group('indiScoreDate') throw new SoapFault('ERR', $e->getMessage());
->order('indiScoreDate DESC'); } else {
throw new SoapFault('ERR', "Application error");
try { }
$rows = $scoresDb->fetchAll($query); }
} catch(Exception $e) {
if ($this->User->idClient==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
}
$motifLib = array(
'ajout' => "Initialisation",
'ancien' => "Score trop ancien",
'bilans1' => "Publication bilan",
'bilans2' => "Publication bilan",
'bilansasso'=> "Publication bilan Association",
'bodacc' => "Publication Bodacc",
'collecte' => "Publication JAL ou Greffe",
'dirigeants'=> "Modification de l'administration",
'impayes' => "Informations de paiements",
'insee' => "Modification identitaires INSEE",
'jour' => "Modifications identitaires",
'liens' => "Mise à jour de la structure du groupe",
'modifenc' => "Autre modification identitaire",
'privileges'=> "Mise à jour des privilèges",
'regulier' => "Informations de paiements",
'rncs' => "Modifications identitaires RNCS",
'default' => "Modification identitaire",
);
$list = array(); $list = array();
if ($stmt->rowCount() > 0) {
foreach($rows as $row) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$item = new ScoresHisto(); $item = new ScoresHisto();
$item->date = $row->indiScoreDate; $item->date = $row->indiScoreDate;
$item->value = $row->{$type}; $item->value = $row->{$type};
$item->label = $motifLib[$row->sourceModif]; $item->label = $motifLib[$row->sourceModif];
$item->encours = round($row->encours/1000,1); $item->encours = round($row->encours/1000,1);
$list[] = $item; $list[] = $item;
}
} }
$output = new ScoresHistoReturn(); $output = new ScoresHistoReturn();
@ -2649,7 +2656,7 @@ class Interne extends Scores_Ws_Server
$iDb = new Metier_Util_Db(); $iDb = new Metier_Util_Db();
$iInsee = new Metier_Insee_MInsee($iDb); $iInsee = new Metier_Insee_MInsee();
$rep = $iInsee->getEtablissements($siren, '', $position, $nbRep, 200, $departement, $actif); $rep = $iInsee->getEtablissements($siren, '', $position, $nbRep, 200, $departement, $actif);
$etabs = $rep['reponses']; $etabs = $rep['reponses'];
$nbReponses = $rep['nbReponsesTotal']; $nbReponses = $rep['nbReponsesTotal'];

View File

@ -109,13 +109,17 @@ class Saisie extends Scores_Ws_Server
try { try {
$isInserted = $db->insert('jo.infos_entrep', array_merge(array('siren'=>$siren), $tabUpdate)); $isInserted = $db->insert('jo.infos_entrep', array_merge(array('siren'=>$siren), $tabUpdate));
} catch(Zend_Db_Exception $e) { } catch(Zend_Db_Exception $e) {
file_put_contents('insert.log', "INSERT = ".$e->getMessage()); if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
} }
} else { } else {
try { try {
$isUpdated = $db->update('jo.infos_entrep', $tabUpdate, "siren=$siren"); $isUpdated = $db->update('jo.infos_entrep', $tabUpdate, "siren=$siren");
} catch(Zend_Db_Exception $e) { } catch(Zend_Db_Exception $e) {
file_put_contents('update.log', "INSERT = ".$e->getMessage()); if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
} }
} }
// Fin mise à jour identité // Fin mise à jour identité