<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php');?>
<?php include('php_session.php');?>
<?php

// include('../../_lib/php_gene1.php');
// include('../../_lib/php_session.php');
//include('php_session.php');
//$pagina_descri='REGISTRO DE DOCUMENTOS -'.time().' ';
$pagina_descri='REGISTRO DE PLANIFICACION ';
$pagina_nivel;
$pagina_tipo;

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<!-- <link rel="stylesheet" type="text/css" href="http://vcrxol.com/_lib/vrgets.css">   -->
<link rel="stylesheet" type="text/css" href="//vcrxol.com/_lib/vrgets.css<?php echo $jsver;?>">  
  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- <script type="text/javascript" src="http://vcrxol.com/_js/jquery-3.3.1.min.js"></script> -->
<!-- <script type="text/javascript" src="http://vcrxol.com/_js/js_gene1.js<?php //echo $jsver;?>"></script> -->
<!-- <script type="text/javascript" src="http://vcrxol.com/_js/js_ajax1.js<?php //echo $jsver;?>"></script> -->
   <link rel="stylesheet" media="all" href="//vcrxol.com/css/style.css<?php echo $jsver;?>" >
     
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://vcrxol.com/_js/js_gene1b.js<?php echo $jsver;?>"></script>
<script src="https://vcrxol.com/_js/js_ajax1b.js<?php echo $jsver;?>"></script>
<!-- <script src="https://vcrxol.com/_js/js_options1b.js<?php //echo $jsver;?>"></script> -->
<!-- <script src="https://vcrxol.com/_js/js_espe1b.js<?php //echo $jsver;?>"></script> -->
     
  
<title><?php echo $pagina_descri; ?></title>

<style type="text/css">
body{font-family: arial;}
/* body{font-family: courier new;} */
/* body input {font-family: courier new; font-size:14px} */
/* body button {font-family: courier new; font-size:14px;} */
/* body textarea {font-family: courier new; font-size:14px} */
.sub_deta{ padding-left:2px;}

#docu{border: solid 1px #000; width:40px; padding-left:2px; text-transform:uppercase;}
#bode{border: solid 1px #000; width:50px; padding-left:2px;}
#numero{border: solid 1px #000; width:80px; padding-left:2px; text-align:right;}
#numer{border: solid 1px #000; width:80px; padding-left:2px; text-align:right;}
#enti{border: solid 1px #000; width:110px; padding-left:2px;}
#concepto{border: solid 1px #000; resize:none;text-transform:uppercase;}
#fecha{border: solid 1px #000; width:150px; font-size:14px; padding-left:2px;}
#bod2{border: solid 1px #000; width:50px; padding-left:2px;}
@media print {

#reg_deta{ font-size:12px;}
/*.tablitita{ font-size:12px; border:none; }*/
#deta_cont{ display:none; visibility:hidden;}
#deta_txt{ display:none; visibility:hidden;}

#doculbl    { border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#docu       { border:none; background:none; color:#000; font-size:10px;}
#docu_descri{ border:none; background:none; color:#000; font-size:10px;}

#bodelbl    { border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#bode       { border:none; background:none; color:#000; font-size:10px;}
#bode_descri{ border:none; background:none; color:#000; font-size:10px;}
#numero{border:none; background:none; color:#000; font-size:10px;}
#numero_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#enti_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#enti {border:none; background:none; color:#000; font-size:10px;}
#concepto_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#concepto{border:none; background:none; color:#000; font-size:10px;}
#fecha_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#fecha{border:none; background:none; color:#000; font-size:10px;}
#table_cont_btn{ display:none;}
.e_detab{ display:none;}
#bode2_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#bod2{border:none; background:none; color:#000; font-size:10px;}
} 
</style>
<!-- <script type="text/javascript" src="../js/jquery-1.11.1.js"></script> -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
     
