Nouvelle interface de consultation des commandes infogreffes (courrier, etc), issue #0000252
This commit is contained in:
parent
0aa4a799bc
commit
b3c17f902b
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
require_once 'common/dates.php';
|
||||
require_once 'dbbootstrap.php';
|
||||
require_once 'infogreffe/constantes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/constantes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/infogreffews.php';
|
||||
|
||||
/**
|
||||
* Recherche les commandes suivant le numéro de commande et/ou le siren
|
||||
@ -18,6 +19,9 @@ function commandesRecherche($num, $siren, $type = '-'){
|
||||
$table = tableNumCommande($num);
|
||||
$identifiant = identifiantTable($table);
|
||||
$q->from($table)->where($identifiant.' = ?', substr($num,1));
|
||||
if (!hasModeEdition()){
|
||||
$q->andWhere('login = ?', $_SESSION['tabInfo']['login']);
|
||||
}
|
||||
$commandes = $q->execute();
|
||||
$outputCommandes = array();
|
||||
foreach ($commandes as $commande){
|
||||
@ -29,6 +33,9 @@ function commandesRecherche($num, $siren, $type = '-'){
|
||||
} elseif (!empty($siren)) {
|
||||
$table = tableTypeCommande($type);
|
||||
$q->from($table)->where('siren = ?', $siren);
|
||||
if (!hasModeEdition()){
|
||||
$q->andWhere('login = ?', $_SESSION['tabInfo']['login']);
|
||||
}
|
||||
$commandes = $q->execute();
|
||||
//Filtrage
|
||||
if($type!='-' && count($commandes)>0){
|
||||
@ -145,13 +152,28 @@ function documentLib($ref, $info, $type){
|
||||
function documentInfo($ref, $info, $type){}
|
||||
|
||||
|
||||
function documentFilename($siren, $ref, $type){
|
||||
$filename = '';
|
||||
switch($type){
|
||||
case 'greffe':
|
||||
if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $ref, $matches)){
|
||||
$filename = infogreffe_acte_filename($siren, $ref);
|
||||
} elseif (preg_match('/^([0-9]{4}).*?$/', $ref, $matches)){
|
||||
$filename = infogreffe_bilan_filename($siren, $ref);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown_type $type
|
||||
* @param unknown_type $etat
|
||||
* @param unknown_type $date
|
||||
*/
|
||||
function commandesListe($type, $etat, $date){
|
||||
function commandesListe($type, $etat, $date, $mode){
|
||||
setDbConn('sdv1');
|
||||
$table = tableTypeCommande($type);
|
||||
|
||||
@ -178,6 +200,14 @@ function commandesListe($type, $etat, $date){
|
||||
break;
|
||||
}
|
||||
|
||||
if ($mode!=''){
|
||||
$q->andWhere('typeCommande = ?', $mode);
|
||||
}
|
||||
|
||||
if (!hasModeEdition()){
|
||||
$q->andWhere('login = ?', $_SESSION['tabInfo']['login']);
|
||||
}
|
||||
|
||||
//Résultat
|
||||
$commandes = $q->execute();
|
||||
FB::log($commandes->toArray(), 'commandes');
|
||||
@ -200,14 +230,30 @@ function commandesListe($type, $etat, $date){
|
||||
return $commandes;
|
||||
}
|
||||
|
||||
function listStatus(){
|
||||
$q = Doctrine_Query::create()
|
||||
->from('CommandesStatut')
|
||||
->where('typeCommande = ?', 'C')
|
||||
->orderBy('ordre ASC');
|
||||
$cStatuts = $q->execute();
|
||||
return $cStatuts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la raison sociale à partir du siren
|
||||
* @param unknown_type $siren
|
||||
*/
|
||||
function raisonSociale($siren){
|
||||
|
||||
|
||||
|
||||
global $client;
|
||||
$rs = '';
|
||||
try {
|
||||
$O = $client->getIdentite($siren, 0, false);
|
||||
$rs = $O['result']['Nom'];
|
||||
} catch (SoapFault $fault) {
|
||||
require_once 'soaperror.php';
|
||||
processSoapFault($client,$fault,$tabInfo);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
@ -217,6 +263,8 @@ function raisonSociale($siren){
|
||||
*/
|
||||
function afficheCommande($commande, $type){
|
||||
|
||||
static $compteur = 0;
|
||||
|
||||
if ($commande->typeCommande=='' || $commande->typeCommande=='G'){
|
||||
$typeCommande = 'G';
|
||||
} elseif ($commande->typeCommande=='C'){
|
||||
@ -228,28 +276,117 @@ function afficheCommande($commande, $type){
|
||||
$commande->libDocument,
|
||||
'greffe');
|
||||
|
||||
$output =
|
||||
'<tr><td colspan="3">'.$typeCommande.$commande->idCommande.'</td></tr>'.
|
||||
'<tr>'.
|
||||
' <td>'.
|
||||
' <div>'.$commande->siren.'</div>'.
|
||||
' <div>(RS)</div>'.
|
||||
' </td>'.
|
||||
' <td>'.
|
||||
' <div><u>Document :</u> '.$documentLib.'</div>'.
|
||||
' <div>Informations : '.$commande->libDocument.'</div>';
|
||||
$colspan = 3;
|
||||
|
||||
/*
|
||||
* Lien pour placer une erreur sur la commande en mode edition
|
||||
*/
|
||||
$contenuLien = '';
|
||||
if ($commande->statutCommande!=9 &&
|
||||
$commande->dateReception=='0000-00-00 00:00:00' &&
|
||||
hasModeEdition()){
|
||||
$output.=
|
||||
'<div>'.
|
||||
$contenuLien.= '<div>'.
|
||||
'<a class="changeEtat" title="Erreur sur la commande" target="_blank" '.
|
||||
'href="./pages/greffescmd.php?id='.$commande->idCommande.'&erreur=9&ajax=true">'.
|
||||
'Placer cette commande en erreur'.
|
||||
'</a>'.
|
||||
'</div>';
|
||||
$colspan = 1;
|
||||
}
|
||||
|
||||
$contenuEtat = '';
|
||||
|
||||
if ($typeCommande=='C' && hasModeEdition()){
|
||||
$cStatuts = listStatus();
|
||||
|
||||
$contenuEtat.= '<div>' .
|
||||
'<label>Changer l\'état : </label>' .
|
||||
'<select class="changeEtatC" name="Etat'.$commande->idCommande.'">';
|
||||
if($commande->statutCommande == 0)
|
||||
{
|
||||
$contenuEtat.='<option value="0">Non traité</option>';
|
||||
}
|
||||
foreach ($cStatuts as $cStatut)
|
||||
{
|
||||
$selected = '';
|
||||
//Selection du statut en cours
|
||||
if($cStatut->ordre == $commande->statutCommande)
|
||||
{
|
||||
$selected = 'selected';
|
||||
}
|
||||
//Ne pas afficher les états précedents et les états suivant +2
|
||||
if( $cStatut->ordre == $commande->statutCommande ||
|
||||
$cStatut->ordre == $commande->statutCommande+1 ){
|
||||
$contenuEtat.= '<option value="'.
|
||||
$commande->idCommande.'-'.$cStatut->id.'" '.$selected.'>'.
|
||||
$cStatut->libStatut .
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
$contenuEtat.= '</select></div>';
|
||||
|
||||
$contenuEtat.= '<a href="./pages_saisie/gencourrier.php?id='.
|
||||
$commande->idCommande.'"target="_blank">Générer le courrier</a>';
|
||||
|
||||
}
|
||||
|
||||
if ($compteur%2){
|
||||
$class = 'even';
|
||||
}else{
|
||||
$class = 'odd';
|
||||
}
|
||||
$compteur++;
|
||||
|
||||
$output = '<tr class="'.$class.'">'.
|
||||
'<td style="vertical-align:bottom;" colspan="'.$colspan.'">'.
|
||||
$typeCommande . $commande->idCommande .
|
||||
'</td>';
|
||||
|
||||
if ($colspan == 1){
|
||||
$output.= '<td colspan="2">'.$contenuLien . $contenuEtat.'</td>';
|
||||
}
|
||||
$output.= '</tr>';
|
||||
|
||||
$output.= '<tr class="'.$class.'">'.
|
||||
' <td>'.
|
||||
' <div><a href="/?page=identite&siret="'.$commande->siren.'>'.
|
||||
$commande->siren.'</a></div>'.
|
||||
' <div>'.raisonSociale($commande->siren).'</div>'.
|
||||
' </td>'.
|
||||
' <td>'.
|
||||
' <div><u>Document :</u> '.$documentLib.'</div>'.
|
||||
' <div>Informations : '.$commande->libDocument.'</div>';
|
||||
|
||||
/* Affichage du lien vers le document pdf - en mode edition et si la
|
||||
* date de reception est de moins d'un mois pour les clients
|
||||
*/
|
||||
if ($commande->dateReception != '0000-00-00 00:00:00'){
|
||||
$dateMoinsMois = mktime(0, 0, 0,
|
||||
date('m')-1,
|
||||
date('d'),
|
||||
date('Y'));
|
||||
$dateReception = mktime(0, 0, 0,
|
||||
substr($commande->dateReception,4,2),
|
||||
substr($commande->dateReception,6,2),
|
||||
substr($commande->dateReception,0,4));
|
||||
$output.= '<div>';
|
||||
if (hasModeEdition() || $dateMoinsMoins>$dateReception){
|
||||
$filename = documentFilename($commande->siren, $commande->refDocument, $type);
|
||||
if (file_exists(PATH_DATA.'/pdf/'.$filename)){
|
||||
$output.= '<a href="./datafile.php?q='.$filename.'&type=pdf">'.
|
||||
'Télécharger le fichier de votre commande</a>';
|
||||
} else {
|
||||
$output.= 'Erreur : Le fichier n\'a pas été trouvé.';
|
||||
}
|
||||
} else {
|
||||
$output.= 'Consulter les pièces pour afficher le document';
|
||||
}
|
||||
$output.= '</div>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Affichage du commentaire d'erreur sur la commande
|
||||
*/
|
||||
if ($commande->statutCommande==9){
|
||||
$output.=
|
||||
'<div>'.
|
||||
|
@ -46,11 +46,12 @@ function typeCommandeTarifsWs($ref)
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
table {width:100%; border-collapse:collapse; margin:5px 0;}
|
||||
th, td {border:1px solid; padding:5px;}
|
||||
table tr.odd {background-color:#e6eeee;}
|
||||
table tr.even {}
|
||||
table th, table td {border:1px solid; padding:5px;}
|
||||
select {font-size:11px;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
@ -91,10 +92,20 @@ $(document).ready(function()
|
||||
});
|
||||
});
|
||||
|
||||
var url = './pages/ajax/greffescmd_courrier.php';
|
||||
|
||||
$('.changeEtatC').change(function(){
|
||||
var newEtat = $(this).val();
|
||||
var name = $(this).attr('name');
|
||||
$.post(url, { changeEtat: newEtat },
|
||||
function(data){ $('select[name='+name+']').replaceWith(data); }
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<div id="center">
|
||||
<h1>Commandes INFOGREFFE</h1>
|
||||
<h1>Commandes INFOGREFFE<?=hasModeEdition()?' - Interface de production':''?></h1>
|
||||
<?php
|
||||
if (!$_SESSION['connected'])
|
||||
{
|
||||
@ -118,6 +129,8 @@ else
|
||||
$cmd = $_REQUEST['cmd'] :
|
||||
$cmd = '';
|
||||
|
||||
require_once 'infogreffe/gestion.php';
|
||||
|
||||
?>
|
||||
<h2>Rechercher une commande</h2>
|
||||
<div class="blockh2">
|
||||
@ -141,25 +154,57 @@ else
|
||||
<br/>
|
||||
|
||||
<form name="cmd_liste" method="post" action="./?page=greffescmd">
|
||||
<label>Lister les commandes</label>
|
||||
<label>Lister les commandes de</label>
|
||||
<select name="type">
|
||||
<option value="greffe-bilans">Comptes annuels</option>
|
||||
<option value="greffe-actes">Actes & Statuts</option>
|
||||
<option value="greffe-bilans">comptes annuels</option>
|
||||
<option value="greffe-actes">actes & statuts</option>
|
||||
<!--
|
||||
<option value="pieces-kbis">Kbis</option>
|
||||
<option value="pieces-priv">Privilèges</option>
|
||||
-->
|
||||
</select>
|
||||
<?php
|
||||
$cStatuts = listStatus();
|
||||
?>
|
||||
<select name="etat">
|
||||
<option value="commande">en cours</option>
|
||||
<option value="reception">reçues</option>
|
||||
<option value="erreur">en erreur</option>
|
||||
|
||||
<?php
|
||||
if (count($cStatuts)>0 && hasModeEdition()){
|
||||
?>
|
||||
<option value="-">-</option>
|
||||
<?php
|
||||
foreach($cStatuts as $cStatut){
|
||||
?>
|
||||
<option value="C-"<?=$cStatut->id?>><?=$cStatut->libStatut?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
if (hasModeEdition()){
|
||||
?>
|
||||
<label>demandé par</label>
|
||||
<select name="typeCommande">
|
||||
<option value="-">-</option>
|
||||
<option value="E">courrier infogreffe</option>
|
||||
<option value="C">courrier S&D</option>
|
||||
<option value="E">e-mail</option>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<label>concernant le mois de</label>
|
||||
<select name="date">
|
||||
<?php
|
||||
$dateToday = date('m');
|
||||
$dateIntervalle = 12;
|
||||
if (hasModeEdition()){ $dateIntervalle = 24;}
|
||||
for($i=$dateToday-$dateIntervalle; $i<=$dateToday; $i++)
|
||||
{
|
||||
$dateTime = mktime(0, 0, 0, $i+1, 0, date('Y'));
|
||||
@ -181,17 +226,17 @@ for($i=$dateToday-$dateIntervalle; $i<=$dateToday; $i++)
|
||||
<h2>Commandes</h2>
|
||||
<div class="blockh2">
|
||||
<?php
|
||||
require_once 'infogreffe/gestion.php';
|
||||
if (isset($_REQUEST['cmd_recherche'])){
|
||||
$num = strtoupper($_REQUEST['num']);
|
||||
$siren = $_REQUEST['siren'];
|
||||
$type = $_REQUEST['type'];
|
||||
$commandes = commandesRecherche($num, $siren, $type);
|
||||
} elseif (isset($_REQUEST['cmd_liste'])){
|
||||
$etat = $_REQUEST['etat'];
|
||||
$date = $_REQUEST['date'];
|
||||
$type = $_REQUEST['type'];
|
||||
$commandes = commandesListe($type, $etat, $date);
|
||||
$etat = isset($_REQUEST['etat']) ? $_REQUEST['etat'] : '';
|
||||
$date = isset($_REQUEST['date']) ? $_REQUEST['date'] : '';
|
||||
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
|
||||
$typeCommande = isset($_REQUEST['typeCommande'])? $_REQUEST['typeCommande'] : '';
|
||||
$commandes = commandesListe($type, $etat, $date, $typeCommande);
|
||||
}
|
||||
|
||||
if (count($commandes)>0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user