/** * Return an account summary and amazon payment button. * @param $cid The cid of the contact to create a form for. * @return An html string for the summary and button. */ function theme_amazon_payment_account_info($cid) { $balances = payment_accounts(array('cid' => $cid)); $balance = $balances[$cid]; $params = array('referenceId' => $cid, 'amount' => $balance['code'] . ' ' . payment_format_currency($balance, false), 'description' => 'CRM Dues Payment'); $output = '<div>'; $amount = payment_format_currency($balance); if ($balance['value'] > 0) { $output .= "<p><strong>Outstanding balance:</strong> {$amount}</p>"; $output .= theme('amazon_payment_button', $cid, $params); } else { $balance['value'] = -1 * $balance['value']; $amount = payment_format_currency($balance); $output .= "<p><strong>No balance owed. Account credit:</strong> {$amount}</p>"; } $output .= '</div>'; return $output; }
/** * Return the payment form structure. * * @param $pmtid The id of the key assignment to delete. * @return The form structure. */ function payment_delete_form($pmtid) { // Ensure user is allowed to delete keys if (!user_access('payment_delete')) { return NULL; } // Get data $data = crm_get_data('payment', array('pmtid' => $pmtid)); $payment = $data[0]; // Construct key name $amount = payment_format_currency($payment); $payment_name = "Payment:{$payment['pmtid']} - {$amount}"; if ($payment['credit_cid']) { $name = theme('contact_name', $payment['credit_cid']); $payment_name .= " - Credit: {$name}"; } if ($payment['debit_cid']) { $name = theme('contact_name', $payment['debit_cid']); $payment_name .= " - Debit: {$name}"; } // Create form structure $form = array('type' => 'form', 'method' => 'post', 'command' => 'payment_delete', 'hidden' => array('pmtid' => $payment['pmtid']), 'fields' => array(array('type' => 'fieldset', 'label' => 'Delete Payment', 'fields' => array(array('type' => 'message', 'value' => '<p>Are you sure you want to delete the payment "' . $payment_name . '"? This cannot be undone.'), array('type' => 'submit', 'value' => 'Delete'))))); return $form; }