Exemplo n.º 1
0
 public function getNumeroCampos()
 {
     $num = dbase_numfields($this->conexao);
     if ($num != false) {
         return $num;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
function import_dbf($db, $table, $dbf_file)
{
    global $conn;
    if (!($dbf = dbase_open($dbf_file, 0))) {
        die("Could not open {$dbf_file} for import.");
    }
    $num_rec = dbase_numrecords($dbf);
    $num_fields = dbase_numfields($dbf);
    $fields = array();
    for ($i = 1; $i <= $num_rec; $i++) {
        $row = @dbase_get_record_with_names($dbf, $i);
        $q = "insert into {$db}.{$table} values (";
        foreach ($row as $key => $val) {
            if ($key == 'deleted') {
                continue;
            }
            $q .= "'" . addslashes(trim($val)) . "',";
            // Code modified to trim out whitespaces
        }
        if (isset($extra_col_val)) {
            $q .= "'{$extra_col_val}',";
        }
        $q = substr($q, 0, -1);
        $q .= ')';
        //if the query failed - go ahead and print a bunch of debug info
        if (!($result = mysql_query($q, $conn))) {
            print mysql_error() . " SQL: {$q}\n\n";
            print substr_count($q, ',') + 1 . " Fields total.\n\n";
            $problem_q = explode(',', $q);
            $q1 = "desc {$db}.{$table}";
            $result1 = mysql_query($q1, $conn);
            $columns = array();
            $i = 1;
            while ($row1 = mysql_fetch_assoc($result1)) {
                $columns[$i] = $row1['Field'];
                $i++;
            }
            $i = 1;
            foreach ($problem_q as $pq) {
                print "{$i} column: {$columns[$i]} data: {$pq}\n\n";
                $i++;
            }
            die;
        }
    }
}
Exemplo n.º 3
0
 function subedbff($file = 'TRABAJAD.DBF')
 {
     //nota:hay que modificar el upload_max_file_size=100M del php.ini
     //nota:cambiar el tamanano de pres.nacinal a 15 caracteres
     //nota:cambiar tamano de carg.descrip a tamano de 100
     set_time_limit(3600);
     $this->load->dbforge();
     $this->load->dbutil();
     $filea = explode('.', $file);
     $name = $filea[0];
     $ext = $filea[1];
     $uploadsdir = getcwd() . '/uploads/';
     $filedir = $uploadsdir . $file;
     $tabla = strtoupper($ext . $name);
     if (extension_loaded('dbase')) {
         $db = dbase_open($filedir, 0);
         $this->dbforge->drop_table($tabla);
         if ($db) {
             $cols = dbase_numfields($db);
             $rows = dbase_numrecords($db);
             $row = dbase_get_record_with_names($db, 10);
             foreach ($row as $key => $value) {
                 $fields[trim($key)] = array('type' => 'TEXT');
             }
             //print_r($fields);
             //exit();
             $this->dbforge->add_field($fields);
             $this->dbforge->create_table($tabla);
             $insert = array();
             for ($i = 0; $i <= $rows; $i++) {
                 $r = dbase_get_record_with_names($db, $i);
                 foreach ($row as $key => $value) {
                     $a = utf8_encode(trim($r[trim($key)]));
                     $insert[trim($key)] = $a;
                 }
                 $this->db->insert($tabla, $insert);
             }
             echo $i;
             dbase_close($db);
         } else {
             echo "No pudo abrir el archivo";
         }
     } else {
         echo 'Debe cargar las librerias dbase para poder usar este modulo';
     }
 }
Exemplo n.º 4
0
 public function load_dbf($filename, $mode = 0)
 {
     if (!file_exists($filename)) {
         return cy_dt(CYE_ERROR, 'Not a valid DBF file!');
     }
     $tail = substr($filename, -4);
     if (strcasecmp($tail, '.dbf') != 0) {
         return cy_dt(CYE_ERROR, 'Not a valid DBF file!');
     }
     try {
         $this->_handler = dbase_open($filename, $mode);
     } catch (Exception $e) {
         echo $e->getMessage();
         return cy_dt(CYE_ERROR, 'open DBF file failed!');
     }
     $this->field_num = dbase_numfields($this->_handler);
     $this->rec_num = dbase_numrecords($this->_handler);
     $this->field_names = dbase_get_header_info($this->_handler);
     return cy_dt(0);
 }
Exemplo n.º 5
0
 /**
  * Gets the number of columns in a result set
  *
  * This method is not meant to be called directly.  Use
  * DB_result::numCols() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * @param resource $result  PHP's query result resource
  *
  * @return int  the number of columns.  A DB_Error object on failure.
  *
  * @see DB_result::numCols()
  */
 function numCols($foo)
 {
     return @dbase_numfields($this->connection);
 }
Exemplo n.º 6
0
<?php

$db = false;
if (!empty($argc)) {
    $file = end($argv);
    $db = dbase_open($file, 0);
}
if ($db) {
    $iconvFrom = '866';
    $iconvTo = 'UTF-8';
    $delimetr = ',';
    $info = dbase_get_header_info($db);
    $fields = dbase_numfields($db);
    $fieldsCount = sizeof($fields);
    $records = dbase_numrecords($db);
    //for ($i = 1; $i <= 10; $i++) { # test
    for ($i = 1; $i <= $records; $i++) {
        $row = dbase_get_record($db, $i);
        $line = array();
        for ($j = 0; $j < $fields; $j++) {
            $line[] = addslashes(iconv($iconvFrom, $iconvTo, trim($row[$j])));
        }
        echo implode($delimetr, $line);
        echo PHP_EOL;
    }
    dbase_close($db);
}
Exemplo n.º 7
0
 $tab_date = array();
 // on constitue le tableau des champs à extraire
 $tabchamps = array("ABSTYPE", "ELENOET", "ABSDATD", "ABSDATF", "ABSSEQD", "ABSSEQF", "ABSHEUR", "ABSJUST", "ABSMOTI", "ABSACTI");
 //ABSTYPE : Absence ou Retard ou Infirmerie
 //ELENOET : numéro de l'élève
 //ABSDATD : date de début de l'absence
 //ABSDATF : date de fin de l'absence
 //ABSSEQD : numéro de la séquence de début de l'absence
 //ABSSEQF : numéro de la séquence de fin de l'absence
 //ABSHEUR : heure de rentrée dans la cas d'un retard
 //ABSJUST : justification (Oui ou Non)
 //ABSMOTI : Motif
 //ABSACTI : ???? prend les valeurs suivantes AT, LE, CO, ... ?
 $nblignes = dbase_numrecords($fp);
 //number of rows
 $nbchamps = dbase_numfields($fp);
 //number of fields
 if (@dbase_get_record_with_names($fp, 1)) {
     $temp = @dbase_get_record_with_names($fp, 1);
 } else {
     echo "<p>Le fichier sélectionné n'est pas valide !<br />\n";
     echo "<a href='import_absences_gep.php?id_classe={$id_classe}&amp;periode_num={$periode_num}&amp;step=3'>Cliquer ici </a> pour recommencer !</center></p>\n";
     die;
 }
 $nb = 0;
 foreach ($temp as $key => $val) {
     $en_tete[$nb] = $key;
     $nb++;
 }
 // On range dans tabindice les indices des champs retenus
 for ($k = 0; $k < count($tabchamps); $k++) {
Exemplo n.º 8
0
$xi = xbase_open("test/xbase.dbf", 2);
echo "dbase<br>";
echo "index = {$di} <br>";
echo "<br>";
echo "xbase<br>";
echo "index = {$xi} <br>";
echo "header info: ";
print_r(xbase_get_header_info($xi));
dbase_close($di);
xbase_close($xi);
echo "<br><br>";
$di = dbase_open("test/xbase.dbf", 0);
$xi = xbase_open("test/dbase.dbf", 0);
echo "dbase<br>";
echo "index = {$di} <br>";
echo "column count = " . dbase_numfields($di) . " <br>";
echo "record count = " . dbase_numrecords($di) . " <br>";
echo "<table>";
for ($i = 0; $i < dbase_numrecords($di); $i++) {
    echo "<tr>";
    $r = dbase_get_record_with_names($di, $i + 1);
    foreach ($r as $c => $v) {
        echo "<td> {$c}={$v} </td>";
    }
    echo "</tr>";
}
echo "</table>";
echo "<br>";
echo "xbase<br>";
echo "index = {$xi} <br>";
echo "column count = " . xbase_numfields($xi) . " <br>";
Exemplo n.º 9
0
 function subedbf($file = 'DATONO02.DBF', $insertar = true)
 {
     set_time_limit(3600);
     $this->load->dbforge();
     $this->load->dbutil();
     $filea = explode('.', $file);
     $name = $filea[0];
     $ext = $filea[1];
     $uploadsdir = getcwd() . '/uploads/';
     $filedir = $uploadsdir . $file;
     $tabla = strtoupper($ext . $name);
     if (extension_loaded('dbase')) {
         $db = @dbase_open($filedir, 0);
         $this->dbforge->drop_table($tabla);
         if ($db) {
             $cols = @dbase_numfields($db);
             $rows = @dbase_numrecords($db);
             $row = @dbase_get_record_with_names($db, 10);
             print_r($row);
             count($row);
             if (is_array($row) > 0) {
                 foreach ($row as $key => $value) {
                     $fields[trim($key)] = array('type' => 'TEXT');
                 }
                 //print_r($fields);
                 //exit();
                 @$this->dbforge->add_field($fields);
                 @$this->dbforge->create_table($tabla);
                 if ($insertar) {
                     $insert = array();
                     for ($i = 0; $i <= $rows; $i++) {
                         $r = @dbase_get_record_with_names($db, $i);
                         foreach ($row as $key => $value) {
                             $a = @utf8_encode(trim($r[trim($key)]));
                             $insert[trim($key)] = $a;
                         }
                         @$this->db->insert($tabla, $insert);
                         echo 1;
                     }
                 }
                 @dbase_close($db);
             }
         } else {
             echo "No pudo abrir el archivo";
         }
     } else {
         echo 'Debe cargar las librerias dbase para poder usar este modulo';
     }
 }
Exemplo n.º 10
0
 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}");
     }
 }
Exemplo n.º 11
0
 function num_fields($query)
 {
     if ($this->debug) {
         echo "<pre style=\"color : green\">Getting number of fields {$this->dbpath} <p style=\"color:purple;\">  {$query} </p></pre>";
     }
     $nooffields = 0;
     //Validate the sql statement and make adjustments
     switch ($this->dbtype) {
         /* Firebird Functionality */
         case "firebird":
             //write some things here
             $nooffields = ibase_num_fields($query);
             break;
             /* SQLite Functionality */
         /* SQLite Functionality */
         case "sqlite":
             putenv("TMP=" . $this->tmppath);
             $nooffields = sqlite_num_fields($query);
             break;
             /*DBASE functionality */
         /*DBASE functionality */
         case "dbase":
             $nooffields = dbase_numfields($this->dbh);
             break;
             /* MYSQL Functionality */
         /* MYSQL Functionality */
         case "mysql":
             $nooffields = mysql_num_fields($query);
             break;
             /* Oracle Functionality */
         /* Oracle Functionality */
         case "oracle":
             $nooffields = oci_num_fields($query);
             break;
             /* PGSQL Functionality */
         /* PGSQL Functionality */
         case "pgsql":
             $nooffields = pg_num_fields($query);
             break;
     }
     if ($this->debug) {
         echo "<pre style=\"color : blue\">Number of fields {$nooffields} \n </pre>";
     }
     return $nooffields;
 }
Exemplo n.º 12
0
    echo 'row before inserting is: ';
    print_r($row);
    // Replace the record
    dbase_replace_record($db, $row, 1);
    echo 'trying record num 1: ';
    $rec = dbase_get_record($db, 1);
    $nf = dbase_numfields($db);
    for ($i = 0; $i < $nf; $i++) {
        echo $rec[$i], "\n";
    }
    echo 'deleting row 2. before deletion: ';
    $rec = dbase_get_record($db, 2);
    $nf = dbase_numfields($db);
    for ($i = 0; $i < $nf; $i++) {
        echo $rec[$i], "\n";
    }
    echo dbase_delete_record($db, 2);
    echo 'before db pack';
    echo dbase_pack($db);
    echo 'after pack, trying to fetch record 2';
    $rec = dbase_get_record($db, 2);
    $nf = dbase_numfields($db);
    for ($i = 0; $i < $nf; $i++) {
        echo $rec[$i], "\n";
    }
    dbase_close($db);
}
?>