<script type="text/javascript">
function _graba_docu(){
var	enti=document.getElementById('enti').value;
var	docu=document.getElementById('docum').value;
var	numero=document.getElementById('numero').value;
var	fecha=document.getElementById('fecha').value;
var	concepto=document.getElementById('concepto').value;
var	valorpla=document.getElementById('valorpla').value;
var	empresa=document.getElementById('empresa').value;
var idnum='<?php echo $_GET['idnum'];?>';
//var enti2=document.getElementById('enti2').value;
var asub=document.getElementById('asub').value;
//var funcion=document.getElementById('funcion').value;
//var asignacion=document.getElementById('asignacion').value;
//var grupo=document.getElementById('grupo').value;
//var cant=document.getElementById('cant').value;
//var puni=document.getElementById('puni').value;
//var detalle=document.getElementById('detalle').value;
	
$.ajax({
		cache:false,
		url:'vrpla2.php',
		datatype: "text",
	  async:false,
		type:'POST',
		data:{
    idnum:idnum,
		docu:docu,
		numero:numero,
		fecha:fecha,
		enti:enti,
		asub:asub,
		valorpla:valorpla,
		empresa:empresa,
		concepto:concepto/*,
		enti2:enti2,
		
		funcion:funcion,
		asignacion:asignacion,
		grupo:grupo,
		cant:cant,
		puni:puni,
		detalle:detalle*/
		},
  	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
			//document.getElementById("sub_cont").innerHTML=dato;
			alert(dato);
			/*
	    var fin=$(dato).find("error").text();
			if(fin=='0')
			{
				document.getElementById('agregar').disabled=true;
				carga_tabla2();
			}
		*/	
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
			if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
			else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
			else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
			else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
			else if (exception === 'timeout') {alert('Servidor no Responde');}
			else if (exception === 'abort') {console.log('Ajax request aborted.');}
			else {console.log('Uncaught Error: ' + jqXHR.responseText);}
		}, 
	  complete:function(jqXHR, textStatus)
    	{if(textStatus==='success'){}},
		timeout:60000
	});


}

function _pla2(iddet){
	var ent2=document.getElementById('ent2_'+iddet).value;
	var cant=document.getElementById('cant_'+iddet).value;
	var idnum2='<?php echo $_GET['idnum'];?>';
	var detalle=document.getElementById('concepto_'+iddet).value;
	$.ajax({
		cache:false,
		url:'vrpla3.php',
		datatype: "text",
	  async:false,
		type:'POST',
		data:{
    	idnum2:idnum2,
		iddet:iddet,
		ent2:ent2,
		cant:cant,
		detalle:detalle
		},
  	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
			
			//document.getElementById("contenedor_auxiliar").innerHTML=dato;
			document.getElementById("msg_"+iddet).innerHTML=dato;
			console.log(dato);

			/*
	    var fin=$(dato).find("error").text();
			if(fin=='0')
			{
				document.getElementById('agregar').disabled=true;
				carga_tabla2();
			}
		*/	
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
			if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
			else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
			else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
			else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
			else if (exception === 'timeout') {alert('Servidor no Responde');}
			else if (exception === 'abort') {console.log('Ajax request aborted.');}
			else {console.log('Uncaught Error: ' + jqXHR.responseText);}
		}, 
	  complete:function(jqXHR, textStatus)
    	{if(textStatus==='success'){}},
		timeout:60000
	});


}	
function _borrar(iddet){ 
	var idnum2='<?php echo $_GET['idnum'];?>';

	$.ajax({
		cache:false,
		url:'vrpla4.php',
		datatype: "text",
	async:false,
		type:'POST',
		data:{
    	idnum2:idnum2,
		iddet:iddet},
  	beforeSend: function(jqXHR, textStatus){}, 
	success:function(dato, textStatus, jqXHR){ 
			if($(dato).find("dd_idxidnum").text()=='ok'){ document.getElementById('tr_'+iddet).style.display='none'; console.log('entro'); }
			document.getElementById('tr_'+iddet).style.display='none';
		},
	error:function(jqXHR,textStatus,errorThrown )
		{
			if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
			else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
			else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
			else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
			else if (exception === 'timeout') {alert('Servidor no Responde');}
			else if (exception === 'abort') {console.log('Ajax request aborted.');}
			else {console.log('Uncaught Error: ' + jqXHR.responseText);}
		}, 
	complete:function(jqXHR, textStatus)
    	{if(textStatus==='success'){}},
		timeout:60000
	});
}
function _insertar(iddet){ 
	var idnum2='<?php echo $_GET['idnum'];?>';
	var asub=document.getElementById('asub_'+iddet).innerHTML;
	var	numero=document.getElementById('numero').value;
	var	docu=document.getElementById('docum').value;

	$.ajax({
		cache:false,
		url:'vrpla5.php',
		datatype: "text",
	async:false,
		type:'POST',
		data:{
		asub:asub,
		numero:numero,
		docu:docu,
    	idnum2:idnum2,
		iddet:iddet},
  	beforeSend: function(jqXHR, textStatus){}, 
	success:function(dato, textStatus, jqXHR){
			console.log(dato);
		},
	error:function(jqXHR,textStatus,errorThrown )
		{
			if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
			else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
			else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
			else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
			else if (exception === 'timeout') {alert('Servidor no Responde');}
			else if (exception === 'abort') {console.log('Ajax request aborted.');}
			else {console.log('Uncaught Error: ' + jqXHR.responseText);}
		}, 
	complete:function(jqXHR, textStatus)
    	{if(textStatus==='success'){}},
		timeout:60000
	});
}

