Beispiel #1
0
/**
 * Generate description for a membership plan.
 *
 * @param $sid The sid of the membership.
 * @return The description string.
 */
function member_membership_description($sid)
{
    // Get membership data
    $data = member_membership_data(array('sid' => $sid));
    $membership = $data[0];
    // Get member contact info
    $data = member_contact_data(array('cid' => $membership['cid']));
    $contact = $data[0];
    // Construct description
    $description = 'Membership : ';
    $description .= theme_contact_name($contact['cid']);
    $description .= ' : ' . $membership['plan']['name'];
    $description .= ' : Starting ' . $membership['start'];
    return $description;
}
Beispiel #2
0
/**
 * Return a table structure representing a member's past and current memberships.
 *
 * @param $opts Options to pass to member_membership_data().
 * @return The table structure.
*/
function member_membership_table($opts = NULL)
{
    // Ensure user is allowed to view members
    if (!user_access('member_membership_view')) {
        return NULL;
    }
    // Get member data
    $memberships = member_membership_data($opts);
    // Create table structure
    $table = array('id' => '', 'class' => '', 'rows' => array());
    // Add columns
    $table['columns'] = array();
    if (user_access('member_membership_view')) {
        $table['columns'][] = array('title' => 'Start', 'class' => '');
        $table['columns'][] = array('title' => 'End', 'class' => '');
        $table['columns'][] = array('title' => 'Plan', 'class' => '');
        $table['columns'][] = array('title' => 'Price', 'class' => '');
    }
    // Add ops column
    if (user_access('member_membership_edit')) {
        $table['columns'][] = array('title' => 'Ops', 'class' => '');
    }
    // Loop through membership data
    foreach ($memberships as $membership) {
        // Add user data
        $row = array();
        if (user_access('member_membership_view')) {
            $row[] = $membership['start'];
            $row[] = $membership['end'];
            $row[] = $membership['plan']['name'];
            $row[] = $membership['plan']['price'];
        }
        // Construct ops array
        $ops = array();
        // Add delete op
        if (user_access('member_membership_edit')) {
            $ops[] = '<a href=' . crm_url('membership&sid=' . $membership['sid'] . '&tab=edit') . '>edit</a>';
            $ops[] = '<a href=' . crm_url('delete&type=member_membership&amp;id=' . $membership['sid']) . '>delete</a>';
        }
        // Add ops row
        if (!empty($ops)) {
            $row[] = join(' ', $ops);
        }
        // Add row to table
        $table['rows'][] = $row;
    }
    // Return table
    return $table;
}
Beispiel #3
0
/**
 * Return the form structure for editing a membership.
 *
 * @param $sid id of the membership to edit.
 * @return The form structure.
*/
function member_membership_edit_form($sid)
{
    // Ensure user is allowed to edit memberships
    if (!user_access('member_membership_edit')) {
        return NULL;
    }
    // Get membership data
    $data = member_membership_data(array('sid' => $sid));
    $membership = $data[0];
    if (empty($membership) || count($membership) < 1) {
        return array();
    }
    // Construct contact name
    $data = member_contact_data(array('cid' => $membership['cid']));
    $contact = $data[0];
    $name = theme_contact_name($contact['cid']);
    // Create form structure
    $form = array('type' => 'form', 'method' => 'post', 'command' => 'member_membership_update', 'hidden' => array('sid' => $sid, 'cid' => $membership['cid']), 'fields' => array(array('type' => 'fieldset', 'label' => 'Edit Membership Info', 'fields' => array(array('type' => 'readonly', 'label' => 'Name', 'value' => $name), array('type' => 'select', 'label' => 'Plan', 'name' => 'pid', 'options' => member_plan_options(), 'selected' => $membership['pid']), array('type' => 'text', 'label' => 'Start', 'name' => 'start', 'class' => 'date', 'value' => $membership['start']), array('type' => 'text', 'label' => 'End', 'name' => 'end', 'class' => 'date', 'value' => $membership['end']), array('type' => 'submit', 'value' => 'Update')))));
    return $form;
}
Beispiel #4
0
/**
 * Return the text of an email notifying administrators that a user has been created.
 * @param $cid The contact id of the new member.
 */
function theme_member_created_email($cid)
{
    // Get info on the logged in user
    $data = member_contact_data(array('cid' => user_id()));
    $admin = $data[0];
    $adminName = theme_contact_name($admin['cid']);
    // Get info on member
    $data = member_data(array('cid' => $cid));
    $member = $data[0];
    $contact = $member['contact'];
    $name = theme_contact_name($contact['cid']);
    // Get info on member's plan
    $data = member_membership_data(array('cid' => $cid, $filter => array('active' => true)));
    $date = $data[0]['start'];
    $plan = $data[0]['plan']['name'];
    $output = "<p>Contact info:<br/>\n";
    $output .= "Name: {$name}<br/>\n";
    $output .= "Email: {$contact['email']}<br/>\n";
    $output .= "Phone: {$contact['phone']}\n</p>\n";
    $output .= "<p>Membership info:<br/>\n";
    $output .= "Plan: {$plan}<br/>\n";
    $output .= "Start date: {$date}\n</p>\n";
    $output .= "<p>Entered by: {$adminName}</p>\n";
    return $output;
}