<?php include_once dirname(__FILE__) . '/functions/functions.php';?>

<?php $this->load->view('adv/category_adv1', array('adv_position' => 1));?>
<!-- top row -->

<!-- added general search form -->
<!-- <form action="/category/p/Category-2/MY58TSN15SDZ36E" method="get" id="plistform" enctype="multipart/form-data" accept-charset="utf-8">-->

<?php
//added change base url
//original is base_url('category/' . $category_id) . '/' . $brand
$searchurl = "";
if ($category_id == "weeksale") {
	$searchurl = base_url('category_week_sale/') . $brand;
} elseif ($category_id == "bestsale") {
	$searchurl = base_url('category_best_sale/') . $brand;
} elseif ($category_id == "category_all") {
	$searchurl = base_url('category_all/') . $brand;
} elseif ($category_id == "category_limitedtime") {
	$searchurl = base_url('category_limitedtime/') . $brand;
} else {
	//original url
	$searchurl = base_url('category/' . $category_id) . '/' . $brand;
}
//end added change base url

?>
<!-- <form action="<?php echo base_url('category/' . $category_id) . '/' . $brand; ?>" method="get" id="plistform" enctype="multipart/form-data" accept-charset="utf-8"> -->
<form action="<?php echo $searchurl; ?>" method="get" id="plistform" enctype="multipart/form-data" accept-charset="utf-8">



    <!-- added display format -->
    <input type="hidden" name="displayorder" id="displayorder" value="<?php echo $displayorder; ?>">
    <input type="hidden" name="sorting" id="sorting" value="<?php echo $sorting; ?>">

    <!-- //added search brands -->
    <!-- <input type="hidden" name="searchbrands" id="searchbrandsaa" value=""> -->
    <!-- end added search brands -->

    <!-- added search subcat -->
<!--     <input type="hidden" name="searchsubcat" id="searchsubcataa" value=""> -->
    <!-- end added search subcat -->

    <!-- end added display format -->


</form>

<!-- end  added general search form -->



</div>
<!-- end top row -->
<div class="container py-4">

    <div class="row">
        <div class="<?php echo (!empty($after_search) ? 'col-md-3' : 'col-md-3') ?> d-none d-lg-block leftSidebar mb-3 pr-xl-4">

            <div class="card-header d-flex align-items-center justify-content-between">
                    <h2 class="mb-0 fs-17 weborange"><?php echo display('series') ?></h2>
                    <i  class="fa fa-minus weborange"></i>
                </div>
            <?php //var_dump($all_main_category);?>
            <!-- added left row main menu -->
            <style>
                ul {
    list-style-type: none
}

a {
    color: #b63b4d;
    text-decoration: none
}

.accordion {
    width: 100%;
    /*max-width: 384px;*/
    /*margin: 30px auto 20px;*/
    background: #f2f2f2;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 0px;


    /*added ul padding*/

    padding-inline-start: 0px;
}

.accordion .link {
    cursor: pointer;
    display: block;
    /*padding: 15px 15px 15px 42px;*/
    padding: 5px 5px 5px 20px;
    color: #4D4D4D;
    /*font-size: 14px;*/
    font-size: 1.25rem;
    /*font-weight: 700;*/
    border-bottom: 1px solid #CCC;
    position: relative;
    -webkit-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    transition: all 0.4s ease
}

/*.accordion li:last-child .link {
    border-bottom: 0
}*/
.accordion li:first-child .link {
    border-top: 1px solid #CCC;
}

.accordion li i {
    position: absolute;
    top: 16px;
    left: 12px;
    font-size: 18px;
    color: #595959;
    -webkit-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    transition: all 0.4s ease
}

.accordion li i.fa-chevron-down {
    right: 12px;
    left: auto;
    font-size: 16px
}

.accordion li.open .link {
    color: #e98b50
    /*color: #AA00FF*/
}

.accordion li.open i {
    /*color: #AA00FF*/
    color: #e98b50
}

.accordion li.open i.fa-chevron-down {
    -webkit-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    -o-transform: rotate(180deg);
    transform: rotate(180deg)
}

.submenu {
    display: none;
/*    background: #444359;
    font-size: 14px;*/
    font-size: 1.25rem;
    padding-inline-start: 0px;
}

.submenu li {
    border-bottom: 1px solid #d2d2d2
}

.submenu a {
    display: block;
    text-decoration: none;
    color: #4d4d4d;

    /*padding: 12px;*/
    padding: 5px 5px 5px 5px;

    padding-left: 50px;
    -webkit-transition: all 0.25s ease;
    -o-transition: all 0.25s ease;
    transition: all 0.25s ease
}

.submenu a:hover {
    /*background: #b63b4d;*/
    /*color: #FFF*/
    color: #e98b50
}

