I've been doing some work on php files (not too familiar with php at all really) and I have a printable purchase order file, that builds the table inside the php file itself. but I designed a new HTML purchase order and want to have it -> load it as a template.
here is the php code
Code
<?php
if ($msword == "true") {
header("Content-Type: application/vnd.ms-word");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=shipper_$shipment_no.doc");
}
//This code must be at the top of the file to connect to the database server.//
require("../functions/db.php");
$db_name = get_db_name();
$table_name = "ORDITEM";
$hostname = get_db_hostname();
$username = get_db_username();
$sql_password = get_db_password();
$connection = @mysql_connect($hostname, $username, $sql_password) or die("Couldn't Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Could Not Select Database.");
include("./classes/materials_supliers.class.php"); //this will be the class for this table.
include("./classes/materials_po.class.php"); //this will be the class for this table.
include("./classes/materials_po_item.class.php"); //this will be the class for this table.
include("./classes/materials_item.class.php"); //this will be the class for this table.
include "./functions/supliers.functions.php";
include "./functions/materials.functions.php";
require '../classes/config.class.php';
$myLogoName = new config("company_logo_with_address");
// Read phpbb login
if (isset($_COOKIE["USER_NAME"]) && $_COOKIE["USER_NAME"] != "") {
$phpbbuser = $_COOKIE['USER_NAME'];
////echo "$phpbbuser<br>";
} else {
echo "Not logged in!";
exit;
}
//this runs in the db.php file and will conferm that the user is still active and has a good session number.
get_db_CheckLogin($phpbbuser, $_COOKIE['SN']);
include("../functions/user_functions.php");
if (get_permission($phpbbuser, "Materials_PO") == 0) {
//not allowed to do this.
echo "$phpbbuser must be a member of Materials_PO to do this.";
exit;
} else {
//echo "$phpbbuser";
//exit;
}//end check permaission.
///////////////////////////////////////////////////////
if (get_permission($phpbbuser, "Rep") == 1) {
echo "$phpbbuser is a member of SALES_REP. Please see your system admin for help.";
exit;
}
function getHeader() {
global $connection; // = @mysql_connect($hostname, $username, $sql_password) or die("Couldn't Conect.");
global $id;
global $myLogoName;
$myPO = new materials_po($id);
//if ($FOB == "") $FOB = " ";
//make the header table.
$header = "<html>
<head>
<style>
@page { size 8.5in 11in; margin: 2cm }
div.page { page-break-after: always }
</style>
<style>
html body{
margin-left:'-0.3in'
}
</style>
<title>Untitled Document</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<style>
@page { size 8.5in 11in; margin: 2cm }
div.page { page-break-after: always }
</style>
</head>
<body leftmargin='0' style=\"font:12px arial, sans-serif;\">
<table width='700' border='0' cellspacing='0' cellpadding='0'>
<tr height='50'><td align='center'> </td></tr>
</table>";
$mySupplier = new materials_supliers($myPO->suplier_id);
//make the address table.
$header .= "<table width='700' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='350'>
<img src='../images/$myLogoName->config_value'><br>
<table width='100%' border='0'>
<tr>
<td width='373'>To:</td>
</tr>
<tr>
<td><font size='2'>$mySupplier->company</font></td>
</tr>
<tr>
<td><font size='2'>$mySupplier->address</font></td>
</tr>
<tr>
<td height='21'><font size='2'>$mySupplier->city</font>, <font size='2'>$mySupplier->state</font>
<font size='2'>$mySupplier->zip</font></td>
</tr>
<tr>
<td height='21'><font size='2'>
Fax:$mySupplier->fax_number
<br>
Phone:$mySupplier->phone
</font>
</tr>
</table>
</td>
<td width='350'>
<table width='100%' border='1' cellspacing='0' cellpadding='1'>
<tr>
<td colspan='2'><div align='center'><font size='5'><strong>Purchase Order</strong></font></div> </td>
</tr>
<tr>
<td><div align='center'><font size='3'>Number</font></div></td>
<td ><div align='center'><font size='3'>$id</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Date</font></div></td>
<td ><div align='center'><font size='3'>$myPO->date</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Required Date</font></div></td>
<td><div align='center'><font size='3'>$myPO->date_needed</font></div></td>
</tr>
<tr>
<td colspan='2'><div align='center'><font size='3'>$myPO->date_needed_note</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Ship Via</font></div></td>
<td><div align='center'><font size='3'>$myPO->carrier</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Terms</font></div></td>
<td><div align='center'><font size='3'>$mySupplier->freight_terms</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Shipment matches P.O.</font></div></td>
<td><div align='center'><font size='3'> ________/________</font></div></td>
</tr>
<tr>
<td><div align='center'><font size='3'>Truck is free of pests/odors</font></div></td>
<td><div align='center'><font size='3'> ________/________</font></div></td>
</tr>
</table>
<br>
</td>
</tr>
</table>
<p> </p>
";
//////////////end get the shipto address///////////////////////////
//col headers for items.
$header .= "<table width='700' border='1' cellspacing='0' >
<tr bgcolor='#999999'>
<td width='100'><b>Quantity</b></td>
<td width='400'><strong>Description</strong></td>
<td><strong>Date</strong></td>
<td><strong>Max Overrun</strong></td>
<td width='100'><div align='center'><b>Price</td>
<td width='100'><div align='center'><b>Extension<br>
</tr>
";
return $header;
}//end get header
//get the items for this shipper
$sql = "SELECT id FROM materials_po_item
WHERE materials_po_id = $id and deleted = 0";
$c = 0;
$item_row = 0;
$header = getHeader();
echo $header;
$result = @mysql_query($sql, $connection) or die("Could Not Execute. SQL = $sql.");
while ($row = mysql_fetch_array($result)) {
$materials_po_item_id = $row['id'];
$myPOItem = new materials_po_item($materials_po_item_id);
$myItem = new materials_item($myPOItem->materials_item_id);
if ($c > 0) echo "<tr><tr><td colspan='4'> </td></tr>";
$ucost = number_format($myPOItem->estimated_unit_cost, 2, ".", ",");
$grandtotal = $grandtotal + $myPOItem->estimated_total_cost;
$tcost = number_format($myPOItem->estimated_total_cost, 2, ".", ",");
$size = "";
if ($myItem->paperboard == 1) {
if ($myPOItem->size_y > 0) {
$size = $myPOItem->size_y;
}
if ($myPOItem->size_x > 0) {
if ($myPOItem->size_y > 0) $size .= " X ";
$size .= $myPOItem->size_x;
}
if ($myPOItem->size_z > 0) {
if ($myPOItem->size_y > 0) $size .= " X ";
$myPOItem->size_z = number_format($myPOItem->size_z, 3, ".", "");
$size .= $myPOItem->size_z;
}
} else {
if ($myPOItem->size_x > 0) {
$size = $myPOItem->size_x;
}
if ($myPOItem->size_y > 0) {
if ($myPOItem->size_x > 0) $size .= " X ";
$size .= $myPOItem->size_y;
}
if ($myPOItem->size_z > 0) {
if ($myPOItem->size_y > 0) $size .= " X ";
$size .= $myPOItem->size_z;
}
}
if (strlen($myPOItem->note) > 1) {
$note = "<br>" . $myPOItem->note;
} else {
$note = "";
}
echo "<tr>
<td width='100'>$myPOItem->order_quantity<br>$myPOItem->uom</td>
<td width='400'>
$myItem->materials_name<br>
$myItem->supplier_item_number<br>
$size $note<br>
$myItem->po_item_note
</td>
<td><div align='center'>$myPOItem->promised_date</div></td>
<td><div align='center'>$myPOItem->order_overrun_percent_allowed </div></td>
<td width='100' align='right'>$$ucost<br>Per $myPOItem->uom_for_cost</td>
<td width='100' align='right'>$$tcost</td>
</tr>
";
$c++;
}//end while through shippers items.
$grandtotal = number_format($grandtotal, 2, ".", ",");
echo "<tr>
<td width='100'>Total</td>
<td width='400'>
</td>
<td></td>
<td></td>
<td width='100' align='right'> </td>
<td width='100' align='right'>$$grandtotal</td>
</tr>
";
$myPO = new materials_po($id);
echo "</table>
<p>$myPO->delivery_locating</p>
<p >$myPO->note</p>
<p>" . $myPO->getLocationPOtext() . "
</body>
</html>";
//end show the shippers//////////////////////////////////////////////////////////////
exit;
?>
<html>
<head>
<title>Ship/Invoice <? echo "$SHIPMENT_NO"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" style="font:12px arial, sans-serif;">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="532"><p><img src="../images/shipper_logo.jpg"></p>
</td>
<td width="218" align="center" valign="middle">
<div align="center"></div>
<div align="center"></div>
<table width="250" border="1" cellspacing="0" cellpadding="1">
<tr>
<td colspan="2">
<div align="center"><font size="5"><strong>Notice of Shipment</strong></font></div>
</td>
</tr>
<tr>
<td>
<div align="center"><font size="5">Number</font></div>
</td>
<td>
<div align="center"><font size="5">Date</font></div>
</td>
</tr>
<tr>
<td width="50%">
<div align="center"><font size="5">111</font></div>
</td>
<td width="50%">
<div align="center"><font size="5">1/1/08</font></div>
</td>
</tr>
</table>
<div align="center"><img src="../images/50logo150.gif" width="150" height="76"></div>
</td>
</tr>
</table>
<table width="800" border="0">
<tr>
<td width="400">
<table width="100%" border="0">
<tr>
<td width="373"> Bill To;</td>
</tr>
<tr>
<td><font size="2"><? echo "$customer"; ?></font></td>
</tr>
<tr>
<td><font size="2"><? echo "$address"; ?> </font></td>
</tr>
<tr>
<td height="21"><font size="2"><? echo "$address2"; ?></font></td>
</tr>
<tr>
<td height="21"><font size="2"><? echo "$city"; ?></font>, <font
size="2"><? echo "$state"; ?></font>
<font size="2"><? echo "$zip"; ?></font></td>
</tr>
</table>
</td>
<td width="400">
<table width="100%" border="0">
<tr>
<td width="352"><span class="style3">Ship To;</span></td>
</tr>
<tr>
<td><font size="2"><? echo "$STcustomer"; ?></font></td>
</tr>
<tr>
<td><font size="2"><? echo "$STaddress"; ?> </font></td>
</tr>
<tr>
<td height="21"><font size="2"><? echo "$STaddress2"; ?></font></td>
</tr>
<tr>
<td height="21"><font size="2"><? echo "$STcity"; ?></font>, <font
size="2"><? echo "$STstate"; ?></font>
<font size="2"><? echo "$STzip"; ?></font></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<table width="800" border="1" cellspacing="0">
<tr>
<td><font size="2">Our Order No </font></td>
<td><font size="2">Your Order No </font></td>
<td><font size="2">Terms</font></td>
<td><font size="2">FOB</font></td>
<td>Sales Person</td>
<td>Ship Via</td>
<td>PPD.</td>
<td>COL.</td>
</tr>
<tr>
<td width="123"><font size="2">$ORDERNO</font></td>
<td width="125"><font size="2">$PO</font></td>
<td width="184"><font size="2">$TURMS</font></td>
<td width="132"> </td>
<td width="132"> </td>
<td width="132"> </td>
<td width="132"> </td>
<td width="132"> </td>
</tr>
</table>
<table width="800" border="0">
<tr bgcolor="#999999">
<td width="81"><b>Quantity</b></td>
<td width="385"><strong>Description</strong></td>
<td width="84">
<div align="center"><b>No Of<br>
Cases </b></div>
</td>
<td width="51">
<div align="center"><b>Cases<br>
Count</b></div>
</td>
<td width="48">
<div align="center"><b>Weight</b></div>
</td>
<td width="52">
<div align="center"><b>Printing</b></div>
</td>
<td width="69">
<div align="center"><b>Other</b></div>
</td>
</tr>
<? echo "$item_list"; ?>
</table>
<p><font size="2"><? echo "$NOTE"; ?></font></p>
<p> </p>
</body>
</html>
instead of buidling the tables display in the php i want to do something like this
$myHeaderTemplat = new template("","");
$myHeaderTemplate->load("C:\xampp\htdocs\main\materials\templates\purchase_order.header.template.html");
but im not sure on how to make it fit becuase I am a novice to php.