Planning::showAddEventForm PHP Method

showAddEventForm() static public method

static public showAddEventForm ( $params = [] )
    static function showAddEventForm($params = array())
    {
        global $CFG_GLPI;
        if (count($CFG_GLPI['planning_add_types']) == 1) {
            $params['itemtype'] = $CFG_GLPI['planning_add_types'][0];
            self::showAddEventSubForm($params);
        } else {
            $rand = mt_rand();
            $select_options = array();
            foreach ($CFG_GLPI['planning_add_types'] as $add_types) {
                $select_options[$add_types] = $add_types::getTypeName(1);
            }
            echo __("Event type") . " : <br>";
            Dropdown::showFromArray('itemtype', $select_options, array('display_emptychoice' => true, 'rand' => $rand));
            echo Html::scriptBlock("\n         \$(document).ready(function() {\n            \$('#dropdown_itemtype{$rand}').on('change', function() {\n               var current_itemtype = \$(this).val();\n               \$('#add_planning_subform{$rand}').load('" . $CFG_GLPI['root_doc'] . "/ajax/planning.php',\n                                                    {action:   'add_event_sub_form',\n                                                     itemtype: current_itemtype,\n                                                     begin:    '" . $params['begin'] . "',\n                                                     end:      '" . $params['end'] . "'});\n            });\n         });");
            echo "<br><br>";
            echo "<div id='add_planning_subform{$rand}'></div>";
        }
    }

Usage Example

Ejemplo n.º 1
0
if (!isset($_REQUEST["action"])) {
    exit;
}
if ($_REQUEST["action"] == "get_events") {
    header("Content-Type: application/json; charset=UTF-8");
    echo json_encode(Planning::constructEventsArray($_REQUEST));
    exit;
}
if ($_REQUEST["action"] == "update_event_times") {
    echo Planning::updateEventTimes($_REQUEST);
    exit;
}
Html::header_nocache();
header("Content-Type: text/html; charset=UTF-8");
if ($_REQUEST["action"] == "add_event_fromselect") {
    Planning::showAddEventForm($_REQUEST);
}
if ($_REQUEST["action"] == "add_event_sub_form") {
    Planning::showAddEventSubForm($_REQUEST);
}
if ($_REQUEST["action"] == "add_planning_form") {
    Planning::showAddPlanningForm();
}
if ($_REQUEST["action"] == "add_user_form") {
    Planning::showAddUserForm();
}
if ($_REQUEST["action"] == "add_group_users_form") {
    Planning::showAddGroupUsersForm();
}
if ($_REQUEST["action"] == "add_group_form") {
    Planning::showAddGroupForm();