<?php
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/

session_name('portal_absa');
session_start();
require_once "../conexion/conectar.php";

$conexion = new CONDB();
$conexion->conectar();

$rfc=$_REQUEST['id'];
$tipodocto=$_REQUEST['id2'];
$serie=$_REQUEST['id3'];
$folio=$_REQUEST['id4'];
$uuid=$_REQUEST['id5'];

$completaQuery="";

if(trim($_REQUEST['id3']) != "")
	$completaQuery.=" and serie='$serie'";
if(trim($_REQUEST['id4']) != "")
	$completaQuery.=" and folio=$folio";
if(trim($_REQUEST['id5']) != "")
	$completaQuery.=" and uuid='$uuid'";

$result = mysqli_query($conexion->CONEXION,"select status,comentario_status from recibedoce where rfcemisor='$rfc' and tipodocto='$tipodocto' $completaQuery limit 1");
if(mysqli_num_rows($result) > 0){
	$temp=mysqli_fetch_array($result,MYSQLI_ASSOC);
}else{
	echo "<br/><br/><font color='red' style='font-size: 14px'><strong>No se encontro el registro seleccionado, intente nuevamente.</strong></font>";
	exit;	
}

?>
<script language="javascript" src="libs/Vanadium/vanadium.js"></script>
<script>
$j_6(document).ready(function() {
	$j_6('#loading').hide();
	
    $j_6().ajaxStart(function() {
        $j_6('#loading').show();
        $j_6('#result').hide();
    }).ajaxStop(function() {
        $j_6('#result').fadeIn('slow');
		$j_6('#loading').hide();
    });
	
		/*$j_3('#formProveedor').ajaxForm(function(data) {
						$j_3('#result').html(data);
						$j_3('#loading').hide();
		});*/
		
		$j_6('#form, #fat, #form_status').submit(function() {
        $j_6.ajax({
            type: 'POST',
            url: $j_6(this).attr('action'),
            data: $j_6(this).serialize(),
            success: function(data) {
					$j_6('#result').html(data);
					$j_6('#loading').hide();
            }
        })
        
        return false;
    });
		
});

function cambiaStatus_check(id){
	
	if(id.id=="check_aceptado"){
		id.checked=true;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_ES').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_advertencia"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_ES').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_rechazado"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_ES').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_pendienteAceptar"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_ES').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_WS"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_ES').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_ES"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_E').checked=false;
	}
	if(id.id=="check_E"){
		id.checked=true;
		document.getElementById('check_aceptado').checked=false;
		document.getElementById('check_advertencia').checked=false;
		document.getElementById('check_rechazado').checked=false;
		document.getElementById('check_pendienteAceptar').checked=false;
		document.getElementById('check_WS').checked=false;
		document.getElementById('check_ES').checked=false;
	}
	
	document.getElementById('status').value=id.value;
}

</script>

<font color="gray" style="font-size: 14px"><strong>Seleccione el status por el cual desea cambiarlo.</strong></font><br/><br/>
<form action="formularios/guardar/altaStatus.php" name="form_status" id="form_status">
	
	<input type="hidden" name="rfcemisor" value="<?=$rfc?>" />
	<input type="hidden" name="tipodocto" value="<?=$tipodocto?>" />
	<input type="hidden" name="serie" value="<?=$serie?>" />
	<input type="hidden" name="folio" value="<?=$folio?>" />
	<input type="hidden" name="uuid" value="<?=$uuid?>" />
	
	<input type="checkbox" value="A" onClick="cambiaStatus_check(this);" id="check_aceptado" <?if($temp['status']=="A"){?>checked="true"<?}?>/> <img src="Imagenes/acceptHand.png" width="16" height="16"/>&nbsp;&nbsp;
	<input type="checkbox" value="W" onClick="cambiaStatus_check(this);" id="check_advertencia" <?if($temp['status']=="W"){?>checked="true"<?}?>/> <img src="Imagenes/Attention.png" width="16" height="16"/>&nbsp;&nbsp;
	<input type="checkbox" value="R" onClick="cambiaStatus_check(this);" id="check_rechazado" <?if($temp['status']=="R"){?>checked="true"<?}?>/> <img src="Imagenes/rejectHand.png" width="16" height="16"/>
	<input type="checkbox" value="S" onClick="cambiaStatus_check(this);" id="check_pendienteAceptar" <?if($temp['status']=="S"){?>checked="true"<?}?>/> <img src="Imagenes/pendienteAceptar.png" width="16" height="16"/>
	<input type="checkbox" value="WS" onClick="cambiaStatus_check(this);" id="check_WS" <?if($temp['status']=="WS"){?>checked="true"<?}?>/> <img src="Imagenes/WS.png" width="16" height="16"/>
	<input type="checkbox" value="ES" onClick="cambiaStatus_check(this);" id="check_ES" <?if($temp['status']=="ES"){?>checked="true"<?}?>/> <img src="Imagenes/pendienteERPS.png" width="16" height="16"/>
	<input type="checkbox" value="E" onClick="cambiaStatus_check(this);" id="check_E" <?if($temp['status']=="E"){?>checked="true"<?}?>/> <img src="Imagenes/pendienteERP.png" width="16" height="16"/>
	<br/>
	<br/>
	<?$comentario_status = end(explode(":",$temp['comentario_status']));?>
	<input type="text" size="40" name="comentario" value="<?=$comentario_status?>" maxlength="255" class=":required"/><input type="submit" value="Guardar" />
	<input type="hidden" id="status" name="status" value="<?=$temp['status']?>"/>
</form>