*  detalhes.                                                         
 *                                                                    
 *  Voce deve ter recebido uma copia da Licenca Publica Geral GNU     
 *  junto com este programa; se nao, escreva para a Free Software     
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA          
 *  02111-1307, USA.                                                  
 *  
 *  Copia da licenca no diretorio licenca/licenca_en.txt 
 *                                licenca/licenca_pt.txt 
 */
include "libs/db_conecta.php";
include "libs/db_stdlib.php";
include "libs/db_sql.php";
include "libs/db_utils.php";
parse_str($HTTP_SERVER_VARS["QUERY_STRING"]);
$oGet = db_utils::postmemory($_GET);
$cnpj = formataCpfCnpj($oGet->cnpj);
$sql = "select * from cgm where z01_cgccpf = '{$cnpj}'";
//die($sql);
$result = pg_query($sql);
$linha = pg_num_rows($result);
if ($linha > 0) {
    db_fieldsmemory($result, 0);
    echo " <script> \n          \tparent.document.form1.nomerazao.value = '{$z01_nome}';\n  \t     </script>";
}
/*else{
   $sql2= "select q21_nome from issplanit where q21_cnpj =  '$cnpj'";
   //die($sql2);
	 $result2=pg_query($sql2);
	 $linha2=pg_num_rows($result2);
		if ($linha2 > 0) {
include "libs/db_stdlib.php";
include "libs/db_utils.php";
include "dbforms/db_funcoes.php";
include "classes/db_db_usuarios_classe.php";
include "classes/db_db_usuacgm_classe.php";
include "libs/db_sql.php";
include "classes/db_cgm_classe.php";
include "libs/smtp.class.php";
require_once "libs/db_encriptacao.php";
$cldb_usuarios = new cl_db_usuarios();
$cldb_usuacgm = new cl_db_usuacgm();
$clcgm = new cl_cgm();
parse_str(base64_decode($HTTP_SERVER_VARS["QUERY_STRING"]));
db_logs("", "", 0, "Pedido de Senha.");
$oGet = db_utils::postmemory($_GET);
$oPost = db_utils::postmemory($_POST);
$sMatric = $oGet->nummatricula;
$sNome = $oGet->nome;
$sCgcCpf = formataCpfBanco($oGet->numcpf);
$sDataNasc = formataDataNascBanco($oGet->datansc);
$sNomeMae = $oGet->nomemae;
$sEmailServ = $oGet->emailsrv;
$sPassword = Encriptacao::encriptaSenha($oPost->senhasrv);
$sHeader = $oGet->header;
$mostar = 1;
// pedido de senha e executado se chave == 't'
if (isset($oGet->chave) && $oGet->chave == 't') {
    $sql = " select rh01_regist,\n                  z01_numcgm,\n                  z01_nome,\n                  z01_cgccpf,\n                  z01_nasc,\n                  z01_mae,\n                  z01_email,\n                  email,\n                  senha,\n                  login\n             from rhpessoal\n                  inner join cgm on rh01_numcgm = z01_numcgm\n                  left join db_usuarios on db_usuarios.nome  =  cgm.z01_nome\n            where rh01_regist = '{$sMatric}'\n              and z01_nasc is not null\n              and z01_mae is not null limit 1 ";
    $result = db_query($sql);
    $total = pg_num_rows($result);
    if ($total == 0) {