Entreprise - getSubventionList : remove Zend_Db
This commit is contained in:
parent
75b9abeda8
commit
9f04226286
@ -2099,14 +2099,19 @@ class Entreprise extends Scores_Ws_Server
|
||||
$entites[] = $entite;
|
||||
|
||||
//Search titulaire
|
||||
$boamplotsM = new Application_Model_JoBoampLots();
|
||||
$sql = $boamplotsM->select()->from($boamplotsM, array(
|
||||
'LPAD(siren, 9, 000000000) AS siren',
|
||||
'LPAD(nic, 5, 00000) AS nic', 'nom','adresse','cp', 'ville', 'pays')
|
||||
)->where('idAnn=?', substr($ann['id'],2));
|
||||
$result = $boamplotsM->fetchAll($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $entity) {
|
||||
try {
|
||||
$sql = "SELECT LPAD(siren, 9, 000000000) AS siren, LPAD(nic, 5, 00000) AS nic, nom, adresse, cp, ville, pays
|
||||
FROM jo.boamp_lots WHERE idAnn=:id";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('id', substr($ann['id'],2));
|
||||
$stmt->execute();
|
||||
} catch(\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmt->rowCount() > 0) {
|
||||
while ($entity = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$entite = new AnnonceEntite();
|
||||
$entite->siret = $entity->siren.$entity->nic;
|
||||
$entite->raisonSociale = $entity->nom;
|
||||
@ -5338,7 +5343,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//Init
|
||||
// Init
|
||||
if ( intval($companyId) == 0 ) {
|
||||
$this->sendError('1010');
|
||||
} elseif ( strlen($companyId)!=9 ) {
|
||||
@ -5348,77 +5353,94 @@ class Entreprise extends Scores_Ws_Server
|
||||
if ( empty($nbItems) || $nbItems > 100 ) { $nbItems = 100; }
|
||||
if ( !empty($type) ) { $type = strtoupper($type); }
|
||||
|
||||
//SQL
|
||||
$listM = new Application_Model_JoAssoSubventions();
|
||||
$countsql = $listM->select()->from($listM, array('COUNT(*) AS num'));
|
||||
$sql = $listM->select()->from($listM, array(
|
||||
'id',
|
||||
'millesime', //Annee
|
||||
'sirenAsso', //sirenIn
|
||||
'nomAsso',
|
||||
'sirenOrigine', //sirenOut
|
||||
'libOrigine', //Origine
|
||||
'libImputation', //Programme
|
||||
'mtSubvention', //Montant
|
||||
));
|
||||
// SQL
|
||||
$qbList = $this->conn->createQueryBuilder();
|
||||
$qbCount = $this->conn->createQueryBuilder();
|
||||
$qbList->select(array(
|
||||
'id',
|
||||
'millesime', //Annee
|
||||
'sirenAsso', //sirenIn
|
||||
'nomAsso',
|
||||
'sirenOrigine', //sirenOut
|
||||
'libOrigine', //Origine
|
||||
'libImputation', //Programme
|
||||
'mtSubvention', //Montant
|
||||
))->from(jo.asso_subventions);
|
||||
$qbCount->select('COUNT(*) AS num')->from('jo.asso_subventions');
|
||||
|
||||
//Subvention reçues => sirenAsso = companyId
|
||||
// Subvention reçues => sirenAsso = companyId
|
||||
if ($type == 'IN') {
|
||||
$sql->where('sirenAsso=?', $companyId);
|
||||
$countsql->where('sirenAsso=?', $companyId);
|
||||
$qbList->where('sirenAsso=:companyId')->setParameter('companyId', $companyId);
|
||||
$qbCount->where('sirenAsso=:companyId')->setParameter('companyId', $companyId);
|
||||
}
|
||||
//Subvention reçues => sirenOrigine = companyId
|
||||
// Subvention reçues => sirenOrigine = companyId
|
||||
elseif ($type == 'OUT') {
|
||||
$sql->where('sirenOrigine=?', $companyId);
|
||||
$countsql->where('sirenOrigine=?', $companyId);
|
||||
$qbList->where('sirenOrigine=:companyId')->setParameter('companyId', $companyId);
|
||||
$qbCount->where('sirenOrigine=:companyId')->setParameter('companyId', $companyId);
|
||||
}
|
||||
//All
|
||||
// All
|
||||
else {
|
||||
$sql->where('sirenAsso=?', $companyId)
|
||||
->orWhere('sirenOrigine=?', $companyId);
|
||||
$countsql->where('sirenAsso=?', $companyId)
|
||||
->orWhere('sirenOrigine=?', $companyId);
|
||||
$qbList->where('sirenAsso=:companyId')->orWhere('sirenOrigine=:companyId')->setParameter('companyId', $companyId);
|
||||
$qbCount->where('sirenAsso=:companyId')->orWhere('sirenOrigine=:companyId')->setParameter('companyId', $companyId);
|
||||
}
|
||||
$sql->order('millesime DESC')->limit($nbItems, $offset);
|
||||
$qbList->orderBy('millesime DESC')->setFirstResult($offset)->setMaxResults($nbItems);
|
||||
|
||||
$count = $listM->fetchRow($countsql);
|
||||
$nbReponsesTotal = 0;
|
||||
if ( $count!==null ) {
|
||||
$nbReponsesTotal = $count->num;
|
||||
try {
|
||||
$stmt = $qbCount->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 ( $nbReponsesTotal != 0 ) {
|
||||
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
$nbReponsesTotal = $count->num;
|
||||
|
||||
$rows = $listM->fetchAll($sql);
|
||||
if ($nbReponsesTotal > 0) {
|
||||
|
||||
try {
|
||||
$stmt = $qbList->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");
|
||||
}
|
||||
}
|
||||
|
||||
$output = new SubventionList();
|
||||
$output->nbReponsesTotal = $nbReponsesTotal;
|
||||
$result = array();
|
||||
|
||||
if ( $rows !== null ) {
|
||||
foreach ( $rows as $row ) {
|
||||
|
||||
$item = new Subvention();
|
||||
$item->Id = $row->id;
|
||||
if ( $row->sirenAsso == $companyId ) {
|
||||
$item->Type = 'IN';
|
||||
} elseif ( $row->sirenOrigine == $companyId ) {
|
||||
$item->Type = 'OUT';
|
||||
}
|
||||
$item->Millesime = $row->millesime;
|
||||
$item->AssoSiren = $row->sirenAsso;
|
||||
$item->AssoNom = $row->nomAsso;
|
||||
$item->OrigineSiren = $row->sirenOrigine;
|
||||
$item->OrigineLib = $row->libOrigine;
|
||||
$item->Programme = $row->libImputation;
|
||||
$item->Montant = $row->mtSubvention;
|
||||
|
||||
$result[] = $item;
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$item = new Subvention();
|
||||
$item->Id = $row->id;
|
||||
if ( $row->sirenAsso == $companyId ) {
|
||||
$item->Type = 'IN';
|
||||
} elseif ( $row->sirenOrigine == $companyId ) {
|
||||
$item->Type = 'OUT';
|
||||
}
|
||||
$output->result = $result;
|
||||
$this->wsLog('subventionlist', $companyId);
|
||||
$item->Millesime = $row->millesime;
|
||||
$item->AssoSiren = $row->sirenAsso;
|
||||
$item->AssoNom = $row->nomAsso;
|
||||
$item->OrigineSiren = $row->sirenOrigine;
|
||||
$item->OrigineLib = $row->libOrigine;
|
||||
$item->Programme = $row->libImputation;
|
||||
$item->Montant = $row->mtSubvention;
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
|
||||
$output->result = $result;
|
||||
$this->wsLog('subventionlist', $companyId);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@ -5434,14 +5456,27 @@ class Entreprise extends Scores_Ws_Server
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
$subventionM = new Application_Model_JoAssoSubventions();
|
||||
$row = $subventionM->find($id);
|
||||
try {
|
||||
$sql = "SELECT * FROM jo.asso_subventions 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 {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
if (null === row) {
|
||||
if ($stmt->rowCount() == 0) {
|
||||
throw new SoapFault('MSG', "Aucun résultat");
|
||||
}
|
||||
|
||||
$data = $row->current();
|
||||
$data = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
|
||||
$item = new SubventionDetail();
|
||||
$item->Millesime = $data->millesime;
|
||||
|
Loading…
Reference in New Issue
Block a user