コード例 #1
0
ファイル: calendar.php プロジェクト: akochnov/fts
    echo '<table>';
    echo '<tr><th>Date</th><th>Price</th><th>Average</th><th>Transfers</th><th>Return at</th><th>Link</th></tr>';
    foreach ($dates as $date) {
        $calendar = getCalendar($originIata, $destIata, $date);
        $average = getAverage($originIata, $destIata, $date);
        if (array_key_exists('success', $calendar) && $calendar['success'] == 1 && array_key_exists('data', $calendar)) {
            $color = false;
            foreach ($calendar['data'] as $day => $data) {
                if ($color) {
                    echo '<tr class="colored">';
                } else {
                    echo '<tr>';
                }
                $color = !$color;
                $tdHighlited = $data['price'] / $average < $compare ? '<td class="highlighted">' : '<td>';
                $link = getSearchLink($originIata, $destIata, $day, substr($data['return_at'], 0, 10));
                echo '<td>' . $day . '</td>' . $tdHighlited . $data['price'] . '</td>';
                echo '<td>' . round($average) . '</td>';
                echo '<td>' . $data['transfers'] . '</td><td>' . $data['return_at'] . '</td>';
                echo '<td><a href="' . $link . '" target="_blank">link</a></td>';
                echo '</tr>';
            }
        } else {
            echo 'Error: ' . $calendar['message'] . '</br>';
        }
    }
    echo '</table>';
    echo '</br> END';
} else {
    echo "bad request";
}
コード例 #2
0
ファイル: weekends.php プロジェクト: akochnov/fts
 $cheap = getCheap($originIata, $destIata, $weekend[$day], $weekend['Sunday']);
 if (array_key_exists('success', $cheap) && true == $cheap['success'] && array_key_exists('data', $cheap) && array_key_exists($destIata, $cheap['data'])) {
     //loop through variants
     foreach ($cheap['data'][$destIata] as $variant) {
         $departure_at = date('Y-m-d H:i', strtotime($variant['departure_at']));
         $return_at = date('Y-m-d H:i', strtotime($variant['return_at']));
         $expires_at = $variant['expires_at'];
         $airline = $variant['airline'];
         $flight_number = $variant['flight_number'];
         $price = $variant['price'];
         $dest = $destination['destination_name'];
         //Count trip duration
         $day1 = new DateTime($weekend[$day]);
         $day2 = new DateTime($return_at);
         $days = $day2->diff($day1)->d;
         $link = getSearchLink($originIata, $destIata, $weekend[$day], $weekend['Sunday']);
         $link = '<a href="' . $link . '" target="_blank">link</a>';
         //When variant price is good
         if ($variant['price'] / $average < $ratio) {
             //Output table row
             echo '<tr>';
             echo "<td>[{$originIata}] {$origin} </td>";
             echo "<td>[{$destIata}] {$dest}</td>";
             echo "<td>{$departure_at}</td>";
             echo "<td>{$days}</td>";
             echo "<td>{$return_at}</td>";
             echo "<td>{$price}</td>";
             echo "<td>{$average}</td>";
             echo "<td>{$link}</td>";
             echo '</tr>';
         }