.hreflink {
    color:#4d4d4d;
}
.hreflink:hover {
    color:#e98b50;
}
            </style>
            <script type="text/javascript">

//                 $( document ).ready(function() {

//     $('a.linkhref').click(function(){
//     alert("test");
//     event.preventDefault();
// });


// });





                $(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;

var links = this.el.find('.link');
// var links = this.el.find('.link').parentElement;

links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
}

Accordion.prototype.dropdown = function(e) {

    // if(if($(this).attr('href') == "#" || $(this).attr('href') == ""))

        // alert( $(this).attr('href'));
    // alert(e.data.el);
var $el = e.data.el;
$this = $(this),
$next = $this.next();
// $next = $this.parent().next();

$next.slideToggle();
// $next.slideToggle();
$this.parent().toggleClass('open');

// $this.parent().parent().toggleClass('open');
// if (!e.data.multiple) {
// $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
// };
}

var accordion = new Accordion($('#accordion'), false);
});

//added link to prevent toggle class
// $('.menuLink').click(function (e) {
//     alert("clicled");
//     e.stopPropagation();
// });
//end
// $('.link').on('hide.bs.dropdown', function(e) {
//   e.preventDefault();
//   e.stopPropagation();
// });

// $(".link a").on('click', function(event) {
//         alert(1);
//         event.preventDefault();
//     });

// $(".testlink").on('click', function(event) {
//         alert(1);
//         event.preventDefault();
//     });


       </script>
<!-- <div id="new_div" class="test" style="border:1px solid;">
Clicked Me......
</div> -->
        <ul id="accordion" class="accordion">
        <li>

            <div class="link pl-5">
                <a href="<?php echo base_url() . "category_all"; ?>" class="hreflink <?php if ($category_id == "category_all") {
	echo "categorylinkpink";
}?>">
                <?php

if ($this->session->userdata('language') == "english") {
	echo html_escape("All products");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("所有");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Diskon besar-besaran");
}
// echo $all_main_cate_row->category_name;
?>
</a>
</div>
<!--             <ul class="submenu">
                <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul> -->
        </li>

        <!-- limitedtime -->
        <li>

            <div class="link  pl-5">
                <a href="<?php echo base_url() . "category_limitedtime"; ?>" class="hreflink <?php if ($category_id == "category_limitedtime") {
	echo "categorylinkpink";
}?>">
                <?php
echo display('limitedtime');
// if ($this->session->userdata('language') == "english") {
// 	echo display('limitedtime');
// }
// if ($this->session->userdata('language') == "chinese") {

// 	echo html_escape("所有");
// }
// if ($this->session->userdata('language') == "indonesian") {
// 	echo html_escape("Diskon besar-besaran");
// }
// echo $all_main_cate_row->category_name;
 ?>
</a>
</div>
<!--             <ul class="submenu">
                <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul> -->
        </li>

        <!-- end limitedtime -->

      <!--   <li>

            <div class="link">
                <a href="<?php echo base_url() . "category_week_sale"; ?>" class="hreflink <?php if ($category_id == "weeksale") {
	echo "categorylinkpink";
}?>"> -->
                <?php

// if ($this->session->userdata('language') == "english") {
// 	echo html_escape("Hot Sale");
// }
// if ($this->session->userdata('language') == "chinese") {

// 	echo html_escape("本週熱買");
// }
// if ($this->session->userdata('language') == "indonesian") {
// 	echo html_escape("Diskon besar-besaran");
// }
// echo $all_main_cate_row->category_name;
?>
<!-- </a>
</div> -->
<!--             <ul class="submenu">
                <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul> -->
        <!-- </li> -->
  <!--       <li>
            <div class="link">
                     <a href="<?php echo base_url() . "category_best_sale"; ?>" class="hreflink <?php if ($category_id == "bestsale") {
	echo "categorylinkpink";
}?>"> -->
                <?php

// if ($this->session->userdata('language') == "english") {
// 	echo html_escape("Best Sale");
// }
// if ($this->session->userdata('language') == "chinese") {

// 	echo html_escape("人氣商品");
// }
// if ($this->session->userdata('language') == "indonesian") {
// 	echo html_escape("Penjualan Terbaik");
// }
// echo $all_main_cate_row->category_name;
?>
              <!--   </a>
</div> -->
<!--             <ul class="submenu">
                <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul> -->
        <!-- </li> -->

 <?php

