1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
if ($sem=='2') {
$rec_deb=pg_query($dbconnect,"select generate_series('$start'::timestamp,'$datef'::timestamp, '1 week'::interval),generate_series('$end'::timestamp,'$datef'::timestamp, '1 week'::interval)");
while ($row = pg_fetch_row($rec_deb))
{
$debut = $row[0];
$fin = $row[1];
/*controle date*/
$rowcount=pg_query($dbconnect,"select start,fin, salles from evenement where resources='$ev' and (('$debut' > start and '$debut' < fin) or (start > '$debut' and fin < '$fin') or (start < '$debut' and fin > '$fin') or
('$fin' > start and '$fin' < fin) or ('$debut'= start and '$fin' = fin) or ('$debut'= start and '$fin' > fin)) group by start,fin, salles");
$rowrejet = pg_fetch_array($rowcount);
$startrejet=$rowrejet[0];
$finrejet=$rowrejet[1];
$debrej=date('d/m/Y H:i', strtotime($startrejet));
$finrej=date('d/m/Y H:i', strtotime($finrejet));
$rown = pg_num_rows($rowcount);
if ($rown == '0')
{
$sql=pg_query($dbconnect,"insert into evenement (start,fin,title,resources,salles,allday) values ('$debut','$fin','$title','$ev','$noms',true) RETURNING id");
$idrow=pg_fetch_array($sql);
$ids=$idrow[0];
$id = array($ids);
$_SESSION['id']= $id;
}
else
{
$sql=pg_query($dbconnect,"insert into evenement (start,fin,title,resources,salles,allday) values ('$debut','$fin','$title','$ev','$noms',true) where not exists
(select start,fin, salles from evenement where resources='$ev' and
(('$debut' > start and '$debut' < fin) or
(start > '$debut' and fin < '$fin') or
(start < '$debut' and fin > '$fin') or
('$fin' > start and '$fin' < fin) or
('$debut'= start and '$fin' = fin) or
('$debut'= start and '$fin' > fin)) group by start,fin, salles RETURNING id") ;
$idrow=pg_fetch_array($sql);
$ids=$idrow[0];
$id = array($ids);
$_SESSION['id']= $id;
echo "
<tbody>
<tr>
<td> $debrej </td>
<td> $finrej </td>
<td> Rejeté plage horaire prise </td>
</tr>
</tbody>";
}
var_dump($id);
$deb=date('d/m/Y H:i', strtotime($debut));
$fi=date('d/m/Y H:i', strtotime($fin));
echo "
<tbody>
<tr>
<td>$ids</td>
<td>$id</td>
<td> $deb </td>
<td> $fi </td>
</tr>
</tbody>";
$_SESSION['deb']=$debut;
$_SESSION['fine']=$fin;
}
} |
Partager