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, $show_voided = 0)
+ $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT, $show_voided = 0, $by_delivery=0, $no_auto=0)
{
if ($filter=='OutstandingOnly')
$order_value = 'Sum(line.unit_price*(line.quantity-line.qty_sent)*(1-line.discount_percent))+freight_cost';
{
$date_after = date2sql($from);
$date_before = date2sql($to);
-
- $sql .= " AND sorder.ord_date >= '$date_after'"
- ." AND sorder.ord_date <= '$date_before'";
+ $by_date = $by_delivery ? 'delivery_date' : 'ord_date';
+ $sql .= " AND sorder.$by_date >= '$date_after'"
+ ." AND sorder.$by_date <= '$date_before'";
}
+ if ($no_auto)
+ $sql .= " AND sorder.reference != 'auto'";
}
if ($trans_type == ST_SALESQUOTE && !check_value('show_all'))
$sql .= " AND sorder.delivery_date >= '".date2sql(Today())."' AND line.qty_sent=0"; // show only outstanding, not realized quotes