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 GetTableHeads($order) { global $recordSet, $fieldSet, $arr_field, $table, $onsubmit, $action, $th2, $width_all, $admin_true, $current_params; $th1 = $th2 = $in_group =''; $width_all = 30; // padding bootramp 15px $output_text = "<output name='State'>⎋</output>"; for( $i = 0; $i < $recordSet->FieldCount(); $i++ ) // проходит по полям { $field = $recordSet->FetchField($i); // print_r($recordSet->FetchField($i)); //проверить потом multiple_key; $arr_field[$i]["name"] = $name = $field->name; if ( ($name == 'primary') || ( $field->primary_key ) ) { $th1 .= WrapTH( $name, "<a href='show_tovar.php$current_params".( $admin_true ? '' : '&admin' )."' > <img src='http://solution.artel.ws/images/ddn.png' /> </a>", WIDTH_FIRST_COL ); if ( $admin_true ) // создаем форму для добавления элемента { $th2 .= WrapTH( $name, "$output_text<input id='btnId' type='image' src='http://solution.artel.ws/images/add.png' form='fFilter' title='Добавить новую запись' style='display:none;' />", WIDTH_FIRST_COL ); } else $th2 .= WrapTH( $name, "$output_text<button id='btnId' value='♋︎' form='fFilter' title='Очистить фильтры' hidden onclick='return PLayFilter( this );' class='btn-info'> <span class='glyphicon glyphicon-arrow-up'></span> </button>", WIDTH_FIRST_COL ); $width_all += 30; continue; } if ( ($name == 'id') || ($name == 'photo') ) continue; $arr_field[$i]["field_name"] = $field_name = GetFieldProp($name); $arr_field[$i]["is_view"] = ( !$fieldSet->EOF ? $fieldSet->fields['is_view'] : '1' ); if ( !($admin_true || $arr_field[$i]["is_view"]) ) continue; // сохраняем настройки слобцов для последующего показа в глобальном массиве $arr_field $arr_field[$i]["type"] = $type = ( $fieldSet->fields['type_input'] ? $fieldSet->fields['type_input'] : StyleInput( $field->type ) ); $arr_field[$i]["length"] = $length = ( $fieldSet->fields['field_len'] ? $fieldSet->fields['field_len'] : ( ($length = $field->max_length) <151 ? $length : 150) ); $arr_field[$i]["in_table"] = $in_table = ( $fieldSet->fields['in_table'] ? $fieldSet->fields['in_table'] : ''); $arr_field[$i]["formula"] = $fieldSet->fields['formula']; $arr_field[$i]["url"] = $fieldSet->fields['url']; $style = $arr_field[$i]["style"] = $fieldSet->fields['style']; if (substr($name, 0, 3 ) == 'id_' && (substr($name, 2) != substr($table, 2)) && (substr($name, 3) != $table) ) { $in_table = substr($name, 3); $type = 'select'; } $align = ( ($type=='checkbox') || ($type=='radio') ? 'center' : 'left' ); $temp = $col_width = ( ($align != 'center') && ($length > 5) ? $length : GetLengthFromType($type) ); if ( $align == 'center' ) $col_width = ( ($col_width < 55) ? 55 : $col_width ); else if ( $type=='number' ) $col_width = ($col_width < 55 ? 55 : $col_width ); else if ( $col_width < 75 ) $col_width = 75; else if ( $col_width > 550 ) $col_width = 550; $arr_field[$i]["col_width"] = $col_width; $style = "width:$col_width;"; $width_all += $col_width; $order_type = "&order=$name"; $field_title= 'Нажмите, чтобы сортировать по возрастанию'; $sort_arrow = ''; // готовим сортировку для нажатия по имени поля if ($order == "$name desc" ) { $sort_arrow = '<span class="glyphicon glyphicon-sort-by-attributes-alt"></span>'; $field_title= 'Отсортировано по убыванию, нажмите, чтобы сортировать по возрастанию'; } else if ($order == $name) { $order_type .= '%20desc'; $sort_arrow = '<span class="glyphicon glyphicon-sort-by-attributes"></span>'; $field_title= 'Отсортировано по возрастанию, нажмите, чтобы сортировать по убыванию'; } if ( strstr( $current_params, 'order') ) { $new_params = preg_replace( '/&order=[^&]+/', $order_type, $current_params ); } else $new_params = $current_params.$order_type; if ( $in_group != $fieldSet->fields['name_group'] ) { if ( $in_group ) // закрываем старую группу $th1 .= '</div>'; if ( ($in_group = $fieldSet->fields['name_group']) ) // начинаем новую группу $th1 .= "<div class='td'> <p class='name_group' > $in_group</p> "; } // строка заголовков столбцов $th1 .= WrapTH( $name, "<a href='show_tovar.php$new_params' title='$field_title' >$field_name$sort_arrow</a>", $style ); // строка фильтров либо добавления новой записи $th2.= WrapTH( $name, GetInputFromType( $type, $name, ( $admin_true && isset( $_REQUEST[$name] ) ? $_REQUEST[$name] : '' ), $style, 'fFilter', $in_table, $field_name, ( $admin_true ? 'return FormIsModified( event, this.form);' : 'return FilterIsModified( event, this );' ) ), '', $align ); } $th2 = WrapSimpleForm( 'fFilter', ( $admin_true ? "$action.php" : ''), GetHiddenInput('table', $table).GetHiddenInput('key_name', $name).$th2, "margin:0", '', "class='thead'" ); return $th1; }
//(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; */ $arr_field[$i]["length"] = $col_width; } //for while (!$recordSet->EOF) {