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 GetFieldFromMacros( $type_date, $macros, $button, $onchange ) { global $fieldSet, $in_group, $macrosU; $text = $in_group = ''; // макросы могут повторяться, потому удаляем дубликаты $macrosU = array_map("unserialize",array_unique(array_map("serialize",$macros))); $type_date = ( (sizeof($macros) > 1) && ($type_date == 'week') ? 'date' : $type_date ); // создаем элементы ввода для макросов for( $i=0; $i <= sizeof($macrosU); $i++ ) { if ( !($param = $macrosU[$i][1]) ) continue; $required = ( $macrosU[$i][2] =='%%' ? 'required' : '' ); if ( strstr( $param, 'date' ) ) // выставляем поля для дат двух типов (день либо месяц) $text .= GetDateInput( $param, "ГГГГ-ММ-ДД", GetParamOrDefault( $param, ($type_date == 'date' ? strftime('%Y-%m-%d') : strftime('%Y-%m') ) ), "max-width:90%", $type_date, '', $onchange, "required title='$param'" ); else if( substr($param, 0, 3 ) == 'id_' ) { global $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $recordSet = runSQL("select * from rs_".substr($param, 3) ); $options = "<option value='-1' noselect >".($title=GetFieldProp( $param ))."</option>"; foreach( $recordSet as $key => $row ) $options .= "<option value='{$row[0]}'> {$row[1]}</option>"; $text .= GetGrouptitle()."<select class='form-control' name='$param' onchange='$onchange' style='max-width:90%' title='$title' $required value='-1' > $options </select>"; } else if ( strstr( $param, 'check' ) ) // выставляем галочки { $fieldName = substr($param, 6); $title = GetFieldProp( $fieldName ); $text .= GetGrouptitle()."<label class='checkbox-inline'> <input type='checkbox' name='$fieldName' value='".GetParamOrDefault( $param, '' )."' onchange='$onchange' title='$title' $required />$title</label>"; } else if ( substr($param, 0, 3 ) == 'or_' ) // необязательные текстовые поля { $fieldName = substr($param, 3); $title = GetFieldProp( $fieldName ); $text .= GetTextInput( $fieldName, $title, GetParamOrDefault( $param, '' ), "max-width:90%", 'search', '', '', "$required title='$title' data-param='or'" ); } else { $title = GetFieldProp( $param ); $text .= GetTextInput( $param, $title, GetParamOrDefault( $param, '' ), "max-width:90%", 'search', '', '', "$required title='$title'" ); } }// for if ( $in_group ) // закрываем последнюю группу $text .= '</fieldset>'; if ( (sizeof($macrosU) > 1) || ($button != '⏎') ) return $text."<button type='submit' name='Add' value='$button' > <span class='glyphicon glyphicon-import'></span> </button>"; else return "<div class='input-group'>$text<span class='input-group-btn'> <button class='btn btn-success' type='button'><span class='glyphicon glyphicon-download'></span></button> </span> </div>"; }
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 GetTitleParam($param) { if ( !$param || !($value=GetParamOrDefault( $param, '' )) ) return ''; if ( strstr( $param, 'check' ) ) return ( $value ? GetFieldProp( substr($param, 6) ) : '' ); else if ( strstr( $param, 'date' ) ) return " - '".GetFullStringDate($value)."'. "; else return GetFieldProp( $param ); // временно .'='.$value; }
} else { return; } } $pdf->SetTitle("Данные по {$table}"); //(30, 6, "Данные по $table", 1, 1, 'C'); // выводим ячейку с надписью шириной 30 мм и высотой 6 мм. Строка отцентрирована относительно границ ячейки if ($where = GetParamOrDefault('where', '')) { $table .= " where {$where}"; } $recordSet = runSQL("select * from {$table}", 20); // $pdf->setDefaultTableColumns( $recordSet->FieldCount() ); for ($i = 0; $i < $recordSet->FieldCount(); $i++) { $field = $recordSet->FetchField($i); $name = $field->name; $value = $recordSet->fields[$name]; $arr_field[$i]["field_name"] = $field_name = GetFieldProp($name); $arr_field[$i]["length"] = $length = $fieldSet->fields['field_len'] ? $fieldSet->fields['field_len'] / 2 : (($length = $field->max_length) < 51 ? $length : 50); $arr_field[$i]["type"] = $type = $fieldSet->fields['type_input'] ? $fieldSet->fields['type_input'] : StyleInput($field->type); $arr_field[$i]["is_view"] = !$fieldSet->EOF ? $fieldSet->fields['is_view'] : '1'; $align = $type == 'checkbox' || $type == 'radio' ? 'center' : ($type == 'number' ? 'center' : 'left'); $col_width = $length > 0 ? $length : GetLengthFromType($type); if ($align == 'center' && $col_width < 10) { $col_width = 10; } else { if ($type == 'number' && $col_width < 50) { $col_width = 50; } } /* else if ( $col_width < 80 ) $col_width = 80;