foreach ($all_main_category as $all_main_cate_row) {
	?>
         <li>
            <div class="link  pl-5">
                <!-- <span><div class="menuLink" style="z-index: 20">123</div></span> -->
                <a href="<?php echo base_url('/category/p/' . remove_space($all_main_cate_row->category_name) . '/' . $all_main_cate_row->category_id); ?>" onclick="event.stopPropagation();" class="hreflink <?php if ($category_id == $all_main_cate_row->category_id) {
		echo "categorylinkpink";
	}?>"  >
                <?php

	if ($this->session->userdata('language') == "english") {
		echo html_escape($all_main_cate_row->category_name);
	}
	if ($this->session->userdata('language') == "chinese") {
		echo html_escape($all_main_cate_row->category_name_ch);
	}
	if ($this->session->userdata('language') == "indonesian") {
		echo html_escape($all_main_cate_row->category_name_indonesian);
	}
	// echo $all_main_cate_row->category_name;
	?></a><!-- <i class="fa fa-chevron-down "></i> -->
</div>
            <ul class="submenu">
               <?php foreach ($all_sub_category as $all_sub_category_row) {
		if ($all_main_cate_row->category_id == $all_sub_category_row->parent_category_id) {
			?>
                    <li><a href="<?php echo base_url('/category/p/' . remove_space($all_sub_category_row->category_name) . '/' . $all_sub_category_row->category_id); ?>" class="<?php if ($category_id == $all_sub_category_row->category_id) {
				echo "categorylinkpink";
			}?>"><?php

			if ($this->session->userdata('language') == "english") {
				echo html_escape($all_sub_category_row->category_name);
			}
			if ($this->session->userdata('language') == "chinese") {
				echo html_escape($all_sub_category_row->category_name_ch);
			}
			if ($this->session->userdata('language') == "indonesian") {
				echo html_escape($all_sub_category_row->category_name_indonesian);
			}
			// echo $all_sub_category_row->category_name;

			?></a></li>
                <?php
} //if( $all_main_cate_row->category_id == $all_sub_category_row->parent_category_id){
	} //foreach ($all_sub_category as $all_sub_category_row) {

	?>
        </ul>
        </li>
                <?php
} //foreach ($all_main_category as $all_main_cate_row) {
?>
                <!-- <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul>
        </li> -->
        <!--  </ul>
        </li> -->
<?php
//} //foreach ($all_main_category as $all_main_cate_row) {
?>
        <!-- <li>
            <div class=""><i class="fa fa-laptop"></i>Laptops<i class="fa fa-chevron-down linkicon"></i></div>
            <ul class="submenu">
                <li><a href="#">Dell Acron</a></li>
                <li><a href="#">HP Envy</a></li>
                <li><a href="#">Macbook Air</a></li>
            </ul>
        </li>
        <li>
            <div class="link"><i class="fa fa-tv"></i>Smart TV<i class="fa fa-chevron-down"></i></div>
            <ul class="submenu">
                <li><a href="#">Sony Bravia</a></li>
                <li><a href="#">Samsung</a></li>
                <li><a href="#">MI</a></li>
            </ul>
        </li>
        <li>
            <div class="link"><i class="fa fa-mobile"></i>Mobiles<i class="fa fa-chevron-down"></i></div>
            <ul class="submenu">
                <li><a href="#">Samsung S9</a></li>
                <li><a href="#">Apple X</a></li>
                <li><a href="#">Honor Play</a></li>
            </ul>
        </li>
        <li>
            <div class="link"><i class="fa fa-globe"></i>Search Engines<i class="fa fa-chevron-down"></i></div>
            <ul class="submenu">
                <li><a href="#">Google</a></li>
                <li><a href="#">Bing</a></li>
                <li><a href="#">Yahoo</a></li>
            </ul>
        </li> -->

                    </ul>

    <!-- end added left row main menu -->


            <?php
// hide small menu
// $sub_category = $this->Homes->get_sub_category($category_id);
// if (!empty($sub_category)) {
?>
<!--             <div class="card mb-4">
                <div class="card-header d-flex align-items-center justify-content-between">
                    <h2 class="mb-0 fs-17"> -->
                        <?php
// echo html_escape($category_name)

?>

                     <!-- </h2> -->
<!--                     <i data-feather="sliders" class="card-header_icon"></i>
                </div>

                <div class="card-body">
                    <ul class="subcategories list-unstyled"> -->
                        <?php
// if ($sub_category) {
// 		$i = 1;
// 		foreach ($sub_category as $cat) {
// 			if ($i == 11) {
// 				break;
// 			}

// 			$no_of_pro = $this->Categories->select_total_sub_cat_no_of_pro($cat['category_id']);
?>

                       <!--  <li>
                            <a href="<?php echo base_url('category/p/' . remove_space($cat['category_name']) . '/' . $cat['category_id']) ?>" class="d-flex align-items-center mb-2 text-black">
                                <i data-feather="chevron-right" class="mr-1"></i>
                                <span class="name"><?php echo html_escape($cat['category_name']) ?></span>
                                <span class="total fs-12 text-black-50 ml-2">(<?php echo html_escape($no_of_pro); ?>)</span>
                            </a>
                        </li> -->
                        <?php
