- [FORECAST] 2주 이상 주기 표시 적용.
- [CUSTOMER] 주기에 8주, 12주 추가.
This commit is contained in:
Hyojin Ahn 2026-05-21 07:52:47 -04:00
parent 65ddd4109d
commit 9e2339e55e
6 changed files with 168 additions and 54 deletions

View File

@ -748,29 +748,30 @@ class DailyService extends CONF {
} }
// -------------------------------------------------- // --------------------------------------------------
// 3) Scheduled 처리 (d_ordertype == 'S') // 3) Scheduled 처리 (d_ordertype == 'S')
// -> c_schedulebasic 를 시작 기준일로 고정해서 업데이트 필요없음.
// -------------------------------------------------- // --------------------------------------------------
if ($ordertype === 'S' && !empty($visitdate)) { // if ($ordertype === 'S' && !empty($visitdate)) {
$schedule = $customer['c_schedule'] ?? ''; // $schedule = $customer['c_schedule'] ?? '';
$scheduleDay = $customer['c_scheduleday'] ?? ''; // $scheduleDay = $customer['c_scheduleday'] ?? '';
if ($schedule > '1W' && $schedule <= '6W') { // if ($schedule > '1W' && $schedule <= '6W') {
$weekCount = (int)substr($schedule, 0, 1); // $weekCount = (int)substr($schedule, 0, 1);
if ($weekCount > 0 && !empty($scheduleDay)) { // if ($weekCount > 0 && !empty($scheduleDay)) {
$dayParts = explode('|', $scheduleDay); // $dayParts = explode('|', $scheduleDay);
$dayOfWeek = $dayParts[0] ?? ''; // $dayOfWeek = $dayParts[0] ?? '';
$calcStr = "+{$weekCount} week {$dayOfWeek}"; // $calcStr = "+{$weekCount} week {$dayOfWeek}";
$nextDate = date('Ymd', strtotime($calcStr, strtotime($visitdate))); // $nextDate = date('Ymd', strtotime($calcStr, strtotime($visitdate)));
$updateFields[] = "c_schedulebasic = '{$nextDate}'"; // $updateFields[] = "c_schedulebasic = '{$nextDate}'";
} // }
} // }
} // }
// -------------------------------------------------- // --------------------------------------------------
// UPDATE 실행 // UPDATE 실행

View File

