Header Panel (inc/panels/header.php)
This panel renders the site’s top header, combining user controls, branding, navigation, and a banner. It adapts its content based on the current session state, offering customer/location switching for logged-in users and a static menu for guests.
Initialization & Variables
The script begins by defining key variables that drive the dynamic dropdown and form behavior:
- $topHeaderComboBox: Holds the HTML for the company/location selector.
- $formAction: Target script for the selector form (
customer_select.php). - $actionField: Name of the hidden input to indicate action (
customer_idorlocation_id).
These variables default to empty strings and are populated based on session checks .
🔄 Session-driven Customer/Location Switcher
The header supports two modes for logged-in users:
- Admin impersonation: If
$_SESSION['ADMIN_ID_FRONT']is set alongsideCustomer_ID, it builds a company selector. - Standard user: If only
Customer_IDis set, it builds a location selector. - It uses helper functions:
getCompaniesTreeCombo()for company hierarchies.GenerateCustomersTreeDDL()for location trees.
// Determine selector mode
if (isset($_SESSION['ADMIN_ID_FRONT']) && $_SESSION['Customer_ID']) {
$formAction = "customer_select.php";
$actionField = "customer_id";
$topHeaderComboBox = getCompaniesTreeCombo(
'customer_id',
$_SESSION['Customer_ID'],
'class="top-bar-select-menu"'
);
}
else if (isset($_SESSION['Customer_ID']) && !isset($_SESSION['ADMIN_ID_FRONT'])) {
$formAction = "customer_select.php";
$actionField = "location_id";
// Build WHERE clause based on Master_Customer or Customer_Type...
$topHeaderComboBox = GenerateCustomersTreeDDL(
'location_id',
$ComboWhere,
$_SESSION['Customer_ID'],
'',
'class="top-bar-select-menu"'
);
}
*Excerpt from header.php *
User Info & Logout Section
When a customer is logged in, the header shows their email, a Log Out link, and the switcher form:
<?php if (!empty($_SESSION['Customer_ID'])) { ?>
<div id="logout_div">
<p>
<?= $_SESSION['Customer_email'] ?>
|
<a href="logout.php">Log Out</a>
</p>
<form
method="post"
name="top_header_companies_frm"
id="top_header_companies_frm"
action="<?= $formAction ?>"
>
<input
type="hidden"
name="action"
value="<?= $actionField ?>"
/>
<input
type="image"
style="cursor:pointer; vertical-align:bottom;"
src="images/go.gif"
name="submit"
/>
<?= $topHeaderComboBox ?>
</form>
</div>
<?php } ?>
Branding & Contact Block
Central branding includes the site title linking to the home path and a postal address:
<h1><a href="<?=SITE_PATH?>">Logistics</a></h1>
<address>
<img src="images/tel_icon.gif" alt="" />
800-641-5300<br />
300 Elm Street Unit 1<br />
Milford, NH 03055
</address>
🔗 Main Navigation Menu
The menu adapts for logged-in versus guest users:
| Link Text | URL | Active Condition |
|---|---|---|
| Home | <?=SITE_PATH?> |
When $currnt_file_name is index.php, welcome.php, or empty. |
| Quote & Ship | start_quote.php or JS popup |
For Canadian users opens a modal; else links directly. |
| My Shipments | my_shipments.php |
$currnt_file_name == 'my_shipments.php'. |
| My Account | my_account.php |
$currnt_file_name == 'my_account.php'. |
| Address Book | address_book.php |
Includes address_add.php variant. |
| Product Catalog | product_catalog.php |
Includes add_product.php variant. |
| Static Pages | From $staticPagesArray |
Iterates over included static pages for guests. |
| Freight Tools | external link to TechTools | Shows a hint on hover. |
| Contact Us | contact_us.php |
$currnt_file_name == 'contact_us.php'. |
<div id="top_nav">
<ul>
<li>
<a href="<?=SITE_PATH?>" class="<?= $homeClass ?>">Home</a>
</li>
<!-- Logged-in links / guest static pages -->
</ul>
</div>
💬 Quote Banner
A stylized quote encourages users to engage with the service:
<div id="quote">
<p>
<span class="ldquo">“</span>
Let our team of professionals do the work…
<img src="images/rdquo.gif" alt="" />
</p>
</div>
🖼️ Flash Banner Embed
The header embeds a Flash banner with cross-browser object tags and fallback content:
<div id="flash_div">
<object
id="FlashID"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width="458"
height="171"
>
<param name="movie" value="images/banner.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<!-- Fallback for non-IE browsers -->
<!--[if !IE]>-->
<object
type="application/x-shockwave-flash"
data="images/banner.swf"
width="458"
height="171"
>
<div>
<h4>Content on this page requires a newer version of Flash Player.</h4>
<p>
<a href="https://www.adobe.com/go/getflashplayer">
<img
src="https://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Flash Player"
/>
</a>
</p>
</div>
</object>
<!--<![endif]-->
</object>
</div>
Integration
The header panel is included in the main site template, ensuring consistent layout across pages:
<?php include_once("inc/panels/header.php"); ?>
*Excerpt from site_template_lastok-17-04-2014.php *