extranet/www/pages/greffescmd.php

250 lines
5.9 KiB
PHP

<?php
/*
* Liste des commandes passées sur infogreffe
*
*/
if(isset($_REQUEST['submit']) && $_REQUEST['submit']=='comment')
{
require_once 'dbbootstrap.php';
setDbConn('sdv1');
$q = Doctrine_Query::create()
->update('Commandes')
->set('statutCommande', '?', $_REQUEST['statutCommande'])
->set('commentaire', '?', $_REQUEST['commentaire'])
->where('idCommande = ?', $_REQUEST['idCommande']);
//echo $q->getSql();
//print_r($q->getFlattenedParams());
echo $rows = $q->execute();
exit;
}
if(isset($_REQUEST['ajax']))
{
?>
<form>
<span id="message"></span><br/>
<input type="hidden" name="idCommande" value="<?=$_REQUEST['id']?>"/>
<input type="hidden" name="statutCommande" value="<?=$_REQUEST['erreur']?>"/>
Commentaire sur la commande G<?=$_REQUEST['id']?><br/>
<textarea name="commentaire" cols="40" rows="3"></textarea>
</form>
<?php
exit;
}
?>
<style type="text/css">
table {width:100%; border-collapse:collapse; margin:5px 0;}
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">
$(document).ready(function()
{
$('.changeEtat').each(function(){
var $link = $(this);
var $dialog = $('<div></div>')
.dialog({
autoOpen: false,
title: $link.attr('title'),
width: 400,
height: 200,
open: function(event, ui) {
$(this).load($link.attr('href'));
},
buttons: {
'Placer la commande en erreur': function() {
$.post('./pages/greffescmd.php',
{
idCommande: $('input[name=idCommande]').val(),
commentaire: $('textarea[name=commentaire]').val(),
statutCommande: $('input[name=statutCommande]').val(),
submit: 'comment'
},
function(data){
if(data==1){ $dialog.dialog('close'); }
else $('#message').html('Erreur...');
}
);
},
'Annuler': function() { $(this).dialog('close'); }
}
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
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<?=hasModeEdition()?' - Interface de production':''?></h1>
<?php
if (!$_SESSION['connected'])
{
echo 'Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité';
}
elseif(!hasModeEdition())
{
echo 'L\'accès à cette page est restreint';
}
//Affichage des commandes
else
{
require_once 'infogreffe/gestion.php';
isset($_REQUEST['num'])?
$num = trim($_REQUEST['num']) :
$num = '';
isset($_REQUEST['siren'])?
$siren = trim(preg_replace('/[^0-9]/','', $_REQUEST['siren'])) :
$siren = '';
$siren = str_replace(' ', '',$siren);
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
isset($_REQUEST['cmd'])?
$cmd = $_REQUEST['cmd'] :
$cmd = '';
if (isset($_REQUEST['cmd_recherche'])){
$num = strtoupper($_REQUEST['num']);
$commandes = commandesRecherche($num, $siren, $type);
} elseif (isset($_REQUEST['cmd_liste'])){
$etat = isset($_REQUEST['etat']) ? $_REQUEST['etat'] : '';
$date = isset($_REQUEST['date']) ? $_REQUEST['date'] : '';
$typeCommande = isset($_REQUEST['typeCommande'])? $_REQUEST['typeCommande'] : '';
$commandes = commandesListe($type, $etat, $date, $typeCommande);
}
?>
<h2>Rechercher une commande</h2>
<div class="blockh2">
<form name="cmd_recherche" method="post" action="./?page=greffescmd">
<label>Commande</label>&nbsp;
<input type="text" name="num" value="<?=$num?>"/>
ou <label>SIREN</label>&nbsp;
<input type="text" name="siren" size="9" value="<?=$siren?>" />
<label>Type</label>
<select name="type">
<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>
&nbsp;<input type="submit" name="cmd_recherche" value="Rechercher"/>
</form>
<br/>
<form name="cmd_liste" method="post" action="./?page=greffescmd">
<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="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="G">courrier infogreffe</option>
<option value="C">courrier S&D</option>
<option value="E">e-mail</option>
</select>
<?php
}
?>
<label>commandé au 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'));
$selected = '';
if( $i==$dateToday ){ $selected = 'selected'; }
?>
<option value="<?=$dateTime?>" <?=$selected?>>
<?=date('m/Y', $dateTime)?>
</option>
<?php
}
?>
</select>
<input type="submit" name="cmd_liste" value="Afficher"/>
</form>
</div>
<h2>Commandes</h2>
<div class="blockh2">
<?php
if (count($commandes)>0){
?>
<table>
<tbody>
<?php
foreach($commandes as $commande){
echo afficheCommande($commande, $type);
}
?>
</tbody>
</table>
<?php
} else {
?>
Aucune commande.
<?php
}
} // Fin permission d'accès
?>
</div>
</div>