首页 > 代码库 > order meeting room - 离散度30min

order meeting room - 离散度30min

w

 

<meta charset="UTF-8">
<?php
include(‘conn.php‘);
include(‘w_fun.php‘);
include(‘config_lang.php‘);
include(‘w_fun_this_project.php‘);
$sql = ‘SET GLOBAL  connect_timeout=31536000‘;
mysqli_query($link, $sql);
$wclock0 = 8;
$wclock1 = 21;


$wtoday = date(‘Y-m-d‘);
$wts = strtotime($wtoday);
$wts += $wclock0 * 3600;
echo $wts . ‘<br>‘;

$sql = ‘SELECT * FROM room_order WHERE wstart>‘ . $wts . ‘  ORDER  BY wstart  ASC‘;
var_dump($sql);

$wts = strtotime($wtoday);
$wts += $wclock1 * 3600;
echo $wts . ‘<br>‘;

$wrows = db_multiple_rows_link($link, $sql);


echo ‘<br>-------------------------------db<br>‘;
foreach ($wrows AS $one) {
    //var_dump($one);
    echo ‘<br>‘;
    $date = date(‘Y_m_d‘, $one[‘wstart‘]);
    $dateb = date(‘H:i‘, $one[‘wstart‘]);
    $ws = intval(date(‘Hi‘, $one[‘wstart‘]));
    echo ‘<br>‘ . $date;
    echo ‘<br>‘ . $dateb;
    echo ‘<br>‘ . $ws;

    $date = date(‘Y_m_d‘, $one[‘wend‘]);
    $dateb = date(‘H:i‘, $one[‘wend‘]);
    $we = intval(date(‘Hi‘, $one[‘wend‘]));
    echo ‘<br>‘ . $date;
    echo ‘<br>‘ . $dateb;
    echo ‘<br>‘ . $we;
    $wcount = floor(($we - $ws) / 30);
    echo ‘<br>‘ . $wcount;
    for ($w = $wclock0; $w < $wclock1; $w++) {


        $wn = ‘w‘ . $date . ‘ws‘ . ($w * 100);
        $wv = ‘w‘;
        if ($ws >= ($w - 1) * 100 && $ws < ($w * 100 + 30)) {
            $wv = $one[‘id‘] . ‘@w@‘ . $one[‘sysuser‘];
        }
        wjs_cookie($wn, $wv);
        $wn = ‘w‘ . $date . ‘we‘ . ($w * 100);
        $wv = ‘w‘;
        if ($we >= ($w - 1) * 100 && $we < ($w * 100 + 30)) {
            $wv = $one[‘id‘] . ‘@w@‘ . $one[‘sysuser‘];
        }
        wjs_cookie($wn, $wv);


        $wn = ‘w‘ . $date . ‘ws‘ . ($w * 100 + 30);
        $wv = ‘w‘;
        if ($ws >= ($w * 100 + 30) && $ws < ($w + 1) * 100) {
            $wv = $one[‘id‘] . ‘@w@‘ . $one[‘sysuser‘];
        }
        wjs_cookie($wn, $wv);
        $wn = ‘w‘ . $date . ‘we‘ . ($w * 100 + 30);
        $wv = ‘w‘;
        if ($we >= ($w * 100 + 30) && $we < ($w + 1) * 100) {
            $wv = $one[‘id‘] . ‘@w@‘ . $one[‘sysuser‘];
        }
        wjs_cookie($wn, $wv);


    }
}


function wjs_cookie($wn, $wv)
{

    echo ‘<script>document.cookie="‘ . $wn . ‘=‘ . $wv . ‘";</script>‘;
}

echo ‘<br>-------------------------------wcookie<br>‘;
//var_dump($_COOKIE);


$sql = ‘SELECT MAX(wstart) AS wmaxdate FROM room_order ‘;
var_dump($sql);
$wmaxdate = db_single_row_single_field_link($link, $sql, ‘wmaxdate‘);
$wts = strtotime($wtoday);
//$wmaxdate  = date(‘Y_m_d‘, $wmaxdate );
echo ‘<br>‘ . $wmaxdate . ‘<br>‘;

$sql = ‘SELECT MIN(wstart) AS wmindate FROM room_order ‘;
var_dump($sql);
$wmindate = db_single_row_single_field_link($link, $sql, ‘wmindate‘);
$wts = strtotime($wtoday);
//$wmindate  = date(‘Y_m_d‘, $wmindate);
//echo   ‘<br>‘.$wmindate .‘<br>‘;
$wdays = ceil(($wmaxdate - $wmindate) / (24 * 3600));
var_dump($wdays);

?>
<script>
    console.log(document.cookie);
</script>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>order room - 离散度30min </title>
    <link rel="stylesheet" href="http://www.mamicode.com/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://www.mamicode.com/static/bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="http://www.mamicode.com/static/base.css">
    <script src="http://www.mamicode.com/static/jquery-3.1.0.min.js"></script>
</head>
<body>
<?php
$wtr = ‘<table class="table table-striped">
<tr><td>日期</td><td>会议室编号</td><td>会议室名称</td>;
for ($w = $wclock0; $w < $wclock1; $w++) {

    $wtr .= ‘<td>‘ . $w . ‘:00</td>‘;
    $wtr .= ‘<td>‘ . $w . ‘:30</td>‘;
}

$wtr .= ‘<td>‘ . $wclock1 . ‘:00</td></tr>‘;


for ($wtab = 0; $wtab < $wdays; $wtab++) {
    $wtr .= ‘<tr><td>‘ . date(‘Y-m-d‘, $wrows[$wtab][‘wstart‘]) . ‘</td><td>会议室编号12</td><td>会议室名称124</td>‘;
    for ($w = $wclock0; $w < $wclock1; $w++) {
        $wtr .= ‘<td>‘ . ‘wwr‘ . ‘:00</td>‘;
    }
    $wtr .= ‘</tr>‘;
}


$wtr .= ‘</table>‘;
echo $wtr;
?>

</body>
</html>

 

order meeting room - 离散度30min