Entreprise - getLiensById : remove Application_Model

This commit is contained in:
Michael RICOIS 2017-03-15 15:07:14 +01:00
parent a66fc30119
commit 22e907ceaf

View File

@ -846,7 +846,6 @@ class Entreprise extends Scores_Ws_Server
} }
} }
$tabPays = array(); $tabPays = array();
if ($stmt->count() > 0) { if ($stmt->count() > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
@ -1061,35 +1060,36 @@ class Entreprise extends Scores_Ws_Server
$this->authenticate(); $this->authenticate();
$this->permission('liens'); $this->permission('liens');
//Load country table
try { try {
$countryM = new Application_Model_JoTabPays(); $sql = "SELECT codPays3, libPays FROM jo.tabPays";
$sql = $countryM->select()->from($countryM, array('codPays3', 'libPays')); $stmt = $this->conn->prepare($sql);
$result = $countryM->fetchAll($sql); $stmt->execute();
} catch (Zend_Db_Adapter_Exception $e) { } catch(\Doctrine\DBAL\DBALException $e) {
if ($this->User->idClient==1) { if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
if ($this->User->idClient == 1) {
throw new SoapFault('ERR', $e->getMessage()); throw new SoapFault('ERR', $e->getMessage());
} else { } else {
throw new SoapFault('ERR', "Application error"); throw new SoapFault('ERR', "Application error");
} }
} catch (Zend_Exception $e) {
throw new SoapFault('ERR', "Application error");
} }
$tabPays = array(); $tabPays = array();
if ( $result->count()>0 ) { if ($stmt->count() > 0) {
foreach ( $result as $item ) { while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabPays[$item->codPays3] = $item->libPays; $tabPays[$item->codPays3] = $item->libPays;
} }
} }
$tabAct = $tabPar = $tabDir = array(); $tabAct = $tabPar = $tabDir = array();
try try {
{
$liensM = new Metier_Liens_Base(); $liensM = new Metier_Liens_Base();
$liensM->setId($id); $liensM->setId($id);
//Actionnaires // Actionnaires
$liens = $liensM->getActionnaires(null, true); $liens = $liensM->getActionnaires(null, true);
if (count($liens)>0) { if (count($liens)>0) {
foreach ( $liens as $item ) { foreach ( $liens as $item ) {
@ -1124,23 +1124,29 @@ class Entreprise extends Scores_Ws_Server
$nbIdNum = 3; $nbIdNum = 3;
$refs = array(); $refs = array();
$idM = new Application_Model_Sdv1TabIdLocal();
for ($i=0;$i<$nbIdNum;$i++) { for ($i=0;$i<$nbIdNum;$i++) {
if( !empty($item->{'idLoc'.$i.'Num'}) ) { if( !empty($item->{'idLoc'.$i.'Num'}) ) {
$ref = new LienRefId(); $ref = new LienRefId();
$ref->num = $item->{'idLoc'.$i.'Num'}; $ref->num = $item->{'idLoc'.$i.'Num'};
if (!empty($item->{'idLoc'.$i.'Type'})) {
if ( !empty($item->{'idLoc'.$i.'Type'}) ) { try {
$sql = $idM->select()->from($idM, array('idLocal', 'idPrincipal')) $sql = "SELECT idLocal, idPrincipal FROM sdv1.tabIdLocal WHERE id=:id";
->where('id=?', $item->{'idLoc'.$i.'Type'}); $stmt = $this->conn->prepare($sql);
$result = $idM->fetchRow($sql); $stmt->bindValue('id', $item->{'idLoc'.$i.'Type'});
if (null!==$result) { $stmt->execute();
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$ref->label = $result->idLocal; $ref->label = $result->idLocal;
$ref->type = $result->idPrincipal; $ref->type = $result->idPrincipal;
} else { } else {
$ref->label = ''; $ref->label = '';
$ref->type = 0; $ref->type = 0;
} }
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} else { } else {
$ref->label = 'Identifiant local'; $ref->label = 'Identifiant local';
$ref->type = 1; $ref->type = 1;
@ -1155,7 +1161,7 @@ class Entreprise extends Scores_Ws_Server
} }
} }
//Participations // Participations
$liens = $liensM->getParticipations(null, true); $liens = $liensM->getParticipations(null, true);
if (count($liens)>0) { if (count($liens)>0) {
foreach ( $liens as $item ) { foreach ( $liens as $item ) {
@ -1190,23 +1196,29 @@ class Entreprise extends Scores_Ws_Server
$nbIdNum = 3; $nbIdNum = 3;
$refs = array(); $refs = array();
$idM = new Application_Model_Sdv1TabIdLocal();
for ($i=0;$i<$nbIdNum;$i++) { for ($i=0;$i<$nbIdNum;$i++) {
if( !empty($item->{'idLoc'.$i.'Num'}) ) { if (!empty($item->{'idLoc'.$i.'Num'})) {
$ref = new LienRefId(); $ref = new LienRefId();
$ref->num = $item->{'idLoc'.$i.'Num'}; $ref->num = $item->{'idLoc'.$i.'Num'};
if ( !empty($item->{'idLoc'.$i.'Type'}) ) { if ( !empty($item->{'idLoc'.$i.'Type'}) ) {
$sql = $idM->select()->from($idM, array('idLocal', 'idPrincipal')) try {
->where('id=?', $item->{'idLoc'.$i.'Type'}); $sql = "SELECT idLocal, idPrincipal FROM sdv1.tabIdLocal WHERE id=:id";
$result = $idM->fetchRow($sql); $stmt = $this->conn->prepare($sql);
if (null!==$result) { $stmt->bindValue('id', $item->{'idLoc'.$i.'Type'});
$stmt->execute();
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ);
$ref->label = $result->idLocal; $ref->label = $result->idLocal;
$ref->type = $result->idPrincipal; $ref->type = $result->idPrincipal;
} else { } else {
$ref->label = ''; $ref->label = '';
$ref->type = 0; $ref->type = 0;
} }
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
} else { } else {
$ref->label = 'Identifiant local'; $ref->label = 'Identifiant local';
$ref->type = 1; $ref->type = 1;