/**
 * Add options to main menu
 *
 * @param Menu $menu
 * @param User $user
 * @return null
 */
function invoicing_handle_on_build_menu(&$menu, &$user)
{
    $company = $user->getCompany();
    if ($user->getSystemPermission('can_manage_invoices')) {
        $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('invoices'), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countOverdue())), 'main');
    } else {
        if ($user->isCompanyManager($company)) {
            $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('people_company_invoices', array('company_id' => $user->getCompanyId())), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countByCompany($user->getCompany(), array(INVOICE_STATUS_ISSUED)))), 'main');
        }
    }
    // if
}
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function incoming_mail_handle_on_build_menu(&$menu, &$user)
{
    if (($user->isAdministrator() || $user->getSystemPermission('can_use_incoming_mail_frontend')) && ($count_pending = IncomingMails::countPending()) > 0) {
        $menu->addToGroup(array(new MenuItem('incoming_mail', lang('Inbox'), assemble_url('incoming_mail'), get_image_url('icon_menu.gif', INCOMING_MAIL_MODULE), $count_pending)), 'main');
    }
    // if
}
/**
 * Add options to main menu
 *
 * @param Menu $menu
 * @param User $user
 * @return null
 */
function timetracking_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('use_time_reports')) {
        $menu->addToGroup(array(new MenuItem('time', lang('Time'), 'https://www.healingcrystals.com/admin/timeSheets.php', get_image_url('navigation/time.gif'))), 'main');
    }
    // if
}
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function documents_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('can_use_documents')) {
        $menu->addToGroup(array(new MenuItem('documents', lang('Docs'), assemble_url('documents'), get_image_url('icon.gif', DOCUMENTS_MODULE))), 'main');
    }
    // if
}
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function status_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('can_use_status_updates')) {
        $last_visit = UserConfigOptions::getValue('status_update_last_visited', $user);
        $menu->addToGroup(array(new MenuItem('status', lang('Status'), assemble_url('status_updates'), get_image_url('icon_menu.gif', STATUS_MODULE), StatusUpdates::countNewMessagesForUser($user, $last_visit))), 'main');
    }
    // if
}