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 PutRecordSetToCSV($recordSet, $file, $TERMINATED = ',', $ENCLOSED = '"', $LINES_TERMINATED = "\r\n") { global $filename; $fd = fopen($file, 'wb'); // пишем заголовки for ($i = 0; $i < $recordSet->FieldCount(); $i++) { $field = $recordSet->FetchField($i); $name = $field->name; /* if ( substr($name, 0, 3 ) == 'id_' && (substr($name, 2) != substr($filename, 2)) ) ClearCashe($name); */ fwrite($fd, $ENCLOSED . GetFieldProp($field->name) . $ENCLOSED . $TERMINATED); } fwrite($fd, $LINES_TERMINATED); // пишем данные foreach ($recordSet as $key => $row) { for ($i = 0; $i < $recordSet->FieldCount(); $i++) { $field = $recordSet->FetchField($i); $name = $field->name; $value = substr($name, 0, 3) == 'id_' && substr($name, 2) != substr($filename, 2) ? GetValueFromID($row[$i], $name, 300) : $row[$i]; fwrite($fd, $ENCLOSED . $value . $ENCLOSED . $TERMINATED); } fwrite($fd, $LINES_TERMINATED); } // while fclose($fd); // чистим кеш for ($i = 0; $i < $recordSet->FieldCount(); $i++) { $field = $recordSet->FetchField($i); $name = $field->name; if (substr($name, 0, 3) == 'id_' && substr($name, 2) != substr($filename, 2)) { ClearCashe($name); } } }
function GetRealValue( $value, $name ) { global $table; if ( substr($name, 0, 3 ) == 'id_' ) return GetValueFromID( $value, $name ); else return $value; }
while (!$recordSet->EOF) { $pdf->AddPage(); // создаем первую страницу, на которой будет содержимое if ($photo = $recordSet->fields['photo']) { $pdf->Image("/photos/{$photo}", 0, 0, 500); $pdf->setCellMargins(110); } for ($i = 0; $i < $recordSet->FieldCount(); $i++) { $field = $recordSet->FetchField($i); $name = $field->name; $value = $recordSet->fields[$i]; if (!$arr_field[$i]["is_view"] || $name == 'photo') { continue; } if (substr($name, 0, 2) == 'id' && substr($name, 2) != substr($table, 2) && $name != 'id') { $value = GetValueFromID($value, $name); } $type = $arr_field[$i]["type"]; $align = $type == 'checkbox' || $type == 'radio' ? 'C' : ($type == 'number' ? 'C' : 'L'); // Наименование поля $pdf->SetFont('freeserif', 'b', 12); $pdf->Cell(50, 0, $arr_field[$i]["field_name"], 1, 0, 'L'); $pdf->SetFont('', ''); if ($type == 'checkbox' || $type == 'radio') { $pdf->CheckBox($name, 12, $recordSet->fields[$i]); } else { $pdf->Cell(-$arr_field[$i]["length"], 0, $value ? $value : '-', 0, 0, 'L'); } $pdf->Ln(); //ПЕРЕВОД СТРОКИ }