@ -416,7 +416,7 @@ addLog ("add", "CUSTOMER DETAIL", "VIEW", $lguserid, $query, $c_uid);
$(document).ready(function(){ $(document).ready(function(){
$(function () { $(function () {
$('#c_contractdate, #c_form_eu, #c_form_corsia, #c_fpickup, #c_removaldate, #c_installdate, #c_exchangedate, #d_visitdate, #c_inactivedate, #c_switchformdate').datepicker({ $('#c_contractdate, #c_form_eu, #c_form_corsia, #c_schedulebasic, #c_fpickup, #c_removaldate, #c_installdate, #c_exchangedate, #d_visitdate, #c_inactivedate, #c_switchformdate').datepicker({
dateFormat: 'yy-mm-dd', dateFormat: 'yy-mm-dd',
buttonImage: "/images/cal_red.png", buttonImage: "/images/cal_red.png",
buttonImageOnly: true, buttonImageOnly: true,
@ -1442,18 +1442,6 @@ $(document).ready(function()
<input class="cycle" type="text" id="c_fullcycle" name="c_fullcycle" placeholder="365" value="<?=$c_fullcycle?>" maxlength="6"> <input class="cycle" type="text" id="c_fullcycle" name="c_fullcycle" placeholder="365" value="<?=$c_fullcycle?>" maxlength="6">
</td> </td>
<td class="td-title-info">Container Location</td>
<td class="td-text-info">
<input class="containerLocation" type="text" id="c_location" name="c_location" value="<?=htmlspecialchars($c_locationSTR, ENT_QUOTES)?>" placeholder="beside of back door">
</td>
</tr>
<tr>
<td class="td-title-info">Forced Cycle</td>
<td class="td-text-info">
<input class="cycle" type="text" id="c_fullcycleforced" name="c_fullcycleforced" style='color:red;' placeholder="365" value="<?=$c_fullcycleforced?>" maxlength="6">
</td>
<td class="td-title-info">Pickup Schedule</td> <td class="td-title-info">Pickup Schedule</td>
<td class="td-text-info"> <td class="td-text-info">
<select name="c_schedule" id="c_schedule" class="custom-select" required='required'> <select name="c_schedule" id="c_schedule" class="custom-select" required='required'>
@ -1464,9 +1452,9 @@ $(document).ready(function()
</tr> </tr>
<tr> <tr>
<td class="td-title-info">Expected Oil Volume Per Month</td> <td class="td-title-info">Forced Cycle</td>
<td class="td-text-info"> <td class="td-text-info">
<input class="cycle" type="text" id="c_expoilmonth" name="c_expoilmonth" placeholder="100" value="<?=$c_expoilmonth?>" maxlength="7"> <input class="cycle" type="text" id="c_fullcycleforced" name="c_fullcycleforced" style='color:red;' placeholder="365" value="<?=$c_fullcycleforced?>" maxlength="6">
</td> </td>
<td class="td-title-info">Pickup Weekday</td> <td class="td-title-info">Pickup Weekday</td>
@ -1499,6 +1487,18 @@ $(document).ready(function()
</td> </td>
</tr> </tr>
<tr>
<td class="td-title-info">Expected Oil Volume Per Month</td>
<td class="td-text-info">
<input class="cycle" type="text" id="c_expoilmonth" name="c_expoilmonth" placeholder="100" value="<?=$c_expoilmonth?>" maxlength="7">
</td>
<td class="td-title-info">Pickup Schedule Start at</td>
<td class="td-text-info">
<input type="text" id="c_schedulebasic" name="c_schedulebasic" value="<?=$c_schedulebasicSTR?>" placeholder="<?=date('Y-m-d')?>" readonly>
</td>
</tr>
<tr> <tr>
<td class="td-title-info">First Pickup<div style="display: inline; float:right; padding-right: 30px;">Init <input type="checkbox" id="fpna" name="fpna" value="1"></div></td> <td class="td-title-info">First Pickup<div style="display: inline; float:right; padding-right: 30px;">Init <input type="checkbox" id="fpna" name="fpna" value="1"></div></td>
<td class="td-text-info"> <td class="td-text-info">
@ -1572,7 +1572,13 @@ $(document).ready(function()
<input type="text" id="c_exchangedate" name="c_exchangedate" value="<?=$c_exchangedateSTR?>" placeholder="<?=date('Y-m-d')?>" readonly> <input type="text" id="c_exchangedate" name="c_exchangedate" value="<?=$c_exchangedateSTR?>" placeholder="<?=date('Y-m-d')?>" readonly>
</td> </td>
<td class="td-text-info" colspan="2"> <td class="td-title-info">Container Location</td>
<td class="td-text-info">
<input class="containerLocation" type="text" id="c_location" name="c_location" value="<?=htmlspecialchars($c_locationSTR, ENT_QUOTES)?>" placeholder="beside of back door">
</td>
</tr>
<tr>
<td class="td-text-info" colspan="4">
<div class="btn-box"> <div class="btn-box">
<button type="submit" id="customer-button-id2" class="btn-save text-center" href="#">SAVE</button> <button type="submit" id="customer-button-id2" class="btn-save text-center" href="#">SAVE</button>
</div><!--btn-box Ends--> </div><!--btn-box Ends-->

View File

@ -199,7 +199,7 @@ if ($actionStr == "CUSTOMERINFO") {
} }
$values[] = $c_scheduleday_vals; $values[] = $c_scheduleday_vals;
$values[] = $c_schedulebasic; $values[] = str_replace("-", "", trim($c_schedulebasic));
$values[] = str_replace("-", "", trim($c_fpickup)); $values[] = str_replace("-", "", trim($c_fpickup));
$values[] = str_replace("\\", "", trim($c_salesperson)); $values[] = str_replace("\\", "", trim($c_salesperson));
$values[] = str_replace("-", "", trim($c_salescommissiondate)); $values[] = str_replace("-", "", trim($c_salescommissiondate));

View File

@ -677,10 +677,18 @@ if ($actionStr == "CUSTOMER") {
} }
echo "</Row>\n"; echo "</Row>\n";
// 중복 제거
$uids_R = [];
$uids_P = [];
//
$qryR_dupQRY = "";
if ($c_type_r == 'R') { if ($c_type_r == 'R') {
$orderdate = str_replace("-", "", $orderdate); $orderdate = str_replace("-", "", $orderdate);
$qryR_dupQRY = " and c_uid not in (";
$qry_r = " $qry_r = "
SELECT * SELECT *
FROM tbl_request FROM tbl_request
@ -697,6 +705,9 @@ if ($actionStr == "CUSTOMER") {
$$key = $value; $$key = $value;
} }
$qryR_dupQRY .= $r_customeruid . ',';
$uids_R[] = $r_customeruid;
$qry_rc = "SELECT * FROM tbl_customer WHERE c_uid = '$r_customeruid'"; $qry_rc = "SELECT * FROM tbl_customer WHERE c_uid = '$r_customeruid'";
$rt_rc = $jdb->fQuery($qry_rc, "query error"); $rt_rc = $jdb->fQuery($qry_rc, "query error");
@ -740,22 +751,25 @@ if ($actionStr == "CUSTOMER") {
flush(); flush();
} }
$qryR_dupQRY .= '0) ';
} }
// 중복 제거 용
$qryS_dupQRY = "";
if ($c_type_p == 'P') { if ($c_type_p == 'P') {
$getWeekDay = strtoupper(date('D', strtotime($orderdate))); $getWeekDay = strtoupper(date('D', strtotime($orderdate)));
$orderdate = str_replace("-", "", $orderdate); $orderdate = str_replace("-", "", $orderdate);
$qryS_dupQRY = " and c_uid not in (";
$qry_s = " $qry_s = "
SELECT * SELECT *
FROM tbl_customer FROM tbl_customer
WHERE c_driveruid = '$org_driveruid' WHERE c_driveruid = '$org_driveruid'
AND c_status = 'A' AND c_status = 'A'
AND ( AND c_schedule IN ('1W','2W','3W','4W','5W','6W','8W','12W')
c_schedulebasic = '$orderdate' AND c_scheduleday LIKE '%".$getWeekDay."%'
OR (c_schedule = '1W' AND c_scheduleday LIKE '%" . $getWeekDay . "%')
)
ORDER BY c_uid DESC"; ORDER BY c_uid DESC";
$rt_s = $jdb->nQuery($qry_s, "list error"); $rt_s = $jdb->nQuery($qry_s, "list error");
@ -766,6 +780,27 @@ if ($actionStr == "CUSTOMER") {
$$key = $value; $$key = $value;
} }
//
$isScheduleMatch = false;
$weekNum = intval(str_replace('W', '', $c_schedule));
if (!empty($c_schedulebasic)) {
$baseDate = strtotime($c_schedulebasic);
$targetDate = strtotime($orderdate);
$diffDays = floor(($targetDate - $baseDate) / 86400);
$diffWeeks = floor($diffDays / 7);
if (($diffWeeks % $weekNum) == 0) {
$isScheduleMatch = true;
}
}
if (!$isScheduleMatch) {
continue;
} else {
$qryS_dupQRY .= $c_uid . ',';
$uids_P[] = $c_uid;
}
$list_numberSTR = "S"; $list_numberSTR = "S";
$c_nameSTR = str_replace("\\", "", $c_name); $c_nameSTR = str_replace("\\", "", $c_name);
$c_addressSTR = str_replace("\\", "", $c_address); $c_addressSTR = str_replace("\\", "", $c_address);
@ -802,14 +837,28 @@ if ($actionStr == "CUSTOMER") {
flush(); flush();
} }
$qryS_dupQRY .= '0) ';
} }
$query = " $query = "
SELECT * SELECT *
FROM tbl_customer FROM tbl_customer
WHERE c_uid <> '' WHERE c_uid <> ''
AND c_status = 'A' AND c_status = 'A'"
" . $orderflagQRY . $driveruidQRY . $typeQRY . $add_srchquery . $newaccountQRY . $dormantaccountQRY . $fullcycleQRY . $fullquantityQRY . $containerQRY . $areaQRY . $add_query_order . $add_query; . $orderflagQRY
. $driveruidQRY
. $typeQRY
. $add_srchquery
. $newaccountQRY
. $dormantaccountQRY
. $fullcycleQRY
. $fullquantityQRY
. $containerQRY
. $areaQRY
. $qryR_dupQRY
. $qryS_dupQRY
. $add_query_order
. $add_query;
$result = $jdb->nQuery($query, "list error"); $result = $jdb->nQuery($query, "list error");

View File

@ -243,16 +243,43 @@ if ($c_type_p == 'P') {
$orderdate = str_replace("-", "", $orderdate); $orderdate = str_replace("-", "", $orderdate);
$qryS_dupQRY = " and c_uid not in ("; $qryS_dupQRY = " and c_uid not in (";
$qryS_dup = "SELECT * FROM tbl_customer $qryS_dup = "SELECT * FROM tbl_customer
WHERE c_driveruid ='$org_driveruid' AND c_status = 'A' WHERE c_driveruid ='$org_driveruid'
AND (c_schedulebasic = '$orderdate' OR (c_schedule = '1W' AND c_scheduleday LIKE '%".$getWeekDay."%'))"; AND c_status = 'A'
AND c_schedule IN ('1W','2W','3W','4W','5W','6W','8W','12W')
AND c_scheduleday LIKE '%".$getWeekDay."%'
";
$result=$jdb->nQuery($qryS_dup, "list error"); $result=$jdb->nQuery($qryS_dup, "list error");
while($list=mysqli_fetch_array($result, MYSQLI_ASSOC)) { while($list=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
for($i=0; $i<sizeof($list); $i++) { foreach ((Array)$list as $key => $value) {
foreach ( (Array) $list as $key => $value )
$$key = $value; $$key = $value;
} }
$qryS_dupQRY = $qryS_dupQRY . $c_uid . ',';
$uids_P[] = $c_uid; $isScheduleMatch = false;
if ($c_schedulebasic == $orderdate) {
// 최초 1회
$isScheduleMatch = true;
} else {
// 몇 주마다?
$weekNum = intval(str_replace('W', '', $c_schedule));
// 기준일 체크
if (!empty($c_schedulebasic)) {
$baseDate = strtotime($c_schedulebasic);
$targetDate = strtotime($orderdate);
// 날짜 차이
$diffDays = floor(($targetDate - $baseDate) / 86400);
$diffWeeks = floor($diffDays / 7);
// n주 간격 체크
if (($diffWeeks % $weekNum) == 0) {
$isScheduleMatch = true;
}
}
}
if ($isScheduleMatch) {
$qryS_dupQRY = $qryS_dupQRY . $c_uid . ',';
$uids_P[] = $c_uid;
}
} }
$qryS_dupQRY = $qryS_dupQRY . '0) '; // 의미없는 uid 추가 $qryS_dupQRY = $qryS_dupQRY . '0) '; // 의미없는 uid 추가
} }
@ -681,21 +708,52 @@ if ($c_type_p == 'P') {
$getWeekDay = strtoupper(date('D', strtotime($orderdate))); $getWeekDay = strtoupper(date('D', strtotime($orderdate)));
$orderdate = str_replace("-", "", $orderdate); $orderdate = str_replace("-", "", $orderdate);
$qry_s = "SELECT * FROM tbl_customer $qry_s = "
WHERE c_driveruid ='$org_driveruid' AND c_status = 'A' SELECT *
AND (c_schedulebasic = '$orderdate' OR (c_schedule = '1W' AND c_scheduleday LIKE '%".$getWeekDay."%')) FROM tbl_customer
ORDER BY c_uid DESC"; WHERE c_driveruid ='$org_driveruid'
AND c_status = 'A'
AND c_schedule IN ('1W','2W','3W','4W','5W','6W','8W','12W')
AND c_scheduleday LIKE '%".$getWeekDay."%'
ORDER BY c_uid DESC
";
//echo "<br><br><br><br><br>Scheduled[$qry_s]<br>"; //echo "<br><br><br><br><br>Scheduled[$qry_s]<br>";
$rt_s=$jdb->nQuery($qry_s, "list error"); $rt_s=$jdb->nQuery($qry_s, "list error");
while($list=mysqli_fetch_array($rt_s, MYSQLI_ASSOC)) { while($list=mysqli_fetch_array($rt_s, MYSQLI_ASSOC)) {
for($i=0; $i<sizeof($list); $i++) { for($i=0; $i<sizeof($list); $i++) {
//list($key, $value) = each($list); //list($key, $value) = each($list);
foreach ( (Array) $list as $key => $value ) foreach ( (Array) $list as $key => $value )
$$key = $value; $$key = $value;
}
// 2주 이상 스케줄 적용
$isScheduleMatch = false;
// 최초 1회
if ($c_schedulebasic == $orderdate) {
$isScheduleMatch = true;
} else {
// 몇 주마다?
$weekNum = intval(str_replace('W', '', $c_schedule));
if (!empty($c_schedulebasic)) {
$baseDate = strtotime($c_schedulebasic);
$targetDate = strtotime($orderdate);
// 날짜 차이
$diffDays = floor(($targetDate - $baseDate) / 86400);
$diffWeeks = floor($diffDays / 7);
// n주 간격 체크
if (($diffWeeks % $weekNum) == 0) {
$isScheduleMatch = true;
} }
}
}
if (!$isScheduleMatch) continue;
$c_nameSTR = str_replace("\\", "", $c_name); $c_nameSTR = str_replace("\\", "", $c_name);
$c_addressSTR = str_replace("\\", "", $c_address); $c_addressSTR = str_replace("\\", "", $c_address);

View File

@ -11,7 +11,7 @@ $arrBin = array ('D' => '200L Drum', '400B' => '400L Bin', '500B' => '500L Bin',
'P' => 'Bucket', 'CB' => 'Customized Bin'); 'P' => 'Bucket', 'CB' => 'Customized Bin');
$arrForm = array ('Not Yet' => 'Not Yet', 'Paper' => 'Paper', 'Electronic' => 'Electronic' ); $arrForm = array ('Not Yet' => 'Not Yet', 'Paper' => 'Paper', 'Electronic' => 'Electronic' );
$arrSchedule = array ('None' => 'None', '1W' => '1W', '2W' => '2W', '3W' => '3W', '4W' => '4W', '5W' => '5W', '6W' => '6W', 'Will Call' => 'Will Call' ); $arrSchedule = array ('None' => 'None', '1W' => '1W', '2W' => '2W', '3W' => '3W', '4W' => '4W', '5W' => '5W', '6W' => '6W', '8W' => '8W', '12W' => '12W', 'Will Call' => 'Will Call' );
$arrSalesMethod = array ('New/call' => 'New/call', 'New/visit' => 'New/visit', 'OC/call' => 'OC/call', 'OC/visit' => 'OC/visit' ); $arrSalesMethod = array ('New/call' => 'New/call', 'New/visit' => 'New/visit', 'OC/call' => 'OC/call', 'OC/visit' => 'OC/visit' );
$arrPaymentCycle = array ('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'F' => 'F', 'M' => 'M', 'Y' => 'Y', 'PAY STOP' => 'PAY STOP' ); $arrPaymentCycle = array ('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'F' => 'F', 'M' => 'M', 'Y' => 'Y', 'PAY STOP' => 'PAY STOP' );