<?php
/** 
 *
 * @copyright Copyright 2003-2007 Paul Mathot Haarlem, The Netherlands
 * @copyright parts Copyright 2003-2005 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version v1.5.0 (or newer) 
 */
?>
<body id="pricelist">
<!-- bof noPrintPL -->
<div class="noPrintPL">
<!-- Current profile: <?php echo PL_PROFILE_NAME . ' (' . PL_PROFILE . ')'; ?> -->
<?php
if ($messageStack->size('header') > 0) {
  echo $messageStack->output('header');
}
if ($pl_errorMessage != '') echo '<div class="errorMessagePL">' . $pl_errorMessage . ' (' . PL_DEFAULT_PROFILE . ')' . '</div>'; 
?>
<!-- bof screenIntroPL -->
<div id="screenIntroPL">
<?php
// logo (disabled because the logo is printed on every page anyway)
if(TEXT_PL_HEADER_LOGO == 'true'){
  echo '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>';
}
echo '<h3>' . sprintf(TEXT_PL_HEADER_TITLE, '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . TITLE . '</a>') . '</h3>' . "\n";
echo '<p>' . sprintf(TEXT_PL_SCREEN_INTRO, $productCount) . '</p>'; ?>
</div>
<!-- eof screenIntroPL -->
<?php

if (PL_SHOW_PROFILES == 'true') {
  $profiles_list = pl_get_profiles(PL_PROFILE);
  if(!empty($profiles_list)){
  // shows a list contaning links to each enabled profile (if more than one)
    echo '<div id="profilesListPL">' . "\n" . $profiles_list . '</div>' . "\n";
  }
} 
if (PL_SHOW_BOXES == 'true') {
  // hack for "external box usage"
  $column_box_default = 'tpl_box_default.php';
?>
<table id="boxesPL">
  <tr>
    <?php $box_id = 'languagesPL'; ?>
    <td><?php require(DIR_WS_MODULES . 'sideboxes/' . 'languages.php') ?></td>
    <?php $box_id = 'currenciesPL'; ?>
    <td><?php require(DIR_WS_MODULES . 'sideboxes/' . 'currencies.php') ?></td>
    <?php $box_id = 'categoriesPL'; ?>    
    <td><?php
    $content = '';
    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
    $content .= zen_draw_form('categories', zen_href_link(FILENAME_PRICELIST, zen_get_all_get_params()), 'post') . "\n";
    if(PL_CATEGORY_TREE_MAIN_CATS_ONLY == 'true'){
      $content .= zen_draw_pull_down_menu('category', pl_zen_get_category_tree('', '', '', '', '', true), $_SESSION['pl_category'], 'onchange="this.form.submit();"') . "\n";
    }else{
      $content .= zen_draw_pull_down_menu('category', pl_zen_get_category_tree(), $_SESSION['pl_category'], 'onchange="this.form.submit();"') . "\n";      
    }
    $content .= '</form>';
    $content .= '</div>';
    echo $content;
  ?></td>   
  </tr>
</table>
<?php
} 
?>          
</div>
<!-- eof noPrintPL -->

<!-- bof echo Price List -->
<?php


if(pl_group_is_valid(PL_PROFILE)){
  pl_print_the_list ($columnArray);
}else{
  // customer is not allowed to view this list
  echo PL_TEXT_GROUP_NOT_ALLOWED;
  if ($_SESSION['customer_id']){
      echo '<a taget="_blank" href="'. zen_href_link(FILENAME_LOGOFF, '', 'SSL') . '">' . HEADER_TITLE_LOGOFF . '</a>';     
  } else {
    if(STORE_STATUS == '0'){
      echo '&nbsp;(<a target="_blank" href="'. zen_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . HEADER_TITLE_LOGIN . '</a>)';
    }
  }
} 

function pl_print_the_list ($columnArray){ 
  // globals $template added to include logo image
  global $template;
    // print the pricelist
  if (is_array($columnArray)) {
    while (list($pl_page, $colTables) = each($columnArray)) {
      $pageNumber++;
      if ($pageNumber == 1) $pageClassPL = 'pageOnePL'; else $pageClassPL = 'pagePL';
      echo "\n" . '<!-- start page -->' . "\n" . '<div class="' . $pageClassPL . '">' . "\n";

      // bof Price List page headers
      if(PL_SHOW_PRICELIST_PAGE_HEADERS == 'true'){
        echo '<div class="headPL">';
        echo '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>';
        echo '<h4 class="headerTitlePrintPL">' . sprintf(TEXT_PL_HEADER_TITLE_PRINT ,'<a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . TITLE . '</a>') . '</h4>';
        echo '</div><!-- eof headPL -->';
      }
      // eof Price List page headers

      if (PL_MAINCATS_NEW_PAGE == 'true') echo '<h1>' . $colTables['cat'] . '</h1>' . "\n";
      echo '<div class="subhPL"><div class="pageNrPL">' . TEXT_PL_PAGE . $pageNumber . '/' . PL_PAGES . '</div><div class="datePL">' . PL_DATE . '</div></div>' . "\n";
      $colsPL = $colTables['column']; // number of columns for this page   
      // two classes are assigned to the wrapper table "colWrapPL" and "colsPL-n" where n is the number of columns/tables on this page
      echo '<table cellspacing="0" class="colWrapPL' . ' colsPL-' . $colsPL . '"><tr>' . "\n";
      echo $colTables['table'];
      echo '</tr>' . "\n" . '</table>';

      // bof Price List page footers
      if(PL_SHOW_PRICELIST_PAGE_FOOTERS == 'true'){
        echo '<div class="footPL">';
        echo STORE_NAME_ADDRESS_PL . "<br>\n";
        echo '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . TITLE . '</a>' . "\n";
        echo '</div><!-- eof footPL -->';
      }
      // eof Price List page footers
    
      echo "\n" . '</div>' . "\n" . '<!-- end page -->' . "\n" ;
    } // end while 
  } else {
    echo '<h3 id="noMatchPL">' . TEXT_PL_NOTHING_FOUND . '</h3>';
  }
} 
?>
<?php
if(PL_DEBUG == 'true'){
?>
<!-- eof echo Price List  -->
<!-- bof noPrintPL -->
<div class="noPrintPL">
<!--bof- superglobals display -->
<?php
// BEGIN Superglobals
if(SHOW_SUPERGLOBALS == 'true') echo superglobals_echo();
// END Superglobals
?>
<!--eof- superglobals display -->
<p>
<?php
echo 'memory_get_usage:' . memory_get_usage();
if(function_exists(memory_get_peak_usage)){
  echo ',&nbsp;memory_get_peak_usage:' . memory_get_peak_usage();
}
echo ',&nbsp;queries:' . $db->count_queries;
echo ',&nbsp;query time:' . $db->total_query_time;
?>
</p>
</div>
<!-- eof noPrintPL -->
<?php
}
?>
</body>