actionnaires multiligne, ajout des models et controle....

This commit is contained in:
Michael RICOIS 2013-02-19 13:53:38 +00:00
parent eebdaa2303
commit 4059e0dd19
9 changed files with 88 additions and 36 deletions

View File

@ -39,7 +39,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
$c = Zend_Registry::get('config');
try {
$db = Zend_Db::factory($c->profil->db);
$db = Zend_Db::factory($c->profil->db->local);
Zend_Db_Table::setDefaultAdapter ($db);
} catch ( Exception $e ) {
exit ( $e->getMessage() );

View File

@ -20,12 +20,21 @@ profil.mail.smtp_host = smtp.free.fr
profil.mail.email.support = support@scores-decisions.com
profil.mail.email.supportdev = supportdev@scores-decisions.com
profil.path.data = "C:\Users\mricois\www\dataenrichissement"
profil.db.adapter=mysqli
profil.db.params.host=127.0.0.1
profil.db.params.username=root
profil.db.params.password=bj10sx
profil.db.params.dbname=enrichissement
profil.db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
profil.db.local.adapter=mysqli
profil.db.local.params.host=127.0.0.1
profil.db.local.params.username=root
profil.db.local.params.password=bj10sx
profil.db.local.params.dbname=enrichissement
profil.db.local.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
profil.db.jo.adapter=mysqli
profil.db.jo.params.host=88.190.14.56
profil.db.jo.params.port=53336
profil.db.jo.params.username=wsuser
profil.db.jo.params.password=wspass2012
profil.db.jo.params.dbname=jo
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
[staging : production]
resources.frontController.params.displayExceptions = 0

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_JoLiens extends Zend_Db_Table_Abstract
{
protected $_name = 'liens2';
}

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_JoLiensDoc extends Zend_Db_Table_Abstract
{
protected $_name = 'liensDoc';
}

View File

@ -0,0 +1,15 @@
<?php
class Application_Model_JoLiensRef extends Zend_Db_Table_Abstract
{
protected $_name = 'liensRef';
public function insert(array $data)
{
// Ajout d'un timestamp
if (empty($data['dateInsert'])) {
$data['dateInsert'] = date('YmdHis');
}
return parent::insert($data);
}
}

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_JoTabPays extends Zend_Db_Table_Abstract
{
protected $_name = 'tabPays';
}

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_Sdv1TabIdLocal extends Zend_Db_Table_Abstract
{
protected $_name = 'tabIdLocal';
}

View File

@ -258,8 +258,9 @@ Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
//Définition bdd local
$config = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $config);
try {
$db = Zend_Db::factory($config->profil->db);
$db = Zend_Db::factory($config->profil->db->local);
} catch ( Exception $e ) {
exit ( $e->getMessage() );
}
@ -494,7 +495,7 @@ $tabEntete[] = 'SiretValide';
if( null != $profilDoublon ) {
$tabEntete[] = 'Doublon';
}
unset($tabExtract);
//unset($tabExtract);
//Construction de l'entete pour le fichier
$tabEnteteF = array();
@ -538,6 +539,7 @@ if ( $opts->reprise ) {
}
$row = 0;
$extendNbRow = 0;
$doublonList = array();
//Vérification et création des données
@ -578,24 +580,24 @@ foreach($tabIdentifiant as $item)
//On définit le tableau de retour (les colonnes du fichier client sont déjà présentent)
if ( $posKeySiret!==false ){
$tabData[$row]['siret'] = $item;
$tabData[$extendNbRow]['siret'] = (string)$item;
} elseif ( $posKeySiren!==false && $posKeyNic!==false ){
$tabData[$row]['siren'] = $siren;
$tabData[$row]['nic'] = $nic;
$tabData[$extendNbRowow]['siren'] = (string)$siren;
$tabData[$extendNbRow]['nic'] = (string)$nic;
} elseif ( $posKeySiren !==false ){
$tabData[$row]['siren'] = $siren;
$tabData[$extendNbRow]['siren'] = (string)$siren;
}
$tabData[$row]['SiretValide'] = ($siretValide===true) ? 1 : 0;
$tabData[$extendNbRow]['SiretValide'] = ($siretValide===true) ? 1 : 0;
//Clé de doublon
$keyDoublon = null;
if ( array_key_exists('keyDoublon', $tabData[$row])) {
$keyDoublon = $tabData[$row]['keyDoublon'];
if ( array_key_exists('keyDoublon', $tabData[$extendNbRow])) {
$keyDoublon = $tabData[$extendNbRow]['keyDoublon'];
}
if ( null !== $keyDoublon && in_array($keyDoublon, $doublonList) ) {
$tabData[$row]['doublon'] = 1;
$tabData[$extendNbRow]['doublon'] = 1;
} elseif ( $sirenValide===false || intval($siren)==0 ){
//Siren faux
} else {
@ -632,8 +634,8 @@ foreach($tabIdentifiant as $item)
}
if ( $posKeySiren!==false && $posKeyNic!==false ){
$tabData[$row]['siren'] = $siren;
$tabData[$row]['nic'] = $nicV;
$tabData[$extendNbRow]['siren'] = $siren;
$tabData[$extendNbRow]['nic'] = $nicV;
}
//Récupération des données SQL
@ -650,7 +652,7 @@ foreach($tabIdentifiant as $item)
$stmt = $dbMetier->query(${$element.'SQL'});
$result = $stmt->fetchAll();
if ( count($result)>0 ) {
$tabData[$row] = array_merge( $tabData[$row] , $result[0]);
$tabData[$extendNbRow] = array_merge( $tabData[$extendNbRow] , $result[0]);
}
} catch (Zend_Db_Exception $e) {
@ -677,7 +679,7 @@ foreach($tabIdentifiant as $item)
$values = ${$selectItem.'Data'};
}
$retour = call_user_func($selectItem.'Data', $siren, $nicV, $values);
$tabData[$row] = $tabData[$row] + $retour;
$tabData[$extendNbRow] = $tabData[$extendNbRow] + $retour;
}
}
}
@ -685,20 +687,22 @@ foreach($tabIdentifiant as $item)
//Retour lignes multiples
elseif ( $element == 'multiple' )
{
$isSelected = false;
foreach($select as $selectItem){
if ( in_array($selectItem, $tabEntete) ) {
if ( in_array($selectItem, $tabExtract) ) {
$isSelected = true;
break;
}
}
$retour = array();
if ( function_exists($selectItem) ) {
if ( $isSelected && function_exists($selectItem.'Multiple') ) {
$retour = call_user_func($selectItem.'Multiple', $siren, $nicV);
}
if (count($retour)>0) {
$originalLine = $tabData[$row];
$originalLine = $tabData[$extendNbRow];
foreach($retour as $i => $retourItem) {
$row = $row + $i;
$tabData[$row] = $originalLine + $retourItem;
$extendNbRow = $extendNbRow + $i;
$tabData[$extendNbRow] = $originalLine + $retourItem;
}
}
}
@ -711,14 +715,14 @@ foreach($tabIdentifiant as $item)
if ( in_array($cle.'Lib', $tabEntete) && isset(${'tab'.ucfirst($cle)}) )
{
$retour[$cle.'Lib'] = 'Non trouvé';
$codeFromData = $tabData[$row][$cle];
$codeFromData = $tabData[$extendNbRow][$cle];
foreach( ${'tab'.ucfirst($cle)} as $cleItem ) {
if ( $codeFromData == $cleItem['code'] ) {
$retour[$cle.'Lib'] = $cleItem['label'];
break;
}
}
$tabData[$row] = $tabData[$row] + $retour;
$tabData[$extendNbRow] = $tabData[$extendNbRow] + $retour;
}
}
}
@ -731,13 +735,16 @@ foreach($tabIdentifiant as $item)
}
//Trier pour la sortie
$tabSortie = array();
foreach($tabEntete as $key){
$tabSortie[] = isset($tabData[$row][$key]) ? $tabData[$row][$key] : '';
$nbLine = $extendNbRow - $row;
for($i=0;$i<=$nbLine;$i++) {
$tabSortie = array();
foreach($tabEntete as $key){
$tabSortie[] = isset($tabData[$row+i][$key]) ? $tabData[$row+$i][$key] : '';
}
fputcsv($fp, $tabSortie, ',', '"');
}
fputcsv($fp, $tabSortie, ',', '"');
$extendNbRow++;
$row++;
echo "OK";
}
@ -1539,6 +1546,8 @@ function actionnairesMultiple($siren, $nic)
}
}
print_r($tabData);
return $tabData;
}

View File

@ -38,15 +38,14 @@ class MLiens2
} else {
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini');
}
//Connect to the database
try {
$this->db = Zend_Db::factory($c->profil->db->jo);
$this->db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage(), 'ERR');
throw new Exception($e->getMessage());
} catch (Zend_Exception $e) {
throw new Exception("Application error", 'ERR');
throw new Exception($e->getMessage());
}
if ( $type == 'siren' ) {