name = $name; //Read the dico $fields = new Scores_Fields(); $params = $fields->get($name); $html = ''; $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.= '
'; $html.= $this->structureLabel($label); $html.= '
'; foreach ( $params['fields'] as $type => $options ) { switch ($type) { case 'tree': $href = $this->view->url(array('controller' => 'arborescence', 'action' => $options['action'], 'key' => $name)); $html.= ''; $html.= ''; $html.= ''; break; case 'text': $html.= ''; $html.= ''; $html.= ''; break; } $html.= ' '; } $html.= '
'; $html.= '
'; //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 'checkbox': $html.= $this->structureHTML( $label, $this->checkboxHTML($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) { $out = ''; $style = ''; $class = ' class="fieldgrp"'; if ( $this->display===false ) { $style = ' style="display:none;"'; } $out.= '
'; $out.= $this->structureLabel($label); $out.= '
'.$html.'
'; $out.= '
'; return $out; } /** * Définition du label * @param unknown_type $label */ private function structureLabel($label) { $return = ''; return $return; } protected function getMinMax($name, $valeur) { if(!empty($name)) { //$fields = new Scores_Fields(); //$default = $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, $options) { $session = new Scores_Fields(); $sessionValeur = explode(',', $session->getCritere($name)); $minMax = $this->getMinMax($name, array(0,0)); $return = ' à '; $return .= ''; $return .= ' Valider'; return ($return); } protected function checkboxHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); $select = ''; if ($sessionValeur==1) $select = ' checked'; $return = ''; return $return; } /** * * @param unknown_type $name * @param unknown_type $options * @return string */ protected function selectMultipleHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); $return = ''; $return .= 'Sélectionner'; $return .= ' Exclure'; return $return; } /** * * @param unknown_type $name * @param unknown_type $options * @return string */ protected function selectHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); if( is_array($sessionValeur) ) { $sessionValeur = implode(',', $sessionValeur); } $return = ''; return $return; } /* Interval */ private function intervalHTML($name, $field) { $session = new Scores_Fields(); $valeur = $session->getCritere($name); $valeur = explode(',', $valeur); $return = '
'; $return .= ' à '; $return .= ''; $return .= ' Valider'; $return .= '
'; return $return; } /* Dates */ private function dateHTML($name, $field) { $session = new Scores_Fields(); $return = '
'; $return .= ' a '; $return .= ''; $return .= '
'; return ($return); } /* Textes */ private function textHTML($name, $options) { $session = new Scores_Fields(); switch($name) { case 'ape_entrep': case 'ape_etab': $type = 'Naf'; break; case 'vil': $type= 'Vil'; break; case 'adr_com': case 'adr_com_ex': $type= $name; break; case 'cj': $type = 'Cj'; break; case 'cj_ex': $type = 'Cj_ex'; break; case 'adr_dept': case 'adr_dept_ex': $type= $name; break; } $return = ''; $return .= 'Sélectionner'; $return .= ' Exclure'; return $return; } /* Textarea */ private function textareaHTML($name, $field) { $return = ' '; if($name == 'adr_com') $return .= ' '; return ($return); } private function fileuploadHtml($name, $field) { $return = ' '; return ($return); } /* Radios */ private function radioHTML($name, $field, $item) { $return = ''; return ($return); } }