i have computer order for food and drink and i want if i click print button so automatic print in kitcen and bartender without i select printer manualy. how to make this?

Member Avatar

diafol

Is this php?

i make aplication use php and little javascript

Member Avatar

diafol

If you care to share your code with us, perhaps we could advise you further.

This is print in kitchen print

<?  
    date_default_timezone_set("Asia/Jakarta");

    session_start();
    session_id();
    include("conectDB.inc");
    $ku=$_SESSION['kd'];

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tavern Dapur</title>
<style type="text/css">
<!--

.style1 {font-size: 16px}
.style3 {font-size: 10px}
.style2 {font-size: 20px}
.style4 {
    color: #FF0000;
    font-weight: bold;
}
.het {
    font-weight: bold;
}
.het {
    font-size: large;
}
.het {
    font-size: xx-large;
}
.het {
    font-size: x-large;
}
-->
</style>
<script type="text/javascript" language="javascript">

function printPage()
{
    // Do print the page
    if (typeof(window.print) != 'undefined') {
       window.print();
    window.location.href = "order1.php?mj=<?=$_GET[mj];?>";
    }

}

</script>
</head>

<body>
<?

$dt=date("h:i d-m-Y");
$iu=$_SESSION['kd'];
$valid=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu,ket", $link_id);
    while($row=mysql_fetch_row($query1))
    {
        $query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    if($cek=='fd')
    {
        $valid=1;
    }
    }


if($valid==1)
{
?>
<table cellpadding="0" cellspacing="0">
<tr class="het">
<td colspan="2" align="center"><img src="logo.jpg" width="180"><br>
<?=date("d-M-Y G:i ");?><br><a href="t_penj.php">NO MEJA : <?=$_GET[mj];?></a></td>
</tr>
<tr>
<td colspan="2" align="center">User : <?=$_GET[usr];?></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#000000" height="3px">
</td>
</tr>
<?

$sth=0;
$th=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    $cek2=substr($row4[1],0,3);
    if($cek=='fd')
    {
        if($cek2!='fdb')
        {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
        }
?>
<tr class="style2">
<td width="10%"><?=$row[4];?></td>
<td><?
    $query2=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row2=mysql_fetch_row($query2);
    echo $row2[2];
    ?></td>

</tr>
<?
$query2=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0&& menu like '$row[1]' group by menu,ket", $link_id);
    while($row2=mysql_fetch_row($query2))
            {

            ?>
<tr class="style2">
<td colspan="2"><?
if($row2[3]!='')
{
    ?>*<?=$row2[4];?> <?=$row2[3];?>
    <?
}

?></td>
</tr>
<?

    }
    ?>
<tr class="style2"><td colspan="2"> 
</td>
</tr>
<?
    }
            }
            ?>
<tr class="style2"><td colspan="2"> 
</td>
</tr><tr class="style2"><td colspan="2"> 
</td>
</tr>
</table>
<?

$sth=0;
$th=0;
$query1=mysql_query("select * from penj_temp where meja = '$_GET[mj]'&&prt>0", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    $cek2=substr($row4[1],0,3);
    if($cek=='fd'&&$cek2!='fdb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
    }
}
?>

<DIV style="page-break-after:always"></DIV>


<?

$dt=date("h:i d-m-Y");
$iu=$_SESSION['kd'];
$valid=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu,ket", $link_id);
    while($row=mysql_fetch_row($query1))
    {
        $query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='fdb')
    {
        $valid=1;
    }
    }


if($valid==1)
{
?>
<table width="350" cellpadding="0" cellspacing="0">
<tr class="het">
<td colspan="2" align="center">K2<br>
<?=date("d-M-Y G:i ");?><br><a href="t_penj.php">NO MEJA : <?=$_GET[mj];?></a></td>
</tr>
<tr>
<td colspan="2" align="center">User : <?=$_GET[usr];?></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#000000" height="3px">
</td>
</tr>
<?

$sth=0;
$th=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='fdb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
?>
<tr class="style2">
<td width="10%"><?=$row[4];?></td>
<td><?
    $query2=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row2=mysql_fetch_row($query2);
    echo $row2[2];
    ?></td>

</tr>
<?
$query2=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0&& menu like '$row[1]' group by menu,ket", $link_id);
    while($row2=mysql_fetch_row($query2))
            {

            ?>
<tr class="style2">
<td colspan="2"><?
if($row2[3]!='')
{
    ?>*<?=$row2[4];?> <?=$row2[3];?>
    <?
}

?></td>
</tr>
<?

    }
    ?>
<tr class="style2"><td colspan="2"> 
</td>
</tr>
<?
    }
            }
            ?>
