add Scores repository

This commit is contained in:
benoitpotier 2017-03-28 17:25:23 +02:00
parent 5a7852aa25
commit 1fdefaf663
42 changed files with 7968 additions and 0 deletions

View File

@ -0,0 +1,85 @@
<?php
return array(
//RECHERCHE
'RECHCSV' => "Export des résultats de la recherche",
'IPARI' => "Investigation par l'image IparI&copy;",
'HISTOBODACC' => "Historique des annonces bodacc",
'INVESTIG' => "Investigation",
'SEARCHENT' => "Recherche Entreprise",
'SEARCHDIR' => "Recherche Dirigeant",
'SEARCHACT' => "Recherche Actionnaire",
//IDENTITE
'IDENTITE' => "Fiche d'identité",
'IDPROCOL' => 'Fiche procédure collective',
'LIENS' => "Liens inter-entreprise",
'ETABLISSEMENTS' => "Liste des établissements",
'GROUPE' => "Informations et organigramme du groupe",
'EVENINSEE' => '&Eacute;vènements INSEE',
'AVISINSEE' => 'Avis de situation INSEE',
'AVISRNCS' => 'Avis de situation RNCS',
'RNVP' => "Normalisation postale",
//DIRIGEANT
'DIRIGEANTS' => "Liste des dirigeants",
'DIRIGEANTSOP' => "Liste des dirigeants opérationnels",
//FINANCE
'SYNTHESE' => "Synthèse",
'RATIOS' => "Ratios",
'FLUX' => "Flux de trésorerie",
'LIASSE' => "Liasse fiscale",
'LIASSEXLS' => "Export des Liasses au format XLS",
'UPLOADBILAN' => "Saisie de bilan",
'BOURSE' => "Bourse & cotations",
'BANQUE' => "Relations bancaires",
//JURIDIQUE
'ANNONCES' => "Annonces légales",
'INFOSREG' => "Informations réglementée",
'COMPETENCES' => "Compétences territoriales",
'CONVENTIONS' => "Conventions collectives",
'MARQUES' => "Marques déposées",
'CONTENTIEUX' => "Contentieux Judiciaires",
//EVALUATION
'INDISCORE' => "indiScore&copy;",
'INDISCORE2' => "Rapport synthetique",
'INDISCORE3' => "Rapport complet",
'INDISCOREP' => "indiScore+",
'INDISCORE2P' => "Rapport synthetique+",
'INDISCORE3P' => "Rapport complet+",
'VALORISATION' => "Valorisation",
'SCORECSF' => "Score CSF",
'ENQUETEC' => "Enquête commerciale",
'AVISCREDIT' => "Avis de crédit personnalisé",
//PIECES
'KBIS' => "Extrait RCS",
'ACTES' => "Pièces officielles",
'PRIVILEGES' => "Privilèges",
//SURVEILLANCES
'SURVANNONCE' => "Surveillance des annonces légales",
'SURVINSEE' => "Surveillance des événements INSEE",
'SURVBILAN' => "Surveillance des bilans saisies (liasse fiscale)",
'SURVSCORE' => "Surveillance des événements sur le score",
'SURVACTES' => "Surveillance des pieces officielles (comptes annuels, actes)",
'SURVDIRIGEANTS'=> "Surveillance des dirigeants",
'SURVPAIEMENTS' => "Surveillance des paiements",
'SURVLIENS' => "Surveillance des liens financiers",
'SURVPRIV' => "Surveillance des privilèges",
//OPTIONS
'MONPROFIL' => "Mon profil",
'EDITION' => "Mode Edition",
'PORTEFEUILLE' => "Portefeuille",
'SURVLISTE' => "Liste des surveillances",
//DIVERS
'INTERNATIONAL' => "Recherche Internationale",
'BDF' => "Banque de France",
'WORLDCHECK' => "World-Check Risk Intelligence",
);

View File

@ -0,0 +1,112 @@
<?php
return array(
'RECHERCHE' => array(
'label' => "Recherche",
'droits' => array(
'RECHCSV',
'IPARI',
'HISTOBODACC',
'INVESTIG',
'SEARCHENT',
'SEARCHDIR',
'SEARCHACT'
),
),
'IDENTITE' => array(
'label' => "Identité",
'droits' => array(
'IDENTITE',
'IDPROCOL',
'LIENS',
'ETABLISSEMENTS',
'GROUPE',
'EVENINSEE',
'AVISINSEE',
'AVISRNCS',
'RNVP'
),
),
'DIRIGEANT' => array(
'label' => "Dirigeant",
'droits' => array(
'DIRIGEANTS',
'DIRIGEANTSOP',
'WORLDCHECK'
),
),
'FINANCE' => array(
'label' => 'Elements Financiers',
'droits' => array(
'SYNTHESE',
'RATIOS',
'FLUX',
'LIASSE',
'LIASSEXLS',
'UPLOADBILAN',
'BOURSE',
'BANQUE'
),
),
'JURIDIQUE' => array(
'label' => 'Elements Juridiques',
'droits' => array('ANNONCES',
'INFOSREG',
'COMPETENCES',
'CONVENTIONS',
'MARQUES',
'CONTENTIEUX'
),
),
'EVALUATION' => array(
'label' => 'Evaluation',
'droits' => array(
'INDISCORE',
'INDISCORE2',
'INDISCORE3',
'INDISCOREP',
'INDISCORE2P',
'INDISCORE3P',
'VALORISATION',
'ENQUETEC',
'AVISCREDIT'
),
),
'PIECES' => array(
'label' => 'Pièces officielles',
'droits' => array(
'KBIS',
'ACTES',
'PRIVILEGES'
),
),
'SURVEILLANCES' => array(
'label' => 'Surveillances',
'droits' => array(
'SURVANNONCE',
'SURVINSEE',
'SURVBILAN',
'SURVSCORE',
'SURVACTES',
'SURVDIRIGEANTS',
'SURVPAIEMENTS',
'SURVLIENS',
'SURVPRIV',
),
),
'OPTIONS' => array(
'label' => 'Options',
'droits' => array(
'MONPROFIL',
'SURVLISTE',
'PORTEFEUILLE',
'EDITION'
),
),
'DIVERS' => array(
'label' => 'Divers',
'droits' => array(
'INTERNATIONAL',
'BDF'
),
),
);

View File

@ -0,0 +1,67 @@
<div>
<h3 style="padding:0 0 6px 0;margin:0;font-family:Arial,Sans-serif;font-size:16px;font-weight:bold;color:#222">
<span>Scores & Décisions - Paramètres d'accès</span></h3>
<table summary="" style="width:100%;font-family:Arial,Sans-serif;border-width:1px 2px 2px 1px;border:1px Solid #ccc" border="0" cellpadding="8" cellspacing="0">
<tbody>
<tr>
<td>
<div style="padding:2px"><span></span>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Interface</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<a href="http://extranet.scores-decisions.com">http://extranet.scores-decisions.com</a>
<span style="font-size:11px;color:#888">- Cliquer sur ce lien et enregistrer le dans votre navigateur</span>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Login</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<div>
<div style="margin:0 0 0.3em 0"><span>{{Login}}</span>
<span style="font-size:11px;color:#888">- Votre Identifiant</span></div>
</div>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Mot de passe</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<div>
<div style="margin:0 0 0.3em 0"><span>{{Password}}</span>
<span style="font-size:11px;color:#888">- respecter la casse des caractères</span></div>
</div>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Date d'ouverture de compte</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">{{DateHeure}}
<span style="color:#888">Paris</span>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td style="background-color:#f6f6f6;color:#888;border-top:1px Solid #ccc;font-family:Arial,Sans-serif;font-size:11px">
<p>Vous recevez ce message à l'adresse <a href="mailto:{{Email}}" target="_blank">{{Email}}</a>,
suite à l'ouverture d'un contrat pour une prestation chez Scores &amp; Décisions.
<a href="http://www.scores-decisions.com" target="_blank">http://www.scores-decisions.com</a>.<br/>
Léquipe <a href="mailto:support@scores-decisions.com">Support</a> est à votre disposition pour
toute question.
</p>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,67 @@
<div>
<h3 style="padding:0 0 6px 0;margin:0;font-family:Arial,Sans-serif;font-size:16px;font-weight:bold;color:#222">
<span>Scores & Décisions - Modification de vos paramètres d'accès</span></h3>
<table summary="" style="width:100%;font-family:Arial,Sans-serif;border-width:1px 2px 2px 1px;border:1px Solid #ccc" border="0" cellpadding="8" cellspacing="0">
<tbody>
<tr>
<td>
<div style="padding:2px"><span></span>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Interface</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<a href="http://extranet.scores-decisions.com">http://extranet.scores-decisions.com</a>
<span style="font-size:11px;color:#888">- Cliquer sur ce lien et enregistrer le dans votre navigateur</span>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Login</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<div>
<div style="margin:0 0 0.3em 0"><span>{{Login}}</span>
<span style="font-size:11px;color:#888">- Votre Identifiant</span></div>
</div>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Mot de passe</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">
<div>
<div style="margin:0 0 0.3em 0"><span>{{Password}}</span>
<span style="font-size:11px;color:#888">- respecter la casse des caractères</span></div>
</div>
</td>
</tr>
<tr>
<td style="padding:0 1em 10px 0;font-family:Arial,Sans-serif;font-size:13px;color:#888;white-space:nowrap" valign="top">
<div><i style="font-style:normal">Date de modification</i></div>
</td>
<td style="padding-bottom:10px;font-family:Arial,Sans-serif;font-size:13px;color:#222" valign="top">{{DateHeure}}
<span style="color:#888">Paris</span>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td style="background-color:#f6f6f6;color:#888;border-top:1px Solid #ccc;font-family:Arial,Sans-serif;font-size:11px">
<p>Vous recevez ce message à l'adresse <a href="mailto:{Email}" target="_blank">{{Email}}</a>,
suite à une modification de votre accès chez Scores &amp; Décisions.
<a href="http://www.scores-decisions.com" target="_blank">http://www.scores-decisions.com</a>.<br/>
Léquipe <a href="mailto:support@scores-decisions.com">Support</a> est à votre disposition pour
toute question.
</p>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,152 @@
<?php
class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
{
protected $_username;
protected $_password;
protected $_hash;
protected $_timeout = 3600;
protected $checkWs = false;
protected $clients = array();
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Auth DB
* @param string $username
* @param string $password
* @param boolean $checkWs
*/
public function __construct($username, $password, $checkWs = false)
{
$this->_username = $username;
$this->_password = $password;
$this->_hash = md5($username.'|'.$password);
$this->checkWs = $checkWs;
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
* Limit access to only client IDs
* @param array $id
*/
public function limitClient($id = null)
{
if (is_array($id) && count($id) > 0) {
$this->clients = $id;
}
}
/**
* Override the timeout
* @param integer $seconds
*/
public function setTimeout($seconds = null)
{
if ($seconds === null) {
return;
}
$this->_timeout = $seconds;
}
/**
* (non-PHPdoc)
* @see Zend_Auth_Adapter_Interface::authenticate()
*/
public function authenticate()
{
try {
$qb = $this->conn->createQueryBuilder();
$qb->select(array('u.idClient', 'u.id', 'u.login', 'u.password', 'c.timeout'))
->from('sdv1.utilisateurs', 'u')
->join('u', 'sdv1.clients', 'c', 'u.idClient = c.id')
->where("u.login=:login")->setParameter('login', $this->_username)
->andWhere("u.actif=1")
->andWhere("u.deleted=0")
->andWhere("c.actif='Oui'");
if (count($this->clients) > 0) {
$qb->andWhere('u.idClient IN('.join(',', $this->clients).')');
}
if ($this->checkWs) {
$qb->andWhere('u.accesWS=1');
}
$stmt = $qb->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$identity = new stdClass();
$identity->username = $this->_username;
$identity->hash = $this->_hash;
if ($stmt->rowCount() == 0) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity,
array("Identifiant ou mot de passe invalid"));
} else {
$result = $stmt->fetch(PDO::FETCH_OBJ);
if ($this->_password == $result->password
|| $this->_password == md5($result->login.'|'.$result->password)) {
/**
* Date de debut de compte
*/
if (!empty($result->dateDebutCompte) && $result->dateDebutCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$dateDebutCompte = mktime(0, 0, 0, substr($result->dateDebutCompte, 5, 2),
substr($result->dateDebutCompte, 8, 2), substr($result->dateDebutCompte, 0, 4));
if ($today < $dateDebutCompte) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Date de validité dépassé"));
}
}
/**
* Date de fin de compte
*/
if (!empty($result->dateFinCompte) && $result->dateFinCompte!='0000-00-00') {
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$dateFinCompte = mktime(0, 0, 0, substr($result->dateFinCompte, 5, 2),
substr($result->dateFinCompte, 8, 2), substr($result->dateFinCompte, 0, 4));
if ($today > $dateFinCompte) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Date de validité dépassé"));
}
}
$identity->id = $result->id;
$identity->idClient = $result->idClient;
$timeout = (!empty($result->timeout)) ? $result->timeout : $this->_timeout;
$identity->timeout = $timeout;
$identity->time = time() + $timeout;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity,
array("Identification impossible"));
}
}
}
}

View File

@ -0,0 +1,189 @@
<?php
class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
{
/**
* Identifiant de l'utilisateur
* @var string
*/
protected $_username;
/**
* Password
* @var string
*/
protected $_password;
/**
* Timeout
* @var int
*/
protected $_timeout = 1800;
/**
* Marqueur de vérification IP (en iponly)
* @var boolean
*/
protected $_checkIp = false;
/**
* Marqueur de vérification de hach
* @var boolean
*/
protected $_checkHach = false;
/**
* Liste des IPs des frontends (proxy)
* @var array
*/
protected $listProxyIp = array(
'62.210.222.34',
);
/**
* Authentification par WS
* @param string $username
* @param string $password
* @param string $mode
*/
public function __construct($username, $password, $mode = null)
{
$this->_username = $username;
$this->_password = $password;
if ($mode == 'hach') {
$this->_checkHach = true;
}
if ($mode == 'iponly') {
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$this->_password = 'iponly:'.$ip;
$this->_checkIp = true;
}
}
/**
* (non-PHPdoc)
* @see Zend_Auth_Adapter_Interface::authenticate()
*/
public function authenticate()
{
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$ws = new Scores_Ws_Client('gestion', '0.3');
$ws->setHttpLogin($this->_username);
$ws->setHttpPassword($this->_password);
$adressIp = $_SERVER['REMOTE_ADDR'];
$parameters = new stdClass();
$parameters->login = $this->_username;
$parameters->ipUtilisateur = $ip;
$parameters->from = 'auth';
$InfosLogin = $ws->getInfosLogin($parameters);
// --- Renvoi
if (is_string($InfosLogin) || $InfosLogin->error->errnum != 0) {
$message = $InfosLogin;
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
}
// --- Assignation identity
elseif ($InfosLogin !== false && !empty($InfosLogin->result->login)) {
$identity = new stdClass();
if ($this->_checkIp || $this->_checkHach) {
Zend_Registry::get('firebug')->info("IN");
$identity->password = $this->_password;
} else {
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
}
Zend_Registry::get('firebug')->info($identity->password);
$identity->username = $InfosLogin->result->login;
$identity->email = $InfosLogin->result->email;
$identity->profil = $InfosLogin->result->profil;
$identity->pref = $InfosLogin->result->pref;
$identity->droits = $InfosLogin->result->droits;
$identity->droitsClients = $InfosLogin->result->droitsClients;
$identity->nom = $InfosLogin->result->nom;
$identity->prenom = $InfosLogin->result->prenom;
$identity->tel = $InfosLogin->result->tel;
$identity->fax = $InfosLogin->result->fax;
$identity->mobile = $InfosLogin->result->mobile;
$identity->id = $InfosLogin->result->id;
$identity->idClient = $InfosLogin->result->idClient;
$identity->reference = $InfosLogin->result->reference;
$identity->nbReponses = $InfosLogin->result->nbReponses;
$identity->typeScore = $InfosLogin->result->typeScore;
$identity->dateValidation = $InfosLogin->result->dateValidation;
$identity->nombreConnexions = $InfosLogin->result->nombreConnexions;
$identity->dateDerniereConnexion = $InfosLogin->result->dateDerniereConnexion;
$identity->dateDebutCompte = $InfosLogin->result->dateDebutCompte;
$identity->dateFinCompte = $InfosLogin->result->dateFinCompte;
$identity->acceptationCGU = $InfosLogin->result->acceptationCGU;
$identity->ip = $ip;
$identity->version = $InfosLogin->result->version;
$identity->modeEdition = false;
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
$identity->timeout = $timeout;
$identity->time = time() + $timeout;
$lang = in_array($InfosLogin->result->lang, array('fr', 'en')) ? $InfosLogin->result->lang : 'fr';
$identity->lang = $lang;
$identity->langtmp = $lang;
// --- Adresse Ip interdites
$ipInterdites = array(
'81.252.88.0-81.252.88.7', // CTE D AGGLOMERATION DE SOPHIA
'195.200.187.163', // PacWan
'213.11.81.41', // Verizon France SAS
'83.206.171.252', // FR-BASE-D-INFORMATIONS-LEGALES-BI
'81.255.32.139',
'212.155.191.100-212.155.191.199', // Satair A/S
'212.37.196.156', // GENERALE-MULTIMEDIA-SUD
'80.245.60.121', // Planete Marseille - Mailclub
'213.246.57.101', // IKOULA
'193.104.158.0-193.104.158.255', // Altares.fr
'195.6.3.0-195.6.3.255', // ORT
'217.144.112.0-217.144.116.63', // Coface
);
// --- Validation IP
$overallIpValidate = false;
foreach ($ipInterdites as $filtre) {
if (strpos($filtre, '*')) {
$filtre = str_replace('*', '0', $filtre) . '-' . str_replace('*', '255', $filtre);
}
// Is it a range ?
if (strpos($filtre, '-')) {
$validateIp = new Scores_Validate_IpInNetwork();
$validateIp->setNetworkNotation($filtre);
$overallIpValidate = $validateIp->isValid($ipToValidate);
}
// Ip only
else {
if ($filtre === $ipToValidate) {
$overallIpValidate = true;
}
}
// Break foreach
if ($overallIpValidate === true) {
break;
}
}
// Exit with error
if ($overallIpValidate === false) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
}
// --- OK connecté
$this->_username = $identity->username;
$this->_password = $identity->password;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity, array("Identification impossible"));
}
}
}

View File

@ -0,0 +1,7 @@
<?php
class Scores_Bill_Article
{
}

View File

@ -0,0 +1,5 @@
<?php
return array(
'extranet' => "Extranet",
'webservice' => "WebService",
);

17
src/Scores/Bill/Data.php Normal file
View File

@ -0,0 +1,17 @@
<?php
class Scores_Bill_Data
{
public function __construct(){}
public function setInfos(){}
public function setInfosClient(){}
public function setLines(){}
public function addLine(){}
public function calculLineTotal(){}
public function calculTaxe(){}
public function calculTotalHT(){}
public function calculTotalTVA(){}
public function calculTotalTTC(){}
public function calculToPaid(){}
}

453
src/Scores/Bill/Pdf.php Normal file
View File

@ -0,0 +1,453 @@
<?php
class Scores_Bill_Pdf extends TCPDF
{
protected $Logo;
protected $Title = 'Facture';
protected $Num;
protected $Label;
protected $Date;
protected $ClientNum;
protected $ClientL1;
protected $ClientL2;
protected $ClientL3;
protected $ClientL4;
protected $ClientL5;
protected $ClientL6;
protected $ClientL7;
protected $ClientContact;
protected $ModePaiement;
protected $DateDue;
protected $DatePeriodBegin;
protected $DatePeriodEnd;
protected $Line = array();
protected $TotalHT = 0;
protected $TotalTTC = 0;
protected $TotalTVA = 0;
protected $TauxTVA = array();
protected $PageBottom;
protected $PageFooter;
protected $pdf;
protected $posY;
public function Header()
{
// Logo
$image_file = __DIR__.'/logo.jpg';
$this->Image($image_file, PDF_MARGIN_LEFT, 0, 50, '', 'JPG', '', 'T', false, 300, 'C', false, false, 0, false, false, false);
// Set font
$this->SetFont('helvetica', 'B', 15);
$this->SetAbsXY(PDF_MARGIN_LEFT, PDF_MARGIN_HEADER);
$this->Cell(0, 15, '', 'B', false, 'C', 0, '', 0, false, 'M', 'M');
}
public function Footer()
{
$cur_y = $this->y;
$this->SetTextColorArray($this->footer_text_color);
//set style for cell border
$line_width = (0.85 / $this->k);
$this->SetLineStyle(array('width' => $line_width, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $this->footer_line_color));
$w_page = isset($this->l['w_page']) ? $this->l['w_page'].' ' : '';
if (empty($this->pagegroups)) {
$pagenumtxt = $w_page.$this->getAliasNumPage().' / '.$this->getAliasNbPages();
} else {
$pagenumtxt = $w_page.$this->getPageNumGroupAlias().' / '.$this->getPageGroupAlias();
}
$this->SetY($cur_y);
// Print legal
$this->Cell(0, 10, "Société anonyme par actions simplifiée au capital de 618 450,00 Euros - SIRET : 494 967 938 00056 RCS VERSAILLES B 494967938 - N.I.I: FR 84 494967938", 'T', 1, 'C');
// Print page number
$this->SetX($this->original_lMargin);
$this->Cell(0, 0, $this->getAliasRightShift().$pagenumtxt, 0, 0, 'R');
}
public function setData($id)
{
// --- Lecture des paramètres de la facturation
$factureM = new Application_Model_FacturationFacture();
$factureSql = $factureM->select()->where('id=?', $id);
$factureResult = $factureM->fetchRow($factureSql);
if ($factureResult->type == 'avoir') {
$this->Title = 'Avoir';
}
switch($factureResult->paiement) {
case 'virement':
$this->ModePaiement = 'Virement';
break;
case 'cheque':
$this->ModePaiement = 'Cheque';
break;
case 'none':
$this->ModePaiement = '';
break;
}
$this->Num = $factureResult->num;
$this->Label = $factureResult->label;
$this->Date = substr($factureResult->date,8,2).'/'.substr($factureResult->date,5,2).'/'.substr($factureResult->date,0,4);
$this->DateDue = substr($factureResult->dateDue,8,2).'/'.substr($factureResult->dateDue,5,2).'/'.substr($factureResult->dateDue,0,4);
$this->ClientNum = $factureResult->clientCode;
$this->DatePeriodBegin = substr($factureResult->periodBegin,8,2).'/'.substr($factureResult->periodBegin,5,2).'/'.substr($factureResult->periodBegin,0,4);
$this->DatePeriodEnd = substr($factureResult->periodEnd,8,2).'/'.substr($factureResult->periodEnd,5,2).'/'.substr($factureResult->periodEnd,0,4);
/*
$adresseM = new Application_Model_FacturationFactureZoneclient();
$adresseSql = $adresseM->select()->where('factId=?', $id);
*/
// --- Articles à facturer
$lineM = new Application_Model_FacturationFactureLine();
$lineSql = $lineM->select()->where('factId=?', $id)->order('num ASC');
$lineResult = $lineM->fetchAll($lineSql);
$data = array();
foreach ($lineResult as $l) {
$data[] = array($l->code, $l->zonetxt, $l->qte, $l->montantUnit, $l->montantLine, $l->tva);
}
$this->Line = $data;
// --- Calcul
if (count($lineResult) > 0) {
foreach($lineResult as $l) {
$lineTVA = new stdClass();
if (array_key_exists($l->tva, $this->TauxTVA)) {
$old = $this->TauxTVA[$l->tva];
$lineTVA->Base = $l->montantLine + $old->Base;
$lineTVA->Mt = $lineTVA->Base * ($l->tva / 100);
} else {
$lineTVA->Base = $l->montantLine;
}
$lineTVA->Mt = $lineTVA->Base * ($l->tva / 100);
$this->TauxTVA[$l->tva] = $lineTVA;
$this->TotalHT+= $l->montantLine;
$this->TotalTTC+= $l->montantLine * (1 + $l->tva / 100);
$this->TotalTVA = $this->TotalTTC - $this->TotalHT;
}
}
}
public function displayLines()
{
// column titles
$header = array('Code', 'Description', 'Quantité', 'P.U. HT', 'Total HT', 'Tx TVA');
$w = array(30, 86, 16, 16, 16, 16);
// Colors, line width and bold font
$this->SetFillColor(200, 200, 200);
$this->SetTextColor(0);
$this->SetDrawColor(0, 0, 0);
//$this->SetLineWidth(0.3);
$this->SetFont('', 'B', 10);
// Header
$num = count($header);
for($i = 0; $i < $num; ++$i) {
$this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
}
$this->Ln();
// Color and font restoration
$this->SetFillColor(224, 235, 255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = 0;
foreach($this->Line as $row) {
// Label cell
//$this->Cell($w[1], 6, $row[1], 'LR', 0, 'L', $fill, '', 0, true);
$this->SetAbsX(PDF_MARGIN_LEFT + $w[0]);
$nbLine = $this->MultiCell($w[1], 6, $row[1], 'LR', 'L', $fill, 0);
// Other cells
$this->SetAbsX(PDF_MARGIN_LEFT);
$this->Cell($w[0], 6 * $nbLine, $row[0], 'LR', 0, 'L', $fill, '', 0, false, 'T', 'T');
$this->SetAbsX(PDF_MARGIN_LEFT + $w[0] + $w[1]);
$this->Cell($w[2], 6 * $nbLine, number_format($row[2], 2, ',', ' '), 'LR', 0, 'R', $fill, '', 0, false, 'T', 'T');
$this->Cell($w[3], 6 * $nbLine, number_format($row[3], 2, ',', ' '), 'LR', 0, 'R', $fill, '', 0, false, 'T', 'T');
$this->Cell($w[4], 6 * $nbLine, number_format($row[4], 2, ',', ' '), 'LR', 0, 'R', $fill, '', 0, false, 'T', 'T');
$this->Cell($w[5], 6 * $nbLine, number_format($row[5], 2, ',', ' '), 'LR', 0, 'R', $fill, '', 0, false, 'T', 'T');
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w), 0, '', 'T');
$this->Ln();
}
public function displayResumeTaxe()
{
$this->posY = $this->y;
$header = array('Tx TVA', 'Base', 'Montant TVA');
$data = array();
foreach ($this->TauxTVA as $t => $d) {
$data[] = array($t, $d->Base, $d->Mt);
}
$widthColTotal = $this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT - 80;
$widthCol = $widthColTotal / 3;
$w = array($widthCol, $widthCol, $widthCol);
// Colors, line width and bold font
$this->SetFillColor(200, 200, 200);
$this->SetTextColor(0);
$this->SetDrawColor(0, 0, 0);
//$this->SetLineWidth(0.3);
$this->SetFont('', 'B', 8);
// Header
$num = count($header);
for($i = 0; $i < $num; ++$i) {
$this->Cell($w[$i], 6, $header[$i], 1, 0, 'C', 1);
}
$this->Ln();
// Color and font restoration
$this->SetFillColor(224, 235, 255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = 0;
foreach($data as $row) {
for($i = 0; $i < $num; ++$i) {
$this->Cell($w[$i], 6, number_format($row[$i], 2, ',', ' '), 'LR', 0, 'R', $fill);
}
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w), 0, '', 'T');
$this->Ln();
}
public function displayTotal()
{
$this->setY($this->posY);
$header = array('Total HT', 'Total TVA', 'Total TTC', 'Net à payer (en euros)');
$data = array($this->TotalHT, $this->TotalTVA, $this->TotalTTC, $this->TotalTTC);
$w = array(45, 45, 45, 45);
$maxPosX = $this->getPageWidth() - PDF_MARGIN_RIGHT;
$num = count($header);
for($i = 0; $i < $num; ++$i) {
$this->SetAbsX($maxPosX - 45 - 30);
// Header - Colors, line width and bold font
$this->SetFillColor(200, 200, 200);
$this->SetTextColor(0);
$this->SetDrawColor(0, 0, 0);
$this->SetLineWidth(0.3);
$this->SetFont('', 'B', 10);
$this->Cell(45, 7, $header[$i], 1, 0, 'C', 1);
// Data - Color and font restoration
$this->SetFillColor(224, 235, 255);
$this->SetTextColor(0);
$this->SetFont('');
//$this->SetAbsX($maxPosX - $x);
$this->Cell(30, 7, number_format($data[$i], 2, ',', ' '), 1, 0, 'R', 0);
$this->Ln();
}
}
public function displayPaiement()
{
$this->SetFont('', 'B', 8);
$w = $this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT - 80;
$this->Cell($w, 0, "Mode de paiement : " . $this->ModePaiement, 'LTR', 1);
$this->Cell($w, 0, "Date d'échéance : " . $this->DateDue, 'LBR', 1);
}
public function displayIBAN()
{
$header = array('Code Banque', 'Code Guichet', 'N° Compte', 'Clé');
$data = array('42559', '00072', '21009306208', '91');
$widthColTotal = $this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT - 80;
$widthCol = $widthColTotal / count($header);
$this->SetFont('');
$this->Ln();
// Header
$num = count($header);
for($i = 0; $i < $num; ++$i) {
$this->Cell($widthCol, 6, $header[$i], 1, 0, 'C', 0);
}
$this->Ln();
// Data
$fill = 0;
for($i = 0; $i < $num; ++$i) {
$this->Cell($widthCol, 6, $data[$i], 'LTRB', 0, 'C', $fill);
}
$this->Ln();
$w = $this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT - 80;
$this->Cell($w, 0, "Code IBAN : FR76 4255 9000 7221 0093 0620 891", 'LTR', 1);
$this->Cell($w, 0, "BIC : CCOPFRPPXXX - Domiciliation : CREDITCOOP PARIS POMMIER", 'LBR', 1);
}
public function displayFooter()
{
$this->Ln();
$this->SetFont('', '', 8);
$maxPosX = $this->getPageWidth() - PDF_MARGIN_RIGHT;
$this->Cell($this->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT, 0, '', 'T');
$this->Ln();
// Info
$this->Cell(20, 0, "Escompte pour paiement anticipé : Néant", 0, 1, 'L', 0, '', 0, false, 'T', 'M');
$this->Cell(20, 0, "Pénalités de retard ; 1,5 fois le taux de l'interêt légal", 0, 1, 'L', 0, '', 0, false, 'T', 'M');
$this->Cell(20, 0, "Frais de recouvrement : pénalité forfaitaire fixée à 10% des sommes dues", 0, 1, 'L', 0, '', 0, false, 'T', 'M');
}
public function compile($id)
{
$this->setPageUnit('mm');
$this->setPageFormat('A4', 'P');
$this->SetAuthor('SCORES ET DECISIONS');
$this->setData($id);
$this->SetTitle($this->Title);
$this->SetSubject($this->Title);
// set default header data
//$this->SetHeaderData('', 200, "FACTURE", "Scores & Décisions");
// set header and footer fonts
$this->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$this->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$this->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$this->SetMargins(PDF_MARGIN_LEFT, 20, PDF_MARGIN_RIGHT);
$this->SetHeaderMargin(PDF_MARGIN_HEADER);
$this->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$this->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$this->setImageScale(PDF_IMAGE_SCALE_RATIO);
// add a page
$this->AddPage();
// set font
$this->SetFont('times', '', 16);
$maxPosX = $this->getPageWidth() - PDF_MARGIN_RIGHT;
$minPosX = PDF_MARGIN_LEFT;
$maxWidth = $this->getPageWidth() - PDF_MARGIN_RIGHT - PDF_MARGIN_LEFT;
$this->Cell($maxWidth - 115, 15, strtoupper($this->Title), 0, false, 'C', 0, '', 0, false, 'M', 'M');
$this->SetAbsY(15);
$this->SetFont('times', '', 10);
// Infos Facture
$this->SetFillColor(200, 200, 200);
$this->SetTextColor(0);
$this->SetDrawColor(0, 0, 0);
//$this->SetLineWidth(0.3);
$this->SetFont('', 'B');
// Header
$header = array('N°', 'Date', 'Code client');
$w = array(40, 35, 40);
$num = count($header);
$x = 0;
for($i = 0; $i < $num; ++$i) {
$x+= $w[$num-($i+1)];
$this->SetAbsX($maxPosX - $x);
$this->Cell($w[$num-($i+1)], 7, $header[$num-($i+1)], 1, 0, 'C', 1);
}
$this->Ln();
// Data
$this->SetFillColor(255, 255, 255);
$data = array($this->Num, $this->Date, $this->ClientNum);
$num = count($data);
$x = 0;
for($i = 0; $i < $num; ++$i) {
$x+= $w[$num-($i+1)];
$this->SetAbsX($maxPosX - $x);
$this->Cell($w[$num-($i+1)], 7, $data[$num-($i+1)], 1, 0, 'C', 1);
}
$this->Ln();
$infoClientY = $this->GetY();
// set color for background
$this->SetFillColor(255, 255, 255);
// Infos Client
$w = 90;
$this->SetFont('', 'B');
$this->SetAbsXY($maxPosX - $w, $infoClientY + 5);
$this->Cell($w, 0, "Adresse de facturation", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetFont('', '');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L1", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L2", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L3", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L4", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L5", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L6", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L7", '', 1, '', false, '', 0, false, 'T', 'M');
$this->SetAbsX($maxPosX - $w);
$this->Cell($w, 0, "L8", '', 1, '', false, '', 0, false, 'T', 'M');
$infoClientEndY = $this->GetY();
// Infos SCORES
$w = 90;
$this->SetAbsY($infoClientY + 10);
$this->Cell($w, 0, "SCORES ET DECISIONS SAS", 0, 1, '', false, '', 0, false, 'T', 'M');
$this->SetFont('', '');
$this->Cell($w, 0, "1 RUE DE CLAIREFONTAINE", 0, 1, '', false, '', 0, false, 'T', 'M');
$this->Cell($w, 0, "78120 RAMBOUILLET", 0, 1, '', false, '', 0, false, 'T', 'M');
$this->Cell($w, 0, "compta@scores-decisions.com", 0, 1, '', false, '', 0, false, 'T', 'M');
$this->Cell($w, 0, "Tél : 01 75 43 80 10 - Fax : 01 75 43 85 74", 0, 1, '', false, '', 0, false, 'T', 'M');
$this->Ln();
$this->SetAbsY($infoClientEndY);
$this->SetFont('', 'B', 12);
$this->Cell(20, 0, "Période du " . $this->DatePeriodBegin . " au " . $this->DatePeriodEnd, 0, 1);
$this->SetFont('', '', 12);
$this->Cell(20, 0, "Objet : " . $this->Label, 0, 1);
$this->Ln();
// Create table article
$this->displayLines();
// Create taxe Resume
$this->displayResumeTaxe();
$this->displayPaiement();
$this->displayIBAN();
$this->displayFooter();
//Create total
$this->displayTotal();
// move pointer to last page
$this->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$this->Output(APPLICATION_PATH . '/../testfacture.pdf', 'F');
}
}

View File

@ -0,0 +1 @@
<?php

BIN
src/Scores/Bill/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
src/Scores/Bill/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

101
src/Scores/Configure.php Normal file
View File

@ -0,0 +1,101 @@
<?php
class Configure
{
/**
* Configuration object
* @var Zend_Config_Ini
*/
protected $profil;
public function __construct()
{
$this->readConfig();
$this->_defineDb();
$this->_definePath();
$this->_defineSphinx();
$this->_defineMail();
}
/**
* Read config application.ini
*/
protected function readConfig()
{
if ( Zend_Registry::isRegistered('config') ) {
$c = Zend_Registry::get('config');
$this->profil = $c->profil;
} else {
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production');
$this->profil = $c->profil;
}
}
protected function _defineDb()
{
$c = Zend_Registry::get('config');
if ( $c->resources->db ) {
define('MYSQL_HOST', $c->resources->db->params->host);
define('MYSQL_USER', $c->resources->db->params->username);
define('MYSQL_PASS', $c->resources->db->params->password);
define('MYSQL_DEFAULT_DB', 'jo');
define('MYSQL_SQL_LOG', 'NONE');
}
}
protected function _definePath()
{
//Use of realpath
define('BODACC_LOCAL_DIR' , '/home/data/bodacc/');
define('JAL_LOCAL_DIR' , '/home/data/jal/');
define('HUGIN_LOCAL_DIR' , '/home/data/infosreg/hugin/');
define('ACTUSNEWS_LOCAL_DIR' , '/home/data/infosreg/actusnews/');
define('DIRELEASE_LOCAL_DIR' , '/home/data/infosreg/direlease/');
define('LESECHOS_LOCAL_DIR' , '/home/data/infosreg/lesechos/');
define('BUSINESSWIRE_LOCAL_DIR_INCOMING' , '/home/data/ftp/businesswire/');
define('BUSINESSWIRE_LOCAL_DIR' , '/home/data/infosreg/businesswire/');
define('DOC_WEB_LOCAL' , $this->profil->path->files.'/');
define('DOC_WEB_URL' , '/fichier/');
define('LOG_PATH' , $this->profil->path->shared.'/log');
}
protected function _defineSphinx()
{
// Entreprise
define('SPHINX_ENT_HOST', $this->profil->sphinx->ent->host);
define('SPHINX_ENT_PORT', intval($this->profil->sphinx->ent->port));
define('SPHINX_ENT_VERSION', $this->profil->sphinx->ent->version);
// Dirigeants
define('SPHINX_DIR_HOST', $this->profil->sphinx->dir->host);
define('SPHINX_DIR_PORT', intval($this->profil->sphinx->dir->port));
define('SPHINX_DIR_VERSION', $this->profil->sphinx->dir->version);
// Historique
define('SPHINX_HISTO_HOST', $this->profil->sphinx->histo->host);
define('SPHINX_HISTO_PORT', intval($this->profil->sphinx->histo->port));
define('SPHINX_HISTO_VERSION', $this->profil->sphinx->histo->version);
// Actionnaire
define('SPHINX_ACT_HOST', $this->profil->sphinx->act->host);
define('SPHINX_ACT_PORT', intval($this->profil->sphinx->act->port));
define('SPHINX_ACT_VERSION', $this->profil->sphinx->act->version);
//Old
define('SPHINX_HOST', $this->profil->sphinx->ent->host);
define('SPHINX_PORT', intval($this->profil->sphinx->ent->port));
}
protected function _defineMail()
{
//Messagerie
define('SMTP_HOST', $this->profil->mail->smtp_host);
define('SMTP_PORT', '');
define('SMTP_USER', '');
define('SMTP_PASS', '');
}
}

View File

@ -0,0 +1,95 @@
<?php
use League\Csv\Writer;
class Scores_Conso_Export
{
//Extraction des logs payants
//Extraction des logs bruts
protected $entete = array(
'login' => "Identifiant",
'referenceParDefaut' => "Service",
'page' => "Code Requete",
'pageLib' => "Libellé Requete",
'params' => "Paramètres",
'siren' => "Siren",
'nic' => "Nic",
'raisonSociale' => "Raison Sociale",
'cp' => "CP",
'ville' => "Ville",
'dateHeure' => "DateHeure",
'nbDoublon' => "Nb Doublon",
);
protected $pageLib = array();
protected $data = array();
/**
* Export des logs de conso sous forme de fichier CSV
*/
public function __construct()
{
$this->setPageLib();
}
public function setData($d)
{
$this->data = $d;
}
/**
* Formattage des données pour le CSV
* @param string $filename
* @param string $addEntete
*/
public function export($filename, $addEntete = true)
{
$enteteCode = array_keys($this->entete);
$enteteLabel = array_values($this->entete);
// Create CSV File
$csv = Writer::createFromPath($filename, 'w');
// Insert the CSV header
$csv->insertOne($enteteLabel);
// --- Parcours des données
foreach ($this->data as $data){
$row = array();
foreach ($enteteCode as $entete) {
if (array_key_exists($entete, $data)) {
$row[] = $data[$entete];
} else if (property_exists($this, $entete)){
$code = str_replace('Lib', '', $entete);
if (array_key_exists($data[$code], $this->{$entete})) {
$row[] = $this->{$entete}[$data[$code]];
} else {
$row[] = 'NO LABEL';
}
} else {
$row[] = 'UNKNOWN';
}
}
// Insert Data
$csv->insertOne($row);
}
}
/**
* Récupération des libellés de requete
*/
protected function setPageLib()
{
$libM = new Application_Model_Sdv1LogsItem();
$libSql = $libM->select()->from($libM, array('Code', 'Label'));
$libResult = $libM->fetchAll($libSql);
if (count($libResult) > 0) {
foreach ($libResult as $l) {
$this->pageLib[$l->Code] = $l->Label;
}
}
}
}

135
src/Scores/Conso/File.php Normal file
View File

@ -0,0 +1,135 @@
<?php
/**
* Comptabilise le nombre d'entité d'un fichier
*/
class Scores_Conso_File
{
protected $login = array();
protected $date;
protected $item;
/**
* @var Zend_Db_Table_Abstract
*/
protected $table;
/**
*
* @var Zend_Db_Select
*/
protected $sql;
/**
*
* @param Zend_Db_Table_Abstract $table
*/
public function __construct(Zend_Db_Table_Abstract $table)
{
$this->table = $table;
$this->sql = $this->table->select();
}
/**
* Array of login
* @param array $login
*/
public function setLogin($login)
{
$this->login = $login;
}
/**
* Date au format AAAAMM
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
}
/**
* Code de l'élément à compter
* @param string $item
*/
public function setItem($item)
{
$this->item = $item;
}
/**
* Retourne la requete
* @return Zend_Db_Select
*/
public function getSqlRule()
{
$this->addSqlLogin();
$this->addSqlItem();
$this->addSqlDate();
return $this->sql;
}
/**
*
* @param unknown $name
* @param unknown $value
*/
public function setOption($name, $value)
{
if ( null === $this->item ) {
return new Zend_Exception('Item is not set !');
}
if ($name == 'duplicate') {
if ( !array_key_exists('duplicate', $this->rules[$this->item]) ) {
switch ( strtolower($value) ) {
case 'day':
case 'jour':
$this->rules[$this->item]['duplicate'] = 'day';
break;
case 'month':
case 'mois':
case 'period':
case 'periode':
$this->rules[$this->item]['duplicate'] = 'period';
break;
}
}
}
}
/**
*
*/
public function addSqlLogin()
{
$this->sql->where("login IN ('".join("','", $this->login)."')");
}
public function addSqlDate()
{
$formatedDate = substr($this->date,0,4).'-'.substr($this->date,4,2);
$this->sql->where("dateAjout BETWEEN '".$formatedDate."-01 00:00:00' AND '".$formatedDate."-31 23:59:59'");
}
public function addSqlItem()
{
$this->sql->from($this->table, array('COUNT(*) AS NB'));
$rule = $this->rules[$this->item];
//Apply item parameters
/*if ( array_key_exists('params', $rule) && count($rule['params'])>0 ) {
foreach ( $rule['params'] as $param ) {
$this->sql->where($param);
}
}*/
$this->sql->where('source=?', $this->item);
$this->sql->order('dateAjout ASC');
}
}

66
src/Scores/Conso/Flux.php Normal file
View File

@ -0,0 +1,66 @@
<?php
class Scores_Conso_Flux
{
protected $code;
protected $date;
protected $dateStock = false;
/**
* @var Zend_Db_Table_Abstract
*/
protected $table;
/**
*
* @var Zend_Db_Select
*/
protected $sql;
/**
*
* @param Zend_Db_Table_Abstract $table
*/
public function __construct(Zend_Db_Table_Abstract $table)
{
$this->table = $table;
$this->sql = $this->table->select();
}
/**
* Date au format AAAAMM
* @param string $date
* @param boolean $stock
*/
public function setDate($date, $stock = false)
{
$this->date = $date;
$this->dateStock = $stock;
}
public function setCode($name)
{
$this->code = $name;
}
public function setType($name)
{
}
public function getSqlRule()
{
$this->sql->from($this->table, array('COUNT(*) AS NB'));
$formatedDate = substr($this->date,0,4).'-'.substr($this->date,4,2);
if ($this->dateStock === true) {
$this->sql->where("dateSuppr = 0");
} else {
$this->sql->where("dateAjout BETWEEN '".$formatedDate."-01 00:00:00' AND '".$formatedDate."-31 23:59:59'");
}
$this->sql->where('idClient=?', $this->code);
return $this->sql;
}
}

358
src/Scores/Conso/Logs.php Normal file
View File

@ -0,0 +1,358 @@
<?php
/**
* Comptabilise la consommation
* Logs brutes :
* Aucun traitement, fournir la consomation avec date et heure
* Logs consommation :
* Dédoublonnage,
* Condition d'exclusion
* Croiser les tables pour avoir un libellé
*
* Mettre une date sur les règles pour suivre la facturation dans le temps
*
*/
class Scores_Conso_Logs
{
protected $login = array();
protected $date;
protected $item;
/**
* Standard count rules
* Format :
* ITEM NAME => array(
* 'params' => array of supplemental sql and where
* 'duplicate' => none, day, month, period (specified if this params must not change)
* )
* @var array
*/
protected $rules = array (
'identite' => array(),
'annonces' => array(),
'dirigeants' => array(),
'dirigeantsop' => array(),
'evenements' => array(),
'etablissements' => array(),
'liens' => array(
'duplicate' => 'none',
),
'competences' => array(),
'kbis' => array(// à correler avec la table des commandes - Non fonctionnel
'duplicate' => 'day',
),
'synthese' => array(),
'ratios' => array(),
'bilan' => array(
'duplicate' => 'none',
),
'indiscore' => array(),
'indiscore2' => array(),
'indiscore3' => array(),
'indiscorep' => array(),
'indiscore2p' => array(),
'indiscore3p' => array(),
'flux' => array(),
'liassexls' => array(
'duplicate' => 'none',
),
'rapport1' => array(),
'rapport2' => array(),
'rapport3' => array(),
'marques' => array(),
'banque' => array(),
'conventions' => array(),
'groupeinfos' => array(),
'groupesarbo' => array(),
'infosreg' => array(),
'rechcsv' => array(
'duplicate' => 'none',
),
'greffe_bilans' => array(
'params' => array(
"params != 'Liste'"
),
'group' => array('login', 'siren', 'page', 'params', 'raisonSociale', 'period'),
),
'greffe_actes' => array(
'params' => array(
"params != 'Liste'"
),
'group' => array('login', 'siren', 'page', 'params', 'raisonSociale', 'period'),
),
'greffe_statuts' => array(
'group' => array('login', 'siren', 'page', 'params', 'raisonSociale', 'period'),
),
'bourse' => array(),
'scorecsf' => array(),
'avis_situation' => array(),
'privileges' => array(),
'commandeAsso' => array(),
'privcumul' => array(),
'privdetail' => array(),
'uploadbilan' => array(),
'histobodacc' => array(),
'aviscredit' => array(),
'tva' => array(),
'sirenExiste' => array(),
'histobodacc' => array(),
'valo' => array(),
'rnvp' => array(),
'avisrncs' => array(),
'affairelist' => array(),
'affairedetail' => array(),
);
/**
* @var Zend_Db_Table_Abstract
*/
protected $table;
/**
*
* @var Zend_Db_Select
*/
protected $sql;
/**
*
* @param Zend_Db_Table_Abstract $table
*/
public function __construct(Zend_Db_Table_Abstract $table)
{
$this->table = $table;
$this->sql = $this->table->select();
}
/**
* Array of login
* @param array $login
*/
public function setLogin($login)
{
$this->login = $login;
}
/**
* Date au format AAAAMM
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
}
/**
* Code de l'élément à compter
* @param string $item
*/
public function setItem($item)
{
$this->item = $item;
}
/**
* Retourne requete SQL avec les règles
* @return Zend_Db_Select
*/
public function getSqlRule($file = false)
{
$this->addSqlLogin();
$this->addSqlItem($file);
$this->addSqlDate();
return $this->sql;
}
/**
* Retourne requete SQL
* @return Zend_Db_Select
*/
public function getSql()
{
$this->addSqlLogin();
$this->addSqlDate();
$columns = array(
'LOWER(login) AS login', 'page', 'LPAD(siren, 9, 0) AS siren', 'LPAD(nic, 5, 0) AS nic',
'params', 'raisonSociale', 'cp', 'ville', 'dateHeure', new Zend_Db_Expr('"none" as nbDoublon'));
$this->sql->from($this->table, $columns);
return $this->sql;
}
/**
*
* @param unknown $name
* @param unknown $value
*/
public function setOption($name, $value)
{
if ( null === $this->item ) {
return new Zend_Exception('Item is not set !');
}
if ($name == 'duplicate') {
if ( !array_key_exists('duplicate', $this->rules[$this->item]) ) {
switch ( strtolower($value) ) {
case 'day':
case 'jour':
$this->rules[$this->item]['duplicate'] = 'day';
break;
case 'month':
case 'mois':
case 'period':
case 'periode':
$this->rules[$this->item]['duplicate'] = 'period';
break;
}
}
}
}
/**
*
*/
public function addSqlLogin()
{
$this->sql->where($this->table->info('name').".login IN ('".join("','", $this->login)."')");
}
public function addSqlDate()
{
$formatedDate = substr($this->date,0,4).'-'.substr($this->date,4,2);
$this->sql->where("dateHeure BETWEEN '".$formatedDate."-01 00:00:00' AND '".$formatedDate."-31 23:59:59'");
}
public function addSqlItem($file = false)
{
$rule = array();
if ( array_key_exists($this->item, $this->rules) ){
$rule = $this->rules[$this->item];
}
// --- Group to deduplicate
if ( array_key_exists('duplicate', $rule) ) {
switch($rule['duplicate']) {
case 'day':
if ($file === false ) {
$columns = array('COUNT(*) AS doublon', "DATE_FORMAT(dateHeure, '%Y%m%d') AS period");
} else {
$columns = array(
'LOWER('.$this->table->info('name').'.login) AS login',
'page',
'LPAD(siren, 9, 0) AS siren',
'LPAD(nic, 5, 0) AS nic',
'params',
'raisonSociale',
'cp',
'ville',
'dateHeure',
"DATE_FORMAT(dateHeure, '%Y%m%d') AS period",
'COUNT(*) AS nbDoublon'
);
}
$this->sql->from($this->table, $columns);
if ( array_key_exists('group', $rule) ) {
$this->sql->group($rule['group']);
} else {
$this->sql->group(array('login', 'siren', 'page', 'raisonSociale', 'period'));
}
break;
case 'period':
if ($file === false ) {
/*SELECT count(doublon) as NB FROM () test*/
$columns = array('COUNT(*) AS doublon', "DATE_FORMAT(dateHeure, '%Y%m') AS period");
} else {
$columns = array(
'LOWER('.$this->table->info('name').'.login) AS login',
'page',
'LPAD(siren, 9, 0) AS siren',
'LPAD(nic, 5, 0) AS nic',
'params',
'raisonSociale',
'cp',
'ville',
'dateHeure',
"DATE_FORMAT(dateHeure, '%Y%m') AS period",
'COUNT(*) AS nbDoublon'
);
}
$this->sql->from($this->table, $columns);
if ( array_key_exists('group', $rule) ) {
$this->sql->group($rule['group']);
} else {
$this->sql->group(array('login', 'siren', 'page', 'raisonSociale', 'period'));
}
break;
case 'none':
default:
if ($file === false ) {
$columns = array('dateHeure AS period');
} else {
$columns = array(
'LOWER('.$this->table->info('name').'.login) AS login',
'page',
'LPAD(siren, 9, 0) AS siren',
'LPAD(nic, 5, 0) AS nic',
'params',
'raisonSociale',
'cp',
'ville',
'dateHeure',
new Zend_Db_Expr('"none" as nbDoublon')
);
}
$this->sql->from($this->table, $columns);
break;
}
}
// --- No duplicate rules
if ( !array_key_exists('duplicate', $rule) || count($rule) == 0 ) {
if ($file === false ) {
$columns = array('dateHeure');
} else {
$columns = array(
'LOWER('.$this->table->info('name').'.login) AS login',
'page',
'LPAD(siren, 9, 0) AS siren',
'LPAD(nic, 5, 0) AS nic',
'params',
'raisonSociale',
'cp',
'ville',
'dateHeure',
new Zend_Db_Expr('"none" as nbDoublon')
);
}
$this->sql->from($this->table, $columns);
}
// --- Apply item parameters
if ( array_key_exists('params', $rule) && count($rule['params'])>0 ) {
foreach ( $rule['params'] as $param ) {
$this->sql->where($param);
}
}
if ($file === true) {
$this->sql->setIntegrityCheck(false)
->joinLeft('utilisateurs', 'utilisateurs.login='.$this->table->info('name').'.login', array('referenceParDefaut'), 'sdv1');
}
$this->sql->where('page=?', $this->item);
$this->sql->order('dateHeure ASC');
}
}

View File

@ -0,0 +1,165 @@
<?php
/**
* Comptabilise la consommation surveillances
*
*/
class Scores_Conso_Surveillances
{
protected $login = array();
protected $date;
protected $dateStock;
protected $item;
/**
* Standard count rules
* Format :
* ITEM NAME => array(
* 'params' => array of supplemental sql and where
* 'duplicate' => none, day, month, period (specified if this params must not change)
* )
* @var array
*/
protected $rules = array (
'annonces' => array(),
'insee' => array(),
'bilans' => array(),
'score' => array(),
'actes' => array(),
'dirigeants' => array(),
'paiements' => array(),
'liens' => array(),
'privileges' => array(),
);
/**
* @var Zend_Db_Table_Abstract
*/
protected $table;
/**
*
* @var Zend_Db_Select
*/
protected $sql;
/**
*
* @param Zend_Db_Table_Abstract $table
*/
public function __construct(Zend_Db_Table_Abstract $table)
{
$this->table = $table;
$this->sql = $this->table->select();
}
/**
* Array of login
* @param array $login
*/
public function setLogin($login)
{
$this->login = $login;
}
/**
* Date au format AAAAMM
* @param string $date
* @param boolean $stock
*/
public function setDate($date, $stock = false)
{
$this->date = $date;
$this->dateStock = $stock;
}
/**
* Code de l'élément à compter
* @param string $item
*/
public function setItem($item)
{
$this->item = $item;
}
/**
* Retourne la requete
* @return Zend_Db_Select
*/
public function getSqlRule()
{
$this->addSqlLogin();
$this->addSqlItem();
$this->addSqlDate();
return $this->sql;
}
/**
*
* @param unknown $name
* @param unknown $value
*/
public function setOption($name, $value)
{
if ( null === $this->item ) {
return new Zend_Exception('Item is not set !');
}
if ($name == 'duplicate') {
if ( !array_key_exists('duplicate', $this->rules[$this->item]) ) {
switch ( strtolower($value) ) {
case 'day':
case 'jour':
$this->rules[$this->item]['duplicate'] = 'day';
break;
case 'month':
case 'mois':
case 'period':
case 'periode':
$this->rules[$this->item]['duplicate'] = 'period';
break;
}
}
}
}
/**
*
*/
public function addSqlLogin()
{
$this->sql->where("login IN ('".join("','", $this->login)."')");
}
public function addSqlDate()
{
$formatedDate = substr($this->date,0,4).'-'.substr($this->date,4,2);
if ($this->dateStock === true) {
$this->sql->where("dateSuppr = 0");
} else {
$this->sql->where("dateAjout BETWEEN '".$formatedDate."-01 00:00:00' AND '".$formatedDate."-31 23:59:59'");
}
}
public function addSqlItem()
{
$this->sql->from($this->table, array('COUNT(*) AS NB'));
$rule = $this->rules[$this->item];
//Apply item parameters
/*if ( array_key_exists('params', $rule) && count($rule['params'])>0 ) {
foreach ( $rule['params'] as $param ) {
$this->sql->where($param);
}
}*/
$this->sql->where('source=?', $this->item);
$this->sql->order('dateAjout ASC');
}
}

View File

@ -0,0 +1,373 @@
<?php
class Scores_Courrier_Generate
{
protected $format = 'odt';
protected $path = '';
protected $info = null;
public function __construct($numCommande, $type)
{
$c = Zend_Registry::get('config');
$this->path = realpath($c->profil->path->shared).'/courrier/';
$this->info = new stdClass();
$this->info->ref = $numCommande;
$this->info->refType = $type;
}
public function setInfosCommande()
{
$typeCommande = $this->info->refType;
$id = $this->info->ref;
if ($typeCommande == 'ac') {
$commande = new Application_Model_Sdv1GreffeCommandesAc();
$sql = $commande->select()->where('id = ?', $id);
$result = $commande->fetchRow($sql);
$typeDocument = 'actes';
$gM = new Application_Model_JoGreffesActes();
$sql = $gM->select()
->where('siren=?', $result->siren)
->where('num_depot=?', $result->depotNum)
->where('date_depot=?', $result->depotDate)
->where('num_acte=?', $result->acteNum)
->where('date_acte=?', $result->acteDate)
->where('type_acte=?', $result->acteType);
$document = $gM->fetchRow($sql);
$this->info->libDocument = $document->type_acte_libelle;
$this->info->dateDocument = $result->acteDate;
$this->info->dateDepot = $result->acteType;
} else if ($typeCommande == 'bi') {
$commande = new Application_Model_Sdv1GreffeCommandesBi();
$sql = $commande->select()->where('id = ?', $id);
$result = $commande->fetchRow($sql);
$typeDocument = 'bilans';
$gM = new Application_Model_JoGreffesBilans();
$sql = $gM->select()
->where('siren=?', $result->siren)
->where('date_cloture=?', $result->bilanCloture);
if ( $result->bilanType == 'sociaux' || $result->bilanType == '' ) {
$sql->where("(type_comptes='sociaux' OR type_comptes='')");
} else {
$sql->where('type_comptes=?', $result->bilanType);
}
$sql->order('dateInsert DESC')->order('num_depot DESC')->limit(1);
$document = $gM->fetchRow($sql);
$this->info->libDocument = '';
$this->info->dateDocument = $result->bilanCloture;
} else if ($typeCommande == 'kb') {
$commande = new Application_Model_Sdv1GreffeCommandesKb();
$sql = $commande->select()->where('id = ?', $id);
$result = $commande->fetchRow($sql);
$typeDocument = 'kbis';
if ($result->type == 'M') {
$this->info->type = 'MAIL';
}
}
//Assignation des variables
$this->info->siren = $result->siren;
$this->info->typeDocument = $typeDocument;
}
public function setInfosIdentite()
{
// @todo : How to include old framework
$insee = new Metier_Insee_MInsee();
$reponse = $insee->getIdentiteEntreprise($this->info->siren);
$this->info->commune = $reponse['codeCommune'];
$this->info->dept = $reponse['Dept'];
$this->info->siret = $reponse['Siret'];
$this->info->numRC = $reponse['NumRC'];
//$info->siren = substr($siren, 0, 3).' '.substr($siren, 3, 3).' '.substr($siren, 6, 3);
$this->info->nom = htmlspecialchars_decode($reponse['Nom'], ENT_QUOTES);
$this->info->adresse = htmlspecialchars_decode($reponse['Adresse'], ENT_QUOTES).' ';
if (empty($reponse['Adresse2']) == false) {
$info->adresse .= $reponse['Adresse2'].' ';
}
$this->info->adresse .= "\n".$reponse['CP'].' '.$reponse['Ville'];
}
public function setInfosTribunal()
{
// Adresse du tribunal de commerce
// @todo : How to include old framework
$iBodacc = new Metier_Bodacc_MBodacc();
$reponse = $iBodacc->getTribunauxParCommune($this->info->dept.$this->info->commune);
$tribunalLib = $reponse[0]['triNom'];
if (preg_match('/(A|B|C|D)/i', $this->info->numRC)) {
$libTrib = ' RCS '.
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
} else if (preg_match('/(P)/i', $this->info->numRC)) {
$libTrib = ' RSAC '.
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
}
$this->info->tribunalCode = $reponse[0]['triCode'];
$this->info->libTrib = $libTrib;
$this->info->tribunal->Adr = strtoupper(preg_replace('/ +/',' ',
$reponse[0]['triAdrNum'].' '.
$reponse[0]['triAdrIndRep'].' '.
$reponse[0]['triAdrTypeVoie'].' '.
$reponse[0]['triAdrVoie']));
$this->info->tribunal->AdrComp = strtoupper($reponse[0]['triAdrComp']);
$this->info->tribunal->CP = $reponse[0]['triCP'];
$this->info->tribunal->Ville = strtoupper($reponse[0]['triVille']);
}
public function setTarifs()
{
$tarifs = new Application_Model_Sdv1GreffeTarifs();
$sql = $tarifs->select()->where('codeTribunal = ?', $this->info->tribunalCode)
->where('type = ?', $this->info->typeDocument)
->where('annee = ?', date('Y'));
$result = $tarifs->fetchAll($sql)->toArray();
if (count($result) == 0) {
echo 'Commande '.$this->info->ref.' - Pas de tarifs d&eacute;fini pour le tribunal '.
$this->info->tribunal->Nom.' ('.$this->info->tribunalCode.')';
exit;
}
$this->info->prix = number_format($result[0]['prix'], 2, ',', ' ');
$this->info->enveloppe = $result[0]['enveloppe'];
}
protected function setDestinataire()
{
// Destinataire
$this->info->destinataire = "REGISTRE DU COMMERCE - GREFFE\n".
$this->normaliseVoie(trim($this->info->tribunal->Adr))."\n".
$this->normaliseVoie($this->info->tribunal->AdrComp)."\n".
$this->info->tribunal->CP.' '.$this->info->tribunal->Ville."\n";
}
protected function setSujet()
{
// Type de document demandé (actes ou bilans pour l'instant)
// [un Kbis / l'état d'endettement / la copie de jugement de XXX en date du XXX]
if ($this->info->typeDocument == 'bilans') {
$this->info->sujet = 'une copie du bilan au '.
substr($this->info->dateDocument, 6, 2).'/'.
substr($this->info->dateDocument, 4, 2).'/'.
substr($this->info->dateDocument, 0, 4);
} else if ($this->info->typeDocument == 'actes') {
$this->info->sujet = 'une copie de l\'acte '.$this->info->libDocument;
$this->info->sujet .= ' en date du '.
substr($this->info->dateDocument, 6, 2).'/'.
substr($this->info->dateDocument, 4, 2).'/'.
substr($this->info->dateDocument, 0, 4);
} else if ($this->info->typeDocument == 'kbis') {
$this->info->sujet = 'un extrait RCS';
}
}
protected function setSociete()
{
// Societe
$this->info->societe = $this->info->nom."\n".'( '.$this->info->siren.$this->info->libTrib.' )'."\n";
$this->info->societe .= $this->normaliseVoie($this->info->adresse);
}
protected function setMontant()
{
// Piece jointe et montant
if ($this->info->enveloppe) {
$this->info->montant = 'Ci-joint une enveloppe timbrée ainsi qu\'un '.
'chèque d\'un montant de '.$this->info->prix.
' euros en règlement de cette commande.';
} else {
$this->info->montant = 'Ci-joint un chèque d\'un montant de '.$this->info->prix.
' euros en règlement de cette commande.';
}
}
public function computeOdt()
{
$config = array(
'ZIP_PROXY' => 'PhpZipProxy',
);
$odf = new Odf(__DIR__.'/Model/modeleLettreGreffe.odt', $config);
$this->setInfosCommande();
$this->setInfosIdentite();
$this->setInfosTribunal();
$this->setTarifs();
$this->setDestinataire();
$this->setSujet();
$this->setSociete();
$this->setMontant();
$file = $this->info->siren.'-'.$this->info->ref.'.odt';
$odf->setVars('destinataire', $this->info->destinataire, true, 'UTF-8');
$odf->setVars('date', date('d/m/Y'), true, 'UTF-8');
$odf->setVars('ref', $this->info->ref, true, 'UTF-8');
$odf->setVars('sujet', $this->info->sujet, true, 'UTF-8');
$odf->setVars('societe', $this->info->societe, true, 'UTF-8');
$odf->setVars('montant', $this->info->montant, true, 'UTF-8');
if ($this->info->type == 'MAIL') {
$odf->setVars('bymail',"ou à votre convenance par mail à : support@scores-decisions.com", true, 'UTF-8');
}
$odf->saveToDisk($this->path.$file);
if (file_exists($this->path.$file) == true) {
header('Content-Transfer-Encoding: none');
header('Content-type: application/vnd.oasis.opendocument.text');
header('Content-Length: '.filesize($this->path.$file));
header('Content-MD5: '.base64_encode(md5_file($this->path.$file)));
header('Content-Disposition:attachment; filename="'.$file.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($this->path.$file);
} else {
echo 'Erreur Génération du fichier';
}
}
public function computePdf()
{
$this->setInfosCommande();
$this->setInfosIdentite();
$this->setInfosTribunal();
$this->setTarifs();
$this->setDestinataire();
$this->setSujet();
$this->setSociete();
$this->setMontant();
// initiate PDF
$pdf = new Scores_Courrier_Pdf();
/*
* Définition des marges
* Left, Top et Right
* Dimension du logo d'entete :
**/
$pdf->SetMargins(25, 50, 25);
$border = 0;
// add a page
$pdf->AddPage();
$pdf->SetFont("times", "", 10);
//Position de départ
$pdf->SetY(50);
//Bloc Addresse destinataire
$largeur = 80;
$positionX = 105;
$pdf->MultiCell($largeur, 5, $this->info->destinataire, $border, 'L', 0, 1, $positionX);
//Bloc Lieu, date
$date = date('d/m/Y');
$txt = "Rambouillet, le $date";
$positionY = $pdf->GetY()+5;
$pdf->MultiCell($largeur, 5, $txt, $border, 'L', 0, 1, $positionX, $positionY);
//Bloc objet
$positionY = $pdf->GetY()+5;
$pdf->MultiCell(20, 5, "Objet:", $border, 'L', 0, 0, '', $positionY, true);
$pdf->MultiCell(0, 5, "Commande de document", $border, 'L', 0, 1, '', '', true);
//Bloc ref
$pdf->MultiCell(20, 5, "Réf.", $border, 'L', 0, 0, '', '', true);
$pdf->MultiCell(0, 5, $this->info->ref, $border, 'L', 0, 1, '', '', true);;
//Bloc titre
$positionY = $pdf->GetY()+5;
$pdf->MultiCell(0, 5, "Madame, Monsieur,", $border, 'L', 0, 1, '', $positionY, true);
//Type de document demandé (actes ou bilans pour l'instant)
//[un Kbis / l'état d'endettement / la copie de jugement de XXX en date du XXX ]
$positionY = $pdf->GetY()+2;
$pdf->MultiCell(0, 5, "Nous vous prions de nous faire parvenir $this->info->sujet concernant la société:", $border, 'L', 0, 1, '', $positionY, true);
//Bloc société
$positionY = $pdf->GetY()+2;
$pdf->MultiCell(0, 5, $this->info->societe, $border, 'L', 0, 1, '', $positionY, true);
//Bloc pièce jointe
$positionY = $pdf->GetY()+5;
$pdf->MultiCell(0, 5, $this->info->montant, $border, 'L', 0, 1, '', $positionY, true);
//Bloc intitulé adresse reception
$positionY = $pdf->GetY()+2;
$pdf->MultiCell(0, 5,
"Veuillez nous renvoyer le(s) document(s) par retour à l'adresse suivante:",
$border, 'L', 0, 1, '', $positionY, true);
//Bloc adresse s&d
$positionY = '';
$pdf->MultiCell(0, 5,
"SCORES ET DECISIONS" . "\n" .
"19 rue Clairefontaine". "\n" .
"78120 RAMBOUILLET" . "\n"
, $border, 'L', 0, 1, '', $positionY, true);
if ($this->info->type == 'MAIL') {
$positionY = $pdf->GetY()+2;
$pdf->MultiCell(0, 5,
"ou à votre convenance par mail à : support@scores-decisions.com",
$border, 'L', 0, 1, '', $positionY, true);
}
//Bloc formule politesse
$positionY = $pdf->GetY()+2;
$pdf->MultiCell(0, 5, "Dans l'attente de notre prochain échange, nous vous prions de recevoir, Madame, Monsieur, l'expression de nos plus sincères salutations.", $border, 'L', 0, 1, '', $positionY, true);
$file = $this->info->siren.'-'.$this->info->ref.'.pdf';
$pdf->Output($this->path.$file, 'F');
if(file_exists($path.$file))
{
$content_type = 'application/pdf';
header('Content-Transfer-Encoding: none');
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($this->path.$file));
header('Content-MD5: '.base64_encode(md5_file($this->path.$file)));
header('Content-Disposition: attachment, filename="'.$file.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($this->path.$file);
}
}
protected function normaliseVoie($txt)
{
$replace_pairs = array(
'BD ' => 'BOULEVARD ',
'BVD ' => 'BOULEVARD ',
'AV ' => 'AVENUE ',
'AVE ' => 'AVENUE ',
'PL ' => 'PLACE ',
'PLA ' => 'PLACE ',
'PLAC ' => 'PLACE ',
'ESP ' => 'ESP ',
'RTE ' => 'ROUTE ',
'ST ' => 'SAINT ',
'STE ' => 'SAINTE ',
'QU ' => 'QUAI '
);
return strtr($txt, $replace_pairs);
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,22 @@
<?php
class Scores_Courrier_Pdf extends FPDI {
/**
* "Remembers" the template id of the imported page
*/
var $_tplIdx;
/**
* include a background template for every page
*/
function Header() {
if (is_null($this->_tplIdx)) {
$file = __DIR__.'/Model/modele.pdf';
$this->setSourceFile($file);
$this->_tplIdx = $this->importPage(1);
}
$this->useTemplate($this->_tplIdx);
}
function Footer() {
}
}

680
src/Scores/Extract/Dict.php Normal file
View File

@ -0,0 +1,680 @@
<?php
class Scores_Extract_Dict
{
//Traiter la demande en créant les requetes sql nécessaires
protected $tabDico = array(
'idSd' => array(
'lib' => "SD : Identifiant - Etablissement",
'help' => "Identifiant interne propre à SD, usage restreint",
'columns' => array(
'id' => 'Identifiant Interne',
)
),
'source' => array(
'lib' => "SD : Source"
//@todo : Yoann
),
'triCode' => array(
'lib' => "?? : Code BODACC du Tribunal - Etablissement",
'help' => "Code BODACC du tribunal, voir la table jo.tribunaux (à confirmer, sortir triNom)
<br/>Entreprise exclusivement INSEE pas de code tribunal",
'columns' => array(
'triCode' => ''
)
),
'autre_id' => array(
'lib' => "Autre ID (SIREN ou WALDEC)",
'help' => "Doublon SIREN (source RNCS) ou WALDEC (source JOAFE) si association",
'columns' => array(
'autre_id' => "Autre ID (SIREN ou WALDEC)",
),
),
'actif' => array(
'lib' => 'SD : ACTIF',
//@todo : Yoann
),
'siege' => array(
'lib' => "SD : Siège ou Etablissement",
'help' => "Valeur : 0 les établissements Secondaires (source INSEE),
1 l'établissement Siège de l'entreprise (source INSEE) ;
2 notion RNCS désignant l'établissement Principal qui n'est pas obligatoirement le siège
http://www.greffe-tc-caen.fr/rcs_etabs.php",
),
'raisonSociale' => array(
'lib' => "SD : Raison Sociale",
'help' => "Regle de composition de la donnée"
),
'enseigne' => array(
'lib' => "SD : Enseigne",
'help' => "Regle de composition de la donnée"
),
'sigle' => array(
'lib' => "SD : Sigle",
'help' => "Regle de composition de la donnée"
),
'marques' => array(
'lib' => "SD : Marques déposées",
'help' => "Chaine de caractère assemblé - Regle de composition de la donnée"
),
'adr_num' => array(
'lib' => "SD : Adresse Numéro dans la voie - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_btq' => array(
'lib' => "SD : Adresse Bis/Ter/etc.. - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_typeVoie' => array(
'lib' => "SD : Adresse Type de voie - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_libVoie' => array(
'lib' => "SD : Adresse Libellé de la voie - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_comp' => array(
'lib' => "SD : Adresse Complément - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_cp' => array(
'lib' => "SD : Adresse Code Postal - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_ville' => array(
'lib' => "SD : Adresse Ville - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_dep' => array(
'lib' => "SD : Adresse Département - Etablissement",
'help' => "Regle de composition de la donnée"
),
'adr_codeCom' => array(
'lib' => "SD : Adresse Code Commune étab - Etablissement",
'help' => "Regle de composition de la donnée"
),
'telEtab' => array(
'lib' => "Téléphone"
),
'faxEtab' => array(
'lib' => "Télécopie"
),
'cj' => array(
'lib' => "Forme juridique"
),
'capital' => array(
'lib' => "Capital"
),
'capitalDev' => array(
'lib' => "Devise du capital"
),
'ape_etab' => array(
'lib' => "SD : NAF Etablissement",
'help' => "Code NAF 5 positions",
'columns' => array(
'ape_etab' => "SD : NAF Etablissement",
),
),
'ape_entrep' => array(
'lib' => "SD : NAF Entreprise",
'help' => "Code NAF 5 positions",
'columns' => array(
'ape_entrep' => "SD : NAF Entreprise",
),
),
'NaceEtab' => array(
'lib' => "SD : NACE Etablissement",
'help' => "",
'columns' => array(
'NaceEtab' => "SD : NACE Etablissement",
'NaceEtabLib' => "SD : NACE Etablissement",
),
),
'NaceEn' => array(
'lib' => "SD : NACE Entreprise",
'help' => "",
'columns' => array(
'NaceEn' => "SD : NACE Entreprise",
'NaceEnLib' => "SD : NACE Entreprise",
),
),
'SiretEnBase' => array(
'lib' => "Vérifier la présence en base du siren/siret"
),
'etActifInsee' => array(
'lib' => "Insee : Actif"
),
'nomInsee' => array(
'lib' => 'Insee : Raison Sociale'
),
'nomInsee2' => array(
'lib' => 'Insee : Raison Sociale (suite)'
),
'sigleInsee' => array(
'lib' => 'Insee : Sigle'
),
'enseigneInsee' => array(
'lib' => 'Insee : Enseigne'
),
'adrNumVoieInsee' => array(
'lib' => 'Insee : Adresse - Numéro dans la voie'
),
'adrBtqInsee' => array(
'lib' => 'Insee : Adresse - Bis/Ter/etc'
),
'adrTypeVoieInsee' => array(
'lib' => 'Insee : Adresse - Type de voie'
),
'adrVoieInsee' => array(
'lib' => 'Insee : Adresse - Libellé de la voie'
),
'adrCompInsee' => array(
'lib' => 'Insee : Adresse - Complément'
),
'adrCPInsee' => array(
'lib' => 'Insee : Adresse - Code Postal'
),
'adrVilleInsee' => array(
'lib' => 'Insee : Adresse - Commune'
),
'adrDistSPInsee' => array(
'lib' => 'Insee : Adresse - Distribution spéciale'
),
'CjInsee' => array(
'lib' => "Insee : Forme juridique de l'entreprise"
),
'nafEnInsee' => array(
'lib' => "Insee : NAF de l'entreprise"
),
'nafEtInsee' => array(
'lib' => "Insee : NAF de l'etablissement"
),
'APRM' => array(
'lib' => "Insee : APRM"
),
'ACTIVNAT' => array(
'lib' => "Insee : ACTIVNAT"
),
'ORIGINE' => array(
'lib' => "Insee : Origine de création de l'établissement"
),
'MODET' => array(
'lib' => "Insee : MODET"
),
'EXPLET' => array(
'lib' => 'Insee : EXPLET'
),
'LIEUACT' => array(
'lib' => "Insee : LIEUACT"
),
'ACTISURF' => array(
'lib' => "Insee : ACTISURF"
),
'DEFET' => array(
'lib' => "Insee : Année MAJ de l'effectif de l'établissement"
),
'MODEN' => array(
'lib' => "Insee : MODEN"
),
'PRODPART' => array(
'lib' => "Insee : PRODPART"
),
'EXPLEN' => array(
'lib' => "Insee : EXPLEN"
),
'DEFEN' => array(
'lib' => "Insee : Année MAJ de l'effectif de l'entreprise"
),
'MONOREG' => array(
'lib' => "Insee : Mono-régionalité"
),
'REGIMP' => array(
'lib' => "Insee : Principale région d'implantation"
),
'MONOACT' => array(
'lib' => "Insee : Mono-activité"
),
'DCREN' => array(
'lib' => "Insee : Date de création de l'entreprise"
),
'SIEGE' => array(
'lib' => "Insee : Siege",
'help' => "Qualité de siege ou non de l'établissement",
'columns' => array(
'SIEGE' => 'Insee : Siege',
)
),
'AUXILT' => array(
'lib' => "Insee : Auxiliarité"
),
'SAISONAT' => array(
'lib' => "Insee : Saisonalité"
),
'CIVILITE' => array(
'lib' => "Insee : Civilité"
),
'TCA' => array(
'lib' => "Insee : Tranche de chiffre d'affaire"
),
'TCAEXP' => array(
'lib' => "Insee : Tranche de chiffre d'affaire à l'export"
),
'EFF_ENT' => array(
'lib' => "Insee : Effectif de l'entreprise"
),
'DCRET' => array(
'lib' => "Insee : Date de création de l'établissement"
),
'TEFF_ENT' => array(
'lib' => "Insee : Tranche effectif entreprise",
),
'ADR_DEP' => array(
'lib' => "Insee : Adresse - Département",
'help' => "Département de localisation de l'établissement (2 caractères)",
'columns'=> array(
'ADR_DEP' => 'Insee : Departement',
),
),
'ADR_COM' => array(
'lib' => "Insee : Commune de localisation de l'établissement",
'help' => "(3 chiffres)",
'columns' => array(
'ADR_COM' => "Insee : Code commune",
),
),
'EFF_ET' => array(
'lib' => "Insee : Effectif de l'établissement"
),
'TEFF_ET' => array(
'lib' => "Insee : Tranche effectif etablissement",
),
'CODEVOIE' => array(
'lib' => "Insee : Code voie",
'help' => "Code Rivoli / Ex Fantoir",
),
'dateMajInsee' => array(
'lib' => "Insee : Date de la dernière mise à jour"
),
'insRPET' => array(
'lib' => "Insee : RPET"
),
'insDEPCOMEN' => array(
'lib' => "Insee : Code commune siège"
),
'insRPEN' => array(
'lib' => "Insee : RPEN"
),
'insARRONET' => array(
'lib' => "Insee : Arrondissement de l'établissement"
),
'insCTONET' => array(
'lib' => "Insee : Canton de l'établissement"
),
'insTCD' => array(
'lib' => "Insee : Tranche de commune détaillé"
),
'insZEMET' => array(
'lib' => "Insee : ZEMET"
),
'insDU' => array(
'lib' => "Insee : DU"
),
'insTU' => array(
'lib' => "Insee : TU"
),
'insUU' => array(
'lib' => "Insee : UU"
),
'insMMINTRET' => array(
'lib' => "Insee : MMINTRET",
),
'insMMINTREN' => array(
'lib' => "Insee : MMINTREN",
),
'insRECME' => array(
'lib' => "Insee : RCEM"
),
'insEAEANT' => array(
'lib' => "Insee : EAEANT"
),
'insEAEAPET' => array(
'lib' => "Insee : EAEAPET"
),
'insEAESEC1T' => array(
'lib' => "Insee : EAESEC1T"
),
'insEAESEC2T' => array(
'lib' => "Insee : EAESEC2T"
),
'insEAEANN' => array(
'lib' => "Insee : EAEANN"
),
'insEAEAPEN' => array(
'lib' => "Insee : EAEAPEN"
),
'insEAESEC1N' => array(
'lib' => "Insee : EAESEC1N"
),
'insEAESEC2N' => array(
'lib' => "Insee : EAESEC2N"
),
'insEAESEC3N' => array(
'lib' => "Insee : EAESEC3N"
),
'insEAESEC4N' => array(
'lib' => "Insee : EAESEC4N"
),
'dateMajNotice' => array(
'lib' => "Insee : Date de la dernière MAJ notice"
),
'NBETEXPL' => array(
'lib' => "Insee : Nombre d'établissement exploitant actif"
),
'entActiveRncs' => array(
'lib' => "RNCS : Actif - Entreprise"
),
'numRC2' => array(
'lib' => "RNCS : Numéro RC"
),
'raisonSocialeRncs' => array(
'lib' => "RNCS : Raison Sociale"
),
'sigleRncs' => array(
'lib' => "RNCS : Sigle"
),
'dateNaiss' => array(
'lib' => "RNCS : Date Naissance PP"
),
'lieuNaiss' => array(
'lib' => "RNCS : Lieu Naissance PP"
),
'nationalite' => array(
'lib' => "RNCS : Nationalité PP"
),
'pays' => array(
'lib' => "RNCS : Pays"
),
'nafEnRncs' => array(
'lib' => "RNCS : NAF Entrepise"
),
'cjRncs' => array(
'lib' => "RNCS : Forme juridique"
),
'dateImma' => array(
'lib' => "RNCS : Date Immatriculation"
),
'dateRad' => array(
'lib' => "RNCS : Date de radiation"
),
'capitalType' => array(
'lib' => "RNCS : Type de capital"
),
'dateMajEnRncs' => array(
'lib' => "RNCS : Date MAJ Entreprise"
),
'etActifRncs' => array(
'lib' => "RNCS : Actif"
),
'siegeRncs' => array(
'lib' => "RNCS : Siège"
),
'enseigneRncs' => array(
'lib' => "RNCS : Enseigne"
),
'nomCommercialRncs' => array(
'lib' => "RNCS : Nom Commercial"
),
'adrNumVoieRncs' => array(
'lib' => "RNCS : Numéro"
),
'adrIndRepRncs' => array(
'lib' => "RNCS : Adresse - Numéro"
),
'adrLibVoieRncs' => array(
'lib' => "RNCS : Adresse - Bis/Ter/etc"
),
'adrTypeVoieRncs' => array(
'lib' => "RNCS : Adresse - Type de la voie"
),
'adrVoieRncs' => array(
'lib' => "RNCS : Adresse - Libellé de la voie"
),
'cpRncs' => array(
'lib' => "RNCS : Adresse - Code postal"
),
'villeRncs' => array(
'lib' => "RNCS : Adresse - Ville"
),
'adrCompRncs' => array(
'lib' => "RNCS : Adresse - Complément"
),
'nafEtRncs' => array(
'lib' => "RNCS : NAF Etablissement"
),
'dateMajEtRncs' => array(
'lib' => "RNCS : Date MAJ établissement"
),
'isin' => array(
'lib' => "Code ISIN (société en bourse)"
),
'tel' => array(
),
'fax' => array(),
'web' => array(),
'mail' => array(),
'nicSiege'=> array(
'lib' => "NIC du siège (si nic absent)"
),
'tva'=> array(
'lib' => "Numéro de TVA (non validés)"
),
'dateFermetureEn'=> array(),
'dateFermetureEt'=> array(),
'activite'=> array(),
'situationJuridique'=> array(),
'indiScore'=> array(
'lib' => 'SD : indiScore',
),
'AdresseNormalise' => array(
'lib' => 'AdresseNormalise',
'columns' => array(
'AdresseL1_NOM' => '',
'AdresseL2_NOM2' => '',
'AdresseL3_ADRCOMP' => '',
'AdresseL4_VOIE' => '',
'AdresseL5_DISTSP' => '',
'AdresseL6_POST' => '',
'AdresseL7_PAYS' => '',
),
),
'AdresseNormaliseInsee' => array(
'lib' => 'AdresseNormaliseInsee',
'columns' => array(
'L1_NOM' => 'L1_NOMEN',
'L2_NOM2' => 'L2_COMP',
'L3_ADRCOMP' => 'L3_CADR',
'L4_VOIE' => 'L4_VOIE',
'L5_DISTSP' => 'L5_DISP',
'L6_POST' => 'L6_POST',
'L7_PAYS' => 'L7_ETRG',
),
),
'SiretSuc' => array(
'lib' => 'INSEE : Siret Successeur',
'help' => "",
'columns' => array(
'SiretSuc' => '',
'SiretSucNbDem' => '',
'SiretSucSiege' => '',
'SiretSucActif' => '',
'SiretSucCodeEve' => '',
'SiretSucDateEve' => '',
'SiretSucOrigine' => '',
)
),
'dirigeant'=> array(),
'bilanN'=> array('values'=>''),
'bilanN1'=> array('values'=>''),
'bilanN2'=> array('values'=>''),
'annonces'=> array('values'=>''),
'privilege' => array(),
'GPS' => array(
'lib' => 'SD : Coordonnées GPS - Etablissement',
'help' => "",
'columns' => array(
'latitude' => "Latitude en degrés et décimales de degrés",
'longitude' => "Longitude en degrés et décimales de degrés",
'altitude' => "Altitude en mètres",
'precis' => "Précision du géocodage (de 0=non géocodé à 8/9=géocodage à l'adresse)",
)
),
'TelOrder' => array(
'lib' => 'Telephone priorisé',
'help' => "",
'columns' => array()
),
'LienHead' => array(
'lib' => 'Tête de lien financier',
'help' => "",
'columns' => array()
),
'LienHeadUltimate' => array(
'lib' => 'Tête de lien ultime',
'help' => "",
'columns' => array()
),
'ZonePrioritaire' => array(
'lib' => 'Zone Prioritaire',
'help' => "",
'columns' => array()
),
'AdresseDom'=> array(
'lib' => 'AdresseDom',
'help' => "",
'columns' => array()
),
'Iris'=> array(
'lib' => 'Iris',
'help' => "",
'columns' => array()
),
);
public function __construct()
{
}
//Vérifie que les entêtes du fichier sont correct
public function checkFileEntete($pathFile)
{
$posKeySiren = $posKeySiret = $posKeyNic = false;
$row = 0;
$error = array();
if (($handle = fopen($pathFile, 'r')) !== false) {
while (($data = fgetcsv($handle, 0, ',', '"')) !== false) {
$num = count($data);
//Traitement de la première ligne
if ($row == 0) {
for ($c=0; $c < $num; $c++) {
//Détection clé importante
switch (strtolower($data[$c])) {
case 'siren':
$posKeySiren = $c;
break;
case 'nic':
$posKeyNic = $c;
break;
case 'siret':
$posKeySiret = $c;
break;
case 'ref':
//Clé réference
break;
default:
//Détection clé pour enrichissement
$values = false;
if (preg_match('/(.*)\((.*)\)/', $key, $matches)) {
$key = $matches[1];
$values = $matches[2];
} else {
$key = $data[$c];
}
if (!array_key_exists($key, $this->tabDico)) {
$error[] = "Clé enrichissement $key incorrect";
}
break;
}
}
if ($posKeySiren!==false && $posKeyNic!==false && $posKeySiret!==false || $posKeySiren!==false && $posKeySiret!==false) {
$error[] = "Trop de clé!";
}
if ($posKeySiren===false && $posKeySiret===false) {
$error[] = "Aucune clé détecté!";
}
} else {
//Erreur dans les entetes, on arrete
if (count($error)>0) {
break;
}
}
$row++;
}
fclose($handle);
if (count($error)>0) {
return $error;
}
return $row-1;
}
return false;
}
//Retourne les clés de dictionnaire pour les données d'enrichissement
public function getDico()
{
return $this->tabDico;
}
//Retourne le libellé pour chaque clés du dictionnaire
public function getDicoLib($key)
{
//Si () alors traitement champs spécial
if (preg_match('/(.*)\((.*)\)/', $key, $matches)) {
$key = $matches[1];
}
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('lib', $element) && !empty($element['lib'])) {
return $element['lib'];
}
return $key;
}
return false;
}
//Retourne le texte d'aide
public function getDicoHelp($key)
{
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('help', $element) && !empty($element['help'])) {
return $element['help'];
}
return '';
}
return false;
}
//Retourne les colonnes de sortie
public function getDicoColumns($key)
{
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('columns', $element)) {
return $element['columns'];
}
return array();
}
return false;
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Miscellaneous functions to clean string.
*/
class Scores_Locale_String
{
/**
* Clean up a string value.
*
* Resulting string contains only alphanumerics and separators.
*
* @param $string
* A string to clean.
* @param $clean_slash
* Whether to clean slashes from the given string.
* @return
* The cleaned string.
*/
public static function cleanstring($string)
{
$transliterate = true;
$reduce_ascii = false;
$output = $string;
// Remove accents and transliterate
if ($transliterate) {
static $i18n_loaded = false;
static $translations = array();
if (!$i18n_loaded) {
$path = realpath(dirname(__FILE__));
if (is_file($path .'/i18n-ascii.txt')) {
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
}
$i18n_loaded = true;
}
$output = strtr($output, $translations);
}
// Reduce to the subset of ASCII96 letters and numbers
if ($reduce_ascii) {
$pattern = '/[^a-zA-Z0-9\/]+/ ';
$output = preg_replace($pattern, $separator, $output);
}
return $output;
}
public static function cleanutf8($string)
{
$transliterate = true;
$output = $string;
// Remove accents and transliterate
if ($transliterate) {
static $i18n_loaded = false;
static $translations = array();
if (!$i18n_loaded) {
$path = realpath(dirname(__FILE__));
if (is_file($path .'/i18n-ascii.txt')) {
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
}
$i18n_loaded = true;
}
$output = strtr($output, $translations);
}
return $output;
}
// Fixes the encoding to uf8
public static function fixEncoding($in_str)
{
$cur_encoding = mb_detect_encoding($in_str) ;
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) {
return $in_str;
} else {
return utf8_encode($in_str);
}
} // fixEncoding
public static function cleanstring_deep($value)
{
$value = is_array($value) ?
array_map('self::cleanstring_deep', $value) :
cleanstring($value);
return $value;
}
}

