Demo entry 3347737

Javier

   

Submitted by Javier on Dec 17, 2015 at 09:45
Language: PHP. Code size: 4.7 kB.

<link type="text/css" rel="stylesheet" href="inc/css/style.css" />
<?php
include('inc/config.php');
include('inc/noche.php');
date_default_timezone_set('America/Argentina/Buenos_Aires');
$link = mysql_connect($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname, $link) or die
        ('No se puede seleccionar la base de datos');
?>
<div>MESAS NO COBRADAS <?php echo(date('d/m/y')) ?></div>
<?php
$sql = "SELECT * FROM mesas"; //trae todos las mesas de la tabla mesas
$result = mysql_query($sql);
?>
<?php

while ($rows = mysql_fetch_array($result)) {
    $ID = $rows['ID'];
    $mesaactual = $rows['numero'];

    /////////////////////////////////////////
    //
        $sql2 = "SELECT * FROM registros WHERE numeroMesa = '$mesaactual'"
                . "and cobrado = 1 AND borrado = 0 "
                . "AND fecha > Now()-Interval 12 hour LIMIT 1";
    $result2 = mysql_query($sql2);
    ?>

    <?php
// Start looping rows in mysql database.
    while ($rows2 = mysql_fetch_array($result2)) {
        $grupo = $rows2['grupo'];
        $numeroMesa = $rows2['numeroMesa'];
        $numeroDeMesa = "Mesa " . $numeroMesa;
        $mozoMesa = $rows2['mozo'];
        $mozoDeMesa = "Mozo: " . $mozoMesa;
        ?>

        <b><?php echo ucfirst($numeroDeMesa) ?></b>

        <?php
        $sql3 = "SELECT * FROM products";
        $result3 = mysql_query($sql3);
        ?>
        <div id="<?php echo $numeroDeMesa ?>">
<div class="noMostrar">
    <img style="width: 100px; margin-left: 80px;"
         src="../images/marcadeagua/<?php echo $logoNoche ?>"</img>
    <p style="font-size: 19px;"><?php echo ucfirst($nombreNoche) ?></p>
    <p><u><?php echo ucfirst($numeroDeMesa) ?></u></p>
    <p><u><?php echo ucfirst($mozoDeMesa) ?></u></p>
    <p><?php echo(date('d/m/y')) ?></p>
</div>
<script>
    function imprSelec(<?php echo $numeroDeMesa ?>)
    {
        var ficha = document.getElementById(<?php echo $numeroDeMesa ?>);
        var ventimp = window.open('', 'popimpr');
        ventimp.document.write(ficha.innerHTML);
        ventimp.document.close();
        ventimp.print();
        ventimp.close();
    }
</script>        
<table border='1'>
    <tr>        
        <th width='120'>Producto</th>
        <th width='30'>Cant</th>
        <th width='40'>U</th>
        <th width='50'>Total</th>
    </tr>
    <?php
    $total = 0;
    // Start looping rows in mysql database.
    while ($rows3 = mysql_fetch_array($result3)) { 
        $IDProducto = $rows3['productID'];

        /////////////////////////////////////////
        //
 $sql7 = "SELECT * FROM registros "
   . "WHERE productID = '$IDProducto' and numeroMesa = '$mesaactual'"
   . " and cobrado = 1 AND borrado = 0 AND fecha > Now()-Interval 12 hour";
        $result7 = mysql_query($sql7);
        $cuenta = mysql_num_rows($result7);
        //
        /////////////////////////////////////////
        /////////////////////////////////////////
        //
$sql4 = "SELECT * FROM registros WHERE productID = '$IDProducto'"
        . " and numeroMesa = '$mesaactual' and cobrado = 1"
        . " AND borrado = 0 AND fecha > Now()-Interval 12 hour LIMIT 1";
        $result4 = mysql_query($sql4);

        // Start looping rows in mysql database.
        while ($rows4 = mysql_fetch_array($result4)) {
        $IDProductoVendido = $rows4['productID'];

/////////////////////////////////////////
//
         $sql5 = "SELECT * FROM products WHERE productID = $IDProductoVendido";
         $result5 = mysql_query($sql5);
?>

<?php
// Start looping rows in mysql database.


while ($rows5 = mysql_fetch_array($result5)) {


    $nombreProducto = $rows5['productName'];
    $IDProducto = $rows5['productID'];
    $productPrice = $rows5['productPrice'];
    $montoPorProducto = $cuenta * $productPrice;
}
$total = $total + $montoPorProducto;

//
/////////////////////////////////////////
?>
<tr>
    <td width='120'><?php echo $nombreProducto ?></td>
    <td width='30'><?php echo $cuenta ?></td>
    <td width='40'>$<?php echo $productPrice ?></td>
    <td width='50'>$<?php echo $montoPorProducto ?></td>    
</tr> 

<?php
        }
    }
    ?>
    <tr>
        <td colspan='2' align='right'>
<strong> Total</strong>
        </td>
        <td colspan='2'>
<strong>$<?php echo $total; ?></strong>
        </td>
    </tr>     </table>
        </div>
    <a href="javascript:imprSelec('<?php echo $numeroDeMesa ?>')" >
    <input type="button" class="button" value="Imprimir" id="boton"></a>
        <br>
        <?php
    }
}
?>

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).