168 lines
5.4 KiB
PHP
168 lines
5.4 KiB
PHP
<?php
|
|
function getAnnonceCollecte($idan, $siret = ''){
|
|
global $client;
|
|
$idanResult = false;
|
|
try {
|
|
$O = $client->getAnnonceCollecte($idan, $siret);
|
|
$idanResult = $O['result'];
|
|
} catch (SoapFault $fault) {
|
|
require_once 'soaperror.php';
|
|
processSoapFault($client, $fault, $_SESSION['tabInfo']);
|
|
}
|
|
return $idanResult;
|
|
}
|
|
|
|
function supprAnnonceCollecte($idan, $siret = ''){
|
|
global $client;
|
|
try {
|
|
$O = $client->supprAnnonceCollecte($idan, $siret);
|
|
$error = $O['error'];
|
|
} catch (SoapFault $fault) {
|
|
require_once 'soaperror.php';
|
|
processSoapFault($client, $fault, $_SESSION['tabInfo']);
|
|
}
|
|
if ( isset($error) && $error['errNum'] == 0 ){
|
|
$output = 'Annonce '.$idan.' supprimé !';
|
|
} elseif ( isset($error) && $error['errNum'] != 0 ) {
|
|
$output = 'Erreur lors de la suppression.';
|
|
} else {
|
|
$output = "Une erreur est survenue...";
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
function dupliqueAnnonceCollecte($idan, $siret){
|
|
global $client;
|
|
try {
|
|
$O = $client->dupliqueAnnonceCollecte($idan, $siret);
|
|
$error = $O['error'];
|
|
} catch (SoapFault $fault) {
|
|
require_once 'soaperror.php';
|
|
processSoapFault($client, $fault, $_SESSION['tabInfo']);
|
|
}
|
|
if ( isset($error) && $error['errNum'] == 0 ){
|
|
$output = 'Annonce '.$idan.' dupliqué sur '.$siret.'!';
|
|
} elseif ( isset($error) && $error['errNum'] != 0 ) {
|
|
$output = 'Erreur lors de la duplication.';
|
|
} else {
|
|
$output = "Une erreur est survenue...";
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
switch ( $subaction ) {
|
|
case 'deleteDialog':
|
|
$idan = $params[2];
|
|
$siret = $params[3];
|
|
?>
|
|
<div id="result">
|
|
Êtes-vous sur de vouloir supprimer l'annonce <?=$idan?> ?
|
|
</div>
|
|
<form name="deleteDialog">
|
|
<input type="hidden" name="idan" value="<?=$idan?>" />
|
|
<input type="hidden" name="siret" value="<?=$siret?>" />
|
|
</form>
|
|
<?php
|
|
break;
|
|
case 'copyDialog':
|
|
$idan = $params[2];
|
|
$siret = $params[3];
|
|
?>
|
|
<div id="result">
|
|
Affecte l'annonce <?=$idan?> de <?=$siret?> sur un nouveau siren.
|
|
</div>
|
|
<br/>
|
|
<form name="copyDialog">
|
|
<input type="hidden" name="idan" value="<?=$idan?>" />
|
|
Siren / Siret : <input type="text" name="siret" value="" />
|
|
</form>
|
|
<?php
|
|
break;
|
|
case 'editDialog':
|
|
$inEditDialog = true;
|
|
$idan = $params[2];
|
|
$siret = $params[3]; FB::log($siret, 'siret');
|
|
$siren = substr($siret,0,9); FB::log($siren, 'siren');
|
|
$nic = substr($siret,10,5);
|
|
if ( !empty($idan) ) {
|
|
$idanResult = getAnnonceCollecte($idan, $siret);
|
|
FB::log($idanResult, 'result');
|
|
//Limitation des événements
|
|
$eventLimits = array('5500');
|
|
foreach ( $eventLimits as $eventLimit ) {
|
|
if ( in_array($eventLimit, $idanResult['even']) && $idanResult['source']=='JT' ) {
|
|
echo '<link rel="stylesheet" type="text/css" media="all" href="css/saisie.css"/>';
|
|
echo '<script type="text/javascript" src="js/saisieajax.js"></script>';
|
|
echo '<form id="saisie" name="saisie" action="/?page=saisieajax&q=annonces/edit" method="post">';
|
|
echo '<input type="hidden" name="siret" value="'.$siret.'"/>';
|
|
echo '<input type="hidden" name="idan" value="'.$idan.'">';
|
|
//Mapper idanResult dans le tableau de saisie
|
|
require_once 'common/dates.php';
|
|
$saisie = array(
|
|
'source' => isset($_SESSION['source']) ? $_SESSION['source'] : $idanResult['source'],
|
|
'dateParution' => isset($_SESSION['dateParution']) ? $_SESSION['dateParution'] :
|
|
WDate::dateT('Y-m-d', 'd/m/Y', substr($idanResult['dateSource'],0,10)),
|
|
'numParution' => isset($_SESSION['numParution']) ? $_SESSION['numParution'] : '',
|
|
'dateJugement' => WDate::dateT('Y-m-d', 'd/m/Y', $idanResult['dateEffetFinP']),
|
|
'tribunal' => $idanResult['tribunal'],
|
|
'even' => $idanResult['even'],
|
|
'eventNum' => $eventLimit,
|
|
'comp' => $idanResult['complement'],
|
|
'montant' => $idanResult['montant'],
|
|
'dateFinPeriode' => WDate::dateT('Y-m-d', 'd/m/Y', $idanResult['dateJugement']),
|
|
);
|
|
$intervenants = array();
|
|
for ( $i=0 ; $i<3 ; $i++ ) {
|
|
$intervenants[$i] = array(
|
|
'type' => $idanResult['inter'.($i+1).'type'],
|
|
'id' => $idanResult['inter'.($i+1).'id'],
|
|
'nom' => $idanResult['inter'.($i+1).'nom'],
|
|
);
|
|
}
|
|
require_once realpath(dirname(__FILE__)).'/constantes.php';
|
|
require_once realpath(dirname(__FILE__)).'/saisie_form_event.php';
|
|
echo '</form>';
|
|
echo '<script>';
|
|
echo "$('form#saisie').bind('submit', function(){
|
|
var options = {
|
|
target: '#saisie',
|
|
beforeSubmit: function(formData){},
|
|
success: function(data){
|
|
$('#saisie').html(data);
|
|
}
|
|
};
|
|
$(this).ajaxSubmit(options);
|
|
return false;
|
|
});";
|
|
echo '</script>';
|
|
break;
|
|
} else {
|
|
$message = "Source : ".$idanResult['source']."<br/>";
|
|
$message.= "Evénement(s) non éditable : <br/>";
|
|
foreach($idanResult['even'] as $code => $event){
|
|
$message.= $code." - ".$event."<br/>";
|
|
}
|
|
echo $message;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 'delete':
|
|
$idan = $_REQUEST['idan'];
|
|
$siret = $_REQUEST['siret'];
|
|
echo supprAnnonceCollecte($idan, $siret);
|
|
break;
|
|
case 'copy':
|
|
$idan = $_REQUEST['idan'];
|
|
$siret = str_replace(' ','',$_REQUEST['siret']);
|
|
echo dupliqueAnnonceCollecte($idan, $siret);
|
|
break;
|
|
case 'edit':
|
|
$idan = $_REQUEST['idan'];
|
|
$siret = isset($_REQUEST['siret']) ? $_REQUEST['siret'] : '';
|
|
require_once realpath(dirname(__FILE__)).'/saisie_save.php';
|
|
echo saisie_save($siret, '', $tabInfo);
|
|
echo '<br/>';
|
|
echo supprAnnonceCollecte($idan, $siret);
|
|
break;
|
|
}
|