@php

    use App\Libraries\ejLib;
    $var = ejLib::getInstance();
    $soapclient = $var->getWs();
    $wsClave = $var->get_wsClave();

    function recuperaCadena($cadena_entrante){       
        $cadena = $cadena_entrante;
        $cadena = utf8_decode($cadena);
        $cadena = str_replace('.*-*.br .*-*.', '<br>', $cadena);
        $cadena = str_replace('.*-*.b .*-*.', '<b>', $cadena);
        return trim(utf8_decode($cadena));
    }


    $data = $soapclient->Archivo_getLstAgendaVacunas($_GET['centro_sal'], $_GET['fecha'], $_GET['id_med_con'], $wsClave);
    $nConsult =  $soapclient->AdministrarConsultorios_get_Consultorio($_GET['id_consultorio'], $wsClave );
    $result = new SimpleXMLElement($nConsult);
    //  $data = utf8_decode($data);
   $data = str_replace('lt;br>', '', $data);
   $data = new SimpleXMLElement($data);

  $nombreMedico = $_GET['medico']; 
  if(isset($data->respuesta->error)==2){
    die("La agenda no cuenta con registros");
  }

  //print_r($data); die();
@endphp

<style type="text/css">
    .botonRefrescar{ font-size: 15px; color: #3bc647; cursor: pointer; }
    .tirar:hover{ font-size: 17px; color: red; cursor: pointer; }
   table {margin: 0px;}
    .header { width: 100%; }
    .logo { width: 200px; vertical-align: top; }
    .htd2 { text-align: center; font-size: 18px; font-weight: 700; padding: 0px; margin: 0px; }
    .htd3 { font-size: 10px; text-align: right; width: 200px; }
    .subtitulo { font-size: 10px; text-align: center; font-weight: 500; padding: 0px; margin: 0px; }
    .titulo { /*border-top: 1px solid #000000;*/ font-size: 22px; font-weight: 700; text-align: center; }
    .table2 { width: 100%; border-collapse: collapse; }
    .table2 tr, .table2 td { border: 1px solid black; }
    .text-center { text-align: center; }
    .table-bordered { border-collapse: collapse; }
    .table-bordered tr, .table-bordered td, .table-bordered th { border: 1px solid black; }

    .table_opt {width: 98%; }
    .table_opt tr {text-align: center;}
</style>

<div class= "box-body"> <!-- "box-header with-border"> -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <div class="box-tools pull-right">
        <table class="header" cellpadding="0" cellspacing="0">
          <tr>
            <td class="logo" rowspan="3"> 
                <img width="150" src="{{url('img/insabi.png')}}" alt="">
               
            </td>            
            <td height="14" class="htd2">{!!utf8_decode('SECRETARÍA DE SALUD')!!}</td>
                     
            <td class="htd3" rowspan="3">
              <img width="150" src="{{url('img/salud.png')}}" alt="">
                            
            </td>
          </tr>

          <tr>
            <td height="20" class="titulo">{!!utf8_decode('AGENDA VACUNACIÓN')!!}</td>
          </tr>
        </table>

         <table width="100%" style=" font-size: 12px;">
            <tr>
                <td>
                    <table align="center" class="table_opt" style="width: 100%;">
                        <tr>
                            <td style="text-align: left; font-size: 14px;">{!!utf8_decode('Médico:')!!}</td>
                        </tr>
                        <tr>
                            <td style="border-bottom: 1px solid #000; border-right: 1px solid #000; font-size: 12px; letter-spacing: 2px;"> {{utf8_decode($nombreMedico)}}</td>
                        </tr>
                    </table>
                </td>

                <td>
                    <table align="center" class="table_opt" style="width: 100%;">
                        <tr>
                            <td style="text-align: left; font-size: 14px;">{!!utf8_decode('Consultorio:')!!}</td>
                        </tr>
                        <tr>
                            <td style="border-bottom: 1px solid #000; border-right: 1px solid #000; font-size: 12px; letter-spacing: 2px;">{{utf8_decode($result->respuesta->no)}}</td>
                        </tr>
                    </table>
                </td>
                           
               
            </tr>
        </table>
        <br>

        <div class="col-sm-12">
           
                <table class="table" style="width: 100%;" >
                    <thead>
                    <tr>
                        <th style="border-bottom: 1px solid #000;  border-top: 1px solid #000; font-size: 14px; letter-spacing: 2px;" >FECHA </th>
                        <th style="border-bottom: 1px solid #000; border-top: 1px solid #000; font-size: 14px; letter-spacing: 2px;" >HORA</th>
                        <th style="border-bottom: 1px solid #000; border-top: 1px solid #000; font-size: 14px; letter-spacing: 2px;" >NOMBRE PACIENTE</th>                        
                        <th style="border-bottom: 1px solid #000; border-top: 1px solid #000; font-size: 14px; letter-spacing: 2px;" >VACUNAS</th>
                                          
                    </tr>
                    </thead>
                        
                        @foreach($data->respuesta as $vacunasAgendadas)
                            <tr >

                                <td style="border-bottom: 1px solid #000; font-size: 10px; letter-spacing: 2px;" >{{utf8_decode($vacunasAgendadas->fecha_cita)}}</td>
                                <td style="border-bottom: 1px solid #000; font-size: 10px; letter-spacing: 2px;">{{utf8_decode($vacunasAgendadas->hora_cita)}}</td>
                                <td style="border-bottom: 1px solid #000; font-size: 10px; letter-spacing: 2px;">{{utf8_decode(utf8_encode($vacunasAgendadas->nombre))}}</td>
                                <td style="border-bottom: 1px solid #000; font-size: 10px; letter-spacing: 2px;"><?=recuperaCadena(utf8_encode(str_replace('lt;br>','',$vacunasAgendadas->vacuna)))?></td>  
                                                         
                          
                            </tr>
                        @endforeach
                        
                       

                    </table>
               
            </div>






        


        


    </div>
</div>

