<?php

echo ShowDate(1450417031);
function ShowDate($timestamp)
{
    $stf = 0;
    $cur_time = time();
    $diff = $cur_time - $timestamp;
    $phrase = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
    $length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
    for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) {
    }
    if ($i < 0) {
        $i = 0;
    }
    $_time = $cur_time - $diff % $length[$i];
    $no = floor($no);
    if ($no != 1) {
        $phrase[$i] .= 's';
    }
    $value = sprintf("%d %s ", $no, $phrase[$i]);
    if ($stf == 1 && $i >= 1 && $cur_tm - $_time > 0) {
        $value .= time_ago($_time);
    }
    return $value . ' ago ';
}
            ?>
</td> 
                                                <td class="center"> <img src="./dist/images/media/<?php 
            echo $image;
            ?>
" style="width: 75px;"></td> 
                                                <td class="center"> <?php 
            echo $row['problem_description'];
            ?>
</td>
                                                <td class="center "> <?php 
            echo $row['status'] == '' ? 'อยู่ระหว่างดำเนินการ' : $row['status'];
            ?>
</td>
                                                <td class="center"> <?php 
            echo ShowDate($row['date_input']);
            ?>
</td>

                                                </td>

                                            </tr>


                                            <?php 
        }
    }
    ?>

                                </tbody>
                            </table>
        ?>
">
                                                    <p class="help-block">
                                                        - ซ่อมได้ทันที ลงบันทึกอาการ สถานะ <span class="badge">ซ่อมแล้ว</span> <br>
                                                        - ซ่อมได้แต่ต้องรออุปกรณ์ ลงบันทึกอาการ สถานะ <span class="badge">รอการแก้ไข</span><br>
                                                        - ซ่อมได้แต่ต้องไปส่งซ่อมข้างนอก ลงบันทึกอาการ สถานะ <span class="badge">ส่งซ่อมข้างนอก</span><br>
                                                        - ซ่อมไม่ได้ ลงบันทึกอาการ สถานะ <span class="badge">แทงจำหน่าย</span>

                                                    </p>
                                                </div>
                                            </div>
                                            <div class="row da-form-row">
                                                <label class="col-md-2">วันที่ซ่อม <span class="required"></span></label>
                                                <div class="col-md-10">
                                                    <input type="text" class="form-control" value="<?php 
        echo $row['date_success'] == '0000-00-00 00:00:00' ? '-' : ShowDate($row['date_success']);
        ?>
">
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>
                                            <div class="row da-form-row">
                                                <label class="col-md-2">หมายเหตุ <span class="required"></span></label>
                                                <div class="col-md-10">
                                                    <textarea class="form-control" rows="5" name="comment" ><?php 
        echo $row['comment'];
        ?>
</textarea>
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>
                        </div>
                        <div class="row da-form-row">
                            <label class="col-md-2">นามสกุลผู้แจ้งซ่อม <span class="required">*</span></label>
                            <div class="col-md-10">
                                <input class="form-control input-sm" name="last_name" type="text" value="<?php 
    echo getDataDesc('last_name', 'tb_repair', 'id=' . $_GET['id']);
    ?>
">
                                <p class="help-block"></p>
                            </div>
                        </div>
                        <div class="row da-form-row">
                            <label class="col-md-2">วันที่แจ้ง <span class="required">*</span></label>
                            <div class="col-md-10">
                                <input class="form-control input-sm" name="created_at" type="text" value="<?php 
    echo ShowDate(getDataDesc('created_at', 'tb_repair', 'id=' . $_GET['id']));
    ?>
">
                                <p class="help-block"></p>
                            </div>
                        </div>


                    </div>

                </div>
                <!-- /.col-lg-6 (nested) -->

                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
示例#5
0
$c = mysql_fetch_array($b);
$staff_id = $s['created_by'];
$d = "SELECT * FROM staff WHERE `staff_id` = '{$staff_id}' ";
$e = mysql_query($d, $connect);
$f = mysql_fetch_array($e);
$driver_id = $s['driver_id'];
$g = "SELECT * FROM staff WHERE `staff_id` = '{$driver_id}' ";
$h = mysql_query($g, $connect);
$i = mysql_fetch_array($h);
$car_id = $s['car_id'];
$j = "SELECT * FROM cars WHERE `car_id` = '{$car_id}' ";
$k = mysql_query($j, $connect);
$l = mysql_fetch_array($k);
echo "<span id ='box'style='color:#3f4fd2;text-align:center'> The trip is for " . $c['name'] . " and the exact location is " . $s['loc_desc'] . "</span>";
echo "<span id='box' style='text-align:center'>Vehicle to be used</br><span style='color:#3f4fd2;'>" . $l['make'] . "&nbsp;" . $l['model'] . "&nbsp;with registration number:&nbsp;" . $l['reg_num'] . "</span></span>";
echo "<span id='box'>Number of people travelling:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . $s['personnel_num'] . "</span></span>";
echo "<span id='box'>Date of use:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . ShowDate($s['date_use']) . "</span></span>";
echo "<span id='box'>Date of return:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . ShowDate($s['date_return']) . "</span></span>";
if ($_SESSION['privileges'] == "admin" || $_SESSION['privileges'] == "staff") {
    echo "<span id='box'>Assigned driver:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . $i['firstname'] . "&nbsp;" . $i['surname'] . "</span></span>";
    if ($_SESSION['privileges'] == "admin") {
        echo "<span id='box'>Booking made by:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . $f['firstname'] . "&nbsp;" . $f['surname'] . "</span></span>";
    }
} else {
    if ($_SESSION['privileges'] == "driver") {
        echo "<span id='box'>Booking made by:&nbsp;<span style='color:#3f4fd2;text-align:right'>" . $f['firstname'] . "&nbsp;" . $f['surname'] . "</span></span>";
    }
}
?>

