<?php
require_once APPLICATION_PATH . '/modules/alw/views/helpers/Loadjs.php';
use Orchard\Feature\Feature;
use Orchard\FeatureFlags\FeatureService;
use Orchard\FeatureFlags\Context\AccountContext;
use Orchard\Service\SegmentAnalyticsTracking;
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/images/icons/favicon.ico" type="image/x-icon">
    <title></title>
<?php
/*
* These styles will be moved to the controller for the redesign
*/
$sessionData = new Zend_Session_Namespace('Alw');
$alwBannerDisplay = Feature::isEnabled('alw_banner_display', 'enabled');
$oauthConfig = Zend_Registry::get('oauthconfig');
$awsConfigs = yaml_parse_file(APPLICATION_PATH . '/configs/aws.yml');
$logger = Zend_Registry::get('applicationLoggerWS');
$featuresService = new FeatureService($logger);
$userVendorContext = AccountContext::fromLegacy(
    (string)$sessionData->S_VEND_CONTACT_ID,
    'alw',
    $sessionData->S_VENDOR_ID
);
$feaureMergeEnabled = $featuresService->isFeatureVariantActive('feature_merge', 'enabled', $userVendorContext);
$isBrandingEnabled = $featuresService->isFeatureVariantActive('orchard_suite_use_branding', 'enabled', $userVendorContext);
$isColorV2Enabled = $featuresService->isFeatureVariantActive('workstation_solfege_color_scheme_v2', 'enabled', $userVendorContext);

echo $this->headLink();
$loadjs = new Zend_View_Helper_loadjs();
echo $this->headScript()->appendFile($loadjs->getCdnJsPath('jquery-1.8.2.min.js', 'workstation'));
echo $this->headScript()->appendFile('/scripts/dropdown.js');
?>
<link href="https://fonts.googleapis.com/css?family=Rubik:400,500" media="screen" rel="stylesheet" type="text/css">

<?php
echo $this->partial('partials/segment-analytics.phtml', array(
    'configs' => SegmentAnalyticsTracking::getTraitsFromSession($_SESSION, 'workstation')
));
?>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization,geometry&key=<?php echo getenv("GOOGLE_MAPS_KEY"); ?>"></script>
<?php if ($alwBannerDisplay) { ?>
    <script type="text/javascript" src="/scripts/alw/top-banner.js"></script>
<?php } ?>
</head>
<body class="<?php echo ($isBrandingEnabled ? 'branded' : '') .($isColorV2Enabled ? ' SuiteColorSchemeV2' : '') ?>">
<?php
    echo $this->partial('partials/subaccount_impersonation_banner.phtml', ['session', $_SESSION]);
?>
<noscript>Javascript appears to be turned off. In order to use this page, you must have it turned on.</noscript>
<script type="text/json" id="user_data">
    <?php echo json_encode($this->user); ?>
</script>
<?php
if ($feaureMergeEnabled) {
    echo $this->feature($oauthConfig, $awsConfigs, $_SESSION);
} else {
?>
    <script type="text/json" id="features">
        <?php echo json_encode($this->features); ?>
    </script>
<?php
}
?>
<script type="text/json" id="i18n">
    <?php echo json_encode($this->i18n); ?>
</script>
<?php

echo $this->render('_header_redesign.phtml');
echo $this->render('_chaplin_container.phtml');
echo $this->render('_footer_redesign.phtml');

echo $this->bottomScripts();
?>
</body>
</html>
