<?php
Yii::app()->setLanguage(isset(Yii::app()->session['lang']) ? Yii::app()->session['lang'] : 'ar');
$lang = Yii::app()->getLanguage();
$baseUrl = Yii::app()->getBaseUrl();

?>

<!-- start section1-->
<section class="section1 section1-position">
  <div class="container-fluid">
    <div class="row hidden-xs">
      <div id="myCarousel" data-interval="5000" class="carousel slide homepage-carousel" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <?php
          $j = -1;
          if ($lang == 'ar') {
            $slider = Slider::model()->findByAttributes(array('title' => 'main'));
          } else {
            $slider = Slider::model()->findByAttributes(array('title' => 'main_en'));
          }

          if ($slider != null)
            foreach ($slider->sliderImages as $image) {
              $j++;
          ?>
            <li data-target="#myCarousel" data-slide-to="<?php echo $j; ?>" class="<?php echo ($j == 0 ? "active" : "") ?>"></li>
          <?php } ?>
        </ol>
        <!-- Wrapper for slides -->

        <div class="carousel-inner ">

          <?php
          $i = 0;
          foreach ($slider->sliderImages as $image) {
            $i++;
            if ($image->type == 'image') {
          ?>
              <div class="item <?php echo ($i == 1 ? "active" : "") ?>">
                <img src="<?php echo Yii::app()->request->baseUrl . "/uploads/SliderImages/" . $image->image ?>" alt="slider-img-<?php
                                                                                                                            echo $j; ?>" class="full-width">

              </div>
            <?php } elseif ($image->type == 'video') {
            ?>
              <div class="item" id="video_<?php echo $image->id; ?>">
                <iframe src="https://www.youtube.com/embed/<?php echo $image->link ?>?enablejsapi=1&loop=1&rel=0&showinfo=0" class="video-iframe site-index-iframe-no-overflow" allow="encrypted-media;fullscreen"></iframe>
              </div>
            <?php } elseif ($image->type == 'flash') {
            ?>
              <div class="item">
                <embed src="<?php echo Yii::app()->request->baseUrl . "/uploads/SliderImages/" . $image->image ?>" class="full-width-heigh">
              </div>
          <?php }
          } ?>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
          <img class="icon-slider" src="images/carousel-prev2.png" alt="prev-icon">
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
          <img class="icon-slider" src="images/carousel-next2.png" alt="next-icon">
          <span class="sr-only">Next</span>
        </a>
      </div>
    </div>

    <div class="row hidden-lg hidden-md hidden-sm">
      <div id="myCarouselMobile" data-interval="false" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <?php
          $j = -1;
          if ($lang == 'ar') {
            $slider = Slider::model()->findByAttributes(array('title' => 'main-mobile'));
          } else {
            $slider = Slider::model()->findByAttributes(array('title' => 'main-mobile_en'));
          }

          if ($slider != null)
            foreach ($slider->sliderImages as $image) {
              $j++;
          ?>
            <li data-target="#myCarouselMobile" data-slide-to="<?php echo $j; ?>" class="<?php echo ($j == 1 ? "active" : "") ?>"></li>
          <?php } ?>
        </ol>
        <!-- Wrapper for slides -->
        <div class="carousel-inner ">
          <?php
          $i = 0;

          if ($slider != null)
            foreach ($slider->sliderImages as $image) {
              $i++;
              if ($image->type == 'image') {
          ?>
              <div class="item <?php echo ($i == 1 ? "active" : "") ?>">
                <img src="<?php echo Yii::app()->request->baseUrl . "/uploads/SliderImages/" . $image->image ?>" alt="slider-img-mob-<?php echo $i; ?>" class="full-width">

              </div>

            <?php } elseif ($image->type == 'video') {
            ?>
              <div class="item">
                <iframe src="https://www.youtube.com/embed/<?php echo $image->link ?>" class="video-iframe site-index-iframe" allow="  encrypted-media;fullscreen"></iframe>
              </div>
            <?php } elseif ($image->type == 'flash') {
            ?>
              <div class="item">
                <embed src="<?php echo Yii::app()->request->baseUrl . "/uploads/SliderImages/" . $image->image ?>" class="full-width-heigh">
              </div>
          <?php }
            } ?>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarouselMobile" data-slide="prev">
          <img class="icon-slider" src="images/carousel-prev2.png" alt="prev-icon">
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarouselMobile" data-slide="next">
          <img class="icon-slider" src="images/carousel-next2.png" alt="next-icon">
          <span class="sr-only">Next</span>
        </a>
      </div>
    </div>
  </div>


  <!-- start section2--> 
