function __construct() { $variables = new Variables(); $connect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName); $result; $xkey = "fmsfmsfms"; if (!$connect->start()) { echo "Impossible to star connection in Sigin."; } if (!($result = $connect->execute("SELECT matricula, senha, codigo_fol FROM Cadastros ORDER BY matricula"))) { echo "Impossible to execute MySQL query."; } while ($row = mysql_fetch_array($result)) { echo "Matricula: " . zkl($xkey, $row["matricula"]) . ", senha: " . base64_decode($row["senha"]) . ", folha: " . $row["codigo_fol"] . "<br/>"; } //$connect->close(); }
function execute() { $toFix = false; $archiveDBFname = $this->path; $variables = new Variables(); $MySQLconnect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName); if (!($DFBconnect = dbase_open($archiveDBFname, 0))) { //only reading return false; } //Connection to DBF error //get number of rows of dbf table $numRows = dbase_numrecords($DFBconnect); //get number of files of dbf table $numFields = dbase_numfields($DFBconnect); //the DBF registers begins with 1 for ($x = 1; $x <= $numRows; $x++) { $DBFrow = dbase_get_record($DFBconnect, $x); //Get DBF archive rows $this->DB[$x - 1] = $DBFrow; } /*$host_ftp = "localhost"; $user_ftp = "root"; $pass_ftp = ""; // Faz a conexão com o Servidor $ftp_con = ftp_connect($host_ftp); // Efetua o login com o usuário e senha informados $ftp_log = ftp_login($ftp_con,$user_ftp,$pass_ftp); // Deleta o arquivo informado if(!ftp_delete($ftp_con, $archiveDBFname)) die("ERRO CRITICO FTP!"); // Encerramos a conexão de FTP previamente estabelecida ftp_close($ftp_con);*/ /*echo(decoct(777)."<br/>"); $temp = stat($archiveDBFname); echo(octdec($temp["mode"])."<br/>"); echo(octdec(fileperms($archiveDBFname))); if(!unlink($archiveDBFname)) die("ERRO CRITICO!"); die("OK");*/ //unlink($archiveDBFname) if (!$MySQLconnect->start()) { echo "Impossible to star connection in Handler."; } if (strlen($this->folhaType) > 0) { $row = mysql_fetch_assoc($MySQLconnect->execute("SELECT codigo_fol FROM Folhas where nome='{$this->folhaType}'")); $code = $row["codigo_fol"]; } for ($x = 0; $x < $numRows; $x++) { switch ($this->tableId) { case "dcr": $aux = array("INSERT INTO Cargos (cargo, descricao_cargo , tipo, vencimento) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . $this->DB[$x][2] . "', " . $this->DB[$x][3] . ")"); break; case "dlt": $aux = array("INSERT INTO Lotacoes (lotacao, descricao_lotacao , secretaria) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][2])) . "')"); break; case "especial": $aux = array("INSERT INTO Especialidades (codigo_esp, descricao_especialidade , cargo) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . $this->DB[$x][2] . "')"); break; case "eventos": $aux = array("INSERT INTO Eventos (codigo_eve, descricao_evento, IRRF, IPMT, FAL, FIXO, TEMP, valor_eve, GRAT, FGTS, desconto, nivel_eve, INSS) VALUES ('" . $this->DB[$x][0] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][1])) . "', '" . $this->DB[$x][2] . "', '" . $this->DB[$x][3] . "', '" . $this->DB[$x][4] . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][6] . "', " . $this->DB[$x][7] . ", '" . $this->DB[$x][8] . "', '" . $this->DB[$x][9] . "', " . $this->DB[$x][10] . ", '" . $this->DB[$x][11] . "', '" . $this->DB[$x][12] . "')"); break; case "cadastro": $date = explode("-", $_SESSION["day"]); $query = "SELECT * FROM Cadastros WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code; $result = $MySQLconnect->execute($query); $cont = $MySQLconnect->counterResult($result); if ($code == 1) { if ($cont > 0) { $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][28] . "', descontar='" . $this->DB[$x][29] . "', receber='" . $this->DB[$x][30] . "', funcao='" . $this->DB[$x][31] . "', maior_360='" . $this->DB[$x][33] . "', prof_40h='" . $this->DB[$x][34] . "', vlt_ver='" . $this->DB[$x][35] . "', val_niv=" . $this->valueFormater($this->DB[$x][36]) . ", data_FGTS='" . $this->dateFormater($this->DB[$x][37]) . "', permanente='" . $this->DB[$x][38] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][39]) . ", vencimento=" . $this->valueFormater($this->DB[$x][40]) . ", flag='" . $this->DB[$x][41] . "', entrada='" . $this->DB[$x][42] . "', liquido=" . $this->valueFormater($this->DB[$x][45]) . ", sobregrat='" . $this->DB[$x][46] . "', assistencia='" . $this->DB[$x][47] . "', medico='" . $this->DB[$x][48] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][43] . "', numero='" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . ""); } else { $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][34] . "', '" . $this->DB[$x][35] . "', " . $this->valueFormater($this->DB[$x][36]) . ", '" . $this->dateFormater($this->DB[$x][37]) . "', '" . $this->DB[$x][38] . "', " . $this->valueFormater($this->DB[$x][39]) . ", " . $this->valueFormater($this->DB[$x][40]) . ", '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', " . $this->valueFormater($this->DB[$x][45]) . ", '" . $this->DB[$x][46] . "', '" . $this->DB[$x][47] . "', '" . $this->DB[$x][48] . "', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', '" . $this->dateFormater($this->DB[$x][17]) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][43] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "', " . $code . ")"); } } else { if ($code == 2) { if ($cont > 0) { $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][10] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][11] . "', dep_imp_re='" . $this->DB[$x][13] . "', hora_sem='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', instrucao='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', data_afastamento='" . $this->dateFormater($this->DB[$x][20]) . "', sindical='" . $this->DB[$x][21] . "', dp_sal_fam='" . $this->DB[$x][22] . "', hora_ponto='" . $this->DB[$x][23] . "', vale_transporte='" . $this->DB[$x][24] . "', data_promocao='" . $this->dateFormater($this->DB[$x][26]) . "', tipo='" . $this->DB[$x][29] . "', situacao='" . $this->DB[$x][30] . "', descontar='" . $this->DB[$x][31] . "', receber='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', funcao='" . $this->DB[$x][33] . "', maior_360='" . $this->DB[$x][35] . "', prof_40h='" . $this->DB[$x][36] . "', vlt_ver='" . $this->DB[$x][37] . "', val_niv=0, data_FGTS='" . $this->dateFormater($this->DB[$x][38]) . "', permanente='" . $this->DB[$x][40] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][39]) . ", vencimento=0, flag='" . $this->DB[$x][41] . "', entrada='" . $this->DB[$x][42] . "', liquido=" . $this->valueFormater($this->DB[$x][45]) . ", sobregrat='" . $this->DB[$x][8] . "', assistencia='" . $this->DB[$x][9] . "', medico='" . $this->DB[$x][46] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][14] . "', CPF='" . $this->DB[$x][17] . "', PIS_PASEP='" . $this->DB[$x][18] . "', data_nascimento='" . $this->dateFormater($this->DB[$x][19]) . "', ultimo_nome='" . $this->DB[$x][34] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . $this->DB[$x][27] . "', orgao_expedidor='" . $this->DB[$x][28] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][43] . "', numero='" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . ""); } else { $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][10] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', '" . $this->dateFormater($this->DB[$x][20]) . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->DB[$x][23] . "', '" . $this->DB[$x][24] . "', '" . $this->dateFormater($this->DB[$x][26]) . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][35] . "', '" . $this->DB[$x][36] . "', '" . $this->DB[$x][37] . "', 0, '" . $this->dateFormater($this->DB[$x][38]) . "', '" . $this->DB[$x][40] . "', " . $this->valueFormater($this->DB[$x][39]) . ", 0, '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', " . $this->valueFormater($this->DB[$x][45]) . ", '" . $this->DB[$x][8] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][46] . "', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][14] . "', '" . $this->DB[$x][17] . "', '" . $this->DB[$x][18] . "', '" . $this->dateFormater($this->DB[$x][19]) . "', '" . $this->DB[$x][34] . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][43] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][44])) . "', " . $code . ")"); } } else { if ($code == 3) { if ($cont > 0) { $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][30] . "', descontar='" . $this->DB[$x][31] . "', receber='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', funcao='" . $this->DB[$x][33] . "', maior_360='" . $this->DB[$x][35] . "', prof_40h='" . $this->DB[$x][36] . "', vlt_ver='" . $this->DB[$x][37] . "', 0, data_FGTS='" . $this->dateFormater($this->DB[$x][44]) . "', permanente='" . $this->DB[$x][41] . "', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][42]) . ", 0, 'z', 'z', liquido=" . $this->valueFormater($this->DB[$x][40]) . ", sobregrat='" . $this->DB[$x][43] . "', assistencia='" . $this->DB[$x][45] . "', 'z', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . $this->DB[$x][34] . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][38] . "', numero='" . $this->DB[$x][39] . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . ""); } else { $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][35] . "', '" . $this->DB[$x][36] . "', '" . $this->DB[$x][37] . "', 0, '" . $this->dateFormater($this->DB[$x][44]) . "', '" . $this->DB[$x][41] . "', " . $this->valueFormater($this->DB[$x][42]) . ", 0, 'z', 'z', " . $this->valueFormater($this->DB[$x][40]) . ", '" . $this->DB[$x][43] . "', '" . $this->DB[$x][45] . "', 'z', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', '" . $this->dateFormater($this->DB[$x][17]) . "', '" . $this->DB[$x][34] . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][38] . "', '" . $this->DB[$x][39] . "', " . $code . ")"); } } else { if ($code == 4) { if ($cont > 0) { $aux = array("UPDATE Cadastros SET cargo='" . $this->DB[$x][8] . "', lotacao='" . $this->DB[$x][1] . "', data_admissao='" . $this->dateFormater($this->DB[$x][4]) . "', vinculo='" . $this->DB[$x][5] . "', previdencia'" . $this->DB[$x][7] . "', nivel='" . $this->DB[$x][9] . "', dep_imp_re='" . $this->DB[$x][11] . "', hora_sem='" . $this->DB[$x][13] . "', instrucao='" . $this->DB[$x][14] . "', data_afastamento='" . $this->dateFormater($this->DB[$x][18]) . "', sindical='" . $this->DB[$x][19] . "', dp_sal_fam='" . $this->DB[$x][20] . "', hora_ponto='" . $this->DB[$x][21] . "', vale_transporte='" . $this->DB[$x][22] . "', data_promocao='" . $this->dateFormater($this->DB[$x][24]) . "', tipo='" . $this->DB[$x][27] . "', situacao='" . $this->DB[$x][28] . "', descontar='" . $this->DB[$x][29] . "', receber='" . $this->DB[$x][30] . "', funcao='" . $this->DB[$x][31] . "', maior_360='" . $this->DB[$x][33] . "', prof_40h='" . $this->DB[$x][34] . "', vlt_ver='" . $this->DB[$x][35] . "', 0, data_FGTS='" . $this->dateFormater($this->DB[$x][36]) . "', permanente='z', remuneracao_bruto=" . $this->valueFormater($this->DB[$x][44]) . ", vencimento=0, flag='z', entrada='" . $this->DB[$x][37] . "', liquido=" . $this->valueFormater($this->DB[$x][38]) . ", sobregrat='" . $this->DB[$x][41] . "', assistencia='" . $this->DB[$x][42] . "', medico='z', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Pessoal SET nome='" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', sexo='" . $this->DB[$x][12] . "', CPF='" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', PIS_PASEP='" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', data_nascimento='" . $this->dateFormater($this->DB[$x][17]) . "', ultimo_nome='" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE RG SET identidade='" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', orgao_expedidor='" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', codigo_fol=" . $code . " WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "'", "UPDATE Inf_Bancaria SET conta='" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', banco='" . $this->DB[$x][39] . "', numero='" . $this->DB[$x][40] . "' WHERE matricula='" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "' AND codigo_fol=" . $code . ""); } else { $aux = array("INSERT INTO Cadastros (matricula, cargo, lotacao, data_admissao, vinculo, previdencia, nivel, dep_imp_re, hora_sem, instrucao, data_afastamento, sindical, dp_sal_fam, hora_ponto, vale_transporte, data_promocao, tipo, situacao, descontar, receber, funcao, maior_360, prof_40h, vlt_ver, val_niv, data_FGTS, permanente, remuneracao_bruto, vencimento, flag, entrada, liquido, sobregrat, assistencia, medico, senha, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->DB[$x][8] . "', '" . $this->DB[$x][1] . "', '" . $this->dateFormater($this->DB[$x][4]) . "', '" . $this->DB[$x][5] . "', '" . $this->DB[$x][7] . "', '" . $this->DB[$x][9] . "', '" . $this->DB[$x][11] . "', '" . $this->DB[$x][13] . "', '" . $this->DB[$x][14] . "', '" . $this->dateFormater($this->DB[$x][18]) . "', '" . $this->DB[$x][19] . "', '" . $this->DB[$x][20] . "', '" . $this->DB[$x][21] . "', '" . $this->DB[$x][22] . "', '" . $this->dateFormater($this->DB[$x][24]) . "', '" . $this->DB[$x][27] . "', '" . $this->DB[$x][28] . "', '" . $this->DB[$x][29] . "', '" . $this->DB[$x][30] . "', '" . $this->DB[$x][31] . "', '" . $this->DB[$x][33] . "', '" . $this->DB[$x][34] . "', '" . $this->DB[$x][35] . "', 0, '" . $this->dateFormater($this->DB[$x][36]) . "', 'z', " . $this->valueFormater($this->DB[$x][44]) . ", 0, 'z', '" . $this->DB[$x][37] . "', " . $this->valueFormater($this->DB[$x][38]) . ", '" . $this->DB[$x][41] . "', '" . $this->DB[$x][42] . "', 'z', '" . $this->passwordMaker() . "', " . $code . ")", "INSERT INTO Pessoal (matricula, nome, sexo, CPF, PIS_PASEP, data_nascimento, ultimo_nome, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][3])) . "', '" . $this->DB[$x][12] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][15])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][16])) . "', '" . $this->dateFormater($this->DB[$x][17]) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][32])) . "', " . $code . ")", "INSERT INTO RG (matricula, identidade, orgao_expedidor, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][25])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][26])) . "', " . $code . ")", "INSERT INTO Inf_Bancaria (matricula, conta, banco, numero, codigo_fol) VALUES ('" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][6])) . "', '" . $this->DB[$x][39] . "', '" . $this->DB[$x][40] . "', " . $code . ")"); } } } } } break; case "calculo": $date = explode("-", $_SESSION["day"]); $query = "SELECT * FROM Calculos WHERE matricula='" . $this->DB[$x][0] . "' AND fol_codigo=" . $code . " AND data BETWEEN '" . $date[2] . "-" . $date[1] . "-01' and '" . $date[2] . "-" . $date[1] . "-31' AND eve_codigo='" . $this->DB[$x][1] . "' AND valor='" . $this->valueFormater($this->DB[$x][2]) . "'"; $result = $MySQLconnect->execute($query); if ($MySQLconnect->counterResult($result) > 0) { $aux = array("UPDATE Calculos SET valor=" . $this->valueFormater($this->DB[$x][2]) . " WHERE matricula='" . $this->DB[$x][0] . "' AND fol_codigo=" . $code . " AND eve_codigo='" . $this->DB[$x][1] . "' AND data BETWEEN '" . $date[2] . "-" . $date[1] . "-01' and '" . $date[2] . "-" . $date[1] . "-31'"); } else { $aux = array("INSERT INTO Calculos (valor, fol_codigo, eve_codigo, matricula, data) VALUES (" . $this->valueFormater($this->DB[$x][2]) . ", " . $code . ", '" . $this->DB[$x][1] . "', '" . addslashes(zkl($this->xkey, $this->DB[$x][0])) . "', '" . $this->dateFormater2($_SESSION["day"]) . "')"); } break; } /*foreach($aux as $query){ echo $query."<br>"; }*/ foreach ($aux as $query) { if (!$MySQLconnect->execute($query)) { /*echo $query."<br>"; die();*/ $toFix = true; $this->DB[$x][$numFields] = "true"; } else { $this->DB[$x][$numFields] = "false"; } } } //$MySQLconnect->close(); dbase_close($DFBconnect); unlink($archiveDBFname); if ($toFix and $this->tableId != "cadastro" and $this->tableId != "calculo") { $this->fixProblems($numFields, $numRows); } else { header("Location: ../importDocuments.php?upl=true&tab={$this->tableId}"); } }
function printCC($connect) { $c = $this->dateCounterDiff($this->date1, $this->date2); $date = explode("-", $this->date1); echo '<table><tr><td><a href="../index.php">Clique aqui para gerar novos contracheques</a></td><td width="250"><p onclick="javascript: window.print();" align="center">Imprimir<br/><img src="../images/impressora.png" width="35" height="35" style="cursor:pointer";/></p></td><td><a href="../actions/Logout.class.php">Desconectar<img src="../images/desconectar.png" width="36" height="36" /></a></td></tr></table><br/>'; $cont = 0; for ($x = 0; $x < $c; $x++) { if (!($result = $connect->execute("SELECT * FROM Calculos cl INNER JOIN Cadastros cd ON cl.matricula = cd.matricula INNER JOIN Lotacoes lo ON cd.lotacao = lo.lotacao INNER JOIN Cargos cg ON cd.cargo = cg.cargo INNER JOIN Pessoal ps\tON cd.matricula = ps.matricula INNER JOIN Eventos ev ON cl.eve_codigo = ev.codigo_eve WHERE cl.matricula = '" . $_SESSION["user"] . "' AND cl.data BETWEEN '" . $date[2] . "-" . $date[1] . "-01' and '" . $date[2] . "-" . $date[1] . "-31' ORDER BY cl.eve_codigo"))) { echo "Impossible to execute MySQL query."; } if ($connect->counterResult($result) < 1) { if ($date[1] == 12) { $date[1] = "01"; $date[2] += 1; } else { $date[1] += 1; } continue; } else { $cont++; } $row = mysql_fetch_array($result); $infos["x"] = "***"; $infos["nome"] = zkl($this->xkey, $row["nome"]); $infos["matricula"] = zkl($this->xkey, $row["matricula"]); $infos["lotacao"] = $row["lotacao"]; $infos["descricao_secretaria"] = zkl($this->xkey, $row["descricao_lotacao"]); $infos["descricao_cargo"] = zkl($this->xkey, $row["descricao_cargo"]); $infos["nivel"] = $row["nivel"]; $infos["CPF"] = zkl($this->xkey, $row["CPF"]); $infos["PIS_PASEP"] = zkl($this->xkey, $row["PIS_PASEP"]); $infos["data_nascimento"] = $row["data_nascimento"]; $infos["data_admissao"] = $row["data_admissao"]; $infos["dp_sal_fan"] = $row["dp_sal_fan"]; $infos["dep_imp_re"] = $row["dep_imp_re"]; $infos["proventos"] = 0; $infos["descontos"] = 0; $infos["liquido"] = 0; $infos[0] = $row["eve_codigo"]; $infos[1] = zkl($this->xkey, $row["descricao_evento"]); $infos[2] = $row["valor"]; $today = getdate(); $infos["date"] = $today["mday"] . "/" . $today["mon"] . "/" . $today["year"]; $z = 3; $loop = 1; while ($row = mysql_fetch_array($result)) { $infos[$z++] = $row["eve_codigo"]; $infos[$z++] = zkl($this->xkey, $row["descricao_evento"]); $infos[$z++] = $row["valor"]; $loop++; } $w = 0; for ($y = 0; $y < ($z + 1) / 3; $y++) { if ($infos[$w + $y * 2] < 500) { $infos["proventos"] += $infos[$w + $y * 2 + 2]; } else { $infos["descontos"] += $infos[$w + $y * 2 + 2]; } $w++; } $contP = $contD = $m = 0; for ($y = 0; $y < $loop; $y++) { if ($infos[$m] < 500) { $contP++; } else { $contD++; } $m += 3; } if ($contP > $contD) { $loop = $contP + 1; } else { if ($contD > $contP) { $loop = $contD + 1; } else { $loop = $contD + 1; } } $infos["liquido"] = $infos["proventos"] - $infos["descontos"]; echo '<style type="text/css"> <!-- #table{ border-top-style: ridge; border-right-style: ridge; border-bottom-style: ridge; border-left-style: ridge; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; } .style2 { font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; font-size: 14px; } .words3 { font-size: 9px; font-family: Georgia, "Times New Roman", Times, serif; } --> </style>'; // 595, 842 echo '<table width="595" border="1" cellpadding="0" cellspacing="0" id="table"> <tr> <td width="638" class="style1"><table width="586"> <tr> <td width="73"><div align="center"><img src="../images/brasao_bw.png" width="59" height="71" /></div></td> <td width="375"><div align="center" class="style2">Prefeitura Municipal de Teresina<br /> Secretaria Municipal de Administração<br /> </div> <span class="style6"><br /> <span class="words3">EMITIDO: ' . $infos["date"] . '</span></span></td> <td width="122"><div align="right"><img src="../images/fms_logo_bw.png" width="121" height="35" /></div></td> </tr></table> </td> </tr> <tr> <td><div align="right" class="style2">CONTRACHEQUE </div> <table width="100%" border="1" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="8%" >EMPRESA<br /> FMSA</td> <td width="13%">MATRÍCULA<br /> ' . $infos['matricula'] . '</td> <td width="79%">NOME<br /> ' . $infos['nome'] . '</td> </tr> </table> <table width="100%" border="1" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="57%">CARGO<br /> ' . $infos['descricao_cargo'] . '</td> <td width="43%">LOTAçÃO<br /> ' . $infos['descricao_secretaria'] . '</td> </tr> </table> <table width="100%" border="1" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="8%">NÍVEL<br /> ' . $infos['nivel'] . '</td> <td width="30%">CPF<br /> ' . $infos['CPF'] . '</td> <td width="26%">PIS/PASEP<br /> ' . $infos['PIS_PASEP'] . '.</td> <td width="18%">ADMISSÃO<br /> ' . $infos['data_admissao'] . '</td> <td width="18%">NASCIMENTO<br /> ' . $infos['data_nascimento'] . '</td> </tr> </table> <table width="100%" border="1" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="6%">DP SF<br /> ' . $infos['dp_sal_fan'] . '.</td> <td width="6%">DP IR<br /> ' . $infos['dep_imp_re'] . '.</td> <td width="7%">BANCO<br /> ' . $infos['x'] . '</td> <td width="11%">AGÊNCIA<br /> ' . $infos['x'] . '</td> <td width="12%">OPERAçÃO<br /> ' . $infos['x'] . '</td> <td width="27%">CONTA CORRENTE<br /> ' . $infos['x'] . '</td> <td width="31%">REFERÊNCIA PAGAMENTO<br /> ' . $this->appDateMaker($date[0] . "-" . $date[1] . "-" . $date[2]) . '</td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="16%">CÓDIGO</td> <td width="61%">DESCRIMINAÇÃO</td> <td width="23%">VALOR EM R$ </td> </tr> </table>'; $h = 0; for ($y = 0; $y < $loop; $y++) { if ($y % 2 == 0) { echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#E1E1E1" class="words3">'; } else { echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="words3">'; } if ($y >= $contP) { echo '<tr><td width="16%"> </td> <td width="61%"> </td> <td width="23%"> </td> </tr> </table>'; } else { echo '<td width="16%">' . $infos[$h++] . '</td> <td width="61%">' . $infos[$h++] . '</td> <td width="23%" align="right">' . $this->formatValue($infos[$h++]) . '</td> </tr> </table>'; } } echo '</td> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="words3"> <tr> <td width="16%">CÓDIGO</td> <td width="61%">DESCRIMINAÇÃO</td> <td width="23%">VALOR EM R$ </td> </tr> </table>'; for ($y = 0; $y < $loop; $y++) { if ($y % 2 == 0) { echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#E1E1E1" class="words3">'; } else { echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="words3">'; } if ($y >= $contD) { echo '<tr><td width="16%"> </td> <td width="61%"> </td> <td width="23%"> </td> </tr> </table>'; } else { echo '<td width="16%">' . $infos[$h++] . '</td> <td width="61%">' . $infos[$h++] . '</td> <td width="23%" align="right">' . $this->formatValue($infos[$h++]) . '</td> </tr> </table>'; } } echo '</td> </tr> </table></td> </tr> <tr> <td class="words3"> </td> </tr> <tr> <td><table width="100%" border="1" cellpadding="0" cellspacing="0" class="words3"> <tr> <td>PROVENTOS<br /> R$ ' . $this->formatValue($infos['proventos']) . '</td> <td>DESCONTOS<br /> R$ ' . $this->formatValue($infos['descontos']) . '</td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" class="words3"> <tr> <td width="63%"><div align="right">LÍQUIDO:</div></td> <td width="37%">R$ ' . $this->formatValue($infos['liquido']) . '</td> </tr> </table></td> </tr> <tr> <td><div align="right"><br /> <br /> <br /> <span class="style2">Gerado via WEB. </span></div></td> </tr> </table></br></br>'; if ($date[1] == 12) { $date[1] = "01"; $date[2] += 1; } else { $date[1] += 1; } } if ($cont == 0) { header("Location: ../index.php?found=false"); die; } }