<?php
    include ('functions.php');
    include ('header.php');
?>
<?php
    $main_data = mainData(); // array one raw
    $parent_categories = parentCategory(); // array many row
    $setting = setting();
    $accept_order=$setting['accept_orders'];
    $logo=$main_data['image'];
    if(isset($_POST['name'])){
        $key_word=$_POST['name'];
    }
?>

<style>
    /* Edit Image of Logo and bg Area */
    /*.top-header .logo-area .logo { background-image: url(<?php echo $logo ?>); } */
    
    .bg-area:before{ background-image: url(<?php echo $main_data['image_backGround']; ?>); }
</style>

<!--<div class="row page-body">-->
<!--    <div class="bg-area row align-items-end">-->
<!--    </div>-->
<!--    <div class="row w-100 navbar-area">-->

<!--        <div class="container px-3 px-sm-0 position-relative">-->
<!--            <div class="nav-scroller py-1">-->
<!--                <nav class="nav d-flex">-->
                    <?php
                        // $nav_list = "";

                        // foreach ($parent_categories as $key => $row) {
                        //     $parent_category_id = $row['parent_category_id'];
                        //     $parent_category_name = $row['parent_category_name'];
                        //     $active = $nav_list ? "" : "active";
                        //     $nav_list .= "
                        //                             <a class='nav-link {$active} pl-sm-0 pl-3 pr-3' href='#cat-{$parent_category_id}' select-target='true'>{$parent_category_name}</a>
                        //                     ";
                        // }

                        // echo $nav_list;
                    ?>
<!--                </nav>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->


<div class="row items-list">
    <!-- Start of first serction -->
    <?php
        // foreach ($parent_categories as $key => $row) {
        //     $parent_category_id = $row['parent_category_id'];
        //     $parent_category_name = $row['parent_category_name'];
           
    ?>
            <div class="container px-3 px-sm-0 mb-3" id="cat-<?php echo $parent_category_id; ?>">
                <h1 class="h2 my-4">
                    <a class="category_name"><span class="size22" data-icon="&#xe936"></span> <?php echo $key_word; ?></a>
                </h1>
                <div class="row">


                    <?php
                    $sub_categotirs = subCatgeoryBySeachKey($key_word);
                    if (is_array($sub_categotirs)) {
                        foreach ($sub_categotirs as $subs => $sub) {

                            $sub_category_id = $sub['sub_category_id'];
                            $sub_category_image = $sub['sub_category_image'];
                            $sub_category_name = $sub['sub_category_name'];
                            $sub_category_desc = $sub['sub_category_desc'];
                           // number_format($total_price;
                            $sub_category_price =  number_format($sub['sub_category_price'], 3, '.', '');
                            
                            ?>
                            <div class="col-12 col-sm-6 col-md-4 items mb-2 mb-sm-5 pl-0 pr-2 pb-1" onclick="showModal(<?php echo $sub_category_id; ?>)" >
                                <div class="row" data-toggle="modal" data-target="#order-now" >

                                    <div class="col-4 p-0">
                                        <img class="img-fluid w-100 h-100 p-2 p-sm-0 lazy" data-src="<?php echo "./TimThumb-master/timthumb.php?src={$sub_category_image}&w=600&h=600" ; ?>"  onerror="this.onerror=null; this.src='<?php echo $logo; ?>'"  alt="<?php echo $sub_category_name; ?>">
                                    </div>

                                    <div class="col-8 px-0 px-sm-3 pt-3 pt-sm-0">
                                        <a class="h5 font-weight-bold text-dark text-capitalize d-block w-100"><?php echo $sub_category_name; ?></a>
                                        <span class="d-inline-block mt-2 bg-danger text-white px-2 py-1 rounded">BHD <?php echo $sub_category_price; ?></span>
                                        <p class="mb-0 py-2 px-0 text-secondary size12"><?php echo $sub_category_desc; ?></p>
                                    </div>

                                </div>
                            </div>
                            <?php
                        }//end of forEach of Subs
                    }//end of If is_array
                    ?>

                </div>

            </div>

            <?php
        // }
    ?>
    <!-- end first section -->




