<?php
// 数据库连接配置
$servername = "localhost";
$username = "root";
$password = "0000000";
$dbname = "meet";
// 建立数据库连接
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("数据库连接失败: " . $conn->connect_error);
}
// 处理表单提交
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 获取表单数据
$date = $_POST["date"];
$team = $_POST["team"];
$location = $_POST["location"];
$moderator = $_POST["moderator"];
$content = $_POST["content"];
$signature = $_POST["signature"];
// 处理上传的照片
$photo = $_FILES["photo"];
$targetDir = "uploads/";
$targetFile = $targetDir . basename($photo["name"]);
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
// 检查图片大小,并自动缩小大小至100K以下
if ($photo["size"] > 100000) {
$tempFile = $photo["tmp_name"];
$maxWidth = 800;
$maxHeight = 100;
list($width, $height) = getimagesize($tempFile);
$ratio = min($maxWidth / $width, $maxHeight / $height);
$newWidth = $width * $ratio;
$newHeight = $height * $ratio;
$tempImage = imagecreatetruecolor($newWidth, $newHeight);
$sourceImage = null;
if ($imageFileType == "jpg" || $imageFileType == "jpeg") {
$sourceImage = imagecreatefromjpeg($tempFile);
} elseif ($imageFileType == "png") {
$sourceImage = imagecreatefrompng($tempFile);
}
imagecopyresampled($tempImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if ($imageFileType == "jpg" || $imageFileType == "jpeg") {
imagejpeg($tempImage, $targetFile, 75);
} elseif ($imageFileType == "png") {
imagepng($tempImage, $targetFile, 5);
}
imagedestroy($tempImage);
imagedestroy($sourceImage);
} else {
move_uploaded_file($photo["tmp_name"], $targetFile);
}
$sql1 = "SELECT * FROM meetings WHERE date = '$date'";
$result = $conn->query($sql1);
// 检查查询结果
if ($result->num_rows > 0) {
echo '<span style="color: red; font-size: 20px;">已有会议记录,不要重复添加。</span>' . $conn->error;
}else{
// 将数据插入数据库
$sql = "INSERT INTO meetings (date, team, location, moderator, content, photo, signature) VALUES ('$date', '$team', '$location', '$moderator', '$content', '$targetFile', '$signature')";
if ($conn->query($sql) === TRUE) {
// 移动上传的照片到指定目录
//echo "会议记录已成功保存";
header('Location: ok.html');
} else {
echo "保存会议记录时出错: " . $conn->error;
}
}
}
// 检查是否点击了查询按钮
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET["month"])) {
// 获取用户选择的月份
$month = $_GET["month"];
// 构造查询语句
$sql = "SELECT date FROM meetings WHERE date LIKE '$month%'";
// 执行查询
$result = $conn->query($sql);
// 显示查询结果
if ($result->num_rows > 0) {
// 输出数据
echo "<ul>";
while($row = $result->fetch_assoc()) {
echo "<li><a href='show_meetings.php?date=" . $row['date'] . "' target='_blank'>" . $row['date'] . "</a></li>";
}
echo "</ul>";
} else {
echo "无记录!";
}
// 关闭数据库连接
// $conn->close();
}
// 处理删除请求
if (isset($_POST['delete'])) {
$deleteDate = $_POST['delete-date'];
// 执行删除操作
$deleteQuery = "DELETE FROM meetings WHERE date = '$deleteDate'";
if (mysqli_query($conn, $deleteQuery)) {
header('Location: ok-1.html');
} else {
echo "<p>删除会议记录时出现错误: " . mysqli_error($conn) . "</p>";
}
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>晨会记录</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h2 {
font-size: 20px;
}
form {
margin-bottom: 20px;
}
input, textarea {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
box-sizing: border-box;
margin-bottom: 10px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
@media print {
.print-hidden {
display: none;
}
button {
display: none;
}
}
</style>
</head>
<body>
<div class="print-hidden">
<h2>添加晨会记录</h2>
<p style="color:red;font-size: 20px;">要求每个参会人员签字!</p>
<form method="POST" enctype="multipart/form-data">
日期: <input type="date" name="date" required><br>
班组: <input type="text" name="team" required><br>
地点: <input type="text" name="location" required><br>
主持人: <input type="text" name="moderator" required><br>
会议内容: <textarea name="content" rows="10" required>
1、带班负责人对当班作业人员点名,确保无错漏。
2、通过观察和询问了解人员心理、情绪状况是否正常。
3、传达贯彻相关上级、企业有关文件、会议精神和安全生产安排,布置当班工作任务。
4、结合当天实际,强调每个作业点安全注意事项等, 对可能出现的问题,提出应急措施和整改办法。
5、结合工作现场实际和天气情况,针对每个环节、每道工序、每个作业点强调安全生产注意事项,点评、解析存在的隐患或可能出现的问题,提出应急措施和整改办法。
6、对吊装作业进行风险分析,并确保措施可靠。
7、晨会内容及签到资料存档备查。
</textarea><br>
会议照片: <input type="file" name="photo" required><br>
<!--参加人员: <textarea name="signature" rows="4" required></textarea><br>-->
人员签名:<a href="sign.php" style="font-size: 25px;color:red;">点击此处签名</a><br><br>
<input type="submit" value="保存记录">
</form>
<h2>查询会议记录</h2>
<form method="GET">
<label for="month">选择月份:</label>
<input type="month" name="month" required>
<input type="submit" value="查询记录">
</form>
<h2>删除会议记录</h2>
<form method="post">
<label for="delete-date">选择删除的日期:</label>
<input type="date" id="delete-date" name="delete-date" required>
<input type="submit" name="delete" value="删除记录">
</form>
<center>© 青岛金隽铭企业网站 2023 All Rights Reserved. Powered by jinjunming</center>
</div>
</body>
</html>