$query = new TimetableQuery();
$query->setRoute(Provider::ROUTE_BARCELONA)->setDeparture("79600")->setDestination("71802");
// Barcelona-Passeig de Gràcia
$httpAdapter = new BuzzHttpAdapter();
$provider = new Provider($httpAdapter);
$cercanias = new Cercanias($provider);
$timetable = $cercanias->getTimetable($query);
echo "Timetable 'Barcelona': \n";
echo sprintf(" - departure:     '%s'\n", $timetable->getDeparture()->getName());
echo sprintf(" - destination:   '%s'\n", $timetable->getDestination()->getName());
echo sprintf(" - transfer:      '%s'\n", $timetable->getTransferName());
echo sprintf(" - date:          %s\n", $query->getDate()->format("Y-m-d"));
$pattern = "%4s  %6s  %6s  %6s  %4s  %6s\n";
echo sprintf($pattern, "LINE", "DEPART", "ARRIVE", "DEPART", "LINE", "ARRIVE");
foreach ($timetable->getTrips() as $trip) {
    foreach (prepareResults($trip) as $item) {
        echo sprintf($pattern, $item["line"], $item["departure"], $item["arrival"], $item["transfer_departure"], $item["transfer_line"], $item["transfer_arrival"]);
    }
}
function prepareResults(Trip $trip)
{
    $result = array("line" => $trip->getDepartureTrain()->getLine(), "departure" => $trip->getDepartureTrain()->getDepartureTime()->format("H:i"), "arrival" => $trip->getDepartureTrain()->getArrivalTime()->format("H:i"), "transfer_departure" => "", "transfer_arrival" => "", "transfer_line" => "");
    $transfers = array();
    if ($trip->hasTransfer()) {
        $i = 0;
        foreach ($trip->getTransferTrains() as $transfer) {
            /* @var Train $transfer */
            if ($i == 0) {
                $result["transfer_departure"] = $transfer->getDepartureTime()->format("H:i");
                $result["transfer_arrival"] = $transfer->getArrivalTime()->format("H:i");
                $result["transfer_line"] = $transfer->getLine();
Example #2
0
                     /*if ($AlreadyFound == 0)   {					
                     		foreach ($jsonAll['databases'] as $rowAll){
                             if (($rowAll['organization']) == 'buyer') {					
                     			prepareResults($DbPath,$rowAll['name'],"buyerVatIdOrName","by_buyerDtls_VatIdOrName",'*',25,"score",$term2);                    
                     			}
                                      }						
                     	    }	*/
                     prepareResults($DbPath, "elod_diaugeia_hybrids", "buyerVatIdOrName", "by_buyerDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_espa_beneficiaries", "VatIdOrName", "by_beneficiaryDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_buyers", "buyerVatIdOrName", "by_buyerDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_diaugeia_buyers", "buyerVatIdOrName", "by_buyerDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_sellers", "sellerVatIdOrName", "by_sellerDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_diaugeia_sellers", "sellerVatIdOrName", "by_sellerDtls_VatIdOrName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_eprices_shops", "Shop", "by_eprices_ShopName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_eprices_products", "Product", "by_eprices_ProductName", '*', 25, "score", $term2);
                     prepareResults($DbPath, "elod_kath_products", "Product", "by_eprices_ProductName", '*', 25, "score", $term2);
                 }
             }
         }
         //end of words>1
     }
     //end of english and greek
 }
 //end of name
 //sortResults();
 showResults();
 curl_close($chAll);
 $time_post = microtime(true);
 $exec_time = $time_post - $time_pre;
 echo "<div ALIGN='CENTER'>";
 echo '(Σε ' . number_format($exec_time, 2) . ' δευτερόλεπτα)';