if (is_a($objDobaProducts, 'DobaProducts') && DobaInteraction::loadDobaProductsIntoDB($objDobaProducts)) {
        DobaLog::logProductUpload($objDobaProducts, $filename);
        $msg = $filename . UPLOAD_SUCCESS_MSG;
    } else {
        $MSG = UPLOAD_FAILURE_MSG;
    }
} else {
    if (isset($_GET['api'])) {
        if ($_GET['api'] == 'success') {
            $msg = 'Your products were successfully loaded from Doba';
        } else {
            $msg = 'There were problems loading your products from Doba.  Please try again later.';
        }
    }
}
$upload_history = DobaLog::getLogHistorySummary('product');
?>
<!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>
					- the product does not have enough stock to complete the order<br>
					Please log into Doba to verify.';
            }
        } else {
            // this was an unrecognized action
        }
    }
}
if (!$downloaded) {
    $msg = FILE_DOWNLOAD_ERROR;
}
$order_cnt_new = DobaInteraction::getOrderCount('new');
$order_cnt_all = DobaInteraction::getOrderCount('all');
$order_cnt_submitted = DobaInteraction::getOrderCount('submitted');
$order_cnt_unsubmitted = DobaInteraction::getOrderCount('unsubmitted');
$download_history = DobaLog::getLogHistorySummary('order');
?>
<!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>
require_once 'doba/DobaProducts.php';
include_once 'doba/DobaApi.php';
include_once 'doba/DobaProductAPI.php';
$msg = '';
$api = new DobaApi();
if (isset($_POST['submit'])) {
    require_once 'doba/DobaInteraction.php';
    $watchlist_id = isset($_POST['watchlist_id']) ? intval($_POST['watchlist_id']) : 0;
    if ($watchlist_id > 0) {
        $action = DOBA_API_ACTION_GETPRODUCTDETAIL;
        $data = array('watchlist_id' => $watchlist_id);
        if ($api->compileRequestXml($action, $data) && $api->sendRequest()) {
            $objDobaProducts = DobaProductAPI::parseProductDetails($api->getResponseXml());
            if (is_a($objDobaProducts, 'DobaProducts') && DobaInteraction::loadDobaProductsIntoDB($objDobaProducts)) {
                require_once 'doba/DobaLog.php';
                DobaLog::logProductApiLoad($objDobaProducts, 'success');
                header('Location: ' . FILENAME_DOBA_PRODUCTS . '?api=success');
                exit;
            } else {
                $msg = 'Your request could not be completed at this time.  Please try again later.';
            }
        } else {
            if ($api->hasErrors()) {
                $msg = 'Your request could not be completed due to the following errors:<br>- ' . implode('<br>- ', $api->getErrors());
            } else {
                $msg = 'Your request could not be completed at this time.  Please try again later.';
            }
        }
    } else {
        $msg = 'Please select a watchlist to use.';
    }
 function logProductApiLoad($objDobaProducts, $response, $time = null)
 {
     if (is_null($time)) {
         $time = time();
     }
     foreach ($objDobaProducts->products as $p) {
         $dl = new DobaLog();
         $dl->datatype('product');
         $dl->local_id($p->item_id());
         $dl->xfer_method('api');
         $dl->ymdt($time, true);
         $dl->api_response($response);
         $dl->store();
     }
     return;
 }