<?php
/**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License version 3.0
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
 */
if (!defined('_PS_VERSION_')) {
    exit;
}

class pagenavhelp extends Module {


    private $_name = 'spmreviewsadv';

    public function pagenav($start,$count,$step, $_data =null )
    {

        $custom_parameters = '';

        $prefix = isset($_data['prefix'])?$_data['prefix']:'';
        $action = isset($_data['action'])?$_data['action']:'';

        $is_rating_store = isset($_data['frat'])?$_data['frat']:0;
        $is_search = isset($_data['is_search'])?$_data['is_search']:0;
        $id_customer = isset($_data['id_customer'])?$_data['id_customer']:0;
        $id_product = isset($_data['id_product'])?$_data['id_product']:0;

        $is_sort = isset($_data['is_sort'])?$_data['is_sort']:0;


        $custom_parameter_product = $id_product?', '.$id_product.'':'';



        $custom_parameter = $id_customer?', '.$id_customer.'':$custom_parameter_product;


        if($id_customer && !$is_search && !$is_rating_store){
            $custom_parameters = ', \'\', \'\', '.$id_customer.'';
        }


        if($id_product && !$is_search && !$is_rating_store){
            $custom_parameters = ', \'\', \'\', '.$id_product.'';
        }


        if($is_rating_store){
            $custom_parameters = ', '.$is_rating_store.', \'\' '.$custom_parameter.'';
        }


        if($is_rating_store && $is_search){
            $custom_parameters = ', '.$is_rating_store.', 1 '.$custom_parameter.'';
        }

        if(!$is_rating_store && $is_search){
            $custom_parameters = ', \'\', 1 '.$custom_parameter.'';
        }

        if($is_sort){

            $custom_parameter_product_sort = Tools::strlen($custom_parameter_product) > 0 ? $custom_parameter_product : ($id_customer?', '.$id_customer.'':',\'\'');

            $custom_parameters = ', \'\', \'\' '.$custom_parameter_product_sort.', 1';
        }


        ob_start();
        include(dirname(__FILE__).'/../views/templates/hooks/'.$this->_name.'/'.__FUNCTION__.'.phtml');
        $res = ob_get_clean();

        return $res;
    }
}