}
	  require_once(DIR_WS_CLASSES . 'phreebooks.php');
	  $dnXML = new phreebooks();
	  if (sizeof($pb_orders) > 0) $dnXML->submitXML('download', $pb_orders);
	  $_GET['action'] = '';
	  $action         = '';
	  $oID            = '';
	  break;
  }
*/
if (zen_not_null($action) && $order_exists == true) {
    switch ($action) {
        case 'download':
            require_once DIR_WS_CLASSES . 'phreebooks.php';
            // open the phreebooks class
            $dnXML = new phreebooks();
            $dnXML->submitXML('download', array($oID));
            $_GET['action'] = '';
            $action = '';
            $oID = '';
            break;
            // EOF - Download operation added by PhreeSoft
        // EOF - Download operation added by PhreeSoft
        case 'edit':
            // reset single download to on
            if ($_GET['download_reset_on'] > 0) {
                // adjust download_maxdays based on current date
                $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,\n                                      date_purchased from " . TABLE_ORDERS . "\n                                      where orders_id = '" . $_GET['oID'] . "'");
                // check for existing product attribute download days and max
                $chk_products_download_query = "SELECT orders_products_id, orders_products_filename, products_prid from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_products_download_id='" . $_GET['download_reset_on'] . "'";
                $chk_products_download = $db->Execute($chk_products_download_query);
            $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
        }
    }
}
if (zen_not_null($action) && $order_exists == true) {
    switch ($action) {
        // Begin - Download operation added by PhreeSoft to download order to PhreeBooks
        case 'download':
            $oID = zen_db_prepare_input($_GET['oID']);
            $order = new order($oID);
            // open the order and read all information
            $order->id = $oID;
            //echo 'order # ' . $oID . ' = '; print_r($order); echo'<br>';
            require DIR_WS_CLASSES . 'phreebooks.php';
            // open the phreebooks class
            $dnXML = new phreebooks();
            if ($dnXML->submitXML('download', $order)) {
                // set the download successful flag
                $db->Execute("update " . TABLE_ORDERS . " set phreebooks = 1, last_modified = now() where orders_id = " . (int) $oID);
            }
            $_GET['action'] = '';
            $action = '';
            $oID = '';
            break;
            // End - Download operation added by PhreeSoft
        // End - Download operation added by PhreeSoft
        case 'edit':
            // reset single download to on
            if ($_GET['download_reset_on'] > 0) {
                // adjust download_maxdays based on current date
                $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,\r\n                                      date_purchased from " . TABLE_ORDERS . "\r\n                                      where orders_id = '" . $_GET['oID'] . "'");