<?php
 session_start();
 include '../config.php';
 $lang = 'en';
 $seccion = $_GET['m'];

if(strlen($_SESSION['guias'])>90 && strlen($_COOKIE['persistID'])<2)
{
    $responsemanuales = $_SESSION['guias'];
    //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  paginasManualesOperativos(stage: PUBLISHED) {\\r\\n    imagenDerecha\\r\\n    imagenIzquierda\\r\\n    slug\\r\\n    subtituloDePagina\\r\\n    tituloDePagina\\r\\n    localizations {\\r\\n      imagenDerecha\\r\\n      imagenIzquierda\\r\\n      slug\\r\\n      subtituloDePagina\\r\\n      tituloDePagina\\r\\n    }\\r\\n  }\\r\\n  guiasOperativas(stage: PUBLISHED, where: {estatus_not: \\"oculto\\"}) {\\r\\n    imagen\\r\\n    slug\\r\\n    localizations {\\r\\n      archivo\\r\\n      imagen\\r\\n      slug\\r\\n      texto\\r\\n      textoBoton\\r\\n      titulo\\r\\n    }\\r\\n    archivo\\r\\n    texto\\r\\n    textoBoton\\r\\n    titulo\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
        CURLOPT_HTTPHEADER => array(
          'Content-Type: application/json',
          'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
        ),
      ));
      
      
   
  $responsemanuales = curl_exec($curl);
  $_SESSION['guias'] = $responsemanuales;
  curl_close($curl);
}

$arraymanual = json_decode($responsemanuales, true);
//print_r ($arraymanual);
$urles = $arraymanual['data']['paginasManualesOperativos'][0]['localizations'][0]['slug'];
$urlen = $arraymanual['data']['paginasManualesOperativos'][0]['slug'];
//echo $responsemanuales;

//echo $urlen;
if($lang == 'en'){
	///////INFO PÁGINA
	$titulopag = $arraymanual['data']['paginasManualesOperativos'][0]['tituloDePagina'];
    $titulopag = "Operating Guides";
	$subtitulopag = $arraymanual['data']['paginasManualesOperativos'][0]['subtituloDePagina'];
    $imagenDerecha =$arraymanual['data']['paginasManualesOperativos'][0]['imagenDerecha'];
    $imagenIzquierda =$arraymanual['data']['paginasManualesOperativos'][0]['imagenIzquierda'];
}
if($lang == 'es'){
	$titulopag = $arraymanual['data']['paginasManualesOperativos'][0]['localizations'][0]['tituloDePagina'];
    $titulopag = "Guías operativas";
	$subtitulopag = $arraymanual['data']['paginasManualesOperativos'][0]['localizations'][0]['subtituloDePagina'];
    $imagenDerecha =$arraymanual['data']['paginasManualesOperativos'][0]['localizations'][0]['imagenDerecha'];
    $imagenIzquierda =$arraymanual['data']['paginasManualesOperativos'][0]['localizations'][0]['imagenIzquierda'];
}

$urles = "/guias-operativas";
$urlen = "/operating-guides";
?>

<!DOCTYPE html>
<html lang="es">
    <head>
        <?php include '../include/generales.php'; ?>
			
        <style>
            .page-section {
                padding-top: 160px;
                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 .content p {
    font-size: 13px;
    font-weight: 300;
    font-family: 'Noto Sans', sans-serif;
    color: #888;
}
.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;
    
}

.comunicado-bg.left {
    background-color: #eeeeee;
    padding: 20px 40px 20px 40px;
    margin-bottom: 50px;
    background-repeat: no-repeat;
    padding-left: 5%;
    background-size: 30% 100%;
    padding-right: 5%;
    box-shadow: 1px 2px 9px #c7c7c7;
}

h5.text-blue.my-3.text-uppercase {
    color: #48aa42!important;
    text-transform: none!important;
}

.col-md-12, .col-md-10  , .col-md-2{
    float:left;
}
.rounded {
    border-radius: 50%!important;
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 8px solid #48aa42;
}
.btn.btn-primary {
    float: right;
    margin-top: 15px;
}
@media(max-width:950px){

}
    </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"><?php echo $titulopag; ?></h4>
				</div>	
				
				  
				<div class="col-lg-12" style="margin-top: 30px;">
                <div class="container">

                <?php

                    foreach ($arraymanual['data']['guiasOperativas'] as $item) {
                            
                            if($lang == 'en'){

                                if(strlen($item['imagen'])<4){
                                    $imagen ="/assets/img/pdf.svg";
                                }
                                else{
                                    $imagen = $cloudfront.$item['imagen'];
                                }
                                if(strlen($item['textoBoton'])<2){
                                    $boton ="View Guide";
                                }
                                else{
                                    $boton = $item['textoBoton'];
                                }

                                if($item['textoBoton'] == "ENGLISH"){
                                    $boton ="View Guide";
                                    echo '
                                <div class="col-md-12 comunicado-bg left">
                                    <div class="overlay"></div>

                                    <div class="col-md-2">
                                        <img class="rounded" src="'.$imagen.'">
                                    </div>
                                    
                                    <div class="col-md-10">
                                        <h5 class="text-blue my-3 text-uppercase">'.urldecode($item['titulo']).'</h5>
                                        <p class="text-blue">'.urldecode($item['texto']).'</p>
                                        
                                        <a class="btn btn-primary btn-xl text-uppercase js-scroll-trigger btnmanual" href="'.$item['archivo'].'">'.urldecode($boton).'</a>
                                    </div>
                                    
                                </div>';

                                }
                                
                            }

                            if($lang == 'es'){

                                foreach ($item['localizations'] as $subitem) {
                                    if(strlen($subitem['imagen'])<4){
                                        $imagen ="/assets/img/pdf.svg";
                                    }
                                    else{
                                        $imagen = $cloudfront.$subitem['imagen'];
                                    }
                                    if(strlen($subitem['textoBoton'])<2){
                                        $boton ="Ver Guía";
                                    }
                                    else{
                                        $boton = $subitem['textoBoton'];
                                    }
                            
                            echo '
                                <div class="col-md-12 comunicado-bg left">
                                    <div class="overlay"></div>

                                    <div class="col-md-2">
                                        <img class="rounded" src="'.$imagen.'">
                                    </div>
                                    
                                    <div class="col-md-10">
                                        <h5 class="text-blue my-3 text-uppercase">'.urldecode($subitem['titulo']).'</h5>
                                        <p class="text-blue">'.urldecode($subitem['texto']).'</p>
                                        
                                        <a class="btn btn-primary btn-xl text-uppercase js-scroll-trigger btnmanual" href="'.$cloudfront.$subitem['archivo'].'">'.urldecode($boton).'</a>
                                    </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($seccion)>2){
                    echo' 
                    
                    $("html, body").animate({
                            scrollTop: $("#'.$seccion.'").offset().top - 140
                    }, 1000);

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