Location: PHPKode > projects > WebArchive > phparchive.0.1.82.beta/printpreview.php
<?php
/**
 * @version $Id: printpreview.php,v 1.4 2004/01/18 20:01:50 freedev Exp $
 * @author Vincenzo D'Amore <hide@address.com>
 * @package wa_base
*/

/**
 *
 */

require_once("./wacommon.inc.php");
require_once("./includes/databases.inc.php");
require_once("./includes/contents.inc.php");
require_once("./includes/modifyform.inc.php");
require_once("./includes/searchform.inc.php");
require_once("./includes/waform.inc.php");
require_once("./includes/wafields.inc.php");

CheckSession();

function LocalHTMLHeader($sTitle, $sRedirect = "", $iSec = "0")
{
	$sStyleName = "print.css";

	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
	echo '<html><head><title>'.$sTitle.'</title>';
	if (!empty($sRedirect))
		echo "<META HTTP-EQUIV='Refresh' CONTENT='".$iSec.";URL=".$sRedirect."'>";
    echo '<link rel="shortcut icon" href="images/wa_ico.png">';
    echo '<link rel="stylesheet" title="Standard" href="styles/'.$sStyleName.'" type="text/css">';

	echo '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">';
	echo '<META http-equiv="Default-Style" content="Standard">';
	echo '</head>';
}

LocalHTMLHeader("Print Preview", "");

?>
<body class="BodyStandard">
<!--- Main Table Start -->
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
	<td></td>
  </tr>
  <tr>
	<td>
		<!--- Content Table Start -->
		<?php
		$form = new WAForm();
		if ( $form->InitByUID($_GET['FormUID']) )
		{
			$aFields = &$form->GetFields();
			$field = new WAField();
			$field->AttachForm( $form->m_Form );
			echo "<div class='Title'>".htmlentities($form->GetDescription(), ENT_QUOTES)."</div>";
			echo "<table>";
			foreach ($aFields as $aField)
			{
//				if ($_SESSION["giAdmin"])
				if ($aField["WAIdType"] != WA_KEYNUM)
				{
					$field->Attach( $aField );
					echo "<tr><td class='Label'><b>";
					echo htmlentities($field->GetDescription(), ENT_QUOTES);
					echo "</b></td><td>";
	//				echo htmlentities($field->GetValue(), ENT_QUOTES);
					echo htmlentities($field->GetTag(), ENT_QUOTES);
					echo "</td></tr>";
				}
			}
			echo "</table>";
			echo "<blockquote>";
			$aTablesRel = $form->GetTablesRel();
			reset($aTablesRel);
			foreach ($aTablesRel as $TableRel)
			{
				if ($TableRel["WAIdRelType"] == WA_REL_MULTI)
				{
					echo "<div class='Subtitle'>";
					echo htmlentities(stripcslashes($TableRel["WADescr"]), ENT_QUOTES)."<br>";
					echo "</div>";
					$formChild = new WAForm();
					if ($formChild->InitByUID($TableRel["WAUIDChild"]) )
					{
						$aFieldsChild = $formChild->GetFields();
//						$aFieldsChild[$TableRel["WAFieldChild"]]["WATag"] = $aFields[$TableRel["WAField"]]["WATag"];

						$fieldChild = new WAField();
						$fieldChild->AttachForm( $formChild->m_Form );
						$sSql = "";
						$sMessage = "";
//						echo $aFields[$TableRel["WAFieldChild"]]["WAIdType"];
						if ( $aFieldsChild[$TableRel["WAFieldChild"]]["WAIdType"] != WA_LIST)
							$sSql = "SELECT * FROM " . $formChild->m_Form["WATableName"] . " WHERE " . $TableRel["WAFieldChild"] . " = " . $aFields[$TableRel["WAField"]]["WATag"] ;
						else
						{
							$sSql = "SELECT * FROM " . $formChild->m_Form["WATableName"].", ". $aFieldsChild[$TableRel["WAFieldChild"]]["WAField"];
							$sSql .= " WHERE " . $aFieldsChild[$TableRel["WAFieldChild"]]["WAField"].".".$TableRel["WAField"] . " = " . $aFields[$TableRel["WAField"]]["WATag"];
							$sSql .= " AND " . $aFieldsChild[$TableRel["WAFieldChild"]]["WAField"].".".$formChild->m_Form["WATableKeyField"] . " = " . $formChild->m_Form["WATableName"].".".$formChild->m_Form["WATableKeyField"];
						}
//						if (CreateSearchSql($formChild->m_Form, "", "", $sSql, $sMessage))
						{
							$recValues = new WARecordset();
							$recValues->SetConnection($formChild->m_Form);
							$recValues->WAOpenRecordset($sSql);
							if ($recValues->WAFetchRow())
							{
								echo "<table><tr>";
								foreach ($aFieldsChild as $aField)
								{
									if (($aField["WAIdType"] != WA_KEYNUM) &&
										($aField["WAField"] != $TableRel["WAFieldChild"]) )
									{
										$fieldChild->Attach( $aField );
										echo "<td class='Label'><b>";
										echo htmlentities($fieldChild->GetDescription(), ENT_QUOTES);
										echo "</b></td>";
									}
								}
								do
								{
									echo "</tr><tr>";
									Recordset2Fields($aFieldsChild, $recValues, $formChild->m_Form);
				//				echo "<pre>"; print_r($Fields["DataCreazione"]["WATag"]); echo "</pre>";
									foreach ($aFieldsChild as $aField)
									{
										if (($aField["WAIdType"] != WA_KEYNUM) &&
											($aField["WAField"] != $TableRel["WAFieldChild"]) )
										{
											$fieldChild->Attach( $aField );
											echo "<td>";
									//		if ($aField["WAIdType"] != WA_LIST)
											echo htmlentities($fieldChild->GetValue(), ENT_QUOTES);
											echo "</td>";
										}
									}
								}
								while ($recValues->WAFetchRow());
								echo "</tr></table>";
							}
							$recValues->WACloseRecordset();
						}
					}
				}
			}
			echo "</blockquote>";
		}
		?>
		<!--- Content Table End -->
	</td>
  </tr>
  <tr>
	<td>
    </td>
  </tr>
</table>
<!--- Main Table End -->
</body>
</html>
Return current item: WebArchive