</div>


<!-- Start Order Now Modal -->
<div class="modal fade animated fadeIn faster" id="order-now" tabindex="-1" role="dialog" aria-labelledby="order-nowModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <h5 class="modal-title" id="order-nowModalLabel">Beef</h5>
                <button  type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true" data-icon="&#xe912"></span>
                </button>
            </div>

            <div class="modal-body">
                <div class="col-12 order-now">
                    <div class="row">
                        <img id="sub-image-modal" class="img-fluid w-100" src="assets/img/home/beef-burger-1.jpg" onerror="this.onerror=null; this.src='Default.jpg'" alt="BEEF SANDWICHS">

                        <div class="col-12 px-0 py-3">
                            <a id="sub-cat-title" class="h5 font-weight-bold text-dark text-capitalize d-block w-100">Beef</a>
                            <p id="sub-cat-desc" class="mb-0 py-2 px-0 text-secondary">Beef burger with guacamole, lettuce and tomato, Vlasic速 Zesty Garlic Dill Stackers </p>
                            <hr class="w-100 d-block">

                            <p id="sub-cat-notes-order" class="m-0 py-2">Special Instructions (optional)</p>
                            <textarea rows="4" cols="8"  style="resize:none;" name="sub-cat-notes-value" id="sub-cat-notes-value" class="form-control"></textarea>
                        </div>
                    </div>
                </div>

                <div class="pl-1" id="additions">
                    <h5>Additions</h5>
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="customCheck1">
                        <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
                    </div>

                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="customCheck2">
                        <label class="custom-control-label" for="customCheck2">Check this custom checkbox</label>
                    </div>
                </div>
                <hr class="w-100 d-block">
                <div class="pl-1 mt-3" id="removes">
                    <h5>Removes</h5>


                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
                        <label class="custom-control-label" for="customRadio2">Toggle this custom radio</label>
                    </div>

                </div>

               
                <div class="pl-1 mt-3" id="sizes">
                    <h5>Sizes</h5>


                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
                        <label class="custom-control-label" for="customRadio2">Toggle this custom radio</label>
                    </div>

                </div>


                <div class="col-12 set-price py-4">
                    <div class="form-row">
                        <div class="col-2">
                            <button type="button" class="btn btn-sm btn-danger btn-block minus">-</button>
                        </div>
                        <div class="col-2">
                            <input id="sub-cat-quanity" type="text" class="form-control border-0 text-center p-0" value="1" placeholder="Number">
                        </div>
                        <div class="col-2">
                            <button type="button" class="btn btn-sm btn-danger btn-block plus">+</button>
                        </div>
                        <div id="sub-cat-price" class="col-6 text-right" data-price="1.400">
                            BHD 1.400
                        </div>
                    </div>
                </div>

                <?php if ($accept_order){?>
                    <div class="col-12">
                        <button type="button" id="add_item_to_order" value="0" onclick="addItemToOrder()" class="btn btn-danger btn-block" data-dismiss="modal">ADD TO ORDER</button>
                    </div>
                <?php }else{
                        echo "<h3>The Restutant Is Closed Now, We Will Back Soon ! </h3>";
                    } ?>
                    
            </div>
        </div>
    </div>
</div>
<!-- End Order Now Modal -->
<div class="checkout w-100 fixed-bottom d-block d-sm-none">
    <div class="row justify-content-between mb-2 px-2">
        <a class="col-2 m-1 btn btn-danger text-white rounded-pill" onclick="showModalCartDetials()" href="#Cart" data-toggle="modal" data-target="#Cart">
            <span class="cart-count2 position-absolute">0</span>
            <span data-icon="&#xf24f"></span>
        </a>
        <a href="checkout_continue.php" class="col-9 m-1 btn btn-danger text-white rounded-pill">CHECKOUT</a>
    </div>
</div>
<?php include ('footer.php'); ?>