<?php 

function create_dbEdit( $dbEdit, $dbEdit_Conf )
{
  $path  = ( defined( 'STUDIO' ) )? _CFG_ : _CFG_;
  $dataSet = '';

  if( $dbEdit_Conf['enabled'] == 'true' )
  {
    $enabled = "";
  }else
  {
    if( defined('STUDIO') )
    {
      $enabled = '';
    }else
    {
      $enabled = "disabled";
    }// End
  }// End if( $dbEdit_Conf['enabled'] == 'true' )

  $alt_key = '';

  if( $dbEdit_Conf['tab_index'] == 'auto' )
  {
    $tab_index = '';
  }else
  {
    $tab_index = $dbEdit_Conf['tab_index'];
  }//End if( $dbEdit_Conf['tab_index'] == 'auto' )

/**
 *  definição do Caption  --------------------------------------------------  //
 */
  if( $dbEdit_Conf['caption'] == 'auto' )
  {
    if( empty($dbEdit_Conf['data_set'] ) )
    {
      $label = $dbEdit;
    }else
    {
      $dataSet = $dbEdit_Conf['data_set'];
      $nFile_dataSet = $path . $dataSet . ".config.data.ini";

      if( file_exists( $nFile_dataSet ) )
      {
        $arrINI_dataSet = readINIfile( $nFile_dataSet );
        if( empty( $arrINI_dataSet[ $dataSet . '_data' ]['datasource'] ) )
        {
          echo('erro: dataSet não Configurado..');exit;
        }else
        {
          $flagDTS = true;
          $_dataSource_ = $arrINI_dataSet[ $dataSet . '_data' ]['datasource'];
          $_dataTabela_ = $arrINI_dataSet[ $dataSet . '_data' ]['tabela'];


        }// End if( empty( $arrINI[ $dataSet . '_data' ]['datasource'] ) )

        echo"ok".$_dataTabela_;
      }else
      {
        echo"erro";
      }// End if( file_exists( $nFile_dataSet ) )
      exit;
    }// end if( empty($dbedit_Conf['data_set'] ) )
  }else
  {
    $label = $dbEdit_Conf['caption'];
  }// End if( $dbEdit_Conf['caption'] == 'auto' )

//     writeTO( '<div id="' . $dbEdit . '_label" objeto="' . $dbEdit. '">' );
//     writeTO( '  dbEdit1' );
//     writeTO( '</div end="' . $dbEdit . '">' );

  writeTO( '<label id="'.$dbEdit.'_Caption" '                    );
  writeTO( '       class="dbEdit_Caption" '                      );
  writeTO( '       for="'.$dbEdit.'_Input" '                     );
  writeTO( '       accesskey="' . $alt_key . '"'                 );
  writeTO( '       ' .$enabled. '>'                              );
  writeTO( '       ' . $label . '</label>'                       );
  writeTO( '<input id="' . $dbEdit . '_Input"  '                 );
  writeTO( '       type="text" '                                 );
  writeTO( '       tipoCampo="'.$dbEdit_Conf['tipo_field'].'" '  );
  writeTO( '       tipoDado="'.$dbEdit_Conf['tipo_dado'].'" '    );
  writeTO( '       value="'.$dbEdit_Conf['valor'].'" '           );
  writeTO( '       class="dbEdit_Input" '                        );
  writeTO( '       tab_index="'.$tab_index.'" '                  );
  writeTO( '       maxlength="'. $dbEdit_Conf['max_len'].'"'     );
  writeTO( '       ' .$enabled. '/>'                             );


}// End create_dbEdit()
  

/**
 *  create_dbEdit()
 *  ------------------------------------------------------------------------  //
 */
function create_dbEdit_css( $dbEdit,
                            $dbEdit_Global,
                            $dbEdit_Style,
                            $dbEdit_Conf,
                            $flag_dbEdit )
{
//    global $projeto, $esquema;
  if( defined('STUDIO') )
  {
    $visible = 'visible';
  }else
  {
    $visible = ($dbEdit_Conf['visibility'] == 'true' ) ? 'inherit':'hidden';
  }// End if( defined('STUDIO') )
  
  $paddingTop = 3;
  $paddingBottom = 0;
  $paddingLeft = 5;

  $lenLabel    = $dbEdit_Conf['label_len'];
  $lenInput    = $dbEdit_Conf['input_len'];
  $initInput   = ($lenLabel) -5;
  $colorBorder = '#808080';

  $cor_borderLeft  = $dbEdit_Global['cor_borderLeft'];
  $cor_borderRight = $dbEdit_Global['cor_borderRight'];

  if( $dbEdit_Conf['font_size'] == 'auto' )
  {
    $fontSize = $dbEdit_Global['fontSize'];
  }else
  {
    $fontSize = $dbEdit_Conf['font_size'];
  }// End if( $dbEdit_Conf['font_size'] == 'auto' )

  writeTO( '  #' . $dbEdit . '{ '                                          );
  writeTO( '    position:absolute; '                                       );
  writeTO( '    top:' . $dbEdit_Global['top'] . 'px;'                      );
  writeTO( '    left:' . $dbEdit_Global['left'] . 'px;'                    );
  writeTO( '    '                                                          );
  writeTO( '    z-index:10;'                                               );
  writeTO( '    visibility:'.$visible.';'                                  );
  writeTO( '    '                                                          );
  writeTO( '    width:' . $dbEdit_Global['width'] . 'px;'                  );
  writeTO( '    height:' . $dbEdit_Global['height'] . 'px;'                );
  writeTO( '    '                                                          );
  writeTO( '    }'                                                         );
  writeTO( '  '                                                            );

  writeTO( '  #' . $dbEdit . '_Caption{ '                                  );
  writeTO( '    position:absolute;'                                        );
  writeTO( '    top:0px'                                             . ';' );
  writeTO( '    left:0px'                                            . ';' );
  writeTO( '    '                                                          );
  writeTO( '    width:'.$lenLabel . 'px'                             . ';' );
  writeTO( '    height:' . $dbEdit_Global['height'] . 'px'           . ';' );
  writeTO( '    '                                                          );
  writeTO( '    font-size:' . $fontSize . 'px'   . ';'                     );
  writeTO( '    padding-top:'.$paddingTop.'px'                             );
  writeTO( '  }'                                                           );
  writeTO( '  '                                                            );

  writeTO( '  #' . $dbEdit . '_Input{ '                                    );
  writeTO( '    position:absolute'                                   . ';' );
  writeTO( '    top:0px'                                             . ';' );
  writeTO( '    left:'.$initInput.'px'                               . ';' );
  writeTO( '    '                                                          );
  writeTO( '    font-size:' . $fontSize . 'px'                       . ';' );
  writeTO( '    width:'.$lenInput . 'px'                             . ';' );
  writeTO( '    height:' . $dbEdit_Global['height'] . 'px'           . ';' );
  writeTO( '    border-top:'    . $dbEdit_Style['borderTopInput']    . ';' );
  writeTO( '    border-bottom:' . $dbEdit_Style['borderBottomInput'] . ';' );
  writeTO( '    border-left:'   . $dbEdit_Style['borderLeftInput']   . ';' );
  writeTO( '    border-right:'  . $dbEdit_Style['borderRightInput']  . ';' );
  writeTO( '  }'                                                           );
  writeTO( '  #' . $dbEdit . '_key{ '                                      );
  writeTO( '    text-decoration:underline;'                                );
  writeTO( '  }'                                                           );
  writeTO( '  '                                                            );

}// End create_dbEdit_css()


?> 
