X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fallocations%2Fcustomer_allocation_main.php;h=b08d8548d8e75bf45f85609c3c2a13fa0b6e2e78;hb=128be63f9ae68744f37eae8072f95d0f524f86b4;hp=9c60415e7101e95afa2e4e49216eaeb2821e1012;hpb=95ff74b5722826544743a01daf527aa3c9efe11a;p=fa-stable.git diff --git a/sales/allocations/customer_allocation_main.php b/sales/allocations/customer_allocation_main.php index 9c60415e..b08d8548 100644 --- a/sales/allocations/customer_allocation_main.php +++ b/sales/allocations/customer_allocation_main.php @@ -32,6 +32,7 @@ if (!isset($_POST['customer_id'])) echo "
" . _("Select a customer: ") . "  "; echo customer_list('customer_id', $_POST['customer_id'], true, true); echo "
"; + check(_("Show Settled Items:"), 'ShowSettled', null, true); echo "


"; @@ -65,14 +66,21 @@ function trans_view($trans) function alloc_link($row) { - return pager_link(_("Allocate"), + global $all_settled; + + return ($row['settled']&&!get_post('ShowSettled')) || (!$row['settled'] && $all_settled) ? '' : pager_link(_("Allocate"), "/sales/allocations/customer_allocate.php?trans_no=" .$row["trans_no"] . "&trans_type=" . $row["type"]. "&debtor_no=" . $row["debtor_no"], ICON_ALLOC); } +function amount_total($row) +{ + return price_format($row['type'] == ST_JOURNAL && $row["Total"] < 0 ? -$row["Total"] : $row["Total"]); +} + function amount_left($row) { - return price_format($row["Total"]-$row["alloc"]); + return price_format(($row['type'] == ST_JOURNAL && $row["Total"] < 0 ? -$row["Total"] : $row["Total"])-$row["alloc"]); } function check_settled($row) @@ -80,17 +88,20 @@ function check_settled($row) return $row['settled'] == 1; } +$all_settled = !db_num_rows(get_allocatable_to_cust_transactions($customer_id)); +if ($all_settled) + display_note(''._("There is no unsettled transactions for this customer.").''); $sql = get_allocatable_from_cust_sql($customer_id, $settled); $cols = array( _("Transaction Type") => array('fun'=>'systype_name'), - _("#") => array('fun'=>'trans_view'), + _("#") => array('fun'=>'trans_view', 'align'=>'right'), _("Reference"), _("Date") => array('name'=>'tran_date', 'type'=>'date', 'ord'=>'asc'), _("Customer") => array('ord'=>''), _("Currency") => array('align'=>'center'), - _("Total") => 'amount', + _("Total") => array('align'=>'right','fun'=>'amount_total'), _("Left to Allocate") => array('align'=>'right','insert'=>true, 'fun'=>'amount_left'), array('insert'=>true, 'fun'=>'alloc_link') );