238 lines
5.9 KiB
PHP
238 lines
5.9 KiB
PHP
<?php
|
|
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_WARNING);
|
|
|
|
// Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
|
|
|
// Define application environment
|
|
defined('APPLICATION_ENV')
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
// Ensure library/ is on include_path
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
get_include_path(),
|
|
)));
|
|
|
|
/** Zend_Application */
|
|
require_once 'Zend/Application.php';
|
|
|
|
// Create application, bootstrap, and run
|
|
$application = new Zend_Application(
|
|
APPLICATION_ENV,
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
);
|
|
|
|
try {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => "Displays usage information.",
|
|
'manual=s' => "Provide manualy the file without save in database",
|
|
'debug' => "Send a mail for debug",
|
|
)
|
|
);
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
//Usage
|
|
if( isset($opts->help) || count($opts->getOptions())==0 )
|
|
{
|
|
echo "Place files in right directory for sending to the customer.\n";
|
|
echo $opts->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
require_once APPLICATION_PATH.'/configs/config.php';
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
|
|
|
|
$sfrdataM = new Application_Model_JoSfrData();
|
|
|
|
//Select NumSeq
|
|
$sql = $sfrdataM->select()
|
|
->order('dateInsert DESC')
|
|
->limit(1);
|
|
$result = $sfrdataM->fetchRow($sql);
|
|
$numSeq = $result->NumSeq;
|
|
|
|
//Select all NumSeq
|
|
$sql = $sfrdataM->select()->where('NumSeq=?',$numSeq);
|
|
$result = $sfrdataM->fetchAll($sql);
|
|
|
|
$fileValues = array();
|
|
|
|
if ( $result->count()>0 ) {
|
|
|
|
//Marqueur suppression dans les portefeuilles
|
|
|
|
//Pour chaque entité
|
|
foreach ($result as $item) {
|
|
$values = array();
|
|
|
|
//Est ce que la surveillance existe ?
|
|
$survM = new Application_Model_JoSurveillancesSite();
|
|
$row = $survM->fetchRow("login='".$login."' AND siren='".$siren."' AND source='".$source."'");
|
|
|
|
// |- non => on insert
|
|
// |-- Est ce une surveillance score ?
|
|
// |--- oui => on initialise avec le scores dans scores_surveillance
|
|
// |--- Si surveillance scores, on garde les éléments pour le fichier
|
|
if ( $row === null ) {
|
|
|
|
if ($source == 'score') {
|
|
|
|
$scoresurvM = new Application_Model_JoScoresSurveillance();
|
|
$rowscore = $scoresurvM->fetchRow("siren='".$siren."' AND source='".$source."'");
|
|
if ($rowscore !== null) {
|
|
//Assignation des variables au fichier
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteLight($siren, $nic);
|
|
|
|
$data = array(
|
|
'source' => $source,
|
|
'login' => $login,
|
|
'email' => $email,
|
|
'siren' => $siren,
|
|
'nic' => $nic,
|
|
'ref' => $ref,
|
|
'encoursClient' => $encoursClient,
|
|
'rs' => $tabIdentite['Nom'],
|
|
'cp' => $tabIdentite['CP'],
|
|
'ville' => $tabIdentite['Ville'],
|
|
'dateAjout'=>date('Y-m-d'),
|
|
'dateSuppr'=>0,
|
|
);
|
|
|
|
|
|
$values = array(
|
|
'loginUti' => $login,
|
|
'source' => $source,
|
|
'email' => $email,
|
|
'siren' => $siren,
|
|
'nic' => '00000',
|
|
'ref' => 'AUTO',
|
|
'dateAjout' => date('Y-m-d'),
|
|
|
|
'rs' => IDENTITE,
|
|
'cp' => IDENTITE,
|
|
'ville' => IDENTITE,
|
|
|
|
'dateDerEnvoi' => '0000-00-00 00:00:00',
|
|
'encoursClient' => 0,
|
|
'actif' => scores_surveillance,
|
|
'procol' => scores_surveillance,
|
|
'indiScore20' => scores_surveillance,
|
|
'encours' => scores_surveillance,
|
|
'indiScoreDate' => scores_surveillance,
|
|
'dateBilan' => scores_surveillance,
|
|
'indiScore20Pre' => scores_surveillance,
|
|
'encoursPre' => scores_surveillance,
|
|
'indiScoreDatePre' => scores_surveillance,
|
|
'sourceModif' => scores_surveillance,
|
|
'scoreSolv' => scores_surveillance,
|
|
'scoreSolvPre' => scores_surveillance,
|
|
'scoreDir' => scores_sureillance,
|
|
'scoreDirPre' => scores_surveillance,
|
|
'scoreConf' => scores_surveillance,
|
|
'scoreConfPre' => scores_surveillance,
|
|
|
|
'cj' => IDENTITE,
|
|
'capital' => IDENTITE,
|
|
'capitalDev' => IDENTITE,
|
|
'ape_entrep' => IDENTITE,
|
|
'tca' => IDENTITE,
|
|
'teff_entrep' => IDENTITE,
|
|
|
|
'dateUpdate' => scores_surveillance,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
//Insertion de la surveillance
|
|
|
|
|
|
} else {
|
|
// |- oui => on réactive
|
|
// |-- Si surveillance scores, on garde les éléments pour le fichier
|
|
|
|
if ($source == 'score') {
|
|
|
|
//Assignation des variables au fichier
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fileValues[] = $values;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
loginUti => AUTO
|
|
source => score
|
|
email => ''
|
|
siren => scores_surveillance
|
|
nic => 00000
|
|
ref => AUTO
|
|
dateAjout => sfr_data
|
|
|
|
rs => IDENTITE
|
|
cp => IDENTITE
|
|
ville => IDENTITE
|
|
|
|
dateDerEnvoi => 0000-00-00 00:00:00
|
|
encoursClient => 0
|
|
actif => scores_surveillance
|
|
procol => scores_surveillance
|
|
indiScore20 => scores_surveillance
|
|
encours => scores_surveillance
|
|
indiScoreDate => scores_surveillance
|
|
dateBilan => scores_surveillance
|
|
indiScore20Pre => scores_surveillance
|
|
encoursPre => scores_surveillance
|
|
indiScoreDatePre => Lecture historique
|
|
sourceModif => scores_surveillance
|
|
scoreSolv => scores_surveillance
|
|
scoreSolvPre => scores_surveillance
|
|
scoreDir => scores_sureillance
|
|
scoreDirPre => scores_surveillance
|
|
scoreConf => scores_surveillance
|
|
scoreConfPre => scores_surveillance
|
|
|
|
cj => IDENTITE
|
|
capital => IDENTITE
|
|
capitalDev => IDENTITE
|
|
ape_entrep => IDENTITE
|
|
tca => IDENTITE
|
|
teff_entrep => IDENTITE
|
|
|
|
dateUpdate => scores_surveillance
|
|
*/
|
|
|
|
/*
|
|
- Reprise du fichier ? ou lecture dans la bdd
|
|
- Pour chaque entités
|
|
1 -> Mettre le marqueur de suppression sur toutes les entités du portefeuille (login)
|
|
2 -> Pour element du fichier ajouter ou réactiver surveillance
|
|
(login, email) + initialisation suivant les éléments de scores_surveillance
|
|
3 -> A la lecture des scores du portefeuille ou de scores_surveillance alors on place dans le fichier
|
|
|
|
*/
|
|
|