Merge branch 'develop' of git@gitlab.factory.insight.doubletrade.com:scores/webservice.git into develop

This commit is contained in:
Claire DELBOS 2017-04-13 11:33:45 +02:00
commit 1760970994
12 changed files with 76 additions and 2210 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/.buildpath
/.project
/vendor/
/composer-develop.lock

22
README.md Normal file
View File

@ -0,0 +1,22 @@
# WebService
## Installation du projet
1. Création de la configuration du VHOST apache
2. Référencer le domaine virtuel dans le fichier host de la machine
* ex : 192.168.33.10 webservice.sd.dev
3. Executer composer install pour charger les librairies externes dans vendor
4. Configurer l'application (application.ini)
* exemple fourni - `docs/config` ou projet `ansible`
Voir le fichier `docs/README` pour plus d'éléments
## Mode développement pour les librairies externes
Utiliser la branche `develop` de `scores/library`
`$ COMPOSER=composer-develop.json composer install`

View File

@ -1,391 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'list' => "List item.",
'generate|g=s' => "Generate the specify cache.",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nGénération Table Static Metier\n\n";
echo $opts->getUsageMessage();
exit;
}
if ( $opts->list ) {
$tabItems = array(
'Tribunaux' => "Tribunaux",
'FctDir' => "Fonctions de direction",
'Evenements' => "Table des evenements bodacc",
'Devises' => "Table des devises bodacc",
'RncsTribunaux' => "Table des tribunaux",
'DevisesInpi' => "Devises Inpi",
'Jugements' => "Jugements",
'PaysInpi' => "PaysInpi",
'CodesNaf' => "Codes Naf",
'CodesNace' => "Codes Nace",
'CodesNafa' => "Codes Nafa",
'CodesFJ' => "Codes Formes Juridiques",
'AffairesTypes' => "Codes natures des contentieux",
'ProcolDelete' => "Codes effacement de procol",
);
echo "\n";
foreach ( $tabItems as $code => $label ) {
echo "\t" . $code . " => ". $label . PHP_EOL;
}
exit;
}
/**
* Cache des Tribunaux Bodacc
*/
if( $opts->generate == 'Tribunaux' ) {
$sql = "SELECT triCode, triNom, LPAD(triCP,5,0) AS triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/BodaccTribunaux.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
$dep = substr($item->triCP, 0, 2);
if ($dep == 97 || $dep == 98) {
$dep = substr($item->triCP, 0, 3);
}
fwrite($fp, "\t'" . $item->triCode . "' => array(");
fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\"");
fwrite($fp, "),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Fonctions de Direction
*/
if ( $opts->generate == 'FctDir' ) {
$sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/FctDir.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Evenements
*/
if ( $opts->generate == 'Evenements' ) {
$sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Evenements.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n");
fwrite($fp, "\t\t'libEven' => \"" . $item->libEven . "\",\n");
fwrite($fp, "\t\t'Bodacc_Code' => \"" . $item->Bodacc_Code . "\",\n");
fwrite($fp, "\t\t'Rubrique' => \"" . $item->Rubrique . "\",\n");
fwrite($fp, "\t\t'Version' => " . $item->version . ",\n");
fwrite($fp, "\t\t'LienEtab' => " . $item->lienEtab . ",\n");
fwrite($fp, "\t),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache des devises Bodacc
*/
if ( $opts->generate == 'Devises' ) {
$sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Devises.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Tribunaux RNCS
*/
if ( $opts->generate == 'RncsTribunaux' ) {
$sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/RncsTribunaux.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array(");
fwrite($fp, "'Id'=>\"" . intval($item->triId) . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
fwrite($fp, "),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Devises Inpi
*/
if ( $opts->generate == 'DevisesInpi' ) {
$sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/DevisesInpi.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Jugements
*/
if ( $opts->generate == 'Jugements' ) {
$sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Jugements.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache PaysInpi
*/
if ( $opts->generate == 'PaysInpi' ) {
$sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/PaysInpi.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNaf
*/
if ( $opts->generate == 'CodesNaf' ) {
$sql = "SELECT codNaf700 AS naf, libNaf700 AS LibNaf FROM jo.tabNaf4";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNaf.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n");
}
}
$sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf FROM jo.tabNaf5";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNace
*/
if ( $opts->generate == 'CodesNace' ) {
$sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf, codNaf1 FROM jo.tabNaf5";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNace.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNafa
*/
if ( $opts->generate == 'CodesNafa' ) {
$sql = "SELECT codNafa AS nafa, libNafa FROM jo.tabNafa";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNafa.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesFJ
*/
if ( $opts->generate == 'CodesFJ' ) {
$sql = "SELECT code AS FJ, libelle AS libFJ FROM jo.tabFJur WHERE code>=1000";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesFJ.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache AffairesTypes
* Code Nature des contentieux
*/
if ( $opts->generate == 'AffairesTypes' ) {
$sql = "SELECT code, label FROM jo.greffes_affaires_nature";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->code . "' => \"" . $item->label ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Procol Delete
*/
if ( $opts->generate == 'ProcolDelete' ) {
$sql = "SELECT codEven, affProcol, libEven FROM jo.tabEvenements WHERE affProcol>0";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Defaillance/ProcolDelete.php', 'w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .", //".$item->libEven." \n");
}
}
fwrite($fp, ");\n");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'compile-s' => "Génére le cache des règles, sans paramètres (tout), avec paramètres (VORD, VORP, PO)",
'version=s' => "Version des régles",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nRegles SFR\n\n";
echo $opts->getUsageMessage();
exit;
}
$types = array('VORD', 'VORP', 'PO');
if ( $opts->compile!='' && in_array($opts->compile, $types) ) {
$types = array($opts->compile);
}
if ( count($types) > 0 ) {
foreach ( $types as $type ) {
$ruleSfrM = new Metier_Sfr_Compile($conn);
$ruleSfrM->setVersion($opts->version);
$ruleSfrM->construct($type);
}
}

View File

@ -1,57 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'log' => "",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nLog\n\n";
echo $opts->getUsageMessage();
exit;
}
if ($opts->log) {
$sql = "SELECT * FROM sdv1.logs_item";
$stmt = $conn->prepare($sql);
$stmt->execute();
$outPath = APPLICATION_PATH . '/../library/Scores/Account/Log/List.php';
$outFile = $outPath . '/Config.php';
if ($stmt->rowCount() > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "/* Auto generated ".date('Y-m-d H:i:s')." */\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND);
foreach ($result as $c) {
file_put_contents($outFile, "\t'". $c->Code . "' => array(,\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Label' => ". $c->Label . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\'Description' => ". $c->Description . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Category' => ". $c->Category . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t),\n", FILE_APPEND);
}
file_put_contents($outFile, ");\n", FILE_APPEND);
}
}

View File

@ -1,632 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Aide.",
'fichier=s' => "Nom du fichier complet : version ",
'affiche=s' => "Affiche resultat traitement "
));
$opts->parse();
$optionsNb = count($opts->getOptions());
}
catch (Zend_Console_Getopt_Exception $e)
{
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Charge les commentaires ratios à partir de CSV.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
#########################################################
##### Presence te taille du fichier #####
#########################################################
$fichier = $opts->fichier; // $fichier contient chemin/qqchose.csv
$nomfichier = basename($fichier); // $nomfichier contient qqchose.csv, basename retourne un array donc un tableau ayant comme valeur chacun des
// fichiers (chemain absolu) contenu dans le repertoir $directory, ici le repertoir contient normalement une seul fichier a la fois , donc $fichier[]
$fic = $fichier ; // On definti notre variable $fic comme etant notre fichier.
#########################################################
##### Teste de validité du nom du fichier #####
#########################################################
$detect1 = strstr($nomfichier, 'valo_commentaires_');
$detect2 = strstr($nomfichier, 'valo_formules_');
$detect3 = strstr($nomfichier, 'scores_formules_');
$detect4 = strstr($nomfichier, 'scores_commentaires_');
if ($detect1 !== false or $detect2 !== false or $detect3 !== false or $detect4 !== false)
{
echo "\n"." Nom du fichier ok"."\n" ;
}
else
{
echo "\n" . "le nom du fichier est incorrect" . "\n";
echo "\n" . "le nom du fichier doit obliqatoirement etre compose de la sorte :" . "\n";
echo "\n" . 'valo_commentaires_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'valo_formules_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'scores_formules_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'scores_commentaires_' . "\n";
Exit;
}
#########################################################
##### On indique si le fichier est present ou non #####
#########################################################
if ((file_exists($fichier)))
{
echo "\n Fichier $nomfichier au format csv trouve a l'emplacement prevu : \n";
echo "\n"." La taille du fichier est de :".filesize($fic)." octets"."\n";
$file = true;
}
else
{
echo "\n". "Pas de fichier .csv present a l'endroit indique"."\n";
$file = false;
exit;
}
#########################################################
##### taille du contenu du fichier #####
#########################################################
# déclaration variables :
$fileopen = fopen($fic, 'r');
$contenufichier = fgetcsv($fileopen);
$nblignes=0;
$cnbl = count($nblignes);
$fific = file($fic); // retourner le contenu du fichier dans une chaîne de caractères.
foreach ($fific as $line_num => $line)
{
$nblignes++;
}
echo "\n"." le fichier contient " . $nblignes . " lignes."."\n" ;
#########################################################
##### Routage vers commentaires ou formules #####
#########################################################
#variables :
$doublon = 0; // On initialise la variable doublon.
$row = 0 ; // On initialise les lignes.
$verif = array() ; // creation d'un tableau
$nom_fic = basename($fic) ;
$col3= 0;
#########################################################
##### Identification du type de fichier #####
#########################################################
//On commance rechercher si le nom du fichier contient "COMMENTAIRE" pour 4 colonnes sinon 2 colonnes
if (strstr($nom_fic, 'commentaires'))
{
$nbcol_cle = 4;
}
else
{
$nbcol_cle = 2;
}
// Si $fic est bien ouvert on commence le traitement.
if ($file = true )
{
$fileopen2 = fopen($fic, "r+");
if($fileopen2)
{
$contenufichier=fgetcsv($fileopen2);
$nblignes = file($fic);
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
$num = count($row); //compte nombre de partits dans la phrase
$row++;
// On fait une concatenation des colonnes de $fic dans un nouveau tableau nomme $cle.
// Cela nous permettera de dedoublonner par la suite.
if ($nbcol_cle == 4) // si nbcol = 4 alors notre clé sera composée de 4 colonnes sinon 3
{
$cle = $data[0].$data[1].$data[2].$data[3];
}
else
{
$cle = $data[0].$data[1].$data[2];
}
#########################################################
##### Dédoublonnage #####
#########################################################
// On regarde si on retrouve les valeurs de $verif dans $cle
if (in_array($cle, $verif, TRUE))
{
$doublon = $doublon + 1; // On définit un compteur qui nous indiquera le nombre de doublons
echo "\n"."Attention vous avez $doublon doublon(s) dans votre fichier !\n";
echo "\n"."il semblerait qu'il soit present a la ligne $row contenant $cle "."\n";
}
else
{
// Ajout de la cle au tableau indexe numeriquement
$verif[] = $cle ;
}
#########################################################
##### Routage commentaires ou formules #####
##### et verification des champs #####
#########################################################
if (strstr ($nom_fic , 'commentaires'))// le nom du fichier contient 'commentaires' alors ...
{
// On teste les champs vide
if (strlen($data[0])== 0 or strlen($data[1]) == 0
or strlen($data[2]) == 0 or strlen($data[3]) == 0)
{
echo "\n"."Erreur ! Vous avez des champs vides commentaires , sur la ligne $num"."\n"."contenant $data[1].$data[2].$data[3].$data[4].$data[5].$data[6].$data[7]";
}
if ($data[0] == 0)
{
echo "\n"."erreur code commentaire ". $data[0] ." null"."\n";
exit;
}
if($data[2] < 0)
{
echo "\n"."erreur code ligne " . $data[2] . "null"."\n";
exit;
}
}
elseif (strstr ($nom_fic , 'formules'))
{
if (strlen($data[0]) == 0 or strlen($data[1]) == 0 )
{
echo "\n"." Erreur vous avez des champs vides formules , sur la ligne $row"."\n"."contenant $data[0].$data[1]. . ";
exit;
}
if ($data[0] == 0)
{
echo "\n"."erreur code commentaire " . $data[0] . " null"."\n";
exit;
}
if($data[1] < 0)
{
echo "\n"."erreur code code ligne". $data[1] ."null"."\n";
exit;
}
}
}
}
}
if ($doublon >= 1)
{
$ok = false;
echo "\n"." $doublon Doublons détectés dans le fichier."."\n";
// Quitte avec un code d'erreur: doublon détecté.
exit(1);
}
elseif ($doublon == 0 && !file_exists($fic))
{
$ok = false;
exit;
}
else
{
// le script appelant continue.
$ok = true; // petit marqueur de fonctionnement du script jusqu'a présent
echo "\n Le fichier ne comporte pas de doublon. \n";
}
fclose($fileopen);
echo "\n Bon, maintenant on va passer a la base de donnee \n";
#########################################################
##### ________ ____ ____ #####
### | __ \ | \ | \ ###
# | / | |\ \ | |\ \ #
### | __ \ | |/ / | |/ / ###
##### |_______/ |___/ |___/ #####
#########################################################
// si notre scripte est bon on passe a la suite
$c = new Zend_Config($application->getOptions());
try {
$db = Zend_Db::factory($c->profil->db->metier);
$db->getConnection();
// print_r (get_class_methods($db));
}
catch (Zend_Exception $e)
{
echo $e->getMessage();
}
if ($db->isConnected())
{
echo "\n***********************************************\n";
echo "\n Connection a la BDD ok \n";
echo "\n***********************************************\n";
}
else
{
echo "\n***********************************************\n";
echo "\n !!!! Erreur / ! Pas connecte a la BDD !!!! \n";
echo "\n***********************************************\n";
}
$pathCache = APPLICATION_PATH . '/../library/Metier/Scores/Variables';
$copy_fic = $nomfichier;
if($nomfichier) // Si le nom du fichier comprend 'scores' ou 'valo'...
{
// On découpe la chaine de caractère à chaque "/" et on fait un array.
$token = basename($copy_fic);
// On prend ce qui se trouve avant le point
$token1 = strtok($token, ".");
// On effece '_utf8' et '.csv'
$nomtabletemp =(str_replace('_utf8', '', $token));
$nomtable =(str_replace('.csv','', $nomtabletemp));
// Affichage du nom de la table
echo "\n Le nom de la table est : $nomtable . \n";
}
####################################################
##### // Création de la Table Ccmmentaires \\ #####
####################################################
if (strstr($nomtable,"commentaires"))
{
try
{
// Création d'une table "TEXTE"
$sql_ctc_query = $db->query("CREATE TABLE $nomtable
(
code int(8) NOT NULL,
langue char(2) NOT NULL,
cycle smallint(3) NOT NULL,
ligne char(4) NOT NULL,
commentaire longtext,
tri varchar(5) DEFAULT NULL,
deleted varchar(2) DEFAULT NULL,
idUser varchar(0) DEFAULT NULL,
dateInsert varchar(15) DEFAULT NULL,
dateUpdate varchar(0) DEFAULT NULL,
PRIMARY KEY (code,langue,cycle,ligne)
)
ENGINE = MyISAM DEFAULT CHARSET=latin1 COMMENT= 'Commentaires Valorisation - Liste des commentaires';");
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!! ERREUR ! / CHARGEMENT ARRETE !!!!!"."\n"."\n";
}
echo "\n" . " Table $nomtable cree." ."\n";
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$fileopen2 = fopen($fic, "r+");
$nbr=0;
if($fileopen2)
{
$contenufichier=fgetcsv($fileopen2);
$nblignes = file($fic);
$vide = "";
$null = null;
$zero = 0;
}
else
{
exit;
echo "\n"."Erreur a l'ouverture du fichier"."\n";
}
if(strstr($nomtable,"commentaires"))
{
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
####################################################
##### encodage et remplacement du contenu #####
####################################################
$data[4] = str_replace(chr(93), "]", $data[4]); // crochet fermant
$data[4] = str_replace(chr(92), "\\" , $data[4]); // anti slash
$data[4] = str_replace(chr(128), '€', $data[4]); // devise euros
$data[4] = str_replace(chr(130), ',', $data[4]); // baseline single quote
$data[4] = str_replace(chr(132), '"', $data[4]); // baseline double quote
$data[4] = str_replace(chr(133), '...', $data[4]); // ellipsis
$data[4] = str_replace(chr(145), "'", $data[4]); // left single quote
$data[4] = str_replace(chr(146), "'", $data[4]); // right single quote
$data[4] = str_replace(chr(147), '"', $data[4]); // left double quote
$data[4] = str_replace(chr(148), '"', $data[4]); // right double quote
$data[4] = str_replace(chr(150), '', $data[4]); // tiret du 6
$data[5] = str_replace(chr(93), "]", $data[5]); // crochet fermant
$data[5] = str_replace(chr(92), "\\" , $data[5]); // anti slash
$data[5] = str_replace(chr(128), '€', $data[5]); // devise euros
$data[5] = str_replace(chr(130), ',', $data[5]); // baseline single quote
$data[5] = str_replace(chr(132), '"', $data[5]); // baseline double quote
$data[5] = str_replace(chr(133), '...', $data[5]); // ellipsis
$data[5] = str_replace(chr(145), "'", $data[5]); // left single quote
$data[5] = str_replace(chr(146), "'", $data[5]); // right single quote
$data[5] = str_replace(chr(147), '"', $data[5]); // left double quote
$data[5] = str_replace(chr(148), '"', $data[5]); // right double quote
$data[5] = str_replace(chr(150), '', $data[5]); // tiret du 6
$encode = mb_detect_encoding($data[4]); // detection de l'encodage.
$encode = mb_detect_encoding($data[5]); // detection de l'encodage.
$data[4] = mb_convert_encoding($data[4], $encode, 'UTF-8');
$data[5] = mb_convert_encoding($data[5], $encode, 'UTF-8');
// $Zdata4 = '"'.$db->->real_escape_string($data[4]);
// $Zdata4 = $db->quote($data[4]);
//$Zdata4 = mysqli_real_escape_string($db, $data[4]);
if ($data[5] == null)
{
$data[5] = 0;
}
$zdata4= $db->quote($data[4]);
$nbr++;
// ESSAI 1
$sql_insert = array
(
'code' => "$data[0]",
'langue' => "$data[1]",
'cycle' => "$data[2]",
'ligne' => "$data[3]",
'commentaire' => "$data[4]",
'tri' => "$data[5]",
'deleted' => "$null",
'idUser' => "$null",
'dateInsert' => "$null",
'dateUpdate' => "$null"
);
try
{
# $num = count($row); // On compte nombre de parti dans la phrase
# $row++; // à chaques tour de boucle j'ajoute 1 à $row
// ESSAI 2
/*
$sql_itc = $db->query("INSERT INTO $nomtable
(
code, langue, cycle, ligne, commentaire, tri, deleted, idUser, dateInsert, dateUpdate)
VALUES
(
".$data[0].",".$data[1].",".$data[2].",".$data[3].",".$Zdata4.",".$data[5].",'','','',)
");
*/
$db->insert($nomtable, $sql_insert);
//`
// Astuce !! La structure de $data[0] étant un int on retire les "
// Astuce !! La colonne 5 contenant des apostrophs étant interprété par le sql comme un nouveau champ il est necessaire de protéger ce champs, du coup in ajoute la fonction mysql_real_escape_string() pour insérer un antislash devant les caractères " NULL, \x00, \n, \r, \, ', " et \x1a. "
}
// Renseignement sur les erreurs possibles
#echo ("$sql_itt");
catch(Zend_Exception $e)
{
echo "\n" . $e->getMessage()."\n";
//echo "\n"."!!!!!!!!!!!!!!!!!!!!! Import de la table $nomtable echouee. !!!!!!!!!!!!!!!!!!!!!"."\n"."\n";
//$sql_erase = $db->query("DROP TABLE $nomtable;");
//echo "La table $nomtable a ete effacee !! \n ";
}
}
echo "\n"."Import de la table $nomtable . ok". "\n";
// comptage sql
$comptage = count($sql_itc_query);
echo "\n"."Nombre de lignes importees : "."$nbr"."\n";
exit;
}
elseif(strstr($nomtable,"formules"))
{
####################################################
// Création de la Table formules \\
####################################################
try{
$sql_ctf_query = $db->query("CREATE TABLE $nomtable
(
code int(8) NOT NULL DEFAULT '0',
ligne char(4) NOT NULL DEFAULT '',
remarque varchar(120) DEFAULT NULL,
operande varchar(7) DEFAULT NULL,
ope1 varchar(255) DEFAULT NULL,
operation varchar(9) DEFAULT NULL,
valeur varchar(255) DEFAULT NULL,
tri varchar(0) DEFAULT NULL,
deleted varchar(0) DEFAULT NULL,
idUser varchar(0) DEFAULT NULL,
dateInsert varchar(0) DEFAULT NULL,
dateUpdate varchar(0) DEFAULT NULL,
PRIMARY KEY (code,ligne)
)
ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Criteres Valorisation - Formules de calculs' ;");
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!!!!!!!!!!!!!!!!!! CHARGEMENT ARRETE !!!!!!!!!!!!!!!!!!!!!"."\n"."\n";
}
echo "\n Table $nomtable cree.\n";
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
####################################################
##### encodage et remplacement du contenu #####
####################################################
$data[2] = str_replace(chr(93), "]", $data[2]); // crochet fermant
$data[2] = str_replace(chr(92), "\\" , $data[2]); // anti slash
$data[2] = str_replace(chr(128), '€', $data[2]); // devise euros
$data[2] = str_replace(chr(130), ',', $data[2]); // baseline single quote
$data[2] = str_replace(chr(132), '"', $data[2]); // baseline double quote
$data[2] = str_replace(chr(133), '...', $data[2]); // ellipsis
$data[2] = str_replace(chr(145), "'", $data[2]); // left single quote
$data[2] = str_replace(chr(146), "'", $data[2]); // right single quote
$data[2] = str_replace(chr(147), '"', $data[2]); // left double quote
$data[2] = str_replace(chr(148), '"', $data[2]); // right double quote
$data[2] = str_replace(chr(150), '', $data[2]); // tiret du 6
$data[4] = str_replace(chr(93), "]", $data[4]); // crochet fermant
$data[4] = str_replace(chr(92), "\\" , $data[4]); // anti slash
$data[4] = str_replace(chr(128), '€', $data[4]); // devise euros
$data[4] = str_replace(chr(130), ',', $data[4]); // baseline single quote
$data[4] = str_replace(chr(132), '"', $data[4]); // baseline double quote
$data[4] = str_replace(chr(133), '...', $data[4]); // ellipsis
$data[4] = str_replace(chr(145), "'", $data[4]); // left single quote
$data[4] = str_replace(chr(146), "'", $data[4]); // right single quote
$data[4] = str_replace(chr(147), '"', $data[4]); // left double quote
$data[4] = str_replace(chr(148), '"', $data[4]); // right double quote
$data[4] = str_replace(chr(150), '', $data[4]); // tiret du 6
$data[5] = str_replace(chr(93), "]", $data[5]); // crochet fermant
$data[5] = str_replace(chr(92), "\\" , $data[5]); // anti slash
$data[5] = str_replace(chr(128), '€', $data[5]); // devise euros
$data[5] = str_replace(chr(130), ',', $data[5]); // baseline single quote
$data[5] = str_replace(chr(132), '"', $data[5]); // baseline double quote
$data[5] = str_replace(chr(133), '...', $data[5]); // ellipsis
$data[5] = str_replace(chr(145), "'", $data[5]); // left single quote
$data[5] = str_replace(chr(146), "'", $data[5]); // right single quote
$data[5] = str_replace(chr(147), '"', $data[5]); // left double quote
$data[5] = str_replace(chr(148), '"', $data[5]); // right double quote
$data[5] = str_replace(chr(150), '', $data[5]); // tiret du 6
$data[6] = str_replace(chr(93), "]", $data[6]); // crochet fermant
$data[6] = str_replace(chr(92), "\\" , $data[6]); // anti slash
$data[6] = str_replace(chr(128), '€', $data[6]); // devise euros
$data[6] = str_replace(chr(130), ',', $data[6]); // baseline single quote
$data[6] = str_replace(chr(132), '"', $data[6]); // baseline double quote
$data[6] = str_replace(chr(133), '...', $data[6]); // ellipsis
$data[6] = str_replace(chr(145), "'", $data[6]); // left single quote
$data[6] = str_replace(chr(146), "'", $data[6]); // right single quote
$data[6] = str_replace(chr(147), '"', $data[6]); // left double quote
$data[6] = str_replace(chr(148), '"', $data[6]); // right double quote
$data[6] = str_replace(chr(150), '', $data[6]); // tiret du 6
$encode = mb_detect_encoding($data[2]); // detection de l'encodage.
$encode = mb_detect_encoding($data[5]); // detection de l'encodage.
$encode = mb_detect_encoding($data[4]); // detection de l'encodage.
$encode = mb_detect_encoding($data[6]); // detection de l'encodage.
$data[2] = mb_convert_encoding($data[2], $encode, 'UTF-8');
$data[4] = mb_convert_encoding($data[4], $encode, 'UTF-8');
$data[5] = mb_convert_encoding($data[5], $encode, 'UTF-8');
$data[6] = mb_convert_encoding($data[6], $encode, 'UTF-8');
$sql_insert = array(
'code' => "$data[0]",
'ligne' => "$data[1]",
'remarque' => "$data[2]",
'operande' => "$data[3]",
'ope1' => "$data[4]",
'operation' => "$data[5]",
'valeur' => "$data[6]",
'tri' => "$null",
'deleted' => "$null",
'idUser' => "$null",
'dateInsert' => "$null",
'dateUpdate' => "$null"
);
$nbr++;
try{
$db->insert($nomtable, $sql_insert);
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!! ERREUR ! / CHARGEMENT ARRETE !!!!!"."\n"."\n";
}
}
echo "\n"." Import de la table $nomtable ok."."\n";
// comptage sql
$comptage = count($sql_insert);
echo "\n"." Nombre de lignes importees : "."$nbr"."\n";
fclose($fileopen2);
exit;
}
// Exécution de la requête
//$result = $db->query($sql_ctt);
// Renseignement sur les erreurs possibles
// echo "<strong>" . $Erreur . "</strong> <br /> <br />\n";
//
// if ($sql_ctt_query) // si code retour OK
// {
// echo "Création de la table $nomtable ok.<br />";
// }
// else
// {
// echo "Création de la table $nomtable échouée.<br />";
// }

33
composer-develop.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "scores/webservice",
"description": "Webservice API",
"require": {
"zendframework/zendframework1": "^1.12",
"geshi/geshi": "dev-master",
"league/csv": "^8.1",
"doctrine/dbal": "^2.5",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"scores/library": "dev-develop"
},
"repositories": [
{
"type": "git",
"url": "git@gitlab.factory.insight.doubletrade.com:scores/library.git"
}
],
"include-path": ["library/"],
"autoload": {
"classmap": [
"application/",
"library/Application/"
]
},
"authors": [
{
"name": "Scores et Decisions",
"email": "supportdev@scores-decisions.com"
}
]
}

19
composer.lock generated
View File

@ -481,12 +481,12 @@
"source": {
"type": "git",
"url": "https://github.com/GeSHi/geshi-1.0.git",
"reference": "66e94d3b274cee8aaab221caf199117542d31a4e"
"reference": "6b2973d145ac9b20b4f3df1dc98bda3f13066e90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GeSHi/geshi-1.0/zipball/66e94d3b274cee8aaab221caf199117542d31a4e",
"reference": "66e94d3b274cee8aaab221caf199117542d31a4e",
"url": "https://api.github.com/repos/GeSHi/geshi-1.0/zipball/6b2973d145ac9b20b4f3df1dc98bda3f13066e90",
"reference": "6b2973d145ac9b20b4f3df1dc98bda3f13066e90",
"shasum": ""
},
"require-dev": {
@ -513,7 +513,7 @@
],
"description": "Generic Syntax Highlighter",
"homepage": "http://qbnz.com/highlighter/",
"time": "2017-04-04 05:32:42"
"time": "2017-04-09 14:44:44"
},
{
"name": "guzzlehttp/guzzle",
@ -1052,7 +1052,7 @@
"source": {
"type": "git",
"url": "git@gitlab.factory.insight.doubletrade.com:scores/library.git",
"reference": "59285193eb629e6f321a2cad42b5ac6738ea746e"
"reference": "c130f972acc31cf1fc97902832840f273c248834"
},
"require": {
"doctrine/dbal": "^2.5",
@ -1063,6 +1063,13 @@
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "2.*"
},
"bin": [
"bin/library-cache.php",
"bin/library-log.php",
"bin/library-ratios.php",
"bin/library-ratiosload.php",
"bin/library-sfr.php"
],
"type": "library",
"autoload": {
"classmap": [
@ -1080,7 +1087,7 @@
}
],
"description": "library",
"time": "2017-04-06 08:53:44"
"time": "2017-04-11 08:46:47"
},
{
"name": "zendframework/zendframework1",

View File

@ -3534,7 +3534,7 @@ class Entreprise extends Scores_Ws_Server
$this->permission('ratios');
global $tva, $tabFormules, $mBil, $tabBilan, $efftr, $tabInfla;
$tabFormules = include APPLICATION_PATH . '/../library/Metier/Scores/Data/TabFormules.php';
$tabFormules = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Scores/Data/TabFormules.php';
//Initialisation
if (empty($page)) $page = 'ratios';

View File

@ -2766,7 +2766,7 @@ class Entreprise extends Scores_Ws_Server
$output->Indiscore = $Indiscore;
//Tableau d'infos sur les formules
$tabFormules = include APPLICATION_PATH . '/../library/Metier/Scores/Data/Formules.php';
$tabFormules = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Scores/Data/Formules.php';
$tabBorneMin = $tabBorneMax = array();
foreach ($tabFormules as $formule) {
$id = $formule['id']*1;
@ -4684,7 +4684,7 @@ class Entreprise extends Scores_Ws_Server
/**
* Tableau d'infos sur les formules
*/
$tabFormules = include APPLICATION_PATH . '/../library/Metier/Scores/Data/Formules.php';
$tabFormules = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Scores/Data/Formules.php';
$tabBorneMin = $tabBorneMax = array();
foreach ($tabFormules as $formule) {
$tabFormulesInfos[$id] = $formule; //Pour la gestion des unités des ratios secteur

View File

@ -881,8 +881,8 @@ class Entreprise extends Scores_Ws_Server
}
}
$status = include APPLICATION_PATH . '/../library/Metier/Ctx/AffaireStatus.php';
$categories = include APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php';
$status = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Ctx/AffaireStatus.php';
$categories = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Table/AffairesTypes.php';
$affaireList = array();
if ($stmt->rowCount() > 0) {
@ -1048,8 +1048,8 @@ class Entreprise extends Scores_Ws_Server
}
// --- Formattage
$status = include APPLICATION_PATH . '/../library/Metier/Ctx/AffaireStatus.php';
$categories = include APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php';
$status = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Ctx/AffaireStatus.php';
$categories = include APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Table/AffairesTypes.php';
$output = new GreffeAffaireDetail();
$output->Id = $affaireResult->id;