 <?php
    $lang = Yii::app()->getLanguage();
    ?>

 <nav class=" navbar-mobile hidden-lg hidden-md hidden-sm">
     <div class="container-fluid">
         <div class="row">
            <div class="col-xs-6"></div>    
         
            <div class="logo-image-container">
                 <a href="<?php echo Yii::app()->request->baseUrl ?>">
                    <?php if(Yii::app()->language == 'ar'): ?>
                        <img itemprop="logo" class="img-logo img-responsive center-block logo-image" src="<?php echo Yii::app()->request->baseUrl ?>/images/logo.png" alt="img-logo"></a>
                    <?php else: ?>
                        <img itemprop="logo" class="img-logo img-responsive center-block logo-image-english" src="<?php echo Yii::app()->request->baseUrl ?>/images/logo-en.png" alt="img-logo"></a>
                    <?php endif; ?>
             </div>

             <!-- start calculator  -->
             <div class="  col-xs-2 mobile-share-menu mobile-menu-calculator">

                 <div class="dropdown">
                     <!-- <a href="#" class="dropdown-toggle  " data-toggle="dropdown" > -->
                     <a href="<?php echo Yii::app()->request->baseUrl ?>/site/calculator?active=1">
                         <img class="img-responsive mobile-share-icon" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-red-7.png" alt="calculator-icon">
                     </a>
                 </div>

             </div>
             <!-- end calculator -->
             <!-- start social media -->
             <div class="  col-xs-2 mobile-share-menu mobile-menu-calculator">
                 <div class="row">
                     <div class="dropdown">
                         <a href="#" class="dropdown-toggle  " data-toggle="dropdown">
                             <img class="img-responsive mobile-share-icon" src="<?php echo Yii::app()->request->baseUrl ?>/images/share-icon-mobile.png" alt="share-icon">
                         </a>

                         <ul class="dropdown-menu  ">
                             <li>
                                 <a class="icon-social" href=" <?php $telegram_page = Option::model()->findByAttributes(array('key' => 'TELEGRAM'));
                                                                echo $telegram_page != Null ? $telegram_page->value : "#"; ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-1-gray.png" alt="icon-share">
                                 </a>
                             </li>
                             <li>
                                 <a class="icon-social" href=" <?php $telegram_page = Option::model()->findByAttributes(array('key' => 'YOUTUBE_PAGE'));
                                                                echo $telegram_page != Null ? $telegram_page->value : "#"; ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-2-gray.png" alt="icon-youtube">
                                 </a>
                             </li>
                             <li>
                                 <a class="icon-social" href=" <?php $telegram_page = Option::model()->findByAttributes(array('key' => 'INSTGRAM_PAGE'));
                                                                echo $telegram_page != Null ? $telegram_page->value : "#"; ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-3-gray.png" alt="icon-instagram">
                                 </a>
                             </li>
                             <li>
                                 <a class="icon-social" href=" <?php $telegram_page = Option::model()->findByAttributes(array('key' => 'FACEBOOK_PAGE'));
                                                                echo $telegram_page != Null ? $telegram_page->value : "#"; ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-4-gray.png" alt="icon-facebook">
                                 </a>
                             </li>

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


             </div>
             <!-- end social media -->

             <div class="col-xs-2 text-left">
                 <div class="row mobile-menu-style">
                     <ul class="  mobile_menu">
                         <li class="search-form">
                             <form class="navbar-form navbar-right" action="<?php echo Yii::app()->request->baseUrl; ?>/site/siteSearch" method="post">
                                 <div class="form-group">
                                     <input class="form-control search-box-nav" placeholder="<?php echo ($lang == 'en' ? 'Search' : 'أدخل كلمة البحث  ...') ?>">
                                     <button type="submit" class="btn btn-default search-btn-nav">
                                         <img class="img-responsive img-search-icon" src="<?php echo Yii::app()->request->baseUrl; ?>/images/searchicon.png" alt="search-icon-img">
                                     </button>
                                 </div>
                             </form>

                         </li>

                         <li class="search-form">

                             <div class="form-group">
                                 <input id="doc_num2" class="form-control search-box-nav" placeholder="<?php echo ($lang == 'en' ? 'Check Document' : 'أدخل رقم الوثيقة للتحقق منها') ?>">
                                 <button id="doc_btn" class="btn btn-default search-btn-nav">
                                     <img class="img-responsive img-search-icon" src="<?php echo Yii::app()->request->baseUrl; ?>/images/checkicon.png" alt="search-icon-img">
                                 </button>
                             </div>

                         </li>

                         <?php

                            $main_menu = Menu::model()->findByAttributes(array('title' => 'main'));
                            if ($main_menu != null) {
                                $st = 0;

                                foreach ($main_menu->menuItemsFirstLevel as $item) {
                                    $sub = $item->menuItems;
                                    echo '
                                          <li data-backgroundColor="#f7f7f7" data-HeadColor="#f7f7f7" data-borderColor="#f7f7f7">
                                          <a href="' . ((substr($item->link, 0, 4) === "http") ? $item->link : ('#menu' . $item->id)) . '">
                                        <!-- caret for links with sub menu -->
                                        ' . ((sizeof($sub) > 0) ? ' <span><img class="img-caret-mob" src="' . Yii::app()->request->baseUrl . '/images/caret-mob-black.png" alt="list-icon-img"></span> ' : "") . ($lang == 'en' ? $item->en_title : $item->title) . '</a>';


                                    if (sizeof($sub) > 0) {
                                        echo '<ul class="submenu">';
                                        foreach ($sub as $sub_item) {
                                            $third_item = $sub_item->menuItems;

                                            $link = ($sub_item->link == "#" || $sub_item->link == "") ? "#" : ((substr($sub_item->link, 0, 4) === "http") ? $sub_item->link : Yii::app()->request->baseUrl . $sub_item->link);

                                            echo '<li><a href="' . $link . '">' . ((sizeof($third_item) > 0) ? ' <span><img class="img-caret-mob" src="' . Yii::app()->request->baseUrl . '/images/caret-mob-black.png" alt="list-icon-img"></span> ' : "") . ($lang == 'en' ? $sub_item->en_title : $sub_item->title) . '</a>';
                                            if (sizeof($third_item) > 0) {
                                                echo '<ul class="submenu">';
                                                foreach ($third_item as $third_menu_item) {
                                                    echo '<li><a href="' . ((substr($third_menu_item->link, 0, 4) === "http") ? $third_menu_item->link : (Yii::app()->request->baseUrl . $third_menu_item->link)) . '">' . ($lang == 'en' ? $third_menu_item->en_title : $third_menu_item->title) . '</a></li>';
                                                }
                                                echo '</ul>';
                                            }
                                            echo '</li>';
                                        }
                                        echo '</ul>';
                                    }
                                    echo '</li>';
                                    $st++;
                                }
                            } ?>
                         <!-- social media design should be in every sub menu -->
                         <li><a href="<?php echo Yii::app()->request->baseUrl ?>/site/suggestion"><?php echo ($lang == 'en' ? 'Complaints and Suggestions' : 'شكاوي ومقترحات') ?></a></li>
                         <li><a href="<?php echo Yii::app()->request->baseUrl ?>/site/calculator?active=1"><?php echo ($lang == "ar" ? "احتساب التمويل" : "Financial calculator") ?></a></li>
                         <li><a href="<?php echo Yii::app()->request->baseUrl ?>/site/calculator?active=2"><?php echo ($lang == "ar" ? "احتساب الأرباح" : "Profits calculator") ?></a></li>
                         <?php
                            $header_menu = Menu::model()->findByAttributes(array('title' => 'header'));
                            if ($header_menu != null) {
                                foreach ($header_menu->menuItems as $item) {
                                    echo '<li>
                                        <a  href="' . ((substr($item->link, 0, 4) === "http") ? $item->link : (Yii::app()->request->baseUrl . $item->link)) . '">
                                       ' . ($lang == "en" ? $item->en_title : $item->title) . '
                                        </a>  
                                        </li>';
                                }
                            }
                            ?>
                         <?php $currpage = strpos(Yii::app()->request->url, '?lang') ? (substr(Yii::app()->request->url, 0, strpos(Yii::app()->request->url, '?lang'))) : (Yii::app()->request->url); ?>
                         <?php echo '
							<li><a href="' . Yii::app()->request->baseUrl . '/site/setLanguage?lang=ar&currpage=' . $currpage . '">AR</a></li> 
				
							<li><a href="' . Yii::app()->request->baseUrl . '/site/setLanguage?lang=en&currpage=' . $currpage . '">EN</a></li>
							'; ?>

                         <li class="social-media">
                             <a class="icon-social" href=" <?php $telegram_page = Option::model()->findByAttributes(array('key' => 'TELEGRAM'));
                                                            echo $telegram_page != Null ? $telegram_page->value : "#"; ?>">
                                 <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-1-gray.png" alt="icon-share">
                             </a>
                             <a class="icon-social" href="<?php $twitter_page = Option::model()->findByAttributes(array('key' => 'YOUTUBE_PAGE'));
                                                            echo ($twitter_page != Null ? $twitter_page->value : '#'); ?>">
                                 <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-2-gray.png" alt="icon-youtube">
                             </a>
                             <a class="icon-social" href="<?php $twitter_page = Option::model()->findByAttributes(array('key' => 'INSTGRAM_PAGE'));
                                                            echo ($twitter_page != Null ? $twitter_page->value : '#'); ?>">
                                 <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-3-gray.png" alt="icon-instagram">
                             </a>
                             <a class="icon-social" href="<?php $twitter_page = Option::model()->findByAttributes(array('key' => 'FACEBOOK_PAGE'));
                                                            echo ($twitter_page != Null ? $twitter_page->value : '#'); ?>">
                                 <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/icon-social-mob-4-gray.png" alt="icon-facebook">
                             </a>

                         </li>
                         <!--monile app-->
                         <li class="social-media">
                             <?php $twitter_page = Option::model()->findByAttributes(array('key' => 'ANDROID_APP')); ?>
                             <?php if ($twitter_page != null && ($twitter_page->value != "" && $twitter_page->value != "#")) { ?>
                                 <a class="icon-social" href="<?php
                                                                echo ($twitter_page != Null ? $twitter_page->value : '#'); ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/android.png" alt="ANDROID_APP">
                                 </a>
                             <?php } ?>
                             <?php $twitter_page = Option::model()->findByAttributes(array('key' => 'IOS_APP')); ?>
                             <?php if ($twitter_page != null && ($twitter_page->value != "" && $twitter_page->value != "#")) { ?>
                                 <a class="icon-social" href="<?php
                                                                echo ($twitter_page != Null ? $twitter_page->value : '#'); ?>">
                                     <img class="img-social" src="<?php echo Yii::app()->request->baseUrl ?>/images/apple.png" alt="ANDROID_APP">
                                 </a>
                             <?php } ?>
                         </li>

                     </ul>
                 </div>
             </div>
         </div>
     </div>
 </nav>

 <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/script.js"></script>