<?php
	include("../init1_db.php");

$PAGE_TITLE = "山梨県内ニュース（動画）";
$index_flag = 1 ;

$DEBUG = 1;	// 0:デバック

$wheresql		= 	" where news_disp_flag = 1 and ( ( news_flag10 = 1 ) or ( news_start_date is null or ( news_flag10=1 or ( news_start_date <= '$cond4' and news_end_date >= '$cond4' ) ) ) ) ";
$wheresql		.= 	" and news_flag5=0 " ;
//$wk_fieldname2	=	" news_rsv3 desc , news_no desc , news_id";
$wk_fieldname2	=	" news_rsv3 desc , news_rsv4 , news_img1 desc , news_id";

$target_date	=	"" ;

// パラメータ取得
$no	=	func_sanitaze( func_parm_get( 'no' ) , 2 ) ;
$d	=	func_sanitaze( func_parm_get( 'd' ) , 2 ) ;
if( is_numeric( $d ) && $d && strlen( $d )==8 )
	$target_date	=	substr( $d , 0 , 4 )."/".substr( $d , 4 , 2 )."/".substr( $d , 6 , 2 ) ;

$tab_no			=	99 ;
$wk_news_name	=	"" ;
if( $no && is_numeric( $no ) )
{
	$stmt = "SELECT ";
	$stmt .= "news_id , " ;
	$stmt .= "news_name , " ;
	$stmt .= "news_memo2 , " ;
	$stmt .= "news_memo3 , " ;
	$stmt .= "news_memo4 , " ;
	$stmt .= "news_memo6 , " ;
	$stmt .= "news_img1 , " ;
	$stmt .= "news_img2 , " ;
	$stmt .= "news_pdf1 , " ;
	$stmt .= "news_pdf2 , " ;
	$stmt .= "news_pdf_title1 , " ;
	$stmt .= "news_pdf_title2 , " ;
	$stmt .= "news_flag1 , " ;
	$stmt .= "news_rand , " ;
	$stmt .= "news_date1 , ";
	$stmt .= "news_rsv3 , " ;
	$stmt .= "news_rsv4 " ;
	$stmt .= "FROM t_news $wheresql and " ;
	$stmt .= "news_memo3<>'' and " ;
	$stmt .= "news_id=" ;
	$stmt .= $no ;
	$sth = dbRunSql( $stmt ) ;
	$j = @mysqli_num_rows ( $sth ) ;
	if( $j > 0 )
	{
		$data	= mysqli_fetch_array( $sth , MYSQLI_ASSOC ) ;
		$wk_news_name	=	( $data['news_memo6'] ? $data['news_memo6'] : $data['news_name'] ) ;
		$target_date	=	$data['news_date1'] ;
	}
	else
		$no		=	0 ;
	$rinf = dbFreeResult( $sth ) ;
}

if( !$wk_news_name )
{
	mysqli_close( $dbh ) ;
	header("Location: /news/");
	exit();
}

// 今日
$now_y	=	substr( $cond , 0 , 4 ) ;
$now_m	=	(int)substr( $cond , 5 , 2 ) ;
$now_d	=	(int)substr( $cond , 8 , 2 ) ;
$wk		=	date( "w" , mktime( 0 , 0 , 0 , $now_m , $now_d, $now_y ) ) ;
$now_w	=	$DEF_YOUBI[$wk] ;

// 最新日付取得
$wk	=	"" ;
$stmt = "SELECT ";
$stmt .= "news_rsv3 ";
$stmt .= "FROM t_news $wheresql order by $wk_fieldname2 " ;
$stmt .= "limit 1" ;
$sth = dbRunSql( $stmt ) ;
$j = @mysqli_num_rows ( $sth ) ;
if( $j > 0 )
{
	$row	=	mysqli_fetch_object( $sth ) ;
	$wk	=	$row->news_rsv3 ;
	unset( $row ) ;
}
$rinf = dbFreeResult( $sth ) ;
if( $wk )
{
	$wk_y	=	substr( $wk , 0 , 4 ) ;
	$wk_m	=	substr( $wk , 5 , 2 ) ;
	$wk_d	=	substr( $wk , 8 , 2 ) ;
}
else
{
	$wk_y	=	$now_y ;
	$wk_m	=	$now_m ;
	$wk_d	=	$now_d ;
}
$before7	=	date( "Y/m/d" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - 6 , $wk_y ) ) ;


// 日付配列
$arr_date	=	array() ;

