MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: /home/asjudine/www/ahistoser/programacion_consulta.php
<!DOCTYPE html>
<html>
<head>
<title>PROGRAMACION CONSULTAS</title>
<meta http-equiv="X-UA-Compatible" content="IE=8; IE=9; IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
<style type="text/css">
	*{margin: 0;padding: 0;}
    body{background-color:#FFFFFF;font-family:Verdana, Geneva, sans-serif;}
    header {background-color: #B7271F; text-align: center;}
    .cerrarsesion{width: auto;background-color: #DBD8C9;color: #000;font-size: 13px;position:absolute;top: 15px;right:10px;z-index:0;padding: 10px;border-radius: 10px;cursor: pointer;}
    .cerrarsesion:hover{background-color: #ffffff;color: #000;}
    .titulo{width: 100%;text-align: center;background-color: #dbd8c9;color: #b20606;padding: 6px 0;font-size: 18px;}
	.subtitulos{width: 100%;text-align: left;color: #b20606;padding: 2px 0;font-size: 13px;}
    table{margin: 0 auto;border: 8px solid #bebebe; text-align: center; 
	-webkit-box-shadow: 10px 10px 10px -4px rgba(0,0,0,0.75);
	-moz-box-shadow: 10px 10px 10px -4px rgba(0,0,0,0.75);
	box-shadow: 10px 10px 10px -4px rgba(0,0,0,0.75);}
    .irmenu{width: 200px;background-color: #1c4fa0;color: #fff; padding: 4px;border-radius: 6px;}
    .irmenu:hover{background-color: #67a0d9; color: #000;}
    
    .fecha{background-color: #d6e08b; padding: 2px;color: #000;font-size: 15px; text-align: center;}
    td{border: #D7D7D7 solid 0.2px; height: 24px;}
    .tdizq{background-color: #EEE; color: #C70000;font-size: 14px;font-weight: 200; text-align: left;}
    .tdcen{background-color: #EEE; color: #00135F;font-size: 14px;font-weight: 200; text-align: center;}
    .tdder{background-color: #EEE; color: #630000;font-size: 14px;font-weight: 200; text-align: right;}
	.tdroja{background-color: #EEE; color: #CC0005;font-size: 14px;font-weight: 400; text-align: right;}
	.tdi{background-color: #; color: #00135F;font-size: 13px;font-weight: 200; text-align: left;}
    .tdc{background-color: #E3DCB0; color: #00135F;font-size: 13px;font-weight: 200; text-align: center;}
    .tdd{background-color: #E3DCB0; color: #00135F;font-size: 13px;font-weight: 200; text-align: right;}
	.tdvd{background-color: #EEE; color: #188409;font-size: 13px;font-weight: 200; text-align: right;}
	.exp{color:#8A0000; font-size:12px;}
    .boton1{background-color: #ffffff;color: #000;padding: 5px;border:1px solid #580000;border-radius:2px;}
    .boton1:hover{background-color: #6f0000;color: #fff;cursor: pointer;}
	.direcciona{width: 180px; background-color: #8F0E11;color: #fff; padding: 5px;border-radius: 3px;}
	.direcciona:hover{background-color: #67a0d9; color: #000;}
    input[type=text],select{height: 22px; font-size: 13px;}
	/*select{border:solid #191919 0.5px; border-radius: 3px; padding: 1px;background-color: #FFFFFF; font-weight:600px; }*/
	textarea{border:1px solid #5C5C5C;}
	
	.tdtitulo{background-color: #e3dec0; color: #b20606; padding: 2px; text-align: center; font-size: 12px; font-weight: 900}
    .tdfull{background-color: #fff; color: #000; padding: 5px; text-align: center; font-size: 12px; font-family:Verdana, Geneva, sans-serif;}
	.tdjustify{background-color: #fff; color: #000; padding: 5px; text-align: justify; font-size: 12px;}
    .botonnew{background-color: #C0292E;color: #FFFFFF;padding: 1px;border-radius:5px;}
    .botonnew:hover{background-color: #cbbd6a;color: #000;padding: 1px;border-radius:5px;}
</style>


<script languaje="JavaScript">
function Mostrar_Fecha()
{
         var mydate=new Date()
         var year=mydate.getYear()
         if (year < 1000)
                 year+=1900
                 var day=mydate.getDay()
                 var month=mydate.getMonth()
                 var daym=mydate.getDate()
                 if (daym<10)
                    daym="0"+daym
                    var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado")
                    var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
                    document.write("<b><font face='Arial, Helvetica, sans-serif'>"+dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year+"</font></b>")
}					
</script>

<script Language="JavaScript"><!--
function validar(formulario)
{

  if (formulario.ciudad.value == "")
  {
    alert("Ingrese el nombre de la ciudad");
    formulario.ciudad.focus();
    return (false);
  }

  if (formulario.cedula.value == "")
  {
    alert("Ingrese el número de la cédula");
    formulario.cedula.focus();
    return (false);
  }

  if (formulario.nombre_completo.value == "")
  {
    alert("Ingrese apellidos y nombres");
    formulario.nombre_completo.focus();
    return (false);
  }

  if (formulario.expedicion_cedula.value == "")
  {
    alert("Ingrese la ciudad donde expidió su cédula");
    formulario.expedicion_cedula.focus();
    return (false);
  }

  if (formulario.edad.value == "")
  {
    alert("Ingrese su edad");
    formulario.edad.focus();
    return (false);
  }

  if (formulario.estado_civil.value == "")
  {
    alert("Ingrese su estado civil");
    formulario.estado_civil.focus();
    return (false);
  }

  if (formulario.ciudad.value == "")
  {
    alert("Ingrese el nombre de la ciudad");
    formulario.ciudad.focus();
    return (false);
  }

  if (formulario.natural_de.value == "")
  {
    alert("Ingrese de donde es usted");
    formulario.natural_de.focus();
    return (false);
  }

  if (formulario.residente_en.value == "")
  {
    alert("Ingrese la dirección de residencia");
    formulario.residente_en.focus();
    return (false);
  }

  if (formulario.ciudad_reside.value == "")
  {
    alert("Ingrese la ciudad donde reside");
    formulario.ciudad_reside.focus();
    return (false);
  }

  if (formulario.telefono_fijo.value == "")
  {
    alert("Ingrese el su número de teléfono fijo");
    formulario.telefono_fijo.focus();
    return (false);
  }

  if (formulario.celular.value == "")
  {
    alert("Ingrese el número de su celular");
    formulario.celular.focus();
    return (false);
  }
  
  if (formulario.grado.value == "")
  {
    alert("Ingrese su grado militar");
    formulario.grado.focus();
    return (false);
  }
  
  if (formulario.cargo.value == "")
  {
    alert("Ingrese su cargo actual");
    formulario.cargo.focus();
    return (false);
  }
   
  if (formulario.hechos.value == "")
  {
    alert("Redacte los hechos por el cual se le imputan los cargos");
    formulario.hechos.focus();
    return (false);
  }
  
  if (formulario.nom_funcionario.value == "")
  {
    alert("Escriba el nombre del funcionario investigador");
    formulario.nom_funcionario.focus();
    return (false);
  }

  
  if (formulario.cargo_funcionario.value == "")
  {
    alert("Escriba el cargo del funcionario investigador");
    formulario.cargo_funcionario.focus();
    return (false);
  }
  
  if (formulario.dia_noti.value == "")
  {
    alert("Escriba el día de la notificación");
    formulario.dia_noti.focus();
    return (false);
  }
  
  if (formulario.mes_noti.value == "")
  {
    alert("Escriba el mes de la notificación");
    formulario.mes_noti.focus();
    return (false);
  }
 
  return (true);
}
//--></script>

<script Language="JavaScript"><!--
var timerID = null;
var timerRunning = false; 
var id,pause=0,position=0; 
function stopclock () 
{
    if(timerRunning) 
        clearTimeout(timerID); 
    timerRunning = false;
}

function showtime ()
{ 
    var now = new Date();
    var hours = now.getHours(); 
    var minutes = now.getMinutes(); 
    var seconds = now.getSeconds() 
    var timeValue = "" + ((hours >12) ? hours -12 :hours)
    timeValue += ((minutes < 10) ? ":0" : ":") + minutes
    timeValue += ((seconds < 10) ? ":0" : ":") + seconds
    timeValue += (hours >= 12) ? " p.m." : " a.m." 
    document.formulario.hora.value = timeValue;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true; 
}

function startclock ()
{ 
    stopclock ();
    showtime ();
}

//--></script>

</head>


<?php
global $dbi;
   
require_once("../Conectarse.php");

$control = mysql_query('SELECT cedula, nombre, direccion, telefono, celular, ciudad, email FROM cartera_serviasjudinet  WHERE cedula =  "' . $_GET["cedulita"]  . '" ');
if (!$control) {
	die('Error de consulta: ' . mysql_error());
}
list($cedula_c,$nombre_completo, $direccion, $telefono, $celular, $ciudad, $email) = mysql_fetch_row($control);
$fil = mysql_num_rows($control);		 

if ($fil == '0')
{
	$control = mysql_query('SELECT cedula, nombre, direccion, telefono, celular, ciudad, email FROM beneficiarios  WHERE cedula =  "' . $_GET["cedulita"]  . '" ');
	if (!$control) {
		die('Error de consulta: ' . mysql_error());
	}
    list($cedula_c,$nombre_completo, $direccion, $telefono, $celular, $ciudad, $email) = mysql_fetch_row($control);
}
//$query_sql = "SELECT * FROM sucursal order by nombre";
//$sql = mysql_query($query_sql, $dbi) or die(mysql_error());
$sql = mysql_query('SELECT * FROM sucursal order by nombre');
if (!$sql) {
	die('Invalid query: ' . mysql_error());
}
$row_sql = mysql_fetch_assoc($sql);
$totalRows_sql = mysql_num_rows($sql); 

	
$sql2 = mysql_query('SELECT * FROM Usuarios WHERE (Cargo = "ABOGADO" || Cargo = "ABOGADA"  || Cargo = "DISER MOCOA"  || Cargo = "DISER BARRANQUILLA" || Cargo = "DIRECTORA DE SERVICIOS MONTERIA" || Cargo = "DIRECTOR DE SERVICIOS BUCARAMANGA" || Cargo = "DISER CALI" || Cargo = "DISER FLORENCIA" || Cargo = "DISER IBAGUE" || Cargo = "DISER MEDELLIN" || Cargo = "DIRECTOR DE SERVICIOS NEIVA" || Cargo = "DIRECTORA DE SERVICIOS PEREIRA" || Cargo = "DIRECTORA DE SERVICIOS TUNJA"  || Cargo = "DISER VILLAVICENCIO" || Cargo = "MEDICO" || Cargo = "DIRECTORA DE SERVICIOS " || Cargo = "DISER VALLEDUPAR"  || Cargo = "PRESIDENTE SERVIASJUDINET" || Cargo = "DISER ARAUCA") order by Nombre_Completo');
			if (!$sql2) {
				die('Invalid query: ' . mysql_error());
			}
	$row_sql2 = mysql_fetch_assoc($sql2);
	$totalRows_sql2 = mysql_num_rows($sql2); 
	 
	$cedulafun = $cedu;
?>
<body onLoad="document.formulario.ciudad.focus();startclock()">
<header>
    <img src="../ELEMENTS/bannerInterasjudinet.png" alt="" width=" 700" height="70">
</header>
<h3 class="titulo">INGRESO PROGRAMACION CONSULTA</h3>


<form method="post" name="formulario" action="<?php echo $editFormAction; ?>" onSubmit="return validar(this)">
<table width="863" border="0" align="center" cellpadding="3" cellspacing="3">    
<!--<tr>
	<td colspan="8" align="right" nowrap><div align="center"><span class="exp">INGRESO PROGRAMACION CONSULTA </span></div></td>
</tr>-->
<tr>
    <td colspan="8" align="right" nowrap><div align="center" class="Estilo2">
      <script languaje="JavaScript">Mostrar_Fecha()</script></div></td>
</tr>
<tr>
	<td colspan="8"><table width="852">
    <tr>
    	<td  class="fecha" width="200"><div align="center"></div></td>
        <td class="fecha" width="320">Fecha dd-mm/aaaa:
          <input name="dia" type="text" id="dia2" value="<?php echo date("d"); ?>" size="2" maxlength="2" readonly="">
          <input name="mes" type="text" id="mes2" value="<?php echo date("m"); ?>" size="2" maxlength="2" readonly="">
          <input name="ano" type="text" id="ano2" value="<?php echo date("Y"); ?>" size="4" maxlength="4" readonly="">
        </span></span></div></td>
        <td class="fecha" width="200"><div align="center"></div></td>
      </tr>
    </table></td>
</tr>

<tr>
    <td colspan="8"><div align="right" class="Estilo19 Estilo20">
      <div align="left" class="Estilo41"> 
        <div align="center" class="Estilo42">
          <p>&nbsp;</p>
          </div>
      </div>
    </div>      </td>
    </tr>
	
  <tr>
    <td class="tdcen" width="215" align="right"></td>
    <td class="tdcen" colspan="7">&nbsp;</td>
  </tr>
  
<tr>
	<td class="tdder">Numero de Cedula:</td>
	<td class="tdizq"><input name="ced3" type="text" value="<?php echo $cedula_c ?>" size="30" maxlength="30" readonly=""></td>
    <td class="tdder">Nombre:</td>
    <td class="tdizq"><input name="name_full" type="text" id="name_full" value="<?php echo $nombre_completo ?>" size="30" maxlength="30" readonly=""></td>
</tr>

<tr>
	<td class="tdder">Direccion:</td>
	<td class="tdizq"><input name="dir" type="text" id="dir" value="<?php echo $direccion ?>" size="45" maxlength="45" ></td>
    <td class="tdder">Telefono:</td>
    <td class="tdizq"><input name="tel" type="text" id="tel" value="<?php echo $telefono ?>" size="30" maxlength="30" ></td>
</tr>


<tr>
	<td class="tdder">Numero Celular:</td>
	<td class="tdizq"><input name="cel" type="text" id="cel" value="<?php echo $celular ?>" size="30" maxlength="30" ></td>
    <td class="tdder">Ciudad:</td>
    <td class="tdizq"><input name="ciu" type="text" id="ciu" value="<?php echo $ciudad ?>" size="30" maxlength="30"></td>
</tr>
<tr>
	<td class="tdder">Email:</td>
    <td class="tdizq" colspan="7"><input name="mail" type="text" id="mail" value="<?php echo $email ?>" size="30" maxlength="30" ></td>
</tr>

<tr>
	<td class="tdder">Numero de Atencion:</td>
    <td class="tdizq"><input name="$atencionnum" type="text" size="15" maxlength="15" ></td>
    <td class="tdder">Fecha de Servicio:</td>
    <td class="tdizq"><input name="fechas" type="text" value="0000-00-00" size="15" maxlength="15" ></td>
</tr>

<tr>
	<td class="tdder">Sucursal:</td>
    <td class="tdizq"><select name="codigo_sucursal" class="campo">
    <option value="">--SELECCIONE SUCURSAL--</option>
    <?php
     do {  
	?>
    <option value="<?php echo $row_sql['codigo'];?>"><?php echo $row_sql['nombre']?></option>
    <?php
	} while ($row_sql = mysql_fetch_assoc($sql));
  	$rows = mysql_num_rows($sql);
  	if($rows > 0) {
      mysql_data_seek($sql, 0);
       $row_sql = mysql_fetch_assoc($sql);
  	}
	?>
    </select></td>
    <td class="tdder">Hora de Servicio:</td>
    <td class="tdizq"><input name="horas" type="text" id="horas" value="00:00 am" size="12" maxlength="8" ></td>
</tr>

<tr>
  	<td class="tdder">Nombre Funcionario:</td>
    <td class="tdizq">
    <select name="ced_funcionario" id="ced_funcionario">
   	<option>SELECCIONE FUNCIONARIO</option>
    <?php
     do {  
	?>
    <option value="<?php echo $row_sql2['Cedula'];?>"><?php echo $row_sql2['Nombre_Completo']?></option>
    <?php
	} while ($row_sql2 = mysql_fetch_assoc($sql2));
  	$rows2 = mysql_num_rows($sql2);
  	if($rows2 > 0) {
      mysql_data_seek($sql2, 0);
       $row_sql2 = mysql_fetch_assoc($sql2);
 	}
	?>
    </select></td>
    <td class="tdder">Tipo de Atencion :</td>
    <td class="tdizq">
    	<select name="tipo_servi" class="sel3">
        	<option value="" selected>--TIPO DE SERVICIO--</option>
           	<option value="PERSONALIZADA">PERSONALIZADA</option>
           	<option value="DOMICILIARIA">DOMICILIARIA </option>
           	<option value="VIDEO CONFERENCIA">VIDEO CONFERENCIA</option>
           <option value="TELEFONICA">TELEFONICA</option>
       	</select>
  	</td>
</tr>

<tr>
	<td colspan="8" align="right" nowrap>
    <div align="center" class="Estilo20">
    <p>
    	<input  name="submit" type="submit" class="direcciona" value="ENVIAR" > 
      	<!--<input name="button" type="button" class="irmenu" onClick="window.location.href='index.php'" value="IR A LA PAGINA PRINCIPAL">
        <input name="button" type="button" class="boton1" onClick="window.location.reload()" value="Actualizar">-->
  	</p>
    </div>
    </td>
</tr>
</table>
<div align="center">
	<input type="hidden" name="MM_insert" value="formulario">
</div>
</form>  
</body>
</html>



<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING']))
{
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formulario"))
{
	global $dbi;
	if($atencionnum!='' && $fechas!='' && $horas!='' && $codigo_sucursal!='' && $ced_funcionario!='' && $tipo_servi!='' )
   	{
		$numr = mysql_query('SELECT * FROM record_servicios WHERE cedula = "' .$ced3. '" and numero_atencion = "' .$atencionnum. '"');
		if (!$numr) {
			die('Invalid query: ' . mysql_error());
		}
		$num=mysql_num_rows($numr); 
			
		if($num==0)
		{
			$contf = mysql_query('SELECT numerocontrato, tipocontrato FROM cartera_serviasjudinet    WHERE numerocontrato =  "' . $_GET["contrato"]  . '" and (tipocontrato = "SJ09" || tipocontrato = "SJ10" || tipocontrato = "SJ11" || tipocontrato = "SJ12" || tipocontrato = "SJ13")');
			if (!$contf) {
				die('Invalid query proceso bene: ' . mysql_error());
			} 
			list($contra, $tipo) = mysql_fetch_row($contf);	
					
			if ($tipo > 0)
			{
				$con = mysql_query('SELECT codigo_contrato   FROM planes_contratos  WHERE  codigo  =  "' .$tipo. '" ');
		 		if (!$con) {
					die('Invalid query proceso bene: ' . mysql_error());
				} 
				list($tipo) = mysql_fetch_row($con);
			}
	
			$conttr = mysql_query('SELECT numero_visitas, horas_asesorias FROM planes_contratos  WHERE  codigo_contrato = "'.$tipo.'" ');
		  	if (!$conttr) {
				die('Invalid query proceso bene: ' . mysql_error());
			} 
			list($numvis, $horvis) = mysql_fetch_row($conttr);
					
			$contf = mysql_query('SELECT numerocontrato, tipocontrato FROM cartera_serviasjudinet    WHERE numerocontrato =  "' . $_GET["contrato"]  . '" and (tipocontrato = "SJ09" || tipocontrato = "SJ10" || tipocontrato = "SJ11" || tipocontrato = "SJ12" || tipocontrato = "SJ13")');
			if (!$contf) {
				die('Invalid query proceso bene: ' . mysql_error());
			} 
			list($contra, $tipo) = mysql_fetch_row($contf);	
					
			if ((mysql_num_rows($contf)!=0)) 
	      	{
				$cont = mysql_query('SELECT visitas, horas FROM control_atenciones   WHERE contrato =  "'.$contra. '" ');
				if (!$cont) {
					die('Invalid query proceso bene: ' . mysql_error());
				} 			
				if ((mysql_num_rows($cont)==0)) 
	            {	
					mysql_query("INSERT INTO control_atenciones (contrato, tipo)  VALUES ('" ."$contra". "', '" ."$tipo". "')");
					
					$cont = mysql_query('SELECT visitas, horas FROM control_atenciones   WHERE contrato =  "'.$contra. '" ');
					if (!$cont) {
						die('Invalid query proceso bene: ' . mysql_error());
					} 	
				}
				list($visita, $horas) = mysql_fetch_row($cont);	
			}
		
			if ($tipo_servi != "DOMICILIARIA")		
			{
				$control = mysql_query('SELECT Nombre_Completo FROM Usuarios WHERE Cedula = "' ."$ced_funcionario". '" ');
				if (!$control) {
					die('Invalid query: ' . mysql_error());
				}
				list($nombre_funcio) = mysql_fetch_row($control);
		 
		  		$ides = mysql_query('SELECT MAX(id), MAX(numero_atencion) FROM record_servicios  WHERE sucursal  = "' . $_POST[codigo_sucursal] . '"');
				if (!$ides) {
					die('Invalid query sucuuu: ' . mysql_error());
				}
		 		list($idsucu, $taten) = mysql_fetch_row($ides);
		 
 				$idto = mysql_query('SELECT MAX(id) FROM record_servicios ');
				if (!$idto) {
					die('Invalid query idesides: ' . mysql_error());
				}
		 		list($idtota) = mysql_fetch_row($idto);
						 
				$guardd =  mysql_query("INSERT INTO record_servicios (cedula, numero_atencion, fecha_servicio , hora_servicio, sucursal, nombre_funcionario, cedula_funcionario,tipo, estado)  VALUES ('" . $_POST["ced3"] . "', '" . $_POST["atencionnum"] . "', '" . $_POST["fechas"] . "', '" . $_POST["horas"] . "', '" . $_POST["codigo_sucursal"] . "', '" ."$nombre_funcio". "', '" . $_POST["ced_funcionario"] . "', '" . $_POST["tipo_servi"] . "', '4')");
				if (!$guardd) {
					die('Invalid query update guardd: ' . mysql_error());
				}
							

				$idos = $idtota + 2;


				if ($atencionnum < $taten)
				{
					$totadd = mysql_query("UPDATE  record_servicios  set id = '" .$idos. "' WHERE id = '" .$idsucu. "' ");
					if (!$totadd) {
						die('Invalid query totadd 174: ' . mysql_error());
					}									 
				}							
							
							
				
				$mssql2 = mysql_query("UPDATE  cartera_serviasjudinet   set direccion = '" . $_POST[dir] . "', telefono = '" . $_POST[tel] . "', celular = '" . $_POST[cel] . "', ciudad = '" . $_POST[ciu] . "', email  = '" . $_POST[mail] . "' WHERE cedula = '" . $_POST[ced3] . "' ");
				if (!$mssql2) {
				die('Invalid query update 174: ' . mysql_error());
							}
				$mssql2 = mysql_query("UPDATE  beneficiarios  set direccion = '" . $_POST[dir] . "', telefono = '" . $_POST[tel] . "', celular = '" . $_POST[cel] . "', ciudad = '" . $_POST[ciu] . "', email  = '" . $_POST[mail] . "' WHERE cedula = '" . $_POST[ced3] . "' ");
				if (!$mssql2) {
					die('Invalid query update 1222: ' . mysql_error());
				}


				$mss = mysql_query("UPDATE  solicitud_citas set fecha = '" . $_POST[fechas] . "', hora = '" . $_POST[horas] . "', atencion = '" . $_POST[atencionnum] . "', funcionario = '" . $_POST[ced_funcionario] . "', estado = '2' WHERE cedula = '" . $_POST[ced3] . "' and estado = '1' ");
				if (!$mss) {
					die('Invalid query update 174: ' . mysql_error());
				}

				echo "<script>alert('La información se ha enviado correctamente ');</script>";
			}
			else
			{		
				if ($visita < $numvis and $horas < $horvis)
				{
		
					$vito = $visita + 1;
					$hort = $horas + 2 ;
		
					$mssql2 = mysql_query("UPDATE  control_atenciones  set visitas = '" .$vito. "', horas = '" .$hort. "' WHERE contrato =  '" . $_GET[contrato]  . "' ");
					if (!$mssql2) {
						die('Invalid query update 1478: ' . mysql_error());
					}
		
		  			$control = mysql_query('SELECT Nombre_Completo FROM Usuarios WHERE Cedula = "' ."$ced_funcionario". '" ');
					if (!$control) {
						die('Invalid query: ' . mysql_error());
					}
		 			list($nombre_funcio) = mysql_fetch_row($control);
				
				
 					$ides = mysql_query('SELECT MAX(id)  FROM record_servicios  WHERE sucursal  = "' . $_POST[codigo_sucursal] . '"');
					if (!$ides) {
						die('Invalid query idesides: ' . mysql_error());
					}
		 			list($idsucu) = mysql_fetch_row($ides);
		 
		  			$idto = mysql_query('SELECT MAX(id) FROM record_servicios');
					if (!$idto) {
						die('Invalid query idesides: ' . mysql_error());
					}
		 			list($idtota) = mysql_fetch_row($idto);

					$idtos = $idtota + 1; 




					$totadd = mysql_query("UPDATE  record_servicios  set id = '" .$idtos. "' WHERE id = '" .$idsucu. "' ");
					if (!$totadd) {
						die('Invalid query totadd 174: ' . mysql_error());
					}
							 
				
							 
  					mysql_query("INSERT INTO record_servicios (id, cedula, numero_atencion, fecha_servicio , hora_servicio, sucursal, nombre_funcionario, cedula_funcionario,tipo, estado)  VALUES ('" ."$idsucu". "','" . $_POST["ced3"] . "', '" . $_POST["atencionnum"] . "', '" . $_POST["fechas"] . "', '" . $_POST["horas"] . "', '" . $_POST["codigo_sucursal"] . "', '" ."$nombre_funcio". "', '" . $_POST["ced_funcionario"] . "', '" . $_POST["tipo_servi"] . "', '4')");

				
					$mssql2 = mysql_query("UPDATE  cartera_serviasjudinet   set direccion = '" . $_POST[dir] . "', telefono = '" . $_POST[tel] . "', celular = '" . $_POST[cel] . "', ciudad = '" . $_POST[ciu] . "', email  = '" . $_POST[mail] . "' WHERE cedula = '" . $_POST[ced3] . "' ");
					if (!$mssql2) {
						die('Invalid query update 4: ' . mysql_error());
					}
					$mssql2 = mysql_query("UPDATE  beneficiarios  set direccion = '" . $_POST[dir] . "', telefono = '" . $_POST[tel] . "', celular = '" . $_POST[cel] . "', ciudad = '" . $_POST[ciu] . "', email  = '" . $_POST[mail] . "' WHERE cedula = '" . $_POST[ced3] . "' ");
					if (!$mssql2) {
						die('Invalid query update 17: ' . mysql_error());
					}

			
					$mss = mysql_query("UPDATE  solicitud_citas set fecha = '" . $_POST[fechas] . "', hora = '" . $_POST[horas] . "', atencion = '" . $_POST[atencionnum] . "', funcionario = '" . $_POST[ced_funcionario] . "', estado = '2' WHERE cedula = '" . $_POST[ced3] . "' and estado = '1' ");
					if (!$mss) {
						die('Invalid query update 174: ' . mysql_error());
					}
				 	 
  					echo "<script>alert('La información se ha enviado correctamente ');</script>";
				 
				}
				else
				{
 					echo "<script> alert('No se le puede Asignar Citas Domiciliarias ha este contrato');</script>";
				}
				 
			}	 
		}
		else
		{
			echo "<script> alert('Este Numero de Atencion ya existe');</script>";
		}
	}
}
?>