<section class="section2 flex-item section2-position">
  <div class="container">
    <?php $this->renderPartial('subCategoryServices'); ?>
  </div>
  <!-- end container-->
</section>
<!-- end section2-->


</section>
<!-- end section1-->



<!-- start section3-->
<?php $this->renderPartial('albarakaNews'); ?>
<!-- end section3-->

<!-- start section4-->
<section class="section4">
  <?php $this->renderPartial('article'); ?>
</section>
<!-- end section4-->

<div class="flex-container-index-mobile">
  <!-- start section5-->
  <section class="section5 flex-item">
    <div class="container">
      <div class="row">
        <div class="flex-container">
          <div class="col-sm-6 col-xs-12 flex-item">
            <?php $this->renderPartial('employee'); ?>
          </div>
          <?php $this->renderPartial('prayTime'); ?>
        </div>
      </div>
    </div>
  </section><!-- end section5-->
  
  <!-- start section6-->
  <section class="section6 ltr-direction">
    <div class="container ">
      <div class="owl-carousel">

        <?php
        $section6_menu = Menu::model()->findByAttributes(array('title' => 'section6'));
        if ($section6_menu != null) {
          foreach ($section6_menu->menuItems as $section6) {
            echo '   <div> 
              <div class="service-image">
                  <a href="' . Yii::app()->request->baseUrl . $section6->link . '">
                <img class="img-responsive" src="' . Yii::app()->request->baseUrl . '/uploads/MenuItem/' . $section6->image . '" alt="' . ($lang == 'ar' ? $section6->title : $section6->en_title) . '">
                  <div class="icon-text text-center">' .
              ($lang == 'ar' ? $section6->title : $section6->en_title)
              . '
                    </div>
                  </a> 
              </div>
              </div>';
          }
        }
        ?>

      </div>
    </div>
  </section>
  <!-- end section6-->

  <!-- start section7-->
  <section class="section7">
    <div class="container">
      <div class="flex-container ">
        <div class=" col-md-8  col-sm-12 col-xs-12  border-container ">
          <div class="row-left">
            <div class="col-xs-12 col-sm-4 ">
              <div class="row-right">
                <?php $this->renderPartial('governorate'); ?>
              </div>
            </div>
            <div class="col-xs-12 col-sm-8 ">
              <div class="row-left">
                <div id="map"></div>
              </div>
            </div>
          </div>
        </div>
        <!---->
        <?php $this->renderPartial('currencySection'); ?>
        <!---->
      </div>

      <!--MY MODAL-->
      <?php
      $questionnaire = Questionnaire::model()->findByAttributes(array('featured' => '1'));
      if (!empty($questionnaire)) {
      ?>
        <div class="col-lg-hidden">
          <div id="myModal" class="modal fade" role="dialog">
            <div class="modal-dialog">
              <!--Modal content-->
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body" id="getCode">
                  <?php
                  echo '<a href="' . Yii::app()->request->baseUrl . '/site/questionnaire/' . $questionnaire->id . '" >' . $questionnaire->title . '</a>';
                  ?>
                </div>
                <div class="modal-footer">
                  <a type="button" href="<?php echo Yii::app()->request->baseUrl . '/site/questionnaire/' . $questionnaire->id ?>" class="btn btn-default"><?php echo ($lang == 'ar' ? 'تعبئة الاستبيان' : 'Fill Questionnaire') ?></a>
                  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo ($lang == 'ar' ? 'اغلاق' : 'Close') ?></button>
                </div>
              </div>
            </div>
          </div>
        </div>
      <?php } ?>
      <!--END MY MODAL-->


  </section>
</div>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/owl.carousel.min.js"></script>
<script type="application/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/site/scriptIndex"></script>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/youtube_iframe_api.min.js"></script>