broker_landing_page.php 17.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
<?php
/*
 * Template Name: Broker Landing Page
 */

global $user_ID;
get_currentuserinfo();
if (!$user_ID) {
    auth_redirect();
}

?>
<?php get_header("brokerlanding");
global $wpdb;
$results[] = "";
$brokerId = get_user_meta($current_user->ID, 'broker_id', true);
$menu_name = 'broker-menu'; // specify custom menu slug
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menuCount = count($menu_items);
$menuCount = 12 / $menuCount;
if ($menuCount == '2.4') {
    $menuCount = '5ths';
    $menuLeftCount = 'three5ths';
} else {

    $menuLeftCount = 12 - $menuCount;
}

$colCount = count($results);
$colCount = 12 / $colCount;
if ($colCount == '2.4') {
    $colCount = '5ths';
}

?>
<style>
    #new-footer {
        display: none;
    }

    .col-sm-smallMenu {
        padding-bottom: 0px;
    }
</style>
<div id="brokercontent">
<style>
a[target=_blank] {
    margin-top: -10px !important;
    display: inline-block;
}
</style>

    <div class="row  <?php echo !$results ? 'is-table-row' : '' ?> brokers_background">
        <div class="col-xs-12 col-sm-12 col-md-<?php echo $menuLeftCount; ?> col-lg-<?php echo $menuLeftCount; ?>   no-team-message">
        <?php
echo apply_filters('the_content', get_the_content());
if (1 == 2) {
    foreach ($results as $row) {
        $data = get_user_meta($row->staff_id);
        ?>
                    <div class="col-xs-6 col-sm-<?php echo $colCount; ?> col-md-<?php echo $colCount; ?> col-lg-<?php echo $colCount; ?>">
                        <div class="video-wrapper">
                            <div class="video_container">
                                <?php
if ($data['VideoLink'][0]) {?>

                                    <iframe src="<?php echo $data['VideoLink'][0]; ?>" frameborder="0"></iframe>
                                <?php } elseif ($data['photo'][0]) {
            echo '<img class="user_image" src="' . $data['photo'][0] . '"   />';
        } else {
            echo '<img class="placeholder" src="' . get_template_directory_uri() . '/images/placeholder.png"   />';
        }?>
                            </div>
                        </div>
                        <span class="SSname"><?php echo $data['first_name'][0] ?></span>
                        <span class="SStitle"><?php echo $data['Commonwelltitle'][0] ?></span>
                        <span class="SSmessage">
                            <?php echo wp_trim_words($data['CommonwellPersonalizedMesssage'][0], 17); ?>
                        </span>
                        <span class="SSphone" style="margin-top: 15px;"> <?php if ($data['CommonwellTel'][0]) {?> <i class="material-icons md-18" style="top: 4px;position: relative;">
                                    &#xE61D;</i><a href="tel:<?php echo str_replace(['-', ' '], ['', ''], $data['CommonwellTel'][0]); ?>"> <?php echo $data['CommonwellTel'][0] ?></a> <?php }?></span>

                        <span class="SScontact"> <?php if ($row->mail) {?> <a href="mailto:<?php echo $row->mail; ?>"></a> <?php }?></span>

                        <?php if ($row->messager) {?> <a href=""></a></span><?php }?>
                    </div>
            <?php }
}?>


        </div>

        <div class="col-xs-12 col-sm-12 col-md-<?php echo $menuCount; ?> col-lg-<?php echo $menuCount; ?> notification grad_background">

            <?php

$new_loop = new WP_Query(
    array(
        'post_type' => 'notifications',
        'meta_query' => array(
            array(
                'key' => 'notification_type',
                'value' => 'general',
                'compare' => '=',
            ),
        ),

    )
);
?>
            <div class="slider-wrap">
                <ul class="bxslider2">
                    <?php if ($new_loop->have_posts()): ?>
                        <?php while ($new_loop->have_posts()): $new_loop->the_post();?>
								                            <li <?php post_class();?> id="post-<?php the_ID();?>">
								                                <?php $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'thumbnail');?>
								                                <img src="<?php echo $url ?>" />
								                                <div class="not-body">
								                                    <h5><?php the_title();?></h5>
								                                    <p style="font-size:12px">
								                                        <?php
    if (get_the_excerpt() != '') {
        echo wp_trim_words(get_the_excerpt(), 25);
    } else {
        echo wp_trim_words(get_the_content(), 25);
    }
    ?>
								                    </p>
								                    <button id="read-more" style="width: 100px;cursor: pointer;font-size:10px; margin-left:10px;">[ READ MORE ]</button>
								                    <div id="read-more-dialog" style="display:none;">
								                        <h4 class="dialog_title" style="font-size:18px;"><?php the_title();?></h4>
								                        <span style="font-size:16px;">
								                            <p class="dialog_message" style="font-size:15px;"><?php echo apply_filters('the_content', get_the_content()); ?></p>
								                        </span></p>
								                    </div>
								                </div>
								            </li>

								        <?php endwhile;?>
    </ul><!-- END Blog Roll -->
            </div>
        <?php else: ?>
        <?php endif;?>
        <?php wp_reset_query();?>
        </div>
    </div>
    <div class="row">
        <?php
