<?php
 header("Access-Control-Allow-Origin: *");
	$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  avisosDepositantes(orderBy: fijo_ASC, stage: PUBLISHED,where: {fijo_gt: 0, estatus: \\"publicado\\"} ) {\\r\\n    archivo\\r\\n    fijo\\r\\n  company\\r\\n    estatus\\r\\n    fecha\\r\\n    id\\r\\n    logo\\r\\n    resumen\\r\\n    slug\\r\\n    stage\\r\\n    titulo\\r\\n    localizations(locales: es_MX) {\\r\\n      archivo\\r\\n     fijo\\r\\n  company\\r\\n      estatus\\r\\n      fecha\\r\\n      id\\r\\n      logo\\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'
        ),
      ));
      
      
   
  $responseavisoslist2 = curl_exec($curl2);
 
  curl_close($curl);

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


<div class="col-lg-12 avisosfijos" style="position:relative;">

<i class="fas fa-thumbtack"></i>


                <?php

                    foreach ($arraylist2['data']['avisosDepositantes'] as $item) {

                      
                            if($lang == 'en'){

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

                                if(strlen($item['texto'])>0){
                                    $text = '<p class="text-blue">'.urldecode($item['texto']).'</p>';
                                }

                                $myDateTime = DateTime::createFromFormat('Y-m-d', $item['fecha']);
                                $fecha_es = $myDateTime->format('d/m/Y');
                                echo '
                                <div class="col-md-12 comunicado-bg left">
                                    <div class="overlay"></div>

                                    
                                    <div class="col-md-10">
                                         
                                        <h5 class="text-blue my-3 text-uppercase"><span style="display:none;">'.$fecha_es.'</span><i class="datenum">'.urldecode($item['company']).'</i></h5>
                                        '.$text.'
                                        
                                        
                                    </div>

                                    <div class="col-md-2">
                                        
                                        <a target="_blank" class="btn btn-primary btn-xl text-uppercase js-scroll-trigger" href="'.$cloudfront.$item['archivo'].'"><i class="fas fa-file-download"></i></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 ="Ver Aviso";
                                    }
                                    else{
                                        $boton = $subitem['textoBoton'];
                                    }

                                    if(strlen($subitem['texto'])>0){
                                        $text = '<p class="text-blue">'.urldecode($subitem['texto']).'</p>';
                                    }

                                    $myDateTime = DateTime::createFromFormat('Y-m-d', $subitem['fecha']);
                                    $fecha_es = $myDateTime->format('d/m/Y');
                                
                            
                            echo '
                                <div class="col-md-12 comunicado-bg left">
                                    <div class="overlay"></div>

                                    
                                    <div class="col-md-10">
                                         
                                        <h5 class="text-blue my-3 text-uppercase"><span style="display:none;">'.$fecha_es.'</span><i class="datenum">'.urldecode($subitem['company']).'</i></h5>
                                        '.$text.'
                                        
                                        
                                    </div>

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

                
                </div>