Issue #0001634:
This commit is contained in:
parent
49bf51a9da
commit
6de3bec3d9
@ -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' => '',
|
||||
);
|
||||
$message = '';
|
||||
$params = $request->getParams();
|
||||
$message = '';
|
||||
// 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 $item vide !";
|
||||
break;
|
||||
$message .= "Valeur $val vide !<br/>";
|
||||
}
|
||||
if (is_array($val)) {
|
||||
if(intval($params[$item])<$val['min'] || intval($params[$item]>$val['max'])) {
|
||||
$message = "$item : Erreur borne";
|
||||
break;
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,62 +27,150 @@ $('a.dialog').on('click', function(e){
|
||||
</script>
|
||||
|
||||
<?php } elseif ($this->message) {?>
|
||||
<style>
|
||||
.message {
|
||||
font-size: 10px;
|
||||
width: 98%;
|
||||
background-color: #FFFFDD;
|
||||
border: 1px solid #FCEFA1;
|
||||
border-radius: 4px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
</style>
|
||||
<div class='message'><p><?=$this->message; ?></p></div>
|
||||
|
||||
<?=$this->message?>
|
||||
<script>
|
||||
$('#dialog').dialog({ buttons: [
|
||||
{ text: "Quitter", click: function() { $(this).dialog('close'); } }
|
||||
{ text: "Fermer", click: function() {
|
||||
location.reload();
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
] });
|
||||
</script>
|
||||
|
||||
<?php } else {?>
|
||||
<style>
|
||||
|
||||
label {
|
||||
text-align:left;
|
||||
margin-right:0px;
|
||||
width:12em;
|
||||
width:13em;
|
||||
}
|
||||
|
||||
select, input {
|
||||
width:5em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php
|
||||
$getcutoff = $this->getcutoff;
|
||||
$wdate = new WDate();
|
||||
?>
|
||||
|
||||
<p>
|
||||
<div class="paragraph">
|
||||
<div class="StyleInfoLib" style="float:left; margin-left:40em;">Date de création Cut-off - </div>
|
||||
<div class="StyleInfoData" style="float:left; "> <?=$wdate->dateT('Y-m-d', 'd/m/Y', $getcutoff['dateInsert']); ?></div>
|
||||
</div>
|
||||
</p>
|
||||
<div class="paragraph">
|
||||
<div class="StyleInfoLib" style="float:left; margin-left:40em;">Date de mise à jour Cut-off - </div>
|
||||
<div class="StyleInfoData" style="float:left;"> <?=$wdate->dateT('Y-m-d', 'd/m/Y', $getcutoff['dateUpdate']); ?></div>
|
||||
</div>
|
||||
|
||||
<div class="paragraph">
|
||||
|
||||
<form>
|
||||
<input type="hidden" name="siren" value="<?=$this->siren?>">
|
||||
|
||||
<div>
|
||||
<label>Encours</label>
|
||||
<input type="text" name="encours"/> euros (de 0 à 500 000)
|
||||
<input type="text" name="encours" value="<?=$getcutoff['encours']/1000 ?>" required pattern="([0-4]{1}[0-9]{1}[0-9]{1})|500" maxlength="3"/> K€ (de 0 à 500 K€)
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>scoreSolv</label>
|
||||
<input type="text" name="scoreSolv"/> (de 0 à 100)
|
||||
<label>IndiScore</label>
|
||||
<select name="scoreSolv" required>
|
||||
<option value=''>---</option>
|
||||
<?php
|
||||
for($i=0; $i<=$this->typescore; $i++) {
|
||||
$selected = '';
|
||||
if ($i == $getcutoff['scoreSolv']) {
|
||||
$selected = 'selected';
|
||||
}
|
||||
echo '<option value="'.$i.'" '.$selected.'>'.$i.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>scoreDir</label>
|
||||
<input type="text" name="scoreDir"/> (de 0 à 100)
|
||||
<label>Score dirigeance</label>
|
||||
<select name="scoreDir" required>
|
||||
<option value=''>---</option>
|
||||
<?php
|
||||
for($i=0; $i<=$this->typescore; $i++) {
|
||||
$selected = '';
|
||||
if ($i == $getcutoff['scoreDir']) {
|
||||
$selected = 'selected';
|
||||
}
|
||||
echo '<option value="'.$i.'" '.$selected.'>'.$i.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>scoreConf</label>
|
||||
<input type="text" name="scoreConf"/> (de 0 à 100)
|
||||
<label>Score de conformité</label>
|
||||
<select name="scoreConf" required>
|
||||
<option value=''>---</option>
|
||||
<?php
|
||||
for($i=0; $i<=$this->typescore; $i++) {
|
||||
$selected = '';
|
||||
if ($i == $getcutoff['scoreConf']) {
|
||||
$selected = 'selected';
|
||||
}
|
||||
echo '<option value="'.$i.'" '.$selected.'>'.$i.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Remarque</label>
|
||||
<input type="text" name="remarque"/> (obligatoire)
|
||||
<textarea name="remarque" cols="5" required><?=$getcutoff['remarque']; ?></textarea>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function validate() {
|
||||
var allvals = true;
|
||||
$("[required]").each(function() { if(!$(this).val()) { allvals = false; } });
|
||||
if($('[name=encours]').val()<0 || $('[name=encours]').val()>500) { allvals = false; }
|
||||
return allvals
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
validate();
|
||||
});
|
||||
|
||||
$('.required').blur(function(){
|
||||
validate();
|
||||
});
|
||||
|
||||
$('#dialog').dialog({ buttons: [
|
||||
{ text: "Valider", click: function() {
|
||||
var values = $(this).find('form').serialize();
|
||||
if (validate()) {
|
||||
$.post('<?=$this->url(array('controller'=>'saisie','action'=>'scorecutoff'),null,true)?>', values, function(data) {
|
||||
$('#dialog').html(data);
|
||||
});
|
||||
}
|
||||
}},
|
||||
{ text: "Annuler", click: function() { $(this).dialog('close'); } }
|
||||
{ text: "Fermer", click: function() { $(this).dialog('close'); }}
|
||||
] });
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user