MRncs : Finition

This commit is contained in:
Michael RICOIS 2017-01-12 14:23:52 +01:00
parent d69bceeb3b
commit 44a554b1d0

View File

@ -115,12 +115,14 @@ class Metier_Partenaires_MRncs
if (file_exists($cache)) {
return include $cache;
} else {
$rep = $this->iDb->select('jo.tabDevises', 'devInpi, devIso', 'devInpi>0', false, MYSQL_ASSOC);
$tabDevises = array();
foreach ($rep as $k=>$dev) {
$tabDevises[$dev['devInpi']*1]=$dev['devIso'];
$sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabDevises[intval($item->devInpi)] = $item->devIso;
}
}
return $tabDevises;
}
}
@ -140,7 +142,7 @@ class Metier_Partenaires_MRncs
}
/**
*
* Table Jugements
* @return array
*/
public function getTabJugements()
@ -149,12 +151,15 @@ class Metier_Partenaires_MRncs
if (file_exists($cache)) {
return include $cache;
} else {
$rep = $this->iDb->select('jo.tabJugeRncs', 'codJugement, codEven', '1', false, MYSQL_ASSOC);
$tabJug = array();
foreach ($rep as $k => $dev) {
$tabJug[$dev['codJugement']*1] = $dev['codEven'];
$sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabJug[intval($item->codJugement)] = $item->codEven;
}
}
return $tabJug;
}
}
@ -172,18 +177,21 @@ class Metier_Partenaires_MRncs
* Initialisation du tableau privé des pays Inpi <=> ISO
* @return array
*/
private function getTabPaysInpi()
protected function getTabPaysInpi()
{
$cache = dirname(__FILE__) . '/../Table/PaysInpi.php';
if (file_exists($cache)) {
return include $cache;
} else {
$rep = $this->iDb->select('jo.tabPays', 'codePaysInpi, codPays', 'codePaysInpi>0', false, MYSQL_ASSOC);
$tabPays = array();
foreach ($rep as $k => $dev) {
$tabPays[$dev['codePaysInpi']*1] = $dev['codPays'];
$sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tabPays[$item->codePaysInpi*1] = $item->codPays;
}
}
return $tabPays;
}
}
@ -192,39 +200,43 @@ class Metier_Partenaires_MRncs
* Tableau des mandataires suceptibles d'être tranmis par l'INPI
* @return array
*/
private function getTabMandataires()
protected function getTabMandataires()
{
$tabTmp = $this->iDb->select('jo.tabMandataires',
"UPPER(CONCAT(SUBSTRING(Nom,1,4),'-',SUBSTRING(Prenom,1,3))) AS NomPre, SUBSTRING(cp,1,2) AS dep, COUNT(*) AS Nb, sirenMand, id, sirenGrp, Nom, Prenom, type, coursAppel, tribunal, Statut, adresse, adresseComp, cp, ville, tel, fax, email, web, contact",
"TYPE IN ('A', 'M') GROUP BY NomPre, dep, sirenMand ORDER BY NomPre ASC", true, MYSQL_ASSOC);
$tabMandSD = array();
foreach ($tabTmp as $mand) {
$tabMandSD[] = array(
'id' => $mand['id'],
'siren' => $mand['sirenMand'],
'nom' => $mand['Nom'],
'prenom'=> $mand['Prenom'],
'type' => $mand['type'],
'adr1' => $mand['adresse'],
'adr2' => $mand['adresseComp'],
'cp' => $mand['cp'],
'ville' => $mand['ville'],
'tel' => $mand['tel'],
'fax' => $mand['fax'],
'email' => $mand['email'],
);
$sql = "SELECT UPPER(CONCAT(SUBSTRING(Nom,1,4),'-',SUBSTRING(Prenom,1,3))) AS NomPre,
SUBSTRING(cp,1,2) AS dep, COUNT(*) AS Nb, sirenMand, id, sirenGrp, Nom, Prenom,
type, coursAppel, tribunal, Statut, adresse, adresseComp, cp, ville, tel, fax, email, web, contact
FROM jo.tabMandataires WHERE TYPE IN ('A', 'M') GROUP BY NomPre, dep, sirenMand ORDER BY NomPre ASC";
$stmt = $this->conn->executeQuery($sql);
if ($stmt->rowCount() > 0) {
while ($mand = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabMandSD[] = array(
'id' => $mand['id'],
'siren' => $mand['sirenMand'],
'nom' => $mand['Nom'],
'prenom' => $mand['Prenom'],
'type' => $mand['type'],
'adr1' => $mand['adresse'],
'adr2' => $mand['adresseComp'],
'cp' => $mand['cp'],
'ville' => $mand['ville'],
'tel' => $mand['tel'],
'fax' => $mand['fax'],
'email' => $mand['email'],
);
}
}
return $tabMandSD;
}
/**
* Donne l'id du mandataire en fonction de son libellé INPI
* @param unknown $strNomPrenom
* @param string $strNomPrenom
* @param string $adresse
* @param string $cp
* @param string $ville
* @param string $debug
* @return boolean|Ambigous <multitype:>
* @return boolean|integer
*/
public function getIdMandataireInpi($strNomPrenom, $adresse='', $cp='', $ville='', $debug=false)
{
@ -235,28 +247,30 @@ class Metier_Partenaires_MRncs
return false;
}
$tabTmp = $this->iDb->select(
'jo.tabMandataires',
"id, Nom, Prenom, adresse, adresseComp, cp, ville, MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE) AS score",
"TYPE IN ('A', 'M') AND (Nom<>'' OR Prenom <>'') AND MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE) ORDER BY score DESC LIMIT 0,10", false, MYSQL_ASSOC);
$nbRet = count($tabTmp);
if ($nbRet == 0) {
return false;
} elseif ($nbRet == 1) {
$this->matching = $tabTmp[0]['score'];
return $tabTmp[0]['id'];
} else {
foreach ($tabTmp as $i=>$iRet) {
$sql = "SELECT id, Nom, Prenom, adresse, adresseComp, cp, ville,
MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE) AS score
FROM jo.tabMandataires
WHERE TYPE IN ('A', 'M') AND (Nom!='' OR Prenom!='')
AND MATCH (Nom, Prenom, adresse, adresseComp, ville) AGAINST ('$strNomPrenom $adresse $ville' IN NATURAL LANGUAGE MODE)
ORDER BY score DESC LIMIT 0,10";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$this->matching = $result['score'];
return $result['id'];
} elseif ($stmt->rowCount() > 1) {
while ($iRet = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($debug) {
echo "je compare '$cp' avec '".$iRet['cp']."' et '$ville' avec '".$iRet["ville"]."' (score=".$iRet['score'].")".PHP_EOL;
echo "je compare '$cp' avec '".$iRet['cp']."' et '$ville' avec '".$iRet["ville"]."' (score=".$iRet['score'].")\n";
}
if ((($iRet['cp'] == $cp || substr($iRet['cp'], 0, 2) == $cp2)
&& ($iRet["ville"] == $ville || preg_replace('/ 0/', ' ', $iRet["ville"]) == $ville)
|| (strpos($iRet["ville"], $ville) > 0 && $nbRet == 1) || $iRet["score"] > 17)
|| ($cp == '' && $ville == '' && $iRet["score"] >6.88)) {
$this->matching = $iRet['score'];
return $iRet['id'];
}
|| ($cp == '' && $ville == '' && $iRet["score"] > 6.88)) {
$this->matching = $iRet['score'];
return $iRet['id'];
}
}
}
@ -281,18 +295,24 @@ class Metier_Partenaires_MRncs
* Initialisation du tableau privé des codes tribunaux Greffes/Inpi avec le libellé Bodacc
* @return array
*/
private function getTabTribunaux()
protected function getTabTribunaux()
{
$cache = dirname(__FILE__) . '/../Table/RncsTribunaux.php';
if (file_exists($cache)) {
return include $cache;
} else {
$rep=$this->iDb->select('jo.tribunaux', 'triNumGreffe, triNom, triId, triCode', 'triNumGreffe IS NOT NULL', false, MYSQL_ASSOC);
$tabTribunaux=array();
foreach ($rep as $k=>$dev) {
$tabTribunaux[$dev['triNumGreffe']*1]['Id']=$dev['triId'];
$tabTribunaux[$dev['triNumGreffe']*1]['Nom']=$dev['triNom'];
$tabTribunaux[$dev['triNumGreffe']*1]['Code']=$dev['triCode'];
$tabTribunaux = array();
$sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabTribunaux[$item->triNumGreffe*1] = array(
'Id' => $item->triId,
'Nom' => $item->triNom,
'Code' => $item->triCode,
);
}
}
return $tabTribunaux;
}
@ -532,7 +552,7 @@ class Metier_Partenaires_MRncs
$stmt->execute();
$tabDepots = array();
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array(
'codDepot' => $result['codeEven'],
'libDepot' => $result['libEven'],