function _insertatfle(){
	var asub=document.getElementById('asub').value;
	var	numero=document.getElementById('numero').value;
	var	docu=document.getElementById('docum').value;

	$.ajax({
		cache:false,
		url:'vrpla6.php',
		datatype: "text",
	async:false,
		type:'POST',
		data:{
		idnum2:'<?php echo $_GET['idnum']?>',	
		asub:asub,
		numero:numero,
		docu:docu},
  	beforeSend: function(jqXHR, textStatus){}, 
	success:function(dato, textStatus, jqXHR){  
			document.getElementById('sub_cont').innerHTML=dato;
			
		},
	error:function(jqXHR,textStatus,errorThrown )
		{
			if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
			else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
			else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
			else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
			else if (exception === 'timeout') {alert('Servidor no Responde');}
			else if (exception === 'abort') {console.log('Ajax request aborted.');}
			else {console.log('Uncaught Error: ' + jqXHR.responseText);}
		}, 
	complete:function(jqXHR, textStatus)
    	{if(textStatus==='success'){}},
		timeout:60000
	});



}	
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>
<?php include('../../_js/hora_format.js');?>
<?php include('../../_js/deledeta.js');?>
	
	
</script>


</head>

<body>
<?php include('../../_lib/cabecera2.php');?>
<?php

  $pla_sql='select * from plan1 where idnum1="'.$_GET['idnum'].'"';
  $pla_res=msql_query($pla_sql,$link_vcrx);
  
  $pla_docu=@msql_result($pla_res,0,'docu');
  $pla_fecha=@msql_result($pla_res,0,'fecha');
  $pla_numero=@msql_result($pla_res,0,'numero');
  $pla_enti=@msql_result($pla_res,0,'enti');
  $pla_valorpla=@msql_result($pla_res,0,'valorpla');
  $pla_empresa=@msql_result($pla_res,0,'empr1');
  $pla_concepto=@msql_result($pla_res,0,'concepto');


?>

<?php ?>
<table>
<tr valign="top">
<td>
	<table cellspacing="0" cellpadding="2" width="100%" style="font-size:14px;">
    <tr><?php $pcaption='DOCU'; $ptabla='docu';$pdefa=$_GET['docu']; $pidtxt="docum"; $pobj=3; $preado=1; include('vrgetcod.php'); ?>  </tr>
    <tr id="tr_numero" style="" valign="center"><?php $pcaption='NUMERO'; $pidtxt='numero';$pdefa=$pla_numero;  $plong=9; $ponblur='_numero(event);';  $preado=1;include('vrgetnum.php'); ?></tr>
    <tr id="tr_enti" style="" valign="top"><?php $pcaption='ENTIDAD'; $ptabla='enti'; $pidtx='enti'; $ponblur='enti(event,'.$empr_ruc.');'; $ponchange='';$pdefa=$pla_enti;  include('vrgetcod.php'); ?></tr>
    </table>
</td>
<td>
	<table>
        <tr><?php $pcaption='_FECHA_'; $pidtxt="fecha"; $pobj=3; include('vrgetfec.php'); ?> </tr>
        <tr>
          <?php
            $pidtxt='valorpla'; $pcaption='VALORACION';  $pdefa=$pla_valorpla; include('vrgetval.php');
          ?>
        </tr>
        <tr>
          <?php
            $pidtxt='empresa'; $pcaption='EMPRESA'; $plong=4; $pdefa=$pla_empresa; $poptions='TFLE;SCIE'; include('vrselopt.php');
          ?>
        </tr>
        <tr id="tr_concepto" style="" valign="top"><?php $pdefa=$pla_concepto; $pcaption='CONCEPTO'; $pidtxt='concepto'; $plong=40; $prows=5;include('vrgettxt.php'); ?></tr>
        <tr style="" align="right" valign="top"><td></td><td><input type="button"  tabIndex="-1"  value="GUARDAR" onClick="if(confirm('Registrar Detalle?')){_graba_docu();}" /></td></tr>    
    </table>
