<?php

 if (isset($_GET['accion'])) {
	 require_once "../config/conexion.php";
        $id = $_REQUEST['accion'];
	    ECHO $id;   
}
 ?>
 

     
<div id="modificar" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="my-modal-title" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header bg-gradient-primary text-white">
                <h5 class="modal-title" id="title">Modificar Producto</h5>
                <button class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
			 <?php
            $query = mysqli_query($conexion, "SELECT p.*, p.descripcion, c.idtiposervicio AS id_cat, c.nomtiposervicio FROM servicio p INNER JOIN tiposervicio c ON c.idtiposervicio = p.idtiposervicio WHERE p.idservicio=$id ORDER BY p.idservicio DESC");
			$data = mysqli_fetch_assoc($query);
			$desc = $data['descripcion'];
			echo $desc;
			echo $data['imagen'];
            ?>
            <div class="modal-body">
                <form action="" method="POST" enctype="multipart/form-data" autocomplete="off">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="nombre">Nombre</label>
                                <input id="nombre" class="form-control" type="text" name="nomservicio" placeholder="Nombre" required value="<?php echo $data['nomservicio']; ?>">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="cantidad">Cantidad</label>
                                <input id="cantidad" class="form-control" type="text" name="cantidad" placeholder="Cantidad" required value="<?php echo $data['cantidad']; ?>">
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="descripcion">Descripción</label>
								<textarea id="descripcion" class="form-control" type="text" rows="3" name="descripcion" placeholder="Descripción" required><?php echo $data['descripcion']?></textarea>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="p_normal">Precio Normal</label>
                                <input id="p_normal" class="form-control" type="text" name="p_normal" placeholder="Precio Normal" required value="<?php echo $data['precioservicio']; ?>">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="p_rebajado">Precio Rebajado</label>
                                <input id="p_rebajado" class="form-control" type="text" name="p_rebajado" placeholder="Precio Rebajado" required value="<?php echo $data['precio_rebajado']; ?>">
                            </div>
                        </div>
						 <div class="col-md-6">
                            <div class="form-group">
                                <label for="categoria">Tipo Categoria</label>
                                <select id="categoria" class="form-control" name="Tipocategoria" required>
                                    <?php
                                    $tipocategoria = mysqli_query($conexion, "SELECT *, convert(idclaseservicio,varchar(3))+":"+UCASE(nomclaseservicio)) as clase FROM claseservicio");
                                    foreach ($tipocategoria as $cat) { ?>
                                       <option value="<?php echo $cat['idclaseservicio']; ?>"><?php echo $cat['clase']; ?></option>												
                                    <?php } ?>
                                </select>					
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="categoria">Categoria</label>
                                <select id="categoria" class="form-control" name="categoria" required>
                                    <?php
                                    $categorias = mysqli_query($conexion, "SELECT *, (STRING(idtiposervicio)+":"+UCASE(nomtiposervicio)) AS categoria FROM tiposervicio");
                                    foreach ($categorias as $cat) { ?>
                                        <option value="<?php echo $cat['idtiposervicio']; ?>"><?php echo $cat['categoria']; ?></option>						
                                    <?php } ?>
                                </select>					
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="imagen">Foto</label>
                                <input type="file" class="form-control" name="foto" required><?php echo $data['imagen']?>
                            </div>
                        </div>
                    </div>
					  <form method="post" action="modificar2.php?accion=<?php echo $data['idservicio']; ?>" class="d-inline modificar">
                                 	<button class="btn btn-danger" type="submit" name="button">Registrar</button>
					</form>
                  </form>
            </div>
        </div>
    </div>
</div>