Modification structure des définitions

This commit is contained in:
Michael RICOIS 2012-05-11 12:26:16 +00:00
parent 075b6e9918
commit daabfd826a
20 changed files with 1382 additions and 1604 deletions

View File

@ -65,8 +65,7 @@ class ComptageController extends Zend_Controller_Action
$criteres = $criteresRow->current();
$structure = json_decode($criteres->criteres, true);
require_once 'Scores/Field.php';
$field = new Fields();
$field = new Scores_Fields();
$values = $field->getValues($structure);
//Comptage

View File

@ -8,8 +8,7 @@ class EconomiqueController extends Zend_Controller_Action
public function indexAction()
{
require_once('Scores/Field.php');
$field = new Fields();
$field = new Scores_Fields();
$this->view->fields = $field;
}

View File

@ -8,8 +8,7 @@ class EntrepriseController extends Zend_Controller_Action
public function indexAction()
{
require_once('Scores/Field.php');
$field = new Fields();
$field = new Scores_Fields();
$this->view->fields = $field;
}

View File

@ -9,10 +9,9 @@ class FinancierController extends Zend_Controller_Action
public function indexAction()
{
require_once('Scores/Field.php');
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$field = new Fields();
$field = new Scores_Fields();
$this->view->fields = $field;
}

View File

@ -9,10 +9,9 @@ class GeographiqueController extends Zend_Controller_Action
public function indexAction()
{
require_once('Scores/Field.php');
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$field = new Fields();
$field = new Scores_Fields();
$this->view->fields = $field;
}

View File

@ -24,11 +24,9 @@ Class IndexController extends Zend_Controller_Action
if($ajax)
$this->_helper->layout()->disableLayout();
require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage();
$session = new Scores_Fields();
require_once 'Scores/Field.php';
$this->view->field = new Fields();
$this->view->field = $session;
$this->view->criteres = $session->getCriteres();
}

View File

@ -9,8 +9,7 @@ class JuridiqueController extends Zend_Controller_Action
public function indexAction()
{
require_once('Scores/Field.php');
$field = new Fields();
$field = new Scores_Fields();
$this->view->fields = $field;
}

View File

