php Programming
<html lang="es">
<head>
<title> Tarea Unidad 3 - SENA
</title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
</head>
<style>
table, th, td { border: 2px solid
blueviolet; }
</style>
<body>
<h4> Elaborado por Luis A.
Sanchez </h4>
<h3> CALCULADORA SENA MARZO -
2019</h3>
<h4>A = Adicion R = Resta
M = Multiplicacion </h4>
<h4>L = Limpiar D = Dividir
I = Igual </h4>
<?php
$buttons1=[1,2,3,'+',4,5,6,'-',7,8,9,'*',0,'.','C','/','='];
$buttons2=[1,2,3,'A',4,5,6,'R',7,8,9,'M',0,'.','L','D','I'];
$Presionado='';
$Presionado1='';
if(isset($_POST['Presionado'])
&& in_array($_POST['Presionado'],$buttons2))
{
$Presionado=$_POST['Presionado'];
if ($_POST['Presionado'] =="A")
{$Presionado1='+';}
elseif ($_POST['Presionado']
=="R") {$Presionado1='-';}
elseif ($_POST['Presionado']
=="M") {$Presionado1='*';}
elseif ($_POST['Presionado']
=="D") {$Presionado1='/';}
elseif ($_POST['Presionado']
=="L") {$Presionado1='C';}
elseif ($_POST['Presionado']
=="I") {$Presionado1='=';}
else {
$Presionado1=$_POST['Presionado']; }
}
$Guardado='';
if(isset($_POST['Guardado'])
&& preg_match('~^(?:[\d.]+[*/+-]?)+$~',$_POST['Guardado'],$out))
{ $Guardado=$out[0]; }
$display=$Guardado.$Presionado1;
if(($Presionado=='C')||($Presionado=='L')){ $display=''; }
elseif(($Presionado=='=')||($Presionado=='I')
&& preg_match('~^\d*\.?\d+(?:[*/+-]\d*\.?\d+)*$~',$Guardado))
{ $display.=eval("return $Guardado;"); }
echo "<form
action=\"\" method=\"POST\">";
echo "<table
style=\"width:400px;border:solid thick black;\">";
echo
"<tr>";
echo
"<td colspan=\"10\">$display</td>";
echo "</tr>";
foreach(array_chunk($buttons2,4) as
$chunk){
echo "<tr>";
foreach($chunk as $button){
echo
"<td",(sizeof($chunk)!=10?"
colspan=\"7\"":""),">"
. "<button
name=\"Presionado\"
value=\"$button\">$button</button></td>";
}
echo "</tr>"; }
echo "</table>"; echo
"<input type=\"hidden\" name=\"Guardado\"
value=\"$display\">";
echo "</form>";
?>
</body>
</html>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title> Tarea Unidad 4 - SENA </title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
</head>
<style>
table, th, td { border: 2px solid blueviolet; }
</style>
<body>
<h4> Elaborado por Luis A. Sanchez </h4>
<h3> SISTEMA DE RESERVA DE SILLAS - 2019</h3>
<h4>L=Libre V=Vendido R=Reservado </h4>
<h2> ============================== =========</h2>
</head>
<body>
<?php
$S=0;$display=''; $Cambio=False;$i=0;
if ($S==0){
$SillaNum=['F/C',1,2,3,4,5,1,' L','L','L','V','L',2,'L','L',' R','L','L',3,'L','L','L','V',' L',4,'L','L','L','L','L',5,'L' ,'L','R','L','L'];
$S=1; }
if (($S==1)|| ($Cambio==True)) { $display='';
$Presionado; $Possilla=0;$Guardado='';$ display='';
echo "<form action=\"\" method=\"POST\">";
echo "<table style=\"width:400px;border: solid thick black;\">";
echo "<tr>"; echo "</tr>";
foreach(array_chunk($SillaNum, 6) as $chunk){ echo "<tr>";
foreach($chunk as $button){echo "<td",(sizeof($chunk)!=25?" colspan=\"7\"":""),">"
. "<button name=\"Presionado\" value=\"$button\">$button</ button></td>"; }
echo "</tr>"; } echo "</table>";
//echo "<input type=\"hidden\" name=\"Guardado\" value=\"$display\">";
echo "</form>"; $S=2;
}
if (isset($_POST['submit'])) {
foreach ($_POST['Sillafila'] as $Sillafila);
foreach ($_POST['Sillacolumna'] as $Sillacolumna);
$Transaccion = $_POST ['Transaccion'];
$Possilla = ($Sillafila)*6 + ($Sillacolumna);
$Estado = $SillaNum[$Possilla];
echo "============================= ====";echo "<br>";
echo "RESULTADOS DEL SISTEMA DE RESERVA" ; echo "<br>";
echo "Localizacion Silla : " ;
echo " Fila: ".$Sillafila;echo " - - - - " ;
echo " Columna: ".$Sillacolumna;echo " " ;echo "<br>";
if ($Estado =="L") {echo "Estado Actual: ".$Estado ." = Libre";}
elseif ($Estado =="R") { echo "Estado Actual: ".$Estado ." = Reservado";}
else {echo "Estado Actual: ".$Estado ." = Vendido";} echo "<br>";
echo "Silla Num: " .$Possilla; echo " " ;echo "<br>";
echo "============================= ====";echo "<br>";
echo "EVALUACION DE LA SOLICITUD : " ; echo "<br>";
echo " Transaccion requerida: ". $_POST['Transaccion'];echo "<br>";
if($Transaccion == "L"){ echo "Estado Solicitado: ".$Transaccion ." = Libre";}
elseif ($Transaccion =="R") { echo "Estado Actual: ".$Transaccion ." = Reservado";}
elseif ($Transaccion =="P") { echo "Estado Actual: ".$Transaccion ." = Comprar";}
else {echo "Estado Actual: ".$Transaccion ." = Cancelar Reservacion";} echo "<br>";
echo "============================= ====";echo "<br>";
echo "RESULTADO : " ; echo "<br>";
if ($Transaccion == "L"){
if ($Estado =="L") { echo "Silla Libre - Haga transaccion apropiada " ; echo "<br>";}
elseif($Estado =="R") {echo "Silla Reservada - Busque otra disponible " ; echo "<br>";}
else {echo "Silla Vendida - Busque otra disponible " ; echo "<br>";}
}
if ($Transaccion == "R"){
if ($Estado =="L") { echo "Silla Reservada para UD - Congratulations " ; echo "<br>";
$SillaNum[$Possilla]='R'; $Cambio = True; }
elseif($Estado =="R") {echo "Silla Ya Reservada - Busque otra disponible " ; echo "<br>";}
else {echo "Silla Vendida - Busque otra disponible " ; echo "<br>";}
}
if ($Transaccion == "P"){
if ($Estado =="L") { echo "Silla Comprada para UD - Congratulations " ; echo "<br>";
$SillaNum[$Possilla]='V'; $Cambio = True; }
elseif($Estado =="R") {echo "Silla Ya Reservada - Busque otra disponible " ; echo "<br>";}
else {echo "Silla Vendida - Busque otra disponible " ; echo "<br>";}
}
if ($Transaccion == "C"){
if ($Estado =="L") { echo "Silla Libre - Haga transaccion apropiada " ; echo "<br>"; }
elseif($Estado =="R") {echo "Acepta Cancelacion Ya Reservada " ; echo "<br>";
$SillaNum[$Possilla]='L'; $Cambio = True;
} else {echo "Silla YA Vendida - No Puede Cancelar - Sorry " ; echo "<br>";}
}
}
if ($Cambio==True){
$SillaNum= $SillaNum;
echo "<form action=\"\" method=\"POST\">";
echo "<table style=\"width:400px;border: solid thick black;\">";
echo "<tr>"; echo "</tr>";
foreach(array_chunk($SillaNum, 6) as $chunk){ echo "<tr>";
foreach($chunk as $button){echo "<td",(sizeof($chunk)!=25?" colspan=\"7\"":""),">"
. "<button name=\"Presionado\" value=\"$button\">$button</ button></td>"; }
echo "</tr>"; } echo "</table>";
echo "<input type=\"hidden\" name=\"Guardado\" value=\"$display\">";
echo "</form>";
$Cambio=false;
}
?>
<form action="#" method="post">
<form class="form-inline" action="/action_page.php">
<h2> =================== </h2>
<label for='Sillafila'>Seleccione Silla fila:</label><br>
<select name="Sillafila[]" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<h2> </h2>
<label for='Sillacolumna'>Seleccione Silla Columna:</label><br>
<form action="#" method="post">
<select name="Sillacolumna[]" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<h2> =================== </h2>
<h4> Seleccione la transaccion </h4>
<form action="#" method="post">
<input class="radio" type="radio" name="Transaccion" value="L">Libre </td>
<input class="radio" type="radio" name="Transaccion" value="R">Reservar <td>
<input class="radio" type="radio" name="Transaccion" value="P">Comprar<td>
<input class="radio" type="radio" name="Transaccion" value="C">Cancelar Reserva<td>
<h2> =================== </h2>
<input type="submit" name="submit" value="Enviar">
<h2> =================== </h2>
</form>
</body>
</html>
======================================================
Comments
Post a Comment