<?php
require_once("../class/class.conectar.php");
require_once("../class/class.horareprog.php");

$Objcon = new Conectar();
$conex = $Objcon->con();


if($_POST){
$idj = $_POST['idj'];
$idsa = $_POST['ids'];
$dia = $_POST['dia'];
$mm = $_POST['mes'];
$anno = $_POST['anno'];
$ugid = $_POST['ugid'];

$hrejepers = $_POST['hrejepers'];
$datosper = $_POST['datosper'];

date_default_timezone_set("America/Lima"); setlocale(LC_TIME,"es_PE.UTF-8");

$arrayhrejepers = array();
$arraydatosper = array();

$arrayhrejepers =  unserialize(stripslashes($hrejepers));
$arraydatosper =   unserialize(stripslashes($datosper));

//echo "No llego: ".htmlspecialchars(print_r($arraydatosper,true));
//print_r($arraydatosper,true);
//print_r($arrayhrejepers);
//echo "<BR>";
//print_r($arraydatosper);

function fechadia($i,$mm, $anno){

$dia= date("w",mktime( 0, 0, 0, $mm, $i, $anno )); 
switch ($dia) {
    case 0:
        $diafecha= 'DOMINGO';
		break;
    case 1:
        $diafecha= 'LUNES';
        break;
    case 2:
        $diafecha= 'MARTES';
        break;
	case 3:
        $diafecha= 'MIERCOLES';
        break;
	case 4:
        $diafecha= 'JUEVES';
        break;
	case 5:
        $diafecha= 'VIERNES';
        break;
	case 6:
        $diafecha= 'SABADO';
        break;
}
$arraymes = array();
$arraymes[] = array('idmes'=>'1','mes'=>'ENERO');
$arraymes[] = array('idmes'=>'2','mes'=>'FEBRERO');
$arraymes[] = array('idmes'=>'3','mes'=>'MARZO');
$arraymes[] = array('idmes'=>'4','mes'=>'ABRIL');
$arraymes[] = array('idmes'=>'5','mes'=>'MAYO');
$arraymes[] = array('idmes'=>'6','mes'=>'JUNIO');
$arraymes[] = array('idmes'=>'7','mes'=>'JULIO');
$arraymes[] = array('idmes'=>'8','mes'=>'AGOSTO');
$arraymes[] = array('idmes'=>'9','mes'=>'SETIEMBRE');
$arraymes[] = array('idmes'=>'10','mes'=>'OCTUBRE');
$arraymes[] = array('idmes'=>'11','mes'=>'NOVIEMBRE');
$arraymes[] = array('idmes'=>'12','mes'=>'DICIEMBRE');

$diafecha = $diafecha.", ".$i." DE ".$arraymes[$mm-1]['mes']." DEL ".$anno;

return $diafecha;
}



//echo $idsa."-".$dia."-".$mm."-".$anno."-".$ugid;

if(isset($arrayhrejepers)){
for($i=0;$i<count($arrayhrejepers);$i++){
//echo $arrayhrejepers[$i]."<br>";
$codprog = $arraydatosper[$i]['codprog'];
$idh = $arraydatosper[$i]['idh'];
$idga = $arraydatosper[$i]['idga'];
$ida = $arraydatosper[$i]['ida'];
$idtp = $arraydatosper[$i]['idtp'];
$tipohora = $arraydatosper[$i]['tipohora'];
//busca codigo del personal y el servicio
$sqlask ="SELECT ug_id as cod, s_id as ids FROM tb_usutrab where ut_codprog='$codprog' and tp_id='$idtp' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and ut_idserva='$idsa'";
//echo $sqlask."<br>"; 


$resultask = mysqli_query($conex,$sqlask);
if(mysqli_num_rows($resultask)!=0){
while($rowask = mysqli_fetch_array($resultask)){
$codper = $rowask['cod'];
$ids = $rowask['ids'];
}

$sqlinsertdel ="delete from tb_horaeje".$anno." where he_dia='$dia' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and he_idserva='$idsa'";
$resultinsertdel = mysqli_query($conex,$sqlinsertdel);
//consuta de la repro??
	$Objre = new HoraReprogramacion();
	$res_re = array();
	$res_re = $Objre->consulta_hrreprog_dia_tipohr($conex,$anno,$mm,$idj,$ids,$idsa,$idtp,$idh,$dia,$idga,$ida,$codper,$tipohora);
	if(count($res_re)>0){
			if($arrayhrejepers[$i]==1){
			$sqlinsert="insert into tb_horaeje".$anno." values ('$dia','$codprog','$ida','$idga','$idh','$idtp','$codper','$anno','$mm','$ids','$idj','$tipohora','$idsa','$ugid')";
			//echo $sqlinsert."<br>";
			$resultinsert = mysqli_query($conex,$sqlinsert);
			}
	}
}
}
}


$fecha =$dia."/".$mm."/".$anno;

echo "<table align='center'>";
echo "<tr><td colspan='10' align='center' class='LlenarTablaGarea'>";
echo fechadia($dia,$mm,$anno);
echo "</td></tr>";


$codigohora1='';
$matriz='';
//pregunta por el tipo de personal
$sqltpersonal = "select a.tp_id as cod, (select tp_desc from tb_tipoperson where tp_id=a.tp_id) as descripcion from tb_areatipopersona a where a.j_id='$idj' and a.s_id='$idsa' ";
$resulttpersonal = mysqli_query($conex,$sqltpersonal);
while ($rowtp= mysqli_fetch_array($resulttpersonal)){
$idtp= $rowtp['cod'];
$nomtp=$rowtp['descripcion'];
$matriz=$matriz."<tr><td colspan='10' align='center' class ='llenarTabla' >".$nomtp."</td></tr>";
$matriz=$matriz."<tr><td class ='llenarTabla' align='center'>AREA</td><td colspan='3' align='center' class ='llenarTabla' >".utf8_encode("MAŅANA")."</td><td colspan='3' align='center' class ='llenarTabla' >TARDE</td><td colspan='3' align='center' class ='llenarTabla' >NOCHE</td></tr>";
//busca el las areas a programar
$gareaprog="select distinct a.ga_id as idga, b.ga_desc as nomga from tb_horareprog".$anno." a inner join tb_garea b on a.ga_id = b.ga_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' order by idga";
$resultreprog = mysqli_query($conex,$gareaprog);
if(mysqli_num_rows($resultreprog)==0){
$matriz =$matriz."<tr><td colspan='10' align='center' class ='FacetDataTextC'>NO EXISTE PROGRAMACION DEL DIA </td></tr>";
}else{
while ($row= mysqli_fetch_array($resultreprog)){
$idga=$row['idga'];
$nomga=$row['nomga'];
$matriz=$matriz."<tr><td colspan='10' align='center' class='LlenarTablaGarea'>".$nomga."</td></tr>";
//pregunta por el area prog
$areaprog="select distinct a.a_id as ida, b.a_desc as noma from tb_horareprog".$anno." a inner join tb_area b on a.a_id = b.a_id and a.ga_id=b.ga_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' and a.ga_id='$idga' order by b.a_id";
$resultaprog = mysqli_query($conex,$areaprog);
if(mysqli_num_rows($resultaprog)==0){
$matriz =$matriz."<tr><td colspan='10' align='center' class ='FacetDataTextC'>PROGRAMACION LIBRE</td></tr>";
}else{
while ($rowap= mysqli_fetch_array($resultaprog)){
$codigohora='';
$cabmatriz='';
$matrizb='';
$ida=$rowap['ida'];
$noma=$rowap['noma'];
$matrizb=$matrizb."<tr><td width='110' class='facetfilaTD'>".$noma."</td>";
//pregunta por personal programado en la manana o diurno
$personalman="select a.ug_id as ugid, a.s_id as ids, a.ut_codprog as codprog, (select concat(left(ua_nom,2),'. ',ua_apepat,' ',left(ua_apemat,2),'.') from tb_usuasist where ug_id = a.ug_id) as apepat, c.h_id as idh, concat(date_format(c.h_horaini,'%k:%i %p'), ' - ',date_format(c.h_horafin,'%k:%i %p')) as hora,c.h_horaturn as turno, a.hr_tipohora as thora from tb_horareprog".$anno." a inner join tb_horario c on a.h_id = c.h_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' and a.ga_id='$idga' and a.a_id='$ida' and c.h_horaturn in ('D','M') and c.h_horatipo=1";
$resultperprogman = mysqli_query($conex,$personalman);
//echo $personalman."<br>";

if(mysqli_num_rows($resultperprogman)==0){
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'></td>";
$matrizb =$matrizb."<td width='150' align='center' colspan='3' class ='FacetDataTextC'>LIBRE</td>";

////pregunta por personal programado en la tarde sola
$personaltar="select a.ug_id as ugid, a.s_id as ids, a.ut_codprog as codprog, (select concat(left(ua_nom,2),'. ',ua_apepat,' ',left(ua_apemat,2),'.') from tb_usuasist where ug_id=a.ug_id) as apepat, c.h_id as idh, concat(date_format(c.h_horaini,'%k:%i %p'), ' - ',date_format(c.h_horafin,'%k:%i %p')) as hora, c.h_horaturn as turno, a.hr_tipohora as thora from tb_horareprog".$anno." a inner join tb_horario c on a.h_id = c.h_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' and a.ga_id='$idga' and a.a_id='$ida' and c.h_horaturn in ('T') and c.h_horatipo=1";
//echo $personaltar;
$resultperprogtar = mysqli_query($conex,$personaltar);
if(mysqli_num_rows($resultperprogtar)==0){
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'></td>";
$matrizb =$matrizb."<td width='150' align='center' colspan='3' class ='FacetDataTextC'>LIBRE</td>";
//$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'>LIBRE</td>";
}else{
while ($rowpt= mysqli_fetch_array($resultperprogtar)){
$codigohora=$codigohora.$rowpt['idh'];
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'>".$rowpt['hora']."</td>";
$matrizb =$matrizb."<td align='left' class ='FacetDataTextC'>".$rowpt['codprog']."</td>";
$matrizb =$matrizb."<td width='150' align='center' class ='FacetDataTextC'>".$rowpt['apepat'];
if($rowpt['thora']==1){
$matrizb =$matrizb." ( Ext ) ";
$arrayinfhrseje[] = array('codprog'=>$rowpt['codprog'],'idh'=>$rowpt['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>1);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>1);
}else{
$arrayinfhrseje[] = array('codprog'=>$rowpt['codprog'],'idh'=>$rowpt['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>0);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>0);
}
$matrizb =$matrizb."</td>";
$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'><input type='checkbox' name='hreje[]' ";
//pregunta
$codprog = $rowpt['codprog'];
$idh = $rowpt['idh'];
$codper = $rowpt['ugid'];
$idso = $rowpt['ids'];
$sqlask ="select he_dia from tb_horaeje".$anno." where he_dia='$dia' and ut_codprog='$codprog' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and ug_id='$codper' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and s_id ='$idso' and he_idserva='$idsa'";
$resultaskeje = mysqli_query($conex,$sqlask);
if(mysqli_num_rows($resultaskeje)!=0){
//terminapregunta
$matrizb =$matrizb." checked ";
}
$matrizb =$matrizb."></td>";
}}//termina la tarde sola

}else{
while ($rowp= mysqli_fetch_array($resultperprogman)){
if($rowp['turno']=='D'){
$codigohora=$codigohora.$rowp['idh'];
$cabmatriz =$cabmatriz."<td align='center' colspan='6' class='LlenarHorario'>".$rowp['hora']."</td>";
$matrizb =$matrizb."<td align='left' class ='FacetDataTextC'>".$rowp['codprog']."</td>";
$matrizb =$matrizb."<td width='300' align='center' colspan='4' class ='FacetDataTextC'>".$rowp['apepat'];
if($rowp['thora']==1){
$matrizb =$matrizb." ( Ext ) ";
$arrayinfhrseje[] = array('codprog'=>$rowp['codprog'],'idh'=>$rowp['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>1);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>1);
}else{
$arrayinfhrseje[] = array('codprog'=>$rowp['codprog'],'idh'=>$rowp['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>0);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>0);
}
$matrizb =$matrizb."</td>";
$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'><input type='checkbox' name='hreje[]'";
//pregunta
$codprog = $rowp['codprog'];
$idh = $rowp['idh'];
$codper = $rowp['ugid'];
$idso = $rowp['ids'];
$sqlask ="select he_dia from tb_horaeje".$anno." where he_dia='$dia' and ut_codprog='$codprog' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and ug_id='$codper' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and s_id ='$idso' and he_idserva='$idsa'";
//echo $sqlask;
$resultaskeje = mysqli_query($conex,$sqlask);
if(mysqli_num_rows($resultaskeje)!=0){
//terminapregunta
$matrizb =$matrizb." checked ";
}
$matrizb =$matrizb."></td>";
}
if($rowp['turno']=='M'){
$codigohora=$codigohora.$rowp['idh'];
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'>".$rowp['hora']."</td>";
$matrizb =$matrizb."<td align='left' class ='FacetDataTextC'>".$rowp['codprog']."</td>";
$matrizb =$matrizb."<td width='150' align='center' class ='FacetDataTextC'>".$rowp['apepat'];
if($rowp['thora']==1){
$matrizb =$matrizb." ( Ext ) ";
$arrayinfhrseje[] = array('codprog'=>$rowp['codprog'],'idh'=>$rowp['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>1);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>1);
}else{
$arrayinfhrseje[] = array('codprog'=>$rowp['codprog'],'idh'=>$rowp['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>0);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,tipohora=>0);
}
$matrizb =$matrizb."</td>";
$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'><input type='checkbox' name='hreje[]'";
//pregunta
$codprog = $rowp['codprog'];
$idh = $rowp['idh'];
$codper = $rowp['ugid'];
$idso = $rowp['ids'];
$sqlask ="select he_dia from tb_horaeje".$anno." where he_dia='$dia' and ut_codprog='$codprog' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and ug_id='$codper' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and s_id ='$idso' and he_idserva='$idsa'";
//echo $sqlask;
$resultaskeje = mysqli_query($conex,$sqlask);
if(mysqli_num_rows($resultaskeje)!=0){
//terminapregunta
$matrizb =$matrizb." checked ";
}
$matrizb =$matrizb."></td>";

//pregunta por personal programado en la tarde
$personaltar="select a.ug_id as ugid, a.s_id as ids, a.ut_codprog as codprog, (select concat(left(ua_nom,2),'. ',ua_apepat,' ',left(ua_apemat,2),'.') from tb_usuasist where ug_id=a.ug_id) as apepat, c.h_id as idh, concat(date_format(c.h_horaini,'%k:%i %p'), ' - ',date_format(c.h_horafin,'%k:%i %p')) as hora,c.h_horaturn as turno, a.hr_tipohora as thora from tb_horareprog".$anno." a inner join tb_horario c on a.h_id = c.h_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' and a.ga_id='$idga' and a.a_id='$ida' and c.h_horaturn in ('T') and c.h_horatipo=1";
//echo $personaltar;
$resultperprogtar = mysqli_query($conex, $personaltar);
if(mysqli_num_rows($resultperprogtar)==0){
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario' ></td>";
$matrizb =$matrizb."<td width='120' align='center' colspan='3' class ='FacetDataTextC'>LIBRE</td>";
}else{
while ($rowpt= mysqli_fetch_array($resultperprogtar)){
$codigohora=$codigohora.$rowpt['idh'];
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'>".$rowpt['hora']."</td>";
$matrizb =$matrizb."<td align='left' class ='FacetDataTextC'>".$rowpt['codprog']."</td>";
$matrizb =$matrizb."<td width='150' align='center' class ='FacetDataTextC'>".$rowpt['apepat'];
if($rowpt['thora']==1){
$matrizb =$matrizb." ( Ext ) ";
$arrayinfhrseje[] = array('codprog'=>$rowpt['codprog'],'idh'=>$rowpt['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>1);
}else{
$arrayinfhrseje[] = array('codprog'=>$rowpt['codprog'],'idh'=>$rowpt['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>0);
//$arrayinfhrseje[] = array(codprog=>$rowpt['codprog'],idh=>$rowpt['idh'],idga=>$idga,ida=>$ida,idtp=>$idtp,'tipohora'=>0);
}
$matrizb =$matrizb."</td>";
$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'><input type='checkbox' name='hreje[]' ";
//pregunta
$codprog = $rowpt['codprog'];
$idh = $rowpt['idh'];
$codper = $rowpt['ugid'];
$idso = $rowpt['ids'];
$sqlask ="select he_dia from tb_horaeje".$anno." where he_dia='$dia' and ut_codprog='$codprog' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and ug_id='$codper' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and s_id ='$idso' and he_idserva='$idsa'";
$resultaskeje = mysqli_query($conex, $sqlask);
if(mysqli_num_rows($resultaskeje)!=0){
//terminapregunta
$matrizb =$matrizb." checked ";
}
$matrizb =$matrizb."></td>";
}}}//fin manana
}}//fin del diruno o manana

//personal programado para la noche
$personalnoc="select a.ug_id as ugid, a.s_id as ids, a.ut_codprog as codprog, (select concat(left(ua_nom,2),'. ',ua_apepat,' ',left(ua_apemat,2),'.') from tb_usuasist where ug_id=a.ug_id) as apepat, c.h_id as idh, concat(date_format(c.h_horaini,'%k:%i %p'), ' - ',date_format(c.h_horafin,'%k:%i %p')) as hora,c.h_horaturn as turno, a.hr_tipohora as thora from tb_horareprog".$anno." a inner join tb_horario c on a.h_id = c.h_id where a.hr_dia='$dia' and a.uap_anno='$anno' and a.uap_mes='$mm' and a.hr_idserva='$idsa' and a.j_id='$idj' and a.tp_id='$idtp' and a.ga_id='$idga' and a.a_id='$ida' and c.h_horaturn in ('N') and c.h_horatipo=1";
$resultperprognoc = mysqli_query($conex, $personalnoc);

//echo $personalnoc;
if(mysqli_num_rows($resultperprognoc)==0){
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'></td></tr>";
$matrizb =$matrizb."<td width='150' align='center' colspan='3' class ='FacetDataTextC'>LIBRE</td></tr>";
}else{
while ($rowpn= mysqli_fetch_array($resultperprognoc)){
$codigohora=$codigohora.$rowpn['idh'];
$cabmatriz =$cabmatriz."<td align='center' colspan='3' class='LlenarHorario'>".$rowpn['hora']."</td></tr>";
$matrizb =$matrizb."<td align='left' class ='FacetDataTextC'>".$rowpn['codprog']."</td>";
$matrizb =$matrizb."<td width='150' align='center' class ='FacetDataTextC'>".$rowpn['apepat'];
if($rowpn['thora']==1){
$matrizb =$matrizb." ( Ext ) ";
$arrayinfhrseje[] = array('codprog'=>$rowpn['codprog'],'idh'=>$rowpn['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>1);
}else{
$arrayinfhrseje[] = array('codprog'=>$rowpn['codprog'],'idh'=>$rowpn['idh'],'idga'=>$idga,'ida'=>$ida,'idtp'=>$idtp,'tipohora'=>0);
}
$matrizb =$matrizb."</td>";
$matrizb =$matrizb."<td align='center' class ='FacetDataTextC'><input type='checkbox' name='hreje[]'";
//pregunta
$codprog = $rowpn['codprog'];
$idh = $rowpn['idh'];
$codper = $rowpn['ugid'];
$idso = $rowpn['ids'];
$sqlask ="select he_dia from tb_horaeje".$anno." where he_dia='$dia' and ut_codprog='$codprog' and a_id='$ida' and ga_id='$idga' and h_id='$idh' and tp_id='$idtp' and ug_id='$codper' and uap_anno='$anno' and uap_mes='$mm' and j_id='$idj' and s_id ='$idso' and he_idserva='$idsa'";
$resultaskeje = mysqli_query($conex, $sqlask);
if(mysqli_num_rows($resultaskeje)!=0){
//terminapregunta
$matrizb =$matrizb." checked ";
}
$matrizb =$matrizb."></td></tr>";
}
}//fin noche
//pone y evalua cabecera horario
if($codigohora1!=$codigohora){
$matriz =$matriz."<td class='LlenarHorario'></td>".$cabmatriz.$matrizb;
$codigohora1=$codigohora;
}else{
$matriz =$matriz.$matrizb;
}
}}//fin del area programada

}}//programacion de grupo area
}//fin tipo personal
//echo "<input type='hidden' id='datos[]' name='datos[]' value='".$arrayinfhrseje."'>";
$matriz =$matriz."</table>";
echo $matriz."<br>";
//session_start(); 
//for ($ii=0;$ii<count($arrayinfhrseje);$ii++){
//echo $arrayinfhrseje[$ii]['tipohora']."<br>";
//}
$datosper = serialize($arrayinfhrseje); 
echo "<input type='hidden' id='datosper' name='datosper' value='".$datosper."'>";
//$_SESSION['datosper']=$datosper;



//$cadena = "ejeprogramaciondia.php?idj=".$idj."&ids=".$idsa."&fecha=".$fecha."&ugid=".$ugid;
//header("Location:$cadena"); 

}
?>