<div id="prefactura" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form name="form1" method="get" action="tirillas/prefactura.php" target="_blank">
                    <input type="hidden" name="pen_id" value="<?php echo $pen_id; ?>">
                    <input type="checkbox" id="propi" name="propi" value="si" checked>
                    <label class="lab" for="propi"> Aplicar Propina</label>  
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">NO</button>
                        <button name="prefactura" value="prefactura" type="submit" class="btn btn-success"><i class="icon-print"></i> <strong>Imprimir</strong></button>
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div> 

<div id="confirmar" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form name="form1" method="post" action="">
                    <input type="hidden" name="pen_id" value="<?php echo $pen_id; ?>">
                    <div class="alert alert-success alert-dismissable">
                        <strong>Desea realmente confirmar el pedido !</strong> <a href="#" class="alert-link"></a>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                        <button name="confirmar" value="confirmar" type="submit" class="btn btn-success"><i class="icon-ok"></i> <strong>SI</strong></button>
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div> 

<?php
if(!empty($_POST['confirmar']) ) 
{
    $fecha=date('Y-m-d H:i:s');
    $hora_pedido = date('h:i:s A'); // Formato de 12 horas con AM/PM
    $sql=mysqli_query($con,"UPDATE pedido Set
                                pen_fecha='$fecha',
                                pen_estado='Procesando'
                                Where pen_id='$pen_id' and pen_estado='En Proceso'") or  die(mysqli_error($con)); 

    $sql=mysqli_query($con,"UPDATE pedido Set
                                pen_estado='Procesando'
                                Where pen_id='$pen_id' and pen_estado='Espachado'") or  die(mysqli_error($con)); 

    $sql=mysqli_query($con,"UPDATE pedido_detalle Set
                                pend_archivado='si', 
                                pend_hora='$hora_pedido'                              
                                Where pedido_pen_id ='$pen_id' and pend_archivado='no' ") or  die(mysqli_error($con)); 

    $sql=mysqli_query($con,"UPDATE pedido_detalle_combo Set
                                pend_archivado='si',
                                pedcom_hora='$hora_pedido'                               
                                Where pedido_pen_id ='$pen_id' and pend_archivado='no' ") or  die(mysqli_error($con)); 
    
    echo '<script>location.href = "P_turno.php";</script>';
}
?>