<?php
require_once('Connections/con_imag.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Crear Clientes</title>
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<script type="text/javascript">
function toggle(elemento)
{
if(elemento.value=="menor")
{
document.getElementById("menor").style.display = "block";
document.getElementById("intermedio").style.display = "none";
document.getElementById("mayor").style.display = "none";
document.getElementById("otro").style.display = "none";
}else
{
if(elemento.value=="intermedio")
{
document.getElementById("menor").style.display = "none";
document.getElementById("intermedio").style.display = "block";
document.getElementById("mayor").style.display = "none";
document.getElementById("otro").style.display = "none";
}else
{
if(elemento.value=="mayor")
{
document.getElementById("menor").style.display = "none";
document.getElementById("intermedio").style.display = "none";
document.getElementById("mayor").style.display = "block";
document.getElementById("otro").style.display = "none";
}else
{
if(elemento.value=="otro")
{
document.getElementById("menor").style.display = "none";
document.getElementById("intermedio").style.display = "none";
document.getElementById("mayor").style.display = "none";
document.getElementById("otro").style.display = "block";
}
}
}
}
}
</script>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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"] == "form1")) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$tema=$_POST["tema"];
for ($i = 0; $i <count($tema); $i++) {
for($j = 0; $j <count($tema[$i]); $j++) {
$tema[$i][$j].'<br/>';
$modaser = $tema[$i][$j];
echo $modaser;
}
}
$moa= $tema[0][0] ;//menor 200
$ms= $tema[0][1] ;//menor 300
$msr= $tema[0][2] ;//menor 500
$moda= $tema[1][0] ;//intermedio 1200
$mosr= $tema[1][1] ;//intermedio 1000
$mods= $tema[2][0] ;//mayor 2400
$moser= $tema[2][1] ;//mayor 2000
$mdri= $tema[3][0];//otro
$mdser= "$moa $ms $msr"; //menor 200 300 500
$mdr= "$moda $mosr"; //intermedio 1200 1000
$mdsr= "$mods $moser"; //mayor 2400 2000
$modser="$mdser $mdr $mdsr $mdri";// todos
echo $modser;
}
$insertSQL = sprintf("INSERT INTO clientes (Nom_emp, Nom_contac, Dir, Telefono, Email, Descripcion, mod_serv) VALUES (%s, %s, %s, %s, %s, %s, '$modaser')",
GetSQLValueString($_POST['txtNom_emp'], "text"),
GetSQLValueString($_POST['txtNom_contac'], "text"),
GetSQLValueString($_POST['txtDir'], "text"),
GetSQLValueString($_POST['txtTel'], "int"),
GetSQLValueString($_POST['txtMail'], "text"),
GetSQLValueString($_POST['txtDescripcion'], "text"),
GetSQLValueString($_POST[$tema[$i][$j]], "text")
);
if ($Result1 == true)
{
echo "Registro Guardado existosamente!!!";
}
else
{
echo "No se puede realizar el registro!!!";
}
}
?>
<div class="control-group info">
<h1>Alta de Clientes</h1>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="50%" border="1" class="table">
<tr class="info">
<td colspan="2"><center><strong>Nombre de la empresa:</strong></center></td>
<td><label for="txtNom_emp"></label>
<input type="text" name="txtNom_emp" id="txtNom_emp" /></td>
</tr>
<tr>
<td colspan="2"><center><strong>Nombre del contacto:</strong></center></td>
<td><label for="txtNom_contac"></label>
<input type="text" name="txtNom_contac" id="txtNom_contac" /></td>
</tr>
<tr>
<td colspan="2"><center><strong>Direccion:</strong></center></td>
<td><label for="txtDir"></label>
<input type="text" name="txtDir" id="txtDir" /></td>
</tr>
<tr>
<td colspan="2" width="152"><center><strong>Telefono:</strong></center></td>
<td><label for="txtTel"></label>
<input type="text" name="txtTel" id="txtTel" /></td>
</tr>
<tr>
<td colspan="2" width="152"><center><strong>E-mail:</strong></center></td>
<td><label for="txtMail"></label>
<input type="text" name="txtMail" id="txtMail" /></td>
</tr>
<tr>
<td colspan="2" width="152"><center><strong>Descripción:</strong></center></td>
<td><label for="txtDescripcion"></label>
<textarea name="txtDescripcion" id="txtDescripcion" cols="45" rows="2"></textarea></td>
</tr>
</tr>
</table>
<dl>
<dt><label>Modalidad:</label></dt>
<dd>
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="menor" >Servicio Menor
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="intermedio">Servicio Intermedio
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="mayor">Servicio Mayor
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="otro">Otro Servicio
<div id="menor" style="display:none">
<p>
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="200"> 200 hr
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="300">300 hr
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="500">500 hr
</p>
</div>
<div id="intermedio" style="display:none">
<p>
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="1200"> 1200 hr
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="1000">1000 hr
</p>
</div>
<div id="mayor" style="display:none">
<p>
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="2400"> 2400 hr
<input type="checkbox" name="tema[][]" onclick="toggle(this)" value="2000">2000 hr
</p>
</div>
<div id="otro" style="display:none">
<p>
<input name="tema[][]" type="text" value="" style="width:80px;" /><br />
Ingrese modalidad
</p>
</div>
</dd>
</dl>
<p>
<input type="submit" name="button" id="button" value="Enviar" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<form id="Productos_menu" name="Productos_menu" action="Productos_menu.php" method="POST" >
<table BORDER=1 CELLSPACING=0 CELLPADDING=0 BACKGROUND='white'>
<tr>
<input type='submit' name='regresar' id='regresar' value='Regresar' />
</tr>
</table>
</form>
</html>