// $i++;
// 		}
// 	}
?>
<!--                     </ul>
                </div>
            </div> -->
            <?php

// }
//end  hide small menu
?>
            <div class=" mb-4">
                <div class="card-header d-flex align-items-center justify-content-between" style="border-bottom: 1px solid #CCC;;">
                    <h2 class="mb-0 fs-17"><?php echo display('price') ?></h2>
                     <i  class="fa fa-minus weborange"></i>
                    <!-- <i data-feather="sliders" class="card-header_icon"></i> -->
                </div>
                <div class="card-body">
                    <?php echo form_open('', array('id' => 'priceForm')); ?>

                    <input type="text" class="price-range" value="price-range" name="price-range"/>
                    <?php echo form_close(); ?>
                </div>
            </div>
            <?php

//hide brand
$brand_info = $this->Categories->select_sub_cat_brand_info($category_table_id);
// echo $this->db->last_query();
if ($brand_info) {
	?>

            <div class="card mb-4">
                <div class="card-header d-flex align-items-center justify-content-between">
                    <h2 class="mb-0 fs-17 weborange"><?php echo display('brand') ?></h2>
                    <i  class="fa fa-minus weborange"></i>
                </div>
                <div class="card-body">
                    <?php
$i = 1;
	$query_string = '';
	$query_string = $this->input->server('QUERY_STRING');
	if ($query_string) {
		$query_string = '?' . $this->input->server('QUERY_STRING');
	} else {
		$query_string = '';
	}
	$brand_url_ids = $this->uri->segment('3');
	if ($brand_url_ids) {
		$all_brand = (explode("--", $brand_url_ids));
		$lastElementKey = count($all_brand);
	} else {
		$lastElementKey = 0;
	}
	foreach ($brand_info as $brand_in) {
		if ($brand_in['brand_id']) {
			?>
                    <div class="custom-control custom-checkbox mb-2">

                        <input id="brand<?php echo $i ?>" type="checkbox"
                                               class="brand_class custom-control-input" name="brand" value="<?php
$target_id = $brand_in['brand_id'];
			if (strpos($brand_url_ids, $target_id) !== false) {
				if ($lastElementKey == 1) {
					$output = preg_replace('/' . $target_id . '/', '', $brand_url_ids);
					echo base_url('category') . '/' . $category_id . $query_string;
				} else {
					if (strpos($brand_url_ids, $target_id . '--') !== false) {
						$output = preg_replace('/' . $target_id . '--/', '', $brand_url_ids);
					} else {
						$output = preg_replace('/--' . $target_id . '/', '', $brand_url_ids);
					}
					echo base_url('category') . '/' . $category_id . '/' . $output . $query_string;
				}
			} else {
				if ($lastElementKey == 0) {
					echo base_url('category') . '/' . $category_id . '/' . $brand_url_ids . $target_id . $query_string;
				} else {
					echo base_url('category') . '/' . $category_id . '/' . $brand_url_ids . '--' . $target_id . $query_string;
				}
			}
			?>"

<?php
if (strpos($brand_url_ids, $target_id) !== false) {
				echo 'checked';
			}
			?>
        >


                        <label class="custom-control-label" for="brand<?php echo $i ?>">
                            <?php echo html_escape($brand_in['brand_name']) ?><span class="count text-muted fs-12 ml-1"></span>
                        </label>
                    </div>
                     <?php
$i++;
		}
	}
	?>
                </div>
            </div>
            <?php
}
//end hide brand
?>

            <?php $this->load->view('adv/category_adv2', array('adv_position' => 3));?>


        </div>
        <div class="<?php echo (!empty($after_search) ? 'col-md-9' : 'col-md-9') ?> mainContent category-content">

            <!-- inside category menu -->

    <div class="row mt-1 mb-2">
        <div class="col-12 col-md-3">

            <!-- added breadcrumb -->
            <?php
// middle category judge by category_id
if ($this->session->userdata('language') == "english") {
	// echo html_escape($all_main_cate_row->category_name);
}
if ($this->session->userdata('language') == "chinese") {
	// echo html_escape($all_main_cate_row->category_name_ch);
}
if ($this->session->userdata('language') == "indonesian") {
	// echo html_escape($all_main_cate_row->category_name_indonesian);
}

$middleurl = "";
if ($category_id == "weeksale") {
	$middleurl = base_url('category_week_sale/') . $brand;
} elseif ($category_id == "bestsale") {
	$middleurl = base_url('category_best_sale/') . $brand;
} else {
	//original url
	// $middleurl = base_url('category/' . $category_id) . '/' . $brand;
	$middleurl = base_url('category/p/' . remove_space($category_name) . '/' . $category_id);
}

