[MAP][ORDER][CUSTOMER DETAIL] 슬러지 필수입력, 슬러지 입력값 지정

This commit is contained in:
Kang Lee 2026-05-11 11:19:53 -04:00
parent b79f0347a1
commit 591d17cec5
4 changed files with 179 additions and 35 deletions

View File

@ -318,7 +318,7 @@ class DailyService extends CONF {
// 숫자 필드 기본값
$intFields = [
'd_quantity',
'd_sludge'
//'d_sludge' 주석처리-값이 비었을 때 0이 되지 않게
];
foreach ($intFields as $f) {
@ -692,6 +692,13 @@ class DailyService extends CONF {
$isTop = $customer['c_is_top'] ?? '';
// [추가된 로직] d_sludge 업데이트 판단
// 화면에서 넘어온 d_sludge가 빈칸이 아니면 c_sludge를 갱신
if (isset($after['d_sludge']) && (string)$after['d_sludge'] !== '') {
$val = (int)$after['d_sludge'];
$updateFields[] = "c_sludge = '{$val}'";
}
// --------------------------------------------------
// 0) Ghost Check
// --------------------------------------------------

View File

@ -396,6 +396,15 @@ if ($mode == "update") {
$c_driveruidSTRM .= "<option value='".$lt_driver['dr_uid']."' $selected>".$lt_driver['dr_initial']."</option>";
}
// --- 슬러지 기본값 설정 로직 추가 시작 ---
// d_sludge(오늘 입력값)가 없으면 고객 정보의 c_sludge를 기본값으로 사용
if (!isset($d_sludge) || trim((string)$d_sludge) === '') {
$display_sludge = $c_sludge;
} else {
$display_sludge = $d_sludge;
}
// --- 로직 추가 끝 ---
}
addLog ("add", "CUSTOMER DETAIL", "VIEW", $lguserid, $query, $c_uid);
@ -2616,6 +2625,10 @@ $(document).ready(function(){
required: "#d_paystatuspaid:checked",
//minlength: 6,
},
// --- 슬러지 규칙 추가 ---
d_sludge: {
required: true
}
},
messages: {
d_quantity: {
@ -2626,16 +2639,48 @@ $(document).ready(function(){
required: "Please input Cash Amount",
//minlength: "Minimum of 6 characters.",
},
// --- 슬러지 메시지 추가 ---
d_sludge: {
required: "Please input Sludge value"
}
},
errorElement : 'div',
errorPlacement: function(error, element) {
// 메시지 스타일 조정
error.css({
"color": "red",
"font-size": "13px",
"margin-top": "2px",
"display": "block"
});
if (element.hasClass("d_sludge")) {
// 슬러지 버튼 박스(.number-input) 전체의 뒤에 에러 배치
error.insertAfter(element.closest('.number-input'));
} else {
error.insertAfter(element);
}
},
highlight: function(element) {
$(element).css('border', '2px solid red');
},
unhighlight: function(element) {
$(element).css('border', '');
},
// 핵심: 이 핸들러가 있어야 검증 실패 시 제출을 막습니다.
submitHandler: function(form) {
//if (grecaptcha.getResponse(1) == '') alert("Error");
//else form.submit();
form.submit();
}
});
// 증감 버튼 클릭 시 0이라도 값이 있으면 에러 즉시 삭제
$(document).on('click', '.number-input button', function() {
var $input = $(this).siblings('input.d_sludge');
setTimeout(function() {
$input.valid(); // 실시간 검증 트리거
}, 10);
});
// 2. [추가 코드] 오프캔버스 객체 생성 및 버튼 이벤트
@ -2748,9 +2793,9 @@ $(document).ready(function(){
</tr>
<tr>
<td class="td-title-info">Oil Quantity</td>
<td class="td-title-info">Quantity</td>
<td class="td-text-info">
<input type="text" id="d_quantity" name="d_quantity" placeholder="500" value="<?=$d_quantity?>" required='required' minlength="1" maxlength="10">
<input type="number" class="form-control required" id="d_quantity" name="d_quantity" value="<?=$d_quantity?>" placeholder="0">
</td>
</tr>
@ -2759,10 +2804,9 @@ $(document).ready(function(){
<td class="td-text-info">
<div class="number-input">
<button class="left" type="button"></button>
<input type="number" class="d_sludge" id="d_sludge" name="d_sludge" value="<?= (isset($d_sludge) && trim((string)$d_sludge) !== '') ? $d_sludge : $c_sludge ?>" min="0" max="100" placeholder="50">
<input type="number" class="d_sludge required" id="d_sludge" name="d_sludge" value="<?=$display_sludge?>" min="0" max="100">
<button class="right" type="button"></button>
</div>
</td>
</tr>

View File

@ -415,6 +415,7 @@ function popup(){
<td class="td-title-info">Oil Quantity</td>
<td class="td-text-info">
<input type="number" class="d_quantity" placeholder="500" minlength="1" maxlength="10">
<div class="qty-error" style="color: red; font-size: 11px; display: none; margin-top: 4px;">Please input Oil Quantity</div>
</td>
</tr>
@ -427,6 +428,9 @@ function popup(){
<input type="number" class="d_sludge" value="50" min="0" max="100" placeholder="50">
<button class="right" type="button"></button>
</div>
<div class="sludge-error" style="color: red; font-size: 11px; display: none; margin-top: 4px;">Please input the Sludge value.</div>
</td>
</tr>
</td>
</tr>
@ -1506,7 +1510,10 @@ function popup(){
let loadingTxt = 'Loading...';
jQuery("#map-modal-input .shortinput-store-name").text(loadingTxt);
// =슬러지 에러메세지 초기화=====================================================
jQuery(".qty-error, .sludge-error").hide();
jQuery("#map-modal-input .d_quantity, #map-modal-input .d_sludge").css("border", "1px solid #ced4da");
// ===========================================================================
jQuery("#map-modal-input .d_uid, #map-modal-input .d_customeruid, #map-modal-input .d_customerno, #map-modal-input .orderdate, #map-modal-input .d-ruid, #map-modal-input .d_visitdate, #map-modal-input .d_quantity, #map-modal-input .d_sludge, #map-modal-input .d_note").val('');
jQuery("#map-modal-input .d_payamount, #map-modal-input .d_payeename").val('');
jQuery("#map-modal-input .d_customeruid").val(customer_id);
@ -1583,10 +1590,24 @@ function popup(){
}
function saveInputValidation(){
jQuery("#map-modal-input .d_visitdate, #map-modal-input .d_quantity").css("border","1px solid black");
// 1. 초기화 (테두리 원복 및 에러메시지 숨김)
jQuery("#map-modal-input .d_quantity, #map-modal-input .d_sludge").css("border", "1px solid black");
jQuery(".qty-error, .sludge-error").hide();
// 2. 수량(Quantity) 검사
if(jQuery("#map-modal-input .d_quantity").val().trim() === '') {
jQuery("#map-modal-input .d_quantity").css("border", "1px solid red");
jQuery(".qty-error").show(); // 수량 에러 문구 표시
jQuery("#map-modal-input .d_quantity").focus();
return false;
}
// 3. 슬러지(Sludge) 검사
if(jQuery("#map-modal-input .d_sludge").val().trim() === '') {
// .number-input 박스 자체나 input에 빨간 테두리
jQuery("#map-modal-input .d_sludge").css("border", "1px solid red");
jQuery(".sludge-error").show(); // 슬러지 에러 문구 표시
jQuery("#map-modal-input .d_sludge").focus();
return false;
}

View File

@ -93,7 +93,6 @@ $qry_sludge = "SELECT c_sludge FROM tbl_customer WHERE c_uid ='$d_customeruid' "
$rt_sludge = $jdb->fQuery($qry_sludge, "fetch query error");
// Get Driver Info (Request)
$qry_dr = "SELECT * FROM tbl_driver WHERE dr_status = 'A' ".$add_qry." ORDER by dr_initial ASC ";
$rt_dr = $jdb->nQuery($qry_dr, "list error");
@ -110,7 +109,8 @@ while($lt_dr=mysqli_fetch_array($rt_dr, MYSQLI_ASSOC)) {
?>
<!--*버튼-->
<link href="/assets/css/mapMAPCSS.css" rel="stylesheet" type="text/css">
<!--link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.css"-->
<!--link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/south-street/jquery-ui.css" rel="stylesheet"-->
<script type="text/javascript" src="/assets/js/jquery.ui.touch-punch.min.js"></script>
@ -225,6 +225,12 @@ $(document).ready(function(){
required: "#d_paystatuspaid:checked",
//minlength: 6,
},
// --- d_sludge 규칙 추가 ---
d_sludge: {
required: true,
min: 0,
max: 100
}
},
messages: {
d_quantity: {
@ -235,10 +241,25 @@ $(document).ready(function(){
required: "Please input Cash Amount",
//minlength: "Minimum of 6 characters.",
},
// --- d_sludge 메시지 추가 ---
d_sludge: {
required: "Please input the Sludge value.",
}
},
errorElement : 'div',
errorPlacement: function(error, element) {
if (element.hasClass("d_sludge")) {
// 슬러지 전용 컨테이너 하단에 에러 표시
error.appendTo(element.closest(".number-input-container"));
} else {
// 나머지 필드들은 기본 위치(input 바로 뒤)
error.insertAfter(element);
}
},
submitHandler: function(form) {
var $inputs = $(form).find("input, select, button, textarea");
@ -295,6 +316,8 @@ $(document).ready(function(){
</script>
<style>
.error{
color: red;
@ -362,7 +385,13 @@ $(document).ready(function(){
<tr>
<td class="td-title-info">Sludge</td>
<td class="td-text-info">
<input type="text" id="d_sludge" name="d_sludge" value="<?= (empty($d_sludge)) ? $rt_sludge['c_sludge'] : $d_sludge ?>" placeholder="50">
<div class="number-input-container">
<div class="number-input">
<button class="left" type="button"></button>
<input type="number" id="d_sludge" name="d_sludge" class="d_sludge" value="<?= ($d_sludge !== "" && $d_sludge !== null) ? $d_sludge : ($rt_sludge['c_sludge'] ?? "0") ?>" placeholder="50">
<button class="right" type="button"></button>
</div>
</div>
</td>
</tr>
@ -440,9 +469,13 @@ $(document).ready(function(){
<button type="button" class="btn-gray" data-dismiss="modal">CLOSE</button>
</div>
</FORM>
</div>
<div class="modal fade" id="myModalPopup" tabindex="-1" role="dialog" aria-labelledby="myModalPopup" style="opacity: 0.5; padding-right: 0px !important;">
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
<div class="modal-content" style="background-color:#2A9B56 !important; max-width:260px; margin: 0 auto;">
@ -452,3 +485,42 @@ $(document).ready(function(){
</div>
</div>
</div>
<script>
$(document).ready(function() {
// 1. 기존 이벤트 제거 및 새로 등록 (증감 버튼)
$(document).off('click', '.number-input .left');
$(document).off('click', '.number-input .right');
const step = 5;
const min = 0;
const max = 100;
// 감소 버튼 (▼)
$(document).on('click', '.number-input .left', function(e) {
e.preventDefault();
e.stopPropagation();
var $input = $(this).siblings('input.d_sludge');
var currentVal = parseInt($input.val(), 10) || 0;
var newVal = currentVal - step;
if (newVal < min) newVal = min;
$input.val(newVal).removeClass('sludge-error-border'); // 입력 시 에러 테두리 제거
$('#sludge_error_text').hide(); // 입력 시 에러 메시지 숨김
});
// 증가 버튼 (▲)
$(document).on('click', '.number-input .right', function(e) {
e.preventDefault();
e.stopPropagation();
var $input = $(this).siblings('input.d_sludge');
var currentVal = parseInt($input.val(), 10) || 0;
var newVal = currentVal + step;
if (newVal > max) newVal = max;
$input.val(newVal).removeClass('sludge-error-border');
$('#sludge_error_text').hide();
});
});
</script>