diff --git a/application/controllers/SaisieController.php b/application/controllers/SaisieController.php index 7a3016519..4aba81152 100644 --- a/application/controllers/SaisieController.php +++ b/application/controllers/SaisieController.php @@ -2288,49 +2288,65 @@ class SaisieController extends Zend_Controller_Action public function scorecutoffAction() { + $ws = new WsScores(); + $user = new Scores_Utilisateur(); + $request = $this->getRequest(); $siren = $request->getParam('siren'); + $getcutoff = json_decode($ws->getScoreCutoff($siren), true); + + if(!$getcutoff) { + $getcutoff = array( + 'siren' => '', + 'encours' => '', + 'scoreSolv' => '', + 'scoreDir' => '', + 'scoreConf' => '', + 'remarque' => '', + 'dateInsert' => '', + 'dateUpdate' => '' + ); + } + $this->view->assign('siren', $siren); + $this->view->assign('getcutoff', $getcutoff); + $this->view->assign('typescore', $user->getTypeScore()); if ( $request->isXmlHttpRequest() ) { $this->_helper->layout()->disableLayout(); if ( $request->isPost() ) { - $paramlist = array( - 'siren' => '', - 'encours' => array('min'=>0, 'max'=>500000), - 'scoreSolv' => array('min'=>0, 'max'=>100), - 'scoreDir' => array('min'=>0, 'max'=>100), - 'scoreConf' => array('min'=>0, 'max'=>100), - 'remarque' => '', - ); + $params = $request->getParams(); $message = ''; - $params = $request->getParams(); - foreach ($paramlist as $item => $val) { - if (!isset($params[$item])) { - $message = "Valeur $item vide !"; - break; - } - if (is_array($val)) { - if(intval($params[$item])<$val['min'] || intval($params[$item]>$val['max'])) { - $message = "$item : Erreur borne"; - break; - } - } + // check values one more time + $paramlist = array( + 'siren' => 'Siren', + 'encours' => 'Encours', + 'scoreSolv' => 'Indiscore', + 'scoreDir' => 'Score dirigeance', + 'scoreConf' => 'Score de conformité', + 'remarque' => 'Remarque', + ); + foreach ($paramlist as $item => $val) { + if (!isset($params[$item])) { + $message .= "Valeur $val vide !
"; + } + if ($params['encours']<0 || $params['encours']>500 ) { + $message = "Encours : Erreur borne"; + } } - if( empty($message)) { - //Enregistrer le formulaire - $ws = new WsScores(); - $message = $ws->setScoreCutoff($params['siren'], $params['encours'], $params['scoreSolv'], $params['scoreDir'], $params['scoreConf'], $params['remarque']); - + // end checking values + + if ($message == '') { + $message = $ws->setScoreCutoff($params['siren'], $params['encours']*1000, $params['scoreSolv'], $params['scoreDir'], $params['scoreConf'], $params['remarque']); + if (is_int($message)){ + $message = "Cut-off mis à jour."; + } } $this->view->assign('message', $message); - } - } else { $this->view->assign('name', "Définir un Cut-off"); $this->view->assign('href', $this->view->url(array('controller'=>'saisie','action'=>'scorecutoff','siren'=>$siren))); } } - } \ No newline at end of file diff --git a/application/views/default/scripts/saisie/scorecutoff.phtml b/application/views/default/scripts/saisie/scorecutoff.phtml index f543f58ed..8940cb1e8 100644 --- a/application/views/default/scripts/saisie/scorecutoff.phtml +++ b/application/views/default/scripts/saisie/scorecutoff.phtml @@ -27,62 +27,150 @@ $('a.dialog').on('click', function(e){ message) {?> + +

message; ?>

-message?> +getcutoff; +$wdate = new WDate(); +?> + +

+

+
Date de création Cut-off -
+
dateT('Y-m-d', 'd/m/Y', $getcutoff['dateInsert']); ?>
+
+

+
+
Date de mise à jour Cut-off -
+
dateT('Y-m-d', 'd/m/Y', $getcutoff['dateUpdate']); ?>
+
+ +
+
- euros (de 0 à 500 000) + K€ (de 0 à 500 K€)
- - (de 0 à 100) + +
- - (de 0 à 100) + +
- - (de 0 à 100) + +
- (obligatoire) +
+