source: types/PointerOneToOne.php@ 11

Last change on this file since 11 was 11, checked in by george, 17 years ago
  • Opraveno: Mazání položek nyní položku neodstraňuje z databáze, ale pouze ji označí za smazanou. Sloupce DeletionTime se nastaví na aktuální čas a položka nadále nebude zobrazována ve výpisech.
  • Opraveno: Načítání položek formuláře nyní prováděno přes událost OnLoad pro každý typ samostatně. Tímto také opraveno načítání hodnoty typu Boolean(checkbox) a Date(comboboxy datumu).
  • Opraveno: Správné zpracování typů nejenom podle id, ale také podle jména.
File size: 2.1 KB
Line 
1<?php
2
3function GetTablePointerName($Type, $Item)
4{
5 global $Database, $Lists;
6
7 $Columns = '';
8 $TargetTable = $Type['Parameters'][0];
9
10 foreach($Lists[$TargetTable]['Items'] as $ListItem)
11 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
12 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
13 $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$Item['Value']);
14 //echo($Database->LastQuery);
15 if($DbResult->num_rows > 0)
16 {
17 return($DbResult->fetch_assoc());
18 } else return('');
19}
20
21function GetTablePointerNameList($Type, $Item)
22{
23 global $Database, $Lists;
24
25 $Columns = '';
26 $TargetTable = $Type['Parameters'][0];
27
28 foreach($Lists[$TargetTable]['Items'] as $ListItem)
29 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
30 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
31 $DbResult = $Database->select($TargetTable, $Columns);
32 //echo($Database->LastQuery);
33 if($DbResult->num_rows > 0)
34 {
35 $Result = array();
36 while($DbRow = $DbResult->fetch_assoc())
37 $Result[] = $DbRow;
38 return($Result);
39 } else return(array());
40}
41
42function TypePointerOneToOneOnView($Item)
43{
44 global $Database, $Lists, $Types;
45
46 $Type = $Types[$Item['Type']];
47 $TargetTable = $Type['Parameters'][0];
48 $TargetName = GetTablePointerName($Type, $Item);
49 $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
50 return($Output);
51}
52
53function TypePointerOneToOneOnEdit($Item)
54{
55 global $Database, $Lists, $Types;
56
57 $Type = $Types[$Item['Type']];
58 $Output = '<select name="'.$Item['Name'].'">';
59 $TargetNameList = GetTablePointerNameList($Type, $Item);
60 //echo($Database->LastQuery);
61 foreach($TargetNameList as $TargetName)
62 {
63 if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
64 $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
65 }
66 $Output .= '</select>';
67 return($Output);
68}
69
70function TypePointerOneToOneOnLoad($Item)
71{
72 return($_POST[$Item['Name']]);
73}
74
75?>
Note: See TracBrowser for help on using the repository browser.