Ignore:
Timestamp:
Oct 11, 2008, 11:06:21 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Částečná podpora pro historii všech záznamů. Editace vytváří nový záznam. Zobrazení historie dané položky.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • types/PointerOneToOne.php

    r8 r9  
    11<?php
    22
    3 function TypePointerOneToOneViewHtml($Type, $Item)
     3function GetTablePointerName($Type, $Item)
    44{
    55  global $Database, $Lists;
    66
    7   //print_r($Type);
    8   $Output = '';
    97  $Columns = '';
    108  $ItemType = explode(':', $Item['Type']);
     
    1816  if($DbResult->num_rows > 0)
    1917  {
    20     $DbRow = $DbResult->fetch_array();
    21     $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>';
    22   }
     18    return($DbResult->fetch_assoc());
     19  } else return('');
     20}
     21
     22function GetTablePointerNameList($Type, $Item)
     23{
     24  global $Database, $Lists;
     25
     26  $Columns = '';
     27  $ItemType = explode(':', $Item['Type']);
     28  $TargetTable = $ItemType[1];
     29
     30  foreach($Lists[$TargetTable]['Items'] as $ListItem)
     31    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
     32  $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
     33  $DbResult = $Database->select($TargetTable, $Columns);
     34  //echo($Database->LastQuery);
     35  if($DbResult->num_rows > 0)
     36  {
     37    $Result = array();
     38    while($DbRow = $DbResult->fetch_assoc())
     39      $Result[] = $DbRow;
     40    return($Result);
     41  } else return(array());
     42}
     43
     44function TypePointerOneToOneViewHtml($Type, $Item)
     45{
     46  global $Database, $Lists;
     47
     48  $ItemType = explode(':', $Item['Type']);
     49  $TargetTable = $ItemType[1];
     50  $TargetName = GetTablePointerName($Type, $Item);
     51  $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
    2352  return($Output);
    2453}
     
    2958
    3059  $Output = '<select name="'.$Item['Name'].'">';
    31   $Columns = '';
    32   $ItemType = explode(':', $Item['Type']);
    33   $TargetTable = $ItemType[1];
    34   foreach($Lists[$TargetTable]['Items'] as $ListItem)
    35     if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    36   $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    37   $DbResult = $Database->select($TargetTable, $Columns);
     60  $TargetNameList = GetTablePointerNameList($Type, $Item);
    3861  //echo($Database->LastQuery);
    39   while($DbRow = $DbResult->fetch_array())
     62  foreach($TargetNameList as $TargetName)
    4063  {
    41     if($Parameter == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
    42     $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
     64    if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
     65    $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
    4366  }
    4467  $Output .= '</select>';
Note: See TracChangeset for help on using the changeset viewer.