<tr class="style2"><td colspan="2"> 
</td>
</tr><tr class="style2"><td colspan="2"> 
</td>
</tr>
</table>
<?

$sth=0;
$th=0;
$query1=mysql_query("select * from penj_temp where meja = '$_GET[mj]'&&prt>0", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='fdb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
    }
}

}
?>
<script type="text/javascript"> if (typeof(window.print) != 'undefined') {
       window.print();
    window.location.href = "mnmoo_print.php?mj=<?=$_GET[mj];?>&usr=<?=$_GET[usr];?>";
    } </script>
    <?
}else{
?>
<script type="text/javascript">  window.location.href = "mnmoo_print.php?mj=<?=$_GET[mj];?>&usr=<?=$_GET[usr];?>";</script>
    <?
}
?>
</body>
</html>

This Print in Bartender Print

<?  
    date_default_timezone_set("Asia/Jakarta");

    session_start();
    session_id();
    include("conectDB.inc");
    $ku=$_SESSION['kd'];

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tavern Minuman</title>
<style type="text/css">
<!--

.style1 {font-size: 16px}
.style3 {font-size: 10px}
.style2 {font-size: 20px}
.style4 {
    color: #FF0000;
    font-weight: bold;
}
.het {
    font-weight: bold;
}
.het {
    font-size: large;
}
.het {
    font-size: xx-large;
}
.het {
    font-size: x-large;
}
-->
</style>
<script type="text/javascript" language="javascript">

function printPage()
{
    // Do print the page
    if (typeof(window.print) != 'undefined') {
       window.print();
    window.location.href = "order1.php?mj=<?=$_GET[mj];?>";
    }

}

</script>
</head>

<body>
<?

$dt=date("h:i d-m-Y");
$iu=$_SESSION['kd'];
$valid=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu,ket", $link_id);
    while($row=mysql_fetch_row($query1))
    {
        $query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    if($cek=='dc')
    {
        $valid=1;
    }
    }


if($valid==1)
{
?>
<table cellpadding="0" cellspacing="0">
<tr class="het">
<td colspan="2" align="center"><img src="logo.jpg" width="180"><br>
<?=date("d-M-Y G:i ");?><br><a href="t_penj.php">NO MEJA : <?=$_GET[mj];?></a></td>
</tr>
<tr>
<td colspan="2" align="center">User : <?=$_GET[usr];?></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#000000" height="3px">
</td>
</tr>
<?

$sth=0;
$th=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    $cek2=substr($row4[1],0,3);
    if($cek=='dc')
    {
        if($cek2!='dcb')
        {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
        }
?>
<tr class="style2">
<td width="10%"><?=$row[4];?></td>
<td><?
    $query2=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row2=mysql_fetch_row($query2);
    echo $row2[2];
    ?></td>

</tr>
<?
$query2=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0&& menu like '$row[1]' group by menu,ket", $link_id);
    while($row2=mysql_fetch_row($query2))
            {

            ?>
<tr class="style2">
<td colspan="2"><?
if($row2[3]!='')
{
    ?>*<?=$row2[4];?> <?=$row2[3];?>
    <?
}

?></td>
</tr>
<?

    }
    ?>
<tr class="style2"><td colspan="2">&nbsp;
</td>
</tr>
<?
    }
            }
            ?>
<tr class="style2"><td colspan="2">&nbsp;
</td>
</tr><tr class="style2"><td colspan="2">&nbsp;
</td>
</tr>
</table>
<?

$sth=0;
$th=0;
$query1=mysql_query("select * from penj_temp where meja = '$_GET[mj]'&&prt>0", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,2);
    $cek2=substr($row4[1],0,3);
    if($cek=='dc'&&$cek2!='dcb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
    }
}
?>

<DIV style="page-break-after:always"></DIV>


<?

