<?php

// Javascript-function as template only for categorie depending on date-filter (not status-filter)
$onLoadCall = "displayStatusMessage();";
$js_date = "";

// Check output regarding the export category
$displayFilterByCategory = ($f_exp_category == "4" || $f_exp_category == "5" || $f_exp_category == "6" || $f_exp_category == "7" || $f_exp_category == "8" || $f_exp_category == "9" || $f_exp_category == "110" || $f_exp_category == "115" || $f_exp_category == "120" || $f_exp_category == "125");
  
if ($displayFilterByCategory || $specialFunctionsArrayLen > 0) :

   $js_date .= "<script src=\"../include/lib_global.js\" type=\"text/javascript\">\n";
   $js_date .= "</script>\n";
   $js_date .= "\n";
   $js_date .= "<script type=\"text/javascript\">\n";
   $js_date .= "<!--\n";
   $js_date .= "function initForm() {\n";
   /*
   $js_date .= "  fillDateFields(1,0,0,0,10,11,12,-1,-1,-1);\n";
   $js_date .= "  setDateTimeFields(0,0,".$day_from.",".$month_from.",".$year_from.", -1, -1, 10, 11, 12, -1, -1);\n";
   $js_date .= "  fillDateFields(1, 0, 0, 0, 13, 14, 15, -1, -1, -1);\n";
   $js_date .= "  setDateTimeFields(0,0,".$day_to.",".$month_to.",".$year_to.", -1, -1, 13, 14, 15, -1, -1);\n";
   */
   $js_date .= "  fillDateFields(1,\"".$frameName."\",\"export_form\",\"\",\"day_from\",\"month_from\",\"year_from\",\"\",\"\",\"\");\n";
   $js_date .= "  setDateTimeFields(\"".$frameName."\",\"export_form\",".$day_from.",".$month_from.",".$year_from.", \"\", \"\", \"day_from\", \"month_from\", \"year_from\", \"\", \"\", \"\");\n";
   $js_date .= "  fillDateFields(1,\"".$frameName."\",\"export_form\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
   $js_date .= "  setDateTimeFields(\"".$frameName."\",\"export_form\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";   
   $js_date .= "}\n";
   $js_date .= "-->\n";
   $js_date .= "</script>\n";
   
   $onLoadCall .= "initForm();";
endif;

$f_headline_0 = "";
if ($f_headline == "1") : $f_headline_0 = "checked"; endif;
?>


<html>

<head>
<title>EXPORT</title>

<link rel="stylesheet" type="text/css" href="../css/phoenix.css"> 
<style type="text/css">
  <?php include_once ("../css/navigation.css.php"); ?>
</style>

<?php include_once ("../include/js_framework.inc.php"); ?>

<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>

function finishPage(f_act_value) {  
  document.forms[0].f_act.value=f_act_value;
  document.forms[0].submit();
};

function removeExportfile(f_exportFileToDeleteValue) {
  if (confirm('Exportdatei ' + f_exportFileToDeleteValue + ' entfernen?')) {
     document.forms[0].f_exportFileToDelete.value=f_exportFileToDeleteValue;
     finishPage('removeExportfile');
  };
};
-->
</script>

<?php echo $js_date ?>


</head>

<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?><?php echo $onLoadCall ?>">

<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>

<div class="maincontent" name="maincontent" id="maincontent">

