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 GetCategoryByParent( $key_parent, $parent_name='', $title_parent='', $null_category=FALSE ) { global $adminTrue, $show_tovar, $show_category; $addForm = $text = $clickTovarEdit = $for_user = ''; $symbol_form = "<span class='glyphicon glyphicon-collapse-down'></span>"; $symbol_form1 = "<span class='glyphicon glyphicon-collapse-up'></span>"; $symbol_add_li = "<span class='glyphicon glyphicon-collapse-down collapsible' style='float:rigth;' ></span>"; if ( $adminTrue ) { $parent_name = ($key_parent > 0 ? " в $parent_name": 'подуровень' ); $clickTovarEdit = ' onclick="'; $nameForm = "fCategory$key_parent"; // создание нового элемента, содержащего данные ( и новой таблицы в БД при необходимости ) $addForm = //"<li onclick='$(this).children(1).toggle(); return ExpandParents(this);'>Добавить $parent_name $symbol_form "<span class='glyphicon glyphicon-plus pop_menu' target='content' onclick='return ShowOknoAndExpandParents(this);' data-href='show_form.php?key_parent=$key_parent&parent_name=$parent_name' title='Добавить элемент'></span>"; // по клику будет вызываться форма для создания новой подкатегории $addForm .= "<span class='glyphicon glyphicon-collapse-down pop_menu' onclick='$(this).next().toggle(); return false;' title='Добавить подуровень'> ". WrapForm( $nameForm, "add_record_in_table.php", 'return SaveObject( this, "key_category" );', GetHiddenInput('key_parent', $key_parent).GetHiddenInput("table" , "category").GetHiddenInput("key_name" , "key_category").GetTextInput("name", 'Название', '', "width:90%", 'search', $nameForm, null, 'required')/* GetTextArea("sql_text", "Код sql для отбора данных (после from)", '', "width:90%", $nameForm, null, 'required') */."<input hidden type=submit name=Add value='Добавить $parent_name'/>", 'width:230px;display:none;float:left' ).'</span>'; //</li>'; } else if ( isset($_REQUEST['user']) && ($key_parent == 0) ) $for_user = "******"; global $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $strwhere = "select * from category where key_parent = $key_parent and is_view = 1 $for_user order by leaf, name" ; // echo $strwhere; $recordSet = runSQL( $strwhere ); $count = 1; while (!$recordSet->EOF) { $count++; /* if ( ($key_parent == 0) && ($text) ) $text .= "<img src='images/vensel.png' />"; */ /* else if ($count++ == 8) $text .= "<li style='float:left'>Показать больше</li> $symbol_add_li <ul>"; */ $name_category = trim( $recordSet->fields['name'] ); $key_category = $recordSet->fields['key_category']; $table = $recordSet->fields['sql_text']; $title = ( $title_parent ? $title_parent.' > '.$name_category : $name_category); $memo = htmlspecialchars( $recordSet->fields['memo'] ); $href_tovary = "show_tovar.php?key_parent=$key_category$adminTrue"; $href_category = "show_tovar.php?key_parent=$key_category&category&catalog$adminTrue&title=$title"; $submenu = GetCategoryByParent( $key_category, $name_category, $title, ($table == '') ); $onsubmit= "return ShowFromMacros( this );"; $onchange= "return ShowFromMacros( this.form );"; // Показываем ссылку на таблицу(набор данных) if ( ($submenu == '') && ($table) ) { if ( preg_match_all( '/#\$(\w+)(%%)*\$#/', $table, $macros, PREG_SET_ORDER ) ) // форма для параметров запроса $text .= "<li onclick='$(this).next().toggle(); return ExpandParents(this);' title='$title' >$name_category $symbol_form</li>".WrapForm( $nameForm= "f$key_category", $href_tovary, $onsubmit, GetFieldFromMacros( ( strstr($name_category, 'день') ? 'date' : (strstr($name_category, 'месяц') ? 'month' : 'week') ), $macros, '⏎', $onchange ), 'width:230px', null, $title ).''; else $text .= GetLiOnclick( $key_category, $name_category, '', $title ); } // показываем ссылку на категории - для уже ветвей дерева либо пустых кодов SQL else $text .= "<li class='collapsed collapsible'> <a href='$href_category' target='content' title='$title' onclick=' ExpandUL( $(this) ); ".( $adminTrue ? $show_tovar : '' )."'><span>$name_category</span></a>".( $adminTrue ? AddFormNewElement( $key_category, $name_category ) : '' ).($submenu == '' ? GetDelFormtext( $key_category, $name_category ) : "<div class='panel wrapper' ><ul>$submenu</ul></div>" )."</li>"; $recordSet->MoveNext(); } return ($text ? $text/* .($count > 7 ? '</ul>': '' ) */ : ''); }
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 по записям }