- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
function get_datefrom ($eventid, $eventtype)
{
global $filter_date_kudy;
$today = date("Ymd");
if ($filter_date_kudy) $today = $filter_date_kudy;
$todayweekday = date("w");
$quGroup = mysql_query("SELECT datefrom, dateto, permanent, weekday1, weekday2, weekday3, weekday4, weekday5, weekday6, weekday7 from eventtime where eventid='$eventid' and eventtype='$eventtype' order by datefrom ASC");
while ($flGroup = mysql_fetch_row($quGroup)) {
$datefrom = ($flGroup[0]);
$dateto = ($flGroup[1]);
$permanent = ($flGroup[2]);
$weekday1 = ($flGroup[3]);
$weekday2 = ($flGroup[4]);
$weekday3 = ($flGroup[5]);
$weekday4 = ($flGroup[6]);
$weekday5 = ($flGroup[7]);
$weekday6 = ($flGroup[8]);
$weekday7 = ($flGroup[9]);
if ($datefrom && !$dateto && !$permanent && $datefrom >= $today) $date = $datefrom;
if (!$datefrom && !$dateto && $permanent && !$weekday1 && !$weekday2 && !$weekday3 && !$weekday4 && !$weekday5 && !$weekday6 && !$weekday7) $date = $today;
if ($datefrom && $dateto && $today >= $datefrom && $today <= $dateto) $date = $today;
if (!$datefrom && !$dateto && $permanent && ($weekday1 || $weekday2 || $weekday3 || $weekday4 || $weekday5 || $weekday6 || $weekday7)) {
$dt = "";
if ($todayweekday == 0 && $weekday7) $dt = $today;
if ($todayweekday == 1 && $weekday1) $dt = $today;
if ($todayweekday == 2 && $weekday2) $dt = $today;
if ($todayweekday == 3 && $weekday3) $dt = $today;
if ($todayweekday == 4 && $weekday4) $dt = $today;
if ($todayweekday == 5 && $weekday5) $dt = $today;
if ($todayweekday == 6 && $weekday6) $dt = $today;
$j = 0;
while (!$dt && $j < 100) {
$j++;
$todayweekday2 = date("w", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
$today2 = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
if ($todayweekday2 == 0 && $weekday7) $dt = $today2;
if ($todayweekday2 == 1 && $weekday1) $dt = $today2;
if ($todayweekday2 == 2 && $weekday2) $dt = $today2;
if ($todayweekday2 == 3 && $weekday3) $dt = $today2;
if ($todayweekday2 == 4 && $weekday4) $dt = $today2;
if ($todayweekday2 == 5 && $weekday5) $dt = $today2;
if ($todayweekday2 == 6 && $weekday6) $dt = $today2;
}
$date = $dt;
}
if ($date) break;
}
return $date;
}
Комментарии (0) RSS
Добавить комментарий