diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index 8643ee51..e75df8d9 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -4357,28 +4357,29 @@ class Entreprise extends Scores_Ws_Server //Check SIREN //Lecture de la base de données - try { - $bilansM = new Application_Model_JoGreffesBilans(); - $sql = $bilansM->select() - ->where('siren=?', $siren) - ->where('actif=1') - ->order('date_cloture DESC') - ->order('num_depot DESC') - ->order('dateInsert DESC') - ->limit(1); - $row = $bilansM->fetchRow($sql); - } catch (Zend_Db_Exception $e) { - if ($this->User->idClient==1) { + try { + $sql = "SELECT * FROM jo.greffes_bilans WHERE siren=:siren AND actif=1 + ORDER BY date_cloture DESC, num_depot DESC, dateInsert DESC"; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('siren', $siren); + $stmt->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"); } } - if ( $row === null ) { - return null; + if ($stmt->rowCount() == 0) { + return null; } + $row = $stmt->fetch(\PDO::FETCH_OBJ); + $liasseInfos = new LiasseInfos(); $liasseInfos->Id = $row->id; $liasseInfos->BilanDateCloture = $row->date_cloture; @@ -4425,21 +4426,26 @@ class Entreprise extends Scores_Ws_Server //Surcharge des codes de saisie $date = DateTime::createFromFormat('Y-m-d', $row->date_cloture); try { - $liasseM = new Application_Model_JoBilans(); - $sql = $liasseM->select() - ->where('siren=?', $siren) - ->where('typeBilan=?', $liasseInfos->BilanType) - ->where('dateExercice=?', $date->format('Ymd')); - $row = $liasseM->fetchRow($sql); - } catch (Zend_Db_Exception $e) { - //file_put_contents('debug.log', $e->getMessage()."\n", FILE_APPEND); - } - if ( $row !== null ) { - $liasseInfos->SaisieDate = substr($row->dateProvPartenaire,0,4) . - '-' . substr($row->dateProvPartenaire,4,2) . - '-' . substr($row->dateProvPartenaire,6,2); - $liasseInfos->SaisieCode = '00'; + $sql = "SELECT * FROM jo.bilans + WHERE siren=:siren AND typeBilan=:type AND dateExercice=:date"; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('siren', $siren); + $stmt->bindValue('type', $liasseInfos->BilanType); + $stmt->bindValue('date', $date->format('Ymd')); + $stmt->execute(); + if ($stmt->rowCount() > 0) { + $row = $stmt->fetch(\PDO::FETCH_OBJ); + $liasseInfos->SaisieDate = substr($row->dateProvPartenaire,0,4) . + '-' . substr($row->dateProvPartenaire,4,2) . + '-' . substr($row->dateProvPartenaire,6,2); + $liasseInfos->SaisieCode = '00'; + } + } catch(\Doctrine\DBAL\DBALException $e) { + if ($this->logger !== null) { + $this->logger->error($e->getMessage()); + } } + } return $liasseInfos;