<!doctype html>
<html <?php echo get_language_attributes(); ?>>
  <?php echo $__env->make('partials.head', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
  <body <?php body_class('lock') ?>><?php wp_body_open(); ?>

    <div class="loading" id="loading">
      <div class="op-top"></div>
      <div class="op-bottom"></div>
      <div class="loading-logo"><img src="<?= App\asset_path('images/logo.svg'); ?>"></div>
    </div>

    <?php do_action('get_header') ?>
    <?php echo $__env->make('partials.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

    <div id="post-header">
      <header>
        <?php if(has_post_thumbnail()): ?>
        <div class="main-img"><?php the_post_thumbnail(); ?></div>
        <?php else: ?>
        <div class="main-img"><img src="<?= App\asset_path('images/noimage.jpg'); ?>"></div>
        <?php endif; ?>
        <div class="main-text">
          <h2>Works</h2>
          <h1 class="entry-title"><?php echo get_the_title(); ?></h1>
          <div class="mt-5 link"><a href="#entry-content"><img src="<?= App\asset_path('images/works-arrow-down.svg'); ?>"></a></div>
        </div>
      </header>
    </div>
<?php
  $category = get_the_category();
  $cat = $category[0];
  $cat_name = $cat->name;
  $cat_id = $cat->cat_ID;
  $cat_slug = $cat->slug;
?>
    <div class="wrap container" role="document" id="document">
      <div class="content">

        <div class="post-info d-flex flex-wrap align-items-center">
          <?php
          $terms = get_the_terms($query->post->ID, 'pr_cat');
          if( !empty( $terms ) && !is_wp_error( $terms ) ) {
            foreach($terms as $term){ ?>
              <p class="cat mr-1 mr-md-3">
              <?php echo $term_name = $term->name; ?>
              </p>
            <?php }
          }
          ?>
          <div class="sns-share d-flex ml-auto align-items-center">
            <div class="mr-1 mr-md-3">この記事をシェアする：</div>
            <div class="mr-1 mr-md-3"><a class="facebook"  href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/facebook.svg'); ?>" alt="facebook"></a></div>
            <div><a class="twitter" href="javascript:window.open('http://twitter.com/share?text='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/twitter.svg'); ?>" alt="twitter"></a></div>
          </div>
        </div>

        <main class="main">
          <?php while(have_posts()): ?> <?php the_post() ?>
            <?php echo $__env->make('partials.content-single-'.get_post_type(), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
          <?php endwhile; ?>
        </main>

        <div class="sns-share content-footer d-none d-md-flex align-items-center">
          <div>この記事をシェアする：</div>
          <div class="ml-auto"><a href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/facebook.svg'); ?>" alt="facebook"></a></div>
          <div class="ml-1 ml-md-3"><a href="javascript:window.open('http://twitter.com/share?text='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/twitter.svg'); ?>" alt="twitter"></a></div>
        </div>

        <div class="post-info d-flex flex-wrap d-md-none align-items-center">
          <?php
          $terms = get_the_terms($query->post->ID, 'pr_cat');
          if( !empty( $terms ) && !is_wp_error( $terms ) ) {
            foreach($terms as $term){ ?>
              <p class="cat mr-1 mr-md-3">
              <?php echo $term_name = $term->name; ?>
              </p>
            <?php }
          }
          ?>
          <div class="sns-share d-flex ml-auto align-items-center">
            <div class="mr-1 mr-md-3">この記事をシェアする：</div>
            <div class="mr-1 mr-md-3"><a class="facebook"  href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/facebook.svg'); ?>" alt="facebook"></a></div>
            <div><a class="twitter" href="javascript:window.open('http://twitter.com/share?text='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'sharewindow','width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=!');"><img src="<?= App\asset_path('images/twitter.svg'); ?>" alt="twitter"></a></div>
          </div>
        </div>

      </div>
    </div>

    <section class="single-bg-gray">

      <div class="container px-0">
        <h2 class="work-list-title">関連するPR実績 <span>PR実績</span></h2>

          <div class="row pr-movie-list mx-md-0">

            <?php // 現在表示されている投稿と同じタームに分類された投稿を取得
            $taxonomy_slug = 'pr_cat'; // タクソノミーのスラッグを指定
            $post_type_slug = 'pr_movie'; // 投稿タイプのスラッグを指定
            $post_terms = wp_get_object_terms($post->ID, $taxonomy_slug); // タクソノミーの指定
            if( $post_terms && !is_wp_error($post_terms)) { // 値があるときに作動
            $terms_slug = array(); // 配列のセット
            foreach( $post_terms as $value ){ // 配列の作成
            $terms_slug[] = $value->slug; // タームのスラッグを配列に追加
            }
            }
            $args = array(
            'post_type' => $post_type_slug, // 投稿タイプを指定
            'posts_per_page' => 3, // 表示件数を指定
            'orderby' =>  'rand', // ランダムに投稿を取得
            'post__not_in' => array($post->ID), // 現在の投稿を除外
            'tax_query' => array( // タクソノミーパラメーターを使用
            array(
              'taxonomy' => $taxonomy_slug, // タームを取得タクソノミーを指定
              'field' => 'slug', // スラッグに一致するタームを返す
              'terms' => $terms_slug, // タームの配列を指定
            )
            )
            );

  $the_query = new WP_Query($args); if($the_query->have_posts()): ?>
  <?php while ($the_query->have_posts()): $the_query->the_post(); ?>
          <div class="pr-movie-post col-12 col-lg-4">

            <a class="pr-movie-thumb-wrap" href="https://youtu.be/<?php $txt = get_field('youtube_id'); if($txt){?><?php echo $txt; }?>" target="_blank">
              <img class="pr-movie-thumb" src="http://img.youtube.com/vi/<?php $txt = get_field('youtube_id'); if($txt){?><?php echo $txt; }?>/sddefault.jpg">

              <?php
              if ($terms = get_the_terms($term->ID, 'pr_cat')) {
                foreach ( $terms as $term ) {
                  echo '<p class="pr_cat">' .$term->name. '</p>';
                }
              }
              ?>

              <svg id="youtube-icon" xmlns="http://www.w3.org/2000/svg" width="110.122" height="82.593" viewBox="0 0 110.122 82.593">
                <path d="M90,3.845c-16.537-1.129-53.368-1.124-69.882,0C2.239,5.065.133,15.866,0,44.3.133,72.676,2.221,83.523,20.12,84.748c16.518,1.124,53.345,1.129,69.882,0,17.881-1.221,19.987-12.022,20.12-40.452C109.989,15.917,107.9,5.07,90,3.845ZM41.3,62.65V25.943L78,44.264Z" transform="translate(0 -3)" opacity="0.8"/>
              </svg>
            </a>

            <p class="client_name"><?php $txt = get_field('client_name'); if($txt){?><?php echo $txt; }?></p>
            <h3 class="pr-movie-title"><a href="https://youtu.be/<?php $txt = get_field('youtube_id'); if($txt){?><?php echo $txt; }?>" target="_blank"><?php the_title(); ?></a></h3>

          </div>

          <?php endwhile; ?>
          <?php else : ?>
          <p class="no-result">関連するPR実績はまだありません。</p>
          <?php wp_reset_postdata(); ?>
          <?php endif; ?>


        </div>
      </div>


      <div class="container px-0" id="works-list">

        <h2 class="work-list-title">その他の実績 <span>Works</span></h2>

        <div class="d-flex flex-wrap justify-content-between">
<?php
 setup_postdata( $GLOBALS['post'] =& $post_object );
 $args = array(
  'numberposts' => 4, //4件表示(デフォルトは５件)
  'orderby' => 'rand', //ランダム表示
  'post__not_in' => array($post->ID) //表示中の記事を除外
 );
?>
<?php remove_all_filters('posts_orderby'); ?>
<?php $myPosts = get_posts($args); if($myPosts) : ?>
<?php foreach($myPosts as $post_object) : setup_postdata($post_object); ?>

          <div class="post">
            <div class="post-img-wrap">
              <a href="<?php the_permalink() ?>">
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('index_thumbnail'); ?>
<?php else: ?>
                <img src="<?= App\asset_path('images/noimage.jpg'); ?>">
<?php endif; ?>
              </a>
            </div>

            <div>
              <div class="post-info">
                <p class="date"><?php the_time("Y.m.d"); ?></p>
              </div>

              <a href="<?php the_permalink() ?>">
                <h3 class="post-title"><?php the_title(); ?></h3>
              </a>
            </div>

          </div>
  <?php endforeach; ?>
  <?php else : ?>
          <p class="no-result">その他の実績はまだありません。</p>
  <?php endif; wp_reset_postdata(); ?>

        </div>

        <!-- <div>
          <a href="<?php echo e(home_url('/works/#works-list')); ?>">＜ 実績一覧に戻る</a>
        </div> -->
      </div>

    </section>


    <section class="single-info">

      <div class="container d-sp-block sp-contact-title">
        <h3>Contact</h3>
      </div>

      <section id=contact>
        <div class="container">
          <div class="row">
            <div class="col-sm-12 col-md-4">
              <h3>Contact</h3>
            </div>
            <div class="col-sm-12 col-md-8">
              <p class="sub">各種お問い合わせ</p>
              <p class="main">
                まずは<br class="d-pc">お気軽にご連絡ください。
              </p>
              <div class="link d-pc-block">
                <a href="https://bitstar.tokyo/corp/contact" target="_blank" class="rounded-pill">案件のご相談他、各種お問い合わせ</a>
              </div>
              <div class="link d-sp-block">
                <a href="https://bitstar.tokyo/corp/contact" target="_blank" class="rounded-pill">案件のご相談他、各種お問い合わせは<br>こちらから</a>
              </div>
            </div>
          </div>
        </div>
      </section>
      <div class="d-sp-block sp-phone">
        <div class="container">
          <h5>電話でのお問い合わせ</h5>
          <a class="number" href="tel:0345205775">03-4520-5775</a>
          <p class="note">午前10時 〜午後6時<span>平日のみ</span></p>
        </div>
      </div>

      <section id="recruit" class="d-pc-block">
        <div class="container recruit_container">
          <div class="recruit_bg">
            <a href="https://www.wantedly.com/companies/bitstar7?ql=gaJpZM4AeDIj" target="_blank" class="wantedly_link">Wantedlyへ移動する</a>
          </div>
        </div>
      </section>

      <section id="corporate">
        <div class="container">
          <h3>Corporate Profile</h3>
    <?php require_once( dirname( __FILE__ , 6) . '/github/production/corporate_profile.php' ); ?>
          </div>
      </section>

    </section>



    <?php do_action('get_footer') ?>
    <?php echo $__env->make('partials.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php wp_footer() ?>

  </body>
</html>
