<?php 
session_start();
include('../cfg/cfg.php');
include('../cfg/res.php');
if(empty($_SESSION['user_vcrx_tipo']) || !isset($_SESSION['user_vcrx_tipo']))
{
	die('<a href="../salir.php">SU SESSION EXPIRO.</a>');
}

$pagina_descri='MIS DEPOSITOS ';
$pagina_nivel;
$pagina_tipo;

// $item_sql='alter table item0 add column item_irbp varchar(9)';
// console.log( $item_sql);
// $item_res=mysql_query($item_sql,$link_vcrx);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><?php echo $empr_nombre .' - ' . $_SESSION['user_vcrx_descri'];?></title>
<link rel="stylesheet" href="http://vcrxol.com/css/ambiente.css"  type="text/css" />
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="../js/busca_maes.js"></script>
<style type="text/css">
body{background:#ffffff;}
.dper_txt{border:solid 1px #000000; border-radius:2px; padding:2px; margin:2px;}
.txt_adr{ width:100%;}
</style>
<script type="text/javascript">
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>
<?php include('../../_js/busca_maes2.js');?>
function enti(e)
{
	if(e.keyCode==13)
	{
		busca_maes2('enti',document.getElementById('enti').value,'enti_descri','h','enti');
	}
}
function notificar()
{
	var enti=document.getElementById('enti').value;
	var fecha=document.getElementById('anio').value+'-'+document.getElementById('mes').value+'-'+document.getElementById('dia').value;
	//var banco=document.getElementById('banco').value;
	var banco='';
	
	var cuenta=document.getElementById('cuenta').value;
	var papeleta=document.getElementById('papeleta').value;
	var concepto=document.getElementById('concepto').value;
	var valor=parseFloat(document.getElementById('valor').value);

	var today = new Date();
	var fechao= new Date(today.getTime() - (60 * 24 * 3600 * 1000));
	
	if(enti.length==0 || enti=='')
	{
		alert('No ingreso numero de Cedula');
		document.getElementById('enti').focus();
		return false;
	}

//++++++++

fechao=fechao.getFullYear()+'-'+(fechao.getMonth()+1)+'-'+fechao.getDate();
today=today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

if(fecha<fechao || fecha>today)
{
//alert('Fecha Incorrecta');
//return false;
}


if(document.getElementById('anio').value==<?php echo date('Y');?> && 1==0)
{
	if(document.getElementById('mes').value==<?php echo date('n');?>)
	{
		if(document.getElementById('dia').value><?php echo date('j');?>)
		{
			//alert('Fecha Incorrecta');
			//return false;
		}
		
	}

	if(document.getElementById('mes').value==<?php echo date('n')-1;?>)
	{
		if(document.getElementById('dia').value<<?php echo date('j');?>)
		{
			//alert('Fecha Incorrecta');
			//return false;
		}
	}
}



if(document.getElementById('anio').value==<?php echo date('Y')-1;?>&& 1==0)
{
	
	if(document.getElementById('mes').value>1)
	{
		
		if(document.getElementById('dia').value<<?php echo date('j');?>)
		{
			//alert('Fecha Incorrecta');
			//return false;
		}
	}

	if(document.getElementById('mes').value==1)
	{
		//alert('Fecha Incorrecta');
		//return false;
		
	}
}

//++++++++	
	
	
	
	if(papeleta.length==0 || papeleta=='')
	{
		alert('No ingreso numero de Papeleta');
		document.getElementById('papeleta').focus();
		return false;
	}
	
	if(valor.length==0 || valor=='')
	{
		alert('No ingreso valor');
		document.getElementById('valor').focus();
		return false;
	}

	if(isNaN(valor) )
	{
		alert('Solo NUMEROS');
		document.getElementById('valor').focus();
		return false;
	}
	
$.ajax({
		cache:false,
		url:'../lib/dcnotifica1.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{enti:enti,fecha:fecha,banco:banco,cuenta:cuenta,papeleta:papeleta,concepto:concepto,valor:valor}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			if(dato!='0')
			{
				alert(dato);
			}
			else
			{
				alert('Su noficiacion fue registrada.');
				document.getElementById('papeleta').value='';
	 			document.getElementById('concepto').value='';
  				document.getElementById('valor').value='';
				carga_noti();
				
			}
		},
		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') {
               //console.log('Time out error.');
			   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:30000
	});
	
}

function carga_noti()
{
	$.ajax({
		cache:false,
		url:'../lib/dcnotifica3.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			document.getElementById('depo').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') {
               //console.log('Time out error.');
			   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 eli_notifica(idxnoti)
{
	
	$.ajax({
		cache:false,
		url:'../lib/dcnotifica4.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{idxnoti:idxnoti,accion:'X'},
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			dato=dato.trim();
			if(dato!='0')
			{
				console.log(dato.trim());
				alert('Ocurrio un error al Eliminar');
				return false;
			}
			carga_noti();
		},
		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') {
               //console.log('Time out error.');
			   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
	});

}


</script>
<body>
<?php include('../../_lib/cabecera2.php');?>
<?php require('../../_lib/select.php');?>
<div align="left" style="padding-left:20px;">
<table cellspacing="0" cellpadding="6">


<tr>
<td>
<div style="font-weight:bolder;">CLIENTE</div>
<div>
<input type="text" id="enti" onkeypress="enti(event);" style="border: solid 1px #000; width:100px; padding-left:2px;" value="<?php echo $_SESSION['user_vcrx_id'];?>" maxlength="13" />
<span id="enti_descri" style="height:25px;"><?php echo $_SESSION['user_vcrx_descri'];?></span>
</div>
</td>
</tr>




<tr>

<td>
<div style="font-weight:bolder;">FECHA(Año-Mes-Dia)</div>
<div>
	<select id="anio" style="border:solid 1px #000;">
	    <?php if($_SESSION['user_vcrx_tipo']=='admi'){?>
			<option value="<?php echo date("Y")-1; ?>"><?php echo date("Y")-1; ?></option>	
		<?php }?>
        <option value="<?php echo date("Y"); ?>" selected="selected" > <?php echo date("Y"); ?></option>
    </select>
    
    
	<select id="mes" style="border:solid 1px #000;">
        <?php if($_SESSION['user_vcrx_tipo']=='admi'){?>
		     	<option value="01" > ENE</option>
                <option value="02" > FEB</option>
                <option value="03" > MAR</option>
                <option value="04" > ABR</option>
                <option value="05" > MAY</option>
                <option value="06" > JUN</option>
                <option value="07" > JUL</option>
                <option value="08" > AGO</option>
                <option value="09" > SET</option>
                <option value="10" > OCT</option>
                <option value="11" > NOV</option>
                <option value="12" > DIC</option>
		

		<?php }else{?>
				<option value="<?php echo date("m")-1;?>"><?php echo date("m")-1;?></option>
		        <option value="<?php echo date("m");?>" selected="selected"><?php echo date("M");?></option>	
		<?php }?>


        
    </select>
	<select id="dia" style="border:solid 1px #000;">
    	<?php
		for($d=1;$d<=31;$d++)
		{
		?>
		<option value="<?php echo $d;?>" <?php if($d==date('j')){echo 'selected="selected"';}?> ><?php echo $d;?></option>
		<?php	
		}
		?>
    </select>

</div>
</td>
</tr>

<!--
<tr><td style="font-weight:bolder;">BANCO</td></tr>
<tr><td><input type="text" id="banco" style="border:solid 1px #000;" /></td></tr>
-->


<tr><td>
<div style="font-weight:bolder;">#CTA.BANCARIA</div>
<div>
<select id="cuenta" style="border:solid 1px #000;">
<?php //$cuenta=new select(); $cuenta->select_simple('../cfg/res.php','ctab0','select ctab_codigo,ctab_descri from ctab0');?>
<?php 
if($_SESSION['user_vcrx_empr']=='gnya')
{
    $cuenta=new select(); $cuenta->select_simple('../cfg/res.php','ctab0','select ctab_codigo,ctab_descri from ctab0 where ctab_codigo="B090"');
}
else
{
    $cuenta=new select(); $cuenta->select_simple('../cfg/res.php','ctab0','select ctab_codigo,ctab_descri from ctab0');
}

?>
</select>
</div>
</td></tr>




<tr>
<td>
<div style="font-weight:bolder;">#PAPELETA</div>
<div><input type="text" id="papeleta" style="border:solid 1px #000; padding-left:2px;" /></div>
</td></tr>


<tr><td>
<div style="font-weight:bolder;">VALOR</div>
<div><input type="text" id="valor" style="border:solid 1px #000; text-align:right;" maxlength="7" align="right" /></div>
</td></tr>


<tr><td>
<div style="font-weight:bolder;">CONCEPTO</div>
<div><textarea id="concepto" maxlength="250"  style="resize:none;border:solid 1px #000;"></textarea></div>
</td></tr>

<tr><td><input type="button" value="NOTIFICAR" onclick="if(confirm('Desea Notificar?')){ notificar();}" /></td></tr>

</table>
<div id="depo"><?php require('../../_lib/dcnotifica2.php');?></div>
</div>


</body>
</html>