<?php
 session_start();
 include '../config.php';
 $lang = $_GET['l'];
 $y = $_GET['y'];

 //echo $lang;

	$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  dividendosEventosSic(orderBy: fecha_DESC, stage: PUBLISHED, where: {estatus: \\"publicado\\"}) {\\r\\n    archivo\\r\\n   estatus\\r\\n    fecha\\r\\n    id\\r\\n    resumen\\r\\n    slug\\r\\n    stage\\r\\n    titulo\\r\\n    localizations(locales: es_MX) {\\r\\n      archivo\\r\\n            estatus\\r\\n      fecha\\r\\n      id\\r\\n    resumen\\r\\n      slug\\r\\n      stage\\r\\n      titulo\\r\\n    }\\r\\n  }\\r\\n}\\r\\n","variables":{}}',
        CURLOPT_HTTPHEADER => array(
          'Content-Type: application/json',
          'Cookie: __cfduid=da2693cdfd39b7377a8a05e305da45b8f1613001694'
        ),
      ));
      
      
   
  $responseavisoslist = curl_exec($curl);
 
  curl_close($curl);

$arraylist = json_decode($responseavisoslist, true);
//echo $responseavisoslist;
?>


<div class="col-lg-12">
                <div class="container" id="listado">

                <?php

                    foreach ($arraylist['data']['dividendosEventosSic'] as $item) {

                      
                            if($lang == 'en'){

                                if(strlen($item['imagen'])<4){
                                    $imagen ="/assets/img/pdf.svg";
                                }
                                if(strlen($item['textoBoton'])<2){
                                    $boton ="<i class='far fa-file-archive'> </i>";
                                }
                                else{
                                    $boton = $item['textoBoton'];
                                }
                                if(strlen($item['texto'])>0){
                                    $text = '<p class="text-blue">'.urldecode($item['texto']).'</p>';
                                }
                                echo '
                                    <div class="col-md-12 comunicado-bg left">
                                        <div class="overlay"></div>
    
                                        
                                        <div class="col-md-10">
                                            <span>'.$item['company'].'</span>
                                            <h5 class="text-blue my-3 text-uppercase">'.urldecode($item['titulo']).'</h5>
    
                                            '.$text.'
                                            
                                           
                                        </div>

                                        <div class="col-md-2">
                                            
                                            <a class="btn btn-primary btn-xl text-uppercase js-scroll-trigger" href="'.$cloudfront.$item['archivo'].'">'.$boton.'</a>
                                        </div>
                                        
                                    </div>';
                            }

                            if($lang == 'es'){

                                foreach ($item['localizations'] as $subitem) {
                                    if(strlen($subitem['imagen'])<4){
                                        $imagen ="/assets/img/pdf.svg";
                                    }
                                    if(strlen($subitem['textoBoton'])<2){
                                        $boton =" <i class='far fa-file-archive'> </i>";
                                    }
                                    else{
                                        $boton = $subitem['textoBoton'];
                                    }
                                    if(strlen($item['texto'])>0){
                                        $text = '<p class="text-blue">'.urldecode($subitem['texto']).'</p>';
                                    }
                            
                                    echo '
                                    <div class="col-md-12 comunicado-bg left">
                                        <div class="overlay"></div>
    
                                        
                                        <div class="col-md-10">
                                            <span>'.$item['company'].'</span>
                                            <h5 class="text-blue my-3 text-uppercase">'.urldecode($subitem['titulo']).'</h5>
    
                                            '.$text.'
                                            
                                           
                                        </div>

                                        <div class="col-md-2">
                                            
                                            <a class="btn btn-primary btn-xl text-uppercase js-scroll-trigger" href="'.$cloudfront.$subitem['archivo'].'">'.$boton.'</a>
                                        </div>
                                        
                                    </div>';
                                }
                                
                            }
                    
                    }
                ?>

                
                </div>
				</div>
                
                
                			
                <style>
          
          a.btndescarga i {
              padding: 0 10px;
              
          }
          
          .comunicado-bg.left {
              background-color: transparent;
              padding: 10px;
              margin-bottom: 0px;
              background-repeat: no-repeat;
              padding-left: 5%;
              background-size: 30% 100%;
              padding-right: 5%;
              box-shadow: 0;
              background-color: #eeeeee;
          }
          h5.text-blue.my-3.text-uppercase {
              color: #2b4365 !important;
              text-transform: none!important;
              padding: 0;
              margin: 0!important;
              font-size: 15px;
              padding-top: 7.5px;
          }
          .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;
          }
          .col-md-12.comunicado-bg.left span {
              float: right;
              letter-spacing: 2px;
              font-family: "Montserrat", sans-serif;
          }
          
          a.btn.btn-primary.btn-xl.text-uppercase.js-scroll-trigger {
              padding: 0;
              border: 0;
              font-size: 20px;
          }
          .col-md-12.comunicado-bg.left.even {
              background: #fff;
          }
              </style>
          
              <script>
                  $('#listado .comunicado-bg:nth-child(even)').addClass('even');
                  $('#listado .comunicado-bg:nth-child(odd)').addClass('odd');
              </script>