response('',404); if((int)method_exists($this,$func) > 0) $this->$func(); else $this->response('',404); } private function json($data){ if(is_array($data)){ return json_encode($data); } } public function inqPoint(){ try { $optionCondition = " AND"; if($_POST['option']['ordered'] === "true") { $optionCondition .= " td.d_orderdate != ''"; }else{ $optionCondition .= " td.d_orderdate = ''"; } $searchCondition = ""; if(strlen($_POST['search']) > 0){ $searchCondition .= " AND (tc.c_accountno LIKE '%".$_POST['search']."%' OR tc.c_name LIKE '%".$_POST['search']."%' OR tc.c_name LIKE '%".strtoupper($_POST['search'])."%' OR tc.c_name LIKE '%".strtolower($_POST['search'])."%' OR tc.c_phone LIKE '%".$_POST['search']."%')"; } $result = array(); $uidList = ""; $sqOptionPoint = qry("SELECT 'flag' AS type, tc.c_uid, tc.c_accountno, tc.c_paymentcycle, tc.c_maincontainer, tc.c_rate, tc.c_name, IF(tc.c_phoneext IS NULL OR LENGTH(tc.c_phoneext) < 1, tc.c_phone, CONCAT(tc.c_phone,' (ext.',tc.c_phoneext,')')) AS phone, CONCAT(tc.c_address, ', ', tc.c_city, ', ', tc.c_postal) AS addr, tc.c_paymenttype, td.d_uid, td.d_orderdate, IFNULL(td.d_quantity,0) as d_quantity, IFNULL(td.d_estquantity,0) as d_estquantity, td.d_ordertype, td.d_driveruid, td.d_createruid, td.d_status, tc.c_comment_ri, tc.c_location, IFNULL(DATE_FORMAT(tc.c_lastpickupdate,'%Y-%m-%d'),'') as c_lastpickupdate, IFNULL(DATE_FORMAT(tc.c_lastpaiddate,'%Y-%m-%d'),'') as c_lastpaiddate, IFNULL(tc.c_geolat,'') as lat, IFNULL(tc.c_geolon,'') as lon, td.d_ruid, td.r_note FROM (SELECT c_uid, c_accountno, c_paymentcycle, c_maincontainer, c_rate, c_driveruid, c_name, c_phoneext, c_phone, c_address, c_city, c_province, c_postal, c_paymenttype, c_lastpickupdate, c_lastpaiddate, c_comment_ri, c_location, c_geolat, c_geolon FROM tbl_customer) tc, (SELECT td.d_uid, td.d_ruid, tr.r_note, td.d_customeruid, td.d_orderdate, td.d_quantity, td.d_estquantity, td.d_ordertype, td.d_driveruid, td.d_createruid, td.d_status FROM tbl_daily td LEFT OUTER JOIN tbl_request tr ON td.d_ruid = tr.r_uid) td WHERE tc.c_uid = td.d_customeruid AND td.d_driveruid = ".(int)$_POST['driver']." AND td.d_orderdate = '".$_POST['search_date']."' ".$optionCondition.$searchCondition." GROUP BY tc.c_uid ORDER BY td.d_orderdate DESC"); $loc_comp = array(); while($rstOptionPoint = fetch_array($sqOptionPoint)) { $color = '#FF80FF'; $orderFlag = 'DISABLED'; if ($rstOptionPoint['d_driveruid'] == $rstOptionPoint['d_createruid']) { $color = '#FFFDD5'; // Driver 가 직접 Add Order 시 if ($rstOptionPoint['d_orderdate'] >= date('Ymd')) $orderFlag = ''; // Driver 가 직접 Add Order 한 경우 해당일 이후것 삭제 가능함 } if($rstOptionPoint['d_status'] === 'F') { $color = '#7B7A7A'; }else{ switch($rstOptionPoint['d_ordertype']) { case 'R': $color = '#FF0000'; break; case 'S': $color = '#800080'; break; } } $crntLoc = array($rstOptionPoint['lat'],$rstOptionPoint['lon']); for($i=0;$i < 99;$i++) { if(in_array($crntLoc,$loc_comp)){ $crntLoc = array($rstOptionPoint['lat'],((float)$rstOptionPoint['lon']+0.0001000)); }else{ break; } } $loc_comp[] = $crntLoc; $d_ordertype = $rstOptionPoint['d_ordertype']; if ($d_ordertype == 'S') $d_ordertype = '📅'; else if ($d_ordertype == 'R') $d_ordertype = '🏃'; else $d_ordertype = ''; $result[] = array( "type" => $rstOptionPoint['type'], "id" => $rstOptionPoint['c_uid'], "accountno" => $rstOptionPoint['c_accountno'], "paymentcycle" => $rstOptionPoint['c_paymentcycle'], "maincontainer" => $rstOptionPoint['c_maincontainer'], "rate" => $rstOptionPoint['c_rate'], "name" => $rstOptionPoint['c_name'], "phone" => $rstOptionPoint['phone'], "address" => $rstOptionPoint['addr'], "payment_type" => $rstOptionPoint['c_paymenttype'], "order_date" => $rstOptionPoint['d_orderdate'], "ordertype" => $d_ordertype, "lat" => (string)$crntLoc[0], "lon" => (string)$crntLoc[1], "qty" => $rstOptionPoint['d_quantity'], "estqty" => $rstOptionPoint['d_estquantity'], "color" => $color, "comment" => $rstOptionPoint['c_comment_ri'], "container_location" => stripslashes($rstOptionPoint['c_location']), "last_pickup_date" => $rstOptionPoint['c_lastpickupdate'], "last_paid_date" => $rstOptionPoint['c_lastpaiddate'], "duid" => $rstOptionPoint['d_uid'], "druid" => $rstOptionPoint['d_ruid'], "rnote" => $rstOptionPoint['r_note'], "orderFlag" => $orderFlag ); if(strlen($uidList) > 0){ $uidList .= ",".$rstOptionPoint['c_uid']; }else{ $uidList .= $rstOptionPoint['c_uid']; } } // 오늘 날짜 $today = new DateTime(date("Y-m-d")); //$today = new DateTime('20240425'); // 지정한 날짜 $searchDate = new DateTime($_POST['search_date']); // 두 날짜 간 차이 계산 $interval = $today->diff($searchDate); $qtyCondition = ""; foreach($_POST['quantity'] as $quantity) { if($quantity['checked'] === "true") { if(strlen($qtyCondition) > 0){ $qtyCondition .= " OR"; }else{ $qtyCondition .= " AND ("; } if($quantity['max'] === 'MAX') { $qtyCondition .= " (tc.realQty > ".$quantity['min'].")"; }else{ $qtyCondition .= " (tc.realQty BETWEEN ".$quantity['min']." AND ".$quantity['max'].")"; } } } if(strlen($qtyCondition) > 0){ $qtyCondition .= ")"; if(strlen($uidList) > 0){ $uidList = "AND tc.c_uid NOT IN (".$uidList.")"; } $sqQtyPoint = qry("SELECT 'map-marker' AS type, tc.c_uid, tc.c_accountno, tc.c_paymentcycle, tc.c_maincontainer, tc.c_rate, tc.c_name, IF(tc.c_phoneext IS NULL OR LENGTH(tc.c_phoneext) < 1, tc.c_phone, CONCAT(tc.c_phone,' (ext.',tc.c_phoneext,')')) AS phone, CONCAT(tc.c_address, ', ', tc.c_city, ', ', tc.c_postal) AS addr, tc.c_paymenttype, IFNULL(tc.c_fullquantity,0), IFNULL(tc.c_fullquantitydaily,0), tc.realQty, tc.c_schedule, tc.c_comment_ri, tc.c_location, IFNULL(DATE_FORMAT(tc.c_lastpickupdate,'%Y-%m-%d'),'') as c_lastpickupdate, IFNULL(DATE_FORMAT(tc.c_lastpaiddate,'%Y-%m-%d'),'') as c_lastpaiddate, IFNULL(tc.c_geolat,'') as lat, IFNULL(tc.c_geolon,'') as lon FROM (SELECT c_uid, c_accountno, c_paymentcycle, c_maincontainer, c_rate, c_driveruid, c_name, c_phoneext, c_phone, c_address, c_city, c_province, c_postal, c_paymenttype, c_lastpickupdate, c_lastpaiddate, c_fullquantitydaily, c_fullquantity, IFNULL((c_fullquantity - c_fullquantitydaily + (".(int)$interval->days." * c_fullquantitydaily)),0) as realQty, c_location, c_schedule, c_comment_ri, c_geolat, c_geolon FROM tbl_customer WHERE c_status = 'A') tc WHERE tc.c_driveruid = ".(int)$_POST['driver']." ".$uidList." ".$qtyCondition.$searchCondition." GROUP BY tc.c_uid"); $loc_comp = array(); while($rstQtyPoint = fetch_array($sqQtyPoint)) { $realQty = $rstQtyPoint['realQty']; //$colorArr = array('#000000','#D32F2F','#1ABC9C','#FBC02D','#2979FF','#CDDC39'); //Something wrong on black $colorArr = array('#000000','#FFFF00','#FBC02D','#1ABC9C','#2979FF','#000000'); //Something wrong on black $color = $colorArr[0]; $qtyNum = 1; foreach($_POST['quantity'] as $quantity) { if($quantity['max'] === 'MAX') { if((int)$realQty >= (int)$quantity['min']) { $color = $colorArr[$qtyNum]; break; } }else{ if((int)$realQty >= (int)$quantity['min'] && (int)$realQty <= (int)$quantity['max']) { $color = $colorArr[$qtyNum]; break; } } $qtyNum += 1; } $crntLoc = array($rstQtyPoint['lat'],$rstQtyPoint['lon']); for($i=0;$i < 99;$i++) { if(in_array($crntLoc,$loc_comp)){ $crntLoc = array($rstQtyPoint['lat'],((float)$rstQtyPoint['lon']+0.0001000)); }else{ break; } } $loc_comp[] = $crntLoc; $c_schedule = $rstQtyPoint['c_schedule']; if ($c_schedule == 'Will Call') $c_schedule = '📞'; else if ($c_schedule != 'None') $c_schedule = '📅'; else $c_schedule = ''; $result[] = array( "type" => $rstQtyPoint['type'], "id" => $rstQtyPoint['c_uid'], "accountno" => $rstQtyPoint['c_accountno'], "paymentcycle" => $rstQtyPoint['c_paymentcycle'], "maincontainer" => $rstQtyPoint['c_maincontainer'], "rate" => $rstQtyPoint['c_rate'], "name" => $rstQtyPoint['c_name'], "phone" => $rstQtyPoint['phone'], "address" => $rstQtyPoint['addr'], "payment_type" => $rstQtyPoint['c_paymenttype'], "order_date" => null, "ordertype" => $c_schedule, "lat" => (string)$crntLoc[0], "lon" => (string)$crntLoc[1], "estqty" => $realQty, "color" => $color, "comment" => $rstQtyPoint['c_comment_ri'], "container_location" => stripslashes($rstQtyPoint['c_location']), "last_pickup_date" => $rstQtyPoint['c_lastpickupdate'], "last_paid_date" => $rstQtyPoint['c_lastpaiddate'] ); } } $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function updtPoint(){ try { qry("UPDATE tbl_customer SET c_geolat=".$_POST['lat'].", c_geolon=".$_POST['lon']." WHERE c_uid=".(int)$_POST['id']); $this->response($this->json(array("markerIndex"=>$_POST['marker_index'], "lat"=>$_POST['lat'], "lon"=>$_POST['lon'], "name"=>$_POST['name'], "qty"=>$_POST['qty'], "property"=>$_POST['property'])), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function updtShortInfo(){ try { qry("UPDATE tbl_customer SET c_location='".addslashes($_POST['location'])."', c_comment_ri='".addslashes($_POST['comment'])."' WHERE c_uid=".(int)$_POST['id']); $this->response($this->json(array("result"=>"success")), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqDriverGeo(){ try { $sqDriverGeo = qry("SELECT m_geolat, m_geolon FROM tbl_member WHERE m_uid = ".(int)$_POST['driver']); $rstDriverGeo = fetch_array($sqDriverGeo); $result = array( "geolat" => $rstDriverGeo['m_geolat'], "geolon" => $rstDriverGeo['m_geolon'] ); $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } private function getGeoCoordinates($address) { // Google API 키를 여기에 입력하세요. $apiKey = 'AIzaSyDg9u03mGrBhyOisp7VGc27CTPI9QXp8sY'; // 주소를 URL 인코딩 $address = urlencode($address); // Google Maps Geocoding API URL $url = "https://maps.googleapis.com/maps/api/geocode/json?address={$address}&key={$apiKey}"; // cURL 세션 초기화 $ch = curl_init(); // cURL 옵션 설정 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // URL의 내용을 가져옴 $responseJson = curl_exec($ch); curl_close($ch); // JSON 응답을 PHP 배열로 변환 $response = json_decode($responseJson, true); // 위도와 경도를 추출 if ($response['status'] == 'OK') { $latitude = $response['results'][0]['geometry']['location']['lat']; $longitude = $response['results'][0]['geometry']['location']['lng']; return array('latitude' => $latitude, 'longitude' => $longitude); } else { // 에러 처리 return false; } } public function inqNearby(){ try { $result = array(); $uidList = ""; $sqOptionPoint = qry("SELECT 'flag' AS type, tc.c_uid, tc.c_accountno, tc.c_paymentcycle, tc.c_maincontainer, tc.c_rate, tc.c_name, IF(tc.c_phoneext IS NULL OR LENGTH(tc.c_phoneext) < 1, tc.c_phone, CONCAT(tc.c_phone,' (ext.',tc.c_phoneext,')')) AS phone, CONCAT(tc.c_address, ', ', tc.c_city, ', ', tc.c_postal) AS addr, tc.c_paymenttype, td.d_orderdate, IFNULL(td.d_quantity,0) as d_quantity, IFNULL(td.d_estquantity,0) as d_estquantity, td.d_ordertype, td.d_uid, td.d_driveruid, td.d_createruid, td.d_status, tc.c_comment_ri, tc.c_location, IFNULL(DATE_FORMAT(tc.c_lastpickupdate,'%Y-%m-%d'),'') as c_lastpickupdate, IFNULL(DATE_FORMAT(tc.c_lastpaiddate,'%Y-%m-%d'),'') as c_lastpaiddate, IFNULL(tc.c_geolat,'') as lat, IFNULL(tc.c_geolon,'') as lon, ( ST_Distance_Sphere( point(".(float)$_POST['center_lon'].", ".(float)$_POST['center_lat']."), point(tc.c_geolon, tc.c_geolat) ) ) / 1000 AS distance_km FROM (SELECT c_uid, c_accountno, c_paymentcycle, c_maincontainer, c_rate, c_driveruid, c_name, c_phoneext, c_phone, c_address, c_city, c_province, c_postal, c_paymenttype, c_lastpickupdate, c_lastpaiddate, c_location, c_comment_ri, c_geolat, c_geolon FROM tbl_customer) tc, (SELECT d_uid, d_customeruid, d_orderdate, d_quantity, d_estquantity, d_ordertype, d_driveruid, d_createruid, d_status FROM tbl_daily) td WHERE tc.c_uid = td.d_customeruid AND td.d_driveruid = ".(int)$_POST['driver']." AND td.d_orderdate = '".$_POST['search_date']."' GROUP BY tc.c_uid /* HAVING distance_km <= 1 */ ORDER BY td.d_orderdate DESC"); $loc_comp = array(); while($rstOptionPoint = fetch_array($sqOptionPoint)) { $color = '#FF80FF'; $orderFlag = 'DISABLED'; $d_ordertype = ''; if ($rstOptionPoint['d_driveruid'] == $rstOptionPoint['d_createruid']) { $color = '#FFFDD5'; // Driver 가 직접 Add Order 시 if ($rstOptionPoint['d_orderdate'] >= date('Ymd')) $orderFlag = ''; // Driver 가 직접 Add Order 한 경우 해당일 이후것 삭제 가능함 } if($rstOptionPoint['d_status'] === 'F') { $color = '#7B7A7A'; $d_ordertype = ''; }else{ switch($rstOptionPoint['d_ordertype']) { case 'R': $color = '#FF0000'; $d_ordertype = '🏃'; break; case 'S': $color = '#800080'; $d_ordertype = '📅'; break; } } $crntLoc = array($rstOptionPoint['lat'],$rstOptionPoint['lon']); for($i=0;$i < 99;$i++) { if(in_array($crntLoc,$loc_comp)){ $crntLoc = array($rstOptionPoint['lat'],((float)$rstOptionPoint['lon']+0.0001000)); }else{ break; } } $loc_comp[] = $crntLoc; $result[] = array( "type" => $rstOptionPoint['type'], "id" => $rstOptionPoint['c_uid'], "accountno" => $rstOptionPoint['c_accountno'], "paymentcycle" => $rstOptionPoint['c_paymentcycle'], "maincontainer" => $rstOptionPoint['c_maincontainer'], "rate" => $rstOptionPoint['c_rate'], "name" => $rstOptionPoint['c_name'], "phone" => $rstOptionPoint['phone'], "address" => $rstOptionPoint['addr'], "payment_type" => $rstOptionPoint['c_paymenttype'], "order_date" => $rstOptionPoint['d_orderdate'], "ordertype" => $d_ordertype, "lat" => (string)$crntLoc[0], "lon" => (string)$crntLoc[1], "qty" => $rstOptionPoint['d_quantity'], "estqty" => $rstOptionPoint['d_estquantity'], "color" => $color, "comment" => $rstOptionPoint['c_comment_ri'], "container_location" => stripslashes($rstOptionPoint['c_location']), "last_pickup_date" => $rstOptionPoint['c_lastpickupdate'], "last_paid_date" => $rstOptionPoint['c_lastpaiddate'], "duid" => $rstOptionPoint['d_uid'], "orderFlag" => $orderFlag ); if(strlen($uidList) > 0){ $uidList .= ",".$rstOptionPoint['c_uid']; }else{ $uidList .= $rstOptionPoint['c_uid']; } } // 오늘 날짜 $today = new DateTime(date("Y-m-d")); //$today = new DateTime('20240425'); // 지정한 날짜 $searchDate = new DateTime($_POST['search_date']); // 두 날짜 간 차이 계산 $interval = $today->diff($searchDate); $qtyCondition = ""; foreach($_POST['quantity'] as $quantity) { if($quantity['checked'] === "true") { if(strlen($qtyCondition) > 0){ $qtyCondition .= " OR"; }else{ $qtyCondition .= " AND ("; } if($quantity['max'] === 'MAX') { $qtyCondition .= " (tc.realQty > ".$quantity['min'].")"; }else{ $qtyCondition .= " (tc.realQty BETWEEN ".$quantity['min']." AND ".$quantity['max'].")"; } } } if(strlen($qtyCondition) > 0){ $qtyCondition .= ")"; if(strlen($uidList) > 0){ $uidList = "AND tc.c_uid NOT IN (".$uidList.")"; } $sqQtyPoint = qry("SELECT 'map-marker' AS type, tc.c_uid, tc.c_accountno, tc.c_paymentcycle, tc.c_maincontainer, tc.c_rate, tc.c_name, IF(tc.c_phoneext IS NULL OR LENGTH(tc.c_phoneext) < 1, tc.c_phone, CONCAT(tc.c_phone,' (ext.',tc.c_phoneext,')')) AS phone, CONCAT(tc.c_address, ', ', tc.c_city, ', ', tc.c_postal) AS addr, tc.c_paymenttype, IFNULL(tc.c_fullquantity,0), IFNULL(tc.c_fullquantitydaily,0), tc.realQty, tc.c_comment_ri, tc.c_location, tc.c_schedule, IFNULL(DATE_FORMAT(tc.c_lastpickupdate,'%Y-%m-%d'),'') as c_lastpickupdate, IFNULL(DATE_FORMAT(tc.c_lastpaiddate,'%Y-%m-%d'),'') as c_lastpaiddate, IFNULL(tc.c_geolat,'') as lat, IFNULL(tc.c_geolon,'') as lon, ( ST_Distance_Sphere( point(".(float)$_POST['center_lon'].", ".(float)$_POST['center_lat']."), point(tc.c_geolon, tc.c_geolat) ) ) / 1000 AS distance_km FROM (SELECT c_uid, c_accountno, c_paymentcycle, c_maincontainer, c_rate, c_driveruid, c_name, c_phoneext, c_phone, c_address, c_city, c_province, c_postal, c_paymenttype, c_lastpickupdate, c_lastpaiddate, c_fullquantitydaily, c_fullquantity, IFNULL((c_fullquantity - c_fullquantitydaily + (".(int)$interval->days." * c_fullquantitydaily)),0) as realQty, c_location, c_schedule, c_comment_ri, c_geolat, c_geolon FROM tbl_customer WHERE c_status = 'A') tc WHERE tc.c_driveruid = ".(int)$_POST['driver']." ".$uidList." ".$qtyCondition." GROUP BY tc.c_uid HAVING distance_km <= 1"); $loc_comp = array(); while($rstQtyPoint = fetch_array($sqQtyPoint)) { //$realQty = $rstQtyPoint['c_fullquantity'] - $rstQtyPoint['c_fullquantitydaily'] + ((int)$interval->days * $rstQtyPoint['c_fullquantitydaily']); $realQty = $rstQtyPoint['realQty']; //$colorArr = array('#000000','#D32F2F','#1ABC9C','#FBC02D','#2979FF','#CDDC39'); //Something wrong on black $colorArr = array('#000000','#FFFF00','#FBC02D','#1ABC9C','#2979FF','#000000'); //Something wrong on black $color = $colorArr[0]; $qtyNum = 1; foreach($_POST['quantity'] as $quantity) { if($quantity['max'] === 'MAX') { if((int)$realQty >= (int)$quantity['min']) { $color = $colorArr[$qtyNum]; break; } }else{ if((int)$realQty >= (int)$quantity['min'] && (int)$realQty <= (int)$quantity['max']) { $color = $colorArr[$qtyNum]; break; } } $qtyNum += 1; } $crntLoc = array($rstQtyPoint['lat'],$rstQtyPoint['lon']); for($i=0;$i < 99;$i++) { if(in_array($crntLoc,$loc_comp)){ $crntLoc = array($rstQtyPoint['lat'],((float)$rstQtyPoint['lon']+0.0001000)); }else{ break; } } $loc_comp[] = $crntLoc; $c_schedule = $rstQtyPoint['c_schedule']; if ($c_schedule == 'Will Call') $c_schedule = '📞'; else if ($c_schedule != 'None') $c_schedule = '📅'; else $c_schedule = ''; $result[] = array( "type" => $rstQtyPoint['type'], "id" => $rstQtyPoint['c_uid'], "accountno" => $rstQtyPoint['c_accountno'], "paymentcycle" => $rstQtyPoint['c_paymentcycle'], "maincontainer" => $rstQtyPoint['c_maincontainer'], "rate" => $rstQtyPoint['c_rate'], "name" => $rstQtyPoint['c_name'], "phone" => $rstQtyPoint['phone'], "address" => $rstQtyPoint['addr'], "payment_type" => $rstQtyPoint['c_paymenttype'], "order_date" => null, "ordertype" => $c_schedule, "lat" => (string)$crntLoc[0], "lon" => (string)$crntLoc[1], "estqty" => $realQty, "color" => $color, "comment" => $rstQtyPoint['c_comment_ri'], "container_location" => stripslashes($rstQtyPoint['c_location']), "last_pickup_date" => $rstQtyPoint['c_lastpickupdate'], "last_paid_date" => $rstQtyPoint['c_lastpaiddate'] ); } } $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqHistory(){ try { $sqHistory = qry("SELECT IFNULL(DATE_FORMAT(td.d_orderdate,'%Y-%m-%d'),'') as d_orderdate, td.d_quantity, td.d_driveruid, td.d_paystatus, IFNULL(td.d_payamount,'') as d_payamount, tm.m_initial FROM tbl_daily td,tbl_member tm WHERE td.d_customeruid = '".$_POST['id']."' AND td.d_status = 'F' AND td.d_driveruid = tm.m_uid ORDER BY td.d_orderdate DESC"); $result = array(); while($rstHistory = fetch_array($sqHistory)) { if($rstHistory['d_paystatus'] === 'P') { //$d_paystatusSTR = $arrPaidStatus['P']; $d_paystatusSTR = "Paid". " ($".$rstHistory['d_payamount'] . ")"; } else if ($rstHistory['d_paystatus'] === 'N') { $d_paystatusSTR = "Unpaid"; } else $d_paystatusSTR = ""; $result[] = array( "date" => $rstHistory['d_orderdate'], "quantity" => $rstHistory['d_quantity'], "driver" => $rstHistory['m_initial'], "paid" => $d_paystatusSTR ); } $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqShortNotice(){ try { $sqNotice = qry("SELECT IFNULL(DATE_FORMAT(td.d_orderdate,'%Y-%m-%d'),'') as d_orderdate, tr.r_note FROM tbl_daily td,tbl_request tr WHERE td.d_uid = '".$_POST['id']."' AND td.d_ruid = tr.r_uid ORDER BY td.d_uid DESC LIMIT 1 "); $rstNotice = fetch_array($sqNotice); $result = array( "orderdate" => $rstNotice['d_orderdate'], "rnote" => $rstNotice['r_note'] ); $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqRouteAddress(){ try { $myLocation = ["lat" => (float)$_POST['m_lat'], "lon" => (float)$_POST['m_lon']]; $apiKey = "AIzaSyDg9u03mGrBhyOisp7VGc27CTPI9QXp8sY"; // Google Maps API 키 $getThisYear = date("Y"); $getLastYear = date("Y", strtotime('last year')); $_POST['route_date'] = str_replace("-","",$_POST['route_date']); $sqAddress = qry("SELECT tc.c_uid, tc.c_name, tc.c_address, tc.c_city, tc.c_postal, td.d_accountno, td.d_maincontainer, td.d_paymenttype, td.d_rate, td.d_lastpickupquantity, td.d_estquantity, IFNULL(td.d_quantity, '') as d_quantity, td.d_lastpaiddate, s.THIS_YEAR, s.LAST_YEAR, td.d_fullcycle, td.d_lastpickupdate, IFNULL(tc.c_geolat,'') as lat, IFNULL(tc.c_geolon,'') as lon FROM tbl_customer tc, tbl_daily td LEFT JOIN (SELECT d_customeruid, SUM(CASE WHEN d_visitdate like '".$getThisYear."%' THEN d_quantity ELSE 0 END) AS THIS_YEAR, SUM(CASE WHEN d_visitdate like '".$getLastYear."%' THEN d_quantity ELSE 0 END) AS LAST_YEAR FROM tbl_daily WHERE d_status = 'F' GROUP BY d_customeruid) s ON s.d_customeruid = td.d_customeruid WHERE tc.c_uid = td.d_customeruid AND td.d_driveruid = '".$_POST['driver']."' AND td.d_orderdate = '".$_POST['route_date']."'"); $results = array(); while($rstAddress = fetch_array($sqAddress)) { if (strlen($rstAddress['lat']) < 1 || strlen($rstAddress['lon']) < 1) { // 주소로부터 위도와 경도 찾기 (예제에서는 이름 필드를 주소로 가정) $address = urlencode($rstAddress['address']); $url = "https://maps.googleapis.com/maps/api/geocode/json?address=$address&key=$apiKey"; $response = file_get_contents($url); $json = json_decode($response, true); if (!empty($json['results'])) { $rstAddress["lat"] = $json['results'][0]['geometry']['location']['lat']; $rstAddress["lon"] = $json['results'][0]['geometry']['location']['lng']; } } $results[] = array( "id" => $rstAddress['c_uid'], "name" => $rstAddress['c_name'], "address" => str_replace("/", "/", $rstAddress['c_address']), "city" => $rstAddress['c_city'], "postal" => $rstAddress['c_postal'], "accountno" => $rstAddress['d_accountno'], "maincontainer" => $rstAddress['d_maincontainer'], "paymenttype" => $rstAddress['d_paymenttype'], "rate" => $rstAddress['d_rate'], "lastpickupquantity" => $rstAddress['d_lastpickupquantity'], "estquantity" => $rstAddress['d_estquantity'], "quantity" => $rstAddress['d_quantity'], "lastpaiddate" => $rstAddress['d_lastpaiddate'], "THIS_YEAR" => (float)$rstAddress['THIS_YEAR'], "LAST_YEAR" => (float)$rstAddress['LAST_YEAR'], "fullcycle" => $rstAddress['d_fullcycle'], "lastpickupdate" => $rstAddress['d_lastpickupdate'], "lat" => (float)$rstAddress['lat'], "lon" => (float)$rstAddress['lon'] ); } usort($results, function($a, $b) use ($myLocation) { $distA = sqrt(pow($a["lat"] - $myLocation["lat"], 2) + pow($a["lon"] - $myLocation["lon"], 2)); $distB = sqrt(pow($b["lat"] - $myLocation["lat"], 2) + pow($b["lon"] - $myLocation["lon"], 2)); return $distA <=> $distB; }); $this->response($this->json(array("result"=>$results)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqShortInfo(){ try { $sqShortInfo = qry("SELECT c_name, c_paymenttype, c_comment_ri, c_location FROM tbl_customer WHERE c_uid = ".(int)$_POST['id']); $rstShortInfo = fetch_array($sqShortInfo); if ($rstShortInfo['c_paymenttype'] == "CA") { $sqShortDaily = qry("SELECT IFNULL(DATE_FORMAT(td.d_orderdate,'%Y-%m-%d'),'') as d_orderdate, td.d_paystatus, td.d_payamount FROM tbl_daily td WHERE td.d_customeruid = '".$_POST['id']."' AND td.d_status = 'F' AND td.d_quantity > 1 ORDER BY td.d_visitdate DESC LIMIT 1 "); if(db_num_rows($sqShortDaily) > 0) { $rstShortDaily = fetch_array($sqShortDaily); if($rstShortDaily['d_paystatus'] === 'P') { //$d_paystatusSTR = $arrPaidStatus['P']; $d_paystatusSTR = "Paid". " (".$rstShortDaily['d_orderdate']." / $".$rstShortDaily['d_payamount'] . ")"; } else if ($rstShortDaily['d_paystatus'] === 'N') { $d_paystatusSTR = "Unpaid" ." (".$rstShortDaily['d_orderdate'].")"; } } else { $d_paystatusSTR = ""; } } else $d_paystatusSTR = ""; $result = array( "id" => $_POST['id'], "name" => $rstShortInfo['c_name'], "payment_type" => $rstShortInfo['c_paymenttype'], "paymentstring" => $d_paystatusSTR, "comment" => $rstShortInfo['c_comment_ri'], "location" => $rstShortInfo['c_location'] ); $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function addOrder(){ try { qry("INSERT INTO tbl_daily (d_orderdate, d_ordertype, d_ruid, d_driveruid, d_customeruid, d_accountno, d_name, d_paymenttype, d_cycle, d_rate, d_form_eu, d_form_corsia, d_maincontainer, d_container, d_location, d_status) SELECT '".$_POST['orderdate']."', '".$_POST['ordertype']."', '".$_POST['ruid']."', '".$_POST['driveruid']."', c_uid, c_accountno, c_name, c_paymenttype, c_paymentcycle, c_rate, c_form_eu, c_form_corsia, c_maincontainer, c_container, c_location, 'A' FROM tbl_customer WHERE c_uid=".(int)$_POST['customer_uid']); $this->response($this->json(array("msg"=>"Order has been successfully added.", "c_index"=>$_POST['c_index'])), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function addOrderDirect(){ try { $sqCheckOrder = qry("SELECT count(d_uid) as rowcnt FROM tbl_daily WHERE d_orderdate='".$_POST['orderdate']."' AND d_customeruid=".(int)$_POST['customer_uid']); $rstCheckOrder = fetch_array($sqCheckOrder); if ($rstCheckOrder['rowcnt'] > 0) { $this->response($this->json(array("msg"=>"This order already exists.", "c_index"=>$_POST['c_index'], "c_return"=>"0")), 200); } // 오늘 날짜 $today = new DateTime(date("Y-m-d")); //$today = new DateTime('20240425'); // 지정한 날짜 $searchDate = new DateTime($_POST['orderdate']); // 두 날짜 간 차이 계산 $interval = $today->diff($searchDate); //$estquantity = (c_fullquantity - c_fullquantitydaily + (".(int)$interval->days." * c_fullquantitydaily)); qry("INSERT INTO tbl_daily ( d_orderdate, d_driveruid, d_customeruid, d_accountno, d_name, d_paymenttype, d_cycle, d_rate, d_form_eu, d_form_corsia, d_maincontainer, d_container, d_location, d_address, d_city, d_postal, d_oil_2y, d_oil_1y, d_oil_0y, d_fullcycle, d_fullcycleforced, d_fullcycleflag, d_lastpickupdate, d_lastpickupquantity, d_lastpaiddate, d_estquantity, d_createruid, d_createddate, d_status) SELECT '".$_POST['orderdate']."', '".$_POST['driveruid']."', c_uid, c_accountno, c_name, c_paymenttype, c_paymentcycle, c_rate, c_form_eu, c_form_corsia, c_maincontainer, c_container, c_location, c_address, c_city, c_postal, 0, 0, 0, c_fullcycle, c_fullcycleforced, c_fullcycleflag, c_lastpickupdate, c_lastpickupquantity, c_lastpaiddate, IFNULL((c_fullquantity - c_fullquantitydaily + (".(int)$interval->days." * c_fullquantitydaily)),0), '".$_POST['d_createruid']."', '".date('YmdHis')."', 'A' FROM tbl_customer WHERE c_uid=".(int)$_POST['customer_uid']); qry("UPDATE tbl_customer SET c_orderdate='".$_POST['orderdate']."', c_orderflag = 1 WHERE c_uid = ".(int)$_POST['customer_uid']); $this->response($this->json(array("msg"=>"Order has been successfully added.", "c_index"=>$_POST['c_index'])), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function removeOrder(){ try { qry("DELETE FROM tbl_daily WHERE d_uid = '".$_POST['duid']."'"); qry("UPDATE tbl_customer SET c_orderdate='', c_orderflag = 0 WHERE c_uid='".$_POST['id']."'"); qry("DELETE FROM tbl_request WHERE r_customeruid = '".$_POST['id']."' AND r_requestdate = '".$_POST['orderdate']."'"); // 오더장 삭제시 오더장 먼저 삭제하고 last pickupdate, quantity, last paid date 를 tbl_daily 에서 찾아서 tbl_customer 에 업데이트 (2023.11.17) // sludge 는 어떻게 처리? customer detail 에서 수정할수도 있고, 오더장에 입력시 전체 업데이트 됨. 어디서 언제 입력했는지 확인 불가. $sqrmInfo = qry("SELECT d_orderdate,d_visitdate,d_quantity,d_paymenttype,d_paystatus,d_sludge FROM tbl_daily WHERE d_customeruid = '".$_POST['id']."' AND d_status = 'F' ORDER BY d_orderdate DESC LIMIT 1"); $rstrmInfo = fetch_array($sqrmInfo); // tbl_daily 의 마지막 데이터중 cash 이고 paid 면 c_lastpaiddate // 그렇지 않으면 다시 tbl_daily 에서 cash 이고 paid 인 마지막 데이터를 가져옴. 없으면 null 처리 if ($rstrmInfo['d_paymenttype']== "CA" && $rstrmInfo['d_paystatus'] == "P") $addQry = ", c_lastpaiddate = '".$rstrmInfo['d_visitdate']."' "; else { $sqrmInfoLast = qry("SELECT d_visitdate FROM tbl_daily WHERE d_customeruid = '".$_POST['id']."' AND d_status = 'F' AND d_paymenttype = 'CA' AND d_paystatus = 'P' ORDER BY d_orderdate DESC LIMIT 1"); $rstrmInfoLast = fetch_array($sqrmInfoLast); if ($rstrmInfoLast && $rstrmInfoLast["d_visitdate"] == !'') $addQry = ", c_lastpaiddate = '".$rstrmInfoLast['d_visitdate']."' "; else $addQry = ", c_lastpaiddate = '' "; } qry("UPDATE tbl_customer SET c_lastpickupdate='".$rstrmInfo['d_orderdate']."', c_lastpickupquantity = '".$rstrmInfo['d_quantity']."' ". $addQry ." WHERE c_uid = '".$_POST['id']."'"); $this->response($this->json(array("msg"=>"Order has been successfully removed.", "c_index"=>$_POST['c_index'])), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function initInput(){ try { $sqInput = qry("SELECT td.d_uid, td.d_customeruid, td.d_orderdate, td.d_ordertype, td.d_driveruid, td.d_ruid, td.d_visitdate, td.d_quantity, td.d_payamount, td.d_paystatus, td.d_payeename, td.d_payeesign, td.d_sludge, tc.c_sludge, tc.c_paymenttype, tc.c_name FROM tbl_daily td, tbl_customer tc WHERE td.d_customeruid = tc.c_uid AND td.d_customeruid='".$_POST['c_uid']."' AND td.d_orderdate='".$_POST['orderdate']."'"); $result = array(); if(db_num_rows($sqInput) > 0) { $rstInput = fetch_array($sqInput); // 이미 존재하는 오더장을 수정한다면 Note 정보도 가져와야 함 $sqNoteInput = qry("SELECT n_note FROM tbl_note WHERE n_dailyuid = '".$rstInput['d_uid']."' "); if(db_num_rows($sqNoteInput) > 0) { $rstNoteInput = fetch_array($sqNoteInput); $noteSTR = $rstNoteInput['n_note']; } else $noteSTR = ""; $result = array( "d_uid" => $rstInput['d_uid'], "d_customeruid" => $rstInput['d_customeruid'], "d_orderdate" => $rstInput['d_orderdate'], "d_driveruid" => $rstInput['d_driveruid'], "d_visitdate" => $rstInput['d_visitdate'], "d_quantity" => $rstInput['d_quantity'], "d_payamount" => $rstInput['d_payamount'], "d_paystatus" => $rstInput['d_paystatus'], "d_payeename" => $rstInput['d_payeename'], "d_payeesign" => $rstInput['d_payeesign'], "d_sludge" => $rstInput['c_sludge'], "d_paymenttype" => $rstInput['c_paymenttype'], "d_name" => $rstInput['c_name'], "d_note" => $noteSTR ); } else { // tbl_daily data 없는 경우 처리 $sqInput = qry("SELECT c_driveruid, c_sludge, c_paymenttype FROM tbl_customer WHERE c_uid='".$_POST['c_uid']."'"); $rstInput = fetch_array($sqInput); $result = array( "d_uid" => '', "d_customeruid" => $_POST['c_uid'], "d_orderdate" => $_POST['orderdate'], "d_driveruid" => $rstInput['c_driveruid'], "d_visitdate" => $_POST['orderdate'], "d_sludge" => $rstInput['c_sludge'], "d_paymenttype" => $rstInput['c_paymenttype'] ); } $this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function saveInput(){ try { // 오늘 날짜 $today = new DateTime(date("Y-m-d")); //$today = new DateTime('20240425'); // 지정한 날짜 $searchDate = new DateTime($_POST['orderdate']); // 두 날짜 간 차이 계산 $interval = $today->diff($searchDate); $result = array( "d_uid" => $_POST['uid'], "d_customeruid" => $_POST['customeruid'], "d_orderdate" => $_POST['orderdate'], "d_driveruid" => $_POST['driveruid'], "d_visitdate" => $_POST['visitdate']."000000", "d_sludge" => $_POST['sludge'], "d_paymenttype" => $_POST['paymenttype'], "d_payamount" => $_POST['payamount'], "d_payeename" => $_POST['payeename'], "d_paystatus" => $_POST['paystatus'], "d_note" => $_POST['note'] ); if ($_POST['paymenttype'] == 'CA') $paystatusSTR = $_POST['paystatus']; else $paystatusSTR = ""; if(strlen($_POST['uid']) > 0) { //update qry("UPDATE tbl_daily SET d_orderdate = '".$_POST['visitdate']."', d_driveruid = '".$_POST['driveruid']."', d_inputdate = '".date('YmdHis')."', d_modifydate = '".date('YmdHis')."', d_quantity = '".$_POST['quantity']."', d_sludge = '".$_POST['sludge']."', d_paystatus = '".$paystatusSTR."', d_payamount = '".$_POST['payamount']."', d_visit = 'Y', d_visitdate = '".$_POST['visitdate']."000000', d_payeename = '".$_POST['payeename']."', d_status='F' WHERE d_uid='".(int)$_POST['uid']."'"); $sqNote = qry("SELECT n_uid FROM tbl_note WHERE n_dailyuid = '".(int)$_POST['uid']."'"); if(db_num_rows($sqNote) > 0) { qry("UPDATE tbl_note SET n_note = '".$_POST['note']."' WHERE n_dailyuid = '".(int)$_POST['uid']."'"); } else { if(strlen(trim($_POST['note'])) > 0){ qry("INSERT INTO tbl_note ( n_memberuid, n_customeruid, n_dailyuid, n_type, n_view, n_note, n_createddate) VALUE ( '".$_POST['driveruid']."', '".$_POST['customeruid']."', '".$_POST['uid']."', 'D', 1, '".$_POST['note']."', '".date('YmdHis')."') "); } } }else{ //new /* 오더장 있는지 확인 모듈 추가 (2025.02.20) */ $sqData = qry("SELECT d_uid FROM tbl_daily WHERE d_orderdate = '".$_POST['visitdate']."' AND d_customeruid = '".$_POST['customeruid']."'"); if(db_num_rows($sqData) <= 0) { qry("INSERT INTO tbl_daily ( d_orderdate, d_driveruid, d_customeruid, d_accountno, d_name, d_paymenttype, d_cycle, d_rate, d_form_eu, d_form_corsia, d_maincontainer, d_container, d_location, d_address, d_city, d_postal, d_oil_2y, d_oil_1y, d_oil_0y, d_fullcycle, d_fullcycleforced, d_fullcycleflag, d_lastpickupdate, d_lastpickupquantity, d_lastpaiddate, d_estquantity, d_createruid, d_createddate, d_inputdate, d_quantity, d_sludge, d_paystatus, d_payamount, d_visit, d_visitdate, d_status, d_payeename ) SELECT '".$_POST['visitdate']."', '".$_POST['driveruid']."', c_uid, c_accountno, c_name, c_paymenttype, c_paymentcycle, c_rate, c_form_eu, c_form_corsia, c_maincontainer, c_container, c_location, c_address, c_city, c_postal, 0, 0, 0, c_fullcycle, c_fullcycleforced, c_fullcycleflag, c_lastpickupdate, c_lastpickupquantity, c_lastpaiddate, IFNULL((c_fullquantity - c_fullquantitydaily + (".(int)$interval->days." * c_fullquantitydaily)),0), '".$_POST['createruid']."', '".date('YmdHis')."', '".date('YmdHis')."', ".$_POST['quantity'].", '".$_POST['sludge']."', '".$paystatusSTR."', '".$_POST['payamount']."', 'Y', '".$_POST['visitdate']."000000"."', 'F', '".$_POST['payeename']."' FROM tbl_customer WHERE c_uid='".(int)$_POST['customeruid']."'"); $sqDailyUid = qry("SELECT d_uid FROM tbl_daily WHERE d_customeruid='".(int)$_POST['customeruid']."' AND d_orderdate='".$_POST['visitdate']."' ORDER BY d_uid DESC LIMIT 1 "); $rstDailyUid = fetch_array($sqDailyUid); if(strlen(trim($_POST['note'])) > 0){ qry("INSERT INTO tbl_note ( n_memberuid, n_customeruid, n_dailyuid, n_type, n_view, n_note, n_createddate) VALUE ( '".$_POST['driveruid']."', '".$_POST['customeruid']."', '".$rstDailyUid['d_uid']."', 'D', 1, '".$_POST['note']."', '".date('YmdHis')."') "); } $folderPath = getenv("DOCUMENT_ROOT")."/upload_sign/".$_POST['customeruid']; $setFilename = ""; if (is_dir($folderPath)) { $files = scandir($folderPath); $tmpFilename = "T_".$_POST['visitdate']; foreach ($files as $file) { if (strstr($file, $tmpFilename)) { $setFilename = $file; } } if ($setFilename != "") { $setFilenameNew = str_replace("T_", "", $setFilename); rename($folderPath."/".$setFilename, $folderPath."/".$setFilenameNew); qry("UPDATE tbl_daily SET d_payeesign='".$setFilenameNew."' WHERE d_uid = '".$rstDailyUid['d_uid']."' "); } } } } //////////////////////////////////////////////////////////////////////////// // tbl_customer 의 c_lastpickupdate, c_lastpickupquantity, c_lastpaiddate , // c_orderdate = "", c_orderflag = 0, c_sludge 업데이트 //////////////////////////////////////////////////////////////////////////// // d_visitdate 가 c_lastpickupdate 보다 커야 tbl_customer 에 c_lastpickupdate, c_lastpickupquantity 저장 $qry_a = qry("SELECT c_lastpickupdate, c_paymenttype FROM tbl_customer WHERE c_uid = '".$_POST['customeruid']."' "); $rt_a = fetch_array($qry_a); $c_lastpickupdate = $rt_a['c_lastpickupdate']; if ($_POST['visitdate'] >= $c_lastpickupdate) { $addQry_a = " c_lastpickupdate = '".$_POST['visitdate']."', c_lastpickupquantity = '".$_POST['quantity']."',"; if (trim($_POST['sludge']) != "") { $add_sludge = " c_sludge = '".$_POST['sludge']."', "; // tbl_daily 의 sludge update qry("UPDATE tbl_daily SET d_sludge='".$_POST['sludge']."' WHERE d_customeruid = '".$_POST['customeruid']."' "); } else $add_sludge = ""; } else { $addQry_a = ""; $add_sludge = ""; } if ($rt_a['c_paymenttype'] == "CA" && $_POST['paystatus'] == "P") { $addQry = " c_lastpaiddate = '".$_POST['visitdate']."', "; $addWhereQry = "AND (c_lastpaiddate < '".$_POST['visitdate']."' OR c_lastpaiddate IS NULL) "; } else { $addQry = ""; $addWhereQry = ""; } //if (trim($d_sludge) != "") $add_sludge = " c_sludge = '$d_sludge', "; //else $add_sludge = ""; qry("UPDATE tbl_customer SET ".$addQry_a." ".$addQry." c_orderdate = '', ".$add_sludge." c_orderflag = 0 WHERE c_uid = '".$_POST['customeruid']."' ". $addWhereQry ." "); $this->response($this->json(array("msg"=>"Input has been successfully saved.")), 200); //$this->response($this->json(array("result"=>$result)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } public function inqMapCenter(){ try { $geo = array( "lat" => '43.732188', "lon" => '-79.571618' ); $sqCenter = qry("SELECT m_geolat, m_geolon FROM tbl_member WHERE m_uid=".(int)$_POST['driver']); if(db_num_rows($sqCenter) > 0) { $rstCenter = fetch_array($sqCenter); if($rstCenter['m_geolat'] !== null && $rstCenter['m_geolon'] !== null) { $geo = array( "lat" => $rstCenter['m_geolat'], "lon" => $rstCenter['m_geolon'] ); } } $this->response($this->json(array("geo"=>$geo)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } /////////////////////// // Get Pickup Quantity /////////////////////// public function inqPickupQty(){ try { $_POST['route_date'] = str_replace("-","",$_POST['route_date']); $sqQuantity = qry("SELECT SUM(d_quantity) as pickupquantity FROM tbl_daily WHERE d_status = 'F' AND d_orderdate = '".$_POST['route_date']."' AND d_driveruid = '".$_POST['driver']."' "); $rstQuantity = fetch_array($sqQuantity); $curPickupQty = number_format((int)$rstQuantity['pickupquantity']); $this->response($this->json(array("curPickupQty"=>$curPickupQty)), 200); } catch(Exception $e) { $error = array($e->getMessage()); $this->response($this->json($error), 417); } } } $api = new API; $api->processApi(); ?>