if (function_exists(clean_custom_menus())) {
    clean_custom_menus();
}
?>
    </div>
</div>
<div  class="new-footer-box">
<div  class="left-image-menu"><a href="<?php echo site_url(); ?>/lets-connect-info/"></a></div>
<?php wp_nav_menu(
    array(
        'theme_location' => 'broker-footer',
        'container' => 'nav',
        'container_id' => 'broker-footer',
    )
);

?>
</div>
<script>
    (function($) {
        jQuery( document ).ready(function( $ ) {
                console.log($.cookie('dialog_cookie_new'));
                if ($.cookie('dialog_cookie_new') == null) {
                    $(window).resize(
                        function() {
                            $(".ui-dialog").position({
                                my: "center",
                                at: "center",
                                of: window
                            });
                        }
                    );



                    $("#dialog").dialog({
                        width: "auto",
                        // maxWidth: 660, // This won't work
                        create: function(event, ui) {
                            // Set maxWidth
                            $(this).css("maxWidth", "516px");
                        },
                        modal: true,
                        position: {
                            my: "center",
                            at: "center",
                            of: window
                        },
                        closeText: "hide",
                        close: function(event, ui) {
                            note_id = document.getElementById("get_note_id").className;
                            note_only_once = document.getElementById("note_only_once").className;
                            if (note_only_once == 'yes') {
                                var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
                                nonce = $(this).attr("data-nonce");
                                $.ajax({
                                    type: "post",
                                    dataType: "json",
                                    url: ajaxurl,
                                    data: {
                                        action: "seen_urgent_note",
                                        note_id: note_id,
                                        nonce: nonce
                                    },
                                    success: function(response) {
                                        if (response.type == "success") {
                                            alert('true')
                                        } else {
                                            alert("false")
                                        }

                                    }
                                });

                            }
                            var date = new Date();
                            var m = 1440;
                            date.setTime(date.getTime() +  (1000 * 60 * 60 * 1));
                            $.cookie('dialog_cookie_new', note_id, {
                                expires: date, path    : '/',
                            })

                        }
                    });
                }

                $('#note_more').click(
                    function() {
                        note_id = document.getElementById("get_note_id").className;
                        note_only_once = document.getElementById("note_only_once").className;
                        if (note_only_once == 'yes') {
                            var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
                            nonce = $(this).attr("data-nonce");
                            $.ajax({
                                type: "post",
                                dataType: "json",
                                url: ajaxurl,
                                data: {
                                    action: "seen_urgent_note",
                                    note_id: note_id,
                                    nonce: nonce
                                },
                                success: function(response) {
                                    if (response.type == "success") {
                                        alert('true')
                                    } else {
                                        alert("false")
                                    }

                                }
                            });
                        }
                        var date = new Date();
                        var m = 1440;
                        date.setTime(date.getTime() +  (1000 * 60 * 60 * 1));
                        $.cookie('dialog_cookie_new', note_id, {
                            expires: date,
                            path    : '/',
                        })

                    }
                );




                // MAKE SURE YOUR SELECTOR MATCHES SOMETHING IN YOUR HTML!!!
                $('#tooltip').tooltipster({
                    content: '<?php echo esc_attr(get_option('broker_info_message')); ?>',
                    contentAsHTML: true,
                    animation: 'grow',
                    interactive: true,
                    maxWidth: 260,
                    minWidth: 260,
                    trigger: 'click',
                    trackOrigin: true,
                    trackTooltip: true,
                    side: 'right',
                    functionPosition: function(instance, helper, position) {
                        position.coord.top -= 70;
                        return position;
                    },
                    functionReady: function(instance, helper) {
                        $(helper.tooltip).addClass('desktop-tooltip');
                        $('#tooltipmobile').tooltipster('open');
                        $(helper.tooltip).append('<a href="#" class="tooltipster-close-button">Tooltip close button</a>');
                        $('.tooltipster-close-button').click(
                            function() {
                                $('#tooltip').tooltipster('close');
                            }
                        );
                    },
                    functionAfter: function() {
                        $('#tooltipmobile').tooltipster('close');
                    }

                });

                $('#tooltipmobile').tooltipster({
                    content: '<?php echo esc_attr(get_option('broker_info_message')); ?>',
                    contentAsHTML: true,
                    animation: 'grow',
                    interactive: true,
                    maxWidth: '95%',
                    minWidth: '95%',
                    trigger: 'click',
                    trackOrigin: true,
                    trackTooltip: true,
                    side: 'bottom',
                    functionReady: function(instance, helper) {
                        $(helper.tooltip).addClass('mobile-tooltip');
                        $('#tooltip').tooltipster('open');
                        $(helper.tooltip).append('<a href="#" class="tooltipster-close-button mobile">Tooltip close button</a>');
                        $('.tooltipster-close-button.mobile').click(
                            function() {
                                $('#tooltipmobile').tooltipster('close');
                            }
                        );
                    },
                    functionAfter: function() {
                        $('#tooltip').tooltipster('close');
                    }
                });

            

                $(window).resize(function() {
                    if ($(this).width() < 701) {
                        setTimeout(function() {
                            var currentIndex = $('.bx-wrapper .bxslider li:visible').index();
                            setSliderControlPosition(currentIndex);
                        }, 100);
                    }
                });

                var smallMenu = jQuery('.col-sm-smallMenu');
                // Change zIndex when a user hovers the side menu
                smallMenu.on('mouseenter', function() {
                    jQuery(this).css('zIndex', 999999);
                });

                smallMenu.on('mouseleave', function() {
                    setTimeout(function() {
                        smallMenu.css('zIndex', 0);
                    }, 500);
                });

                $("#read-more-dialog").dialog({
                    width: "auto",
                    autoOpen: false,
                    // maxWidth: 660, // This won't work
                    create: function(event, ui) {
                        // Set maxWidth
                        $(this).css("maxWidth", "516px");
                    },
                    modal: true,
                    position: {
                        my: "center",
                        at: "center",
                        of: window
                    },
                    closeText: "hide",
                    hide: {
                        effect: "explode",
                        duration: 1000
                    }
        });


        $(document).on('click', '#read-more', function() {
            $("#read-more-dialog").dialog("open");
            $(".ui-dialog-title").hide();
        });

            }
        );

        function setSliderControlPosition(index) {
            var currentItem = $('.bxslider li').eq(index);
            var $wrapper = $(currentItem).find('.video-wrapper');
            var height = $wrapper.height();
            var $sliderControls = $('.slider-controls');
            $sliderControls.height(height);

            var dummyControlPosition = $sliderControls.find('.slider-controls-direction').position().top;
            var dummyPagerPosition = $sliderControls.find('.slider-pager').position().top;
            var $bxControls = $('.bx-controls');
            var $bxControlsDirectionPrev = $bxControls.find('.bx-controls-direction .bx-prev');
            var $bxControlsDirectionNext = $bxControls.find('.bx-controls-direction .bx-next');
            var $bxPager = $('.bx-pager');

            $bxControlsDirectionPrev.css('top', dummyControlPosition);
            $bxControlsDirectionNext.css('top', dummyControlPosition);
            $bxPager.css('top', dummyPagerPosition);
            $bxControls.fadeIn(10);
        }


        


    })(jQuery);
