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_startanddate_endfields (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 likecustom_lunch_calendar.phpwith 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.
- To avoid editing core files (which get overwritten on upgrades), create a custom extension. Make a directory
- 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, andparent_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
panelsarray, 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'), ),
- In the
- You can do this via Studio or by editing
- 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_idfield (default in custom modules) and that your user roles have permission to access Calendar data.
内容的提问来源于stack exchange,提问作者Mubin
相关产品推荐
相关产品推荐

