Ejemplo n.º 1
0
function plugin_connections_MassiveActionsProcess($data)
{
    $PluginConnectionsConnection = new PluginConnectionsConnection();
    $PluginConnectionsConnection_Item = new PluginConnectionsConnection_Item();
    switch ($data['action']) {
        case "plugin_connections_add_item":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $input = array('plugin_connections_connections_id' => $data['plugin_connections_connections_id'], 'items_id' => $key, 'itemtype' => $data['itemtype']);
                    if ($PluginConnectionsConnection_Item->can(-1, UPDATE, $input)) {
                        $PluginConnectionsConnection_Item->add($input);
                    }
                }
            }
            break;
        case "plugin_connections_install":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $input = array('plugin_connections_connections_id' => $key, 'items_id' => $data["item_item"], 'itemtype' => $data['itemtype']);
                    if ($PluginConnectionsConnection_Item->can(-1, UPDATE, $input)) {
                        $PluginConnectionsConnection_Item->add($input);
                    }
                }
            }
            break;
        case "plugin_connections_desinstall":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $PluginConnectionsConnection_Item->deleteItemByConnectionsAndItem($key, $data['item_item'], $data['itemtype']);
                }
            }
            break;
        case "plugin_connections_transfert":
            if ($data['itemtype'] == 'PluginConnectionsConnection') {
                foreach ($data["item"] as $key => $val) {
                    if ($val == 1) {
                        $PluginConnectionsConnection->getFromDB($key);
                        $type = PluginConnectionsConnectionType::transfer($PluginConnectionsConnection->fields["plugin_connections_connections_id"], $data['entities_id']);
                        $values["id"] = $key;
                        $values["plugin_connections_connections_id"] = $type;
                        $values["entities_id"] = $data['entities_id'];
                        $PluginConnectionsConnection->update($values);
                    }
                }
            }
            break;
    }
}
Ejemplo n.º 2
0
 public function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->canView()) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, UPDATE);
         $this->getEmpty();
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . " : </td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Other') . " : </td>";
     echo "<td>";
     Html::autocompletionTextField($this, "others");
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Supplier') . " : </td>";
     echo "<td>";
     Supplier::dropdown(array('name' => "suppliers_id", 'value' => $this->fields["suppliers_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Rates', 'connections') . " : </td>";
     echo "<td>";
     PluginConnectionsConnectionRate::dropdown(array('name' => "plugin_connections_connectionrates_id", 'value' => $this->fields["plugin_connections_connectionrates_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Type of Connections', 'connections') . " : </td><td>";
     PluginConnectionsConnectionType::dropdown(array('name' => "plugin_connections_connectiontypes_id", 'value' => $this->fields["plugin_connections_connectiontypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Guaranteed Rates', 'connections') . " : </td>";
     echo "<td>";
     PluginConnectionsGuaranteedConnectionRate::dropdown(array('name' => "plugin_connections_guaranteedconnectionrates_id", 'value' => $this->fields["plugin_connections_guaranteedconnectionrates_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . " : </td><td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Associable to a ticket') . " :</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . " : </td><td>";
     Group::dropdown(array('name' => "groups_id", 'value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Last update') . " : </td>";
     echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Comments') . " : </td>";
     echo "<td class='center' colspan='3'>";
     echo "<textarea cols='35' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }