/**
 * 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;
}
Exemple #2
0
function doorLockCheck($rfid)
{
    global $con;
    $rfid = testInput($rfid);
    //get the key owner and their current membership plan
    $query = "SELECT c.cid, p.price\r\n\t\t\t\tFROM ((\r\n\t\t\t\t`key` k\r\n\t\t\t\tLEFT JOIN  `contact` c ON k.cid = c.cid\r\n\t\t\t\t)\r\n\t\t\t\tLEFT JOIN `membership` m ON m.cid = c.cid\r\n\t\t\t\t)\r\n\t\t\t\tLEFT JOIN `plan` p ON p.pid = m.pid\r\n\t\t\t\twhere k.serial = '" . $rfid . "'";
    $result = mysqli_query($con, $query) or die(json_encode(array("doorLockCheckQueryERROR" => mysqli_error($con))));
    //if no rows returned then that key wasn't even found in the DB
    if (mysqli_num_rows($result) == 0) {
        $jsonResponse = array("key " . $rfid . " not found in db");
    } else {
        $row = mysqli_fetch_assoc($result);
        $memberID = $row["cid"];
        $planPrice = $row["price"];
        $accountData = payment_accounts(array("cid" => $memberID));
        //{"2":{"credit":"2","code":"USD","value":5000}}
        $memberBalance = $accountData[$memberID]["value"] / 100;
        //if the current key owner's balance is
        // greater than 2 months of dues then access is denied!
        // Unless thier plan price is zero then 0 balance == 0 price is OK.
        if ($memberBalance > $planPrice * 2 && $memberBalance > 0) {
            $jsonResponse = array("member balance = " . $memberBalance);
        } else {
            $jsonResponse = array("True");
        }
    }
    return $jsonResponse;
}
Exemple #3
0
/**
 * Return a table showing account balances.
 * @param $opts An associative array of options.
 * @return A table object.
 */
function payment_accounts_table($opts)
{
    $export = array_key_exists('export', $opts) && $opts['export'] ? true : false;
    $cids = payment_contact_filter(array('balance_due' => true));
    $balances = payment_accounts(array('cid' => $cids));
    $table = array('columns' => array(array('title' => 'Name'), array('title' => 'Email'), array('title' => 'Balance Owed')), 'rows' => array());
    $contacts = crm_get_data('contact', array('cid' => $cids));
    $cidToContact = crm_map($contacts, 'cid');
    foreach ($balances as $cid => $balance) {
        $row = array();
        $row[] = theme('contact_name', $cid, !$export);
        $row[] = $cidToContact[$cid]['email'];
        $row[] = payment_format_currency($balance);
        $table['rows'][] = $row;
    }
    return $table;
}