extranet/www/pages/greffescmd.php

218 lines
5.0 KiB
PHP
Raw Normal View History

<?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;
}
2010-02-17 14:44:28 +00:00
function typeCommandeTarifsWs($ref)
{
if( preg_match('/^([0-9]{4}_).*?$/', $ref, $matches) )
{
$output = 'BI';
}elseif( preg_match('/^(ST_).*?$/', $ref, $matches) ){
$output = 'ST';
}else{
2010-02-17 14:44:28 +00:00
$output = 'AC';
}
return $output;
}
?>
<style type="text/css">
table {width:100%; border-collapse:collapse; margin:5px 0;}
th, 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;
});
});
});
</script>
<div id="center">
<h1>Commandes INFOGREFFE</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
{
isset($_REQUEST['num'])?
$num = trim($_REQUEST['num']) :
$num = '';
isset($_REQUEST['siren'])?
$siren = trim(preg_replace('/[^0-9]/','', $_REQUEST['siren'])) :
$siren = '';
isset($_REQUEST['cmd'])?
$cmd = $_REQUEST['cmd'] :
$cmd = '';
?>
<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</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>
<select name="etat">
<option value="commande">en cours</option>
<option value="reception">reçues</option>
<option value="erreur">en erreur</option>
</select>
<label>concernant le mois de</label>
<select name="date">
<?php
$dateToday = date('m');
$dateIntervalle = 12;
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
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);
}
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>