Location: PHPKode > projects > T-77.com Operational Management System > omis/print.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php

$colname_bills = "12";
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", $colname_bills);
$bills = mysql_query($query_bills, $t77_connect) or die(mysql_error());
$row_bills = mysql_fetch_assoc($bills);
$totalRows_bills = mysql_num_rows($bills);

$colname_items = "1";
if (isset($_GET['id'])) {
  $colname_items = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
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);

$colname_contact = $row_bills['bill_contact'];
if (isset($row_bills['bill_contact'])) {
  $colname_contact = (get_magic_quotes_gpc()) ? $row_bills['bill_contact'] : addslashes($row_bills['bill_contact']);
}

$contactSelect = $row_bills['bill_contact'];
$subtotal = 0;

$colname_contacts = "1";
if (isset($contactSelect)) {
  $colname_contacts = (get_magic_quotes_gpc()) ? $contactSelect : addslashes($contactSelect);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_contacts = sprintf("SELECT * FROM t77_bill_contacts, t77_bill_companies WHERE t77_bill_contacts.contact_company_name = t77_bill_companies.company_id AND t77_bill_contacts.contact_id = %s", $colname_contacts);
$contacts = mysql_query($query_contacts, $t77_connect) or die(mysql_error());
$row_contacts = mysql_fetch_assoc($contacts);
$totalRows_contacts = mysql_num_rows($contacts);
?>
<?php
$typeVar = $row_bills['bill_type'];
$colname_types = "1";
if (isset($typeVar)) {
  $colname_types = (get_magic_quotes_gpc()) ? $typeVar : addslashes($typeVar);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_types = sprintf("SELECT * FROM t77_bill_types WHERE t77_bill_types.bill_type = %s", $colname_types);
$types = mysql_query($query_types, $t77_connect) or die(mysql_error());
$row_types = mysql_fetch_assoc($types);
$totalRows_types = mysql_num_rows($types);

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);
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
p {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 8pt;
	color: #000000;
	line-height: 14pt;
	margin: 0px;
	padding: 0px;
}
body {
	margin: 0px;
	padding: 0px;
}

@page { size 21cm 29.7cm; margin: 5cm }

h1 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 8pt;
	line-height: 14pt;
	font-weight: bold;
	color: #000000;
	margin: 0px;
	padding: 0px;

}
.tableBorder {
	border: 1px solid #6FA2D0;
}
.tableTop {
	border-bottom-width: 1px;
	border-bottom-style: solid;
	border-bottom-color: #6FA2D0;
	background-color: #D6E5F2;
}
.bodyHeader {
	background-image: url(images/bodyTop.gif);
	background-repeat: repeat-x;
}
.lineleft {
	border-left-width: 1px;
	border-left-style: solid;
	border-left-color: #003CA5;
}
textarea {
	background-color: #ffffff;
	border: 1px solid #003CA5;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
}
input {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	background-color: #ffffff;
	border: 1px solid #003CA5;
}
a:link {
	color: #003ca5;
	text-decoration: none;
}
a:hover {
	color: #003ca5;
	text-decoration: underline;
}
.LineTotal {
	border-top-width: 1px;
	border-top-style: solid;
	border-top-color: #003ca5;
}

-->
</style>
</head>