</td>
</tr>

<tr>
<td colspan="2">
			<table>
		    <tr><?php $pcaption='actividad'; $ptabla='asub'; $pidtxt="asub"; $pobj=3; include('vrgetcod.php'); ?>
		    <td><input type="button" value="Insertar" onClick="_insertatfle();"></td></tr>
		    </table>



</td>

</tr>
</table>




<div id="contenedor_auxiliar"></div>
<div id="sub_cont">
<?php 
$pla_sql='select * from plan2 where idnum2="'.$_GET['idnum'].'" order by asub, iddet';
$pla_res=msql_query($pla_sql,$link_vcrx);
if(msql_num_rows($pla_res)!=0){?>
<table cellpadding="4" style="border-collapse:collapse;">
    <tr style="background:#F2F2F2;">
    <th></th>
    	<th>ACTIVIDAD</th>
        <th>DESCRI</th>
        <th>HORAS</th>
        <th>RECURSO</th>
        <th>NOMBRE</th>
        
<!--        <th>FUNCION</th>
        <th>ASIGNACION</th>
        <th>GUPO</th>-->
        
        <th>COSTO</th>
        <th>DETALLE</th>
        <th>ACCION</th>
    
        <td></td>
    </tr>

<?php $i=1; while($pla_r=msql_fetch_assoc($pla_res)){?>
    <tr align="left" id="tr_<?php echo $pla_r['iddet'];?>" valign="top" style="  <?php if($i%3==0){echo 'border-bottom:#000 dotted 1px;';}$i++; ?>">
    <td><input type="button" value="I" onClick="_insertar('<?php echo $pla_r['iddet'];?>');"></td>
	<td><span id="asub_<?php echo $pla_r['iddet'];?>"><?php echo $pla_r['asub'];?></span></td>
    <td><span id="asub_<?php echo $pla_r['iddet'];?>"><?php echo r_fiel('asub',$pla_r['asub'],$campo="descri",$valor="");?></span></td>
    <?php if( substr($pla_r['asub'],-4)=='0000'){echo '<td></td><!-- ';} $pcaption='CANT.'; $pidtxt='cant_'.$pla_r['iddet']; $plong=5; $pobj=1; $pdefa=number_format($pla_r['cant'],2); include('vrgetval.php'); if( substr($pla_r['asub'],-4)=='0000'){echo '--> ';} ?>
	<td><?php $pcaption='RECURSO'; $ptabla='enti'; $pidtxt='ent2_'.$pla_r['iddet']; $pobj=5;  $pdefa=$pla_r['enti2']; if( substr($pla_r['asub'],-4)!='0000'){include('vrgetcod.php');} ?> </td>
    <td><?php if( substr($pla_r['asub'],-4)!='0000'){ echo r_fiel('enti',$pla_r['enti2'],'nom1').' '.r_fiel('enti',$pla_r['enti2'],'ape1');}?></td>
    
<!--    <td><?php echo $pla_r['funcion'];?></td>
    <td><?php echo $pla_r['asignacion'];?></td>
    <td><?php echo $pla_r['grupo'];?></td>-->
<!--    <td><input type="text" value="<?php echo $pla_r['cant'];?>"  id="cant_<?php echo $pla_r['iddet'];?>" /></td>-->
    
    <td align="right"><?php if( substr($pla_r['asub'],-4)!='0000'){echo $pla_r['puni'];}?></td>
    <td><?php $pcaption='CONCEPTO'; $pidtxt='concepto_'.$pla_r['iddet']; $plong=20; $prows=2; $pdefa=$pla_r['detalle']; $pobj=1; include('vrgettxt.php'); ?></td>
    <td><input type="button"  value="Actualizar" id="btn2_<?php echo $pla_r['iddet'];?>"  onClick="_pla2('<?php echo $pla_r['iddet'];?>');" ></td>
    
    <td><input type="button" value="O" onClick="if(confirm('Desea eliminar?')){_borrar('<?php echo $pla_r['iddet'];?>');}"></td>
    <td id="<?php echo 'msg_'.$pla_r['iddet'];?>"></td>
    </tr>

<?php } ?>
</table>
<?php }?>
</div>

</body>
</html>