?>



    <nav aria-label="breadcrumb" class="my-2">
        <ol class="breadcrumb d-inline-flex mb-0">
            <li class="breadcrumb-item align-items-center"><a href="<?php echo base_url() ?>" class="categorylink d-flex align-items-center"><i data-feather="home" class="mr-2"></i><?php echo display('home') ?></a></li>
            <!-- <li class="breadcrumb-item align-items-center"><a href="<?php echo base_url('category/p/' . remove_space($category_name) . '/' . $category_id) ?>" class="d-flex align-items-center"><?php echo html_escape($category_name); ?></a></li> -->
            <li class="breadcrumb-item align-items-center"><a href="<?php echo $middleurl; ?>" class="categorylink d-flex align-items-center categorylinkpink">
                       <?php

if ($this->session->userdata('language') == "english") {
	?>
               <?php echo html_escape($category_name); ?>
                <?php
}
?>
                <?php
if ($this->session->userdata('language') == "chinese") {
	?>
                <?php echo html_escape($category_name_ch); ?>
                <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>
                 <?php echo html_escape($category_name_indonesian); ?>
                <?php
}
?>


            </a></li>

        </ol>
    </nav>

            <!-- end breadcrumb -->


            <!-- home link -->

                <!-- <a class="" href="<?php echo base_url() ?>">
                <?php echo display('home') ?>
                </a> -->

                <!-- get parent category link     -->

                <!-- end get parent category link -->


            <!-- end home link -->
        </div>

        <div class="col-12 col-md-9 text-center text-md-right">

            <!-- select order form -->
            <select name="selectsorting" class="selectbox mr-0 ml-0 mr-md-4 ml-md-4 mb-2 mb-md-0" style="" onchange="changeSortingBox(event)">
            <option  class="selectboxOption" value="null" style="text-align: center;" >

        <?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("Default Sorting");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("預設排序");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Penyortiran Default");
}
?>
            </option>
            <option class="selectboxOption"  value="lastest" style="text-align:center;" <?php if ($sorting == "lastest") {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("Newest to Oldest");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("最新產品排序");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Terbaru hingga Terlama");
}
?></option>
             <option class="selectboxOption" value="oldest" style="text-align:center;" <?php if ($sorting == "oldest") {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("Oldest to Newest");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("最舊產品排序");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Terlama hingga Terbaru");
}
?>
             </option>
            <option class="selectboxOption" value="priceasd" style="text-align:center;" <?php if ($sorting == "priceasd") {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("Price:Low to High");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("價格低至高排序");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Harga: Rendah ke Tinggi");
}
?></option>
            <option class="selectboxOption" value="pricedec" style="text-align:center;" <?php if ($sorting == "pricedec") {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("Price:High to Low");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("價格高至低排序");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("Harga: Tinggi ke Rendah");
}
?></option>
            </select>
<!--             <?php echo "sorting"; ?>
            <?php echo $sorting; ?> -->
            <!-- end select order form -->

            <!-- select box per page -->
<!--             <?php echo "displayorder"; ?>
            <?php echo $displayorder; ?> -->
            <select name="selectdisplay" class="selectbox" style="" onchange="changeSelectBox(event)">

           <!--  <option class="selectboxOption" value="1" style="text-align:center;" <?php if ($displayorder == 1) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("1 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示1個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("1 Item per halaman");
}
?></option>

            <option class="selectboxOption" value="2" style="text-align:center;" <?php if ($displayorder == 2) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("2 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示2個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("2 Item per halaman");
}
?></option>
            <option class="selectboxOption" value="3" style="text-align:center;" <?php if ($displayorder == 3) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("3 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示3個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("3 Item per halaman");
}
?></option> -->

            <option class="selectboxOption" value="6" style="text-align:center;" <?php if ($displayorder == 6) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("6 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示6個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("6 Item per halaman");
}
?></option>
            <option class="selectboxOption" value="9" style="text-align:center;" <?php if ($displayorder == 9) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("9 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示9個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("9 Item per halaman");
}
?></option>
             <option class="selectboxOption" value="18" style="text-align:center;" <?php if ($displayorder == 18) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("18 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示18個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("18 Item per halaman");
}
?></option>
            <option class="selectboxOption" value="27" style="text-align:center;" <?php if ($displayorder == 27) {echo "selected";}?>><?php
