par
piotrowski-s » 10 mai 2012, 09:27
j'ai juste un tout petit soucis, en fait voici le code
<?php if (isset($_GET['liasse']) AND $_GET['liasse']=='liasse_a') { ?>
<?php
$sql = "SELECT * FROM liasse_a where n_doss='".mysql_real_escape_string($_GET['n_doss'])."' AND date_action < now() ";
$qry = mysql_query($sql) or die(__LINE__.mysql_error().$sql);
$get_date = function($data_jours) {
$today = new DateTime();
$today->setTime(0, 0);
$jours = (isset($_POST['jours']) && ctype_digit($_POST['jours'])) ? $_POST['jours'] : 0;
if (isset($_POST['submit']) && ($_POST['submit'] === 'moins')) {
$jours = -$jours;
}
$nb = $data_jours + $jours;
$func = ($nb < 0) ? 'sub' : 'add';
$interval = new DateInterval("P{$nb}D");
return $today->$func($interval)->format('d-m-Y');
};
$i = -1; // index des enregistrements
?>
<table cellpadding="5" cellspacing="5">
<tr>
<td><strong>CODE SCENARIO</strong></td>
<td><strong>LIBELLE</strong></td>
<td><strong>ACTION</strong></td>
<td><strong>DESCRIPTION</strong></td>
<td><strong>DATE</strong></td>
</tr>
<form action="<?php echo (isset($_POST['go'])) ? 'go2.php' : '#'; ?>" method="post">
<input type="hidden" name="liasse" value="<?php echo $_GET['liasse']; ?>"/>
<input type="hidden" name="n_doss" value="<?php echo $_GET['n_doss']; ?>"/>
<?php while($row = mysql_fetch_assoc($qry)): ?>
<tr>
<td><input name="data[<?php echo ++$i; ?>][code_s]" type="text" value="<?php echo $row['code_s'];?>" size="10"></td>
<td><input name="data[<?php echo $i; ?>][libelle]" type="text" value="<?php echo $row['libelle']; ?>" size="45"></td>
<td><input name="data[<?php echo $i; ?>][action]" type="text" value="<?php echo $row['action']; ?>" size="15"></td>
<td><input name="data[<?php echo $i; ?>][libelle]" type="text" value="<?php echo $row['description']; ?>" size="55"></td>
<td><input type="text" name="data[<?php echo $i; ?>][date]" value="<?php $jours = date('d-m-Y',strtotime($row['date_action'])) ; echo $get_date($jours) ; ?>" size="12"></td>
</tr>
<?php endwhile; ?>
<p>
<strong>Décalage des date </strong>
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" bgcolor="#FFFF99">
<input type="image" src="images/minus_remove_green.png" width="22" height="22" name="submit" value="moins" />
<input name="jours" type="text" value="" size="5" />
<input type="image" src="images/plus_add_green.png" width="22" height="22" name="submit" value="plus" />
</td>
</tr>
</table>
d'office il m'incrémente 10 jours, sans que je ne lui ai demandé. Par exemple, j'ai des enregistrements au 8 mai dans ma bdd, et lui il m'affiche avec la condition < a now() le 18 mai, or si c'était le cas ca ne serait pas possible.
du coup je ne sais pas, je penses que cela vient de la fonction, mais je ne sais pas comment et pourquoi.
j'ai juste un tout petit soucis, en fait voici le code [php] <?php if (isset($_GET['liasse']) AND $_GET['liasse']=='liasse_a') { ?>
<?php
$sql = "SELECT * FROM liasse_a where n_doss='".mysql_real_escape_string($_GET['n_doss'])."' AND date_action < now() ";
$qry = mysql_query($sql) or die(__LINE__.mysql_error().$sql);
$get_date = function($data_jours) {
$today = new DateTime();
$today->setTime(0, 0);
$jours = (isset($_POST['jours']) && ctype_digit($_POST['jours'])) ? $_POST['jours'] : 0;
if (isset($_POST['submit']) && ($_POST['submit'] === 'moins')) {
$jours = -$jours;
}
$nb = $data_jours + $jours;
$func = ($nb < 0) ? 'sub' : 'add';
$interval = new DateInterval("P{$nb}D");
return $today->$func($interval)->format('d-m-Y');
};
$i = -1; // index des enregistrements
?>
<table cellpadding="5" cellspacing="5">
<tr>
<td><strong>CODE SCENARIO</strong></td>
<td><strong>LIBELLE</strong></td>
<td><strong>ACTION</strong></td>
<td><strong>DESCRIPTION</strong></td>
<td><strong>DATE</strong></td>
</tr>
<form action="<?php echo (isset($_POST['go'])) ? 'go2.php' : '#'; ?>" method="post">
<input type="hidden" name="liasse" value="<?php echo $_GET['liasse']; ?>"/>
<input type="hidden" name="n_doss" value="<?php echo $_GET['n_doss']; ?>"/>
<?php while($row = mysql_fetch_assoc($qry)): ?>
<tr>
<td><input name="data[<?php echo ++$i; ?>][code_s]" type="text" value="<?php echo $row['code_s'];?>" size="10"></td>
<td><input name="data[<?php echo $i; ?>][libelle]" type="text" value="<?php echo $row['libelle']; ?>" size="45"></td>
<td><input name="data[<?php echo $i; ?>][action]" type="text" value="<?php echo $row['action']; ?>" size="15"></td>
<td><input name="data[<?php echo $i; ?>][libelle]" type="text" value="<?php echo $row['description']; ?>" size="55"></td>
<td><input type="text" name="data[<?php echo $i; ?>][date]" value="<?php $jours = date('d-m-Y',strtotime($row['date_action'])) ; echo $get_date($jours) ; ?>" size="12"></td>
</tr>
<?php endwhile; ?>
<p>
<strong>Décalage des date </strong>
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" bgcolor="#FFFF99">
<input type="image" src="images/minus_remove_green.png" width="22" height="22" name="submit" value="moins" />
<input name="jours" type="text" value="" size="5" />
<input type="image" src="images/plus_add_green.png" width="22" height="22" name="submit" value="plus" />
</td>
</tr>
</table>[/php]
d'office il m'incrémente 10 jours, sans que je ne lui ai demandé. Par exemple, j'ai des enregistrements au 8 mai dans ma bdd, et lui il m'affiche avec la condition < a now() le 18 mai, or si c'était le cas ca ne serait pas possible.
du coup je ne sais pas, je penses que cela vient de la fonction, mais je ne sais pas comment et pourquoi.