/** * Display the budget form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * *@return boolean item found **/ function showForm($ID, $options = array("")) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name", array('value' => $this->fields["name"])); echo "</td>"; echo "<td>" . __('Budget volume', 'resources') . "</td>"; echo "<td>"; Dropdown::show('PluginResourcesBudgetType', array('value' => $this->fields["plugin_resources_budgettypes_id"], 'entity' => $this->fields["entities_id"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Profession', 'resources') . "</td>"; echo "<td>"; $params = array('name' => 'plugin_resources_professions_id', 'value' => $this->fields['plugin_resources_professions_id'], 'entityt' => $this->fields["entities_id"], 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownRank.php", 'span' => 'span_rank', 'sort' => true); PluginResourcesResource::showGenericDropdown('PluginResourcesProfession', $params); echo "</td>"; echo "<td>" . __('Rank', 'resources') . "</td><td>"; echo "<span id='span_rank' name='span_rank'>"; if ($this->fields["plugin_resources_ranks_id"] > 0) { echo Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->fields["plugin_resources_ranks_id"]); } else { _e('None'); } echo "</span></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Budget volume', 'resources') . "</td>"; echo "<td>"; $options = array('value' => 0); Html::autocompletionTextField($this, 'volume', $options); echo "</td><td>" . __('Type of budget volume', 'resources') . "</td><td>"; Dropdown::show('PluginResourcesBudgetVolume', array('value' => $this->fields["plugin_resources_budgetvolumes_id"], 'entity' => $this->fields["entities_id"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Begin date') . "</td>"; echo "<td>"; Html::showDateFormItem("begin_date", $this->fields["begin_date"], true, true); echo "</td>"; echo "<td>" . __('End date') . "</td>"; echo "<td>"; Html::showDateFormItem("end_date", $this->fields["end_date"], true, true); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center' colspan='6'>"; printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); echo "</td>"; echo "</tr>"; if ($_SESSION['glpiactiveprofile']['interface'] != 'central') { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }
function showForm($plugin_resources_resources_id, $users_id, $withtemplate = '') { global $CFG_GLPI; if (!$this->canView()) { return false; } $employee_spotted = false; $resource = new PluginResourcesResource(); $restrict = "`plugin_resources_resources_id` = '{$plugin_resources_resources_id}'"; $employees = getAllDatasFromTable($this->getTable(), $restrict); $canedit = $resource->can($plugin_resources_resources_id, 'w'); $ID = 0; if (!empty($employees)) { foreach ($employees as $employer) { $ID = $employer["id"]; } } if (empty($ID)) { if ($this->getEmpty()) { $employee_spotted = true; } } else { if ($this->getfromDB($ID)) { $employee_spotted = true; } } if ($employee_spotted) { echo "<div align='center'>"; if ($withtemplate < 2) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php\">"; } if (!empty($plugin_resources_resources_id)) { $resource->getFromDB($plugin_resources_resources_id); $entity = $resource->fields["entities_id"]; } else { $entity = $_SESSION["glpiactive_entity"]; } echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . self::getTypeName(1) . "</th></tr>"; if (empty($plugin_resources_resources_id)) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>" . __('The resource is also created if not existent', 'resources'); echo "</td></tr>"; } echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; echo "<input type='hidden' name='plugin_resources_resources_id' value='{$plugin_resources_resources_id}'>"; echo PluginResourcesEmployer::getTypeName(1) . "</td>"; echo "<td colspan='2'>"; $params = array('name' => 'plugin_resources_employers_id', 'value' => $this->fields['plugin_resources_employers_id'], 'entity' => $entity, 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownLocation.php", 'span' => 'span_location'); PluginResourcesResource::showGenericDropdown('PluginResourcesEmployer', $params); echo "</td></tr>"; $locationId = 0; if ($this->fields["plugin_resources_employers_id"] > 0) { $employer = new PluginResourcesEmployer(); $employer->getFromDB($this->fields["plugin_resources_employers_id"]); $locationId = $employer->fields["locations_id"]; } echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; _e('Address'); echo "</td><td>"; echo "<span id='span_location' name='span_location'>"; if ($locationId > 0) { echo Dropdown::getDropdownName('glpi_locations', $locationId); } else { _e('None'); } echo "</span>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; echo PluginResourcesClient::getTypeName(1) . "</td>"; echo "<td colspan='2'>"; Dropdown::show('PluginResourcesClient', array('value' => $this->fields["plugin_resources_clients_id"], 'entity' => $entity)); echo "</td></tr>"; echo "<tr>"; echo "<td class='tab_bg_2 top' colspan='4'>"; if ($withtemplate < 2) { if (empty($ID)) { if ($this->canCreate() && $canedit) { echo "<input type='hidden' name='plugin_resources_resources_id' value=\"" . $plugin_resources_resources_id . "\">"; if (!empty($plugin_resources_resources_id)) { echo "<div align='center'>"; echo "<input type='submit' name='addemployee' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</div>"; } else { echo "<div align='center'>"; $resource->dropdownTemplate("templates_id", $_SESSION["glpiactive_entity"]); echo "<input type='hidden' name='users_id' value='{$users_id}'>"; echo " <input type='submit' name='addressourceandemployee' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</div>"; } } } else { if ($this->canCreate() && $canedit) { echo "<input type='hidden' name='id' value=\"{$ID}\">"; echo "<input type='hidden' name='plugin_resources_resources_id' value=\"" . $this->fields["plugin_resources_resources_id"] . "\">"; echo "<div align='center'>"; echo "<input type='submit' name='updateemployee' value=\"" . _sx('button', 'Update') . "\" class='submit' > "; echo " <input type='submit' name='deleteemployee' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>"; echo "</div>"; } } } echo "</td>"; echo "</tr>"; echo "</table>"; if ($withtemplate < 2) { Html::closeForm(); } echo "</div>"; } }
/** * Display the cost's form * * @param $ID * @param array $options * @return bool */ function showForm($ID, $options = array("")) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showTabs($options); $this->showFormHeader($options); $fields = $this->getAdditionalFields(); $nb = count($fields); echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>"; echo __('Comments') . "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>\n <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Profession', 'resources') . "</td>"; echo "<td>"; $params = array('name' => 'plugin_resources_professions_id', 'value' => $this->fields['plugin_resources_professions_id'], 'entity' => $this->fields["entities_id"], 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownRank.php", 'span' => 'span_rank', 'sort' => false); PluginResourcesResource::showGenericDropdown('PluginResourcesProfession', $params); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Rank', 'resources') . "</td><td>"; echo "<span id='span_rank' name='span_rank'>"; if ($this->fields["plugin_resources_ranks_id"] > 0) { echo Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->fields["plugin_resources_ranks_id"]); } else { _e('None'); } echo "</span></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Begin date') . "</td>"; echo "<td>"; Html::showDateFormItem("begin_date", $this->fields["begin_date"], true, true); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('End date') . "</td>"; echo "<td>"; Html::showDateFormItem("end_date", $this->fields["end_date"], true, true); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Budget cost', 'resources') . "</td>"; echo "<td>"; echo "<input type='text' name='cost' value='" . Html::formatNumber($this->fields["cost"], true) . "' size='14'></td></tr>"; if (isset($this->fields['is_protected']) && $this->fields['is_protected']) { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }