<?php

ini_set('include_path', ini_get('include_path') . ':' . $_SERVER['DOCUMENT_ROOT'] . '/admin/includes/');
include_once 'doba/DobaOrderInfo.php';
include_once 'doba/DobaOrders.php';
$tempData = array('orders_id' => 12345, 'first_name' => 'Candice', 'last_name' => 'Johnson', 'address' => '4958 W 495 S', 'city' => 'Orem', 'state' => 'UT', 'postal' => '84097', 'country' => 'USA', 'items' => array());
$dpo = new DobaOrderInfo();
echo "<ul>";
echo "<li>\"" . $dpo->orders_id($tempData['orders_id']) . "\" should be \"" . $tempData['orders_id'] . "\"</li>";
echo "<li>\"" . $dpo->first_name($tempData['first_name']) . "\" should be \"" . $tempData['first_name'] . "\"</li>";
echo "<li>\"" . $dpo->last_name($tempData['last_name']) . "\" should be \"" . $tempData['last_name'] . "\"</li>";
echo "<li>\"" . $dpo->address($tempData['address']) . "\" should be \"" . $tempData['address'] . "\"</li>";
echo "<li>\"" . $dpo->city($tempData['city']) . "\" should be \"" . $tempData['city'] . "\"</li>";
echo "<li>\"" . $dpo->state($tempData['state']) . "\" should be \"" . $tempData['state'] . "\"</li>";
echo "<li>\"" . $dpo->postal($tempData['postal']) . "\" should be \"" . $tempData['postal'] . "\"</li>";
echo "<li>\"" . $dpo->country($tempData['country']) . "\" should be \"" . $tempData['country'] . "\"</li>";
echo "</ul>";
echo "<p>Done</p>";
$dpoAry = new DobaOrders();
echo "<p>" . ($dpoAry->orderExists($tempData['orders_id']) ? 'Order added' : 'Order not added') . "</p>";
$dpoAry->addOrder($dpo);
echo "<p>" . ($dpoAry->orderExists($tempData['orders_id']) ? 'Order added' : 'Order not added') . "</p>";
 function findItems($ItemDetails)
 {
     /* 
             <items>       
                 <item>
             <item_id>
             <qty>
             <price>
                 </item>
             </items>		
     */
     $itemList = array();
     if (array_key_exists('item', $ItemDetails['items'])) {
         //Only 1 item
         $tempDobaOrder = new DobaOrderInfo();
         $tempDobaOrder->item_id($ItemDetails['items']['item']['item_id']);
         $tempDobaOrder->quantity($ItemDetails['items']['item']['qty']);
         //No where to put this...
         //$tempDobaOrder->$max_expected_total($ItemDetails['items']['item']['price']);
         $itemList[0] = $tempDobaOrder;
     } else {
         $cnt = 0;
         foreach ($ItemDetails['items'] as $item) {
             $tempDPD = new DobaProductData();
             $tempDobaOrder = new DobaOrderInfo();
             $tempDobaOrder->item_id($item['item_id']);
             $tempDobaOrder->quantity($item['qty']);
             //No where to put this...
             //$tempDobaOrder->$max_expected_total($item['price']);
             $itemList[$cnt++] = $tempDobaOrder;
         }
     }
     return $itemList;
 }
    /**
     * Pulls orders by sent to Doba status
     * @static method
     * @return DobaOrders
     * @param $status string (all, new, submitted, unsubmitted)
     */
    function loadOrders($status)
    {
        $do = new DobaOrders();
        $orders = array();
        $sql = 'select 
					' . TABLE_ORDERS . '.orders_id as ponumber, 
					' . TABLE_ORDERS . '.delivery_name as name,
					' . TABLE_ORDERS . '.delivery_street_address as address1,
					' . TABLE_ORDERS . '.delivery_city as city,
					' . TABLE_ORDERS . '.delivery_state as state,
					' . TABLE_ORDERS . '.delivery_postcode as postal,
					' . TABLE_ORDERS . '.delivery_country as country,
					' . TABLE_ORDERS_PRODUCTS . '.products_id as item_id,
					' . TABLE_ORDERS_PRODUCTS . '.products_quantity as quantity,
					' . TABLE_ORDERS_PRODUCTS . '.final_price as max_expected_total,
					DobaLog.doba_log_id,
					DobaLog.api_response
				from 
					' . TABLE_ORDERS . '
					join ' . TABLE_ORDERS_PRODUCTS . ' on ' . TABLE_ORDERS_PRODUCTS . '.orders_id=' . TABLE_ORDERS . '.orders_id 
					left join DobaLog on DobaLog.local_id=' . TABLE_ORDERS . '.orders_id and DobaLog.datatype="order"';
        if ($status == 'new') {
            $sql .= ' where DobaLog.doba_log_id is NULL';
        } else {
            if ($status == 'submitted') {
                $sql .= ' where DobaLog.api_response is not NULL';
            } else {
                if ($status == 'unsubmitted') {
                    $sql .= ' where DobaLog.api_response is NULL';
                }
            }
        }
        $orders_query = tep_db_query($sql);
        while ($o = tep_db_fetch_array($orders_query)) {
            $i = new DobaOrderInfo();
            $i->po_number($o['ponumber']);
            $name = $i->name_to_parts($o['name']);
            $i->first_name($name['FirstName']);
            $i->last_name($name['LastName']);
            $i->address1($o['address1']);
            $i->city($o['city']);
            $i->state($o['state']);
            $i->postal($o['postal']);
            $i->country($o['country']);
            $i->item_id($o['item_id']);
            $i->quantity($o['quantity']);
            $i->max_expected_total($o['max_expected_total']);
            $do->addOrder($i);
        }
        return $do;
    }
<?php

ini_set('include_path', ini_get('include_path') . ':' . $_SERVER['DOCUMENT_ROOT'] . '/admin/includes/');
include_once 'doba/DobaOrderInfo.php';
include_once 'doba/DobaOrders.php';
include_once 'doba/DobaOrderFile.php';
$do = new DobaOrders();
$dboi = new DobaOrderInfo();
$dof = new DobaOrderFile();
$tempData = array('orders_id' => 12345, 'first_name' => 'Candice', 'last_name' => 'Johnson', 'address' => '4958 W 495 S', 'address2' => 'none', 'city' => 'Orem', 'state' => 'UT', 'postal' => '84097', 'country' => 'USA', 'items_id' => '25', 'quantity' => '30', 'max' => '1025');
for ($i = 0; $i < 10; $i++) {
    $temp = new DobaOrderInfo();
    $temp->po_number($i);
    $temp->first_name($tempData['first_name']);
    $temp->last_name($tempData['last_name']);
    $temp->address1($tempData['address']);
    $temp->address2($tempData['address2']);
    $temp->city($tempData['city']);
    $temp->state($tempData['state']);
    $temp->postal($tempData['postal']);
    $temp->country($tempData['country']);
    $temp->item_id($tempData['items_id']);
    $dboi->quantity($tempData['quantity']);
    $dboi->max_expected_total($tempData['max']);
    $do->addOrder($temp);
}
/*for ($i = 0; $i < 10; $i++)
{
	$do->addOrder($dboi);
}*/
echo "<pre>";