<?php	
	$academia->instruccion("SELECT ide_adtivo, LCASE(CONCAT_WS(' ', no1_adtivo, no2_adtivo,ape1_adtivo, ape2_adtivo)) nom_ape FROM adm_administrativos WHERE cod_cargo=1 or cod_cargo=2 order by cod_cargo");
	$regFirmantes=$academia->fetchAll();
	$nom_rector=$regFirmantes[0]['nom_ape'];
	
	$sql="call SP_BOLETINES_INDIVIDUAL_GENERICO('$cod_estudiantes',$grupo,$periodon,'$iduser')"; 

	$academia->instruccion($sql);
	echo '<div style="display:none">'.$sql.'</div>';
	unset($sql);
	$row=$academia->extraer_registro();
	$dtsColegio=$sesion->get('info_colegio');
	$encabezado=$dtsColegio['enca_boletin_pres'];
	do{  
		echo '<div id="pageBoletin">';
		echo $encabezado;
		$notest=json_decode($row['notas'],true);
		$infcom=json_decode($row['comportamiento'],true);
		$cod_est=$notest['cd_est'];
		$msgPbar="id-".$notest[dc_est]."-pto-".$notest['pto_gru'];
		$msgPbar.="-grado-".$grado."-per-".$periodon.'-val-si-anio'.$sesion->get('anio');
	?>
	
	<table width="100%" style="border:1px solid; margin-bottom:2px; font-size: 8pt;  font-family: Arial, Helvetica, sans-serif;  vertical-align:top;">
		<tr align="left">
			<td ><strong>Id:</strong>&nbsp;&nbsp;<?php echo  $notest[dc_est]; ?></td>
			<td ><strong>Estudiante:</strong>&nbsp;&nbsp;<?php echo ucwords($notest[no_est]); ?></td>
			<td><strong>Grado:</strong> &nbsp;&nbsp;<?php echo $grado; ?></td>
			<td><strong>Puesto en el grupo:</strong>&nbsp;&nbsp; <?php echo $notest[pto_gru]; ?></td>
		</tr>
		<tr align="left">
			<td colspan="2"> <strong>Sede:</strong>&nbsp;&nbsp;<?php echo $sede;  $observa=""; ?></td>
			<td> <strong>Jornada:</strong>&nbsp;&nbsp;<?php echo $jornada; ?></td>
			<td> <strong>Periodo:</strong>&nbsp;&nbsp;<?php echo $periodo; ?></td>
		</tr>
	</table>

	
	
	<table width="100%" cellspacing="1" class='boletin'>
<tr>
<td width="20%" class='spancabecera'>Dimensión</td>
<td width="15%" class='spancabecera'>Desempeño</td>
<td width="60%" class='spancabecera'>Descripción </td>
</tr>

<?php 
$materias=$notest['materias'];	
foreach($materias as $rmat):
$historicos=$rmat['historicos'] 
?>
<tr>
<td ><?php echo ucfirst($rmat['no_asi']); ?></td>
<td align="center"><?php
$imagen = "images/preescolar/" . strtolower($rmat['nl']) . ".png";

?> <img src=<?php echo $imagen; ?> width="57" height="57" alt="<?php echo ucfirst($rmat['nl'])?>" >
<div> <?php echo ucfirst($rmat['nl']); ?></div></td>
<td> <?php echo ucwords($rmat['obs_asi']);
endforeach; 
?>


</table>
   
	<br />
	<table width="60%" cellspacing="1" class='boletin'>
	  <tr>
		<td colspan="3"  width="35%" ><div class='spancabecera'>FALTAS DE COMPORTAMIENTO</div></td>
		<td colspan="4"   width="65%"><div class='spancabecera'>NIVEL DE COMPORTAMIENTO</div></td>
	  </tr>
	  <tr>
		<td width="15%" rowspan="2"><div class='spancabecera'>LEVES</div></td>
		<td width="15%" rowspan="2"><div class='spancabecera'>GRAVES</div></td>
		<td width="15%" rowspan="2"><div class='spancabecera'>GRAVÍSIMAS</div></td>
		<td colspan="4" ><div class='spancabecera'>PERIODOS</div></td>
	  </tr>
		  <tr>
			<td width="11%"><div class='spancabecera'>1</div></td>
			<td width="11%"><div class='spancabecera'>2</div></td>
			<td width="11%"><div class='spancabecera'>3</div></td>
			<td width="12%"><div class='spancabecera'>4</div></td>
		  </tr>
	
   <?php
		$pierdex=$infcom['pierde'];
		foreach($infcom as $rcom):
			$faltas=$rcom['faltas'];
			$defcomporta=$rcom['hist'];
   ?>
	   <tr>
		 <td ><?php echo $faltas[0]; ?></td>
		 <td ><?php echo $faltas[1]; ?></td>
		 <td ><?php echo $faltas[2]; ?></td>
		 <td ><?php echo ucfirst($defcomporta[1]); ?></td>
		 <td ><?php echo ucfirst($defcomporta[3]); ?></td>
		 <td ><?php echo ucfirst($defcomporta[5]); ?></td>
		 <td ><?php echo ucfirst($defcomporta[7]); ?></td>
	   </tr>
	<?php 
	   endforeach; 
	?>
	
	</table>
<?php
	echo "<br/><div class='boletin'>OBSERVACIONES:</div>".  $observa;
?>
	<br><br>
	
<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr align="center">
			<td>_________________________________<br>
				<?php echo ucwords($nom_rector) ?><br>
				Rector
			</td>
			<td>_________________________________<br>
				<?php echo ucwords($nom_cordin) ?><br>
				Cordinador Académico
			</td>
		</tr>
		<tr align="center">
			<td colspan="2">
				<br><br><br>_________________________________<br>
				<?php echo ucwords($director) ?><br>
				Director de Grupo</td> 
		</tr>
	</table>
	<table id="foot" width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td width="6%" rowspan="2" align="center" valign="middle"><?php
				// user data
				$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
				$PNG_WEB_DIR = 'temp/';
				//ofcourse we need rights to create temp dir
				if (!file_exists($PNG_TEMP_DIR))
					mkdir($PNG_TEMP_DIR);
					
				$errorCorrectionLevel = 'L';
				$matrixPointSize = 1;
				//echo $msgPbar;
				$filename = $PNG_TEMP_DIR.'Boletin'.$cod_est.'_'.$sesion->get('academia_succes')."-".md5($errorCorrectionLevel.'|'.$matrixPointSize.'').'.png';
				QRcode::png($msgPbar, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
				echo '<img src="'.$PNG_WEB_DIR.basename($filename).'" class="codbar" />';
			?></td>
			<td align="center" valign="middle"><?php echo $sesion->getVar('info_colegio.pie_boletin') ?></td>
			<td width="6%" rowspan="2" align="right">&nbsp;</td>
		</tr>
		<tr>
			<td align="center"><span class="copy"><?php echo $dtsLang['project']['nom_soft'].' ' .$dtsLang['project']['ver_soft'].' '.$dtsLang['project']['footertext']." ".$dtsLang['project']['anio_ini'].' - '.date('Y') ?></span></td>
		</tr>
	</table>
	
<?php
	echo "</div>";//cirra la pagina
}while($row=$academia->extraer_registro());
$academia->liberar();
?>