You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SuiteCRM自定义模块Lunch接入日历及编辑视图添加调度面板问询

Hey there! Let's tackle your two questions about your custom Lunch module—getting it to show up in the Calendar like Meetings/Calls, and adding that handy scheduling panel to its Edit View. I’ve worked through this exact scenario a few times, so here’s a straightforward breakdown to get you sorted:

1. Get Lunch Module Entries Showing in the Calendar

First, let’s make sure your module has the right foundation:

  • Add required date/time fields: The Calendar relies on date_start and date_end fields (just like Meetings/Calls). If you don’t have these, head to Studio > Lunch Module > Fields and create them. Make sure they’re set to "Date/Time" type.
  • Enable the module in Calendar settings:
    • Go to Admin > System Settings > Calendar.
    • Look for the "Modules to Display in Calendar" section. Your Lunch module should be listed here (if not, double-check it’s active and has those date fields). Check the box next to it and save.
  • Map module fields to Calendar (best practice: use custom extensions):
    • To avoid editing core files (which get overwritten on upgrades), create a custom extension. Make a directory custom/modules/Calendar/Ext/CalendarDisplay/ and add a file like custom_lunch_calendar.php with this code:
      <?php
      $calendar_display_modules['Lunch'] = array(
          'module' => 'Lunch',
          'date_start' => 'date_start',
          'date_end' => 'date_end',
          'color' => '#FFA500', // Pick a unique color for Lunch entries
          'icon' => 'fa-cutlery', // Use a fitting Font Awesome icon
          'name' => 'Lunch',
          'table' => 'lunch', // Your module's database table name
      );
      ?>
      
    • Run a Quick Repair and Rebuild from Admin > Repair to apply the changes.
  • Test it out: Go to the Calendar module, use the dropdown filter to make sure Lunch is selected, and you should see your entries alongside Meetings and Calls.
2. Add the Scheduling Panel to Lunch's Edit View

The scheduling panel (with auto-updating dates/durations) needs a few key fields and metadata tweaks:

  • Add scheduling-related fields: If you haven’t already, add these fields via Studio: time_start, time_end, duration_hours, duration_minutes, parent_type, parent_id, and parent_name. These mirror the fields used in Meetings/Calls.
  • Update Edit View metadata:
    • You can do this via Studio or by editing custom/modules/Lunch/metadata/editviewdefs.php. Either way, add a scheduling panel section and include the necessary JavaScript:
      • In the panels array, add this panel:
        array(
            'name' => 'scheduling',
            'label' => 'LBL_SCHEDULING_PANEL',
            'panel' => 'default',
            'fields' => array(
                array(
                    'name' => 'date_start',
                    'label' => 'LBL_DATE_START',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateDuration'),
                ),
                array(
                    'name' => 'time_start',
                    'label' => 'LBL_TIME_START',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateDuration'),
                ),
                array(
                    'name' => 'date_end',
                    'label' => 'LBL_DATE_END',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateDuration'),
                ),
                array(
                    'name' => 'time_end',
                    'label' => 'LBL_TIME_END',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateDuration'),
                ),
                array(
                    'name' => 'duration_hours',
                    'label' => 'LBL_DURATION_HOURS',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateEndDate'),
                ),
                array(
                    'name' => 'duration_minutes',
                    'label' => 'LBL_DURATION_MINUTES',
                    'displayParams' => array('update_callback' => 'SchedulingHelper.updateEndDate'),
                ),
                array(
                    'name' => 'parent_name',
                    'label' => 'LBL_PARENT_NAME',
                    'displayParams' => array('module' => 'Contacts'), // Adjust to your related modules
                ),
            ),
        ),
        
      • Add the required JavaScript includes at the top of the editviewdefs file:
        'includes' => array(
            array('file' => 'modules/Calendar/Scheduling.js'),
            array('file' => 'modules/Calendar/Calendar.js'),
        ),
        
  • Studio shortcut: If you prefer using Studio, drag the scheduling fields into your Edit View layout, then go to "Advanced" > "Includes" and add those two JavaScript files.
  • Final steps: Run a Quick Repair and Rebuild, then open the Lunch module’s Edit View. You should see the scheduling panel working just like in Meetings—changing the start time will auto-update the end time based on duration, and vice versa.
  • Bonus: Availability checking: If you want to see if assigned users are free, make sure your Lunch module has the assigned_user_id field (default in custom modules) and that your user roles have permission to access Calendar data.

内容的提问来源于stack exchange,提问作者Mubin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:21:39