Example #1
0
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
$view = new MM_ProductView();
$dataGrid = new MM_DataGrid($_REQUEST, "id", "desc", 10);
$data = $view->getViewData($dataGrid);
$dataGrid->setTotalRecords($data);
$dataGrid->recordName = "product";
$rows = array();
foreach ($data as $key => $item) {
    $product = new MM_Product($item->id);
    // Actions
    $editActionUrl = 'onclick="mmjs.edit(\'mm-products-dialog\', \'' . $product->getId() . '\', 580, 600)"';
    $deleteActionUrl = 'onclick="mmjs.remove(\'' . $product->getId() . '\')"';
    $actions = MM_Utils::getEditIcon("Edit Product", '', $editActionUrl);
    if (!MM_Product::isBeingUsed($product->getId()) && !MM_Product::hasBeenPurchased($product->getId())) {
        $actions .= MM_Utils::getDeleteIcon("Delete Product", 'margin-left:5px;', $deleteActionUrl);
    } else {
        $actions .= MM_Utils::getDeleteIcon("This product is currently being used and cannot be deleted", 'margin-left:5px;', '', true);
    }
    $purchaseLinks = '<a title="Get purchase links" onclick="mmjs.showPurchaseLinks(' . $product->getId() . ',\'' . htmlentities(addslashes($product->getName()), ENT_QUOTES) . '\')" class="mm-ui-button" style="margin:0px;">' . MM_Utils::getIcon('money', '', '1.3em', '1px', '', 'margin-right:0px;') . '</a>';
    // Associated Access
    $accessGranted = "";
    $membership = $product->getAssociatedMembership();
    if ($membership->isValid()) {
        $accessGranted .= MM_Utils::getAccessIcon(MM_OrderItemAccess::$ACCESS_TYPE_MEMBERSHIP);
        $accessGranted .= " <a href='" . MM_ModuleUtils::getUrl(MM_MODULE_PRODUCT_SETTINGS, MM_MODULE_MEMBERSHIP_LEVELS) . "&autoload=" . $membership->getId() . "'>" . $membership->getName() . "</a>";
    }
    if (empty($accessGranted)) {
        $bundle = $product->getAssociatedBundle();
        if ($bundle->isValid()) {