<form name="export_form" action="../export/export.php" method="post">
  <input type="hidden" name="adminInterfacePassword" value="<?php echo ec($adminInterfacePassword); ?>">
  <input type="hidden" name="f_act" value="">
  <input type="hidden" name="f_expp_id" value="<?php echo ec($f_expp_id); ?>">
  <input type="hidden" name="customerId" value="<?php echo ec($customerId) ?>">
  <input type="hidden" name="cscIdRoot" value="<?php echo ec($cscIdRoot) ?>">
  <input type="hidden" name="cscIdActual" value="<?php echo ec($cscIdActual) ?>">  
  <input type="hidden" name="f_exportFileToDelete" value="">
  <?php echo $phpCurrentNavigationInputHidden ?>
  
  <?php echo htmlDivLineSpacer("20px"); ?>
  
  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Kategorie:") ?></div>
    <div>
      <select name="f_exp_category" onChange="submit();">
      <option value="0" <?php if ($f_exp_category == "0") : echo "selected"; endif; ?>>---</option>
      <?php // echo addOptionsFromTable("exportcategory","expc_id","expc_name","expc_id","expc_usrtype = '".$userType."'",$f_exp_category); ?>
      <?php echo addOptionsFromTable("exportcategory","expc_id","expc_name","expc_id","expc_usrtype = '".$userType."' AND expc_type = '0'",$f_exp_category); ?>
      </select>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Export-Format:") ?></div>
    <div>
      <select name="f_parname_export">
         <?php echo $parameterNamesOptions ?>
      </select>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Dateiname:") ?></div>
    <div>
      <input type="text" name="f_fileName" value="<?php echo $f_fileName; ?>" size="30">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Kopfzeile:") ?></div>
    <div>
      <input type="checkbox" name="f_headline[]" value="1" <?php echo $f_headline_0 ?>>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Delimiter:") ?></div>
    <div>
      <input type="text" name="f_delimiter" value="<?php echo $f_delimiter; ?>" size="5">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <?php
  $statusFilterText_01 = "Alle (kein Log)";
  $statusFilterText_02 = "Nur neue";
  $statusFilterText_03 = "Nur geänderte";
  $statusFilterText_04 = "Nur neue und geänderte";

  mcIsSet($categoryFilter);
  if ($displayFilterByCategory || $specialFunctionsArrayLen > 0) :
     // Date-ranges
     $categoryFilter = "<div>\n";
     $categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Datums-Filter:</div>\n";
     $categoryFilter .= "  <div>\n";
     $categoryFilter .= "von:&nbsp;\n";
     $categoryFilter .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'day_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
     $categoryFilter .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'month_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
     $categoryFilter .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'year_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
     $categoryFilter .= "&nbsp;&nbsp;bis:&nbsp;\n";
     $categoryFilter .= "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'day_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
     $categoryFilter .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'month_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
     $categoryFilter .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'year_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
     $categoryFilter .= "  <div>\n";
     $categoryFilter .= "<div>\n";
     $categoryFilter .= htmlDivLineSpacer("10px");
   endif;

   if ($displayFilterByCategory && $userTypeName == "hq") :
     // Special customer         
     $categoryFilter .= "<div>\n";
     $categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Spezieller Kunde (EID):</div>\n";
     $categoryFilter .= "  <div>\n";
     $categoryFilter .= "   <input type=\"text\" name=\"f_cs_eid_filter\" value=\"".$f_cs_eid_filter."\" size=\"15\">\n";
     $categoryFilter .= "  <div>\n";
     $categoryFilter .= "<div>\n";
     $categoryFilter .= htmlDivLineSpacer("10px");

     $statusFilterText_01 = "Alle";
     $statusFilterText_02 = "Nur Barzahlung";
     $statusFilterText_03 = "Nur Rechnung";
     $statusFilterText_04 = "";
  endif; 

  mcIsSet($filterSelected_0); mcIsSet($filterSelected_1); mcIsSet($filterSelected_2); mcIsSet($filterSelected_3);
  if ($f_status_filter == "0") : $filterSelected_0 = "selected"; endif;
  if ($f_status_filter == "1") : $filterSelected_1 = "selected"; endif;
  if ($f_status_filter == "2") : $filterSelected_2 = "selected"; endif;
  if ($f_status_filter == "3") : $filterSelected_3 = "selected"; endif;

  $categoryFilter .= "<div>\n";
  $categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Status-Filter:</div>\n";
  $categoryFilter .= "  <div>\n";
  $categoryFilter .= "  <select name=\"f_status_filter\">\n";
  $categoryFilter .= "    <option value=\"0\" $filterSelected_0 >$statusFilterText_01</option>\n";
  $categoryFilter .= "    <option value=\"1\" $filterSelected_1 >$statusFilterText_02</option>\n";
  $categoryFilter .= "    <option value=\"2\" $filterSelected_2 >$statusFilterText_03</option>\n";
  if ($statusFilterText_04 != "") :
     $categoryFilter .= "    <option value=\"3\" $filterSelected_3 >$statusFilterText_04</option>\n";
  endif;
  $categoryFilter .= "  </select>\n";
  $categoryFilter .= "  <div>\n";
  $categoryFilter .= "<div>\n";
  $categoryFilter .= htmlDivLineSpacer("10px");

  echo $categoryFilter;
  ?>