@ -1,85 +1,146 @@
<?php
Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
{
public function Field($name, $field, $type = null)
protected $display = true;
protected $name = '';
public function Field($name)
{
$this->name = $name;
//Read the dico
$fields = new Scores_Fields();
$params = $fields->get($name);
$html = '';
if($field != null) {
$html.= '<div class="fieldgrp">';
if($type == null)
$type = $field['type'];
switch($type)
$label = $labelG = $fields->getLibelle($name);
//How many type of fields is defined
$nbFields = count($params['fields']);
$this->display = true;
//If more than one field exist we need to make a special display
if ( $nbFields > 1) {
$html.= '<div class="fieldgrp clearfix">';
$html.= $this->structureLabel($label);
$html.= '<div class="field">';
foreach ( $params['fields'] as $type => $options )
{
case 'select':
$html.= $this->structureHTML(
$field['label'],
$this->selectHTML($name, $field));
break;
case 'selectMultiple':
$html.= $this->structureHTML(
$field['label'],
$this->selectMultipleHTML($name, $field));
break;
case 'intervalSelect':
$html.= $this->structureHTML(
$field['label'],
$this->intervalSelectHTML($name, $field));
break;
case 'interval':
$html.= $this->structureHTML(
$field['label'],
$this->intervalHTML($name, $field));
break;
case 'date':
$html.= $this->structureHTML(
$field['label'],
$this->dateHTML($name, $field));
break;
case 'text':
switch($name) {
case 'reg':
$label = 'Régions';
break;
case 'vil':
case 'adr_com':
$label = 'Villes';
break;
case 'dep':
$label = 'Départements';
break;
default:
$label = $field['label'];
}
$html.= $this->structureHTML(
$label,
$this->textHTML($name, $field, $name), $field['help'][ucfirst($name)]);
break;
case 'textarea':
$html.= $this->structureHTML(
$field['label'],
$this->textareaHTML($name, $field));
break;
case 'radio':
$html.= $this->structureHTML(
$field['label'],
$this->radioHTML($name, $field));
break;
case 'file':
$html.= $this->structureHTML(
$field['label'],
$this->fileuploadHtml($name, $field));
break;
switch ($type) {
case 'tree':
$href = $this->view->url(array('controller' => 'arborescence', 'action' => $options['action'], 'key' => $name));
$html.= '<a class="arborescence" title="'.$options['title'].'" href="'.$href.'">';
$html.= '<img src="/themes/default/images/arborescence.gif" />';
$html.= '</a>';
break;
case 'text':
$html.= '<img style="cursor:pointer" class="manuel" ref="'.$name.'" src="/themes/default/images/Textarea.gif" title="'.$options['title'].'"/>';
break;
}
$html.= '&nbsp;';
}
$html.= '</div>';
$html.= '</div>';
//Masquer les champs
$this->display = false;
}
//Draw fields
foreach ( $params['fields'] as $type => $options )
{
$label = $labelG;
if ( array_key_exists('label', $options) ) {
$label = $options['label'];
}
switch($type)
{
case 'select':
$html.= $this->structureHTML(
$label,
$this->selectHTML($name, $options)
);
break;
case 'selectMultiple':
$html.= $this->structureHTML(
$label,
$this->selectMultipleHTML($name, $options)
);
break;
case 'intervalSelect':
$html.= $this->structureHTML(
$label,
$this->intervalSelectHTML($name, $options)
);
break;
case 'interval':
$html.= $this->structureHTML(
$label,
$this->intervalHTML($name, $field)
);
break;
case 'date':
$html.= $this->structureHTML(
$field['label'],
$this->dateHTML($name, $field));
break;
case 'text':
switch($name) {
case 'reg':
$label = 'Régions';
break;
case 'dep':
$label = 'Départements';
break;
}
$html.= $this->structureHTML(
$label,
$this->textHTML($name, $options)
);
break;
case 'textarea':
$html.= $this->structureHTML(
$field['label'],
$this->textareaHTML($name, $field));
break;
case 'radio':
$html.= $this->structureHTML(
$field['label'],
$this->radioHTML($name, $field));
break;
case 'file':
$html.= $this->structureHTML(
$field['label'],
$this->fileuploadHtml($name, $field));
break;
case 'tree':
//Do nothing
break;
default:
$html.= $this->structureHTML($label, '');
break;
}
}
return $html;
}
private function structureHTML($label, $html, $help = null)
private function structureHTML($label, $html)
{
$out = '';
$out.= $this->structureLabel($label, $help);
$style = '';
$class = ' class="fieldgrp"';
if ( $this->display===false ) {
$style = ' style="display:none;"';
$class = ' class="fieldgrp '.$this->name.'"';
}
$out.= '<div '.$class.''.$style.'>';
$out.= $this->structureLabel($label);
$out.= '<div class="field">'.$html.'</div>';
$out.= '</div>';
return $out;
}
@ -87,33 +148,31 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
* Définition du label
* @param unknown_type $label
*/
private function structureLabel($label, $help)
private function structureLabel($label)
{
$return = '<label>'.$label.'</label>';
if($help)
$return .= '<p style="font-size:9px;">'.$help.'</p>';
return ($return);
return $return;
}
protected function getMinMax($name, $valeur)
{
if(!empty($name)) {
$default = Fields::getMinMax($name);
$default = Scores_Fields::getMinMax($name);
if(empty($valeur[0])){$valeur[0] = $default[0]['min'];}
if(empty($valeur[1])){$valeur[1] = $default[0]['max'];}
}
return ($valeur);
}
private function intervalSelectHTML($name, $field)
private function intervalSelectHTML($name, $options)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
$sessionValeur = explode(',', $session->getCritere($name));
$minMax = $this->getMinMax($name, array(0,0));
$return = '<select class="intervalSelect" name="'.$name.'1" id="'.$name.'" number="1">';
foreach($field['fields'][$field['type']]['value'] as $elements) {
foreach($options['value'] as $elements) {
if($elements[0] == 0)
$return .= '<option value="'.$minMax[0].'">Min</option>';
else
@ -122,7 +181,7 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$return .= '</select> à ';
$return .= '<select class="intervalSelect" name="'.$name.'2" id="'.$name.'" number="2">';
foreach($field['fields'][$field['type']]['value'] as $elements) {
foreach($options['value'] as $elements) {
if($elements[1] == 0)
$return .= '<option value="'.$minMax[1].'">Max</option>';
else
@ -135,49 +194,53 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
}
/* Select */
private function selectMultipleHTML($name, $field)
private function selectMultipleHTML($name, $options)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
$sessionValeur = $session->getCritere($name);
/*if(is_array($sessionValeur))
$sessionValeur = implode(',', $sessionValeur);*/
$return = '<select size="'.count($field['fields'][$field['type']]['value']).'" class="criteres '.$field['type']['class'].'" name="'.$name.'" multiple>';
$return .= '<option '.(($sessionValeur == '-')?'selected':'').' value="-">-</option>';
foreach($field['fields'][$field['type']]['value'] as $value => $label) {
$return = '<select size="'.count($options['value']).'" class="criteres " name="'.$name.'" multiple>';
foreach($options['value'] as $value => $label) {
$selected = "";
if(($sessionValeur != null) and in_array($value, $sessionValeur) and $sessionValeur != "tous")
$selected = " selected";
Zend_Registry::get('firebug')->info('sessionValeur : '.$sessionValeur);
if( !empty($sessionValeur) ) {
if (is_array($sessionValeur) && in_array($value, $sessionValeur) ) {
$selected = " selected";
}
}
$return .= '<option'.$selected.' value="'.$value.'">'.$label.'</option>';
}
$return .= '</select>';
return ($return);
return $return;
}
/* Select Multiple */
private function selectHTML($name, $field)
private function selectHTML($name, $options)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
$sessionValeur = $session->getCritere($name);
if(is_array($sessionValeur))
$sessionValeur = implode(',', $sessionValeur);
$return = '<select class="criteres '.$field['type']['class'].'" name="'.$name.'">';
$return = '<select class="criteres" name="'.$name.'">';
$return .= '<option '.(($sessionValeur == '-')?'selected':'').' value="-">-</option>';
foreach($field['fields'][$field['type']]['value'] as $value => $label) {
foreach($options['value'] as $value => $label) {
$selected = "";
if(($sessionValeur != null) and $sessionValeur == $value and $sessionValeur != "-")
if( $sessionValeur!==null && $sessionValeur==$value && $sessionValeur != "-")
$selected = " selected";
$return .= '<option'.$selected.' value="'.$value.'">'.$label.'</option>';
}
$return .= '</select>';
return ($return);
return $return;
}
/* Interval */
private function intervalHTML($name, $field)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
$valeur = $session->getCritere($name);
$valeur = explode(',', $valeur);
@ -187,13 +250,13 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$return .= ' <a href="" class="interval" id="'.$name.'">Valider</a>';
$return .= '</div>';
return ($return);
return $return;
}
/* Dates */
private function dateHTML($name, $field)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
$return = '<div class="date" >';
$return .= '<input value="'.$session->getCritere($name).'" type="text" class="datepicker" name="'.$name.'1" /> a ';
@ -204,9 +267,9 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
}
/* Textes */
private function textHTML($name, $field, $name)
private function textHTML($name, $options)
{
$session = new SessionCiblage();
$session = new Scores_Fields();
switch($name) {
case 'ape_entrep':
case 'ape_etab':
@ -230,10 +293,10 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$type= $name;
break;
}
/* Modifier les données */
$return = '<textarea rows="5" style="border:1px inset silver;width:60%" class="criteres complited'.$type.'" id="textarea_'.$name.'" name="'.$name.'">'.$session->getCritere($name).'</textarea>';
$return .= '<a href="" class="autocomplet" textarea="'.$name.'">Valider</a> <a href="">Aide</a>';
return ($return);
$return = '<input type="text" class="criteres complited'.$type.'" id="textarea_'.$name.'" name="'.$name.'" />';
$return .= '<a href="" class="autocomplet" textarea="'.$name.'">Sélectionner</a>';
$return .= '&nbsp;<a href="" textarea="'.$name.'">Exclure</a>';
return $return;
}
/* Textarea */

View File

@ -1,46 +1,26 @@
<div id="economique">
<div id="s_economique">
<ul id="fieldsblock">
<li><?php echo $this->Field('capital', $this->fields->get('capital'));?></li>
<li><?php echo $this->Field('ape_etab', $this->fields->get('ape_etab'));?></li>
<li class="ape_etab" style="display:none;background-image:none;height:100px;">
<div id="ape_etab_ex" class="exclusion" style="display:none">
<?php echo $this->Field('ape_etab_ex', $this->fields->get('ape_etab_ex'), 'text');?>
</div>
<div id="ape_etab_in" class="inclusion">
<?php echo $this->Field('ape_etab', $this->fields->get('ape_etab'), 'text');?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="ape_etab" />
</li>
<li class="ape_etab" style="display:none;background-image:none;height:100px;">
<div id="ape_entrep_ex" class="exclusion" style="display:none">
<?php echo $this->Field('ape_entrep_ex', $this->fields->get('ape_entrep_ex'), 'text');?>
</div>
<div id="ape_entrep_in" class="inclusion">
<?php echo $this->Field('ape_entrep', $this->fields->get('ape_entrep'), 'text');?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="ape_entrep" />
</li>
<li><?php echo $this->Field('age_etab', $this->fields->get('age_etab'));?></li>
<li><?php echo $this->Field('teff_etab', $this->fields->get('teff_etab'));?></li>
<li><?php echo $this->Field('teff_etabM', $this->fields->get('teff_etabM'));?></li>
<li><?php echo $this->Field('eff_etab', $this->fields->get('eff_etab'));?></li>
</ul>
</div>
<div id="a_economique" style="display:none">
<ul id="fieldsblock">
<li><?php echo $this->Field('age_entrep', $this->fields->get('age_entrep'));?></li>
<li><?php echo $this->Field('teff_entrep', $this->fields->get('teff_entrep'));?></li>
<li><?php echo $this->Field('teff_entrepM', $this->fields->get('teff_entrepM'));?></li>
<li><?php echo $this->Field('eff_entrep', $this->fields->get('eff_entrep'));?></li>
<li><?php echo $this->Field('nbEtab', $this->fields->get('nbEtab'));?></li>
</ul>
</div>
<li><?=$this->Field('capital')?></li>
<li><?=$this->Field('ape_etab')?></li>
<li><?=$this->Field('age_etab')?></li>
<li><?=$this->Field('teff_etab')?></li>
<li><?=$this->Field('teff_etabM')?></li>
<li><?=$this->Field('eff_etab')?></li>
<div id="a_economique" style="display:none;">
<li><?=$this->Field('age_entrep')?></li>
<li><?=$this->Field('teff_entrep')?></li>
<li><?=$this->Field('teff_entrepM')?></li>
<li><?=$this->Field('eff_entrep')?></li>
<li><?=$this->Field('nbEtab')?></li>
</div>
</ul>
<p>
<a class="mode" id="a_economique" style="cursor:pointer;margin-left:50%">
<img src="/themes/default/images/fleche-bas.gif" />
</a>
</p>
</div>
</div>
<div style="text-align:right;margin-top:20px;">
<a class="resetFamille" id="economique">Réinitialiser les critères economiques</a>

View File

@ -4,26 +4,26 @@
<div id="entreprise">
<div id="s_entreprise">
<ul id="fieldsblock">
<li id="siege"><?=$this->Field('siege', $this->fields->get('siege'));?></li>
<li id="sirenGrp"><?=$this->Field('sirenGrp', $this->fields->get('sirenGrp'));?></li>
<li id="tel"><?=$this->Field('tel', $this->fields->get('tel'));?></li>
<li id="fax"><?=$this->Field('fax', $this->fields->get('fax'));?></li>
<li id="web"><?=$this->Field('web', $this->fields->get('web'));?></li>
<li id="mail"><?=$this->Field('mail', $this->fields->get('mail'));?></li>
<li id="presentRcs"><?=$this->Field('present cs', $this->fields->get('presentRcs'));?></li>
<li id="adrDom"><?=$this->Field('adrDom', $this->fields->get('adrDom'));?></li>
<li id="dirNom"><?=$this->Field('dirNom', $this->fields->get('dirNom'));?></li>
<li id="li_dateCrea_etab"><?=$this->Field('dateCrea_etab', $this->fields->get('dateCrea_etab'));?></li>
<li id="part"><?=$this->Field('part', $this->fields->get('part'));?></li>
<li id="siege"><?=$this->Field('siege');?></li>
<li id="sirenGrp"><?=$this->Field('sirenGrp');?></li>
<li id="tel"><?=$this->Field('tel');?></li>
<li id="fax"><?=$this->Field('fax');?></li>
<li id="web"><?=$this->Field('web');?></li>
<li id="mail"><?=$this->Field('mail');?></li>
<li id="presentRcs"><?=$this->Field('presentRcs');?></li>
<li id="adrDom"><?=$this->Field('adrDom');?></li>
<li id="dirNom"><?=$this->Field('dirNom');?></li>
<li id="li_dateCrea_etab"><?=$this->Field('dateCrea_etab');?></li>
<li id="part"><?=$this->Field('part');?></li>
</ul>
</div>
<div id="a_entreprise" style="display:none">
<ul id="fieldsblock">
<li id="nbMPublic"><?=$this->Field('nbMPubli', $this->fields->get('nbMPubli'));?></li>
<li id="li_dateCrea_etab" ><?=$this->Field('dateCrea_ent',$this->fields->get('dateCrea_ent'));?></li>
<li id="action"><?=$this->Field('action', $this->fields->get('action'));?></li>
<li id="nbActio"><?=$this->Field('nbActio', $this->fields->get('nbActio'));?></li>
<li id="nbPart"><?=$this->Field('nbPart', $this->fields->get('nbPart'));?></li>
<li id="nbMPublic"><?=$this->Field('nbMPubli');?></li>
<li id="li_dateCrea_ent" ><?=$this->Field('dateCrea_ent');?></li>
<li id="action"><?=$this->Field('action');?></li>
<li id="nbActio"><?=$this->Field('nbActio');?></li>
<li id="nbPart"><?=$this->Field('nbPart');?></li>
</ul>
</div>
<p>

View File

@ -1,53 +1,29 @@
<div id="financiere">
<div id="s_financier">
<ul id="fieldsblock" style="width:100%;height:100%;">
<li style="background: none; height:80px;">
<div id="bilType_ex" class="exclusion" style="display:none">
<?php echo $this->Field('bilType_ex', $this->fields->get('bilType_ex'));?>
</div>
<div id="bilType_in" class="inclusion">
<?php echo $this->Field('bilType', $this->fields->get('bilType'));?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="bilType" />
</li>
<li style="background: none; height:150px;">
<div id="avisCs_ex" class="exclusion" style="display:none">
<?php echo $this->Field('avisCs_ex', $this->fields->get('avisCs_ex'));?>
</div>
<div id="avisCs_in" class="inclusion">
<?php echo $this->Field('avisCs', $this->fields->get('avisCs'));?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="avisCs" />
</li>
<li><?php echo $this->Field('bilAnnee', $this->fields->get('bilAnnee'));?></li>
<li><?php echo $this->Field('bilCloture', $this->fields->get('bilCloture'));?></li>
<li><?php echo $this->Field('bilDuree', $this->fields->get('bilDuree'));?></li>
<li style="background: none; height:190px;">
<div id="bilTca_ex" class="exclusion" style="display:none">
<?php echo $this->Field('bilTca_ex', $this->fields->get('bilTca_ex'));?>
</div>
<div id="bilTca_in" class="inclusion">
<?php echo $this->Field('bilTca', $this->fields->get('bilTca'));?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="bilTca" />
</li>
<li><?php echo $this->Field('bilFL', $this->fields->get('bilFL'));?></li>
<ul id="fieldsblock">
<li><?=$this->Field('bilType')?></li>
<li><?=$this->Field('avisCs')?></li>
<li><?=$this->Field('bilAnnee')?></li>
<li><?=$this->Field('bilCloture')?></li>
<li><?=$this->Field('bilDuree')?></li>
<li><?=$this->Field('bilTca')?></li>
<li><?=$this->Field('bilFL')?></li>
</ul>
</div>
<div id="a_financiere" style="display:none">
<ul id="fieldsblock">
<li><?php echo $this->Field('bilEE', $this->fields->get('bilEE'));?></li>
<li><?php echo $this->Field('bilFK', $this->fields->get('bilFK'));?></li>
<li><?php echo $this->Field('bilFR', $this->fields->get('bilFR'));?></li>
<li><?php echo $this->Field('bilGF', $this->fields->get('bilGF'));?></li>
<li><?php echo $this->Field('bilGP', $this->fields->get('bilGP'));?></li>
<li><?php echo $this->Field('bilGW', $this->fields->get('bilGW'));?></li>
<li><?php echo $this->Field('bilHD', $this->fields->get('bilHD'));?></li>
<li><?php echo $this->Field('bilHH', $this->fields->get('bilHH'));?></li>
<li><?php echo $this->Field('bilHL', $this->fields->get('bilHL'));?></li>
<li><?php echo $this->Field('bilHM', $this->fields->get('bilHM'));?></li>
<li><?php echo $this->Field('bilHN', $this->fields->get('bilHN'));?></li>
<li><?php echo $this->Field('bilYP', $this->fields->get('bilYP'));?></li>
<li><?=$this->Field('bilEE')?></li>
<li><?=$this->Field('bilFK')?></li>
<li><?=$this->Field('bilFR')?></li>
<li><?=$this->Field('bilGF')?></li>
<li><?=$this->Field('bilGP')?></li>
<li><?=$this->Field('bilGW')?></li>
<li><?=$this->Field('bilHD')?></li>
<li><?=$this->Field('bilHH')?></li>
<li><?=$this->Field('bilHL')?></li>
<li><?=$this->Field('bilHM')?></li>
<li><?=$this->Field('bilHN')?></li>
<li><?=$this->Field('bilYP')?></li>
</ul>
</div>
<p>

View File

@ -1,36 +1,17 @@
<div id="geographique">
<ul id="fieldsblock">
<li><?php echo $this->Field('adr_com', $this->fields->get('adr_com'));?></li>
<li class="adr_com" style="display:none;background-image:none;height:100px;">
<div id="adr_com_ex" class="exclusion" style="display:none">
<?php echo $this->Field('adr_com_ex', $this->fields->get('adr_com_ex'), 'text');?>
</div>
<div id="adr_com_in" class="inclusion">
<?php echo $this->Field('adr_com', $this->fields->get('adr_com'), 'text');?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="adr_com" />
<li>
<?=$this->Field('adr_com')?>
Exclure DOM-TOM <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_domtom" /><br />
Exclure Etranger <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_entr" /><br />
Exclure Corse <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_corse" /><br />
</li>
<li class="adr_com" style="display:none;background-image:none;height:150px;">
<div id="adr_dept_ex" class="exclusion" style="display:none">
<?php echo $this->Field('adr_dept_ex', $this->fields->get('adr_dept_ex'), 'text');?>
</div>
<div id="adr_dept_in" class="inclusion">
<?php echo $this->Field('adr_dept', $this->fields->get('adr_dept'), 'text');?>
</div><br />
Recherche régions : <input type="text" name="" id="textarea_adr_reg" /><br />
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="adr_dept" />
</li>
<li style="height:50px;background-image:none">
Exclure DOM-TOM <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_domtom" /><br />
Exclure Etranger <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_entr" /><br />
Exclure Corse <input style="float:right" value="1" type="checkbox" class="ex_prede" name="ex_corse" /><br />
</li>
<li><?php echo $this->Field('zus', $this->fields->get('zus'), 'select');?></li>
<li><?php echo $this->Field('zru', $this->fields->get('zru'), 'select');?></li>
<li><?php echo $this->Field('zfu', $this->fields->get('zfu'), 'select');?></li>
<li><?php echo $this->Field('cucs', $this->fields->get('cucs'), 'select');?></li>
<li><?php echo $this->Field('zrr', $this->fields->get('zrr'), 'select');?></li>
<li><?php echo $this->Field('zafr', $this->fields->get('zafr'), 'select');?></li>
<li><?=$this->Field('zus')?></li>
<li><?=$this->Field('zru')?></li>
<li><?=$this->Field('zfu')?></li>
<li><?=$this->Field('cucs')?></li>
<li><?=$this->Field('zrr')?></li>
<li><?=$this->Field('zafr')?></li>
</ul>
</div>
<div style="text-align:right;margin-top:20px;">

View File

@ -4,6 +4,7 @@
}
#criteres {
border: 1px solid;
padding:10px 0;
}
#criteres tr td {

View File

@ -1,24 +1,15 @@
<div id="juridique">
<div id="s_juridique">
<ul id="fieldsblock">
<li><?php echo $this->Field('cj', $this->fields->get('cj'));?></li>
<li class="cj" style="display:none;background-image:none;height:100px;">
<div id="cj_text_ex" class="exclusion" style="display:none">
<?php echo $this->Field('cj_ex', $this->fields->get('cj_ex'), 'text');?>
</div>
<div id="cj_text_in" class="inclusion">
<?php echo $this->Field('cj', $this->fields->get('cj'), 'text');?>
</div>
Valeurs exclusions : <input value="1" type="checkbox" class="checkbox_ex" name="cj_text" />
</li>
<li><?php echo $this->Field('actifEco', $this->fields->get('actifEco'));?></li>
<li><?php echo $this->Field('procolHisto', $this->fields->get('procolHisto'));?></li>
<li><?php echo $this->Field('dateImmat', $this->fields->get('dateImmat'));?></li>
<li><?=$this->Field('cj');?></li>
<li><?=$this->Field('actifEco', $this->fields->get('actifEco'));?></li>
<li><?=$this->Field('procolHisto', $this->fields->get('procolHisto'));?></li>
<li><?=$this->Field('dateImmat', $this->fields->get('dateImmat'));?></li>
</ul>
</div>
<div id="a_juridique" style="display:none">
<ul id="fieldsblock">
<li><?php echo $this->Field('tvaIntraValide', $this->fields->get('tvaIntraValide'));?></li>
<li><?=$this->Field('tvaIntraValide', $this->fields->get('tvaIntraValide'));?></li>
</ul>
</div>
<p>

View File

@ -9,8 +9,7 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
$action = $request->getActionName();
if ($controller == 'index' && $action == 'index') {
require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage();
$session = new Scores_Fields();
$view = $layout->getView();
$auth = Zend_Auth::getInstance();

View File

@ -1,55 +1,86 @@
<?php
//require_once 'sphinxapi/sphinxapi-2.0.2.php';
require_once 'sphinxapi/sphinxapi-2.0.4.php';
Class Ciblage
/**
* Ciblage construct the request send to Sphinx
*/
class Ciblage
{
protected $sphinx;
protected $alpha = '';
protected $presentRcs = 0;
/**
* Name of the index store in Sphinx
* @var string
*/
protected $index = 'ciblage';
protected $index = 'ciblage';
/**
* Sphinx instantiation
* @var object
*/
protected $sphinx;
public $sphinx_match = SPH_MATCH_EXTENDED2;
public $sphinx_sort = SPH_SORT_EXTENDED;
public $sphinx_match = SPH_MATCH_EXTENDED2;
public $sphinx_sort = SPH_SORT_EXTENDED;
protected function setMinMax($name, $valeur)
{
/*if(!$this->need) {*/
if(!empty($name)) {
$default = Fields::getMinMax($name);
/**
* Construct request
* @var string
*/
protected $alpha = '';
protected $presentRcs = 0;
if(empty($valeur[0])){$valeur[0] = $default[0]['min'];}
if(empty($valeur[1])){$valeur[1] = $default[0]['max'];}
}
return ($valeur);
/*}*/
return ($valeur);
}
/**
*
* @param array $structure
* @param boolean $need
*/
public function __construct($structure, $need = false)
{
/*
* First of all we need to load the Sphinx API
* @todo : Make a test and load the right version of API
*/
require_once 'sphinxapi/sphinxapi-2.0.4.php';
$this->need = true;
//Load configuration from registry
$configuration = Zend_Registry::get('configuration');
//Instantiation Sphinx
//Sphinx init
$this->sphinx = new SphinxClient();
$this->sphinx->SetServer($configuration->sphinx->host, intval($configuration->sphinx->port));
$this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$this->sphinx->ResetFilters();
//
foreach($structure as $key => $valeur) {
if (method_exists($this, $key)) {
if(is_array($valeur)) {
if(isset($valeur[0])) {
if($valeur[0] != "" and $valeur[0] != 'tous')
if($valeur[0] != "" and $valeur[0] != '-')
$this->$key($valeur);
}
} else {
if($valeur != 'tous' and $valeur != "")
if($valeur != '-' and $valeur != "")
$this->$key($valeur);
}
}
}
}
protected function setMinMax($name, $valeur)
{
if(!empty($name)) {
$default = Fields::getMinMax($name);
if(empty($valeur[0])){
$valeur[0] = $default[0]['min'];
}
if(empty($valeur[1])){
$valeur[1] = $default[0]['max'];
}
}
return ($valeur);
}
public function extract()
{
$resultats = $this->execute(true);
@ -64,12 +95,17 @@ Class Ciblage
);
return $total;
}
public function calculRedevanceInsee()
{
$this->sphinx->SetFilter('presentrcs', array(0));
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
return ($resSphinx['total_found']);
}
protected function getSiret($structure)
{
$siret = array();
@ -84,6 +120,7 @@ Class Ciblage
public function execute($need = false, $limitD = false)
{
Zend_Registry::get('firebug')->info("Sphinx : ");
Zend_Registry::get('firebug')->info($this->alpha);
if($need) {
$return = array();
$limit = 0;
@ -101,15 +138,18 @@ Class Ciblage
}
Zend_Registry::get('firebug')->info($resSphinx);
return ($resSphinx['total_found']);
return $resSphinx['total_found'];
}
protected function setFilter($name, $valeur, $ex = false) {
protected function setFilter($name, $valeur, $ex = false)
{
if(!is_array($valeur)) {
$this->sphinx->SetFilter($name, array(intval($valeur)),($ex)?true:false);
$this->sphinx->SetFilter($name, array(intval($valeur)), $ex);
}else {
$this->sphinx->SetFilter($name, $this->transformIntval($valeur), ($ex)?true:false);
$this->sphinx->SetFilter($name, $this->transformIntval($valeur), $ex);
}
}
protected function setFilterRange($name, $valeur) {
$this->sphinx->SetFilterRange($name, intval($valeur[0]), intval($valeur[1]));
}
@ -126,26 +166,19 @@ Class Ciblage
return ($depts);
}
protected function writeRequest($name, $valeur, $ex, $or = false) {
if(in_array($name, array('adr_com_ex', 'adr_dept_ex', 'bilType_ex', 'ape_etab_ex', 'ape_entrep_ex'))) {
if(!strstr($this->alpha, 'adr_dept') or
!strstr($this->alpha, 'ape_etab') or
if(in_array($name, array('bilType_ex', 'ape_etab_ex', 'ape_entrep_ex'))) {
if(!strstr($this->alpha, 'ape_etab') or
!strstr($this->alpha, 'bilType') or
!strstr($this->alpha, 'ape_entrep')) {
$this->alpha .= ' @exclu (ex) ';
}
switch($name) {
case 'adr_com_ex':
$name = 'adr_com';
break;
case 'ape_entrep_ex':
$name = 'ape_entrep';
break;
case 'ape_etab_ex':
$name = 'ape_etab';
break;
case 'adr_dept_ex':
$name = 'adr_dept';
break;
case 'bilType_ex':
$name = 'bilType';
break;
@ -168,7 +201,7 @@ Class Ciblage
}
protected function setAlpha($name, $valeur, $ex = false)
{
$or = array('adr_com', 'adr_dept', 'adr_com_ex', 'adr_dept_ex');
$or = array('adr_com', 'adr_dep', 'adr_com_ex', 'adr_dep_ex');
$and = array('bilType', 'ape_etab_ex', 'ape_etab','ape_entrep', 'ape_entrep_ex', 'NaceEntrep', 'NaceEtab', 'bilType_ex');
if(!empty($this->alpha))
$this->alpha .= ' ';
@ -200,29 +233,29 @@ Class Ciblage
protected function ex_domtom($valeur)
{
if($valeur == 1) {
$this->setAlpha('adr_dept_ex', array(971, 972, 973, 974, 976), true);
$this->setFilter('adr_dep', array(971, 972, 973, 974, 976), true);
}
}
protected function ex_entr($valeur)
{
if($valeur == 1) {
$this->setAlpha('adr_dept_ex', array(986, 987, 988), true);
$this->setFilter('adr_dep', array(986, 987, 988), true);
}
}
protected function ex_corse($valeur)
{
if($valeur == 1) {
$this->setAlpha('adr_dept_ex', array(200), true);
$this->setFilter('adr_dep', array(201, 202), true);
}
}
protected function adr_com_ex($valeur) {
$this->setAlpha('adr_com_ex', $valeur, true);
}
protected function adr_dept($valeur) {
$this->setAlpha('adr_dept', $valeur);
protected function adr_dep($valeur) {
$this->setAlpha('adr_dep', $valeur);
}
protected function adr_dept_ex($valeur) {
$this->setAlpha('adr_dept_ex', $valeur, true);
protected function adr_dep_ex($valeur) {
$this->setAlpha('adr_dep_ex', $valeur, true);
}
protected function action($valeur) {
$this->setFilter('action', $valeur);

File diff suppressed because it is too large Load Diff

1055
library/Scores/Fields.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +0,0 @@
<?php
class SessionCiblage
{
protected $valeur;
protected $total = null;
protected $insee = null;
public function __construct()
{
$session = new Zend_Session_Namespace('ciblage');
$this->valeur = empty($session->ciblage) ? array() : $session->ciblage;
if (isset($this->valeur['NB']['total'])){ $this->total = $this->valeur['NB']['total']; }
if (isset($this->valeur['NB']['insee'])){ $this->insee = $this->valeur['NB']['insee']; }
if (isset($this->valeur['NB'])){ unset($this->valeur['NB']); }
}
/**
* Enregistre les informations dans la session
*/
protected function setSession()
{
$session = new Zend_Session_Namespace('ciblage');
$this->valeur['NB']['total'] = $this->total;
$this->valeur['NB']['insee'] = $this->insee;
$session->ciblage = $this->valeur;
}
/**
* Enregistre un critère et sa valeur
* @param unknown_type $key
* @param unknown_type $value
*/
public function setCritere($key, $value)
{
$this->valeur[$key] = $value;
$this->setSession();
}
/**
* Définir les critères en une fois
* @param array $criteres
*/
public function setCriteres($criteres)
{
$this->valeur = $criteres;
$this->setSession();
}
/**
* Désactivation d'un critère
* @param unknown_type $key
*/
public function unsetCritere($key)
{
if(key_exists($key, $this->valeur)) {
unset($this->valeur[$key]);
$this->setSession();
}
}
/*Permet de supprimer une valeur dans une clef de session*/
public function unsetCritereValue($key, $valeur) {
//@todo provisoir trouver une autre technique plus adapté.
if(key_exists($key, $this->valeur)) {
$don = explode(',', $this->valeur[$key]);
foreach ($don as $val) {
if($val == $valeur)
$don[key($don)] = '';
else
$new[] = $val;
}
if(count($new) > 0) {
$don = implode(',', $new);
if(!empty($don))
$this->valeur[$key] = $don;
} else {
unset($this->valeur[$key]);
}
$this->setSession();
}
}
/**
* Récupération de la valeur d'un critère
* @param unknown_type $key
*/
public function getCritere($key)
{
if(array_key_exists($key, $this->valeur)) {
return $this->valeur[$key];
}
return null;
}
/**
* Récupération des critères et de leurs valeurs
*/
public function getCriteres()
{
return $this->valeur;
}
/**
* Définit un élément de comptage
* @param unknown_type $element
* @param unknown_type $nb
*/
public function setNb($element, $nb)
{
$this->{$element} = $nb;
$this->setSession();
}
/**
* Récupére la valeur d'un élément de comptage
* @param unknown_type $element
*/
public function getNb($element)
{
return $this->{$element};
}
public function resetFamille($famille)
{
require_once('Field.php');
$fields = new Fields(null);
$reference = $fields->getByFamille($famille);
foreach($this->valeur as $name => $valeur) {
if($name != 'null') {
if(array_key_exists($name, $reference)) {
unset($this->valeur[$name]);
}
}
}
$this->setSession();
}
public function clearCiblage()
{
Zend_Session::namespaceUnset('ciblage');
}
}

View File

@ -238,6 +238,7 @@ $(document).ready(function()
}
});
/*
$('textarea.complitedNaf').autocomplete({
delay:600,
source: function(request, response) {
@ -254,6 +255,7 @@ $(document).ready(function()
return false;
}
});
*/
$('#textarea_adr_dept').autocomplete({
delay:600,