<?php

include_once 'casafari.class.php';

//$client_url = 'https://crmapi.proppydev.com';
//$client_secret = 'ZXh0ZXJuYWxkZXY6Rml0aDVmQmRmZ3NkeEhWTUF4aXpkNW9yNjhn';
$client_url = 'https://crmapi.casafaricrm.com';
$client_secret = 'dGVuIEhvb3BlbiAtIENyZWF0aW9uIE1lZGlhOnRlbkhvb3BlbjIwMjQq';

$casafari_api = new CasafariAPI($client_url, $client_secret);

$params = [
    'PropertyIncludes' => [
        'IncludeFeatures' => true,
        'IncludeBrokers' => true,
        'IncludeAgency' => true,
        'UseHtmlDescription' => false
    ],
    'PropertyId' => ($_GET['id'] ?: null),
    'Reference' => ($_GET['reference'] ?: null),
    'BusinessTypeIds' => [
        'Sale'
    ],
    'PropertyTypeIds' => [],
    'Sold' => false,
    //'Featured' => true,
    'VisibleOnWebsite' => true,
    'PriceFrom' => ($_GET['price_from'] ?: null),
    'PriceTo' => ($_GET['price_to'] ?: null),
    'MinBedrooms' => ($_GET['bedrooms'] == 'Studio' ? null : $_GET['bedrooms']),
    'MaxBedrooms' => ($_GET['bedrooms'] != 6 ? ($_GET['bedrooms'] == 'Studio' ? 0 : $_GET['bedrooms']) : null),
    'Lang' => 'en',
    'PropertyListSorts' => [
        'SortBy' => 'DateAsc'
    ],
    'InnertLocations' => [
        'RegionIds' => [],
        'CityIds' => [],
        'LocalityIds' => [],
        'Zonenames' => []
    ],
    'CorrelationId' => 'string',
    'EchoToken' => 'string',
    'PrimaryLangId' => 0,
    'RetransmissionIndicator' => true,
    'TimeStamp' => 'string',
    'Version' => 0
];

$properties_json = $casafari_api->getProperties($params);

$property = $properties_json->PropertyList[0];

//header('Content-type: application/json; charset=utf-8');
//echo json_encode($property);
//echo '<pre>' . print_r($property, true) . '</pre>';

?>




