$numOfPeople = $book['numOfPeople']; $expectedBudget = $book['expectedBudget']; $mobileNumber = $book['mobileNumber']; $altMobileNumber = $book['altMobileNumber']; $hotels = $book['hotels']; $travel = $book['travel']; $amenities = $book['amenities']; $email = $book['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" => '', "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_book = array("trips_id" => $trip_id, "no_of_persons" => $numOfPeople, "expect_total_budget" => $expectedBudget, "trip_type" => $typeOfTrip, "no_of_days" => $tripDuration, "origin_city" => $originCity, "end_city" => $returningCity, "returning_city" => $returningCity, "hotels" => $hotels, "travel" => $travel, "amenities" => $amenities); $trip = $db->trips_book()->insert($insert_trip_book); 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); } } else { $fullName = $plan['fullName']; $mobileNumber = $plan['mobileNumber']; $altMobileNumber = $mobileNumber; $tripDuration = $plan['numOfDays']; $priceToPay = $plan['priceToPay'];
// echo json_encode(array('places_data'=>$data)); // // }); $app->get('/user/userdata', $authenticate($app), function () use($app, $db) { $p = $db->users()->where('user_email', $_SESSION['user'])->fetch(); // $user_id = $q1['id']; $user_data = array('user_email' => $_SESSION['user'], 'user_name' => $p['user_name'], 'user_contact_no1' => $p['user_contact_no1'], 'user_contact_no2' => $p['user_contact_no2']); $app->response()->header('content-type', 'application/json'); echo json_encode(array('our_trips' => $user_data)); }); $app->get('/user/userTrips', $authenticate($app), function () use($app, $db) { $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']);