<?php
 session_start();
 include '../config.php';
 $lang = 'en';

if(strlen($_SESSION['alta'])>90 && strlen($_COOKIE['persistID'])<2)
{
    $responsealta = $_SESSION['alta'];
    //echo $_SESSION['alta'];
}
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  paginasHistoria( stage: PUBLISHED, ){\\r\\n    imagenDerecha\\r\\n    imagenIzquierda\\r\\n    subtituloDeLaPagina\\r\\n    titulo\\r\\n    localizations {\\r\\n      imagenDerecha\\r\\n      imagenIzquierda\\r\\n      subtituloDeLaPagina\\r\\n      titulo\\r\\n      misionVisionImagenDerecha\\r\\n      misionVisionImagenIzquierda\\r\\n      misionVisionTitulo\\r\\n      valores\\r\\n      vision\\r\\n      mision\\r\\n      altaDireccionImagen\\r\\n      altaDireccionTitulo\\r\\n    }\\r\\n    misionVisionImagenDerecha\\r\\n    misionVisionImagenIzquierda\\r\\n    misionVisionTitulo\\r\\n    valores\\r\\n    vision\\r\\n    mision\\r\\n    altaDireccionImagen\\r\\n    altaDireccionTitulo\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
        CURLOPT_HTTPHEADER => array(
          'Content-Type: application/json',
          'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
        ),
      ));
      
  $responsealta = curl_exec($curl);
  $_SESSION['alta'] = $responsealta;
  curl_close($curl);
}

$arrayalta = json_decode($responsealta, true);
//print_r($arrayalta);  
$urles = $arrayalta['data']['paginasHistoria'][0]['localizations'][0]['slug'];
$urlen = $arrayalta['data']['paginasHistoria'][0]['slug'];

$urles = '/alta-direccion';
$urlen = '/top-company-management';
//echo  "Es:".$urles." En:".$urlen;

if($lang == 'en'){
	///////INFO PÁGINA
    $titulopag = $arrayalta['data']['paginasHistoria'][0]['altaDireccionTitulo'];
    $imagenDerecha  = $arrayalta['data']['paginasHistoria'][0]['altaDireccionImagen'];
    
	
}
if($lang == 'es'){
    $titulopag = $arrayalta['data']['paginasHistoria'][0]['localizations'][0]['altaDireccionTitulo'];
    $imagenDerecha  = $arrayalta['data']['paginasHistoria'][0]['localizations'][0]['altaDireccionImagen'];

}

$curl2 = curl_init();
curl_setopt_array($curl2, 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  altoDirectivos(stage: PUBLISHED, where: {estatus_not: \\"oculto\\"}) {\\r\\n    nombre\\r\\n  cargo\\r\\n    imagen\\r\\n    texto\\r\\n    localizations {\\r\\n      cargo\\r\\n  nombre\\r\\n      imagen\\r\\n      texto\\r\\n    }\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/json',
      'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
    ),
  ));

  
$responsedirectivos = curl_exec($curl2);

curl_close($curl2);


$arraydirectivos = json_decode($responsedirectivos, true);
//print_r($arraydirectivos);
$titulopag = urldecode($titulopag);
?>

<!DOCTYPE html>
<html lang="en" translate="no">
    <head>
        <?php include '../include/generales.php'; ?>
		
        <style>
            section#services {
    padding-top: 160px;
}
.descarga {
    background-color: #48aa42 !important;
    width: 100%!important;
    min-height: 250px;
    float: left!important;
    color: #fff!important;
    text-align: left;
    padding: 1em!important;
    font-size: 2.2em;
    margin: 0!important;
	position: relative
}
		
.descarga-icon {
		
	position: absolute;
    bottom: 1em;
    right: 1em;3
}
			
.comunicado {
    height: auto;
    position: absolute;
    right: 0;
    z-index: 1;
    background-color: #48aa42;
    padding: 10px 110px 30px 40px;
    top: 447px;
}
		
.comunicado2 {
    height: auto;
    position: absolute;
    right: 0;
    z-index: 1;
    background-color: #9e9fb3;
    padding: 10px 110px 30px 40px;
    top: 796px;
}

.img-comunicado {
	max-width: 569px;
	height: 550px;
	position: absolute;
	right: 0;
	z-index:-1;
	background-color:#cdcdd4;
	padding-right: 0;
	padding-left: 0;
}
	

p {
    line-height: 1.75;
    color: #666;
}
.col-lg-4.img-int-01 {
    min-height: 200px;
}
.greenbar {
    bottom: -160px;
}


