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 }
function GetTableRecords($order) { global $recordSet, $fieldSet, $table, $onsubmit, $arr_field, $admin_true; $order_value = ''; $output_text = "<output name='State'>✎</output>"; foreach($recordSet as $k => $row) { $photo = ( $row['photo'] ? $row['photo'] : $row['primary'] ); $photo_img = ( $photo ? "<img src='$photo' class='photo_max' /> <span class='glyphicon glyphicon-eye-open'></span>" : "<span class='glyphicon glyphicon-eye-close'></span>" ); $style_div = ( $order && ($order_value != $row[$order]) // отчертим предыдущие значения ? 'border-top: 1px inset; padding-top: 1px;' : '' ); $text = ''; for( $i = 0; $i < $recordSet->FieldCount(); $i++ ) { $field = $recordSet->FetchField($i); $name = $arr_field[$i]["name"]; $value = $row[$i]; if ( ($name == 'primary') || ( $field->primary_key ) ) // потом разобраться, чтобы это было одно поле { $id = $value; $formName = "f$table$id"; if ( $admin_true ) $text .= WrapTD( $name, "$output_text<input type='image' src='http://solution.artel.ws/images/valid.png' value='Сохранить' form='$formName' style='display:none;' title='Сохранить изменения'/> ", WIDTH_FIRST_COL ); else $text .= WrapTD( $name, "<a target='_blank' href='show_record.php?table=$table&id=$value&key_id=$name' > $photo_img</a> ", WIDTH_FIRST_COL, 'left' ); continue; } if ( ($name == 'id') || !($admin_true || $arr_field[$i]["is_view"]) || ($name == 'photo') ) continue; $type = $arr_field[$i]["type"]; $length = $arr_field[$i]["length"]; $col_width = $arr_field[$i]["col_width"]; $field_name = $arr_field[$i]["field_name"]; $in_table = $arr_field[$i]["in_table"]; $style = $arr_field[$i]["style"]; $url=$arr_field[$i]["url"]; $align = ( (($type=='checkbox') || ($type=='radio')) ? 'center' : ( ($type=='number') ? 'center' : 'left' ) ); $style .= "max-width:550px;min-width:".( $align == 'center' ? '10px;' : ( ($type=='number') ? '50px' : '70px').";width:$col_width;" ); //."margin: auto;"; if ( $admin_true && ($name != 'date_sys') ) $text .= WrapTD( $name, GetInputFromType( $type, $name, $value, $style, $formName, $in_table, $field_name), $style.";margin: auto;height: auto;width:$col_width;", $align ); else { if ( ($order == $name) ) { $order_value = $value; } if (substr($name, 0, 3 ) == 'id_' && (substr($name, 2) != substr($table, 2)) ) { $value = GetValueFromID( $value, $name ); $text .= WrapTD( $name, ( $url ? GetURLField( $url, $value ) : $value ), $style, $align ); } elseif ($name == 'photo') $text .= WrapTD( $name, "<a href='/photos/$value' class='fancybox-button' rel='collection'> <img src='/photos/$value' style='$style'/> <img src='/photos/$value' class='photo_max' /> </a>", $style, 'center' ); else { if ( !($value) && $arr_field[$i]["formula"] ) $value = GetValueFormula( $arr_field[$i]["formula"] ); $text .= WrapTD( $name, ( (($type=='checkbox') || ($type=='radio')) ? ( $value ? "✔︎" : "✖︎" )/* GetTextInput( $name, '', $value, $style, $type, '', '' ) */ : ( $value ? ( $url ? GetURLField( $url, $value ) : $value ) : '-')), $style.";margin: auto;height: auto;", $align ); } } } //for по полям if ( $admin_true ) echo WrapSimpleForm( $formName, "add_record_in_table.php", GetHiddenInput('table', $table).GetHiddenInput('key_name', $name).GetHiddenInput( $name, $value ).$text, $style_div.'margin:0', 'Изменить запись', 'class=tr' ); else echo "<div class='tr' style='$style_div' >$text</div>"; } // while по записям }