本文整理汇总了PHP中Location::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::getFromDB方法的具体用法?PHP Location::getFromDB怎么用?PHP Location::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location::getFromDB方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
//.........这里部分代码省略.........
示例2: testTree
/**
* sons / ancestors for CommonTreeDropdown
*/
public function testTree() {
$entity = $this->sharedFixture['entity'][0];
$loc = new Location();
// A
$id[0] = $loc->add(array('entities_id' => $entity,
'locations_id' => 0,
'name' => 'A'));
$this->assertGreaterThan(0, $id[0]);
// A > AA
$id[1] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[0],
'name' => 'AA'));
$this->assertGreaterThan(0, $id[1]);
$this->assertTrue($loc->getFromDB($id[1]));
$this->assertEquals('A > AA', $loc->fields['completename']);
// A > BB
$id[2] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[0],
'name' => 'BB'));
$this->assertGreaterThan(0, $id[2]);
$this->assertTrue($loc->getFromDB($id[2]));
$this->assertEquals('A > BB', $loc->fields['completename']);
// Sons of A (A, AA, BB)
$sons = getSonsOf('glpi_locations',$id[0]);
$this->assertEquals(3, count($sons));
$this->assertArrayHasKey($id[0], $sons);
$this->assertArrayHasKey($id[1], $sons);
$this->assertArrayHasKey($id[2], $sons);
// Ancestors of A (none)
$parent = getAncestorsOf('glpi_locations', $id[0]);
$this->assertEquals(0, count($parent));
// Ancestors of AA (A)
$parent = getAncestorsOf('glpi_locations', $id[1]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// Ancestors of BB (none)
$parent = getAncestorsOf('glpi_locations', $id[2]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// B
$id[3] = $loc->add(array('entities_id' => $entity,
'locations_id' => 0,
'name' => 'B'));
$this->assertGreaterThan(0, $id[3]);
// B > CC
$id[4] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[3],
'name' => 'CC'));
$this->assertGreaterThan(0, $id[4]);
$this->assertTrue($loc->getFromDB($id[4]));
$this->assertEquals('B > CC', $loc->fields['completename']);
$sons = getSonsOf('glpi_locations',$id[3]);
$this->assertEquals(2, count($sons));
$this->assertArrayHasKey($id[4], $sons);
// B > CC > XXX
$id[5] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[4],
'name' => 'XXX'));
$this->assertGreaterThan(0, $id[5]);
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('B > CC > XXX', $loc->fields['completename']);
// B > CC => A > CC
$res = $loc->update(array('id' => $id[4],
'locations_id' => $id[0]));
$this->assertTrue($res);
$this->assertTrue($loc->getFromDB($id[4]));
$this->assertEquals('A > CC', $loc->fields['completename']);
// B > CC > XXX => A > CC > XXX
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('A > CC > XXX', $loc->fields['completename']);
// New parent of CC (A)
$parent = getAncestorsOf('glpi_locations', $id[4]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// New sons of B (only B)
$sons = getSonsOf('glpi_locations',$id[3]);
$this->assertEquals(1, count($sons));
$this->assertArrayHasKey($id[3], $sons);
// New sons of A (A, AA, BB, CC)
$sons = getSonsOf('glpi_locations',$id[0]);
//.........这里部分代码省略.........
示例3: 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()));
//.........这里部分代码省略.........
示例4: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
$datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
$datas['##ticket.content##'] = $datas['##ticket.description##'];
// Specific datas
$datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
$datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
$datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
$datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
$autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
$datas['##ticket.autoclose##'] = __('Never');
$datas['##lang.ticket.autoclosewarning##'] = "";
if ($autoclose_value > 0) {
$datas['##ticket.autoclose##'] = $autoclose_value;
$datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
}
$datas['##ticket.sla##'] = '';
if ($item->getField('slas_id')) {
$datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
}
$datas['##ticket.location##'] = '';
if ($item->getField('locations_id')) {
$datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
$locations = new Location();
$locations->getFromDB($item->getField('locations_id'));
if ($locations->getField('comment')) {
$datas['##ticket.location.comment##'] = $locations->getField('comment');
}
if ($locations->getField('room')) {
$datas['##ticket.location.room##'] = $locations->getField('room');
}
if ($locations->getField('building')) {
$datas['##ticket.location.building##'] = $locations->getField('building');
}
if ($locations->getField('latitude')) {
$datas['##ticket.location.latitude##'] = $locations->getField('latitude');
}
if ($locations->getField('longitude')) {
$datas['##ticket.location.longitude##'] = $locations->getField('longitude');
}
if ($locations->getField('altitude')) {
$datas['##ticket.location.altitude##'] = $locations->getField('altitude');
}
}
// is ticket deleted
$datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
//Tags associated with the object linked to the ticket
$datas['##ticket.itemtype##'] = '';
$datas['##ticket.item.name##'] = '';
$datas['##ticket.item.serial##'] = '';
$datas['##ticket.item.otherserial##'] = '';
$datas['##ticket.item.location##'] = '';
$datas['##ticket.item.locationcomment##'] = '';
$datas['##ticket.item.locationroom##'] = '';
$datas['##ticket.item.locationbuilding##'] = '';
$datas['##ticket.item.locationlatitude##'] = '';
$datas['##ticket.item.locationlongitude##'] = '';
$datas['##ticket.item.locationaltitude##'] = '';
$datas['##ticket.item.contact##'] = '';
$datas['##ticket.item.contactnumber##'] = '';
$datas['##ticket.item.user##'] = '';
$datas['##ticket.item.group##'] = '';
$datas['##ticket.item.model##'] = '';
$item_ticket = new Item_Ticket();
$items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
$datas['items'] = array();
if (count($items)) {
foreach ($items as $val) {
if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
$tmp = array();
//Object type
$tmp['##ticket.itemtype##'] = $hardware->getTypeName();
//Object name
$tmp['##ticket.item.name##'] = $hardware->getField('name');
//Object serial
if ($hardware->isField('serial')) {
$tmp['##ticket.item.serial##'] = $hardware->getField('serial');
}
//Object contact
if ($hardware->isField('contact')) {
$tmp['##ticket.item.contact##'] = $hardware->getField('contact');
}
//Object contact num
if ($hardware->isField('contact_num')) {
$tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
}
//Object otherserial
if ($hardware->isField('otherserial')) {
$tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
}
//Object location
if ($hardware->isField('locations_id')) {
$tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
//.........这里部分代码省略.........
示例5: transferDropdownLocation
/**
* Transfer location
*
* @param $locID location ID
*
* @return new location ID
**/
function transferDropdownLocation($locID)
{
global $DB;
if ($locID > 0) {
if (isset($this->already_transfer['locations_id'][$locID])) {
return $this->already_transfer['locations_id'][$locID];
}
// else // Not already transfer
// Search init item
$location = new Location();
if ($location->getFromDB($locID)) {
$data = Toolbox::addslashes_deep($location->fields);
$input['entities_id'] = $this->to;
$input['completename'] = $data['completename'];
$newID = $location->findID($input);
if ($newID < 0) {
$newID = $location->import($input);
}
$this->addToAlreadyTransfer('locations_id', $locID, $newID);
return $newID;
}
}
return 0;
}
示例6: addNetworkEthernetPort
/** Generate bigdump : Create networkport ethernet
*
* @since version 0.84
*
* @param $itemtype item type
* @param $items_id item ID
* @param $entities_id item entity ID
* @param $locations_id ID of the location trying to link with network equipment (default 0)
**/
function addNetworkEthernetPort($itemtype, $items_id, $entities_id, $locations_id=0) {
global $NET_LOC, $NET_PORT, $MAX, $VLAN_LOC;
// Add networking ports
$newIP = getNextIP();
$newMAC = getNextMAC();
if (($itemtype == 'NetworkEquipment') && $locations_id) {
// Find father locations_id;
$loc = new Location();
if ($loc->getFromDB($locations_id)) {
$locations_id = $loc->getField('locations_id');
} else {
$locations_id = 0;
}
}
//insert netpoint
$netpoint = new NetPoint();
$netpointID = $netpoint->add(toolbox::addslashes_deep(
array('entities_id' => $entities_id,
'locations_id' => $locations_id,
'name' => getNextNETPOINT(),
'comment' => "comment 'netpoint $locations_id")));
if ($locations_id && !isset($VLAN_LOC[$locations_id])) {
$vlanID = mt_rand(1,$MAX["vlan"]);
$VLAN_LOC[$locations_id] = $vlanID;
}
if (!isset($NET_PORT[$itemtype][$items_id])) {
$NET_PORT[$itemtype][$items_id]=0;
}
$np = new NetworkPort();
$nv = new NetworkPort_Vlan();
$newportname = "port of $itemtype-$items_id";
$refportID = 0;
if ($locations_id && isset($NET_LOC[$locations_id]) && $NET_LOC[$locations_id]) {
$refportname = "link 'port to $itemtype-$items_id";
$newportname .= " link to 'NetworkEquipment' -".$NET_LOC[$locations_id];
$newMAC2 = getNextMAC();
$newIP2 = getNextIP();
// Create new port on ref item
$param = toolbox::addslashes_deep(
array('itemtype' => 'NetworkEquipment',
'items_id' => $NET_LOC[$locations_id],
'entities_id' => $entities_id,
'logical_number' => $NET_PORT['NetworkEquipment'][$NET_LOC[$locations_id]]++,
'name' => "name '$refportname",
'instantiation_type' => 'NetworkPortEthernet',
'mac' => $newMAC2,
'comment' => "comment '$refportname",
'netpoints_id' => $netpointID,
'NetworkName_name' => "NetworkEquipment$itemtype-$items_id-$entities_id",
'NetworkName__ipaddresses' => array(-100 => $newIP2['ip']),
));
$np->splitInputForElements($param);
$refportID = $np->add($param);
$np->updateDependencies(1);
if (isset($VLAN_LOC[$locations_id]) && $refportID) {
$nv->add(array('networkports_id' => $refportID,
'vlans_id' => $VLAN_LOC[$locations_id]));
}
}
// $query = "INSERT INTO `glpi_networkports`
// VALUES (NULL, '$netwID', 'NetworkEquipment', '$ID_entity', '0',
// '".$NET_PORT['NetworkEquipment'][$netwID]++."',
// 'link port to netw ".$NET_LOC[$data['locations_id']]."',
// '".$newIP['ip']."', '$newMAC', '$iface', '$netpointID',
// '".$newIP['netwmask']."', '".$newIP['gateway']."',
// '".$newIP['subnet']."','comment')";
// $DB->query($query) or die("PB REQUETE ".$query);
$param = toolbox::addslashes_deep(
array('itemtype' => $itemtype,
'items_id' => $items_id,
'entities_id' => $entities_id,
'logical_number' => $NET_PORT[$itemtype][$items_id]++,
'name' => "name '$newportname",
'instantiation_type' => 'NetworkPortEthernet',
'mac' => $newMAC,
'comment' => "comment '$newportname",
'netpoints_id' => $netpointID,
'NetworkName_name' => "$itemtype-$items_id-$entities_id",
'NetworkName__ipaddresses' => array(-100 => $newIP['ip']),
));
$np->splitInputForElements($param);
//.........这里部分代码省略.........
示例7: while
}
if ($number) {
if ($config->fields['use_view_all_object'] && $_GET["name"] != "type") {
$current_location = '';
while ($data = $DB->fetch_array($result)) {
if (empty($current_location)) {
$children = array();
$level = 1;
$current_location = new Location();
$current_location->getFromDB($data['locations_id']);
} elseif ($current_location->fields['id'] != $data['locations_id']) {
array_push($out, array('text' => $current_location->fields['completename'], 'children' => $children));
$children = array();
$level = 1;
$current_location = new Location();
$current_location->getFromDB($data['locations_id']);
}
$output = $data[$field];
$ID = $data['id'];
if (empty($output)) {
$output = "({$ID})";
}
array_push($children, array('id' => $_GET['itemtype'] . ";" . $ID, 'text' => $output, 'level' => '1'));
$level++;
}
array_push($out, array('text' => $current_location->fields['completename'], 'children' => $children));
} else {
while ($data = $DB->fetch_array($result)) {
$output = $data[$field];
$ID = $data['id'];
if (empty($output)) {
示例8: updateLocation
/**
* Update location for a computer if needed after rule processing
*
* @param line_links
* @param data
*
* @return nothing
*/
static function updateLocation($line_links, $data)
{
//If there's a location to update
if (isset($data['locations_id'])) {
$computer = new Computer();
$computer->getFromDB($line_links['computers_id']);
$ancestors = getAncestorsOf('glpi_entities', $computer->fields['entities_id']);
$location = new Location();
if ($location->getFromDB($data['locations_id'])) {
//If location is in the same entity as the computer, or if the location is
//defined in a parent entity, but recursive
if ($location->fields['entities_id'] == $computer->fields['entities_id'] || in_array($location->fields['entities_id'], $ancestors) && $location->fields['is_recursive']) {
$tmp['locations_id'] = $data['locations_id'];
$tmp['id'] = $line_links['computers_id'];
$computer->update($tmp);
}
}
}
}
示例9: showAddFromPlugin
static function showAddFromPlugin($locations_id)
{
global $CFG_GLPI;
if (!Session::haveRight('plugin_positions', UPDATE)) {
return false;
}
echo "<div align='center'>";
echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/positions/front/position.form.php\" name='addfromplugin' id='addfromplugin'>";
$entity = $_SESSION["glpiactive_entity"];
$loc = new Location();
if ($loc->getFromDB($locations_id)) {
$entity = $loc->fields["entities_id"];
}
echo "<table class='tab_cadre' width='30%'>";
echo "<tr><th colspan='3'>" . __('Create coordinates', 'positions') . " :</th></tr>";
echo "<tr class='tab_bg_1'><td>";
echo _n('Associated item', 'Associated items', 2) . "</td>";
echo "<td>";
PluginPositionsImageItem::showAllItems("items_id", 0, 0, $entity, self::getTypes(), $locations_id);
echo "</td>";
echo "<td>";
echo "<input type='hidden' name='locations_id' value='" . $locations_id . "'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
示例10: testTreeImport
/**
* @covers Dropdown::import
* @covers CommonTreeDropdown::import
* @dataProvider dataTestTreeImport
*/
public function testTreeImport($input, $result, $complete, $msg)
{
$id = Dropdown::import('Location', $input);
if ($result) {
$this->assertGreaterThan(0, $id, $msg);
$ut = new Location();
$this->assertTrue($ut->getFromDB($id), $msg);
$this->assertEquals($result, $ut->getField('name'), $msg);
$this->assertEquals($complete, $ut->getField('completename'), $msg);
} else {
$this->assertLessThanOrEqual(0, $id, $msg);
}
}
示例11: testTreeImport
/**
* @covers Dropdown::import
* @covers CommonTreeDropdown::import
* @dataProvider dataTestTreeImport
*/
public function testTreeImport($input, $result, $complete, $msg)
{
$input['entities_id'] = getItemByTypeName('Entity', '_test_root_entity', true);
$id = Dropdown::import('Location', $input);
if ($result) {
$this->assertGreaterThan(0, $id, $msg);
$ut = new Location();
$this->assertTrue($ut->getFromDB($id), $msg);
$this->assertEquals($result, $ut->getField('name'), $msg);
$this->assertEquals($complete, $ut->getField('completename'), $msg);
} else {
$this->assertLessThanOrEqual(0, $id, $msg);
}
}
示例12: updateLocation
/**
* Update location for a computer if needed after rule processing
*
* @param $line_links
* @param $data
* @param $cfg_ocs
* @return nothing
* @internal param $line_links
* @internal param $data
*
*/
static function updateLocation($line_links, $data, $cfg_ocs)
{
//If there's a location to update
if (isset($data['locations_id'])) {
$computer = new Computer();
$computer->getFromDB($line_links['computers_id']);
$ancestors = getAncestorsOf('glpi_entities', $computer->fields['entities_id']);
$location = new Location();
if ($location->getFromDB($data['locations_id'])) {
//If location is in the same entity as the computer, or if the location is
//defined in a parent entity, but recursive
if ($location->fields['entities_id'] == $computer->fields['entities_id'] || in_array($location->fields['entities_id'], $ancestors) && $location->fields['is_recursive']) {
$ko = 0;
$locks = self::getLocksForComputer($line_links['computers_id']);
if (is_array($locks) && count($locks)) {
if (in_array("locations_id", $locks)) {
$ko = 1;
}
}
if ($ko == 0) {
$tmp['locations_id'] = $data['locations_id'];
$tmp['id'] = $line_links['computers_id'];
$computer->update($tmp, $cfg_ocs['history_hardware']);
}
}
}
}
}
示例13: showResult
//.........这里部分代码省略.........
$cptField = 13;
}
echo Search::showEndLine($output_type);
$num = 1;
$currentRack = -1;
while ($row = $DB->fetch_array($result)) {
// itemtype
$itemtype = $row['itemtype'];
$num = 1;
$cptRow++;
echo Search::showNewLine($output_type);
if (isset($row['itemtype']) && $row['itemtype'] != "") {
$class = substr($itemtype, 0, -5);
$item = new $class();
$table = getTableForItemType($class);
$r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' ");
$device = $DB->fetch_array($r);
}
// nom
$link = Toolbox::getItemTypeFormURL("PluginRacksRack");
if ($groupByRackName || $currentRack != $row['id']) {
if ($output_type == Search::HTML_OUTPUT) {
echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow);
} else {
echo Search::showItem($output_type, $row["name"], $num, $cptRow);
}
} else {
echo Search::showItem($output_type, " ", $num, $cptRow);
}
// lieu
if ($groupByRackName || $currentRack != $row['id']) {
$tmpId = $row['locations_id'];
$tmpObj = new Location();
$tmpObj->getFromDB($tmpId);
if (isset($tmpObj->fields['name'])) {
echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow);
} else {
echo Search::showItem($output_type, " ", $num, $cptRow);
}
} else {
echo Search::showItem($output_type, " ", $num, $cptRow);
}
// Emplacement
if ($groupByRackName || $currentRack != $row['id']) {
$tmpId = $row['plugin_racks_roomlocations_id'];
$tmpObj = new PluginRacksRoomLocation();
$tmpObj->getFromDB($tmpId);
if (isset($tmpObj->fields['name'])) {
echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow);
} else {
echo Search::showItem($output_type, ' ', $num, $cptRow);
}
} else {
echo Search::showItem($output_type, " ", $num, $cptRow);
}
if (isset($row['itemtype']) && $row['itemtype'] != "") {
// U
if (isset($row['position']) && $row['position'] != "") {
echo Search::showItem($output_type, $row['position'], $num, $cptRow);
} else {
echo Search::showItem($output_type, " ", $num, $cptRow);
}
// avant / arrière
if ($row['faces_id'] == 1) {
echo Search::showItem($output_type, __("Front", "racks"), $num, $cptRow);
} else {