<?php
 session_start();
 include 'config.php';
 $lang = 'en';
 $faq = $_GET['f'];

if(strlen($_SESSION['niveles'])>90 && strlen($_COOKIE['persistID'])<2)
{
    $responsefaqs = $_SESSION['niveles'];
    //echo $_SESSION['myArray'];
}
else{
	$curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => $endpoint_graph_cms,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS =>'{"query":"query MyQuery {\\r\\n  faqs(stage: PUBLISHED, where: {estatus: \\"publicado\\"}) {\\r\\n    archivo1\\r\\n    archivo2\\r\\n    archivo3\\r\\n    imagenEsquema\\r\\n    texto\\r\\n    titulo\\r\\n    slug\\r\\n    localizations {\\r\\n      archivo1\\r\\n      archivo2\\r\\n      archivo3\\r\\n      imagenEsquema\\r\\n      texto\\r\\n      titulo\\r\\n      slug\\r\\n    }\\r\\n  }\\r\\n  paginasFaqs(stage: PUBLISHED) {\\r\\n    imagenDerecha\\r\\n    imagenIzquierda\\r\\n    subtituloDePagina\\r\\n    tituloDePagina\\r\\n    slug\\r\\n    localizations {\\r\\n      imagenDerecha\\r\\n      imagenIzquierda\\r\\n      tituloDePagina\\r\\n      subtituloDePagina\\r\\n      slug\\r\\n    }\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
        CURLOPT_HTTPHEADER => array(
          'Content-Type: application/json',
          'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
        ),
      ));
   
  $responsefaqs = curl_exec($curl);
  $_SESSION['niveles'] = $responsefaqs;
  curl_close($curl);
}

$arrayfaqs = json_decode($responsefaqs, true);
//echo  $arrayfaqs;
$urles = "/niveles-servicio";
$urlen = "/service-levels";
//echo $responsefaqs;

if($lang == 'en'){
	///////INFO PÁGINA
	$titulopag = "Service Levels";
	$subtitulopag = $arrayfaqs['data']['paginasFaqs'][0]['subtituloDePagina'];
    $imagenDerecha =$arrayfaqs['data']['paginasFaqs'][0]['imagenDerecha'];
    $imagenIzquierda =$arrayfaqs['data']['paginasFaqs'][0]['imagenIzquierda'];
}
if($lang == 'es'){
	$titulopag = "Niveles de servicio";
	$subtitulopag = $arrayfaqs['data']['paginasFaqs'][0]['localizations'][0]['subtituloDePagina'];
    $imagenDerecha =$arrayfaqs['data']['paginasFaqs'][0]['localizations'][0]['imagenDerecha'];
    $imagenIzq =$arrayfaqs['data']['paginasFaqs'][0]['localizations'][0]['imagenIzq'];
}

?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <?php include '../include/generales.php'; ?>
			
        <style>
            .page-section {
                padding-top: 180px;
                padding-bottom: 30px;
            }
            .caja{
                    /* display: flex; */
                /* flex-flow: column wrap; */
                justify-content: center;
                align-items: center;
                height: 100%;
                overflow: hidden;
            }
            .box{
            /*width: 450px;*/
            /*height: 300px;*/
            overflow: hidden;
            }

            .box img{
            width: 100%;
            height: auto;
            }
            @supports(object-fit: cover){
                .box img{
                /*height: 100%;*/
                object-fit: cover;
                object-position: center center;
                }
            } 

            .padding-0{
                padding-right:0;
                padding-left:0;
            }

            .accordion a {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  width: 100%;
  padding: 1rem 3rem 1rem 1rem;
  color: #7288a2;
  font-size: 1.15rem;
  font-weight: 400;
  border-bottom: 1px solid #e5e5e5;
}

.accordion a:hover,
.accordion a:hover::after {
  cursor: pointer;
  color: #48aa42;
}

.accordion a:hover::after {
  border: 1px solid #48aa42;
}

.accordion a.active {
  color: #48aa42;
  border-bottom: 1px solid #48aa42;
}

.accordion a::after {
    font-family: 'Ionicons';
    content: '\f218';
    position: absolute;
    float: right;
    right: 1rem;
    font-size: 20px;
    color:#2b4365;
    padding: 0;
    width: 30px;
    height: 30px;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    border: 1px solid #2b4365;
    text-align: center;
}
.accordion a.active::after {
  font-family: 'Ionicons';
  content: '\f209';
  color: #48aa42;
  border: 1px solid #48aa42;
}

.accordion .content {
  display: none;
  padding: 1rem;
  border-bottom: 1px solid #e5e5e5;
  overflow: hidden;
}


