0){
$whereDriver = " AND di_driver_uid = '{$driver_uid}'";
}
}
// driver list
$driverList = [];
$sql_member = "SELECT dr_uid, dr_initial FROM tbl_driver WHERE dr_type = 'INSTALL' and dr_status = 'A' ORDER BY dr_initial";
$res_member = $jdb->nQuery($sql_member, "Load driver list error");
while($row = mysqli_fetch_assoc($res_member)){
$driverList[] = $row;
}
$driverInitialMap = [];
foreach($driverList as $d){
$driverInitialMap[(int)$d['dr_uid']] = $d['dr_initial'];
}
// daily install data
$installData = [];
$sql_order = "
SELECT di.*,
n.n_note AS di_additional_note,
EXISTS(
SELECT 1
FROM tbl_customer_image ci
WHERE ci.i_sourceuid = di.di_uid
and ci.i_type in ('install','clean_before','clean_after')
LIMIT 1
) AS has_image
FROM tbl_daily_install di
LEFT JOIN tbl_note n
ON n.n_dailyuid = CONCAT('i_', di.di_uid)
WHERE di_install_date = '{$selectedDate}'
{$whereDriver}
ORDER BY di_driver_uid, di_order_seq ASC
";
$res_order = $jdb->nQuery($sql_order, "Load daily install error");
// install container
while($row = mysqli_fetch_assoc($res_order)){
// 컨테이너 불러오기
$containers = [];
$sql2 = "
SELECT *
FROM tbl_daily_install_container
WHERE dic_di_uid = {$row['di_uid']}
";
$r2 = $jdb->nQuery($sql2,"Load container error");
while($c = mysqli_fetch_assoc($r2)){
$containers[] = $c;
}
$row['containers'] = $containers;
$installData[] = $row;
}
// image
if (isset($_GET['ajax']) && $_GET['ajax'] === 'work_images') {
if (ob_get_length()) ob_clean();
header('Content-Type: application/json; charset=utf-8');
$type = $_GET['type'] ?? ''; // 'install' or 'install_order'
$sourceuid = (int)($_GET['sourceuid'] ?? 0);
// type 화이트리스트
if (!in_array($type, ['install', 'install_order', 'clean_before', 'clean_after'], true)) {
echo json_encode(['ok' => false, 'msg' => 'Invalid type']);
exit;
}
$qry = "
SELECT tci.*
FROM tbl_customer_image tci
WHERE tci.i_type = '".addslashes($type)."'
AND tci.i_sourceuid = {$sourceuid}
AND tci.i_status = 'A'
ORDER BY tci.i_uid DESC
LIMIT 1
";
$rt = $jdb->nQuery($qry, "work image list error");
$img = mysqli_fetch_assoc($rt);
// 없으면 빈
if (!$img) {
echo json_encode(['ok' => true, 'data' => null]);
exit;
}
// filepath + filename split
$files = array_filter(array_map('trim', explode(',', $img['i_filename'] ?? '')));
$images = [];
foreach ($files as $f) {
$images[] = ($img['i_filepath'] ?? '') . $f;
}
echo json_encode([
'ok' => true,
'data' => [
'i_uid' => $img['i_uid'],
'i_type' => $img['i_type'],
'i_sourceuid' => $img['i_sourceuid'],
'i_note' => $img['i_note'],
'i_createddate' => $img['i_createddate'],
'images' => $images
]
]);
exit;
}
?>
Load Before Start
Expected Return