Location: PHPKode > projects > T-77.com Operational Management System > omis/items.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php
$colname2_bills = "1";
if (isset($_GET['ordernr'])) {
  $colname2_bills = (get_magic_quotes_gpc()) ? $_GET['ordernr'] : addslashes($_GET['ordernr']);
}
$colname_bills = "1";
if (isset($_GET['id'])) {
  $colname_bills = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_bills = sprintf("SELECT * FROM t77_bill_bills WHERE t77_bill_bills.bill_id = %s OR t77_bill_bills.order_number = %s", $colname_bills,$colname2_bills);
$bills = mysql_query($query_bills, $t77_connect) or die(mysql_error());
$row_bills = mysql_fetch_assoc($bills);
$totalRows_bills = mysql_num_rows($bills);

$var = $row_bills['bill_id'];

$colname_items = "1";
if (isset($var)) {
  $colname_items = (get_magic_quotes_gpc()) ? $var : addslashes($var);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_items = sprintf("SELECT * FROM t77_bill_items WHERE t77_bill_items.bill_id = %s ORDER BY t77_bill_items.item_order", $colname_items);
$items = mysql_query($query_items, $t77_connect) or die(mysql_error());
$row_items = mysql_fetch_assoc($items);
$totalRows_items = mysql_num_rows($items);

mysql_select_db($database_t77_connect, $t77_connect);
$query_settings = "SELECT * FROM t77_bill_settings";
$settings = mysql_query($query_settings, $t77_connect) or die(mysql_error());
$row_settings = mysql_fetch_assoc($settings);
$totalRows_settings = mysql_num_rows($settings);

$subtotal = 0;
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
//-->
</script>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="lineleft">
  <tr>
    <td height="40" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="20"><img src="images/tabletopstart.gif" width="20" height="31" /></td>
        <td><table width="100%" height="30" border="0" cellpadding="5" cellspacing="0">
          <tr>
            <td><p><?php echo $row_bills['order_number']; ?>&nbsp;&nbsp;<strong><?php echo $row_bills['bill_name']; ?> - <?php echo DateAndTime($row_bills['bill_date']); ?></strong></p>
            </td>
            <td>&nbsp;
            </td>
            <td><table width="32" border="0" align="right" cellpadding="0" cellspacing="0">
                <tr>
                  <td><a href="javascript:;" onClick="MM_openBrWindow('item_insert.php?ordernr=<?php echo $row_bills['order_number']; ?>&amp;ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','item','resizable=yes,width=750,height=550')"><img src="images/toolbar/add_small.gif" alt="nieuw item op deze order zetten" width="20" height="20" border="0" /></a></td>
                  <td width="5"><img src="images/spacer.gif" width="5" height="16" /></td>
                  <td><a href="delete.php?bill_id=<?php echo $row_bills['bill_id']; ?>&amp;delete=bill&typeID=<? echo $row_bills['bill_type']; ?>" onClick="GP_popupConfirmMsg('Are you sure you want to delete this Document? This cannot be undone.');return document.MM_returnValue"><img src="images/toolbar/delete_small.gif" alt="Wis dit item" width="17" height="17" border="0" /></a></td>
                </tr>
              </table>
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="20">
        <tr>
          <td><?php if ($totalRows_items > 0) { // Show if recordset not empty ?>
            <table width="100%" border="0" cellpadding="7" cellspacing="0" class="tableBorder">
              <tr> 
                <td><?php 
		$i = 0;
		do { 
		$i++;
		$bgcolor = "#ffffff"; 
		$subtotal = $subtotal + $row_items['item_price'];
		?>
                  <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="<? echo $bgcolor; ?>">
                    <tr> 
                      <td colspan="2" align="left" valign="top"><table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
                          <tr valign="middle"> 
                            <td><h1><?php echo $row_items['item_name']; ?></h1></td>
                            <td><table width="32" border="0" align="right" cellpadding="0" cellspacing="0">
                                <tr> 
                                  <td><a href="javascript:;" onClick="MM_openBrWindow('item_update.php?id=<?php echo $row_items['item_id']; ?>&amp;billid=<?php echo $row_items['bill_id']; ?>&amp;ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','ItemUpdate','scrollbars=yes,resizable=yes,width=750,height=550')" onMouseOver="MM_displayStatusMsg('bewerk <?php echo $row_items['item_name']; ?>');return document.MM_returnValue"><img src="images/toolbar/edit_small_white.gif" alt="Bewerk dit item" width="17" height="17" border="0" /></a></td>
                                  <td width="10"><img src="images/spacer.gif" width="10" height="16" /></td>
                                  <td><a href="delete.php?item_id=<?php echo $row_items['item_id']; ?>&amp;delete=item&amp;billid=<?php echo $row_items['bill_id']; ?>" onClick="GP_popupConfirmMsg('Are you sure you want to delete this item? This cannot be undone.');return document.MM_returnValue" onMouseOver="MM_displayStatusMsg('wis <?php echo $row_items['item_name']; ?>');return document.MM_returnValue"><img src="images/toolbar/delete_small_white.gif" alt="Wis dit item" width="17" height="17" border="0" /></a></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table>
                        <img src="images/pblue.gif" alt="hr" width="100%" height="1" /></td>
                    </tr>
                    <tr> 
                      <td align="left" valign="top"><p><?php echo $row_items['item_description']; ?></p></td>
                      <td align="right" valign="bottom" nowrap="nowrap"> 
                        <? if($row_items['item_price'] < 0) { 
					$color = "#ff0000";
				} else {
					$color = "#000000";
				} ?>
                        <? if($row_items['item_price'] != '') { ?><p><font color="<? echo $color; ?>"><?php echo $row_settings['valuta_sign']; ?>&nbsp;<?php echo number_format($row_items['item_price'],2,',','.'); ?></font></p><? } else { echo "&nbsp;"; } ?></td>
                    </tr>
                    <tr> 
                      <td height="10" align="left" valign="top"><img src="images/spacer.gif" width="1" height="1" /></td>
                      <td height="10" align="right" valign="bottom" nowrap="nowrap">&nbsp;</td>
                    </tr>
                  </table>
                  <?php } while ($row_items = mysql_fetch_assoc($items)); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td><img src="images/pblue.gif" alt="hr" width="100%" height="1" /> 
                        <table width="100%" border="0" cellspacing="0" cellpadding="5">
                          <tr> 
                            <td width="54">&nbsp;</td>
                            <td width="475" align="right" valign="top"><p><strong>Sub
                                  total</strong></p></td>
                            <td width="128" align="right" valign="top" nowrap="nowrap"><p><?php echo $row_settings['valuta_sign']; ?>&nbsp;<? echo number_format($subtotal,2,',','.'); ?></p></td>
                          </tr>
                          <tr> 
                            <td>&nbsp;</td>
                            <td align="right" valign="top"><p><strong>VAT: <?php echo number_format($row_settings['VAT'],2,',','.'); ?>%</strong></p></td>
                            <td align="right" valign="top" nowrap="nowrap"><p> 
                                <?php 	echo $row_settings['valuta_sign'];
					echo "&nbsp;"; 
					$VAT = (($subtotal/100)*$row_settings['VAT']);
					echo number_format($VAT,2,',','.'); ?>
                              </p></td>
                          </tr>
                          <tr> 
                            <td>&nbsp;</td>
                            <td align="right" valign="top"><p><strong>Total</strong></p></td>
                            <td align="right" valign="top" nowrap="nowrap"><p><?php echo $row_settings['valuta_sign']; ?>&nbsp;<? echo number_format(($subtotal+$VAT),2,',','.'); ?></p></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
            </table>
            <?php } else { ?>
            <h1>This document contains no items. Click <a href="javascript:;" onClick="MM_openBrWindow('item_insert.php?ordernr=<?php echo $row_bills['order_number']; ?>&amp;ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','item','resizable=yes,width=600,height=350')">here<img src="images/toolbar/add_small_white.gif" alt="nieuw item op deze order zetten" width="17" height="17" border="0" align="baseline" /></a>to
              add one.<? } ?>
            </h1></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($bills);

mysql_free_result($items);

mysql_free_result($settings);
?>
Return current item: T-77.com Operational Management System