/** * @since version 0.85 * * @see CommonDBTM::showMassiveActionsSubForm() **/ static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { case 'duplicate': Entity::dropdown(); echo "<br><br>"; echo Html::submit(_x('button', 'Duplicate'), array('name' => 'massiveaction')) . "</span>"; return true; case 'addholiday': Holiday::dropdown(); echo "<br><br>"; echo Html::submit(_x('button', 'Add'), array('name' => 'massiveaction')) . "</span>"; return true; } return parent::showMassiveActionsSubForm($ma); }
/** * Show holidays for a calendar * * @param $calendar Calendar object **/ static function showForCalendar(Calendar $calendar) { global $DB, $CFG_GLPI; $ID = $calendar->getField('id'); if (!$calendar->can($ID, 'r')) { return false; } $canedit = $calendar->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_calendars_holidays`.`id` AS linkID,\n `glpi_holidays`.*\n FROM `glpi_calendars_holidays`\n LEFT JOIN `glpi_holidays`\n ON (`glpi_calendars_holidays`.`holidays_id` = `glpi_holidays`.`id`)\n WHERE `glpi_calendars_holidays`.`calendars_id` = '{$ID}'\n ORDER BY `glpi_holidays`.`name`"; $result = $DB->query($query); $holidays = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $holidays[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n action='"; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a close time') . "</tr>"; echo "<tr class='tab_bg_2'><td class='right' colspan='4'>"; echo "<input type='hidden' name='calendars_id' value='{$ID}'>"; Holiday::dropdown(array('used' => $used, 'entity' => $calendar->fields["entities_id"])); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $numrows); Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Start') . "</th>"; echo "<th>" . __('End') . "</th>"; echo "<th>" . __('Recurrent') . "</th>"; echo "</tr>"; $used = array(); if ($numrows) { Session::initNavigateListItems('Holiday', sprintf(__('%1$s = %2$s'), Calendar::getTypeName(1), $calendar->fields["name"])); foreach ($holidays as $data) { Session::addToNavigateListItems('Holiday', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td><a href='" . Toolbox::getItemTypeFormURL('Holiday') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>"; echo "<td>" . Html::convDate($data["begin_date"]) . "</td>"; echo "<td>" . Html::convDate($data["end_date"]) . "</td>"; echo "<td>" . Dropdown::getYesNo($data["is_perpetual"]) . "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $numrows) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }