Exemplo n.º 1
0
        $priceToPay = $plan['priceToPay'];
        $numOfPeople = $plan['numOfPeople'];
        $address = (array) $plan['address'];
        $email = $plan['email'];
        $user_id = 0;
        $q1 = $db->users()->where('user_email', $email);
        if (count($q1) == 1) {
            $user_id = $q1->fetch()['id'];
        }
        $insert_trip = array("places_id" => $selectedPlaceId, "trip_place_name" => $selectedPlace, "trip_booktype" => $planType, "trip_starting_date" => $journeyStartingDate, "user_name" => $fullName, "user_email" => $email, "users_id" => $user_id, "user_address" => $address, "user_contact_no1" => $mobileNumber, "user_contact_no2" => $altMobileNumber, "isOrderOk" => 0, "isOrderDone" => 0);
        //       print_r($insert_trip);
        $trip = $db->trips()->insert($insert_trip);
        $trip_id = $trip['id'];
        //       echo $trip_id ;
        $insert_trip_plan = array("trips_id" => $trip_id, "no_of_persons" => $numOfPeople, "no_of_days" => $tripDuration, "price_to_pay" => $priceToPay);
        $trip_plan = $db->trips_plan()->insert($insert_trip_plan);
        for ($i = 0; $i < sizeOf($attractionsList); $i++) {
            $p = (array) $attractionsList[$i];
            $attraction = array("trips_id" => $trip_id, "attractions_id" => $p['id'], "attraction_preference" => 0);
            $db->trip_attractions()->insert($attraction);
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode(array('order_id' => $data));
});
$app->get('/region/places(/:region_id)', function ($region_id = null) use($app, $db) {
    if ($region_id != null) {
        $data = array();
        foreach ($db->places()->where('place_region_id', $region_id) as $p) {
            $data[] = array('id' => $p["id"], 'place_name' => $p["place_name"], 'place_region_name' => $p["place_region_name"], 'place_region_id' => $p["place_region_id"]);
        }
Exemplo n.º 2
0
    $p = $db->users()->where('user_email', $_SESSION['user'])->fetch();
    $user_id = $p['id'];
    $bookTrips = array();
    $planTrips = array();
    foreach ($db->trips()->where('users_id', $user_id) as $trip) {
        if ($trip['trip_booktype'] == 'Book') {
            $booked_trip = $db->trips_book()->where('trips_id', $trip['id'])->fetch();
            $trip_attractions = $db->trip_attractions()->where('trips_id', $trip['id']);
            $attractions = array();
            foreach ($trip_attractions as $attr) {
                $attractions[] = array('id' => $attr['id'], 'attraction_id' => $attr['attractions_id']);
            }
            $bookTrips[] = array("trip_id" => $trip['id'], "places_id" => $trip["places_id"], "trip_place_name" => $trip["trip_place_name"], "trip_booktype" => $trip["trip_booktype"], "trip_starting_date" => $trip["trip_starting_date"], "user_name" => $trip["user_name"], "user_email" => $trip["user_email"], "users_id" => $trip["users_id"], "user_address" => $trip["user_address"], "user_contact_no1" => $trip["user_contact_no1"], "user_contact_no2" => $trip["user_contact_no2"], "isOrderOk" => $trip["isOrderOk"], "isOrderDone" => $trip["isOrderDone"], "our_plan_id" => $trip["our_plan_id"], "no_of_persons" => $booked_trip["no_of_persons"], "expect_total_budget" => $booked_trip["expect_total_budget"], "trip_type" => $booked_trip["trip_type"], "no_of_days" => $booked_trip["no_of_days"], "origin_city" => $booked_trip["origin_city"], "end_city" => $booked_trip["end_city"], "returning_city" => $booked_trip["returning_city"], "hotels" => $booked_trip["hotels"], "travel" => $booked_trip["travel"], "amenities" => $booked_trip["amenities"], "attractions" => $attractions);
        } else {
            if ($trip['trip_booktype'] == 'Plan') {
                $planned_trip = $db->trips_plan()->where('trips_id', $trip['id'])->fetch();
                $trip_attractions = $db->trip_attractions()->where('trips_id', $trip['id']);
                $attractions = array();
                foreach ($trip_attractions as $attr) {
                    $attractions[] = array('id' => $attr['id'], 'attraction_id' => $attr['attractions_id']);
                }
                $planTrips[] = array("trip_id" => $trip['id'], "places_id" => $trip["places_id"], "trip_place_name" => $trip["trip_place_name"], "trip_booktype" => $trip["trip_booktype"], "trip_starting_date" => $trip["trip_starting_date"], "user_name" => $trip["user_name"], "user_email" => $trip["user_email"], "users_id" => $trip["users_id"], "user_address" => $trip["user_address"], "user_contact_no1" => $trip["user_contact_no1"], "user_contact_no2" => $trip["user_contact_no2"], "isOrderOk" => $trip["isOrderOk"], "isOrderDone" => $trip["isOrderDone"], "our_plan_id" => $trip["our_plan_id"], "no_of_persons" => $planned_trip["no_of_persons"], "no_of_days" => $planned_trip["no_of_days"], "price_to_pay" => $planned_trip["price_to_pay"], "attractions" => $attractions);
            }
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode(array('plan_trips' => $planTrips, 'book_trips' => $bookTrips));
});
$app->get('/our_trips(/:place_id)', function ($place_id) use($app, $db) {
    if ($place_id != null) {
        $data = array();