Hello,

I am using Zen-Cart 1.37. I installed the Canadapost Destop EST Export module which should export a cvs file with the customer addresses of a selected range of orders.

However when I click on the "Generate" button nothing happens.

The main code file is pasted here, maybe somebody can give me a clue of what's missing from here. I should be pointed to save the file - but none of that happens:

Code:
<?php
// GPL license - see license.txt

  require('includes/application_top.php');

  // csv settings
  define("CSV_SEPARATOR", ",");
  define("CSV_NEWLINE", "\r\n");

// not submitted, so show form to submit
if (!$submitted || $submitted != 1)
{
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
  <!--
  function init()
  {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
      var kill = document.getElementById('hoverJS');
      kill.disabled = true;
    }
  }
  // -->
</script>
</head>
<body onload="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
<td>
  <div class="pageHeading"><?php echo HEADING_TITLE; ?></div>

  <form method="GET" action="<?php echo $PHP_SELF; ?>">
  <table border="0" cellpadding="3">
  <tr>
    <td><?php echo TEXT_START_ORDER_NUM; ?></td>
    <td><input name="start" size="5" value="<?php echo $start; ?>">
  </tr>
  <tr>
    <td><?php echo TEXT_END_ORDER_NUM; ?></td>
    <td><input name="end" size="5" value="<?php echo $end; ?>">
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="<?php echo BUTTON_GENERATE; ?>"></td>
  </tr>
  </table>
  <input type="hidden" name="submitted" value="1">
  </form>

</td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php
}
// submitted so generate csv
else
{
  generatecsv($start, $end);
}

// generates csv file from $start order to $end order, inclusive
function generatecsv($start, $end)
{
  global $db;

  $sql =  "SELECT * ";
  $sql .= "FROM " . TABLE_ORDERS . " ";
  $sql .= "WHERE orders_id >= $start
           AND   orders_id <= $end";

  $orders = $db->Execute($sql);

  header("Pragma: cache");
  header("Content-Type: text/comma-separated-values");
  header("Content-Disposition: attachment; filename=" . FILENAME_CANADA_POST_DESKTOP_EST_EXPORT_DATA);
  

  while (!$orders->EOF)
  {
    echo quote(2).CSV_SEPARATOR;
    echo quote($orders->fields['orders_id']).CSV_SEPARATOR;
    echo quote($orders->fields['customers_id']).CSV_SEPARATOR;
    echo quote(NULL).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_name']).CSV_SEPARATOR;
    echo quote(NULL).CSV_SEPARATOR;
    echo quote(NULL).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_company']).CSV_SEPARATOR;
    echo quote(NULL).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_street_address']).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_suburb']).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_city']).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_state']).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_postcode']).CSV_SEPARATOR;
    echo quote($orders->fields['delivery_country']).CSV_SEPARATOR;
    echo quote($orders->fields['customers_telephone']).CSV_SEPARATOR;
    echo quote(NULL).CSV_SEPARATOR;
    echo quote($orders->fields['customers_email_address']).CSV_SEPARATOR;
    echo quote(0).CSV_NEWLINE;

    $orders->MoveNext();
  }
}

// returns the name for a shipping status
function getorderstatus($statusid)
{
  global $db;

  $query = "select * from " . TABLE_ORDERS_STATUS . " where orders_status_id = $statusid";

  $statii = $db->Execute($query);

  while (!$statii->EOF)
  {
    return $statii->fields['orders_status_name'];
  }

  return $statusid;
}

// formats a value suitable for including in a csv file
function quote($value)
{
  // if quote mark in string then escape with another quote mark
  // then put in quote marks and return
  if (strstr($value, "\"") !== FALSE)
  {
    $value = ereg_replace("\"", "\"\"", $value);
    return "\"$value\"";
  }

  // if seperator in string then put in quote marks
  if (strstr($value, CSV_SEPARATOR) !== FALSE)
  {
    return "\"$value\"";
  }

  return $value;
}

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>