<?php
require_once("../include/AsignacionMod.php");
require_once("../include/AdquisicionMod.php");
require_once("../include/PersonaMod.php");
require_once("../include/ResasignacionMod.php");
ini_set('date.timezone','America/Lima');
$obm=new AsignacionMod();
$oaq=new AdquisicionMod();
$bea=new AdquisicionEnt();
$ope=new PersonaMod();
$ore=new ResasignacionMod();

if(!isset($_POST['bus'])){
	$bus="";
}else{
	$bus=$_POST['bus'];
}

if(!isset($_POST['asi'])){
	$asi="";
}else{
	$asi=$_POST['asi'];
}

if(!isset($_POST['fec'])){
	$fec="";
}else{
	$fec=$_POST['fec'];
}

$val=$obm->listarAsignacionTodos($bus,$asi,$fec);
?>
<?php 
if($val!=0){for($i=0;$i<count($val);$i++){
	$fv=$val[$i]->getFecha_ven();
	$i1=$val[$i]->getCod_entidad();
	$ie=(int)$i1;/*Codigo en modo entero*/
	$c2=$val[$i]->getNom_entidad();
	$ne=$i1." - ".$c2;
	$d5=$val[$i]->getDepart();
	$pv=$val[$i]->getProvin();
	$t6=$val[$i]->getDistri();
	$i3=$val[$i]->getIgv();
	$f4=$val[$i]->getNombreu();

	$vme=$oaq->mostrarTiempoAdquisicion($ie,'1');
	$vcl=$oaq->mostrarTiempoAdquisicion($ie,'2');
	$vmc=$oaq->mostrarTiempoAdquisicion($ie,'4');
	$vnd=$oaq->mostrarTiempoAdquisicion($ie,'5');
	
	$vpm=$ope->listarPersonaAsignacion($ie,'1');
	$vpc=$ope->listarPersonaAsignacion($ie,'2');
	$vec=$ope->listarPersonaAsignacion($ie,'4'); /*MYC*/
	$vod=$ope->listarPersonaAsignacion($ie,'5'); /*No definido*/
		
?>
<style>
	#thet<?=$i?>{
		width: 100%;
		min-width: 900px;
		height: 40px;
		background-color: #3E4095;
		display: flex;
		justify-content: center;
		align-content: center;
		flex-direction: column;
		float: left;
		border-bottom: 1px solid #646464;
		color: #FFFFFF;
	}
	#thet<?=$i?>:hover{
		background-color: #2F3073;
	}
</style>

<div id="thet<?=$i?>">
	<div>
		<span class="xh nb" style="width:4%;"><?=$fv?></span>
		<span class="xh nb" style="width:25%;text-align: left"><?=$i1?> - <?=$c2?></span>
		<span class="xh nb" style="width:16%;text-align: left">DEPARTAMENTO : <?=$d5?></span>
		<span class="xh nb" style="width:8%;text-align: left">PROVINCIA : <?=$pv?></span>
		<span class="xh nb" style="width:17%;text-align: left">DISTRITO : <?=$t6?></span>
		<span class="xh nb" style="width:8%;">EMPRESA : <?=$i3?></span>
		<span class="xh nb" style="width:18%;text-align: left">RESPONSABLES : <?=$f4?></span>
		<span class="xh nb" style="width:2%;">
			<span class="icon-menu" style="cursor: pointer;" onClick="verEntidadMenu('<?=$i1." - ".$c2?>');listarUsuaAsign('<?=$ie?>');"></span>
		</span>
		<span class="xh nb" style="width:2%;">
			<span class="icon-triangle-down" style="cursor: pointer;" onClick="myPersoDet<?=$i?>();"></span>
		</span>
	</div>
	<script>
		function myPersoDet<?=$i?>(){
			if ($('#listaPersoDet<?=$i?>').css('display') == 'none'){
				$('#listaPersoDet<?=$i?>').css('display','block');
				$('#thet<?=$i?>').css('background-color','#000000');
				$('.dot1').dotdotdot();
			}else{
				$('#listaPersoDet<?=$i?>').css('display','none');
				$('#thet<?=$i?>').css('background-color','#3E4095');
				$('.dot1').dotdotdot();
			}

		}
	</script>
</div> 

