<?php use_helper('UrlFunctions'); ?>
<?php
//echo Cr_prestamo_fileFN::buscarEstadoDoc( 2427 );
$s_Param = '';
if( isset( $id ) )
{
    $s_Param = 'id='.$id;
}
?>
<?php
//error_reporting(E_ALL);
//ini_set('display_errors','On'); //PARA PRODUCCION "Off"
$s_User = myUser::getUser()->getUserId();
if( isset( $TypeProcess ) )
{
    switch ( $TypeProcess )
    {
        case "Anular":
            $o_cr_cliente_fileFN = new Cr_cliente_fileFN();
            $o_Resource = $o_cr_cliente_fileFN->getConnect();
            $s_SQLQuery = "UPDATE cr_prestamo SET FlagCerrarDocumento='C' WHERE IdPrestamo='{$i_IdPr}';";
            $b_Result = mysql_query( $s_SQLQuery, $o_Resource );
        break;
    }
    if( $b_Result )
    {
        ?>
        <script>
        location.href = "<?php echo buildUrl('cli/datDocPe', $s_Param) ?>";
        </script>
        <?php
    }
}
?>
<script type="text/javascript">
abrirVentanaAdicionar = function()
{
    objMainTab.modalDialog( '<?php echo buildUrl('cli/datDocAddDoc', $s_Param) ?>', {height:300} );
};
abrirVentanaVer = function( i_IdTipoFile )
{
    objMainTab.modalDialog( '<?php echo buildUrl('cli/datDocVer', $s_Param) ?>/i_IdTipoFile/' + i_IdTipoFile, { width:500, height:250 } );
};
abrirVentanaAnul = function( i_IdPr )
{
    location.href = "<?php echo buildUrl( 'cli/datDocPe', $s_Param ) ?>/i_IdPr/" + i_IdPr + "/TypeProcess/Anular";
};
recargarApp = function()
{
    location.href = "<?php echo buildUrl( 'cli/datDoc', $s_Param ) ?>";
};
</script>
<script type="text/javascript">
validatePass = function()
{
	valid.onSubmit = false;
};
limpiarForm = function()
{
    $( 'NroPrestamo' ).value = "";
    $( 'Estado' ).value = "";
    $( 'txtFechaInicial' ).value = "";
    $( 'txtFechaFinal' ).value = "";
}
</script>
<script>
findControl = function(){ concatValueStr(); }
concatValueStr = function()
{
    strFormSerialize = $('form1').serialize();
    if( arguments[0] )
    {
        strFormSerialize += '&'+arguments[0];
    }
    executeFind( strFormSerialize );
}
executeFind = function(str, action)
{
    var url = "<?=buildUrl('cli/datDocPeGr')?>";
	var myAjax  = new Ajax.Updater(
                                	"resultGrtid",
                                	url,
                                	{
                                		asynchronous:	true,
                                		method			: 'get',
                                		parameters	: str,
                                		evalScripts	: true,
                                		onLoading   : cargandoImagenSerch()
                                	});
}
function cargandoImagenSerch()
{
	disabledWin.show(true,true,'resultGrtid');
}
</script>
<?php
$o_ClienteBean = new ClienteBean();
$o_ClienteBean->setIdCliente($id);
$o_class = new ClienteBL();
$a_ObjectBean = $o_class->busquedaCliente($o_ClienteBean);
if( $a_ObjectBean )
{
    $o_ClienteBean = $a_ObjectBean[0];
}
?>

<table class="cuerpo" width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td valign="top">
			 <form id="form1" name="form1" method="GET">
				<input type="hidden" name="control" value="1">
				<input type="hidden" name="id" value="<?php echo $id ?>">
                <input type="hidden" name="TypeProcess" value=""/>
                        <table id="tabShowScan" cellpadding="0" cellspacing="0" class="" style="margin-top: 5px;">
                            <tr>
                              <td class="mnuInactivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
                              <td class="mnuInactivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('cli/edit', $s_Param) ?>';">Datos Generales</td>
                              <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
                              <?php if( isset( $id ) && $id != "" ){ ?>
                              <td class="mnuInactivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
                              <td class="mnuInactivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('cli/datPer', $s_Param) ?>';">Datos Personales</td>
                              <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
                             
                              <?php } ?>
                            </tr>
                        </table>

                        <table width="100%" cellspacing="2" cellpadding="2" border="0" class="marco marcoForm">
                            <tr>
                                <td nowrap="nowrap">
                                    <fieldset>
                                        <input type="hidden" name="txtNuemroCliente" id="txtNuemroCliente" value="<?php echo $id;?>"/>
                                        <!--
                                        <table width="100%" cellspacing="1" cellpadding="2" border="0" >
                                            <tr>
                                                <td align=""><input type="button" align="right" value="Adicionar Documento" class="button" id="" onclick="abrirVentanaAdicionar();"></td>
                                            </tr>
                                        </table>
                                        -->
                                        <table width="100%" cellspacing="5" cellpadding="5" border="0" >
                                            <tr>
                                                <!--<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>-->
                                                <td><label class="label req"><?php echo $o_ClienteBean->getNombreCompleto() ?> [ DNI: <?php echo $o_ClienteBean->getDni() ?> ]</label></td>
                                                <!--<td><label class="label req"></label></td>-->
                                            </tr>
                                        </table>
                                        
                                        <table class="SubCabecera" width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                                <td><label class="label" for="Tipo">Nro Prestamo</label></td>
                                                <td>
                                                    <input type="text" name="NroPrestamo" id="NroPrestamo" value="" class="text"/>
                                                </td>
                                                <td><label class="label" for="Estado">Estado</label></td>
                                                <td>
                                                    <select name="Estado" id="Estado" >
                                                        <option value=""> - SELECCIONE - </option>
                                                        <option value="P" <?php if( $Estado=="P"){ echo "SELECTED"; } ?>>Pendiente</option>
                                                        <option value="C" <?php if( $Estado=="C"){ echo "SELECTED"; } ?>>Cancelado</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <input class="text" type="text" ondblclick="this.value=''" size="8" maxlength="10" name="txtFechaInicial" id="txtFechaInicial" value="<?php echo $txtFechaInicial ?>" /><button type="button" onclick="return false" id="btnFechaInicial">...</button>
                                                    <script type="text/javascript">
                                                    document.getElementById( "txtFechaInicial" ).disabled = false;
                                                    Calendar.setup( { inputField : "txtFechaInicial", ifFormat : "%Y-%m-%d", daFormat : "%Y-%m-%d", button   : "btnFechaInicial" } );
                                                    </script>
                                                </td>
                                                <td><label class="label" for="txtFechaFinal">Fecha Final</label></td>
                                                <td>
                                                    <input class="text" type="text" ondblclick="this.value=''" size="8" maxlength="10" name="txtFechaFinal" id="txtFechaFinal" value="<?php echo $txtFechaFinal ?>" /><button type="button" onclick="return false" id="btnFechaFinal">...</button>
                                                    <script type="text/javascript">
                                                    document.getElementById( "txtFechaFinal" ).disabled = false;
                                                    Calendar.setup( { inputField : "txtFechaFinal", ifFormat : "%Y-%m-%d", daFormat : "%Y-%m-%d", button   : "btnFechaFinal" } );
                                                    </script>
                                                </td>
                                                <td>
                                                    <input type="button" class="button" value="Buscar" onclick="findControl();"/>
                                                    <input type="button" class="button" value="Limpiar" onclick="limpiarForm();"/>
                                                </td>
                                            </tr>
                                        </table>
                                        
                                        <div id="resultGrtid"></div>
                                        
                                        
                                    </fieldset>

                                </td>
                            </tr>
                        </table>



                <!--
				<table hspace="2px" class="marco" width="96%" cellpadding="0" cellspacing="0">
					<tr>
						<td valign="top" colspan="2">

                            <table style="pad">
                            </table>

								<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background: #fff">
									<tr>
										<td height="0" width="100%">


											   <table width="100%" border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td><img src="/images/common/spacer.gif" width="10"></td>
													</tr>
													<tr>
													    <td align="center">
															<input type="hidden" name="typeSubmit" id="typeSubmit">
															<input class="button" type="button" value="Anterior" onclick="location.href='<?php echo buildUrl('cli/datPer', $s_Param) ?>'"/>
															<input class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='ok';">
															<input class="button" type="submit" value="Grabar y Siguiente" onclick="$('typeSubmit').value='next';">
															<input class="button" type="button" value="Siguiente" onclick="location.href='<?php echo buildUrl('cli/datDoc', $s_Param) ?>'"/>
															<input class="button" type="button" value="Cancelar" onclick="location.href='<?php echo buildUrl('cli/list', $s_Param."&block=001" ) ?>'"/>
													    </td>
													</tr>
													<tr>
														<td height="10">&nbsp;</td>
													</tr>
												</table>

										</td>
									</tr>
								</table>

						</td>
					</tr>
				</table>
				-->
			</form>
				<script type="text/javascript">
				    findControl();
					//var valid = new Validation( 'form1', { immediate : true } );
				</script>
		</td>
	</tr>
</table>