<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\MainCategories */
/* @var $form yii\widgets\ActiveForm */
$lang = Yii::$app->language;

$script =<<< JS

    $( ".popup" ).click(function(){
        var popup = $("#myPopup");
        // console.log(popup.classList);
        popup.toggle("show");
    });
JS;

$this->registerJs($script);

?>




<div class="row main-categories-top">
    <div class="col-xs-12 logo-img">
      <img class="img-responsive img-top" src="<?= Url::base() ?>/<?= $logo ? $logo : 'home-icon/blank-logo.jpg'?>" alt="">   
    </div>
        
            <div class="col-sm-8 col-sm-offset-2 col-xs-10 col-xs-offset-1 contact-top">
                <a href="<?= Url::base()?>/menu/home">
                    <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/home-01.svg" alt=""> 
                </a>
                <a href="<?= Url::base()?>/menu/about">
                    <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/about-01.svg" alt=""> 
                </a>
                <?php if($branches): ?>
                <?php if($branches[0]->location || $branches[0]->english_address || $branches[0]->arabic_address) : ?>
                    <div class="popup">
                    <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/location-01.svg" alt="">
                        <span class="popuptext" id="myPopup">
                            <p class="text-popup"> <?= $lang == 'en' ? $branches[0]->english_address : $branches[0]->arabic_address?></p>
                            <a class="popup-link" href="<?= $branches[0]->location?>" target="_blank"><?= Yii::t('app','Show on Map')?><a>
                        </span>
                    </div>
                <?php endif; ?>
              
                <a href="tel:<?= $branches[0]->phone_num ?>">
                    <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/phone-01.svg" alt="">
                </a>
                <?php if(count($branches) > 1) : ?>
                    <a href="<?= Url::base()?>/menu/branches">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/address-01.svg" alt=""> 
                    </a>
                <?php endif; ?>
                <?php endif; ?>
                <?php if ($twitter_link) : ?>
                    <a href="<?= $twitter_link ?>" target="_blank">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/twitter-01.svg" alt="">
                    </a>
                <?php endif; ?>
                <?php if ($facebook_link) : ?>
                    <a href="<?=  $facebook_link ?>" target="_blank">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/facebook-01.svg" alt="">
                    </a>
                <?php endif; ?>
                <?php if ($instagram_link) : ?>
                    <a href="<?= $instagram_link ?>" target="_blank">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/insta-01.svg" alt="">
                    </a>
                <?php endif; ?>
                <?php if ($whatsapp_link) : ?>
                    <a href="<?= $whatsapp_link ?>" target="_blank">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/whatsapp-01.svg" alt="">
                    </a>
                <?php endif; ?>
                <?php if ($messenger_link) : ?>
                    <a href="<?= $messenger_link ?>" target="_blank">
                        <img class="img-responsive img-social" src="<?= Url::base()?>/home-icon/messenger-01.svg" alt="">
                    </a>
                <?php endif; ?>
                <?= Html::a(
                        Html::img(Url::base() .'/home-icon/'. ($lang == 'ar' ? 'lang-en-01.svg' : 'lang-ar-01.svg'), ['class' => 'img-responsive img-social']),
                        ['/site/change-language', 'lang' => ($lang == 'ar' ? 'en' : 'ar'), 'current_url' => Yii::$app->request->url]
                ) ?>
                
            </div>

            <!-- <div class="col-xs-12">
                <?php if (Yii::$app->controller->action->id == 'items' || Yii::$app->controller->action->id ==  'sub-categories'):?>

                    <nav class="nav-category">
                        <div class="content-nav">
                        <a href="<?= Url::base() ?>/menu/home" class="nav-custom nav-item"><?= Yii::t('app','Home')?><span class="seperator-nav">|</span></a>
                        <?php $categories_count = count($categories) ?>
                        
                        <?php foreach ($categories as $index => $category) : ?>
                            
                            <a href="<?= $category->subCategories ? 'sub-categories?cate_id='.$category->id:'items?cate_id='.$category->id ?>" class="nav-custom nav-item"><?= $lang == 'ar' ? $category->arabic_name : $category->english_name ?><?= ($index == $categories_count - 1 ? '' : '<span class="seperator-nav">|</span>') ?></a>
                        <?php endforeach; ?>
                        </div>
                    </nav>
                <?php elseif (Yii::$app->controller->action->id == 'item'):?>
                    
                    <nav class="nav-item-details">
                        <div class="content-nav">
                            <a href="<?= Url::base() ?>/menu/categories" class="nav-custom nav-item"><?= Yii::t('app','Home')?><span class="seperator-nav">|</span></a>
                            <a href="<?= 'items?cate_id='.$item->mainCategory->id ?>" class="nav-custom nav-item"><?= $lang == 'ar' ? $item->mainCategory->arabic_name :$item->mainCategory->english_name ?><span class="seperator-nav">|</span></a>
                            <p id="item-name" class="nav-custom nav-item"><?= $lang == 'ar' ? $item->mainCategory->arabic_name : $item->mainCategory->english_name ?><span class="seperator-nav">|</span></p>
                        </div>
                    </nav>
                <?php endif;?>
            </div>
    -->
</div>