.accordion {
    padding-top: 40px;
    font-family:"Montserrat", sans-serif;
}	
.accordion a {
    color:#2b4365!important;
    font-weight:bold;
    text-decoration:none;
}
.accordion-item {
    padding: 12.5px 0;


}
.accordion a.btndescarga {
    background: #48aa42;
    border-radius: 10px;
    display: inline-block;
    width: auto;
    color: #fff!important;
    transition: .35s all ease;
    font-size: 15px;
    margin-right: 15px;
    padding: 10px;
}
.accordion a.btndescarga:hover {
    background: #2b4365;
}
.accordion a.btndescarga:after {
    display:none;
}
a.btndescarga i {
    padding: 0 10px;
    
}
li::marker {
    color: #48aa42;
}
.content ul {
    padding-left: 15px;
}

.inactive { 
    opacity: .5;
    cursor: not-allowed;
}

.inactive * {
    pointer-events: none;
}

.accordion .content {
    text-align: center;
}
img.esquema {
    max-width: 750px;
    width: 100%;
    margin-bottom: 30px;
    margin-top: 20px;
}
.accordion .content h4 {
    font-size: 30px;
    margin-top: 30px;
}
.accordion .content h5 {
    opacity: .5;
}

.accordion-item .content img{
    max-width:750px;
}
    </style>
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    </head>
    <body id="page-top"  data-url = '<?php echo $page_url;?>'>
		
		<?php include '../include/nav2.php'; ?>

                <!-- Services-->
                <section class="page-section" id="services">
			<div class="container">
			  <div class="row">
			  	
				<div class="col-lg-12">
				  <h4 class="text-left">Service Levels (SLAs)</h4>
				</div>	
				
				  
				<div class="col-lg-12">
                <div class="container">

                <div class="accordion">


                <?php

                    if(strlen($_SESSION['nivelesDeServicios'])>90 && strlen($_COOKIE['persistID'])<2)
                    {
                        $responsenivelesDeServicios = $_SESSION['nivelesDeServicios'];
                        //echo $_SESSION['nivelesDeServicios'];
                    }
                    else{
                        $curl = curl_init();
                        curl_setopt_array($curl, array(
                            CURLOPT_URL => $endpoint_graph_cms,
                            CURLOPT_RETURNTRANSFER => true,
                            CURLOPT_ENCODING => '',
                            CURLOPT_MAXREDIRS => 10,
                            CURLOPT_TIMEOUT => 0,
                            CURLOPT_FOLLOWLOCATION => true,
                            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                            CURLOPT_CUSTOMREQUEST => 'POST',
                            CURLOPT_POSTFIELDS =>'{"query":"query MyQuery {\\r\\n  nivelesDeServicios(orderBy: orden_DESC, stage: PUBLISHED, where: {estatus_not: \\"oculto\\", estatus_not_contains: \\"eliminado\\"}) {\\r\\n    texto\\r\\n    orden\\r\\n    titulo\\r\\n    localizations {\\r\\n      enviadoRevision\\r\\n      estatus\\r\\n      id\\r\\n     texto\\r\\n      orden\\r\\n      titulo\\r\\n    }\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
                            CURLOPT_HTTPHEADER => array(
                            'Content-Type: application/json',
                            'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
                            ),
                        ));
                    $responsenivelesDeServicios = curl_exec($curl);
                    $_SESSION['nivelesDeServicios'] = $responsenivelesDeServicios;
                    curl_close($curl);
                    }
                    
                    //echo $responsenivelesDeServicios;
                    $arraynivelesDeServicios = json_decode($responsenivelesDeServicios, true);

                    foreach ($arraynivelesDeServicios['data']['nivelesDeServicios'] as $item) {
                        
                        if($lang == 'en'){
 
                                echo '
                                
                                <div class="accordion-item" id="'.$item['orden'].'">
                                    <a>'.urldecode($item['titulo']).'</a>
                                    <div class="content">
                                        '.urldecode($item['texto']).'
                                    </div>
                                </div>
                                
                                ';
                            
                            
                        }

                        if($lang == 'es'){

                            foreach ($item['localizations'] as $subitem) {
                              
                                echo '
                                
                                <div class="accordion-item" id="'.$subitem['orden'].'">
                                    <a>'.urldecode($subitem['titulo']).'</a>
                                    <div class="content">
                                        '.urldecode($subitem['texto']).'
                                    </div>
                                </div>
                                
                                ';
                            }
                            
                        }


                    }
                    ?>

                
               
                </div>

                </div>
				</div>	  
					
					  
				  
			  </div>	  
			</div>
			
			<br><br>
					
							
        </section>
		
    		<?php include '../include/footer.php'; ?>
		<script>
            $(document).ready(function() {
                $('.accordion a').click(function(){
                    $(this).toggleClass('active');
                    $(this).next('.content').slideToggle(400);
                });
                

                <?php
                if(strlen($faq)>2){
                    echo' 
                    
                    $("html, body").animate({
                            scrollTop: $("#'.$faq.'").offset().top - 140
                    }, 1000);

                    setTimeout(() => {
                        $("#'.$faq.' a").click();
                    }, 750);
                    
                    ';
                }
                ?>
            });
		</script>
    </body>
</html>
