issue #0001541 : Delete line to remove duplicates
This commit is contained in:
parent
f7a65e2df3
commit
96c00b773b
@ -44,9 +44,12 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
$this->mode_diffusion = 'XL';
|
||||
$this->reference_client = 'list-' . $this->siren;
|
||||
|
||||
$actesM = new Application_Model_JoGreffesActes($this->db);
|
||||
|
||||
//Requete WebService
|
||||
$actesXML = null;
|
||||
if ( $onlyDb === false ) {
|
||||
$actesM->update(array('actif' => 0), 'siren='.$this->siren);
|
||||
//Infogreffe webservice
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
@ -59,9 +62,9 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
}
|
||||
|
||||
//Lecture de la base de données
|
||||
$actesM = new Application_Model_JoGreffesActes($this->db);
|
||||
$sql = $actesM->select()
|
||||
->where('siren=?', $this->siren)
|
||||
->where('actif=1')
|
||||
->order('date_depot DESC')
|
||||
->order('num_depot DESC')
|
||||
->order('num_acte ASC')
|
||||
@ -443,6 +446,7 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
'decision_nature' => empty($depot['decision']['nature']) ? '' : $depot['decision']['nature'] ,
|
||||
'decision_libelle' => empty($depot['decision']['libelle']) ? '' : $depot['decision']['libelle'] ,
|
||||
'mode_diffusion' => join(',',$depot['mode_diffusion']),
|
||||
'actif' => 1,
|
||||
);
|
||||
|
||||
//Only new element are inserted
|
||||
@ -457,12 +461,14 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
->order('dateInsert DESC');
|
||||
$rows = $acteM->fetchAll($sql);
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
throw new Exception('ERR', $e->getMessage());
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
//Insert new element
|
||||
if ( count($rows)==0 ) {
|
||||
try {
|
||||
//Add dateInsert
|
||||
$data['dateInsert'] = date('YmdHis');
|
||||
$result = $acteM->insert($data);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
@ -474,21 +480,23 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
|
||||
$item = $rows[0];
|
||||
if ( count($rows) > 1 ) {
|
||||
try {
|
||||
$result = $acteM->delete('id='.$item->id);
|
||||
$result = $acteM->delete(array(
|
||||
'siren='.$this->siren,
|
||||
'num_depot='.$list['num_depot'],
|
||||
'num_acte='.intval($depot['num_acte']),
|
||||
'id!='.$item->id,
|
||||
));
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
$item = $rows[1];
|
||||
}
|
||||
//Correct type
|
||||
if ( $depot['type_acte'] != $item->type_acte ) {
|
||||
|
||||
try {
|
||||
$result = $acteM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
|
||||
$bilansXML = null;
|
||||
if ( $onlyDb === false ) {
|
||||
//Set All line state to 0
|
||||
|
||||
$bilansM->update(array('actif' => 0), 'siren='.$this->siren);
|
||||
//Infogreffe webservice
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
@ -71,6 +71,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
|
||||
//Lecture de la base de données
|
||||
$sql = $bilansM->select()
|
||||
->where('siren=?', $this->siren)
|
||||
->where('actif=1')
|
||||
->order('date_cloture DESC')
|
||||
->order('num_depot DESC')
|
||||
->order('dateInsert DESC');
|
||||
@ -426,28 +427,50 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
|
||||
$sql = $bilanM->select()
|
||||
->where('siren=?', $this->siren)
|
||||
->where('date_cloture=?', $list['date_cloture_iso'])
|
||||
->where('type_comptes=?', $list['type_comptes']);
|
||||
$test = $bilanM->fetchRow($sql);
|
||||
if ( null === $test ) {
|
||||
//Add dateInsert
|
||||
$data['dateInsert'] = date('YmdHis');
|
||||
$result = $bilanM->insert($data);
|
||||
} else {
|
||||
$result = $bilanM->update($data, 'id='.$test->id);
|
||||
}
|
||||
->where('type_comptes=?', $list['type_comptes'])
|
||||
->order('dateInsert DESC');
|
||||
$rows = $bilanM->fetchAll($sql);
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $query = $this->db->getProfiler()->getLastQueryProfile()->getQuery();
|
||||
/*echo $query = $this->db->getProfiler()->getLastQueryProfile()->getQuery();
|
||||
echo "\n";
|
||||
$queryParams = $this->db->getProfiler()->getLastQueryProfile()->getQueryParams();
|
||||
print_r($queryParams);
|
||||
echo "\n";
|
||||
echo "\n";*/
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
$this->db->getProfiler()->setEnabled(false);
|
||||
|
||||
if ( count($rows) == 0 ) {
|
||||
//Add dateInsert
|
||||
$data['dateInsert'] = date('YmdHis');
|
||||
$result = $bilanM->insert($data);
|
||||
} else {
|
||||
//Correct multiple item
|
||||
$item = $rows[0];
|
||||
if ( count($rows) > 1 ) {
|
||||
try {
|
||||
$result = $bilanM->delete(array(
|
||||
'siren='.$this->siren,
|
||||
'num_depot='.$list['num_depot'],
|
||||
'date_cloture='.$list['date_cloture_iso'],
|
||||
'type_comptes='.$list['type_comptes'],
|
||||
'id!='.$item->id,
|
||||
));
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $bilanM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user