$dt=date("h:i d-m-Y");
$iu=$_SESSION['kd'];
$valid=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu,ket", $link_id);
    while($row=mysql_fetch_row($query1))
    {
        $query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='dcb')
    {
        $valid=1;
    }
    }


if($valid==1)
{
?>
<table width="350" cellpadding="0" cellspacing="0">
<tr class="het">
<td colspan="2" align="center">K2<br>
<?=date("d-M-Y G:i ");?><br><a href="t_penj.php">NO MEJA : <?=$_GET[mj];?></a></td>
</tr>
<tr>
<td colspan="2" align="center">User : <?=$_GET[usr];?></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#000000" height="3px">
</td>
</tr>
<?

$sth=0;
$th=0;
$query1=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0 group by menu", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='dcb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
?>
<tr class="style2">
<td width="10%"><?=$row[4];?></td>
<td><?
    $query2=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row2=mysql_fetch_row($query2);
    echo $row2[2];
    ?></td>

</tr>
<?
$query2=mysql_query("select `meja`, `menu`, `jml`, `ket`, sum(`prt`), `nb` from penj_temp where meja = '$_GET[mj]'&&prt>0&& menu like '$row[1]' group by menu,ket", $link_id);
    while($row2=mysql_fetch_row($query2))
            {

            ?>
<tr class="style2">
<td colspan="2"><?
if($row2[3]!='')
{
    ?>*<?=$row2[4];?> <?=$row2[3];?>
    <?
}

?></td>
</tr>
<?

    }
    ?>
<tr class="style2"><td colspan="2">&nbsp;
</td>
</tr>
<?
    }
            }
            ?>
<tr class="style2"><td colspan="2">&nbsp;
</td>
</tr><tr class="style2"><td colspan="2">&nbsp;
</td>
</tr>
</table>
<?

$sth=0;
$th=0;
$query1=mysql_query("select * from penj_temp where meja = '$_GET[mj]'&&prt>0", $link_id);
    while($row=mysql_fetch_row($query1))
            {

$query3=mysql_query("select * from menu where kode = '$row[1]'", $link_id);
    $row3=mysql_fetch_row($query3);
    $query4=mysql_query("select * from kategori where kategori = '$row3[1]'", $link_id);
    $row4=mysql_fetch_row($query4);
    $cek=substr($row4[1],0,3);
    if($cek=='dcb')
    {
        $query2=mysql_query("UPDATE `penj_temp` SET prt = '0' WHERE `meja` like '$_GET[mj]'&& menu like '$row[1]'&& idx like '$row[6]' limit 1", $link_id);
    }
}

}
?>
<script type="text/javascript"> if (typeof(window.print) != 'undefined') {
       window.print();
    window.location.href = "iceoo_print.php?mj=<?=$_GET[mj];?>&usr=<?=$_GET[usr];?>";
    } </script>
    <?
}else{
?>
<script type="text/javascript">  window.location.href = "iceoo_print.php?mj=<?=$_GET[mj];?>&usr=<?=$_GET[usr];?>";</script>
    <?
}
?>
</body>
</html>
Member Avatar

diafol

Let's see if I understand you, you want to press the webpage 'print' button without having the system dialog of choosing a printer - is that right?

The system print (or browser print page as in Chrome) is a good step to use IMO as you can view and decide on the number of copies. It's also a security option to stop malware from printing 1000's of pages of nonsense.

I don't think js can do this. However, there may be a workaround for certain browsers. Her's an old thread:

http://justtalkaboutweb.com/2008/05/09/javascript-print-bypass-printer-dialog-in-ie-and-firefox/

Which describes a script you could use for IE (old versions anyway) and a change you could implement in Firefox (old version again).

For firefox - another reference: http://www.blueboxtwo.com/?showkm&global%5Buid%5D=392-()-Enabling-silent-printing-in-Firefox

I haven't tried it though, but the new versions allow you to add this property.

Here's how to set up Chrome to automatically print:

http://www.youtube.com/watch?v=D6UHjuvI7IE

It uses Vend payment system, but that doesn't matter - you just need to set up a "kiosk".

So although this isn't a js solution, it can be done via the browser - which may be better as the user should not lose control of their browser - they should be in control of it.

It's silent print only print for default printer. but i need for 2 printer whitout choosing a printer