# -*- coding: utf-8 -*-

import werkzeug
from odoo import fields, http, _
from odoo.http import request
from datetime import datetime
import json
class WebsiteCountriesController(http.Controller):

    @http.route(['/accommodations/booking/<model("etourism.enterprise"):enterprise>','/accommodations/booking'], type='http', auth="public", website=True)
    def hotels_iframe(self,enterprise=None, **searches):
            #print "ENTERPRISE: ",enterprise
            #print "SEARCHES: ",json.dumps(searches)
            searches.setdefault('default_island', 0)
            searches.setdefault('island', 0)
            values = {
                'checkIn': searches['checkIn'] if 'checkIn' in searches else '',
                'checkOut': searches['checkOut'] if 'checkOut' in searches else '',
                'p_main': '',
                'p_light': '',
                'p_accent': '',
                'default_feature': 0,
                'default_island': searches.get('default_island')
            }
            if enterprise:
                values['enterprise'] = enterprise
                values['method'] = 'Accomodation'
                values['island_id'] = enterprise.island_id
            else:

                Location = request.env['ecom.location']

                island_id = None
                if 'island' in searches and searches['island']:
                    island_id = Location.sudo().search([('id', '=', searches["island"])], limit=1)

                values['method'] = 'Search'
                values['island_id'] = island_id
                values['locked'] = True
            return request.render("website_hotels_iframe.index", values)
