<?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="504" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="66" class="lblCampo"><div align="left">Codigo</div></td>
    <td width="5">&nbsp;</td>
    <td width="433"><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>
  <? }?>
  <? if($_POST['tipodoc']=="PAG"){?>
  <tr>
    <td colspan="3"  class="lblCampo"><div align="left">
      <table width="501" border="0" cellspacing="0" cellpadding="0">

        
        <tr class="lblCampo">
          <td><div align="left">Fecha Pago </div></td>
          <td><div align="left">
            <input name="fechareq" type="text" id="fechareq" size="12">
			<a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fechareq');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a>
          </div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td width="69"><div align="left">Ruc</div></td>
          <td width="170"><div align="left">
            
            <input name="ruc" type="text" id="ruc" size="25">
            
          </div></td>
          <td width="89"><div align="right">Tipo Comprobante </div></td>
          <td width="173"><div align="left">
            
                <input name="tipocomp" type="text" id="tipocomp" size="25">
                
            </div></td>
          </tr>
        <tr class="lblCampo">
          <td><div align="left">Monto</div></td>
          <td><div align="left">
            <input name="monto" type="text" id="monto" size="10">
            
              <select name="tipomon" id="tipomon">
                <option value="S/">S/</option>
                <option value="USD">USD</option>
				<option value="EUR">EUR</option>
              </select>
            
            </div></td>
          <td><div align="right">Comprobante #</div></td>
          <td><div align="left">
            <input name="numcomp" type="text" id="numcomp" size="20">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="1" onClick="deshabi()">
          </div></td>
          <td><div align="left">Caja Chica </div></td>
          <td><div align="right"></div></td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="2" onClick="deshabi()">
          </div></td>
          <td><div align="left">Carta</div></td>
          <td><div align="right"></div></td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="3" onClick="deshabi()">
          </div></td>
          <td><div align="left">Cheque de Gerencia </div></td>
          <td><div align="right">Banco</div></td>
          <td><div align="left">
            <input name="banco" type="text" id="banco" size="25">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="4" onClick="deshabi()">
          </div></td>
          <td><div align="left">Cheque Normal - Entrega a RH </div></td>
          <td><div align="right">Cuenta</div></td>
          <td><div align="left">
            <input name="cuenta" type="text" id="cuenta" size="25">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="5" onClick="habi()">
          </div></td>
          <td><div align="left">Transferencia a CTA Beneficiario </div></td>
          <td><div align="right"></div></td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="rdoa" type="radio" value="6" onClick="deshabi()">
          </div></td>
          <td><div align="left">Transferencia Nomina </div></td>
          <td><div align="right"></div></td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td>&nbsp;</td>
          <td colspan="2"><div align="center">Centro de Costo </div></td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">CC</div></td>
          <td><div align="center">Monto</div></td>
          <td><div align="center">CC</div></td>
          <td><div align="center">Monto</div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="cc1" type="text" id="cc1" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc1" type="text" id="mc1" size="10">
          </div></td>
          <td><div align="center">
            <input name="cc5" type="text" id="cc5" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc5" type="text" id="mc5" size="10">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="cc2" type="text" id="cc2" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc2" type="text" id="mc2" size="10">
          </div></td>
          <td><div align="center">
            <input name="cc6" type="text" id="cc6" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc6" type="text" id="mc6" size="10">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="cc3" type="text" id="cc3" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc3" type="text" id="mc3" size="10">
          </div></td>
          <td><div align="center">
            <input name="cc7" type="text" id="cc7" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc7" type="text" id="mc7" size="10">
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td><div align="center">
            <input name="cc4" type="text" id="cc4" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc4" type="text" id="mc4" size="10">
          </div></td>
          <td><div align="center">
            <input name="cc8" type="text" id="cc8" size="10">
          </div></td>
          <td><div align="center">
            <input name="mc8" type="text" id="mc8" size="10">
          </div></td>
        </tr>
        <tr class="lblCampo" valign="top">
          <td><div align="left">Concepto</div></td>
          <td colspan="3"><div align="left">
            <input name="concepto" type="text" id="concepto" value="" size="70">
          </div></td>
          </tr>
        <tr class="lblCampo">
          <td><div align="left">Solicitado por </div></td>
          <td><div align="left">
            <input name="solicita" type="text" id="solicita" size="25" onKeyUp="javascript:autocompletar1('solici',this.value);"/><span id="reloj1"><img src='../imagenes/image.gif' border=0 /></span>
          </div></td>
          <td><div align="right">Aprobado por </div></td>
          <td><input name="aprueba" type="text" id="aprueba" size="25" onKeyUp="javascript:autocompletar2('aprue',this.value);"><span id="reloj2"><img src='../imagenes/image.gif' border=0 /></span></td>
        </tr>
        <tr class="lblCampo">
          <td colspan="2"><div id="solici"></div></td>
          <td colspan="2"><div id="aprue"></div></td>
          </tr>
        
      </table>
    </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="deshabilita()"/>
si
<input name="confidencial" type="radio" value="0" checked="checked" onClick="habilita()"/>
no </div></td>
  </tr>
  <tr class="lblCampo">
    <td  class="lblCampo"><div align="left">Copy To </div></td>
    <td>&nbsp;</td>
    <td class="lblCampo"><div align="left">
      <input type="text" name="send" id="send" onKeyUp="javascript:autocompletar('lista',this.value);" size="15" /><span id="reloj"><img src='../imagenes/image.gif' border=0 /></span>
      <input name="input" type="text" id="input" size="52">
      </div></td>
  </tr>
  <tr>
    <td colspan="3"  class="lblCampo"><div id="lista"></div></td>
  </tr>
  <tr>
    <td colspan="3">
	<div id="listar" align="center">
	  <table width="336" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="169"><input name="button" type="button" class="botira" id="button" style="<?=$stylo['st2']?>" onClick="enviar_url(form1,'procesos/per_send_grabar.php')" value="Crear Doc"></td>
          <td width="167"><input type="button" name="Submit2" value="Cancelar" onClick="volver(this.form);" style="<?=$stylo['st2']?>" class="botira"></td>
        </tr>
      </table>
	  <? //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";
}?>
