/** * Show wizard form of the current step */ function showWizard($step) { echo "<div class='badges_wizard'>"; echo "<form name='wizard_form' id='badges_wizardForm'\n method='post'>"; switch ($step) { case 'badgerequest': $badgerequest = new PluginBadgesRequest(); $badgerequest->showBadgeRequest(); break; case 'badgereturn': $badgereturn = new PluginBadgesReturn(); $badgereturn->showBadgeReturn(); break; } Html::closeForm(); echo "</div>"; }
/** * Display tab for each users * * @param CommonGLPI $item * @param int $withtemplate * @return array|string */ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (!$withtemplate) { if ($item->getType() == 'PluginBadgesBadge') { if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(PluginBadgesRequest::getTypeName(), countElementsInTable($this->getTable(), "`badges_id` = '" . $item->getID() . "'")); } return PluginBadgesRequest::getTypeName(); } } return ''; }
/** * Show badge request */ function showBadgeRequest() { global $CFG_GLPI; $request = new PluginBadgesRequest(); $request->getEmpty(); // Init badge cart javascript echo "<script type='text/javascript'>"; echo "var badges = \$(document).badges(" . json_encode(array('root_doc' => $CFG_GLPI['root_doc'])) . ");"; echo "</script>"; // Wizard title echo "<div class='badges_wizard_title'><p>"; echo "<img class='badges_wizard_img' src='" . $CFG_GLPI['root_doc'] . "/plugins/badges/pics/badgerequest.png' alt='badgerequest'/> "; _e("Access badge request", "badges"); echo "</p></div>"; // Add badges request echo "<table class='tab_cadre_fixe badges_wizard_rank'>"; echo "<tr>"; echo "<th colspan='4'>" . __("Access badge request", "badges") . "</th>"; echo "</tr>"; echo "<tr>"; echo "<td>" . __("Visitor firstname", "badges") . " <span class='red'>*</span></td>"; echo "<td>"; html::autocompletionTextField($request, "visitor_firstname", array('name' => "visitor_firstname")); echo "</td>"; echo "<td>" . __("Visitor realname", "badges") . " <span class='red'>*</span></td>"; echo "<td>"; html::autocompletionTextField($request, "visitor_realname", array('name' => "visitor_realname")); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>" . __("Visitor society", "badges") . " <span class='red'>*</span></td>"; echo "<td>"; html::autocompletionTextField($request, "visitor_society", array('name' => "visitor_society")); echo "</td>"; echo "<td>" . _n("Available badge", "Availabe badges", 2, "badges") . " <span class='red'>*</span></td>"; echo "<td id='badges_available'>"; $this->loadAvailableBadges(); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>" . __("Arrival date", "badges") . " <span class='red'>*</span></td>"; echo "<td>"; html::showDateTimeField("affectation_date", array('value' => date('Y-m-d H:i:s'))); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='center' colspan='4'>"; echo "<input type=\"button\" class=\"submit\" name=\"addToCart\" onclick=\"badges.badges_addToCart('addToCart','badges_wizardForm', 'badges_cart');\" value=\"" . __('Add to cart', 'badges') . "\">"; echo "</td>"; echo "</tr>"; echo "</table>"; // Cart echo "<br><div class='center'>"; echo "<table class='tab_cadre_fixe badges_wizard_rank' id='badges_cart' style='display:none'>"; echo "<tr><th colspan='6'>" . __("Cart", "badges") . "</th></tr>"; echo "<tr>"; echo "<th>" . __("Visitor firstname", "badges") . "</th>"; echo "<th>" . __("Visitor realname", "badges") . "</th>"; echo "<th>" . __("Visitor society", "badges") . "</th>"; echo "<th>" . _n("Badge", "Badges", 2, "badges") . "</th>"; echo "<th>" . __("Arrival date", "badges") . "</th>"; echo "<th></th>"; echo "</tr>"; echo "</table>"; echo "</div>"; // Footer echo "<br/><table width='100%'>"; echo "<tr>"; echo "<td class='badges_wizard_button'>"; echo "<div id='dialog-confirm'></div>"; echo "<input type=\"button\" class=\"submit badge_next_button\" name=\"addBadges\" value=\"" . _sx('button', 'Post') . "\" onclick=\"badges.badges_addBadges('addBadges','badges_wizardForm');\">"; echo "<input type=\"button\" class=\"badge_previous_button submit\" name=\"previous\" value=\"" . _sx('button', 'Cancel') . "\" onclick=\"badges.badges_cancel('" . $CFG_GLPI['root_doc'] . "/plugins/badges/front/wizard.php');\">"; echo "</td>"; echo "</tr>"; echo "</table>"; }
echo json_encode($request->addToCart($_POST)); break; case 'addBadges': header('Content-Type: application/json; charset=UTF-8"'); $request = new PluginBadgesRequest(); echo json_encode($request->addBadges($_POST)); break; case 'reloadAvailableBadges': header("Content-Type: text/html; charset=UTF-8"); $request = new PluginBadgesRequest(); if (!isset($_POST['used'])) { $_POST['used'] = array(); } $request->loadAvailableBadges($_POST['used']); break; case 'loadBadgeInformation': header("Content-Type: text/html; charset=UTF-8"); $return = new PluginBadgesReturn(); $return->loadBadgeInformation(Session::getLoginUserID(), $_POST['badges_id']); break; case 'returnBadges': header('Content-Type: application/json; charset=UTF-8"'); $return = new PluginBadgesReturn(); echo json_encode($return->returnBadge($_POST)); break; case 'searchBadges': header('Content-Type: application/json; charset=UTF-8"'); $request = new PluginBadgesRequest(); echo json_encode($request->listItems($_POST['requesters_id'], $_POST)); break; }