par
guigui69 » 13 sept. 2017, 21:55
Bonjour,
Grace à Moogli qui m'a aidé sur un autre topic:
viewtopic.php?f=8&t=278215 concernant un calendrier/planning j'ai avancé sur mon sujet.
J'ai modifié mon code pour inclure autre info dans un Array:
$sql_conges="SELECT id_rhp, debut_conges, fin_conges,id_rhpcv FROM `rh_personnel_conges`
WHERE `id_rhp`='".$list["id_rhp"]."'
AND (month(`debut_conges`)='".$_POST["mois"]."' OR month(`fin_conges`)=".$_POST["mois"].")
AND (year(`debut_conges`)='".$_POST["annee"]."' OR year(`fin_conges`)='".$_POST["annee"]."')
and conges_annule='0'
ORDER BY debut_conges";
//echo '<br/>'.$sql_conges;
$query_conges= mysql_query($sql_conges) or die('erreursql_conges');
$nbconges=mysql_num_rows($query_conges);
if ($nbconges == null)
{
for ($i = 1; $i <= $count; $i++) {
echo '<td class="travail" >-</td>';
}
}
else
{
$listedateperiodeconges = array();
while ( $listc = mysql_fetch_array( $query_conges ) ){
echo '<br/>'.$listc["id_rhpcv"];
$id=$listc["id_rhpcv"];
$startperiodeconges = DateTime::createFromFormat('Y-m-d',$listc["debut_conges"]);
$endperiodeconges = DateTime::createFromFormat('Y-m-d',$listc["fin_conges"]);
$endperiodeconges = $endperiodeconges->add(new DateInterval('P1D'));
$intervalperiodeconges = new DateInterval('P1D');
//objet qui représente la période avec l'intervalle choisit
$daterangeperiodeconges = new DatePeriod($startperiodeconges, $intervalperiodeconges ,$endperiodeconges);
foreach($daterangeperiodeconges as $dateperiodeconges)
{
$listedateperiodeconges[$dateperiodeconges->format('d-m-Y')]= array("date" => $dateperiodeconges->format('Y-m-d'),"id" =>$id );
//echo'<th>', $date->format("d") ,'</th>';
echo $id;
}
}
$daterange2 = new DatePeriod($start, $interval ,$end);
foreach($daterange2 as $data){
echo '<td ';
if(isset($listedateperiodeconges[$data->format("d-m-Y")]))
{
if($listedateperiodeconges[$data->format("d-m-Y")]['id']=2)
{
..
.
Voici la donnée extrait de ma requete SQL:
Code : Tout sélectionner
id_rhp debut_conges fin_conges id_rhpcv
107 2017-08-28 2017-09-03 1
107 2017-09-11 2017-09-17 2
107 2017-09-18 2017-09-24 2
donc avec mon code il va liste tout les date entre 2017-08-28 et 2017-09-03 et normalement inclure ID_rhpcv ($id) à 1. et pourtant des qu'on arrive sur le 2017-09-01, il transforme le 1 en 2 et je comprend pas pourquoi
resultat de print_r($listedateperiodeconges);
Array
(
[28-08-2017] => Array
(
[date] => 2017-08-28
[id] => 1
)
[29-08-2017] => Array
(
[date] => 2017-08-29
[id] => 1
)
[30-08-2017] => Array
(
[date] => 2017-08-30
[id] => 1
)
[31-08-2017] => Array
(
[date] => 2017-08-31
[id] => 1
)
[01-09-2017] => Array
(
[date] => 2017-09-01
[id] => 2
)
[02-09-2017] => Array
(
[date] => 2017-09-02
[id] => 2
)
[03-09-2017] => Array
(
[date] => 2017-09-03
[id] => 2
)
[11-09-2017] => Array
(
[date] => 2017-09-11
[id] => 2
)
[12-09-2017] => Array
(
[date] => 2017-09-12
[id] => 2
)
Je comprend pas ce que j'ai loupé dans mon code, si quelqu'un pourrait m'eclairer

je suis preneur
merci d'avance
guigui69