if ($this->session->userdata('language') == "english") {
	echo html_escape("27 Items per page");
}
if ($this->session->userdata('language') == "chinese") {

	echo html_escape("每頁顯示27個產品");
}
if ($this->session->userdata('language') == "indonesian") {
	echo html_escape("27 Item per halaman");
}
?></option>
            </select>
        </div>
            <script type="text/javascript">
            function changeSortingBox(e){
                    document.getElementById("sorting").value = e.target.value;
                    document.getElementById("plistform").submit();
            }
            function changeSelectBox(e) {
                    document.getElementById("displayorder").value = e.target.value;
                    // alert( e.target.value);
                    document.getElementById("plistform").submit();
            }

            </script>
            <!-- end select box per page -->




        </div>



            <!-- end inside category menu -->


            <!-- <div class="filter-row d-flex align-items-center justify-content-between mb-2"> -->
                <!-- <div class="filter-title"> -->
                    <?php if (!empty($after_search)) {
	?>
                        <h1 class="fs-21 mb-0 d-inline-block">
                            <?php echo html_escape($total) . " " . display('search_items') . '"' . $keyword . '"';
	?>
                    </h1>
                    <?php } else {?>
                  <!--   <h1 class="fs-21 mb-0 d-inline-block"><?php echo html_escape($category_name); ?></h1>
                    <span class="text-black-50">- <?php echo html_escape($total); ?> <?php echo display('items') ?></span> -->
                    <?php }?>
                <!-- </div> -->

                <!-- <a class="btn btn-warning color4 color46 text-white" href="<?php echo base_url() ?>"><i class="far fa-hand-point-left"></i> <?php echo display('back_to_home') ?></a> -->
            <!-- </div> -->
            <div class="row">
                <?php

