Entreprise - getGreffeAffaireDetail : remove Application_Model

This commit is contained in:
Michael RICOIS 2017-03-15 15:15:06 +01:00
parent 22e907ceaf
commit 2ad397baf3

View File

@ -934,13 +934,16 @@ class Entreprise extends Scores_Ws_Server
$this->authenticate();
$this->permission('contentieux');
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$affaireSql = "SELECT id, idAffaire, numGreffe, natureDemande, codNatureDemande, etatAffaire, dateEnrolement FROM jo.greffes_affaires ".
"WHERE id=".$id;
try {
$affaireResult = $db->fetchRow($affaireSql, null, Zend_DB::FETCH_OBJ);
} catch (Zend_Db_Exception $e) {
$sql = "SELECT id, idAffaire, numGreffe, natureDemande, codNatureDemande, etatAffaire, dateEnrolement
FROM jo.greffes_affaires WHERE id=:id";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('id', $id);
$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 {
@ -949,17 +952,22 @@ class Entreprise extends Scores_Ws_Server
}
// --- Aucun resultat
if ($affaireResult === null) {
if ($stmt->rowCount() == 0) {
throw new SoapFault('MSG', "Aucun résultat");
}
$affaireResult = $stmt->fetch(\PDO::FETCH_OBJ);
// --- Selection des Entités
$tiers = array();
$entiteSql = "SELECT * FROM jo.greffes_affaires_siren WHERE idAffaire='".$affaireResult->idAffaire."' ORDER BY FIELD(qualite, 'DE', 'DF')";
try {
$entiteResult = $db->fetchAll($entiteSql, null, Zend_DB::FETCH_OBJ);
if (count($entiteResult) > 0) {
foreach ($entiteResult as $item) {
$sql = "SELECT * FROM jo.greffes_affaires_siren WHERE idAffaire=:id ORDER BY FIELD(qualite, 'DE', 'DF')";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('id', $affaireResult->idAffaire);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$entite = new GreffeAffaireTiers();
$entite->companyId = $item->entSiren;
$entite->companyNom = $item->nomPartie;
@ -985,7 +993,10 @@ class Entreprise extends Scores_Ws_Server
}
}
} catch (Zend_Db_Exception $e) {
} 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 {
@ -995,11 +1006,13 @@ class Entreprise extends Scores_Ws_Server
// --- Selection de l'historique
$histo = array();
$histoSql = "SELECT * FROM jo.greffes_affaires_histo WHERE idAffaire='".$affaireResult->idAffaire."' ORDER BY dateDecision DESC";
try {
$histoResult = $db->fetchAll($histoSql, null, Zend_DB::FETCH_OBJ);
if (count($histoResult) > 0) {
foreach ($histoResult as $h){
$sql = "SELECT * FROM jo.greffes_affaires_histo WHERE idAffaire=:id ORDER BY dateDecision DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('id', $affaireResult->idAffaire);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($h = $stmt->fetch(\PDO::FETCH_OBJ)) {
$decision = new GreffeAffaireHisto();
$decision->Label = $h->libelleDecision;
$decision->Date = $h->dateDecision;
@ -1007,8 +1020,11 @@ class Entreprise extends Scores_Ws_Server
$histo[] = $decision;
}
}
} catch (Zend_Db_Exception $e) {}
} catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
// --- Formattage
$status = include APPLICATION_PATH . '/../library/Metier/Ctx/AffaireStatus.php';
@ -1357,8 +1373,6 @@ class Entreprise extends Scores_Ws_Server
throw new SoapFault('ERR', 'Identifiant incorrect.');
}
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$cadastre = new Metier_Partenaires_MCadastre();
$cadastre->setId($companyId);
$patrimoine = array();