Dashboard Customisation

Discussion in 'Customization & add-ons' started by cooltrader, Jun 17, 2019.

Thread Status:
Not open for further replies.
  1. cooltrader

    cooltrader aMember Pro Customer

    Joined:
    Apr 17, 2006
    Messages:
    9
    Hello
    Is it possible to get another dashboard widget that displays upcoming membership expirations for either 7/30 days. Makes it easy to monitor renewals
    i.e.

    member | expirey date | current membershi type |

    Thanks
    Mick
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello Mick,

    It is possible to implement new widget that works exactly as you need
    but it require some custom coding. Please contact us in helpdesk:
    https://www.amember.com/support

    Best Regards.
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    You can put the following code snippet to site.php file and then add widget "Upcoming Expirations" to your Dashboard
    http://www.amember.com/docs/Site.php_file

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::LOAD_ADMIN_DASHBOARD_WIDGETS, function(Am_Event $e) {
        
    $e->addReturn(new Am_AdminDashboardWidget('upcoming-expire'___('Upcoming Expirations'),
            function(
    Am_View $v$config null) {

                
    $lookahead sqlDate('+7 days');
                
    $now sqlDate('now');
                
    $data Am_Di::getInstance()->db->select(<<<CUT
            SELECT u.login, u.email, u.name_f, u.name_l, product_id, MAX(expire_date) AS exp
                FROM ?_user u
                LEFT JOIN ?_access a USING (user_id)
                GROUP BY user_id, product_id
                HAVING exp BETWEEN ? AND ?
                ORDER BY exp ASC;
    CUT
                    , 
    $now$lookahead);

                
    $pMap Am_Di::getInstance()->productTable->getOptions();
                
    $out '';
                foreach (
    $data as $_) {
                    
    $out .= sprintf('<tr class="grid-row am-grid-row"><td><strong>%s</strong> (%s)<br/>%s</td><td>%s</td><td>%s</td></tr>',
                            
    $v->escape("{$_['name_f']} {$_['name_l']}"),
                            
    $v->escape($_['login']),
                            
    $v->escape($_['email']),
                            
    $v->escape($pMap[$_['product_id']]),
                            
    amDate($_['exp'])
                        );
                }

                return <<<CUT
    <div class="admin-last">
        <h2>Upcoming Expirations</h2>
        <div class="grid-container am-grid-container">
            <table class="am-grid grid-no-highlight">
                <tr>
                    <th class="helper-corner-left" nowrap="nowrap">Customer</th>
                    <th>Product</th>
                    <th class="helper-corner-right">Expires</th>
                </tr>
                
    {$out}
            </table>
        </div>
    </div>
    CUT;
            }));
    });
    everbatim likes this.
  4. cooltrader

    cooltrader aMember Pro Customer

    Joined:
    Apr 17, 2006
    Messages:
    9
    Thankyou Caesar. Thats perfect for me...
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
Thread Status:
Not open for further replies.

Share This Page