$ot['act'] = 'Action';
 $otable[] = $ot;
 $linksep = ' ⋅ ';
 foreach ($orders as $oid => $o) {
     $ot = array();
     $ot['r'] = $o['suppliers_name'];
     $submit_date = date('d.m.Y', strtotime($o['date_submitted']));
     $ot['d'] = '<input type="text" id="podate-' . $oid . '" name="podate" value="' . $submit_date . '" class="date_picker" />';
     $ot['id1'] = $o['po_number'] . '<input type="hidden" name="oid" value="' . $oid . '" />';
     $ot['o'] = '<input type="text" id="suppid-' . $oid . '" name="suppid" value="' . $o['supplier_order_id'] . '" style="text-align:center;" />';
     //$ot['c'] = count($elements[$oid]).' Elements<br />('.array_sum($elements[$oid]).' Total Qty)';
     $total_ordered_qty = array_sum($elements[$oid]);
     $total_received_qty = array_sum($elements_received[$oid]);
     $total_void_qty = array_sum($elements_void[$oid]);
     $total_ordered_after_void = $total_ordered_qty - $total_void_qty;
     $ot['email'] = elementsSourcingOpenPOlinks($oid, $o['suppliers_id'], count($elements[$oid]), $total_ordered_qty, $total_received_qty, $total_void_qty, count($elements_confpri[$oid]), count($elements_confwax[$oid]), 'PRICEONLY');
     //$ot['email'] = '<div id="er-'.$oid.'" '.$e_class.' style="padding-right:15px;text-align:right;">'.$total_received.'/'.$total_ordered.$linksep.$wax.$linksep.$receive.$linksep.$confprice.'</div>';
     $ot['id2'] = $total_weight[$oid] . ' gram';
     $ot['id3'] = displayCurrency($o['currency'], $total_price[$oid]);
     if ($o['date_received'] != null) {
         $received_date = date('d.m.Y', strtotime($o['date_received']));
     } else {
         $received_date = '';
     }
     $ot['dr'] = $received_date;
     //$ot['t']  = '<input type="text" id="paypri-'.$oid.'" name="paypri" value="'.number_format($o['payment_price'],2,'.',' ').'" style="width:80px;text-align:right;" />';
     //$ot['t'] .= '<select id="paycur-'.$oid.'" name="paycur">'.loadComboListFromArray($currencies, null, $o['payment_currency'], false).'</select>';
     $added_class = '';
     if ($total_ordered_after_void > 0) {
         if ($o['payment_status'] == '1') {
             $paid_image = 'yes';
        if ($open_qty <= 0) {
            $open_qty_text = '<span class="notice">-</span>';
            $status = 'CLOSED';
        } else {
            $open_qty_weight = $open_qty * $eoi['unit_multiplier'] * $eoi['elements_weight'];
            $open_qty_text = $open_qty . ' ' . $eoi['quantity_unit'] . '<br /><span class="notice">(' . $open_qty_weight . ' gram)</span>';
            $status = 'OPEN';
        }
        $result = array();
        $result['oid'] = $oid;
        $result['eoi_id'] = $eoi_id;
        $result['status'] = $status;
        $result['id2'] = $recv_qty . ' ' . $eoi['quantity_unit'] . '<br /><span class="notice">(' . $recv_qty_weight . ' gram)</span>';
        $result['id4'] = $void_qty . ' ' . $eoi['quantity_unit'] . '<br /><span class="notice">(' . $void_qty_weight . ' gram)</span>';
        $result['id3'] = $open_qty_text;
        $result['order_er'] = elementsSourcingOpenPOlinks($oid, $eo->suppliers_id, count($eo->items), $eo->total_ordered, $eo->total_received, $eo->total_void, $eo->total_price_confirmed, $eo->total_wax_confirmed, 'NOPRICE');
        $result['qty_ok'] = $qtyok;
        $result['qty_bad'] = $qtybad;
        $result['item_number'] = $eoi['item_number'];
        ajaxReturn($result);
        exit;
    }
}
$item_number = array();
$item_received = array();
$item_void = array();
foreach ($eo->items_received as $eoi_id => $eoir) {
    foreach ($eoir as $ir) {
        if (!isset($item_received[$eoi_id])) {
            $item_received[$eoi_id] = 0;
        }