public function query($query)
 {
     $query = strtolower(filter_var($query, FILTER_SANITIZE_STRING));
     $cities_raw = Gulliver::getCitiesBooking();
     $cities = array();
     if (!Gulliver::$error) {
         foreach ($cities_raw as $city) {
             $city_name = strtolower($city['name']);
             if (strstr($city_name, $query)) {
                 $country = Country::where('code', $city['country'])->first();
                 $city = array('value' => $city['name'] . ', ' . $country->name . ' (' . $city['country'] . ')');
                 $cities[] = $city;
             }
         }
     }
     return json_encode($cities);
 }
 /**
  * @return mixed
  **/
 public function grid()
 {
     $EncryptedSearch = Request::get('search', "");
     if ("" == $EncryptedSearch) {
         return Response::json(['error' => true, 'description' => 'No search'], 412);
     }
     //
     try {
         $search = Crypt::decrypt($EncryptedSearch);
     } catch (\Exception $e) {
         return Response::json(['error' => true, 'description' => 'Search decode'], 412);
     }
     //
     $response = Gulliver::getInsuranceAvailability(['origin' => mb_convert_case($search['origin'], MB_CASE_UPPER), 'destination' => mb_convert_case($search['destination'], MB_CASE_TITLE), 'dateFrom' => $search['dateFrom'], 'dateTo' => $search['dateTo'], 'passengers' => true == is_array($search['passengers']) ? implode(',', $search['passengers']) : $search['passengers'], 'currency' => 'ARS']);
     if (false == $response) {
         return Response::json(['error' => true, 'description' => Gulliver::$error], 412);
     }
     //
     $sessionId = $response['sessionId'];
     $response = $response['availablePlans'];
     //
     foreach ($response as $key => $item) {
         $response[$key]['insuranceTotalPrices']['requestedSellingPrice']['taxes'] = $item['insuranceTotalPrices']['requestedSellingPrice']['afterTax'] - $item['insuranceTotalPrices']['requestedSellingPrice']['beforeTax'];
         //
         $row = InsuranceModel::store(['session' => $sessionId, 'plan_number' => $key, 'item' => json_encode($response[$key]), 'search' => json_encode($search)]);
         //  http://viajes-laravel.dev/compra/seguros/?GID=71ff1103-d3c6-4e12-92b1-0caccc864d2a&BID=1
         $response[$key]['booking'] = url() . '/compra/seguros?' . http_build_query(['GID' => $sessionId, 'BID' => $row->id]);
     }
     //
     Cookie::queue(self::$config['cookieName'], $search, self::$config['cookieTtl']);
     //
     return Response::json(['error' => false, 'description' => 'Ok', 'total' => sizeof($response), 'grid' => view('Insurance/grid')->with(['destination' => mb_convert_case($search['destination'], MB_CASE_LOWER), 'response' => $response])->render()], 200);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $offers_raw = Gulliver::getFlightsOffers();
     $error_gulliver = false;
     if (Gulliver::$error) {
         $error_gulliver = Gulliver::$error;
     } else {
         DB::table('offers_air')->truncate();
         $error_offer = false;
         foreach ($offers_raw as $item) {
             $offer = new Offer_air();
             if (isset($item['offerId'])) {
                 $offer->offerId = $item['offerId'];
             }
             if (isset($item['airline'])) {
                 $offer->airline = $item['airline'];
             }
             if (isset($item['origin'])) {
                 $offer->origin = $item['origin'];
             }
             if (isset($item['destination'])) {
                 $offer->destination = $item['destination'];
             }
             if (isset($item['ranges']) && !empty($item['ranges'])) {
                 foreach ($item['ranges'] as $range) {
                     if ($range['rangeType'] == 'DEPARTURE') {
                         if (isset($range['from'])) {
                             $offer->departureFrom = $range['from'];
                         }
                         if (isset($range['to'])) {
                             $offer->departureTo = $range['to'];
                         }
                     } else {
                         if (isset($range['from'])) {
                             $offer->arrivalFrom = $range['from'];
                         }
                         if (isset($range['to'])) {
                             $offer->arrivalTo = $range['to'];
                         }
                     }
                 }
             }
             if (isset($item['description'])) {
                 $offer->description = $item['description'];
             }
             if (isset($item['minStay'])) {
                 $offer->minStay = $item['minStay'];
             }
             if (isset($item['maxStay'])) {
                 $offer->maxStay = $item['maxStay'];
             }
             if (isset($item['fareBasis'])) {
                 $offer->fareBasis = $item['fareBasis'];
             }
             if (isset($item['validFrom'])) {
                 $offer->validFrom = $item['validFrom'];
             }
             if (isset($item['validTo'])) {
                 $offer->validTo = $item['validTo'];
             }
             if (isset($item['bookingClasses'])) {
                 $offer->bookingClasses = implode(", ", $item['bookingClasses']);
             }
             if (isset($item['departureFlightNumber'])) {
                 $offer->departureFlightNumber = $item['departureFlightNumber'];
             }
             if (isset($item['returnFlightNumber'])) {
                 $offer->returnFlightNumber = $item['returnFlightNumber'];
             }
             if (isset($item['ticketingLimitDate'])) {
                 $offer->ticketingLimitDate = $item['ticketingLimitDate'];
             }
             if (isset($item['completeTripBeforeDate'])) {
                 $offer->completeTripBeforeDate = $item['completeTripBeforeDate'];
             }
             if (isset($item['sellingPriceAfterTax'])) {
                 $offer->sellingPriceAfterTax = implode(" ", $item['sellingPriceAfterTax']);
             }
             if (isset($item['sellingPriceRequestedAfterTax'])) {
                 $offer->sellingPriceRequestedAfterTax = implode(" ", $item['sellingPriceRequestedAfterTax']);
             }
             if (isset($item['sellingCondition'])) {
                 $offer->sellingCondition = $item['sellingCondition'];
             }
             if (isset($item['minSeatsAtDeparture'])) {
                 $offer->minSeatsAtDeparture = $item['minSeatsAtDeparture'];
             }
             if (isset($item['minSeatsAtArrival'])) {
                 $offer->minSeatsAtArrival = $item['minSeatsAtArrival'];
             }
             if (isset($item['availableSeats'])) {
                 $offer->availableSeats = $item['availableSeats'];
             }
             if (!$offer->save()) {
                 $error_offer = true;
             }
         }
         if ($error_offer) {
             $error_gulliver = "One or more Air Offers could not be saved.";
         }
     }
     return view('cms/offers_air/all')->with('error', $error_gulliver)->with('offers_air', Offer_air::all());
 }
Beispiel #4
0
 function CitiesAutocomplete()
 {
     Request::setMethod('GET');
     $stateCode = Request::get('stateCode', "");
     $stateCode = filter_var($stateCode, FILTER_SANITIZE_STRING);
     $cityName = Request::get('cityName', "");
     $cityName = filter_var($cityName, FILTER_SANITIZE_STRING);
     //
     $cityResult = [];
     if ("" != $cityName) {
         $cities = DB::table('cache_gulliver_states')->select('cities')->where('code', $stateCode)->get();
         $cities = json_decode($cities[0]->cities);
         foreach ($cities as $city) {
             if ($city->name == $cityName) {
                 $cityResult = $city;
                 break;
             }
         }
         return Response::json($cityResult, 200);
     } else {
         $cities = DB::table('cache_gulliver_states')->select('cities')->where('code', $stateCode)->get();
         if (true == empty($cities[0]->cities)) {
             $cities = Gulliver::getCities('AR', $stateCode);
             DB::table('cache_gulliver_states')->where('code', $stateCode)->update(['cities' => json_encode($cities)]);
         } else {
             $cities = json_decode($cities[0]->cities);
         }
         return Response::json($cities, 200);
     }
 }
 static function bookGet()
 {
     //  Prepare Purchase Passengers
     $paxLead = "";
     $coveredTravelers = [];
     foreach (self::$form['traveler'] as $key => $traveler) {
         $isLead = false;
         if (0 == $key) {
             $isLead = true;
             $paxLead = $traveler['nombre'] . ' ' . $traveler['apellido'];
         }
         $coveredTravelers[] = ['email' => "", 'code' => 'ADT', 'documents' => [['docType' => $traveler['tipoDocumento'], 'docId' => $traveler['numeroDocumento'], 'primary' => true]], 'lastName' => $traveler['apellido'], 'firstName' => $traveler['nombre'], 'birthDate' => dateFormat($traveler['anio_nac'] . '-' . $traveler['mes_nac'] . '-' . $traveler['dia_nac'], 'Y-m-d'), 'isLead' => $isLead];
     }
     view()->share('paxLead', $paxLead);
     // Prepare Purchase Parameters
     $GulliverParameters = ['purchaseComments' => self::$form['comentarios'] . ' | Datos de fact:' . self::$form['domicilio'] . ' ' . self::$form['altura'] . ' ' . self::$form['piso'] . ' ' . self::$form['depto'] . ' (' . self::$form['localidad'] . ')-' . self::$form['clave'] . ':' . self::$form['cuil'], 'dateTo' => self::$search['dateTo'], 'onlinePurchase' => true, 'contactInfo' => ['firstName' => $coveredTravelers[0]['firstName'], 'lastName' => $coveredTravelers[0]['lastName'], 'email' => self::$form['email'], 'telephones' => [['telephoneType' => 'Home', 'phoneNumber' => self::$form['telefono']]]], 'emergencyContactsInfo' => [['firstName' => self::$form['emergencyContactsInfo']['name'], 'lastName' => self::$form['emergencyContactsInfo']['lastname'], 'email' => '', 'telephones' => [['telephoneType' => 'Home', 'phoneNumber' => self::$form['emergencyContactsInfo']['phone']]]]], 'sessionId' => self::$form['GID'], 'dateFrom' => self::$search['dateFrom'], 'isPromotion' => false, 'requestedCurrency' => self::$item['insuranceTotalPrices']['requestedPromotionalPrice']['currency'], 'purchasedPlans' => [['purchasePlanCode' => self::$item['insurancePlan']['code'], 'coveredTravelers' => $coveredTravelers, 'coveredDestination' => mb_convert_case(self::$search['destination'], MB_CASE_TITLE)]]];
     //   For testing proposes
     if (false == self::$testPNR) {
         $resp = Gulliver::BookingInsurance($GulliverParameters);
     } else {
         $resp = '{"data":{"dateTo":"2016-01-16","success":true,"bookingId":"N7IZZA","coveredTravelersCount":2,"sessionId":"64624cfb-9bf9-4b5d-8d29-bad8ee5c5bbe","dateFrom":"2016-01-15","requestedCurrency":"ARS","purchasedPlans":[{"insurancePlan":{"insuranceProvider":"TVA","name":"EuropeEUR30.000","description":"Europe30.000Euros","tripType":"SINGLE_TRIP","validTo":"2016-09-30T03:00:00Z","validFrom":"2013-10-01T03:00:00Z","code":"EUR30K","quotingUnit":"PER_DAY"},"coverages":[{"coverage":{"code":"CODE1","name":"Asistenciamédicaencasodeenfermedad","order":1.00,"priority":false},"detail":"HastaEUR30.000"},{"coverage":{"code":"CODE2","name":"Asistenciamédicaencasodeaccidente","order":2.00,"priority":false},"detail":"HastaEUR30.000"},{"coverage":{"code":"CODE3","name":"Asistenciamédicaencasodepre-existencia","order":3.00,"priority":false},"detail":"HastaEUR300"},{"coverage":{"code":"CODE4","name":"MedicamentosInternaciónoAmbulatorio","order":4.00,"priority":false},"detail":"HastaEUR1.000"},{"coverage":{"code":"CODE5","name":"Odontología","order":5.00,"priority":false},"detail":"HastaEUR250"},{"coverage":{"code":"CODE6","name":"Díascomplementariosporinternación","order":6.00,"priority":false},"detail":"2días"},{"coverage":{"code":"CODE8","name":"SegurodeAccidentesPersonalesencasodemuerteaccidentalentrasportepúblico","order":8.00,"priority":false},"detail":"HastaUSD60.000"},{"coverage":{"code":"CODE9","name":"Compensaciónporpérdidadeequipajecomplementaria","order":9.00,"priority":false},"detail":"HastaEUR1.200"},{"coverage":{"code":"CODE11","name":"Gastosdehotelporconvalecencia","order":11.00,"priority":false},"detail":"HastaEUR500"},{"coverage":{"code":"CODE12","name":"Gastosdehotelfamiliaracompañante","order":12.00,"priority":false},"detail":"HastaEUR500"},{"coverage":{"code":"CODE13","name":"Anticipodefondosparafianza","order":13.00,"priority":false},"detail":"HastaEUR10.000"},{"coverage":{"code":"CODE14","name":"Transferenciadefondos","order":14.00,"priority":false},"detail":"HastaEUR2.000"},{"coverage":{"code":"CODE16","name":"Garantíagastoscancelación/interrupciónc/restriccióndecausas(h/75años)","order":16.00,"priority":false},"detail":"HastaEUR1.000"},{"coverage":{"code":"CODE17","name":"Localizacióndeequipaje","order":17.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE18","name":"Trasladodefamiliarencasodehospitalización","order":18.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE19","name":"Asistenciaencasodeextravíodedocumentos","order":19.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE20","name":"Acompañamientodemenores","order":20.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE21","name":"Viajederegresoporenfermedaddeltitular","order":21.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE22","name":"Trasladosanitario","order":22.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE23","name":"Repatriaciónsanitaria(incluidodentrodellímitedeasistenciamédica)","order":23.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE24","name":"Trasladoderestos(incluidodentrodellímitedeasistenciamédica)","order":24.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE25","name":"Transmisióndemensajesurgentes","order":25.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE26","name":"Líneadeconsultas24hs","order":26.00,"priority":false},"detail":"Incluido"},{"coverage":{"code":"CODE27","name":"Cúmuloporevento,accidenteconmúltiplesTitulares,aprorrata","order":27.00,"priority":false},"detail":"HastaEUR150.000"}],"insuranceTotalPrices":{"requestedPromotionalPrice":{"beforeTax":233.96,"afterTax":239.01,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":47.41,"name":"IVAGravadoal10.5%","amount":5.05,"code":"GRAVADO105","currencyCode":"ARS"}]},"requestedSellingPrice":{"beforeTax":310.91,"afterTax":324.12,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":124.36,"name":"IVAGravadoal10.5%","amount":13.21,"code":"GRAVADO105","currencyCode":"ARS"}]},"sellingPrice":{"beforeTax":16.00,"afterTax":16.68,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":6.40,"name":"IVAGravadoal10.5%","amount":0.68,"code":"GRAVADO105","currencyCode":"USD"}]},"costPrice":{"beforeTax":9.60,"afterTax":9.60,"currency":"USD","taxes":[]},"currencyConversion":{"rateConversion":19.43,"requestedCurrency":"ARS","sourceCurrency":"USD"},"promotionalPrice":{"beforeTax":12.04,"afterTax":12.30,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":2.44,"name":"IVAGravadoal10.5%","amount":0.26,"code":"GRAVADO105","currencyCode":"USD"}]}},"insurancePassengerPrice":[{"requestedPromotionalPrice":{"beforeTax":116.98,"afterTax":119.50,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":23.71,"name":"IVAGravadoal10.5%","amount":2.53,"code":"GRAVADO105","currencyCode":"ARS"}]},"requestedSellingPrice":{"beforeTax":155.45,"afterTax":162.06,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":62.18,"name":"IVAGravadoal10.5%","amount":6.61,"code":"GRAVADO105","currencyCode":"ARS"}]},"travelerAge":46,"sellingPrice":{"beforeTax":8.00,"afterTax":8.34,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":3.20,"name":"IVAGravadoal10.5%","amount":0.34,"code":"GRAVADO105","currencyCode":"USD"}]},"costPrice":{"beforeTax":4.80,"afterTax":4.80,"currency":"USD","taxes":[]},"currencyConversion":{"rateConversion":19.43,"requestedCurrency":"ARS","sourceCurrency":"USD"},"promotionalPrice":{"beforeTax":6.02,"afterTax":6.15,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":1.22,"name":"IVAGravadoal10.5%","amount":0.13,"code":"GRAVADO105","currencyCode":"USD"}]}},{"requestedPromotionalPrice":{"beforeTax":116.98,"afterTax":119.50,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":23.71,"name":"IVAGravadoal10.5%","amount":2.53,"code":"GRAVADO105","currencyCode":"ARS"}]},"requestedSellingPrice":{"beforeTax":155.45,"afterTax":162.06,"currency":"ARS","taxes":[{"rate":0.105,"baseAmount":62.18,"name":"IVAGravadoal10.5%","amount":6.61,"code":"GRAVADO105","currencyCode":"ARS"}]},"travelerAge":40,"sellingPrice":{"beforeTax":8.00,"afterTax":8.34,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":3.20,"name":"IVAGravadoal10.5%","amount":0.34,"code":"GRAVADO105","currencyCode":"USD"}]},"costPrice":{"beforeTax":4.80,"afterTax":4.80,"currency":"USD","taxes":[]},"currencyConversion":{"rateConversion":19.43,"requestedCurrency":"ARS","sourceCurrency":"USD"},"promotionalPrice":{"beforeTax":6.02,"afterTax":6.15,"currency":"USD","taxes":[{"rate":0.105,"baseAmount":1.22,"name":"IVAGravadoal10.5%","amount":0.13,"code":"GRAVADO105","currencyCode":"USD"}]}}]}]},"audit":{"serverName":"gulliverdesa1","schemaRelease":"2012-05-2.16","productVersion":"master-InternalVersion","serverIp":"10.0.1.38","processTime":3262}}';
     }
     //	Check response
     if (false === $resp && true === Gulliver::$error) {
         return false;
     }
     //	Decode the response
     $response = json_decode($resp, true);
     //	Check for json error
     if (json_last_error() != JSON_ERROR_NONE) {
         return false;
     } else {
         unset($resp);
     }
     if (true == empty($response['data']['success'])) {
         return false;
     }
     //
     self::$response = $response['data'];
     unset($response);
     return true;
 }