<?php $i=0;foreach($property->photos as $photo) { ?>

    <?php if($i%3==0) { ?>
            
    <div class="elementor-element elementor-element-daf94de elementor-widget elementor-widget-gallery" data-id="daf94de" data-element_type="widget" data-settings="{&quot;gallery_layout&quot;:&quot;masonry&quot;,&quot;columns&quot;:1,&quot;lazyload&quot;:&quot;yes&quot;,&quot;columns_tablet&quot;:1,&quot;columns_mobile&quot;:1,&quot;gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;link_to&quot;:&quot;file&quot;,&quot;overlay_background&quot;:&quot;yes&quot;,&quot;content_hover_animation&quot;:&quot;fade-in&quot;}" data-widget_type="gallery.default">
        <div class="elementor-widget-container">
            <div class="elementor-gallery__container e-gallery-container e-gallery-masonry e-gallery--ltr e-gallery--lazyload" style="--hgap: 10px; --vgap: 10px; --animation-duration: 350ms; --columns: 1; --highest-column-gap-count: 3; padding-bottom: 104.464%;">
                <a class="e-gallery-item elementor-gallery-item elementor-animated-content" href="<?php echo $photo->Url;?>" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="daf94de" data-elementor-lightbox-title="property-photos-1" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6NjExLCJ1cmwiOiJodHRwczpcL1wvbmV3LnRlbmhvb3BlbnJlYWx0eS5jb21cL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMjNcLzA5XC9wcm9wZXJ0eS1waG90b3MtMS5qcGciLCJzbGlkZXNob3ciOiJkYWY5NGRlIn0%3D" style="--item-height: 56.25%; --column: 0; --items-in-column: 0; --percent-height: 0%;">
                    <div class="e-gallery-image elementor-gallery-item__image e-gallery-image-loaded" data-thumbnail="<?php echo $photo->Url;?>" data-width="2410" data-height="1506" aria-label="" role="img" style="background-image: url(&quot;<?php echo $photo->Url;?>&quot;);"></div>
                    <div class="elementor-gallery-item__overlay"></div>
                </a>
            </div>
        </div>
    </div>

    <?php } elseif($i%3==1) { ?>

    <div class="elementor-element elementor-element-daf94de elementor-widget elementor-widget-gallery" data-id="daf94de" data-element_type="widget" data-settings="{&quot;gallery_layout&quot;:&quot;masonry&quot;,&quot;columns&quot;:2,&quot;lazyload&quot;:&quot;yes&quot;,&quot;columns_tablet&quot;:2,&quot;columns_mobile&quot;:1,&quot;gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;link_to&quot;:&quot;file&quot;,&quot;overlay_background&quot;:&quot;yes&quot;,&quot;content_hover_animation&quot;:&quot;fade-in&quot;}" data-widget_type="gallery.default">
        <div class="elementor-widget-container">
            <div class="elementor-gallery__container e-gallery-container e-gallery-masonry e-gallery--ltr e-gallery--lazyload" style="--hgap: 10px; --vgap: 10px; --animation-duration: 350ms; --columns: 2; --highest-column-gap-count: 3; padding-bottom: 104.464%;">
                <a class="e-gallery-item elementor-gallery-item elementor-animated-content" href="<?php echo $photo->Url;?>" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="daf94de" data-elementor-lightbox-title="property-photos-1" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6NjExLCJ1cmwiOiJodHRwczpcL1wvbmV3LnRlbmhvb3BlbnJlYWx0eS5jb21cL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMjNcLzA5XC9wcm9wZXJ0eS1waG90b3MtMS5qcGciLCJzbGlkZXNob3ciOiJkYWY5NGRlIn0%3D" style="--item-height: 56.25%; --column: 0; --items-in-column: 0; --percent-height: 0%;">
                    <div class="e-gallery-image elementor-gallery-item__image e-gallery-image-loaded" data-thumbnail="<?php echo $photo->Url;?>" data-width="1184" data-height="666" aria-label="" role="img" style="background-image: url(&quot;<?php echo $photo->Url;?>&quot;);"></div>
                    <div class="elementor-gallery-item__overlay"></div>
                </a>

    <?php } elseif($i%3==2) { ?>

                <a class="e-gallery-item elementor-gallery-item elementor-animated-content" href="<?php echo $photo->Url;?>" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="daf94de" data-elementor-lightbox-title="property-photos-1" data-e-action-hash="#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6NjExLCJ1cmwiOiJodHRwczpcL1wvbmV3LnRlbmhvb3BlbnJlYWx0eS5jb21cL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMjNcLzA5XC9wcm9wZXJ0eS1waG90b3MtMS5qcGciLCJzbGlkZXNob3ciOiJkYWY5NGRlIn0%3D" style="--item-height: 56.25%; --column: 0; --items-in-column: 0; --percent-height: 0%;">
                    <div class="e-gallery-image elementor-gallery-item__image e-gallery-image-loaded" data-thumbnail="<?php echo $photo->Url;?>" data-width="1184" data-height="666" aria-label="" role="img" style="background-image: url(&quot;<?php echo $photo->Url;?>&quot;);"></div>
                    <div class="elementor-gallery-item__overlay"></div>
                </a>
            </div>
        </div>
    </div>

    <?php } ?>

<?php $i++;} ?>

<?php if($i%3==0) { ?>

            </div>
        </div>
    </div>
    
<?php } ?>

<a class="floating-button" href="#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjU4NSIsInRvZ2dsZSI6ZmFsc2V9">
    ENQUIRE NOW
</a>