diff --git a/library/Metier/partenaires/classMBilans.php b/library/Metier/partenaires/classMBilans.php index fc2fcd8f..ab21456a 100644 --- a/library/Metier/partenaires/classMBilans.php +++ b/library/Metier/partenaires/classMBilans.php @@ -610,9 +610,9 @@ class MBilans { 'postes' =>$strPostes, 'partenaire' =>$tabBilan['SOURCE'], ); - if (!$iDb2->insert('bilans', $tabInsert, true)) - $iDb2->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'"); - $ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true); + if (!$this->iDb->insert('bilans', $tabInsert, true)) + $this->iDb->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'"); + $ret=$this->iDb->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true); $bilan=$ret[0]; } } @@ -740,7 +740,7 @@ class MBilans { ) { /** Il n'y a aucune information sur le bilan précédent **/ - $ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice<'$millesimeDB' ORDER BY dateExercice DESC LIMIT 0,1", true); + $ret=$this->iDb->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice<'$millesimeDB' ORDER BY dateExercice DESC LIMIT 0,1", true); $bilanPre=$ret[0]; $tabBilan['DATE_CLOTURE_PRE'] = $bilanPre['dateExercice']; // SSAAMMJJ $tabBilan['DUREE_MOIS_PRE'] = $bilanPre['dureeExercice'];