<?php
session_start();
if (!@$_SESSION['admin']) {
	$url = "index.php";
	echo "<script language='javascript'
	type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}
?>
<!DOCTYPE html>
<!--
BeyondAdmin - Responsive Admin Dashboard Template build with Twitter Bootstrap 3.2.0
Version: 1.0.0
Purchase: http://wrapbootstrap.com
-->

<html xmlns="http://www.w3.org/1999/xhtml">
    <!-- Head -->
    <head>
        <meta charset="utf-8" />
        <title>HKSECE</title>

        <meta name="description" content="Dashboard" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="icon" href="../en/hkier-ico.jpg" type="image/x-icon">
            <link rel="shortcut icon" href="../en/hkier-ico.jpg" type="image/x-icon"/>


            <!--Basic Styles-->
            <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
            <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
            <link href="assets/css/font-awesome.min.css" rel="stylesheet" />
            <link href="assets/css/weather-icons.min.css" rel="stylesheet" />

            <!--Fonts-->
            <link href="../en/fonts.googleapis.com/css@family=Open+Sans_3A300italic,400italic,600italic,700italic,400,600,700,300" rel="stylesheet" type="text/css"/>

            <!--Beyond styles-->
            <link id="beyond-link" href="assets/css/beyond.min.css" rel="stylesheet" type="text/css" />
            <link href="assets/css/demo.min.css" rel="stylesheet" />
            <link href="assets/css/typicons.min.css" rel="stylesheet" />
            <link href="assets/css/animate.min.css" rel="stylesheet" />
            <link href="css/style.css" rel="stylesheet" />
            <link id="skin-link" href="" rel="stylesheet" type="text/css" />

            <!--Skin Script: Place this script in head to load scripts for skins and rtl support-->
            <script src="assets/js/skins.min.js"></script>
            <style>
                .html{
                    font-size:10px
                }
                .Dark{
                    font-size:30px;
                    color:black;
                    text-shadow: 0 0 6px #000000;
                    display:inline;
                }
                .White{
                    font-size:30px;
                    color:white;
                    text-shadow: 0 0 6px #000000,0 0 6px #000000,0 0 6px #000000;
                    display:inline;
                }
                .Pink{
                    font-size:30px;
                    color:pink;
                    text-shadow: 0 0 6px #000000,0 0 6px #000000,0 0 6px #000000;
                    display:inline;
                }

                .table01{
                    margin-left:10px;
                    width:50%
                }
                .list01{
                    width:25%
                }
                .list02{
                    width:38%
                }
                .list03{
                    width:38%
                }
                .list04{
                    width:25%
                }
                .list05{
                    width:76%
                }
                .p{
                    margin-left:10px;
                }

                #showcase_status_container{
                    margin:10px 0;
                }

                #showcase_status_container>input[type='checkbox']{
                    position: initial;
                    margin: 0;
                    padding-left: 0;
                    width: auto;
                    height: auto;
                    margin-left: 20px;
                }

                #showcase_status_container>label{
                    cursor:pointer;
                }

                #showcase_status_container>span{
                    color:red;
                    margin: 0 0 5px 15px;
                    display: inline-block;
                    vertical-align: middle;
                }


            </style>
    </head>

    <style>
        .page-sidebar .sidebar-menu li.active-b:not(.open):before{
            display:block;
        }

        .page-sidebar .sidebar-menu  li:before  {
            background-color: #80E1FF;
        }

        .page-sidebar .sidebar-menu li.active-b>a{
            background-color: #f5f5f5;
        }

    </style>

    <!-- Body -->
    <body>
        <!-- Loading Container -->

        <div class="loading-container">
            <div class="loading-progress">
                <div class="rotator">
                    <div class="rotator">
                        <div class="rotator colored">
                            <div class="rotator">
                                <div class="rotator colored">
                                    <div class="rotator colored"></div>
                                    <div class="rotator"></div>
                                </div>
                                <div class="rotator colored"></div>
                            </div>
                            <div class="rotator"></div>
                        </div>
                        <div class="rotator"></div>
                    </div>
                    <div class="rotator"></div>
                </div>
                <div class="rotator"></div>
            </div>
        </div>
        <!--  /Loading Container -->
        <!-- Navbar -->
        <?php include 'includes/Settings.html';?>
        <!-- /Navbar -->
        <!-- Main Container -->
        <div class="main-container container-fluid">
            <!-- Page Container -->
            <div class="page-container">
                <!-- Page Sidebar -->
                <div class="page-sidebar" id="sidebar">
                    <!-- Sidebar Menu -->
                    <?php include 'includes/Sidebar_Menu.php';?>
                    <!-- /Sidebar Menu -->
                </div>
                <!-- /Page Sidebar -->
                <div class="page-content">
                    <!-- Page Header -->
                    <div class="page-header position-relative">
                        <div class="header-title">
                            <h1>
                                <?php
