<?php
 	include("stilos/config.inc.php");
	include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("../clases/clsTdoc.php");
  include("funcion/funciones.php");
  include("Funciones.php");  
  session_start();
  $objPer=new clsPer;
  $objTdoc=new clsTdoc;
  if($_POST['tipodoc']=="PAG"){
  	if(date(dm)=='0101'){
	  $numero1=0;
  	  $objTdoc->Updatenumtdoc2($_SESSION['usuarea'],$numero1);
	  $result=$objPer->getNumDocxArea($_SESSION['usuarea']);
	  $fila=$objPer->NextRow1($result);
	  $numero=getNumCeros4($fila['Inum']);
	}else{
	  $result=$objPer->getNumDocxArea($_SESSION['usuarea']);
	  $fila=$objPer->NextRow1($result);
	  $numero=getNumCeros4($fila['Inum']);
	}
  }elseif($_POST['tipodoc']=="CAR"){
  	if(date(dm)=='0101'){
	  $numero1=0;
  	  $objTdoc->Updatenumtdoc1($_POST['tipodoc'],$numero1);
	  $result=$objPer->getNumDocxDoc($_POST['tipodoc']);
	  $fila=$objPer->NextRow1($result);
	  $numero=getNumCeros4($fila['Inum']);
	}else{
	  $result=$objPer->getNumDocxDoc($_POST['tipodoc']);
	  $fila=$objPer->NextRow1($result);
	  $numero=getNumCeros4($fila['Inum']);
	}
  }else{
  	  $result=$objPer->getNumDocxDoc($_POST['tipodoc']);
	  $fila=$objPer->NextRow1($result);
	  $numero=getNumCeros4($fila['Inum']);  
  }
  /* if(($_POST['tipodoc']=='PRO') or ($_POST['tipodoc']=='FOR')){
  
  } */
  if($_SESSION['usuarea']!=""){
  if(($_SESSION['usuarea']=="LEG" and $_POST['tipodoc']=="CTO") or ($_SESSION['usuarea']=="RH" and $_POST['tipodoc']=="FOR") or ($_SESSION['usuarea']=="RH" and $_POST['tipodoc']=="PRO") or ($_POST['tipodoc']=="CAR") or ($_POST['tipodoc']=="MEM") or ($_POST['tipodoc']=="PAG")){
?>

<link href="Estilos.css" rel="stylesheet" type="text/css">
<body>
<table width="360" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="85" class="lblCampo"><div align="left">Codigo</div></td>
    <td width="10">&nbsp;</td>
    <td width="265"><div align="left">
      <input name="codigodoc" type="text" id="codigodoc" value="<? echo "PER/".$_POST['tipodoc']."-".$numero."/";?>" size="15" readonly="true"/>
      
        <input name="codigodoc1" type="text" id="codigodoc1" value="<? echo $_SESSION['usuarea']?>" size="2" <? if($_SESSION['usuarea']=="RH" and $_POST['tipodoc']=="PRO"){?> <? }else{?> readonly="true"<? }?>>
     
       
            <input name="codigodoc2" type="text" id="codigodoc2" value="<? echo "-".date(my);?>" size="5" readonly="true">
         
        </div></td>
  </tr>
  <tr>
    <td class="lblCampo"><div align="left">Fecha</div></td>
    <td>&nbsp;</td>
    <td><div align="left">
      <input name="fecha" type="text" class="lblCampoF" id="fecha" value="<? echo date("d/m/Y")?>" size="12" readonly="true"/>
	  <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fecha');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a>
      <input name="numero" type="hidden" id="numero" value="<?=$numero?>">
    </div></td>
  </tr>
   <? if($_POST['tipodoc']=="PRO"){?>
  <tr>
    <td  class="lblCampo"><div align="left">Titulo</div></td>
    <td>&nbsp;</td>
    <td>      <div align="left">
      <input name="titulo" type="text" id="titulo" value="" size="30">
    </div></td>
  </tr>
  <? }?>
  <? if($_POST['tipodoc']=="MEM"){?>
  <tr>
    <td  class="lblCampo"><div align="left">De</div></td>
    <td>&nbsp;</td>
    <td><div align="left">
      <input name="de" type="text" id="de" size="30" />
    </div></td>
  </tr>
  <? }?>
  <? if(($_POST['tipodoc']=="MEM") or ($_POST['tipodoc']=="CAR")){?>
  <tr valign="top">
    <td  class="lblCampo"><div align="left">Para</div></td>
    <td><div align="left"></div></td>
    <td><div align="left">
      <input name="para" type="text" id="para" value="" size="30">
    </div></td>
  </tr>
  <? }?>
  <? if($_POST['tipodoc']=="CAR"){?>
  <tr>
    <td class="lblCampo"><div align="left">Referencia</div></td>
    <td>&nbsp;</td>
    <td>
      
      <div align="left">
        <input name="referencia" type="text" id="referencia" value="" size="30">      
      </div></td>
  </tr>
  <? }?>
  <? if(($_POST['tipodoc']=="MEM") or ($_POST['tipodoc']=="CAR")){?>
  <tr>
    <td  class="lblCampo"><div align="left">Asunto</div></td>
    <td>&nbsp;</td>
    <td><div align="left">
      <input name="asunto" type="text" id="asunto" size="30" />
    </div></td>
  </tr>
  <? }?>
  <? if(($_POST['tipodoc']=="CTO") or ($_POST['tipodoc']=="PAG")){?>
  <tr>
    <td  class="lblCampo"><div align="left">Beneficiario</div></td>
    <td>&nbsp;</td>
    <td><div align="left">
      <input name="personal" type="text" id="personal" size="30" />
    </div></td>
  </tr>
  <? }?>
  <tr>
    <td class="lblCampo"><div align="left">confidencial</div></td>
    <td>&nbsp;</td>
    <td><div align="left">
      <input name="confidencial" type="radio" value="1" onClick="deselecciona()"/>
     si 
     <input name="confidencial" type="radio" value="0" checked="checked" onClick="deselecciona()"/>
     no </div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>Seleccione Areas a Enviar </td>
  </tr>
  <tr>
    <td colspan="3">
	<div id="listar" align="center"><? //include_once("per_lista_areas.php");?>
	  <input name="tipodoc" type="hidden" size="5" id="tipodoc" value="<?=$_POST['tipodoc']?>">
	</div></td>
  </tr>
  
  
</table>
</body>
<? }else{ echo "no tiene Permiso a Crear este Documento";}
}else{
echo "La session finalizo debe cerrar el sistema y volver a entrar";
}?>