if( $target_date && $before7 > $target_date )
{
	$wk_y	=	substr( $target_date , 0 , 4 ) ;
	$wk_m	=	substr( $target_date , 5 , 2 ) ;
	$wk_d	=	substr( $target_date , 8 , 2 ) ;
	$wk	=	date( "Y/m/d" , mktime( 0 , 0 , 0 , $wk_m , $wk_d + 6 , $wk_y ) ) ;
	$wk_y	=	substr( $wk , 0 , 4 ) ;
	$wk_m	=	substr( $wk , 5 , 2 ) ;
	$wk_d	=	substr( $wk , 8 , 2 ) ;
}
for( $i=0 ; $i<7 ; $i++ )
{
	$arr_date[$i]['date']	=	date( "Y/m/d" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - $i , $wk_y ) ) ;
	$arr_date[$i]['year']	=	date( "Y" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - $i , $wk_y ) ) ;
	$arr_date[$i]['mon']	=	date( "m" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - $i , $wk_y ) ) ;
	$arr_date[$i]['day']	=	date( "d" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - $i , $wk_y ) ) ;
	$wk	=	date( "w" , mktime( 0 , 0 , 0 , $wk_m , $wk_d - $i , $wk_y ) ) ;
	$arr_date[$i]['week']	=	$DEF_YOUBI[$wk] ;
	if( $target_date==$arr_date[$i]['date'] )
		$tab_no		=	$i ;
}
if( $tab_no==99 )
{
	$no			=	0 ;
	$tab_no		=	0 ;
}
$target_date	=	$arr_date[$tab_no]['date'] ;
$target_date_y	=	$arr_date[$tab_no]['year']  ;
$target_date_m	=	$arr_date[$tab_no]['mon']  ;
$target_date_d	=	$arr_date[$tab_no]['day']  ;
$target_date_w	=	$arr_date[$tab_no]['week']  ;


$CHAR_KEYWORD		=	"山梨県,ニュース,動画,速報,報道" ;

$url		=	"" ;
$wk_memo	=	"" ;
if( $wk_news_name )
{
	$PAGE_TITLE			=	$wk_news_name."（動画）" ;
	$wk_memo			=	strip_tags( func_non_entity( $wk_news_memo2 ) ) ;
	$wk_memo			=	str_replace( array( "\r\n", "\n", "\r" ) , "", $wk_memo ) ;
	$CHAR_DESCRIPTION	=	$wk_news_name."ニュース動画。".mb_strimbyte( $wk_memo , 0, 200, "..." , "utf-8" );

	$url		=	$HOME_URL."news/video/".str_replace( "/" , "" , $target_date )."/".$no."/" ;
}
else
{
//	$CHAR_DESCRIPTION	=	"山梨県内のニュース速報を毎日配信しております。スゴろくニュースの送時間の告知。また皆様からの投稿も受付ております。" ;
	$CHAR_DESCRIPTION	=	"山梨県内の最新ニュースを毎日配信しております。また皆様からのニュースの投稿も受付けております。" ;
}
?>

<!doctype html>
<html class="no-js" lang="ja">
    <head>
        <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="format-detection" content="telephone=no" />
<meta name="robots" content="INDEX,FOLLOW" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="Keywords" content="<?php print $CHAR_KEYWORD;?>" />
<meta name="Description" content="<?php print ( $wk_memo ? $wk_memo : $CHAR_DESCRIPTION ) ;?>" />
<?php
if( $wk_memo )
{
?>
<meta property="og:title" content="<?php print $wk_news_name ; ?>（動画）" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php print $url ; ?>" />
<meta property="og:image" content="<?php print ( $data['news_img1'] ? "https://www.uty.co.jp/up_img/news/".$data['news_rand']."/".$data['news_img1'] : "https://www.uty.co.jp/common/images/news.jpg" ) ; ?>" />
<meta property="og:description" content="<?php print ( $wk_memo ? $wk_memo : $CHAR_DESCRIPTION ) ;?>" />
<meta property="og:site_name" content="<?php print $SITE_NAME ; ?>" />
<?php
}
?>
<meta http-equiv="expires" content="sat, 1 Jan 2000 00:00:00 GMT" />
<meta http-equiv="cache-control" content="no-store, no-cache, must-revalidate, max-age=0" />
<meta http-equiv="cache-control" content="post-check=0, pre-check=0" />
<meta http-equiv="pragma" content="no-cache" />
<title><?php print $PAGE_TITLE." | ".$SITE_NAME; ?></title>
<link rel="shortcut icon" href="<?php print $CHAR_FAVICON;?>" />
<base href="<?php print $HOME_URL ; ?>news/">

		<!-- ========================= CSS here ========================= -->
		<link rel="stylesheet" href="../css/bootstrap-5.0.0-alpha-1.min.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
        <link rel="stylesheet" href="../css/LineIcons.2.0.css">
		<link rel="stylesheet" href="../css/animate.css">
		<link rel="stylesheet" href="../css/slider-pro.css">
		<link rel="stylesheet" href="../assets/js/slick/slick-theme.css">
		<link rel="stylesheet" href="../assets/js/slick/slick.css">
		<link rel="stylesheet" href="../css/main.css">
