From 113bc53ad48cc07d55d32ca3870ad08840ff9509 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 28 Mar 2017 12:28:12 +0200 Subject: [PATCH] add folder src --- composer.json | 6 +- src/Metier/Identification/Item.php | 20 ++ src/Metier/Identification/ItemTable.php | 7 + {Metier => src/Metier}/Insee/MInsee.php | 0 {Metier => src/Metier}/Insee/Table.php | 0 src/Scores/Sirenage/Display.php | 159 +++++++++ src/Scores/Sirenage/Valid.php | 449 ++++++++++++++++++++++++ 7 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 src/Metier/Identification/Item.php create mode 100644 src/Metier/Identification/ItemTable.php rename {Metier => src/Metier}/Insee/MInsee.php (100%) rename {Metier => src/Metier}/Insee/Table.php (100%) create mode 100644 src/Scores/Sirenage/Display.php create mode 100644 src/Scores/Sirenage/Valid.php diff --git a/composer.json b/composer.json index f4021db..eda81e5 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,13 @@ "doctrine/dbal": "^2.5", "monolog/monolog": "^1.22" }, + "require-dev": { + "phpunit/phpunit": "^4.8" + }, + "include-path": ["src/"], "autoload": { "classmap": [ - "Metier/" + "src/Metier/" ] }, "authors": [ diff --git a/src/Metier/Identification/Item.php b/src/Metier/Identification/Item.php new file mode 100644 index 0000000..bb4b795 --- /dev/null +++ b/src/Metier/Identification/Item.php @@ -0,0 +1,20 @@ +db = Zend_Db_Table_Abstract::getDefaultAdapter(); + $this->source = $source; + $this->sourceSql(); + } + + public function sourceSql() + { + $this->sql = "SELECT "; + + // --- Champs + if ($this->source == 'annonces') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.raisonSociale, b.adresse, LPAD(b.codePostal,5,0) AS codePostal, b.ville, b.typeEven, b.dateJugement, b.dateInsert AS dateInsert_Bodacc, CONCAT(b.complement,' ',b.annonce,' ',b.infosBrutes) AS annonce, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'clients') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.nom AS raisonSociale, TRIM(CONCAT_WS(' ',b.adresse1,b.adresse2, b.adresse3)) AS adresse, LPAD(b.cp,5,0) AS codePostal, b.ville, '' AS typeEven, '' AS dateJugement, b.dateInsert AS dateInsert_Bodacc, CONCAT_WS(' ','Ref client :',refClient,', Enseigne :',enseigne) AS annonce, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'asso') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.Num_Parution AS Bodacc_Num, b.Date_Parution AS Bodacc_Date_Parution, b.Num_Annonce, b.codTribunal AS Tribunal_Code, '' AS Rubrique_Bodacc, b.Activite AS Rubrique, b.typeAnnonce, b.corrNum_Annonce, corrDate_Parution AS corrBodacc_Date_Parution, b.corrPage, b.corrNumParution, '' AS corrTexteRectificatif, b.typeAsso AS FJ, '' AS Capital, '' AS CapitalDev, b.Waldec AS RC, b.Assoc_Nom AS raisonSociale, '' AS nomCommercial, '' AS enseigne, '' AS nationalite, b.Assoc_Adresse AS adresse, Assoc_AdrNum AS adrNum, Assoc_AdrIndRep AS adrIndRep, Assoc_AdrTypVoie AS adrTypVoie, Assoc_AdrLibVoie AS adrLibVoie, LPAD(Assoc_AdrCP,5,0) AS codePostal, Assoc_AdrVille AS ville, Assoc_AdrComp AS adrComp1, '' AS adrComp2, codEven AS typeEven, Assoc_Date_Declaration2 AS dateJugement, b.dateInsert AS dateInsert_Bodacc, Annonce_Html AS annonce, b.Assoc_Objet AS activite, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'dirigeants') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, '' AS Bodacc_Num, '' AS Bodacc_Date_Parution, '' AS Num_Annonce, '' AS Tribunal_Code, '' AS Rubrique_Bodacc, '' AS Rubrique, 'Insertion' AS typeAnnonce, '' AS corrNum_Annonce, '' AS corrBodacc_Date_Parution, '' AS corrPage, '' AS corrNumParution, '' AS corrTexteRectificatif, '' AS RC, dirRS AS raisonSociale, civilite, b.nom, prenom, naissance_nom, naissance_date, naissance_lieu, nat AS nationalite, typeDir AS FJ, adresse, fonction_code, fonction_lib, actif, dateFin, source, flux, cinf, b.siren AS sirenDirected, b.dateInsert AS dateInsert_Bodacc, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'dirigeantsCAC') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, '' AS Bodacc_Num, '' AS Bodacc_Date_Parution, '' AS Num_Annonce, '' AS Tribunal_Code, '' AS Rubrique_Bodacc, '' AS Rubrique, 'Insertion' AS typeAnnonce, '' AS corrNum_Annonce, '' AS corrBodacc_Date_Parution, '' AS corrPage, '' AS corrNumParution, '' AS corrTexteRectificatif, '' AS RC, b.RS AS raisonSociale, '' AS civilite, b.nom, prenom, nomUsage AS naissance_nom, 0 AS naissance_date, '' AS naissance_lieu, '' AS nationalite, '' AS FJ, '' AS adresse, fonction AS fonction_code, '' AS fonction_lib, (depart-1) AS actif, dateFin, 0 AS source, 0 AS flux, 0 AS cinf, b.siren AS sirenDirected, b.dateInsert AS dateInsert_Bodacc, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'boamp') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, a.Boamp_Num AS Bodacc_Num, b.Boamp_Date_Parution AS Bodacc_Date_Parution, a.Num_Annonce, a.Boamp_Dept_Lib AS Tribunal_Code, b.Boamp_Rubrique AS Rubrique_Bodacc, b.Boamp_Code AS Rubrique, a.typeAnnonce, '' AS corrNum_Annonce, '' AS corrBodacc_Date_Parution, '' AS corrPage, '' AS corrNumParution, '' AS corrTexteRectificatif, '' AS RC, nom AS raisonSociale, adresse, LPAD(cp,5,0) AS codePostal, ville, b.tel, b.fax, b.email, b.web, b.montantTxt, autre, b.num, b.titre, `desc` AS decription, b.dateInsert AS dateInsert_Bodacc, s.appelerMand, s.droitLocal, a.annonce"; + } + elseif ($this->source == 'boamp2') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, a.Boamp_Num AS Bodacc_Num, b.Boamp_Date_Parution AS Bodacc_Date_Parution, a.Num_Annonce, a.Boamp_Dept_Lib AS Tribunal_Code, b.Boamp_Rubrique AS Rubrique_Bodacc, b.Boamp_Code AS Rubrique, a.typeAnnonce, '' AS corrNum_Annonce, '' AS corrBodacc_Date_Parution, '' AS corrPage, '' AS corrNumParution, '' AS corrTexteRectificatif, '' AS RC, raisonSociale, adresse, LPAD(cp,5,0) AS codePostal, ville, b.tel, b.fax, b.email, b.web, b.estimValeur AS montantTxt, autres AS autre, 0 AS num, b.titre, carAutre AS decription, b.dateInsert AS dateInsert_Bodacc, s.appelerMand, s.droitLocal, a.annonce"; + } + elseif ($this->source == 'tourisme') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.nom AS raisonSociale, b.adresse, LPAD(b.adrCp,5,0) AS codePostal, b.adrVille AS ville, '' AS typeEven, '' AS dateJugement, b.dateInsert AS dateInsert_Bodacc, CONCAT_WS(' ', 'Etoiles :',nbEtoiles) AS annonce, s.appelerMand, s.droitLocal"; + } + elseif ($this->source == 'marques') { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.deposantMarque AS raisonSociale, TRIM(CONCAT_WS(' ',b.deposant_AdrNum,b.deposant_AdrIndRep, b.deposant_AdrTypVoie, b.deposant_AdrLibVoie, b.deposant_AdrComp)) AS adresse, LPAD(b.deposant_AdrCP,5,0) AS codePostal, b.deposant_AdrVille AS ville, '' AS typeEven, '' AS dateJugement, b.dateInsert AS dateInsert_Bodacc, CONCAT_WS(' ','Marque :',nomMarque,',',rayonMarque,', Numéro :',numeroMarque,'Dépôt le :',dateDepot,'
',infoMarque) AS annonce, s.appelerMand, s.droitLocal"; + } + else { + $this->sql.= "s.droitLocal, s.idTable, s.idLien, s.idAnn, s.siren, s.siretProposes, s.dateInsert AS dateInsert_Sirenage, b.Bodacc_Num, b.Bodacc_Date_Parution, b.Num_Annonce, b.Tribunal_Code, b.Rubrique_Bodacc, b.Rubrique, b.typeAnnonce, b.corrNum_Annonce, b.corrBodacc_Date_Parution, b.corrPage, b.corrNumParution, b.corrTexteRectificatif, b.RC, b.raisonSociale, b.nomCommercial, b.enseigne, b.nationalite, b.FJ, b.Capital, b.CapitalDev, b.adresse, b.adrNum, b.adrIndRep, b.adrTypVoie, b.adrLibVoie, b.adrComp1, b.adrComp2, LPAD(b.codePostal,5,0) AS codePostal, b.ville, b.adresseSiege, b.adrSiegeNum, b.adrSiegeIndRep, b.adrSiegeTypVoie, b.adrSiegeLibVoie, b.adrSiegeComp1, b.adrSiegeComp2, b.codePostalSiege, b.villeSiege, b.administration, b.activite, b.typeEven, b.dateEffet, b.dateDebutActivite, b.dateCessationActivite, b.dateCessationPaiement, b.dateJugement, b.dateInsert AS dateInsert_Bodacc, d.annonce, b.activite, s.appelerMand, s.droitLocal"; + } + + // --- FROM + $this->sql.= " FROM "; + + if ($this->source == 'annonces'){ + $this->sql.= 'jo.bodacc_sirenage s, jo.annonces b'; + } + elseif ($this->source == 'clients') { + $this->sql.= 'jo.bodacc_sirenage s, jo.sirenage_clients b'; + } + elseif ($this->source == 'asso') { + $this->sql.= 'jo.bodacc_sirenage s, jo.asso b'; + } + elseif ($this->source == 'dirigeants') { + $this->sql.= 'jo.bodacc_sirenage s, jo.rncs_dirigeants b'; + } + elseif ($this->source == 'dirigeantsCAC') { + $this->sql.= 'jo.bodacc_sirenage s, jo.bodacc_dirigeants b'; + } + elseif ($this->source == 'bodacc') { + $this->sql.= 'jo.bodacc_sirenage s, jo.bodacc_detail b'; + } + elseif ($this->source == 'boamp') { + $this->sql.= 'jo.bodacc_sirenage s, jo.boamp_lots b'; + } + elseif ($this->source == 'boamp2') { + $this->sql.= 'jo.bodacc_sirenage s, jo.boamp_detail b'; + } + elseif ($this->source == 'tourisme') { + $this->sql.= 'jo.bodacc_sirenage s, jo.tourisme b'; + } + elseif ($this->source == 'marques') { + $this->sql.= 'jo.bodacc_sirenage s, bopi.marques b'; + } + else { + $this->sql.= 'jo.bodacc_sirenage s, jo.bodacc_detail b, jo.bodacc d'; + } + + // --- WHERE + $this->sql.= " WHERE "; + + if ($this->source == 'annonces') { + $this->sql.= "s.idAnn=b.id AND s.idTable='annonces' AND s.siren=b.siren"; + } + elseif ($this->source == 'clients') { + $this->sql.= "s.idAnn=b.id AND s.idTable='sirenage_clients' AND s.siren=b.siren"; + } + elseif ($this->source == 'asso') { + $this->sql.= "s.idAnn=b.id AND s.idTable='asso' AND s.siren=b.siren"; + } + elseif ($this->source == 'dirigeants') { + $this->sql.= "s.idAnn=b.id AND idTable='rncs_dirigeants' AND s.siren=b.dirSiren"; + } + elseif ($this->source == 'dirigeantsCAC') { + $this->sql.= "s.idAnn=b.idL AND idTable='bodacc_dirigeants' AND s.siren=b.dirSiren"; + } + elseif ($this->source == 'boamp') { + $this->sql.= "s.idAnn=b.id AND s.idTable='boamp_lots' AND b.idAnn=a.id AND s.siren=b.siren"; + } + elseif ($this->source == 'boamp2') { + $this->sql.= "s.idAnn=b.id AND s.idTable='boamp_detail' AND b.id=a.id AND s.siren=b.siren"; + } + elseif ($this->source == 'tourisme') { + $this->sql.= "s.idAnn=b.id AND s.idTable='tourisme' AND s.siren=b.siren"; + } + elseif ($this->source == 'marques') { + $this->sql.= "s.idAnn=b.id AND s.idTable='marques' AND s.siren=b.sirenDeposant AND deposantPays='FR'"; + } + else { + $this->sql.= "s.idAnn=b.id AND s.idTable='bodacc_detail' AND b.sirenValide=0 AND s.siren=b.siren AND b.id=d.id"; + } + } + + public function setLimit($offset) + { + $this->sql.= " LIMIT $offset, $this->Limit"; + } + + public function setFilter($name, $value) + { + + } + + //Date + //Filtre + //Pagination - nbAffichage + + //count + + + public function getResults() + { + + $results = $this->db->fetchAll($this->sql); + $resultsFormated = $this->format($results); + return $resultsFormated; + } + + + public function format($results) + { + + + } +} \ No newline at end of file diff --git a/src/Scores/Sirenage/Valid.php b/src/Scores/Sirenage/Valid.php new file mode 100644 index 0000000..b5a94e4 --- /dev/null +++ b/src/Scores/Sirenage/Valid.php @@ -0,0 +1,449 @@ +db = Zend_Db_Table_Abstract::getDefaultAdapter(); + } + + public function getErrorMsg() + { + return $this->msg; + } + + public function setUserId($id) + { + $this->userId = $id; + } + + /** + * ASSO + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + * @param unknown $siret + */ + public function saveASSO($idLien, $idAnn, $idSiren, $sirenLu, $nicLu, $siret = null) + { + if (strtoupper(substr($sirenLu,0,1)) == 'W') { + $dataUpdate = array( + 'Waldec' => strtoupper(substr($siret,0,10)), + 'idSirenage' => $this->userId, + ); + } else { + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId, + ); + } + + if (empty($idSiren)) { + $whereUpdate = 'id='.$idAnn; + } else { + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + } + + $this->db->beginTransaction(); + try { + $this->db->update('jo.asso', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * Tourisme + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + */ + public function saveTOURISME($idLien, $idAnn, $idSiren, $sirenLu, $nicLu) + { + if (intval($nicLu) == 0) { + $nicValide = 0; + } else { + $nicValide = 2; + } + + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.tourisme', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * BOAMP + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + */ + public function saveBOAMP($idLien, $idAnn, $idSiren, $sirenLu, $nicLu) + { + if (intval($nicLu) == 0) { + $nicValide = 0; + } else { + $nicValide = 2; + } + + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.boamp_lots', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * Boamp Administration + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + */ + public function saveBOAMP2($idLien, $idAnn, $idSiren, $sirenLu, $nicLu) + { + if (intval($nicLu) == 0) { + $nicValide = 0; + } else { + $nicValide = 2; + } + + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.boamp_detail', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * Annonces + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + */ + public function saveANNONCES($idLien, $idAnn, $idSiren, $sirenLu) + { + $dataUpdate = array( + 'siren' => $sirenLu, + 'sirenValide' => 2, + 'idSaisie' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.annonces', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * CLIENTS + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + */ + public function saveCLIENTS($idLien, $idAnn, $idSiren, $sirenLu, $nicLu) + { + if (intval($nicLu) == 0) { + $nicValide = 0; + } else { + $nicValide = 2; + } + + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.sirenage_clients', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * MARQUES + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @return boolean + */ + public function saveMARQUES($idLien, $idAnn, $idSiren, $sirenLu) + { + $dataUpdate = array( + 'sirenDeposant' => $sirenLu, + 'sirenValide' => 2, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn.' AND sirenDeposant='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('bopi.marques', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * DIRIGEANTS + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + */ + public function saveDIRIGEANTS($idLien, $idAnn, $idSiren, $sirenLu) + { + $dataUpdate = array( + 'dirSiren' => $sirenLu, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'id='.$idAnn; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.rncs_dirigeants', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * DIRIGEANTS CAC + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + */ + public function saveDIRIGEANTSCAC($idLien, $idAnn, $idSiren, $sirenLu) + { + $dataUpdate = array( + 'dirSiren' => $sirenLu, + 'idSirenage' => $this->userId + ); + $whereUpdate = 'idL='.$idAnn; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.bodacc_dirigeants', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + + /** + * BODACC + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + * @param unknown $nicLu + * @param unknown $siret + */ + public function saveBODACC($idLien, $idAnn, $idSiren, $sirenLu, $nicLu, $siret = null) + { + $exist = $this->db->fetchRow("SELECT count(*) AS nb FROM jo.bodacc_detail WHERE id=$idAnn AND siren=$sirenLu AND sirenValide>0"); + // Cette annonce est déjà ratachée à ce siren pour le même code évènement + if (count($exist) > 0 && $exist['nb'] > 0){ + if ($idSiren < 1000) { + if (strtoupper(substr($sirenLu,0,1))=='W') { + // --- ???? + } else { + $dataUpdate = array( + 'idSuppr' => $this->userId, + 'dateSuppr' => date('YmdHis'), + ); + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.bodacc_detail', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + } + } + + } else { + if (intval($nicLu) == 0) { + $nicValide = 0; + } else { + $nicValide = 2; + } + + if (strtoupper(substr($sirenLu,0,1))=='W'){ + $dataUpdate = array( + 'waldec'=>strtoupper(substr($siret,0,10)), + 'sirenValide' => 8, + 'idSirenage' => $this->userId + ); + } else { + $dataUpdate = array( + 'siren' => $sirenLu, + 'nic' => $nicLu, + 'sirenValide' => 2, + 'nicValide' => $nicValide, + 'idSirenage' => $this->userId + ); + } + $whereUpdate = 'id='.$idAnn.' AND siren='.$idSiren; + + $this->db->beginTransaction(); + try { + $this->db->update('jo.bodacc_detail', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + } + + return false; + } + + /** + * Contentieux + * @param unknown $idLien + * @param unknown $idAnn + * @param unknown $idSiren + * @param unknown $sirenLu + */ + public function saveCTX($idLien, $idAnn, $idSiren, $sirenLu) + { + $dataUpdate = array( + 'entSiren' => $sirenLu, + ); + $whereUpdate = 'idL='.$idAnn; + // --- id, userId, action, value, date + + $this->db->beginTransaction(); + try { + $this->db->update('jo.greffes_affaires_siren', $dataUpdate, $whereUpdate); + $this->db->delete('jo.bodacc_sirenage', 'idLien='.$idLien); + $this->db->commit(); + return true; + } catch (Exception $e) { + $this->db->rollBack(); + $this->msg = $e->getMessage(); + } + + return false; + } + +} \ No newline at end of file