| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/AppointmentScheduler-Don/include/Smarty/plugins/ |
Upload File : |
<?php
use SuiteCRM\Search\SearchModules;
/**
* Prints a panel that allows you to select modules.
*
* Options: $name, $selectedModules.
*
* The list of modules will be stored as a json array in an hidden field named $name.
*
* @param $params
*/
function smarty_function_modules_selector($params)
{
$modules = SearchModules::getModulesList();
$name = $params['name'];
echo
"<div class=\"modules-container\" id='$name-container'>",
"<input type='hidden' name='$name' id='$name'/>";
foreach ($modules as $module => $translation) {
$checked = in_array($module, $params['selectedModules']) ? 'checked' : null;
echo
'<div class="form-check">',
"<input type='checkbox' class='form-check-input' id='mod-$module' name='{$module}' $checked>",
" <label class='form-check-label' for='mod-$module'>$translation</label>",
'</div>';
}
echo '</div>';
script($name);
}
/**
* Prints the javascript code.
*
* @param string $name Name of the field
*/
function script($name)
{
?>
<script>
var selector, hiddenInput;
$(function () {
selector = $('#<?php echo $name?>-container .form-check input');
hiddenInput = $('#<?php echo $name?>-container input[type=hidden]');
selector.change(function () {
updateModuleSelector();
});
updateModuleSelector();
});
function updateModuleSelector() {
var modules = [];
selector.each(function (key, item) {
if (item.checked) {
modules.push(item.getAttribute('name'))
}
});
hiddenInput.val(JSON.stringify(modules));
}
</script>
<?php
}