当前位置: 首页>>代码示例>>PHP>>正文


PHP countElementsInTableForEntity函数代码示例

本文整理汇总了PHP中countElementsInTableForEntity函数的典型用法代码示例。如果您正苦于以下问题:PHP countElementsInTableForEntity函数的具体用法?PHP countElementsInTableForEntity怎么用?PHP countElementsInTableForEntity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了countElementsInTableForEntity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showForUser

 /**  Show groups of a user
  *
  * @param $user   User object
  **/
 static function showForUser(User $user)
 {
     global $CFG_GLPI;
     $ID = $user->fields['id'];
     if (!Group::canView() || !$user->can($ID, READ)) {
         return false;
     }
     $canedit = $user->can($ID, UPDATE);
     $rand = mt_rand();
     $groups = self::getUserGroups($ID);
     $used = array();
     if (!empty($groups)) {
         foreach ($groups as $data) {
             $used[$data["id"]] = $data["id"];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='groupuser_form{$rand}' id='groupuser_form{$rand}' method='post'";
         echo " action='" . Toolbox::getItemTypeFormURL('User') . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Associate to a group') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         echo "<input type='hidden' name='users_id' value='{$ID}'>";
         // All entities "edited user" have access
         $strict_entities = Profile_User::getUserEntities($ID, true);
         // Keep only entities "connected user" have access
         foreach ($strict_entities as $key => $val) {
             if (!Session::haveAccessToEntity($val)) {
                 unset($strict_entities[$key]);
             }
         }
         $nb = countElementsInTableForEntity("glpi_groups", $strict_entities, '`is_usergroup`');
         if ($nb > count($used)) {
             Group::dropdown(array('entity' => $strict_entities, 'used' => $used, 'condition' => '`is_usergroup`'));
             echo "</td><td>" . __('Manager') . "</td><td>";
             Dropdown::showYesNo('is_manager');
             echo "</td><td>" . __('Delegatee') . "</td><td>";
             Dropdown::showYesNo('is_userdelegate');
             echo "</td><td class='tab_bg_2 center'>";
             echo "<input type='submit' name='addgroup' value=\"" . _sx('button', 'Add') . "\"\n                   class='submit'>";
         } else {
             _e('None');
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && count($used)) {
         $rand = mt_rand();
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         echo "<input type='hidden' name='users_id' value='" . $user->fields['id'] . "'>";
         $massiveactionparams = array('num_displayed' => count($used), 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && count($used)) {
         $header_begin .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end .= "</th>";
     }
     $header_end .= "<th>" . Group::getTypeName(1) . "</th>";
     $header_end .= "<th>" . __('Dynamic') . "</th>";
     $header_end .= "<th>" . __('Manager') . "</th>";
     $header_end .= "<th>" . __('Delegatee') . "</th></tr>";
     echo $header_begin . $header_top . $header_end;
     $group = new Group();
     if (!empty($groups)) {
         Session::initNavigateListItems('Group', sprintf(__('%1$s = %2$s'), User::getTypeName(1), $user->getName()));
         foreach ($groups as $data) {
             if (!$group->getFromDB($data["id"])) {
                 continue;
             }
             Session::addToNavigateListItems('Group', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit && count($used)) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             $link = $data["completename"];
             if ($_SESSION["glpiis_ids_visible"]) {
                 $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]);
             }
             $href = "<a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $link . "</a>";
             if ($data["is_dynamic"]) {
                 $href = sprintf(__('%1$s (%2$s)'), $href, "<span class='b'>" . __('D') . "</span>");
             }
             echo "<td>" . $group->getLink() . "</td>";
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:group_user.class.php

示例2: getSQLCondition

 /**
  * get SQL condition for filtered dropdown assign groups
  * @param int $tickets_id
  * @param int $itilcategories_id
  * @return string
  */
 static function getSQLCondition($tickets_id, $itilcategories_id)
 {
     $ticket = new Ticket();
     $group = new Group();
     $params = array('entities_id' => $_SESSION['glpiactive_entity'], 'is_recursive' => 1);
     if (!empty($tickets_id) && $ticket->getFromDB($tickets_id)) {
         // == UPDATE EXISTING TICKET ==
         $params['entities_id'] = $ticket->fields['entities_id'];
         $params['condition'] = " AND " . ($ticket->fields['type'] == Ticket::DEMAND_TYPE ? "`is_request`='1'" : "`is_incident`='1'");
     }
     $found_groups = self::getGroupsForCategory($itilcategories_id, $params);
     $groups_id_toshow = array();
     //init
     if (!empty($found_groups)) {
         for ($lvl = 1; $lvl <= 4; $lvl++) {
             if (isset($found_groups['groups_id_level' . $lvl])) {
                 if ($found_groups['groups_id_level' . $lvl] === "all") {
                     foreach (PluginItilcategorygroupsGroup_Level::getAllGroupForALevel($lvl, $params['entities_id']) as $groups_id) {
                         if ($group->getFromDB($groups_id)) {
                             $groups_id_toshow[] = $group->getID();
                         }
                     }
                 } else {
                     foreach ($found_groups['groups_id_level' . $lvl] as $groups_id) {
                         if (countElementsInTableForEntity("glpi_groups", $ticket->getEntityID(), "`id`='{$groups_id}'") > 0) {
                             $group->getFromDB($groups_id);
                             $groups_id_toshow[] = $group->getID();
                         }
                     }
                 }
             }
         }
     }
     $condition = "";
     if (count($groups_id_toshow) > 0) {
         // transform found groups (2 dimensions) in a flat array
         $groups_id_toshow_flat = array();
         array_walk_recursive($groups_id_toshow, function ($v, $k) use(&$groups_id_toshow_flat) {
             array_push($groups_id_toshow_flat, $v);
         });
         $newarray = implode(", ", $groups_id_toshow_flat);
         $condition = " id IN ({$newarray})";
     }
     return $condition;
 }
开发者ID:erchbox,项目名称:itilcategorygroups,代码行数:51,代码来源:category.class.php

示例3: testCountElementsInTableForEntity

 /**
  * @covers ::countElementsInTableForEntity
  */
 public function testCountElementsInTableForEntity()
 {
     $e = getItemByTypeName('Entity', '_test_child_1', true);
     $this->assertEquals(2, countElementsInTableForEntity('glpi_computers', $e));
     $this->assertEquals(1, countElementsInTableForEntity('glpi_computers', $e, 'name="_test_pc11"'));
     $this->assertEquals(0, countElementsInTableForEntity('glpi_computers', $e, 'name="_test_pc01"'));
     $e = getItemByTypeName('Entity', '_test_root_entity', true);
     $this->assertEquals(1, countElementsInTableForEntity('glpi_computers', $e, 'name="_test_pc01"'));
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:12,代码来源:DbFunctionTest.php

示例4: transfer

 public function transfer($ID, $entity)
 {
     global $DB;
     if ($ID <= 0 || !$this->getFromDB($ID)) {
         return 0;
     }
     //If reference is not visible in the target entity : transfer it!
     if (!countElementsInTableForEntity($this->getTable(), $entity, "`id`='" . $this->getID() . "'")) {
         $input = $this->fields;
         $input['entities_id'] = $entity;
         $oldref = $input['id'];
         unset($input['id']);
         $input['transfert'] = 1;
         $newid = $this->add($input);
         $reference_supplier = new PluginOrderReference_Supplier();
         $reference_supplier->getFromDBByReference($oldref);
         $input = $reference_supplier->fields;
         $input['entities_id'] = $entity;
         $input['plugin_order_references_id'] = $newid;
         unset($input['id']);
         $reference_supplier->add($input);
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $query = "SELECT `id`\n                   FROM `glpi_plugin_order_orders_items`\n                   WHERE `plugin_order_references_id` = '{$oldref}'";
         $result = $DB->query($query);
         $num = $DB->numrows($result);
         if ($num) {
             while ($dataref = $DB->fetch_array($result)) {
                 $values["id"] = $dataref['id'];
                 $values["plugin_order_references_id"] = $newid;
                 $PluginOrderOrder_Item->update($values);
             }
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:34,代码来源:reference.class.php

示例5: show


//.........这里部分代码省略.........
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $output = '';
     $name = $params['emptylabel'];
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     // Check default value for dropdown : need to be a numeric
     if (strlen($params['value']) == 0 || !is_numeric($params['value'])) {
         $params['value'] = 0;
     }
     if ($params['value'] > 0 || $itemtype == "Entity" && $params['value'] >= 0) {
         $tmpname = self::getDropdownName($table, $params['value'], 1);
         if ($tmpname["name"] != "&nbsp;") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             if (Toolbox::strlen($name) > $_SESSION["glpidropdown_chars_limit"]) {
                 if ($item instanceof CommonTreeDropdown) {
                     $pos = strrpos($name, ">");
                     $limit_length = max(Toolbox::strlen($name) - $pos, $_SESSION["glpidropdown_chars_limit"]);
                     if (Toolbox::strlen($name) > $limit_length) {
                         $name = "&hellip;" . Toolbox::substr($name, -$limit_length);
                     }
                 } else {
                     $limit_length = Toolbox::strlen($name);
                 }
             } else {
                 $limit_length = $_SESSION["glpidropdown_chars_limit"];
             }
         }
     }
     // Manage entity_sons
     if (!($params['entity'] < 0) && $params['entity_sons']) {
         if (is_array($params['entity'])) {
             // translation not needed - only for debug
             $output .= "entity_sons options is not available with entity option as array";
         } else {
             $params['entity'] = getSonsOf('glpi_entities', $params['entity']);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $nb = 0;
         if ($item->isEntityAssign()) {
             if (!($params['entity'] < 0)) {
                 $nb = countElementsInTableForEntity($table, $params['entity'], $params['condition']);
             } else {
                 $nb = countElementsInTableForMyEntities($table, $params['condition']);
             }
         } else {
             $nb = countElementsInTable($table, $params['condition']);
         }
         $nb -= count($params['used']);
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $param = array('searchText' => '__VALUE__', 'value' => $params['value'], 'itemtype' => $itemtype, 'myname' => $params['name'], 'limit' => $limit_length, 'toadd' => $params['toadd'], 'comment' => $params['comments'], 'rand' => $params['rand'], 'entity_restrict' => $params['entity'], 'update_item' => $params['toupdate'], 'used' => $params['used'], 'on_change' => $params['on_change'], 'condition' => $params['condition'], 'emptylabel' => $params['emptylabel'], 'display_emptychoice' => $params['display_emptychoice'], 'displaywith' => $params['displaywith'], 'display' => false, 'permit_select_parent' => $params['permit_select_parent']);
     if ($item->canView()) {
         $param['update_link'] = 1;
     }
     $default = "<select name='" . $params['name'] . "' id='dropdown_" . $params['name'] . $params['rand'] . "'>";
     $default .= "<option value='" . $params['value'] . "'>{$name}</option></select>";
     $output .= Ajax::dropdown($use_ajax, "/ajax/dropdownValue.php", $param, $default, $params['rand'], false);
     // Display comment
     if ($params['comments']) {
         $options_tooltip = array('contentid' => "comment_" . $params['name'] . $params['rand'], 'display' => false);
         if ($item->canView()) {
             if ($params['value'] && $item->getFromDB($params['value']) && $item->canViewItem()) {
                 $options_tooltip['link'] = $item->getLinkURL();
             } else {
                 $options_tooltip['link'] = $item->getSearchURL();
             }
             $options_tooltip['linkid'] = "comment_link_" . $params['name'] . $params['rand'];
             $options_tooltip['linktarget'] = '_blank';
         }
         $output .= Html::showToolTip($comment, $options_tooltip);
         if ($item instanceof CommonDropdown && $item->canCreate() && !isset($_GET['popup'])) {
             $output .= "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n                            onClick=\"var w = window.open('" . $item->getFormURL() . "?popup=1&amp;rand=" . $params['rand'] . "' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
         }
         // Display specific Links
         if ($itemtype == "Supplier") {
             if ($item->getFromDB($params['value'])) {
                 $output .= $item->getLinks();
             }
         }
         if ($itemtype == 'ITILCategory' && Session::haveRight('knowbase', 'r')) {
             if ($params['value'] && $item->getFromDB($params['value'])) {
                 $output .= '&nbsp;' . $item->getLinks();
             }
         }
     }
     if ($params['display']) {
         echo $output;
         return $params['rand'];
     } else {
         return $output;
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:dropdown.class.php

示例6: dropdownNetpoint

 /**
  * Print out an HTML "<select>" for a dropdown with preselected value
  *
  * @param $myname             the name of the HTML select
  * @param $value              the preselected value we want (default 0)
  * @param $locations_id       default location ID for search (default -1)
  * @param $display_comment    display the comment near the dropdown (default 1)
  * @param $entity_restrict    Restrict to a defined entity(default -1)
  * @param $devtype            (default '')
  *
  * @return nothing (display the select box)
  **/
 static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = '')
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $name = Dropdown::EMPTY_VALUE;
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     if (empty($value)) {
         $value = 0;
     }
     if ($value > 0) {
         $tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1);
         if ($tmpname["name"] != "&nbsp;") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             $limit_length = max(Toolbox::strlen($name), $_SESSION["glpidropdown_chars_limit"]);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         if ($locations_id < 0 || $devtype == 'NetworkEquipment') {
             $nb = countElementsInTableForEntity("glpi_netpoints", $entity_restrict);
         } else {
             if ($locations_id > 0) {
                 $nb = countElementsInTable("glpi_netpoints", "locations_id={$locations_id} ");
             } else {
                 $nb = countElementsInTable("glpi_netpoints", "locations_id=0 " . getEntitiesRestrictRequest(" AND ", "glpi_netpoints", '', $entity_restrict));
             }
         }
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $params = array('searchText' => '__VALUE__', 'value' => $value, 'locations_id' => $locations_id, 'myname' => $myname, 'limit' => $limit_length, 'comment' => $display_comment, 'rand' => $rand, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype);
     $default = "<select name='{$myname}'><option value='{$value}'>{$name}</option></select>";
     Ajax::dropdown($use_ajax, "/ajax/dropdownNetpoint.php", $params, $default, $rand);
     // Display comment
     if ($display_comment) {
         Html::showToolTip($comment);
         $item = new self();
         if ($item->canCreate()) {
             echo "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"var w = window.open('" . $item->getFormURL() . "?popup=1&amp;rand={$rand}' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
         }
     }
     return $rand;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:58,代码来源:netpoint.class.php

示例7: dropdownConnect

 /**
  * Make a select box for connections
  *
  * @param $itemtype               type to connect
  * @param $fromtype               from where the connection is
  * @param $myname                 select name
  * @param $entity_restrict        Restrict to a defined entity (default = -1)
  * @param $onlyglobal             display only global devices (used for templates) (default 0)
  * @param $used             array Already used items ID: not to display in dropdown
  *
  * @return nothing (print out an HTML select box)
  */
 static function dropdownConnect($itemtype, $fromtype, $myname, $entity_restrict = -1, $onlyglobal = 0, $used = array())
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $nb = 0;
         if ($entity_restrict >= 0) {
             $nb = countElementsInTableForEntity(getTableForItemType($itemtype), $entity_restrict);
         } else {
             $nb = countElementsInTableForMyEntities(getTableForItemType($itemtype));
         }
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $params = array('searchText' => '__VALUE__', 'fromtype' => $fromtype, 'itemtype' => $itemtype, 'myname' => $myname, 'onlyglobal' => $onlyglobal, 'entity_restrict' => $entity_restrict, 'used' => $used);
     $default = "<select name='{$myname}'><option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n                  </select>\n";
     Ajax::dropdown($use_ajax, "/ajax/dropdownConnect.php", $params, $default, $rand);
     return $rand;
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:33,代码来源:computer_item.class.php

示例8: showForItem

 /**
  * Show projet associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated projet must be displayed
  * @param $withtemplate    (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!plugin_projet_haveRight('projet', 'r')) {
         return false;
     }
     if (!$item->can($item->fields['id'], 'r')) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $canedit = $item->canadditem('PluginProjetProjet');
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_plugin_projet_projets_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_projet_projets`.`name` AS assocName,\n                       `glpi_plugin_projet_projets`.*\n                FROM `glpi_plugin_projet_projets_items`\n                LEFT JOIN `glpi_plugin_projet_projets`\n                 ON (`glpi_plugin_projet_projets_items`.`plugin_projet_projets_id`=`glpi_plugin_projet_projets`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_projet_projets`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_projet_projets_items`.`items_id` = '{$ID}'\n                      AND `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_projet_projets", '', '', true);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $projets = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $projets[$data['assocID']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     $projet = new PluginProjetProjet();
     if ($canedit && $withtemplate < 2) {
         // Restrict entity for knowbase
         $entities = "";
         $entity = $_SESSION["glpiactive_entity"];
         if ($item->isEntityAssign()) {
             /// Case of personal items : entity = -1 : create on active entity (Reminder case))
             if ($item->getEntityID() >= 0) {
                 $entity = $item->getEntityID();
             }
             if ($item->isRecursive()) {
                 $entities = getSonsOf('glpi_entities', $entity);
             } else {
                 $entities = $entity;
             }
         }
         $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_projets", '', $entities, true);
         $q = "SELECT COUNT(*)\n               FROM `glpi_plugin_projet_projets`\n               WHERE `is_deleted` = '0'\n               AND `is_template` = '0' ";
         if ($item->getType() != 'User') {
             $q .= " {$limit}";
         }
         $result = $DB->query($q);
         $nb = $DB->result($result, 0, 0);
         echo "<div class='firstbloc'>";
         if (plugin_projet_haveRight('projet', 'r') && $nb > count($used)) {
             echo "<form name='projet_form{$rand}' id='projet_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL('PluginProjetProjet') . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='entities_id' value='{$entity}'>";
             echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
             }
             if ($item->getType() != 'User') {
                 $projet->dropdownProjet("plugin_projet_projets_id", $entities, $used);
             } else {
                 $strict_entities = Profile_User::getUserEntities($ID, true);
                 if (!Session::haveAccessToOneOfEntities($strict_entities) && !isViewAllEntities()) {
                     $canedit = false;
                 }
                 if (countElementsInTableForEntity("glpi_plugin_projet_projets", $strict_entities) > count($used)) {
                     Dropdown::show('PluginProjetProjet', array('name' => "plugin_projet_projets_id", 'used' => $used, 'entity' => $strict_entities));
                 }
             }
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a project', 'projet') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:projet_item.class.php

示例9: getDatasForObject


//.........这里部分代码省略.........
     }
     $datas["##{$objettype}.assigntogroups##"] = '';
     if ($item->countGroups(CommonITILActor::ASSIGN)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.assigntogroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.solution.type##"] = '';
     if ($item->getField('solutiontypes_id')) {
         $datas["##{$objettype}.solution.type##"] = Dropdown::getDropdownName('glpi_solutiontypes', $item->getField('solutiontypes_id'));
     }
     $datas["##{$objettype}.solution.description##"] = Toolbox::unclean_cross_side_scripting_deep($item->getField('solution'));
     // Complex mode
     if (!$simple) {
         $datas['log'] = array();
         // Use list_limit_max or load the full history ?
         foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
             $tmp = array();
             $tmp["##{$objettype}.log.date##"] = $data['date_mod'];
             $tmp["##{$objettype}.log.user##"] = $data['user_name'];
             $tmp["##{$objettype}.log.field##"] = $data['field'];
             $tmp["##{$objettype}.log.content##"] = $data['change'];
             $datas['log'][] = $tmp;
         }
         $datas["##{$objettype}.numberoflogs##"] = count($datas['log']);
         // Get unresolved items
         $restrict = "`" . $item->getTable() . "`.`status`\n                        NOT IN ('" . implode("', '", array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray())) . "'\n                               )";
         if ($item->maybeDeleted()) {
             $restrict .= " AND `" . $item->getTable() . "`.`is_deleted` = '0' ";
         }
         $datas["##{$objettype}.numberofunresolved##"] = countElementsInTableForEntity($item->getTable(), $this->getEntity(), $restrict);
         // Document
         $query = "SELECT `glpi_documents`.*\n                   FROM `glpi_documents`\n                   LEFT JOIN `glpi_documents_items`\n                     ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n                   WHERE `glpi_documents_items`.`itemtype` =  '" . $item->getType() . "'\n                         AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
         $datas["documents"] = array();
         $addtodownloadurl = '';
         if ($item->getType() == 'Ticket') {
             $addtodownloadurl = "%2526tickets_id=" . $item->fields['id'];
         }
         if ($result = $DB->query($query)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $tmp = array();
                 $tmp['##document.id##'] = $data['id'];
                 $tmp['##document.name##'] = $data['name'];
                 $tmp['##document.weblink##'] = $data['link'];
                 $tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']);
                 $downloadurl = "/front/document.send.php?docid=" . $data['id'];
                 $tmp['##document.downloadurl##'] = $this->formatURL($options['additionnaloption']['usertype'], $downloadurl . $addtodownloadurl);
                 $tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']);
                 $tmp['##document.filename##'] = $data['filename'];
                 $datas['documents'][] = $tmp;
             }
         }
         $datas["##{$objettype}.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . '_Document_Item$1');
         $datas["##{$objettype}.numberofdocuments##"] = count($datas['documents']);
         //costs infos
         $costtype = $item->getType() . 'Cost';
         $costs = $costtype::getCostsSummary($costtype, $item->getField("id"));
         $datas["##{$objettype}.costfixed##"] = $costs['costfixed'];
         $datas["##{$objettype}.costmaterial##"] = $costs['costmaterial'];
         $datas["##{$objettype}.costtime##"] = $costs['costtime'];
         $datas["##{$objettype}.totalcost##"] = $costs['totalcost'];
         $restrict = "`" . $item->getForeignKeyField() . "`='" . $item->getField('id') . "'";
         $restrict .= " ORDER BY `begin_date` DESC, `id` ASC";
开发者ID:glpi-project,项目名称:glpi,代码行数:67,代码来源:notificationtargetcommonitilobject.class.php

示例10: showForUser

 /**  Show groups of a user
  *
  * @param $user the user
  **/
 static function showForUser(User $user)
 {
     global $CFG_GLPI, $LANG;
     $ID = $user->fields['id'];
     if (!haveRight("group", "r") || !$user->can($ID, 'r')) {
         return false;
     }
     $canedit = $user->can($ID, 'w');
     $rand = mt_rand();
     $nb_per_line = 3;
     if ($canedit) {
         $headerspan = $nb_per_line * 2;
         echo "<form name='groupuser_form{$rand}' id='groupuser_form{$rand}' method='post'";
         echo " action='" . getItemTypeFormURL('User') . "'>";
     } else {
         $headerspan = $nb_per_line;
     }
     $groups = self::getUserGroups($ID);
     $used = array();
     if (!empty($groups)) {
         foreach ($groups as $data) {
             $used[$data["id"]] = $data["id"];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='2'>" . $LANG['setup'][604] . "</th></tr>";
         echo "<tr><td class='tab_bg_2 center'>";
         echo "<input type='hidden' name='users_id' value='{$ID}'>";
         // All entities "edited user" have access
         $strict_entities = Profile_User::getUserEntities($ID, true);
         // Keep only entities "connected user" have access
         foreach ($strict_entities as $key => $val) {
             if (!haveAccessToEntity($val)) {
                 unset($strict_entities[$key]);
             }
         }
         if (countElementsInTableForEntity("glpi_groups", $strict_entities) > count($used)) {
             Dropdown::show('Group', array('entity' => $strict_entities, 'used' => $used));
             echo "</td><td class='tab_bg_2 center'>";
             echo "<input type='submit' name='addgroup' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
         } else {
             echo $LANG['common'][49];
         }
         echo "</td></tr>";
         echo "</table></div>";
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixehov'><tr>";
     echo "<th colspan='{$headerspan}'>" . $LANG['Menu'][36] . "&nbsp;(D=" . $LANG['profiles'][29] . ")</th>";
     echo "</tr>";
     if (!empty($groups)) {
         initNavigateListItems('Group', $user->getTypeName() . " = " . $user->getName());
         $i = 0;
         foreach ($groups as $data) {
             addToNavigateListItems('Group', $data["id"]);
             if ($i % $nb_per_line == 0) {
                 if ($i != 0) {
                     echo "</tr>";
                 }
                 echo "<tr class='tab_bg_1'>";
             }
             if ($canedit) {
                 echo "<td width='10'>";
                 $sel = "";
                 if (isset($_GET["select"]) && $_GET["select"] == "all") {
                     $sel = "checked";
                 }
                 echo "<input type='checkbox' name='item[" . $data["linkID"] . "]' value='1' {$sel}>";
                 echo "</td>";
             }
             echo "<td><a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $data["name"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["id"] . ")" : "") . "</a>";
             echo "&nbsp;";
             if ($data["is_dynamic"]) {
                 echo "<strong>&nbsp;(D)</strong>";
             }
             echo "</td>";
             $i++;
         }
         while ($i % $nb_per_line != 0) {
             if ($canedit) {
                 echo "<td>&nbsp;</td>";
             }
             echo "<td>&nbsp;</td>";
             $i++;
         }
         echo "</tr>";
     } else {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='{$headerspan}' class='center'>" . $LANG['common'][49] . "</td></tr>";
     }
     echo "</table>";
     if ($canedit) {
         if (count($used)) {
             openArrowMassive("groupuser_form{$rand}", true);
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:group_user.class.php

示例11: getDatasForObject


//.........这里部分代码省略.........
             if ($user_tmp->getFromDB($uid)) {
                 $users[$uid] = $user_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntousers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntosupplier##"] = '';
     if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
         $suppliers = array();
         foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['suppliers_id'];
             $supplier_tmp = new Supplier();
             if ($supplier_tmp->getFromDB($uid)) {
                 $suppliers[$uid] = $supplier_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntosupplier##"] = implode(', ', $suppliers);
     }
     $datas["##{$objettype}.groups##"] = '';
     if ($item->countGroups(CommonITILActor::REQUESTER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::REQUESTER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.groups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observergroups##"] = '';
     if ($item->countGroups(CommonITILActor::OBSERVER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::OBSERVER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.observergroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observerusers##"] = '';
     if ($item->countUsers(CommonITILActor::OBSERVER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::OBSERVER) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
             } else {
                 $users[] = $tmp['alternative_email'];
             }
         }
         $datas["##{$objettype}.observerusers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntogroups##"] = '';
     if ($item->countGroups(CommonITILActor::ASSIGN)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.assigntogroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.solution.type##"] = '';
     if ($item->getField('solutiontypes_id')) {
         $datas["##{$objettype}.solution.type##"] = Dropdown::getDropdownName('glpi_solutiontypes', $item->getField('solutiontypes_id'));
     }
     $datas["##{$objettype}.solution.description##"] = Toolbox::unclean_cross_side_scripting_deep($item->getField('solution'));
     $datas['log'] = array();
     // Use list_limit_max or load the full history ?
     foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
         $tmp = array();
         $tmp["##{$objettype}.log.date##"] = $data['date_mod'];
         $tmp["##{$objettype}.log.user##"] = $data['user_name'];
         $tmp["##{$objettype}.log.field##"] = $data['field'];
         $tmp["##{$objettype}.log.content##"] = $data['change'];
         $datas['log'][] = $tmp;
     }
     $datas["##{$objettype}.numberoflogs##"] = count($datas['log']);
     // Get unresolved items
     $restrict = "`" . $item->getTable() . "`.`status`\n                     NOT IN ('" . implode("', '", array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray())) . "'\n                             )";
     if ($item->maybeDeleted()) {
         $restrict .= " AND `" . $item->getTable() . "`.`is_deleted` = '0' ";
     }
     $datas["##{$objettype}.numberofunresolved##"] = countElementsInTableForEntity($item->getTable(), $this->getEntity(), $restrict);
     // Document
     $query = "SELECT `glpi_documents`.*\n                 FROM `glpi_documents`\n                 LEFT JOIN `glpi_documents_items`\n                      ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n                 WHERE `glpi_documents_items`.`itemtype` =  '{$objettype}'\n                       AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
     $datas["documents"] = array();
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_assoc($result)) {
             $tmp = array();
             $tmp['##document.id##'] = $data['id'];
             $tmp['##document.name##'] = $data['name'];
             $tmp['##document.weblink##'] = $data['link'];
             $tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']);
             $tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']);
             $tmp['##document.filename##'] = $data['filename'];
             $datas['documents'][] = $tmp;
         }
     }
     $datas["##{$objettype}.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . '_Document_Item$1');
     $datas["##{$objettype}.numberofdocuments##"] = count($datas['documents']);
     return $datas;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:notificationtargetcommonitilobject.class.php

示例12: showSuppliers

 /**
  * Print the HTML array for entreprises on the current contact
  *
  *@return Nothing (display)
  *
  **/
 function showSuppliers()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, 'r')) {
         return false;
     }
     $canedit = $this->can($instID, 'w');
     $query = "SELECT `glpi_contacts_suppliers`.`id`,\n                       `glpi_suppliers`.`id` AS entID,\n                       `glpi_suppliers`.`name` AS name,\n                       `glpi_suppliers`.`website` AS website,\n                       `glpi_suppliers`.`fax` AS fax,\n                       `glpi_suppliers`.`phonenumber` AS phone,\n                       `glpi_suppliers`.`suppliertypes_id` AS type,\n                       `glpi_suppliers`.`is_deleted`,\n                       `glpi_entities`.`id` AS entity\n                FROM `glpi_contacts_suppliers`, `glpi_suppliers`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n                WHERE `glpi_contacts_suppliers`.`contacts_id` = '{$instID}'\n                      AND `glpi_contacts_suppliers`.`suppliers_id` = `glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n                ORDER BY `glpi_entities`.`completename`, `name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/contact.form.php\">";
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='7'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['financial'][67];
     } else {
         if ($DB->numrows($result) == 1) {
             echo $LANG['financial'][64];
         } else {
             echo $LANG['financial'][65];
         }
     }
     echo "</th></tr>";
     echo "<tr><th>" . $LANG['financial'][26] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['financial'][79] . "</th>";
     echo "<th>" . $LANG['help'][35] . "</th>";
     echo "<th>" . $LANG['financial'][30] . "</th>";
     echo "<th>" . $LANG['financial'][45] . "</th>";
     echo "<th>&nbsp;</th></tr>";
     $used = array();
     if ($number > 0) {
         initNavigateListItems('Supplier', $LANG['common'][92] . " = " . $this->fields['name']);
         while ($data = $DB->fetch_array($result)) {
             $ID = $data["id"];
             addToNavigateListItems('Supplier', $data["entID"]);
             $used[$data["entID"]] = $data["entID"];
             $website = $data["website"];
             if (!empty($website)) {
                 $website = $data["website"];
                 if (!preg_match("?https*://?", $website)) {
                     $website = "http://" . $website;
                 }
                 $website = "<a target=_blank href='{$website}'>" . $data["website"] . "</a>";
             }
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id=" . $data["entID"] . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["entID"]) . "</a></td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
             echo "</td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_suppliertypes", $data["type"]);
             echo "</td>";
             echo "<td class='center' width='80'>" . $data["phone"] . "</td>";
             echo "<td class='center' width='80'>" . $data["fax"] . "</td>";
             echo "<td class='center'>" . $website . "</td>";
             echo "<td class='tab_bg_2 center'>";
             if ($canedit) {
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contact.form.php?deletecontactsupplier=1" . "&amp;id={$ID}&amp;contacts_id={$instID}'><strong>" . $LANG['buttons'][6] . "</strong></a>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td></tr>";
         }
     }
     if ($canedit) {
         if ($this->fields["is_recursive"]) {
             $nb = countElementsInTableForEntity("glpi_suppliers", getSonsOf("glpi_entities", $this->fields["entities_id"]));
         } else {
             $nb = countElementsInTableForEntity("glpi_suppliers", $this->fields["entities_id"]);
         }
         if ($nb > count($used)) {
             echo "<tr class='tab_bg_1'><td>&nbsp;</td><td class='center' colspan='4'>";
             echo "<input type='hidden' name='contacts_id' value='{$instID}'>";
             Dropdown::show('Supplier', array('used' => $used, 'entity' => $this->fields["entities_id"], 'entity_sons' => $this->fields["is_recursive"]));
             echo "&nbsp;&nbsp;<input type='submit' name='addcontactsupplier' value='" . $LANG['buttons'][8] . "' class='submit'>";
             echo "</td><td>&nbsp;</td><td>&nbsp;</td>";
             echo "</tr>";
         }
     }
     echo "</table></div></form>";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:89,代码来源:contact.class.php

示例13: showGenericDropdown

 /**
  * Permet l'affichage dynamique d'une liste déroulante imbriquee
  *
  * @static
  * @param array ($itemtype,$myname,$value,$entity_restrict,$action,$span)
  */
 static function showGenericDropdown($itemtype, $options = array())
 {
     global $DB, $CFG_GLPI;
     $item = getItemForItemtype($itemtype);
     if ($itemtype && !($item = getItemForItemtype($itemtype))) {
         return false;
     }
     $table = $item->getTable();
     /*$options["table"] = $table;
       $options["rand"] = $rand;
       
       $params['name']        = $item->getForeignKeyField();
       $params['value']       = ($itemtype=='Entity' ? $_SESSION['glpiactive_entity'] : '');
       
       $params['entity']      = -1;
       $params['entity_sons'] = false;
       $params['toupdate']    = '';
       $params['used']        = array();
       $params['toadd']       = array();
       $params['on_change']   = '';
       $params['condition']   = '';
       $params['rand']        = mt_rand();
       $params['displaywith'] = array();
       //Parameters about choice 0
       //Empty choice's label
       $params['emptylabel'] = self::EMPTY_VALUE;*/
     $params['comments'] = true;
     $params['condition'] = '';
     $params['entity'] = -1;
     $params['entity_sons'] = false;
     $params['rand'] = mt_rand();
     $params['used'] = array();
     $params['table'] = $table;
     $params['emptylabel'] = Dropdown::EMPTY_VALUE;
     //Display emptychoice ?
     $params['display_emptychoice'] = true;
     //In case of Entity dropdown, display root entity ?
     $params['display_rootentity'] = false;
     //specific
     $params['action'] = "";
     $params['span'] = "";
     $params['sort'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $name = $params['emptylabel'];
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     if (strlen($params['value']) == 0 || !is_numeric($params['value'])) {
         $params['value'] = 0;
     }
     if ($params['value'] > 0) {
         $tmpname = Dropdown::getDropdownName($table, $params['value'], 1);
         if ($tmpname["name"] != "&nbsp;") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             if (Toolbox::strlen($name) > $_SESSION["glpidropdown_chars_limit"]) {
                 if ($item instanceof CommonTreeDropdown) {
                     $pos = strrpos($name, ">");
                     $limit_length = max(Toolbox::strlen($name) - $pos, $_SESSION["glpidropdown_chars_limit"]);
                     if (Toolbox::strlen($name) > $limit_length) {
                         $name = "&hellip;" . Toolbox::substr($name, -$limit_length);
                     }
                 } else {
                     $limit_length = Toolbox::strlen($name);
                 }
             } else {
                 $limit_length = $_SESSION["glpidropdown_chars_limit"];
             }
         }
     }
     // Manage entity_sons
     if (!($params['entity'] < 0) && $params['entity_sons']) {
         if (is_array($params['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $params['entity'] = getSonsOf('glpi_entities', $params['entity']);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $nb = 0;
         if ($item->isEntityAssign()) {
             if (!($params['entity'] < 0)) {
                 $nb = countElementsInTableForEntity($table, $params['entity'], $params['condition']);
             } else {
                 $nb = countElementsInTableForMyEntities($table, $params['condition']);
             }
         } else {
             $nb = countElementsInTable($table, $params['condition']);
         }
         $nb -= count($params['used']);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:resource.class.php

示例14: uninstall

 static function uninstall($type, $model_id, $tab_ids, $location)
 {
     global $UNINSTALL_DIRECT_CONNECTIONS_TYPE;
     //Get the model
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     //Then destroy all the connexions
     $transfer = new Transfer();
     $transfer->getFromDB($model->fields["transfers_id"]);
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'><tr><th>" . __('Uninstall', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>";
     $count = 0;
     $tot = count($tab_ids[$type]);
     Html::createProgressBar(__('Please wait, uninstallation is running...', 'uninstall'));
     foreach ($tab_ids[$type] as $id => $value) {
         $count++;
         $item = new $type();
         $item->getFromDB($id);
         //First clean object and change location and status if needed
         $entity = $item->fields["entities_id"];
         $input = array();
         $input["id"] = $id;
         $input["entities_id"] = $entity;
         $fields = array();
         //Hook to perform actions before item is being uninstalled
         $item->fields['_uninstall_event'] = $model->getID();
         $item->fields['_action'] = 'uninstall';
         Plugin::doHook("plugin_uninstall_before", $item);
         //--------------------//
         //Direct connections //
         //------------------//
         if (in_array($type, $UNINSTALL_DIRECT_CONNECTIONS_TYPE)) {
             $conn = new Computer_Item();
             $conn->deleteByCriteria(array('computers_id' => $id), true);
         }
         //--------------------//
         //-- Common fields --//
         //------------------//
         //RAZ contact and contactnumber
         if ($item->isField('contact') && $model->fields["raz_contact"] == 1) {
             $fields["contact"] = '';
             if ($item->isField('contact_num')) {
                 $fields["contact_num"] = '';
             }
         }
         //RAZ user
         if ($model->fields["raz_user"] == 1 && $item->isField('users_id')) {
             $fields["users_id"] = 0;
         }
         //RAZ status
         if ($model->fields["states_id"] > 0 && $item->isField('states_id')) {
             $fields["states_id"] = $model->fields["states_id"];
         }
         //RAZ machine's name
         if ($item->isField('name') && $model->fields["raz_name"] == 1) {
             $fields["name"] = '';
         }
         if ($item->isField('locations_id')) {
             if ($location == '') {
                 $location = 0;
             }
             switch ($location) {
                 case -1:
                     break;
                 default:
                     $fields["locations_id"] = $location;
                     break;
             }
         }
         if ($item->isField('groups_id')) {
             $nbgroup = countElementsInTableForEntity("glpi_groups", $entity, "`id`='" . $item->fields['groups_id'] . "'");
             if ($model->fields["groups_id"] > -1 && $nbgroup == 1) {
                 // If a new group is defined and if the group is accessible in the object's entity
                 $fields["groups_id"] = $model->fields["groups_id"];
             }
         }
         //------------------------------//
         //-- Computer specific fields --//
         //------------------------------//
         if ($type == 'Computer') {
             //RAZ all OS related informations
             if ($model->fields["raz_os"] == 1) {
                 $fields["operatingsystems_id"] = 0;
                 $fields["operatingsystemversions_id"] = 0;
                 $fields["operatingsystemservicepacks_id"] = 0;
                 $fields["os_licenseid"] = '';
                 $fields["os_license_number"] = '';
                 $fields["autoupdatesystems_id"] = 0;
             }
             $plug = new Plugin();
             if ($plug->isActivated('ocsinventoryng')) {
                 if ($item->fields["is_dynamic"] && ($model->fields["remove_from_ocs"] || $model->fields["delete_ocs_link"])) {
                     $input["is_dynamic"] = 0;
                 }
             }
             if ($item->isField('domains_id') && $model->fields["raz_domain"]) {
                 $fields["domains_id"] = 0;
             }
             //RAZ network
//.........这里部分代码省略.........
开发者ID:pluginsGLPI,项目名称:uninstall,代码行数:101,代码来源:uninstall.class.php

示例15: showContracts

 /**
  * Print an HTML array with contracts associated to the enterprise
  *
  *@return Nothing (display)
  **/
 function showContracts()
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $this->fields['id'];
     if (!haveRight("contract", "r") || !$this->can($ID, 'r')) {
         return false;
     }
     $canedit = $this->can($ID, 'w');
     $query = "SELECT `glpi_contracts`.*,\n                       `glpi_contracts_suppliers`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity\n                FROM `glpi_contracts_suppliers`, `glpi_contracts`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_contracts`.`entities_id`)\n                WHERE `glpi_contracts_suppliers`.`suppliers_id` = '{$ID}'\n                      AND `glpi_contracts_suppliers`.`contracts_id`=`glpi_contracts`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n                ORDER BY `glpi_entities`.`completename`,\n                         `glpi_contracts`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php'>";
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='7'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['financial'][58];
     } else {
         if ($DB->numrows($result) == 1) {
             echo $LANG['financial'][63];
         } else {
             echo $LANG['financial'][66];
         }
     }
     echo "</th></tr>";
     echo "<tr><th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['financial'][4] . "</th>";
     echo "<th>" . $LANG['financial'][6] . "</th>";
     echo "<th>" . $LANG['search'][8] . "</th>";
     echo "<th>" . $LANG['financial'][8] . "</th>";
     echo "<th>&nbsp;</th>";
     echo "</tr>";
     $used = array();
     while ($data = $DB->fetch_array($result)) {
         $cID = $data["id"];
         $used[$cID] = $cID;
         $assocID = $data["assocID"];
         echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
         echo "<td class='center'>\n               <a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>";
         echo "<strong>" . $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             echo " (" . $data["id"] . ")";
         }
         echo "</strong></a></td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
         echo "</td><td class='center'>" . $data["num"] . "</td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_contracttypes", $data["contracttypes_id"]) . "</td>";
         echo "<td class='center'>" . convDate($data["begin_date"]) . "</td>";
         echo "<td class='center'>" . $data["duration"] . " " . $LANG['financial'][57];
         if ($data["begin_date"] != '' && !empty($data["begin_date"])) {
             echo " -> " . getWarrantyExpir($data["begin_date"], $data["duration"]);
         }
         echo "</td>";
         echo "<td class='tab_bg_2 center'>";
         if ($canedit) {
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?deletecontractsupplier=" . "1&amp;id={$assocID}&amp;contracts_id={$cID}'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/delete2.png' alt='" . $LANG['buttons'][6] . "'></a>";
         } else {
             echo "&nbsp;";
         }
         echo "</td></tr>";
         $i++;
     }
     if ($canedit) {
         if ($this->fields["is_recursive"]) {
             $nb = countElementsInTableForEntity("glpi_contracts", getSonsOf("glpi_entities", $this->fields["entities_id"]));
         } else {
             $nb = countElementsInTableForEntity("glpi_contracts", $this->fields["entities_id"]);
         }
         if ($nb > count($used)) {
             echo "<tr class='tab_bg_1'><td class='center' colspan='5'>";
             echo "<input type='hidden' name='suppliers_id' value='{$ID}'>";
             Contract::dropdown(array('used' => $used, 'entity' => $this->fields["entities_id"], 'entity_sons' => $this->fields["is_recursive"], 'nochecklimit' => true));
             echo "</td><td class='center'>";
             echo "<input type='submit' name='addcontractsupplier' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
             echo "</td>";
             echo "<td>&nbsp;</td></tr>";
         }
     }
     echo "</table></div></form>";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:87,代码来源:supplier.class.php


注:本文中的countElementsInTableForEntity函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。