Ir para conteúdo
Fórum Script Brasil
  • 0

Rotina para gerar codigo de barras 2of5


andrel.afonso

Pergunta

Bom Dia,

Vou colocar abaixo meu problema, se alguém souber, ficarei grato pela ajuda.

_______________________________________________________________________________________________________

Estou desenvolvendo um sistema para gerar codigo de barras no cracha da empresa, Já esta tudo funcionando, porem se eu puxar uma row que esteja acima da programação do codigo de barras ele gera o seguinte erro:

Notice: Undefined variable: row_b in C:\xampp\htdocs\xampp\intranet\cracha_imagens\barcode.php on line 110

Se estiver abaixo ai sim ele funciona trazendo o Nome da pessoa Ex.

André Luiz

Porem eu necessito buscar as informações do banco como o nome e deixar acima do codigo de barras.

Abaixo segue todo o codigo.

Coloquei em vermelho onde funciona, ele traz o nome,

Coloquei em azul onde não funciona, ele não traz o nome.

Coloquei em Laranja onde finaliza a rotina do codigo de barras

<?php require_once('../Connections/intranet.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_b = "-1";
if (isset($_GET['id'])) {
  $colname_b = $_GET['id'];
}
mysql_select_db($database_intranet, $intranet);
$query_b = sprintf("SELECT * FROM cracha WHERE %s=id and ativo=1", GetSQLValueString($colname_b, "int"));
$b = mysql_query($query_b, $intranet) or die(mysql_error());
$row_b = mysql_fetch_assoc($b);
mysql_select_db($database_intranet, $intranet);
$query_b = "SELECT * FROM cracha ";
$b = mysql_query($query_b, $intranet) or die(mysql_error());
$row_b = mysql_fetch_assoc($b);
$totalRows_b = mysql_num_rows($b);

mysql_select_db($database_intranet, $intranet);
$query_Recordset1 = "SELECT * FROM agenda";
$Recordset1 = mysql_query($query_Recordset1, $intranet) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<?


$valor = isset($_POST['valor']) ? $_POST['valor'] : "341911"; // Valor Inicial

fbarcode($valor); // Linha de Exemplo

function fbarcode($valor){

$fino = 1;
$largo = 3;
$altura = 50;

  $barcodes[0] = "00110";
  $barcodes[1] = "10001";
  $barcodes[2] = "01001";
  $barcodes[3] = "11000";
  $barcodes[4] = "00101";
  $barcodes[5] = "10100";
  $barcodes[6] = "01100";
  $barcodes[7] = "00011";
  $barcodes[8] = "10010";
  $barcodes[9] = "01010";
  for($f1=9;$f1>=0;$f1--){ 
    for($f2=9;$f2>=0;$f2--){  
      $f = ($f1 * 10) + $f2;
      $texto = "";
      for($i=1;$i<6;$i++){ 
        $texto .=  substr($barcodes[$f1],($i-1),1) . substr($barcodes[$f2],($i-1),1);
      }
      $barcodes[$f] = $texto;
    }
  }


//Desenho da barra


//Guarda inicial
?>
<link href="../cssemphasis.css" rel="stylesheet" type="text/css" />

<p><span class="fontemaior"><?php echo $row_b['nome_verso']; ?></span></p>
<table width="45%" border="0">
  <tr>
    <td width="44%" rowspan="4"><img src="esquerdos.png" width="218" height="259" /></td>
    <td height="21" colspan="4" align="center">&nbsp;</td>
    <td width="3%" rowspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="10%" height="21" align="left" valign="top" class="letrapequena">Nome:</td>
    <td height="21" colspan="3" align="left" class="fontemaior">&nbsp;</td>
  </tr>
  <tr>
    <td height="21" align="left" valign="top" class="letrapequena">Admiss&atilde;o: </td>
    <td width="5%" height="21" align="left" valign="top" class="fontemaior">&nbsp;</td>
    <td width="10%" height="21" align="left" valign="top" class="letrapequena">Matricula: </td>
    <td width="28%" height="21" align="left" valign="top" class="fontemaior">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4" align="left"><img src="direito_meio.png" width="212" height="177" /></td>
  </tr>
  <tr>
    <td width="44%" valign="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $row_b['nome_frente']; ?></td>
    <td colspan="4" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=p.gif width=<?=$fino?> height=<?=$altura?> border=0 /><img 
src=b.gif width=<?=$fino?> height=<?=$altura?> border=0 /><img 
src=p.gif width=<?=$fino?> height=<?=$altura?> border=0 /><img 
src=b.gif width=<?=$fino?> height=<?=$altura?> border=0 /><img 
<?
$texto = $valor;
if(bcmod(strlen($texto),2) <> 0){
    $texto = "0" . $texto;
}

// Draw dos dados
while (strlen($texto) > 0) {
  $i = round(esquerda($texto,2));
  $texto = direita($texto,strlen($texto)-2);
  $f = $barcodes[$i];
  for($i=1;$i<11;$i+=2){
    if (substr($f,($i-1),1) == "0") {
      $f1 = $fino;
    }else{
      $f1 = $largo;
    }
?>
    src=p.gif width=<?=$f1?> height=<?=$altura?> border=0 /><img 
<?
    if (substr($f,$i,1) == "0") {
      $f2 = $fino;
    }else{
      $f2 = $largo;
    }
?>
    src=b.gif width=<?=$f2?> height=<?=$altura?> border=0 /><img 
<?
  }
}

// Draw guarda final
?>
src=p.gif width=<?=$largo?> height=<?=$altura?> border=0 /><img 
src=b.gif width=<?=$fino?> height=<?=$altura?> border=0 /><img 
src=p.gif width=<?=1?> height=<?=$altura?> border=0 />
   
</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p><br>
</p>
<form name="form1" method="post" action="">
  <p><font face="Arial, Helvetica, sans-serif" size="2"><b>Digite o valor do c&oacute;digo 
    de barras:</b></font><br>
    <input type="text" name="valor" maxlength="50" size="50" value="<? echo $valor ?>">
    <input type="submit" name="Submit" value="Gerar C&oacute;digo de Barrar">
  </p>
[color=#0000FF]<?php echo $row_b['nome_frente']; ?>[/color]
  [color=#FF8C00] <?php
}//Fim da função

function esquerda($entra,$comp){
    return substr($entra,0,$comp);
}

function direita($entra,$comp){
    return substr($entra,strlen($entra)-$comp,$comp);
}[/color]

?>

</form>
<p><br>
</p>
<table width="100%" border="1">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
[color=#FF0000]<?php echo $row_b['nome_frente']; ?>[/color]
<?php
mysql_free_result($b);

mysql_free_result($Recordset1);
?>

Editado por *FIT*
Adicionar a tag [code]! *FIT*
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...