img {
    vertical-align: middle;
    border-style: none;
    max-width: 100%;
}
.greenbar {
    background-color: #48aa42;
    /* max-height: 170px; */
    /* margin-bottom: 170px !important; */
    position: absolute!important;
    right: 0;
    z-index: 1;
    padding: 280px 0!important;
    float: left;
    bottom: -330px;
    left: auto;
}
section#services ul {
    padding: 0 30px;
    color: #666;
}
section#services ul li {
    padding: 10px;
}
.col-lg-8 {
    padding-right: 10%;
}
img.infografia1 {
    margin-left: -15px;
    min-height: 400px;
    object-fit: cover;
}
.carousel {
    padding: 30px 0;
}
.directivo {
    padding: 0;
    position:relative;
}
.directivo img {
    width: 100%;
    margin: 0 auto;
    border-radius: 0%;
    height: auto;
    padding: 0;
    position: relative;
    z-index: 2;
    max-width: 200px;
    border-radius: 0%;
    border: 1.5px solid #2b4365;
}
.bgimage {
    background: #2b4365;
    position: absolute;
    width: 100%;
    left: 0;
    top: 115px;
    z-index: 1;
    height: 150px;
    display:none;
}

  .slick-dots li button:before {
    font-family: 'slick';
    font-size: 26px;
    line-height: 20px;
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    content: '•';
    text-align: center;
    opacity: .25;
    color: #2b4365;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.desc {
    padding: 15px 20px;
    font-size: 13px;
    text-align: justify;
}
.slick-prev:before, .slick-next:before {
    font-family: 'slick';
    font-size: 20px;
    line-height: 1;
    opacity: .75;
    color: #2b4365;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
}
.slick-next {
    right: -5%;
}
.slick-prev {
    left: 5%;
}
.directivo {
    border: none!important;
    outline:0!important;
}
.desc h4 {
    font-size: 17px;
    text-align: center;
    padding: 10px 10px 0;
}
@media(max-width:700px){
    .carousel {
    padding: 0;
}
    img.infografia1 {
    margin-left: -15px;
    min-height: 200px;
    object-fit: cover;
}
    h4, .h4 {
        font-size: 1.5rem;
        color: #2b4365;
    }
    section#services {
    padding-top: 90px;
}
.descarga {
    min-height: 10px;
}
.col-md-1.greenbar {
    display: none;
}
.row.enlacesinteres {
    margin-top: 80px;
}
.img-int-01 {
    width: 100%;
    height: 100px;
    margin-bottom: 40px;
}
}


.extendido {
    right: 0;
    position: absolute;
    margin-right: -15px;
}
.extendido img {
    height: 400px;
    width: 100%;
    object-fit: cover;
}
.title {
    margin: 0 0 30px 0;
}
.innerbox {
    background: rgba(205,205,212, 0.4);
    padding: 30px;
    margin-bottom: 30px;
}
.innerbox h5 {
    min-height: 60px;
}
h5 {
    font-size: 13px;
    text-align: center;
}
img.imgdirector {
    max-width: 200px;
    border-radius: 0%;
    border: 1.5px solid #2b4365;
}
.direct .desc{
    padding-left: 15px;
}
@media(max-width:1100px){
   .textodirector {
        padding-right: 10%;
    }
}

