<?php
/**********************************************************************
***********************************************************************/

function get_pos_for_reopen()
{

	$sql = "SELECT 
                porder.order_no, 
                porder.reference, 
                supplier.supp_name, 
                location.location_name,
                porder.requisition_no, 
                porder.ord_date, 
                supplier.curr_code, 
                Sum(line.unit_price*line.quantity_ordered) AS OrderValue,
                porder.into_stock_location,
                porder.approval_status 
		FROM ".TB_PREF."purch_orders as porder, "
                .TB_PREF."purch_order_details as line, "
                .TB_PREF."suppliers as supplier, "
                .TB_PREF."locations as location
		WHERE porder.order_no = line.order_no
                AND porder.supplier_id = supplier.supplier_id
                AND location.loc_code = porder.into_stock_location 
                AND porder.approval_status =".db_escape(AS_APPROVED);

        $sql .= " GROUP BY porder.order_no "
                . " HAVING Sum(line.quantity_received) = 0";
        
        return db_query($sql,"No Purchase Orders were returned");
	
  }	

//----------------------------------------------------------------------------------------

?>