View File

@ -0,0 +1,564 @@
; global transliteration
[default]
À = "A"
Á = "A"
 = "A"
à = "A"
Ä = "Ae"
Å = "A"
Æ = "A"
Ā = "A"
Ą = "A"
Ă = "A"
Ç = "C"
Ć = "C"
Č = "C"
Ĉ = "C"
Ċ = "C"
Ď = "D"
Đ = "D"
È = "E"
É = "E"
Ê = "E"
Ë = "E"
Ē = "E"
Ę = "E"
Ě = "E"
Ĕ = "E"
Ė = "E"
Ĝ = "G"
Ğ = "G"
Ġ = "G"
Ģ = "G"
Ĥ = "H"
Ħ = "H"
Ì = "I"
Í = "I"
Î = "I"
Ï = "I"
Ī = "I"
Ĩ = "I"
Ĭ = "I"
Į = "I"
İ = "I"
IJ = "IJ"
Ĵ = "J"
Ķ = "K"
Ľ = "K"
Ĺ = "K"
Ļ = "K"
Ŀ = "K"
Ł = "L"
Ñ = "N"
Ń = "N"
Ň = "N"
Ņ = "N"
Ŋ = "N"
Ò = "O"
Ó = "O"
Ô = "O"
Õ = "O"
Ö = "Oe"
Ø = "O"
Ō = "O"
Ő = "O"
Ŏ = "O"
Œ = "OE"
Ŕ = "R"
Ř = "R"
Ŗ = "R"
Ś = "S"
Ş = "S"
Ŝ = "S"
Ș = "S"
Š = "S"
Ť = "T"
Ţ = "T"
Ŧ = "T"
Ț = "T"
Ù = "U"
Ú = "U"
Û = "U"
Ü = "Ue"
Ū = "U"
Ů = "U"
Ű = "U"
Ŭ = "U"
Ũ = "U"
Ų = "U"
Ŵ = "W"
Ŷ = "Y"
Ÿ = "Y"
Ý = "Y"
Ź = "Z"
Ż = "Z"
Ž = "Z"
à = "a"
á = "a"
â = "a"
ã = "a"
ä = "ae"
ā = "a"
ą = "a"
ă = "a"
å = "a"
æ = "ae"
ç = "c"
ć = "c"
č = "c"
ĉ = "c"
ċ = "c"
ď = "d"
đ = "d"
è = "e"
é = "e"
ê = "e"
ë = "e"
ē = "e"
ę = "e"
ě = "e"
ĕ = "e"
ė = "e"
ƒ = "f"
ĝ = "g"
ğ = "g"
ġ = "g"
ģ = "g"
ĥ = "h"
ħ = "h"
ì = "i"
í = "i"
î = "i"
ï = "i"
ī = "i"
ĩ = "i"
ĭ = "i"
į = "i"
ı = "i"
ij = "ij"
ĵ = "j"
ķ = "k"
ĸ = "k"
ł = "l"
ľ = "l"
ĺ = "l"
ļ = "l"
ŀ = "l"
ñ = "n"
ń = "n"
ň = "n"
ņ = "n"
ʼn = "n"
ŋ = "n"
ò = "o"
ó = "o"
ô = "o"
õ = "o"
ö = "oe"
ø = "o"
ō = "o"
ő = "o"
ŏ = "o"
œ = "oe"
ŕ = "r"
ř = "r"
ŗ = "r"
ś = "s"
š = "s"
ş = "s"
ť = "t"
ţ = "t"
ù = "u"
ú = "u"
û = "u"
ü = "ue"
ū = "u"
ů = "u"
ű = "u"
ŭ = "u"
ũ = "u"
ų = "u"
ŵ = "w"
ÿ = "y"
ý = "y"
ŷ = "y"
ż = "z"
ź = "z"
ž = "z"
ß = "ss"
ſ = "ss"
Α = "A"
Ά = "A"
Ἀ = "A"
Ἁ = "A"
Ἂ = "A"
Ἃ = "A"
Ἄ = "A"
Ἅ = "A"
Ἆ = "A"
Ἇ = "A"
ᾈ = "A"
ᾉ = "A"
ᾊ = "A"
ᾋ = "A"
ᾌ = "A"
ᾍ = "A"
ᾎ = "A"
ᾏ = "A"
Ᾰ = "A"
Ᾱ = "A"
Ὰ = "A"
Ά = "A"
ᾼ = "A"
Β = "B"
Γ = "G"
Δ = "D"
Ε = "E"
Έ = "E"
Ἐ = "E"
Ἑ = "E"
Ἒ = "E"
Ἓ = "E"
Ἔ = "E"
Ἕ = "E"
Έ = "E"
Ὲ = "E"
Ζ = "Z"
Η = "I"
Ή = "I"
Ἠ = "I"
Ἡ = "I"
Ἢ = "I"
Ἣ = "I"
Ἤ = "I"
Ἥ = "I"
Ἦ = "I"
Ἧ = "I"
ᾘ = "I"
ᾙ = "I"
ᾚ = "I"
ᾛ = "I"
ᾜ = "I"
ᾝ = "I"
ᾞ = "I"
ᾟ = "I"
Ὴ = "I"
Ή = "I"
ῌ = "I"
Θ = "TH"
Ι = "I"
Ί = "I"
Ϊ = "I"
Ἰ = "I"
Ἱ = "I"
Ἲ = "I"
Ἳ = "I"
Ἴ = "I"
Ἵ = "I"
Ἶ = "I"
Ἷ = "I"
Ῐ = "I"
Ῑ = "I"
Ὶ = "I"
Ί = "I"
Κ = "K"
Λ = "L"
Μ = "M"
Ν = "N"
Ξ = "KS"
Ο = "O"
Ό = "O"
Ὀ = "O"
Ὁ = "O"
Ὂ = "O"
Ὃ = "O"
Ὄ = "O"
Ὅ = "O"
Ὸ = "O"
Ό = "O"
Π = "P"
Ρ = "R"
Ῥ = "R"
Σ = "S"
Τ = "T"
Υ = "Y"
Ύ = "Y"
Ϋ = "Y"
Ὑ = "Y"
Ὓ = "Y"
Ὕ = "Y"
Ὗ = "Y"
Ῠ = "Y"
Ῡ = "Y"
Ὺ = "Y"
Ύ = "Y"
Φ = "F"
Χ = "X"
Ψ = "PS"
Ω = "O"
Ώ = "O"
Ὠ = "O"
Ὡ = "O"
Ὢ = "O"
Ὣ = "O"
Ὤ = "O"
Ὥ = "O"
Ὦ = "O"
Ὧ = "O"
ᾨ = "O"
ᾩ = "O"
ᾪ = "O"
ᾫ = "O"
ᾬ = "O"
ᾭ = "O"
ᾮ = "O"
ᾯ = "O"
Ὼ = "O"
Ώ = "O"
ῼ = "O"
α = "a"
ά = "a"
ἀ = "a"
ἁ = "a"
ἂ = "a"
ἃ = "a"
ἄ = "a"
ἅ = "a"
ἆ = "a"
ἇ = "a"
ᾀ = "a"
ᾁ = "a"
ᾂ = "a"
ᾃ = "a"
ᾄ = "a"
ᾅ = "a"
ᾆ = "a"
ᾇ = "a"
ὰ = "a"
ά = "a"
ᾰ = "a"
ᾱ = "a"
ᾲ = "a"
ᾳ = "a"
ᾴ = "a"
ᾶ = "a"
ᾷ = "a"
β = "b"
γ = "g"
δ = "d"
ε = "e"
έ = "e"
ἐ = "e"
ἑ = "e"
ἒ = "e"
ἓ = "e"
ἔ = "e"
ἕ = "e"
ὲ = "e"
έ = "e"
ζ = "z"
η = "i"
ή = "i"
ἠ = "i"
ἡ = "i"
ἢ = "i"
ἣ = "i"
ἤ = "i"
ἥ = "i"
ἦ = "i"
ἧ = "i"
ᾐ = "i"
ᾑ = "i"
ᾒ = "i"
ᾓ = "i"
ᾔ = "i"
ᾕ = "i"
ᾖ = "i"
ᾗ = "i"
ὴ = "i"
ή = "i"
ῂ = "i"
ῃ = "i"
ῄ = "i"
ῆ = "i"
ῇ = "i"
θ = "th"
ι = "i"
ί = "i"
ϊ = "i"
ΐ = "i"
ἰ = "i"
ἱ = "i"
ἲ = "i"
ἳ = "i"
ἴ = "i"
ἵ = "i"
ἶ = "i"
ἷ = "i"
ὶ = "i"
ί = "i"
ῐ = "i"
ῑ = "i"
ῒ = "i"
ΐ = "i"
ῖ = "i"
ῗ = "i"
κ = "k"
λ = "l"
μ = "m"
ν = "n"
ξ = "ks"
ο = "o"
ό = "o"
ὀ = "o"
ὁ = "o"
ὂ = "o"
ὃ = "o"
ὄ = "o"
ὅ = "o"
ὸ = "o"
ό = "o"
π = "p"
ρ = "r"
ῤ = "r"
ῥ = "r"
σ = "s"
ς = "s"
τ = "t"
υ = "y"
ύ = "y"
ϋ = "y"
ΰ = "y"
ὐ = "y"
ὑ = "y"
ὒ = "y"
ὓ = "y"
ὔ = "y"
ὕ = "y"
ὖ = "y"
ὗ = "y"
ὺ = "y"
ύ = "y"
ῠ = "y"
ῡ = "y"
ῢ = "y"
ΰ = "y"
ῦ = "y"
ῧ = "y"
φ = "f"
χ = "x"
ψ = "ps"
ω = "o"
ώ = "o"
ὠ = "o"
ὡ = "o"
ὢ = "o"
ὣ = "o"
ὤ = "o"
ὥ = "o"
ὦ = "o"
ὧ = "o"
ᾠ = "o"
ᾡ = "o"
ᾢ = "o"
ᾣ = "o"
ᾤ = "o"
ᾥ = "o"
ᾦ = "o"
ᾧ = "o"
ὼ = "o"
ώ = "o"
ῲ = "o"
ῳ = "o"
ῴ = "o"
ῶ = "o"
ῷ = "o"
¨ = ""
΅ = ""
᾿ = ""
= ""
῍ = ""
῝ = ""
῎ = ""
῞ = ""
῏ = ""
῟ = ""
= ""
῁ = ""
΄ = ""
΅ = ""
= ""
῭ = ""
ͺ = ""
= ""
А = "A"
Б = "B"
В = "V"
Г = "G"
Д = "D"
Е = "E"
Ё = "E"
Ж = "ZH"
З = "Z"
И = "I"
Й = "I"
К = "K"
Л = "L"
М = "M"
Н = "N"
О = "O"
П = "P"
Р = "R"
С = "S"
Т = "T"
У = "U"
Ф = "F"
Х = "KH"
Ц = "TS"
Ч = "CH"
Ш = "SH"
Щ = "SHCH"
Ы = "Y"
Э = "E"
Ю = "YU"
Я = "YA"
а = "A"
б = "B"
в = "V"
г = "G"
д = "D"
е = "E"
ё = "E"
ж = "ZH"
з = "Z"
и = "I"
й = "I"
к = "K"
л = "L"
м = "M"
н = "N"
о = "O"
п = "P"
р = "R"
с = "S"
т = "T"
у = "U"
ф = "F"
х = "KH"
ц = "TS"
ч = "CH"
ш = "SH"
щ = "SHCH"
ы = "Y"
э = "E"
ю = "YU"
я = "YA"
Ъ = ""
ъ = ""
Ь = ""
ь = ""
ð = "d"
Ð = "D"
þ = "th"
Þ = "TH"

