<?php
$optres['css'][] = $module_css_path . 'amodules/events_ext_side/css/events_side.css';
$optres['js'][] = $path . "amodules/events_ext_side/js/events_side_main.js";
$def_event_srch = array(
    'event_category' => '',
    'event_location' => '',
    'event_period' => '',
    'event_keyword' => '',
    'i_limit' => 10
);

if(!isset($event_srch)) {
    $event_srch = $def_event_srch;
}
else {
    $event_srch = array_merge($def_event_srch, $event_srch);
}

//echo '<pre>$event_srch = ', var_export($event_srch, true), '</pre>';
?>


<div class="row">
    <div class="col-sm-10">

        <form method="post" action="events/" name="side_events_search_frm" id="side_events_search_frm" class="form-horizontal" role="form">
            <section class="evsrch_container box box-srch-side">
                <div class="box-header">
                        <b><i class="fa fa-search fa-fw fa-lg"></i> Search Events</b>

                </div>

                <div class="box-body">

                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-10">
                                <div class="form-group">
                                    <label class="control-label sr-only" for="event_category_side"><?php echo 'Event Category';?></label>
                                    <select name="event_srch[event_category]" id="event_category_side" class=" event-side-selectbox show-menu-arrow form-control input-sm" data-title="All Categories">
                                        <option value="" <?php echo ($event_srch['event_category'] == '' ? 'selected="selected"' : '');?>><?php echo 'All Categories';?></option>
                                        <?php
                                        $all_event_categs = $events_config['categories'];
                                        foreach ($all_event_categs as $gr_id => $gr_data){
                                            $categ_code = $gr_id;
                                            $selected = '';
                                            if($event_srch['event_category'] == $categ_code) $selected = ' selected="selected"';
                                            echo '<option value="',$categ_code,'" ',$selected,' class="event-category-group">', $gr_data['title'], '</option>';
                                            if(count($gr_data['subs']) > 0) {
                                                foreach($gr_data['subs'] as $cat_id=>$cat_title) {
                                                    $categ_code = $gr_id . '-' . $cat_id;
                                                    $selected = '';
                                                    if($event_srch['event_category'] == $categ_code) $selected = ' selected="selected"';
                                                    echo '<option value="',$categ_code,'" ',$selected,' class="event-category-opt">', $cat_title, '</option>';
                                                }
                                            }
                                        }

                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-10">
                                <div class="form-group">
                                    <label class="control-label sr-only" for="event_location_side"><?php echo 'All Cyprus';?></label>
                                    <select name="event_srch[event_location]" id="event_location_side" class=" event-side-selectbox show-menu-arrow form-control input-sm" data-title="All Cyprus">

                                        <?php
                                        $locations = $events_config['locations'];
                                        foreach ($locations as $dcode=>$loc) {
                                            $selected = '';
                                            if($event_srch['event_location'] == $dcode) $selected = 'selected="selected"';
                                            echo '<option value="',$dcode,'" ',$selected,'>', $loc['title'], '</option>';
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-10">
                                <div class="form-group">
                                    <label class="control-label sr-only" for="event_period_side"><?php echo 'Period';?></label>
                                    <select name="event_srch[event_period]" id="event_period_side" class=" event-side-selectbox show-menu-arrow form-control input-sm" data-title="All Future Events">
                                        <option value="" selected="selected">All Future Events</option>
                                        <?php
                                        $posted_vals = array(
                                            'today' => 'Today',
                                            'tomorrow' => 'Tomorrow',
                                            'next7days'	=> 'Next 7 Days',
                                            'next30days'=> 'Next 30 Days',
                                            'next60days'=> 'Next 60 Days'

                                        );

                                        foreach ($posted_vals as $pv=>$pv_title) {
                                            $selected = '';
                                            if(isset($event_srch['event_period']) && $event_srch['event_period'] != "all" && $event_srch['event_period'] == $pv) $selected = 'selected="selected"';
                                            echo '<option value="',$pv,'" ',$selected,'>', $pv_title, '</option>';
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-10">
                                <div class="form-group">
                                    <label class="control-label sr-only" for="event_keyword_side"><?php echo 'Keyword';?></label>
                                    <input type="text" value="<?=$event_srch['event_keyword'];?>" placeholder="Keyword" name="event_srch[event_keyword]" id="event_keyword_side" class="form-control input-sm">

                                </div>
                            </div>
                        </div>

                    </div>




                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-10 text-left">
                                <div class="form-group">
                                    <button type="submit" class="load-disabled btn btn-red btn-sm pull-left" disabled="disabled"><i class="fa fa-search fa-lg fa-spin"></i> Search</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <input type="hidden" name="event_srch[i_limit]" value="10">
                <input type="hidden" name="event_srch[i_from]" value="0">
                <input type="hidden" name="module_page" value="events_ext">
                <input type="hidden" name="events_url" value="event"/>
                <input type="hidden" name="event_srch[display]" value="yes"/>
                <input type="hidden" name="domain_id" value="<?=$domain_id;?>"/>

            </section>
        </form>
    </div>
    <div class="col-sm-10">
        <div class="evsrch_container box box-srch-side past-box">
            <div class="box-body">
                <a href="<?=$full_addon_uri;?>past-events" class="past-link" title="Cyprus Past Events"><i class="fa fa-history fa-lg"></i> Past Events</a>
            </div>
        </div>

    </div>

    <?php
    if(isset($show_events_ext_side) && $show_events_ext_side == true) {
        ?>
        <div class="col-sm-10">
            <!--inject_found_events_category_list-->
        </div>
        <?php
    }
    ?>

</div>