<div id="listaPersoDet<?=$i?>" style="display: none;">
	
	
	<!-- NO DEFINIDO -->
	<?php if($vod!=0){ ?>
	<div class="sthe">
		<div>
			<span class="xh nb" style="width:34%;">Programa : <b>NO DEFINIDO</b></span>
			<span class="xh nb" style="width:27%;">Fecha de vencimiento: <?php if($vnd==0) echo 'No definido';else echo $vnd->getFech_ven();?></span>
			<span class="xh nb" style="width:24%;">Tiempo : <?php if($vnd==0) echo 'No definido';else echo $vnd->getTiem_meses().' Meses';?></span>
			<span class="xh nb" style="width:15%;">&nbsp;</span>
		</div>
	</div> 
	<div class="ssst">
		<div>
			<span class="xhs nb" style="width:13%;">Persona :</span>
			<span class="xhs nb" style="width:12%;">Area :</span>
			<span class="xhs nb" style="width:9%;">Cargo :</span>
			<span class="xhs nb" style="width:13%;">Correo :</span>
			<span class="xhs nb" style="width:7%;">Celular :</span>
			<span class="xhs nb" style="width:40%;">Observaciones :</span>
			<span class="xhs nb" style="width:6%;">Herram :</span>
		</div>
	</div> 
	<div class='span4'>
		<ol class='limited_drop_targets<?=$i?> vertical cindd<?=$i?>'>
		<?php 
			for($n=0;$n<count($vod);$n++){
				$ndid=$vod[$n]->getIdpersona();
				$ndno=ucwords(strtolower($vod[$n]->getNomper()));
				$ndar=ucwords(strtolower($vod[$n]->getNomarea()));
				$ndca=ucwords(strtolower($vod[$n]->getNcargo()));
				$ndoc=ucwords(strtolower($vod[$n]->getCorreo()));
				$ndrp=$vod[$n]->getCelrpm();
				$ndtf=$vod[$n]->getTelfijo();
				$ndto=$vod[$n]->getTelofici();
				$ndrc=$vod[$n]->getCelrpc();
		?>
			<li class="highlight edgl<?=$i?>" style="text-align: center" id="<?=$ndid?>">
				<span style="width:13%;float: left"><?=$ndno?></span>
				<span style="width:12%;float: left"><?=$ndar?></span>
				<span style="width:9%;float: left"><?=$ndca?></span>
				<span class="do1" style="width:13%;float: left"><?php if($ndoc===''){echo'&nbsp;';}else{echo $ndoc;} ?></span>
				<span style="width:7%;float: left"><?php if($ndrp===''){echo'&nbsp;';}else{echo $ndrp;} ?></span>
				<span style="width:40%;font-size: 10px;float: left">
					<?php 
					$vand=$ore->listarResasignacion($ndid,$ie);
					if($vand!=0){
						for($o=0;$o<count($vand);$o++){ 
							$idnd=$vand[$o]->getIdresasig();
							$cond=$vand[$o]->getComentario();
							$fend=$vand[$o]->getFereg();
							$nund=$vand[$o]->getNombreu();
					?>
					<span style="margin-left:12px;">
						<?=$nund?> (<?=$fend?>) <span class="icon-note"></span>
					</span>
					<?php }}else{ ?>
					<span style="margin-left:12px;">
						Sin observaciones
					</span>
					<?php }?>
				</span>
				<span style="width:6%;cursor: pointer">
					<span class="icon-menu" onClick="verDetallesPersona('<?=$ndno?>');"></span>
				</span>
			</li>
		<?php }?>
		</ol>
	</div>
	<?php } ?>
	
	<!-- MELISSA -->
	<?php if($vpm!=0){?>
	<div class="sthe" style="margin-top: 10px;">
		<div>
			<span class="xh nb" style="width:34%;">Programa : <b>MELISSA</b></span>
			<span class="xh nb" style="width:27%;">Fecha de vencimiento: <?php if($vme==0) echo 'No definido';else echo $vme->getFech_ven();?></span>
			<span class="xh nb" style="width:24%;">Tiempo : <?php if($vme==0) echo 'No definido';else echo $vme->getTiem_meses().' Meses';?></span>
			<span class="xh nb" style="width:15%;cursor: pointer" onClick="verAgregarPersona('1','<?=$ne?>');">AGREGAR PERSONA <span class="icon-plus"></span></span>
		</div>
	</div>	
	<div class="ssst">
		<div>
			<span class="xhs nb" style="width:13%;">Persona :</span>
			<span class="xhs nb" style="width:12%;">Area :</span>
			<span class="xhs nb" style="width:9%;">Cargo :</span>
			<span class="xhs nb" style="width:13%;">Correo :</span>
			<span class="xhs nb" style="width:7%;">Celular :</span>
			<span class="xhs nb" style="width:40%;">Observaciones :</span>
			<span class="xhs nb" style="width:6%;">Herram :</span>
		</div>
	</div>
	<div class='span4'>
		<ol class='limited_drop_targets<?=$i?> vertical unodd'>
		<?php 
			for($k=0;$k<count($vpm);$k++){
				$mid=$vpm[$k]->getIdpersona();
				$mno=ucwords(strtolower(utf8_encode($vpm[$k]->getNomper())));
				$mar=ucwords(strtolower($vpm[$k]->getNomarea()));
				$mca=ucwords(strtolower($vpm[$k]->getNcargo()));
				$moc=ucwords(strtolower($vpm[$k]->getCorreo()));
				$mrp=$vpm[$k]->getCelrpm();
				$mtf=$vpm[$k]->getTelfijo();
				$mto=$vpm[$k]->getTelofici();
				$mrc=$vpm[$k]->getCelrpc();
		?>
		  	<li class="highlight edgl<?=$i?>" style="text-align: center" id="<?=$mid?>">
				<span style="width:13%;float: left"><?=$mno?></span>
				<span style="width:12%;float: left"><?=$mar?></span>
				<span style="width:9%;float: left"><?=$mca?></span>
				<span class="do1" style="width:13%;float: left"><?php if($moc===''){echo'&nbsp;';}else{echo $moc;} ?></span>
				<span style="width:7%;float: left"><?php if($mrp===''){echo'&nbsp;';}else{echo $mrp;} ?></span>
				<span style="width:40%;font-size: 10px;float: left">
					<?php 
					$vame=$ore->listarResasignacion($mid,$ie);
					if($vame!=0){
						for($p=0;$p<count($vame);$p++){ 
							$idme=$vame[$p]->getIdresasig();
							$come=$vame[$p]->getComentario();
							$feme=$vame[$p]->getFereg();
							$nume=$vame[$p]->getNombreu();
					?>
					<span style="margin-left:12px;">
						Edgard (25/12/2018) <span class="icon-note"></span>
					</span>
					<?php }}else{ ?>
					<span style="margin-left:12px;">
						Sin observaciones
					</span>
					<?php }?>
				</span>
				<span style="width:6%;cursor: pointer">
					<span class="icon-menu" onClick="verDetallesPersona('<?=$mno?>');"></span> 
				</span>
			</li>
		<?php }?>
		</ol>
	</div>
	<?php } ?>
	
	<!-- CLARISSA -->
	<?php if($vpc!=0){ ?>
	<div class="sthe" style="margin-top: 10px;">
		<div>
			<span class="xh nb" style="width:34%;">Programa : <b>CLARISSA</b></span>
			<span class="xh nb" style="width:27%;">Fecha de vencimiento: <?php if($vcl==0) echo 'No definido';else echo $vcl->getFech_ven();?></span>
			<span class="xh nb" style="width:24%;">Tiempo : <?php if($vcl==0) echo 'No definido';else echo $vcl->getTiem_meses().' Meses';?></span>
			<span class="xh nb" style="width:15%;cursor: pointer" onClick="verAgregarPersona('2');">AGREGAR PERSONA <span class="icon-plus"></span></span>
		</div>
	</div>
	<div class="ssst">
		<div>
			<span class="xhs nb" style="width:13%;">Persona :</span>
			<span class="xhs nb" style="width:12%;">Area :</span>
			<span class="xhs nb" style="width:9%;">Cargo :</span>
			<span class="xhs nb" style="width:13%;">Correo :</span>
			<span class="xhs nb" style="width:7%;">Celular :</span>
			<span class="xhs nb" style="width:40%;">Observaciones :</span>
			<span class="xhs nb" style="width:6%;">Herram :</span>
		</div>
	</div>
	<div class='span4'>
		<ol class='limited_drop_targets<?=$i?> vertical dosdd'>
		<?php 
			for($l=0;$l<count($vpc);$l++){
				$cid=$vpc[$l]->getIdpersona();
				$cno=ucwords(strtolower($vpc[$l]->getNomper()));
				$car=ucwords(strtolower($vpc[$l]->getNomarea()));
				$cca=ucwords(strtolower($vpc[$l]->getNcargo()));
				$coc=ucwords(strtolower($vpc[$l]->getCorreo()));
				$crp=$vpc[$l]->getCelrpm();
				$ctf=$vpc[$l]->getTelfijo();
				$cto=$vpc[$l]->getTelofici();
				$crc=$vpc[$l]->getCelrpc();
		?>
			<li class="highlight edgl<?=$i?>" style="text-align: center" id="<?=$cid?>">
				<span style="width:13%;float: left"><?=$cno?></span>
				<span style="width:12%;float: left"><?=$car?></span>
				<span style="width:9%;float: left"><?=$cca?></span>
				<span class="do1" style="width:13%;float: left"><?php if($coc===''){echo'&nbsp;';}else{echo $coc;} ?></span>
				<span style="width:7%;float: left"><?php if($crp===''){echo'&nbsp;';}else{echo $crp;} ?></span>
				<span style="width:40%;font-size: 10px;float: left">
					<?php 
					$vacl=$ore->listarResasignacion($cid,$ie);
					if($vacl!=0){
						for($q=0;$q<count($vacl);$q++){ 
							$idcl=$vacl[$q]->getIdresasig();
							$cocl=$vacl[$q]->getComentario();
							$fecl=$vacl[$q]->getFereg();
							$nucl=$vacl[$q]->getNombreu();
					?>
					<span style="margin-left:12px;">
						Edgard (25/12/2018) <span class="icon-note"></span>
					</span>
					<?php }}else{ ?>
					<span style="margin-left:12px;">
						Sin observaciones
					</span>
					<?php }?>
				</span>
				<span style="width:6%;cursor: pointer">
					<span class="icon-menu" onClick="verDetallesPersona('<?=$cno?>');"></span> 
				</span>
			</li>
		<?php }?>
		</ol>
	</div>
	<?php } ?>
	
	<!-- MYC -->
	<?php if($vec!=0){ ?>
	<div class="sthe" style="margin-top: 10px;">
		<div>
			<span class="xh nb" style="width:34%;">Programa : <b>MYC</b></span>
			<span class="xh nb" style="width:27%;">Fecha de vencimiento: <?php if($vmc==0) echo 'No definido';else echo $vmc->getFech_ven();?></span>
			<span class="xh nb" style="width:24%;"><?php if($vmc==0) echo 'No definido';else echo $vmc->getTiem_meses().' Meses';?></span>
			<span class="xh nb" style="width:15%;cursor: pointer" onClick="verAgregarPersona('4');">AGREGAR PERSONA <span class="icon-plus"></span></span>
		</div>
	</div>
	<div class="ssst">
		<div>
			<span class="xhs nb" style="width:13%;">Persona :</span>
			<span class="xhs nb" style="width:12%;">Area :</span>
			<span class="xhs nb" style="width:9%;">Cargo :</span>
			<span class="xhs nb" style="width:13%;">Correo :</span>
			<span class="xhs nb" style="width:7%;">Celular :</span>
			<span class="xhs nb" style="width:40%;">Observaciones :</span>
			<span class="xhs nb" style="width:6%;">Herram :</span>
		</div>
	</div>
	<div class='span4'>
		<ol class='limited_drop_targets<?=$i?> vertical cuadd'>
		<?php 
			for($m=0;$m<count($vec);$m++){
				$mcid=$vec[$m]->getIdpersona();
				$mcno=ucwords(strtolower($vec[$m]->getNomper()));
				$mcar=ucwords(strtolower($vec[$m]->getNomarea()));
				$mcca=ucwords(strtolower($vec[$m]->getNcargo()));
				$mcoc=ucwords(strtolower($vec[$m]->getCorreo()));
				$mcrp=$vec[$m]->getCelrpm();
				$mctf=$vec[$m]->getTelfijo();
				$mcto=$vec[$m]->getTelofici();
				$mcrc=$vec[$m]->getCelrpc();
		?>
			<li class="highlight edgl<?=$i?>" style="text-align: center" id="<?=$mcid?>">
				<span style="width:13%;float: left"><?=$mcno?></span>
				<span style="width:12%;float: left"><?=$mcar?></span>
				<span style="width:9%;float: left"><?=$mcca?></span>
				<span class="do1" style="width:13%;float: left"><?php if($mcoc===''){echo'&nbsp;';}else{echo $mcoc;} ?></span>
				<span style="width:7%;float: left"><?php if($mcrp===''){echo'&nbsp;';}else{echo $mcrp;} ?></span>
				<span style="width:40%;font-size: 10px;float: left">
					<?php 
					$vamc=$ore->listarResasignacion($mcid,$ie);
					if($vamc!=0){
						for($r=0;$r<count($vamc);$r++){ 
							$idmc=$vamc[$r]->getIdresasig();
							$comc=$vamc[$r]->getComentario();
							$femc=$vamc[$r]->getFereg();
							$numc=$vamc[$r]->getNombreu();
					?>
					<span style="margin-left:12px;">
						Edgard (25/12/2018) <span class="icon-note"></span>
					</span>
					<?php }}else{ ?>
					<span style="margin-left:12px;">
						Sin observaciones
					</span>
					<?php }?>
				</span>
				<span style="width:6%;cursor: pointer">
					<span class="icon-menu" onClick="verDetallesPersona('<?=$mcno?>');"></span> 
				</span>
			</li>
		<?php } ?>
		</ol>
	</div>
	<?php } ?>
</div>
<?php }}else{ ?>
<div class='span4'>
	<ol class='limited_drop_targets vertical'>
		<li class="highlight">Sin entidades asignadas</li>
	</ol>
</div>
<?php }?>
<script>
$(function(){
	$('.dot1').dotdotdot();
});

</script>

