}
//----------------------------------------------------------------------------------------
-function get_sql_for_customer_inquiry($from, $to, $cust_id = ALL_TEXT, $filter = ALL_TEXT, $show_voided = 0)
+function get_sql_for_customer_inquiry($from, $to, $cust_id = ALL_TEXT, $filter = ALL_TEXT, $show_voided = 0, $ref='')
{
$date_after = date2sql($from);
$date_to = date2sql($to);
WHERE debtor.debtor_no = trans.debtor_no"; // exclude voided transactions and self-balancing (journal) transactions:
if (!$show_voided)
$sql .= " AND ISNULL(v.date_) AND (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) != 0";
-
+ if ($ref) {
+ $sql .= " AND trans.reference LIKE ". db_escape("%$ref%");
+ }
if ($filter == '2')
$sql .= " AND ABS(IF(prep_amount, prep_amount, ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount)-trans.alloc)>"
.FLOAT_COMP_DELTA;
PrepaidOrders
*/
function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter,
- $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT)
+ $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT, $show_voided = 0)
{
if ($filter=='OutstandingOnly')
$order_value = 'Sum(line.unit_price*(line.quantity-line.qty_sent)*(1-line.discount_percent))+freight_cost';
sorder.branch_code,
sorder.customer_ref,
sorder.ord_date,
- sorder.deliver_to
- ORDER BY sorder.order_no DESC";
+ sorder.deliver_to";
+ if ($show_voided == 0)
+ $sql .= " HAVING OrderValue != 0";
+ $sql .= " ORDER BY sorder.order_no DESC";
return $sql;
}
customer_list_cells(_("Select a customer: "), 'customer_id', null, true, true);
if ($trans_type == ST_SALESQUOTE)
check_cells(_("Show All:"), 'show_all');
-
+if ($trans_type == ST_SALESORDER)
+ check_cells(_("Zero values"), 'show_voided');
submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
hidden('order_view_mode', $_POST['order_view_mode']);
hidden('type', $trans_type);
// Orders inquiry table
//
$sql = get_sql_for_sales_orders_view($trans_type, get_post('OrderNumber'), get_post('order_view_mode'),
- get_post('SelectStockFromList'), get_post('OrdersAfterDate'), get_post('OrdersToDate'), get_post('OrderReference'), get_post('StockLocation'),
- get_post('customer_id'));
+ get_post('SelectStockFromList'), get_post('OrdersAfterDate'), get_post('OrdersToDate'), get_post('OrderReference'), get_post('StockLocation'), get_post('customer_id'), check_value('show_voided'));
if ($trans_type == ST_SALESORDER)
$cols = array(