<?php if(! defined('ABSPATH')) exit; ?>
<?php $countFiori = count($annuncio['fiori']); ?>
<?php $countOpere = count($annuncio['opereBene']); ?>

<div id="annfu_form_cordoglio_wrapper" class="col-xs-12 col-sm-12 col-md-5">

    <?php if ($annuncio['abilitatoFotoCordogli'] || $annuncio['abilitatoFiori'] || $countOpere > 0): ?>
        <ul id="annfu_tabs" class="nav nav-tabs" role="tablist">
            <li role="presentation" class="nav-item annfu_li_cordoglio">
                <a href="#annfu_form_cordoglio" class="nav-link active" aria-controls="annfu_form_cordoglio" role="tab" data-tab="cordoglio"
                   data-toggle="tab">Lascia un cordoglio</a>
            </li>
            <?php if ($annuncio['abilitatoFotoCordogli']): ?>
                <li role="presentation" class="nav-item annfu_li_foto">
                    <a href="#annfu_form_foto" class="nav-link" aria-controls="annfu_form_foto" role="tab" data-tab="foto"
                       data-toggle="tab">Invia una foto</a>
                </li>
            <?php endif; ?>
            <?php if (filter_var(get_option('annfu_link_fiori', ''), FILTER_VALIDATE_URL)): ?>
                <li class="nav-item annfu_li_fiori">
                    <a href="<?php echo esc_url(get_option('annfu_link_fiori')); ?>" class="nav-link direct_link" target="_blank">Acquista dei fiori</a>
                </li>
            <?php elseif ($template != 'alternativo2' && ($annuncio['abilitatoFiori'] || $countFiori > 0)): ?>
                <li role="presentation" class="nav-item annfu_li_fiori">
                    <a href="#annfu_form_fiori" class="nav-link" aria-controls="annfu_form_fiori" role="tab" data-tab="fiori"
                       data-toggle="tab">Acquista dei fiori</a>
                </li>
            <?php endif; ?>
            <?php if ($countOpere > 0): ?>
                <li role="presentation" class="nav-item annfu_li_donazioni">
                    <a href="#annfu_donazioni" class="nav-link" aria-controls="annfu_donazioni" role="tab" data-tab="donazioni"
                       data-toggle="tab">Donazioni</a>
                </li>
            <?php endif; ?>
        </ul>

        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="annfu_form_cordoglio">
                <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_partecipazioni-cordogli-form.php') ?>
                <?php //if (filter_var(get_option('annfu_link_fiori', ''), FILTER_VALIDATE_URL)): ?>
                    <a href="<?php echo esc_url(get_option('annfu_link_fiori')); ?>" class="annfu_acquista_fiori" target="_blank">
                        <img src="<?php echo esc_html(ANNFU_PLUGIN_URL); ?>img/pagotto/flower.png" /> Acquista dei fiori
                    </a>
                <?php //endif; ?>
            </div>
            <?php if ($annuncio['abilitatoFotoCordogli']): ?>
                <div role="tabpanel" class="tab-pane" id="annfu_form_foto">
                    <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_foto-cordogli-form.php') ?>
                </div>
            <?php endif; ?>
            <?php if ($annuncio['abilitatoFiori'] && $template != 'alternativo2' && $annuncio['onoranzaFunebre']['fiori'] != 3 && $countFiori > 0): ?>
                <div role="tabpanel" class="tab-pane" id="annfu_form_fiori">
                    <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_fiori.php') ?>
                </div>
            <?php endif; ?>
            <?php if ($annuncio['abilitatoFiori'] && $annuncio['onoranzaFunebre']['fiori'] == 3): ?>
                <div role="tabpanel" class="tab-pane" id="annfu_form_fiori">
                    <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_fiori-floremoria.php') ?>
                </div>
            <?php endif; ?>
            <?php if ($countOpere > 0): ?>
                <div role="tabpanel" class="tab-pane" id="annfu_donazioni">
                    <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_donazioni.php') ?>
                </div>
            <?php endif; ?>
        </div>
    <?php else: ?>
        <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_partecipazioni-cordogli-form.php') ?>
    <?php endif; ?>

    <?php include(ANNFU_PLUGIN_PATH_TEMPLATE_DEFAULT . '_testo_fondo_form_cordogli.php') ?>
</div>