" style="width: 75px;"></td> 
                                                <td class="center"> <?php 
            echo $row['problem_description'];
            ?>
</td>

                                                <td class="center"> <?php 
            echo ShowDate($row['date_input']);
            ?>
</td>
                                                <td class="center "> <?php 
            echo $row['status'] == '' ? 'อยู่ระหว่างดำเนินการ' : $row['status'];
            ?>
</td>
                                                <td class="center"> <?php 
            echo ShowDate($row['date_success']);
            ?>
</td>
                                                <?php 
            if ($_SESSION['group'] == 'ผู้บริหาร' || $_SESSION['group'] == 'ผู้ดูแลระบบ') {
                ?>
                                                    <td class="center"> <?php 
                echo getDataDesc('first_name', 'tb_staff', 'id = ' . $row['staff_id']);
                ?>
</td>
                                                <?php 
            }
            ?>
                                                </td>

                                            </tr>
        // insert ข้อมูลลงในตาราง tb_repair โดยฃื่อฟิลด์ และค่าตามตัวแปร array ชื่อ $data
        if (insert("tb_repair", $data)) {
            // บันทึกข้อมูลลงตาราง tb_repair
            if ($_POST['media_id'] != '') {
                //ถ้ามีรหัสคอมพิวเตอร์
                $arrIDMedia = explode(',', $_POST['media_id']);
                $repair_id = getDataDescLastID("id", 'tb_repair');
                foreach ($arrIDMedia as $key => $value) {
                    $data = array("repair_id" => $repair_id, "computer_id" => $value, "status" => '', "problem_description" => $_POST['problem_description'][$key], "created_at" => DATE_TIME, "updated_at" => DATE_TIME, "date_input" => DATE_TIME);
                    insert("tb_repair_list", $data);
                    // อัพเดรต status คอมพิวเตอร์หากมีการแจ้งปัญหา
                    $dataStatusCpt = array("status" => 'ส่งซ่อม', "updated_at" => DATE_TIME);
                    update("tb_computer", $dataStatusCpt, 'id = ' . $value);
                }
            }
            SetAlert('เพิ่ม แก้ไข ข้อมูลสำเร็จ <br><br> <b>รหัสการแจ้งซ่อม : ' . getDataDescLastID('id', 'tb_repair') . '<br> วันที่แจ้งซ่อม : ' . ShowDate(getDataDescLastID('created_at', 'tb_repair')) . '</b>', 'success');
            //แสดงข้อมูลแจ้งเตือนถ้าสำเร็จ
            header('location:' . ADDRESS . 'repair_add_user');
            die;
        }
    }
}
//ลบคอมพิวเตอร์
if ($_POST['media_id'] != '') {
    $all_id = '';
    $arrr = explode(',', $_POST['media_id']);
    foreach ($arrr as $v) {
        if ($_POST['delete_id'] != $v) {
            $all_id .= ',' . $v;
        }
    }
                $status = 'แจ้งซ่อม';
            } else {
                $status = getDataDesc('status', 'tb_repair_list', 'repair_id = ' . $row['id'] . ' AND computer_id = ' . $value);
            }
            ?>
                                                            <p class="badge "><?php 
            echo $value . ' | ' . $status;
            ?>
</p><br>
                                                        <?php 
        }
        ?>
                                                    </div>
                                                </td>
                                                <td class="center"><?php 
        echo ShowDate($row['created_at']);
        ?>
</td>
                                              
                                                <td class="center "><a href="<?php 
        echo ADDRESS;
        ?>
repair_edit_user&id=<?php 
        echo $row['id'];
        ?>
" class="btn btn-primary btn-small">แก้ไข / ดู</a> <a href="javascript:;" onclick="if (confirm('คุณต้องการลบข้อมูลนี้หรือใม่?') == true) {
                                                                    document.location.href = '<?php 
        echo ADDRESS;
        ?>
repair&id=<?php 
        echo $row['id'];