Beispiel #1
0
 function showBehaviorForm($ID, $options = array())
 {
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check($ID, CREATE);
         $use_cache = false;
         $this->getEmpty();
     }
     $this->fields['id'] = $ID;
     $right_name = PluginGenericobjectProfile::getProfileNameForItemtype(__CLASS__);
     $canedit = Session::haveRight($right_name, UPDATE);
     self::includeLocales($this->fields["name"]);
     self::includeConstants($this->fields["name"]);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Internal identifier", "genericobject") . "</td>";
     echo "<td>";
     if (!$ID) {
         Html::autocompletionTextField($this, 'name', array('value' => $this->fields["name"]));
     } else {
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo $this->fields["name"];
     }
     echo "</td>";
     echo "<td></td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Label") . "</td>";
     echo "<td>";
     if ($ID) {
         $itemtype = $this->fields["itemtype"];
         echo $itemtype::getTypeName();
     }
     echo "</td>";
     echo "<td rowspan='3' class='middle right'>" . __("Comments") . "&nbsp;: </td>";
     echo "<td class='center middle' rowspan='3'><textarea cols='45' rows='4'\n             name='comment' >" . $this->fields["comment"] . "</textarea></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Active") . "</td>";
     echo "<td>";
     if (!$ID) {
         echo __("No");
     } else {
         Dropdown::showYesNo("is_active", $this->fields["is_active"]);
     }
     echo "</td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Family of type of objects", 'genericobject') . "</td>";
     echo "<td>";
     PluginGenericobjectTypeFamily::dropdown(array('value' => $this->fields["plugin_genericobject_typefamilies_id"]));
     echo "</td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     if (!$this->isNewID($ID)) {
         $canedit = $this->can($ID, CREATE);
         echo "<tr class='tab_bg_1'><th colspan='4'>";
         echo __("Behaviour", "genericobject");
         echo "</th></tr>";
         $use = array("use_recursivity" => __("Child entities"), "use_tickets" => __("Assistance"), "use_deleted" => __("Item in the dustbin"), "use_notepad" => _n('Note', 'Notes', 2), "use_history" => __("Historical"), "use_template" => __("Templates"), "use_infocoms" => __("Financial and administratives information"), "use_contracts" => _n("Contract", "Contracts", 2), "use_documents" => _n("Document", "Documents", 2), "use_loans" => _n("Reservation", "Reservations", 2), "use_global_search" => __("Global search"), "use_projects" => _n("Project", "Projects", 2), "use_network_ports" => __("Network connections", "genericobject"));
         $plugins = array("use_plugin_datainjection" => __("injection file plugin", "genericobject"), "use_plugin_geninventorynumber" => __("geninventorynumber plugin", "genericobject"), "use_plugin_order" => __("order plugin", "genericobject"), "use_plugin_uninstall" => __("item's uninstallation plugin", "genericobject"), "use_plugin_simcard" => __("simcard plugin", "genericobject"));
         $plugin = new Plugin();
         $odd = 0;
         foreach ($use as $right => $label) {
             if (!$odd) {
                 echo "<tr class='tab_bg_2'>";
             }
             echo "<td>" . _sx('button', 'Use') . " " . $label . "</td>";
             echo "<td>";
             switch ($right) {
                 case 'use_deleted':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canBeDeleted()));
                     break;
                 case 'use_recursivity':
                     Html::showCheckbox(array('name' => $right, 'value' => $this->canBeRecursive(), 'checked' => $this->canBeRecursive()));
                     break;
                 case 'use_notes':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canUseNotepad()));
                     break;
                 case 'use_template':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canUseTemplate()));
                     break;
                 default:
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     break;
             }
             echo "</td>";
             if ($odd == 1) {
                 $odd = 0;
                 echo "</tr>";
             } else {
                 $odd++;
             }
         }
         if ($odd != 0) {
             echo "<td></td></tr>";
         }
         echo "<tr class='tab_bg_1'><th colspan='4'>";
         echo _n("Plugin", "Plugins", 2);
         echo "</th></tr>";
         $odd = 0;
         foreach ($plugins as $right => $label) {
             if (!$odd) {
                 echo "<tr class='tab_bg_2'>";
             }
             echo "<td>" . _sx('button', 'Use') . " " . $label . "</td>";
             echo "<td>";
             switch ($right) {
                 case 'use_plugin_datainjection':
                     if ($plugin->isActivated('datainjection')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_datainjection' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_pdf':
                     if ($plugin->isActivated('pdf')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_pdf' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_order':
                     if ($plugin->isActivated('order')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_order' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_uninstall':
                     if ($plugin->isActivated('uninstall')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_uninstall' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_simcard':
                     if ($plugin->isActivated('simcard')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_simcard' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_geninventorynumber':
                     if ($plugin->isActivated('geninventorynumber')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_geninventorynumber' value='0'>\n";
                     }
                     break;
             }
             echo "</td>";
             if ($odd == 1) {
                 $odd = 0;
                 echo "</tr>";
             } else {
                 $odd++;
             }
         }
         if ($odd != 0) {
             echo "<td></td></tr>";
         }
     }
     $this->showFormButtons($options);
 }