<?php
if( $DEBUG )
{
	include("../common/accesslog.php");
}
?>
    </head>
    <body class="subbody" oncontextmenu="return false;">
        <!--[if lte IE 9]>
            <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
        <![endif]-->
<?php include("../common/header.php"); ?>

        <div class="sub_main">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="../">TOP</a></li>
            <li class="breadcrumb-item"><a href="./">山梨県内ニュース</a></li>
<?php
if( $wk_news_name )
{
?>
            <li class="breadcrumb-item"><a href="/news/<?php print str_replace( "/" , "" , $target_date )."/".$no."/" ; ?>"><?php print $wk_news_name ; ?></a></li>
<?php
}
?>
            <li class="breadcrumb-item active" aria-current="page"><?php print $PAGE_TITLE ; ?></li>
          </ol>
        </nav>
        <section class="module">
            <div class="container">
                <div class="row">
                   
                    <div class="col-lg-8 col-xl-9">
                    <div class="h2_title"><img src="../images/news/main.jpg" alt="<?php print $PAGE_TITLE ; ?>" class="img-responsive"></div>

<?php
if( $data['news_memo3'] )
{
				$class	=	"" ;
				if( $data['news_flag1'] )
					$class	=	( $data['news_flag1']==5 ? "flag13" : "flag".sprintf( "%02d" , $data['news_flag1'] ) ) ;
				else
					$class	=	"flag04" ;

				$wk		=	str_replace( "https://youtu.be/" , "" , $data['news_memo3'] ) ;
?>
                    <div class="news_detail">
                        <h3 class="news_title"><img src="../images/sub/icon2.svg" width="25"><?php print $PAGE_TITLE ; ?></h3>
                        <p class="date <?php print $class ; ?>"><?php print str_replace( "/" , "." , substr( $data['news_rsv3'] , 0 , 10 ) ) ; ?><span class="time"><?php print substr( $data['news_rsv3'] , 11 , 5 ) ; ?></span></p>
                        <div class="movie-wrap">
						<iframe width="854" height="480" src="https://www.youtube.com/embed/<?php print $wk ; ?>?wmode=transparent&rel=0" frameborder="0" allowfullscreen></iframe>
                        </div>
                        <div class="links">
                            <a href="/news/<?php print str_replace( "/" , "" , $target_date )."/".$no."/" ; ?>" class="underline">この動画の記事を読む</a>
                        </div>

                        <div class="arrow">
<?php
							$wk_fieldname3	=	" news_rsv3 desc , news_rsv4 desc , news_img1 , news_id desc";
							$stmt = "SELECT ";
							$stmt .= "news_id , ";
							$stmt .= "news_date1 ";
							$stmt .= "FROM t_news $wheresql and news_jump_url like '' and news_date1 like '" ;
							$stmt .= $target_date ;
							$stmt .= "' and news_rsv4 < '" ;
							$stmt .= $data['news_rsv4'] ;
							$stmt .= "' " ;
							$stmt .= " and news_memo3<>'' " ;
							$stmt .= "order by $wk_fieldname3 limit 1 " ;
							$sth = dbRunSql( $stmt ) ;
							$jj = @mysqli_num_rows ( $sth ) ;
							if( $jj > 0 )
							{
								$row	=	mysqli_fetch_object( $sth ) ;
								$link	=	"/news/video/".str_replace( "/" , "" , $row->news_date1 )."/".$row->news_id."/" ;
?>

                            <a href="<?php print $link ; ?>" class="btn btn-primary btn-sm"><i class="fas fa-angle-left"></i>&nbsp;&nbsp;&nbsp;前のニュース動画</a>&nbsp;&nbsp;
<?php
								unset( $row ) ;
							}
?>
<?php
							$rinf = dbFreeResult( $sth ) ;

							$stmt = "SELECT ";
							$stmt .= "news_id , ";
							$stmt .= "news_date1 ";
							$stmt .= "FROM t_news $wheresql and news_jump_url like '' and news_date1 like '" ;
							$stmt .= $target_date ;
							$stmt .= "' and news_rsv4 > '" ;
							$stmt .= $data['news_rsv4'] ;
							$stmt .= "' " ;
							$stmt .= " and news_memo3<>'' " ;
							$stmt .= "order by $wk_fieldname2 limit 1 " ;
							$sth = dbRunSql( $stmt ) ;
							$jj = @mysqli_num_rows ( $sth ) ;
							if( $jj > 0 )
							{
								$row	=	mysqli_fetch_object( $sth ) ;
								$link	=	"/news/video/".str_replace( "/" , "" , $row->news_date1 )."/".$row->news_id."/" ;
?>
                            <a href="<?php print $link ; ?>" class="btn btn-primary btn-sm">次のニュース動画&nbsp;&nbsp;&nbsp;<i class="fas fa-angle-right"></i></a>
<?php
								unset( $row ) ;
							}
							$rinf = dbFreeResult( $sth ) ;
?>
                        </div>

                    </div>
                    <div class="news_detail">
                        <h3 class="news_title"><img src="../images/sub/icon_list.svg" width="25">関連する動画</h3>
                        <div class="row">
<?php
							$stmt = "SELECT ";
							$stmt .= "news_id , " ;
							$stmt .= "news_name , " ;
							$stmt .= "news_memo6 , " ;
							$stmt .= "news_img1 , " ;
							$stmt .= "news_rand , " ;
							$stmt .= "news_date1  ";
							$stmt .= "FROM t_news $wheresql and news_jump_url like '' " ;
							$stmt .= " and news_memo3<>'' " ;
							$stmt .= " and news_id<> " ;
							$stmt .= $data['news_id'] ;
							$stmt .= " and news_flag1 = " ;
							$stmt .= $data['news_flag1'] ;
							$stmt .= " order by $wk_fieldname2 limit 12 " ;
							$sth = dbRunSql( $stmt ) ;
							$jj = @mysqli_num_rows ( $sth ) ;
							for( $ii=0 ; $ii<$jj ; $ii++ )
							{
								$row	=	mysqli_fetch_object( $sth ) ;
								$wk		=	( $row->news_memo6 ? $row->news_memo6 : $row->news_name ) ;

								$img	=	"../images/news/exp.jpg" ;
								if( $row->news_img1 )
									$img	=	"/up_img/news/".$row->news_rand."/".$row->news_img1 ;

								$link	=	"/news/video/".str_replace( "/" , "" , $row->news_date1 )."/".$row->news_id."/" ;
?>
                            <div class="col-sm-6 col-md-4 col-lg-3">
                                <div class="hights mt-3">
                                   <a href="<?php print $link ; ?>">
                                       <img src="<?php print $img ; ?>" class="img-responsive">
                                       <p class="news_text_s"><?php print $wk ; ?></p>
                                   </a>
                                    
                                </div>
                            </div>
<?php
								unset( $row ) ;
							}
							$rinf = dbFreeResult( $sth ) ;
?>
                     </div>
<?php
}
unset( $data ) ;
?>
                    </div>
                    </div>
                    <div class="col-lg-4 col-xl-3">
<?php
	include( "./sub_side.php" ) ;
?>
                       </div>
                       </div>
                    </div>
        </section>
        </div>

<?php include("../common/footer.php"); ?>

        <!-- ========================= scroll-top ========================= -->
        <a href="#" class="scroll-top">
            <i class="fas fa-level-up-alt"></i>
        </a>

		<!-- ========================= JS here ========================= -->
		<script src="../assets/js/bootstrap.bundle-5.0.0.alpha-1-min.js"></script>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
		<script src="../assets/js/wow.min.js"></script>
		<script src="../assets/js/main.js"></script>
   <script src="../assets/js/jquery.matchHeight.js"></script>
   <script src="../assets/js/jquery.sliderPro.min.js"></script>
   <script src="../assets/js/slick/slick.js"></script>
   <script>
      $(function() {
    $('.hights').matchHeight();
    $('.link_list_footer').matchHeight();
          $('.slider1').slick({
            autoplay:true,
            arrows:true,
            autoplaySpeed:5000,
            dots:false,
            slidesToShow:3,
            slidesToScroll:1,
            responsive:[
        {
            breakpoint: 768,
            settings:{
                slidesToShow:2,
            }
        },
        {
            breakpoint: 480,
            settings:{
                slidesToShow:1,
            }
        },
    ]
});
  });
    </script>
<?php
unset( $arr_date ) ;
func_array_unset() ;
/* データベースクローズ */
mysqli_close( $dbh ) ;
?>
    </body>
</html>
