issue #0001391 : Test si PDetention > 100%

This commit is contained in:
Michael RICOIS 2012-12-26 10:07:51 +00:00
parent d1590c3739
commit 599ac8eb39

View File

@ -1634,6 +1634,19 @@ class Saisie extends WsScore
$lienM = new Application_Model_JoLiens($db);
//Test si PDetention > 100
$sql = $lienM->select()->from($lienM, array(
'idPar', Zend_Db_Expr('sum( PDetention ) AS sumDet')
))
->where('idPar=?',$infos->idPar)
->where('actif=?',1);
$result = $lienM->fetchRow($sql);
if ( null !== $result ) {
if ( $result->sumDet + $infos->PDetention > 100 ) {
throw new SoapFault('ERR', "Erreur Detention > 100%");
}
}
//Enregistrer les infos
if (empty($id)) {
@ -1669,6 +1682,10 @@ class Saisie extends WsScore
try {
$id = $lienM->update($dataLien, 'id = '.$id);
} catch (Zend_Db_Statement_Exception $e) {
if ( $e->getCode() == 1062 ) {
$id = $lienM->delete('id = '.$id);
}
} catch (Zend_Db_Exception $e) {
if ($this->tabInfoUser['idClient']!=1) {
throw new SoapFault('ERR', "Application error");
@ -2337,13 +2354,13 @@ class Saisie extends WsScore
$lienM->update(
array('idPar'=>$idLien, 'idUpdate'=>$this->tabInfoUser['id']),
'idPar='.$id);
//Supprimer la fiche
$lienrefM = new Application_Model_JoLiensRef();
$lienM->update(
array('dateSuppr'=>date('Ymd'), 'idSuppr'=>$this->tabInfoUser['id']),
'id='.$id);
return true;
}