Skip to content

Commit

Permalink
add secondary PC
Browse files Browse the repository at this point in the history
  • Loading branch information
rudnerbjoern committed Oct 18, 2024
1 parent 7a331b7 commit 491fd94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ The class `Workstation` is a child class of `PhysicalDevice`.
| Location | Foreign key to a Location | No |
| User | Foreign key to a Person/Contact | No |
| PC | Foreign key to a [PC](#pc) | Yes |
| Secondary PC | Foreign key to a [PC](#pc) | No |
| Docking Station | Foreign key to a [Docking Station](#dockingstation) | No |
| Monitor A | Foreign key to a [Monitor](#monitor) | No |
| Monitor B | Foreign key to a [Monitor](#monitor) | No |
Expand Down
28 changes: 27 additions & 1 deletion br-peripherals/datamodel.br-peripherals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@
<extkey_attcode>pc_id</extkey_attcode>
<target_attcode>name</target_attcode>
</field>
<field id="pcB_id" xsi:type="AttributeExternalKey">
<filter><![CDATA[SELECT PC AS obj JOIN Organization AS child ON obj.org_id = child.id JOIN Organization AS root ON child.parent_id BELOW root.id WHERE root.id=:this->org_id AND obj.workstation_id = 0]]></filter>
<dependencies>
<attribute id="org_id" />
</dependencies>
<sql>pcB_id</sql>
<target_class>PC</target_class>
<is_null_allowed>true</is_null_allowed>
<on_target_delete>DEL_MANUAL</on_target_delete>
<allow_target_creation>false</allow_target_creation>
</field>
<field id="pcB_name" xsi:type="AttributeExternalField">
<extkey_attcode>pcB_id</extkey_attcode>
<target_attcode>name</target_attcode>
</field>
<field id="monitorA_id" xsi:type="AttributeExternalKey">
<filter><![CDATA[SELECT Monitor AS obj JOIN Organization AS child ON obj.org_id = child.id JOIN Organization AS root ON child.parent_id BELOW root.id WHERE root.id=:this->org_id AND obj.workstation_id = 0]]></filter>
<dependencies>
Expand Down Expand Up @@ -319,7 +334,7 @@
<code>
<![CDATA[public static function GetPeripherals()
{
return array('pc_id','monitorA_id','monitorB_id','dockingstation_id',
return array('pc_id','pcB_id','monitorA_id','monitorB_id','dockingstation_id',
'keyboard_id','mouse_id','headset_id',
'mobilephone_id','telephonyA_id','telephonyB_id',
'printerA_id','printerB_id',
Expand Down Expand Up @@ -482,6 +497,12 @@ return array('pc_id','monitorA_id','monitorB_id','dockingstation_id',
// disconnect the old Workstation
$this->DisconnectTargetFromWorkstation($this->GetOriginal('pc_id'));
}
if (array_key_exists('pcB_id', $aChanges)) {
// record in the local memory object that the secondary PC was changed
$this->bPCBChanged = true;
// disconnect the old Workstation
$this->DisconnectTargetFromWorkstation($this->GetOriginal('pcB_id'));
}
if (array_key_exists('monitorA_id', $aChanges)) {
// record in the local memory object that the MonitorA was changed
$this->bMonitorAChanged = true;
Expand Down Expand Up @@ -590,6 +611,8 @@ return array('pc_id','monitorA_id','monitorB_id','dockingstation_id',
// The Workstation is updated in DB and assigned Peripherals changed
if (isset($this->bPCChanged))
$this->ConnectTargetToWorkstation($this->Get('pc_id'), $bUpdateLocations);
if (isset($this->bPCBChanged))
$this->ConnectTargetToWorkstation($this->Get('pcB_id'), $bUpdateLocations);
if (isset($this->bMonitorAChanged))
$this->ConnectTargetToWorkstation($this->Get('monitorA_id'), $bUpdateLocations);
if (isset($this->bMonitorBChanged))
Expand Down Expand Up @@ -718,6 +741,9 @@ return array('pc_id','monitorA_id','monitorB_id','dockingstation_id',
<item id="pc_id">
<rank>10</rank>
</item>
<item id="pcB_id">
<rank>15</rank>
</item>
<item id="monitorA_id">
<rank>20</rank>
</item>
Expand Down
1 change: 1 addition & 0 deletions br-peripherals/de.dict.br-peripherals.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'Class:Workstation+' => 'Ein Arbeitsplatz',
'Class:Workstation/Attribute:user_id' => 'Benutzer',
'Class:Workstation/Attribute:pc_id' => 'PC',
'Class:Workstation/Attribute:pcB_id' => 'Zweiter PC',
'Class:Workstation/Attribute:monitorA_id' => 'Bildschirm A',
'Class:Workstation/Attribute:monitorB_id' => 'Bildschirm B',
'Class:Workstation/Attribute:dockingstation_id' => 'Docking Station',
Expand Down
1 change: 1 addition & 0 deletions br-peripherals/en.dict.br-peripherals.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'Class:Workstation+' => 'A workstation',
'Class:Workstation/Attribute:user_id' => 'User',
'Class:Workstation/Attribute:pc_id' => 'PC',
'Class:Workstation/Attribute:pcB_id' => 'secondary PC',
'Class:Workstation/Attribute:monitorA_id' => 'Monitor A',
'Class:Workstation/Attribute:monitorB_id' => 'Monitor B',
'Class:Workstation/Attribute:dockingstation_id' => 'Docking station',
Expand Down

0 comments on commit 491fd94

Please sign in to comment.