source: trunk/www/Base/Types/PointerOneToOne.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
File size: 1.7 KB
Line 
1<?php
2
3class TypePointerOneToOne extends TypeBase
4{
5 function OnView($Item)
6 {
7 global $TypeDefinitionList;
8
9 $Type = $TypeDefinitionList[$Item['Type']];
10 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name FROM `'.$Type['Parameters']['Table'].'` WHERE `'.$Type['Parameters']['Id'].'`='.$Item['Value']);
11 $DbRow = $DbResult->fetch_assoc();
12 $Output = $DbRow['Name'];
13
14/* $Type = GetTypeDefinition($Item['Type']);
15 $List = GetListDefinition($Type['Parameters'][0]);
16 $TargetTable = $Type['Parameters'][0];
17 $TargetName = $this->GetTablePointerName($Type, $Item);
18 if($TargetName != '') $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName[$List['IdName']].'">'.$TargetName['Name'].'</a>';
19 else $Output = '';
20 */
21 return($Output);
22 }
23
24 function OnEdit($Item)
25 {
26 global $TypeDefinitionList;
27
28 $Output = '<select name="'.$Item['Name'].'">';
29 $Type = $TypeDefinitionList[$Item['Type']];
30 if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
31 else $Where = '';
32 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC');
33 while($DbRow = $DbResult->fetch_assoc())
34 {
35 if($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
36 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
37 }
38 $Output .= '</select>';
39 return($Output);
40 }
41
42 function OnLoad($Item)
43 {
44 return($_POST[$Item['Name']]);
45 }
46}
Note: See TracBrowser for help on using the repository browser.