</script>
<?php
$blogtime = current_time('mysql');
$blogtime = list($today_year, $today_month, $today_day) = preg_split('([^0-9])', $blogtime);
$blogtime = $today_year . $today_month . $today_day;

$new_loop = new WP_Query(
    array(
        'post_type' => 'notifications',
        'posts_per_page' => 1,
        'meta_query' => array(
            array(
                'key' => 'notification_type',
                'value' => 'urgent',
                'compare' => '=',
            ),
            array(
                'key' => 'expiry_date',
                'value' => $blogtime,
                'compare' => '>=',
            ),
        ),

    )
);?>

<?php if ($new_loop->have_posts()): ?>
    <?php while ($new_loop->have_posts()): $new_loop->the_post();?>
										        <?php $display_rate = get_post_meta(get_the_ID(), 'display_rate', true);
    $seen_urgent_note = get_user_meta($current_user->ID, 'seen_urgent_note', true);

    if ($display_rate[0] == 'yes' && $seen_urgent_note == get_the_ID()) {} else {;?>

									                                        <div id="dialog" style="display:none;" title="(special announcement) ">
									                                            <input type="hidden" id="get_note_id" class="<?php the_ID();?>">

									                                <input type="hidden" id="note_only_once" class="<?php echo $display_rate[0]; ?>">



									                                <h4 class="dialog_title"><?php the_title();?></h4>
									                                <span style="font-size:10px;">
									                                    <p class="dialog_message"><?php the_excerpt();?></p>
									                                    <a id="note_more" href="<?php the_permalink();?>">[ READ MORE ]</a>
									                                </span></p>
									                            </div>
									                    <?php }
endwhile;?>


<?php else: ?>
<?php endif;?>
<?php wp_reset_query();?>

<?php get_footer();?>