View File

@ -0,0 +1,2 @@
[default]
№ = "N°"

66
src/Scores/Logger/Sql.php Normal file
View File

@ -0,0 +1,66 @@
<?php
use Doctrine\DBAL\Logging\SQLLogger;
class Scores_Logger_Sql implements SQLLogger
{
/**
* Executed SQL queries.
*
* @var array
*/
public $query = array();
/**
* If Debug Stack is enabled (log queries) or not.
*
* @var boolean
*/
public $enabled = true;
/**
* @var float|null
*/
public $start = null;
/**
*
* @var integer
*/
public $total = 0;
/**
*
* @var integer
*/
public $nb = 0;
/**
* {@inheritdoc}
*/
public function startQuery($sql, array $params = null, array $types = null)
{
if ($this->enabled) {
$this->start = microtime(true);
$this->query = array('sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0);
}
}
/**
* {@inheritdoc}
*/
public function stopQuery()
{
if ($this->enabled) {
$time = microtime(true) - $this->start;
$this->total+= $time;
$this->query['executionTotal'] = $this->total;
$this->query['executionMS'] = $time;
if ($this->nb == 0) {
file_put_contents('logger.log', print_r($this->query, 1));
} else {
file_put_contents('logger.log', print_r($this->query, 1), FILE_APPEND);
}
$this->nb++;
}
}
}

129
src/Scores/Mail/Method.php Normal file
View File

@ -0,0 +1,129 @@
<?php
class Scores_Mail_Method extends Zend_Mail
{
protected $config;
protected $transport;
/**
* Gestion de l'envoi des mails en fonction de la configuration
* Fournir un objet de configuration ou utiliser la configuration de l'application
* method => smtp, sendmail, file
* Si method = smtp
* (host => IP, dns)
*
* Activer l'authentification
* (auth => login, plain, ....)
* (username => )
* (password => )
*/
public function __construct($config = null)
{
if ($config === null) {
$c = Zend_Registry::get('config');
$this->config = $c->profil->mail;
} else {
$this->config = $config;
}
$this->_charset = 'ISO-8859-15';
// --- Configuration du transport SMTP
if ($this->config->method == 'smtp') {
$config = array();
if (isset($this->config->auth)) {
$config['auth'] = $this->config->auth;
if (isset($this->config->username)) {
$config['username'] = $this->config->username;
}
if (isset($this->config->password)) {
$config['password'] = $this->config->password;
}
}
if (isset($this->config->port)) {
$config['port'] = $this->config->port;
}
$tr = new Zend_Mail_Transport_Smtp($this->config->host, $config);
}
// --- Configuration transport Sendmail
if ($this->config->method == 'sendmail') {
$tr = new Zend_Mail_Transport_Sendmail();
}
// --- Configuration transport File
if ($this->config->method == 'file') {
$tr = new Zend_Mail_Transport_File(array('callback' => array($this, 'recipientFilename')));
}
$this->transport = $tr;
}
/**
* Champ From en fonction de la clé de configuration
* @param string $configKey
*/
public function setFromKey($configKey)
{
$email = $this->config->email->$configKey;
$this->setFrom($email, ucfirst($configKey));
}
/**
* Champ To en fonction de la clé de configuration
* @param string $configKey
*/
public function addToKey($configKey)
{
$email = $this->config->email->$configKey;
$this->addTo($email, ucfirst($configKey));
}
/**
* Définit le sujet de l'email
* @param string $texte
*/
public function setSubjectC($texte = '')
{
$this->setSubject($this->txtConvert($texte));
}
/**
* Définit le corps de l'email au format texte
* @param string $texte
*/
public function setBodyTextC($texte = '')
{
$this->setBodyText($this->txtConvert($texte));
}
/**
* Définit le corps de l'email au format html
* @param string $html
*/
public function setBodyHtmlC($html = '')
{
$this->setBodyHtml($this->txtConvert($html));
}
/**
* Envoi de l'emai
*/
public function execute()
{
return $this->send($this->transport);
}
//We suppose that character encoding of strings is UTF-8 on PHP script.
protected function txtConvert($string)
{
return mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8');
}
protected function recipientFilename($transport)
{
return $transport->recipients . '_' . mt_rand() . '.tmp';
}
}

237
src/Scores/Stat/Op.php Normal file
View File

@ -0,0 +1,237 @@
<?php
class Scores_Stat_Op
{
protected $sql = array(
'bod' => array(
array(
'table' => 'jo.bodacc_detail',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'annonce' => array(
array(
'table' => 'jo.annonces',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSaisie={id}',
'source IN ("JS","TS","GC","PC") AND (dateInsert BETWEEN "{begin}" AND "{end}" OR dateUpdate BETWEEN "{begin}" AND "{end}")',
),
'group' => array(),
'order' => array(),
),
),
'asso' => array(
array(
'table' => 'jo.asso',
'columnsTotal' => array('COUNT(*) as Nb'),
'columnsCsv' => array('*'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
)
),
'dir' => array(
array(
'table' => 'jo.rncs_dirigeants',
'columnsTotal' => array('COUNT(*) as Nb'),
'columnsCsv' => array('*'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'cac' => array(
array(
'table' => 'jo.bodacc_dirigeants',
'columnsTotal' => array('COUNT(*) as Nb'),
'columnsCsv' => array('*'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'boamp' => array(
array(
'table' => 'jo.boamp_lots',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
array(
'table' => 'jo.boamp_detail',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'client' => array(
array(
'table' => 'jo.sirenage_clients',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'marque' => array(
array(
'table' => 'bopi.marques',
'columnsTotal' => array('COUNT(*) as Nb'),
'columnsCsv' => array('*'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'lien' => array(
array(
'table' => 'jo.liens2',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idInsert={id} AND dateInsert BETWEEN "{begin}" AND "{end}" OR
idUpdate={id} AND dateUpdate BETWEEN "{begin}" AND "{end}" OR
idSuppr={id} AND dateSuppr BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
array(
'table' => 'jo.liensRef',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idInsert={id} AND dateInsert BETWEEN "{begin}" AND "{end}" OR
idUpdate={id} AND dateUpdate BETWEEN "{begin}" AND "{end}" OR
idSuppr={id} AND dateSuppr BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
array(
'table' => 'jo.liensDoc',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idInsert={id}',
'dateInsert BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'bilansaisie' => array(
array(
'table' => 'jo.bilans_user',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idUtilisateur={id} AND dateAction BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
'tourisme' => array(
array(
'table' => 'jo.tourisme',
'columnsTotal' => array('COUNT(*) as Nb'),
'where' => array(
'idSirenage={id}',
'dateUpdate BETWEEN "{begin}" AND "{end}"',
),
'group' => array(),
'order' => array(),
),
),
);
protected $category;
protected $user;
protected $begin;
protected $end;
protected $db;
public function __construct($category, $user, $dateBegin, $dateEnd = null)
{
$this->category = $category;
$this->user = $user;
$this->begin = $dateBegin.' 00:00:00';
$this->end = $dateBegin.' 23:59:59';
if ($dateEnd !== null) {
$this->end = $dateEnd.' 23:59:59';
}
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
}
public function total()
{
$config = $this->sql[$this->category];
$nb = 0;
foreach ($config as $param) {
$sql = $this->db->select()->from($param['table'], $param['columnsTotal']);
foreach ($param['where'] as $where) {
$where = preg_replace('/\{id\}/', $this->user, $where);
$where = preg_replace('/\{begin\}/', $this->begin, $where);
$where = preg_replace('/\{end\}/', $this->end, $where);
$sql->where($where);
}
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->db->fetchRow($sql);
if ($result !== null) {
$nb = $nb + $result->Nb;
}
}
return $nb;
}
public function csv()
{
$config = $this->sql[$this->category];
foreach ($config as $param) {
$sql = $this->db->select()->from($param['table'], $param['columnsCSV']);
foreach ($param['where'] as $where) {
$where = preg_replace('/\{id\}/', $this->user, $where);
$where = preg_replace('/\{begin\}/', $this->begin, $where);
$where = preg_replace('/\{end\}/', $this->end, $where);
$sql->where($where);
}
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->db->fetchRow($sql);
if ($result !== null) {
}
}
}
}

View File

@ -0,0 +1,90 @@
<?php
/**
*
* @author mricois
*
*/
class Scores_Surveillance_File
{
/**
* Declare the header
* @var array
*/
protected $header = array(
'siren',
'nic',
'ref',
'login',
'email',
'source',
);
protected $headerRequired = array(
'siren',
'nic',
'ref',
);
protected $position = array();
protected $delimiter = ',';
/**
*
* @param string $delimiter
*/
public function __construct($delimiter = null)
{
$this->delimiter = ',';
if (null !== $delimiter) {
$this->delimiter = $delimiter;
}
}
/**
* Check file header
* @param string $file
* @return boolean|array
*/
public function checkHeader($file)
{
$row = 0;
$error = array();
if (($handle = fopen($file, 'r')) !== false) {
while (($data = fgetcsv($handle, 0, $this->delimiter, '"')) !== false) {
$num = count($data);
//First line
if ($row == 0) {
//Detect key
foreach ( $this->header as $key ) {
for ( $c=0; $c < $num; $c++ ) {
if ( $key == strtolower($data[$c]) ) {
$this->position[$key] = $c;
}
}
}
break;
}
$row++;
}
fclose($handle);
}
if ( count($this->position) > 0 ) {
$tabKey = array_keys($this->position);
foreach( $this->headerRequired as $key) {
if ( !in_array($key, $tabKey) ) {
return false;
}
}
return $tabKey;
}
return false;
}
public function setCmd(){}
public function loadLines(){}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,632 @@
<?php
class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
{
const NOT_IN_NETWORK = 'notInNetwork';
const LOW_IN_NETWORK = 'lowInNetwork';
const HIGH_IN_NETWORK = 'highInNetwork';
const INVALID_NETWORK = 'invalidNetwork';
const MISSING_NETWORK = 'missingNetwork';
/**
* A CIDR number (valid values 0-32)
* @var int
*/
protected $_cidr = 0;
/**
* A decimal 32-bit netmask
* @var string
*/
protected $_netmask = '255.255.255.255';
/**
* A 4-octet IPv4 network address
* @var string
*/
protected $_network = null;
/**
* A network/mask notation or network range
* @var string
*/
protected $_notation = null;
/**
* Unsigned decimal "from" IP address
* @var string
*/
protected $_rangeFrom = null;
/**
* Unsigned decimal "to" IP address
* @var string
*/
protected $_rangeTo = 0;
/**
* Will throw Exception instead of trigger_error if true
* @var false
*/
protected $_throw = false;
/**
* Constructor for IpInNetwork class
*
* @desc <p>Accepts an array with options. Also adds the error messages to the parent's message templates.</p>
* @example <p>List of allow options and their use:
* $options argument must be an array and allows two key/value pairs for this class and passes on any remaining
* values to the parent class Zend_Validate_Ip. If key 'network' exists it will pass on the value to method
* setNetworkNotation and for key 'throw' to setThrow4Notation.</p>
* @see Zend_Validate_Ip::__construct()
* @see Scores_Validate_IpInNetwork::setNetworkNotation()
* @see Scores_Validate_IpInNetwork::setThrow4Notation()
* @param array $options
* @return void
*/
public function __construct($options = array())
{
if (!empty($options) && is_array($options)) {
if (array_key_exists('throw', $options)) {
$this->setThrow4Notation($options['throw']);
unset($options['throw']);
}
if (array_key_exists('network', $options)) {
$this->setNetworkNotation($options['network']);
unset($options['network']);
}
}
$this->setMessages(array());
parent::__construct($options);
}
/**
* (non-PHPdoc)
* @see Zend_Validate_Abstract::setMessages()
*/
public function setMessages(array $messages)
{
$newMessages = array(
self::MISSING_NETWORK => 'No valid network has been given to validate against',
self::INVALID_NETWORK => 'The network is not an accepted format',
self::NOT_IN_NETWORK => "The ip '%value%' does not match the provided 32 network",
self::LOW_IN_NETWORK => "The ip '%value%' is lower in range than the provided network",
self::HIGH_IN_NETWORK => "The ip '%value%' is higher in range than the provided network",
);
foreach ($newMessages as $messageKey => $messageString) {
if (!isset($this->_messageTemplates[$messageKey])) {
$this->_messageTemplates[$messageKey] = $messageString;
} elseif (!empty($messages) && array_key_exists($messageKey, $messages)) {
$this->_messageTemplates[$messageKey] = $messages[$messageKey];
unset($messages[$messageKey]);
}
}
empty($messages) || parent::setMessages($messages) ;
return $this;
}
/**
* (non-PHPdoc)
* @see Zend_Validate_Ip::isValid()
*/
public function isValid($value)
{
if (true === parent::isValid($value)) {
$notation = $this->_getNotation();
if (!empty($notation)) {
// a valid notation has been set
$network = $this->_getNetwork();
if (!empty($network)) {
if (true === $this->_validateIpInNetwork($value)) {
return true;
}
} else {
if (true === $this->_validateIpInRange($value)) {
return true;
}
}
// NOTE: Errors are only available in regards to the value (ip address) and not the network/netmask (notation)
$errors = $this->getErrors();
if (empty($errors)) {
$this->_error(self::NOT_IN_NETWORK);
}
} else {
$this->_error(self::MISSING_NETWORK);
}
}
return false;
}
/**
* Validates the IP in a given network
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 16:34:00 CST
* @author aw
* @desc <p>Takes the CIDR and network (IP) address and validates the given IP address against it. Sets the appropriate
* errors if the IP is not a match for the network.</p>
* @param string $ip
* @return bool
*/
protected function _validateIpInNetwork($ip)
{
$netmask = $this->getCidr();
$network = $this->_getNetwork();
// lets get this out of the way first
if (32 === $netmask) {
// this network has to match the IP
if ($network === $ip) {
return true;
} else {
$this->_error(self::NOT_IN_NETWORK);
return false;
}
}
// get the unsigned integers for the IP and network address
$ip_addr_uDec = $this->_makeUnsignedAddress($ip);
$lNetwork_uDec = $this->_makeUnsignedAddress($network);
// let verify the IP against the lower end of the range
if ($ip_addr_uDec < $lNetwork_uDec) {
// the ip is below the network range
$this->_error(self::LOW_IN_NETWORK);
return false;
}
// well then, finally verify the IP against the uppoer end of the range
// add the decimal representation of the netmask to the network IP
$netmask_uDec1 = $netmask < 31 ? pow(2, (32-$netmask)) - 1 : 1 ;
$netmask_uDec = pow(2, 32-$netmask) - 1 ;
$uNetwork_uDec = $lNetwork_uDec + $netmask_uDec;
if ($ip_addr_uDec > $uNetwork_uDec) {
// the ip is above the network range
$this->_error(self::HIGH_IN_NETWORK);
return false;
}
return true;
}
/**
* Validates the IP in a given range
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/16 13:06:00 CST
* @author aw
* @desc <p>Takes the "from" and "to" (IP) address and validates the given IP address against it. Sets the appropriate
* errors if the IP is not within the defined range.</p>
* @param string $ip
* @return bool
*/
protected function _validateIpInRange($ip)
{
$uInt_Ip = $this->_makeUnsignedAddress($ip);
if (is_numeric($this->_rangeFrom) && $uInt_Ip >= $this->_rangeFrom) {
if ($uInt_Ip <= $this->_rangeTo) {
return true;
} elseif (is_numeric($this->_rangeTo)) {
$this->_error(self::HIGH_IN_NETWORK);
return false;
}
} elseif (is_numeric($this->_rangeFrom)) {
$this->_error(self::LOW_IN_NETWORK);
return false;
}
$this->_error(self::MISSING_NETWORK);
return false;
}
/**
* Set the network (notation) to the properties
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 13:43:00 CST
* @author aw
* @desc <p>The network is usually a notation with a network/netmask combination. The method uses two methods to validate
* the netmask and the network address. If the notation is a range fromIPAddress-toIPAddress the netmask and network address
* are ignored. The isValid() will then attempt to validate the value within the range and not the network segment.</p>
* string $notation network/address (128.0.0.0/24) (128.0.0.0/255.255.255.0) or (128.0.0.0-128.0.0.255)
* @return object|false Awd_Validate_IpInNetwork
*/
public function setNetworkNotation($notation)
{
$network = false !== strpos($notation, '/') ? $this->_evaluateNetmask($notation) : false ;
if (false !== $network) {
// a valid CIDR/netmask has been found
if (true === parent::isValid($network)) {
if ($this->_validateNetwork($network)) {
$this->_network = $network;
$this->_notation = $notation;
return $this;
}
} else {
$this->_invalidNetwork(__LINE__);
}
} elseif (false !== strpos($notation, '-')) {
// the notation is looking like a from-to IP range
if (true === $this->_validateRange($notation)) {
$this->_notation = $notation;
return $this;
}
}
return false;
}
/**
* Sets the value for _throw property
*
* @since Version 0.1.36
* @version 0.1.35 2012/01/17 08:23:00 CST
* @author aw
* @desc <p>The value determines if the application will throw an exception or trigger an E_USER_WARNING if
* an error was found in the submitted network notation. The default is false.</p>
* @throws E_USER_WARNING if the argument is not of type bool
* bool $throw
* @return object Awd_Validate_IpInNetwork
*/
public function setThrow4Notation($throw = false)
{
if (!is_bool($throw)) {
$msg = '[AWD] Programming error: The argument is not a boolean value';
trigger_error($msg, E_USER_WARNING);
}
$this->_throw = $throw;
return $this;
}
/**
* Gets the value for _throw property
*
* @since Version 0.1.36
* @version 0.1.35 2012/01/17 08:27:00 CST
* @author aw
* @desc <p>The value determines if the application will throw an exception or trigger an E_USER_WARNING if
* an error was found in the submitted network notation. The default is false.</p>
* @return bool
*/
public function getThrow4Notation()
{
return (bool) $this->_throw;
}
/**
* Gets the network (notation) as it has been set if valid
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 16:08:00 CST
* @author aw
* @desc <p>If empty the network (notation) was either not set or not valid. Hence, this method can be used to
* verify if setting a network range or notation was successful with the constructor.</p>
* @return string
*/
public function getNetworkNotation()
{
return (string) $this->_getNotation();
}
/**
* Protected method to gets the network (notation) as it has been set if valid
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 16:08:00 CST
* @author aw
* @desc <p>Note that the notation is only available when it passed the internal validation. Internally (protected)
* the network represents the network (IP) address whereas the notation is the full string as set when is valid.
* The notation is a representation of network range or network/mask. This method essentially returns internally
* (protected) the same result as the public method getNetworkNotation().</p>
* @return string|null
*/
protected function _getNotation()
{
return empty($this->_notation) ? null : (string) $this->_notation ;
}
/**
* Gets the network address from the notation if a valid address and mask has been set
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 16:18:00 CST
* @author aw
* @desc <p>Note that internally (protected) the network represents the network (IP) address extracted from the
* "network notation", i.e. a representation of network range or network/mask. If the notation was not valid or a
* network range has been set this value will be empty.</p>
* @return string
*/
protected function _getNetwork()
{
return (string) $this->_network;
}
/**
* Gets the CIDR from the notation if a valid address and mask has been set
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/14 16:26:00 CST
* @author aw
* @desc <p>The CIDR has been extracted from the "network notation", i.e. a representation of network/mask or
* network/CIDR. If the notation was not valid or a network range has been set this value will be empty.</p>
* @return int
*/
public function getCidr()
{
return (int) $this->_cidr;
}
/**
* Evaluates the netmask from a notation
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/15 10:12:00 CST
* @author aw
* @desc <p>The notation is usually set as a {network/CIDR} or {network/netmask} notation. This method examines
* the string following a slash. A CIDR mask will be verified for its number whereas a netmask is passed to
* another method _validateNetmask() for validation and if valid converted into a CIDR representation. In
* either case if the value is valid the remaining network (IP) address is returned or false on failure.</p>
* @throws Calls method _invalidNetwork() when a failure is detected
* @param string $notation
* @return string|bool (false)
*/
protected function _evaluateNetmask($notation)
{
// split the notation in network and netmask information
list($network, $netmask) = explode('/', $notation, 2);
if (is_numeric($netmask)) {
// does look like a CIDR netmask
$between = new Zend_Validate_Between(array('min'=>1, 'max'=>32));
if (true === $between->isValid($netmask)) {
$this->_cidr = (int) $netmask;
return $network;
} else {
$error_msgs = $between->getMessages();
if (!empty($error_msgs) && is_array($error_msgs)) {
$msg = array_shift($error_msgs);
} else {
// fallback, should not really be an option
$msg = sprintf('The netmask [ %s ] is not a valid option', $netmask);
}
// oops, this CIDR is not a valid range
return $this->_invalidNetwork(__LINE__.' - '.$msg);
}
} elseif (!empty($netmask)) {
// looks more like 32-bit (like 255.255.255.0) format
if (true === ($line = $this->_validateNetmask($netmask))) {
return $network;
}
return $this->_invalidNetwork($line);
}
return $this->_invalidNetwork(__LINE__);
}
/**
* Validates a 32-bit netmask
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/16 10:34:00 CST
* @author aw
* @desc <p>A netmask is a decimal representation of 32-bit string where the beginning sequence is a complete
* set of 1 (one) followed by a complete set of 0 (zero). If valid the netmask string will be a CIDR numeric
* value and set to the proected property _cidr. If not valid the returned value is the line plus the index if
* the failure is in one of the segments.</p>
* @param string $netmask
* @return true|string
*/
protected function _validateNetmask($netmask)
{
$classes = explode('.', $netmask);
if (4 !== count($classes)) {
return __LINE__;
}
$cidr = 0;
$end = false;
foreach ($classes as $index => $segment) {
if (!is_numeric($segment)) {
return __LINE__;
} elseif (0 === (int) $segment) {
$end = true; // all following segment have to be 0 (zero) as well
continue;
}
$matches = array();
// evaluate the binary representation of the segment
$bin = decbin($segment);
if (8 !== strlen($bin) || 0 === preg_match('/^([1]{1,8})([0]*)$/', decbin($segment), $matches)) {
if (8 !== strlen($bin)) {
// this segment is not a complete byte (8 bits) i.e. a value below 128
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
}
// this segment is a complete byte (8 bits), i.e. a value above 128, but not a valid binary mask (like 11110000)
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
} elseif (true === $end) {
// a mask was found in the previous segment; therefore, this segment should be 0 (zero)
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
}
$len = strlen($matches[1]);
if ($len < 8) {
$end = true;
}
$cidr += $len;
}
$this->_cidr = $cidr;
return true;
}
/**
* Validates the network address in a subnet notation
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/16 10:34:00 CST
* @author aw
* @desc <p>The network address in a CIDR or subnet mask notation is the base of the assigned block.
* Because the size of the block is specified by the CIDR or subnet mask the base of a network address
* has to fit and match into the block size. This method evaluates the block size and then validates
* if the base of network address fits into the assigned block. If not valid the line plus the index
* of the failed segment is sent to method _invalidNetwork() triggering or throwing an error.</p>
* @param string $network
* @return true|string
*/
protected function _validateNetwork($network)
{
$cidr = $this->getCidr();
$class = $cidr / 8;
// an integer indicates a classful (unicast) network
if (is_int($class)) {
$iClass = $class;
$maskBits = 0;
} else {
$iClass = (int) floor($class);
$maskBits = (int) 8 - ($cidr - ($iClass * 8));
$hosts = (int) pow(2, $maskBits); // number of usable hosts in a subnet
}
$segments = explode('.', $network);
// Note: $segments index begins at 0 (zero) and $iClass is the last complete segment in the netmask (8 bits (255))
// It is irrelevant but just to clarify for $iClass: 1 = Class A, 2 = Class B, 3 = Class C
$complete = false;
// check all segments following the last complete class and because we have to check for
// subnetting in the _follow_ class we do NOT add 1 to $iClass as the index in $segments
for ($index = $iClass; $index < 4; $index++) {
$subNetwork = (int) $segments[$index];
if (0 === $maskBits) {
// this class has no subnets (aka classful network)
// all 0 (zero) are expected as (sub)network numbers
if (0 !== $subNetwork) {
return $this->_invalidNetwork(__LINE__.':'.++$index); // NOTE: Index begins at 0 (zero)
}
continue;
} else {
// this class has subnets (aka a classless (subnetted) network)
if (true === $complete) {
// for all following networks 0 (zero) is expected as (sub)network number
if (0 !== $subNetwork) {
return $this->_invalidNetwork(__LINE__.':'.++$index); // NOTE: Index begins at 0 (zero)
}
continue;
}
$complete = true;
// the (sub)network must be a fact or hosts(/subnets)
$block = $subNetwork / $hosts;
if (is_int($block)) {
// all clear
// NOTE: We do NOT return yet because we may have to verify any following segments
continue;
} else {
return $this->_invalidNetwork(__LINE__.':'.++$index.':'.$hosts); // NOTE: Index begins at 0 (zero)
}
}
}
return true;
}
/**
* Validates a network range with a "from-to" IP address notation
*
* @since Version 0.1.36
* @version 0.1.35 2012/01/16 12:44:00 CST
* @author aw
* @desc <p>A network range can be any difference (or equal) between two valid IP addresses. The method will even switch the
* values if the "to" is lower than the "from" address.</p>
* @param string $range
* @return bool
*/
protected function _validateRange($range)
{
list($from, $to) = explode('-', $range); // Note: we do NOT care if more IP ranges have been set, i.e. the range would be invalid
if (false === ($uInt_from = $this->_makeUnsignedAddress($from)) || false === ($uInt_to = $this->_makeUnsignedAddress($to))) {
return $this->_invalidNetwork(__LINE__); // at least one of the addresses is not a valid IP address
}
if ($uInt_from <= $uInt_to) {
$this->_rangeFrom = $uInt_from;
$this->_rangeTo = $uInt_to;
} else {
// the range is not in the correct order
$this->_rangeFrom = $uInt_to;
$this->_rangeTo = $uInt_from;
}
return true;
}
/**
* Converts an IP address into an unsigned decimal number (see ATTENTION note for returned value)
*
* @since Version 0.1.36
* @version 0.1.35 2012/01/16 12:31:00 CST
* @author aw
* @desc <p>Uses php function ip2long() to convert the IP into a signed value first and then returns the value with
* sprintf($u). ATTENTION: Function sprintf returns this value as a string and typecasting will not produce the expected
* result for IP addresses above 128.0.0.0. Do not typecast this value to an integer!</p>
* @param string $ip
* @return string
*/
private function _makeUnsignedAddress($ip)
{
if (false === ($ip_addr_long = ip2long($ip))) {
// not a valid IP address
return false;
}
// Note ip2long creates signed integers
// a positive number means the address is in the lower half < 128 (0nnn nnnn.)
// a negative number means the address is in the upper half >= 128 (1nnn nnnn.)
// 127.255.255.255 = 2147483647
// 128.0.0.1 = -2147483647
// 128.0.0.0 = -2147483648
// convert to unsigned decimal number
return sprintf('%u', $ip_addr_long);
}
/**
* Triggers an error warning or throws an exception
*
* @since Version 0.1.36
* @version 0.1.36 2012/01/15 11:54:00 CST
* @author aw
* @desc <p>The error message contains the argument which is usually the line where the error occured. The calling method
* may add additional information to the line number.</p>
* @throws E_USER_WARNING If the _throw property is false (default)
* @throws Exception If the _throw property is true
* @param string|int $line
* @return bool (false)
*/
private function _invalidNetwork($line)
{
$error_msg = 'The provided network information is not a recognized format [#'.$line.']';
$this->_error(self::INVALID_NETWORK, $error_msg);
$msg = '[SCORES] Application error: '.$error_msg;
if (false === $this->_throw) {
trigger_error($msg, E_USER_WARNING);
return false;
} else {
throw new Exception($msg);
}
}
}

View File

@ -0,0 +1,39 @@
This validator class will test an IP against a provide network notation. The
network notation can be a network range, or network address with CIDR or 32-bit
decimal subnet mask notation. Note that the main validation method always uses
the CIDR notation, i.e a bitmask will be converted into a CIDR.
Examples for network notations
------------------------------
Network Range:
**************
128.0.0.12-128.0.0.19
true for all IP addresses inclusively in this range (i.e. from .12 to .19)
CIDR notation:
**************
128.0.0.8/30
block with 4 hosts
true for IP addresses from .8-.11 (i.e. .8, .9, .10, .11)
Subnet mask notation:
*********************
128.0.0.8/255.255.255.252
same as CIDR notation
Special Notes:
--------------
1) The network notation is validated, i.e. you have to pass a valid network and
CIDR or subnet mask combination. For the network range the two values must be
valid IP addresses.
2) A CIDR notation of /32, subnet mask /255.255.255.255 or a range with two
equal addresses will match for one host, i.e. the result is true if the network
address or the range addresses are identical to the IP address
3) The network notation or a range has to be set prior to calling isValid() as
is custom with all Zend validators. The notation can be set when instantiating
the object as an array and 'network' as the index. The setter method is
setNetworkNotation($notation) and expects a string as the argument.

53
src/Scores/Wkhtml/Pdf.php Normal file
View File

@ -0,0 +1,53 @@
<?php
class Scores_Wkhtml_Pdf
{
protected $wkhtml;
public function __construct()
{
$c = Zend_Registry::get('config');
$this->wkhtml = $c->profil->wkhtmltopdf->path;
}
/**
* Défini les options supplémentaires à l'execution de wkhtmltopdf
* -n, --disable-javascript Do not allow webpages to run javascript.
* --disable-internal-links Do no make local links
* --disable-external-links Do no make links to remote web pages
* --user-style-sheet <url> Specify a user style sheet, to load with every page.
* --print-media-type Use print media-type instead of screen.
* --header-left|right
* @param string $name
* @param string $value
*/
public function setOptions($name, $value = '')
{
$this->options[$name] = $value;
}
/**
* Imprime un fichier HTML en PDF avec l'utilitaire wkhtmltopdf
* @param string $fileIn
* @param string $fileOut
* @return string Nom du fichier
*/
public function exec($fileIn, $fileOut = '')
{
if (empty($fileOut)) {$fileOut = str_replace('.html', '.pdf', $fileIn); }
if(file_exists($fileOut)){ unlink($fileOut); }
$options = '--disable-internal-links';
if ( count($this->options) )
{
foreach ( $this->options as $name => $value )
{
$options.= ' --'.$name;
if ($value!= '') $options.= ' "'.$value.'"';
}
}
$cmd = $this->wkhtml.' '.$options.' "'.$fileIn.'" "'.$fileOut.'"';
exec( $cmd );
return $fileOut;
}
}

View File

@ -0,0 +1,84 @@
<?php
class Scores_Ws_Discover
{
protected $serviceWsdl = null;
protected $serviceOptions = array();
protected $serviceStructure = array();
protected $serviceStructureTypes = array();
protected $serviceTypes;
protected $serviceFunctions;
public function __construct($wsdl, $options = array())
{
$this->serviceWsdl = $wsdl;
$this->serviceOptions = $options;
$this->setStructure();
}
public function getStructure()
{
return $this->serviceStructure;
}
public function getStructureParam()
{
return $this->serviceStructureTypes;
}
protected function setStructure()
{
$client = new Zend_Soap_Client(
$this->serviceWsdl,
$this->serviceOptions
);
$this->serviceFunctions = $client->getFunctions();
$this->serviceTypes = $client->getTypes();
foreach ($this->serviceFunctions as $func) {
$this->setFunction($func);
}
foreach ($this->serviceTypes as $type) {
$this->setType($type);
}
}
protected function setFunction($func)
{
if (preg_match('/[^\s]+\s([^\s]+)\((.*)\)/', $func, $matches)) {
$funcName = $matches[1];
$funcParams = $matches[2];
$this->serviceStructure[$funcName] = array();
if (preg_match_all('/([^\s]+)\s([^\s]+),?/', $funcParams, $mParams)) {
$nbParams = count($mParams[0]);
for ($i=0;$i<$nbParams;$i++) {
$type = $mParams[1][$i];
$name = $mParams[2][$i];
$this->serviceStructure[$funcName][$i] = array(
'name' => $name,
'type' => $type
);
}
}
}
}
protected function setType($type)
{
$type = str_replace("\n", '', $type);
if (preg_match('/struct\s([^\s]+)\s\{(.*)\}$/m', $type, $matches)) {
$struct = trim($matches[1]);
$params = trim($matches[2]);
preg_match_all('/([^\s]+)\s([^\s]+);/', $params, $paramsMatches);
$nbParams = count($paramsMatches[0]);
$this->serviceStructureTypes[$struct] = array();
for ($i=0; $i<$nbParams;$i++) {
$this->serviceStructureTypes[$struct][$i] = array(
'name' => $paramsMatches[2][$i],
'type' => $paramsMatches[1][$i],
);
}
}
}
}

181
src/Scores/Ws/Doc.php Normal file
View File

@ -0,0 +1,181 @@
<?php
class Scores_Ws_Doc
{
private $serviceClass;
private $classmap = array();
private $serviceMethods = array();
private $serviceTypes = array();
public function __construct($serviceClass = null, $classmap = null, $path)
{
$this->serviceClass = $serviceClass;
$this->classmap = $classmap;
require_once $path . 'Service.php';
$this->parseService();
$this->parseTypes();
}
/**
* Retourne la liste des services et leurs paramètres
* @return array
*/
public function getServiceMethods()
{
return $this->serviceMethods;
}
/**
* Retourne la liste des types de données et leurs paramètres
* @return array
*/
public function getServiceTypes()
{
return $this->serviceTypes;
}
private function parseService()
{
$class = new Zend_Server_Reflection();
$methods = $class->reflectClass($this->serviceClass)
->getMethods();
$methodsElement = array();
foreach ($methods as $method) {
$prototype = null;
$maxNumArgumentsOfPrototype = -1;
foreach ($method->getPrototypes() as $tmpPrototype) {
$numParams = count($tmpPrototype->getParameters());
if ($numParams > $maxNumArgumentsOfPrototype) {
$maxNumArgumentsOfPrototype = $numParams;
$prototype = $tmpPrototype;
}
}
$paramsElement = array();
foreach ($prototype->getParameters() as $param) {
$paramElement = array(
'type' => $param->getType(),
'name' => $param->getName(),
'description' => $param->getDescription(),
);
if ($param->isOptional()) {
$paramElement['optional'] = $param->isOptional();
$paramElement['defaultValue'] = $param->getDefaultValue();
}
$paramsElement[] = $paramElement;
}
$methodElement = array(
'name' => $method->getName(),
'desc' => $method->getDescription(),
'params' => $paramsElement,
'return' => $prototype->getReturnType(),
);
$methodsElement[] = $methodElement;
}
$this->serviceMethods = $methodsElement;
}
private function parseTypes()
{
$typesElement = array();
if (count($this->classmap)>0) {
foreach ($this->classmap as $className) {
$class = new ReflectionClass($className);
$paramsElement = array();
foreach ($class->getProperties() as $property) {
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
$name = $property->getName();
$type = $matches[1][0];
/**
* Traitement éléments de documentation à placer dans le WSDL
* Supprime les retours chariots.
* Récupére les éléments de documentation
*/
$comment = '';
$docBlock = preg_replace('/\n/', '', $property->getDocComment());
if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) {
$comment.= preg_replace(
array('/\r/', '/\*/' ),
array('', ''), $docBlockMatches[1]
);
}
/**
* Traitement des @xsd (Provisoire)
* Définition des longueurs dans la documentation
* @xsd minLength=[\d]+ => (Longueur min = [\d]+)
* @xsd maxLength=[\d]+ => (Longueur max = [\d]+)
* @xsd enumeration=element,element
*/
if (preg_match_all('/@xsd\s+(minLength|maxLength)=([\d]+)\s+(?:\*|@)/m', $property->getDocComment(), $resMatches, PREG_SET_ORDER)) {
$comment.= '(';
$parcourCpt = 0;
foreach ($resMatches as $res) {
switch ($res[1]) {
case 'minLength':
$comment.= 'Longueur min = '.$res[2];
break;
case 'maxLength':
$comment.= 'Longueur max = '.$res[2];
break;
}
$parcourCpt++;
if ($parcourCpt>0 && $parcourCpt<count($resMatches)) {
$comment.= ', ';
}
}
$comment.= ')';
}
/**
* Traitement des références
* @ref fichier:titre:nom_du_fichier
* => http://vhost/ref/fichier/
* @ref mysql:titre:requete.sql
* => http://vhost/ref/table/
*/
if (preg_match_all('/@ref\s+(fichier|mysql):(.*):(.*)\.(?:csv|sql)\s+(?:\*|@)/m', $property->getDocComment(), $refMatches, PREG_SET_ORDER)) {
$view = new Zend_View();
$comment.= ', Référence(s) : ';
foreach ($refMatches as $ref) {
switch ($ref[1]) {
case 'fichier':
$urlFichier = $view->url(array(
'controller' => 'ref',
'action' => 'fichier',
'q' => $ref[3],
), null, true);
$comment.= '<a href="'.$urlFichier.'">'.$ref[2].'</a>';
break;
case 'mysql':
$urlMysql = $view->url(array(
'controller' => 'ref',
'action' => 'table',
'q' => $ref[3],
), null, true);
$comment.= '<a href="'.$urlMysql.'">'.$ref[2].'</a>';
break;
}
$comment.= ', ';
}
}
$paramElement = array(
'name' => $name,
'type' => $type,
'description' => trim($comment)
);
}
$paramsElement[] = $paramElement;
}
$typesElement[$className] = $paramsElement;
}
$this->serviceTypes = $typesElement;
}
}
}

View File

@ -0,0 +1,4 @@
<?php
class Scores_Ws_Exception extends Zend_Exception
{
}

View File

@ -0,0 +1,23 @@
<?php
class Scores_Ws_Form_GetIdentite extends Zend_Form
{
public function init()
{
$this->setName('soapform');
$this->setAction('/demo/requete');
$this->setMethod('post');
$this->addElement('text', 'siret', array(
'filters' => array('StringTrim'),
'validators' => array(
array('stringLength', false, array(9, 14)),
array('NotEmpty', true),
),
'label' => 'Siret : ',
'required' => 'true',
)
);
$this->addElement('submit', 'submit', array(
'label' => 'Envoyez',
));
}
}

1102
src/Scores/Ws/Server.php Normal file

File diff suppressed because it is too large Load Diff

131
src/Scores/Ws/Trigger.php Normal file
View File

@ -0,0 +1,131 @@
<?php
class Scores_Ws_Trigger
{
protected $userInfos;
protected $event;
protected $events = null;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct($event, $userInfos)
{
$this->event = $event;
$this->userInfos = $userInfos;
$this->conn = Zend_Registry::get('doctrine');
}
/**
* Check if we have a trigger to execute
* @return number
*/
protected function hasTrigger()
{
if ($this->userInfos['Service'] === null) {
$service = 'default';
}
$sql = "SELECT * FROM sdv1.clients_services_trigger
WHERE idClient=:client AND service=:service AND (login=:login OR login='')";
$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 ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tmp->action = $item->action;
$tmp->params = json_decode($item->actionParams, true);
$this->events[] = $tmp;
}
}
return $stmtNb;
}
/**
* Execute all triggers after hasTrigger
* @param array $args
* @return boolean
*/
protected function executeAllTrigger($args)
{
if (count($this->events)>0) {
foreach ($this->events as $action) {
$args = array_merge($args, $action->params);
switch ($action->action) {
case 'surveillance':
return $this->surveillance($args);
break;
}
}
}
}
/**
* Mise en surveillance automatique
* @param array $args
* source, siren, ...
* @return boolean
*/
protected function surveillance($args)
{
if (!array_key_exists('source', $args)) {
return false;
}
if (!array_key_exists('siren', $args)) {
return false;
}
if (!array_key_exists('nic', $args)) {
return false;
}
if (empty(trim($this->userInfos['email']))) {
return false;
}
if (array_key_exists('ref', $args)) {
$ref = $args['ref'];
}
try {
$this->conn->insert('jo.surveillances_site', array(
'source' => $args['source'],
'login' => $this->userInfos['login'],
'email' => $this->userInfos['email'],
'siren' => $args['siren'],
'nic' => $args['nic'],
'ref' => $ref,
'encoursClient' => 0,
'rs' => $args['Nom'],
'cp' => $args['CP'],
'ville' => $args['Ville'],
'dateAjout' => date('Y-m-d'),
'dateSuppr' => 0,
));
return true;
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
return false;
}
}