-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_record.php
88 lines (72 loc) · 3.29 KB
/
show_record.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
function WrapDIV( $name, $text, $style, $align='div100' ) {
return "<div name='$name' style='$style' class='td'> <strong>$name</strong> : $text </div>";
}
function GetRecords() {
global $recordSet, $fieldSet, $table, $onsubmit, $arr_field;
for( $i = 0; $i < $recordSet->FieldCount(); $i++ )
{
$field = $recordSet->FetchField($i);
$name = $field->name;
$value = $recordSet->fields[$name];
if ( $field->primary_key )
{
$id = $value;
$formName = "f$table$id";
if ( isAdmin() )
echo WrapDIV( $name, WrapForm( $formName, "add_record_in_table.php", $onsubmit, GetHiddenInput('table', $table).GetHiddenInput('key_name', 'id').GetHiddenInput( $name, $value )."<input type='image' src='http://solution.artel.ws/images/valid.png' value='Сохранить' form='$formName' hidden title='Сохранить изменения'/> ", "max-width:100%;" ) );
else
echo WrapDIV( $name, "<a target='_blank' href='show_record.php?table=$table&id=$value&key_id=$name' onmousemove='this.click();' > <img src='http://solution.artel.ws/images/eye.png' /> </a>", 'max-width:100%;', 'left' );
continue;
}
$field_name = GetFieldProp($name);
if ( ($name == 'id') || !(isAdmin() || ( !$fieldSet->EOF ? $fieldSet->fields['is_view'] : '1' ) ) )
continue;
$type = ( $fieldSet->fields['type_input'] ? $fieldSet->fields['type_input'] : StyleInput( $field->type ) );
$formula = $fieldSet->fields['formula'];
$length = ( $fieldSet->fields['field_len'] ? $fieldSet->fields['field_len'] : $field->max_length );;
$col_width = ( $length > 5 ? $length *10 : GetLengthFromType($type) )."px";
$style = "min-width:$col_width;float:left;";
if ( isAdmin() )
echo WrapDIV( $name, GetInputFromType( $type, $name, $value, "width:100%;max-width:150px;", $formName, $in_table, $field_name), $style );
else
{
if (substr($name, 0, 2 ) == 'id' && (substr($name, 2) != substr($table, 2)) )
echo WrapDIV( $field_name, GetValueFromID( $value, $name ), $style );
elseif ($name == 'photo')
echo WrapDIV( $field_name, "<a href='/photos/$value' class='fancybox-button' rel='collection'> <img src='/photos/$value' style='$style'/> </a>", $style, 'center' );
else
{
if ( !($value) && $formula )
$value = GetValueFormula( $formula );
echo WrapDIV( $field_name, ( (($type=='checkbox') || ($type=='radio')) ? GetTextInput($name, '', $value, $style, $type, '', '' ) : ( $value ? $value : '-') ), $style );
}
}
} //for
}
if ( !isset($_REQUEST['table']) )
return;
try
{
include_once("params.php");
include_once('config_db.php');
$order = $fieldSet = $recordSet = '';
$arr_field = array();
$table = $_REQUEST['table'];
$key_id = $_REQUEST['key_id'];
$id = $_REQUEST['id'];
$recordSet = runSQL( "select * from $table where $key_id=$id".(isset($_REQUEST['order']) ? " order by ".($order=$_REQUEST['order']) : '') );
?>
<div class='row'>
<?=GetRecords()?>
</div>
<?php
}
catch(Exception $e)
{
$_SESSION['errors'] = $conn->ErrorMsg();
$_SESSION['error_class'] = $e;
$_SESSION['error_time'] = date('d.m.y H:i:s');
echo "Ошибка. Подробности смотри <a href='error_log.php' target='_blank'>тут </a>.";
}
?>