Changes up to 2.3.7 merged into unstable branch.
[fa-stable.git] / includes / ui / ui_view.inc
index eb7e7713c272cd641b2cd5da081e0ad26d76a63b..3f27641b67e9508b035366282014748eac5ac829 100644 (file)
@@ -474,14 +474,14 @@ function display_footer_exit()
 
 //--------------------------------------------------------------------------------------
 
-function display_allocations($alloc_result, $total)
+function display_allocations($alloc_result, $total, $payments=false)
 {
        global $systypes_array;
 
        if (!$alloc_result || db_num_rows($alloc_result) == 0)
                return;
 
-    display_heading2(_("Allocations"));
+    display_heading2(($payments ? _("Payments") : _("Allocations")));
 
     start_table(TABLESTYLE, "width=80%");
 
@@ -538,6 +538,23 @@ function display_allocations_from($person_type, $person_id, $type, $type_no, $to
        }
 }
 
+//--------------------------------------------------------------------------------------
+
+function display_allocations_to($person_type, $person_id, $type, $type_no, $total)
+{
+       switch ($person_type)
+       {
+               case PT_CUSTOMER :
+                       $alloc_result = get_allocatable_from_cust_transactions($person_id, $type_no, $type);
+                       display_allocations($alloc_result, $total, true);
+                       return;
+               case PT_SUPPLIER :
+                       $alloc_result = get_allocatable_from_supp_transactions($person_id, $type_no, $type);
+                       display_allocations($alloc_result, $total, true);
+                       return;
+       }
+}
+
 //--------------------------------------------------------------------------------------
 //
 //     Expands selected quick entry $id into GL posings and adds to cart.
@@ -1300,4 +1317,30 @@ function display_backtrace($cond=true, $msg='') {
        }
 }
 
-?>
\ No newline at end of file
+//
+// FIXME: $payment_services array will be moved to bank_accounts in 2.4.x
+//
+if (!isset($payment_services))
+{
+       $payment_services = array(
+               'PayPal' => "https://www.paypal.com/xclick/business=<company_email>&item_name=<comment>&amount=<amount>&currency_code=<currency>",
+       );
+}
+/*
+*      Payment link generation. Options provided during invoice generation:
+*      company_email, comment, amount, currency
+*/
+function payment_link($name, $options)
+{
+       global $payment_services;
+
+       $link = @$payment_services[$name];
+
+       if (!$link) return null;
+
+       $patterns = array();
+       foreach ($options as $id => $option)
+               $patterns['<'.$id.'>'] = urlencode($options[$id]);
+
+       return strtr($link, $patterns);
+}