@media(max-width:768px){
    .carousel {
    padding: 0 10px;
    }
    .slick-prev {
        left: -5px!important;
    }
    .slick-next {
        right: -5px!important;
    }
    section#services {
        padding-top: 60px;
    }
    .extendido {
        right: 0;
        position: absolute;
        margin-right: 15px;
    }
    .title {
        margin: 70px 0 0;
    }
    .extendido img {
        height: 100px;
        width: 100%;
        object-fit: cover;
    }
    h4, .h4 {
        font-size: 2rem;
        color: #2b4365;
    }
}
    </style>


    </head>
    <body id="page-top" class="home" 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 title" style="vertical-align: center;">
                               

                                <div class="row direct">

                                    <div class="col-lg-12 title" style="vertical-align: center;">
                                        <h4 class="text-left"><?php echo $titulopag; ?></h4>
                                    </div>
                                    
                                    <?php 
                        foreach ($arraydirectivos['data']['altoDirectivos'] as $item) {
                            //echo urldecode($item['cargo']);
                                if(strlen($item['imagen'])<5){
                                    $img = '/assets/img/no-photo.jpg';

                                }
                                else{
                                    $img = $cloudfront.$item['imagen'];
                                }


                                if(urldecode($item['cargo']) == 'Director General Indeval' || urldecode($item['cargo']) == 'CEO S.D. Indeval'){

                                    if($lang == 'en'){
                                        echo '
                                        <div class="col-lg-4 text-center desc">
                                            <img src="'.$img.'" class="imgdirector">
                                            <h4>'.urldecode($item['nombre']).'</h4>
                                            <h5>'.urldecode($item['cargo']).'</h5>
                                        </div>	

                                        <div class="col-lg-7 textodirector">
                                            <p>'.urldecode($item['texto']).'</p>
                                        </div>';
                                    }
    
                                    if($lang == 'es'){
                                        foreach ($item['localizations'] as $subitem) {
                                            if(strlen($subitem['imagen'])<5){
                                                $img = '/assets/img/no-photo.jpg';
            
                                            }
                                            else{
                                                $img = $cloudfront.$subitem['imagen'];
                                            }
                                            echo '
                                            <div class="col-lg-4 text-center desc">
                                                <img src="'.$img.'" class="imgdirector">
                                                <h4>'.urldecode($subitem['nombre']).'</h4>
                                                <h5>'.urldecode($subitem['cargo']).'</h5>
                                            </div>	

                                            <div class="col-lg-7 textodirector">
                                                <p>'.urldecode($subitem['texto']).'</p>
                                            </div>';
                                        }
                                        
                                    }

                                }
                    

                                
                            
                        
                        }
                    ?>
                                    
                                    	
                                                
                                </div>
                            </div>	
                            
                            <div class="col-lg-2 padding-0 extendido">
                                <img src="<?php echo $cloudfront.$imagenDerecha;?>" class="padding-0 img-fluid">
                            </div>	
                                        
                        </div>	  
                    </div>
			<div class="container">
			  <div class="row">

                <div class="col-lg-12">
                  <div class="carousel">

                  <?php 
                        foreach ($arraydirectivos['data']['altoDirectivos'] as $item) {

                                if(strlen($item['imagen'])<5){
                                    $img = '/assets/img/no-photo.jpg';

                                }
                                else{
                                    $img = $cloudfront.$item['imagen'];
                                }

                                if(urldecode($item['cargo']) != 'Director General Indeval'  && urldecode($item['cargo']) != 'CEO S.D. Indeval'){

                                    if($lang == 'en'){
                                        echo '<div class="directivo">
                                            <div class="bgimage"></div>
                    
                                            <img src="'.$img.'">
                                            <div class="desc">
                                                <h4>'.urldecode($item['nombre']).'</h4>
                                                <h5>'.urldecode($item['cargo']).'</h5>
                                                <p>'.urldecode($item['texto']).'</p>
                                            </div>  
                    
                                        </div>';
                                    }
    
                                    if($lang == 'es'){
                                        foreach ($item['localizations'] as $subitem) {
                                            if(strlen($subitem['imagen'])<5){
                                                $img = '/assets/img/no-photo.jpg';
            
                                            }
                                            else{
                                                $img = $cloudfront.$subitem['imagen'];
                                            }
                                            echo '<div class="directivo">
                                            <div class="bgimage"></div>
                    
                                            <img src="'.$img.'">
                                            <div class="desc">
                                                <h4>'.urldecode($subitem['nombre']).'</h4>
                                                <h5>'.urldecode($subitem['cargo']).'</h5>
                                                <p>'.urldecode($subitem['texto']).'</p>
                                            </div>  
                    
                                        </div>';
                                        }
                                        
                                    }

                                }
                    

                                
                            
                        
                        }
                    ?>

                    
                    
                    

                  </div>
                 
                </div>
				
                
                
				
				  
			  </div>	  
			</div>
					
											
        </section>

                  		
            <?php include '../include/footer.php'; ?>
        
		<script>
            setTimeout(function(){
                $(window).trigger('resize');
                $('.carousel').slick({
                    infinite: true,
                    slidesToShow: 3,
                    slidesToScroll: 1,
                    lazyLoad: 'ondemand',
                    accessibility: true,
                    arrows: true,
                    dots:true,
                    autoplay: true,
                    responsive: [
                        {
                            breakpoint: 800,
                            settings: {
                                slidesToShow: 2,
                                slidesToScroll: 1
                            }
                        },
                        {
                            breakpoint: 500,
                            settings: {
                                slidesToShow: 1,
                                slidesToScroll: 1
                            }
                        } ],
                    autoplaySpeed: 5000,
                });
            }, 10)

		</script>
    </body>
</html>
