function c2r_requests_get($user_id, $status = null, $past = 1, $company_id = null) { $data = '{"method": "requests_get", "params": [' . $user_id . ', ' . $past . '], "id": 0}'; $rs_tmp = post($data); $rs = array(); foreach ($rs_tmp as $key => $value) { $r = null; $r->id = $value[0]; $r->user_number_id = $value[1]; $r->user_number = c2r_get_user_number($r->user_number_id); $r->start_point_id = $value[2]; $r->start_point = c2r_pickuppoints_get($r->start_point_id); $location_id = $r->start_point->lid; $location = c2r_locations_get($location_id); $timezone = $location->timezone; $r->end_point_id = $value[3]; $r->end_point = c2r_pickuppoints_get($r->end_point_id); $r->earliest_start_time = convertDatetime($value[4], $timezone); $r->latest_start_time = convertDatetime($value[5], $timezone); $r->request_time = $value[6]; $r->status = $value[7]; $user_id = c2r_get_user_id_by_user_number_id($r->user_number_id); $theuser = c2r_user_get($user_id); $r->user = $theuser; if ($company_id && $r->user->company_id != $company_id) { continue; } if (!$status || $status == $r->status) { $rs[$r->id] = $r; } } return $rs; }
ORDER BY Schedule ASC EOS; $stmt = $pdo->prepare($sql); $stmt->execute(array(':planid' => $planid)); $results = array(); while ($spot = $stmt->fetch(PDO::FETCH_ASSOC)) { foreach (array('spotid', 'openid', 'priceid', 'minage', 'maxage', 'price', 'categorycode') as $k) { $spot[$k] = (int) $spot[$k]; } foreach (array('latitude', 'longitude') as $k) { $spot[$k] = (double) $spot[$k]; } foreach (array('name', 'kana', 'description', 'imgpath', 'tel', 'url', 'area', 'category', 'address') as $k) { $spot[$k] = h($spot[$k]); } $spot['schedule'] = convertDatetime($spot['schedule'], 0); $results[] = $spot; } $sql = <<<EOS SELECT pn.Budget as budget, SUM(pr.ExamplePrice) as sumprice FROM Plans AS pn INNER JOIN Course AS co ON pn.PlanID = :planid AND pn.PlanID = co.PlanID INNER JOIN Prices AS pr ON co.PriceID = pr.PriceID EOS; $stmt = $pdo->prepare($sql); $stmt->execute(array(':planid' => $planid));
$longitude = (double) $fetch['longitude']; $budget = (int) $fetch['budget']; $sql = sprintf($selectsql, 'AND NOT EXISTS (SELECT 1 FROM Course AS co WHERE co.planid=:planid AND co.spotid=sp.spotid)', <<<EOS + IF(sp.CategoryCode = :beforecategory, 0, 2) + IF(distance <= 375, 2, 0) + IF(distance <= 750, 1, 0) + IF(distance <= 1500, 1, 0) EOS ); $data = array(':latitude' => $latitude, ':longitude' => $longitude, ':budget' => $budget, ':start' => $start, ':planid' => $planid, ':beforecategory' => $beforecategory); } $stmt = $pdo->prepare($sql); $stmt->execute($data); $results = array(); while ($spot = $stmt->fetch(PDO::FETCH_ASSOC)) { foreach (array('spotid', 'openid', 'priceid', 'minage', 'maxage', 'price', 'categorycode') as $k) { $spot[$k] = (int) $spot[$k]; } foreach (array('latitude', 'longitude', 'distance') as $k) { $spot[$k] = (double) $spot[$k]; } foreach (array('name', 'kana', 'description', 'imgpath', 'tel', 'url', 'area', 'category', 'address') as $k) { $spot[$k] = h($spot[$k]); } $results[] = $spot; } // DB切断 $pdo = null; // JSON表示 echo json_encode(array('spotdata' => $results, 'start' => convertDatetime($start, 0), 'budget' => (int) $budget), JSON_UNESCAPED_UNICODE);
} $sql = sprintf($selectsql, $where, $order); $stmt = $pdo->prepare($sql); $stmt->execute($data); $tmp = array(); while ($spot = $stmt->fetch(PDO::FETCH_ASSOC)) { foreach (array('spotid', 'openid', 'priceid', 'minage', 'maxage', 'price', 'categorycode') as $k) { $spot[$k] = (int) $spot[$k]; } foreach (array('latitude', 'longitude', 'distance') as $k) { $spot[$k] = (double) $spot[$k]; } foreach (array('name', 'kana', 'description', 'imgpath', 'tel', 'url', 'area', 'category', 'address') as $k) { $spot[$k] = h($spot[$k]); } $tmp[] = $spot; } $results[] = array('spotdata' => $tmp, 'start' => convertDatetime($spots[$i]['start'], 0), 'budget' => $budget); if ($i < $len) { $budget -= $spots[$i]['price']; } } $selected = array(); for ($i = 0, $len = count($spots) - 1; $i < $len; $i++) { $tmp = $spots[$i]; $selected[] = array('spotid' => $tmp['spotid'], 'openid' => $tmp['openid'], 'priceid' => $tmp['priceid']); } // DB切断 $pdo = null; // JSON表示 echo json_encode(array('valid' => 1, 'data' => $results, 'selected' => $selected), JSON_UNESCAPED_UNICODE);
$error[] = '開始から終了までが2時間以上'; } if ($maxfin < $finish) { $error[] = '開始から終了までが72時間以内'; } if ($_POST['people'] < 1 || 20 < $_POST['people']) { $error[] = '人数は1人以上20人以下'; } if ($_POST['budget'] < 0) { $error[] = '予算は0円以上'; } if (count($error) == 0) { unset($_POST['token']); unset($_SESSION['token']); $_POST['start'] = convertDatetime($_POST['start']); $_POST['finish'] = convertDatetime($_POST['finish']); $_SESSION['form'] = $_POST; unset($_POST); header('Location: ' . SITE_URL . 'registplan.php'); exit; } } ?> <!DOCTYPE html> <html> <head><title>Form - GoatSupporter</title> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
* @copyright Copyright © 2015, Kalmer Piiskop <*****@*****.**> */ header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: Mon,26 Jul 1997 05:00:00 GMT'); phpinfo(); function convertDatetime($str) { list($date, $time) = explode(' ', $str); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); date_default_timezone_set('Europe/Helsinki'); $timestamp = mktime($hour, $minute, $second, $month, $day, $year); return $timestamp; } echo ' 23: ', convertDatetime('2005-02-27 22:37:00'); $trees = array('okaspuud' => array('type' => 'okaspuud', 'trees' => array('kuusk' => array('type' => 'kuusk', 'evergreen' => true), 'mänd' => array('type' => 'mänd', 'evergreen' => true), 'lehis' => array('type' => 'lehis', 'evergreen' => false))), 'lehtpuud' => array('type' => 'lehtpuud', 'trees' => array('kask' => array('type' => 'kask', 'evergreen' => false), 'pihlakas' => array('type' => 'pihlakas', 'evergreen' => false), 'plasticAppleTree' => array('type' => 'plasticAppleTree', 'evergreen' => true)))); foreach ($trees as $arrayOfTypeOfTrees) { foreach ($arrayOfTypeOfTrees['trees'] as $treeItem) { if ($treeItem['evergreen']) { if ($treeItem['type'] === 'kuusk') { echo "\n" . ' 54: kuusk on igihaljas: ', $treeItem['type']; continue; } echo "\n" . ' 34: igihaljas: ', $treeItem['type']; } else { echo "\n" . ' 58: ei ole igihaljas: ', $treeItem['type']; } } } echo "\n";