$qry .= " LEFT JOIN elements_suppliers esup ON esup.elements_suppliers_id=etes.elements_suppliers_id";
     $qry .= " INNER JOIN element e ON e.elements_id = ep.elements_id";
     $qry .= " WHERE ep.status = '1' AND e.attribute_category_id = '3'";
     $qry .= " GROUP BY ep.elements_id";
     $res = tep_db_query($qry);
     if (tep_db_num_rows($res) == 0) {
         $ercontent .= '<h3 class="red">No Sourcing Data Found</h3>';
     } else {
         while ($row = tep_db_fetch_array($res)) {
             $el_id = $row['elements_id'];
             $el_qty = $row['quantity'];
             $el_weight = $row['elements_weight'];
             $total_weight_per_el = $el_qty * $el_weight;
             $total_weight_casting += $total_weight_per_el;
         }
         $ercontent .= '<tr class="cat-over"><td class="casting">Casting (' . displayWeight($total_weight_casting) . ')</td></tr>';
         $ercontent .= '</table>';
     }
     $result = array();
     $result['ponewcontent'] = $ponewcontent;
     $result['ercontent'] = $ercontent;
     ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'SETASREQUEST') {
     $eid = tep_db_prepare_input($_POST['eid']);
     $etesid = tep_db_prepare_input($_POST['etesid']);
     $qty_unit = tep_db_prepare_input($_POST['qty_unit']);
     $unit = tep_db_prepare_input($_POST['unit']);
     $unit_qpp = tep_db_prepare_input($_POST['uqpp']);
     $qty_default = tep_db_prepare_input($_POST['defqty']);
     $epo = new elements_preorder($eid, '0');
    $sup_pct_per_cat = $total_amount_cat[$cat] > 0 ? $amount / $total_amount_cat[$cat] * 100 : 0;
    $total_sup_pct += $sup_pct_all_cat;
    $sup_reject = $dt['total_received'] > 0 ? $dt['bad'] / $dt['total_received'] * 100 : 0;
    $row['c tac'] = "{$sup_name}";
    $row['o'] = displayWeight($dt['weight']);
    $row['t'] = displayCurrency('IDR', $amount);
    $row['t2'] = (is_decimal($sup_pct_all_cat) ? number_format($sup_pct_all_cat, 2) : $sup_pct_all_cat) . ' %';
    //    $row['e'] = (is_decimal($sup_pct_per_cat) ? number_format($sup_pct_per_cat, 2) : $sup_pct_per_cat ).' %';
    //    $row['s'] = (is_decimal($pct_fullfilled) ? number_format($pct_fullfilled, 2) : $pct_fullfilled ).' %';
    $row['r'] = (is_decimal($pct_reject) ? number_format($pct_reject, 2) : $pct_reject) . ' %';
    $table[] = $row;
}
//PREPARE TOTAL ROW
$row = array();
$row['c total text-center'] = 'Total';
$row['o total'] = displayWeight($total_weight);
$row['t total'] = displayCurrency('IDR', $total_amount);
$row['t2 total'] = "{$total_sup_pct} %";
$row['r total'] = '';
//$row['e'] = "";
//$row['s'] = '';
$table[] = $row;
$content = '<div style="width:700px;">';
$content .= '<div style="float:right;">';
$content .= '<form name="filtering" action="?open=' . $session_page . '" method="post">';
$content .= '<table class="form" border="0" cellpadding="0" cellspacing="0">';
$content .= '<tr><td>Filter by Category</td><td><select name="elcat-filter" class="input" onchange="filtering.submit();"><option value="">Show All</option>' . loadComboList('element_category', 'element_category_id', 'name', $elcatfiltered) . '</select></select></td></tr>';
$content .= '</table>';
$content .= '</form>';
$content .= '</div>';
//float:right