diff --git a/public_html/assets/api/daily.php b/public_html/assets/api/daily.php
index c2271fa..ab027ea 100644
--- a/public_html/assets/api/daily.php
+++ b/public_html/assets/api/daily.php
@@ -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'] ?? '';
- $scheduleDay = $customer['c_scheduleday'] ?? '';
+ // $schedule = $customer['c_schedule'] ?? '';
+ // $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);
- $dayOfWeek = $dayParts[0] ?? '';
+ // $dayParts = explode('|', $scheduleDay);
+ // $dayOfWeek = $dayParts[0] ?? '';
- $calcStr = "+{$weekCount} week {$dayOfWeek}";
- $nextDate = date('Ymd', strtotime($calcStr, strtotime($visitdate)));
+ // $calcStr = "+{$weekCount} week {$dayOfWeek}";
+ // $nextDate = date('Ymd', strtotime($calcStr, strtotime($visitdate)));
- $updateFields[] = "c_schedulebasic = '{$nextDate}'";
- }
- }
- }
+ // $updateFields[] = "c_schedulebasic = '{$nextDate}'";
+ // }
+ // }
+ // }
// --------------------------------------------------
// UPDATE 실행
diff --git a/public_html/doc/customer_detail.php b/public_html/doc/customer_detail.php
index 15b6662..80796eb 100644
--- a/public_html/doc/customer_detail.php
+++ b/public_html/doc/customer_detail.php
@@ -416,7 +416,7 @@ addLog ("add", "CUSTOMER DETAIL", "VIEW", $lguserid, $query, $c_uid);
$(document).ready(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',
buttonImage: "/images/cal_red.png",
buttonImageOnly: true,
@@ -1442,18 +1442,6 @@ $(document).ready(function()
-
Container Location |
-
-
- |
-
-
-
- | Forced Cycle |
-
-
- |
-
Pickup Schedule |
|
- | Expected Oil Volume Per Month |
+ Forced Cycle |
-
+
|
Pickup Weekday |
@@ -1499,6 +1487,18 @@ $(document).ready(function()
+
+ | Expected Oil Volume Per Month |
+
+
+ |
+
+ Pickup Schedule Start at |
+
+
+ |
+
+
| First Pickup Init |
@@ -1572,7 +1572,13 @@ $(document).ready(function()
|
-
+ | Container Location |
+
+
+ |
+
+
+ |
diff --git a/public_html/doc/customer_process.php b/public_html/doc/customer_process.php
index 1b2e499..fd47e04 100644
--- a/public_html/doc/customer_process.php
+++ b/public_html/doc/customer_process.php
@@ -199,7 +199,7 @@ if ($actionStr == "CUSTOMERINFO") {
}
$values[] = $c_scheduleday_vals;
- $values[] = $c_schedulebasic;
+ $values[] = str_replace("-", "", trim($c_schedulebasic));
$values[] = str_replace("-", "", trim($c_fpickup));
$values[] = str_replace("\\", "", trim($c_salesperson));
$values[] = str_replace("-", "", trim($c_salescommissiondate));
diff --git a/public_html/doc/export_process.php b/public_html/doc/export_process.php
index ec52a8d..b93ed80 100644
--- a/public_html/doc/export_process.php
+++ b/public_html/doc/export_process.php
@@ -677,10 +677,18 @@ if ($actionStr == "CUSTOMER") {
}
echo "\n";
+ // 중복 제거
+ $uids_R = [];
+ $uids_P = [];
+
+ //
+ $qryR_dupQRY = "";
if ($c_type_r == 'R') {
$orderdate = str_replace("-", "", $orderdate);
+ $qryR_dupQRY = " and c_uid not in (";
+
$qry_r = "
SELECT *
FROM tbl_request
@@ -697,6 +705,9 @@ if ($actionStr == "CUSTOMER") {
$$key = $value;
}
+ $qryR_dupQRY .= $r_customeruid . ',';
+ $uids_R[] = $r_customeruid;
+
$qry_rc = "SELECT * FROM tbl_customer WHERE c_uid = '$r_customeruid'";
$rt_rc = $jdb->fQuery($qry_rc, "query error");
@@ -740,22 +751,25 @@ if ($actionStr == "CUSTOMER") {
flush();
}
+ $qryR_dupQRY .= '0) ';
}
+ // 중복 제거 용
+ $qryS_dupQRY = "";
if ($c_type_p == 'P') {
$getWeekDay = strtoupper(date('D', strtotime($orderdate)));
$orderdate = str_replace("-", "", $orderdate);
+ $qryS_dupQRY = " and c_uid not in (";
+
$qry_s = "
SELECT *
FROM tbl_customer
WHERE c_driveruid = '$org_driveruid'
- AND c_status = 'A'
- 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."%'
ORDER BY c_uid DESC";
$rt_s = $jdb->nQuery($qry_s, "list error");
@@ -766,6 +780,27 @@ if ($actionStr == "CUSTOMER") {
$$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";
$c_nameSTR = str_replace("\\", "", $c_name);
$c_addressSTR = str_replace("\\", "", $c_address);
@@ -802,14 +837,28 @@ if ($actionStr == "CUSTOMER") {
flush();
}
+ $qryS_dupQRY .= '0) ';
}
$query = "
SELECT *
FROM tbl_customer
WHERE c_uid <> ''
- AND c_status = 'A'
- " . $orderflagQRY . $driveruidQRY . $typeQRY . $add_srchquery . $newaccountQRY . $dormantaccountQRY . $fullcycleQRY . $fullquantityQRY . $containerQRY . $areaQRY . $add_query_order . $add_query;
+ AND c_status = 'A'"
+ . $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");
diff --git a/public_html/doc/forecast_list.php b/public_html/doc/forecast_list.php
index bd21834..bcb021b 100644
--- a/public_html/doc/forecast_list.php
+++ b/public_html/doc/forecast_list.php
@@ -243,16 +243,43 @@ if ($c_type_p == 'P') {
$orderdate = str_replace("-", "", $orderdate);
$qryS_dupQRY = " and c_uid not in (";
$qryS_dup = "SELECT * FROM tbl_customer
- WHERE c_driveruid ='$org_driveruid' AND c_status = 'A'
- AND (c_schedulebasic = '$orderdate' OR (c_schedule = '1W' AND c_scheduleday LIKE '%".$getWeekDay."%'))";
+ 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."%'
+ ";
$result=$jdb->nQuery($qryS_dup, "list error");
while($list=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
- for($i=0; $i $value )
+ foreach ((Array)$list as $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 추가
}
@@ -681,21 +708,52 @@ if ($c_type_p == 'P') {
$getWeekDay = strtoupper(date('D', strtotime($orderdate)));
$orderdate = str_replace("-", "", $orderdate);
- $qry_s = "SELECT * FROM tbl_customer
- WHERE c_driveruid ='$org_driveruid' AND c_status = 'A'
- AND (c_schedulebasic = '$orderdate' OR (c_schedule = '1W' AND c_scheduleday LIKE '%".$getWeekDay."%'))
- ORDER BY c_uid DESC";
+ $qry_s = "
+ SELECT *
+ FROM tbl_customer
+ 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 "
Scheduled[$qry_s] ";
$rt_s=$jdb->nQuery($qry_s, "list error");
while($list=mysqli_fetch_array($rt_s, MYSQLI_ASSOC)) {
- for($i=0; $i $value )
- $$key = $value;
+ for($i=0; $i $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_addressSTR = str_replace("\\", "", $c_address);
diff --git a/public_html/include/arrayinfo.php b/public_html/include/arrayinfo.php
index d64c929..bce428d 100644
--- a/public_html/include/arrayinfo.php
+++ b/public_html/include/arrayinfo.php
@@ -11,7 +11,7 @@ $arrBin = array ('D' => '200L Drum', '400B' => '400L Bin', '500B' => '500L Bin',
'P' => 'Bucket', 'CB' => 'Customized Bin');
$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' );
$arrPaymentCycle = array ('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'F' => 'F', 'M' => 'M', 'Y' => 'Y', 'PAY STOP' => 'PAY STOP' );
|