<?php require_once('../Connections/EVENTS.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO poblaciones (nom_poblacion) VALUES (%s)",
                       GetSQLValueString($_POST['nom_poblacion'], "text"));

  mysql_select_db($database_EVENTS, $EVENTS);
  $Result1 = mysql_query($insertSQL, $EVENTS) or die(mysql_error());

  $insertGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_EVENTS, $EVENTS);
$query_montajes = "SELECT * FROM montajes";
$montajes = mysql_query($query_montajes, $EVENTS) or die(mysql_error());
$row_montajes = mysql_fetch_assoc($montajes);

$colname_montajes = "-1";
if (isset($_GET['datepicker'])) {
  $colname_montajes = $_GET['datepicker'];
}
mysql_select_db($database_EVENTS, $EVENTS);
$query_montajes = sprintf("SELECT * FROM montajes WHERE datepicker = %s", GetSQLValueString($colname_montajes, "text"));
$montajes = mysql_query($query_montajes, $EVENTS) or die(mysql_error());
$row_montajes = mysql_fetch_assoc($montajes);
?>




<!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>Documento sin título</title>

 <link rel="stylesheet" type="text/css" href="css/default.css" />
 
	<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.7.2.custom.css" />
    
     <link rel="stylesheet" type="text/css" href="css/miscss.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($){
	$.datepicker.regional['es'] = {
		closeText: 'Cerrar',
		prevText: '&#x3c;Ant',
		nextText: 'Sig&#x3e;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
		dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['es']);
});    

        $(document).ready(function() {
           $("#datepicker").datepicker();
        });
    </script>

<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="cuerpo_inserta">

<div class="anuncia_pagina_inserta">
  <strong> MANCOMERAL</strong>
</div>
    
<div class="anuncia_inserta">
    <form action="index.php" method="get" name="form1" target="_self" id="form1">
        <label for="datepicker">INSERTAR MONTAJE</label></form>
</div>

<div class="boton_atras">
   <input name="button" type="button" class="mkbutton" id="button" onclick="window.location.href = 'index.php';" value="VOLVER AL INICIO" />
</div>


<div class="form_inserta_poblacion">
 <form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
  <table width="567" align="center">
    <tr valign="baseline">
      <td width="250" height="39" align="center" valign="middle" nowrap="nowrap">NOMBRE DE LA POBLACIÓN </td>
      <td width="305" align="left" valign="middle"><span id="sprytextfield1">
        <label for="nom_poblacion"></label>
        <input name="nom_poblacion" type="text" id="nom_poblacion" size="50" />
        <span class="textfieldRequiredMsg">Se necesita una POBLACIÓN.</span></span></td>
    </tr>
    <tr valign="baseline">
      <td height="35" align="center" valign="middle" nowrap="nowrap">&nbsp;</td>
      <td align="left" valign="middle"><input type="submit" value="Insertar población" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form2" />
</form>

</div>


</div><!--FIN DE DIV CUERPO---> 
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
</script>
</body>
</html>