@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));
    }

    function cifrar($string, $key) {
	   $result = '';
	   for($i=0; $i<strlen($string); $i++) {
	      $char = substr($string, $i, 1);
	      $keychar = substr($key, ($i % strlen($key))-1, 1);
	      $char = chr(ord($char)+ord($keychar));
	      $result.=$char;
	   }
	   return base64_encode($result);
	}

    $centro_salud = $soapclient->AdministrarCatalogos_get_CentroSalud($_GET['centro_sal'], '',$wsClave);
    $CS  = new SimpleXMLElement(utf8_encode($centro_salud));
    $CS = $CS->respuesta;
   
    $data = $soapclient->Estadisticas_indicadoresUrgencias($_GET['fecha_inicio'],$_GET['fecha_fin'] , $_GET['centro_sal'], $wsClave);
    $data = new SimpleXMLElement($data);
    $notas = $data->respuesta;

    if(isset($notas->error)!= 0){
    die($notas->titulo);
  }
   /**/
  
 
@endphp

<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/jquery-3.1.0.min.js"></script>
<script src="js/notify.js"></script>

<style type="text/css">
	.page-headerL { font-size: 1.1em; font-weight: bold;  width: 100%; text-align: left;}

	.margenSuperior { margin-top: 5px; }
	.input-group{ margin-top: 5px; }

	.td{ border: 1px solid; border-color: #d2d6de; height: 30px; padding: 5px 10px; line-height: 1.3;}
	    
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<div class="box box-primary">

			<div class="box-body" id="espAgenda" name="espAgenda" style="width: 95%; margin: 0px auto; margin-top: 40px;">
				<div class="row alinear_centrado">
                    <div class="page-headerL" id="espacioAgenda" name="espacioAgenda">

                      <div>
    <div style="float:left;width: 30%;"> <img src="{{asset('img/insabi.png')}}" width="60%"></div>
    <div style="float:left;width: 40%;"><p align="center">SECRETAR&#205;A DE SALUD <br><?=recuperaCadena($CS->desc_centr)?> <BR>INFORMACI&#211;N RELEVANTE
    <br>INDICADORES DE PRODUCTIVIDAD <?=recuperaCadena($notas->yyyy)?> <br>URGENCIAS ATENDIDAS</p>
                   </div>    
    <div style="float:right;width: 30%;">  <img src="{{asset('img/salud.png')}}" width="60%" align="right"></div>    
</div>
<div style="clear:both"></div>
<div style="width: 97%;">
                        <div style="position: relative; text-align: right; font-weight: 600; margin-top: 5px;">Fecha de creacion: {{ date("d") . "/" . date("m") . "/" . date("Y"). ' ' . date("H") . ':' . date("i") }}</div>                          
                      </div>
                                               
                    </div>
                    <div class="row margenSuperior">

                      <div class="row">
                      <!--  <div class="col-sm-4" align="right">           -->                                         	
                          	                   	
                            <br>
                            <table ALIGN="left" width="100%">
                              <tbody>
                                <tr>
                                  <td rowspan="3" style="background: #eee;font-size:12px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>MES</strong></td>
                                  <td colspan="9" height="50px;" style="background: #eee;font-size:12px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>MOTIVO DE LA ATENCI&#211;N</strong></td>
                                  <td rowspan="3" style="background: #eee;font-size:12px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>TOTAL ATENCIONES</strong></td>
                                  <td colspan="7" rowspan="2" height="50px;" style="background: #eee;font-size:12px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>DESTINO DESPU&#201;S DE LA ATENCI&#211;N</strong></td>
                                </tr>
                                <tr>
                                  <td colspan="4" style="background: #eee;font-size:11px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>URGENCIA CALIFICADA</strong></td>
                                  <td colspan="5" style="background: #eee;font-size:11px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px"><strong>URGENCIA NO CALIFICADA</strong></td>
                                </tr>
                                <tr>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px; width: 10px;">Accidental, Envenenamiento y Violencias</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px; width: 10px;">MEDICA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">GINECO<br>OBSTETRICA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">PEDIATRIA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">Accidental, Envenenamiento y Violencias</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">MEDICA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">GINECO<br>OBSTETRICA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">PEDIATRIA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">APOYO A SERV MED GRAL</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">HOSP</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">CONSULTA EXT</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">OTRA UNIDAD</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">DOMICILIO</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">DEFUNCION</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">FUGA</td>
                                  <td style="background: #eee;font-size:9px;font-weight:400;line-height:1;color:#000000;text-align:center;background-color:#eee;border:1px solid #000000;border-radius:4px;width: 10px;">VOLUNTAD PROPIA</td>
                                </tr>
                                 <?php foreach ($notas as $key => $value) {
                              
                                  ?>
                                    <tr>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo $value->descripcionmes; ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->uc_accident)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->uc_medica)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->uc_gineco)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->uc_pediat)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->unc_accident)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->unc_medica)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->unc_gineco)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->unc_pediat)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->unc_apoyomedg)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->tot_aten)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->hosp)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->ce)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->otra)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->dom)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->def)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->fuga)); ?> </td>
                                      <td class="td" style="line-height:1;color:#555;text-align:center;border:1px solid #000000;border-radius:4px;width: 10px;" ><?php echo number_format(strval($value->vp)); ?> </td>
                                    </tr>    
                                    <?php } ?>   
                              </tbody>
                            </table>
                              

                            

                      <!--  </div> -->
                      </div>

                      
                      <div style="width: 97%;">
                      	<div style="position: relative; text-align: center; margin-top: 5px;"> </div>
                      </div>

                      

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