<?php 

require('cfg/cfg.php');
require('cfg/res.php');
?>

<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 _notificar()
{
	//var enti=document.getElementById('enti').value;
	var enti='<?php echo $_SESSION['user_vcrx_id']?>';
	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();
				window.location.reload();
				
			}
		},
		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 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>
<?php require('../_lib/select.php');?>
<div class="c2">MIS DEPOSITOS</div>
<div align="left">
    <div class="dper_lbl">CLIENTE</div>
    <div id="enti" class="dper_txt"><?php echo $_SESSION['user_vcrx_id'];?></div>
    <div id="enti_descri" class="dper_txt"><?php echo $_SESSION['user_vcrx_descri'];?></div>
	
    <div class="dper_lbl">FECHA(Año-Mes-Dia)</div>
	<div>
	<select id="anio" class="dper_txt" style="width:56%;">
	    <?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" class="dper_txt" style="width:20%;">
        <?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" class="dper_txt" style="width:20%;">
    	<?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>



	<div class="dper_lbl">#CTA.BANCARIA</div>
	<div>
	<select id="cuenta" class="dper_txt" >

	<?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>

    <div class="dper_lbl">#PAPELETA</div>
    <div><input type="text" id="papeleta" class="dper_txt" /></div>

    <div class="dper_lbl">VALOR</div>
    <div><input type="text" id="valor" class="dper_txt" maxlength="7" align="right" /></div>

    <div class="dper_lbl">CONCEPTO</div>
    <div><textarea id="concepto" maxlength="250"  class="dper_txt"></textarea></div>


	<div><input type="button" value="NOTIFICAR" onclick="if(confirm('Desea Notificar?')){ _notificar();}"  style="height:45px; width:100%; background:#09c; color:#FFF; border:none; font-weight:bolder; font-size:16px; cursor:pointer;" /></div>


<div id="depo">
<?php
$sql_depo='select *from cjte11 where enti="'.$_SESSION['user_vcrx_id'].'" or iuser="'.$_SESSION['user_vcrx_id'].'" ORDER BY idnum1 DESC';
$res_depo=mysql_query($sql_depo,$link_vcrx);
//echo $sql_depo;
$filadepo=0; while($row_depo=mysql_fetch_assoc($res_depo)){?>
 
    <div class="dper_lbl" style=" <?php if($filadepo==2){echo 'border-bottom:#000 dotted 1px;';$filadepo=0;}else{$filadepo++;} ?>" >CLIENTE</div>
    <div class="dper_txt"><?php echo $row_depo['enti_descri'];?></div>
    <div class="dper_lbl">FECHA</div>
	<div class="dper_txt"><?php echo '<span title="Fecha de aviso:'.$row_depo['idate'].'">'. $row_depo['fechadmy'].'</span>';?></div>
	<div class="dper_lbl">#CTA.BANCARIA</div>
    <div class="dper_txt"><?php echo $row_depo['ctab_descri'];?></div>
	<div class="dper_lbl">#PAPELETA</div>
    <div class="dper_txt"><?php echo $row_depo['numero'];?></div>
	<div class="dper_lbl">VALOR</div>
    <div class="dper_txt"><?php echo $row_depo['tcant'];?></div>
	<div class="dper_lbl">STATUS</div>
    <div class="dper_txt"><?php echo '<span title="'.$row_depo['stat_descri'].'">'. $row_depo['status'].'</span>';?></div>
	<div class="dper_lbl">CONCEPTO</div>
	<div class="dper_txt"><?php echo $row_depo['concepto'];?></div>
    <?php if(!mb_stristr('ANX',$row_depo['status'])){?>
	<div align="center">
    <input type="button" value="Eliminar esta notificacion"  onclick="if(confirm('Desea Eliminar Notificacion?')){eli_notifica('<?php echo $row_depo['idnum1'];?>');}"  style="height:45px; width:100%; background: #F00; color:#FFF; border:none; font-weight:bolder; font-size:16px; cursor:pointer;" />
    </div>
	<?php } ?>

<?php }?>
</div>

</div>

