299 lines
5.6 KiB
PHP
299 lines
5.6 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
class Metier_Sfr
|
|
{
|
|
/**
|
|
* Version of rules (for loading static files)
|
|
* @var double
|
|
*/
|
|
protected $version = '1.0';
|
|
|
|
/**
|
|
* Debug mode
|
|
* @var boolean
|
|
*/
|
|
protected $debug = false;
|
|
|
|
/**
|
|
* True, to use static file for set vars otherwise read in the database
|
|
* @var boolean
|
|
*/
|
|
protected $compile = true;
|
|
|
|
/**
|
|
* Feu vert
|
|
* @var int
|
|
*/
|
|
const VERT = 3;
|
|
|
|
/**
|
|
* Feu orange
|
|
* @var int
|
|
*/
|
|
const ORANGE = 2;
|
|
|
|
/**
|
|
* Feu rouge
|
|
* @var int
|
|
*/
|
|
const ROUGE = 1;
|
|
|
|
/**
|
|
* CAC = Entreprise du CAC
|
|
* @var int
|
|
*/
|
|
const CAC = 4;
|
|
|
|
/**
|
|
* GE = Grande Entreprise
|
|
* @var int
|
|
*/
|
|
const GE = 3;
|
|
|
|
/**
|
|
* Petites et Moyennes Entreprise
|
|
* @var int
|
|
*/
|
|
const PME = 2;
|
|
|
|
/**
|
|
* Très Petites Entreprise
|
|
* @var int
|
|
*/
|
|
const TPE = 1;
|
|
|
|
/**
|
|
* Liste des NAF Administration
|
|
* @var array
|
|
*/
|
|
protected $TabAdminNaf = null;
|
|
|
|
/**
|
|
* Liste des FJ Administration
|
|
* @var array
|
|
*/
|
|
protected $TabAdminFj = null;
|
|
protected $TabEtrangerNaf = null;
|
|
protected $TabEtrangerFj = null;
|
|
protected $TabNafSFR = null;
|
|
|
|
//Valeurs à remplir
|
|
protected $ValIsCAC = null;
|
|
protected $ValIsAdmin = null;
|
|
protected $ValIsEtranger = null;
|
|
protected $ValEffectif = null;
|
|
protected $ValNAF = null;
|
|
protected $ValFJ = null;
|
|
protected $ValRJ = null;
|
|
protected $ValLJ = null;
|
|
protected $ValSV = null;
|
|
protected $ValIndiscore = null;
|
|
protected $ValInseeActif = null;
|
|
protected $ValInseeAge = null;
|
|
protected $ValEntrepRecente = null;
|
|
|
|
protected $ValContratDate = null;
|
|
protected $ValIR = null;
|
|
|
|
protected $ValVOR = null;
|
|
protected $ValPO = null;
|
|
protected $ValComment = null;
|
|
|
|
|
|
//Rules
|
|
protected $RulesVORP = array();
|
|
protected $RulesVORD = array();
|
|
protected $RulesPO = array();
|
|
|
|
public function __construct( $version = null, $compile = true )
|
|
{
|
|
$this->setVersion($version);
|
|
|
|
$this->setCompile($compile);
|
|
|
|
|
|
|
|
//Charger les Tabs
|
|
//Charger les Rules (dans l'ordre)
|
|
//Charger les paramètres
|
|
}
|
|
|
|
|
|
|
|
|
|
public function evaluate($siren)
|
|
{
|
|
|
|
}
|
|
|
|
protected function rules($type)
|
|
{
|
|
//VORP
|
|
|
|
|
|
//VORD
|
|
|
|
}
|
|
|
|
/**
|
|
* Traitement des conditions
|
|
* - Si la condition est FAUSSE
|
|
* => passe à la règle condition suivante
|
|
* - Si la condition est VRAI
|
|
* => Valeur de retour à "NULL", arrêt
|
|
* => Valeur de retour à "blanc", passe à la règle suivante
|
|
* => Sinon défintion de la valeur de retour et arrêt
|
|
* @param array $conditions
|
|
* - var : Nom de la variable
|
|
* - type : Type du test de la condition
|
|
* - value : Valeur à tester
|
|
* - define : "var" à définir avec la "value"
|
|
*/
|
|
protected function params($conditions = array())
|
|
{
|
|
if ( count($conditions) > 0 ) {
|
|
foreach ( $conditions as $c ) {
|
|
|
|
$test = $this->paramEval($c['var'], $c['type'], $c['value']);
|
|
if ( null === $test ) {
|
|
//Oops ! Problem !
|
|
}
|
|
//Aller à la condition suivante
|
|
elseif ( $test === false ) {
|
|
continue;
|
|
}
|
|
//
|
|
elseif ( $test === true ) {
|
|
|
|
//$this->paramDefine();
|
|
|
|
return $c['return'];
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Transformation des variables
|
|
* @param string $val
|
|
* @return number|mixed|NULL
|
|
*/
|
|
protected function paramValue($val)
|
|
{
|
|
if ( is_numeric($val) ) {
|
|
return (float) $val;
|
|
}
|
|
|
|
if ( is_string($val) && defined('self::'.$val) ) {
|
|
return constant('self::'.$val);
|
|
}
|
|
|
|
if ( is_string($val) && is_array($this->{'Tab'.$val}) ) {
|
|
return $this->{'Tab'.$val};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected function paramEval($var, $type, $value)
|
|
{
|
|
$valueReal = $this->paramValue($value);
|
|
|
|
switch ($type) {
|
|
case 'MIN':
|
|
if ( $this->{'Val'.$var} > $valueReal ) {
|
|
return true;
|
|
}
|
|
return false;
|
|
break;
|
|
|
|
case 'MAX':
|
|
if ( $this->{'Val'.$var} < $valueReal ) {
|
|
return true;
|
|
}
|
|
return false;
|
|
break;
|
|
|
|
case 'EGAL':
|
|
if ( $this->{'Val'.$var} === $valueReal ) {
|
|
return true;
|
|
}
|
|
return false;
|
|
break;
|
|
|
|
case 'LIST':
|
|
if ( in_array($this->{'Val'.$var}, $valueReal) ) {
|
|
return true;
|
|
}
|
|
return false;
|
|
break;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected function paramDefine(){}
|
|
|
|
|
|
protected function comment(){}
|
|
|
|
|
|
/**
|
|
*
|
|
*/
|
|
protected function setTabs()
|
|
{
|
|
if ( $this->compile ) {
|
|
|
|
} else {
|
|
return $this->loadTabsFromDb();
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
protected function loadTabsFromDb(){}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
protected function setRules()
|
|
{
|
|
if ( $this->compile ) {
|
|
$this->RulesVORp = include_once 'Metier/Sfr/RulesVORp-'.$this->version.'.php';
|
|
$this->RulesVORd = include_once 'Metier/Sfr/RulesVORd-'.$this->version.'.php';
|
|
} else {
|
|
$this->RulesVORp = $this->loadRulesFromDb('VORp');
|
|
$this->RulesVORd = $this->loadRulesFromDb('VORd');
|
|
}
|
|
}
|
|
|
|
protected function loadRulesFromDb($type = null)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
protected function setCompile($compile = true)
|
|
{
|
|
$this->compile = $compile;
|
|
}
|
|
|
|
/**
|
|
* Define static file and version
|
|
* @param string $version
|
|
*/
|
|
protected function setVersion($version = null)
|
|
{
|
|
if ( null !== $version ) {
|
|
$this->version = $version;
|
|
}
|
|
}
|
|
|
|
} |