<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="2"><div align="center"><img src="logo.jpg" width="333" height="99"></div></td>
              </tr>
            <tr>
              <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="20">
                  <tr>
                    <td><p><?php echo $row_contacts['company_name']; ?><br />
                    p.a. &nbsp;<?php echo $row_contacts['contact_title']; ?>&nbsp;<?php echo $row_contacts['contact_person']; ?><br />
                    <?php echo $row_contacts['contact_company_address']; ?><br />
                    <?php echo $row_contacts['contact_company_zip']; ?>&nbsp;<?php echo $row_contacts['contact_company_city']; ?><br />
                    <?php echo $row_contacts['contact_country']; ?></p>
                    </td>
                  </tr>
                </table>
              </td>
              <td width="250" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="20">
                  <tr>
                    <td><div align="right">
                        <p align="left"><?php echo $row_settings['company_address']; ?><strong><br />
                          </strong><?php echo $row_settings['company_zip']; ?>&nbsp;<?php echo $row_settings['company_city']; ?><br />
                      Tel : <?php echo $row_settings['company_tel']; ?><br />
                      email: <?php echo $row_settings['company_email']; ?><br />
                      <?php echo $row_settings['company_bank']; ?></p>
                        <p align="left"><?php echo $row_settings['company_COC_nr']; ?>
                          <br>
                          <?php echo $row_settings['company_VAT_nr']; ?></p>
                    </div>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="10">
            <tr>
              <td><table width="80%"  border="0" cellspacing="0" cellpadding="3">
                <tr>
                  <td width="60" nowrap="nowrap">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td width="95" nowrap="nowrap">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="60" nowrap="nowrap"><h1>About: </h1></td>
                  <td><p><?php echo $row_bills['bill_name']; ?></p></td>
                  <td width="95" nowrap="nowrap"><h1>Date:</h1></td>
                  <td><p><?php echo DateAndTime($row_bills['bill_date']); ?></p></td>
                </tr>
                <tr>
                  <td width="60" nowrap="nowrap"><h1>Order nr:</h1></td>
                  <td><p><?php echo $row_bills['order_number']; ?></p></td>
                  <td width="95" nowrap="nowrap"><h1>Handled&nbsp;by: </h1></td>
                  <td><p><?php echo $row_settings['contact_name']; ?></p></td>
                </tr>
                <tr>
                  <td width="60" nowrap="nowrap"><h1>Type:</h1></td>
                  <td><p><?php echo $row_types['type_description']; ?></p></td>
                  <td width="95" nowrap="nowrap">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="60" nowrap="nowrap">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td width="95" nowrap="nowrap">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td height="20" valign="middle">
					<?php 
		do { 
		$bgcolor = "#ffffff";
		$subtotal = $subtotal + $row_items['item_price'];
		
		if($row_items['item_price'] != 0) {
		?>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="<? echo $bgcolor; ?>">
                    <tr>
                      <td colspan="2" align="left" valign="top"><p><strong><?php echo $row_items['item_name']; ?></strong></p>
                      </td>
                    </tr>
                    <tr>
                      <td align="left" valign="top"><table width="85%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td><p><?php echo $row_items['item_description']; ?></p></td>
                        </tr>
                      </table>                      
                            </td>
                      <td align="right" valign="bottom"><p><?php echo $row_settings['valuta_sign']; ?>&nbsp;<?php echo number_format($row_items['item_price'],2,',','.'); ?></p>
                      </td>
                    </tr>
                    <tr>
                      <td height="20" colspan="2" align="left" valign="middle"><img src="images/pgrey.gif" alt="" name="line" width="100%" height="1" id="line" /></td>
                      </tr>
                  </table>
				  <? } else { ?>
				                    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="<? echo $bgcolor; ?>">
                    <tr>
                      <td align="left" valign="top"><p><strong><?php echo $row_items['item_name']; ?></strong></p>
                      </td>
                    </tr>
                    <tr>
                      <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td><p><?php echo $row_items['item_description']; ?></p></td>
                        </tr>
                      </table>                            </td>
                      </tr>
                    <tr>
                      <td height="20" align="left" valign="middle"><img src="images/pgrey.gif" alt="" name="line" width="100%" height="1" id="line" /></td>
                      </tr>
                  </table>
				  <? } ?>
<?php } while ($row_items = mysql_fetch_assoc($items)); ?></td>
                  </tr>
                </table>
</td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%" border="0" align="right" cellpadding="5" cellspacing="0">
                        <tr>
                          <td align="right" valign="top"><p><strong>Sub totwal</strong></p>                          </td>
                          <td width="150" align="right" valign="top"><p><?php echo $row_settings['valuta_sign']; ?>&nbsp;<? echo number_format($subtotal,2,',','.'); ?></p>
                          </td>
                        </tr>
                        <tr>
                          <td align="right" valign="top"><p><strong>VAT: <?php echo number_format($row_settings['VAT'],2,',','.'); ?>%</strong></p>
                            </td>
                          <td width="150" align="right" valign="top"><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 align="right" valign="top"><p><strong>Total</strong></p>
                          </td>
                          <td width="150" align="right" valign="top"><p><?php echo $row_settings['valuta_sign']; ?>&nbsp;<? echo number_format($subtotal+$VAT,2,',','.'); ?></p>
                          </td>
                        </tr>
                        <tr>
                          <td align="right" valign="top">&nbsp;</td>
                          <td align="right" valign="top">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="right" valign="top"><p align="left">&nbsp;</p>
                            </td>
                          <td align="right" valign="top">&nbsp;</td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($bills);

mysql_free_result($items);

mysql_free_result($contacts);

mysql_free_result($types);

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