$this->load->model('web/Wishlist');
if (!empty($category_product)) {
	foreach ($category_product as $product) {

		//check product is in wishlist
		$customer_id = $this->session->userdata('customer_id');
		$isWishList = $this->Wishlist->is_wishlist_product($product->product_id, $customer_id);
		//end check product is in wishlist

		?>

                <div class="col-6 col-sm-4 col-md-4 col-lg-4 col-xl-4 px-md-2 px-1">
                    <div class="feature-card card mb-3 " style="border-radius: 15px;position: relative;">
                        <?php

		// if ($product->onsale == 1 && !empty($product->onsale_price)) {
		?>
                        <div class="" style="position: absolute;z-index: 2;background-image: url('<?php echo base_url("my-assets/image/siteimage/arrow.png"); ?>');background-repeat: no-repeat;
 background-size: 95px;
  width: 95px;
  height: 50px;padding-left: 5px;" >
                            <p class="text-white " style="font-size: 1.1rem;">限量激減</p>

                             </div>
                        <?php
// } // if ($product->onsale == 1 && !empty($product->onsale_price)) {
		?>
                    <!-- clock -->
                    <?php
//calculate date time

		// $A = strtotime($A);

		// $todaydate = date('Y-m-d h:i:s a', time());
		// echo "today date" . $todaydate;

		// $product_time_datetimeobject = strtotime($product->limitedtime_time);
		// if ($product_time_datetimeobject <= time()) {
		// 	echo "ended";
		// } else {
		// 	echo "not ended";
		// }
		//end calculate date time

		?>
                    <?php
$dtNow = DateTime::createFromFormat('Y-m-d H:i:s', Date("Y-m-d H:i:s"));
		// $product_time_datetimeobject = strtotime($product->limitedtime_time);
		$endate = DateTime::createFromFormat('Y-m-d H:i:s', $product->limitedtime_time);
		if ($product->limitedtime == 1 && !empty($product->limitedtime_price) && $endate->getTimestamp() >= $dtNow->getTimestamp()) {
			?>
                    <div class="" style="position: absolute;z-index: 2;right: 0px;top:0px;">
                    <img src="<?php echo base_url("my-assets/image/siteimage/clock1.png"); ?>" class="clocksize" style="">
                    </div>

                <?php } //if ($product->onsale == 1 && !empty($product->onsale_price)) {
		?>
                    <!-- end clock -->


                        <div class="card-body text-center">

                            <a href="<?php echo base_url('product/' . remove_space($product->product_name) . '/' . $product->product_id) ?>" class="product-img d-block">
                                <?php if (@getimagesize($product->image_thumb) === false) {?>
                                <img src="<?php echo base_url() . '/my-assets/image/no-image.jpg' ?>" class="media-object img-fluid"
                                     alt="<?php echo html_escape($product->product_name) ?>">
                                <?php } else {?>
                                    <img class="img-fluid" src="<?php echo base_url() . $product->image_thumb ?>" alt="<?php echo html_escape($product->product_name) ?>">
                                <?php }?>
                            </a>
                            <h3 class="product-name fs-15 font-weight-600 overflow-hidden mt-2">
                                <a href="<?php echo base_url('product/' . remove_space($product->product_name) . '/' . $product->product_id) ?>" class="text-grey text-greylink">
                                    <!-- <?php echo html_escape($product->product_name) ?> -->
                                    <!-- added for multi language         -->
                                    <?php
if ($this->session->userdata('language') == "english") {
			echo html_escape($product->product_name);
		}
		if ($this->session->userdata('language') == "chinese") {
			echo html_escape($product->product_name_ch);
		}
		if ($this->session->userdata('language') == "indonesian") {
			echo html_escape($product->product_name_in);
		}

		?>
                                    <!-- end added for multi language -->
                                    </a>
                            </h3>

                            <!-- <div class="star-rating"> -->
                                <?php
// $result = $this->db->select('IFNULL(SUM(rate),0) as t_rates, count(rate) as t_reviewer')
		//          ->from('product_review')
		//          ->where('product_id', $product->product_id)
		//          ->where('status', 1)
		//          ->get()
		//          ->row();
		//      $p_review = (!empty($result->t_reviewer) ? $result->t_rates / $result->t_reviewer : 0);
		//      for ($s = 1; $s <= 5; $s++) {

//          if ($s <= floor($p_review)) {
		//              echo '<i class="fas fa-star"></i>';
		//          } else if ($s == ceil($p_review)) {
		//              echo '<i class="fas fa-star-half-alt"></i>';
		//          } else {
		//              echo '<i class="far fa-star"></i>';
		//          }
		//      }
		?>
                            <!-- </div> -->
                            <!-- new price row -->
                            <!-- <div class="product-price text-center"> -->
                            <div class="d-flex justify-content-between">
                                <div width="24" style="width:24px;"></div>
                            <?php if ($product->limitedtime == 1 && !empty($product->limitedtime_price) && $endate->getTimestamp() >= $dtNow->getTimestamp()) {
			?>
                                    <span>
                            <del class="text-grey">HK$
                                <?php echo (($position1 == 0) ? " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1); ?>
                            </del>
                            <br class="d-block d-md-none">
                           <!--  <span class="amount regular_price strikediag categoryonsaleprice">
                                <?php echo (($position1 == 0) ? $currency1 . " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1); ?>
                            </span> -->
                        <!-- </del> -->
                                    <!-- <ins class="fs-29 d-inline-block"> -->
                                        <span class="amount var_amount  weborange">
                                            <?php

			// if ($target_con_rate > 1) {
			//  $onsale_price = $product->onsale_price * $target_con_rate;
			//  echo (($position1 == 0) ? $currency1 . " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			// }

			// if ($target_con_rate <= 1) {
			//  $onsale_price = $product->onsale_price * $target_con_rate;
			//  echo (($position1 == 0) ? $currency1 . " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			// }
			if ($target_con_rate > 1) {
				echo "HK$";
				$limitedtime_price = $product->limitedtime_price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($limitedtime_price, 2, '.', ',') : number_format($limitedtime_price, 2, '.', ',') . " " . $currency1);
			}

			if ($target_con_rate <= 1) {
				echo "HK$";
				$limitedtime_price = $product->limitedtime_price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($limitedtime_price, 2, '.', ',') : number_format($limitedtime_price, 2, '.', ',') . " " . $currency1);
			}
			?>

                                    </span>

                                </span>

                            <?php } elseif ($product->onsale == 1 && !empty($product->onsale_price)) {
			?>
                                    <!-- <del class="Price-discount fs-14 text-black-50 font-weight-600 pl-1 price_discount"> -->
                            <span>
                            <del class="text-grey">HK$
                                <?php echo (($position1 == 0) ? " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1); ?>
                            </del>
                            <br class="d-block d-md-none">
                           <!--  <span class="amount regular_price strikediag categoryonsaleprice">
                                <?php echo (($position1 == 0) ? $currency1 . " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1); ?>
                            </span> -->
                        <!-- </del> -->
                                    <!-- <ins class="fs-29 d-inline-block"> -->
                                        <span class="amount var_amount  weborange">
                                            <?php

			// if ($target_con_rate > 1) {
			//  $onsale_price = $product->onsale_price * $target_con_rate;
			//  echo (($position1 == 0) ? $currency1 . " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			// }

			// if ($target_con_rate <= 1) {
			//  $onsale_price = $product->onsale_price * $target_con_rate;
			//  echo (($position1 == 0) ? $currency1 . " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			// }
			if ($target_con_rate > 1) {
				echo "HK$";
				$onsale_price = $product->onsale_price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			}

			if ($target_con_rate <= 1) {
				echo "HK$";
				$onsale_price = $product->onsale_price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($onsale_price, 2, '.', ',') : number_format($onsale_price, 2, '.', ',') . " " . $currency1);
			}
			?>

                                    </span>

                                </span>
                                <!-- </ins> -->


                            <?php
} //if($product->onsale==1 && !empty($product->onsale_price)){
		else {
//not onsale
			?>
            <span class="amount var_amount weborange">
              <?php
// if ($target_con_rate > 1) {
			//              $price = $product->price * $target_con_rate;
			//              echo (($position1 == 0) ? $currency1 . " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1);
			//          }

//          if ($target_con_rate <= 1) {
			//              $price = $product->price * $target_con_rate;
			//              echo (($position1 == 0) ? $currency1 . " " . number_format($price, 2, '.', ',') : number_format($price, 2, '.', ',') . " " . $currency1);
			//          }

			if ($target_con_rate > 1) {
				echo "HK$";
				$price = $product->price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($product->price, 2, '.', ',') : number_format($product->price, 2, '.', ',') . " " . $currency1);
			}

			if ($target_con_rate <= 1) {
				echo "HK$";
				$price = $product->price * $target_con_rate;
				echo (($position1 == 0) ? " " . number_format($price, 2, '.', ',') : number_format($price, 2, '.', ',') . " " . $currency1);
			}
			?>
    <?php
} //end not onsale
		?>
                                </span>
                                <br class="d-block d-md-none">
                                 <a href="javascript:void(0)" class="wishlist  productwish text-greylink" data-toggle="tooltip" data-placement="top"
                            title="" name="<?php echo html_escape($product->product_id) ?>">
                            <br class="d-block d-md-none">
                                <?php if ($isWishList == true) {?>
                                <i class="fa fa-heart" width="24" height="24"></i>
                            <?php } else {
			?>
                        <i class="far fa-heart" width="24" height="24"></i>

                                <?php
}?>

                                </a>
                            </div>
                            <!-- end new price row -->

                            <!-- <div class="product-price font-weight-bolder font-italic">
                            <?php

		if ($product->onsale == 1 && !empty($product->onsale_price)) {
			$price_val = $product->onsale_price * $target_con_rate;
		} else {
			$price_val = $product->price * $target_con_rate;
		}

		echo (($position1 == 0) ? $currency1 . number_format($price_val, 2, '.', ',') : number_format($price_val, 2, '.', ',') . $currency1);?> / <?php echo display('unit') ?></div>
 -->


                        </div>
                         <!-- added footer -->
                            <!-- <div className="card-footer border-0 rounded-bottom" style="background-color: #41e0fe;border-radius: 25px;">
            <small className="text-muted">Intermediate</small>
          </div> -->
                           <!--  <a href="<?php echo base_url('product/' . remove_space($product->product_name) . '/' . $product->product_id) ?>" class="text-black"> -->
                            <!-- <div className="mt-auto col-12 " style="background-color: #41e0fe;border-bottom-left-radius: 15px;border-bottom-right-radius: 15px;"> -->
                          <!--   <div className="mt-auto col-12 " style="background-color: <?php echo $product->color; ?>;border-bottom-left-radius: 15px;border-bottom-right-radius: 15px;">
                            <p class="my-0 py-md-2 py-3 text-center categorytext"> <?php
if ($this->session->userdata('language') == "english") {
			echo html_escape("Quick View");
		}
		if ($this->session->userdata('language') == "chinese") {
			echo html_escape("快速查看");
		}
		if ($this->session->userdata('language') == "indonesian") {
			echo html_escape("Quick View");
		}

		?></p>
                            </div> -->
                            <!-- </a> -->
                            <!-- end added footer -->
                    </div>
                </div>
            <?php }} else {?>
                <div class="col-md-12 text-center">
                    <h3 class='text-muted mt-3'><?php echo display('category_product_not_found'); ?></h3>
                <?php }?>
                </div>
                <div class="pt-2">
                    <!-- Pagination-->
                    <div class="pagination d-flex justify-content-center align-items-right">
                        <div class="column">
                            <?php echo htmlspecialchars_decode($links); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('adv/category_adv1', array('adv_position' => 2));?>

<!-- End OF category Mobile -->
<input type="hidden" name="category_id" id="category_id" value="<?php echo html_escape($category_id) ?>">
<input type="hidden" name="query_string" id="query_string" value="<?php echo $this->input->server('QUERY_STRING'); ?>">
<input type="hidden" name="brand_url_ids" id="brand_url_ids" value="<?php echo $this->uri->segment('3') ?>">
</div>
<input type="hidden" name="price_min_value" id="price_min_value" value="<?php echo html_escape($min_value) ?>">
<input type="hidden" name="price_max_value" id="price_max_value" value="<?php echo (!empty($max_value) ? html_escape($max_value) : 10000) ?>">
<input type="hidden" name="from_price" id="from_price" value="<?php echo html_escape($from_price) ?>">
<input type="hidden" name="to_price" id="to_price" value="<?php echo html_escape($to_price) ?>">
<input type="hidden" name="default_currency_icon" id="default_currency_icon" value="<?php echo (!empty($default_currency_icon) ? html_escape($default_currency_icon) : $currency1) ?>">
