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


PHP Entity::getFromDB方法代码示例

本文整理汇总了PHP中Entity::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getFromDB方法的具体用法?PHP Entity::getFromDB怎么用?PHP Entity::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


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

示例1: displayLine

 static function displayLine($data, $displayhost = 1)
 {
     global $DB, $CFG_GLPI;
     $pMonitoringService = new PluginMonitoringService();
     $networkPort = new NetworkPort();
     $pMonitoringComponent = new PluginMonitoringComponent();
     $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
     $entity = new Entity();
     $pMonitoringService->getFromDB($data['id']);
     echo "<td width='32' class='center'>";
     $shortstate = self::getState($data['state'], $data['state_type'], $data['event'], $data['is_acknowledged']);
     $alt = __('Ok', 'monitoring');
     if ($shortstate == 'orange') {
         $alt = __('Warning (data)', 'monitoring');
     } else {
         if ($shortstate == 'yellow') {
             $alt = __('Warning (connection)', 'monitoring');
         } else {
             if ($shortstate == 'red') {
                 $alt = __('Critical', 'monitoring');
             } else {
                 if ($shortstate == 'redblue') {
                     $alt = __('Critical / Acknowledge', 'monitoring');
                 }
             }
         }
     }
     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'\n         title='" . $alt . "' alt='" . $alt . "' />";
     echo "</td>";
     echo "<td>";
     $entity->getFromDB($data['entities_id']);
     echo $entity->fields['completename'];
     echo "</td>";
     $pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']);
     echo "<td class='center'>";
     $timezone = '0';
     if (isset($_SESSION['plugin_monitoring_timezone'])) {
         $timezone = $_SESSION['plugin_monitoring_timezone'];
     }
     if ($pMonitoringComponent->fields['graph_template'] != '') {
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['id'] . "'>";
         $pmServicegraph = new PluginMonitoringServicegraph();
         ob_start();
         $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "div", "600");
         $div = ob_get_contents();
         ob_end_clean();
         $chart = "<table width='600' class='tab_cadre'><tr><td>" . $div . "</td></tr></table>";
         Html::showToolTip($chart, array('img' => $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/stats_32.png"));
         $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "js");
     }
     echo "</a>";
     echo "</td>";
     if ($displayhost == '1') {
         $pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]);
         if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') {
             $itemtype = $pmComponentscatalog_Host->fields['itemtype'];
             $item = new $itemtype();
             $item->getFromDB($pmComponentscatalog_Host->fields['items_id']);
             echo "<td>";
             echo $item->getTypeName() . " : " . $item->getLink();
             if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
                 $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
                 echo " [" . $networkPort->getLink() . "]";
             }
             echo "</td>";
         } else {
             echo "<td>" . __('Resources', 'monitoring') . "</td>";
         }
     }
     echo "<td>" . $pMonitoringComponent->getLink();
     if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
         $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
         echo " [" . $networkPort->getLink() . "]";
     }
     echo "</td>";
     //      $nameitem = '';
     //      if (isset($itemmat->fields['name'])) {
     //         $nameitem = "[".$itemmat->getLink(1)."]";
     //      }
     //if ($pMonitoringService->fields['plugin_monitoring_services_id'] == '0') {
     //echo "<td>".$itemmat->getLink(1)."</td>";
     //      } else {
     //         $pMonitoringServiceH->getFromDB($pMonitoringService->fields['plugin_monitoring_services_id']);
     //         $itemtypemat = $pMonitoringServiceH->fields['itemtype'];
     //         $itemmat = new $itemtypemat();
     //         $itemmat->getFromDB($pMonitoringServiceH->fields['items_id']);
     //         echo "<td>".$pMonitoringService->getLink(1).$nameitem." ".__('on', 'monitoring')." ".$itemmat->getLink(1)."</td>";
     //      }
     //      unset($itemmat);
     echo "<td class='center'>";
     if ($shortstate == 'red') {
         echo "<table>";
         echo "<tr>";
         echo "<td>";
         echo $data['state'];
         echo "</td>";
         echo "<td>";
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_checked.png'" . " alt='" . __('Define an acknowledge', 'monitoring') . "'" . " title='" . __('Define an acknowledge', 'monitoring') . "'/>" . "</a>";
         echo "</td>";
         echo "</tr>";
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:display.class.php

示例2: getComments

   /**
    * Get comments for host
    * $id, host id
    *    default is current host instance
    *
    */
   function getComments($id=-1) {
      global $CFG_GLPI;

      if ($id == -1) {
         $pm_Host = $this;
      } else {
         $pm_Host = new PluginMonitoringHost();
         $pm_Host->getFromDB($id);
      }

      // Toolbox::logInFile("pm", "Host getcomments : $id : ".$pm_Host->getID()."\n");
      $comment = "";
      $toadd   = array();

      // associated computer ...
      $item = new $pm_Host->fields['itemtype'];
      $item->getFromDB($pm_Host->fields['items_id']);

      if ($pm_Host->getField('itemtype') == 'Computer') {
         if ($item->isField('completename')) {
            $toadd[] = array('name'  => __('Complete name'),
                             'value' => nl2br($item->getField('completename')));
         }

         $type = new ComputerType();
         if ($item->getField("computertypes_id")) {
            $type->getFromDB($item->getField("computertypes_id"));
            $type = $type->getName();
            if (! empty($type)) {
               $toadd[] = array('name'  => __('Type'),
                                'value' => nl2br($type));
            }
         } else {
            return $comment;
         }

         $model = new ComputerModel();
         if ($item->getField("computermodels_id")) {
            $model->getFromDB($item->getField("computermodels_id"));
            $model = $model->getName();
            if (! empty($model)) {
               $toadd[] = array('name'  => __('Model'),
                                'value' => nl2br($model));
            }
         }

         $state = new State();
         $state->getFromDB($item->fields["states_id"]);
         $state = $state->getName();
         if (! empty($state)) {
            $toadd[] = array('name'  => __('State'),
                             'value' => nl2br($state));
         }

         $entity = new Entity();
         $entity->getFromDB($item->fields["entities_id"]);
         $entity = $entity->getName();
         if (! empty($entity)) {
            $toadd[] = array('name'  => __('Entity'),
                             'value' => nl2br($entity));
         }

         $location = new Location();
         $location->getFromDB($item->fields["locations_id"]);
         $location = $location->getName(array('complete'  => true));
         if (! empty($location)) {
            $toadd[] = array('name'  => __('Location'),
                             'value' => nl2br($location));
         }

         if (! empty($item->fields["serial"])) {
            $toadd[] = array('name'  => __('Serial'),
                             'value' => nl2br($item->fields["serial"]));
         }
         if (! empty($item->fields["otherserial"])) {
            $toadd[] = array('name'  => __('Inventory number'),
                             'value' => nl2br($item->fields["otherserial"]));
         }

         if (($pm_Host instanceof CommonDropdown)
             && $pm_Host->isField('comment')) {
            $toadd[] = array('name'  => __('Comments'),
                             'value' => nl2br($pm_Host->getField('comment')));
         }

         if (count($toadd)) {
            foreach ($toadd as $data) {
               $comment .= sprintf(__('%1$s: %2$s')."<br>",
                                   "<span class='b'>".$data['name'], "</span>".$data['value']);
            }
         }
      } else {
         $toadd[] = array('name'  => __('Host type'),
                          'value' => nl2br($item->getTypeName()));
//.........这里部分代码省略.........
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:host.class.php

示例3: header

along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "ticketsatisfaction.php")) {
    $AJAX_INCLUDE = 1;
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
$entity = new Entity();
if (isset($_POST['inquest_config']) && isset($_POST['entities_id'])) {
    if ($entity->getFromDB($_POST['entities_id'])) {
        $inquest_config = $entity->getfield('inquest_config');
        $inquest_delay = $entity->getfield('inquest_delay');
        $inquest_rate = $entity->getfield('inquest_rate');
        $inquest_duration = $entity->getfield('inquest_duration');
        $max_closedate = $entity->getfield('max_closedate');
    } else {
        $inquest_config = $_POST['inquest_config'];
        $inquest_delay = -1;
        $inquest_rate = -1;
        $inquest_duration = -1;
        $max_closedate = '';
    }
    if ($_POST['inquest_config'] > 0) {
        echo "<table class='tab_cadre_fixe' width='50%'>";
        echo "<tr class='tab_bg_1'><td width='50%'>" . __('Create survey after') . "</td>";
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:ticketsatisfaction.php

示例4: getDatasForObject

 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$2');
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
                 $tmp = array();
                 $tmp['##author.id##'] = $uid;
                 $tmp['##author.name##'] = $user_tmp->getName();
                 if ($user_tmp->getField('locations_id')) {
                     $tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
                 } else {
                     $tmp['##author.location##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             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();
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:notificationtargetcommonitilobject.class.php

示例5: updateGenericServicesCatalogs

 function updateGenericServicesCatalogs($action = 'update')
 {
     global $DB;
     $entity = new Entity();
     $pmServicescatalog = new PluginMonitoringServicescatalog();
     $pmBusinessrulegroup = new PluginMonitoringBusinessrulegroup();
     $pmBusinessrulecomponent = new PluginMonitoringBusinessrule_component();
     $existingSCs = array();
     // Find existing instances of generic services catalog ...
     $a_SCs = $this->find("`name` LIKE '" . $this->getName() . "%'");
     foreach ($a_SCs as $a_SC) {
         // Toolbox::logInFile("pm", "SC : ".$a_SC['id'].", name : ".$a_SC['name'].", generic : ".$a_SC['is_generic']."\n");
         if ($a_SC['name'] == $this->getField('name')) {
             continue;
         }
         $existingSCs[$a_SC['name']] = $a_SC;
     }
     if ($action == 'delete') {
         foreach ($existingSCs as $name => $a_SC) {
             $pmServicescatalog->getFromDB($a_SC['id']);
             $pmServicescatalog->delete($pmServicescatalog->fields);
             // Toolbox::logInFile("pm", "Deleted : ".$a_SC['name']."\n");
             $pmBusinessrulecomponent = new PluginMonitoringBusinessrule_component();
             $pmBusinessrule = new PluginMonitoringBusinessrule();
             // Get business rules groups ...
             $a_BRgroups = $pmBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $a_SC['id'] . "'");
             // Delete business groups components
             foreach ($a_BRgroups as $a_BRgroup) {
                 // Toolbox::logInFile("pm", "a_BRgroup : ".$a_BRgroup['id']."\n");
                 $a_brcomponents = $pmBusinessrulecomponent->find("`plugin_monitoring_businessrulegroups_id`='" . $a_BRgroup['id'] . "'");
                 foreach ($a_brcomponents as $a_brcomponent) {
                     // Toolbox::logInFile("pm", "a_brcomponent : ".$a_brcomponent['id']."\n");
                     $pmBusinessrulecomponent->getFromDB($a_brcomponent['id']);
                     $pmBusinessrulecomponent->delete($pmBusinessrulecomponent->fields);
                 }
             }
             // Delete business groups rules
             foreach ($a_BRgroups as $a_BRgroup) {
                 $a_brs = $pmBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $a_BRgroup['id'] . "'");
                 foreach ($a_brs as $a_br) {
                     // Toolbox::logInFile("pm", "a_br : ".$a_br['id']."\n");
                     $pmBusinessrulecomponent->getFromDB($a_brcomponent['id']);
                     $pmBusinessrulecomponent->delete($pmBusinessrulecomponent->fields);
                 }
             }
         }
         return;
     } else {
         foreach ($existingSCs as $name => $a_SC) {
             $pmServicescatalog->getFromDB($a_SC['id']);
             $pmBusinessrulegroup = new PluginMonitoringBusinessrulegroup();
             $pmBusinessrulecomponent = new PluginMonitoringBusinessrule_component();
             $pmBusinessrule = new PluginMonitoringBusinessrule();
             // Get business rules groups ...
             $a_BRgroups = $pmBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $a_SC['id'] . "'");
             // Delete business groups components
             foreach ($a_BRgroups as $a_BRgroup) {
                 // Toolbox::logInFile("pm", "a_BRgroup : ".$a_BRgroup['id']."\n");
                 $a_brcomponents = $pmBusinessrulecomponent->find("`plugin_monitoring_businessrulegroups_id`='" . $a_BRgroup['id'] . "'");
                 foreach ($a_brcomponents as $a_brcomponent) {
                     // Toolbox::logInFile("pm", "a_brcomponent : ".$a_brcomponent['id']."\n");
                     $pmBusinessrulecomponent->getFromDB($a_brcomponent['id']);
                     $pmBusinessrulecomponent->delete($pmBusinessrulecomponent->fields);
                 }
             }
             // Delete business groups rules
             foreach ($a_BRgroups as $a_BRgroup) {
                 $a_brs = $pmBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $a_BRgroup['id'] . "'");
                 foreach ($a_brs as $a_br) {
                     // Toolbox::logInFile("pm", "a_br : ".$a_br['id']."\n");
                     $pmBusinessrulecomponent->getFromDB($a_brcomponent['id']);
                     $pmBusinessrulecomponent->delete($pmBusinessrulecomponent->fields);
                 }
             }
         }
     }
     // Find entities concerned ...
     $a_entitiesServices = $this->getGenericServicesEntities();
     foreach ($a_entitiesServices as $idEntity => $a_entityServices) {
         // New entity ... so it must exist a derivated SC !
         $entity->getFromDB($idEntity);
         // Toolbox::logInFile("pm", "Found entity : ".$idEntity." / ".$entity->getName()."\n");
         $scName = $this->getName() . " - " . $entity->getName();
         if (isset($existingSCs[$scName])) {
             // Update SC
             $pmServicescatalog->getFromDB($existingSCs[$scName]['id']);
             $pmServicescatalog->fields = $this->fields;
             unset($pmServicescatalog->fields['id']);
             $pmServicescatalog->fields['id'] = $existingSCs[$scName]['id'];
             $pmServicescatalog->fields['entities_id'] = $idEntity;
             $pmServicescatalog->fields['is_generic'] = 0;
             $pmServicescatalog->fields['name'] = $DB->escape($scName);
             $pmServicescatalog->update($pmServicescatalog->fields);
             /*            // Finish updating if needed ...
                         $a_BRgroups = $pmBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='".$this->fields['id']."'");
                         foreach ($a_BRgroups as $a_BRgroup) {
                            $pmBusinessrulegroup = $pmBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='".$a_SC['id']."' AND `name`='".$a_BRgroup['name']."'");
                            $pmBusinessrulegroup->fields = $a_BRgroup->fields;
                            unset($pmBusinessrulegroup->fields['id']);
                            $pmBusinessrulegroup->fields['plugin_monitoring_servicescatalogs_id'] = $pmServicescatalog->fields['id'];
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:servicescatalog.class.php

示例6: manageValuesInSession

 /**
  * @param $options   array
  * @param $delete          (false by default)
  **/
 static function manageValuesInSession($options = array(), $delete = false)
 {
     $fields = array('action', 'authldaps_id', 'basedn', 'begin_date', 'criterias', 'end_date', 'entities_id', 'interface', 'ldap_filter', 'mode');
     //If form accessed via modal, do not show expert mode link
     // Manage new value is set : entity or mode
     if (isset($options['entity']) || isset($options['mode'])) {
         if (isset($options['_in_modal']) && $options['_in_modal']) {
             //If coming form the helpdesk form : reset all criterias
             $_SESSION['ldap_import']['_in_modal'] = 1;
             $_SESSION['ldap_import']['no_expert_mode'] = 1;
             $_SESSION['ldap_import']['action'] = 'show';
             $_SESSION['ldap_import']['interface'] = self::SIMPLE_INTERFACE;
             $_SESSION['ldap_import']['mode'] = self::ACTION_IMPORT;
         } else {
             $_SESSION['ldap_import']['_in_modal'] = 0;
         }
     }
     if (!$delete) {
         if (!isset($_SESSION['ldap_import']['entities_id'])) {
             $options['entities_id'] = $_SESSION['glpiactive_entity'];
         }
         if (isset($options['toprocess'])) {
             $_SESSION['ldap_import']['action'] = 'process';
         }
         if (isset($options['change_directory'])) {
             $options['ldap_filter'] = '';
         }
         if (!isset($_SESSION['ldap_import']['authldaps_id'])) {
             $_SESSION['ldap_import']['authldaps_id'] = NOT_AVAILABLE;
         }
         if (!Config::canUpdate() && !Entity::canUpdate() || !isset($_SESSION['ldap_import']['interface']) && !isset($options['interface'])) {
             $options['interface'] = self::SIMPLE_INTERFACE;
         }
         foreach ($fields as $field) {
             if (isset($options[$field])) {
                 $_SESSION['ldap_import'][$field] = $options[$field];
             }
         }
         if (isset($_SESSION['ldap_import']['begin_date']) && $_SESSION['ldap_import']['begin_date'] == 'NULL') {
             $_SESSION['ldap_import']['begin_date'] = '';
         }
         if (isset($_SESSION['ldap_import']['end_date']) && $_SESSION['ldap_import']['end_date'] == 'NULL') {
             $_SESSION['ldap_import']['end_date'] = '';
         }
         if (!isset($_SESSION['ldap_import']['criterias'])) {
             $_SESSION['ldap_import']['criterias'] = array();
         }
         $authldap = new self();
         //Filter computation
         if ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE) {
             $entity = new Entity();
             if ($entity->getFromDB($_SESSION['ldap_import']['entities_id']) && $entity->getField('authldaps_id') > 0) {
                 $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                 $_SESSION['ldap_import']['authldaps_id'] = $entity->getField('authldaps_id');
                 $_SESSION['ldap_import']['basedn'] = $entity->getField('ldap_dn');
                 // No dn specified in entity : use standard one
                 if (empty($_SESSION['ldap_import']['basedn'])) {
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
                 if ($entity->getField('entity_ldapfilter') != NOT_AVAILABLE) {
                     $_SESSION['ldap_import']['entity_filter'] = $entity->getField('entity_ldapfilter');
                 }
             } else {
                 $_SESSION['ldap_import']['authldaps_id'] = self::getDefault();
                 if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
             }
             if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                 $_SESSION['ldap_import']['ldap_filter'] = self::buildLdapFilter($authldap);
             }
         } else {
             if ($_SESSION['ldap_import']['authldaps_id'] == NOT_AVAILABLE || !$_SESSION['ldap_import']['authldaps_id']) {
                 $_SESSION['ldap_import']['authldaps_id'] = self::getDefault();
                 if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
             }
             if (!isset($_SESSION['ldap_import']['ldap_filter']) || $_SESSION['ldap_import']['ldap_filter'] == '') {
                 $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                 $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 $_SESSION['ldap_import']['ldap_filter'] = self::buildLdapFilter($authldap);
             }
         }
         //Unset all values in session
     } else {
         unset($_SESSION['ldap_import']);
     }
 }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:95,代码来源:authldap.class.php

示例7: cronCreateInquest

 /**
  * Cron for ticketsatisfaction's automatic generated
  *
  * @param $task : crontask object
  *
  * @return integer (0 : nothing done - 1 : done)
  **/
 static function cronCreateInquest($task)
 {
     global $DB;
     $conf = new Entity();
     $inquest = new TicketSatisfaction();
     $tot = 0;
     $maxentity = array();
     $tabentities = array();
     $rate = Entity::getUsedConfig('inquest_config', 0, 'inquest_rate');
     if ($rate > 0) {
         $tabentities[0] = $rate;
     }
     foreach ($DB->request('glpi_entities') as $entity) {
         $rate = Entity::getUsedConfig('inquest_config', $entity['id'], 'inquest_rate');
         $parent = Entity::getUsedConfig('inquest_config', $entity['id'], 'entities_id');
         if ($rate > 0) {
             $tabentities[$entity['id']] = $rate;
         }
     }
     foreach ($tabentities as $entity => $rate) {
         $parent = Entity::getUsedConfig('inquest_config', $entity, 'entities_id');
         $delay = Entity::getUsedConfig('inquest_config', $entity, 'inquest_delay');
         $duration = Entity::getUsedConfig('inquest_config', $entity, 'inquest_duration');
         $type = Entity::getUsedConfig('inquest_config', $entity);
         $max_closedate = Entity::getUsedConfig('inquest_config', $entity, 'max_closedate');
         $query = "SELECT `glpi_tickets`.`id`,\n                          `glpi_tickets`.`closedate`,\n                          `glpi_tickets`.`entities_id`\n                   FROM `glpi_tickets`\n                   LEFT JOIN `glpi_ticketsatisfactions`\n                       ON `glpi_ticketsatisfactions`.`tickets_id` = `glpi_tickets`.`id`\n                   LEFT JOIN `glpi_entities`\n                       ON `glpi_tickets`.`entities_id` = `glpi_entities`.`id`\n                   WHERE `glpi_tickets`.`entities_id` = '{$entity}'\n                         AND `glpi_tickets`.`is_deleted` = 0\n                         AND `glpi_tickets`.`status` = '" . self::CLOSED . "'\n                         AND `glpi_tickets`.`closedate` > '{$max_closedate}'\n                         AND ADDDATE(`glpi_tickets`.`closedate`, INTERVAL {$delay} DAY)<=NOW()\n                         AND ADDDATE(`glpi_entities`.`max_closedate`, INTERVAL {$duration} DAY)<=NOW()\n                         AND `glpi_ticketsatisfactions`.`id` IS NULL\n                   ORDER BY `closedate` ASC";
         $nb = 0;
         $max_closedate = '';
         foreach ($DB->request($query) as $tick) {
             $max_closedate = $tick['closedate'];
             if (mt_rand(1, 100) <= $rate) {
                 if ($inquest->add(array('tickets_id' => $tick['id'], 'date_begin' => $_SESSION["glpi_currenttime"], 'entities_id' => $tick['entities_id'], 'type' => $type))) {
                     $nb++;
                 }
             }
         }
         // conservation de toutes les max_closedate des entites filles
         if (!empty($max_closedate) && (!isset($maxentity[$parent]) || $max_closedate > $maxentity[$parent])) {
             $maxentity[$parent] = $max_closedate;
         }
         if ($nb) {
             $tot += $nb;
             $task->addVolume($nb);
             $task->log(sprintf(__('%1$s: %2$s'), Dropdown::getDropdownName('glpi_entities', $entity), $nb));
         }
     }
     // Sauvegarde du max_closedate pour ne pas tester les même tickets 2 fois
     foreach ($maxentity as $parent => $maxdate) {
         $conf->getFromDB($parent);
         $conf->update(array('id' => $conf->fields['id'], 'max_closedate' => $maxdate));
     }
     return $tot > 0;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:60,代码来源:ticket.class.php

示例8: getDatasForTemplate

 /**
  * @see NotificationTarget::getDatasForTemplate()
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     //----------- Reservation infos -------------- //
     $events = $this->getAllEvents();
     $item = $this->obj;
     $this->datas['##project.action##'] = $events[$event];
     $this->datas['##project.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("id"));
     $this->datas["##project.name##"] = $item->getField('name');
     $this->datas["##project.code##"] = $item->getField('code');
     $this->datas["##project.description##"] = $item->getField('content');
     $this->datas["##project.comments##"] = $item->getField('comment');
     $this->datas["##project.creationdate##"] = Html::convDateTime($item->getField('date'));
     $this->datas["##project.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
     $this->datas["##project.priority##"] = CommonITILObject::getPriorityName($item->getField('priority'));
     $this->datas["##project.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
     $this->datas["##project.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
     $this->datas["##project.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
     $this->datas["##project.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
     $this->datas["##project.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
     $this->datas["##project.plannedduration##"] = Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($item->getID()), false);
     $this->datas["##project.effectiveduration##"] = Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($item->getID()), false);
     $entity = new Entity();
     $this->datas["##project.entity##"] = '';
     $this->datas["##project.shortentity##"] = '';
     if ($entity->getFromDB($this->getEntity())) {
         $this->datas["##project.entity##"] = $entity->getField('completename');
         $this->datas["##project.shortentity##"] = $entity->getField('name');
     }
     $this->datas["##project.father##"] = '';
     if ($item->getField('projects_id')) {
         $this->datas["##project.father##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
     }
     $this->datas["##project.state##"] = '';
     if ($item->getField('projectstates_id')) {
         $this->datas["##project.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
     }
     $this->datas["##project.type##"] = '';
     if ($item->getField('projecttypes_id')) {
         $this->datas["##project.type##"] = Dropdown::getDropdownName('glpi_projecttypes', $item->getField('projecttypes_id'));
     }
     $this->datas["##project.manager##"] = '';
     if ($item->getField('users_id')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id'));
         $this->datas["##project.manager##"] = $user_tmp->getName();
     }
     $this->datas["##project.managergroup##"] = '';
     if ($item->getField('groups_id')) {
         $this->datas["##project.managergroup##"] = Dropdown::getDropdownName('glpi_groups', $item->getField('groups_id'));
     }
     // Team infos
     $restrict = "`projects_id` = '" . $item->getField('id') . "'";
     $items = getAllDatasFromTable('glpi_projectteams', $restrict);
     $this->datas['teammembers'] = array();
     if (count($items)) {
         foreach ($items as $data) {
             if ($item2 = getItemForItemtype($data['itemtype'])) {
                 if ($item2->getFromDB($data['items_id'])) {
                     $tmp = array();
                     $tmp['##teammember.itemtype##'] = $item2->getTypeName();
                     $tmp['##teammember.name##'] = $item2->getName();
                     $this->datas['teammembers'][] = $tmp;
                 }
             }
         }
     }
     $this->datas['##project.numberofteammembers##'] = count($this->datas['teammembers']);
     // Task infos
     $restrict = "`projects_id`='" . $item->getField('id') . "'";
     $restrict .= " ORDER BY `date` DESC, `id` ASC";
     $tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
     $this->datas['tasks'] = array();
     foreach ($tasks as $task) {
         $tmp = array();
         $tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
         $tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
         $tmp['##task.name##'] = $task['name'];
         $tmp['##task.description##'] = $task['content'];
         $tmp['##task.comments##'] = $task['comment'];
         $tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
         $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
         $tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
         $this->datas["##task.planstartdate##"] = '';
         $this->datas["##task.planenddate##"] = '';
         $this->datas["##task.realstartdate##"] = '';
         $this->datas["##task.realenddate##"] = '';
         if (!is_null($task['plan_start_date'])) {
             $tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
         }
         if (!is_null($task['plan_end_date'])) {
             $tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
         }
         if (!is_null($task['real_start_date'])) {
             $tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
         }
         if (!is_null($task['real_end_date'])) {
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:glpi,代码行数:101,代码来源:notificationtargetproject.class.php

示例9: showWidgetFrame

   function showWidgetFrame($id, $reduced_interface=false, $is_minemap=FALSE) {
      global $DB, $CFG_GLPI;

      $this->getFromDB($id);
      $data = $this->fields;

      $ret = $this->getInfoOfCatalog($id);
      $nb_ressources = $ret[0];
      if ($nb_ressources == 0) {
         echo '<div class="ch-item">
            <div>
            <h1>'.__('Nothing to display ...', 'monitoring').'</h1>
            </div>
         </div>';

         return;
      }

      $stateg = $ret[1];
      $hosts_ids = $ret[2];
      $services_ids = $ret[3];
      $hosts_ressources = $ret[4];
      $hosts_states = $ret[5];

      $colorclass = 'ok';
      $count = 0;

      $link = '';
      // Toolbox::logInFile("pm", "stateg $id - ".serialize($stateg)."\n");
      if ($stateg['CRITICAL'] > 0) {
         $count = $stateg['CRITICAL'];
         $colorclass = 'crit';
         $link = $CFG_GLPI['root_doc'].
         "/plugins/monitoring/front/service.php?hidesearch=1"
//                 . "&reset=reset&"
                 . "criteria[0][field]=3"
                 . "&criteria[0][searchtype]=equals"
                 . "&criteria[0][value]=CRITICAL"

                 . "&criteria[1][link]=AND"
                 . "&criteria[1][field]=9"
                 . "&criteris[1][searchtype]=equals"
                 . "&criteria[1][value]=".$id

                 . "&itemtype=PluginMonitoringService"
                 . "&start=0";
      } else if ($stateg['WARNING'] > 0) {
         $count = $stateg['WARNING'];
         $colorclass = 'warn';
         $link = $CFG_GLPI['root_doc'].
         "/plugins/monitoring/front/service.php?hidesearch=1"
//                 . "&reset=reset"
                 . "&criteria[0][field]=3"
                 . "&criteria[0][searchtype]=equals"
                 . "&criteria[0][value]=WARNING"

                 . "&criteria[1][link]=AND"
                 . "&criteria[1][field]=9"
                 . "&criteria[1][searchtype]=equals"
                 . "&criteria[1][value]=".$id

                 . "&criteria[2][link]=OR"
                 . "&criteria[2][field]=3"
                 . "&criteria[2][searchtype]=equals"
                 . "&criteria[2][value]=UNKNOWN"

                 . "&criteria[3][link]=AND"
                 . "&criteria[3][field]=9"
                 . "&criteria[3][searchtype]=equals"
                 . "&criteria[3][value]=".$id

                 . "&criteria[4][link]=OR"
                 . "&criteria[4][field]=3"
                 . "&criteria[4][searchtype]=equals"
                 . "&criteria[4][value]=RECOVERY"

                 . "&criteria[5][link]=AND"
                 . "&criteria[5][field]=9"
                 . "&criteria[5][searchtype]=equals"
                 . "&criteria[5][value]=".$id

                 . "&criteria[6][link]=OR"
                 . "&criteria[6][field]=3"
                 . "&criteria[6][searchtype]=equals"
                 . "&criteria[6][value]=FLAPPING"

                 . "&criteria[7][link]=AND"
                 . "&criteria[7][field]=9"
                 . "&criteria[7][searchtype]=equals"
                 . "&criteria[7][value]=".$id

                 . "&itemtype=PluginMonitoringService"
                 . "&start=0";
      } else {
         $count = $stateg['OK'];
         $count += $stateg['ACKNOWLEDGE'];
         $count += $stateg['UNKNOWN'];
         $link = $CFG_GLPI['root_doc'].
         "/plugins/monitoring/front/service.php?hidesearch=1"
//                 . "&reset=reset"
//.........这里部分代码省略.........
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:componentscatalog.class.php

示例10: showContacts

   function showContacts($itemtype, $items_id) {
      global $DB,$CFG_GLPI;

      $this->addContact($itemtype, $items_id);

      $group = new Group();
      $user  = new User();

      $rand = mt_rand();

      echo "<form method='post' name='contact_item_form$rand' id='contact_item_form$rand' action=\"".
                $CFG_GLPI["root_doc"]."/plugins/monitoring/front/contact_item.form.php\">";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th>";
      echo __('Contacts', 'monitoring');
      echo "</th>";
      echo "</tr>";

      echo "</table>";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('Group')." - ".__('Name')."</th>";
      echo "<th colspan='3'></th>";
      echo "</tr>";

      $used = array();
      // Display groups first
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `groups_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $group->getLink(1);
         echo "</td>";
         echo "<td colspan='3'>";

         echo "</td>";

         echo "</tr>";
      }

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('User')." - ".__('Name')."</th>";
      echo "<th>".__('Entity')."</th>";
      echo "<th>".__('Email address')."</th>";
      echo "<th>".__('Phone')."</th>";
      echo "</tr>";

      $entity = new Entity();
      $used = array();
      // Display Users
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `users_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $user->getFromDB($data['users_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->getLink(1);
         echo "</td>";
         $entity->getFromDB($data['entities_id']);
         echo "<td class='center'>";
         echo $entity->getName()." <strong>(R)</strong>";
         echo "</td>";
         echo "<td class='center'>";
         $a_emails = UserEmail::getAllForUser($data['users_id']);
         $first = 0;
         foreach ($a_emails as $email) {
            if ($first == 0) {
               echo $email;
            }
            $first++;
         }
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['phone'];
         echo "</td>";

         echo "</tr>";
//.........这里部分代码省略.........
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:contact_item.class.php

示例11: getUsedConfig

 /**
  * Recovery datas of current entity or parent entity
  *
  * @param $fieldref  string name of the referent field to know if we look at parent entity
  * @param $entities_id
  * @param $fieldval string name of the field that we want value
  **/
 static function getUsedConfig($fieldref, $entities_id, $fieldval = '')
 {
     // for calendar
     if (empty($fieldval)) {
         $fieldval = $fieldref;
     }
     $entdata = new EntityData();
     // Search in entity data of the current entity
     if ($entdata->getFromDB($entities_id)) {
         // Value is defined : use it
         if (isset($entdata->fields[$fieldref]) && ($entdata->fields[$fieldref] > 0 || !is_numeric($entdata->fields[$fieldref]))) {
             return $entdata->fields[$fieldval];
         }
     }
     // Entity data not found or not defined : search in parent one
     if ($entities_id > 0) {
         $current = new Entity();
         if ($current->getFromDB($entities_id)) {
             return self::getUsedConfig($fieldref, $current->fields['entities_id'], $fieldval);
         }
     }
     switch ($fieldval) {
         case "tickettype":
             // Default is Incident if not set
             return Ticket::INCIDENT_TYPE;
     }
     return 0;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:35,代码来源:entitydata.class.php

示例12: displayLine

 static function displayLine($data, $displayhost = 1)
 {
     global $DB, $CFG_GLPI, $LANG;
     $pMonitoringService = new PluginMonitoringService();
     $networkPort = new NetworkPort();
     $pMonitoringComponent = new PluginMonitoringComponent();
     $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
     $pmServicegraph = new PluginMonitoringServicegraph();
     $entity = new Entity();
     $pMonitoringService->getFromDB($data['id']);
     echo "<td width='32' class='center'>";
     $shortstate = self::getState($data['state'], $data['state_type']);
     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'/>";
     echo "</td>";
     echo "<td>";
     $entity->getFromDB($data['entities_id']);
     echo $entity->fields['completename'];
     echo "</td>";
     $pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']);
     echo "<td class='center'>";
     $img = '';
     $timezone = '0';
     if (isset($_SESSION['plugin_monitoring_timezone'])) {
         $timezone = $_SESSION['plugin_monitoring_timezone'];
     }
     $timezone_file = str_replace("+", ".", $timezone);
     $img = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png'/>";
     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['id'] . "'>";
     if (file_exists(GLPI_ROOT . "/files/_plugins/monitoring/PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png") or $pMonitoringComponent->fields['graph_template'] != '') {
         $img = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png'/>";
         showToolTip($img, array('img' => $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/stats_32.png"));
     } else {
     }
     echo "</a>";
     echo "</td>";
     if ($displayhost == '1') {
         $pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]);
         if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') {
             $itemtype = $pmComponentscatalog_Host->fields['itemtype'];
             $item = new $itemtype();
             $item->getFromDB($pmComponentscatalog_Host->fields['items_id']);
             echo "<td>";
             echo $item->getTypeName() . " : " . $item->getLink();
             if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
                 $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
                 echo " [" . $networkPort->getLink() . "]";
             }
             echo "</td>";
         } else {
             echo "<td>" . $LANG['plugin_monitoring']['service'][0] . "</td>";
         }
     }
     echo "<td>" . $pMonitoringComponent->getLink();
     if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
         $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
         echo " [" . $networkPort->getLink() . "]";
     }
     echo "</td>";
     //      $nameitem = '';
     //      if (isset($itemmat->fields['name'])) {
     //         $nameitem = "[".$itemmat->getLink(1)."]";
     //      }
     //if ($pMonitoringService->fields['plugin_monitoring_services_id'] == '0') {
     //echo "<td>".$itemmat->getLink(1)."</td>";
     //      } else {
     //         $pMonitoringServiceH->getFromDB($pMonitoringService->fields['plugin_monitoring_services_id']);
     //         $itemtypemat = $pMonitoringServiceH->fields['itemtype'];
     //         $itemmat = new $itemtypemat();
     //         $itemmat->getFromDB($pMonitoringServiceH->fields['items_id']);
     //         echo "<td>".$pMonitoringService->getLink(1).$nameitem." ".$LANG['networking'][25]." ".$itemmat->getLink(1)."</td>";
     //      }
     //      unset($itemmat);
     echo "<td class='center'>";
     echo $data['state'];
     echo "</td>";
     echo "<td>";
     echo convDate($data['last_check']) . ' ' . substr($data['last_check'], 11, 8);
     echo "</td>";
     echo "<td>";
     echo $data['event'];
     echo "</td>";
     echo "<td align='center'>";
     $segments = CalendarSegment::getSegmentsBetween($pMonitoringComponent->fields['calendars_id'], date('w', date('U')), date('H:i:s'), date('w', date('U')), date('H:i:s'));
     if (count($segments) == '0') {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_pause.png' />";
     } else {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_run.png' />";
     }
     echo "</td>";
     if ($displayhost == '0') {
         $pmUnavaibility = new PluginMonitoringUnavaibility();
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'lastmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentyear', 1);
         echo "<td>";
         $a_arg = importArrayFromDB($pMonitoringService->fields['arguments']);
         $cnt = '';
         if (count($a_arg) > 0) {
             $cnt = " (" . count($a_arg) . ")";
         }
//.........这里部分代码省略.........
开发者ID:RubichonL,项目名称:glpi_monitoring,代码行数:101,代码来源:display.class.php

示例13: doStat

function doStat($table, $entity, $header, $level = 0)
{
    global $DB;
    $Ent = new Entity();
    $Ent->getFromDB($entity);
    // Count for this entity
    $sql = "SELECT `states_id`, count(*) AS cpt\n           FROM `{$table}`\n           WHERE `is_deleted` = '0'\n                 AND `is_template` = '0'\n                 AND `entities_id` = '{$entity}'\n           GROUP BY `states_id`";
    $result = $DB->query($sql);
    $count = array();
    while ($data = $DB->fetch_array($result)) {
        $count[$data["states_id"]] = $data["cpt"];
    }
    $count["tot"] = 0;
    foreach ($header as $id => $name) {
        if (isset($count[$id])) {
            $count["tot"] += $count[$id];
        } else {
            $count[$id] = 0;
        }
    }
    // Display counters for this entity
    if ($count["tot"] > 0) {
        echo "<tr class='tab_bg_2'><td>";
        for ($i = 0; $i < $level; $i++) {
            echo "&nbsp;&nbsp;&nbsp;";
        }
        if ($entity) {
            echo $Ent->fields["name"];
        } else {
            _e('Root entity');
        }
        echo "</td>";
        echo "<td class='right'>" . $count["tot"] . "</td>";
        foreach ($header as $id => $name) {
            echo "<td class='right'>" . $count[$id] . "</td>";
        }
        echo "</tr>\n";
    }
    // Call for Childs
    $save = $count["tot"];
    doStatChilds($table, $entity, $header, $count, $level + 1);
    // Display total (Current+Childs)
    if ($save != $count["tot"]) {
        echo "<tr class='tab_bg_1'><td>";
        for ($i = 0; $i < $level; $i++) {
            echo "&nbsp;&nbsp;&nbsp;";
        }
        _e('Total');
        if ($entity) {
            echo $Ent->fields["name"];
        } else {
            _e('Root entity');
        }
        echo "</td>";
        echo "<td class='right'>" . $count["tot"] . "</td>";
        foreach ($header as $id => $name) {
            echo "<td class='right'>" . $count[$id] . "</td>";
        }
        echo "</tr>\n";
    }
    return $count;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:62,代码来源:pcsbyentity.php

示例14: getDatasForObject

 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$1');
     } else {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     }
     $tab = '$2';
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $tab = '$1';
     }
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . $tab);
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
                 $tmp = array();
                 $tmp['##author.id##'] = $uid;
                 $tmp['##author.name##'] = $user_tmp->getName();
                 if ($user_tmp->getField('locations_id')) {
                     $tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
                 } else {
                     $tmp['##author.location##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($user_tmp->getFromDB($uid)) {
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:notificationtargetcommonitilobject.class.php

示例15: generateOrder

 public function generateOrder($params)
 {
     global $DB;
     $ID = $params['id'];
     $template = $params['template'];
     $signature = $params['sign'];
     if ($template) {
         $config = array('PATH_TO_TMP' => GLPI_DOC_DIR . '/_tmp');
         $odf = new Odtphp\Odf(PLUGIN_ORDER_TEMPLATE_DIR . "{$template}", $config);
         $this->getFromDB($ID);
         if (file_exists(PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php")) {
             include_once PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php";
         }
         if (function_exists("plugin_order_getCustomFieldsForODT")) {
             plugin_order_getCustomFieldsForODT($ID, $template, $odf, $signature);
         } else {
             $PluginOrderOrder_Item = new PluginOrderOrder_Item();
             $PluginOrderReference_Supplier = new PluginOrderReference_Supplier();
             try {
                 $odf->setImage('logo', PLUGIN_ORDER_TEMPLATE_LOGO_DIR . '/logo.jpg');
             } catch (\Odtphp\Exceptions\OdfException $e) {
             }
             $values = array();
             $values['title_order'] = __("Order number", "order");
             $values['num_order'] = $this->fields["num_order"];
             $values['title_invoice_address'] = __("Invoice address", "order");
             $values['comment_order'] = $this->fields["comment"];
             $entity = new Entity();
             $entity->getFromDB($this->fields["entities_id"]);
             $town = '';
             if ($this->fields["entities_id"] != 0) {
                 $name_entity = $entity->fields["name"];
             } else {
                 $name_entity = __("Root entity");
             }
             $values['entity_name'] = $name_entity;
             if ($entity->getFromDB($this->fields["entities_id"])) {
                 $town = $entity->fields["town"];
                 $values['entity_address'] = $entity->fields["address"];
                 $values['entity_postcode'] = $entity->fields["postcode"];
                 $values['entity_town'] = $entity->fields["town"];
                 $values['entity_country'] = $entity->fields["country"];
             }
             $supplier = new Supplier();
             if ($supplier->getFromDB($this->fields["suppliers_id"])) {
                 $values['supplier_name'] = $supplier->fields["name"];
                 $values['supplier_address'] = $supplier->fields["address"];
                 $values['supplier_postcode'] = $supplier->fields["postcode"];
                 $values['supplier_town'] = $supplier->fields["town"];
                 $values['supplier_country'] = $supplier->fields["country"];
             }
             $location = new Location();
             if ($location->getFromDB($this->fields["locations_id"])) {
                 $values['title_delivery_address'] = __("Delivery address", "order");
                 $values['comment_delivery_address'] = $location->fields['comment'];
             }
             if ($town) {
                 $town = $town . ", ";
             }
             $order_date = Html::convDate($this->fields["order_date"]);
             $username = Html::clean(getUserName(Session::getLoginUserID()));
             $values['title_date_order'] = $town . __("The", "order") . " ";
             $values['date_order'] = $order_date;
             $values['title_sender'] = __("Issuer order", "order");
             $values['sender'] = $username;
             $values['title_budget'] = __("Budget");
             $budget = new Budget();
             if ($budget->getFromDB($this->fields["budgets_id"])) {
                 $values['budget'] = $budget->fields['name'];
             } else {
                 $values['budget'] = '';
             }
             $output = '';
             $contact = new Contact();
             if ($contact->getFromDB($this->fields["contacts_id"])) {
                 $output = formatUserName($contact->fields["id"], "", $contact->fields["name"], $contact->fields["firstname"]);
             }
             $values['title_recipient'] = __("Recipient", "order");
             $values['recipient'] = Html::clean($output);
             $values['nb'] = __("Quantity", "order");
             $values['title_item'] = __("Designation", "order");
             $values['title_ref'] = __("Reference");
             $values['HTPrice_item'] = __("Unit price", "order");
             $values['TVA_item'] = __("VAT", "order");
             $values['title_discount'] = __("Discount rate", "order");
             $values['HTPriceTotal_item'] = __("Sum tax free", "order");
             $values['ATIPriceTotal_item'] = __("Price ATI", "order");
             $listeArticles = array();
             $result = $PluginOrderOrder_Item->queryDetail($ID);
             $num = $DB->numrows($result);
             while ($data = $DB->fetch_array($result)) {
                 $quantity = $PluginOrderOrder_Item->getTotalQuantityByRefAndDiscount($ID, $data["id"], $data["price_taxfree"], $data["discount"]);
                 $listeArticles[] = array('quantity' => $quantity, 'ref' => utf8_decode($data["name"]), 'taxe' => Dropdown::getDropdownName(getTableForItemType("PluginOrderOrderTax"), $data["plugin_order_ordertaxes_id"]), 'refnumber' => $PluginOrderReference_Supplier->getReferenceCodeByReferenceAndSupplier($data["id"], $this->fields["suppliers_id"]), 'price_taxfree' => $data["price_taxfree"], 'discount' => $data["discount"], false, 0, 'price_discounted' => $data["price_discounted"] * $quantity, 'price_ati' => $data["price_ati"]);
             }
             $article = $odf->setSegment('articles');
             foreach ($listeArticles as $element) {
                 $article->nbA($element['quantity']);
                 $article->titleArticle($element['ref']);
                 $article->refArticle($element['refnumber']);
                 $article->TVAArticle($element['taxe']);
//.........这里部分代码省略.........
开发者ID:pluginsGLPI,项目名称:order,代码行数:101,代码来源:order.class.php


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