if (isset($_GET["insert"])) {
	echo '新增活動';
} else {
	echo '詳情';
}
?>
                            </h1>
                        </div>
                        <!--Header Buttons-->
                        <div class="header-buttons">
                            <a class="fullscreen" id="fullscreen-toggler" href="#">
                                <i class="glyphicon glyphicon-fullscreen"></i>
                            </a>
                        </div>
                        <!--Header Buttons End-->
                    </div>
                    <!-- /Page Header -->
                    <!-- Page Body -->

                    <?php
$query = "select * from `productstable` where `id` = '" . $_GET["id"] . "' and `status` != 'delete';";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);

echo '<div class="row" style="padding-left:15px"><div class="col-sm-6 col-md-3">
							   	<p style="height:31px">活動主圖像</p>
							   	<p style="color:red;">*圖片必須相同長闊</p>
								<img src="' . $row["image"] . '?id=' . rand(100000, 999999) . '" style="height:100%;width:100%"/>
								<button type="button"style="margin:auto; display:block;margin-bottom:5px" data-toggle="modal" data-target="#upload">上傳照片</button>
							 </div>
							 <div class="col-sm-12 col-md-6">

							   	 <form action="includes/edit_image_number.php" method="post">
								 <p>活動副圖像 數目:
								 <input class="hidden" name="id" value="' . $row["id"] . '"/>
								 <input name="image_number" style="width:35px" placeholder="(0~8)" value="' . $row["image_number"] . '" pattern="[0-8]" onblur="submit()"/>
								 </p>
								 </form>
								<div class="modal fade" id="upload' . '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
								<div class="modal-content">
								<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
								<h4 class="modal-title" id="myModalLabel">上傳照片</h4>
								</div>
								<div class="modal-body">
								<form action="includes/upload_image.php" method="post" enctype="multipart/form-data">
								<input type="file" name="image"/>
								</div>
								<div class="modal-footer">
								<input class="hidden" name="id" value="' . $row["id"] . '"/>
								<input class="hidden" name="image_no" value=""/>
								<button type="button" onClick="submit()" class="btn btn-primary">確定上傳</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
								</form>
								</div>
								</div>
								</div>
								</div>';
$x = 1;
while ($x <= $row["image_number"]) {
	echo '<div class="col-xs-6 col-sm-3">
									<img src="' . $row["image_" . $x] . '?id=' . rand(100000, 999999) . '" style="height:100%; width:100%; margin:auto; display:block;"/>
									<button type="button"style="margin:auto; display:block;margin-bottom:5px" data-toggle="modal" data-target="#upload' . $x . '">上傳照片</button>
							      </div>

								<div class="modal fade" id="upload' . $x . '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
								<div class="modal-content">
								<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
								<h4 class="modal-title" id="myModalLabel">上傳照片</h4>
								</div>
								<div class="modal-body">
								<form action="includes/upload_image.php" method="post" enctype="multipart/form-data">
								<input type="file" id="image" name="image"/>
								</div>
								<div class="modal-footer">
								<input class="hidden" name="id" value="' . $row["id"] . '"/>
								<input class="hidden" name="image_no" value="_' . $x . '"/>
								<button type="button" onClick="submit()" class="btn btn-primary">確定上傳</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
								</form>
								</div>
								</div>
								</div>
								</div>';
	$x++;
}

echo '</div></div>';

echo '<form action="includes/edit_record.php" method="post">
						      <input class="hidden" name="id" value="' . $_GET['id'] . '"/>
							  <input class="hidden" name="page" value="products"/>
							  <div id="showcase_status_container" class="row">
							  	<input id="status_box" type="checkbox" name="showcase" ' . ($row["showcase"] == true ? 'checked' : '') . ' >
								<label for="status_box">顯示商品</label>
								<span>(勾選「顯示商品」，然後「提交修改」後才會顯示於網店頁面！）</span>
							  </div>
							  <div class="row" style="padding-left:15px"><div class="col-sm-12 col-md-8">
							  <p>英文資料</p>
							  <table>
							  <tr>
							  <td>活動名稱</td><td><input name="name" style="width:80%" value="' . htmlentities($row["name"], ENT_QUOTES, "UTF-8") . '"/></td>
							  </tr>
							  <tr>';
echo "<td>活動簡介</td><td><textarea id='outline' name='outline'>" . $row["outline"] . "</textarea></td>
							  </tr>
							  <tr>
							  <td>活動詳介</td><td><textarea id='content' name='description'>" . $row["description"] . "</textarea></td>
							  </tr>
							  <tr>
							  <td>活動所屬大分類</td><td><input name='belong' style='width:80%' value='" . $row["belong"] . "'/></td>
							  </tr>
							  </tr>
							  <tr>
							  <td>活動所屬小分類</td><td><input name='ategory' style='width:80%' value='" . $row["ategory"] . "'/></td>
							  </tr>
							  </table>
							  ";
echo '
							  <p>中文資料</p>
							  <table>
							  <tr>
							  <td>活動名稱</td><td><input name="zh_name" style="width:80%" value="' . htmlentities($row["zh_name"], ENT_QUOTES, "UTF-8") . '"/></td>
							  </tr>
							  <tr>';
echo "
							  <td>活動簡介</td><td><textarea id='zh_outline' name='zh_outline'>" . $row["zh_outline"] . "</textarea></td>
							  </tr>
							  <tr>
							  <td>活動詳介</td><td><textarea id='content1' name='zh_description'>" . $row["zh_description"] . "</textarea></td>
							  </tr>
							  <tr>
							  <td>活動所屬大分類</td><td><input name='zh_belong' style='width:80%' value='" . $row["zh_belong"] . "'/></td>
							  </tr>
							  </tr>
							  <tr>
							  <td>活動所屬小分類</td><td><input name='zh_category' style='width:80%' value='" . $row["zh_category"] . "'/></td>
							  </tr>
							  </table>
							  ";
echo '
							  <p>活動資料</p>
							  <table>
							  <tr>
							  <td>原價</td><td><input name="original_price" style="width:80%" value="' . $row["original price"] . '"/></td>
							  </tr>
							  <tr>
							  <td>正價</td><td><input name="price" style="width:80%" value="' . $row["price"] . '"/></td>
							  </tr>';

echo '<tr><td>級別選項</td>';
echo '<td>';
$selectoptions = explode(",", $row["product_options"]);
?>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="1"

<?php if (in_array("1", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">PN</span> </label> </div>



<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="2"
<?php if (in_array("2", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">K1</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="3"
<?php if (in_array("3", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">K2</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="4"
<?php if (in_array("4", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">K3</span> </label> </div>


<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="5"
<?php if (in_array("5", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P1</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="6"
<?php if (in_array("6", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P2</span> </label> </div>


<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="7"
<?php if (in_array("7", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P3</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="8"
<?php if (in_array("8", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P4</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="9"
<?php if (in_array("9", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P5</span> </label> </div>

<div class="checkbox" style="display: flex;
    align-items: center;padding-left:70px;"> <label style="display: flex;align-items: center;">
<input type="checkbox" id="Check1" class="option-input checkbox" name="product_options[]" value="10"
<?php if (in_array("10", $selectoptions)) {
	echo "checked";
} //if(in_array("1", $selectoptions){
?>
><span class="ml-10">P6</span> </label> </div>
<?php
echo '</td>';
echo '</tr>';

echo '
							  <tr>
							  <td>創建時間</td><td><input name="created" style="width:80%" value="' . $row["created"] . '"/></td>
							  </tr>
							  </table>
							  </div></div>';
echo '<input style="background-color:hsla(0,0%,0%,0.00);" value="';
if (isset($_GET["insert"])) {
	echo '確定';
} else {
	echo '提交修改';
}
echo '" type="submit"/>
					<button type="button" style="background-color:hsla(0,0%,0%,0.00);" data-toggle="modal" data-target="#myModal">';
if (isset($_GET["insert"])) {
	echo '取消';
} else {
	echo '刪除記錄';
}
echo '</button>';
?></form>

                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel">警告</h4>
                                </div>
                                <div class="modal-body">
                                    <?php
if (isset($_GET["insert"])) {
	echo '所以記錄將不會被保存,確定要進行操作嗎?';
} else {
	echo '你正在刪除一條記錄,確定要進行操作嗎?';
}
?>
                                </div>
                                <div class="modal-footer">
                                    <form action="includes/edit_record.php" method="post">
                                        <input class="hidden" name="record" value="<?php echo @$_GET['record']; ?>"/>
                                        <input class="hidden" name="id" value="<?php echo @$_GET['id']; ?>"/>
                                        <input class="hidden" name="page" value="<?php echo $_SESSION["page_name"]; ?>"/>
                                        <input class="hidden" name="delete"/>
                                        <button type="button" onClick="submit()" class="btn btn-primary">確定</button>
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>



                    <!-- /Page Body -->
                    <!--<form id='form'action="a.php" method="post">
                         <textarea id='asd' name="content"></textarea>
                     </form>-->
                    <!--Ckeditor Needed Scripts-->
                    <?php
                    $hash = sha1(rand().microtime());
                    ?>
                    <script type="text/javascript" src="../ckeditor/ckeditor.js?<?=$hash;?>"></script>
                    <script type="text/javascript" src="../ckeditor/config.js?<?=$hash;?>"></script>
                    <script>
                                            CKEDITOR.replace('content', {
                                                filebrowserBrowseUrl: '../ckeditor/index.html',
                                                filebrowserImageBrowseUrl: '../ckeditor/index.html',
                                                filebrowserUploadUrl: '../upload.php?type=Files',
                                                filebrowserImageUploadUrl: '../upload.php?type=Images',
                                            });
                                            CKEDITOR.replace('content1', {
                                                filebrowserBrowseUrl: '../ckeditor/index.html',
                                                filebrowserImageBrowseUrl: '../ckeditor/index.html',
                                                filebrowserUploadUrl: '../upload.php?type=Files',
                                                filebrowserImageUploadUrl: '../upload.php?type=Images',
                                            });
                                            CKEDITOR.replace('outline', {
                                                filebrowserBrowseUrl: '../ckeditor/index.html',
                                                filebrowserImageBrowseUrl: '../ckeditor/index.html',
                                                filebrowserUploadUrl: '../upload.php?type=Files',
                                                filebrowserImageUploadUrl: '../upload.php?type=Images',
                                            });
                                            CKEDITOR.replace('zh_outline', {
                                                filebrowserBrowseUrl: '../ckeditor/index.html',
                                                filebrowserImageBrowseUrl: '../ckeditor/index.html',
                                                filebrowserUploadUrl: '../upload.php?type=Files',
                                                filebrowserImageUploadUrl: '../upload.php?type=Images',
                                            });
                    </script>
                </div>
                <!-- /Page Content -->
            </div>
            <!-- /Page Container -->
            <!-- Main Container -->

        </div>

        <!--Basic Scripts-->
        <script src="assets/js/jquery-2.0.3.min.js"></script>
        <script src="assets/js/bootstrap.min.js"></script>
        <script src="assets/js/slimscroll/jquery.slimscroll.min.js"></script>

        <!--Beyond Scripts-->
        <script src="assets/js/beyond.js"></script>


        <!--Page Related Scripts-->
        <!--Sparkline Charts Needed Scripts-->
        <script src="assets/js/charts/sparkline/jquery.sparkline.js"></script>
        <script src="assets/js/charts/sparkline/sparkline-init.js"></script>

        <!--Easy Pie Charts Needed Scripts-->
        <script src="assets/js/charts/easypiechart/jquery.easypiechart.js"></script>
        <script src="assets/js/charts/easypiechart/easypiechart-init.js"></script>

        <!--Flot Charts Needed Scripts-->
        <script src="assets/js/charts/flot/jquery.flot.js"></script>
        <script src="assets/js/charts/flot/jquery.flot.resize.js"></script>
        <script src="assets/js/charts/flot/jquery.flot.pie.js"></script>
        <script src="assets/js/charts/flot/jquery.flot.tooltip.js"></script>
        <script src="assets/js/charts/flot/jquery.flot.orderBars.js"></script>
        <script src="../en/js/myFunction.js"></script>


    </body>
    <!--  /Body -->
</html>
