Library update
This commit is contained in:
parent
08742cddfb
commit
55a21524b0
@ -493,6 +493,12 @@ class Metier_Bodacc_MBodacc
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Bodacc
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
@ -505,6 +511,10 @@ class Metier_Bodacc_MBodacc
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
|
||||
/* Charge toute la table des tribunaux pour ne pas lancer systématiquement des
|
||||
* requètes sur le serveur MySQL lors des intégrations de Bodacc
|
||||
*/
|
||||
@ -545,11 +555,18 @@ class Metier_Bodacc_MBodacc
|
||||
return include $cache;
|
||||
} else {
|
||||
$tribunaux = array();
|
||||
|
||||
$sql = "SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($t = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$dep = intval(substr($t->triCP, 0, 2));
|
||||
if ($dep == 97 || $dep == 98) {
|
||||
@ -578,11 +595,18 @@ class Metier_Bodacc_MBodacc
|
||||
return include $cache;
|
||||
} else {
|
||||
$result = array();
|
||||
|
||||
$sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$result[intval($row->codeFct)] = $row->libelle;
|
||||
}
|
||||
@ -619,10 +643,18 @@ class Metier_Bodacc_MBodacc
|
||||
FROM jo.tribunaux t, jo.tribunauxInsee i
|
||||
WHERE i.CodeInsee= :inseeCode AND i.triId=t.triId
|
||||
ORDER BY t.triNumGreffe DESC, t.triId ASC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('inseeCode', $codeInseeCommune);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('inseeCode', $codeInseeCommune);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
@ -643,16 +675,24 @@ class Metier_Bodacc_MBodacc
|
||||
t.triSiret, t.triAdrNum, t.triAdrIndRep, t.triAdrTypeVoie, t.triAdrVoie, t.triAdrComp,
|
||||
t.triVille, t.triStatut, t.triDateCessation, t.triCommentaire, t.triNumGreffe
|
||||
FROM jo.tribunaux t WHERE t.triCP BETWEEN :dep1 AND :dep2 ORDER BY t.triType ASC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
if ($dep < 96) {
|
||||
$stmt->bindValue('dep1', $dep.'000');
|
||||
$stmt->bindValue('dep2', $dep.'999');
|
||||
} else {
|
||||
$stmt->bindValue('dep1', $dep.'00');
|
||||
$stmt->bindValue('dep2', $dep.'99');
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
if ($dep < 96) {
|
||||
$stmt->bindValue('dep1', $dep.'000');
|
||||
$stmt->bindValue('dep2', $dep.'999');
|
||||
} else {
|
||||
$stmt->bindValue('dep1', $dep.'00');
|
||||
$stmt->bindValue('dep2', $dep.'99');
|
||||
}
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
if ($stmtNb > 0) {
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
@ -666,10 +706,18 @@ class Metier_Bodacc_MBodacc
|
||||
public function getTribunalIdCA($codeTribunal)
|
||||
{
|
||||
$sql = "SELECT triIdSup FROM jo.tribunaux WHERE triCode = :code";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $codeTribunal);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $codeTribunal);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
return $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
@ -695,11 +743,18 @@ class Metier_Bodacc_MBodacc
|
||||
return include $cache;
|
||||
} else {
|
||||
$result = array();
|
||||
|
||||
$sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$result[$row->codEven] = array(
|
||||
'libEven' => $row->libEven,
|
||||
@ -726,11 +781,17 @@ class Metier_Bodacc_MBodacc
|
||||
return include $cache;
|
||||
} else {
|
||||
$result = array();
|
||||
|
||||
$sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$result[$row->libDeviseBodacc] = $row->devIso;
|
||||
}
|
||||
@ -1170,7 +1231,7 @@ class Metier_Bodacc_MBodacc
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
continue;
|
||||
}
|
||||
if ($stmt->rowCount()) {
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$tabPrenom = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
// C'est plutôt le nom de famille au début de la chaîne
|
||||
if ($i == 0) {
|
||||
@ -1209,12 +1270,20 @@ class Metier_Bodacc_MBodacc
|
||||
|
||||
$sql = "SELECT Bodacc_Code, Bodacc_Annee_Parution, Bodacc_Num, Num_Annonce, Tribunal_Dept, Tribunal_Code, Rubrique_Bodacc, length(annonce) as Long
|
||||
FROM jo.bodacc WHERE Bodacc_Code=:code AND Bodacc_Annee_Parution=:annee AND Bodacc_Num=:num";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $bodaccCode);
|
||||
$stmt->bindValue('annee', $annee);
|
||||
$stmt->bindValue('num', $num);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $bodaccCode);
|
||||
$stmt->bindValue('annee', $annee);
|
||||
$stmt->bindValue('num', $num);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$result[] = array(
|
||||
'BodaccCode' => $ann->Bodacc_Code,
|
||||
@ -1301,10 +1370,18 @@ class Metier_Bodacc_MBodacc
|
||||
|
||||
$sql = "SELECT id, dep, nomJal, siteWeb, email, adresse, cp, ville, tel, fax, parution, aboAnnuel, infos
|
||||
FROM jo.tabJAL WHERE dep = :dep";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('dep', $dep);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('dep', $dep);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
@ -1316,10 +1393,18 @@ class Metier_Bodacc_MBodacc
|
||||
$result = array();
|
||||
|
||||
$sql = "SELECT id, nomJal FROM jo.tabJAL WHERE sedDateAbo!=0 GROUP BY nomJal ORDER BY nomJal ASC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('dep', $dep);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('dep', $dep);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
|
||||
$result['_'.$row->id] = $row->nomJal;
|
||||
}
|
||||
@ -1338,37 +1423,69 @@ class Metier_Bodacc_MBodacc
|
||||
{
|
||||
$strEvenVtLg = " AND Rubrique!='ventes' AND typeEven NOT LIKE '%2700%' AND typeEven NOT LIKE '%2701%' AND typeEven NOT LIKE '%2702%' AND typeEven NOT LIKE '%2703%' AND typeEven NOT LIKE '%2710%' AND typeEven NOT LIKE '%2720%' AND typeEven NOT LIKE '%2721%' AND typeEven NOT LIKE '%2725%' AND typeEven NOT LIKE '%2730%' AND typeEven NOT LIKE '%2740%' AND typeEven NOT LIKE '%2750%' AND typeEven NOT LIKE '%2800%' AND typeEven NOT LIKE '%2840%' AND typeEven NOT LIKE '%2850%' AND typeEven NOT LIKE '%2851%' AND typeEven NOT LIKE '%2860%' AND typeEven NOT LIKE '%2870%' AND typeEven NOT LIKE '%2875%' AND typeEven NOT LIKE '%2880%' AND typeEven NOT LIKE '%2881%' AND typeEven NOT LIKE '%2885%' AND typeEven NOT LIKE '%2890%' AND typeEven NOT LIKE '%2891%' AND typeEven NOT LIKE '%2892%' ";
|
||||
$sql = "SELECT Activite FROM jo.bodacc_detail WHERE siren=:siren AND Activite<>'' AND Activite NOT LIKE 'non precis%' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
if ($fj < 7000 || $fj > 7999) {
|
||||
$activite = trim($annCap['Activite']);
|
||||
}
|
||||
|
||||
if ($activite == '' && ($fj > 90 && $fj < 94 || $fj > 9000 && $fj < 9400)) {
|
||||
$sql = "SELECT Assoc_Objet, Assoc_NObjet FROM jo.asso WHERE siren=:siren AND (Assoc_Objet!='' OR Assoc_NObjet!='') ORDER BY Date_Parution DESC LIMIT 0,1";
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$activite = trim($annCap['Assoc_NObjet']);
|
||||
if ($activite == '') {
|
||||
$activite = trim($annCap['Assoc_Objet']);
|
||||
if ($fj < 7000 || $fj > 7999) {
|
||||
$activite = trim($annCap['Activite']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($activite == '' && ($fj > 90 && $fj < 94 || $fj > 9000 && $fj < 9400)) {
|
||||
$sql = "SELECT Assoc_Objet, Assoc_NObjet FROM jo.asso
|
||||
WHERE siren=:siren AND (Assoc_Objet!='' OR Assoc_NObjet!='')
|
||||
ORDER BY Date_Parution DESC LIMIT 0,1";
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
$annCap = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$activite = trim($annCap['Assoc_NObjet']);
|
||||
if ($activite == '') {
|
||||
$activite = trim($annCap['Assoc_Objet']);
|
||||
}
|
||||
}
|
||||
} elseif ($activite == '' && ($fj < 7000 || $fj > 7999)) {
|
||||
$sql = "SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt
|
||||
FROM historiques.entrep e, historiques.texte x
|
||||
WHERE e.E1GSIR=:siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 AND x.annonceTxt LIKE '%ctivit%'
|
||||
GROUP BY e.ANBASE ORDER BY e.DATE DESC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if (($ann['CODEVE'] < 20) || ($ann['CODEVE'] >= 30 && $ann['CODEVE'] < 42) || ($ann['CODEVE'] >= 51 && $ann['CODEVE'] < 80)) {
|
||||
if (($ann['CODEVE'] < 20) || ($ann['CODEVE'] >= 30 && $ann['CODEVE'] < 42)
|
||||
|| ($ann['CODEVE'] >= 51 && $ann['CODEVE'] < 80)) {
|
||||
if (preg_match('/(.*)Activit(?:e|é)(?:.|)\:(.*)(?:Adresse(?:.*|)|Commentaires?|Administration|Etablissement principal|Date d\'effet|Date.de.d.but d.activit.|Capital|Nom commercial)(?:.|)\:/Uisu', $ann['annonceTxt'], $matches)) {
|
||||
if (strpos(substr($matches[1], -20), 'cess') === false && strpos(substr($matches[1], -20), 'date') === false) {
|
||||
if (strpos(substr($matches[1], -20), 'cess') === false
|
||||
&& strpos(substr($matches[1], -20), 'date') === false) {
|
||||
$activite = $matches[2];
|
||||
break;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,10 +12,20 @@ class Metier_Partenaires_MAmabis
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = Zend_Registry::get('doctrine');
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
|
||||
$this->client = new SoapClient(null, array(
|
||||
'location' => 'http://sw2.amabis.com:5100/',
|
||||
'uri' => 'http://www.amabis.com/ns.xsd',
|
||||
@ -51,16 +61,23 @@ class Metier_Partenaires_MAmabis
|
||||
$adresse = addslashes(trim(preg_replace('/ +/', ' ', "$adrNum $adrIndRep $adrTypeVoie $adrLibVoie")));
|
||||
$ville = addslashes($ville);
|
||||
$majForcee = false;
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$sql = "SELECT zus, zru, zfu, cucs, rnvpStatut, rnvpCorr, rnvpTrt, adr3, adr4, adr5, adr6,
|
||||
adr7, numVoieA, indRepA, typeVoieAlong, typeVoieAcourt, corpVoie, motDir, motDirD,
|
||||
libVoieSec, adr4n32, adr4n38, clePostaleVoie, secteur, cleRoutage, cpx, cleAd,
|
||||
codPaysIso2, codPaysIso3, libPays, codeInsee
|
||||
FROM jo.zonage WHERE address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT zus, zru, zfu, cucs, rnvpStatut, rnvpCorr, rnvpTrt, adr3, adr4, adr5, adr6,
|
||||
adr7, numVoieA, indRepA, typeVoieAlong, typeVoieAcourt, corpVoie, motDir, motDirD,
|
||||
libVoieSec, adr4n32, adr4n38, clePostaleVoie, secteur, cleRoutage, cpx, cleAd,
|
||||
codPaysIso2, codPaysIso3, libPays, codeInsee
|
||||
FROM jo.zonage WHERE address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
if ($stmtNb > 0) {
|
||||
$zones = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
if ($zones['rnvpStatut'] === null && $rnvp) {
|
||||
$majForcee = true;
|
||||
@ -113,7 +130,7 @@ class Metier_Partenaires_MAmabis
|
||||
}
|
||||
}
|
||||
|
||||
if ($stmt->rowCount() == 0 || $majForcee) {
|
||||
if ($stmtNb == 0 || $majForcee) {
|
||||
try {
|
||||
// Le RNVP ne fonctionne pas sans la Raison Sociale qui est la 1ère ligne d'adresse
|
||||
if (trim($raisonSociale) == '') {
|
||||
@ -128,7 +145,6 @@ class Metier_Partenaires_MAmabis
|
||||
new SoapParam('type=M', 'options')
|
||||
);
|
||||
|
||||
|
||||
/** Découpage des ZFU, CUCS etcs... **/
|
||||
$fp = fopen(LOG_PATH.'/amabis.log', 'a');
|
||||
fwrite($fp, date('d-m-Y H:i:s').' - '.implode("\n", $rep)."\n============================================================================\n");
|
||||
@ -225,25 +241,45 @@ class Metier_Partenaires_MAmabis
|
||||
$villeL = addslashes($ville);
|
||||
$sql = "SELECT dateInsert*1 as dateInsert FROM jo.zonage
|
||||
WHERE address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$majNb = 0;
|
||||
try {
|
||||
$majStmt = $this->conn->prepare($sql);
|
||||
$majStmt->execute();
|
||||
$majNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($majNb > 0) {
|
||||
$result = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
$dateInsert = $result->dateInsert;
|
||||
if ($dateInsert != 0) {
|
||||
$this->conn->update('jo.zonage', array_merge($tabUpdate,
|
||||
array('dateInsert' => $dateInsert)),
|
||||
array(
|
||||
'address' => $adresseL,
|
||||
'adr_cp' => $cp,
|
||||
'adr_ville' => $villeL,
|
||||
));
|
||||
try {
|
||||
$this->conn->update('jo.zonage', array_merge($tabUpdate,
|
||||
array('dateInsert' => $dateInsert)),
|
||||
array(
|
||||
'address' => $adresseL,
|
||||
'adr_cp' => $cp,
|
||||
'adr_ville' => $villeL,
|
||||
));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($dateInsert == 0) {
|
||||
$this->conn->insert('jo.zonage', array_merge($tabInsert, $tabUpdate));
|
||||
try {
|
||||
$this->conn->insert('jo.zonage', array_merge($tabInsert, $tabUpdate));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tabTmp[0] = explode(',', $tabZones['LOCREFCLEP']);
|
||||
@ -264,7 +300,13 @@ class Metier_Partenaires_MAmabis
|
||||
'source' => 'Amabis',
|
||||
'dateInsert' => date('YmdHis'),
|
||||
);
|
||||
$this->conn->insert('jo.villesCP', $tabInsert);
|
||||
try {
|
||||
$this->conn->insert('jo.villesCP', $tabInsert);
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Autres Informations de la RNVP **/
|
||||
@ -286,11 +328,19 @@ class Metier_Partenaires_MAmabis
|
||||
$codeInsee = substr($codeRivoli, 0, 5);
|
||||
$sql = "SELECT typeZone, arreteDate, decretDate, decretNum, decretModifieDate, decretModifieNum, dateDebut, dateFin
|
||||
FROM jo.zonageInsee WHERE codeInsee=:code";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $codeInsee);
|
||||
$stmt->execute();
|
||||
$zonageNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('code', $codeInsee);
|
||||
$stmt->execute();
|
||||
$zonageNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$tabRep['ZRR'] = $tabRep['AFR'] = 'NON';
|
||||
if ($stmt->rowCount() > 0) {
|
||||
if ($zonageNb > 0) {
|
||||
while ($zones = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
switch ($zones['typeZone']) {
|
||||
case 'ZRR':
|
||||
|
@ -16,6 +16,12 @@ D. 067 200 329 I 2010-06-30 La CS est valide jusq'au 30/06/2010... Quid
|
||||
*/
|
||||
class Metier_Partenaires_MFacto
|
||||
{
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
public $risqueImpaye = false; // Y a t'il un risque d'impayé ?
|
||||
public $risqueImpayeMois = 0;
|
||||
public $profilPayeur = 0; // 0:N/D, 1:Excellent, 2=Bon, 3=Normal, 4=Lent, 5=Mauvais ou Défaut
|
||||
@ -93,6 +99,10 @@ class Metier_Partenaires_MFacto
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = Zend_Registry::get('doctrine');
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
}
|
||||
|
||||
public function setTypeFic($typeFic)
|
||||
@ -150,11 +160,19 @@ class Metier_Partenaires_MFacto
|
||||
WHERE siren=:siren AND (dateSuppr=0 OR dateConf>dateSuppr)
|
||||
AND (dateFin=0 OR dateFin>NOW()) AND cs NOT IN (20,22,27,33,34)
|
||||
ORDER BY dateConf DESC, dateInsert DESC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$tabRet = array();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
if ($stmtNb > 0) {
|
||||
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$dateEven = $tabCS['dateConf'];
|
||||
if ($dateEven == '0000-00-00') {
|
||||
@ -179,15 +197,23 @@ class Metier_Partenaires_MFacto
|
||||
|
||||
public function getCoteSpecialeOld($siren)
|
||||
{
|
||||
$sql = "SELECT DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE
|
||||
$sql = "SELECT DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE
|
||||
FROM sdv1.ge_cs c LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=c.NUMGFH
|
||||
WHERE a.SIRENE=:siren ORDER BY a.SIRENE ASC, c.DATMAJ1 DESC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$tabRet = array();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
if ($stmtNb > 0) {
|
||||
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$tabRet[] = array(
|
||||
'DateEven' => $tabCS['DATMAJ1'],
|
||||
@ -228,10 +254,18 @@ class Metier_Partenaires_MFacto
|
||||
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE
|
||||
FROM sdv1.ge_paiements p LEFT JOIN sdv1.ge_acheteurs a ON a.NUMACH=p.NUMACH
|
||||
WHERE a.SIRENE=:siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($tabPai = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$nbJoursMoyen = $tabPai['nbJourRetard'] - $tabPai['nbJourPaiement'];
|
||||
if ($nbJoursMoyen < 6) {
|
||||
@ -387,10 +421,18 @@ class Metier_Partenaires_MFacto
|
||||
WHERE idClient='SURBODPRDFTSRECOCASH' AND siren=:siren AND dateSuppr=0
|
||||
AND ABS(DATEDIFF(dateAjout, NOW()))<365
|
||||
ORDER BY dateConf DESC, dateAjout DESC";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
while ($tabCS = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$dateMAJ = Metier_Util_Date::dateT('Y-m-d', 'M Y', $tabCS['dateAjout']);
|
||||
$libProfil = "En date du $dateMAJ : Contentieux importants.";
|
||||
|
@ -4,6 +4,12 @@ require_once __DIR__ . '/MMapFunctions.php';
|
||||
|
||||
class Metier_Partenaires_MMap
|
||||
{
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
|
@ -27,6 +27,12 @@ class Metier_Partenaires_MTva
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Remote Flag
|
||||
* @var boolean
|
||||
@ -40,6 +46,10 @@ class Metier_Partenaires_MTva
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = Zend_Registry::get('doctrine');
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,10 +84,18 @@ class Metier_Partenaires_MTva
|
||||
|
||||
$sql = "SELECT LPAD(cle,2,0) AS cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ
|
||||
FROM sdv1.siren_tva WHERE siren=:siren";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $this->siren);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$stmtNb = 0;
|
||||
try {
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $this->siren);
|
||||
$stmt->execute();
|
||||
$stmtNb = $stmt->rowCount();
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($stmtNb > 0) {
|
||||
$exist = true;
|
||||
$result = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
$cle = $result->cle;
|
||||
@ -104,7 +122,7 @@ class Metier_Partenaires_MTva
|
||||
return true;
|
||||
}
|
||||
|
||||
Metier_Util_Log::write('W', "Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s. Cas impossible !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->logger->error("Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Cas impossible !");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -160,11 +178,23 @@ class Metier_Partenaires_MTva
|
||||
if (preg_match('/Yes, valid VAT number/i', $body)
|
||||
|| preg_match('/Oui, numéro de TVA valide/i', $body)) {
|
||||
if ($exist) {
|
||||
$this->conn->update('sdv1.siren_tva', array('cle' => intval($this->cle),
|
||||
try {
|
||||
$this->conn->update('sdv1.siren_tva', array('cle' => intval($this->cle),
|
||||
'duree' => $time), array('siren' => $this->siren));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
|
||||
'cle' => intval($this->cle), 'duree' => $time));
|
||||
try {
|
||||
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
|
||||
'cle' => intval($this->cle), 'duree' => $time));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
$this->vatDefined = true;
|
||||
@ -172,16 +202,28 @@ class Metier_Partenaires_MTva
|
||||
}
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
Metier_Util_Log::write('I', "TVA ".$e->getMessage(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
|
||||
// Non disponible
|
||||
if ($exist) {
|
||||
$this->conn->update('sdv1.siren_tva', array('cle' => 'NULL', 'duree' => $time),
|
||||
array('siren' => $this->siren));
|
||||
try {
|
||||
$this->conn->update('sdv1.siren_tva', array('cle' => 'NULL', 'duree' => $time),
|
||||
array('siren' => $this->siren));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
|
||||
'cle' => 'NULL', 'duree' => $time));
|
||||
try {
|
||||
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
|
||||
'cle' => 'NULL', 'duree' => $time));
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
|
@ -6,6 +6,12 @@ class Metier_Util_Db
|
||||
*/
|
||||
protected $db = null;
|
||||
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var unknown
|
||||
@ -21,6 +27,10 @@ class Metier_Util_Db
|
||||
if ($db === null) {
|
||||
$this->db = Zend_Db_Table::getDefaultAdapter();
|
||||
}
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,11 +275,14 @@ class Metier_Util_Db
|
||||
$duree = 'N/D';
|
||||
}
|
||||
if ($this->errorCode == 0) {
|
||||
$msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
|
||||
if ($this->logger != null) {
|
||||
$this->logger->debug($this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree);
|
||||
}
|
||||
} else {
|
||||
$msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
|
||||
if ($this->logger != null) {
|
||||
$this->logger->error($this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree);
|
||||
}
|
||||
}
|
||||
file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,6 +240,12 @@ class Scores_Ws_Server
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* Logger
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Server SOAP
|
||||
* Document/Literal Wrapped - WS-I Compliant
|
||||
@ -247,6 +253,11 @@ class Scores_Ws_Server
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = Zend_Registry::get('doctrine');
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
}
|
||||
|
||||
$this->listeDroits = include APPLICATION_PATH . '/../library/Scores/Account/Access.php';
|
||||
$this->listeCategory = include APPLICATION_PATH . '/../library/Scores/Account/Category.php';
|
||||
}
|
||||
@ -568,9 +579,9 @@ class Scores_Ws_Server
|
||||
try {
|
||||
$result = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
$c = Zend_Registry::get('config');
|
||||
file_put_contents($c->profil->path->shared.'/log/application.log',
|
||||
date('Y-m-d H:i:s').'- AUTH : '.$e->getMessage()."\n", FILE_APPEND);
|
||||
if ($this->logger != null) {
|
||||
$this->logger->error("AUTH : ".$e->getMessage());
|
||||
}
|
||||
return '0000';
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
|
||||
function sphPackI64 ( $v )
|
||||
{
|
||||
assert ( is_numeric($v) );
|
||||
|
||||
|
||||
// x64
|
||||
if ( PHP_INT_SIZE>=8 )
|
||||
{
|
||||
@ -153,7 +153,7 @@ function sphPackI64 ( $v )
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", $v < 0 ? -1 : 0, $v );
|
||||
|
||||
// x32, bcmath
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
if ( bccomp ( $v, 0 ) == -1 )
|
||||
@ -190,16 +190,16 @@ function sphPackI64 ( $v )
|
||||
function sphPackU64 ( $v )
|
||||
{
|
||||
assert ( is_numeric($v) );
|
||||
|
||||
|
||||
// x64
|
||||
if ( PHP_INT_SIZE>=8 )
|
||||
{
|
||||
assert ( $v>=0 );
|
||||
|
||||
|
||||
// x64, int
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
|
||||
|
||||
|
||||
// x64, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
@ -207,12 +207,12 @@ function sphPackU64 ( $v )
|
||||
$l = bcmod ( $v, 4294967296 );
|
||||
return pack ( "NN", $h, $l );
|
||||
}
|
||||
|
||||
|
||||
// x64, no-bcmath
|
||||
$p = max ( 0, strlen($v) - 13 );
|
||||
$lo = (int)substr ( $v, $p );
|
||||
$hi = (int)substr ( $v, 0, $p );
|
||||
|
||||
|
||||
$m = $lo + $hi*1316134912;
|
||||
$l = $m % 4294967296;
|
||||
$h = $hi*2328 + (int)($m/4294967296);
|
||||
@ -223,7 +223,7 @@ function sphPackU64 ( $v )
|
||||
// x32, int
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", 0, $v );
|
||||
|
||||
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
@ -236,7 +236,7 @@ function sphPackU64 ( $v )
|
||||
$p = max(0, strlen($v) - 13);
|
||||
$lo = (float)substr($v, $p);
|
||||
$hi = (float)substr($v, 0, $p);
|
||||
|
||||
|
||||
$m = $lo + $hi*1316134912.0;
|
||||
$q = floor($m / 4294967296.0);
|
||||
$l = $m - ($q * 4294967296.0);
|
||||
@ -292,11 +292,11 @@ function sphUnpackU64 ( $v )
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
|
||||
|
||||
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
$lo = (float)$lo;
|
||||
|
||||
|
||||
$q = floor($hi/10000000.0);
|
||||
$r = $hi - $q*10000000.0;
|
||||
$m = $lo + $r*4967296.0;
|
||||
@ -339,7 +339,7 @@ function sphUnpackI64 ( $v )
|
||||
return $lo;
|
||||
return sprintf ( "%.0f", $lo - 4294967296.0 );
|
||||
}
|
||||
|
||||
|
||||
$neg = "";
|
||||
$c = 0;
|
||||
if ( $hi<0 )
|
||||
@ -348,7 +348,7 @@ function sphUnpackI64 ( $v )
|
||||
$lo = ~$lo;
|
||||
$c = 1;
|
||||
$neg = "-";
|
||||
}
|
||||
}
|
||||
|
||||
$hi = sprintf ( "%u", $hi );
|
||||
$lo = sprintf ( "%u", $lo );
|
||||
@ -360,7 +360,7 @@ function sphUnpackI64 ( $v )
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
$lo = (float)$lo;
|
||||
|
||||
|
||||
$q = floor($hi/10000000.0);
|
||||
$r = $hi - $q*10000000.0;
|
||||
$m = $lo + $r*4967296.0;
|
||||
@ -550,7 +550,7 @@ class SphinxClient
|
||||
$this->_path = $host;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->_host = $host;
|
||||
$port = intval($port);
|
||||
assert ( 0<=$port && $port<65536 );
|
||||
@ -630,14 +630,14 @@ class SphinxClient
|
||||
$fp = @fsockopen ( $host, $port, $errno, $errstr );
|
||||
else
|
||||
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
|
||||
|
||||
|
||||
if ( !$fp )
|
||||
{
|
||||
if ( $this->_path )
|
||||
$location = $this->_path;
|
||||
else
|
||||
$location = "{$this->_host}:{$this->_port}";
|
||||
|
||||
|
||||
$errstr = trim ( $errstr );
|
||||
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
|
||||
$this->_connerror = true;
|
||||
@ -768,7 +768,7 @@ class SphinxClient
|
||||
/// set matching mode
|
||||
function SetMatchMode ( $mode )
|
||||
{
|
||||
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
|
||||
//trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
|
||||
assert ( $mode==SPH_MATCH_ALL
|
||||
|| $mode==SPH_MATCH_ANY
|
||||
|| $mode==SPH_MATCH_PHRASE
|
||||
@ -863,7 +863,7 @@ class SphinxClient
|
||||
$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// set string filter
|
||||
/// only match records where $attribute value is equal
|
||||
function SetFilterString ( $attribute, $value, $exclude=false )
|
||||
@ -871,7 +871,7 @@ class SphinxClient
|
||||
assert ( is_string($attribute) );
|
||||
assert ( is_string($value) );
|
||||
$this->_filters[] = array ( "type"=>SPH_FILTER_STRING, "attr"=>$attribute, "exclude"=>$exclude, "value"=>$value );
|
||||
}
|
||||
}
|
||||
|
||||
/// set range filter
|
||||
/// only match records if $attribute value is beetwen $min and $max (inclusive)
|
||||
@ -970,7 +970,7 @@ class SphinxClient
|
||||
assert ( is_string ( $select ) );
|
||||
$this->_select = $select;
|
||||
}
|
||||
|
||||
|
||||
function SetQueryFlag ( $flag_name, $flag_value )
|
||||
{
|
||||
$known_names = array ( "reverse_scan", "sort_method", "max_predicted_time", "boolean_simplify", "idf", "global_idf" );
|
||||
@ -982,10 +982,10 @@ class SphinxClient
|
||||
"idf" => array ("normalized", "plain", "tfidf_normalized", "tfidf_unnormalized" ),
|
||||
"global_idf" => array ( true, false ),
|
||||
);
|
||||
|
||||
|
||||
assert ( isset ( $flag_name, $known_names ) );
|
||||
assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) );
|
||||
|
||||
|
||||
if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 );
|
||||
if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" );
|
||||
if ( $flag_name=="max_predicted_time" )
|
||||
@ -998,7 +998,7 @@ class SphinxClient
|
||||
if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value );
|
||||
if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" );
|
||||
}
|
||||
|
||||
|
||||
/// set outer order by parameters
|
||||
function SetOuterSelect ( $orderby, $offset, $limit )
|
||||
{
|
||||
@ -1014,7 +1014,7 @@ class SphinxClient
|
||||
$this->_hasouter = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// clear all filters (for multi-queries)
|
||||
@ -1038,7 +1038,7 @@ class SphinxClient
|
||||
{
|
||||
$this->_overrides = array ();
|
||||
}
|
||||
|
||||
|
||||
function ResetQueryFlag ()
|
||||
{
|
||||
$this->_query_flags = sphSetBit ( 0, 6, true ); // default idf=tfidf_normalized
|
||||
@ -1126,7 +1126,7 @@ class SphinxClient
|
||||
case SPH_FILTER_FLOATRANGE:
|
||||
$req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
|
||||
break;
|
||||
|
||||
|
||||
case SPH_FILTER_STRING:
|
||||
$req .= pack ( "N", strlen($filter["value"]) ) . $filter["value"];
|
||||
break;
|
||||
@ -1196,11 +1196,11 @@ class SphinxClient
|
||||
|
||||
// select-list
|
||||
$req .= pack ( "N", strlen($this->_select) ) . $this->_select;
|
||||
|
||||
|
||||
// max_predicted_time
|
||||
if ( $this->_predictedtime>0 )
|
||||
$req .= pack ( "N", (int)$this->_predictedtime );
|
||||
|
||||
|
||||
$req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby;
|
||||
$req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit );
|
||||
if ( $this->_hasouter )
|
||||
@ -1356,7 +1356,7 @@ class SphinxClient
|
||||
if ( $type==SPH_ATTR_FLOAT )
|
||||
{
|
||||
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
|
||||
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
|
||||
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
|
||||
$attrvals[$attr] = $fval;
|
||||
continue;
|
||||
}
|
||||
@ -1384,11 +1384,11 @@ class SphinxClient
|
||||
} else if ( $type==SPH_ATTR_STRING )
|
||||
{
|
||||
$attrvals[$attr] = substr ( $response, $p, $val );
|
||||
$p += $val;
|
||||
$p += $val;
|
||||
} else if ( $type==SPH_ATTR_FACTORS )
|
||||
{
|
||||
$attrvals[$attr] = substr ( $response, $p, $val-4 );
|
||||
$p += $val-4;
|
||||
$p += $val-4;
|
||||
} else
|
||||
{
|
||||
$attrvals[$attr] = sphFixUint($val);
|
||||
@ -1469,7 +1469,7 @@ class SphinxClient
|
||||
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
|
||||
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
|
||||
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
|
||||
|
||||
|
||||
|
||||
/////////////////
|
||||
// build request
|
||||
@ -1760,7 +1760,7 @@ class SphinxClient
|
||||
|
||||
fclose ( $this->_socket );
|
||||
$this->_socket = false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
|
||||
function sphPackI64 ( $v )
|
||||
{
|
||||
assert ( is_numeric($v) );
|
||||
|
||||
|
||||
// x64
|
||||
if ( PHP_INT_SIZE>=8 )
|
||||
{
|
||||
@ -145,7 +145,7 @@ function sphPackI64 ( $v )
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", $v < 0 ? -1 : 0, $v );
|
||||
|
||||
// x32, bcmath
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
if ( bccomp ( $v, 0 ) == -1 )
|
||||
@ -182,16 +182,16 @@ function sphPackI64 ( $v )
|
||||
function sphPackU64 ( $v )
|
||||
{
|
||||
assert ( is_numeric($v) );
|
||||
|
||||
|
||||
// x64
|
||||
if ( PHP_INT_SIZE>=8 )
|
||||
{
|
||||
assert ( $v>=0 );
|
||||
|
||||
|
||||
// x64, int
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
|
||||
|
||||
|
||||
// x64, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
@ -199,12 +199,12 @@ function sphPackU64 ( $v )
|
||||
$l = bcmod ( $v, 4294967296 );
|
||||
return pack ( "NN", $h, $l );
|
||||
}
|
||||
|
||||
|
||||
// x64, no-bcmath
|
||||
$p = max ( 0, strlen($v) - 13 );
|
||||
$lo = (int)substr ( $v, $p );
|
||||
$hi = (int)substr ( $v, 0, $p );
|
||||
|
||||
|
||||
$m = $lo + $hi*1316134912;
|
||||
$l = $m % 4294967296;
|
||||
$h = $hi*2328 + (int)($m/4294967296);
|
||||
@ -215,7 +215,7 @@ function sphPackU64 ( $v )
|
||||
// x32, int
|
||||
if ( is_int($v) )
|
||||
return pack ( "NN", 0, $v );
|
||||
|
||||
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
{
|
||||
@ -228,7 +228,7 @@ function sphPackU64 ( $v )
|
||||
$p = max(0, strlen($v) - 13);
|
||||
$lo = (float)substr($v, $p);
|
||||
$hi = (float)substr($v, 0, $p);
|
||||
|
||||
|
||||
$m = $lo + $hi*1316134912.0;
|
||||
$q = floor($m / 4294967296.0);
|
||||
$l = $m - ($q * 4294967296.0);
|
||||
@ -284,11 +284,11 @@ function sphUnpackU64 ( $v )
|
||||
// x32, bcmath
|
||||
if ( function_exists("bcmul") )
|
||||
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
|
||||
|
||||
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
$lo = (float)$lo;
|
||||
|
||||
|
||||
$q = floor($hi/10000000.0);
|
||||
$r = $hi - $q*10000000.0;
|
||||
$m = $lo + $r*4967296.0;
|
||||
@ -331,7 +331,7 @@ function sphUnpackI64 ( $v )
|
||||
return $lo;
|
||||
return sprintf ( "%.0f", $lo - 4294967296.0 );
|
||||
}
|
||||
|
||||
|
||||
$neg = "";
|
||||
$c = 0;
|
||||
if ( $hi<0 )
|
||||
@ -340,7 +340,7 @@ function sphUnpackI64 ( $v )
|
||||
$lo = ~$lo;
|
||||
$c = 1;
|
||||
$neg = "-";
|
||||
}
|
||||
}
|
||||
|
||||
$hi = sprintf ( "%u", $hi );
|
||||
$lo = sprintf ( "%u", $lo );
|
||||
@ -352,7 +352,7 @@ function sphUnpackI64 ( $v )
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
$lo = (float)$lo;
|
||||
|
||||
|
||||
$q = floor($hi/10000000.0);
|
||||
$r = $hi - $q*10000000.0;
|
||||
$m = $lo + $r*4967296.0;
|
||||
@ -542,7 +542,7 @@ class SphinxClient
|
||||
$this->_path = $host;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->_host = $host;
|
||||
$port = intval($port);
|
||||
assert ( 0<=$port && $port<65536 );
|
||||
@ -622,14 +622,14 @@ class SphinxClient
|
||||
$fp = @fsockopen ( $host, $port, $errno, $errstr );
|
||||
else
|
||||
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
|
||||
|
||||
|
||||
if ( !$fp )
|
||||
{
|
||||
if ( $this->_path )
|
||||
$location = $this->_path;
|
||||
else
|
||||
$location = "{$this->_host}:{$this->_port}";
|
||||
|
||||
|
||||
$errstr = trim ( $errstr );
|
||||
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
|
||||
$this->_connerror = true;
|
||||
@ -760,7 +760,7 @@ class SphinxClient
|
||||
/// set matching mode
|
||||
function SetMatchMode ( $mode )
|
||||
{
|
||||
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
|
||||
//trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
|
||||
assert ( $mode==SPH_MATCH_ALL
|
||||
|| $mode==SPH_MATCH_ANY
|
||||
|| $mode==SPH_MATCH_PHRASE
|
||||
@ -855,7 +855,7 @@ class SphinxClient
|
||||
$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// set string filter
|
||||
/// only match records where $attribute value is equal
|
||||
function SetFilterString ( $attribute, $value, $exclude=false )
|
||||
@ -863,7 +863,7 @@ class SphinxClient
|
||||
assert ( is_string($attribute) );
|
||||
assert ( is_string($value) );
|
||||
$this->_filters[] = array ( "type"=>SPH_FILTER_STRING, "attr"=>$attribute, "exclude"=>$exclude, "value"=>$value );
|
||||
}
|
||||
}
|
||||
|
||||
/// set range filter
|
||||
/// only match records if $attribute value is beetwen $min and $max (inclusive)
|
||||
@ -962,7 +962,7 @@ class SphinxClient
|
||||
assert ( is_string ( $select ) );
|
||||
$this->_select = $select;
|
||||
}
|
||||
|
||||
|
||||
function SetQueryFlag ( $flag_name, $flag_value )
|
||||
{
|
||||
$known_names = array ( "reverse_scan", "sort_method", "max_predicted_time", "boolean_simplify", "idf", "global_idf" );
|
||||
@ -974,10 +974,10 @@ class SphinxClient
|
||||
"idf" => array ("normalized", "plain", "tfidf_normalized", "tfidf_unnormalized" ),
|
||||
"global_idf" => array ( true, false ),
|
||||
);
|
||||
|
||||
|
||||
assert ( isset ( $flag_name, $known_names ) );
|
||||
assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) );
|
||||
|
||||
|
||||
if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 );
|
||||
if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" );
|
||||
if ( $flag_name=="max_predicted_time" )
|
||||
@ -990,7 +990,7 @@ class SphinxClient
|
||||
if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value );
|
||||
if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" );
|
||||
}
|
||||
|
||||
|
||||
/// set outer order by parameters
|
||||
function SetOuterSelect ( $orderby, $offset, $limit )
|
||||
{
|
||||
@ -1006,7 +1006,7 @@ class SphinxClient
|
||||
$this->_hasouter = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// clear all filters (for multi-queries)
|
||||
@ -1030,7 +1030,7 @@ class SphinxClient
|
||||
{
|
||||
$this->_overrides = array ();
|
||||
}
|
||||
|
||||
|
||||
function ResetQueryFlag ()
|
||||
{
|
||||
$this->_query_flags = sphSetBit ( 0, 6, true ); // default idf=tfidf_normalized
|
||||
@ -1118,7 +1118,7 @@ class SphinxClient
|
||||
case SPH_FILTER_FLOATRANGE:
|
||||
$req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
|
||||
break;
|
||||
|
||||
|
||||
case SPH_FILTER_STRING:
|
||||
$req .= pack ( "N", strlen($filter["value"]) ) . $filter["value"];
|
||||
break;
|
||||
@ -1188,11 +1188,11 @@ class SphinxClient
|
||||
|
||||
// select-list
|
||||
$req .= pack ( "N", strlen($this->_select) ) . $this->_select;
|
||||
|
||||
|
||||
// max_predicted_time
|
||||
if ( $this->_predictedtime>0 )
|
||||
$req .= pack ( "N", (int)$this->_predictedtime );
|
||||
|
||||
|
||||
$req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby;
|
||||
$req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit );
|
||||
if ( $this->_hasouter )
|
||||
@ -1348,7 +1348,7 @@ class SphinxClient
|
||||
if ( $type==SPH_ATTR_FLOAT )
|
||||
{
|
||||
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
|
||||
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
|
||||
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
|
||||
$attrvals[$attr] = $fval;
|
||||
continue;
|
||||
}
|
||||
@ -1376,11 +1376,11 @@ class SphinxClient
|
||||
} else if ( $type==SPH_ATTR_STRING )
|
||||
{
|
||||
$attrvals[$attr] = substr ( $response, $p, $val );
|
||||
$p += $val;
|
||||
$p += $val;
|
||||
} else if ( $type==SPH_ATTR_FACTORS )
|
||||
{
|
||||
$attrvals[$attr] = substr ( $response, $p, $val-4 );
|
||||
$p += $val-4;
|
||||
$p += $val-4;
|
||||
} else
|
||||
{
|
||||
$attrvals[$attr] = sphFixUint($val);
|
||||
@ -1461,7 +1461,7 @@ class SphinxClient
|
||||
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
|
||||
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
|
||||
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
|
||||
|
||||
|
||||
|
||||
/////////////////
|
||||
// build request
|
||||
@ -1752,7 +1752,7 @@ class SphinxClient
|
||||
|
||||
fclose ( $this->_socket );
|
||||
$this->_socket = false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user