Ajout de l'encours lors de la mise sous surveillance score, issue #0000183
This commit is contained in:
parent
ea21b0b675
commit
8300f43049
@ -12,7 +12,6 @@ function assocSourceDroit()
|
||||
'dirigeants' => 'survdirigeants',
|
||||
'privileges' => 'survpriv',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function assocSourceTxt()
|
||||
@ -77,7 +76,7 @@ function formSurveillance($source, $siret, $notEmail, $inDialog = false)
|
||||
$output.= '<input name="formSurv[source]" '.
|
||||
'type="hidden" value="'.$source.'"/>'."\n";
|
||||
}
|
||||
|
||||
//Champ référence
|
||||
$ref = '';
|
||||
if(isset($_REQUEST['ref'])){
|
||||
$ref = $_REQUEST['ref'];
|
||||
@ -90,6 +89,22 @@ function formSurveillance($source, $siret, $notEmail, $inDialog = false)
|
||||
'value="'.$ref.'" size="10"/></div>'."\n";
|
||||
$output.= '</div>'."\n";
|
||||
|
||||
//Champ spécial suivant source
|
||||
$encours = '';
|
||||
if(isset($_REQUEST['encours'])){
|
||||
$encours = $_REQUEST['encours'];
|
||||
}
|
||||
if ($source=='score'){
|
||||
$output.= '<div id="survForm">'."\n";
|
||||
$output.= '<div class="fieldgrp">'."\n";
|
||||
$output.= '<label class="StyleInfoLib">Votre encours</label>';
|
||||
$output.= '<div class="field">';
|
||||
$output.= '<input class="longfield" name="formSurv[encours]" '.
|
||||
'type="text" value="'.$encours.'" size="10"/></div>'."\n";
|
||||
$output.= '</div>'."\n";
|
||||
}
|
||||
|
||||
//Champ email
|
||||
$email = '';
|
||||
if( !in_array($_SESSION['tabInfo']['login'],$notEmail) &&
|
||||
!isset($_REQUEST['email'])){
|
||||
@ -135,11 +150,10 @@ function getSurveillance($source, $siret){
|
||||
$assocSourceDroit = assocSourceDroit();
|
||||
$return = '';
|
||||
$notEmail = array('testreunica', 'reunicacsf');
|
||||
if(!empty($source) && array_key_exists($source, $assocSourceDroit) &&
|
||||
preg_match('/\b'.$assocSourceDroit[$source].'\b/i',
|
||||
$_SESSION['tabInfo']['droits'])){
|
||||
if( preg_match('/\bvoirsurv\b/i', $_SESSION['tabInfo']['pref']) &&
|
||||
inSurveillance($source, $siret)){
|
||||
if (!empty($source) &&
|
||||
array_key_exists($source, $assocSourceDroit) &&
|
||||
hasPerm($assocSourceDroit[$source]) ){
|
||||
if( hasPref('voirsurv') && inSurveillance($source, $siret)){
|
||||
$return = '<br/>L\'entité est sous surveillance.'."\n";
|
||||
}else{
|
||||
$return = formSurveillance($source, $siret, $notEmail);
|
||||
@ -161,12 +175,9 @@ function getSurveillance($source, $siret){
|
||||
* true or false
|
||||
*/
|
||||
function inSurveillance($source, $siret){
|
||||
global $client, $firephp;
|
||||
$firephp->log($source, 'source');
|
||||
$firephp->log($siret, 'siret');
|
||||
global $client;
|
||||
try{
|
||||
$result = $client->getSurveillances($siret,$source);
|
||||
$firephp->log($result['results']['reponses'], 'response');
|
||||
if(count($result['results']['reponses'])>0 ){
|
||||
$find = FALSE;
|
||||
if(strlen($siret)>9) $siret = substr($siret, 0, 9);
|
||||
@ -190,32 +201,43 @@ function inSurveillance($source, $siret){
|
||||
*/
|
||||
function setSurveillance($tabForm)
|
||||
{
|
||||
global $client, $firephp;
|
||||
global $client;
|
||||
$siret = $tabForm['siret'];
|
||||
$email = $tabForm['email'];
|
||||
$ref = $tabForm['ref'];
|
||||
$source = $tabForm['source'];
|
||||
$firephp->log($tabForm,'tabForm');
|
||||
if(is_array($source))
|
||||
{
|
||||
foreach($source as $s)
|
||||
{
|
||||
isset($tabForm['encours']) && !empty($tabForm['encours']) ?
|
||||
$encours = $tabForm['encours'] : $encours = 0;
|
||||
|
||||
//Vérification de l'encours (chiffres)
|
||||
if (!preg_match('/([0-9]+)/', $encours)){
|
||||
return 'Encours incorrect';
|
||||
exit;
|
||||
}
|
||||
|
||||
//Mise en surveillance pour une liste de sources
|
||||
if (is_array($source)){
|
||||
foreach ($source as $s){
|
||||
try{
|
||||
$result = $client->setSurveillance($siret, $email, $ref, $s);
|
||||
$firephp->log($s, 'Surveillance');
|
||||
$result = $client->setSurveillance($siret, $email, $ref, $s,
|
||||
false, $encours);
|
||||
FB::log($s, 'Surveillance');
|
||||
$result = '';
|
||||
}catch(SoapFault $fault){
|
||||
$firephp->log($fault,'fault');
|
||||
FB::log($fault,'fault');
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Mise en surveillance pour une source
|
||||
} else {
|
||||
try{
|
||||
$result = $client->setSurveillance($siret, $email, $ref, $source);
|
||||
$firephp->log($source, 'Surveillance seul');
|
||||
$result = $client->setSurveillance($siret, $email, $ref, $source,
|
||||
false, $encours);
|
||||
FB::log($source, 'Surveillance seul');
|
||||
$result = '';
|
||||
}catch (SoapFault $fault){
|
||||
$firephp->log($fault,'fault');
|
||||
FB::log($fault,'fault');
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
@ -237,17 +259,11 @@ function setSurveillance($tabForm)
|
||||
* Retourne la réponse du webservice ou false
|
||||
*/
|
||||
function deleteSurveillance($siret, $email, $ref, $source){
|
||||
global $client, $firephp;
|
||||
$firephp->log($siret, 'siret');
|
||||
$firephp->log($email, 'email');
|
||||
$firephp->log($ref, 'ref');
|
||||
$firephp->log($source, 'source');
|
||||
global $client;
|
||||
try{
|
||||
$result = $client->setSurveillance($siret, $email, $ref, $source, TRUE);
|
||||
$firephp->log('Suppression surveillance');
|
||||
return TRUE;
|
||||
}catch(SoapFault $fault){
|
||||
$firephp->log($fault,'fault');
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -41,13 +41,15 @@ $(document).ready(function(){
|
||||
$(":button:contains('"+button+"')").attr('disabled','disabled');
|
||||
}
|
||||
var href = $(location).attr('href');
|
||||
var data = $("#frmSurv").serialize();
|
||||
var serData = $("#frmSurv").serialize();
|
||||
$("#frmSurv").replaceWith('<div id="frmSurv">Mise sous surveillance en cours...</div>');
|
||||
$.post('./pages/ajax_surveillance.php', data,
|
||||
function(data, textStatus) {
|
||||
$('#frmSurv').html(data);
|
||||
if(textStatus == 'success'){
|
||||
$.post('./pages/ajax_surveillance.php', serData,
|
||||
function(data) {
|
||||
if(data==''){
|
||||
$('#frmSurv').html("L'entité a été placé sous surveillance.\n");
|
||||
$(location).attr('href', href);
|
||||
}else{
|
||||
$('#frmSurv').html(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -12,13 +12,14 @@ $client = new SoapClient(null, array(
|
||||
|
||||
if($_REQUEST['q']=='setsurv')
|
||||
{
|
||||
$firephp->log($_REQUEST['formSurv'],'formSurv');
|
||||
$set = setSurveillance($_REQUEST['formSurv']);
|
||||
$firephp->log($set, 'set');
|
||||
if($set!==false){
|
||||
$return = '<br/>L\'entité a été placé sous surveillance.'."\n";
|
||||
FB::log($set, 'set');
|
||||
if($set==''){
|
||||
$return = '';
|
||||
}elseif ($set===false){
|
||||
$return = 'Erreur : Mise sous surveillance impossible.'."\n";
|
||||
}else{
|
||||
$return = '<br/>Une erreur a rendu impossible la mise sous surveillance.'."\n";
|
||||
$return = 'Erreur : '.$set."\n";
|
||||
}
|
||||
}
|
||||
elseif($_REQUEST['q']=='getsurv')
|
||||
@ -27,12 +28,9 @@ elseif($_REQUEST['q']=='getsurv')
|
||||
}
|
||||
elseif($_REQUEST['q']=='ajouter')
|
||||
{
|
||||
$firephp->log($_REQUEST, 'REQUEST');
|
||||
$siret = $_REQUEST['siret'];
|
||||
$source = ( isset($_REQUEST['source']) && !empty($_REQUEST['source']) ) ?
|
||||
$_REQUEST['source'] : '' ;
|
||||
$return = formSurveillance($source, $siret, array(), true);
|
||||
}
|
||||
echo $return;
|
||||
exit;
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user