Skip to content

Pedidos_06102023_1 #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/patch-1_pedidosparcialg3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy PHP app to Azure Web App - PedidosParcialG3

on:
push:
branches:
- patch-1
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v1
with:
files: 'composer.json'

- name: Run composer install if composer.json exists
if: steps.check_files.outputs.files_exists == 'true'
run: composer validate --no-check-publish && composer install --prefer-dist --no-progress

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: php-app
path: release.zip

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: php-app

- name: Unzip artifact for deployment
run: unzip release.zip

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'PedidosParcialG3'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_FE968103DC37469880CCDBA661B60C1D }}
package: .
47 changes: 47 additions & 0 deletions Restaurantes/consultar_pedido.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Obtén el número de pedido desde el formulario
$numero_pedido = $_POST["numero_pedido"];

// Configuración de conexión a Azure SQL Server (reemplaza con tus valores)
$serverName = "bdg3.database.windows.net";
$connectionOptions = array(
"Database" => "Bdg3",
"Uid" => "unmsmg3",
"PWD" => "S54@a1a1"
);

// Intenta establecer la conexión
$conn = sqlsrv_connect($serverName, $connectionOptions);

// Verifica la conexión
if (!$conn) {
die(print_r(sqlsrv_errors(), true));
}

// Consulta SQL para obtener información del pedido
$sql = "SELECT * FROM I01_Pedidos_TC WHERE nro_pedido = ?";
$params = array($numero_pedido);
$stmt = sqlsrv_query($conn, $sql, $params);

// Muestra los resultados
if ($stmt) {
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo "Número de Pedido: " . $row["nro_pedido"] . "<br>";
echo "ID Cliente: " . $row["doc_id_cliente"] . "<br>";
echo "Cliente: " . $row["cdsc_cliente"] . "<br>";
echo "Subtotal: $" . $row["subtotal"] . "<br>";
echo "IGV: $" . $row["igv"] . "<br>";
echo "Total: $" . $row["total"] . "<br>";
}
} else {
echo "Pedido no encontrado.";
}

// Cierra la conexión
sqlsrv_close($conn);
} else {
// Redirige a la página principal si se accede directamente a consultar_pedido.php sin enviar datos
header("Location: ../index.html");
}
?>
37 changes: 37 additions & 0 deletions Restaurantes/restaurante1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/styles.css">
</head>
<body>
<h1>Formulario de pedido para Restaurante 1</h1>
<div class="formulario">
<form action="../procesar_pedido.php" method="post">
<label for="nombre">Nombre:</label>
<input type="text" name="nombre" id="nombre" required>

<label for="direccion">Dirección de entrega:</label>
<input type="text" name="direccion" id="direccion" required>

<label for="comida">Seleccione su comida:</label>
<select name="comida" id="comida" required>
<option value="plato1">Plato 1</option>
<option value="plato2">Plato 2</option>
<!-- Agrega más opciones de comida aquí -->
</select>

<input type="submit" value="Enviar Pedido">
</form>
</div>

<h2>Consulta de Pedido</h2>
<div class="consulta-formulario">
<form action="consultar_pedido.php" method="post">
<label for="numero_pedido">Número de Pedido:</label>
<input type="text" name="numero_pedido" id="numero_pedido" required>
<input type="submit" value="Consultar Pedido">
</form>
</div>

</body>
</html>
82 changes: 82 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* Reset de estilos */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}

h1 {
background-color: #333;
color: #fff;
padding: 10px;
}

.formulario {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.formulario label {
display: block;
margin: 10px 0;
font-weight: bold;
}

.formulario input[type="text"],
.formulario select {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 5px;
}

.formulario select {
appearance: none;
}

.formulario input[type="submit"] {
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
}

.restaurant-list {
display: flex;
justify-content: center;
flex-wrap: wrap;
}

.restaurant-list a {
text-decoration: none;
margin: 20px;
display: block;
color: #333;
}

.restaurant-list img {
width: 200px;
height: 150px;
}

.restaurant-list h2 {
margin-top: 10px;
}

/* Agrega estilos adicionales según tus preferencias */
Binary file added images/restaurante1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/restaurante2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<?php

echo "Hello World!";
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<h1>Seleccione un restaurante</h1>
<div class="restaurant-list">
<a href="restaurantes/restaurante1.php">
<img src="images/restaurante1.png" alt="Restaurante 1">
<h2>Restaurante 1</h2>
</a>
<a href="restaurantes/restaurante2.php">
<img src="images/restaurante2.png" alt="Restaurante 2">
<h2>Restaurante 2</h2>
</a>
<!-- Agrega más restaurantes aquí -->
</div>
</body>
</html>