issue #0001541 : Gestion des doublons
This commit is contained in:
parent
fd1c1b0ad6
commit
4bb9e98e4f
@ -52,6 +52,7 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
} catch( Exception $e ) {
|
||||
//file_put_contents('debug.log', $e->getMessage());
|
||||
//@todo : get error message
|
||||
return array();
|
||||
}
|
||||
@ -62,6 +63,9 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
$actesM = new Application_Model_JoGreffesActes($this->db);
|
||||
$sql = $actesM->select()
|
||||
->where('siren=?', $this->siren)
|
||||
->order('date_depot DESC')
|
||||
->order('num_depot DESC')
|
||||
->order('num_acte ASC')
|
||||
->order('date_acte DESC');
|
||||
$rows = $actesM->fetchAll($sql);
|
||||
|
||||
@ -300,6 +304,9 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
{
|
||||
$actenum = array();
|
||||
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
|
||||
if ($infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue == '') {
|
||||
$actenum['date_acte'] = '000-00-00';
|
||||
}
|
||||
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
||||
@ -406,60 +413,62 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
*/
|
||||
protected function dbUpdateItem($list)
|
||||
{
|
||||
//siren
|
||||
//numRC
|
||||
//numGreffe
|
||||
//num_depot
|
||||
//date_depot
|
||||
//date_acte
|
||||
//num_acte
|
||||
//type_acte => Attention garder la version 1 et 2
|
||||
//type_acte_libelle
|
||||
//nbpages_acte
|
||||
//decision_nature
|
||||
//decision_libelle
|
||||
//mode_diffusion
|
||||
|
||||
foreach ($list['depot'] as $depot) {
|
||||
$data = array(
|
||||
'siren' => $list['siren'],
|
||||
'siren' => $list['num_siren'],
|
||||
'numRC' => $list['num_gest']['dossier_millesime'].
|
||||
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
|
||||
'numGreffe' => $list['num_gest']['greffe'],
|
||||
'num_depot' => $list['num_depot'],
|
||||
'date_depot' => $list['date_depot'],
|
||||
'date_acte' => $list['date_acte'],
|
||||
'num_acte' => $list['num_acte'],
|
||||
'type_acte' => $list['type_acte'], //@todo : Attention type acte différent
|
||||
'type_acte_libelle' => $list['type_acte_libelle'],
|
||||
'nbpages_acte' => $list['nbpages_acte'],
|
||||
'decision_nature' => $list['decision']['nature'],
|
||||
'decision_libelle' => $list['decision']['libelle'],
|
||||
'mode_diffusion' => join(',',$list['mode_diffusion']),
|
||||
'date_acte' => $depot['date_acte'],
|
||||
'num_acte' => $depot['num_acte'],
|
||||
'type_acte' => $depot['type_acte'], //@todo : Attention type acte différent
|
||||
'type_acte_libelle' => $depot['type_acte_libelle'],
|
||||
'nbpages_acte' => $depot['nbpages_acte'],
|
||||
'decision_nature' => $depot['decision']['nature'],
|
||||
'decision_libelle' => $depot['decision']['libelle'],
|
||||
'mode_diffusion' => join(',',$depot['mode_diffusion']),
|
||||
);
|
||||
|
||||
//Only new element are inserted
|
||||
try {
|
||||
$acteM = new Application_Model_JoGreffesActes($this->db);
|
||||
$acteM->select()
|
||||
->where('siren=?', $list['siren'])
|
||||
$sql = $acteM->select()
|
||||
->where('siren=?', $list['num_siren'])
|
||||
->where('num_depot=?', $list['num_depot'])
|
||||
->where('date_depot=?', $list['date_depot'])
|
||||
->where('date_acte=?', $list['date_acte'])
|
||||
->where('num_acte=?', $list['num_acte']);
|
||||
if ( null === $acteM->fetchRow($sql) ) {
|
||||
//->where('date_depot=?', $list['date_depot'])
|
||||
//->where('date_acte=?', $depot['date_acte'])
|
||||
->where('num_acte=?', $depot['num_acte'])
|
||||
->order('dateInsert DESC');
|
||||
file_put_contents('test.log', $sql->__toString()."\n", FILE_APPEND);
|
||||
$rows = $acteM->fetchAll($sql);
|
||||
//Insert new element
|
||||
if ( null === $rows ) {
|
||||
$result = $acteM->insert($data);
|
||||
//Update information
|
||||
} else {
|
||||
file_put_contents('test.log', print_r($list,1), FILE_APPEND);
|
||||
|
||||
//Correct multiple item
|
||||
$item = $rows[0];
|
||||
if ( count($rows) > 1 ) {
|
||||
$acteM->delete('id='.$item->id);
|
||||
$item = $rows[1];
|
||||
}
|
||||
//Correct type
|
||||
if ( $list['type_acte'] != $item->type_acte ) {
|
||||
$acteM->update($data, 'id='.$item->id);
|
||||
}
|
||||
}
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,6 +200,7 @@ class Pieces extends WsScore
|
||||
$list = $infogreffe->getList();
|
||||
$nbBilans = count($list);
|
||||
|
||||
//@todo : Marquer les éléments avec les informations de saisie
|
||||
//@todo : Marquer les éléments en commande courrier si déjà commandé ModeDiffusion = O
|
||||
|
||||
}
|
||||
@ -379,7 +380,7 @@ class Pieces extends WsScore
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($identifiant);
|
||||
$list = $infogreffe->getList(true);
|
||||
$list = $infogreffe->getList();
|
||||
$nbActes = count($list);
|
||||
|
||||
if ($nbActes>0) {
|
||||
@ -476,7 +477,7 @@ class Pieces extends WsScore
|
||||
$refCommande = uniqid();
|
||||
|
||||
$iInsee = new MInsee();
|
||||
$raisonSociale = $iInsee->getIdentiteLight($identifiant);
|
||||
$identite = $iInsee->getIdentiteLight($identifiant);
|
||||
|
||||
//Sauvegarde dans la base
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
||||
@ -487,7 +488,7 @@ class Pieces extends WsScore
|
||||
'refClient' => $reference,
|
||||
'siren' => $identifiant,
|
||||
'mode' => 'C',
|
||||
'raisonSociale' => $raisonSociale,
|
||||
'raisonSociale' => $identite['Nom'],
|
||||
'depotNum' => $depotNum,
|
||||
'depotDate' => $depotDate,
|
||||
'acteType' => $acteType,
|
||||
|
Loading…
Reference in New Issue
Block a user