error_reporting(E_ALL);
//load paAPI
require_once '/var/www/html/magento/paGateway/reportAPI/invoiceReport.php';
//load Mage
require_once "/var/www/html/magento/app/Mage.php";
Mage::app();
$config_info = parse_ini_file('/var/www/html/magento/paGateway/paGateway.ini', true);
$uid = $config_info['login']['uid'];
$pass = $config_info['login']['pass'];
$nw = new invoiceReport();
$nw->setUser($uid, $pass);
$nw->setAction('getInvoiceInRange');
//only supported function
$nw->setStartDate('20120501');
//start date
$nw->setEndDate('20120502');
//end date
$obj = $nw->sendRequest();
// print_r($nw->sendRequest()); //send request and get response in json format
$response = json_decode($obj, true);
// var_dump($response);
echo "<html><head></head><body style='font-family: Arial, sans-serif; font-size: 12px;'>";
echo "<table cellpadding=5 cellspacing=0 border=1>";
echo "<tr style='font-weight:bold; background-color:1D4E51; color:#f1f1f1;'>";
echo "<td>xqty</td>";
echo "<td>xprice</td>";
echo "<td>xmpline</td>";
echo "<td>xline</td>";
echo "<td>xbran</td>";
echo "<td>xfreight</td>";
echo "<td>xcore</td>";
error_reporting(E_ALL);
//load paAPI
require_once '/var/www/html/magento/paGateway/reportAPI/invoiceReport.php';
//load Mage
require_once "/var/www/html/magento/app/Mage.php";
Mage::app();
$config_info = parse_ini_file('/var/www/html/magento/paGateway/paGateway.ini', true);
$uid = $config_info['login']['uid'];
$pass = $config_info['login']['pass'];
$nw = new invoiceReport();
$nw->setUser($uid, $pass);
$nw->setAction('getInvoiceInRange');
//only supported function
$nw->setStartDate('20120101');
//start date
$nw->setEndDate('20120515');
//end date
$obj = $nw->sendRequest();
// print_r($nw->sendRequest()); //send request and get response in json format
$response = json_decode($obj, true);
// var_dump($response);
echo "<html><head></head><body style='font-family: Arial, sans-serif; font-size: 12px;'>";
echo "<table cellpadding=5 cellspacing=0 border=1>";
echo "<tr style='font-weight:bold; background-color:1D4E51; color:#f1f1f1;'>";
echo "<td>xqty</td>";
echo "<td>xprice</td>";
echo "<td>xmpline</td>";
echo "<td>xline</td>";
echo "<td>xbran</td>";
echo "<td>xfreight</td>";
echo "<td>xcore</td>";
//load Mage
require_once "/var/www/html/magento/app/Mage.php";
Mage::app();
$config_info = parse_ini_file('/var/www/html/magento/paGateway/paGateway.ini', true);
$uid = $config_info['login']['uid'];
$pass = $config_info['login']['pass'];
$today = date("Ymd");
$yesterday = date("Y-m-d", strtotime("yesterday"));
$nw = new invoiceReport();
$nw->setUser($uid, $pass);
$nw->setAction('getInvoiceInRange');
//only supported function
// $nw->setStartDate('20111101');//start date
$nw->setStartDate($yesterday);
//start date
$nw->setEndDate($yesterday);
//end date
echo "sending request \r\n";
$obj = $nw->sendRequest();
// print_r($nw->sendRequest()); //send request and get response in json format
$response = json_decode($obj, true);
// var_dump($response);
echo "yo, request received \r\n";
if ($response) {
    $i = 0;
    $responseDetail = $response['responseDetail'];
    //var_dump($responseDetail);
    foreach ($responseDetail as $item) {
        $norm_partnumber = preg_replace("/[^\\p{L}\\p{N}]/u", '', $responseDetail[$i]['xsku']);
        //set up an insert statement
        $xqty = $responseDetail[$i]['xqty'];