초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
61
make/get_check_done.php
Normal file
61
make/get_check_done.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$num = isset($_GET['num']) ? $_GET['num'] : '';
|
||||
|
||||
$response = ['success' => false];
|
||||
|
||||
if ($num) {
|
||||
try {
|
||||
$pdo = db_connect();
|
||||
|
||||
$sql = "SELECT screenlist FROM chandj.output WHERE num = ?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_INT);
|
||||
$stmh->execute();
|
||||
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row) {
|
||||
$screenlist = json_decode($row['screenlist'], true);
|
||||
if (is_array($screenlist)) {
|
||||
$totalCompleted = 0;
|
||||
$totalItems = 0;
|
||||
$checkQuantity = 0;
|
||||
|
||||
foreach ($screenlist as $item) {
|
||||
$totalItems += isset($item['number']) ? (float)$item['number'] : 0;
|
||||
if (isset($item['done_check']) && $item['done_check'] == "1") {
|
||||
$totalCompleted += isset($item['number']) ? (float)$item['number'] : 0;
|
||||
}
|
||||
|
||||
if (
|
||||
(isset($item['left_check']) && $item['left_check'] == "1") ||
|
||||
(isset($item['right_check']) && $item['right_check'] == "1") ||
|
||||
(isset($item['mid_check']) && $item['mid_check'] == "1") ||
|
||||
(isset($item['remain_check']) && $item['remain_check'] == "1") ||
|
||||
(isset($item['done_check']) && $item['done_check'] == "1")
|
||||
) {
|
||||
$checkQuantity += isset($item['number']) ? (float)$item['number'] : 0;
|
||||
}
|
||||
|
||||
}
|
||||
$response['success'] = true;
|
||||
$response['totalCompleted'] = $totalCompleted;
|
||||
$response['totalItems'] = $totalItems;
|
||||
$response['checkQuantity'] = $checkQuantity;
|
||||
} else {
|
||||
$response['message'] = "Invalid screenlist format";
|
||||
}
|
||||
} else {
|
||||
$response['message'] = "No data found";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$response['message'] = "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
?>
|
||||
Reference in New Issue
Block a user