<!--
  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Status-Filter:</div>
    <div>
      <select name="f_status_filter">
         <option value="0" <?php if ($f_status_filter == "0") : echo "selected"; endif; ?>>Alle</option>
         <option value="1" <?php if ($f_status_filter == "1") : echo "selected"; endif; ?>>Nur geänderte</option>
         <option value="2" <?php if ($f_status_filter == "2") : echo "selected"; endif; ?>>Nur Neue</option>
      </select>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>
-->

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Fahrzeug-Filter:</div>
    <div>
      <?php echo addCheckboxesFromTable("f_vht_filter","metatype","mt_sort","mt_value","mt_sort","mt_type = 'vehicletype' AND mt_sort > '0' AND mt_sort < '8'","", "&nbsp;&nbsp;&nbsp;&nbsp;"); ?>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Daten exportieren:</div>
    <div>
      <?php echo defineButtonType10("Export", "action_export", "finishPage('export');", "100", "left"); ?>
    </div>
  </div>

  <!-- Special export functions -->
  <?php if ($specialFunctionsArrayLen > 0) : ?>
    <?php echo htmlDivLineSpacer("10px", "", "left"); ?>
    <div>
      <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Individueller Export:</div>
      <div>
        <?php 
          for ($se = 0; $se < $specialFunctionsArrayLen; $se++) :
              echo defineButtonType10("Funktion " . $specialFunctionsArray[$se], "action_export", "finishPage('special_export_" . pad($specialFunctionsArray[$se],2) . "');", "120", "left", "3");
          endfor; 
        ?>
      </div>
    </div>
  <?php endif; ?>
  <?php echo htmlDivLineSpacer("30px", "", "left"); ?>


  <!-- Configuration -->
  
  <div>
    <div class="f12bp1_blue">Konfiguration</div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Laden der Einstellungen:</div>
    <div>
      <select name="f_parname" onChange="submit();">
         <?php echo $parameterNamesOptions ?>
      </select>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("200px","left"); ?>>Neuer Speichername:</div>
    <div>
      <input type="text" name="f_parname_new" value="" size="30">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("20px"); ?>


  <!-- Configuration table data -->
  
  <div>
    <table border="0">            
      <?php echo $customConfigOutput ?>
    </table>
  </div>
  <?php echo htmlDivLineSpacer("20px"); ?>
      
  <div>
    <div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Zeilenanfang:</div>
    <div>
      <input type="text" name="f_bolchars" value="<?php echo $f_bolchars; ?>" size="122">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>
  
  <div>
    <div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Zeilenende:</div>
    <div>
      <input type="text" name="f_eolchars" value="<?php echo $f_eolchars; ?>" size="122">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>

  <div>
    <div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Dateianfang:</div>
    <div>
      <input type="text" name="f_bofchars" value="<?php echo $f_bofchars; ?>" size="122">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("10px"); ?>
  
  <div>
    <div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Dateiende:</div>
    <div>
      <input type="text" name="f_eofchars" value="<?php echo $f_eofchars; ?>" size="122">
    </div>
  </div>
  <?php echo htmlDivLineSpacer("20px"); ?>


  <div>
    <div <?php echo setStyleHtmlDiv("250px","left"); ?>>Konfiguration speichern:</div>
    <div>
      <?php echo defineButtonType10("Speichern", "action_save", "finishPage('save');", "100", "left"); ?>
    </div>
  </div>
  <?php echo htmlDivLineSpacer("40px", "", "left"); ?>


  <!-- Exportfiles (all categories) -->
  
  <div>
    <div class="f12bp1_blue">Lokale Exportdateien (alle Kategorien)</div>
  </div>
  <?php echo htmlDivLineSpacer("15px"); ?>

  <div>
    <table>            
        <tr>
          <td>           
             <?php echo $storedExportFiles ?>
          </td>
        </tr>
    </table>
  </div>
  <?php echo htmlDivLineSpacer("40px"); ?>

  <div>
    <div class="f12bp1_blue"><?php if ($userTypeName == "hq") : echo "Exportdateien auf dem FTP-Server"; else : echo ""; endif; ?></div>
  </div>
  <?php echo htmlDivLineSpacer("15px"); ?>

  <div>
    <table>            
        <tr>
          <td>           
             <?php echo $storedRemoteExportFiles ?>
          </td>
        </tr>
    </table>
  </div>
  <?php echo htmlDivLineSpacer("30px"); ?>

</form>
</div>
</body>
</html>     

