SuiteCRM is a widely used open-source customer relationship management (CRM) platform, known for its flexibility and extensibility. To improve how customer feedback is collected and managed, businesses often need to customize its default features. This guide demonstrates how to use PHP to build a custom module, create a feedback form, and process submission data for optimized feedback management in SuiteCRM.
The first step in optimizing the feedback feature is to create a dedicated module to store and manage feedback data. This can be done either using the built-in Module Builder or manually creating module files. Here's an example of the manual approach:
Within the SuiteCRM project directory, navigate to `custom/modules` and create a new folder named `Feedback`. Then, create the following files:
Here’s a sample of what the Feedback.php file might look like:
<?php $module_name = 'Feedback'; $object_name = 'Feedback'; $module_title = 'Feedback'; $moduel_icon = 'icon_Feedback'; $modListHeader = array(); $modListHeader['name'] = array('width' => '10', 'label' => 'Name'); $modListHeader['email'] = array('width' => '20', 'label' => 'Email'); // Other field definitions $modListHeader = sugar_alter($modListHeader, $module_name); $moduleList = array(); $moduleList[$module_name] = $module_title; $beanList[$object_name] = $module_name; $beanFiles[$object_name] = 'modules/Feedback/Feedback.php'; $objectName[$object_name] = $object_name; $module_group = array_pop($moduleGroups); $modInvisList[] = $module_name; $modInvisList[] = $object_name; $module_menu[] = array('index', $menus_lang['LBL_MODULE_NAME'], 'Feedback', 'Feedback'); ?>
This example defines a module called "Feedback" with two key fields: name and email.
To collect feedback from users, we need to create a simple HTML form. Create a new file named FeedbackForm.tpl inside the `custom/modules/Feedback` directory, with the following content:
<!-- create form for feedback --> <form action="index.php" method="post"> <input type="hidden" name="module" value="Feedback"> <input type="hidden" name="action" value="save"> <!-- other fields --> <input type="submit" value="Submit"> </form>
This form uses a POST request to submit feedback data to the Feedback module, making it available for CRM processing and storage.
Once the form is submitted, we need a PHP script to capture and store the data in SuiteCRM. Create a new file called save.php and insert the following code:
<?php // Get submitted feedback data $name = $_POST['name']; $email = $_POST['email']; // Additional fields // Save the data in SuiteCRM $bean = BeanFactory::newBean('Feedback'); $bean->name = $name; $bean->email = $email; // Assign other field values $bean->save(); // Display confirmation to the user echo 'Thank you for your feedback!'; ?>
This script retrieves the submitted data, creates a new Feedback record, and saves it to the database. A confirmation message is then displayed to the user.
By following these steps—creating a custom module, building a feedback form, and processing the data—you can successfully enhance the customer feedback functionality in SuiteCRM using PHP. This tailored approach improves user experience and enables businesses to manage customer suggestions more effectively.