Commit 508c40c4 authored by cconard96's avatar cconard96 Committed by Johan Cwiklinski
Browse files

Add softwares on Phone items

parent ca51f36e
......@@ -16,6 +16,7 @@ The present file will list all changes made to the project; according to the
- Project task search options for Projects
- Automatic action to purge closed tickets
- Ability to automatically calculate project's percent done
- Software link on Phones.
### Changed
......@@ -46,6 +47,14 @@ The present file will list all changes made to the project; according to the
- All `TicketTemplate` classes has been renamed to `ITILTemplate`
- `Ticket::getTicketTemplateToUse()` renamed to `Ticket::getITILTemplateToUse()`
- `TicketTemplate::getFromDBWithDatas()` renamed to `Ticket::getFromDBWithData()` (inherited from `ITILTemplate`)
- `Computer_SoftwareLicense` replaced by `Item_SoftwareLicense`
- `Computer_SoftwareVersion` replaced by `Item_SoftwareVersion`
- `Item_SoftwareVersion::updateDatasForComputer` renamed to `Item_SoftwareVersion::updateDatasForItem`
- `Item_SoftwareVersion::showForComputer` renamed to `Item_SoftwareVersion::showForItem`
- `Item_SoftwareVersion::softsByCategory` renamed to `Item_SoftwareVersion::softwareByCategory`
- `Item_SoftwareVersion::displaySoftsByLicense` renamed to `Item_SoftwareVersion::displaySoftwareByLicense`
- `Item_SoftwareVersion::cloneComputer` renamed to `Item_SoftwareVersion::cloneItem`
- `Transfer::transferComputerSoftwares` renamed to `Transfer::transferItemSoftwares`
#### Removed
......
......@@ -73,6 +73,9 @@ if ($_POST["idtable"] && class_exists($_POST["idtable"])) {
if (isset($_POST['used'][$_POST['idtable']])) {
$p['used'] = $_POST['used'][$_POST['idtable']];
}
if (isset($_POST['width'])) {
$p['width'] = $_POST['width'];
}
echo Html::jsAjaxDropdown($_POST["name"], $field_id,
$CFG_GLPI['root_doc']."/ajax/".$link,
......
......@@ -35,14 +35,20 @@ use Glpi\Event;
include ('../inc/includes.php');
Session::checkRight("software", UPDATE);
$csl = new Computer_SoftwareLicense();
$isl = new Item_SoftwareLicense();
if (isset($_POST["add"])) {
if (!isset($_POST['itemtype']) || !isset($_POST['items_id']) || $_POST['items_id'] <= 0) {
$message = sprintf(__('Mandatory fields are not filled. Please correct: %s'),
_n('Item', 'Items', 1));
Session::addMessageAfterRedirect($message, false, ERROR);
Html::back();
}
if ($_POST['softwarelicenses_id'] > 0) {
if ($csl->add($_POST)) {
if ($isl->add($_POST)) {
Event::log($_POST['softwarelicenses_id'], "softwarelicense", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s associates a computer and a license'), $_SESSION["glpiname"]));
sprintf(__('%s associates an item and a license'), $_SESSION["glpiname"]));
}
}
Html::back();
......
......@@ -34,18 +34,20 @@ use Glpi\Event;
include ('../inc/includes.php');
Session::checkRight("software", UPDATE);
$inst = new Computer_SoftwareVersion();
Session::checkRight('software', UPDATE);
$inst = new Item_SoftwareVersion();
// From Computer - Software tab (add form)
if (isset($_POST["add"])) {
if (isset($_POST["computers_id"]) && $_POST["computers_id"]
&& isset($_POST["softwareversions_id"]) && $_POST["softwareversions_id"]) {
// From asset - Software tab (add form)
if (isset($_POST['add'])) {
if (isset($_POST['itemtype']) && isset($_POST['items_id']) && $_POST['items_id']
&& isset($_POST['softwareversions_id']) && $_POST['softwareversions_id']) {
if ($inst->add(['computers_id' => $_POST["computers_id"],
'softwareversions_id' => $_POST["softwareversions_id"]])) {
Event::log($_POST["computers_id"], "computers", 5, "inventory",
if ($inst->add([
'itemtype' => $_POST['itemtype'],
'items_id' => $_POST['items_id'],
'softwareversions_id' => $_POST['softwareversions_id']
])) {
Event::log($_POST["items_id"], $_POST['itemtype'], 5, "inventory",
//TRANS: %s is the user login
sprintf(__('%s installs software'), $_SESSION["glpiname"]));
}
......
......@@ -609,8 +609,8 @@ abstract class API extends CommonGLPI {
// retrieve computer softwares
if (isset($params['with_softwares'])
&& $params['with_softwares']
&& $itemtype == "Computer") {
&& $params['with_softwares']
&& in_array($itemtype, $CFG_GLPI['software_types'])) {
$fields['_softwares'] = [];
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
......@@ -620,16 +620,16 @@ abstract class API extends CommonGLPI {
'glpi_softwares.softwarecategories_id',
'glpi_softwares.id AS softwares_id',
'glpi_softwareversions.id AS softwareversions_id',
'glpi_computers_softwareversions.is_dynamic',
'glpi_items_softwareversions.is_dynamic',
'glpi_softwareversions.states_id',
'glpi_softwares.is_valid'
],
'FROM' => 'glpi_computers_softwareversions',
'FROM' => 'glpi_items_softwareversions',
'LEFT JOIN' => [
'glpi_softwareversions' => [
'ON' => [
'glpi_computers_softwareversions' => 'softwareversions_id',
'glpi_softwareversions' => 'id'
'glpi_items_softwareversions' => 'softwareversions_id',
'glpi_softwareversions' => 'id'
]
],
'glpi_softwares' => [
......@@ -640,8 +640,9 @@ abstract class API extends CommonGLPI {
]
],
'WHERE' => [
'glpi_computers_softwareversions.computers_id' => $id,
'glpi_computers_softwareversions.is_deleted' => 0
'glpi_items_softwareversions.items_id' => $id,
'glpi_items_softwareversions.itemtype' => $itemtype,
'glpi_items_softwareversions.is_deleted' => 0
],
'ORDERBY' => [
'glpi_softwares.name',
......
......@@ -281,6 +281,14 @@ function glpi_autoload($classname) {
Toolbox::deprecated('TicketFollowup has been replaced by ITILFollowup.');
}
// Deprecation warn for Computer_Software* classes
if ($classname === 'Computer_SoftwareLicense') {
Toolbox::deprecated('Computer_SoftwareLicense has been replaced by Item_SoftwareLicense.');
}
if ($classname === 'Computer_SoftwareVersion') {
Toolbox::deprecated('Computer_SoftwareVersion has been replaced by Item_SoftwareVersion.');
}
if ($plug = isPluginItemType($classname)) {
$plugname = strtolower($plug['plugin']);
$dir = GLPI_ROOT . "/plugins/$plugname/inc/";
......
......@@ -953,6 +953,12 @@ class CommonDBTM extends CommonGLPI {
Item_OperatingSystem::class
]);
}
if (in_array($this->getType(), $CFG_GLPI['software_types'])) {
$this->deleteChildrenAndRelationsFromDb([
Item_SoftwareVersion::class
]);
}
}
......
......@@ -44,7 +44,7 @@ class Computer extends CommonDBTM {
public $dohistory = true;
static protected $forward_entity_to = ['Item_Disk','ComputerVirtualMachine',
'Computer_SoftwareVersion', 'Infocom',
'Item_SoftwareVersion', 'Infocom',
'NetworkPort', 'ReservationItem',
'Item_OperatingSystem'];
// Specific ones
......@@ -77,7 +77,7 @@ class Computer extends CommonDBTM {
->addStandardTab('Item_OperatingSystem', $ong, $options)
->addStandardTab('Item_Devices', $ong, $options)
->addStandardTab('Item_Disk', $ong, $options)
->addStandardTab('Computer_SoftwareVersion', $ong, $options)
->addStandardTab('Item_SoftwareVersion', $ong, $options)
->addStandardTab('Computer_Item', $ong, $options)
->addStandardTab('NetworkPort', $ong, $options)
->addStandardTab('Infocom', $ong, $options)
......@@ -102,15 +102,15 @@ class Computer extends CommonDBTM {
function post_restoreItem() {
$comp_softvers = new Computer_SoftwareVersion();
$comp_softvers->updateDatasForComputer($this->fields['id']);
$comp_softvers = new Item_SoftwareVersion();
$comp_softvers->updateDatasForItem('Computer', $this->fields['id']);
}
function post_deleteItem() {
$comp_softvers = new Computer_SoftwareVersion();
$comp_softvers->updateDatasForComputer($this->fields['id']);
$comp_softvers = new Item_SoftwareVersion();
$comp_softvers->updateDatasForItem('Computer', $this->fields['id']);
}
......@@ -263,9 +263,9 @@ class Computer extends CommonDBTM {
Item_Disk::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
// ADD software
Computer_SoftwareVersion::cloneComputer($this->input["_oldID"], $this->fields['id']);
Item_SoftwareVersion::cloneItem('Computer', $this->input["_oldID"], $this->fields['id']);
Computer_SoftwareLicense::cloneComputer($this->input["_oldID"], $this->fields['id']);
Item_SoftwareLicense::cloneItem('Computer', $this->input["_oldID"], $this->fields['id']);
// ADD Contract
Contract_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
......@@ -294,8 +294,8 @@ class Computer extends CommonDBTM {
[
Certificate_Item::class,
Computer_Item::class,
Computer_SoftwareLicense::class,
Computer_SoftwareVersion::class,
Item_SoftwareLicense::class,
Item_SoftwareVersion::class,
ComputerAntivirus::class,
ComputerVirtualMachine::class,
Item_Disk::class,
......@@ -541,7 +541,7 @@ class Computer extends CommonDBTM {
if ($isadmin) {
$actions['Item_OperatingSystem'.MassiveAction::CLASS_ACTION_SEPARATOR.'update'] = OperatingSystem::getTypeName();
$actions['Computer_Item'.MassiveAction::CLASS_ACTION_SEPARATOR.'add'] = _x('button', 'Connect');
$actions['Computer_SoftwareVersion'.MassiveAction::CLASS_ACTION_SEPARATOR.'add'] = _x('button', 'Install');
$actions['Item_SoftwareVersion'.MassiveAction::CLASS_ACTION_SEPARATOR.'add'] = _x('button', 'Install');
$kb_item = new KnowbaseItem();
$kb_item->getEmpty();
......
This diff is collapsed.
This diff is collapsed.
......@@ -3309,9 +3309,9 @@ class Config extends CommonDBTM {
echo "<tr class='tab_bg_1'><th colspan='4'>"._n('Software', 'Software', 2)."</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>".
__("Installation/uninstallation of software on computers")."</td><td>";
self::showLogsInterval('purge_computer_software_install',
$CFG_GLPI["purge_computer_software_install"]);
__("Installation/uninstallation of software on items")."</td><td>";
self::showLogsInterval('purge_item_software_install',
$CFG_GLPI["purge_item_software_install"]);
echo "</td>";
echo "<td>".__("Installation/uninstallation versions on softwares")."</td><td>";
self::showLogsInterval('purge_software_version_install',
......@@ -3320,9 +3320,9 @@ class Config extends CommonDBTM {
echo "</tr>";
echo "<tr class='tab_bg_1'><td class='center'>".
__("Add/Remove computers from software versions")."</td><td>";
self::showLogsInterval('purge_software_computer_install',
$CFG_GLPI["purge_software_computer_install"]);
__("Add/Remove items from software versions")."</td><td>";
self::showLogsInterval('purge_software_item_install',
$CFG_GLPI["purge_software_item_install"]);
echo "</td>";
echo "</tr>";
......
......@@ -443,8 +443,8 @@ $CFG_GLPI['lock_lockable_objects'] = ['Budget', 'Change', 'Contact', 'Contract'
'RSSFeed', 'Software', 'Supplier', 'Ticket', 'User',
'SoftwareLicense', 'Certificate'];
$CFG_GLPI['inventory_lockable_objects'] = ['Computer_Item', 'Computer_SoftwareLicense',
'Computer_SoftwareVersion', 'Item_Disk', 'ComputerVirtualMachine',
$CFG_GLPI['inventory_lockable_objects'] = ['Computer_Item', 'Item_SoftwareLicense',
'Item_SoftwareVersion', 'Item_Disk', 'ComputerVirtualMachine',
'NetworkPort', 'NetworkName', 'IPAddress'];
$CFG_GLPI["kb_types"] = ['Budget', 'Change', 'Computer',
......@@ -465,6 +465,8 @@ $CFG_GLPI["cluster_types"] = ['Computer', 'NetworkEquipment'];
$CFG_GLPI['operatingsystem_types'] = ['Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'];
$CFG_GLPI['software_types'] = ['Computer', 'Phone'];
$CFG_GLPI['javascript'] = [
'central' => [
'central' => ['fullcalendar', 'tinymce']
......
This diff is collapsed.
This diff is collapsed.
......@@ -411,8 +411,7 @@ class Item_Ticket extends CommonDBRelation{
self::dropdownMyDevices($dev_user_id, $ticket->fields["entities_id"], null, 0, ['tickets_id' => $instID]);
}
$data = array_keys(getAllDataFromTable('glpi_items_tickets'));
$used = self::getUsedItems($ticket->fields['id']);
$used = self::getUsedItems($instID);
self::dropdownAllDevices("itemtype", null, 0, 1, $dev_user_id, $ticket->fields["entities_id"], ['tickets_id' => $instID, 'used' => $used, 'rand' => $rand]);
echo "<span id='item_ticket_selection_information$rand'></span>";
echo "</td><td class='center' width='30%'>";
......@@ -822,6 +821,69 @@ class Item_Ticket extends CommonDBRelation{
}
}
}
// Get software linked to all owned items
if (in_array('Software', $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) {
$software_helpdesk_types = array_intersect($CFG_GLPI['software_types'], $_SESSION["glpiactiveprofile"]["helpdesk_item_type"]);
foreach ($software_helpdesk_types as $itemtype) {
if (isset($already_add[$itemtype]) && count($already_add[$itemtype])) {
$iterator = $DB->request([
'SELECT' => [
'glpi_softwareversions.name AS version',
'glpi_softwares.name AS name',
'glpi_softwares.id'
],
'DISTINCT' => true,
'FROM' => 'glpi_items_softwareversions',
'LEFT JOIN' => [
'glpi_softwareversions' => [
'ON' => [
'glpi_items_softwareversions' => 'softwareversions_id',
'glpi_softwareversions' => 'id'
]
],
'glpi_softwares' => [
'ON' => [
'glpi_softwareversions' => 'softwares_id',
'glpi_softwares' => 'id'
]
]
],
'WHERE' => [
'glpi_items_softwareversions.items_id' => $already_add[$itemtype],
'glpi_items_softwareversions.itemtype' => $itemtype,
'glpi_softwares.is_helpdesk_visible' => 1
] + getEntitiesRestrictCriteria('glpi_softwares', '', $entity_restrict),
'ORDERBY' => 'glpi_softwares.name'
]);
$devices = [];
if (count($iterator)) {
$item = new Software();
$type_name = $item->getTypeName();
if (!isset($already_add['Software'])) {
$already_add['Software'] = [];
}
while ($data = $iterator->next()) {
if (!in_array($data["id"], $already_add['Software'])) {
$output = sprintf(__('%1$s - %2$s'), $type_name, $data["name"]);
$output = sprintf(__('%1$s (%2$s)'), $output,
sprintf(__('%1$s: %2$s'), __('version'),
$data["version"]));
if ($_SESSION["glpiis_ids_visible"]) {
$output = sprintf(__('%1$s (%2$s)'), $output, $data["id"]);
}
$devices["Software_".$data["id"]] = $output;
$already_add['Software'][] = $data["id"];
}
}
if (count($devices)) {
$my_devices[__('Installed software')] = $devices;
}
}
}
}
}
// Get linked items to computers
if (isset($already_add['Computer']) && count($already_add['Computer'])) {
$devices = [];
......@@ -885,65 +947,6 @@ class Item_Ticket extends CommonDBRelation{
if (count($devices)) {
$my_devices[__('Connected devices')] = $devices;
}
// Software
if (in_array('Software', $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) {
$iterator = $DB->request([
'SELECT' => [
'glpi_softwareversions.name AS version',
'glpi_softwares.name AS name',
'glpi_softwares.id'
],
'DISTINCT' => true,
'FROM' => 'glpi_computers_softwareversions',
'LEFT JOIN' => [
'glpi_softwareversions' => [
'ON' => [
'glpi_computers_softwareversions' => 'softwareversions_id',
'glpi_softwareversions' => 'id'
]
],
'glpi_softwares' => [
'ON' => [
'glpi_softwareversions' => 'softwares_id',
'glpi_softwares' => 'id'
]
]
],
'WHERE' => [
'glpi_computers_softwareversions.computers_id' => $already_add['Computer'],
'glpi_softwares.is_helpdesk_visible' => 1
] + getEntitiesRestrictCriteria('glpi_softwares', '', $entity_restrict),
'ORDERBY' => 'glpi_softwares.name'
]);
$devices = [];
if (count($iterator)) {
$tmp_device = "";
$item = new Software();
$type_name = $item->getTypeName();
if (!isset($already_add['Software'])) {
$already_add['Software'] = [];
}
while ($data = $iterator->next()) {
if (!in_array($data["id"], $already_add['Software'])) {
$output = sprintf(__('%1$s - %2$s'), $type_name, $data["name"]);
$output = sprintf(__('%1$s (%2$s)'), $output,
sprintf(__('%1$s: %2$s'), __('version'),
$data["version"]));
if ($_SESSION["glpiis_ids_visible"]) {
$output = sprintf(__('%1$s (%2$s)'), $output, $data["id"]);
}
$devices["Software_".$data["id"]] = $output;
$already_add['Software'][] = $data["id"];
}
}
if (count($devices)) {
$my_devices[__('Installed software')] = $devices;
}
}
}
}
echo "<div id='tracking_my_devices'>";
echo __('My devices')."&nbsp;";
......
This diff is collapsed.
......@@ -72,6 +72,7 @@ class Phone extends CommonDBTM {
$ong = [];
$this->addDefaultFormTab($ong);
$this->addStandardTab('Item_OperatingSystem', $ong, $options);
$this->addStandardTab('Item_SoftwareVersion', $ong, $options);
$this->addStandardTab('Item_Devices', $ong, $options);
$this->addStandardTab('Computer_Item', $ong, $options);
$this->addStandardTab('NetworkPort', $ong, $options);
......
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment