CommonDBTM::getComments PHP 메소드

getComments() 공개 메소드

Get comments of the Object
public getComments ( ) : String:
리턴 String:
    function getComments()
    {
        $comment = "";
        $toadd = array();
        if ($this->isField('completename')) {
            $toadd[] = array('name' => __('Complete name'), 'value' => nl2br($this->getField('completename')));
        }
        if ($this->isField('serial')) {
            $toadd[] = array('name' => __('Serial number'), 'value' => nl2br($this->getField('serial')));
        }
        if ($this->isField('otherserial')) {
            $toadd[] = array('name' => __('Inventory number'), 'value' => nl2br($this->getField('otherserial')));
        }
        if ($this->isField('states_id') && $this->getType() != 'State') {
            $tmp = Dropdown::getDropdownName('glpi_states', $this->getField('states_id'));
            if (strlen($tmp) != 0 && $tmp != ' ') {
                $toadd[] = array('name' => __('Status'), 'value' => $tmp);
            }
        }
        if ($this->isField('locations_id') && $this->getType() != 'Location') {
            $tmp = Dropdown::getDropdownName("glpi_locations", $this->getField('locations_id'));
            if (strlen($tmp) != 0 && $tmp != ' ') {
                $toadd[] = array('name' => __('Location'), 'value' => $tmp);
            }
        }
        if ($this->isField('users_id')) {
            $tmp = getUserName($this->getField('users_id'));
            if (strlen($tmp) != 0 && $tmp != ' ') {
                $toadd[] = array('name' => __('User'), 'value' => $tmp);
            }
        }
        if ($this->isField('groups_id') && $this->getType() != 'Group') {
            $tmp = Dropdown::getDropdownName("glpi_groups", $this->getField('groups_id'));
            if (strlen($tmp) != 0 && $tmp != ' ') {
                $toadd[] = array('name' => __('Group'), 'value' => $tmp);
            }
        }
        if ($this->isField('users_id_tech')) {
            $tmp = getUserName($this->getField('users_id_tech'));
            if (strlen($tmp) != 0 && $tmp != ' ') {
                $toadd[] = array('name' => __('Technician in charge of the hardware'), 'value' => $tmp);
            }
        }
        if ($this->isField('contact')) {
            $toadd[] = array('name' => __('Alternate username'), 'value' => nl2br($this->getField('contact')));
        }
        if ($this->isField('contact_num')) {
            $toadd[] = array('name' => __('Alternate username number'), 'value' => nl2br($this->getField('contact_num')));
        }
        if (InfoCom::canApplyOn($this)) {
            $infocom = new Infocom();
            if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
                $toadd[] = array('name' => __('Warranty expiration date'), 'value' => Infocom::getWarrantyExpir($infocom->fields["warranty_date"], $infocom->fields["warranty_duration"], 0, true));
            }
        }
        if ($this instanceof CommonDropdown && $this->isField('comment')) {
            $toadd[] = array('name' => __('Comments'), 'value' => nl2br($this->getField('comment')));
        }
        if (count($toadd)) {
            foreach ($toadd as $data) {
                // Do not use SPAN here
                $comment .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $data['name'], "</strong>" . $data['value']);
            }
        }
        if (!empty($comment)) {
            return Html::showToolTip($comment, array('display' => false));
        }
        return $comment;
    }
CommonDBTM