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/public_html/cunsulta_verificacion_cita.php
<html>
<head>
<title>PROGRAMACION CONSULTAS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Estilo1 {font-family: "Arial Narrow"}
.Estilo2 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.Estilo19 {font-family: "Arial Narrow"; font-weight: bold; }
.Estilo20 {color: #990000}
.Estilo21 {font-family: "Arial Narrow"; font-weight: bold; font-size: 14; color: #990000; }
.Estilo13 {font-size: 12px; font-weight: bold; }
.Estilo41 {font-family: "Times New Roman", Times, serif}
.Estilo42 {color: #009933}
.Estilo45 {
	color: #0066FF;
	font-size: 16px;
}
-->
</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.dir.value == "")
  {
    alert("Falta Ingresar la Direccion");
    formulario.dir.focus();
    return (false);
  }
  
  if (formulario.tel.value == "")
  {
    alert("Falta Ingresar número telefonico");
    formulario.tel.focus();
    return (false);
  }

  if (formulario.cel.value == "")
  {
    alert("Falta Ingresar número de celular");
    formulario.cel.focus();
    return (false);
  }
 
   if (formulario.ciu.value == "")
  {
    alert("Falta Ingresar ciudad");
    formulario.ciu.focus();
    return (false);
  }
  
     if (formulario.mail.value == "")
  {
    alert("Falta Ingresar correo electronico");
    formulario.mail.focus();
    return (false);
  }
  
      if (formulario.fechas.value == "0000-00-00")
  {
    alert("Falta Ingresar posible fecha de cita");
    formulario.fechas.focus();
    return (false);
  }
  
     if (formulario.horas.value == "00:00")
  {
    alert("Falta Ingresar posible hora de cita");
    formulario.horas.focus();
    return (false);
  }
  
    if (formulario.codigo_sucursal.value == "")
  {
    alert("Falta Seleccionar la Sucursal");
    formulario.codigo_sucursal.focus();
    return (false);
  }
  
   if (formulario.tipo_servi.value == "")
  {
    alert("Falta Seleccionar tipo de atención");
    formulario.tipo_servi.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>
<link href="file:///C|/Documents%20and%20Settings/web%20master/Mis%20documentos/job9.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo59 {
	color: #00C
}
.Estilo60 {color: #006600}
.Estilo61 {font-size: 16px}
.Estilo62 {
	color: #000033;
	font-weight: bold;
	font-size: 16px;
}
.Estilo63 {color: #003399}
body form table tr td {
	color: #F00;
}
body form table tr td {
	font-size: 16px;
}
body form table tr td {
	font-family: Arial, Helvetica, sans-serif;
}
body form table tr td {
	font-size: 14px;
}
body form table tr td {
	color: #009;
}
body form table tr td {
	font-size: 16px;
}
body form table tr td {
	color: #F00;
}
body form table tr td {
	color: #F00;
}
-->
</style>
</head>
<?php 
 echo "<form name='form' action='' method='post'>";
    include ("config.php");
   global $dbi;
   
   require_once("Conectarse.php");

	$control = mysql_query('SELECT cedula, nombre, direccion, telefono, celular, ciudad, email, fecha, hora, sucursal, tipo_atencion, funcionario, atencion FROM solicitud_citas WHERE cedula =  "' . $_GET["cedulita"].'" and id="'.$_GET["id"].'" and estado = 5 ');
	if (!$control) {
		die('Error de consulta: ' . mysql_error());
	}
    list($cedula_c,$nombre_completo, $direccion, $telefono, $celular, $ciudad, $email, $fecha, $hora, $sucursal, $atencion, $funci , $numate) = mysql_fetch_row($control);
	  
	$conttre = mysql_query('SELECT Nombre_Completo FROM Usuarios   WHERE Cedula = "' . "$funci". '" ');
	if (!$conttre) {
		die('Invalid query 42: ' . mysql_error());
	}
	list($funcionario) = mysql_fetch_row($conttre); 

	$contt = mysql_query('SELECT nombre FROM sucursal WHERE codigo = "' . "$sucursal". '" ');
	if (!$contt) {
		die('Invalid query 42: ' . mysql_error());
	}
	list($sucursal) = mysql_fetch_row($contt); 
	  
	//$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 = "DIRECTORA COMERCIAL MOCOA"  || Cargo = "DIRECTORA DE SERVICIOS BARRANQUILLA" || Cargo = "DIRECTORA DE SERVICIOS MONTERIA" || Cargo = "DIRECTOR DE SERVICIOS BUCARAMANGA" || Cargo = "DIRECTOR DE SERVICIOS CALI" || Cargo = "DIRECTOR DE SERVICIOS FLORENCIA" || Cargo = "DIRECTOR DE SERVICIOS IBAGUE" || Cargo = "DIRECTOR DE SERVICIOS MEDELLIN" || Cargo = "DIRECTOR DE SERVICIOS NEIVA" || Cargo = "DIRECTORA DE SERVICIOS PEREIRA" || Cargo = "DIRECTORA DE SERVICIOS TUNJA"  || Cargo = "DIRECTORA SERVICIOS VILLAVICENCIO" || Cargo = "MEDICO" || Cargo = "DIRECTORA DE SERVICIOS "  || Cargo = "PRESIDENTE SERVIASJUDINET") 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()">

<form method="post" name="formulario"  onSubmit="return validar(this)">
<table width="908" border="2" align="center" cellpadding="3" cellspacing="3" >    
  <tr valign="baseline" bgcolor="#FF6600">
    <td colspan="8" align="right" nowrap bgcolor="#FEFFDD"><div align="center"><span class="Estilo2 Estilo59">SU CITA HA SIDO PROGRAMADA </span></div></td>
  </tr>
 
  <tr valign="baseline" bgcolor="#F2F2E6">
    <td colspan="8" bgcolor="#FEFFDD"><table width="852">
      <tr>
       
      </tr>
    </table></td>
  </tr>
  <tr valign="baseline" bgcolor="#FFCC99">
    <td colspan="8" bgcolor="#FEFFDD">
   <tr valign="baseline" bgcolor="#FFCC99"> Su cita  Jur&iacute;dica ha sido asignada en la fecha y hora indicada aqui, cuya duración es maximo de 30 Minutos. Se le recomienda su puntual asistencia.</td>
    </tr>
	

   
  <tr valign="baseline" bgcolor="#F2F2E6">
    <td bgcolor="#FEFFDD"><div align="right" class="Estilo60">
      <div align="left"><strong> <span class="Estilo5 Estilo1 Estilo61">N° de Cedula:</span></strong></div>
    </div></td>
	
    <td bgcolor="#FEFFDD"><input name="ced3" type="text" value="<?php echo $cedula_c ?>" size="30" maxlength="30" readonly=""></td>
    <td bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Nombre:</span></strong></td>
    <td bgcolor="#FEFFDD"><input name="name_full" type="text" id="name_full" value="<?php echo $nombre_completo ?>" size="50" maxlength="50" readonly=""></td>
  </tr>
   <tr valign="baseline" bgcolor="#F2F2E6">
    <td bgcolor="#FEFFDD"><div align="right" class="Estilo60">
      <div align="left"><strong> <span class="Estilo5 Estilo1 Estilo61">Direccion:</span></strong></div>
    </div></td>
	
    <td bgcolor="#FEFFDD"><input name="dir" type="text" id="dir" value="<?php echo $direccion ?>" size="45" maxlength="45" ></td>
    <td bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Telefono:</span></strong></td>
    <td bgcolor="#FEFFDD"><input name="tel" type="text" id="tel" value="<?php echo $telefono ?>" size="30" maxlength="30" ></td>
  </tr>
  <tr valign="baseline" bgcolor="#F2F2E6">
    <td bgcolor="#FEFFDD"><div align="right" class="Estilo60">
      <div align="left"><strong> <span class="Estilo5 Estilo1 Estilo61">Numero Celular:</span></strong></div>
    </div></td>
	
    <td bgcolor="#FEFFDD"><input name="cel" type="text" id="cel" value="<?php echo $celular ?>" size="30" maxlength="30" ></td>
    <td bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Ciudad:</span></strong></td>
    <td bgcolor="#FEFFDD"><input name="ciu" type="text" id="ciu" value="<?php echo $ciudad ?>" size="30" maxlength="30"></td>
  </tr>
  <tr valign="baseline" bgcolor="#F2F2E6">
    <td width="116" align="right" nowrap bordercolor="#ECE9D8" bgcolor="#FEFFDD"><div align="left" class="Estilo60"><strong><span class="Estilo5 Estilo1 Estilo61">Email:</span></strong></div></td>
    <td colspan="7" bgcolor="#FEFFDD"><input name="mail" type="text" id="mail" value="<?php echo $email ?>" size="50" maxlength="50" ></td>
    </tr>
  <tr valign="baseline" bgcolor="#F2F2E6">
  
 
    <td width="116" bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Fecha Cita:</span></strong></td>
    <td width="272" bgcolor="#FEFFDD"><input name="fechas" type="text" value="<?php echo $fecha ?>" size="10" maxlength="10" ></td>
    <td width="154" bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Hora Cita:</span></strong></td>
    <td width="327" bgcolor="#FEFFDD"><input name="horas" type="text" id="horas" value="<?php echo $hora ?>" size="5" maxlength="5" >	</td>
  </tr>
    <tr valign="baseline" bgcolor="#F2F2E6">
    <td height="37" bgcolor="#FEFFDD"><div align="right" class="Estilo60">
      <div align="left"><strong><span class="Estilo5 Estilo1 Estilo61"> Sucursal:</span></strong> </div>
    </div></td>
    <td width="272" bordercolor="#ECE9D8" bgcolor="#FEFFDD"><input name="sucur" type="text" value="<?php echo $sucursal ?>" size="20" maxlength="20" >   </td>
   <td width="154" bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">Tipo de Atencion :</span></strong></td>
    <td width="327" bgcolor="#FEFFDD"><input name="atencion" type="text" value="<?php echo $atencion ?>" size="25" maxlength="25" >	</td>
  </tr>
   <tr valign="baseline" bgcolor="#F2F2E6">
    <td bgcolor="#FEFFDD">
      <div align="right" ><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60"> Funcionario :</span></strong>    </div></td>
    <td bordercolor="#ECE9D8" bgcolor="#FEFFDD" > <input name="funcionario" type="text" value="<?php echo $funcionario ?>" size="45" maxlength="45" ></td>
	<td width="154" bgcolor="#FEFFDD"><strong><span class="Estilo5 Estilo1 Estilo45 Estilo60">N&deg; de  Atencion :</span></strong></td>
    <td width="327" bgcolor="#FEFFDD"><input name="numate" type="text" value="<?php echo $numate ?>" size="8" maxlength="8" >	</td>
  </tr>
  </table>

  
    <div align="center">
      <input type="hidden" name="MM_insert" value="formulario">
    </div>
</form>  
</body>
</html>

<?php

if(isset($_POST["guardar"]))
{

  $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);	
				}
	
	$horat = $horas.''.$hor;
		
		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);
							 
 $aprova =  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"] . "', '" ."$horat". "', '" . $_POST["codigo_sucursal"] . "', '" ."$nombre_funcio". "', '" . $_POST["ced_funcionario"] . "', '" . $_POST["tipo_servi"] . "', '4')");
				  if (!$aprova) {
				die('Invalid query update aprova: ' . mysql_error());
							}

			$mss = mysql_query("UPDATE  solicitud_citas set fecha = '" . $_POST[fechas] . "', hora = '" .$horat. "', atencion = '" . $_POST[atencionnum] . "', estado = '2' WHERE cedula = '" . $_POST[ced3] . "' ");
				if (!$mss) {
				die('Invalid query update 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());
			}


echo "<script>alert('La información se ha enviado correctamente ');</script>";
echo "<SCRIPT LANGUAGE='javascript'>window.location.href='listado_central_citas.php?</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);
							 
  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"] . "', '" ."$horat". "', '" . $_POST["codigo_sucursal"] . "', '" ."$nombre_funcio". "', '" . $_POST["ced_funcionario"] . "', '" . $_POST["tipo_servi"] . "', '4')");

				$mss = mysql_query("UPDATE  solicitud_citas set fecha = '" . $_POST[fechas] . "', hora = '" .$horat. "', atencion = '" . $_POST[atencionnum] . "', estado = '2' WHERE cedula = '" . $_POST[ced3] . "' ");
				if (!$mss) {
				die('Invalid query update 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 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());
			}

	 
  echo "<script>alert('La información se ha enviado correctamente ');</script>";
				 echo "<SCRIPT LANGUAGE='javascript'>window.location.href='listado_central_citas.php?</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>";
			
				 }
		
}
?>