示例#1
0
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>";
}
示例#2
0
$_SERVER['HTTP_REFERER'] = ';;;';
// отключаю срабатывание редиректа
require_once "params.php";
if (isset($_REQUEST['table'])) {
    $table = $_REQUEST['table'];
} else {
    if (isset($_REQUEST['key_parent'])) {
        // если нет запроса, возможно,  это вызов категорий для просмотра
        $table = GetParamFromCategory($_REQUEST['key_parent']);
    } 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) {
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;

}
示例#4
0
	    $new_search = '%';
	    
	    // проверяем для каждого слова фразы поиска на ее аналог в таблице ассоциаций
	    foreach( $words as $ind => $word ) {
		    
		    $recordSearch = runSQL("select * from search where name LIKE ? ", 1, 1, Array( $word ) );
		    if ( !$recordSearch->EOF ) {
// 			 нашли соответствие-замену   
		    	$new_word = $recordSearch->fields['replace_name'];
			    $new_search .= "$new_word%";	
			    $search_text = $new_search;
			    // добавляем оставшиеся слова в конец без изменений
			    for( $i=$ind+1; $i < count($words); $i++ ) 
			    	$search_text .= $words[$i].'%';
			    	
			    $recordSet = runSQL( "select * from category where name LIKE ? order by name", GetParamOrDefault( 'nrows', 5 ), GetParamOrDefault( 'offset', -1 ), Array( $search_text )  );
			    if ($recordSet)
			    	break;
		    }
		    $new_search .= "$word%";
	    }
	    	
	    
	    	
	$text = '';

	foreach($recordSet as $k => $row)
    {	    
	    $text .= "<option value='{$row[0]}'>{$row[1]}</option>";
	}	 // while