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 GetMacrosForm() { global $adminTrue, $macros; if ( isset($_REQUEST['key_parent']) ) { $recordSet = runSQL( "select * from category where key_category=".$_REQUEST['key_parent'] ); $name_category = $recordSet->fields['name']; $key_category = $recordSet->fields['key_category']; $table = $recordSet->fields['sql_text']; $title = $recordSet->fields['title']; $memo = htmlspecialchars( $recordSet->fields['memo'] ); $href_tovary = "show_tovar.php?table=$table&title=$name_category"; if ( preg_match_all( '/#\$(\w+)\$#/', $table, $macros, PREG_SET_ORDER ) ) { $onsubmit= 'return NewFromMacros( this,"'. $name_category.'" );'; echo WrapForm( $nameForm= "f$key_category", $href_tovary, $onsubmit, GetFieldFromMacros( ( strstr($name_category, 'день') ? 'date' : (strstr($name_category, 'месяц') ? 'month' : 'week') ), $macros, 'Добавить диаграмму', '' ), "' class='form-inline' role='form'" ); return 'Draw();'; } } return 'Draw();'; }